From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0068.outbound.protection.outlook.com [104.47.2.68]) by dpdk.org (Postfix) with ESMTP id C9B1A1B17D for ; Thu, 11 Oct 2018 07:22:33 +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=ioLPDLyG8rMbHsHtLAG99u0+LI6eouE8XNSvuWFbQfQ=; b=IENKQVFz21PPzFR1Y73YJ7ELOqI2VpexfJ7Nq37eKJyeHaV7zX9X2RX0PqYLkfV3LtkNxV/E2kAvduGNA86GmjTFkHWRJSPg/GN8afxCuVNk3eGPwlxUMHymBQkJ+BfD+mMMPr/X6YVD9fyZUxCq0FLGd/HepjOfBfWg/jxYC2U= Received: from DB7PR05MB4426.eurprd05.prod.outlook.com (52.134.109.15) by DB7PR05MB5306.eurprd05.prod.outlook.com (20.178.42.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.21; Thu, 11 Oct 2018 05:22:32 +0000 Received: from DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::80e:e6b:baf2:d973]) by DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::80e:e6b:baf2:d973%3]) with mapi id 15.20.1228.020; Thu, 11 Oct 2018 05:22:32 +0000 From: Shahaf Shuler To: Mordechay Haimovsky CC: "dev@dpdk.org" Thread-Topic: [PATCH v3] net/mlx5: support e-switch TCP-flags flow filter Thread-Index: AQHUYKeimEL6I6nwFkGtXzRZ5soQK6UZgcRw Date: Thu, 11 Oct 2018 05:22:32 +0000 Message-ID: References: <1539083548-23240-1-git-send-email-motih@mellanox.com> <1539182589-10533-1-git-send-email-motih@mellanox.com> In-Reply-To: <1539182589-10533-1-git-send-email-motih@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-originating-ip: [31.154.10.105] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR05MB5306; 6:L4bCKjYrunV7vDwakdMZs5P1qG+beWIqiemooEol5MWX4kIL0UPqYPqx3XUbLgntJHizEjYaN0aHKMcnCcjPSMLDTyFTySUWD4MPkhG92Sop/fDvfi2D69dO2SpCGxTycD9jQJmZDLz8DgKYRLnIn7975l6vpSX3wXoCCKiLAbfWJrdj8R4BAqK2Q1DFagM7XlR3vfBf2MC/s3QxkK3vPCLK4TV4WQlXHNhxuGIeRG7w9OGGTL4JLxR4GlrjZdev+iHDO0CMS6UlVzgTntqdNt5wLGPFBoWwtGbWG015n+h54MaZSFUyv3AKhFE55XMlhVnWrtsMOeYwYIQFGNzGRHemXunGpq0Fnu+HhFqabdjQWDyYaoY6Nsv6BHWHX1kJ8LIBQJYIUDsjdXA4a+W3gUc3vsD0TvPgwP7CBhS5UmGRISRzJV3Qx9OjtvrIerNUct/HZlcisGK/9RtjJ4zBXg==; 5:QDrpy5ses7i2ismF5oH2HRoiX00DJU02y19M8INYvPE4Nqx8FVbmx0mhh2DWn3ayxNawiVlzV1SmJE9m0aeqcFcLsF9SfL1YHKVrjs6J06vn4rVtganGNs/AdlHWhIaP/7Lnq4pusy+KqyrVVdbugHc8g6DcHeMSsSrjnyGGI24=; 7:77zvZpPzCE9xpoUN4WGGaTligIXVzg6s2nOOyJusPwRs/NXnaCgubKbHYFYincIzddNwQj0KIm1RMPlxXb9XjkldvD/IYIGpbta8phpNJ2YlSbdNviUX4LFUpR2U/4v231rd5dAhD5gSiS6RNaMQqU43RGrWRvhlOEg8nl8lZdPeFqzmb0hRK4NvukS5Gnab+NRFYc4MQUeWw85epsMHgSPZUIHLIjBwJ8iQKNUAZcW+hT6sh7e6FBDXPAZUftln x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: d5d69fb8-c8ce-4cdf-541e-08d62f398bf6 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:DB7PR05MB5306; x-ms-traffictypediagnostic: DB7PR05MB5306: 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)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(201708071742011)(7699051); SRVR:DB7PR05MB5306; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB5306; x-forefront-prvs: 08220FA8D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(136003)(396003)(39860400002)(189003)(199004)(2906002)(26005)(71190400001)(71200400001)(33656002)(486006)(9686003)(7736002)(106356001)(105586002)(55016002)(53936002)(6862004)(305945005)(186003)(478600001)(81166006)(74316002)(102836004)(256004)(3846002)(81156014)(14444005)(6246003)(2900100001)(6116002)(8676002)(86362001)(6436002)(76176011)(14454004)(446003)(8936002)(97736004)(316002)(7696005)(11346002)(5660300001)(66066001)(4326008)(25786009)(6506007)(5250100002)(68736007)(476003)(99286004)(6636002)(229853002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB5306; H:DB7PR05MB4426.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: KEnXfKPOl+m/sdD+qMmYkpPcLNwnLx+6LvIo0cJIUUauUxsQBCR77f9PECTXaCOh/rLPLVastEq8G7GELLm1N4RtnBXWAB2rGKvso9bcPQBRudoIwl9sfIe0Xgs9uqDS8aA5iy8R8UzUzNTivEcn0fB4lMnJwAwcPD5IE0jcO8eEBDdfmj8ZjVmPhUQ5nO8pmpWLoJ97Hk58Rxa5RzQVqJHu/kEu4GlpZUdga6IScrdnfuzgln9t28Syf8hSXs9E2AzAWclB1u/qyKs/ZFgs/HJt21BHtZWwCD9XNC00R9iTzRs6mKIJTAXXjhfspJKHZ3jtJwZ6AVB6i1l+HjeQh7YVIFZoHwoOZ+MZOAvx6xg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5d69fb8-c8ce-4cdf-541e-08d62f398bf6 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2018 05:22:32.6540 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB5306 Subject: Re: [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: Thu, 11 Oct 2018 05:22:34 -0000 Hi Moti, Wednesday, October 10, 2018 5:44 PM, Mordechay Haimovsky: > Subject: [PATCH v3] net/mlx5: support e-switch TCP-flags flow filter >=20 > This patch adds support for offloading flow rules with TCP-flags filter t= o mlx5 > eswitch Hardwrae. >=20 > With mlx5 it is possible to offload a limited set of flow rules to the ml= xsw (or > e-switch) using the DPDK flow commands using the "transfer" attribute. Th= is > set of flow rules also supports filtering according to the values found i= n the > TCP flags. > This patch implements this offload capability in the mlx5 PMD under trans= fer > attribute. >=20 > 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. >=20 > 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(-) >=20 > 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 m= ask. > * @param[out] error > * Pointer to error structure. > * > @@ -1236,9 +1238,17 @@ uint32_t mlx5_flow_adjust_priority(struct > rte_eth_dev *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, This is not what I meant.=20 Have a look on the different flow engines we have. To validate TCP each one= of them is calling the general, fits all, mlx5_flow_validate_item_tcp. if = there is a specific, engine unique, logic for the validation it=20 Is done after it. See example on the TCF engine. The same should be with the TCP flags. The mlx5_flow_validate_item_tcp rema= ins the same as today, just checks the common stuff.=20 The verbs and dv flow engine should have an extra check after it that the T= CP flags are not part of the mask.=20 The TCF should not check it, as it is supported.=20 =20 > 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_dv.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 { >=20 > 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_flow_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 : > -- > 1.8.3.1