From patchwork Mon Nov 12 20:01:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 48011 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB59E4F91; Mon, 12 Nov 2018 21:01:49 +0100 (CET) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80072.outbound.protection.outlook.com [40.107.8.72]) by dpdk.org (Postfix) with ESMTP id 8202E4CAD for ; Mon, 12 Nov 2018 21:01:42 +0100 (CET) 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=0GFiPvYzEK+eig+eqmYLPtjX+WHyeAFzRRH4/w5B/H8=; b=UuRV+8G+IRhKnCeny7xB9a2oXRqjV9wcLih6OwwJBs95EHWcV5DI3svOMexZtsJA0Un9NoPzQHA8bCliNKNmy3qs2NwaJ+ULOqyL2CcUriqSUMFqp+2E12yr56FHY/fQWqA6b0yoSZVdyKd6MZ+PFia+qvqujhF1WF0Q2tn9oKc= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3377.eurprd05.prod.outlook.com (10.171.187.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Mon, 12 Nov 2018 20:01:41 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::544b:a68d:e6a5:ba6e%2]) with mapi id 15.20.1294.044; Mon, 12 Nov 2018 20:01:41 +0000 From: Slava Ovsiienko To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" , Slava Ovsiienko Thread-Topic: [PATCH 3/4] net/mlx5: prepare to add E-switch rule flags check Thread-Index: AQHUesKH/8EtegG8bku1I0zT1VoLwQ== Date: Mon, 12 Nov 2018 20:01:41 +0000 Message-ID: <1542052877-41512-4-git-send-email-viacheslavo@mellanox.com> References: <1541225876-8817-2-git-send-email-viacheslavo@mellanox.com> <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1542052877-41512-1-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0161.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::29) To AM4PR05MB3265.eurprd05.prod.outlook.com (2603:10a6:205:4::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB3377; 6:oAvOEChN4nSDN8B7rUOATV7OJiJ1AD8EGxDES+t448+wylPfwaCXc8JGgtOc23Z5C0HExyBBJiPcw0EoAl2VD7D4UUYEXEab4M3DCT4t2uvYQHNt9cmWd1GOtFg3k9xyw2zi44ZwtLyj5eIS/awPZE595zSunB9F7jr88YGtGb2Ey8DxgPRIvRZfZSocB+JOD5kwmXxFnUG450JAncBHXwrFZPU/2wrqw9J8ZhaotMxVA8r2Og1SljLW99OPpgllnT2QeGzuLALslvdQoWnkGtmDSQBVigP9Big/3Wi3TUVy4B5UHE39pfbI7U7olMugHhtFSWjyD8sUsG84/lStI3Q3vVRnk3MCTeb+HTm+Wi6CodnkqXziAj8xXsZgeNzoHnwfduI/Va87B6BdCnGuInAW/PuHoqpmX2GqesyBro3toGtDZ/0S9EfciAzifcgCFvTPjf8j44QmZl6OEb+b5g==; 5:bURrn+WD9kvYEtenn/sr+2F1/mKlT3pCPMJ+KAcxvzr9xIwN19X0xibvU1z5AtsTHNLoZEANLK4bsTndlzsgy01JdzO27EhUVhpDnZ5ZgeRwZG1rmdMCHo2EyXCwFYkSZ4d8F9ssSLmNiBk6L8RhOFaH52wds7JbE1RZUsd4FiI=; 7:Grc2xBOCx1qU6p9u+AGhl6LCduPnZ1zlL2HSBrnsFHpPXvMJxgVfRspjp8R04PA2oh7WjcEWMjbeQYmeTd0Z4F3FAYQxHJ7sAXfAh37TxHUfMe5ncpymAIJweeS0lGNsJMuo9iAa8ut1/yc70UedDQ== x-ms-office365-filtering-correlation-id: 04aa70b1-30bc-4508-aa64-08d648d9a9b7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3377; x-ms-traffictypediagnostic: AM4PR05MB3377: 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)(10201501046)(3231382)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3377; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3377; x-forefront-prvs: 0854128AF0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(376002)(396003)(39860400002)(189003)(199004)(71200400001)(86362001)(71190400001)(97736004)(6486002)(446003)(478600001)(256004)(6636002)(14444005)(486006)(36756003)(2616005)(110136005)(54906003)(105586002)(68736007)(85306007)(316002)(25786009)(99286004)(2906002)(14454004)(106356001)(8676002)(102836004)(81166006)(107886003)(81156014)(2900100001)(6116002)(3846002)(66066001)(305945005)(7736002)(386003)(186003)(6436002)(53936002)(76176011)(6512007)(8936002)(4326008)(11346002)(5660300001)(6506007)(52116002)(476003)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3377; H:AM4PR05MB3265.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: T0D8f3e1o9+Yj2MXPjDljLhtbKMovmE1mTHCgppV8WPhiaZzb+m6/RXJQogoJJaWmiBvMEXDEejKCZxxM4hMYPyLjxNnDeo7XUeBEzruFZSp8FVJlYJmKCDSl9tQfSBh82xEzGigqdtznPdb22Q6wowS/A6IV5uSUeGBxtow7POAlTzr9Q6ctT4VQusS1tlrF5IMZUls6L4h1HunnRCdEGIUDa7P40ZdNqqJBAYUXN2F2tKHQ0tYyd4l397TmGIE/qabH32yuBjQlYRoU5Kqed4oDNSzXjBGheM1ka/yNkLv+r19Bb7VUr5vAfL4mQm653QCdUmeoYm9mRd39X1sLZxIzpFXDRVwBC0KK2F4d2Y= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04aa70b1-30bc-4508-aa64-08d648d9a9b7 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2018 20:01:41.5335 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3377 Subject: [dpdk-dev] [PATCH 3/4] net/mlx5: prepare to add E-switch rule flags check 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The tc flower filter rules are used to control E-switch from the application side. In order to gain garanteed rule hardware offload the skip_sw flag should be specified while applying the rule. But some tc rules is rejected by kernel if skip_sw flag is set by design. Currently this regards VXLAN tunneling rules, which are applied to special VXLAN virtual devices. Albeit these rules are applied with skip_sw flag reset kernel tries to perform hardware offload. If kernel succeeded the in_hw flag is set in rule properties and application should check this flag to get know whether the applied rule is actually hardware offloaded. This patch prepares for the rule flags query and check in_hw flag. The driver checks only the rules with skip_sw flag reset, so we need to test the actual flags of rule is being applied. The pointer to flags field into translated rule is introduced and flags are tested directly in the rule body. It is more reliable than save and check flags copy. Also patch swaps the flow_tcf_apply() and flow_tcf_remove(), we are going to call flow_tcf_remove() from flow_tcf_appy() if no in_hw flag set found in applied rule. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_tcf.c | 82 +++++++++++++++++++++------------------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 51ab47f..57b312e 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -219,6 +219,7 @@ struct mlx5_flow_dv { struct mlx5_flow_tcf { struct nlmsghdr *nlh; struct tcmsg *tcm; + uint32_t *ptc_flags; /**< tc rule applied flags. */ union { /**< Tunnel encap/decap descriptor. */ struct flow_tcf_tunnel_hdr *tunnel; struct flow_tcf_vxlan_decap *vxlan_decap; diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index 4d154b6..5bfb2d8 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -160,6 +160,9 @@ struct tc_tunnel_key { #ifndef TCA_CLS_FLAGS_SKIP_SW #define TCA_CLS_FLAGS_SKIP_SW (1 << 1) #endif +#ifndef TCA_CLS_FLAGS_IN_HW +#define TCA_CLS_FLAGS_IN_HW (1 << 2) +#endif #ifndef HAVE_TCA_CHAIN #define TCA_CHAIN 11 #endif @@ -3699,6 +3702,8 @@ struct pedit_parser { assert(na_flower); assert(na_flower_act); mnl_attr_nest_end(nlh, na_flower_act); + dev_flow->tcf.ptc_flags = mnl_attr_get_payload + (mnl_nlmsg_get_payload_tail(nlh)); mnl_attr_put_u32(nlh, TCA_FLOWER_FLAGS, decap.vxlan ? 0 : TCA_CLS_FLAGS_SKIP_SW); mnl_attr_nest_end(nlh, na_flower); @@ -5077,6 +5082,44 @@ struct tcf_nlcb_context { pthread_mutex_unlock(&vtep_list_mutex); } +/** + * Remove flow from E-Switch by sending Netlink message. + * + * @param[in] dev + * Pointer to Ethernet device. + * @param[in, out] flow + * Pointer to the sub flow. + */ +static void +flow_tcf_remove(struct rte_eth_dev *dev, struct rte_flow *flow) +{ + struct priv *priv = dev->data->dev_private; + struct mlx5_flow_tcf_context *ctx = priv->tcf_context; + struct mlx5_flow *dev_flow; + struct nlmsghdr *nlh; + + if (!flow) + return; + dev_flow = LIST_FIRST(&flow->dev_flows); + if (!dev_flow) + return; + /* E-Switch flow can't be expanded. */ + assert(!LIST_NEXT(dev_flow, next)); + if (dev_flow->tcf.applied) { + nlh = dev_flow->tcf.nlh; + nlh->nlmsg_type = RTM_DELTFILTER; + nlh->nlmsg_flags = NLM_F_REQUEST; + flow_tcf_nl_ack(ctx, nlh, NULL, NULL); + if (dev_flow->tcf.tunnel) { + assert(dev_flow->tcf.tunnel->vtep); + flow_tcf_vtep_release(ctx, + dev_flow->tcf.tunnel->vtep, + dev_flow); + dev_flow->tcf.tunnel->vtep = NULL; + } + dev_flow->tcf.applied = 0; + } +} /** * Apply flow to E-Switch by sending Netlink message. @@ -5145,45 +5188,6 @@ struct tcf_nlcb_context { } /** - * Remove flow from E-Switch by sending Netlink message. - * - * @param[in] dev - * Pointer to Ethernet device. - * @param[in, out] flow - * Pointer to the sub flow. - */ -static void -flow_tcf_remove(struct rte_eth_dev *dev, struct rte_flow *flow) -{ - struct priv *priv = dev->data->dev_private; - struct mlx5_flow_tcf_context *ctx = priv->tcf_context; - struct mlx5_flow *dev_flow; - struct nlmsghdr *nlh; - - if (!flow) - return; - dev_flow = LIST_FIRST(&flow->dev_flows); - if (!dev_flow) - return; - /* E-Switch flow can't be expanded. */ - assert(!LIST_NEXT(dev_flow, next)); - if (dev_flow->tcf.applied) { - nlh = dev_flow->tcf.nlh; - nlh->nlmsg_type = RTM_DELTFILTER; - nlh->nlmsg_flags = NLM_F_REQUEST; - flow_tcf_nl_ack(ctx, nlh, NULL, NULL); - if (dev_flow->tcf.tunnel) { - assert(dev_flow->tcf.tunnel->vtep); - flow_tcf_vtep_release(ctx, - dev_flow->tcf.tunnel->vtep, - dev_flow); - dev_flow->tcf.tunnel->vtep = NULL; - } - dev_flow->tcf.applied = 0; - } -} - -/** * Remove flow from E-Switch and release resources of the device flow. * * @param[in] dev