From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EB90AA04DD for ; Wed, 28 Oct 2020 11:47:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DA721C9EC; Wed, 28 Oct 2020 11:47:04 +0100 (CET) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 904D1C8F8 for ; Wed, 28 Oct 2020 11:47:03 +0100 (CET) Received: by mail-wr1-f65.google.com with SMTP id a9so1330350wrg.12 for ; Wed, 28 Oct 2020 03:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rzhMD/rQd7z4kMATd3bgsk3CNvfOzFd5ibiKvekeMNs=; b=H5vv9xndnn5kz0oQHdq5ajNP6RYDJFPDgXameOE9RR7PiRBd2lxzHnd1VQOJP95g6T BRZ7BDiUo7pVR+tOGycci6BUg8+9M2BFXEs2dIT4SZ54E6ySyVD/JQcnqUOcatE7HA/s nfysA8WTFPpVV2vQ1LkZSiJ9mxGuPqPkGqFAa8WdMb//C1v0Yibh3YnkU+YhfBi6BEDs /d5s4Bga+UORWLhJs5agIWFFzR624MNPCXkthKEMxIdNW7d+6HFEntTD6CTqgRxFKrDI epsO8PzKtqp04FWhTSU9EGpbGBIsFhtnj6hefg3LOhentUg9i1dAid3OqEvIKLrmtEbk J+kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rzhMD/rQd7z4kMATd3bgsk3CNvfOzFd5ibiKvekeMNs=; b=NK5gbd5F3X9h7PX07LkL9K+WaTEmNva1tmIzLjNagi/Rx6RqqTBXe7MKGaprnP4CaV 9lgn++y9Kzwb4Ilst0mBnNNPfshsXViubQC1Y8FfCgih39b7sKzaTjB7J4ZOHTFGuwwv TRmWmgBZqsXch89sBP+kwwfez+701xY3YUBzZ2rTNpAgUx8Xm+j3cDcSgJ7TuCLYr3rG RObOeKMPpwiVYwRQq/D1VbHxFW54AnQPocjBOH0S8cL/HZCbbt1+0q1GNTQyl0mmbyNb Cyj64BNwssu9eVpVcgJickTWNsFpDSeM07pNnRQtH4fYKVC2WIGvleP3lnAQjRoPTRfZ YApQ== X-Gm-Message-State: AOAM530Yhpc9/Bm8hFsDyRsVRP1DgK7UkJehyECi4LbiYAFdZ95qbspe xDd8TvdNnMOw4mMuFor61K1ZdTuEPotpKA== X-Google-Smtp-Source: ABdhPJxAyk76rRFW9fqIMw1xey2HqKfsFEwBy4q0rscuz8nLXlkhjSGSXI490I7Idb+I0tqqfxVi/A== X-Received: by 2002:adf:c00b:: with SMTP id z11mr7806295wre.320.1603882022295; Wed, 28 Oct 2020 03:47:02 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id 71sm6482644wrm.20.2020.10.28.03.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:47:01 -0700 (PDT) From: luca.boccassi@gmail.com To: Huisong Li Cc: Wei Hu , Chengchang Tang , dpdk stable Date: Wed, 28 Oct 2020 10:42:56 +0000 Message-Id: <20201028104606.3504127-17-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201028104606.3504127-1-luca.boccassi@gmail.com> References: <20201028104606.3504127-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hns3: fix default MAC address from firmware' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/30/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From d7c09f1d39c794a95dd7b6f98945e0262e006d1a Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Tue, 25 Aug 2020 19:53:03 +0800 Subject: [PATCH] net/hns3: fix default MAC address from firmware [ upstream commit 6c507191d12f2071625b70b220d3f4ffb4e34132 ] Currently, default MAC address obtained from firmware in PF driver is directly used by .mac_addr_set ops implementation function when the rte_eth_dev_start API function is executed. At this moment, if the default MAC addr isn't an unicast address, it will fail to set default MAC addr to hardware. So this patch adds the validity check of default MAC addr in PF driver. We will use a random unicast address, if the default MAC address obtained from firmware is not a valid unicast address. In addition, this patch also adjusts the location of processing default MAC addr in VF driver so as to increase relevance and readability of the code. Fixes: eab21776717e ("net/hns3: support setting VF MAC address by PF driver") Fixes: d51867db65c1 ("net/hns3: add initialization") Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengchang Tang --- drivers/net/hns3/hns3_ethdev.c | 11 +++++++++++ drivers/net/hns3/hns3_ethdev_vf.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 217aea4c05..cac1aa53b4 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5386,6 +5386,8 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) struct rte_device *dev = eth_dev->device; struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev); struct hns3_adapter *hns = eth_dev->data->dev_private; + char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct rte_ether_addr *eth_addr; struct hns3_hw *hw = &hns->hw; uint16_t device_id = pci_dev->id.device_id; int ret; @@ -5464,6 +5466,15 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) goto err_rte_zmalloc; } + eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; + if (!rte_is_valid_assigned_ether_addr(eth_addr)) { + rte_eth_random_addr(hw->mac.mac_addr); + rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, + (struct rte_ether_addr *)hw->mac.mac_addr); + hns3_warn(hw, "default mac_addr from firmware is an invalid " + "unicast address, using random MAC address %s", + mac_str); + } rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.mac_addr, ð_dev->data->mac_addrs[0]); diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index b929fbcc84..7acc679e9b 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1458,8 +1458,6 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) goto err_get_config; } - rte_eth_random_addr(hw->mac.mac_addr); /* Generate a random mac addr */ - ret = hns3vf_clear_vport_list(hw); if (ret) { PMD_INIT_LOG(ERR, "Failed to clear tbl list: %d", ret); @@ -2253,8 +2251,10 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) goto err_rte_zmalloc; } + rte_eth_random_addr(hw->mac.mac_addr); /* Generate a random mac addr */ rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.mac_addr, ð_dev->data->mac_addrs[0]); + hw->adapter_state = HNS3_NIC_INITIALIZED; /* * Pass the information to the rte_eth_dev_close() that it should also -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-28 10:35:12.320282074 +0000 +++ 0017-net-hns3-fix-default-MAC-address-from-firmware.patch 2020-10-28 10:35:11.432828963 +0000 @@ -1,8 +1,10 @@ -From 6c507191d12f2071625b70b220d3f4ffb4e34132 Mon Sep 17 00:00:00 2001 +From d7c09f1d39c794a95dd7b6f98945e0262e006d1a Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Tue, 25 Aug 2020 19:53:03 +0800 Subject: [PATCH] net/hns3: fix default MAC address from firmware +[ upstream commit 6c507191d12f2071625b70b220d3f4ffb4e34132 ] + Currently, default MAC address obtained from firmware in PF driver is directly used by .mac_addr_set ops implementation function when the rte_eth_dev_start API function is executed. At this moment, if the @@ -19,30 +21,29 @@ Fixes: eab21776717e ("net/hns3: support setting VF MAC address by PF driver") Fixes: d51867db65c1 ("net/hns3: add initialization") -Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengchang Tang --- drivers/net/hns3/hns3_ethdev.c | 11 +++++++++++ - drivers/net/hns3/hns3_ethdev_vf.c | 29 ++++++++++++++--------------- - 2 files changed, 25 insertions(+), 15 deletions(-) + drivers/net/hns3/hns3_ethdev_vf.c | 4 ++-- + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index fca035d4f5..4d5fa94ff4 100644 +index 217aea4c05..cac1aa53b4 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5574,6 +5574,8 @@ static int - hns3_dev_init(struct rte_eth_dev *eth_dev) - { +@@ -5386,6 +5386,8 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) + struct rte_device *dev = eth_dev->device; + struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev); struct hns3_adapter *hns = eth_dev->data->dev_private; + char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct rte_ether_addr *eth_addr; struct hns3_hw *hw = &hns->hw; + uint16_t device_id = pci_dev->id.device_id; int ret; - -@@ -5646,6 +5648,15 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) +@@ -5464,6 +5466,15 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) goto err_rte_zmalloc; } @@ -59,48 +60,23 @@ ð_dev->data->mac_addrs[0]); diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index e0d6783b4a..1d8eef78ed 100644 +index b929fbcc84..7acc679e9b 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1748,21 +1748,6 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) +@@ -1458,8 +1458,6 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) goto err_get_config; } -- /* -- * The hns3 PF ethdev driver in kernel support setting VF MAC address -- * on the host by "ip link set ..." command. To avoid some incorrect -- * scenes, for example, hns3 VF PMD driver fails to receive and send -- * packets after user configure the MAC address by using the -- * "ip link set ..." command, hns3 VF PMD driver keep the same MAC -- * address strategy as the hns3 kernel ethdev driver in the -- * initialization. If user configure a MAC address by the ip command -- * for VF device, then hns3 VF PMD driver will start with it, otherwise -- * start with a random MAC address in the initialization. -- */ -- ret = rte_is_zero_ether_addr((struct rte_ether_addr *)hw->mac.mac_addr); -- if (ret) -- rte_eth_random_addr(hw->mac.mac_addr); +- rte_eth_random_addr(hw->mac.mac_addr); /* Generate a random mac addr */ - ret = hns3vf_clear_vport_list(hw); if (ret) { PMD_INIT_LOG(ERR, "Failed to clear tbl list: %d", ret); -@@ -2644,8 +2629,22 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2253,8 +2251,10 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) goto err_rte_zmalloc; } -+ /* -+ * The hns3 PF ethdev driver in kernel support setting VF MAC address -+ * on the host by "ip link set ..." command. To avoid some incorrect -+ * scenes, for example, hns3 VF PMD driver fails to receive and send -+ * packets after user configure the MAC address by using the -+ * "ip link set ..." command, hns3 VF PMD driver keep the same MAC -+ * address strategy as the hns3 kernel ethdev driver in the -+ * initialization. If user configure a MAC address by the ip command -+ * for VF device, then hns3 VF PMD driver will start with it, otherwise -+ * start with a random MAC address in the initialization. -+ */ -+ if (rte_is_zero_ether_addr((struct rte_ether_addr *)hw->mac.mac_addr)) -+ rte_eth_random_addr(hw->mac.mac_addr); ++ rte_eth_random_addr(hw->mac.mac_addr); /* Generate a random mac addr */ rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.mac_addr, ð_dev->data->mac_addrs[0]); +