From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 321C495D7 for ; Tue, 2 Feb 2016 07:57:18 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 01 Feb 2016 22:57:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,383,1449561600"; d="scan'208";a="874823362" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 01 Feb 2016 22:57:16 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u126vEPB007485; Tue, 2 Feb 2016 14:57:14 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u126vAuE011833; Tue, 2 Feb 2016 14:57:12 +0800 Received: (from wenzhuol@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u126vAxT011829; Tue, 2 Feb 2016 14:57:10 +0800 From: Wenzhuo Lu To: dev@dpdk.org Date: Tue, 2 Feb 2016 14:57:00 +0800 Message-Id: <1454396225-11784-3-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1454396225-11784-1-git-send-email-wenzhuo.lu@intel.com> References: <1454051035-25757-1-git-send-email-wenzhuo.lu@intel.com> <1454396225-11784-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v2 2/7] lib/librte_ether: support l2 tunnel config 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: Tue, 02 Feb 2016 06:57:18 -0000 Add functions to support l2 tunnel configuration. The support includes ether type modification and the tunnel support enabling/disabling. Ether type modification means modifying the ether type of a specific type of tunnel. So the packet with this ether type will be parsed as this type of tunnel. Enabling/disabling a tunnel support means enabling/disabling the ability of parsing the specific type of tunnel. This ability should be enabled before we enable filtering, forwarding, offloading for this specific type of tunnel. Only support e-tag tunnel now. E-tag introduction, E-tag means external tag which is defined in IEEEE 802.1BR specification. E-tag is a kind of l2 tunnel. It means a tag will be inserted in the l2 header. Like below, |31 24|23 16|15 8|7 0| 0| Destination MAC address | 4| Dest MAC address(cont.) | Src MAC address | 8| Source MAC address(cont.) | 12| E-tag Etherenet type (0x893f) | E-tag header | 16| E-tag header(cont.) | 20| VLAN Ethertype(optional) | VLAN header(optional) | 24| Original type | ...... | ...| ...... | The E-tag format is like below, |0 15|16 18|19 |20 31| | Ethertype - 0x893f | E-PCP |DEI| Ingress E-CID_base | |32 33|34 35|36 47|48 55 |56 63| | RSV | GRP |E-CID_base|Ingress_E-CID_ext| E-CID_ext | The Ingess_E-CID_ext and E-CID_ext are always zero for endpoints and are effectively reserved. The more details of E-tag is in IEEE 802.1BR. 802.1BR is used to replace 802.1Qbh. 802.1BR is a standard for Bridge Port Extension. It specifies the operation of Bridge Port Extenders, including management, protocols, and algorithms. Bridge Port Extenders operate in support of the MAC Service by Extended Bridges. The E-tag is added to l2 header to identify the VM channel and the virtual port. Signed-off-by: Wenzhuo Lu --- lib/librte_ether/rte_eth_ctrl.h | 9 +++++ lib/librte_ether/rte_ethdev.c | 61 ++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 84 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h index ce224ad..09af6fb 100644 --- a/lib/librte_ether/rte_eth_ctrl.h +++ b/lib/librte_ether/rte_eth_ctrl.h @@ -804,6 +804,15 @@ struct rte_eth_hash_filter_info { } info; }; +/** + * l2 tunnel type. + */ +enum rte_eth_l2_tunnel_type { + RTE_L2_TUNNEL_TYPE_NONE = 0, + RTE_L2_TUNNEL_TYPE_E_TAG, + RTE_L2_TUNNEL_TYPE_MAX, +}; + #ifdef __cplusplus } #endif diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index ed971b4..1b90e09 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3239,3 +3239,64 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de eth_dev->data->numa_node = pci_dev->numa_node; eth_dev->data->drv_name = pci_dev->driver->name; } + +int +rte_eth_dev_l2_tunnel_eth_type_conf(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 == NULL) { + RTE_PMD_DEBUG_TRACE("Invalid l2_tunnel parameter\n"); + return -EINVAL; + } + + if (l2_tunnel->l2_tunnel_type >= RTE_L2_TUNNEL_TYPE_MAX) { + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); + return -EINVAL; + } + + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->l2_tunnel_eth_type_conf, + -ENOTSUP); + return (*dev->dev_ops->l2_tunnel_eth_type_conf)(dev, l2_tunnel); +} + +int +rte_eth_dev_l2_tunnel_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 >= RTE_L2_TUNNEL_TYPE_MAX) { + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); + return -EINVAL; + } + + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->l2_tunnel_enable, + -ENOTSUP); + return (*dev->dev_ops->l2_tunnel_enable)(dev, l2_tunnel_type); +} + +int +rte_eth_dev_l2_tunnel_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 >= RTE_L2_TUNNEL_TYPE_MAX) { + RTE_PMD_DEBUG_TRACE("Invalid l2 tunnel type\n"); + return -EINVAL; + } + + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->l2_tunnel_disable, + -ENOTSUP); + return (*dev->dev_ops->l2_tunnel_disable)(dev, l2_tunnel_type); +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index bada8ad..9b594b8 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -957,6 +957,14 @@ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback); } \ } while (0) +/** + * l2 tunnel configuration. + */ +struct rte_eth_l2_tunnel { + enum rte_eth_l2_tunnel_type l2_tunnel_type; + uint16_t ether_type; +}; + /* * Definitions of all functions exported by an Ethernet driver through the * the generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev* @@ -1261,6 +1269,20 @@ typedef int (*eth_set_eeprom_t)(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *info); /**< @internal Program eeprom data */ +typedef int (*eth_l2_tunnel_eth_type_conf_t) + (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel *l2_tunnel); +/**< @internal config l2 tunnel ether type */ + +typedef int (*eth_l2_tunnel_enable_t) + (struct rte_eth_dev *dev, + enum rte_eth_l2_tunnel_type l2_tunnel_type); +/**< @internal enable a type of l2 tunnel */ + +typedef int (*eth_l2_tunnel_disable_t) + (struct rte_eth_dev *dev, + enum rte_eth_l2_tunnel_type l2_tunnel_type); +/**< @internal disable a type of l2 tunnel */ + #ifdef RTE_NIC_BYPASS enum { @@ -1443,6 +1465,12 @@ struct eth_dev_ops { eth_timesync_read_time timesync_read_time; /** Set the device clock time. */ eth_timesync_write_time timesync_write_time; + /** Config ether type of l2 tunnel */ + eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf; + /** Enable a type of l2 tunnel */ + eth_l2_tunnel_enable_t l2_tunnel_enable; + /** Disable a type of l2 tunnel */ + eth_l2_tunnel_disable_t l2_tunnel_disable; }; /** @@ -3887,6 +3915,62 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, uint16_t queue_id, size_t size, unsigned align, int socket_id); + /** + * Config l2 tunnel ether type of an Ethernet device for filtering specific + * tunnel packets by ether type. + * + * @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_eth_type_conf(uint8_t port_id, + struct rte_eth_l2_tunnel *l2_tunnel); + + /** + * Enable the ability of parsing a type of l2 tunnel of an Ethernet device. + * Filtering, forwarding and offloading this type of tunnel packets depend on + * this ability. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param l2_tunnel_type + * The type of l2 tunnel. + * + * @return + * - (0) if successful. + * - (-ENODEV) if port identifier is invalid. + * - (-ENOTSUP) if hardware doesn't support tunnel type. + */ +int +rte_eth_dev_l2_tunnel_enable(uint8_t port_id, + enum rte_eth_l2_tunnel_type l2_tunnel_type); + + /** + * Disable the ability of parsing a type of l2 tunnel of an Ethernet device. + * Filtering, forwarding and offloading this type of tunnel packets will not + * work either even if they're enabled. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param l2_tunnel_type + * The type of l2 tunnel. + * + * @return + * - (0) if successful. + * - (-ENODEV) if port identifier is invalid. + * - (-ENOTSUP) if hardware doesn't support tunnel type. + */ +int +rte_eth_dev_l2_tunnel_disable(uint8_t port_id, + enum rte_eth_l2_tunnel_type l2_tunnel_type); + #ifdef __cplusplus } #endif -- 1.9.3