[ovs-dev] [PATCH 12/15] netdev-dpdk: Introduce an API to query if a dpdk port is an uplink port

Eli Britstein elibr at nvidia.com
Wed Jan 27 18:10:33 UTC 2021


When a vport is offloaded it has no explicit matching physical port so
rte_flows are created on each of the uplink ports. Add an API to query
if a DPDK port is an uplink port, as a pre-step towards applying vport
flows on the uplink ports.

Signed-off-by: Eli Britstein <elibr at nvidia.com>
Reviewed-by: Gaetan Rivet <gaetanr at nvidia.com>
---
 lib/netdev-dpdk.c | 17 +++++++++++++++++
 lib/netdev-dpdk.h |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index ca1667f21..2caca25eb 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -443,6 +443,7 @@ struct netdev_dpdk {
         };
         struct dpdk_tx_queue *tx_q;
         struct rte_eth_link link;
+        bool is_uplink_port; /* True=uplink port, false=representor port. */
     );
 
     PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline1,
@@ -1143,6 +1144,9 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev)
         }
     }
 
+    dev->is_uplink_port = !(*info.dev_flags & RTE_ETH_DEV_REPRESENTOR) &&
+        info.switch_info.domain_id != RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;
+
     n_rxq = MIN(info.max_rx_queues, dev->up.n_rxq);
     n_txq = MIN(info.max_tx_queues, dev->up.n_txq);
 
@@ -5220,6 +5224,19 @@ out:
     return ret;
 }
 
+bool
+netdev_dpdk_port_is_uplink(struct netdev *netdev)
+{
+    struct netdev_dpdk *dev;
+
+    if (!is_dpdk_class(netdev->netdev_class)) {
+        return false;
+    }
+
+    dev = netdev_dpdk_cast(netdev);
+    return dev->is_uplink_port;
+}
+
 bool
 netdev_dpdk_flow_api_supported(struct netdev *netdev)
 {
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
index 0bbbd6927..a03fd3053 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -50,6 +50,8 @@ netdev_dpdk_rte_flow_query_count(struct netdev *netdev,
                                  struct rte_flow_error *error);
 int
 netdev_dpdk_get_port_id(struct netdev *netdev);
+bool
+netdev_dpdk_port_is_uplink(struct netdev *netdev);
 
 #ifdef ALLOW_EXPERIMENTAL_API
 
-- 
2.28.0.546.g385c171



More information about the dev mailing list