3. API

The full API documentation extracted by doxygen can be found here.

3.1. TAS Low-Level Application API

int flextcp_init(void)

Initializes global flextcp state, must only be called once.

Return

0 on success, < 0 on failure

3.1.1. Contexts

struct flextcp_context

A flextcp context is per-thread state for the stack. (opaque) This includes:

  • admin queue pair to kernel

  • notification queue pair to flexnic

int flextcp_context_create(struct flextcp_context *ctx)

Create a flextcp context.

int flextcp_context_poll(struct flextcp_context *ctx, int num, struct flextcp_event *events)

Poll events from a flextcp socket.

Warning

doxygenfunction: Cannot find function “flextcp_block” in doxygen xml output for project “TAS” from directory: xml/

3.1.2. Connections

struct flextcp_connection

TCP connection. (opaque)

int flextcp_connection_open(struct flextcp_context *ctx, struct flextcp_connection *conn, uint32_t dst_ip, uint16_t dst_port)

Open a connection (asynchronous).

int flextcp_connection_close(struct flextcp_context *ctx, struct flextcp_connection *conn)

Close a connection (asynchronous).

int flextcp_connection_rx_done(struct flextcp_context *ctx, struct flextcp_connection *conn, size_t len)

Receive processing for `len’ bytes done.

ssize_t flextcp_connection_tx_alloc(struct flextcp_connection *conn, size_t len, void **buf)

Allocate transmit buffer for `len’ bytes, returns number of bytes allocated.

NOTE: short allocs can occur if buffer wraps around

ssize_t flextcp_connection_tx_alloc2(struct flextcp_connection *conn, size_t len, void **buf_1, size_t *len_1, void **buf_2)

Allocate transmit buffer for `len’ bytes, returns number of bytes allocated. May be split across two buffers, in case of wrap around.

int flextcp_connection_tx_send(struct flextcp_context *ctx, struct flextcp_connection *conn, size_t len)

Send previously allocated bytes in transmit buffer

int flextcp_connection_tx_close(struct flextcp_context *ctx, struct flextcp_connection *conn)

Send previously allocated bytes in transmit buffer

int flextcp_connection_tx_possible(struct flextcp_context *ctx, struct flextcp_connection *conn)

Make sure there is room in the context send queue (not send buffer)

Returns 0 if transmit is possible, -1 otherwise.

int flextcp_connection_move(struct flextcp_context *ctx, struct flextcp_connection *conn)

Move connection to specfied context

3.1.3. Listeners

struct flextcp_listener

TCP listening “socket”. (opaque)

FLEXTCP_LISTEN_REUSEPORT
int flextcp_listen_open(struct flextcp_context *ctx, struct flextcp_listener *lst, uint16_t port, uint32_t backlog, uint32_t flags)

Open a listening socket (asynchronous).

int flextcp_listen_accept(struct flextcp_context *ctx, struct flextcp_listener *lst, struct flextcp_connection *conn)

Accept connections on a listening socket (asynchronous). This can be called more than once to register multiple connection handles.

3.1.4. Events

enum flextcp_event_type

Types of events that can occur in flextcp contexts

Values:

enumerator FLEXTCP_EV_LISTEN_OPEN

flextcp_listen_open() result.

enumerator FLEXTCP_EV_LISTEN_NEWCONN

New connection on listening socket arrived.

enumerator FLEXTCP_EV_LISTEN_ACCEPT

Accept operation completed

enumerator FLEXTCP_EV_CONN_OPEN

flextcp_connection_open() result

enumerator FLEXTCP_EV_CONN_CLOSED

Connection was closed

enumerator FLEXTCP_EV_CONN_RECEIVED

Data arrived on connection

enumerator FLEXTCP_EV_CONN_SENDBUF

More send buffer available

enumerator FLEXTCP_EV_CONN_RXCLOSED

Receive stream closed

enumerator FLEXTCP_EV_CONN_TXCLOSED

transmit stream closed

enumerator FLEXTCP_EV_CONN_MOVED

Connection moved to new context

struct flextcp_event

Events that can occur on flextcp contexts.

Public Members

struct flextcp_event::[anonymous]::[anonymous] listen_open

For FLEXTCP_EV_LISTEN_OPEN

struct flextcp_event::[anonymous]::[anonymous] listen_newconn

For FLEXTCP_EV_LISTEN_NEWCONN

struct flextcp_event::[anonymous]::[anonymous] listen_accept

For FLEXTCP_EV_LISTEN_ACCEPT

struct flextcp_event::[anonymous]::[anonymous] conn_open

For FLEXTCP_EV_CONN_OPEN

struct flextcp_event::[anonymous]::[anonymous] conn_received

For FLEXTCP_EV_CONN_RECEIVED

struct flextcp_event::[anonymous]::[anonymous] conn_sendbuf

For FLEXTCP_EV_CONN_SENDBUF

struct flextcp_event::[anonymous]::[anonymous] conn_rxclosed

For FLEXTCP_EV_CONN_RXCLOSED

struct flextcp_event::[anonymous]::[anonymous] conn_txclosed

For FLEXTCP_EV_CONN_TXCLOSED

struct flextcp_event::[anonymous]::[anonymous] conn_moved

For FLEXTCP_EV_CONN_MOVED

struct flextcp_event::[anonymous]::[anonymous] conn_closed

For FLEXTCP_EV_CONN_CLOSED

3.2. TAS Sockets API