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 3E0DEA046B for ; Mon, 22 Jul 2019 13:33:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BD5C51BF1F; Mon, 22 Jul 2019 13:33:44 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80078.outbound.protection.outlook.com [40.107.8.78]) by dpdk.org (Postfix) with ESMTP id 34A121BEFF for ; Mon, 22 Jul 2019 13:33:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V0RAPlBZD9vWAfAxi6ml7JxK1jWRe0M0TsYUJMccxF3rhJtHagk4sSSqnMfIkRoyl4MB7JCIa90opfnhCB4GWN/86Z2pKVpfnd7wQHMRwbyLhZ8lShh4pzs9SnvnsygszqGABH3cgrQJ7p9uLhN1+GbH99Atu6NJs1iIqWOvQrhdb1kx0whux+9DpAcWN0Ce9x3DusLcngiF0ZhrSv+DkIp6ZITmcM+qEtCtsdI4mx0JzVb3zaa8NqWyjN9l7UgxwZjPsmLmf0amH83oHBXILdyaV/WOvtyOKxwFKTvs3qHRGo/7lS1RUxFhY2Xo3a6CC7YMaKeaFvWPeZj0OdudXw== 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=XzWqrOCttLimSxVqViSItZNhII7vKmpQu8spws58JBw=; b=MOavbUKrLWSLG75yitdP70zRWSAFGJJx8uh4Z5YKasPhoL/WLxkrwHXS98Z8zgqtW30Kpt7nYlbuPQgY+7O/120TmvYc8L91JUudIJ+ySkTrR8TRhnSyEbkwQ/D+yRrlFwWrTj2bvKOMMQBUPcb3gX03Fuw1ybIRHy0h45+hFKi5xyPCKdw4mwPob9/irI1/Dc6IpMcWpq+yAw9f96lXoQtVIr5Hm2seMmoAGyx8c56ukBDz2HxRI5VXzOQWAczjgSHnCs8gOYSByZbEQuWASUr6zhqCRHzdEAe4r9T13iSLO0haDLkS//+BQKmOOumio5X3U9nflygvAvSub/TTnQ== 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=XzWqrOCttLimSxVqViSItZNhII7vKmpQu8spws58JBw=; b=EOerxO85I8QeWGGtxywZxKlROBpXK5fo9ybAIvzW5TQSO6FBmnlYF4unpaVbyl0+U+7/fED7QgIqo0Y+GAngylT/4VoOdjQSrQyvxfVqXMMF9lMhBCP4zjN8Oos8RcMbfnLLlp5LZFBW5r7xqwZZ5k9N8PDPkf5WIzTZrnkF4RM= Received: from AM4PR05MB3460.eurprd05.prod.outlook.com (10.171.187.153) by AM4PR05MB3140.eurprd05.prod.outlook.com (10.171.186.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.16; Mon, 22 Jul 2019 11:33:42 +0000 Received: from AM4PR05MB3460.eurprd05.prod.outlook.com ([fe80::3d47:5e1:befa:a949]) by AM4PR05MB3460.eurprd05.prod.outlook.com ([fe80::3d47:5e1:befa:a949%3]) with mapi id 15.20.2094.017; Mon, 22 Jul 2019 11:33:41 +0000 From: Dekel Peled To: Jack Min CC: Yongseok Koh , Slava Ovsiienko , Shahaf Shuler , Ori Kam , "dev@dpdk.org" Thread-Topic: [PATCH] net/mlx5: fix NVGRE matching Thread-Index: AQHVQHAsHUxwthm2G0uYJ/AfJhsLeabWfN6w Date: Mon, 22 Jul 2019 11:33:41 +0000 Message-ID: References: <3cd91c82dfa7f0feb325c0ed866659c07230c9fb.1563478228.git.dekelp@mellanox.com> <20190722093049.chqtifxh3gdrq77e@mellanox.com> In-Reply-To: <20190722093049.chqtifxh3gdrq77e@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dekelp@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3eecfcdf-3f9b-4935-7fb6-08d70e9872c4 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:AM4PR05MB3140; x-ms-traffictypediagnostic: AM4PR05MB3140: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2958; x-forefront-prvs: 01068D0A20 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(346002)(396003)(366004)(376002)(136003)(39860400002)(199004)(189003)(13464003)(7696005)(54906003)(9686003)(86362001)(316002)(8676002)(3846002)(4326008)(5660300002)(55016002)(6246003)(53936002)(14444005)(66556008)(74316002)(305945005)(66476007)(256004)(66446008)(64756008)(478600001)(6116002)(68736007)(76116006)(25786009)(52536014)(66946007)(7736002)(486006)(33656002)(81156014)(81166006)(6862004)(99286004)(11346002)(76176011)(6636002)(476003)(2906002)(8936002)(71190400001)(71200400001)(53546011)(186003)(66066001)(102836004)(26005)(6506007)(6436002)(446003)(14454004)(229853002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3140; H:AM4PR05MB3460.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: Qs/lj74wsJ3sOgSe3ngme1L1rWyvucEYa+KrDZdYnVr/gYQHtaE3ew1Wikxe1QhQIsANhO+46NjpxTvBTAGTKAOCI5gIMlCPvodAmvUL3r3hLJeAax0KMa8phMOH/v7o4EyVOK/0HFdmsOxs91J7OjgDSwoXggLzAeN0rN8qfkuXUfTBvrqXgloamYrhZhTMNqSF8qalmOXFZxwRiO+tpAhzTLq+78CTH73jMeRn4UC91f4mFrmFDi5FoCK33HI3+eMQzXnaS/3ckOK2N6p6/0lw1nSTg/OTzY8uYl7/1+XseO9/9u7BccAEE44CAObX0ssywfKp/7Y9oFbhdFnS3B1sv6MbK/q73Ovxp7hZaJ7CrpcUUvP0bgE7S/8w6HL2GyHyz9ar825yQkhN/qG6ROmlq/k61LBvSVePBWB4qUY= 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: 3eecfcdf-3f9b-4935-7fb6-08d70e9872c4 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jul 2019 11:33:41.9013 (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: dekelp@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3140 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" Thanks, PSB. > -----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 s= et. > > + */ > > +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? I think it is safer to verify that application doesn't insert invalid value= s. It covers any future pmd or applications change. >=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. The spec is specific 0x2000 and with full 0xffff mask to make sure all bits= are covered. >=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 > >