DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jijiang Liu <jijiang.liu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 06/10] examples/tep_termination:add tunnel filter type configuration
Date: Fri, 15 May 2015 14:08:57 +0800	[thread overview]
Message-ID: <1431670141-7835-7-git-send-email-jijiang.liu@intel.com> (raw)
In-Reply-To: <1431670141-7835-1-git-send-email-jijiang.liu@intel.com>

The follwoing filter types are supported for VXLAN,

1> Inner MAC&VLAN and tenent ID

2> Inner MAC and tenent ID, and Outer MAC

3> Inner MAC and tenent ID

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 examples/tep_termination/main.c        |   20 ++++++++++++
 examples/tep_termination/vxlan_setup.c |   52 +++++++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index c2d3088..c9ad83f 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -110,6 +110,7 @@
 
 #define CMD_LINE_OPT_NB_DEVICES "nb-devices"
 #define CMD_LINE_OPT_UDP_PORT "udp-port"
+#define CMD_LINE_OPT_FILTER_TYPE "filter-type"
 #define CMD_LINE_OPT_RX_RETRY "rx-retry"
 #define CMD_LINE_OPT_RX_RETRY_DELAY "rx-retry-delay"
 #define CMD_LINE_OPT_RX_RETRY_NUM "rx-retry-num"
@@ -137,6 +138,9 @@ struct vpool {
 /* VXLAN UDP destination port */
 uint16_t udp_port;
 
+/* RX filter type for tunneling packet */
+uint8_t filter_idx;
+
 /* overlay packet operation */
 struct ol_switch_ops overlay_options = {
 	.port_configure = vxlan_port_init,
@@ -261,6 +265,10 @@ tep_termination_usage(const char *prgname)
 	RTE_LOG(INFO, VHOST_CONFIG, "%s [EAL options] -- -p PORTMASK\n"
 	"               --udp-port: UDP destination port for VXLAN packet\n"
 	"		--nb-devices[1-64]: The number of virtIO device\n"
+	"               --filter-type[1-3]: filter type for tunneling packet\n"
+	"                   1: Inner MAC&VLAN and tenent ID\n"
+	"                   2: Inner MAC and tenent ID\n"
+	"                   3: Outer MAC, Inner MAC and tenent ID\n"
 	"		-p PORTMASK: Set mask for ports to be used by application\n"
 	"		--rx-retry [0|1]: disable/enable(default) retries on rx."
 	"		 Enable retry if destintation queue is full\n"
@@ -286,6 +294,7 @@ tep_termination_parse_args(int argc, char **argv)
 	static struct option long_option[] = {
 		{CMD_LINE_OPT_NB_DEVICES, required_argument, NULL, 0},
 		{CMD_LINE_OPT_UDP_PORT, required_argument, NULL, 0},
+		{CMD_LINE_OPT_FILTER_TYPE, required_argument, NULL, 0},
 		{CMD_LINE_OPT_RX_RETRY, required_argument, NULL, 0},
 		{CMD_LINE_OPT_RX_RETRY_DELAY, required_argument, NULL, 0},
 		{CMD_LINE_OPT_RX_RETRY_NUM, required_argument, NULL, 0},
@@ -369,6 +378,17 @@ tep_termination_parse_args(int argc, char **argv)
 					burst_rx_retry_num = ret;
 			}
 
+			if (!strncmp(long_option[option_index].name, CMD_LINE_OPT_FILTER_TYPE,
+					sizeof(CMD_LINE_OPT_FILTER_TYPE))) {
+				ret = parse_num_opt(optarg, 3);
+				if (ret == -1) {
+					RTE_LOG(INFO, VHOST_CONFIG, "Invalid argument for filter type [1-3]\n");
+					tep_termination_usage(prgname);
+					return -1;
+				} else
+					filter_idx = ret - 1;
+			}
+
 			/* Enable/disable stats. */
 			if (!strncmp(long_option[option_index].name, CMD_LINE_OPT_STATS,
 					sizeof(CMD_LINE_OPT_STATS))) {
diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index f6efa90..85668ba 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -77,6 +77,7 @@
 extern uint16_t num_devices;
 extern uint16_t udp_port;
 extern uint8_t ports[RTE_MAX_ETHPORTS];
+extern uint8_t filter_idx;
 
 /* ethernet addresses of ports */
 extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
@@ -99,6 +100,11 @@ uint8_t vxlan_overlay_ips[2][4] = { {192, 168, 10, 1}, {192, 168, 30, 1} };
 /* remote VTEP MAC address */
 uint8_t peer_mac[6] = {0x00, 0x11, 0x01, 0x00, 0x00, 0x01};
 
+/* VXLAN RX filter type */
+uint8_t tep_filter_type[] = {RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID,
+			RTE_TUNNEL_FILTER_IMAC_TENID,
+			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC,};
+
 /* Options for configuring ethernet port */
 static const struct rte_eth_conf port_conf = {
 	.rxmode = {
@@ -238,11 +244,12 @@ vxlan_tx_process(uint8_t vport_id, struct rte_mbuf *pkt)
 int
 vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)
 {
-	int i;
+	int i, ret;
 	struct ether_hdr *pkt_hdr;
 	struct virtio_net_data_ll *dev_ll;
 	struct virtio_net *dev = vdev->dev;
 	uint64_t portid = dev->device_fh;
+	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
 
 	dev_ll = ll_root_used;
 
@@ -270,6 +277,28 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)
 		vxdev.port[portid].peer_mac.addr_bytes[i] = peer_mac[i];
 	}
 
+	memset(&tunnel_filter_conf, 0, sizeof(struct rte_eth_tunnel_filter_conf));
+
+	tunnel_filter_conf.outer_mac = &ports_eth_addr[0];
+	tunnel_filter_conf.filter_type = tep_filter_type[filter_idx];
+
+	/* inner MAC */
+	tunnel_filter_conf.inner_mac = &vdev->mac_address;
+
+	tunnel_filter_conf.queue_id = vdev->rx_q;
+	tunnel_filter_conf.tenant_id = tenant_id_conf[vdev->rx_q];
+	tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+
+	ret = rte_eth_dev_filter_ctrl(ports[0],
+		RTE_ETH_FILTER_TUNNEL,
+		RTE_ETH_FILTER_ADD,
+		&tunnel_filter_conf);
+	if (ret) {
+		RTE_LOG(ERR, VHOST_DATA, "%d Failed to add device MAC address to cloud filter\n",
+		vdev->rx_q);
+		return -1;
+	}
+
 	/* Print out inner MAC and VNI info. */
 	RTE_LOG(INFO, VHOST_DATA, "(%d) MAC_ADDRESS %02x:%02x:%02x:%02x:%02x:%02x and VNI %d registered\n",
 		vdev->rx_q,
@@ -319,9 +348,30 @@ void
 vxlan_unlink(struct vhost_dev *vdev)
 {
 	unsigned i = 0, rx_count;
+	int ret;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
 
 	if (vdev->ready == DEVICE_RX) {
+		memset(&tunnel_filter_conf, 0, sizeof(struct rte_eth_tunnel_filter_conf));
+
+		tunnel_filter_conf.outer_mac = &ports_eth_addr[0];
+		tunnel_filter_conf.inner_mac = &vdev->mac_address;
+		tunnel_filter_conf.tenant_id = tenant_id_conf[vdev->rx_q];
+		tunnel_filter_conf.filter_type = tep_filter_type[filter_idx];
+
+		tunnel_filter_conf.queue_id = vdev->rx_q;
+		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+
+		ret = rte_eth_dev_filter_ctrl(ports[0],
+				RTE_ETH_FILTER_TUNNEL,
+				RTE_ETH_FILTER_DELETE,
+				&tunnel_filter_conf);
+		if (ret) {
+			RTE_LOG(ERR, VHOST_DATA, "%d Failed to add device MAC address to cloud filter\n",
+				vdev->rx_q);
+			return;
+		}
 		for (i = 0; i < ETHER_ADDR_LEN; i++)
 			vdev->mac_address.addr_bytes[i] = 0;
 
-- 
1.7.7.6

  parent reply	other threads:[~2015-05-15  6:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15  6:08 [dpdk-dev] [PATCH 00/10] Add a VXLAN sample Jijiang Liu
2015-05-15  6:08 ` [dpdk-dev] [PATCH 01/10] examples/tep_termination:initialize the " Jijiang Liu
2015-05-15 23:53   ` Stephen Hemminger
2015-05-18  1:37     ` Liu, Jijiang
2015-05-15 23:55   ` Stephen Hemminger
2015-05-18  2:42     ` Liu, Jijiang
2015-05-15  6:08 ` [dpdk-dev] [PATCH 02/10] examples/tep_termination:define the basic VXLAN port information Jijiang Liu
2015-05-15  6:08 ` [dpdk-dev] [PATCH 03/10] examples/tep_termination:add the pluggable structures for VXLAN packet processing Jijiang Liu
2015-05-15  6:08 ` [dpdk-dev] [PATCH 04/10] examples/tep_termination:implement " Jijiang Liu
2015-05-15  6:08 ` [dpdk-dev] [PATCH 05/10] examples/tep_termination:add UDP port configuration for UDP tunneling packet Jijiang Liu
2015-05-15  6:08 ` Jijiang Liu [this message]
2015-05-15  6:08 ` [dpdk-dev] [PATCH 07/10] examples/tep_termination:add Tx checksum offload configuration for inner header Jijiang Liu
2015-05-15  6:08 ` [dpdk-dev] [PATCH 08/10] examples/tep_termination:add TSO offload configuration Jijiang Liu
2015-05-15  6:09 ` [dpdk-dev] [PATCH 09/10] examples/tep_termination:add bad Rx checksum statistics of inner IP and L4 Jijiang Liu
2015-05-15  6:09 ` [dpdk-dev] [PATCH 10/10] examples/tep_termination:add the configuration for encapsulation and the decapsulation Jijiang Liu
2015-05-15  8:18 ` [dpdk-dev] [PATCH 00/10] Add a VXLAN sample Mcnamara, John
2015-05-18  2:52   ` Liu, Jijiang

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=1431670141-7835-7-git-send-email-jijiang.liu@intel.com \
    --to=jijiang.liu@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).