[PATCH v2 1/2] lib/ethdev: add reverse macro to quit testpmd
    wenxuanx.wu at intel.com 
    wenxuanx.wu at intel.com
       
    Wed Feb 23 12:32:50 CET 2022
    
    
  
From: wenxuan wu <wenxuanx.wu at intel.com>
There is a heap-free-after-use bug when quit testpmd
with pf and vfs, stop and close ports in reverse order
is a more reasonable approach.
Cc: stable at dpdk.org
Signed-off-by: wenxuan wu <wenxuanx.wu at intel.com>
---
 lib/ethdev/rte_ethdev.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 2660e4f374..813f72e825 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -2185,7 +2185,8 @@ struct rte_eth_dev_owner {
  * @return
  *   Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
  */
-uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
+uint64_t
+rte_eth_find_next_owned_by(uint16_t port_id,
 		const uint64_t owner_id);
 
 /**
@@ -2212,6 +2213,14 @@ uint16_t rte_eth_find_next(uint16_t port_id);
 #define RTE_ETH_FOREACH_DEV(p) \
 	RTE_ETH_FOREACH_DEV_OWNED_BY(p, RTE_ETH_DEV_NO_OWNER)
 
+/**
+ * Macro to iterate over all enabled and ownerless ethdev ports in reverse order.
+ */
+#define RTE_ETH_FOREACH_DEV_REVERSE(p) \
+	for (p = rte_eth_dev_count_total() - 1; \
+	     p < rte_eth_dev_count_total(); \
+	     p--)
+
 /**
  * Iterates over ethdev ports of a specified device.
  *
-- 
2.25.1
    
    
More information about the dev
mailing list