net/bnx2x: set random MAC address if none assigned
authorCharles (Chas) Williams <ciwillia@brocade.com>
Tue, 21 Jun 2016 12:18:46 +0000 (08:18 -0400)
committerBruce Richardson <bruce.richardson@intel.com>
Mon, 4 Jul 2016 13:19:55 +0000 (15:19 +0200)
If the PF hasn't assigned an address, assign one randomly.  While here,
convert to use DPDK's ether address utility routines.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
Acked-by: Rasesh Mody <rasesh.mody@qlogic.com>
drivers/net/bnx2x/bnx2x.h
drivers/net/bnx2x/bnx2x_vfpf.c
drivers/net/bnx2x/bnx2x_vfpf.h

index c24a530..78757a8 100644 (file)
@@ -1906,14 +1906,6 @@ pci_find_cap(struct bnx2x_softc *sc, uint8_t id, uint8_t type)
        return NULL;
 }
 
-static inline int is_valid_ether_addr(uint8_t *addr)
-{
-       if (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]))
-               return 0;
-       else
-               return 1;
-}
-
 static inline void
 bnx2x_set_rx_mode(struct bnx2x_softc *sc)
 {
index 14b1d10..1c895f8 100644 (file)
@@ -293,10 +293,11 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_
                sc->igu_sb_cnt, sc->igu_base_sb);
        strncpy(sc->fw_ver, sc_resp.fw_ver, sizeof(sc->fw_ver));
 
-       if (is_valid_ether_addr(sc_resp.resc.current_mac_addr))
-               (void)rte_memcpy(sc->link_params.mac_addr,
-                      sc_resp.resc.current_mac_addr,
-                      ETH_ALEN);
+       if (is_valid_assigned_ether_addr(&sc_resp.resc.current_mac_addr))
+               ether_addr_copy(&sc_resp.resc.current_mac_addr,
+                               (struct ether_addr *)sc->link_params.mac_addr);
+       else
+               eth_random_addr(sc->link_params.mac_addr);
 
        return 0;
 }
index 966240c..f854d81 100644 (file)
@@ -114,7 +114,7 @@ struct vf_resc {
        uint8_t num_vlan_filters;
        uint8_t num_mc_filters;
        uint8_t permanent_mac_addr[ETH_ALEN];
-       uint8_t current_mac_addr[ETH_ALEN];
+       struct ether_addr current_mac_addr;
        uint16_t pf_link_speed;
        uint32_t pf_link_supported;
 };