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 599F3A046B for ; Mon, 22 Jul 2019 14:09:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A6651BF63; Mon, 22 Jul 2019 14:09:35 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20070.outbound.protection.outlook.com [40.107.2.70]) by dpdk.org (Postfix) with ESMTP id 1A0EF1BF61 for ; Mon, 22 Jul 2019 14:09:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L6/yQpJskxbvvOU4CaMoPC7xDY3b2QKJXM7/UA5fPeXHrqyixb7c2uMdr0LxNnCfZrQV/Rdz+2T756iQppuCOx0bHuzG+Z5hhcEY2blqgQl3JtSfxsJXH+3QBuZzI8QSZSucQm5DfRFIk4+Z1pkq0v0+wnaZ1nul8nY7/zqW6gdBQ65zvfGudqPBO6/805yYubibktZdbMjnWxs1UxiUr1yEV25ydPjPErZRVan7ul45YFO4Qq7iQcqHILefSYLHK0OBFrtLc5nmvicERaBadqAyjGWgaHXKJNG4Vv9DSn7CMybRhvx9TQCA1hUDlpFm2mee/flXbpgsxXhKmYz7Cw== 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=RNYZnN03QXrCV68CvtVZW1g4IBytHGDRG5X5vjL2bvI=; b=ZTKzm2SQeXfsYXBeaYRo7PSBRNloMcEMWVsVK6pLcR9hzKfhGyKqqQrbw3gDOE/jG/yzrv9mpWvuvXzgf4HIkyrLGkhpZIiaIxaDXt9ANMUnIquTo0FvWUSK5Qaj/jjQSDMEFfM4W05ZroUOHoiskacrUCFR7aEbyIw72RrKO0ZAvk2Bkz9KP03t2fkUd8buLtMSchM53pdjsbkeqcG8TduQsTWgWVex+RtDEdg3tMjCKIh1s1aYOej+YQKpHKUY8DYsWBhXL79MIfuPnGnuR/I6E/0NYfVDtnqo3u457nef3ZUDLwpCBGp/yDUS6h3MEbkE8K616llSg4r+lZyMKA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RNYZnN03QXrCV68CvtVZW1g4IBytHGDRG5X5vjL2bvI=; b=Go44FBrjiZAClx+y20sSuKrdZVO4emLHAB63y5ot+rUthd2JgkPAfjP8mHX29D7PISwhuewCDgBn3YsTnCobjth98iT/jRqRTjeii5LWUx6+WNOX6yIT2pHIDLMUaiimHsY1utinFoKKZ1ogbAKjtDYVlocdwqpoAA8aKErJfVg= Received: from AM6PR05MB6567.eurprd05.prod.outlook.com (20.179.6.215) by AM6PR05MB5974.eurprd05.prod.outlook.com (20.179.1.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.17; Mon, 22 Jul 2019 12:09:32 +0000 Received: from AM6PR05MB6567.eurprd05.prod.outlook.com ([fe80::496b:bd1c:863a:ed47]) by AM6PR05MB6567.eurprd05.prod.outlook.com ([fe80::496b:bd1c:863a:ed47%3]) with mapi id 15.20.2094.017; Mon, 22 Jul 2019 12:09:32 +0000 From: Jack Min To: Dekel Peled CC: Yongseok Koh , Slava Ovsiienko , Shahaf Shuler , Ori Kam , "dev@dpdk.org" Thread-Topic: [PATCH] net/mlx5: fix NVGRE matching Thread-Index: AQHVPaEEMr3JZ6qWCUqOpqJnqLntg6bWZQmAgAAiVICAAAn5gA== Date: Mon, 22 Jul 2019 12:09:32 +0000 Message-ID: <20190722120923.xndpxqk6w66iyq2p@mellanox.com> References: <3cd91c82dfa7f0feb325c0ed866659c07230c9fb.1563478228.git.dekelp@mellanox.com> <20190722093049.chqtifxh3gdrq77e@mellanox.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK2PR04CA0047.apcprd04.prod.outlook.com (2603:1096:202:14::15) To AM6PR05MB6567.eurprd05.prod.outlook.com (2603:10a6:20b:bc::23) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jackmin@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [139.227.40.60] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d527285e-eee5-4b47-be86-08d70e9d745a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM6PR05MB5974; x-ms-traffictypediagnostic: AM6PR05MB5974: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; x-forefront-prvs: 01068D0A20 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(376002)(346002)(396003)(39860400002)(366004)(13464003)(199004)(189003)(486006)(5660300002)(14454004)(186003)(36756003)(52116002)(7736002)(305945005)(1076003)(66066001)(229853002)(6636002)(99286004)(37006003)(102836004)(6862004)(26005)(54906003)(30864003)(66946007)(64756008)(66556008)(66476007)(66446008)(3846002)(6506007)(2616005)(386003)(6116002)(476003)(53546011)(11346002)(4326008)(446003)(25786009)(8936002)(2906002)(71200400001)(81156014)(76176011)(6246003)(81166006)(68736007)(14444005)(256004)(8676002)(316002)(86362001)(478600001)(53936002)(6436002)(6486002)(6512007)(71190400001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB5974; H:AM6PR05MB6567.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2ugYE1k/ski5TJ4l+UP7PFoWpkIDZu7G0QXMmtahFI4li6n+wIuo12Ld9n+L2E5LY2DtQ6GWFOzEBKBDUFxwZN+v0HF3Zq650sMk81zoxW04z2yA88Nl2chKMDTgc5a1owzH4HcVChzI2JDhorIJcz8Ijvph4b1dJrdb2m/uI7L/mKgoppSlXI7qzwr1dkok52aJ8J8hcgRB1u40HNX4pWA09+xnKN2N/aSRu9CmkUqnr+yWDkwQz8BXhe7DOATZ/vZ6I/kdE24zrhSKxL1gNiUFH4HM32/9obnMjHTemeY3MwUB5VFjxnAVtsZ1GY54UKejwxo3OtUVtCldyPuy8OgwTHARRdHuLwW8VgdxBsdx9R6ZDW+tWga7D3rW3UpA8PvgzPe0toVuA6ju1VUlBK3x7D0qFPBq1CSd/ZKQ4io= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d527285e-eee5-4b47-be86-08d70e9d745a X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jul 2019 12:09:32.3541 (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: jackmin@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB5974 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix NVGRE matching 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" On Mon, 19-07-22, 19:33, Dekel Peled wrote: > Thanks, PSB. >=20 > > -----Original Message----- > > From: Jack Min > > Sent: Monday, July 22, 2019 12:31 PM > > To: Dekel Peled > > Cc: Yongseok Koh ; Slava Ovsiienko > > ; Shahaf Shuler ; Ori > > Kam ; dev@dpdk.org > > Subject: Re: [PATCH] net/mlx5: fix NVGRE matching > >=20 > > On Thu, 19-07-18, 22:42, Dekel Peled wrote: > > > NVGRE has a GRE header with c_rsvd0_ver value 0x2000 and protocol > > > value 0x6558. > > > These should be matched when item_nvgre is provided. > > > > > > This patch adds validation function of NVGRE item, to validate that > > > the input values, if exist, are as required. > > > It also updates the translate function of NVGRE item, to add the > > > required values, if they were not specified. > > > > > > Original work by Xiaoyu Min > > > > > > Fixes: fc2c498ccb94 ("net/mlx5: add Direct Verbs translate items") > > > Signed-off-by: Dekel Peled > > > --- > > > drivers/net/mlx5/mlx5_flow.c | 69 > > +++++++++++++++++++++++++++++++++++++++++ > > > drivers/net/mlx5/mlx5_flow.h | 10 ++++-- > > > drivers/net/mlx5/mlx5_flow_dv.c | 25 +++++++++++++-- > > > drivers/net/mlx5/mlx5_rxtx.h | 2 +- > > > 4 files changed, 101 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/net/mlx5/mlx5_flow.c > > > b/drivers/net/mlx5/mlx5_flow.c index e082cbb..6aca4d6 100644 > > > --- a/drivers/net/mlx5/mlx5_flow.c > > > +++ b/drivers/net/mlx5/mlx5_flow.c > > > @@ -298,6 +298,10 @@ struct mlx5_flow_tunnel_info { > > > .tunnel =3D MLX5_FLOW_LAYER_MPLS, > > > .ptype =3D RTE_PTYPE_TUNNEL_MPLS_IN_GRE, > > > }, > > > + { > > > + .tunnel =3D MLX5_FLOW_LAYER_NVGRE, > > > + .ptype =3D RTE_PTYPE_TUNNEL_NVGRE, > > > + }, > > > }; > > > > > > /** > > > @@ -1323,6 +1327,11 @@ uint32_t mlx5_flow_adjust_priority(struct > > rte_eth_dev *dev, int32_t priority, > > > return rte_flow_error_set(error, EINVAL, > > > RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > "L3 cannot follow an L4 layer."); > > > + else if ((item_flags & MLX5_FLOW_LAYER_NVGRE) && > > > + !(item_flags & MLX5_FLOW_LAYER_INNER_L2)) > > > + return rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > + "L3 cannot follow an NVGRE layer."); > > > if (!mask) > > > mask =3D &rte_flow_item_ipv4_mask; > > > else if (mask->hdr.next_proto_id !=3D 0 && @@ -1409,6 +1418,11 @@ > > > uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t > > priority, > > > return rte_flow_error_set(error, EINVAL, > > > RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > "L3 cannot follow an L4 layer."); > > > + else if ((item_flags & MLX5_FLOW_LAYER_NVGRE) && > > > + !(item_flags & MLX5_FLOW_LAYER_INNER_L2)) > > > + return rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > + "L3 cannot follow an NVGRE layer."); > > > if (!mask) > > > mask =3D &rte_flow_item_ipv6_mask; > > > ret =3D mlx5_flow_item_acceptable(item, (const uint8_t *)mask, @@ > > > -1887,6 +1901,61 @@ uint32_t mlx5_flow_adjust_priority(struct > > rte_eth_dev *dev, int32_t priority, > > > " update."); > > > } > > > > > > +/** > > > + * Validate NVGRE item. > > > + * > > > + * @param[in] item > > > + * Item specification. > > > + * @param[in] item_flags > > > + * Bit flags to mark detected items. > > > + * @param[in] target_protocol > > > + * The next protocol in the previous item. > > > + * @param[out] error > > > + * Pointer to error structure. > > > + * > > > + * @return > > > + * 0 on success, a negative errno value otherwise and rte_errno is= set. > > > + */ > > > +int > > > +mlx5_flow_validate_item_nvgre(const struct rte_flow_item *item, > > > + uint64_t item_flags, > > > + uint8_t target_protocol, > > > + struct rte_flow_error *error) { > > > + const struct rte_flow_item_nvgre *mask =3D item->mask; > > > + const struct rte_flow_item_nvgre *spec =3D item->spec; > > > + int ret; > > > + > > > + if (target_protocol !=3D 0xff && target_protocol !=3D IPPROTO_GRE) > > > + return rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > + "protocol filtering not compatible" > > > + " with this GRE layer"); > > > + if (item_flags & MLX5_FLOW_LAYER_TUNNEL) > > > + return rte_flow_error_set(error, ENOTSUP, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > + "multiple tunnel layers not" > > > + " supported"); > > > + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L3)) > > > + return rte_flow_error_set(error, ENOTSUP, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > + "L3 Layer is missing"); > > > + if (spec && (spec->protocol !=3D RTE_BE16(RTE_ETHER_TYPE_TEB) || > > > + spec->c_k_s_rsvd0_ver !=3D RTE_BE16(0x2000))) > > > + return rte_flow_error_set(error, EINVAL, > > > + RTE_FLOW_ERROR_TYPE_ITEM, > > item, > > > + "wrong values for NVGRE"); > > Not necessary to check the spec because the following > > mlx5_flow_item_acceptable only accept matching on .tni field. > > Since there is no meaning allowing the user to match on .protocol and > > .c_k_s_rsvd0_ver. > > What do you think? >=20 > I think it is safer to verify that application doesn't insert invalid val= ues. > It covers any future pmd or applications change. If the mask is not enabled for .protocol and c_k_s_rsvd0_ver, whatever the spec value is, it doesn't matter, right? >=20 > >=20 > > > + if (!mask) > > > + mask =3D &rte_flow_item_nvgre_mask; > > > + ret =3D mlx5_flow_item_acceptable > > > + (item, (const uint8_t *)mask, > > > + (const uint8_t *)&rte_flow_item_nvgre_mask, > > > + sizeof(struct rte_flow_item_nvgre), error); > > > + if (ret < 0) > > > + return ret; > > > + return 0; > > > +} > > > + > > > static int > > > flow_null_validate(struct rte_eth_dev *dev __rte_unused, > > > const struct rte_flow_attr *attr __rte_unused, diff --git > > > a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index > > > 3f96bec..24da74b 100644 > > > --- a/drivers/net/mlx5/mlx5_flow.h > > > +++ b/drivers/net/mlx5/mlx5_flow.h > > > @@ -48,6 +48,7 @@ > > > #define MLX5_FLOW_LAYER_VXLAN_GPE (1u << 13) #define > > > MLX5_FLOW_LAYER_GRE (1u << 14) #define MLX5_FLOW_LAYER_MPLS > > (1u << > > > 15) > > > +/* List of tunnel Layer bits continued below. */ > > > > > > /* General pattern items bits. */ > > > #define MLX5_FLOW_ITEM_METADATA (1u << 16) @@ -58,8 +59,10 @@ > > > #define MLX5_FLOW_LAYER_ICMP6 (1u << 19) #define > > > MLX5_FLOW_LAYER_GRE_KEY (1u << 20) > > > > > > +/* Pattern tunnel Layer bits (continued). */ > > > #define MLX5_FLOW_LAYER_IPIP (1u << 21) #define > > > MLX5_FLOW_LAYER_IPV6_ENCAP (1u << 22) > > > +#define MLX5_FLOW_LAYER_NVGRE (1u << 23) > > > > > > /* Outer Masks. */ > > > #define MLX5_FLOW_LAYER_OUTER_L3 \ > > > @@ -79,7 +82,7 @@ > > > /* Tunnel Masks. */ > > > #define MLX5_FLOW_LAYER_TUNNEL \ > > > (MLX5_FLOW_LAYER_VXLAN | MLX5_FLOW_LAYER_VXLAN_GPE | \ > > > - MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_MPLS | \ > > > + MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_NVGRE | > > MLX5_FLOW_LAYER_MPLS > > > +| \ > > > MLX5_FLOW_LAYER_IPIP | MLX5_FLOW_LAYER_IPV6_ENCAP) > > > > > > /* Inner Masks. */ > > > @@ -518,5 +521,8 @@ int mlx5_flow_validate_item_icmp6(const struct > > rte_flow_item *item, > > > uint64_t item_flags, > > > uint8_t target_protocol, > > > struct rte_flow_error *error); > > > - > > > +int mlx5_flow_validate_item_nvgre(const struct rte_flow_item *item, > > > + uint64_t item_flags, > > > + uint8_t target_protocol, > > > + struct rte_flow_error *error); > > > #endif /* RTE_PMD_MLX5_FLOW_H_ */ > > > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > > > b/drivers/net/mlx5/mlx5_flow_dv.c index 7240d3b..ab758d4 100644 > > > --- a/drivers/net/mlx5/mlx5_flow_dv.c > > > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > > > @@ -2966,7 +2966,6 @@ struct field_modify_info modify_tcp[] =3D { > > > > > MLX5_FLOW_LAYER_OUTER_L4_UDP; > > > break; > > > case RTE_FLOW_ITEM_TYPE_GRE: > > > - case RTE_FLOW_ITEM_TYPE_NVGRE: > > > ret =3D mlx5_flow_validate_item_gre(items, > > item_flags, > > > next_protocol, > > error); > > > if (ret < 0) > > > @@ -2974,6 +2973,14 @@ struct field_modify_info modify_tcp[] =3D { > > > gre_item =3D items; > > > last_item =3D MLX5_FLOW_LAYER_GRE; > > > break; > > > + case RTE_FLOW_ITEM_TYPE_NVGRE: > > > + ret =3D mlx5_flow_validate_item_nvgre(items, > > item_flags, > > > + next_protocol, > > > + error); > > > + if (ret < 0) > > > + return ret; > > > + last_item =3D MLX5_FLOW_LAYER_NVGRE; > > > + break; > > > case RTE_FLOW_ITEM_TYPE_GRE_KEY: > > > ret =3D mlx5_flow_validate_item_gre_key > > > (items, item_flags, gre_item, error); @@ - > > 3919,7 +3926,21 @@ > > > struct field_modify_info modify_tcp[] =3D { > > > int size; > > > int i; > > > > > > - flow_dv_translate_item_gre(matcher, key, item, inner); > > > + /* For NVGRE, GRE header fields must be set with defined values. */ > > > + const struct rte_flow_item_gre gre_spec =3D { > > > + .c_rsvd0_ver =3D RTE_BE16(0x2000), > > > + .protocol =3D RTE_BE16(RTE_ETHER_TYPE_TEB) > > > + }; > > > + const struct rte_flow_item_gre gre_mask =3D { > > > + .c_rsvd0_ver =3D RTE_BE16(UINT16_MAX), > > Well, it should be `RTE_BE16(0xB000)`, which, I think, is more explicit= . > > Because our NIC only support matching on C,K,S bits, not else bits in > > c_rsvd0_ver. Our PMD just ignore the other bits. >=20 > The spec is specific 0x2000 and with full 0xffff mask to make sure all bi= ts are covered. I see. You wanna make sure that all bits are covered but what I wanna point out is our PMD only match C,K,S bits and ignore others. So, even though the spec/mask is 0x2000/0xffff, it still will match on 0x20= 01, for example. >=20 > >=20 > > > + .protocol =3D RTE_BE16(UINT16_MAX), > > > + }; > > > + const struct rte_flow_item gre_item =3D { > > > + .spec =3D &gre_spec, > > > + .mask =3D &gre_mask, > > > + .last =3D NULL, > > > + }; > > > + flow_dv_translate_item_gre(matcher, key, &gre_item, inner); > > > if (!nvgre_v) > > > return; > > > if (!nvgre_m) > > > diff --git a/drivers/net/mlx5/mlx5_rxtx.h > > > b/drivers/net/mlx5/mlx5_rxtx.h index dfa79e2..d732757 100644 > > > --- a/drivers/net/mlx5/mlx5_rxtx.h > > > +++ b/drivers/net/mlx5/mlx5_rxtx.h > > > @@ -40,7 +40,7 @@ > > > #include "mlx5_glue.h" > > > > > > /* Support tunnel matching. */ > > > -#define MLX5_FLOW_TUNNEL 5 > > > +#define MLX5_FLOW_TUNNEL 6 > > > > > > struct mlx5_rxq_stats { > > > #ifdef MLX5_PMD_SOFT_COUNTERS > > > -- > > > 1.8.3.1 > > >