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 21DE0A046B for ; Tue, 23 Jul 2019 03:12:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C53F31BEDC; Tue, 23 Jul 2019 03:12:23 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40066.outbound.protection.outlook.com [40.107.4.66]) by dpdk.org (Postfix) with ESMTP id 016381BE5E; Tue, 23 Jul 2019 03:12:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ak9Go/oxtMFWyE/bCEkKkzh8ZNtXfqsgthpnryKEzgs06tWOEvBEUprq4F3SMU3qZlBvYXSKpr1tBMkAIcDqSs4j7Ld7Lij0mPVtfWxdD/Eu9xzwXPo4gCALl2XRoeazUizdNoLf4sGmZQBW1PsRyVhcAH4LFqfDo2q2yGydxY3fEu7sGkynakG2rglzbtw72nWOY3+0JVIT41JgAhAHt7c7POCYj1RPdlRbuE2us4zMPXOPDy3dLxwzAdwrAfgy6P9PSRopQokfb8tjqlUQBi8+RecVLFGcbAAxM+JYElM6XNmxOofVX1ApIg/Zk61nqNHKZXBQfAi2i4vcnVJGfw== 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=AsLxNuJZ9mzPGdQR0ObbnsRqP3Wr39xwHtSqYh7Qjwc=; b=S/kCDXwLSOkMw0LSHocFnvUxgIuNnXuFcscrGRA00mxL2HLgMc4XdMxz4AQSOAIfojyysEnzjdP20NzV00jqU6YHcfRGx+WzrCRf8gDHFa1L5ydFEbSxxNDCwBN2uus9ESfg6X/ejarfoppVAFi6T/Ev1LCNGcufv+8Mpgx5ehMCeANCPZcm4lwxBPJ33cj6uNi0rJmuuJ4a3JhOnXicOIgajsVPpU5F9aMWndUthfEaxuqnUFLpNJCc9qEIBKgkPtDlNMJotesQtNygQXf8v1WG4EHCtWL0qJnG16OB5tVJ/MNwcQQDxJTxGdSY5aUl5couMe10p9WTHbklrnR3nQ== 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=AsLxNuJZ9mzPGdQR0ObbnsRqP3Wr39xwHtSqYh7Qjwc=; b=CDCw6yqaUfjzTQ9vWx3JoFVqA90w/Td0w+mBnJp43e9cp66K8igpj/2RvZUkRMGMyQdxBubqq/zn7Xv1/L1eFv5Dqz3VrGERrm6XLpn3BzKCHHrYj7tKtNH48fYc1ccBbKhr/6mPpZBCbiicu0tyhjoX+Vsia6MI4l1jSsWU2b4= Received: from AM6PR05MB6567.eurprd05.prod.outlook.com (20.179.6.215) by AM6PR05MB4887.eurprd05.prod.outlook.com (20.177.36.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2094.15; Tue, 23 Jul 2019 01:12:16 +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.2115.005; Tue, 23 Jul 2019 01:12:16 +0000 From: Jack Min To: Dekel Peled CC: Yongseok Koh , Slava Ovsiienko , Shahaf Shuler , Ori Kam , "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH v2] net/mlx5: fix NVGRE matching Thread-Index: AQHVQKNgX0B6ZfPKXUOE7Ys/ogwneqbXZgIA Date: Tue, 23 Jul 2019 01:12:16 +0000 Message-ID: <20190723011206.bshd7bmco73g3hqs@mellanox.com> References: <3cd91c82dfa7f0feb325c0ed866659c07230c9fb.1563478228.git.dekelp@mellanox.com> <313676cd6e86314bcf2c187529a697827b78698e.1563808985.git.dekelp@mellanox.com> In-Reply-To: <313676cd6e86314bcf2c187529a697827b78698e.1563808985.git.dekelp@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK2PR02CA0164.apcprd02.prod.outlook.com (2603:1096:201:1f::24) 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: b5478fbc-2387-4c52-c18b-08d70f0acd04 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:AM6PR05MB4887; x-ms-traffictypediagnostic: AM6PR05MB4887: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 0107098B6C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(396003)(376002)(346002)(39860400002)(136003)(199004)(189003)(86362001)(6436002)(14444005)(256004)(6486002)(66946007)(53936002)(186003)(5660300002)(26005)(6246003)(8676002)(1076003)(54906003)(386003)(37006003)(316002)(66446008)(6512007)(7736002)(71190400001)(71200400001)(64756008)(66476007)(66556008)(305945005)(81166006)(8936002)(36756003)(81156014)(66066001)(6636002)(4326008)(6116002)(446003)(2906002)(99286004)(2616005)(476003)(11346002)(6862004)(3846002)(25786009)(68736007)(76176011)(52116002)(450100002)(102836004)(14454004)(229853002)(486006)(478600001)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4887; 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: ZJlQWpoty5eww2HVnv0I/gokkZAoV8fxUL4CTjiUnTISU54EsIdThAXo70FCM9KO7O25fdHP1iQ/94mpY86Tw5syzW3tOhf3/g3Kbf2x90ak3rDxU2yB0UUBgEL2bCg2DyU8TqDVS9T62sresy35uJtgy2e8mUREUwsXd4txUGaYszOpE5eGCKVjPSCMHH68SldRI/OmINaZQUlvrCs8BgHa75cnRVSkqneaN/pZi4Gr+3luZ8dcps6DjpwR0111+FA1oChTMvikaMpSfF/aqT18YsFg+KDVRw4H3P8JbXTFn27x++Axx1oCP6Rn27BLtNabfRHTZIZESiHyKrs/0VSJzNEk/1DLqAAMd2sQBEJiEYErn+XHUEuSORIlV5S3iVAzj0jN00qub6Bq2ra2cRMpDiTNEl2CWfXEhkY4ILE= Content-Type: text/plain; charset="us-ascii" Content-ID: <98257090F1899449B5B43D9F3D65E9FC@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5478fbc-2387-4c52-c18b-08d70f0acd04 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jul 2019 01:12:16.1894 (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: AM6PR05MB4887 Subject: Re: [dpdk-dev] [PATCH v2] 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, 18:36, 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. >=20 > This patch adds validation function of NVGRE item. > It also updates the translate function of NVGRE item, to add the > required values, if they were not specified. >=20 > Original work by Xiaoyu Min >=20 > Fixes: fc2c498ccb94 ("net/mlx5: add Direct Verbs translate items") > Cc: stable@dpdk.org >=20 > Signed-off-by: Dekel Peled Acked-by: Xiaoyu Min > --- > drivers/net/mlx5/mlx5_flow.c | 63 +++++++++++++++++++++++++++++++++++= ++++++ > 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, 95 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index e082cbb..3d2d5fc 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, > + }, > }; > =20 > /** > @@ -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,55 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_= dev *dev, int32_t priority, > " update."); > } > =20 > +/** > + * 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; > + 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 (!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. */ > =20 > /* 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) > =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) > =20 > /* 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) > =20 > /* Inner Masks. */ > @@ -518,5 +521,8 @@ int mlx5_flow_validate_item_icmp6(const struct rte_fl= ow_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..f1d32bd 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; > =20 > - 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(0xB000), > + .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 4252832..928d6c3 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.h > +++ b/drivers/net/mlx5/mlx5_rxtx.h > @@ -40,7 +40,7 @@ > #include "mlx5_glue.h" > =20 > /* Support tunnel matching. */ > -#define MLX5_FLOW_TUNNEL 5 > +#define MLX5_FLOW_TUNNEL 6 > =20 > struct mlx5_rxq_stats { > #ifdef MLX5_PMD_SOFT_COUNTERS > --=20 > 1.8.3.1 >=20