TAS
TCP Acceleration as an OS Service
Macros | Functions | Variables
appif.c File Reference

Application-Kernel interface. More...

#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <tas.h>
#include "internal.h"
#include "appif.h"
#include <kernel_appif.h>
#include <utils_nbqueue.h>
#include <tas_memif.h>
#include <fastpath.h>
Include dependency graph for appif.c:

Go to the source code of this file.

Macros

#define EP_LISTEN   (NULL)
 
#define EP_NOTIFY   ((void *) (-1))
 

Functions

static int uxsocket_init (void)
 
static void * uxsocket_thread (void *arg)
 
static void uxsocket_accept (void)
 
static void uxsocket_notify (void)
 
static void uxsocket_error (struct application *app)
 
static void uxsocket_receive (struct application *app)
 
static void uxsocket_notify_app (struct application *app)
 
int appif_init (void)
 
unsigned appif_poll (void)
 

Variables

static int uxfd = -1
 
static int epfd = -1
 
static int notifyfd = -1
 
static struct nbqueue poll_to_ux
 
static struct nbqueue ux_to_poll
 
static pthread_t pt_ux
 
static struct app_doorbellfree_doorbells = NULL
 
static uint16_t app_id_next = 0
 
static struct applicationapplications = NULL
 

Detailed Description

Application-Kernel interface.

The application-kernel interface consists of two parts: per-application unix socket for setup, and per-core application context queues for normal operation. The message format for both those is defined in kernel_appif.h.

During application initialization the application opens a Unix stream socket to the kernel. This stream socket is then used to negotiate creation of one or more application context queues in the shared packet memory region.

Communication on the application context queues is handled in appif_ctx.c.

The unix socket is handled on a separate thread so a blocking epoll can be used. To avoid synchronization in other kernel parts the ux socket thread just communicates on the sockets and uses two queues ux_to_poll and poll_to_ux to communicate with the main thread. The main thread then calls into other modules to register the context with flexnic etc.

Definition in file appif.c.

Macro Definition Documentation

◆ EP_LISTEN

#define EP_LISTEN   (NULL)

epoll data for listening socket

Definition at line 65 of file appif.c.

◆ EP_NOTIFY

#define EP_NOTIFY   ((void *) (-1))

epoll data for notifyfd associated with poll_to_ux queue

Definition at line 67 of file appif.c.

Variable Documentation

◆ app_id_next

uint16_t app_id_next = 0
static

Next unused application id, used for allocation

Definition at line 94 of file appif.c.

◆ applications

struct application* applications = NULL
static

Linked list of all application structs

Definition at line 97 of file appif.c.

Referenced by appif_poll().

◆ epfd

int epfd = -1
static

Epoll object used by UX socket thread

Definition at line 80 of file appif.c.

◆ free_doorbells

struct app_doorbell* free_doorbells = NULL
static

Freelist for NIC doorbells to be allocated to applications.

Definition at line 92 of file appif.c.

◆ notifyfd

int notifyfd = -1
static

eventfd for notifying UX thread about completion on poll_to_ux

Definition at line 82 of file appif.c.

◆ poll_to_ux

struct nbqueue poll_to_ux
static

Completions of asynchronous NIC operations for UX socket thread

Definition at line 84 of file appif.c.

◆ pt_ux

pthread_t pt_ux
static

Pthread handle for UX socket thread

Definition at line 89 of file appif.c.

◆ ux_to_poll

struct nbqueue ux_to_poll
static

Queue to pass structs for new applications from UX to poll thread

Definition at line 86 of file appif.c.

Referenced by appif_poll().

◆ uxfd

int uxfd = -1
static

Listening UX socket for applications to connect to

Definition at line 78 of file appif.c.