* * Retrieve a burst of input packets from a receive queue of an Ethernet * device. The retrieved packets are stored in *rte_mbuf* structures whose * pointers are supplied in the *rx_pkts* array. * * The rte_eth_rx_burst() function loops, parsing the Rx ring of the * receive queue, up to *nb_pkts* packets, and for each completed Rx * descriptor in the ring, it performs the following operati
| 6053 | * *rx_pkts* array. |
| 6054 | */ |
| 6055 | static inline uint16_t |
| 6056 | rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, |
| 6057 | struct rte_mbuf **rx_pkts, const uint16_t nb_pkts) |
| 6058 | { |
| 6059 | uint16_t nb_rx; |
| 6060 | struct rte_eth_fp_ops *p; |
| 6061 | void *qd; |
| 6062 | |
| 6063 | #ifdef RTE_ETHDEV_DEBUG_RX |
| 6064 | if (port_id >= RTE_MAX_ETHPORTS || |
| 6065 | queue_id >= RTE_MAX_QUEUES_PER_PORT) { |
| 6066 | RTE_ETHDEV_LOG(ERR, |
| 6067 | "Invalid port_id=%u or queue_id=%u\n", |
| 6068 | port_id, queue_id); |
| 6069 | return 0; |
| 6070 | } |
| 6071 | #endif |
| 6072 | |
| 6073 | /* fetch pointer to queue data */ |
| 6074 | p = &rte_eth_fp_ops[port_id]; |
| 6075 | qd = p->rxq.data[queue_id]; |
| 6076 | |
| 6077 | #ifdef RTE_ETHDEV_DEBUG_RX |
| 6078 | RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0); |
| 6079 | |
| 6080 | if (qd == NULL) { |
| 6081 | RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u for port_id=%u\n", |
| 6082 | queue_id, port_id); |
| 6083 | return 0; |
| 6084 | } |
| 6085 | #endif |
| 6086 | |
| 6087 | nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts); |
| 6088 | |
| 6089 | #ifdef RTE_ETHDEV_RXTX_CALLBACKS |
| 6090 | { |
| 6091 | void *cb; |
| 6092 | |
| 6093 | /* rte_memory_order_release memory order was used when the |
| 6094 | * call back was inserted into the list. |
| 6095 | * Since there is a clear dependency between loading |
| 6096 | * cb and cb->fn/cb->next, rte_memory_order_acquire memory order is |
| 6097 | * not required. |
| 6098 | */ |
| 6099 | cb = rte_atomic_load_explicit(&p->rxq.clbk[queue_id], |
| 6100 | rte_memory_order_relaxed); |
| 6101 | if (unlikely(cb != NULL)) |
| 6102 | nb_rx = rte_eth_call_rx_callbacks(port_id, queue_id, |
| 6103 | rx_pkts, nb_rx, nb_pkts, cb); |
| 6104 | } |
| 6105 | #endif |
| 6106 | |
| 6107 | rte_ethdev_trace_rx_burst(port_id, queue_id, (void **)rx_pkts, nb_rx); |
| 6108 | return nb_rx; |
| 6109 | } |
| 6110 | |
| 6111 | /** |
| 6112 | * Get the number of used descriptors of a Rx queue |