From: Jijiang Liu Date: Mon, 22 Jun 2015 16:41:00 +0000 (+0800) Subject: examples/tep_term: add UDP tunneling port configuration X-Git-Tag: spdx-start~9002 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=39c6daca9bbede8df556b3e2134c71c06174d095;p=dpdk.git examples/tep_term: add UDP tunneling port configuration The port number of UDP tunneling packet is configurable. For i40e, it has 16 entries in total. Signed-off-by: Jijiang Liu --- diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c index 8d539f312d..df40e1ecae 100644 --- a/examples/tep_termination/main.c +++ b/examples/tep_termination/main.c @@ -112,6 +112,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" @@ -136,6 +137,9 @@ struct vpool { uint32_t buf_size; } vpool_array[MAX_QUEUES+MAX_QUEUES]; +/* UDP tunneling port */ +uint16_t udp_port = 4789; + /* overlay packet operation */ struct ol_switch_ops overlay_options = { .port_configure = vxlan_port_init, @@ -250,6 +254,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." @@ -275,6 +280,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,19 @@ 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, diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c index 3631e1cf42..54d79844ed 100644 --- a/examples/tep_termination/vxlan_setup.c +++ b/examples/tep_termination/vxlan_setup.c @@ -129,8 +129,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); @@ -176,6 +180,12 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool) if (retval < 0) return retval; + /* Configure UDP port for UDP tunneling */ + 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", @@ -186,13 +196,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 void diff --git a/examples/tep_termination/vxlan_setup.h b/examples/tep_termination/vxlan_setup.h index d7e9a2954c..d5d1b9d682 100644 --- a/examples/tep_termination/vxlan_setup.h +++ b/examples/tep_termination/vxlan_setup.h @@ -35,6 +35,7 @@ #define VXLAN_SETUP_H_ extern uint16_t nb_devices; +extern uint16_t udp_port; extern uint8_t ports[RTE_MAX_ETHPORTS]; extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];