blob: 951694ded79425407906561bf2926845ea06f7d9 [file] [log] [blame]
Steve Shind03798c2017-01-30 09:32:00 -08001From fb7c10892b057533931553f9367acd5541a0537c Mon Sep 17 00:00:00 2001
2From: Steve Shin <jonshin@cisco.com>
3Date: Mon, 30 Jan 2017 09:12:25 -0800
4Subject: [PATCH] This patch fixes a bug in replaying MAC address to the
5 hardware in rte_eth_dev_config_restore() routine. Added default MAC replay as
6 well.
7
8Fixes: 4bdefaade6d1 ("ethdev: VMDQ enhancements")
9
10Signed-off-by: Steve Shin <jonshin@cisco.com>
11---
12 lib/librte_ether/rte_ethdev.c | 48 ++++++++++++++++++++++++-------------------
13 1 file changed, 27 insertions(+), 21 deletions(-)
14
15diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
16index fde8112..2c07dfe 100644
17--- a/lib/librte_ether/rte_ethdev.c
18+++ b/lib/librte_ether/rte_ethdev.c
19@@ -857,34 +857,40 @@ struct rte_eth_dev *
20 {
21 struct rte_eth_dev *dev;
22 struct rte_eth_dev_info dev_info;
23- struct ether_addr addr;
24+ struct ether_addr *addr;
25 uint16_t i;
26 uint32_t pool = 0;
27+ uint64_t pool_mask;
28
29 dev = &rte_eth_devices[port_id];
30
31 rte_eth_dev_info_get(port_id, &dev_info);
32
33- if (RTE_ETH_DEV_SRIOV(dev).active)
34- pool = RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx;
35-
36- /* replay MAC address configuration */
37- for (i = 0; i < dev_info.max_mac_addrs; i++) {
38- addr = dev->data->mac_addrs[i];
39-
40- /* skip zero address */
41- if (is_zero_ether_addr(&addr))
42- continue;
43-
44- /* add address to the hardware */
45- if (*dev->dev_ops->mac_addr_add &&
46- (dev->data->mac_pool_sel[i] & (1ULL << pool)))
47- (*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
48- else {
49- RTE_PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
50- port_id);
51- /* exit the loop but not return an error */
52- break;
53+ /* replay MAC address configuration including default MAC */
54+ addr = &dev->data->mac_addrs[0];
55+ if (*dev->dev_ops->mac_addr_set != NULL)
56+ (*dev->dev_ops->mac_addr_set)(dev, addr);
57+ else if (*dev->dev_ops->mac_addr_add != NULL)
58+ (*dev->dev_ops->mac_addr_add)(dev, addr, 0, pool);
59+
60+ if (*dev->dev_ops->mac_addr_add != NULL) {
61+ for (i = 1; i < dev_info.max_mac_addrs; i++) {
62+ addr = &dev->data->mac_addrs[i];
63+
64+ /* skip zero address */
65+ if (is_zero_ether_addr(addr))
66+ continue;
67+
68+ pool = 0;
69+ pool_mask = dev->data->mac_pool_sel[i];
70+
71+ do {
72+ if (pool_mask & 1ULL)
73+ (*dev->dev_ops->mac_addr_add)(dev,
74+ addr, i, pool);
75+ pool_mask >>= 1;
76+ pool++;
77+ } while (pool_mask);
78 }
79 }
80
81--
821.9.1
83