From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F25F0A0351 for ; Mon, 10 Jan 2022 08:46:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C80744013F; Mon, 10 Jan 2022 08:46:07 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id 3D16E4013F for ; Mon, 10 Jan 2022 08:46:06 +0100 (CET) Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8B594406EC for ; Mon, 10 Jan 2022 07:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1641800763; bh=OcrJBvBJsm13QI0ccwzBTu5D9Rdus40Koeor6RmG+V0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FKabw/05RYEQmhQeF5eU17j7rrdw4FVDGLog8pgmmZSv8qsZq1mPV19H30td9isRW qr0sRQScMeZW6buhZHmyNxAIyqloedZeltCXRDZjqY7cKSBGf75kes2w2/TPMphc5c YR9HNb+zwBHRsHwPrYW17iZKvz58xbF1xgB4AFb4KRm5AVBUX5uKHSnQ7IFOReKtPM Skw/qO2A1YJ2wSy1yOqQ1Xms6uVcWEx1WUsGqdHos6COfe4l/+lZOSw++N6qYBeHjb gtguE7+oll91dVueye6bQNtKzFlOQNMr3JytU9aPk1hLSLtYOtZCRvA2ZLFbUlAU64 0sM5GNn5n8Uag== Received: by mail-qv1-f69.google.com with SMTP id iw6-20020a0562140f2600b004118fe44fa1so12400082qvb.13 for ; Sun, 09 Jan 2022 23:46:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OcrJBvBJsm13QI0ccwzBTu5D9Rdus40Koeor6RmG+V0=; b=7iODzRioYfM3ztSDubIX3M+NI68uMWplKKW600VNtsJJj9qNX3VYqe5nk2fsBXKXzm Kb9gozzAPBrIvyFH8ygz85uOEzepQ9Aq6w+bXaysEQ+MGqalXuu4yUXGjTrHs8RHbOmk VEe47IJYW3pWHYgPMX0ZXVcqhmw8OPvkHAWTyJ4Ne0A1+XbNouWwUgwq9pizabfoj3Zi sMcDBr9x7jvCLHNFrPIQtjPKOBuVhh3BXzyL2FNkKh4fuBYq7QxcMwtcGFTrQeTmM/U5 +HmVHyyiSXplIPaqhFF9V7J55yXz3ogPOLsa7CeA2PtnPWKaPYUTTLEkGePHoTrJcYcC RrtQ== X-Gm-Message-State: AOAM531xXB8z+uoVSI0WvF28rX1nuEQoiIkSNq4vrs9Ru/ulbzth50Xh n0UDLpSeCa5kEn8LUOWOUsri3J64+j4ofPsuKHhQXXauPJZ7JZnQBYMlK/wkorBztIIZEkpBzgj e/dXWdR5fjlHQzhnLnjTByq7xXZZ8J0lqWCDRlRM+ X-Received: by 2002:a05:620a:3192:: with SMTP id bi18mr8192858qkb.168.1641800762700; Sun, 09 Jan 2022 23:46:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6Lxiof6epT/9SnRxjGJ7ZYh4qOq2ELOZL/e/Noy1tMk6AK0KDIkZWSW2n2bWQESf/JHBJiaHh+NeT00wzxeI= X-Received: by 2002:a05:620a:3192:: with SMTP id bi18mr8192847qkb.168.1641800762437; Sun, 09 Jan 2022 23:46:02 -0800 (PST) MIME-Version: 1.0 References: <20211225105344.28355-1-lihuisong@huawei.com> <20211225105344.28355-2-lihuisong@huawei.com> In-Reply-To: <20211225105344.28355-2-lihuisong@huawei.com> From: Christian Ehrhardt Date: Mon, 10 Jan 2022 08:45:36 +0100 Message-ID: Subject: Re: [PATCH 19.11 1/4] net/hns3: fix residual MAC after setting default MAC To: Huisong Li Cc: stable@dpdk.org, humin29@huawei.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 On Sat, Dec 25, 2021 at 11:58 AM Huisong Li wrote: > > [ upstream commit 19e67d8ebced5cb12829f75c70e6c497b5925e82 ] > Thank you, queued for 19.11.12 (later this year) > This problem occurs in the following scenarios: > 1) reset is encountered when the adapter is running. > 2) set a new default MAC address. > > After the above two steps, the old default MAC address should be not > take effect. But the current behavior is contrary to that. This is due > to the change of the "default_addr_setted" in hw->mac from 'true' to > 'false' after the reset. As a result, the old MAC address is not removed > when the new default MAC address is set. This variable controls whether > to delete the old default MAC address when setting the default MAC > address. It is only used when the mac_addr_set API is called for the > first time. In fact, when a unicast MAC address is deleted, if the > address isn't in the MAC address table, the driver doesn't return > failure. So this patch remove the redundant and troublesome variables to > resolve this problem. > > Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations") > > Signed-off-by: Huisong Li > Signed-off-by: Min Hu (Connor) > --- > drivers/net/hns3/hns3_ethdev.c | 58 ++++++++++------------------------ > drivers/net/hns3/hns3_ethdev.h | 1 - > 2 files changed, 16 insertions(+), 43 deletions(-) > > diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c > index 157dd34d4f..a2676f84b0 100644 > --- a/drivers/net/hns3/hns3_ethdev.c > +++ b/drivers/net/hns3/hns3_ethdev.c > @@ -1545,7 +1545,7 @@ hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) > > static int > hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, > - uint32_t idx, __attribute__ ((unused)) uint32_t pool) > + __rte_unused uint32_t idx, __rte_unused uint32_t pool) > { > struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); > char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; > @@ -1576,8 +1576,6 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, > return ret; > } > > - if (idx == 0) > - hw->mac.default_addr_setted = true; > rte_spinlock_unlock(&hw->lock); > > return ret; > @@ -1642,35 +1640,18 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, > struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); > struct rte_ether_addr *oaddr; > char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; > - bool default_addr_setted; > - bool rm_succes = false; > int ret, ret_val; > > - /* check if mac addr is valid */ > - if (!rte_is_valid_assigned_ether_addr(mac_addr)) { > - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, > - mac_addr); > - hns3_err(hw, "Failed to set mac addr, addr(%s) invalid", > - mac_str); > - return -EINVAL; > - } > - > - oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; > - default_addr_setted = hw->mac.default_addr_setted; > - if (default_addr_setted && !!rte_is_same_ether_addr(mac_addr, oaddr)) > - return 0; > - > rte_spinlock_lock(&hw->lock); > - if (default_addr_setted) { > - ret = hns3_remove_uc_addr_common(hw, oaddr); > - if (ret) { > - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, > - oaddr); > - hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", > - mac_str, ret); > - rm_succes = false; > - } else > - rm_succes = true; > + oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; > + ret = hns3_remove_uc_addr_common(hw, oaddr); > + if (ret) { > + rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, > + oaddr); > + hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", > + mac_str, ret); > + rte_spinlock_unlock(&hw->lock); > + return ret; > } > > ret = hns3_add_uc_addr_common(hw, mac_addr); > @@ -1689,7 +1670,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, > > rte_ether_addr_copy(mac_addr, > (struct rte_ether_addr *)hw->mac.mac_addr); > - hw->mac.default_addr_setted = true; > rte_spinlock_unlock(&hw->lock); > > return 0; > @@ -1705,16 +1685,12 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, > } > > err_add_uc_addr: > - if (rm_succes) { > - ret_val = hns3_add_uc_addr_common(hw, oaddr); > - if (ret_val) { > - rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, > - oaddr); > - hns3_warn(hw, > - "Failed to restore old uc mac addr(%s): %d", > - mac_str, ret_val); > - hw->mac.default_addr_setted = false; > - } > + ret_val = hns3_add_uc_addr_common(hw, oaddr); > + if (ret_val) { > + rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, > + oaddr); > + hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", > + mac_str, ret_val); > } > rte_spinlock_unlock(&hw->lock); > > @@ -2880,7 +2856,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) > hw->rss_dis_flag = false; > memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); > hw->mac.phy_addr = cfg.phy_addr; > - hw->mac.default_addr_setted = false; > hw->num_tx_desc = cfg.tqp_desc_num; > hw->num_rx_desc = cfg.tqp_desc_num; > hw->dcb_info.num_pg = 1; > @@ -4699,7 +4674,6 @@ hns3_do_stop(struct hns3_adapter *hns) > reset_queue = true; > } else > reset_queue = false; > - hw->mac.default_addr_setted = false; > return hns3_stop_queues(hns, reset_queue); > } > > diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h > index 6c3ac6f8a9..be0fac4fd2 100644 > --- a/drivers/net/hns3/hns3_ethdev.h > +++ b/drivers/net/hns3/hns3_ethdev.h > @@ -144,7 +144,6 @@ enum hns3_media_type { > > struct hns3_mac { > uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; > - bool default_addr_setted; /* whether default addr(mac_addr) is set */ > uint8_t media_type; > uint8_t phy_addr; > uint8_t link_duplex : 1; /* ETH_LINK_[HALF/FULL]_DUPLEX */ > -- > 2.33.0 > -- Christian Ehrhardt Staff Engineer, Ubuntu Server Canonical Ltd