From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yongseok Koh Subject: Re: [PATCH v3 04/13] net/mlx5: add necessary structures for e-switch VXLAN Date: Thu, 1 Nov 2018 20:36:23 +0000 Message-ID: <20181101203615.GE6118@mtidpdk.mti.labs.mlnx> References: <1539612815-47199-1-git-send-email-viacheslavo@mellanox.com> <1541074741-41368-1-git-send-email-viacheslavo@mellanox.com> <1541074741-41368-5-git-send-email-viacheslavo@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: Shahaf Shuler , "dev@dpdk.org" To: Slava Ovsiienko Return-path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0077.outbound.protection.outlook.com [104.47.0.77]) by dpdk.org (Postfix) with ESMTP id A8B395B32 for ; Thu, 1 Nov 2018 21:36:24 +0100 (CET) In-Reply-To: <1541074741-41368-5-git-send-email-viacheslavo@mellanox.com> Content-Language: en-US Content-ID: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Nov 01, 2018 at 05:19:25AM -0700, Slava Ovsiienko wrote: > This patch introduces the data structures needed to implement VXLAN > encapsulation/decapsulation hardware offload support for E-Switch. >=20 > Suggested-by: Adrien Mazarguil > Signed-off-by: Viacheslav Ovsiienko > --- Acked-by: Yongseok Koh Thanks > drivers/net/mlx5/mlx5_flow.h | 9 ++++ > drivers/net/mlx5/mlx5_flow_tcf.c | 99 ++++++++++++++++++++++++++++++++++= ++++++ > 2 files changed, 108 insertions(+) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 392c525..3887ee9 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -191,6 +191,15 @@ struct mlx5_flow_dv { > struct mlx5_flow_tcf { > struct nlmsghdr *nlh; > struct tcmsg *tcm; > + union { /**< Tunnel encap/decap descriptor. */ > + struct flow_tcf_tunnel_hdr *tunnel; > + struct flow_tcf_vxlan_decap *vxlan_decap; > + struct flow_tcf_vxlan_encap *vxlan_encap; > + }; > + uint32_t applied:1; /**< Whether rule is currently applied. */ > +#ifndef NDEBUG > + uint32_t nlsize; /**< Size of NL message buffer for debug check. */ > +#endif > }; > =20 > /* Verbs specification header. */ > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index 4d54112..55c77e3 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -348,6 +348,100 @@ struct mlx5_flow_tcf_context { > uint8_t *buf; /* Message buffer. */ > }; > =20 > +/** > + * Neigh rule structure. The neigh rule is applied via Netlink to > + * outer tunnel iface in order to provide destination MAC address > + * for the VXLAN encapsultion. The neigh rule is implicitly related > + * to the Flow itself and can be shared by multiple Flows. > + */ > +struct tcf_neigh_rule { > + LIST_ENTRY(tcf_neigh_rule) next; > + uint32_t refcnt; > + struct ether_addr eth; > + uint16_t mask; > + union { > + struct { > + rte_be32_t dst; > + } ipv4; > + struct { > + uint8_t dst[IPV6_ADDR_LEN]; > + } ipv6; > + }; > +}; > + > +/** > + * Local rule structure. The local rule is applied via Netlink to > + * outer tunnel iface in order to provide local and peer IP addresses > + * of the VXLAN tunnel for encapsulation. The local rule is implicitly > + * related to the Flow itself and can be shared by multiple Flows. > + */ > +struct tcf_local_rule { > + LIST_ENTRY(tcf_local_rule) next; > + uint32_t refcnt; > + uint16_t mask; > + union { > + struct { > + rte_be32_t dst; > + rte_be32_t src; > + } ipv4; > + struct { > + uint8_t dst[IPV6_ADDR_LEN]; > + uint8_t src[IPV6_ADDR_LEN]; > + } ipv6; > + }; > +}; > + > +/** VXLAN virtual netdev. */ > +struct tcf_vtep { > + LIST_ENTRY(tcf_vtep) next; > + LIST_HEAD(, tcf_neigh_rule) neigh; > + LIST_HEAD(, tcf_local_rule) local; > + uint32_t refcnt; > + unsigned int ifindex; /**< Own interface index. */ > + unsigned int ifouter; /**< Index of device attached to. */ > + uint16_t port; > + uint8_t created; > +}; > + > +/** Tunnel descriptor header, common for all tunnel types. */ > +struct flow_tcf_tunnel_hdr { > + uint32_t type; /**< Tunnel action type. */ > + struct tcf_vtep *vtep; /**< Virtual tunnel endpoint device. */ > + unsigned int ifindex_org; /**< Original dst/src interface */ > + unsigned int *ifindex_ptr; /**< Interface ptr in message. */ > +}; > + > +struct flow_tcf_vxlan_decap { > + struct flow_tcf_tunnel_hdr hdr; > + uint16_t udp_port; > +}; > + > +struct flow_tcf_vxlan_encap { > + struct flow_tcf_tunnel_hdr hdr; > + uint32_t mask; > + struct { > + struct ether_addr dst; > + struct ether_addr src; > + } eth; > + union { > + struct { > + rte_be32_t dst; > + rte_be32_t src; > + } ipv4; > + struct { > + uint8_t dst[IPV6_ADDR_LEN]; > + uint8_t src[IPV6_ADDR_LEN]; > + } ipv6; > + }; > +struct { > + rte_be16_t src; > + rte_be16_t dst; > + } udp; > + struct { > + uint8_t vni[3]; > + } vxlan; > +}; > + > /** Structure used when extracting the values of a flow counters > * from a netlink message. > */ > @@ -365,6 +459,7 @@ struct flow_tcf_stats_basic { > struct rte_flow_item_ipv6 ipv6; > struct rte_flow_item_tcp tcp; > struct rte_flow_item_udp udp; > + struct rte_flow_item_vxlan vxlan; > } flow_tcf_mask_empty; > =20 > /** Supported masks for known item types. */ > @@ -376,6 +471,7 @@ struct flow_tcf_stats_basic { > struct rte_flow_item_ipv6 ipv6; > struct rte_flow_item_tcp tcp; > struct rte_flow_item_udp udp; > + struct rte_flow_item_vxlan vxlan; > } flow_tcf_mask_supported =3D { > .port_id =3D { > .id =3D 0xffffffff, > @@ -413,6 +509,9 @@ struct flow_tcf_stats_basic { > .src_port =3D RTE_BE16(0xffff), > .dst_port =3D RTE_BE16(0xffff), > }, > + .vxlan =3D { > + .vni =3D "\xff\xff\xff", > + }, > }; > =20 > #define SZ_NLATTR_HDR MNL_ALIGN(sizeof(struct nlattr)) > --=20 > 1.8.3.1 >=20