From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 45E69C314 for ; Fri, 29 May 2015 10:11:04 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 29 May 2015 01:11:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,515,1427785200"; d="scan'208";a="737240902" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 29 May 2015 01:11:04 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t4T8B14T010821; Fri, 29 May 2015 16:11:01 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t4T8AwHM024847; Fri, 29 May 2015 16:11:01 +0800 Received: (from jingche2@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t4T8Awnv024842; Fri, 29 May 2015 16:10:58 +0800 From: "Chen Jing D(Mark)" To: dev@dpdk.org Date: Fri, 29 May 2015 16:10:43 +0800 Message-Id: <1432887044-24777-6-git-send-email-jing.d.chen@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1432887044-24777-1-git-send-email-jing.d.chen@intel.com> References: <1432887044-24777-1-git-send-email-jing.d.chen@intel.com> Cc: shaopeng.he@intel.com Subject: [dpdk-dev] [PATCH 5/6] fm10k: Do sanity check on 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: , X-List-Received-Date: Fri, 29 May 2015 08:11:04 -0000 From: "Chen Jing D(Mark)" After acquiring MAC address from HW, it's necessary to validate MAC address before use. Signed-off-by: Chen Jing D(Mark) --- drivers/net/fm10k/fm10k_ethdev.c | 24 ++++++++++-------------- 1 files changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index dedfbb4..b6e82e3 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -1756,24 +1756,20 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) } diag = fm10k_read_mac_addr(hw); - if (diag != FM10K_SUCCESS) { - /* - * TODO: remove special handling on VF. Need shared code to - * fix first. - */ - if (hw->mac.type == fm10k_mac_pf) { - PMD_INIT_LOG(ERR, "Read MAC addr failed: %d", diag); - return -EIO; - } else { - /* Generate a random addr */ - eth_random_addr(hw->mac.addr); - memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN); - } - } ether_addr_copy((const struct ether_addr *)hw->mac.addr, &dev->data->mac_addrs[0]); + if (diag != FM10K_SUCCESS || + !is_valid_assigned_ether_addr(dev->data->mac_addrs)) { + + /* Generate a random addr */ + eth_random_addr(hw->mac.addr); + memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN); + ether_addr_copy((const struct ether_addr *)hw->mac.addr, + &dev->data->mac_addrs[0]); + } + /* Reset the hw statistics */ fm10k_stats_reset(dev); -- 1.7.7.6