diff mbox series

[ovs-dev] netdev-tc-offloads: Fix probing multi mask per prio

Message ID 1530522478-30378-1-git-send-email-roid@mellanox.com
State Accepted
Headers show
Series [ovs-dev] netdev-tc-offloads: Fix probing multi mask per prio | expand

Commit Message

Roi Dayan July 2, 2018, 9:07 a.m. UTC
When adding TC rules we save the prio so can reuse same prio
for same mask since different mask will have to use different prio.
The multi mask per prio probe broke this by using a prio but
get_prio_for_tc_flower() didn't know about it.
Also multi mask per prio support changes the hash calculation.
It's best the probe will add and del the ingress qdisc to have a clean start
after it.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Acked-by: Paul Blakey <paulb@mellanox.com>
---
 lib/netdev-tc-offloads.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

Comments

Simon Horman July 2, 2018, 2:16 p.m. UTC | #1
On Mon, Jul 02, 2018 at 12:07:58PM +0300, Roi Dayan wrote:
> When adding TC rules we save the prio so can reuse same prio
> for same mask since different mask will have to use different prio.
> The multi mask per prio probe broke this by using a prio but
> get_prio_for_tc_flower() didn't know about it.
> Also multi mask per prio support changes the hash calculation.
> It's best the probe will add and del the ingress qdisc to have a clean start
> after it.
> 
> Signed-off-by: Roi Dayan <roid@mellanox.com>
> Acked-by: Paul Blakey <paulb@mellanox.com>

Thanks, applied to master.
diff mbox series

Patch

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 86dbeeccb33b..bdf288c0622c 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -1235,11 +1235,17 @@  netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED,
 }
 
 static void
-probe_multi_mask_per_prio(int ifindex, uint32_t block_id)
+probe_multi_mask_per_prio(int ifindex)
 {
     struct tc_flower flower;
+    int block_id = 0;
     int error;
 
+    error = tc_add_del_ingress_qdisc(ifindex, true, block_id);
+    if (error) {
+        return;
+    }
+
     memset(&flower, 0, sizeof flower);
 
     flower.key.eth_type = htons(ETH_P_IP);
@@ -1249,7 +1255,7 @@  probe_multi_mask_per_prio(int ifindex, uint32_t block_id)
 
     error = tc_replace_flower(ifindex, 1, 1, &flower, block_id);
     if (error) {
-        return;
+        goto out;
     }
 
     memset(&flower.key.src_mac, 0x11, sizeof flower.key.src_mac);
@@ -1259,13 +1265,16 @@  probe_multi_mask_per_prio(int ifindex, uint32_t block_id)
     tc_del_filter(ifindex, 1, 1, block_id);
 
     if (error) {
-        return;
+        goto out;
     }
 
     tc_del_filter(ifindex, 1, 2, block_id);
 
     multi_mask_per_prio = true;
     VLOG_INFO("probe tc: multiple masks on single tc prio is supported.");
+
+out:
+    tc_add_del_ingress_qdisc(ifindex, false, block_id);
 }
 
 static void
@@ -1306,6 +1315,11 @@  netdev_tc_init_flow_api(struct netdev *netdev)
         ovsthread_once_done(&block_once);
     }
 
+    if (ovsthread_once_start(&multi_mask_once)) {
+        probe_multi_mask_per_prio(ifindex);
+        ovsthread_once_done(&multi_mask_once);
+    }
+
     block_id = get_block_id_from_netdev(netdev);
     error = tc_add_del_ingress_qdisc(ifindex, true, block_id);
 
@@ -1317,10 +1331,5 @@  netdev_tc_init_flow_api(struct netdev *netdev)
 
     VLOG_INFO("added ingress qdisc to %s", netdev_get_name(netdev));
 
-    if (ovsthread_once_start(&multi_mask_once)) {
-        probe_multi_mask_per_prio(ifindex, block_id);
-        ovsthread_once_done(&multi_mask_once);
-    }
-
     return 0;
 }