summaryrefslogtreecommitdiff
path: root/lib/ethdev
diff options
context:
space:
mode:
authorLong Wu <[email protected]>2024-02-26 09:44:57 +0800
committerFerruh Yigit <[email protected]>2024-02-26 11:53:58 +0100
commitc99e1db87798c2cd2c0ac94c7676e961eedffc87 (patch)
tree533838378f3b9b260577c8c5bf12d180d4d2f6b7 /lib/ethdev
parent0007e4045c9efe6a20ad2590dfa68a86cc778b48 (diff)
ethdev: add function to check representor port
Add a function to check if a device is representor port, also modified the related codes for PMDs. Signed-off-by: Long Wu <[email protected]> Reviewed-by: Chaoyong He <[email protected]> Reviewed-by: Peng Zhang <[email protected]> Reviewed-by: Ferruh Yigit <[email protected]>
Diffstat (limited to 'lib/ethdev')
-rw-r--r--lib/ethdev/ethdev_driver.h17
-rw-r--r--lib/ethdev/rte_class_eth.c4
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 0e4c1f0743..0b088fdab7 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1814,6 +1814,23 @@ rte_eth_representor_id_get(uint16_t port_id,
uint16_t *repr_id);
/**
+ * @internal
+ * Check if the ethdev is a representor port.
+ *
+ * @param dev
+ * Pointer to struct rte_eth_dev.
+ *
+ * @return
+ * false the ethdev is not a representor port.
+ * true the ethdev is a representor port.
+ */
+static inline bool
+rte_eth_dev_is_repr(const struct rte_eth_dev *dev)
+{
+ return ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
+}
+
+/**
* PMD helper function to parse ethdev arguments
*
* @param devargs
diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c
index bc003db8af..b52f1dd9f2 100644
--- a/lib/ethdev/rte_class_eth.c
+++ b/lib/ethdev/rte_class_eth.c
@@ -69,7 +69,7 @@ eth_representor_cmp(const char *key __rte_unused,
struct rte_eth_devargs eth_da;
uint16_t id = 0, nc, np, nf, i, c, p, f;
- if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0)
+ if (!rte_eth_dev_is_repr(edev))
return -1; /* not a representor port */
/* Parse devargs representor values. */
@@ -143,7 +143,7 @@ eth_dev_match(const struct rte_eth_dev *edev,
}
/* if no representor key, default is to not match representor ports */
if (ret != 0)
- if ((edev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0)
+ if (rte_eth_dev_is_repr(edev))
return -1; /* do not match any representor */
return 0;