From: Chen Jing D(Mark) Date: Fri, 29 May 2015 08:10:43 +0000 (+0800) Subject: fm10k: check mac address X-Git-Tag: spdx-start~9021 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a66ce098e8707aee38374926843e0d3db6f9590d;p=dpdk.git fm10k: check mac address After acquiring MAC address from HW, it's necessary to validate MAC address before use. Signed-off-by: Chen Jing D(Mark) Acked-by: Shaopeng He Tested-by: Michael Qiu Acked-by: Michael Qiu --- diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 2e58545767..ac3291996b 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -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);