[ovs-dev] [PATCH 5/6] netdev-linux: assign LAG devs to tc blocks

John Hurley john.hurley at netronome.com
Thu Jun 21 13:36:00 UTC 2018


Assign block ids to LAG masters that are added to OvS as linux-netdevs and
offloaded via offload API calls. Only LAG masters are assigned to blocks.

To ensure uniqueness, the block ids are determined by the netdev ifindex.
Implement a get_block_id op for linux netdevs to achieve this.

Signed-off-by: John Hurley <john.hurley at netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe at netronome.com>
Reviewed-by: Simon Horman <simon.horman at netronome.com>
---
 lib/netdev-linux.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 6ed2f05..81de3b1 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -2945,6 +2945,27 @@ netdev_internal_get_status(const struct netdev *netdev OVS_UNUSED,
     return 0;
 }
 
+static uint32_t
+netdev_linux_get_block_id(struct netdev *netdev_)
+{
+    struct netdev_linux *netdev = netdev_linux_cast(netdev_);
+    uint32_t block_id = 0;
+
+    ovs_mutex_lock(&netdev->mutex);
+    /* Ensure the linux netdev has had its fields populated. */
+    if (!(netdev->cache_valid & VALID_IFINDEX)) {
+        netdev_linux_update_via_netlink(netdev);
+    }
+
+    /* Only assigning block ids to linux netdevs that are LAG masters. */
+    if (netdev->is_lag_master) {
+        block_id = netdev->ifindex;
+    }
+    ovs_mutex_unlock(&netdev->mutex);
+
+    return block_id;
+}
+
 /* Looks up the ARP table entry for 'ip' on 'netdev'.  If one exists and can be
  * successfully retrieved, it stores the corresponding MAC address in 'mac' and
  * returns 0.  Otherwise, it returns a positive errno value; in particular,
@@ -3060,7 +3081,7 @@ exit:
 
 #define NETDEV_LINUX_CLASS(NAME, CONSTRUCT, GET_STATS,          \
                            GET_FEATURES, GET_STATUS,            \
-                           FLOW_OFFLOAD_API)                    \
+                           FLOW_OFFLOAD_API, GET_BLOCK_ID)      \
 {                                                               \
     NAME,                                                       \
     false,                      /* is_pmd */                    \
@@ -3133,7 +3154,7 @@ exit:
     netdev_linux_rxq_drain,                                     \
                                                                 \
     FLOW_OFFLOAD_API,                                           \
-    NULL                        /* get_block_id */              \
+    GET_BLOCK_ID                                                \
 }
 
 const struct netdev_class netdev_linux_class =
@@ -3143,7 +3164,8 @@ const struct netdev_class netdev_linux_class =
         netdev_linux_get_stats,
         netdev_linux_get_features,
         netdev_linux_get_status,
-        LINUX_FLOW_OFFLOAD_API);
+        LINUX_FLOW_OFFLOAD_API,
+        netdev_linux_get_block_id);
 
 const struct netdev_class netdev_tap_class =
     NETDEV_LINUX_CLASS(
@@ -3152,7 +3174,8 @@ const struct netdev_class netdev_tap_class =
         netdev_tap_get_stats,
         netdev_linux_get_features,
         netdev_linux_get_status,
-        NO_OFFLOAD_API);
+        NO_OFFLOAD_API,
+        NULL);
 
 const struct netdev_class netdev_internal_class =
     NETDEV_LINUX_CLASS(
@@ -3161,7 +3184,8 @@ const struct netdev_class netdev_internal_class =
         netdev_internal_get_stats,
         NULL,                  /* get_features */
         netdev_internal_get_status,
-        NO_OFFLOAD_API);
+        NO_OFFLOAD_API,
+        NULL);
 
 
 #define CODEL_N_QUEUES 0x0000
-- 
2.7.4



More information about the dev mailing list