From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0078.outbound.protection.outlook.com [104.47.1.78]) by dpdk.org (Postfix) with ESMTP id 6527D5A44 for ; Thu, 13 Sep 2018 12:31:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s/1gDbdEAmAHnXP+8lT2jlcliLFlE1r0GVfaQXBW8HQ=; b=orrmUXwlctboVZrQU7SSaC5Y99vjM9ku8rdF5R9sl1iuoDIZ5HfXui6euNFW+Si32jd7kvSloJrN0cA1E3cBnbYy+bK265ldg97QsH6vfgqzOs/46KLq/0I61lgvbedALLYan61VaUbcZ4RxFQO7ecSFJmyuOcDe1qOZu+lXJAU= Received: from localhost.localdomain (37.142.13.130) by AM6PR05MB4439.eurprd05.prod.outlook.com (2603:10a6:209:43::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.17; Thu, 13 Sep 2018 10:31:02 +0000 From: Moti Haimovsky To: shahafs@mellanox.com Cc: dev@dpdk.org, Moti Haimovsky Date: Thu, 13 Sep 2018 13:30:44 +0300 Message-Id: <1536834644-16891-1-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0501CA0043.eurprd05.prod.outlook.com (2603:10a6:800:60::29) To AM6PR05MB4439.eurprd05.prod.outlook.com (2603:10a6:209:43::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3baeca15-1966-4254-22e5-08d6196401c2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR05MB4439; X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4439; 3:+ErG7JMnouRABbAv9iGqRt3A3eTLkc/zfubr4G5ZW5G+wHQTXoNnsiioB3ixPVP2bTkgP8ay9XD24x0xH4MFI8wF3R88bVoQ6rMZZ9eDnbhab6KqTm1PKMWFE1ztSbIJ1L/4tymqKl10y65NhbIpqj+I+I9ULtlcnnDl4mvic+YaMzgbfpnxd8UVpPtJRuswkmFUkeoMGwAt8OJ/s9/LKpljR/0ZXJ3hd5cDsoQ7KncVZ8bjRZVkPGbvkezdti0S; 25:Ps0v3JSKz+deV9pX2ttvYl1yYxhfl+CCQ8CIYINr7D8bk23vKNrnaa+xNQ4C74M1pMoAFzX/qBXhLHM4ZjcFJ662zgHzN9+Gan2S+9nKN2crGdSH97kAZA8BuM+nJsuKhGVZBfaiTsflFMdzDKQIMrNFbl7jEA/CqFmtvUQnmYzwUwe0gOhUdk4Zk/zRmjysNaFPMLFSNR9tUa/B//bl1pQS5Z3/XO4i0yfvceJYhcA7gVo2/D1Um3zeVBbknoKwtunm3KzlKbB9TxrITHo/mxC5iiI4+MoMgkELMUrmtxqXXS6803Cx0dZG23glcIOzQR7cnpp/HzdzoSjcYKxKgg==; 31:CKD1kh21PpnVwHSyTSlO8l8fLSoeZmdsi+JgK/HNU7DKDhSKolf3z1U5avRKLaEW8NKblQFNR6FIRlpn9R1g66DDyFvruuB2btR39WhcekvECZHDGp+ivej0ZwqHpdibLaZZq4b+fa8UcbSVL++bMbgGx7BuBcRKvDqC+fA/Bv1vkzjjrD3P5pYh2zCMus+Q8+hOVF7dfyPsIzv75Iby5EgxIiCMYmrqfJXr3bdauys= X-MS-TrafficTypeDiagnostic: AM6PR05MB4439: X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4439; 20:9wvGDAem8fdU1zsTCGOmn1g7a/zmI68Z6HJq+3EQMCwV1rvtHFigzA92Q3jDHJCFYYMYgQiysabOYj2+n+QPhhUQll3SxijhmQn9dkJphy/7pLOQCVKZxJaNTIKy0+ZDAD3dYxBQmxakNVnnOp+bFpLEO/0xsPJ0tTrw+PXoz6CJN/crfnFM1WzH8Lj0Rzzar+BBBGREQW4yqOQbd8c8n5MgiIOAVNU/Q6XkfRhTfDKR0WtIuvrCtw3k77QKhWBypFnvK/ig0opqBu4Z9pJaC5NjrNnJXgSv4JYr1/n8q+N8aY/hvnbna6J3muWbUCUY1jznrZ9XLC0Uia+NJeXRileF/jtkjQV2f7X7v0hm9+RjkORPhOCv1X1fJL8tvFWzw6d8gtHTq3D8/2grbmurarwNU0+2YMNGc5Ve41L7xZvBoVNCSusxwnNflhAfhYe2TWwD1JwTN/TrDC4tqZENy8IgJrTdD9kRJ/OAo0vXj+lsCIKwofhT5JllGv9Die6N; 4:NgnczAeQscEnkpav5C4SJDBiE29OYSWtEv2Z5lRUBh8rJaBAxlkHJmdaz6AqTLvsYKDGYDtJe9SFm8vbwMsGWmBMYbTMVAnLSYPFotJXvAX5mgnJGPcRp3ryOOMBWhS/8xMI3k6lt3uI+jSEDNIa+llfkJ6XwEd5GFWC41kX6ZkTwbH5Eo8VLYGDPsV795erdLgcQn7bx8hS7IEr+LMdadX2GpFwq/nn5aQ7KlfwMXcPhYX/PMemz8CoaqoR0Iqhiic9NUwLfHiNUudR/OHMsA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(10201501046)(93006095)(93001095)(3002001)(3231344)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201708071742011)(7699050)(76991041); SRVR:AM6PR05MB4439; BCL:0; PCL:0; RULEID:; SRVR:AM6PR05MB4439; X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(396003)(136003)(366004)(376002)(39860400002)(199004)(189003)(7736002)(478600001)(8676002)(386003)(486006)(4326008)(52116002)(81166006)(6666003)(26005)(6636002)(47776003)(6506007)(53936002)(6346003)(2616005)(81156014)(2906002)(66066001)(86362001)(8936002)(6512007)(3846002)(37006003)(6116002)(5660300001)(305945005)(69590400006)(16586007)(1857600001)(956004)(16526019)(476003)(316002)(50466002)(6486002)(36756003)(50226002)(97736004)(25786009)(68736007)(51416003)(105586002)(106356001)(107886003)(48376002)(34206002)(2351001)(14444005)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4439; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM6PR05MB4439; 23:jYGeGopf2PVjUiS4d+ycCWWhvds+ywm8wywC9Y1dm?= =?us-ascii?Q?cizI84IyD0Kr8lLVGvkYNJkPhXB47xRgW8Qw5cJMyy8VfTsAq8DMfSPWrgjy?= =?us-ascii?Q?CeXIk2UZxA6FWmHVBihU5qQjSBXD3RUyJBHLwkAd+BWedY1NO2OFOwTiDs/n?= =?us-ascii?Q?Ig/4Xt1mhevwe4nm3armwVo7l9DqmstI95+yu4HDMhfbqIurJHBuWUzWjpnH?= =?us-ascii?Q?tDCRbBfabk6FDxfuX4CCcu96x3olz5+7gVAXuGOjfBvKmPwx7nn/hlH0dW9z?= =?us-ascii?Q?y3rkwILgrhCLKKtOSSBCuwVoGGz2IJqwYW4J3rubcTYnVlbd/d08gbGmz97R?= =?us-ascii?Q?9qfi0VH8Jqqf/e+XX3SoidJtQiHNirro4nzJG2CWhP8JlZWGdlr/nHvjNARS?= =?us-ascii?Q?AO4nngp/ziG63EEyUKD1sqaS/Rk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VaBBVnDDYRmmGDkWAF8Mt70U8=; 7:6TDib9Wiqe3yYucfo06JEL80stvNir4fS1JqFJ+B2ohfmLMMFC5TwhilIpnBFs35DSzOgAdTi/2U61r56N7/DwdJm8g225CWlOh98pTVDK4EfumoTu/vEKD1L9QfT7lQGCJu8HrFcQ8ilbdnW0F/fW5+PykQyLtvFYIr5lGLkqYTMsjlgKRbnlfRYRLpYvEeGSaC0ribeOo9w+OXjINLivum0mptxddHwJWzXGec+1Eg9g7Sq3D5X0G85HL7M71e SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 10:31:02.9865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3baeca15-1966-4254-22e5-08d6196401c2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4439 Subject: [dpdk-dev] [PATCH] net/mlx5: support e-switch TCP-flags flow filter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Sep 2018 10:31:04 -0000 This patch adds support for offloading flow rules with tcp-flags filter to mlx5 eswitch hardwrae. Today, it is possible to offload an interface flow rules to the hardware using DPDK flow commands. With mlx5 it is also possible to offload a limited set of flow rules to the mlxsw (or e-switch) using the same DPDK flow commands. A 'transfer' attribute was added to the flow rule creation command in order to distinguish between configuring port flows and E-switch flows. The commands destined for the switch are transposed to TC flower rules and are send, as Netlink messages, to the mlx5 driver, or more precisely to the netdev which represent the mlxsw port. The limited set of e-switch flow rules also supports filtering according to the values found in the TCP flags. This patch implements this offload capability in the mlx5 PMD. Signed-off-by: Moti Haimovsky --- Note: This patch should be applied on top of the new flow engine commits by orika and yskoh --- drivers/net/mlx5/Makefile | 10 ++++++++++ drivers/net/mlx5/mlx5_flow.c | 9 ++++++++- drivers/net/mlx5/mlx5_flow_tcf.c | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index ca1de9f..9097456 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -342,6 +342,16 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh enum TCA_FLOWER_KEY_VLAN_ETH_TYPE \ $(AUTOCONF_OUTPUT) $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_TCP_FLAGS \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_TCP_FLAGS \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_TCA_FLOWER_KEY_TCP_FLAGS_MASK \ + linux/pkt_cls.h \ + enum TCA_FLOWER_KEY_TCP_FLAGS_MASK \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ HAVE_TC_ACT_VLAN \ linux/tc_act/tc_vlan.h \ enum TCA_VLAN_PUSH_VLAN_PRIORITY \ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f9a64d3..c8cc8fe 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1241,6 +1241,13 @@ int mlx5_flow_validate_item_tcp(uint64_t item_flags, struct rte_flow_error *error) { const struct rte_flow_item_tcp *mask = item->mask; + const struct rte_flow_item_tcp nic_mask = { + .hdr = { + .src_port = RTE_BE16(0xffff), + .dst_port = RTE_BE16(0xffff), + .tcp_flags = 0xff, + }, + }; const int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); int ret; @@ -1266,7 +1273,7 @@ int mlx5_flow_validate_item_tcp(uint64_t item_flags, mask = &rte_flow_item_tcp_mask; ret = mlx5_flow_item_acceptable (item, (const uint8_t *)mask, - (const uint8_t *)&rte_flow_item_tcp_mask, + (const uint8_t *)&nic_mask, sizeof(struct rte_flow_item_tcp), error); if (ret < 0) return ret; diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 769a13a..5034862 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -148,6 +148,12 @@ struct tc_vlan { #ifndef HAVE_TCA_FLOWER_KEY_VLAN_ETH_TYPE #define TCA_FLOWER_KEY_VLAN_ETH_TYPE 25 #endif +#ifndef TCA_FLOWER_KEY_TCP_FLAGS +#define TCA_FLOWER_KEY_TCP_FLAGS 71 +#endif +#ifndef TCA_FLOWER_KEY_TCP_FLAGS_MASK +#define TCA_FLOWER_KEY_TCP_FLAGS_MASK 72 +#endif #ifndef IPV6_ADDR_LEN #define IPV6_ADDR_LEN 16 @@ -204,6 +210,7 @@ struct tc_vlan { .tcp.hdr = { .src_port = RTE_BE16(0xffff), .dst_port = RTE_BE16(0xffff), + .tcp_flags = 0xff, }, .udp.hdr = { .src_port = RTE_BE16(0xffff), @@ -1271,6 +1278,18 @@ struct flow_tcf_ptoi { TCA_FLOWER_KEY_TCP_DST_MASK, mask.tcp->hdr.dst_port); } + if (mask.tcp->hdr.tcp_flags) { + mnl_attr_put_u16 + (nlh, + TCA_FLOWER_KEY_TCP_FLAGS, + rte_cpu_to_be_16 + (spec.tcp->hdr.tcp_flags)); + mnl_attr_put_u16 + (nlh, + TCA_FLOWER_KEY_TCP_FLAGS_MASK, + rte_cpu_to_be_16 + (mask.tcp->hdr.tcp_flags)); + } break; default: return rte_flow_error_set(error, ENOTSUP, -- 1.8.3.1