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

The port number of UDP tunneling packet is configurable, which has 16 entries in total for i40e.

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

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 7fd9ae5..c2d3088 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -109,6 +109,7 @@
 #define MAC_ADDR_CMP 0xFFFFFFFFFFFFULL
 
 #define CMD_LINE_OPT_NB_DEVICES "nb-devices"
+#define CMD_LINE_OPT_UDP_PORT "udp-port"
 #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"
@@ -133,6 +134,9 @@ struct vpool {
 	uint32_t buf_size;
 } vpool_array[MAX_QUEUES+MAX_QUEUES];
 
+/* VXLAN UDP destination port */
+uint16_t udp_port;
+
 /* overlay packet operation */
 struct ol_switch_ops overlay_options = {
 	.port_configure = vxlan_port_init,
@@ -255,6 +259,7 @@ static void
 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"
 	"		-p PORTMASK: Set mask for ports to be used by application\n"
 	"		--rx-retry [0|1]: disable/enable(default) retries on rx."
@@ -280,6 +285,7 @@ tep_termination_parse_args(int argc, char **argv)
 	const char *prgname = argv[0];
 	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_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},
@@ -326,6 +332,17 @@ tep_termination_parse_args(int argc, char **argv)
 					enable_retry = ret;
 			}
 
+			if (!strncmp(long_option[option_index].name, CMD_LINE_OPT_UDP_PORT,
+					sizeof(CMD_LINE_OPT_UDP_PORT))) {
+				ret = parse_num_opt(optarg, INT16_MAX);
+				if (ret == -1) {
+					RTE_LOG(INFO, VHOST_CONFIG, "Invalid argument for UDP port [0-N]\n");
+						tep_termination_usage(prgname);
+					return -1;
+				} else
+					udp_port = ret;
+			}
+
 			/* Specify the retries delay time (in useconds) on RX. */
 			if (!strncmp(long_option[option_index].name, CMD_LINE_OPT_RX_RETRY_DELAY,
 					sizeof(CMD_LINE_OPT_RX_RETRY_DELAY))) {
@@ -1074,7 +1091,6 @@ main(int argc, char *argv[])
 		rte_eal_remote_launch(switch_worker,
 			mbuf_pool, lcore_id);
 	}
-
 	rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF);
 
 	/* Register CUSE device to handle IOCTLs. */
diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index 71414eb..f6efa90 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -75,6 +75,7 @@
 #define RTE_TEST_TX_DESC_DEFAULT 512
 
 extern uint16_t num_devices;
+extern uint16_t udp_port;
 extern uint8_t ports[RTE_MAX_ETHPORTS];
 
 /* ethernet addresses of ports */
@@ -141,9 +142,12 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 	uint16_t rx_rings, tx_rings = (uint16_t)rte_lcore_count();
 	const uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
 	const uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
+	struct rte_eth_udp_tunnel tunnel_udp;
 	struct rte_eth_rxconf *rxconf;
 	struct rte_eth_txconf *txconf;
+	struct vxlan_conf *pconf = &vxdev;
 
+	pconf->dst_port = udp_port;
 	rte_eth_dev_info_get (port, &dev_info);
 
 	dev_info.max_rx_queues = num_devices;
@@ -188,6 +192,12 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 	if (retval < 0)
 		return retval;
 
+	/* Configure UDP port for VXLAN */
+	tunnel_udp.udp_port = udp_port;
+	tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
+	retval = rte_eth_dev_udp_tunnel_add(port, &tunnel_udp);
+	if (retval < 0)
+		return retval;
 	rte_eth_macaddr_get(port, &ports_eth_addr[port]);
 	RTE_LOG(INFO, PORT, "Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
 			" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
@@ -198,13 +208,14 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 			ports_eth_addr[port].addr_bytes[3],
 			ports_eth_addr[port].addr_bytes[4],
 			ports_eth_addr[port].addr_bytes[5]);
+
 	return 0;
 }
 
 static int
 vxlan_rx_process(struct rte_mbuf *pkt)
 {
-	return  decapsulation(pkt);
+	return decapsulation(pkt);
 }
 
 static int
-- 
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 ` Jijiang Liu [this message]
2015-05-15  6:08 ` [dpdk-dev] [PATCH 06/10] examples/tep_termination:add tunnel filter type configuration Jijiang Liu
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-6-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).