From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0052.outbound.protection.outlook.com [104.47.2.52]) by dpdk.org (Postfix) with ESMTP id 92A2F1B119 for ; Wed, 24 Oct 2018 14:59:02 +0200 (CEST) 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=umeOF4L6vxC8qzbEfcoKCkIhiS92OwodV1+XuM+GcT4=; b=ACJJfdyXkJVrp/4n2r8D6S04JTcgc7Rnww1Vtd8Sp5Mjw3OCCjuDrKGGodsbNi6a8+4iXTBL963SI7gXNpvdMyXQ8Xafnr+t2b1RUGTh7z4i9ZNWQ4xWNOaAne2ZfZ9Rf5fQofi4ZwHUp6i/dDDi8mI9ovEG+139a0A27JKBrzc= Received: from VI1PR05MB3440.eurprd05.prod.outlook.com (10.170.239.18) by VI1PR05MB5552.eurprd05.prod.outlook.com (20.177.201.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.26; Wed, 24 Oct 2018 12:59:01 +0000 Received: from VI1PR05MB3440.eurprd05.prod.outlook.com ([fe80::fcd0:7d8f:ee3e:3a8d]) by VI1PR05MB3440.eurprd05.prod.outlook.com ([fe80::fcd0:7d8f:ee3e:3a8d%4]) with mapi id 15.20.1250.028; Wed, 24 Oct 2018 12:59:00 +0000 From: Ori Kam To: Dekel Peled , Yongseok Koh , Shahaf Shuler CC: "dev@dpdk.org" Thread-Topic: [PATCH 1/2] net/mlx5: add VXLAN encap decap to Direct Verbs Thread-Index: AQHUa4oC4PoinOea50qSYYxFUpy1CaUuRjMg Date: Wed, 24 Oct 2018 12:59:00 +0000 Message-ID: References: <1540379299-23764-1-git-send-email-dekelp@mellanox.com> <1540379299-23764-2-git-send-email-dekelp@mellanox.com> In-Reply-To: <1540379299-23764-2-git-send-email-dekelp@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=orika@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB5552; 6:P8cgtg9g5bJvidcsXU05r+sWsaiLBBohNzXrrKdNnxc/raU1clQ84cxQU7/TOUoy2gFs2h04nSS4+o6gasUK26zIs0lKkLiyn/DqIqX3dfVBQ8nD0vUm0JXlx0abSprSM7xbycjoM04y76DIqQx6L9WddlmZAy2cLBV8i2oocxNzm5u1M/kwh9tPy1wcyO4J/WSEEwTmPgC7t4t2EzdjFRZbSPWswEv+RFAS/oxH8LLthvyg9f+YBaB7ch5HnI1wh+PtIOXVv3sgm1WO6FtjJqwdhfKwB8+zGP3bwV2kMp3nOiFiKOq8h05rUKSiDDzEsH2N4AIo+G8VAqjfjsJEsJJbQgsrLKzsDVV2S3bvE0ciDnCLhMK1EsFRs0u49URW0vaGOG+fxWwQkOaYxvSBaGBZDa/i9kDhl9Z4FIIzV1N9ooc1LdtEl3Q3agUiUoApPmO0WyhUH62vocB+PanWUg==; 5:qpGKTMtwSyv+x6o4eHzkoEBEk/uIOPDTBlnv+1uqaHWL0XcKbAJG0b/aYdHGGESrnDnbbForsAoPypVS/W3GOqPazEMIzYexQ8VQm0A3k/WqOWFckRM5l3OrX+AZ0op0XCyxmrUkgM7g5speOF4i3YoLw2P9RdIPlO3PNMtCETw=; 7:sKEzOyMFCvkarSYBl8pek0FhYEc8vYps7ia0wScnRzKmRJhJ5lt26zDdSLL9JTHYvyqXNWN60m6osrbRWfqP7BwQ5yu5PaPz2KeVp7ciTO3Kjm2sithucP7hPFM6/o/kwLAvi+9s3wQ0HlZb4VpuLu/JAN6XitaZ/Q7PLj+IIGdM5l/7DqyaSrYwcUTd3YrOv/8h1tUsPkfQhSlyae6P1zxIAGtLWGKJFUKBJFLoGGuZGwbEU7PsTpEoSPosyojN x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 9af7d8ae-0532-4391-b02f-08d639b07802 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB5552; x-ms-traffictypediagnostic: VI1PR05MB5552: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB5552; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB5552; x-forefront-prvs: 083526BF8A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(346002)(136003)(376002)(39860400002)(57704003)(13464003)(189003)(199004)(102836004)(105586002)(106356001)(2900100001)(4326008)(53546011)(6436002)(53936002)(9686003)(55016002)(68736007)(26005)(229853002)(256004)(14444005)(7696005)(99286004)(76176011)(6506007)(446003)(186003)(11346002)(110136005)(81166006)(8676002)(81156014)(486006)(8936002)(476003)(74316002)(25786009)(53946003)(478600001)(7736002)(5250100002)(97736004)(14454004)(305945005)(6116002)(2906002)(6246003)(3846002)(4744004)(71190400001)(6636002)(5660300001)(71200400001)(575784001)(86362001)(316002)(33656002)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB5552; H:VI1PR05MB3440.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-microsoft-antispam-message-info: XJX8bYxV2NE/OJKn6f4YilaE0EQf5cF88Y9N5x3TweHZmvHartsoG+lJsv2gnpDmJNYIJskpg9WrAY6/2b69TJCqoFV3ackuWYaYdh9toN0u0u/pifHEdPDOR5iEhaa/I/083IGOkGQhkapStdab+Zbx0wwYy4OYjVeTC5teJiLnVCLABngihCRh3ICrBslRLACC4OKJangdwHD6l+xWdqjyGbBErJ9f5VYW1rjMY8jqrO3BOwSBads9/+wI3MQlDCcAiKQkypFAvgjQXZv9pGlHBPyq78XDpRx9OzXkuhk/W5mJadQud4fpf9hVmAP066sWOoPRGEFt3hHvFIH69xsQQVJ6YasUPb2YkX2EOqU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM 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: 9af7d8ae-0532-4391-b02f-08d639b07802 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Oct 2018 12:59:00.9035 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB5552 Subject: Re: [dpdk-dev] [PATCH 1/2] net/mlx5: add VXLAN encap decap to Direct Verbs 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: , X-List-Received-Date: Wed, 24 Oct 2018 12:59:02 -0000 > -----Original Message----- > From: Dekel Peled > Sent: Wednesday, October 24, 2018 2:08 PM > To: Yongseok Koh ; Shahaf Shuler > > Cc: dev@dpdk.org; Ori Kam > Subject: [PATCH 1/2] net/mlx5: add VXLAN encap decap to Direct Verbs >=20 > This patch adds support for VXLAN encap and decap operations, in > Direct Verbs flow. >=20 > Signed-off-by: Dekel Peled > --- > drivers/net/mlx5/mlx5_flow.h | 4 + > drivers/net/mlx5/mlx5_flow_dv.c | 409 > +++++++++++++++++++++++++++++++++++++++- > 2 files changed, 408 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 38635c9..9c28e50 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -92,6 +92,8 @@ > #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) >=20 > #define MLX5_FLOW_FATE_ACTIONS \ > (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | > MLX5_FLOW_ACTION_RSS) > @@ -181,6 +183,8 @@ struct mlx5_flow_dv { > #ifdef HAVE_IBV_FLOW_DV_SUPPORT > struct mlx5dv_flow_action_attr > actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS]; > /**< Action list. */ > + struct ibv_flow_action *encap_verb; /**< Verbs object of encap. */ > + struct ibv_flow_action *decap_verb; /**< Verbs object of decap. */ Why do we need encap and decap? > #endif > int actions_n; /**< number of actions. */ > }; > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c > b/drivers/net/mlx5/mlx5_flow_dv.c > index e8f409f..06ecabf 100644 > --- a/drivers/net/mlx5/mlx5_flow_dv.c > +++ b/drivers/net/mlx5/mlx5_flow_dv.c > @@ -35,6 +35,16 @@ >=20 > #ifdef HAVE_IBV_FLOW_DV_SUPPORT >=20 > +#define MLX5_UDP 17 > +#define MLX5_TCP 6 > +#define MLX5_GRE 47 Please use already created defines. (IPPROTO_TCP) > + > +/* > + * Encap buf length, max: > + * Eth:14/VLAN:8/IPv6:40/TCP:36/TUNNEL:20/Eth:14 > + */ > +#define MLX5_ENCAP_LEN 132 > + > /** > * Validate META item. > * > @@ -97,6 +107,331 @@ > } >=20 > /** > + * Validate the vxlan 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_vxlan_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_vxlan_encap *vxlan_encap =3D action->conf; > + > + if (!vxlan_encap) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > action, > + "configuration cannot be null"); > + if (action_flags & MLX5_FLOW_ACTION_DROP) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > + "can't drop and encap in same flow"); > + if (action_flags & MLX5_FLOW_ACTION_VXLAN_ENCAP) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > + "can't have 2 encap actions in same" > + " flow"); > + if (attr->ingress) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, > + NULL, > + "encap action not supported for " > + "ingress"); > + return 0; > +} > + > +/** > + * Validate the vxlan decap action. > + * > + * @param[in] action_flags > + * Holds the actions detected until now. > + * @param[in] action > + * Pointer to the decap 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_vxlan_decap(uint64_t action_flags, > + const struct rte_flow_action *action __rte_unused, > + const struct rte_flow_attr *attr, > + struct rte_flow_error *error) > +{ > + if (action_flags & MLX5_FLOW_ACTION_DROP) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > + "can't drop and decap in same flow"); > + if (action_flags & MLX5_FLOW_ACTION_VXLAN_ENCAP) > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > NULL, > + "can't encap and decap in same > flow"); > + if (attr->egress) > + return rte_flow_error_set(error, ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, > + NULL, > + "decap action not supported for " > + "egress"); Why not EINVAL? > + return 0; > +} > + > +static size_t item_len[] =3D { > + [RTE_FLOW_ITEM_TYPE_VOID] =3D 0, > + [RTE_FLOW_ITEM_TYPE_ETH] =3D sizeof(struct rte_flow_item_eth), > + [RTE_FLOW_ITEM_TYPE_VLAN] =3D sizeof(struct rte_flow_item_vlan), > + [RTE_FLOW_ITEM_TYPE_IPV4] =3D sizeof(struct rte_flow_item_ipv4), > + [RTE_FLOW_ITEM_TYPE_IPV6] =3D sizeof(struct rte_flow_item_ipv6), > + [RTE_FLOW_ITEM_TYPE_UDP] =3D sizeof(struct rte_flow_item_udp), > + [RTE_FLOW_ITEM_TYPE_TCP] =3D sizeof(struct rte_flow_item_tcp), > + [RTE_FLOW_ITEM_TYPE_VXLAN] =3D sizeof(struct rte_flow_item_vxlan), > + [RTE_FLOW_ITEM_TYPE_GRE] =3D sizeof(struct rte_flow_item_gre), > + [RTE_FLOW_ITEM_TYPE_NVGRE] =3D sizeof(struct rte_flow_item_gre), > + [RTE_FLOW_ITEM_TYPE_VXLAN_GPE] =3D sizeof(struct > rte_flow_item_vxlan_gpe), > + [RTE_FLOW_ITEM_TYPE_MPLS] =3D sizeof(struct rte_flow_item_mpls), > +}; > + > +/** > + * Convert the encap action data from rte_flow_item to raw buffer > + * > + * @param[in] item > + * Pointer to rte_flow_item object. > + * @param[out] buf > + * Pointer to the output buffer. > + * @param[out] size > + * Pointer to the output buffer size. > + * @param[out] error > + * Pointer to the error structure. > + * @param[in] l3_type > + * ???. What is ??? > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > + */ > +static int > +flow_dv_convert_encap(struct rte_flow_item *item, uint8_t *buf, size_t *= size, > + struct rte_flow_error *error, uint16_t l3_type) What is the l3_type used for? > +{ > + struct ether_hdr *eth =3D NULL; > + struct vlan_hdr *vlan =3D NULL; > + struct ipv4_hdr *ipv4 =3D NULL; > + struct ipv6_hdr *ipv6 =3D NULL; > + struct udp_hdr *udp =3D NULL; > + struct vxlan_hdr *vxlan =3D NULL; > + const struct rte_flow_item_vlan *vlan_spec; Why vlan has dedicated variable? > + size_t len; > + > + assert(item); Why assert on the item? It should be valid and if not return error. > + *size =3D 0; Why not use temp_size and avoid memory access? > + for (; item->type !=3D RTE_FLOW_ITEM_TYPE_END; item++) { > + /* TODO: variable length handling: raw, vxlan and nvgre. */ Why TODO? > + len =3D item_len[item->type]; This can result in crash if type is not the one you expected. > + if (len + *size > MLX5_ENCAP_LEN) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "invalid item length"); > + rte_memcpy((void *)&buf[*size], item->spec, len); > + switch (item->type) { > + case RTE_FLOW_ITEM_TYPE_ETH: > + eth =3D (void *)&buf[*size]; Why cast to void? Same for all others. > + break; > + case RTE_FLOW_ITEM_TYPE_VLAN: > + vlan_spec =3D item->spec; > + vlan =3D (void *)&buf[*size]; > + if (!eth) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "eth header not found"); > + vlan->vlan_tci =3D vlan_spec->tci; > + vlan->eth_proto =3D vlan_spec->inner_type; > + if (!eth->ether_type) > + eth->ether_type =3D htons(ETHER_TYPE_VLAN); Why not use rte_cpu_to_be? Same for all. > + break; > + case RTE_FLOW_ITEM_TYPE_IPV4: > + ipv4 =3D (void *)&buf[*size]; > + if (!vlan && !eth) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "neither eth nor vlan header > found"); > + if (vlan && !vlan->eth_proto) > + vlan->eth_proto =3D htons(ETHER_TYPE_IPv4); > + else if (eth && !eth->ether_type) > + eth->ether_type =3D htons(ETHER_TYPE_IPv4); > + if (!ipv4->version_ihl) > + ipv4->version_ihl =3D 0x45; > + if (!ipv4->time_to_live) > + ipv4->time_to_live =3D 0x40; > + break; > + case RTE_FLOW_ITEM_TYPE_IPV6: > + ipv6 =3D (void *)&buf[*size]; > + if (!vlan && !eth) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "neither eth nor vlan header > found"); > + if (vlan && !vlan->eth_proto) > + vlan->eth_proto =3D htons(ETHER_TYPE_IPv6); > + else if (eth && !eth->ether_type) > + eth->ether_type =3D htons(ETHER_TYPE_IPv6); > + if (!ipv6->vtc_flow) > + ipv6->vtc_flow =3D htonl(0x60000000); > + if (!ipv6->hop_limits) > + ipv6->hop_limits =3D 0xff; > + break; > + case RTE_FLOW_ITEM_TYPE_UDP: > + udp =3D (void *)&buf[*size]; > + if (!ipv4 && !ipv6) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "ip header not found"); > + if (ipv4 && !ipv4->next_proto_id) > + ipv4->next_proto_id =3D MLX5_UDP; > + else if (ipv6 && !ipv6->proto) > + ipv6->proto =3D MLX5_UDP; > + break; > + case RTE_FLOW_ITEM_TYPE_VXLAN: > + vxlan =3D (void *)&buf[*size]; > + if (!udp) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "udp header not found"); > + if (!udp->dst_port) > + udp->dst_port =3D > htons(MLX5_UDP_PORT_VXLAN); > + if (!vxlan->vx_flags) > + vxlan->vx_flags =3D htonl(0x08000000); > + break; > + case RTE_FLOW_ITEM_TYPE_VXLAN_GPE: > + vxlan =3D (void *)&buf[*size]; > + if (!udp) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "udp header not found"); > + if (!udp->dst_port) > + udp->dst_port =3D > htons(MLX5_UDP_PORT_VXLAN_GPE); > + if (!vxlan->vx_flags) > + vxlan->vx_flags =3D htonl(0x0c000003); > + break; > + case RTE_FLOW_ITEM_TYPE_GRE: > + case RTE_FLOW_ITEM_TYPE_NVGRE: > + if (!ipv4 && !ipv6) > + return rte_flow_error_set(error, EINVAL, > + > RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "ip header not found"); > + if (ipv4 && !ipv4->next_proto_id) > + ipv4->next_proto_id =3D htons(MLX5_GRE); > + else if (ipv6 && !ipv6->proto) > + ipv6->proto =3D htons(MLX5_GRE); > + break; > + case RTE_FLOW_ITEM_TYPE_VOID: > + break; > + default: > + return rte_flow_error_set(error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > + (void *)item->type, > + "unsupported item type"); > + break; > + } > + *size +=3D len; > + } > + if (l3_type && vlan) > + vlan->eth_proto =3D htons(l3_type); > + else if (l3_type && eth) > + eth->ether_type =3D htons(l3_type); > + return 0; > +} > + > +/** > + * Convert VXLAN encap action to DV specification. > + * > + * @param[in] dev > + * Pointer to rte_eth_dev structure. > + * @param[in] action > + * Pointer to action structure. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * Pointer to action on success, NULL otherwise and rte_errno is set. > + */ > +static struct ibv_flow_action * > +flow_dv_create_vxlan_encap(struct rte_eth_dev *dev, > + const struct rte_flow_action *action, > + struct rte_flow_error *error) > +{ > + struct ibv_flow_action *encap_verb =3D NULL; > + const struct rte_flow_action_vxlan_encap *encap_data; > + struct priv *priv =3D dev->data->dev_private; > + uint8_t buf[MLX5_ENCAP_LEN]; > + size_t size =3D 0; > + int convert_result; > + > + encap_data =3D (const struct rte_flow_action_vxlan_encap *)action- > >conf; > + convert_result =3D flow_dv_convert_encap(encap_data->definition, > + buf, &size, error, 0); > + if (convert_result) > + return NULL; > + encap_verb =3D mlx5_glue->dv_create_flow_action_packet_reformat > + (priv->ctx, size, (size ? buf : NULL), > + > MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL, > + MLX5DV_FLOW_TABLE_TYPE_NIC_TX); > + if (!encap_verb) > + rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "cannot create vxlan encap action"); > + return encap_verb; > +} > + > +/** > + * Convert VXLAN decap action to DV specification. > + * > + * @param[in] dev > + * Pointer to rte_eth_dev structure. > + * @param[in] action > + * Pointer to action structure. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * Pointer to action on success, NULL otherwise and rte_errno is set. > + */ > +static struct ibv_flow_action * > +flow_dv_create_vxlan_decap(struct rte_eth_dev *dev, > + const struct rte_flow_action *action __rte_unused, > + struct rte_flow_error *error) > +{ > + struct ibv_flow_action *decap_verb =3D NULL; > + struct priv *priv =3D dev->data->dev_private; > + > + decap_verb =3D mlx5_glue->dv_create_flow_action_packet_reformat > + (priv->ctx, 0, NULL, > + > MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2, > + MLX5DV_FLOW_TABLE_TYPE_NIC_RX); > + if (!decap_verb) > + rte_flow_error_set(error, EINVAL, > RTE_FLOW_ERROR_TYPE_ACTION, > + NULL, "cannot create decap action"); > + return decap_verb; > +} > + > +/** > * Verify the @p attributes will be correctly understood by the NIC and = store > * them in the @p flow if everything is correct. > * > @@ -347,6 +682,24 @@ > action_flags |=3D MLX5_FLOW_ACTION_COUNT; > ++actions_n; > break; > + case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > + ret =3D > flow_dv_validate_action_vxlan_encap(action_flags, > + actions, attr, > + error); > + if (ret < 0) > + return ret; > + action_flags |=3D MLX5_FLOW_ACTION_VXLAN_ENCAP; > + ++actions_n; > + break; > + case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: > + ret =3D > flow_dv_validate_action_vxlan_decap(action_flags, > + actions, attr, > + error); > + if (ret < 0) > + return ret; > + action_flags |=3D MLX5_FLOW_ACTION_VXLAN_DECAP; > + ++actions_n; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, >=20 > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -1056,14 +1409,23 @@ > /** > * Store the requested actions in an array. > * > + * @param[in] dev > + * Pointer to rte_eth_dev structure. > * @param[in] action > * Flow action to translate. > * @param[in, out] dev_flow > * Pointer to the mlx5_flow. > + * @param[out] error > + * Pointer to the error structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set= . > */ > -static void > -flow_dv_create_action(const struct rte_flow_action *action, > - struct mlx5_flow *dev_flow) > +static int > +flow_dv_create_action(struct rte_eth_dev *dev, > + const struct rte_flow_action *action, > + struct mlx5_flow *dev_flow, > + struct rte_flow_error *error) > { > const struct rte_flow_action_queue *queue; > const struct rte_flow_action_rss *rss; > @@ -1110,10 +1472,35 @@ > /* Added to array only in apply since we need the QP */ > flow->actions |=3D MLX5_FLOW_ACTION_RSS; > break; > + case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > + dev_flow->dv.actions[actions_n].type =3D > + MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION; > + dev_flow->dv.actions[actions_n].action =3D > + flow_dv_create_vxlan_encap(dev, action, > error); > + if (!(dev_flow->dv.actions[actions_n].action)) > + return -rte_errno; > + dev_flow->dv.encap_verb =3D > + dev_flow->dv.actions[actions_n].action; > + flow->actions |=3D MLX5_FLOW_ACTION_VXLAN_ENCAP; > + actions_n++; > + break; > + case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP: > + dev_flow->dv.actions[actions_n].type =3D > + MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION; > + dev_flow->dv.actions[actions_n].action =3D > + flow_dv_create_vxlan_decap(dev, action, > error); > + if (!(dev_flow->dv.actions[actions_n].action)) > + return -rte_errno; > + dev_flow->dv.decap_verb =3D > + dev_flow->dv.actions[actions_n].action; > + flow->actions |=3D MLX5_FLOW_ACTION_VXLAN_DECAP; > + actions_n++; > + break; > default: > break; > } > dev_flow->dv.actions_n =3D actions_n; > + return 0; > } >=20 > static uint32_t matcher_zero[MLX5_ST_SZ_DW(fte_match_param)] =3D { 0 }; > @@ -1279,8 +1666,10 @@ > matcher.egress =3D attr->egress; > if (flow_dv_matcher_register(dev, &matcher, dev_flow, error)) > return -rte_errno; > - for (; actions->type !=3D RTE_FLOW_ACTION_TYPE_END; actions++) > - flow_dv_create_action(actions, dev_flow); > + for (; actions->type !=3D RTE_FLOW_ACTION_TYPE_END; actions++) { > + if (flow_dv_create_action(dev, actions, dev_flow, error)) > + return -rte_errno; > + } > return 0; > } >=20 > @@ -1465,6 +1854,16 @@ > LIST_REMOVE(dev_flow, next); > if (dev_flow->dv.matcher) > flow_dv_matcher_release(dev, dev_flow); > + if (dev_flow->dv.encap_verb) { > + claim_zero(mlx5_glue->destroy_flow_action > + (dev_flow->dv.encap_verb)); > + dev_flow->dv.encap_verb =3D NULL; > + } > + if (dev_flow->dv.decap_verb) { > + claim_zero(mlx5_glue->destroy_flow_action > + (dev_flow->dv.decap_verb)); > + dev_flow->dv.decap_verb =3D NULL; > + } > rte_free(dev_flow); > } > } > -- > 1.8.3.1 Thanks, Ori