DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v8 2/5] lib/librte_ether: support l2 tunnel operations
Date: Fri, 11 Mar 2016 09:10:08 +0800	[thread overview]
Message-ID: <1457658611-1035-3-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1457658611-1035-1-git-send-email-wenzhuo.lu@intel.com>

Add functions to support l2 tunnel configuration and operations.
1, L2 tunnel ether type modification.
   It 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.
2, Enabling/disabling l2 tunnel support.
   It 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.
3, Insertion and stripping for l2 tunnel tag.
4, Forwarding the packets to a pool based on l2 tunnel tag.

Only support e-tag tunnel now.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Acked-by: Shaopeng He <shaopeng.he@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
Tested-by: Yong Liu <yong.liu@intel.com>
---
 lib/librte_ether/rte_eth_ctrl.h        | 13 ++++++
 lib/librte_ether/rte_ethdev.c          | 54 ++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 75 ++++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  7 ++++
 4 files changed, 149 insertions(+)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index ce224ad..3c4920f 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -89,6 +89,7 @@ enum rte_filter_type {
 	RTE_ETH_FILTER_TUNNEL,
 	RTE_ETH_FILTER_FDIR,
 	RTE_ETH_FILTER_HASH,
+	RTE_ETH_FILTER_L2_TUNNEL,
 	RTE_ETH_FILTER_MAX
 };
 
@@ -244,6 +245,7 @@ enum rte_eth_tunnel_type {
 	RTE_TUNNEL_TYPE_GENEVE,
 	RTE_TUNNEL_TYPE_TEREDO,
 	RTE_TUNNEL_TYPE_NVGRE,
+	RTE_L2_TUNNEL_TYPE_E_TAG,
 	RTE_TUNNEL_TYPE_MAX,
 };
 
@@ -804,6 +806,17 @@ struct rte_eth_hash_filter_info {
 	} info;
 };
 
+/**
+ * l2 tunnel configuration.
+ */
+struct rte_eth_l2_tunnel_conf {
+	enum rte_eth_tunnel_type l2_tunnel_type;
+	uint16_t ether_type; /* ether type in l2 header */
+	uint32_t tunnel_id; /* port tag id for e-tag */
+	uint16_t vf_id; /* VF id for tag insertion */
+	uint32_t pool; /* destination pool for tag based forwarding */
+};
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 756b234..84d4160 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3237,3 +3237,57 @@ 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_conf *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_TUNNEL_TYPE_MAX) {
+		RTE_PMD_DEBUG_TRACE("Invalid 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_offload_set(uint8_t port_id,
+				  struct rte_eth_l2_tunnel_conf *l2_tunnel,
+				  uint32_t mask,
+				  uint8_t en)
+{
+	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_TUNNEL_TYPE_MAX) {
+		RTE_PMD_DEBUG_TRACE("Invalid tunnel type.\n");
+		return -EINVAL;
+	}
+
+	if (mask == 0) {
+		RTE_PMD_DEBUG_TRACE("Mask should have a value.\n");
+		return -EINVAL;
+	}
+
+	dev = &rte_eth_devices[port_id];
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->l2_tunnel_offload_set,
+				-ENOTSUP);
+	return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en);
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16da821..2008f1c 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -957,6 +957,19 @@ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
 	} \
 } while (0)
 
+/**
+ * l2 tunnel configuration.
+ */
+
+/**< l2 tunnel enable mask */
+#define ETH_L2_TUNNEL_ENABLE_MASK       0x00000001
+/**< l2 tunnel insertion mask */
+#define ETH_L2_TUNNEL_INSERTION_MASK    0x00000002
+/**< l2 tunnel stripping mask */
+#define ETH_L2_TUNNEL_STRIPPING_MASK    0x00000004
+/**< l2 tunnel forwarding mask */
+#define ETH_L2_TUNNEL_FORWARDING_MASK   0x00000008
+
 /*
  * 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 +1274,17 @@ 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_conf *l2_tunnel);
+/**< @internal config l2 tunnel ether type */
+
+typedef int (*eth_l2_tunnel_offload_set_t)
+	(struct rte_eth_dev *dev,
+	 struct rte_eth_l2_tunnel_conf *l2_tunnel,
+	 uint32_t mask,
+	 uint8_t en);
+/**< @internal enable/disable the l2 tunnel offload functions */
+
 #ifdef RTE_NIC_BYPASS
 
 enum {
@@ -1443,6 +1467,10 @@ 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/disable l2 tunnel offload functions */
+	eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
 };
 
 /**
@@ -3880,6 +3908,53 @@ 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_conf *l2_tunnel);
+
+ /**
+ * Enable/disable l2 tunnel offload functions. Include,
+ * 1, 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.
+ * 2, Stripping the l2 tunnel tag.
+ * 3, Insertion of the l2 tunnel tag.
+ * 4, Forwarding the packets based on the l2 tunnel tag.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param l2_tunnel
+ *   l2 tunnel parameters.
+ * @param mask
+ *   Indicate the offload function.
+ * @param en
+ *   Enable or disable this function.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-ENOTSUP) if hardware doesn't support tunnel type.
+ */
+int
+rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
+				  struct rte_eth_l2_tunnel_conf *l2_tunnel,
+				  uint32_t mask,
+				  uint8_t en);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index d8db24d..871221c 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -117,3 +117,10 @@ DPDK_2.2 {
 
 	local: *;
 };
+
+DPDK_16.04 {
+	global:
+
+	rte_eth_dev_l2_tunnel_eth_type_conf;
+	rte_eth_dev_l2_tunnel_offload_set;
+}DPDK_2.2;
-- 
1.9.3

  parent reply	other threads:[~2016-03-11  1:10 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29  7:03 [dpdk-dev] [PATCH 0/8] support E-tag offloading and forwarding on Intel X550 NIC Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 1/8] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 2/8] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 3/8] ixgbe: " Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 4/8] app/testpmd: add CLIs for " Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 5/8] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 6/8] ixgbe: support " Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 7/8] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-01-29  7:03 ` [dpdk-dev] [PATCH 8/8] doc: add release note for E-tag Wenzhuo Lu
2016-02-01 16:15   ` Mcnamara, John
2016-01-29  7:16 ` [dpdk-dev] [PATCH 0/8] support E-tag offloading and forwarding on Intel X550 NIC Qiu, Michael
2016-02-01  1:04   ` Lu, Wenzhuo
2016-02-01  1:39     ` Yuanhan Liu
2016-02-01  1:56       ` Lu, Wenzhuo
2016-02-01  2:06         ` Yuanhan Liu
2016-02-01  3:00           ` Lu, Wenzhuo
2016-02-01  8:31       ` Qiu, Michael
2016-02-02  1:24         ` Lu, Wenzhuo
2016-02-02  6:56 ` [dpdk-dev] [PATCH v2 0/7] " Wenzhuo Lu
2016-02-02  6:56   ` [dpdk-dev] [PATCH v2 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-02-02  6:57   ` [dpdk-dev] [PATCH v2 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-02-02 12:03     ` Bruce Richardson
2016-02-03  1:05       ` Lu, Wenzhuo
2016-02-03  3:36     ` Stephen Hemminger
2016-02-03  8:08       ` Lu, Wenzhuo
2016-02-02  6:57   ` [dpdk-dev] [PATCH v2 3/7] ixgbe: " Wenzhuo Lu
2016-02-02  6:57   ` [dpdk-dev] [PATCH v2 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-02-02  6:57   ` [dpdk-dev] [PATCH v2 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-02-02  6:57   ` [dpdk-dev] [PATCH v2 6/7] ixgbe: support " Wenzhuo Lu
2016-02-02  6:57   ` [dpdk-dev] [PATCH v2 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-02-12 13:50   ` [dpdk-dev] [PATCH v2 0/7] support E-tag offloading and forwarding on Intel X550 NIC De Lara Guarch, Pablo
2016-02-15  1:21     ` Lu, Wenzhuo
2016-02-15  9:39       ` De Lara Guarch, Pablo
2016-02-16  8:20 ` [dpdk-dev] [PATCH v3 " Wenzhuo Lu
2016-02-16  8:20   ` [dpdk-dev] [PATCH v3 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-02-16  8:20   ` [dpdk-dev] [PATCH v3 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-02-16  8:20   ` [dpdk-dev] [PATCH v3 3/7] ixgbe: " Wenzhuo Lu
2016-02-16  8:20   ` [dpdk-dev] [PATCH v3 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-02-16  8:20   ` [dpdk-dev] [PATCH v3 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-02-16  8:20   ` [dpdk-dev] [PATCH v3 6/7] ixgbe: support " Wenzhuo Lu
2016-02-16  8:20   ` [dpdk-dev] [PATCH v3 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-02-18  2:46 ` [dpdk-dev] [PATCH v4 0/7] support E-tag offloading and forwarding on Intel X550 NIC Wenzhuo Lu
2016-02-18  2:46   ` [dpdk-dev] [PATCH v4 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-02-18  2:46   ` [dpdk-dev] [PATCH v4 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-02-18  2:46   ` [dpdk-dev] [PATCH v4 3/7] ixgbe: " Wenzhuo Lu
2016-03-04  1:47     ` He, Shaopeng
2016-03-04  3:17       ` Lu, Wenzhuo
2016-02-18  2:46   ` [dpdk-dev] [PATCH v4 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-02-18  2:46   ` [dpdk-dev] [PATCH v4 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-03-04  1:47     ` He, Shaopeng
2016-03-04  3:31       ` Lu, Wenzhuo
2016-03-07  2:04         ` He, Shaopeng
2016-02-18  2:46   ` [dpdk-dev] [PATCH v4 6/7] ixgbe: support " Wenzhuo Lu
2016-03-04  1:46     ` He, Shaopeng
2016-03-04  3:15       ` Lu, Wenzhuo
2016-02-18  2:46   ` [dpdk-dev] [PATCH v4 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-04  1:46     ` He, Shaopeng
2016-03-04  3:11       ` Lu, Wenzhuo
2016-03-04  9:23   ` [dpdk-dev] [PATCH v4 0/7] support E-tag offloading and forwarding on Intel X550 NIC Liu, Yong
2016-03-07  2:42 ` [dpdk-dev] [PATCH v5 0/7] support E-tag offloading and forwarding on X550 Wenzhuo Lu
2016-03-07  2:42   ` [dpdk-dev] [PATCH v5 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-07  2:42   ` [dpdk-dev] [PATCH v5 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-03-07  2:42   ` [dpdk-dev] [PATCH v5 3/7] ixgbe: " Wenzhuo Lu
2016-03-07  2:42   ` [dpdk-dev] [PATCH v5 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-03-07  2:42   ` [dpdk-dev] [PATCH v5 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-03-07  3:29     ` Wu, Jingjing
2016-03-07  5:29       ` Lu, Wenzhuo
2016-03-07  2:42   ` [dpdk-dev] [PATCH v5 6/7] ixgbe: support " Wenzhuo Lu
2016-03-07  2:42   ` [dpdk-dev] [PATCH v5 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-08  6:53 ` [dpdk-dev] [PATCH v6 0/5] support E-tag offloading and forwarding on X550 Wenzhuo Lu
2016-03-08  6:53   ` [dpdk-dev] [PATCH v6 1/5] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-08  6:53   ` [dpdk-dev] [PATCH v6 2/5] lib/librte_ether: support l2 tunnel operations Wenzhuo Lu
2016-03-09  0:14     ` Thomas Monjalon
2016-03-09  1:15       ` Lu, Wenzhuo
2016-03-09  9:27         ` Thomas Monjalon
2016-03-10  0:54           ` Lu, Wenzhuo
2016-03-08  6:53   ` [dpdk-dev] [PATCH v6 3/5] ixgbe: " Wenzhuo Lu
2016-03-08  6:53   ` [dpdk-dev] [PATCH v6 4/5] app/testpmd: add CLIs for l2 tunnel config Wenzhuo Lu
2016-03-08  6:53   ` [dpdk-dev] [PATCH v6 5/5] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-08  8:08   ` [dpdk-dev] [PATCH v6 0/5] support E-tag offloading and forwarding on X550 Wu, Jingjing
2016-03-09  7:44 ` [dpdk-dev] [PATCH v7 " Wenzhuo Lu
2016-03-09  7:44   ` [dpdk-dev] [PATCH v7 1/5] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-09  7:44   ` [dpdk-dev] [PATCH v7 2/5] lib/librte_ether: support l2 tunnel operations Wenzhuo Lu
2016-03-09  7:44   ` [dpdk-dev] [PATCH v7 3/5] ixgbe: " Wenzhuo Lu
2016-03-09  7:44   ` [dpdk-dev] [PATCH v7 4/5] app/testpmd: add CLIs for l2 tunnel config Wenzhuo Lu
2016-03-09  7:44   ` [dpdk-dev] [PATCH v7 5/5] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-09 10:07   ` [dpdk-dev] [PATCH v7 0/5] support E-tag offloading and forwarding on X550 Thomas Monjalon
2016-03-10  0:44     ` Lu, Wenzhuo
2016-03-11  1:10 ` [dpdk-dev] [PATCH v8 " Wenzhuo Lu
2016-03-11  1:10   ` [dpdk-dev] [PATCH v8 1/5] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-11  1:10   ` Wenzhuo Lu [this message]
2016-03-11  1:10   ` [dpdk-dev] [PATCH v8 3/5] ixgbe: support l2 tunnel operations Wenzhuo Lu
2016-03-11  1:10   ` [dpdk-dev] [PATCH v8 4/5] app/testpmd: add CLIs for l2 tunnel config Wenzhuo Lu
2016-03-11  1:10   ` [dpdk-dev] [PATCH v8 5/5] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-11 22:27   ` [dpdk-dev] [PATCH v8 0/5] support E-tag offloading and forwarding on X550 Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457658611-1035-3-git-send-email-wenzhuo.lu@intel.com \
    --to=wenzhuo.lu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).