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 8A627A2EEB for ; Tue, 10 Sep 2019 12:42:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B561C1EDE3; Tue, 10 Sep 2019 12:42:24 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70085.outbound.protection.outlook.com [40.107.7.85]) by dpdk.org (Postfix) with ESMTP id D166E1EDE2 for ; Tue, 10 Sep 2019 12:42:23 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYzCUnDLWRnCgadJFVf3rWLLDHEaS38Gsb/kSpXo6u1oaN0IqH+ae5LhCn/I2wLjxrxWeM4UPy5I7NsAYg5dZWlik8vakwj5T9GuiaGdN4X4WqytU0EwUNrINI0iYbceOhaTUJeGR0pshbSTqlCM0RRGzb6DZSUfh1hT3kxZiBY050O71Ru/vbwIT9Xk/8bwq2gR80c80ZFgw4TWhLjIq5fNuycVUVm5WijGIYXBO6nTLLnEWxqHLsP+k70v325vmbB6MpXExMUIDStCQs234j4IJiT6B1vtD7cwKAO+BqyLJrRNe5rxLe9vgJ/qX+ps/GVOsXwXCb4mPmo4x0D5ag== 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=ol7zaZikHZAKq8ukGYi73Ao95FYSPv4PSGU4MAR7lhM=; b=nxQAwScEEN4CSlQDaOLGDkI/igX8a/1fULnAlj1joXeSXu8RiuAhqmsRrtDlZf9+JXoJohuPHaAdt9kbniVUSIEpydKC17VkChWQPkFgSTYWfHftchA+EbdTXqUJmL2OHo8fA2unduVMnV5SE050FPiq2xOHdjsoy06vKFcyan0tFYlfqeyUi/XIso+YgK1o+nUA0MLzJXPoJtXZpowEI+RQ/t3kR4MNvtVJIkhJXtDh9lLBfbR9IFYb/G1NZF600mqLTriDD7arXmH3ecetrIBiN/yVB59sl43txqVXjCTUum0sEBLRsWoYuvQawkK3Hx7GvK1iD95XF/gqvE6i5w== 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=ol7zaZikHZAKq8ukGYi73Ao95FYSPv4PSGU4MAR7lhM=; b=JmKP0In6/duYXbRwmSb6FJpgeLIAtFjtZSTjwxluMEvzdC8vr4ZW2JvnljqY9XgnOznrVkSobEjiVHVQL40GYYOZTNtEUk5eyUSUAMrxFNDZ1Y3bG2deBmTOj9qXJzD8dOTqEdwSzb+0Kf7G4V1iMEnKbME3ei1CcyOVidre07E= Received: from VI1PR05MB3278.eurprd05.prod.outlook.com (10.170.238.23) by VI1PR05MB4271.eurprd05.prod.outlook.com (52.133.12.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2241.14; Tue, 10 Sep 2019 10:42:22 +0000 Received: from VI1PR05MB3278.eurprd05.prod.outlook.com ([fe80::d4c:75b4:c928:3890]) by VI1PR05MB3278.eurprd05.prod.outlook.com ([fe80::d4c:75b4:c928:3890%7]) with mapi id 15.20.2241.018; Tue, 10 Sep 2019 10:42:22 +0000 From: Slava Ovsiienko To: Moti Haimovsky , Raslan Darawsheh CC: "dev@dpdk.org" Thread-Topic: [PATCH v5 4/7] net/mlx5: support push flow action on VLAN header Thread-Index: AQHVZyc2gBTNAhW2NkeCMZdFtWTsBackunXA Date: Tue, 10 Sep 2019 10:42:22 +0000 Message-ID: References: <8a16a03ca4e01cbd915588ca1a0c3c2c32cfac7d.1567951423.git.motih@mellanox.com> In-Reply-To: <8a16a03ca4e01cbd915588ca1a0c3c2c32cfac7d.1567951423.git.motih@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=viacheslavo@mellanox.com; x-originating-ip: [95.67.35.250] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 977c8bb3-414a-4e23-ed57-08d735db8fef x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VI1PR05MB4271; x-ms-traffictypediagnostic: VI1PR05MB4271:|VI1PR05MB4271: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:343; x-forefront-prvs: 01565FED4C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(366004)(396003)(376002)(39860400002)(346002)(13464003)(189003)(199004)(8936002)(66946007)(99286004)(64756008)(66556008)(66476007)(305945005)(2906002)(53546011)(316002)(86362001)(476003)(229853002)(446003)(9686003)(14444005)(53946003)(486006)(76116006)(66446008)(76176011)(7696005)(110136005)(55016002)(74316002)(256004)(6246003)(71190400001)(71200400001)(11346002)(53936002)(6506007)(6436002)(4326008)(6116002)(3846002)(8676002)(5660300002)(26005)(7736002)(81156014)(6636002)(186003)(102836004)(30864003)(52536014)(81166006)(25786009)(478600001)(33656002)(14454004)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4271; H:VI1PR05MB3278.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-message-info: rdNoYdyebu8cDROlO6s+px9X4G1hT4SQ62pyhTP0eNLeFIodBjxplkSTirMM0AzU2pMJYWgxq5q927aWlVDkP7tLkbm25nYJBEwTSTp++Kx4xAMtbDIBc5A+Pd8/Wp95rUP2MzSzSwttMo7YvYe2Ba4GXajzwIYbXrkxhBdeOVRrd7GrA1N6VREtim3098EWixfuNPgv8lKD34peteepGJSLjdxqIVv5LlHIxWMY7DUR2OhOIlaC0CglGKX67AcPKmEm0MCpv9cGkqoAAQWhH6ybr+Psfx3vX7qXqmTfEL0lwviXUwNVRI1vXzgqvYxGz7o7SIDAXGUlVHcQvsRrdHcruBMeidUXRRICC+y9dEDwNgoePESU+MnIgMzk+s5hHQfx2OclTShLdgRQ0xZmO8KmYT0engFY1YLb0grncIs= 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: 977c8bb3-414a-4e23-ed57-08d735db8fef X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Sep 2019 10:42:22.3431 (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: C5kJukd+s1APRmslR+iqhITL8sfXk/hCBiXs7jQgAlDULM3TVp+aQsDYxUBl3glTdWOuxObtW91cKPkimdlAZ0k/tNCUYyTfVkj3V50Hzhg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4271 Subject: Re: [dpdk-dev] [PATCH v5 4/7] net/mlx5: support push flow action on VLAN header 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" > -----Original Message----- > From: Moti Haimovsky > Sent: Monday, September 9, 2019 18:57 > To: Slava Ovsiienko ; Raslan Darawsheh > > Cc: dev@dpdk.org > Subject: [PATCH v5 4/7] net/mlx5: support push flow action on VLAN header >=20 > This commit adds support for RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN > using direct verbs flow rules. > If present in the flow, The VLAN default values are taken from the VLAN i= tem > configuration. > In this commit only the VLAN TPID value can be set since VLAN modificatio= n > actions are not supported yet. >=20 > Signed-off-by: Moti Haimovsky Acked-by: Viacheslav Ovsiienko > --- > v5: > - Fixed bug in retrieving VLAN VID and PCP from the existing VLAN flow it= em. > --- >=20 > doc/guides/nics/mlx5.rst | 6 +- > doc/guides/rel_notes/release_19_11.rst | 1 + > drivers/net/mlx5/mlx5.h | 2 + > drivers/net/mlx5/mlx5_flow.h | 18 ++- > drivers/net/mlx5/mlx5_flow_dv.c | 272 > +++++++++++++++++++++++++++++++++ > 5 files changed, 295 insertions(+), 4 deletions(-) >=20 > diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index > 2ae2e8f..875a87f 100644 > --- a/doc/guides/nics/mlx5.rst > +++ b/doc/guides/nics/mlx5.rst > @@ -130,6 +130,8 @@ Limitations > are lacking a match on VLAN as one of their items are not supported. > - The command is not supported on egress traffic. >=20 > +- VLAN push offload is not supported on ingress traffic. > + > - A multi segment packet must have not more segments than reported by > dev_infos_get() > in tx_desc_lim.nb_seg_max field. This value depends on maximal support= ed > Tx descriptor > size and ``txq_inline_min`` settings and may be from 2 (worst case for= ced > by maximal @@ -1039,8 +1041,8 @@ Supported hardware offloads > | | | ConnectX-5 | | N/A | > +-----------------------+-----------------+-----------------+ > | | VLAN | | DPDK 19.11 | | DPDK 19.11 | > - | | (of_pop_vlan) | | OFED 4.6-4 | | OFED 4.6-4 | > - | | | ConnectX-5 | | ConnectX-5 | > + | | (of_pop_vlan / | | OFED 4.6-4 | | OFED 4.6-4 | > + | | of_push_vlan) | | ConnectX-5 | | ConnectX-5 | > +-----------------------+-----------------+-----------------+ >=20 > Notes for testpmd > diff --git a/doc/guides/rel_notes/release_19_11.rst > b/doc/guides/rel_notes/release_19_11.rst > index 5c2ac15..afe92ab 100644 > --- a/doc/guides/rel_notes/release_19_11.rst > +++ b/doc/guides/rel_notes/release_19_11.rst > @@ -228,4 +228,5 @@ Tested Platforms > Updated Mellanox mlx5 driver with new features and improvements, > including: >=20 > * Added support for VLAN pop flow offload command. > + * Added support for VLAN push flow offload command. >=20 > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index > a18f588..dbdc3ce 100644 > --- a/drivers/net/mlx5/mlx5.h > +++ b/drivers/net/mlx5/mlx5.h > @@ -579,6 +579,8 @@ struct mlx5_ibv_shared { > LIST_HEAD(jump, mlx5_flow_dv_jump_tbl_resource) jump_tbl; > LIST_HEAD(port_id_action_list, > mlx5_flow_dv_port_id_action_resource) > port_id_action_list; /* List of port ID actions. */ > + LIST_HEAD(push_vlan_action_list, > mlx5_flow_dv_push_vlan_action_resource) > + push_vlan_action_list; /* List of push VLAN actions. */ > struct mlx5_flow_counter_mng cmng; /* Counters management > structure. */ > /* Shared interrupt handler section. */ > pthread_mutex_t intr_mutex; /* Interrupt config mutex. */ diff --git > a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index > 06b0470..15c9c04 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -150,7 +150,8 @@ >=20 > #define MLX5_FLOW_ENCAP_ACTIONS > (MLX5_FLOW_ACTION_VXLAN_ENCAP | \ > MLX5_FLOW_ACTION_NVGRE_ENCAP | \ > - MLX5_FLOW_ACTION_RAW_ENCAP) > + MLX5_FLOW_ACTION_RAW_ENCAP | \ > + MLX5_FLOW_ACTION_OF_PUSH_VLAN) >=20 > #define MLX5_FLOW_DECAP_ACTIONS > (MLX5_FLOW_ACTION_VXLAN_DECAP | \ > MLX5_FLOW_ACTION_NVGRE_DECAP | \ > @@ -172,7 +173,8 @@ > MLX5_FLOW_ACTION_INC_TCP_ACK | \ > MLX5_FLOW_ACTION_DEC_TCP_ACK) >=20 > -#define MLX5_FLOW_VLAN_ACTIONS > (MLX5_FLOW_ACTION_OF_POP_VLAN) > +#define MLX5_FLOW_VLAN_ACTIONS > (MLX5_FLOW_ACTION_OF_POP_VLAN | \ > + MLX5_FLOW_ACTION_OF_PUSH_VLAN) >=20 > #ifndef IPPROTO_MPLS > #define IPPROTO_MPLS 137 > @@ -309,6 +311,16 @@ struct mlx5_flow_dv_port_id_action_resource { > uint32_t port_id; /**< Port ID value. */ }; >=20 > +/* Push VLAN action resource structure */ struct > +mlx5_flow_dv_push_vlan_action_resource { > + LIST_ENTRY(mlx5_flow_dv_push_vlan_action_resource) next; > + /* Pointer to next element. */ > + rte_atomic32_t refcnt; /**< Reference counter. */ > + void *action; /**< Direct verbs action object. */ > + uint8_t ft_type; /**< Flow table type, Rx, Tx or FDB. */ > + rte_be32_t vlan_tag; /**< VLAN tag value. */ }; > + > /* > * Max number of actions per DV flow. > * See CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED > @@ -335,6 +347,8 @@ struct mlx5_flow_dv { > /**< Pointer to port ID action resource. */ > struct mlx5_vf_vlan vf_vlan; > /**< Structure for VF VLAN workaround. */ > + struct mlx5_flow_dv_push_vlan_action_resource *push_vlan_res; > + /**< Pointer to push VLAN action resource in cache. */ > #ifdef HAVE_IBV_FLOW_DV_SUPPORT > void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS]; > /**< Action list. */ > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c index fd2e810..2780735 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -50,6 +50,13 @@ > #define MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL 1 #endif >=20 > +/* VLAN header definitions */ > +#define MLX5DV_FLOW_VLAN_PCP_SHIFT 13 > +#define MLX5DV_FLOW_VLAN_PCP_MASK (0x7 << > MLX5DV_FLOW_VLAN_PCP_SHIFT) > +#define MLX5DV_FLOW_VLAN_VID_MASK 0x0fff #define > +MLX5DV_FLOW_VLAN_PCP_MASK_BE > RTE_BE16(MLX5DV_FLOW_VLAN_PCP_MASK) > +#define MLX5DV_FLOW_VLAN_VID_MASK_BE > +RTE_BE16(MLX5DV_FLOW_VLAN_VID_MASK) > + > union flow_dv_attr { > struct { > uint32_t valid:1; > @@ -817,6 +824,8 @@ struct field_modify_info modify_tcp[] =3D { > /** > * Validate the pop VLAN action. > * > + * @param[in] dev > + * Pointer to the rte_eth_dev structure. > * @param[in] action_flags > * Holds the actions detected until now. > * @param[in] action > @@ -870,6 +879,101 @@ struct field_modify_info modify_tcp[] =3D { } >=20 > /** > + * Get VLAN default info from vlan match info. > + * > + * @param[in] dev > + * Pointer to the rte_eth_dev structure. > + * @param[in] item > + * the list of item specifications. > + * @param[out] vlan > + * pointer VLAN info to fill to. > + * @param[out] error > + * Pointer to error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static void > +flow_dev_get_vlan_info_from_items(const struct rte_flow_item *items, > + struct rte_vlan_hdr *vlan) > +{ > + const struct rte_flow_item_vlan nic_mask =3D { > + .tci =3D RTE_BE16(MLX5DV_FLOW_VLAN_PCP_MASK | > + MLX5DV_FLOW_VLAN_VID_MASK), > + .inner_type =3D RTE_BE16(0xffff), > + }; > + > + if (items =3D=3D NULL) > + return; > + for (; items->type !=3D RTE_FLOW_ITEM_TYPE_END && > + items->type !=3D RTE_FLOW_ITEM_TYPE_VLAN; items++) > + ; > + if (items->type =3D=3D RTE_FLOW_ITEM_TYPE_VLAN) { > + const struct rte_flow_item_vlan *vlan_m =3D items->mask; > + const struct rte_flow_item_vlan *vlan_v =3D items->spec; > + > + if (!vlan_m) > + vlan_m =3D &nic_mask; > + /* Only full match values are accepted */ > + if ((vlan_m->tci & MLX5DV_FLOW_VLAN_PCP_MASK_BE) =3D=3D > + MLX5DV_FLOW_VLAN_PCP_MASK_BE) { > + vlan->vlan_tci &=3D MLX5DV_FLOW_VLAN_PCP_MASK; > + vlan->vlan_tci |=3D > + rte_be_to_cpu_16(vlan_v->tci & > + > MLX5DV_FLOW_VLAN_PCP_MASK_BE); > + } > + if ((vlan_m->tci & MLX5DV_FLOW_VLAN_VID_MASK_BE) =3D=3D > + MLX5DV_FLOW_VLAN_VID_MASK_BE) { > + vlan->vlan_tci &=3D > ~MLX5DV_FLOW_VLAN_VID_MASK; > + vlan->vlan_tci |=3D > + rte_be_to_cpu_16(vlan_v->tci & > + > MLX5DV_FLOW_VLAN_VID_MASK_BE); > + } > + if (vlan_m->inner_type =3D=3D nic_mask.inner_type) > + vlan->eth_proto =3D rte_be_to_cpu_16(vlan_v- > >inner_type & > + vlan_m- > >inner_type); > + } > +} > + > +/** > + * Validate the push VLAN 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_push_vlan(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_of_push_vlan *push_vlan =3D action- > >conf; > + > + if (push_vlan->ethertype !=3D RTE_BE16(RTE_ETHER_TYPE_VLAN) && > + push_vlan->ethertype !=3D RTE_BE16(RTE_ETHER_TYPE_QINQ)) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > action, > + "invalid vlan ethertype"); > + if (action_flags & > + (MLX5_FLOW_ACTION_OF_POP_VLAN | > MLX5_FLOW_ACTION_OF_PUSH_VLAN)) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > action, > + "no support for multiple VLAN " > + "actions"); > + (void)attr; > + return 0; > +} > + > +/** > * Validate count action. > * > * @param[in] dev > @@ -1300,6 +1404,77 @@ struct field_modify_info modify_tcp[] =3D { } >=20 > /** > + * Find existing push vlan resource or create and register a new one. > + * > + * @param dev[in, out] > + * Pointer to rte_eth_dev structure. > + * @param[in, out] resource > + * Pointer to port ID action resource. > + * @parm[in, out] dev_flow > + * Pointer to the dev_flow. > + * @param[out] error > + * pointer to error structure. > + * > + * @return > + * 0 on success otherwise -errno and errno is set. > + */ > +static int > +flow_dv_push_vlan_action_resource_register > + (struct rte_eth_dev *dev, > + struct mlx5_flow_dv_push_vlan_action_resource > *resource, > + struct mlx5_flow *dev_flow, > + struct rte_flow_error *error) > +{ > + struct mlx5_priv *priv =3D dev->data->dev_private; > + struct mlx5_ibv_shared *sh =3D priv->sh; > + struct mlx5_flow_dv_push_vlan_action_resource *cache_resource; > + struct mlx5dv_dr_domain *domain; > + > + /* Lookup a matching resource from cache. */ > + LIST_FOREACH(cache_resource, &sh->push_vlan_action_list, next) { > + if (resource->vlan_tag =3D=3D cache_resource->vlan_tag && > + resource->ft_type =3D=3D cache_resource->ft_type) { > + DRV_LOG(DEBUG, "push-VLAN action resource > resource %p: " > + "refcnt %d++", > + (void *)cache_resource, > + rte_atomic32_read(&cache_resource- > >refcnt)); > + rte_atomic32_inc(&cache_resource->refcnt); > + dev_flow->dv.push_vlan_res =3D cache_resource; > + return 0; > + } > + } > + /* Register new push_vlan action resource. */ > + cache_resource =3D rte_calloc(__func__, 1, sizeof(*cache_resource), > 0); > + if (!cache_resource) > + return rte_flow_error_set(error, ENOMEM, > + > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, > + "cannot allocate resource > memory"); > + *cache_resource =3D *resource; > + if (resource->ft_type =3D=3D MLX5DV_FLOW_TABLE_TYPE_FDB) > + domain =3D sh->fdb_domain; > + else if (resource->ft_type =3D=3D MLX5DV_FLOW_TABLE_TYPE_NIC_RX) > + domain =3D sh->rx_domain; > + else > + domain =3D sh->tx_domain; > + cache_resource->action =3D > + mlx5_glue->dr_create_flow_action_push_vlan(domain, > + resource- > >vlan_tag); > + if (!cache_resource->action) { > + rte_free(cache_resource); > + return rte_flow_error_set(error, ENOMEM, > + > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, "cannot create action"); > + } > + rte_atomic32_init(&cache_resource->refcnt); > + rte_atomic32_inc(&cache_resource->refcnt); > + LIST_INSERT_HEAD(&sh->push_vlan_action_list, cache_resource, > next); > + dev_flow->dv.push_vlan_res =3D cache_resource; > + DRV_LOG(DEBUG, "new push vlan action resource %p: refcnt %d++", > + (void *)cache_resource, > + rte_atomic32_read(&cache_resource->refcnt)); > + return 0; > +} > +/** > * Get the size of specific rte_flow_item_type > * > * @param[in] item_type > @@ -1719,6 +1894,44 @@ struct field_modify_info modify_tcp[] =3D { } >=20 > /** > + * Create action push VLAN. > + * > + * @param[in] dev > + * Pointer to rte_eth_dev structure. > + * @param[in] vlan_tag > + * the vlan tag to push to the Ethernet header. > + * @param[in, out] dev_flow > + * Pointer to the mlx5_flow. > + * @param[in] attr > + * Pointer to the flow attributes. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_create_action_push_vlan(struct rte_eth_dev *dev, > + const struct rte_flow_attr *attr, > + const struct rte_vlan_hdr *vlan, > + struct mlx5_flow *dev_flow, > + struct rte_flow_error *error) > +{ > + struct mlx5_flow_dv_push_vlan_action_resource res; > + > + res.vlan_tag =3D > + rte_cpu_to_be_32(((uint32_t)vlan->eth_proto) << 16 | > + vlan->vlan_tci); > + if (attr->transfer) > + res.ft_type =3D MLX5DV_FLOW_TABLE_TYPE_FDB; > + else > + res.ft_type =3D attr->egress ? > MLX5DV_FLOW_TABLE_TYPE_NIC_TX : > + > MLX5DV_FLOW_TABLE_TYPE_NIC_RX; > + return flow_dv_push_vlan_action_resource_register > + (dev, &res, dev_flow, error); > +} > + > +/** > * Validate the modify-header actions. > * > * @param[in] action_flags > @@ -3174,6 +3387,15 @@ struct field_modify_info modify_tcp[] =3D { > action_flags |=3D > MLX5_FLOW_ACTION_OF_POP_VLAN; > ++actions_n; > break; > + case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: > + ret =3D > flow_dv_validate_action_push_vlan(action_flags, > + actions, attr, > + error); > + if (ret < 0) > + return ret; > + action_flags |=3D > MLX5_FLOW_ACTION_OF_PUSH_VLAN; > + ++actions_n; > + break; > case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP: > ret =3D > flow_dv_validate_action_l2_encap(action_flags, > @@ -4765,6 +4987,8 @@ struct field_modify_info modify_tcp[] =3D { > void *match_mask =3D matcher.mask.buf; > void *match_value =3D dev_flow->dv.value.buf; > uint8_t next_protocol =3D 0xff; > + struct rte_vlan_hdr vlan =3D { 0 }; > + bool vlan_inherited =3D false; >=20 > flow->group =3D attr->group; > if (attr->transfer) > @@ -4879,6 +5103,21 @@ struct field_modify_info modify_tcp[] =3D { > priv->sh->pop_vlan_action; > action_flags |=3D > MLX5_FLOW_ACTION_OF_POP_VLAN; > break; > + case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN: > + if (!vlan_inherited) { > + flow_dev_get_vlan_info_from_items(items, > &vlan); > + vlan_inherited =3D true; > + } > + vlan.eth_proto =3D rte_be_to_cpu_16 > + ((((const struct rte_flow_action_of_push_vlan *) > + actions->conf)- > >ethertype)); > + if (flow_dv_create_action_push_vlan > + (dev, attr, &vlan, dev_flow, error)) > + return -rte_errno; > + dev_flow->dv.actions[actions_n++] =3D > + dev_flow->dv.push_vlan_res- > >action; > + action_flags |=3D > MLX5_FLOW_ACTION_OF_PUSH_VLAN; > + break; > case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP: > if (flow_dv_create_action_l2_encap(dev, actions, > @@ -5526,6 +5765,37 @@ struct field_modify_info modify_tcp[] =3D { } >=20 > /** > + * Release push vlan action resource. > + * > + * @param flow > + * Pointer to mlx5_flow. > + * > + * @return > + * 1 while a reference on it exists, 0 when freed. > + */ > +static int > +flow_dv_push_vlan_action_resource_release(struct mlx5_flow *flow) { > + struct mlx5_flow_dv_push_vlan_action_resource *cache_resource =3D > + flow->dv.push_vlan_res; > + > + assert(cache_resource->action); > + DRV_LOG(DEBUG, "push VLAN action resource %p: refcnt %d--", > + (void *)cache_resource, > + rte_atomic32_read(&cache_resource->refcnt)); > + if (rte_atomic32_dec_and_test(&cache_resource->refcnt)) { > + claim_zero(mlx5_glue->destroy_flow_action > + (cache_resource->action)); > + LIST_REMOVE(cache_resource, next); > + rte_free(cache_resource); > + DRV_LOG(DEBUG, "push vlan action resource %p: removed", > + (void *)cache_resource); > + return 0; > + } > + return 1; > +} > + > +/** > * Remove the flow from the NIC but keeps it in memory. > * > * @param[in] dev > @@ -5597,6 +5867,8 @@ struct field_modify_info modify_tcp[] =3D { > flow_dv_jump_tbl_resource_release(dev_flow); > if (dev_flow->dv.port_id_action) >=20 > flow_dv_port_id_action_resource_release(dev_flow); > + if (dev_flow->dv.push_vlan_res) > + > flow_dv_push_vlan_action_resource_release(dev_flow); > rte_free(dev_flow); > } > } > -- > 1.8.3.1