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

Eli Britstein elibr at mellanox.com
Mon Jan 20 15:08:24 UTC 2020


From: Ophir Munk <ophirmu at mellanox.com>

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.

Co-authored-by: Eli Britstein <elibr at mellanox.com>
Signed-off-by: Ophir Munk <ophirmu at mellanox.com>
Reviewed-by: Roni Bar Yanai <roniba at mellanox.com>
Signed-off-by: Eli Britstein <elibr at mellanox.com>
---
 lib/netdev-dpdk.c | 21 +++++++++++++++++++++
 lib/netdev-dpdk.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index b108cbd6b..52a3bc153 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -460,6 +460,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,
@@ -1139,6 +1140,8 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev)
         VLOG_WARN("Tx TSO offload is not supported on %s port "
                   DPDK_PORT_ID_FMT, netdev_get_name(&dev->up), dev->port_id);
     }
+    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);
@@ -5295,6 +5298,24 @@ out:
     return ret;
 }
 
+bool
+netdev_dpdk_is_uplink_port(struct netdev *netdev)
+{
+    struct netdev_dpdk *dev;
+    bool ret = false;
+
+    if (!is_dpdk_class(netdev->netdev_class)) {
+        goto out;
+    }
+
+    dev = netdev_dpdk_cast(netdev);
+    ovs_mutex_lock(&dev->mutex);
+    ret = dev->is_uplink_port;
+    ovs_mutex_unlock(&dev->mutex);
+out:
+    return ret;
+}
+
 bool
 netdev_dpdk_flow_api_supported(struct netdev *netdev)
 {
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
index 848346cb4..abda4a865 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -55,6 +55,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_is_uplink_port(struct netdev *netdev);
 
 #else
 
-- 
2.14.5



More information about the dev mailing list