DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] bnx2x: set random MAC address if one isn't assigned
@ 2016-06-21 12:18 Chas Williams
  2016-06-29 10:55 ` Bruce Richardson
  0 siblings, 1 reply; 4+ messages in thread
From: Chas Williams @ 2016-06-21 12:18 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

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: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x.h      | 8 --------
 drivers/net/bnx2x/bnx2x_vfpf.c | 9 +++++----
 drivers/net/bnx2x/bnx2x_vfpf.h | 2 +-
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 135a6eb..78374e2 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -1904,14 +1904,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)
 {
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 14b1d10..89f2fd4 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -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;
 }
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.h b/drivers/net/bnx2x/bnx2x_vfpf.h
index 966240c..f854d81 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.h
+++ b/drivers/net/bnx2x/bnx2x_vfpf.h
@@ -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;
 };
-- 
2.5.5

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-04 13:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21 12:18 [dpdk-dev] [PATCH] bnx2x: set random MAC address if one isn't assigned Chas Williams
2016-06-29 10:55 ` Bruce Richardson
2016-06-30 19:50   ` Rasesh Mody
2016-07-04 13:22     ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).