{"id":807971,"url":"http://patchwork.ozlabs.org/api/1.2/patches/807971/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170830230409.15176-2-saeedm@mellanox.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170830230409.15176-2-saeedm@mellanox.com>","list_archive_url":null,"date":"2017-08-30T23:04:07","name":"[net-next,1/3] net/mlx5e: Use IP version matching to classify IP traffic","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"3c16646131527b55beb717f7a1da5c7a7094f4c6","submitter":{"id":65299,"url":"http://patchwork.ozlabs.org/api/1.2/people/65299/?format=json","name":"Saeed Mahameed","email":"saeedm@mellanox.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170830230409.15176-2-saeedm@mellanox.com/mbox/","series":[{"id":721,"url":"http://patchwork.ozlabs.org/api/1.2/series/721/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=721","date":"2017-08-30T23:04:06","name":"[net-next,1/3] net/mlx5e: Use IP version matching to classify IP traffic","version":1,"mbox":"http://patchwork.ozlabs.org/series/721/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/807971/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807971/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjLg05z05z9s65\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 31 Aug 2017 09:04:28 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751393AbdH3XEW (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 30 Aug 2017 19:04:22 -0400","from mail-il-dmz.mellanox.com ([193.47.165.129]:34540 \"EHLO\n\tmellanox.co.il\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1751237AbdH3XEV (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 30 Aug 2017 19:04:21 -0400","from Internal Mail-Server by MTLPINE1 (envelope-from\n\tsaeedm@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 31 Aug 2017 02:04:17 +0300","from sws.mtl.labs.mlnx (reg-l-vrt-045-015.mtl.labs.mlnx\n\t[10.135.45.15])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v7UN4HFk017137;\n\tThu, 31 Aug 2017 02:04:17 +0300"],"From":"Saeed Mahameed <saeedm@mellanox.com>","To":"\"David S. Miller\" <davem@davemloft.net>","Cc":"netdev@vger.kernel.org, Gal Pressman <galp@mellanox.com>,\n\tAriel Levkovich <lariel@mellanox.com>,\n\tSaeed Mahameed <saeedm@mellanox.com>","Subject":"[net-next 1/3] net/mlx5e: Use IP version matching to classify IP\n\ttraffic","Date":"Thu, 31 Aug 2017 02:04:07 +0300","Message-Id":"<20170830230409.15176-2-saeedm@mellanox.com>","X-Mailer":"git-send-email 2.13.0","In-Reply-To":"<20170830230409.15176-1-saeedm@mellanox.com>","References":"<20170830230409.15176-1-saeedm@mellanox.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Gal Pressman <galp@mellanox.com>\n\nThis change adds the ability for flow steering to classify IPv4/6\npackets with MPLS tag (Ethertype 0x8847 and 0x8848) as standard IP\npackets and hit IPv4/6 classification steering rules.\n\nSince IP packets with MPLS tag header have MPLS ethertype, they\nmissed the IPv4/6 ethertype rule and ended up hitting the default\nfilter forwarding all the packets to the same single RQ (No RSS).\n\nSince our device is able to look past the MPLS tag and identify the\nnext protocol we introduce this solution which replaces ethertype\nmatching by the device's capability to perform IP version\nidentification and matching in order to distinguish between IPv4 and\nIPv6.\nTherefore, when driver is performing flow steering configuration on the\ndevice it will use IP version matching in IP classified rules instead\nof ethertype matching which will cause relevant MPLS tagged packets to\nhit this rule as well.\n\nIf the device doesn't support IP version matching the driver will fall back\nto use legacy ethertype matching in the steering as before.\n\nSigned-off-by: Gal Pressman <galp@mellanox.com>\nSigned-off-by: Ariel Levkovich <lariel@mellanox.com>\nReviewed-by: Or Gerlitz <ogerlitz@mellanox.com>\nSigned-off-by: Saeed Mahameed <saeedm@mellanox.com>\n---\n drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 33 ++++++++++++++++++++++---\n 1 file changed, 29 insertions(+), 4 deletions(-)","diff":"diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c\nindex eecbc6d4f51f..85e6226dacfb 100644\n--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c\n+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c\n@@ -660,6 +660,17 @@ static struct {\n \t},\n };\n \n+static u8 mlx5e_etype_to_ipv(u16 ethertype)\n+{\n+\tif (ethertype == ETH_P_IP)\n+\t\treturn 4;\n+\n+\tif (ethertype == ETH_P_IPV6)\n+\t\treturn 6;\n+\n+\treturn 0;\n+}\n+\n static struct mlx5_flow_handle *\n mlx5e_generate_ttc_rule(struct mlx5e_priv *priv,\n \t\t\tstruct mlx5_flow_table *ft,\n@@ -667,10 +678,12 @@ mlx5e_generate_ttc_rule(struct mlx5e_priv *priv,\n \t\t\tu16 etype,\n \t\t\tu8 proto)\n {\n+\tint match_ipv_outer = MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ft_field_support.outer_ip_version);\n \tMLX5_DECLARE_FLOW_ACT(flow_act);\n \tstruct mlx5_flow_handle *rule;\n \tstruct mlx5_flow_spec *spec;\n \tint err = 0;\n+\tu8 ipv;\n \n \tspec = kvzalloc(sizeof(*spec), GFP_KERNEL);\n \tif (!spec)\n@@ -681,7 +694,13 @@ mlx5e_generate_ttc_rule(struct mlx5e_priv *priv,\n \t\tMLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.ip_protocol);\n \t\tMLX5_SET(fte_match_param, spec->match_value, outer_headers.ip_protocol, proto);\n \t}\n-\tif (etype) {\n+\n+\tipv = mlx5e_etype_to_ipv(etype);\n+\tif (match_ipv_outer && ipv) {\n+\t\tspec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;\n+\t\tMLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.ip_version);\n+\t\tMLX5_SET(fte_match_param, spec->match_value, outer_headers.ip_version, ipv);\n+\t} else if (etype) {\n \t\tspec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;\n \t\tMLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.ethertype);\n \t\tMLX5_SET(fte_match_param, spec->match_value, outer_headers.ethertype, etype);\n@@ -739,7 +758,9 @@ static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv)\n #define MLX5E_TTC_TABLE_SIZE\t(MLX5E_TTC_GROUP1_SIZE +\\\n \t\t\t\t MLX5E_TTC_GROUP2_SIZE +\\\n \t\t\t\t MLX5E_TTC_GROUP3_SIZE)\n-static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc)\n+\n+static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc,\n+\t\t\t\t\t bool use_ipv)\n {\n \tint inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);\n \tstruct mlx5e_flow_table *ft = &ttc->ft;\n@@ -761,7 +782,10 @@ static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc)\n \t/* L4 Group */\n \tmc = MLX5_ADDR_OF(create_flow_group_in, in, match_criteria);\n \tMLX5_SET_TO_ONES(fte_match_param, mc, outer_headers.ip_protocol);\n-\tMLX5_SET_TO_ONES(fte_match_param, mc, outer_headers.ethertype);\n+\tif (use_ipv)\n+\t\tMLX5_SET_TO_ONES(fte_match_param, mc, outer_headers.ip_version);\n+\telse\n+\t\tMLX5_SET_TO_ONES(fte_match_param, mc, outer_headers.ethertype);\n \tMLX5_SET_CFG(in, match_criteria_enable, MLX5_MATCH_OUTER_HEADERS);\n \tMLX5_SET_CFG(in, start_flow_index, ix);\n \tix += MLX5E_TTC_GROUP1_SIZE;\n@@ -812,6 +836,7 @@ void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv)\n \n int mlx5e_create_ttc_table(struct mlx5e_priv *priv)\n {\n+\tbool match_ipv_outer = MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ft_field_support.outer_ip_version);\n \tstruct mlx5e_ttc_table *ttc = &priv->fs.ttc;\n \tstruct mlx5_flow_table_attr ft_attr = {};\n \tstruct mlx5e_flow_table *ft = &ttc->ft;\n@@ -828,7 +853,7 @@ int mlx5e_create_ttc_table(struct mlx5e_priv *priv)\n \t\treturn err;\n \t}\n \n-\terr = mlx5e_create_ttc_table_groups(ttc);\n+\terr = mlx5e_create_ttc_table_groups(ttc, match_ipv_outer);\n \tif (err)\n \t\tgoto err;\n \n","prefixes":["net-next","1/3"]}