From patchwork Tue Mar 8 06:42:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Helin" X-Patchwork-Id: 11159 X-Patchwork-Delegate: bruce.richardson@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 378543238; Tue, 8 Mar 2016 07:42:23 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id DA5F22C6B for ; Tue, 8 Mar 2016 07:42:21 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 07 Mar 2016 22:42:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,555,1449561600"; d="scan'208";a="904645331" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 07 Mar 2016 22:42:20 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u286gH83024039; Tue, 8 Mar 2016 14:42:17 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u286gELT011963; Tue, 8 Mar 2016 14:42:16 +0800 Received: (from hzhan75@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u286gENG011959; Tue, 8 Mar 2016 14:42:14 +0800 From: Helin Zhang To: dev@dpdk.org Date: Tue, 8 Mar 2016 14:42:09 +0800 Message-Id: <1457419329-11915-3-git-send-email-helin.zhang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1457419329-11915-1-git-send-email-helin.zhang@intel.com> References: <1453970423-15234-1-git-send-email-helin.zhang@intel.com> <1457419329-11915-1-git-send-email-helin.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 2/2] i40evf: use ether API to validate MAC address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 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;