DPDK patches and discussions
 help / color / mirror / Atom feed
From: Helin Zhang <helin.zhang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/3] i40evf: use ether interface for validating MAC address
Date: Thu, 28 Jan 2016 16:40:22 +0800	[thread overview]
Message-ID: <1453970423-15234-3-git-send-email-helin.zhang@intel.com> (raw)
In-Reply-To: <1453970423-15234-1-git-send-email-helin.zhang@intel.com>

It uses ether interface of 'is_valid_assigned_ether_addr' for
validating MAC address. In the meanwhile, more annotations are
added for obtaining/generating VF MAC address.

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

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 14d2a50..2a54596 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;
 
-- 
2.5.0

  parent reply	other threads:[~2016-01-28  8:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28  8:40 [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Helin Zhang
2016-01-28  8:40 ` [dpdk-dev] [PATCH 1/3] i40e: add setting VF MAC address in DPDK PF host Helin Zhang
2016-01-28  8:40 ` Helin Zhang [this message]
2016-01-28  8:40 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set default MAC addresses for each VF Helin Zhang
2016-02-26  8:14 ` [dpdk-dev] [PATCH 0/3] support setting i40e VF MAC address from DPDK host side Pei, Yulong
2016-03-08  6:42 ` [dpdk-dev] [PATCH v2 0/2] add VF MAC address generation Helin Zhang
2016-03-08  0:43   ` Zhe Tao
2016-03-08 10:48     ` Bruce Richardson
2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 1/2] i40e: generate MAC address for VF Helin Zhang
2016-03-08  6:42   ` [dpdk-dev] [PATCH v2 2/2] i40evf: use ether API to validate MAC address Helin Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453970423-15234-3-git-send-email-helin.zhang@intel.com \
    --to=helin.zhang@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).