diff mbox series

[ovs-dev,53/62] netdev-dpdk: Add uplink port and vf representor port flag

Message ID 20201228092520.11807-54-taoyunxiang@cmss.chinamobile.com
State Not Applicable
Headers show
Series DPDK Offload API to test | expand

Commit Message

Tao YunXiang Dec. 28, 2020, 9:25 a.m. UTC
From: Taoyunxiang <taoyunxiang@cmss.chinamobile.com>

Code Source From: Self Code
Description:
Add uplink port and vf representor port flag

Jira:  #[Optional]
市场项目编号(名称):[Optional]
---
 lib/netdev-dpdk.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8e093ed..45fc908 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -471,6 +471,8 @@  struct netdev_dpdk {
         };
         struct dpdk_tx_queue *tx_q;
         struct rte_eth_link link;
+        bool is_uplink_port; /* True=uplink port, false=vfrep port or pf port. */
+        bool is_vf_rep_port; /* True=vf rep port, false=vfrep port or pf port. */
     );
 
     PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline1,
@@ -2005,6 +2007,12 @@  netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args,
                       netdev_get_name(netdev));
         err = EINVAL;
     }
+    /* update is_uplink_port && is_vf_rep_port flag */
+    if (strstr(dev->devargs,"representor=[10")) {
+        dev->is_uplink_port = true;
+    } else if (strstr(dev->devargs,"representor")) {
+        dev->is_vf_rep_port = true;
+    }
 
     if (err) {
         goto out;
@@ -5339,7 +5347,27 @@  netdev_dpdk_is_uplink_port(struct netdev *netdev)
 
     dev = netdev_dpdk_cast(netdev);
     ovs_mutex_lock(&dev->mutex);
-    if (strstr(dev->devargs,"representor=[10")) {
+    if (dev->is_uplink_port) {
+        ret = true;
+    }
+    ovs_mutex_unlock(&dev->mutex);
+out:
+    return ret;
+}
+
+bool
+netdev_dpdk_is_vfrep_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);
+    if (dev->is_vf_rep_port) {
         ret = true;
     }
     ovs_mutex_unlock(&dev->mutex);