From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60085.outbound.protection.outlook.com [40.107.6.85]) by dpdk.org (Postfix) with ESMTP id 117361B466 for ; Tue, 9 Oct 2018 13:17:38 +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=ki8WjY13BtkUuCmAOye+f3ng9VLm+glZ32UtBnNohtI=; b=O1H2PfK6YdkAUd684JdFYn6GuyGTEzs3Tx4PrqCTPr5xpso8TeTevcMr7TUALv3Qf/mJ8vPeR98JP+6WnPHeKnG9nNDrG0vEZQQxhc685OBMa6yMErmhuRNbaI7zaxTi7nUw/iwEK5KAZ7/XMkv2BAD2sCCgWWFF06PHcmiP9gQ= Received: from AM0PR05MB4435.eurprd05.prod.outlook.com (52.134.92.20) by AM0PR05MB4290.eurprd05.prod.outlook.com (52.134.91.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.26; Tue, 9 Oct 2018 11:17:37 +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; Tue, 9 Oct 2018 11:17:37 +0000 From: Mordechay Haimovsky To: Shahaf Shuler CC: "dev@dpdk.org" , Mordechay Haimovsky Thread-Topic: [PATCH v2] net/mlx5: support e-switch TCP-flags flow filter Thread-Index: AQHUX8Gu0yBi4QOj9EulAdKXB9vIJw== Date: Tue, 9 Oct 2018 11:17:36 +0000 Message-ID: <1539083548-23240-1-git-send-email-motih@mellanox.com> References: <1536834644-16891-1-git-send-email-motih@mellanox.com> In-Reply-To: <1536834644-16891-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: AM5PR0701CA0014.eurprd07.prod.outlook.com (2603:10a6:203:51::24) 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; AM0PR05MB4290; 6:r1s6KbB2OJbpKjPTh2ot8/Dr8CxpsSVRt7DQuUaZmuOeiO61FAFCcpitvJwWJIqgafEbi1qvgXJbW2H5DgkXshvhdNGc+XU6oSZ70+nzODMKPBazy06wtcibb0xeINdBpPQZw3AkxrItXko5LsRs/GeLMzlN5tojg8cPoEA9DrrS9wJCSBYRRNFF7+BUN7iep7clgkln+JFz6PohzD21Wk58MPCmAq5Xwu1Dizo1R6xoDIvSNorv0NDI+M+ESvQYfqbIkQxChXqBADaMzSwPGtEJSRGVQcTa+FvHNxJRu+2Uw/4BuKcJlBodw99AwnfYl+gZ2voCp2vJZCrohBf5ePP9cQdg0bBiiFLMh6u+7vsxlg7gjWYZDje1dbEmE50uDniXTIqytyyKWFYX56AuZ2O6u28Swmd2OpN1F8WblpnxJagEBlXDFD4Uuya5qRlkgKD5uDjA19x9LFkTNnmmjQ==; 5:z9BW5/ZiJsnw7CLNPsnXU+XJrejMo+macpo7dfcHejQx0oDr8CzszUwlkgEgpy1Yx8Ml8xPV4xlzUjq6XSKIyzHjdgXQkmr4zMGd03mjob2DaEma281o7i4n8Np7vUL4oUPexPgUNWfCfC952br324YmaSgEuEIgCjrUAmRJfRw=; 7:q0fBHaWQ4gWbMLa22SZYW71SRX3wrfzA4zrRcncQW1a9yWuUagZQZdISGsVq1tcB+61oFx5X7N4d/ROhs5VjxEXwdba5B9L9mcnTgmIP5U9piHqvLaaJDPsq88vRH/2jTPzl46WUvjkE02atjxMe97v4uoHjDKaKJ1gPIjl7uRaYfbbK5BM+LRDzcoU1Tn41Wf6OrUs0zAYuAX+2Pg4EAjqi6xyoLC9++Kc6gGgFVtxAEeUDRGEdPUnI4rhU0edF x-ms-office365-filtering-correlation-id: 109d6717-34e5-4bd1-97a1-08d62dd8d0f0 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:AM0PR05MB4290; x-ms-traffictypediagnostic: AM0PR05MB4290: 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)(3231355)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(201708071742011)(7699051); SRVR:AM0PR05MB4290; BCL:0; PCL:0; RULEID:; SRVR:AM0PR05MB4290; x-forefront-prvs: 08200063E9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(366004)(39860400002)(346002)(376002)(136003)(189003)(199004)(8676002)(6636002)(7736002)(8936002)(102836004)(14454004)(81166006)(446003)(2900100001)(305945005)(14444005)(81156014)(86362001)(186003)(256004)(71190400001)(4326008)(71200400001)(486006)(5250100002)(36756003)(26005)(68736007)(476003)(2616005)(11346002)(97736004)(478600001)(66066001)(386003)(6506007)(5660300001)(107886003)(6116002)(3846002)(53936002)(54906003)(99286004)(316002)(6862004)(52116002)(76176011)(106356001)(105586002)(6436002)(37006003)(6486002)(6512007)(2906002)(25786009)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4290; H:AM0PR05MB4435.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: YmeqtCDQr65jdrADD8CvxRDhgE8bCwkZnsghyTWBnG3FKGUkj8qRptga5/KXy8Y+o0PF9PC4vTS9d0LgOEiZyV9o96cT+WUioMac3rKF8OPXQSFGltt0NdhI9ZJFSmlm2SYXxbDCGRPs8vQKxCduY8e+SztgcMD0L9uJbeim70SUCZe71AxrwFe5QqADLmzy7EaH9gZ5KSD16wUlxOy72dw0qlA6oODb+8keLEf1gmyTZRIEUqhyS+wA1z9WBCRhiqQQ5uMO9F8BX05bvvDkoW5Jl+MQ7UTltRU49P4hRdzqOgDa+93ZGfmQSL2gwBeSlY73WIWupUM4Pa4muJW/zPGw+BwzL6fwpSyOoFTHQPY= 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: 109d6717-34e5-4bd1-97a1-08d62dd8d0f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Oct 2018 11:17:36.8733 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4290 Subject: [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 11:17:38 -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 represents 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 --- v2: * Code rebase on latest upstream updates.=20 --- 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 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_de= v *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, + }, + }; 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 { 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, --=20 1.8.3.1