On 1/8/2024 3:20 PM, Konstantin Ananyev wrote: > > rx callbacks when zero packets >> >> I noticed while looking at packet capture that currently the receive >> callbacks >> get called even if there are no packets. This seems unnecessary since if >> nb_rx is zero, then there are no packets to look at. My one concern is that >> an application could be using callbacks as some form of scheduling mechanism >> which would be broken. > > As I remember, original idea was to allow callbacks to inject new packets if > needed. >
Right, callback function updating 'nb_rx' enables this. Also Honnappa has a good point that callback can be used to calculate zero packet polls. These points are not documented and not obvious from the code, @Stephen does it make sense to document that callback function called with zero packet intentionally, in the 'rte_eth_rx_burst()' function comment? >> >> The change would be: >> >> >> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h >> index 21e3a21903ec..f64bf977c46e 100644 >> --- a/lib/ethdev/rte_ethdev.h >> +++ b/lib/ethdev/rte_ethdev.h >> @@ -6077,7 +6077,7 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, >> nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts); >> >> #ifdef RTE_ETHDEV_RXTX_CALLBACKS >> - { >> + if (nb_rx > 0) { >> void *cb; >> >> /* rte_memory_order_release memory order was used when the