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

Function rte_eth_add_rx_callback

dpdk/lib/ethdev/rte_ethdev.c:5721–5778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5719
5720
5721const struct rte_eth_rxtx_callback *
5722rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
5723 rte_rx_callback_fn fn, void *user_param)
5724{
5725#ifndef RTE_ETHDEV_RXTX_CALLBACKS
5726 rte_errno = ENOTSUP;
5727 return NULL;
5728#endif
5729 struct rte_eth_dev *dev;
5730
5731 /* check input parameters */
5732 if (!rte_eth_dev_is_valid_port(port_id) || fn == NULL ||
5733 queue_id >= rte_eth_devices[port_id].data->nb_rx_queues) {
5734 rte_errno = EINVAL;
5735 return NULL;
5736 }
5737 dev = &rte_eth_devices[port_id];
5738 if (rte_eth_dev_is_rx_hairpin_queue(dev, queue_id)) {
5739 rte_errno = EINVAL;
5740 return NULL;
5741 }
5742 struct rte_eth_rxtx_callback *cb = rte_zmalloc(NULL, sizeof(*cb), 0);
5743
5744 if (cb == NULL) {
5745 rte_errno = ENOMEM;
5746 return NULL;
5747 }
5748
5749 cb->fn.rx = fn;
5750 cb->param = user_param;
5751
5752 rte_spinlock_lock(&eth_dev_rx_cb_lock);
5753 /* Add the callbacks in fifo order. */
5754 struct rte_eth_rxtx_callback *tail =
5755 rte_eth_devices[port_id].post_rx_burst_cbs[queue_id];
5756
5757 if (!tail) {
5758 /* Stores to cb->fn and cb->param should complete before
5759 * cb is visible to data plane.
5760 */
5761 rte_atomic_store_explicit(
5762 &rte_eth_devices[port_id].post_rx_burst_cbs[queue_id],
5763 cb, rte_memory_order_release);
5764
5765 } else {
5766 while (tail->next)
5767 tail = tail->next;
5768 /* Stores to cb->fn and cb->param should complete before
5769 * cb is visible to data plane.
5770 */
5771 rte_atomic_store_explicit(&tail->next, cb, rte_memory_order_release);
5772 }
5773 rte_spinlock_unlock(&eth_dev_rx_cb_lock);
5774
5775 rte_eth_trace_add_rx_callback(port_id, queue_id, fn, user_param, cb);
5776
5777 return cb;
5778}

Callers 11

vtune_profile_rx_initFunction · 0.85
bpf_eth_elf_loadFunction · 0.85
ethdev_ptype_setupFunction · 0.85
add_rx_dump_callbacksFunction · 0.85
prepare_ptype_parserFunction · 0.85
port_initFunction · 0.85
reassemble_lcore_initFunction · 0.85
port_initFunction · 0.85
add_cb_parse_ptypeFunction · 0.85
mainFunction · 0.85

Calls 5

rte_zmallocFunction · 0.85
rte_spinlock_lockFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by

no test coverage detected