nfp: flower: restructure flow-key for gre+vlan combination
authorEtienne van der Linde <etienne.vanderlinde@corigine.com>
Wed, 8 Jun 2022 09:29:01 +0000 (11:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:36:19 +0000 (18:36 +0200)
[ Upstream commit a0b843340dae704e17c1ddfad0f85c583c36757f ]

Swap around the GRE and VLAN parts in the flow-key offloaded by
the driver to fit in with other tunnel types and the firmware.
Without this change used cases with GRE+VLAN on the outer header
does not get offloaded as the flow-key mismatches what the
firmware expect.

Fixes: 0d630f58989a ("nfp: flower: add support to offload QinQ match")
Fixes: 5a2b93041646 ("nfp: flower-ct: compile match sections of flow_payload")
Signed-off-by: Etienne van der Linde <etienne.vanderlinde@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/netronome/nfp/flower/conntrack.c
drivers/net/ethernet/netronome/nfp/flower/match.c

index bfd7d1c..7e9fcc1 100644 (file)
@@ -442,6 +442,11 @@ nfp_fl_calc_key_layers_sz(struct nfp_fl_key_ls in_key_ls, uint16_t *map)
                key_size += sizeof(struct nfp_flower_ipv6);
        }
 
+       if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_QINQ) {
+               map[FLOW_PAY_QINQ] = key_size;
+               key_size += sizeof(struct nfp_flower_vlan);
+       }
+
        if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_GRE) {
                map[FLOW_PAY_GRE] = key_size;
                if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6)
@@ -450,11 +455,6 @@ nfp_fl_calc_key_layers_sz(struct nfp_fl_key_ls in_key_ls, uint16_t *map)
                        key_size += sizeof(struct nfp_flower_ipv4_gre_tun);
        }
 
-       if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_QINQ) {
-               map[FLOW_PAY_QINQ] = key_size;
-               key_size += sizeof(struct nfp_flower_vlan);
-       }
-
        if ((in_key_ls.key_layer & NFP_FLOWER_LAYER_VXLAN) ||
            (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_GENEVE)) {
                map[FLOW_PAY_UDP_TUN] = key_size;
@@ -693,6 +693,17 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry)
                }
        }
 
+       if (NFP_FLOWER_LAYER2_QINQ & key_layer.key_layer_two) {
+               offset = key_map[FLOW_PAY_QINQ];
+               key = kdata + offset;
+               msk = mdata + offset;
+               for (i = 0; i < _CT_TYPE_MAX; i++) {
+                       nfp_flower_compile_vlan((struct nfp_flower_vlan *)key,
+                                               (struct nfp_flower_vlan *)msk,
+                                               rules[i]);
+               }
+       }
+
        if (key_layer.key_layer_two & NFP_FLOWER_LAYER2_GRE) {
                offset = key_map[FLOW_PAY_GRE];
                key = kdata + offset;
@@ -733,17 +744,6 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry)
                }
        }
 
-       if (NFP_FLOWER_LAYER2_QINQ & key_layer.key_layer_two) {
-               offset = key_map[FLOW_PAY_QINQ];
-               key = kdata + offset;
-               msk = mdata + offset;
-               for (i = 0; i < _CT_TYPE_MAX; i++) {
-                       nfp_flower_compile_vlan((struct nfp_flower_vlan *)key,
-                                               (struct nfp_flower_vlan *)msk,
-                                               rules[i]);
-               }
-       }
-
        if (key_layer.key_layer & NFP_FLOWER_LAYER_VXLAN ||
            key_layer.key_layer_two & NFP_FLOWER_LAYER2_GENEVE) {
                offset = key_map[FLOW_PAY_UDP_TUN];
index 9d86eea..fb8bd21 100644 (file)
@@ -602,6 +602,14 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
                msk += sizeof(struct nfp_flower_ipv6);
        }
 
+       if (NFP_FLOWER_LAYER2_QINQ & key_ls->key_layer_two) {
+               nfp_flower_compile_vlan((struct nfp_flower_vlan *)ext,
+                                       (struct nfp_flower_vlan *)msk,
+                                       rule);
+               ext += sizeof(struct nfp_flower_vlan);
+               msk += sizeof(struct nfp_flower_vlan);
+       }
+
        if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_GRE) {
                if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) {
                        struct nfp_flower_ipv6_gre_tun *gre_match;
@@ -637,14 +645,6 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
                }
        }
 
-       if (NFP_FLOWER_LAYER2_QINQ & key_ls->key_layer_two) {
-               nfp_flower_compile_vlan((struct nfp_flower_vlan *)ext,
-                                       (struct nfp_flower_vlan *)msk,
-                                       rule);
-               ext += sizeof(struct nfp_flower_vlan);
-               msk += sizeof(struct nfp_flower_vlan);
-       }
-
        if (key_ls->key_layer & NFP_FLOWER_LAYER_VXLAN ||
            key_ls->key_layer_two & NFP_FLOWER_LAYER2_GENEVE) {
                if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) {