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 8608BB376 for ; Mon, 25 Aug 2014 04:05:56 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 24 Aug 2014 19:03:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,393,1406617200"; d="scan'208";a="562892707" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 24 Aug 2014 19:09:47 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s7P29jVZ025048; Mon, 25 Aug 2014 10:09:45 +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 s7P29hah010465; Mon, 25 Aug 2014 10:09:45 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7P29gJA010461; Mon, 25 Aug 2014 10:09:42 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Mon, 25 Aug 2014 10:09:30 +0800 Message-Id: <1408932572-10343-4-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1408932572-10343-1-git-send-email-changchun.ouyang@intel.com> References: <1408932572-10343-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH 3/5] examples/vhost: enable promisc mode and config VMDQ offload register for multicast feature 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, 25 Aug 2014 02:05:57 -0000 This patch is to let vhost receive and forward multicast and broadcast packets, add promiscuous option into command line; and set VMDQ RX mode as: ETH_VMDQ_ACCEPT_BROADCAST|ETH_VMDQ_ACCEPT_MULTICAST if promisc mode is on. Signed-off-by: Changchun Ouyang Acked-by: Huawei Xie Acked-by: Cunming Liang --- examples/vhost/main.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 193aa25..4acc7b8 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -161,6 +161,9 @@ /* mask of enabled ports */ static uint32_t enabled_port_mask = 0; +/* Ports set in promiscuous mode off by default. */ +static uint32_t promiscuous_on; + /*Number of switching cores enabled*/ static uint32_t num_switching_cores = 0; @@ -278,6 +281,7 @@ static struct rte_eth_conf vmdq_conf_default = { .enable_default_pool = 0, .default_pool = 0, .nb_pool_maps = 0, + .rx_mode = 0, .pool_map = {{0, 0},}, }, }, @@ -368,13 +372,15 @@ static inline int get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_devices) { struct rte_eth_vmdq_rx_conf conf; + struct rte_eth_vmdq_rx_conf *def_conf = + &vmdq_conf_default.rx_adv_conf.vmdq_rx_conf; unsigned i; memset(&conf, 0, sizeof(conf)); conf.nb_queue_pools = (enum rte_eth_nb_pools)num_devices; conf.nb_pool_maps = num_devices; - conf.enable_loop_back = - vmdq_conf_default.rx_adv_conf.vmdq_rx_conf.enable_loop_back; + conf.enable_loop_back = def_conf->enable_loop_back; + conf.rx_mode = def_conf->rx_mode; for (i = 0; i < conf.nb_pool_maps; i++) { conf.pool_map[i].vlan_id = vlan_tags[ i ]; @@ -472,6 +478,9 @@ port_init(uint8_t port) return retval; } + if (promiscuous_on) + rte_eth_promiscuous_enable(port); + rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]); RTE_LOG(INFO, VHOST_PORT, "Max virtio devices supported: %u\n", num_devices); RTE_LOG(INFO, VHOST_PORT, "Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8 @@ -604,7 +613,8 @@ us_vhost_parse_args(int argc, char **argv) }; /* Parse command line */ - while ((opt = getopt_long(argc, argv, "p:",long_option, &option_index)) != EOF) { + while ((opt = getopt_long(argc, argv, "p:P", + long_option, &option_index)) != EOF) { switch (opt) { /* Portmask */ case 'p': @@ -616,6 +626,15 @@ us_vhost_parse_args(int argc, char **argv) } break; + case 'P': + promiscuous_on = 1; + vmdq_conf_default.rx_adv_conf.vmdq_rx_conf.rx_mode = + ETH_VMDQ_ACCEPT_BROADCAST | + ETH_VMDQ_ACCEPT_MULTICAST; + VHOST_FEATURES |= (1ULL << VIRTIO_NET_F_CTRL_RX); + + break; + case 0: /* Enable/disable vm2vm comms. */ if (!strncmp(long_option[option_index].name, "vm2vm", @@ -677,7 +696,7 @@ us_vhost_parse_args(int argc, char **argv) return -1; } else { if (ret) - VHOST_FEATURES = (1ULL << VIRTIO_NET_F_MRG_RXBUF); + VHOST_FEATURES |= (1ULL << VIRTIO_NET_F_MRG_RXBUF); } } -- 1.8.4.2