From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 687415688 for ; Mon, 8 Jun 2015 05:02:07 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 07 Jun 2015 20:02:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,571,1427785200"; d="scan'208";a="583820665" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 07 Jun 2015 20:02:05 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t58324Um004118; Mon, 8 Jun 2015 11:02:04 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t58321EL032500; Mon, 8 Jun 2015 11:02:03 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t58321oe032496; Mon, 8 Jun 2015 11:02:01 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Mon, 8 Jun 2015 11:01:43 +0800 Message-Id: <1433732508-32430-6-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1433732508-32430-1-git-send-email-jijiang.liu@intel.com> References: <1433732508-32430-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH v3 05/10] examples/tep_termination:add UDP port configuration for UDP tunneling packet X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jun 2015 03:02:09 -0000 The port number of UDP tunneling packet is configurable, which has 16 entries in total for i40e. Signed-off-by: Jijiang Liu --- 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 bb0f345..ecea9e8 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]; +/* UDP tunneling port */ +uint16_t udp_port; + /* overlay packet operation */ struct ol_switch_ops overlay_options = { .port_configure = vxlan_port_init, @@ -254,6 +258,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." @@ -279,6 +284,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}, @@ -325,6 +331,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 e604b14..fc4f9de 100644 --- a/examples/tep_termination/vxlan_setup.c +++ b/examples/tep_termination/vxlan_setup.c @@ -72,6 +72,7 @@ #define RTE_TEST_TX_DESC_DEFAULT 512 extern uint16_t nb_devices; +extern uint16_t udp_port; extern uint8_t ports[RTE_MAX_ETHPORTS]; /* ethernet addresses of ports */ @@ -135,9 +136,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); if (dev_info.max_rx_queues > MAX_QUEUES) { @@ -180,6 +184,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", @@ -190,13 +200,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 -- 1.7.7.6