From: Jijiang Liu <jijiang.liu@intel.com>
To: dev@dpdk.org, walter.e.gilmore@intel.com, thomas.long@intel.com
Subject: [dpdk-dev] [PATCH RFC 06/10] examples/tep_termination:add UDP port configuration for UDP tunneling packet
Date: Thu, 16 Apr 2015 11:55:54 +0800 [thread overview]
Message-ID: <1429156558-28548-7-git-send-email-jijiang.liu@intel.com> (raw)
In-Reply-To: <1429156558-28548-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 | 14 ++++++++++++++
examples/tep_termination/vxlan.c | 3 ++-
examples/tep_termination/vxlan_setup.c | 17 +++++++++++++----
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 60a825e..68d1706 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -113,6 +113,9 @@ struct vpool {
/* number of devices */
uint16_t num_devices;
+/* VXLAN UDP destination port */
+uint16_t udp_port;
+
/* overlay packet operation */
struct ol_switch_ops overlay_options = {
.port_configure = vxlan_port_init,
@@ -231,6 +234,7 @@ static void
vep_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: number of virtIO device\n"
" --dev-basename <name>\n"
" -p PORTMASK: Set mask for ports to be used by application\n"
@@ -250,6 +254,7 @@ tep_parse_args(int argc, char **argv)
unsigned i;
const char *prgname = argv[0];
static struct option long_option[] = {
+ {"udp-port", required_argument, NULL, 0},
{"nb-devices", required_argument, NULL, 0},
{"stats", required_argument, NULL, 0},
{"dev-basename", required_argument, NULL, 0},
@@ -280,6 +285,15 @@ tep_parse_args(int argc, char **argv)
} else
num_devices = ret;
}
+
+ if (!strncmp(long_option[option_index].name, "udp-port", MAX_LONG_OPT_SZ)) {
+ ret = parse_num_opt(optarg, INT16_MAX);
+ if (ret == -1) {
+ RTE_LOG(INFO, VHOST_CONFIG, "Invalid argument for UDP port [0-N]\n");
+ vep_termination_usage(prgname);
+ return -1;
+ }
+ }
/* Enable/disable stats. */
if (!strncmp(long_option[option_index].name, "stats", MAX_LONG_OPT_SZ)) {
diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c
index 9d86616..942eb10 100644
--- a/examples/tep_termination/vxlan.c
+++ b/examples/tep_termination/vxlan.c
@@ -46,6 +46,7 @@
extern struct vxlan_conf vxdev;
extern struct ipv4_hdr app_ip_hdr[VXLAN_N_PORTS];
extern struct ether_hdr app_l2_hdr[VXLAN_N_PORTS];
+extern uint16_t udp_port;
/*
* Parse an ethernet header to fill the ethertype, l2_len, l3_len and
@@ -100,7 +101,7 @@ int decapsulation(struct rte_mbuf *pkt)
struct udp_hdr *udp_hdr;
udp_hdr = (struct udp_hdr *)((char *)phdr +
info.outer_l2_len + info.outer_l3_len);
- if (udp_hdr->dst_port != rte_cpu_to_be_16(4789))
+ if (udp_hdr->dst_port != rte_cpu_to_be_16(udp_port))
return -1;
}
outer_header_len = info.outer_l2_len + info.outer_l3_len
diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index 7cb2660..fbffbc8 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -80,6 +80,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 */
@@ -156,10 +157,12 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
const uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
int retval;
uint16_t num_queues, q;
- //struct vxlan_conf *pconf = &vxdev;
+ struct vxlan_conf *pconf = &vxdev;
+ struct rte_eth_udp_tunnel tunnel_udp;
struct rte_eth_rxconf *rxconf;
struct rte_eth_txconf *txconf;
+ pconf->vxport = udp_port;
rte_eth_dev_info_get (port, &dev_info);
dev_info.max_rx_queues = num_devices;
@@ -204,6 +207,13 @@ 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",
@@ -230,8 +240,7 @@ vxlan_rx_process(struct rte_mbuf *pkt)
return ret;
}
-static int
-vxlan_tx_process(uint8_t vport_id, struct rte_mbuf *pkt)
+static int vxlan_tx_process(uint8_t vport_id, struct rte_mbuf *pkt)
{
int ret = 0;
@@ -241,6 +250,7 @@ vxlan_tx_process(uint8_t vport_id, struct rte_mbuf *pkt)
}
ret = encapsulation(pkt, vport_id);
+
return ret;
}
@@ -367,7 +377,6 @@ vxlan_tx_pkts (uint8_t port_id, uint16_t queue_id,
}
ret = rte_eth_tx_burst(port_id, queue_id, tx_pkts, nb_pkts);
-
return ret;
}
--
1.7.7.6
next prev parent reply other threads:[~2015-04-16 3:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 3:55 [dpdk-dev] [PATCH RFC 00/10] Add a VXLAN sample Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 01/10] examples/tep_termination:initialize the VXLAN example Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 02/10] examples/tep_termination:define VXLAN device information and APIs Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 03/10] examples/tep_termination:add the pluggable structures for VXLAN packet processing Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 04/10] examples/tep_termination:implement " Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 05/10] examples/tep_termination:implement the APIs of encapsulation and decapsulation for VXLAN Jijiang Liu
2015-04-16 3:55 ` Jijiang Liu [this message]
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 07/10] examples/tep_termination:add tunnel filter type configuration Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 08/10] examples/tep_termination:add Tx checksum offload configuration for inner header Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 09/10] examples/tep_termination:add TSO offload configuration Jijiang Liu
2015-04-16 3:55 ` [dpdk-dev] [PATCH RFC 10/10] examples/tep_termination:add the configuration for encapsulation and the decapsulation Jijiang Liu
2015-04-20 7:22 ` [dpdk-dev] [PATCH RFC 00/10] Add a VXLAN sample Liu, Jijiang
2015-04-28 3:31 ` 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=1429156558-28548-7-git-send-email-jijiang.liu@intel.com \
--to=jijiang.liu@intel.com \
--cc=dev@dpdk.org \
--cc=thomas.long@intel.com \
--cc=walter.e.gilmore@intel.com \
/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).