From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 6BAD02BCE for ; Fri, 4 Mar 2016 04:31:32 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 03 Mar 2016 19:31:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,534,1449561600"; d="scan'208";a="663569625" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 03 Mar 2016 19:31:31 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Mar 2016 19:31:30 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Mar 2016 19:31:30 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.232]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.132]) with mapi id 14.03.0248.002; Fri, 4 Mar 2016 11:31:22 +0800 From: "Lu, Wenzhuo" To: "He, Shaopeng" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4 5/7] lib/librte_ether: support new l2 tunnel operation Thread-Index: AQHRdbfLIrvIr5E460qxOxiCheiyx59In9hg Date: Fri, 4 Mar 2016 03:31:22 +0000 Message-ID: <6A0DE07E22DDAD4C9103DF62FEBC090903437A2D@shsmsx102.ccr.corp.intel.com> References: <1454051035-25757-1-git-send-email-wenzhuo.lu@intel.com> <1455763573-2867-1-git-send-email-wenzhuo.lu@intel.com> <1455763573-2867-6-git-send-email-wenzhuo.lu@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4 5/7] lib/librte_ether: support new l2 tunnel operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Mar 2016 03:31:33 -0000 Hi Shaopeng, > -----Original Message----- > From: He, Shaopeng > Sent: Friday, March 4, 2016 9:47 AM > To: Lu, Wenzhuo; dev@dpdk.org > Subject: RE: [dpdk-dev] [PATCH v4 5/7] lib/librte_ether: support new l2 t= unnel > operation >=20 > Hi Wenzhuo, >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu > > Sent: Thursday, February 18, 2016 10:46 AM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH v4 5/7] lib/librte_ether: support new l2 > > tunnel operation > > > > Add functions to support the new l2 tunnel operation. > > 1, Insertion and stripping for l2 tunnel tag. > > 2, Forwarding the packets to a pool based on l2 tunnel tag. > > > > Signed-off-by: Wenzhuo Lu > > --- > > lib/librte_ether/rte_ethdev.c | 183 > > ++++++++++++++++++++++++++++++++++++ > > lib/librte_ether/rte_ethdev.h | 214 > > ++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 397 insertions(+) > > > > diff --git a/lib/librte_ether/rte_ethdev.c > > b/lib/librte_ether/rte_ethdev.c index c5c12cb..6bc19d4 100644 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -3298,3 +3298,186 @@ rte_eth_dev_l2_tunnel_disable(uint8_t port_id, > > -ENOTSUP); > > return (*dev->dev_ops->l2_tunnel_disable)(dev, l2_tunnel_type); } > > + > > +int > > +rte_eth_dev_l2_tunnel_insertion_enable(uint8_t port_id, > > + struct rte_eth_l2_tunnel *l2_tunnel, > > + uint16_t vf_id) > > +{ > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + if (l2_tunnel =3D=3D NULL) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2_tunnel parameter\n"); > > + return -EINVAL; > > + } > > + > > + if (l2_tunnel->l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { >=20 > How about the value of RTE_L2_TUNNEL_TYPE_NONE here, is it an invalid typ= e > too? Honestly, the purpose I check this tunnel type here is to avoid the subscri= pt out of bound error if some NIC create an array which index is tunnel typ= e. So, although type_none is an invalid type, I don't check it here. How do yo= u think about it? Thanks. >=20 > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > > >l2_tunnel_insertion_enable, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_insertion_enable)(dev, > > + l2_tunnel, > > + vf_id); > > +} > > + > > +int > > +rte_eth_dev_l2_tunnel_insertion_disable(uint8_t port_id, > > + enum rte_eth_l2_tunnel_type > > + l2_tunnel_type, > > + uint16_t vf_id) > > +{ > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + > > + if (l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > > >l2_tunnel_insertion_disable, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_insertion_disable)(dev, > > + l2_tunnel_type, > > + vf_id); > > +} > > + > > +int > > +rte_eth_dev_l2_tunnel_stripping_enable(uint8_t port_id, > > + enum rte_eth_l2_tunnel_type > > + l2_tunnel_type) > > +{ > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + > > + if (l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > > >l2_tunnel_stripping_enable, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_stripping_enable)(dev, > > + l2_tunnel_type); > > +} > > + > > +int > > +rte_eth_dev_l2_tunnel_stripping_disable(uint8_t port_id, > > + enum rte_eth_l2_tunnel_type > > + l2_tunnel_type) > > +{ > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + > > + if (l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > > >l2_tunnel_stripping_disable, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_stripping_disable)(dev, > > + l2_tunnel_type); > > +} > > + > > +int > > +rte_eth_dev_l2_tunnel_forwarding_enable(uint8_t port_id, > > + enum rte_eth_l2_tunnel_type > > + l2_tunnel_type) > > +{ > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + > > + if (l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > > >l2_tunnel_forwarding_enable, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_forwarding_enable)(dev, > > + l2_tunnel_type); > > +} > > + > > +int > > +rte_eth_dev_l2_tunnel_forwarding_disable(uint8_t port_id, > > + enum rte_eth_l2_tunnel_type > > + l2_tunnel_type) > > +{ > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + > > + if (l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > > >l2_tunnel_forwarding_disable, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_forwarding_disable)(dev, > > + l2_tunnel_type); > > +} > > + > > +int > > +rte_eth_dev_l2_tunnel_filter_add(uint8_t port_id, > > + struct rte_eth_l2_tunnel *l2_tunnel, > > + uint32_t pool) > > +{ > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + if (l2_tunnel =3D=3D NULL) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2_tunnel parameter\n"); > > + return -EINVAL; > > + } > > + > > + if (l2_tunnel->l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops- > > >l2_tunnel_filter_add, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_filter_add)(dev, > > + l2_tunnel, > > + pool); > > +} > > + > > +int > > +rte_eth_dev_l2_tunnel_filter_del(uint8_t port_id, > > + struct rte_eth_l2_tunnel *l2_tunnel) { > > + struct rte_eth_dev *dev; > > + > > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > > + if (l2_tunnel =3D=3D NULL) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2_tunnel parameter\n"); > > + return -EINVAL; > > + } > > + > > + if (l2_tunnel->l2_tunnel_type >=3D RTE_L2_TUNNEL_TYPE_MAX) { > > + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); > > + return -EINVAL; > > + } > > + > > + dev =3D &rte_eth_devices[port_id]; > > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->l2_tunnel_filter_del, > > + -ENOTSUP); > > + return (*dev->dev_ops->l2_tunnel_filter_del)(dev, > > + l2_tunnel); > > +} > > diff --git a/lib/librte_ether/rte_ethdev.h > > b/lib/librte_ether/rte_ethdev.h index 709485a..d482f8c 100644 > > --- a/lib/librte_ether/rte_ethdev.h > > +++ b/lib/librte_ether/rte_ethdev.h > > @@ -963,6 +963,7 @@ TAILQ_HEAD(rte_eth_dev_cb_list, > > rte_eth_dev_callback); struct rte_eth_l2_tunnel { > > enum rte_eth_l2_tunnel_type l2_tunnel_type; > > uint16_t ether_type; > > + uint32_t tunnel_id; /* port tag id for e-tag */ > > }; > > > > /* > > @@ -1283,6 +1284,45 @@ typedef int (*eth_l2_tunnel_disable_t) > > enum rte_eth_l2_tunnel_type l2_tunnel_type); /**< @internal > > disable a type of l2 tunnel */ > > > > +typedef int (*eth_l2_tunnel_insertion_enable_t) > > + (struct rte_eth_dev *dev, > > + struct rte_eth_l2_tunnel *l2_tunnel, > > + uint16_t vf_id); > > +/**< @internal enable insertion of l2 tunnel tag */ > > + > > +typedef int (*eth_l2_tunnel_insertion_disable_t) > > + (struct rte_eth_dev *dev, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type, > > + uint16_t vf_id); > > +/**< @internal disable insertion of l2 tunnel tag */ > > + > > +typedef int (*eth_l2_tunnel_stripping_enable_t) > > + (struct rte_eth_dev *dev, enum rte_eth_l2_tunnel_type > > l2_tunnel_type); > > +/**< @internal enable stripping of l2 tunnel tag */ > > + > > +typedef int (*eth_l2_tunnel_stripping_disable_t) > > + (struct rte_eth_dev *dev, enum rte_eth_l2_tunnel_type > > l2_tunnel_type); > > +/**< @internal disable stripping of l2 tunnel tag */ > > + > > +typedef int (*eth_l2_tunnel_forwarding_enable_t) > > + (struct rte_eth_dev *dev, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type); /**< @internal > > enable > > +forwarding of l2 tunnel packets */ > > + > > +typedef int (*eth_l2_tunnel_forwarding_disable_t) > > + (struct rte_eth_dev *dev, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type); /**< @internal > > disable > > +forwarding of l2 tunnel packets */ > > + > > +typedef int (*eth_l2_tunnel_filter_add_t)(struct rte_eth_dev *dev, > > + struct rte_eth_l2_tunnel *l2_tunnel, > > + uint32_t pool); > > +/**< @internal add filter of l2 tunnel packets */ > > + > > +typedef int (*eth_l2_tunnel_filter_del_t)(struct rte_eth_dev *dev, > > + struct rte_eth_l2_tunnel > > *l2_tunnel); /**< @internal delete > > +filter of l2 tunnel packets */ > > + > > #ifdef RTE_NIC_BYPASS > > > > enum { > > @@ -1471,6 +1511,22 @@ struct eth_dev_ops { > > eth_l2_tunnel_enable_t l2_tunnel_enable; > > /** Disable a type of l2 tunnel */ > > eth_l2_tunnel_disable_t l2_tunnel_disable; > > + /** Enable insertion of l2 tunnel tag */ > > + eth_l2_tunnel_insertion_enable_t l2_tunnel_insertion_enable; > > + /** Disable insertion of l2 tunnel tag */ > > + eth_l2_tunnel_insertion_disable_t l2_tunnel_insertion_disable; > > + /** Enable stripping of l2 tunnel tag */ > > + eth_l2_tunnel_stripping_enable_t l2_tunnel_stripping_enable; > > + /** Disable stripping of l2 tunnel tag */ > > + eth_l2_tunnel_stripping_disable_t l2_tunnel_stripping_disable; > > + /** Enable forwarding of l2 tunnel packets */ > > + eth_l2_tunnel_forwarding_enable_t l2_tunnel_forwarding_enable; > > + /** Disable forwarding of l2 tunnel packets */ > > + eth_l2_tunnel_forwarding_disable_t l2_tunnel_forwarding_disable; > > + /** Add filter of l2 tunnel packets */ > > + eth_l2_tunnel_filter_add_t l2_tunnel_filter_add; > > + /** Delete filter of l2 tunnel packets */ > > + eth_l2_tunnel_filter_del_t l2_tunnel_filter_del; > > }; > > > > /** > > @@ -3964,6 +4020,164 @@ int > > rte_eth_dev_l2_tunnel_disable(uint8_t port_id, > > enum rte_eth_l2_tunnel_type l2_tunnel_type); > > > > + /** > > + * Enable l2 tunnel tag insertion of an Ethernet device for specific > > + * tunnel packets by ether type. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel > > + * l2 tunnel configuration. > > + * @param vf_id > > + * vf id. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_insertion_enable(uint8_t port_id, > > + struct rte_eth_l2_tunnel *l2_tunnel, > > + uint16_t vf_id); > > + > > + /** > > + * Disable l2 tunnel tag insertion of an Ethernet device for specific > > + * tunnel packets by ether type. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel_type > > + * l2 tunnel type. > > + * @param vf_id > > + * vf id. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_insertion_disable > > + (uint8_t port_id, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type, > > + uint16_t vf_id); > > + > > + /** > > + * Enable l2 tunnel tag stripping of an Ethernet device for specific > > + * tunnel packets by ether type. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel_type > > + * l2 tunnel type. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_stripping_enable > > + (uint8_t port_id, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type); > > + > > + /** > > + * Disable l2 tunnel tag stripping of an Ethernet device for specific > > + * tunnel packets by ether type. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel_type > > + * l2 tunnel type. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_stripping_disable > > + (uint8_t port_id, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type); > > + > > + /** > > + * Enable l2 tunnel tag forwarding of an Ethernet device for specific > > + * tunnel packets by ether type. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel_type > > + * l2 tunnel type. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_forwarding_enable > > + (uint8_t port_id, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type); > > + > > + /** > > + * Disable l2 tunnel tag forwarding of an Ethernet device for > > +specific > > + * tunnel packets by ether type. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel_type > > + * l2 tunnel type. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_forwarding_disable > > + (uint8_t port_id, > > + enum rte_eth_l2_tunnel_type l2_tunnel_type); > > + > > + /** > > + * Add a filter for packet forwarding based on l2 tunnel tag of an > > +Ethernet > > + * device for specific tunnel packets. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel > > + * l2 tunnel configuration. > > + * @param pool > > + * Destination pool. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_filter_add(uint8_t port_id, > > + struct rte_eth_l2_tunnel *l2_tunnel, > > + uint32_t pool); > > + > > + /** > > + * Delete a filter for packet forwarding based on l2 tunnel tag of an > > +Ethernet > > + * device for specific tunnel packets. > > + * > > + * @param port_id > > + * The port identifier of the Ethernet device. > > + * @param l2_tunnel > > + * l2 tunnel configuration. > > + * > > + * @return > > + * - (0) if successful. > > + * - (-ENODEV) if port identifier is invalid. > > + * - (-ENOTSUP) if hardware doesn't support tunnel type. > > + */ > > +int > > +rte_eth_dev_l2_tunnel_filter_del(uint8_t port_id, > > + struct rte_eth_l2_tunnel *l2_tunnel); > > + > > #ifdef __cplusplus > > } > > #endif > > -- > > 1.9.3