net/mlx5e: Use the inner headers to determine tc/pedit offload limitation on decap flows [Linux 5.0]

This Linux kernel change "net/mlx5e: Use the inner headers to determine tc/pedit offload limitation on decap flows" is included in the Linux 5.0 release. This change is authored by Guy Shattah <sguy [at] mellanox.com> on Mon Jan 28 13:58:07 2019 +0000. The commit for this change in Linux stable tree is 1651925 (patch).

net/mlx5e: Use the inner headers to determine tc/pedit offload limitation on decap flows

In packets that need to be decaped the internal headers
have to be checked, not the external ones.

Fixes: bdd66ac0aeed ("net/mlx5e: Disallow TC offloading of unsupported match/action combinations")
Signed-off-by: Guy Shattah <[email protected]>
Reviewed-by: Or Gerlitz <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>

There are 9 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 043896e..1c3c9fa 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2181,6 +2181,7 @@ static bool csum_offload_supported(struct mlx5e_priv *priv,

 static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
                      struct tcf_exts *exts,
+                     u32 actions,
                      struct netlink_ext_ack *extack)
 {
    const struct tc_action *a;
@@ -2190,7 +2191,11 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
    u16 ethertype;
    int nkeys, i;

-   headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, outer_headers);
+   if (actions & MLX5_FLOW_CONTEXT_ACTION_DECAP)
+       headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, inner_headers);
+   else
+       headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, outer_headers);
+
    ethertype = MLX5_GET(fte_match_set_lyr_2_4, headers_v, ethertype);

    /* for non-IP we only re-write MACs, so we're okay */
@@ -2247,7 +2252,7 @@ static bool actions_match_supported(struct mlx5e_priv *priv,

    if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
        return modify_header_match_supported(&parse_attr->spec, exts,
-                            extack);
+                            actions, extack);

    return true;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *