From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1E69FC7B0 for ; Mon, 22 Jun 2015 18:41:28 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 22 Jun 2015 09:41:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,660,1427785200"; d="scan'208";a="732361850" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 22 Jun 2015 09:41:26 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t5MGfPNm005593; Tue, 23 Jun 2015 00:41:25 +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 t5MGfLp9020463; Tue, 23 Jun 2015 00:41:23 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t5MGfL3R020459; Tue, 23 Jun 2015 00:41:21 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Tue, 23 Jun 2015 00:41:01 +0800 Message-Id: <1434991265-20384-7-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1434991265-20384-1-git-send-email-jijiang.liu@intel.com> References: <1434991265-20384-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH v5 06/10] examples/tep_termination:add tunnel filter type configuration 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, 22 Jun 2015 16:41:30 -0000 Add the filter types for VXLAN packet. The following filter type are added here. - Inner MAC&VLAN and tenant ID - Inner MAC and tenent ID, and Outer MAC - Inner MAC and tenant ID Signed-off-by: Jijiang Liu --- examples/tep_termination/main.c | 22 ++++++++++ examples/tep_termination/vxlan_setup.c | 67 +++++++++++++++++++++++++++++++- examples/tep_termination/vxlan_setup.h | 1 + 3 files changed, 89 insertions(+), 1 deletions(-) diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c index 0f598ff..4119d30 100644 --- a/examples/tep_termination/main.c +++ b/examples/tep_termination/main.c @@ -113,6 +113,7 @@ #define CMD_LINE_OPT_NB_DEVICES "nb-devices" #define CMD_LINE_OPT_UDP_PORT "udp-port" +#define CMD_LINE_OPT_FILTER_TYPE "filter-type" #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" @@ -140,6 +141,9 @@ struct vpool { /* UDP tunneling port */ uint16_t udp_port; +/* RX filter type for tunneling packet */ +uint8_t filter_idx = 1; + /* overlay packet operation */ struct ol_switch_ops overlay_options = { .port_configure = vxlan_port_init, @@ -266,6 +270,10 @@ 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" + " --filter-type[1-3]: filter type for tunneling packet\n" + " 1: Inner MAC and tenent ID\n" + " 2: Inner MAC and VLAN, and tenent ID\n" + " 3: Outer MAC, Inner MAC and tenent ID\n" " -p PORTMASK: Set mask for ports to be used by application\n" " --rx-retry [0|1]: disable/enable(default) retries on rx." " Enable retry if destintation queue is full\n" @@ -291,6 +299,7 @@ tep_termination_parse_args(int argc, char **argv) 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_FILTER_TYPE, 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}, @@ -383,6 +392,19 @@ tep_termination_parse_args(int argc, char **argv) burst_rx_retry_num = ret; } + if (!strncmp(long_option[option_index].name, + CMD_LINE_OPT_FILTER_TYPE, + sizeof(CMD_LINE_OPT_FILTER_TYPE))) { + ret = parse_num_opt(optarg, 3); + if ((ret == -1) || (ret == 0)) { + RTE_LOG(INFO, VHOST_CONFIG, + "Invalid argument for filter type [1-3]\n"); + tep_termination_usage(prgname); + return -1; + } else + filter_idx = ret - 1; + } + /* Enable/disable stats. */ if (!strncmp(long_option[option_index].name, CMD_LINE_OPT_STATS, diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c index 54d7984..942fc06 100644 --- a/examples/tep_termination/vxlan_setup.c +++ b/examples/tep_termination/vxlan_setup.c @@ -71,6 +71,9 @@ #define RTE_TEST_RX_DESC_DEFAULT 1024 #define RTE_TEST_TX_DESC_DEFAULT 512 +/* Default inner VLAN ID */ +#define INNER_VLAN_ID 100 + /* VXLAN device */ struct vxlan_conf vxdev; @@ -86,6 +89,11 @@ uint8_t vxlan_overlay_ips[2][4] = { {192, 168, 10, 1}, {192, 168, 30, 1} }; /* Remote VTEP MAC address */ uint8_t peer_mac[6] = {0x00, 0x11, 0x01, 0x00, 0x00, 0x01}; +/* VXLAN RX filter type */ +uint8_t tep_filter_type[] = {RTE_TUNNEL_FILTER_IMAC_TENID, + RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID, + RTE_TUNNEL_FILTER_OMAC_TENID_IMAC,}; + /* Options for configuring ethernet port */ static const struct rte_eth_conf port_conf = { .rxmode = { @@ -220,12 +228,14 @@ vxlan_tx_process(uint8_t queue_id, struct rte_mbuf *pkt) int vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m) { - int i; + int i, ret; struct ether_hdr *pkt_hdr; struct virtio_net *dev = vdev->dev; uint64_t portid = dev->device_fh; struct ipv4_hdr *ip; + struct rte_eth_tunnel_filter_conf tunnel_filter_conf; + if (unlikely(portid > VXLAN_N_PORTS)) { RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") WARNING: Not configuring device," @@ -251,6 +261,34 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m) vxdev.port[portid].peer_mac.addr_bytes[i] = peer_mac[i]; } + memset(&tunnel_filter_conf, 0, + sizeof(struct rte_eth_tunnel_filter_conf)); + + tunnel_filter_conf.outer_mac = &ports_eth_addr[0]; + tunnel_filter_conf.filter_type = tep_filter_type[filter_idx]; + + /* inner MAC */ + tunnel_filter_conf.inner_mac = &vdev->mac_address; + + tunnel_filter_conf.queue_id = vdev->rx_q; + tunnel_filter_conf.tenant_id = tenant_id_conf[vdev->rx_q]; + + if (tep_filter_type[filter_idx] == RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID) + tunnel_filter_conf.inner_vlan = INNER_VLAN_ID; + + tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; + + ret = rte_eth_dev_filter_ctrl(ports[0], + RTE_ETH_FILTER_TUNNEL, + RTE_ETH_FILTER_ADD, + &tunnel_filter_conf); + if (ret) { + RTE_LOG(ERR, VHOST_DATA, + "%d Failed to add device MAC address to cloud filter\n", + vdev->rx_q); + return -1; + } + /* Print out inner MAC and VNI info. */ RTE_LOG(INFO, VHOST_DATA, "(%d) MAC_ADDRESS %02x:%02x:%02x:%02x:%02x:%02x and VNI %d registered\n", @@ -306,9 +344,36 @@ void vxlan_unlink(struct vhost_dev *vdev) { unsigned i = 0, rx_count; + int ret; struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; + struct rte_eth_tunnel_filter_conf tunnel_filter_conf; if (vdev->ready == DEVICE_RX) { + memset(&tunnel_filter_conf, 0, + sizeof(struct rte_eth_tunnel_filter_conf)); + + tunnel_filter_conf.outer_mac = &ports_eth_addr[0]; + tunnel_filter_conf.inner_mac = &vdev->mac_address; + tunnel_filter_conf.tenant_id = tenant_id_conf[vdev->rx_q]; + tunnel_filter_conf.filter_type = tep_filter_type[filter_idx]; + + if (tep_filter_type[filter_idx] == + RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID) + tunnel_filter_conf.inner_vlan = INNER_VLAN_ID; + + tunnel_filter_conf.queue_id = vdev->rx_q; + tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; + + ret = rte_eth_dev_filter_ctrl(ports[0], + RTE_ETH_FILTER_TUNNEL, + RTE_ETH_FILTER_DELETE, + &tunnel_filter_conf); + if (ret) { + RTE_LOG(ERR, VHOST_DATA, + "%d Failed to add device MAC address to cloud filter\n", + vdev->rx_q); + return; + } for (i = 0; i < ETHER_ADDR_LEN; i++) vdev->mac_address.addr_bytes[i] = 0; diff --git a/examples/tep_termination/vxlan_setup.h b/examples/tep_termination/vxlan_setup.h index d5d1b9d..96442e2 100644 --- a/examples/tep_termination/vxlan_setup.h +++ b/examples/tep_termination/vxlan_setup.h @@ -36,6 +36,7 @@ extern uint16_t nb_devices; extern uint16_t udp_port; +extern uint8_t filter_idx; extern uint8_t ports[RTE_MAX_ETHPORTS]; extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; -- 1.7.7.6