From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70053.outbound.protection.outlook.com [40.107.7.53]) by dpdk.org (Postfix) with ESMTP id E7038201 for ; Thu, 25 Oct 2018 07:53:17 +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=Ltdb7eQ0WgWSkAmgfEK+lPuIsdBYa1qOokXtuHnH3t4=; b=D3ZBuXlXO/au0cm/PNZJJY45+cYoE9eV+ArjkS/kci3Sw+cxp2jJiNo6JMiUhiir++xHhSH56Ek+zCILJPe1NSvAhODeQUQApcELqgUQ3mQJB4rTSaw8cD+1sxWN9tfVHJa0ujZwdpV+Sa+Td1yOd0BrcQXKTRsPdtn3KT26L7E= Received: from VI1PR05MB4224.eurprd05.prod.outlook.com (52.133.12.13) by VI1PR05MB1327.eurprd05.prod.outlook.com (10.162.122.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Thu, 25 Oct 2018 05:53:15 +0000 Received: from VI1PR05MB4224.eurprd05.prod.outlook.com ([fe80::345d:803:9e2:679c]) by VI1PR05MB4224.eurprd05.prod.outlook.com ([fe80::345d:803:9e2:679c%4]) with mapi id 15.20.1273.021; Thu, 25 Oct 2018 05:53:15 +0000 From: Dekel Peled To: Ori Kam , Yongseok Koh , Shahaf Shuler CC: "dev@dpdk.org" Thread-Topic: [PATCH 1/2] net/mlx5: add VXLAN encap decap to Direct Verbs Thread-Index: AQHUa4oAJ9ni0gJZEECgIxYkSqLjvqUuW5UAgABaw9A= Date: Thu, 25 Oct 2018 05:53:15 +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: 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-microsoft-exchange-diagnostics: 1; VI1PR05MB1327; 6:lEcTcna17AxNBYwkRiHTLFRddWmMaCpwfiwoumMbBduT6ra9YDltHgSE/GHxKgxUfBopW/d1xSBGgeMrJZ7MTIzl7gYiLey0ElYGjD+MheTCLT+fy7QNKVeBDGUHd0yApnRXusB+xidukMsFEWTTI1hydyRa7furvmB8jF5Jb8CtnYDZ2/De8xxyviq76b5XeBqGAZcamb9Y6W/qbr0xn0u9+56P+E9/9+nt/a8V2jrVNnqk0bmDffx466vpKyOemcHo+5ZBawGxjUIhA+NxbhG0fWdTYw4J08r4d2JkLnbh3TBwyYgSIEQgz3XTobhDE12ZX/eOF9H4XulH44i+gxLmu6w1Pxff1HerARVEgw+K7E98wTAB0l6onY+Vai8a+Y86IiydmnfDfYIOSLev8O4zWgnfmNOZ3Ez+CE9oKVO0s+qHzl4tom4KUfocbCP++MXKKWccsrfLbg5KPEbGrg==; 5:HAsuLxUAGg6PixOzRveJ2/1aGeVz6o2BtDw4plzHmf815UZspAXEbY7PUnMdy81R+GVYKPAmxhv6aZkLwcR4TCDoFs9bDlvQP5MbVRqadzAMJX6l9tZfzUab0PkeuTF88isN7VUjovH8DaAIH8Oam77rVLXD2BRMOVTaVBfSU5g=; 7:lxzwLTt3Y1UvofhPo2mFpM5wl87tylZNybD0BgyDOcgSzzav4uiZyMsLz0sPh2mIf4ubsnnRDNJzKiGhKHG1rBibcNvjJQH4OwXJOswhPonjNxu5bRUalnXM3K60O+7ZsuTRRT2dlQ8djg7SJMCis6w2DbROlZo8M5Gfi4WV/l7qNjTzSb2CmZs5Va/ZEMFXG0IZZrtXDX38k4igHoO5iDwaXa/zq/zDg5EQCiNwkmsS59skInYh+LujflcnJfEi x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 5cf44803-01ac-4a3f-e0d6-08d63a3e281d 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:VI1PR05MB1327; x-ms-traffictypediagnostic: VI1PR05MB1327: 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB1327; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB1327; x-forefront-prvs: 083691450C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(39860400002)(376002)(396003)(346002)(13464003)(189003)(199004)(57704003)(86362001)(110136005)(99286004)(33656002)(71190400001)(2900100001)(6246003)(71200400001)(53946003)(316002)(575784001)(14444005)(256004)(53936002)(6436002)(8936002)(9686003)(55016002)(229853002)(97736004)(4744004)(68736007)(478600001)(14454004)(81166006)(5250100002)(8676002)(81156014)(53546011)(26005)(186003)(4326008)(25786009)(486006)(476003)(446003)(11346002)(102836004)(6636002)(2906002)(6116002)(3846002)(7736002)(66066001)(305945005)(5660300001)(6506007)(76176011)(7696005)(106356001)(105586002)(74316002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1327; H:VI1PR05MB4224.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: tRPZDOo+Z7Z6ZrvDvkzsVYyViiuUDrP4rVO9PfI7T/eUbzFQx5DNXtQL7rEJuY35HEf9DuVMF4HCch50Upo/4+oB00v3pWBl9+W86woFCQ8RIst/NU0I1KcZE485vFcI5Jt1g0p9C4230i+W9zvOdY6Yv9MreCmNm13fqrp0H/9/VRPdecXRdj8OTVxd6yK+Mq2QMMz5CgcywqkSGX4cOuC+nk3gELl+yw2Io0El+IA1feeKl3AMhj4aUvBZ11raGlZMSfI2P1n4luE7rBwxWw4Be0ws8EJSvKlrcJarCxKdicJhALnYoc9jb0a5erJO8N/EbAh7W/0ltyh49WCQ7O9Dh3qIzMs/13enoOfAi9c= 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: 5cf44803-01ac-4a3f-e0d6-08d63a3e281d X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2018 05:53:15.3843 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1327 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: Thu, 25 Oct 2018 05:53:18 -0000 Thanks. I deferred the series, will send revised series later. > -----Original Message----- > From: Ori Kam > Sent: Wednesday, October 24, 2018 3:59 PM > To: Dekel Peled ; Yongseok Koh > ; Shahaf Shuler > Cc: dev@dpdk.org > Subject: RE: [PATCH 1/2] net/mlx5: add VXLAN encap decap to Direct Verbs >=20 >=20 >=20 > > -----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 > > > > This patch adds support for VXLAN encap and decap operations, in > > Direct Verbs flow. > > > > 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(-) > > > > 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) > > > > #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. */ >=20 > Why do we need encap and decap? >=20 > > #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 @@ > > > > #ifdef HAVE_IBV_FLOW_DV_SUPPORT > > > > +#define MLX5_UDP 17 > > +#define MLX5_TCP 6 > > +#define MLX5_GRE 47 >=20 > Please use already created defines. (IPPROTO_TCP) >=20 > > + > > +/* > > + * 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 @@ > > } > > > > /** > > + * 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 s= et. > > + */ > > +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 s= et. > > + */ > > +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"); >=20 > Why not EINVAL? >=20 > > + 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 > > + * ???. >=20 > What is ??? >=20 > > + * > > + * @return > > + * 0 on success, a negative errno value otherwise and rte_errno is s= et. > > + */ > > +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) >=20 > What is the l3_type used for? >=20 > > +{ > > + 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; >=20 > Why vlan has dedicated variable? >=20 > > + size_t len; > > + > > + assert(item); >=20 > Why assert on the item? It should be valid and if not return error. >=20 > > + *size =3D 0; >=20 > Why not use temp_size and avoid memory access? >=20 > > + for (; item->type !=3D RTE_FLOW_ITEM_TYPE_END; item++) { > > + /* TODO: variable length handling: raw, vxlan and nvgre. */ >=20 > Why TODO? >=20 > > + len =3D item_len[item->type]; >=20 > This can result in crash if type is not the one you expected. >=20 > > + 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]; >=20 > Why cast to void? Same for all others. >=20 > > + 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); >=20 > Why not use rte_cpu_to_be? Same for all. >=20 > > + 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 an= d > 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, > > > > 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 s= et. > > */ > > -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; > > } > > > > 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; > > } > > > > @@ -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 >=20 >=20 > Thanks, > Ori