fm10k: check mac address
authorChen Jing D(Mark) <jing.d.chen@intel.com>
Fri, 29 May 2015 08:10:43 +0000 (16:10 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 22 Jun 2015 15:27:59 +0000 (17:27 +0200)
After acquiring MAC address from HW, it's necessary to validate
MAC address before use.

Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
Acked-by: Shaopeng He <shaopeng.he@intel.com>
Tested-by: Michael Qiu <michael.qiu@intel.com>
Acked-by: Michael Qiu <michael.qiu@intel.com>
drivers/net/fm10k/fm10k_ethdev.c

index 2e58545..ac32919 100644 (file)
@@ -1873,24 +1873,20 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
        }
 
        diag = fm10k_read_mac_addr(hw);
-       if (diag != FM10K_SUCCESS) {
-               /*
-                * TODO: remove special handling on VF. Need shared code to
-                * fix first.
-                */
-               if (hw->mac.type == fm10k_mac_pf) {
-                       PMD_INIT_LOG(ERR, "Read MAC addr failed: %d", diag);
-                       return -EIO;
-               } else {
-                       /* Generate a random addr */
-                       eth_random_addr(hw->mac.addr);
-                       memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN);
-               }
-       }
 
        ether_addr_copy((const struct ether_addr *)hw->mac.addr,
                        &dev->data->mac_addrs[0]);
 
+       if (diag != FM10K_SUCCESS ||
+               !is_valid_assigned_ether_addr(dev->data->mac_addrs)) {
+
+               /* Generate a random addr */
+               eth_random_addr(hw->mac.addr);
+               memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN);
+               ether_addr_copy((const struct ether_addr *)hw->mac.addr,
+               &dev->data->mac_addrs[0]);
+       }
+
        /* Reset the hw statistics */
        fm10k_stats_reset(dev);