From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-7.cisco.com (alln-iport-7.cisco.com [173.37.142.94]) by dpdk.org (Postfix) with ESMTP id A6F48108F for ; Tue, 24 Jan 2017 03:21:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2429; q=dns/txt; s=iport; t=1485224512; x=1486434112; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=nYiPZ30JCzSiBUk8EGU/a4sgwc7L/oS24+T5ifWrM0k=; b=T0mgC70gNYLImRAtXDLM2WGtUZ0uj7JcCClp+SwNtP/Rh5XAasoVxO5g /yvbALrfj/D2gVm9dd+eUQk7UT1L1LbWC9SRKs3DkvNmQ9JXhesGCXE8K 65tuHRuvyi1kYA5jyXFVkoakZvpwUZ+lNBmHi4yyZ9L0ZtBXbqHZWPYT3 0=; X-IronPort-AV: E=Sophos;i="5.33,276,1477958400"; d="scan'208";a="376321075" Received: from rcdn-core-3.cisco.com ([173.37.93.154]) by alln-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2017 02:21:51 +0000 Received: from sjc-ads-512.cisco.com (sjc-ads-512.cisco.com [10.28.13.212]) by rcdn-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id v0O2LoVl019100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 24 Jan 2017 02:21:50 GMT Received: from sjc-ads-512.cisco.com (localhost.localdomain [127.0.0.1]) by sjc-ads-512.cisco.com (8.13.8/8.13.8) with ESMTP id v0O2Ln1F007585; Mon, 23 Jan 2017 18:21:49 -0800 Received: (from jonshin@localhost) by sjc-ads-512.cisco.com (8.13.8/8.13.8/Submit) id v0O2Ln20007584; Mon, 23 Jan 2017 18:21:49 -0800 From: Steve Shin To: dev@dpdk.org Cc: ferruh.yigit@intel.com, iryzhov@nfware.com, Steve Shin Date: Mon, 23 Jan 2017 18:21:45 -0800 Message-Id: <20170124022145.7540-1-jonshin@cisco.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170123235020.19641-1-jonshin@cisco.com> References: <20170123235020.19641-1-jonshin@cisco.com> Subject: [dpdk-dev] [PATCH v4] ethdev: fix MAC address replay X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jan 2017 02:21:53 -0000 This patch fixes a bug in replaying MAC address to the hardware in rte_eth_dev_config_restore() routine. Added default MAC replay as well. Fixes: 4bdefaade6d1 ("ethdev: VMDQ enhancements") --- v2: Added default MAC replay & Code optimization v3: Covered a case (ex, SR-IOV) where multiple pools exist in the mac_pool_sel array. v4: removed a coding style warning Signed-off-by: Steve Shin --- lib/librte_ether/rte_ethdev.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 4790faf..166ffa6 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -931,34 +931,39 @@ rte_eth_dev_config_restore(uint8_t port_id) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; - struct ether_addr addr; + struct ether_addr *addr; uint16_t i; - uint32_t pool = 0; + uint32_t pool; + uint64_t pool_mask; dev = &rte_eth_devices[port_id]; rte_eth_dev_info_get(port_id, &dev_info); - if (RTE_ETH_DEV_SRIOV(dev).active) - pool = RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx; + /* replay MAC address configuration including default MAC */ + if (*dev->dev_ops->mac_addr_set != NULL) { + addr = &dev->data->mac_addrs[0]; + (*dev->dev_ops->mac_addr_set)(dev, addr); + } - /* replay MAC address configuration */ - for (i = 0; i < dev_info.max_mac_addrs; i++) { - addr = dev->data->mac_addrs[i]; + if (*dev->dev_ops->mac_addr_add != NULL) { + for (i = 1; i < dev_info.max_mac_addrs; i++) { + addr = &dev->data->mac_addrs[i]; - /* skip zero address */ - if (is_zero_ether_addr(&addr)) - continue; + /* skip zero address */ + if (is_zero_ether_addr(addr)) + continue; - /* add address to the hardware */ - if (*dev->dev_ops->mac_addr_add && - (dev->data->mac_pool_sel[i] & (1ULL << pool))) - (*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool); - else { - RTE_PMD_DEBUG_TRACE("port %d: MAC address array not supported\n", - port_id); - /* exit the loop but not return an error */ - break; + pool = 0; + pool_mask = dev->data->mac_pool_sel[i]; + + do { + if (pool_mask & 1ULL) + (*dev->dev_ops->mac_addr_add)(dev, + addr, i, pool); + pool_mask >>= 1; + pool++; + } while (pool_mask); } } -- 2.9.3