From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 175A7A00C4; Sun, 10 May 2020 12:48:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 718251C23E; Sun, 10 May 2020 12:48:36 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) by dpdk.org (Postfix) with ESMTP id 8CC751C1C8; Sun, 10 May 2020 12:48:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aKcN3paw6bZpuZXX77Id5M7BD2vJJ07JBLEefCI5VQFJk3sxJnStVdufip5ikEHNLS9I1Y02N3rq1pL6iJG5nLaB2UQ7oMf81Pg7qXaI0xjw+jXb6eRbMG+MISfBnR5ugiWJEO/nj6Fk4bwRnHRiN6Ceq6m+zlKOIU2fYXfPZozKVz4JdkMuokKKqotLaZc/PzIMM0ds+bY7mRBfNxPRddgpmYlv6RDInys/prGUHjXWWXdNi6wwcelgQ/qNOy6c1suSBXOk+Gp9Rj13zIjNn/01J3q4R0yoSU92VY9SM3XS5yeKFdfJviCBpoBSs3PImAw57CvtRQjNRgxYQF1jyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sB/c8xEfxcchhZN0DtESgLZT8QSBWAkgjCkgJSGgDvA=; b=PB8O3D6iW+7Gnnq+VIEVjN0EJVtHjE0mHCJFx9O+y8P35UaODxj6P4U8H1SqBFG5dWtT/ZN3cvJreO2vpI7a4s2xSD01AfRBiP5/3w12rG0rW7yqnF2vf84T5No1/Fhm6T2LAazIUenj43agbaJumw0UpbVac1fnOODPoGi/veRo/5d9I/QG9VJbCKbj7o/myQmi6PnN3jD9lVqv/kK2mpTE/PzaFj75DdHw1eHLRwBsJ9XeVEbtMqsgY6wdw/W+BYY/dqWqr8mHFXyBZ2P55wmln741ZqUF+5iiyld0ez958sI8a21nbJtUwauIyC5UJtg9bhe8DcN+zq9DJl0LJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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=sB/c8xEfxcchhZN0DtESgLZT8QSBWAkgjCkgJSGgDvA=; b=MrogxfiByVD85L5+zhL6vyS8xsi19kmgErEBAbErQZTHyAtiZSNtSvLn1UvoqEZ5F3oG2MnMnFuG79L7Xd3dimMMCB0eej05NoT8ypRyP9IjX4XGiTTdybPp1GyQnXiqBBv3zGUuvZ105N/ZcOeZirRpRWtObaCU5n9lvwc09Tg= Received: from AM0PR05MB6707.eurprd05.prod.outlook.com (2603:10a6:20b:15b::17) by AM0PR05MB6578.eurprd05.prod.outlook.com (2603:10a6:208:142::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Sun, 10 May 2020 10:48:33 +0000 Received: from AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e]) by AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e%5]) with mapi id 15.20.2979.033; Sun, 10 May 2020 10:48:33 +0000 From: Raslan Darawsheh To: Dekel Peled , Matan Azrad , Slava Ovsiienko CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] net/mlx5: fix match on empty VLAN item in DV mode Thread-Index: AQHWItzY1fXH05u1l0Gxb5JZnIXuj6ihK0ZQ Date: Sun, 10 May 2020 10:48:32 +0000 Message-ID: References: <851d6f105d060c15334220049b0e311ceeb774b2.1588683371.git.dekelp@mellanox.com> In-Reply-To: <851d6f105d060c15334220049b0e311ceeb774b2.1588683371.git.dekelp@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [188.161.229.217] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: ac53d7be-1bce-4da6-efa7-08d7f4cfaf33 x-ms-traffictypediagnostic: AM0PR05MB6578:|AM0PR05MB6578: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 039975700A x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ndjQizQVAK9BPvbNu/1JkU1ZMOfWkdjq40w37jdrpYgzl16NtbkF1rhxaODTYfjh3gPX0Ma7zQGsEUfF5EaDqzy7IkYHGFn1Ul6zVPSu66hN4Wo0q/zJZ1/naSBtZU8XVyqd3nopujTEPa+aPZ3QfsVpm1HDPKMWjwQtGNopCcDjjkRdabpmmj2WGlQfCKtmX55xRQaNedF5JbPZ7Y9uWJ7l0QrFQS8YuKm5pZOYA0d4lf/h5y5dWogqOoeTrZzjX5WdEilrMqCxIYCrRBCCigUeZgBZmy4MnniOpCY0qS3qHAn+0E42uWwB+IAiUM1wmqjW7ydwn0KEOn3oIT46b7A8LuNvD70Au2P1siGdsPPk3zPpmcfAwWCiO2ZP7Ish4wztLN1n7AN2fMEnnl/E+/GhSDWO5EkJQeFRu6yTwsdhpkSLeS/YN/W6g5g4EdHsDInkynGG6AxwLggVdObP4LyiUcwC4OQTXkw+8GB3bYN3lh9cGIWTfTo+1q62EYiJ7dZPTNJXqFxf/oBfM4DmIG94VWo6GvxyB9ZyFXiB9AVrPSBwSY+ccSbe/NT8Xfe8ZY9W/MnlA8hbKTxQ9vXWu6ZhSm8TQwOhO+AsrxTu+jE= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6707.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(376002)(366004)(346002)(33430700001)(33656002)(76116006)(54906003)(110136005)(316002)(66446008)(86362001)(8676002)(4326008)(7696005)(186003)(53546011)(966005)(6506007)(64756008)(52536014)(5660300002)(66476007)(26005)(66946007)(66556008)(71200400001)(83080400001)(2906002)(6636002)(45080400002)(8936002)(9686003)(33440700001)(450100002)(55016002)(478600001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: pHPWzJR1uvGzNOIacQgh028Fm1Asthe6v+e8OYNcMFWG5dRHJ4TwKc7CoKYWf8hSBm+9XksXaephMQzC6XER5LzDi4ImnIHngRxLj0XvS3weHkGRnTsaEud5F1PCCYsluDaWmjmWquNZJvdcLDxGdDXs4FZGyPvYmHi0nMyB/VeHqBRBxLYBhNBr94fPA8su3GJggoZ1HdcDUmJl+xPo1cekSSPP1uYdJrTHDVKqkFoSDUsgCVQRI3jSTCOWqVfYcyrpNQxsyRDE3tP2s/HkWt10Yb+JmXgQ52I53U9CTTTDzlFj/h9sfzihvKzYKLdDFgyeesKPRcDIhbOIUhQEp4sQMqjqhzuupHmkRJY7MLSv3c0JaWf0KdRytiLWYvqtQuL9LR748PLlCOBIqiPNCJ4yiLJiWR75Es1rcPzyKRZ5g2iAWSQinj/cvzyafuHZhAZmzostRbCfQz4C4+ZtMlbiwj93ReoKlRVdHnDAwhNx/FvSuZykjhFfEg+NhI2e 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: ac53d7be-1bce-4da6-efa7-08d7f4cfaf33 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 May 2020 10:48:32.9316 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bPPdYahA1SbPL5+KpR8eyTwRk2WIl8d9TQyjzY8kjD5bIN/xLUxljlGGHaG3vpvgSOAOrJA4Wr8nfrUun+fy2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6578 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix match on empty VLAN item in DV mode 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" Hi, > -----Original Message----- > From: Dekel Peled > Sent: Tuesday, May 5, 2020 3:58 PM > To: Matan Azrad ; Slava Ovsiienko > ; Raslan Darawsheh > Cc: dev@dpdk.org; stable@dpdk.org > Subject: [PATCH] net/mlx5: fix match on empty VLAN item in DV mode >=20 > In existing implementation, using wild card VLAN item is not allowed. > A VLAN item in flow pattern must include VLAN ID (vid) value. > This obligation contradics the intention of documentation update [1]. >=20 > This patch updates the VLAN item validation and translation, to allow > wild card VLAN item, without VLAN ID value. > User guide and release notes are updated accordingly. >=20 > [1] > https://eur03.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatch > es.dpdk.org%2Fpatch%2F69207%2F&data=3D02%7C01%7Crasland%40mell > anox.com%7Cb37fc86e5f16401fe17e08d7f0f3fa1b%7Ca652971c7d2e4d9ba6a > 4d149256f461b%7C0%7C0%7C637242802974204161&sdata=3DsTXABuuMC > 83mAuSoZGDgntPl1r4fspKNC4UhOnojmw4%3D&reserved=3D0 >=20 > Fixes: 00f75a40576b ("net/mlx5: fix VLAN match for DV mode") > Cc: stable@dpdk.org >=20 > Signed-off-by: Dekel Peled > Acked-by: Viacheslav Ovsiienko > --- > doc/guides/nics/mlx5.rst | 18 +++++++ > doc/guides/rel_notes/release_20_05.rst | 1 + > drivers/net/mlx5/mlx5_flow_dv.c | 98 > ++++++++++++++++++++++++++++++---- > 3 files changed, 107 insertions(+), 10 deletions(-) >=20 > diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst > index 0643592..fa93a75 100644 > --- a/doc/guides/nics/mlx5.rst > +++ b/doc/guides/nics/mlx5.rst > @@ -127,6 +127,24 @@ Limitations >=20 > Will match any ipv4 packet (VLAN included). >=20 > +- When using DV flow engine (``dv_flow_en`` =3D 1), flow pattern without > VLAN item > + will match untagged packets only. > + The flow rule:: > + > + flow create 0 ingress pattern eth / ipv4 / end ... > + > + Will match untagged packets only. > + The flow rule:: > + > + flow create 0 ingress pattern eth / vlan / ipv4 / end ... > + > + Will match tagged packets only, with any VLAN ID value. > + The flow rule:: > + > + flow create 0 ingress pattern eth / vlan vid is 3 / ipv4 / end .= .. > + > + Will only match tagged packets with VLAN ID 3. > + > - VLAN pop offload command: >=20 > - Flow rules having a VLAN pop offload command as one of their actions= and > diff --git a/doc/guides/rel_notes/release_20_05.rst > b/doc/guides/rel_notes/release_20_05.rst > index b90e117..60fff51 100644 > --- a/doc/guides/rel_notes/release_20_05.rst > +++ b/doc/guides/rel_notes/release_20_05.rst > @@ -144,6 +144,7 @@ New Features > * Removed flow rules caching for memory saving and compliance with > ethdev API. > * Optimized the memory consumption of flow. > * Added support for flow aging based on hardware counter. > + * Added support for flow pattern with wild-card VLAN item (without vid > value). >=20 > * **Updated the AESNI MB crypto PMD.** >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c > index aa5c353..5a0bb9d 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -1640,6 +1640,79 @@ struct field_modify_info modify_tcp[] =3D { > } >=20 > /** > + * Validate VLAN item. > + * > + * @param[in] item > + * Item specification. > + * @param[in] item_flags > + * Bit-fields that holds the items detected until now. > + * @param[in] dev > + * Ethernet device flow is being created on. > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_validate_item_vlan(const struct rte_flow_item *item, > + uint64_t item_flags, > + struct rte_eth_dev *dev, > + struct rte_flow_error *error) > +{ > + const struct rte_flow_item_vlan *mask =3D item->mask; > + const struct rte_flow_item_vlan nic_mask =3D { > + .tci =3D RTE_BE16(UINT16_MAX), > + .inner_type =3D RTE_BE16(UINT16_MAX), > + }; > + const int tunnel =3D !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); > + int ret; > + const uint64_t l34m =3D tunnel ? (MLX5_FLOW_LAYER_INNER_L3 | > + MLX5_FLOW_LAYER_INNER_L4) : > + (MLX5_FLOW_LAYER_OUTER_L3 | > + MLX5_FLOW_LAYER_OUTER_L4); > + const uint64_t vlanm =3D tunnel ? MLX5_FLOW_LAYER_INNER_VLAN : > + MLX5_FLOW_LAYER_OUTER_VLAN; > + > + if (item_flags & vlanm) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > item, > + "multiple VLAN layers not > supported"); > + else if ((item_flags & l34m) !=3D 0) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > item, > + "VLAN cannot follow L3/L4 layer"); > + if (!mask) > + mask =3D &rte_flow_item_vlan_mask; > + ret =3D mlx5_flow_item_acceptable(item, (const uint8_t *)mask, > + (const uint8_t *)&nic_mask, > + sizeof(struct rte_flow_item_vlan), > + error); > + if (ret) > + return ret; > + if (!tunnel && mask->tci !=3D RTE_BE16(0x0fff)) { > + struct mlx5_priv *priv =3D dev->data->dev_private; > + > + if (priv->vmwa_context) { > + /* > + * Non-NULL context means we have a virtual > machine > + * and SR-IOV enabled, we have to create VLAN > interface > + * to make hypervisor to setup E-Switch vport > + * context correctly. We avoid creating the multiple > + * VLAN interfaces, so we cannot support VLAN tag > mask. > + */ > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VLAN tag mask is not" > + " supported in virtual" > + " environment"); > + } > + } > + return 0; > +} > + > +/** > * Validate GTP item. > * > * @param[in] dev > @@ -4818,8 +4891,8 @@ struct field_modify_info modify_tcp[] =3D { > } > break; > case RTE_FLOW_ITEM_TYPE_VLAN: > - ret =3D mlx5_flow_validate_item_vlan(items, > item_flags, > - dev, error); > + ret =3D flow_dv_validate_item_vlan(items, item_flags, > + dev, error); > if (ret < 0) > return ret; > last_item =3D tunnel ? > MLX5_FLOW_LAYER_INNER_VLAN : > @@ -5754,10 +5827,6 @@ struct field_modify_info modify_tcp[] =3D { > uint16_t tci_m; > uint16_t tci_v; >=20 > - if (!vlan_v) > - return; > - if (!vlan_m) > - vlan_m =3D &rte_flow_item_vlan_mask; > if (inner) { > headers_m =3D MLX5_ADDR_OF(fte_match_param, matcher, > inner_headers); > @@ -5770,13 +5839,22 @@ struct field_modify_info modify_tcp[] =3D { > * This is workaround, masks are not supported, > * and pre-validated. > */ > - dev_flow->handle->vf_vlan.tag =3D > - rte_be_to_cpu_16(vlan_v->tci) & 0x0fff; > + if (vlan_v) > + dev_flow->handle->vf_vlan.tag =3D > + rte_be_to_cpu_16(vlan_v->tci) & > 0x0fff; > } > - tci_m =3D rte_be_to_cpu_16(vlan_m->tci); > - tci_v =3D rte_be_to_cpu_16(vlan_m->tci & vlan_v->tci); > + /* > + * When VLAN item exists in flow, mark packet as tagged, > + * even if TCI is not specified. > + */ > MLX5_SET(fte_match_set_lyr_2_4, headers_m, cvlan_tag, 1); > MLX5_SET(fte_match_set_lyr_2_4, headers_v, cvlan_tag, 1); > + if (!vlan_v) > + return; > + if (!vlan_m) > + vlan_m =3D &rte_flow_item_vlan_mask; > + tci_m =3D rte_be_to_cpu_16(vlan_m->tci); > + tci_v =3D rte_be_to_cpu_16(vlan_m->tci & vlan_v->tci); > MLX5_SET(fte_match_set_lyr_2_4, headers_m, first_vid, tci_m); > MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_vid, tci_v); > MLX5_SET(fte_match_set_lyr_2_4, headers_m, first_cfi, tci_m >> > 12); > -- > 1.8.3.1 Patch applied to next-net-mlx, Kindest regards, Raslan Darawsheh