From patchwork Thu Apr 16 03:55:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijiang Liu X-Patchwork-Id: 4325 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 32285C3C2; Thu, 16 Apr 2015 05:56:23 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9E432C3A2 for ; Thu, 16 Apr 2015 05:56:20 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 15 Apr 2015 20:56:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,585,1422950400"; d="scan'208";a="481577938" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 15 Apr 2015 20:56:18 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t3G3uGNO005213; Thu, 16 Apr 2015 11:56:16 +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 t3G3uD2L029062; Thu, 16 Apr 2015 11:56:15 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t3G3uCMg029030; Thu, 16 Apr 2015 11:56:12 +0800 From: Jijiang Liu To: dev@dpdk.org, walter.e.gilmore@intel.com, thomas.long@intel.com Date: Thu, 16 Apr 2015 11:55:54 +0800 Message-Id: <1429156558-28548-7-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1429156558-28548-1-git-send-email-jijiang.liu@intel.com> References: <1429156558-28548-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH RFC 06/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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 | 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 \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; }