summaryrefslogtreecommitdiff
path: root/lib/librte_eventdev
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2018-04-05 17:33:20 +0200
committerThomas Monjalon <thomas@monjalon.net>2018-04-18 00:25:27 +0200
commit8728ccf37615904cf23fb8763895b05c9a3c6b0c (patch)
treeb6e895ec425d20d4933115f533da4be189be1f8a /lib/librte_eventdev
parenta3d6026711d00183e308f1dd79933f6161840e04 (diff)
fix ethdev ports enumeration
Some DPDK applications wrongly assume these requirements: - no hotplug, i.e. ports are never detached - all allocated ports are available to the application Such application iterates over ports by its own mean. The most common pattern is to request the port count and assume ports with index in the range [0..count[ can be used. There are three consequences when using such wrong design: - new ports having an index higher than the port count won't be seen - old ports being detached (RTE_ETH_DEV_UNUSED) can be seen as ghosts - failsafe sub-devices (RTE_ETH_DEV_DEFERRED) will be seen by the application Such mistake will be less common with growing hotplug awareness. All applications and examples inside this repository - except testpmd - must be fixed to use the iterator RTE_ETH_FOREACH_DEV. Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Diffstat (limited to 'lib/librte_eventdev')
-rw-r--r--lib/librte_eventdev/rte_event_eth_rx_adapter.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/librte_eventdev/rte_event_eth_rx_adapter.c b/lib/librte_eventdev/rte_event_eth_rx_adapter.c
index 9cda9607b1..bf5b44f177 100644
--- a/lib/librte_eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/librte_eventdev/rte_event_eth_rx_adapter.c
@@ -213,7 +213,7 @@ eth_poll_wrr_calc(struct rte_event_eth_rx_adapter *rx_adapter)
/* Generate array of all queues to poll, the size of this
* array is poll_q
*/
- for (d = 0; d < rte_eth_dev_count(); d++) {
+ RTE_ETH_FOREACH_DEV(d) {
uint16_t nb_rx_queues;
struct eth_device_info *dev_info =
&rx_adapter->eth_devices[d];
@@ -823,7 +823,7 @@ rx_adapter_ctrl(uint8_t id, int start)
dev = &rte_eventdevs[rx_adapter->eventdev_id];
- for (i = 0; i < rte_eth_dev_count(); i++) {
+ RTE_ETH_FOREACH_DEV(i) {
dev_info = &rx_adapter->eth_devices[i];
/* if start check for num dev queues */
if (start && !dev_info->nb_dev_queues)
@@ -913,7 +913,7 @@ rte_event_eth_rx_adapter_create_ext(uint8_t id, uint8_t dev_id,
return -ENOMEM;
}
rte_spinlock_init(&rx_adapter->rx_lock);
- for (i = 0; i < rte_eth_dev_count(); i++)
+ RTE_ETH_FOREACH_DEV(i)
rx_adapter->eth_devices[i].dev = &rte_eth_devices[i];
event_eth_rx_adapter[id] = rx_adapter;
@@ -1184,7 +1184,7 @@ rte_event_eth_rx_adapter_stats_get(uint8_t id,
dev = &rte_eventdevs[rx_adapter->eventdev_id];
memset(stats, 0, sizeof(*stats));
- for (i = 0; i < rte_eth_dev_count(); i++) {
+ RTE_ETH_FOREACH_DEV(i) {
dev_info = &rx_adapter->eth_devices[i];
if (dev_info->internal_event_port == 0 ||
dev->dev_ops->eth_rx_adapter_stats_get == NULL)
@@ -1221,7 +1221,7 @@ rte_event_eth_rx_adapter_stats_reset(uint8_t id)
return -EINVAL;
dev = &rte_eventdevs[rx_adapter->eventdev_id];
- for (i = 0; i < rte_eth_dev_count(); i++) {
+ RTE_ETH_FOREACH_DEV(i) {
dev_info = &rx_adapter->eth_devices[i];
if (dev_info->internal_event_port == 0 ||
dev->dev_ops->eth_rx_adapter_stats_reset == NULL)