From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0047.outbound.protection.outlook.com [104.47.1.47]) by dpdk.org (Postfix) with ESMTP id 40E6D2C36 for ; Wed, 3 Oct 2018 09:07:27 +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=ZlLuIF56nk4WHod1pGRPjv0Bain81/0E3W0g0K2T7jI=; b=WZHZ/FDnxcPN1bKsPnzYwIpQqK3QVw+pKbJ3HETr5cWTP2FHoXNe37j/sdk2d5CxtcKvZIav/DLPbm3IpykQuYuAIIapLkVmCkgB01qw6pqH9xrzmcF9dJTdDOWyh899gRJ2zyv5GwE0JrsxZkebVO9Gps9UIzhYZpURmxLHKFw= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4009.eurprd05.prod.outlook.com (52.134.72.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.23; Wed, 3 Oct 2018 07:07:25 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::1cb0:661b:ecab:6045]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::1cb0:661b:ecab:6045%2]) with mapi id 15.20.1185.024; Wed, 3 Oct 2018 07:07:25 +0000 From: Yongseok Koh To: Dekel Peled CC: "dev@dpdk.org" , Shahaf Shuler , Ori Kam Thread-Topic: [PATCH 4/4] net/mlx5: add DV decap L2 and L3 operations Thread-Index: AQHUVnHatD2FhSjIxkSaFXDPkTqwwKUNIoyA Date: Wed, 3 Oct 2018 07:07:25 +0000 Message-ID: <20181003070716.GA21743@mtidpdk.mti.labs.mlnx> References: <1538059845-35896-1-git-send-email-dekelp@mellanox.com> <1538059845-35896-5-git-send-email-dekelp@mellanox.com> In-Reply-To: <1538059845-35896-5-git-send-email-dekelp@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN6PR0102CA0009.prod.exchangelabs.com (2603:10b6:805:1::22) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB4009; 6:gj1Qk5oQqKMvKif3+VWPuKpqBnlRqjaZOoBBxpqGzar20GfHp+7+yONeZpkD52DKQOlznrCsDUauCWG4PFO2u84S7CIkN/5iuXaApGKWPmMek1zE+PcTkdCzx8MmHUaeIv2wwVc5Fz8pLQFprQE8M3YERqiwGUFaAJ+qqA/zYExBLBrl0SnWn1gxgbzDZeyhYQhsP8FI/pv7KsWBN1rMa058yKyyWtQJwKmA5fx5FY6kWiqNWQCzR7va6m0rSpchdyHGyfXCfoN0mafqP0blSt49Cawg4/Q7gQewUwmTAYr7M+BY/KCQl/KehQJFz+7n9g3w2BCZrb+QAnPDppBn28zZ3D0Nahv4XCxwCp1dbywuHj8ruPASNlJkDNRHcyLOJMAld1hSof3or9YdEv/HHtiWezdEH3eIPozPICNQ6v/Xfbqmp/a13ZT8iHwh8z5M7rBM7HjPFHY/6tSbzMSbMg==; 5:ArkOZDD6Fc+yWhdAxvtRQRARwsEDlROwcCsD37STJVh43IjR+ZFzpf6WBQGlA6MCduTgD8bBk7UDVmEZlou/XCAYaDF7OhnCl8FPTDOoqLaovD4NJCDPINCLxEvuS911Q7XUBOLVyFgk5TSnsYY7FU+tsWMacHGSTemX7+sff2Y=; 7:hoFJvgqSnhVVwcAETRFmO8dtrghYmbhI+XhaxQVqKZXMSnqS7zf8yaH0pQLP1xZPW+yB7TxKSN9eKJdV114upfjSiMc6MgeoVZ7nSRbP9Tb5QyLMDA932yVLvpsJOBAAFRAweEu3OWuPYvNxyouhojLn50mt1m7boPVO7yATlQaH2Ta7Keux6cce3g6Av4PKgiCW6LwvbBDDgPmre+RwFcIoeok5XsjjMHPE+vPUordDLcA1SqV1OBy32F3WBZm7 x-ms-office365-filtering-correlation-id: 49d08815-4ce5-4ea8-7d87-08d628fedf37 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:DB3PR0502MB4009; x-ms-traffictypediagnostic: DB3PR0502MB4009: 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)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051); SRVR:DB3PR0502MB4009; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4009; x-forefront-prvs: 0814A2C7A3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(376002)(346002)(136003)(199004)(189003)(446003)(14444005)(256004)(11346002)(8676002)(478600001)(106356001)(54906003)(6486002)(476003)(486006)(229853002)(6436002)(71200400001)(5250100002)(2906002)(71190400001)(316002)(1076002)(2900100001)(6116002)(3846002)(6862004)(4326008)(6246003)(81166006)(8936002)(81156014)(105586002)(107886003)(68736007)(33656002)(97736004)(25786009)(14454004)(76176011)(9686003)(6512007)(52116002)(6636002)(26005)(5660300001)(386003)(33896004)(186003)(102836004)(53936002)(305945005)(99286004)(6506007)(86362001)(66066001)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4009; H:DB3PR0502MB3980.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: wGZyv7pbGhrHrRcn009FnmqyI9EG2Ww1EeQYhyph0ARmTlgbXh/31jC3cKSZ4t4KrG+9aDKj9nUdSoEozzyJrLQtE6Z9iYiyE2/aQ3+CZfCb87Xxxznuaaq9XamgPncge6MQ20CT0Xq6VEJhsOr0rz/YCCtzhxbZeLEAme5Kvk+Yt8TjXXI0HPxbXbGhPI9qqj300d2QOzBs4B9H+mb1dXGw10T3wkbk4q5Dv3DUwmvVGqORFLRRMijRyG4wDWZn4hvo2YQWHz8A8W5rr5KrJgij1FPJpvFjfpuoNgSqlpXhqqqL4VPpCtQQUfwPsecNEWh52EyM5yceJ/l1zDJ1ONSOYmYQ5n63ooGCqYPcVO4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <1ECEF28AF058494E9330E8165E47AD88@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49d08815-4ce5-4ea8-7d87-08d628fedf37 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Oct 2018 07:07:25.4786 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4009 Subject: Re: [dpdk-dev] [PATCH 4/4] net/mlx5: add DV decap L2 and L3 operations 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, 03 Oct 2018 07:07:27 -0000 On Thu, Sep 27, 2018 at 05:50:45PM +0300, Dekel Peled wrote: > This patch adds support for Direct Verbs decap operations, L2 and L3. >=20 Almost same code as encap, so I also have the same comments. :-) One more. In the title, we can't use vendor specific acronyms. net/mlx5: add DV decap L2 and L3 operations DV -> Direct Verbs How about something like this? net/mlx5: add L2/L3 encap to Direct Verbs flow > Signed-off-by: Dekel Peled > --- > drivers/net/mlx5/mlx5_flow_dv.c | 258 ++++++++++++++++++++++++++++++++++= ++++-- > 1 file changed, 248 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow= _dv.c > index 50925ac..ca44f13 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -126,12 +126,20 @@ > NULL, > "can't have 2 encap actions in same" > " flow"); > + if (action_flags & (MLX5_ACTION_TUNNEL_DECAP | > + MLX5_ACTION_TUNNEL_DECAP_L3)) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't encap and decap in same" > + " flow"); > if (attr->ingress) > return rte_flow_error_set(error, ENOTSUP, > - RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, > - NULL, > - "encap action not supported for " > - "ingress"); > + RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, > + NULL, > + "encap action not supported for " > + "ingress"); > return 0; > } > =20 > @@ -178,12 +186,130 @@ > NULL, > "can't have 2 encap actions in same" > " flow"); > + if (action_flags & (MLX5_ACTION_TUNNEL_DECAP | > + MLX5_ACTION_TUNNEL_DECAP_L3)) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't encap and decap in same" > + " flow"); > if (attr->ingress) > return rte_flow_error_set(error, ENOTSUP, > - RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, > - NULL, > - "encap action not supported for " > - "ingress"); > + RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, > + NULL, > + "encap action not supported for " > + "ingress"); > + return 0; > +} > + > +/** > + * Validate the tunnel decap action > + * > + * @param[in] action_flags > + * holds the actions detected until now. > + * @param[in] attr > + * Pointer to flow attributes > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_ernno is set= . > + */ > +static int > +mlx5_flow_validate_action_tunnel_decap(uint64_t action_flags, > + const struct rte_flow_attr *attr, > + struct rte_flow_error *error) > +{ > + if (action_flags & MLX5_ACTION_DROP) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't drop and decap in same flow"); > + if (action_flags & (MLX5_ACTION_TUNNEL_DECAP | > + MLX5_ACTION_TUNNEL_DECAP_L3)) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't have 2 decap actions in same" > + " flow"); > + if (action_flags & (MLX5_ACTION_TUNNEL_ENCAP | > + MLX5_ACTION_TUNNEL_ENCAP_L3)) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't encap and decap in same" > + " flow"); > + if (attr->egress) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, > + NULL, > + "decap action not supported for " > + "egress"); > + return 0; > +} > + > +/** > + * Validate the tunnel decap L3 action > + * > + * @param[in] action_flags > + * holds the actions detected until now. > + * @param[in] action > + * Pointer to the decap action. > + * @param[in] attr > + * Pointer to flow attributes > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_ernno is set= . > + */ > +static int > +mlx5_flow_validate_action_tunnel_decap_l3(uint64_t action_flags, > + const struct rte_flow_action *action, > + const struct rte_flow_attr *attr, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_action_tunnel_decap_l3 *tunnel_decap_l3 =3D > + action->conf; > + > + if (!tunnel_decap_l3 || !(tunnel_decap_l3->buf)) > + > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > + action, > + "configuration cannot be null"); > + if (action_flags & MLX5_ACTION_DROP) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't drop and decap in same flow"); > + if (action_flags & (MLX5_ACTION_TUNNEL_DECAP | > + MLX5_ACTION_TUNNEL_DECAP_L3)) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't have 2 decap actions in same" > + " flow"); > + if (action_flags & (MLX5_ACTION_TUNNEL_ENCAP | > + MLX5_ACTION_TUNNEL_ENCAP_L3)) > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "can't encap and decap in same" > + " flow"); > + if (attr->egress) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, > + NULL, > + "decap action not supported for " > + "egress"); > return 0; > } > =20 > @@ -257,6 +383,72 @@ > } > =20 > /** > + * Convert decap action to DV specification. > + * > + * @param[in] action > + * Pointer to action structure. > + * @param[in] ctx > + * Verbs context. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * Pointer to action on success, NULL otherwise and rte_errno is set. > + */ > +static struct ibv_flow_action * > +mlx5_flow_dv_create_decap(const struct rte_flow_action *action __rte_unu= sed, > + struct ibv_context *ctx, > + struct rte_flow_error *error) > +{ > + struct ibv_flow_action *decap_verb =3D NULL; > + > + decap_verb =3D mlx5_glue->dv_create_flow_action_packet_reformat(ctx, > + 0, NULL, > + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2, > + MLX5DV_FLOW_TABLE_TYPE_NIC_RX); > + if (!decap_verb) > + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "cannot create decap action"); > + return decap_verb; > +} > + > +/** > + * Convert decap L3 action to DV specification. > + * > + * @param[in] action > + * Pointer to action structure. > + * @param[in] ctx > + * Verbs context. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * Pointer to action on success, NULL otherwise and rte_errno is set. > + */ > +static struct ibv_flow_action * > +mlx5_flow_dv_create_decap_l3(const struct rte_flow_action *action, > + struct ibv_context *ctx, > + struct rte_flow_error *error) > +{ > + struct ibv_flow_action *decap_l3_verb =3D NULL; > + const struct rte_flow_action_tunnel_decap_l3 *decap_l3_data; > + > + decap_l3_data =3D > + (const struct rte_flow_action_tunnel_decap_l3 *)action->conf; > + decap_l3_verb =3D mlx5_glue->dv_create_flow_action_packet_reformat(ctx, > + decap_l3_data->size, > + decap_l3_data->size ? decap_l3_data->buf : > + NULL, > + MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2, > + MLX5DV_FLOW_TABLE_TYPE_NIC_RX); > + if (!decap_l3_verb) > + rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "cannot create decap L3 action"); > + > + return decap_l3_verb; > +} > + > +/** > * Verify the @p attributes will be correctly understood by the NIC and = store > * them in the @p flow if everything is correct. > * > @@ -529,6 +721,25 @@ > return ret; > action_flags |=3D MLX5_ACTION_TUNNEL_ENCAP_L3; > break; > + case RTE_FLOW_ACTION_TYPE_TUNNEL_DECAP: > + ret =3D mlx5_flow_validate_action_tunnel_decap > + (action_flags, > + attr, > + error); > + if (ret < 0) > + return ret; > + action_flags |=3D MLX5_ACTION_TUNNEL_DECAP; > + break; > + case RTE_FLOW_ACTION_TYPE_TUNNEL_DECAP_L3: > + ret =3D mlx5_flow_validate_action_tunnel_decap_l3 > + (action_flags, > + actions, > + attr, > + error); > + if (ret < 0) > + return ret; > + action_flags |=3D MLX5_ACTION_TUNNEL_DECAP_L3; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -1320,6 +1531,30 @@ > flow->actions |=3D MLX5_ACTION_TUNNEL_ENCAP_L3; > actions_n++; > break; > + case RTE_FLOW_ACTION_TYPE_TUNNEL_DECAP: > + dev_flow->dv.actions[actions_n].type =3D > + MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION; > + dev_flow->dv.actions[actions_n].action =3D > + mlx5_flow_dv_create_decap(action, ctx, error); > + if (!(dev_flow->dv.actions[actions_n].action)) > + return -rte_errno; > + dev_flow->dv.decap_verb =3D > + dev_flow->dv.actions[actions_n].action; > + flow->actions |=3D MLX5_ACTION_TUNNEL_DECAP; > + actions_n++; > + break; > + case RTE_FLOW_ACTION_TYPE_TUNNEL_DECAP_L3: > + dev_flow->dv.actions[actions_n].type =3D > + MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION; > + dev_flow->dv.actions[actions_n].action =3D > + mlx5_flow_dv_create_decap_l3(action, ctx, error); > + if (!(dev_flow->dv.actions[actions_n].action)) > + return -rte_errno; > + dev_flow->dv.decap_verb =3D > + dev_flow->dv.actions[actions_n].action; > + flow->actions |=3D MLX5_ACTION_TUNNEL_DECAP_L3; > + actions_n++; > + break; > default: > break; > } > @@ -1679,13 +1914,16 @@ > LIST_REMOVE(dev_flow, next); > if (dev_flow->dv.matcher) > flow_dv_matcher_release(dev, dev_flow->dv.matcher); > - Looks like it is a mistake on rebasing. > if (dev_flow->dv.encap_verb) { > claim_zero(mlx5_glue->destroy_flow_action > (dev_flow->dv.encap_verb)); > dev_flow->dv.encap_verb =3D NULL; > } > - > + if (dev_flow->dv.decap_verb) { > + claim_zero(mlx5_glue->destroy_flow_action > + (dev_flow->dv.decap_verb)); > + dev_flow->dv.decap_verb =3D NULL; > + } > rte_free(dev_flow); > } > } > --=20 > 1.8.3.1 >=20