From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30071.outbound.protection.outlook.com [40.107.3.71]) by dpdk.org (Postfix) with ESMTP id 852831B6C7 for ; Wed, 10 Oct 2018 16:43:40 +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=0oh9NGvGJSg1R0j8iBI/oeyoTnbdPyefC6QDHDnoGJc=; b=bGy4fI+Wf/vNU86E5SQ3OcxB7KD+HPyOeqlZF5JP/rqq/Zq9n2DWK/h9ILlqtE/cMIkmk+enDzvdkYJ3BJ7dH/YXKXW30pDeCcKsxt8ndoMz8d6lWRsT2C7VwJ7VyFbm9qUG+/W6zZomnVjeijNLDJcJBGr/WdWv/CDjcNXByLQ= Received: from AM0PR05MB4435.eurprd05.prod.outlook.com (52.134.92.20) by AM0PR05MB4834.eurprd05.prod.outlook.com (20.177.41.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.28; Wed, 10 Oct 2018 14:43:39 +0000 Received: from AM0PR05MB4435.eurprd05.prod.outlook.com ([fe80::2549:a872:4864:b84e]) by AM0PR05MB4435.eurprd05.prod.outlook.com ([fe80::2549:a872:4864:b84e%6]) with mapi id 15.20.1207.024; Wed, 10 Oct 2018 14:43:39 +0000 From: Mordechay Haimovsky To: Shahaf Shuler CC: "dev@dpdk.org" , Mordechay Haimovsky Thread-Topic: [PATCH v3] net/mlx5: support e-switch TCP-flags flow filter Thread-Index: AQHUYKehzCEBImc+Dka5pQqiDm2ozA== Date: Wed, 10 Oct 2018 14:43:38 +0000 Message-ID: <1539182589-10533-1-git-send-email-motih@mellanox.com> References: <1539083548-23240-1-git-send-email-motih@mellanox.com> In-Reply-To: <1539083548-23240-1-git-send-email-motih@mellanox.com> Accept-Language: he-IL, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR09CA0066.eurprd09.prod.outlook.com (2603:10a6:7:3c::34) To AM0PR05MB4435.eurprd05.prod.outlook.com (2603:10a6:208:5a::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR05MB4834; 6:91JD0v0MA10+yg4UaYjq0Mt9GfwZkxTAdMdXxuWF7KcugGQDyJlnlMLEoMjq17sDO+TjTqVmAlgyoYnmsR7G4uID9vrJ5F6wC14UG5wgMvlZ39zwZD47Jt9oFvlqQcrmup17cfIFsQ15rfwiqWt7Z6sP2fjlmKG0boUHsMmkA6cBEyJo1sUotaIvhpUMOaA0yE1n2DqM3aZo9iXVhdb175VTX7DPfLpjG8Ycf+mEg+busVvuox4JyMZu2gfXp6Mfqk8HpcFulo1uuZdPjNs5yazMs/Fi6g+Rya6Z6mZI9O87qkpYAh5yyL8cGVyxERxOSw7Z5XlUWvi4B8/sS5++bx9W5W9nWQxIAEVgRben8Vog6WinY5GeGgjYCFVBuQ7ktCV+gHnOLq0jLxjefeOON5XiCkIvuqq+rqtpgSgzMX312ASUpQ3qPwYMQJNUv/TnJhLni+5ka2BiiNXGpyLBRg==; 5:WjxLqBnJ50IM3HF8kCZPAQnTkhT8GvJwb6prb0yJ+g9pluxHFUh32POQq3gQhhOQk74U+A6EgbkQWiUff8xNlQ5BEncOXbQJqchz0Z03OHUkRZYvb6Lo7dyoCtZ0NoLzDgZNQrn7r5dl/c6IohNWX7eDrvU6A1JwTVmo122bfGs=; 7:3dGOxKehnCheV6eSz0E5PGsqkhOX2hopuLilQE7FMxNiDyY54nnhLKBmc0AWXDS8jMwuIVjnTaXi6zUboSyqUT96iCqXUA05P0N3PFYFg4JoS3oDgQwvBJnSwobT65DE+Y1AWmBdRxl1PVQQ4Rpc6ChSOmb0r6VVK2Jujqtw99g/xmqtmBMhUD7lTr9N7NyPc3e1KLSUqDYusi6PPStz1+PDWRGVswa/VlD/YCKazi85kIYk2P3JS34Pe/7lqLq9 x-ms-office365-filtering-correlation-id: 2003c0b1-cd10-4249-2219-08d62ebec3ca x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR05MB4834; x-ms-traffictypediagnostic: AM0PR05MB4834: 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)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051); SRVR:AM0PR05MB4834; BCL:0; PCL:0; RULEID:; SRVR:AM0PR05MB4834; x-forefront-prvs: 08213D42D3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(376002)(366004)(346002)(39860400002)(199004)(189003)(2906002)(107886003)(68736007)(25786009)(5250100002)(99286004)(105586002)(66066001)(8676002)(6862004)(81166006)(81156014)(478600001)(14454004)(6486002)(256004)(4326008)(54906003)(6436002)(37006003)(14444005)(106356001)(8936002)(7736002)(71200400001)(71190400001)(97736004)(5660300001)(186003)(53936002)(305945005)(2900100001)(6506007)(36756003)(386003)(486006)(2616005)(476003)(316002)(446003)(11346002)(52116002)(102836004)(6636002)(86362001)(6512007)(3846002)(6116002)(26005)(76176011)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4834; H:AM0PR05MB4435.eurprd05.prod.outlook.com; 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) x-microsoft-antispam-message-info: 0gjiGDpXLOBNT7W1UwCDuuJ2MAU5XVhmSL2D5t7f6Rnqb31Vw48+Qf1X1XdU8RFVqlt8zQ3qXuB+lecehnfls5RIaaxNj1jMJ9UUglJc7U97paA7nOTAUzxL8YShWcj+3Gdzu4VsqJAOTimz285+vkHJJ2WIF4jx6hPEv6zCxNtD9D8hC34LvQWFHiCcTd1Ze6mD46K8OEDCvSVcPaJtgcYHxeGcKG4EJf7ERZWUI7350K4USEnXxrMPQGbyAOnlWPYJtNkLdTMcezfq99spbWvdscLYll6w2kfv2Wd2LIi8+BHzyhInaklRXvQikkq1BvktRbwrZpz9sVJX5jQJ/EXX3JCb5oAdduUr2ztdEQY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2003c0b1-cd10-4249-2219-08d62ebec3ca X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2018 14:43:39.0127 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4834 Subject: [dpdk-dev] [PATCH v3] 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: Wed, 10 Oct 2018 14:43:40 -0000 This patch adds support for offloading flow rules with TCP-flags filter to mlx5 eswitch Hardwrae. With mlx5 it is possible to offload a limited set of flow rules to the mlxsw (or e-switch) using the DPDK flow commands using the "transfer" attribute. This set of flow rules also supports filtering according to the values found in the TCP flags. This patch implements this offload capability in the mlx5 PMD under transfer attribute. Signed-off-by: Moti Haimovsky --- v3: Changes according to review inputs. * Modified commit header. * Modified mason build to resemble the changes in Makefile. * Corrected TCP flags default support mask. v2: * Code rebase on latest upstream updates. --- drivers/net/mlx5/Makefile | 10 ++++++++++ drivers/net/mlx5/meson.build | 4 ++++ drivers/net/mlx5/mlx5_flow.c | 12 +++++++++++- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 3 ++- drivers/net/mlx5/mlx5_flow_tcf.c | 26 ++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 3 ++- 7 files changed, 54 insertions(+), 5 deletions(-) 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/meson.build b/drivers/net/mlx5/meson.build index fd93ac1..f562f30 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -180,6 +180,10 @@ if build 'TCA_FLOWER_KEY_VLAN_PRIO' ], [ 'HAVE_TCA_FLOWER_KEY_VLAN_ETH_TYPE', 'linux/pkt_cls.h', 'TCA_FLOWER_KEY_VLAN_ETH_TYPE' ], + [ 'HAVE_TCA_FLOWER_KEY_TCP_FLAGS', 'linux/pkt_cls.h', + 'TCA_FLOWER_KEY_TCP_FLAGS' ], + [ 'HAVE_TCA_FLOWER_KEY_TCP_FLAGS_MASK', 'linux/pkt_cls.h', + 'TCA_FLOWER_KEY_TCP_FLAGS_MASK' ], [ 'HAVE_TC_ACT_VLAN', 'linux/tc_act/tc_vlan.h', 'TCA_VLAN_PUSH_VLAN_PRIORITY' ], [ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h', diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ed60c40..74e7251 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1226,6 +1226,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev= *dev, int32_t priority, * Bit-fields that holds the items detected until now. * @param[in] target_protocol * The next protocol in the previous item. + * @param[in] flow_mask + * mlx5 flow-specific (TCF, DV, verbs, etc.) supported header fields mas= k. * @param[out] error * Pointer to error structure. * @@ -1236,9 +1238,17 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_de= v *dev, int32_t priority, mlx5_flow_validate_item_tcp(const struct rte_flow_item *item, uint64_t item_flags, uint8_t target_protocol, + const struct tcp_hdr *flow_mask, struct rte_flow_error *error) { const struct rte_flow_item_tcp *mask =3D item->mask; + const struct tcp_hdr default_mask =3D { + .src_port =3D RTE_BE16(0xffff), + .dst_port =3D RTE_BE16(0xffff), + }; + const struct rte_flow_item_tcp nic_mask =3D { + .hdr =3D flow_mask ? *flow_mask : default_mask, + }; const int tunnel =3D !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); int ret; =20 @@ -1261,7 +1271,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev= *dev, int32_t priority, mask =3D &rte_flow_item_tcp_mask; ret =3D 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.h b/drivers/net/mlx5/mlx5_flow.h index 12de841..da114ca 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -314,6 +314,7 @@ int mlx5_flow_validate_item_mpls(const struct rte_flow_= item *item, int mlx5_flow_validate_item_tcp(const struct rte_flow_item *item, uint64_t item_flags, uint8_t target_protocol, + const struct tcp_hdr *flow_mask, struct rte_flow_error *error); int mlx5_flow_validate_item_udp(const struct rte_flow_item *item, uint64_t item_flags, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_d= v.c index 3bb462c..b878cc0 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -180,7 +180,8 @@ break; case RTE_FLOW_ITEM_TYPE_TCP: ret =3D mlx5_flow_validate_item_tcp(items, item_flags, - next_protocol, error); + next_protocol, + NULL, error); if (ret < 0) return ret; item_flags |=3D tunnel ? MLX5_FLOW_LAYER_INNER_L4_TCP : diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_= tcf.c index 91f6ef6..22b23a4 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 HAVE_TCA_FLOWER_KEY_TCP_FLAGS +#define TCA_FLOWER_KEY_TCP_FLAGS 71 +#endif +#ifndef HAVE_TCA_FLOWER_KEY_TCP_FLAGS_MASK +#define TCA_FLOWER_KEY_TCP_FLAGS_MASK 72 +#endif =20 #ifndef IPV6_ADDR_LEN #define IPV6_ADDR_LEN 16 @@ -204,6 +210,7 @@ struct tc_vlan { .tcp.hdr =3D { .src_port =3D RTE_BE16(0xffff), .dst_port =3D RTE_BE16(0xffff), + .tcp_flags =3D 0xff, }, .udp.hdr =3D { .src_port =3D RTE_BE16(0xffff), @@ -626,8 +633,11 @@ struct flow_tcf_ptoi { return -rte_errno; break; case RTE_FLOW_ITEM_TYPE_TCP: - ret =3D mlx5_flow_validate_item_tcp(items, item_flags, - next_protocol, error); + ret =3D mlx5_flow_validate_item_tcp + (items, item_flags, + next_protocol, + &flow_tcf_mask_supported.tcp.hdr, + error); if (ret < 0) return ret; item_flags |=3D MLX5_FLOW_LAYER_OUTER_L4_TCP; @@ -1289,6 +1299,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, diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flo= w_verbs.c index 6964476..3d68f8b 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -1057,7 +1057,8 @@ break; case RTE_FLOW_ITEM_TYPE_TCP: ret =3D mlx5_flow_validate_item_tcp(items, item_flags, - next_protocol, error); + next_protocol, + NULL, error); if (ret < 0) return ret; item_flags |=3D tunnel ? MLX5_FLOW_LAYER_INNER_L4_TCP : --=20 1.8.3.1