|
CNDP_API txbuff_t * | txbuff_pktdev_create (uint16_t size, txbuff_error_fn cbfn, void *cb_arg, uint16_t lport_id) |
|
CNDP_API txbuff_t * | txbuff_xskdev_create (uint16_t size, txbuff_error_fn cbfn, void *cb_arg, void *xinfo) |
|
CNDP_API void | txbuff_free (txbuff_t *buffer) |
|
CNDP_API int | txbuff_set_err_callback (txbuff_t *buffer, txbuff_error_fn callback, void *userdata) |
|
CNDP_API void | txbuff_drop_callback (txbuff_t *buffer, uint16_t sent, uint16_t unsent) |
|
CNDP_API void | txbuff_count_callback (txbuff_t *buffer, uint16_t sent, uint16_t unsent) |
|
CNDP_API uint16_t | txbuff_flush (txbuff_t *buffer) |
|
CNDP_API uint16_t | txbuff_add (txbuff_t *buffer, pktmbuf_t *tx_pkt) |
|
static int | txbuff_count (txbuff_t *buffer) |
|
Routines and structures to allow an application to send single mbufs or packets while enqueuing the packets to an array and flush the packets to the output port when the number of packets fills the array.
Using this method allows for buffered packet to be sent in bulk and not one at a time.
Definition in file txbuff.h.
Configure a callback for buffered packets which cannot be sent
Register a specific callback to be called when an attempt is made to send all packets buffered on an ethernet lport, but not all packets can successfully be sent. The callback registered here will be called only from calls to txbuff_add() and txbuff_flush() APIs. The callback configured by default just frees the packets back to the original mempool. If additional behaviour is required, for example, to count dropped packets, or to retry transmission of packets which cannot be sent, this function should be used to register a suitable callback function to implement the desired behaviour.
- Parameters
-
buffer | Pointer to the txbuff structure |
callback | The function to be used as the callback |
userdata | Arbitrary parameter to be passed to the callback function |
- Returns
- 0 on success, or -1 on error
CNDP_API void txbuff_count_callback |
( |
txbuff_t * |
buffer, |
|
|
uint16_t |
sent, |
|
|
uint16_t |
unsent |
|
) |
| |
Callback function for counting unsent buffered packets.
This function can be passed to txbuff_set_err_callback() to adjust the default behavior when buffered packets cannot be sent. This function drops any unsent packets, but also updates a user-supplied counter to track the overall number of packets dropped. The counter should be an uint64_t variable.
NOTE: this function should not be called directly, instead it should be used as a callback for packet buffering.
NOTE: when configuring this function as a callback with txbuff_set_err_callback(), the final userdata parameter should point to an uint64_t value.
- Parameters
-
buffer | Pointer to the txbuff structure |
sent | The number of sent packets in the pkts array |
unsent | The number of unsent packets in the pkts array |
- Examples
- examples/cndpfwd/main.c.
Buffer a single packet for future transmission on a lport
This function takes a single mbuf/packet and buffers it for later transmission on the particular lport specified. Once the buffer is full of packets, an attempt will be made to transmit all the buffered packets. In case of error, where not all packets can be transmitted, a callback is called with the unsent packets as a parameter. If no callback is explicitly set up, the unsent packets are just freed back to the owning mempool. The function returns the number of packets actually sent i.e. 0 if no buffer flush occurred, otherwise the number of packets successfully flushed
- Parameters
-
buffer | Buffer used to collect packets to be sent. |
tx_pkt | Pointer to the packet mbuf to be sent. |
- Returns
- 0 = packet has been buffered for later transmission or packets were flushed, but none were transmitted N > 0 = packet has been buffered, and the buffer was subsequently flushed, causing N packets to be sent, and the error callback to be called for the rest.
- Examples
- examples/cndpfwd/acl-func.c, examples/cndpfwd/main.c, and examples/dlb_test/dlb_test.c.