[dpdk-dev,v2,2/2] i40evf: use ether API to validate MAC address

Message ID 1457419329-11915-3-git-send-email-helin.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers

Commit Message

Zhang, Helin March 8, 2016, 6:42 a.m. UTC
  It uses ether API of 'is_valid_assigned_ether_addr' to validate
MAC address. In the meanwhile, more annotations are added.

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 13c5b3d..ded7c8b 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1180,6 +1180,7 @@  i40evf_init_vf(struct rte_eth_dev *dev)
 	int i, err, bufsz;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	struct ether_addr *p_mac_addr;
 
 	vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	vf->dev_data = dev->data;
@@ -1249,13 +1250,12 @@  i40evf_init_vf(struct rte_eth_dev *dev)
 	vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
 	vf->vsi.adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
-	/* check mac addr, if it's not valid, genrate one */
-	if (I40E_SUCCESS != i40e_validate_mac_addr(\
-			vf->vsi_res->default_mac_addr))
-		eth_random_addr(vf->vsi_res->default_mac_addr);
-
-	ether_addr_copy((struct ether_addr *)vf->vsi_res->default_mac_addr,
-					(struct ether_addr *)hw->mac.addr);
+	/* Store the MAC address configured by host, or generate random one */
+	p_mac_addr = (struct ether_addr *)(vf->vsi_res->default_mac_addr);
+	if (is_valid_assigned_ether_addr(p_mac_addr)) /* Configured by host */
+		ether_addr_copy(p_mac_addr, (struct ether_addr *)hw->mac.addr);
+	else
+		eth_random_addr(hw->mac.addr); /* Generate a random one */
 
 	return 0;