From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20051.outbound.protection.outlook.com [40.107.2.51]) by dpdk.org (Postfix) with ESMTP id 9A5234C93 for ; Tue, 9 Oct 2018 15:08: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=Ps/IDErRAIfK55ZNAKYKPIxpX9kI8l/SOzdifDfAh4A=; b=EXe4kkF10yb0TakyobqGZaOpL9ykP3hf21DiIC0PFXUoZPEErH/nxzoiaDaxX21BbKq+3MwSMCvh/P9d7+OskzUo8h2cXmD4glVAJUfh9H/wovh1uTmjv9zmE0VaZGC81Na3Aks60BNji9jHkoLG3JtryALr0jzZ1CcXv5XfRPM= Received: from VI1PR05MB4431.eurprd05.prod.outlook.com (52.133.13.26) by VI1PR05MB4926.eurprd05.prod.outlook.com (20.177.51.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.23; Tue, 9 Oct 2018 13:08:39 +0000 Received: from VI1PR05MB4431.eurprd05.prod.outlook.com ([fe80::80:564f:9ae9:ed9]) by VI1PR05MB4431.eurprd05.prod.outlook.com ([fe80::80:564f:9ae9:ed9%2]) with mapi id 15.20.1207.024; Tue, 9 Oct 2018 13:08:39 +0000 From: Shahaf Shuler To: Mordechay Haimovsky CC: "dev@dpdk.org" Thread-Topic: [PATCH v2] net/mlx5: support e-switch TCP-flags flow filter Thread-Index: AQHUX8GvEAzfQhnoFkak0CSz0jQ78qUW3hxQ Date: Tue, 9 Oct 2018 13:08:39 +0000 Message-ID: References: <1536834644-16891-1-git-send-email-motih@mellanox.com> <1539083548-23240-1-git-send-email-motih@mellanox.com> In-Reply-To: <1539083548-23240-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: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB4926; 6:LhfhFUv03eQ8ndWFxkzo1YayR0DuyLCIi7gG3QGgKSwhxSoVqGiYk6hXQboLmkgP27paRpyS3BUGtHt+WDVtDLmpwcj9G/+B6kN5beuLuEWj20Z3fOvjAzRqfaKlUdlumha8xGQC7xKuVay/g7alLAIr4LU7cFRRayDPCu0JGqh6PuEVJ9eAZwZrNpeFh5jdj4MuDC3LecorZUY5hiHu81G/zqupojrJ1AABC23fAJQBevb7k7RyNF+Sc2rpCeTaJijRbsvCeYXz8mMnc7gduUzIXR9Bmdf6N+6m1UyNi/qp1/ES1lXzvqTdQusfDz5QXUbf5OcTDQVmp4JBpyroVZOEg52g7/pytrtWH/COZ6NqZ+Eb3cSbOJ8HI8uYzY5YDG5nqXW7b/du/1WPS0myg6MhULRE41HGfgQpMKWneS90heyhZFhr85thrap7mPbrDltzVXgN2clxpE8U2wq+bA==; 5:dQ/Cdb7tfZPqkXi3KXBSt99KyOjwxu0ZXYurTH1HyneoFg60a6Cc9oILDz3kfJENbzA6D1T99Xa6OCJ20LTVJQXkxlVEaIqDTEB7txgzfv6K1IbRrcNxjY7fUuFENWx5S/wIUCxc22P3LtptiDIfTF31UYRTn+Y8fuUaQNHndgg=; 7:b0rfXpOUnkZRaCGCqKgCoTRUcf1opcBlcvuFr9NbFhVKnYiTTqit9XvI0o0Za9+ac7jmtQ/nYxqi9Gwolix2m2vNkEqYmSzyrToU5P614lZ53i1OTMATWOYfSxS0WS20lQ49c971mSbKYOG5OB4JNfJ2R2lU2uJxBKB3hj1I5lybJ5GG3xAgMNW7ru0RMcb5oVwY2w2zqldtEX6OISXHQYEVS0vqZXs5m5tPglizwL517uh6pU+KhduIih+qsHMh x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 799d270c-813e-4705-772d-08d62de854a3 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:VI1PR05MB4926; x-ms-traffictypediagnostic: VI1PR05MB4926: 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)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051); SRVR:VI1PR05MB4926; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4926; x-forefront-prvs: 08200063E9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(366004)(136003)(346002)(199004)(189003)(229853002)(2906002)(14444005)(256004)(14454004)(97736004)(486006)(11346002)(446003)(5660300001)(476003)(66066001)(6506007)(478600001)(26005)(316002)(186003)(5250100002)(86362001)(71190400001)(71200400001)(68736007)(105586002)(2900100001)(102836004)(76176011)(53936002)(3846002)(74316002)(8936002)(6636002)(305945005)(33656002)(8676002)(81166006)(81156014)(7736002)(55016002)(6246003)(9686003)(25786009)(106356001)(6436002)(6116002)(6862004)(4326008)(7696005)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4926; H:VI1PR05MB4431.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: EcvU4ldC9HDS0Vy5+JjSHZoln2+PGeG1XONOfKZLsSwYgxS8wK8UoIuDI9qeckJkieXOUkGAtbwZj7RZYFlwwdPoWXPrHC5Dkk6rUWDU2vnjt82Knt78mrlQUxoDNuwTsUlAKbAoPB/VctbRlR74PJ8NQHrrCRLZkWX/IbyW6V3m02K4wv/A4q4b/Wo2Jgebrp8WbrA+WwJplv1J1eZCj5UAtaWWzMOrG0g4nMvu3a8Oo5rnGjsYdTLNjXf0L2PeeMsVJob73m1r9YuMXKitNvpLTLfZMm+XyFWgXJJFPJlYgGSebWRuAjqvDtjRcElTJaEulyEnLOd3gm4zzUvAILxFEla8841WHUrS4+bcYPQ= 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: 799d270c-813e-4705-772d-08d62de854a3 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Oct 2018 13:08:39.4384 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4926 Subject: Re: [dpdk-dev] [PATCH v2] 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: Tue, 09 Oct 2018 13:08:40 -0000 Hi Moty,=20 Please see few comments.=20 Tuesday, October 9, 2018 2:18 PM, Mordechay Haimovsky: > Subject: [PATCH v2] 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 hardware. Hardware. >=20 > 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 t= he mlxsw > (or e-switch) using the same DPDK flow commands. This part Is not needed. You can say it is supported only under the transfe= r attribute.=20 > A 'transfer' attribute was added to the flow rule creation command in ord= er > to distinguish between configuring port flows and E-switch flows. > The commands destined for the switch are transposed to TC flower rules an= d > are send, as Netlink messages, to the mlx5 driver, or more precisely to t= he > netdev which represents the mlxsw port. No need for the last phrase. Just say that this patch implement the TCP fla= gs under the transfer attr.=20 > 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 capabil= ity in > the mlx5 PMD. >=20 > Signed-off-by: Moti Haimovsky > --- > v2: > * Code rebase on latest upstream updates. > --- > 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(-) >=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 -- '$<' '$@' \ Need to update also meson.build file.=20 > 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 ed60c40..c3dd060 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -1239,6 +1239,13 @@ uint32_t mlx5_flow_adjust_priority(struct > rte_eth_dev *dev, int32_t priority, > struct rte_flow_error *error) > { > const struct rte_flow_item_tcp *mask =3D item->mask; > + const struct rte_flow_item_tcp nic_mask =3D { > + .hdr =3D { > + .src_port =3D RTE_BE16(0xffff), > + .dst_port =3D RTE_BE16(0xffff), > + .tcp_flags =3D 0xff, > + }, > + }; This validate function for TCP is shared between verbs, TC and DV flow engi= nes. The addition of the tcp_flags in this function would mean that verbs/dv als= o support such filtering, while it is not the case today.=20 Maybe you should have different TCP validate function for tcf.=20 > const int tunnel =3D !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); > int ret; >=20 > @@ -1261,7 +1268,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_tcf.c > b/drivers/net/mlx5/mlx5_flow_tcf.c > index 91f6ef6..d39ec2b 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), > @@ -1289,6 +1296,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, > -- > 1.8.3.1