MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pdump_register_tx_callbacks

Function pdump_register_tx_callbacks

dpdk/lib/pdump/rte_pdump.c:228–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228static int
229pdump_register_tx_callbacks(enum pdump_version ver,
230 uint16_t end_q, uint16_t port, uint16_t queue,
231 struct rte_ring *ring, struct rte_mempool *mp,
232 struct rte_bpf *filter,
233 uint16_t operation, uint32_t snaplen)
234{
235
236 uint16_t qid;
237
238 qid = (queue == RTE_PDUMP_ALL_QUEUES) ? 0 : queue;
239 for (; qid < end_q; qid++) {
240 struct pdump_rxtx_cbs *cbs = &tx_cbs[port][qid];
241
242 if (operation == ENABLE) {
243 if (cbs->cb) {
244 PDUMP_LOG(ERR,
245 "tx callback for port=%d queue=%d, already exists\n",
246 port, qid);
247 return -EEXIST;
248 }
249 cbs->ver = ver;
250 cbs->ring = ring;
251 cbs->mp = mp;
252 cbs->snaplen = snaplen;
253 cbs->filter = filter;
254
255 cbs->cb = rte_eth_add_tx_callback(port, qid, pdump_tx,
256 cbs);
257 if (cbs->cb == NULL) {
258 PDUMP_LOG(ERR,
259 "failed to add tx callback, errno=%d\n",
260 rte_errno);
261 return rte_errno;
262 }
263 memset(&pdump_stats->tx[port][qid], 0, sizeof(struct rte_pdump_stats));
264 } else if (operation == DISABLE) {
265 int ret;
266
267 if (cbs->cb == NULL) {
268 PDUMP_LOG(ERR,
269 "no existing tx callback for port=%d queue=%d\n",
270 port, qid);
271 return -EINVAL;
272 }
273 ret = rte_eth_remove_tx_callback(port, qid, cbs->cb);
274 if (ret < 0) {
275 PDUMP_LOG(ERR,
276 "failed to remove tx callback, errno=%d\n",
277 -ret);
278 return ret;
279 }
280 cbs->cb = NULL;
281 }
282 }
283
284 return 0;
285}

Callers 1

set_pdump_rxtx_cbsFunction · 0.85

Calls 3

rte_eth_add_tx_callbackFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected