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 4A9A4A0531 for ; Mon, 10 Feb 2020 14:23:42 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 264B81BE88; Mon, 10 Feb 2020 14:23:42 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60049.outbound.protection.outlook.com [40.107.6.49]) by dpdk.org (Postfix) with ESMTP id 978244C90; Mon, 10 Feb 2020 14:23:39 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IzIqf7d/zZ8TAB7UI3lwUampoUdNDN8LCES5ab542VtWNI02Pmq+Mlj65RpXJpkyCPFSpaJLL0E76oc1ZuqUJaR9RnnX0mU6CPtBFNRv6IzCmU8NCp8RhAZtbMaIMcqsgILOiWU+GTmnS0934tNhC/O8Zi5fENrfQPsFVAC7I0sukXa3KsD2TszVi0gubDYVc0FGxMcGiVl6Fyp+BdrLOrZXbVat2Ia667e9W76FV3IE5bY6TtGra/PpFtYbk0euHbWhbtCZfzFEzbMFr2mjrZ2S9UA2r4C36guHhhk+sr5RtMbiE1xvaeVUd74vTks8kl8x84nZN9b2mUxerIJlZQ== 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=Wo4zj05pWkgQxTSnVFkyeAqDOItA/ilB1PzsfaiA4C4=; b=JdiYvAuVLqiI8KIEuOOA1UrI4W4fXQNHH0Cwpt570BU0N64eVFrQNvAcjietndm8r/NHzvzFwCfUQj2wwRWwuY5/pkQDgltIKgKA2rKVNNCw89rJwwalFqeUFcCQogQoDQuJjIPYDKipigYRguFbOjDE75kWWU3xk0kCU3FlxiKjfdPA43gp2jMfup7gnQGjH0peXaOmEkN3/wn/OPtpL65PYfPm7L6/nvC0Ccy2ZoAKOYJPj+HbV1FaB4c0bLF8QBjzwCPzb49rmpK0BUrnHMrY6Itg2WgPajCHdbXKoW4woo/Rh2Hg92K/VRsHM/qZAVYWc9oapr6fu3dHblcinQ== 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=Wo4zj05pWkgQxTSnVFkyeAqDOItA/ilB1PzsfaiA4C4=; b=VCboEV0IhbPhs58V1XCOuy6IEpPCaqbTTXexdLvtZm7A2wMQTlw3jI/K4ebTl2KGdy1Dfq9wx19Lie8QU6ppmqImqvSC3KKBDtfsG3NuK2GtJCmZXaLakywmHEYGZf6K9JX1LpuWnJvTmGEvreT1am3f3tGOlHaoKCD2p4a0pvc= Received: from AM0PR05MB6707.eurprd05.prod.outlook.com (10.186.174.145) by AM0PR05MB4340.eurprd05.prod.outlook.com (52.134.124.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23; Mon, 10 Feb 2020 13:23:38 +0000 Received: from AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::adbd:45ca:54:bba9]) by AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::adbd:45ca:54:bba9%7]) with mapi id 15.20.2707.030; Mon, 10 Feb 2020 13:23:38 +0000 From: Raslan Darawsheh To: Matan Azrad , Slava Ovsiienko CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] net/mlx5: fix xcapsulation validation Thread-Index: AQHV31xSWTlggTssXEW/0tSKZTexYqgUa8jQ Date: Mon, 10 Feb 2020 13:23:38 +0000 Message-ID: References: <1581261556-10561-1-git-send-email-matan@mellanox.com> In-Reply-To: <1581261556-10561-1-git-send-email-matan@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=rasland@mellanox.com; x-originating-ip: [212.29.221.74] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 072af6ad-0b39-42b7-358b-08d7ae2c707a x-ms-traffictypediagnostic: AM0PR05MB4340:|AM0PR05MB4340: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 03094A4065 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(376002)(346002)(136003)(39860400002)(396003)(189003)(199004)(33656002)(186003)(8676002)(4326008)(316002)(8936002)(2906002)(76116006)(450100002)(81166006)(66476007)(66556008)(64756008)(66446008)(30864003)(7696005)(81156014)(66946007)(6506007)(5660300002)(53546011)(52536014)(478600001)(55016002)(9686003)(71200400001)(86362001)(26005)(110136005)(6636002)(54906003)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4340; H:AM0PR05MB6707.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zZ9Oi6ACzEzOnQoMZVyZ43TqHqd2ugKllLxuiOX0P688JcbzOekigVkJoO9NT7/9RK+SbG6Yw4ahrF3eQYSQVmm7yjcm8igcJNBsHLSKilYUBZp/kJhhFkY5thJmYrJbwCBSSHwj5ka8GzmxDKAkcVgY7GTt/XKrh64/mN8NKuk0IENpAT3k4VcYaLOtQnSpd7sG+/PY+jyvCkhkt8+mvcuBOjInrgZyUnQ3fzLPyqRo3QSt+/ZEsWtKC0d/TUKwrSerw1kgzBAGa97MWgg/F1xLEHX9x4SqGAyhTPvtTzUM/VCPvV10Umy7PbCXZtngc2duq+8L+9jrbWD7KcBIwYHXk0/RrTKBEsQTyf87/qhrzC/rpXeONS0W+jMyoSbPbNheC4yW22ll1LKhyya7sVYelDu876hqCqn7XeREaReKnQx6eVP+Gx2WRBeQGsDQ x-ms-exchange-antispam-messagedata: ZV/gynimnCZMHHQfCsETINhehhMYquUQOFi+w3ojx1in3ttB/1D4gTMeVO7Q19IHtuwTx6ZDiNBRrE55pLUwrhTOH8oxVJJ86EsXN0JnK2FFceVe/fxSFn2ULrZBuXB++L0wKxBw1ad8AqKCR2w01g== 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: 072af6ad-0b39-42b7-358b-08d7ae2c707a X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Feb 2020 13:23:38.4139 (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: cDo+EJSbMiTfPAiOEGB1HlyhH8TZ/OwVPBygAmwiewext9fI1YiNvpnNLmqHUzoNHVaqjHmWlTkgG+tGk6BNZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4340 Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] net/mlx5: fix xcapsulation validation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, > -----Original Message----- > From: dev On Behalf Of Matan Azrad > Sent: Sunday, February 9, 2020 5:19 PM > To: Slava Ovsiienko > Cc: dev@dpdk.org; stable@dpdk.org > Subject: [dpdk-dev] [PATCH] net/mlx5: fix xcapsulation validation >=20 > The encapsulation and decapsulation actions are divided into 2 types: > L2 and L3. > In order to configure L3 xcapsulation actions the user should use both > RAW_DECAP and RAW_ENCAP and setting the appropriated data sizes in > their action configuration structures. >=20 > The PMD flow validation wrongly didn't detect the RAW_DECAP > and RAW_ENCAP combination to distinguish between L3_DECAP and > L3_ENCAP. > Thus, some xcapsulation related validation failed. > For example, when configuring modify header action before L3_DECAP. >=20 > Simplify the xcapsulation defines and fix the L3 xcapsulation detection > using the action configuration data sizes. >=20 > By the way, add the hairpin validation in this area. >=20 > Fixes: d85c7b5ea59f ("net/mlx5: split hairpin flows") > Fixes: 8ba9eee4ce32 ("net/mlx5: add raw data encap/decap to Direct Verbs"= ) > Cc: stable@dpdk.org >=20 > Signed-off-by: Matan Azrad > Acked-by: Ori Kam > --- > drivers/net/mlx5/mlx5_flow.c | 9 +- > drivers/net/mlx5/mlx5_flow.h | 38 +++--- > drivers/net/mlx5/mlx5_flow_dv.c | 262 +++++++++++++++++++-------------- > ------- > 3 files changed, 146 insertions(+), 163 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 144e07c..e05d799 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -4154,13 +4154,16 @@ uint32_t mlx5_flow_adjust_priority(struct > rte_eth_dev *dev, int32_t priority, > } items_tx; > struct rte_flow_expand_rss *buf =3D &expand_buffer.buf; > const struct rte_flow_action *p_actions_rx =3D actions; > - int ret; > uint32_t i; > uint32_t flow_size; > int hairpin_flow =3D 0; > uint32_t hairpin_id =3D 0; > struct rte_flow_attr attr_tx =3D { .priority =3D 0 }; > + int ret =3D flow_drv_validate(dev, attr, items, p_actions_rx, external, > + error); >=20 > + if (ret < 0) > + return NULL; > hairpin_flow =3D flow_check_hairpin_split(dev, attr, actions); > if (hairpin_flow > 0) { > if (hairpin_flow > MLX5_MAX_SPLIT_ACTIONS) { > @@ -4172,10 +4175,6 @@ uint32_t mlx5_flow_adjust_priority(struct > rte_eth_dev *dev, int32_t priority, > &hairpin_id); > p_actions_rx =3D actions_rx.actions; > } > - ret =3D flow_drv_validate(dev, attr, items, p_actions_rx, external, > - error); > - if (ret < 0) > - goto error_before_flow; > flow_size =3D sizeof(struct rte_flow); > rss =3D flow_get_rss_action(p_actions_rx); > if (rss) > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 7c31bfe..791f3bd 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -186,22 +186,18 @@ enum mlx5_feature_name { > #define MLX5_FLOW_ACTION_DEC_TTL (1u << 19) > #define MLX5_FLOW_ACTION_SET_MAC_SRC (1u << 20) > #define MLX5_FLOW_ACTION_SET_MAC_DST (1u << 21) > -#define MLX5_FLOW_ACTION_VXLAN_ENCAP (1u << 22) > -#define MLX5_FLOW_ACTION_VXLAN_DECAP (1u << 23) > -#define MLX5_FLOW_ACTION_NVGRE_ENCAP (1u << 24) > -#define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25) > -#define MLX5_FLOW_ACTION_RAW_ENCAP (1u << 26) > -#define MLX5_FLOW_ACTION_RAW_DECAP (1u << 27) > -#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 28) > -#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 29) > -#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 30) > -#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 31) > -#define MLX5_FLOW_ACTION_SET_TAG (1ull << 32) > -#define MLX5_FLOW_ACTION_MARK_EXT (1ull << 33) > -#define MLX5_FLOW_ACTION_SET_META (1ull << 34) > -#define MLX5_FLOW_ACTION_METER (1ull << 35) > -#define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 36) > -#define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 37) > +#define MLX5_FLOW_ACTION_ENCAP (1u << 22) > +#define MLX5_FLOW_ACTION_DECAP (1u << 23) > +#define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 24) > +#define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 25) > +#define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 26) > +#define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 27) > +#define MLX5_FLOW_ACTION_SET_TAG (1ull << 28) > +#define MLX5_FLOW_ACTION_MARK_EXT (1ull << 29) > +#define MLX5_FLOW_ACTION_SET_META (1ull << 30) > +#define MLX5_FLOW_ACTION_METER (1ull << 31) > +#define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 32) > +#define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 33) >=20 > #define MLX5_FLOW_FATE_ACTIONS \ > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \ > @@ -211,13 +207,6 @@ enum mlx5_feature_name { > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \ > MLX5_FLOW_ACTION_JUMP) >=20 > -#define MLX5_FLOW_ENCAP_ACTIONS > (MLX5_FLOW_ACTION_VXLAN_ENCAP | \ > - MLX5_FLOW_ACTION_NVGRE_ENCAP | \ > - MLX5_FLOW_ACTION_RAW_ENCAP) > - > -#define MLX5_FLOW_DECAP_ACTIONS > (MLX5_FLOW_ACTION_VXLAN_DECAP | \ > - MLX5_FLOW_ACTION_NVGRE_DECAP | \ > - MLX5_FLOW_ACTION_RAW_DECAP) >=20 > #define MLX5_FLOW_MODIFY_HDR_ACTIONS > (MLX5_FLOW_ACTION_SET_IPV4_SRC | \ > MLX5_FLOW_ACTION_SET_IPV4_DST | \ > @@ -242,6 +231,9 @@ enum mlx5_feature_name { >=20 > #define MLX5_FLOW_VLAN_ACTIONS > (MLX5_FLOW_ACTION_OF_POP_VLAN | \ > MLX5_FLOW_ACTION_OF_PUSH_VLAN) > + > +#define MLX5_FLOW_XCAP_ACTIONS (MLX5_FLOW_ACTION_ENCAP | > MLX5_FLOW_ACTION_DECAP) > + > #ifndef IPPROTO_MPLS > #define IPPROTO_MPLS 137 > #endif > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c > index 3daabd3..f4eac4c 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -2140,8 +2140,6 @@ struct field_modify_info modify_tcp[] =3D { > * Holds the actions detected until now. > * @param[in] action > * Pointer to the action structure. > - * @param[in] attr > - * Pointer to flow attributes > * @param[out] error > * Pointer to error structure. > * > @@ -2151,29 +2149,22 @@ struct field_modify_info modify_tcp[] =3D { > static int > flow_dv_validate_action_l2_encap(uint64_t action_flags, > const struct rte_flow_action *action, > - const struct rte_flow_attr *attr, > struct rte_flow_error *error) > { > if (!(action->conf)) > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > action, > "configuration cannot be null"); > - if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS | > MLX5_FLOW_DECAP_ACTIONS)) > + if (action_flags & MLX5_FLOW_ACTION_ENCAP) > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > - "can only have a single encap or" > - " decap action in a flow"); > - if (!attr->transfer && attr->ingress) > - return rte_flow_error_set(error, ENOTSUP, > - > RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, > - NULL, > - "encap action not supported for " > - "ingress"); > + "can only have a single encap action > " > + "in a flow"); > return 0; > } >=20 > /** > - * Validate the L2 decap action. > + * Validate a decap action. > * > * @param[in] action_flags > * Holds the actions detected until now. > @@ -2186,15 +2177,17 @@ struct field_modify_info modify_tcp[] =3D { > * 0 on success, a negative errno value otherwise and rte_errno is set= . > */ > static int > -flow_dv_validate_action_l2_decap(uint64_t action_flags, > +flow_dv_validate_action_decap(uint64_t action_flags, > const struct rte_flow_attr *attr, > struct rte_flow_error *error) > { > - if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS | > MLX5_FLOW_DECAP_ACTIONS)) > - return rte_flow_error_set(error, EINVAL, > + if (action_flags & MLX5_FLOW_XCAP_ACTIONS) > + return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > - "can only have a single encap or" > - " decap action in a flow"); > + action_flags & > + MLX5_FLOW_ACTION_DECAP ? "can > only " > + "have a single decap action" : > "decap" > + "after encap is not supported"); > if (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS) > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > @@ -2209,62 +2202,21 @@ struct field_modify_info modify_tcp[] =3D { > return 0; > } >=20 > -/** > - * Validate the raw encap action. > - * > - * @param[in] action_flags > - * Holds the actions detected until now. > - * @param[in] action > - * Pointer to the encap 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_errno is set= . > - */ > -static int > -flow_dv_validate_action_raw_encap(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_raw_encap *raw_encap =3D > - (const struct rte_flow_action_raw_encap *)action->conf; > - if (!(action->conf)) > - return rte_flow_error_set(error, EINVAL, > - RTE_FLOW_ERROR_TYPE_ACTION, > action, > - "configuration cannot be null"); > - if (action_flags & MLX5_FLOW_ENCAP_ACTIONS) > - return rte_flow_error_set(error, EINVAL, > - RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > - "can only have a single encap" > - " action in a flow"); > - /* encap without preceding decap is not supported for ingress */ > - if (!attr->transfer && attr->ingress && > - !(action_flags & MLX5_FLOW_ACTION_RAW_DECAP)) > - return rte_flow_error_set(error, ENOTSUP, > - > RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, > - NULL, > - "encap action not supported for " > - "ingress"); > - if (!raw_encap->size || !raw_encap->data) > - return rte_flow_error_set(error, EINVAL, > - RTE_FLOW_ERROR_TYPE_ACTION, > action, > - "raw encap data cannot be empty"); > - return 0; > -} > +const struct rte_flow_action_raw_decap empty_decap =3D {.data =3D NULL, > .size =3D 0,}; >=20 > /** > - * Validate the raw decap action. > + * Validate the raw encap and decap actions. > * > - * @param[in] action_flags > - * Holds the actions detected until now. > - * @param[in] action > + * @param[in] decap > + * Pointer to the decap action. > + * @param[in] encap > * Pointer to the encap action. > * @param[in] attr > * Pointer to flow attributes > + * @param[in/out] action_flags > + * Holds the actions detected until now. > + * @param[out] actions_n > + * pointer to the number of actions counter. > * @param[out] error > * Pointer to error structure. > * > @@ -2272,37 +2224,63 @@ struct field_modify_info modify_tcp[] =3D { > * 0 on success, a negative errno value otherwise and rte_errno is set= . > */ > static int > -flow_dv_validate_action_raw_decap(uint64_t action_flags, > - const struct rte_flow_action *action, > - const struct rte_flow_attr *attr, > - struct rte_flow_error *error) > +flow_dv_validate_action_raw_encap_decap > + (const struct rte_flow_action_raw_decap *decap, > + const struct rte_flow_action_raw_encap *encap, > + const struct rte_flow_attr *attr, uint64_t *action_flags, > + int *actions_n, struct rte_flow_error *error) > { > - const struct rte_flow_action_raw_decap *decap =3D action- > >conf; > + int ret; >=20 > - if (action_flags & MLX5_FLOW_ENCAP_ACTIONS) > + if (encap && (!encap->size || !encap->data)) > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > - "can't have encap action before" > - " decap action"); > - if (action_flags & MLX5_FLOW_DECAP_ACTIONS) > - return rte_flow_error_set(error, EINVAL, > - RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > - "can only have a single decap" > - " action in a flow"); > - /* decap action is valid on egress only if it is followed by encap */ > - if (attr->egress && decap && > - decap->size > MLX5_ENCAPSULATION_DECISION_SIZE) { > - return rte_flow_error_set(error, ENOTSUP, > - > RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, > - NULL, "decap action not supported" > - " for egress"); > - } else if (decap && decap->size > > MLX5_ENCAPSULATION_DECISION_SIZE && > - (action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS)) { > - return rte_flow_error_set(error, EINVAL, > - RTE_FLOW_ERROR_TYPE_ACTION, > - NULL, > - "can't have decap action " > - "after modify action"); > + "raw encap data cannot be empty"); > + if (decap && encap) { > + if (decap->size <=3D MLX5_ENCAPSULATION_DECISION_SIZE > && > + encap->size > MLX5_ENCAPSULATION_DECISION_SIZE) > + /* L3 encap. */ > + decap =3D NULL; > + else if (encap->size <=3D > + MLX5_ENCAPSULATION_DECISION_SIZE && > + decap->size > > + MLX5_ENCAPSULATION_DECISION_SIZE) > + /* L3 decap. */ > + encap =3D NULL; > + else if (encap->size > > + MLX5_ENCAPSULATION_DECISION_SIZE && > + decap->size > > + MLX5_ENCAPSULATION_DECISION_SIZE) > + /* 2 L2 actions: encap and decap. */ > + ; > + else > + return rte_flow_error_set(error, > + ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "unsupported too small " > + "raw decap and too small raw " > + "encap combination"); > + } > + if (decap) { > + ret =3D flow_dv_validate_action_decap(*action_flags, attr, > error); > + if (ret < 0) > + return ret; > + *action_flags |=3D MLX5_FLOW_ACTION_DECAP; > + ++(*actions_n); > + } > + if (encap) { > + if (encap->size <=3D MLX5_ENCAPSULATION_DECISION_SIZE) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "small raw encap size"); > + if (*action_flags & MLX5_FLOW_ACTION_ENCAP) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, > + "more than one encap > action"); > + *action_flags |=3D MLX5_FLOW_ACTION_ENCAP; > + ++(*actions_n); > } > return 0; > } > @@ -3054,7 +3032,7 @@ struct field_modify_info modify_tcp[] =3D { > return rte_flow_error_set(error, EINVAL, >=20 > RTE_FLOW_ERROR_TYPE_ACTION_CONF, > NULL, "action configuration not > set"); > - if (action_flags & MLX5_FLOW_ENCAP_ACTIONS) > + if (action_flags & MLX5_FLOW_ACTION_ENCAP) > return rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > "can't have encap action before" > @@ -4416,6 +4394,9 @@ struct field_modify_info modify_tcp[] =3D { > int actions_n =3D 0; > uint8_t item_ipv6_proto =3D 0; > const struct rte_flow_item *gre_item =3D NULL; > + const struct rte_flow_action_raw_decap *decap; > + const struct rte_flow_action_raw_encap *encap; > + const struct rte_flow_action_rss *rss; > struct rte_flow_item_tcp nic_tcp_mask =3D { > .hdr =3D { > .tcp_flags =3D 0xFF, > @@ -4425,6 +4406,7 @@ struct field_modify_info modify_tcp[] =3D { > }; > struct mlx5_priv *priv =3D dev->data->dev_private; > struct mlx5_dev_config *dev_conf =3D &priv->config; > + uint16_t queue_index =3D 0xFFFF; >=20 > if (items =3D=3D NULL) > return -1; > @@ -4756,16 +4738,21 @@ struct field_modify_info modify_tcp[] =3D { > attr, error); > if (ret < 0) > return ret; > + queue_index =3D ((const struct rte_flow_action_queue > *) > + (actions->conf))- > >index; > action_flags |=3D MLX5_FLOW_ACTION_QUEUE; > ++actions_n; > break; > case RTE_FLOW_ACTION_TYPE_RSS: > + rss =3D actions->conf; > ret =3D mlx5_flow_validate_action_rss(actions, > action_flags, dev, > attr, item_flags, > error); > if (ret < 0) > return ret; > + if (rss !=3D NULL && rss->queue_num) > + queue_index =3D rss->queue[0]; > action_flags |=3D MLX5_FLOW_ACTION_RSS; > ++actions_n; > break; > @@ -4816,45 +4803,44 @@ struct field_modify_info modify_tcp[] =3D { > case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP: > ret =3D > flow_dv_validate_action_l2_encap(action_flags, > - actions, attr, > - error); > + actions, error); > if (ret < 0) > return ret; > - action_flags |=3D actions->type =3D=3D > - > RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP ? > - > MLX5_FLOW_ACTION_VXLAN_ENCAP : > - > MLX5_FLOW_ACTION_NVGRE_ENCAP; > + action_flags |=3D MLX5_FLOW_ACTION_ENCAP; > ++actions_n; > break; > case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: > case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP: > - ret =3D > flow_dv_validate_action_l2_decap(action_flags, > - attr, error); > + ret =3D flow_dv_validate_action_decap(action_flags, > attr, > + error); > if (ret < 0) > return ret; > - action_flags |=3D actions->type =3D=3D > - > RTE_FLOW_ACTION_TYPE_VXLAN_DECAP ? > - > MLX5_FLOW_ACTION_VXLAN_DECAP : > - > MLX5_FLOW_ACTION_NVGRE_DECAP; > + action_flags |=3D MLX5_FLOW_ACTION_DECAP; > ++actions_n; > break; > case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: > - ret =3D > flow_dv_validate_action_raw_encap(action_flags, > - actions, attr, > - error); > + ret =3D flow_dv_validate_action_raw_encap_decap > + (NULL, actions->conf, attr, &action_flags, > + &actions_n, error); > if (ret < 0) > return ret; > - action_flags |=3D MLX5_FLOW_ACTION_RAW_ENCAP; > - ++actions_n; > break; > case RTE_FLOW_ACTION_TYPE_RAW_DECAP: > - ret =3D > flow_dv_validate_action_raw_decap(action_flags, > - actions, attr, > - error); > + decap =3D actions->conf; > + while ((++actions)->type =3D=3D > RTE_FLOW_ACTION_TYPE_VOID) > + ; > + if (actions->type !=3D > RTE_FLOW_ACTION_TYPE_RAW_ENCAP) { > + encap =3D NULL; > + actions--; > + } else { > + encap =3D actions->conf; > + } > + ret =3D flow_dv_validate_action_raw_encap_decap > + (decap ? decap : &empty_decap, > encap, > + attr, &action_flags, &actions_n, > + error); > if (ret < 0) > return ret; > - action_flags |=3D MLX5_FLOW_ACTION_RAW_DECAP; > - ++actions_n; > break; > case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > @@ -5082,6 +5068,22 @@ struct field_modify_info modify_tcp[] =3D { > actions, > "no fate action is found"); > } > + /* Continue validation for Xcap actions.*/ > + if ((action_flags & MLX5_FLOW_XCAP_ACTIONS) && (queue_index > =3D=3D 0xFFFF || > + mlx5_rxq_get_type(dev, queue_index) !=3D > MLX5_RXQ_TYPE_HAIRPIN)) { > + if ((action_flags & MLX5_FLOW_XCAP_ACTIONS) =3D=3D > + MLX5_FLOW_XCAP_ACTIONS) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "encap and decap " > + "combination arn't > suported"); > + if (!attr->transfer && attr->ingress && (action_flags & > + > MLX5_FLOW_ACTION_ENCAP)) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "encap is not > supported" > + " for ingress traffic"); > + } > return 0; > } >=20 > @@ -7305,10 +7307,7 @@ struct field_modify_info modify_tcp[] =3D { > return -rte_errno; > dev_flow->dv.actions[actions_n++] =3D > dev_flow->dv.encap_decap->verbs_action; > - action_flags |=3D actions->type =3D=3D > - > RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP ? > - > MLX5_FLOW_ACTION_VXLAN_ENCAP : > - > MLX5_FLOW_ACTION_NVGRE_ENCAP; > + action_flags |=3D MLX5_FLOW_ACTION_ENCAP; > break; > case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: > case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP: > @@ -7318,14 +7317,11 @@ struct field_modify_info modify_tcp[] =3D { > return -rte_errno; > dev_flow->dv.actions[actions_n++] =3D > dev_flow->dv.encap_decap->verbs_action; > - action_flags |=3D actions->type =3D=3D > - > RTE_FLOW_ACTION_TYPE_VXLAN_DECAP ? > - > MLX5_FLOW_ACTION_VXLAN_DECAP : > - > MLX5_FLOW_ACTION_NVGRE_DECAP; > + action_flags |=3D MLX5_FLOW_ACTION_DECAP; > break; > case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: > /* Handle encap with preceding decap. */ > - if (action_flags & > MLX5_FLOW_ACTION_RAW_DECAP) { > + if (action_flags & MLX5_FLOW_ACTION_DECAP) { > if (flow_dv_create_action_raw_encap > (dev, actions, dev_flow, attr, error)) > return -rte_errno; > @@ -7340,15 +7336,11 @@ struct field_modify_info modify_tcp[] =3D { > dev_flow->dv.actions[actions_n++] =3D > dev_flow->dv.encap_decap- > >verbs_action; > } > - action_flags |=3D MLX5_FLOW_ACTION_RAW_ENCAP; > + action_flags |=3D MLX5_FLOW_ACTION_ENCAP; > break; > case RTE_FLOW_ACTION_TYPE_RAW_DECAP: > - /* Check if this decap is followed by encap. */ > - for (; action->type !=3D RTE_FLOW_ACTION_TYPE_END > && > - action->type !=3D > RTE_FLOW_ACTION_TYPE_RAW_ENCAP; > - action++) { > - } > - /* Handle decap only if it isn't followed by encap. */ > + while ((++action)->type =3D=3D > RTE_FLOW_ACTION_TYPE_VOID) > + ; > if (action->type !=3D > RTE_FLOW_ACTION_TYPE_RAW_ENCAP) { > if (flow_dv_create_action_l2_decap > (dev, dev_flow, attr->transfer, error)) > @@ -7357,7 +7349,7 @@ struct field_modify_info modify_tcp[] =3D { > dev_flow->dv.encap_decap- > >verbs_action; > } > /* If decap is followed by encap, handle it at encap. > */ > - action_flags |=3D MLX5_FLOW_ACTION_RAW_DECAP; > + action_flags |=3D MLX5_FLOW_ACTION_DECAP; > break; > case RTE_FLOW_ACTION_TYPE_JUMP: > jump_data =3D action->conf; > -- > 1.8.3.1 Fixed warning issue, and applied to next-net-mlx, Kindest regards, Raslan Darawsheh