CNDP  22.08.0
txbuff.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2019-2022 Intel Corporation.
3  */
4 
5 #ifndef __TXBUFF_H
6 #define __TXBUFF_H
7 
18 #include <stdint.h> // for uint16_t, uint32_t
19 #include <cne_common.h> // for CNDP_API, CNE_STD_C11
20 #include <pktmbuf.h> // for pktmbuf_t
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 struct txbuff;
27 
38 typedef void (*txbuff_error_fn)(struct txbuff *buffer, uint16_t unsent, uint16_t sent);
39 
44 typedef struct txbuff {
46  union {
47  void *info;
48  uint16_t lport_id;
49  };
51  void *userdata;
52  uint32_t txtype;
53  uint16_t size;
54  uint16_t length;
57 
61 enum { TXBUFF_PKTDEV_FLAG = 0, TXBUFF_XSKDEV_FLAG = 1 };
62 
69 #define TXBUFF_SIZE(sz) (sizeof(txbuff_t) + (sz) * sizeof(pktmbuf_t *))
70 
85 CNDP_API txbuff_t *txbuff_pktdev_create(uint16_t size, txbuff_error_fn cbfn, void *cb_arg,
86  uint16_t lport_id);
87 
102 CNDP_API txbuff_t *txbuff_xskdev_create(uint16_t size, txbuff_error_fn cbfn, void *cb_arg,
103  void *xinfo);
104 
111 CNDP_API void txbuff_free(txbuff_t *buffer);
112 
135 CNDP_API int txbuff_set_err_callback(txbuff_t *buffer, txbuff_error_fn callback, void *userdata);
136 
155 CNDP_API void txbuff_drop_callback(txbuff_t *buffer, uint16_t sent, uint16_t unsent);
156 
180 CNDP_API void txbuff_count_callback(txbuff_t *buffer, uint16_t sent, uint16_t unsent);
181 
197 CNDP_API uint16_t txbuff_flush(txbuff_t *buffer);
198 
223 CNDP_API uint16_t txbuff_add(txbuff_t *buffer, pktmbuf_t *tx_pkt);
224 
233 static inline int
235 {
236  return (!buffer) ? -1 : buffer->length;
237 }
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #endif /* __TXBUFF_H */
#define CNE_STD_C11
Definition: cne_common.h:91
Definition: txbuff.h:44
txbuff_error_fn error_cb
Definition: txbuff.h:50
uint16_t length
Definition: txbuff.h:54
uint32_t txtype
Definition: txbuff.h:52
pktmbuf_t * pkts[]
Definition: txbuff.h:55
uint16_t size
Definition: txbuff.h:53
void * info
Definition: txbuff.h:47
uint16_t lport_id
Definition: txbuff.h:48
void * userdata
Definition: txbuff.h:51
CNDP_API txbuff_t * txbuff_pktdev_create(uint16_t size, txbuff_error_fn cbfn, void *cb_arg, uint16_t lport_id)
CNDP_API void txbuff_drop_callback(txbuff_t *buffer, uint16_t sent, uint16_t unsent)
void(* txbuff_error_fn)(struct txbuff *buffer, uint16_t unsent, uint16_t sent)
Definition: txbuff.h:38
CNDP_API uint16_t txbuff_add(txbuff_t *buffer, pktmbuf_t *tx_pkt)
CNDP_API void txbuff_count_callback(txbuff_t *buffer, uint16_t sent, uint16_t unsent)
CNDP_API void txbuff_free(txbuff_t *buffer)
struct txbuff txbuff_t
CNDP_API int txbuff_set_err_callback(txbuff_t *buffer, txbuff_error_fn callback, void *userdata)
static int txbuff_count(txbuff_t *buffer)
Definition: txbuff.h:234
CNDP_API txbuff_t * txbuff_xskdev_create(uint16_t size, txbuff_error_fn cbfn, void *cb_arg, void *xinfo)
CNDP_API uint16_t txbuff_flush(txbuff_t *buffer)