Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2902105rwb; Mon, 7 Aug 2023 05:30:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHx/SjVgxL92W6dpXFfxUOtwBYfsTYyxcYq9aGlpz06+INLJjbTcjmxoCdLjFVKeIGCaL5F X-Received: by 2002:ac2:465d:0:b0:4fd:8976:5fc9 with SMTP id s29-20020ac2465d000000b004fd89765fc9mr5598424lfo.23.1691411419736; Mon, 07 Aug 2023 05:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691411419; cv=none; d=google.com; s=arc-20160816; b=QZYXICx6juzHE4UIfdrL4ctjk2dU3ypNpSL0RIbpnHJYo1MZAf1Gvd654dSR7ER3Q4 jcZKWN7181ciV3N0l51qCSj+M4e+hbA4ABOEiC3qz6ehk2sMYB4RdLJA5Qf/IbXWIL/T uZpy1QYfH9W4UHBFuUiatqNliZmWAAHVco4uqMfzrsq3XdxIuns/+BdL1S0e0Q6RSGk5 Y3UZRgVFVnHWTSImK5bXDqRI7pI7r+U3YKC6X6CvACBJImsFyWre7kPuaK7djW8yhLOu ijGmSmeuScka2g+ziGr0TacbLuJa0h8rBsHglC7XUu0xURK2Fjk9+cAa/QqqXiIwrFce bGfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xFk8/SDvXqTLd2pYG8oURu2OwcTopmnD0VD8kIe6CxU=; fh=5sQmHR+cd4KCALmk2NFamhtulCAFoYw71Vmcb9fEMq0=; b=rgsSFUH5dJyEqe8Z2UDj91Qa+6iDQaL3pvsAZEsnhI/UwlYq53l+JVt+Yg/lDxND3J k/UfqWmfAAK7J5AbAUBrNoaDTw9lZCEWJDEGxiLcLUGZL16sEG1S8PVWnvjbXcKC9zQL xOzrfydbHDiWx0HFuNKsFqTABJyrI8MjELko0zT0dF/KBgDRon23pVJO4qhP63wDpOWD sre8VVA1FgrVTHDNBT3UTbm7vjASC8IZHNIQ2HYHNbIWfrtRW5ncoHhYh1e3Y4N4Vqd9 0klXjiajUpEKc1edpsWLm51VuTh11X67PXv2KJEPobYYrh/04/s8eVPEDpgJzdM/8w/f pBZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f23-20020a50ee97000000b005232e66b6d4si2590378edr.160.2023.08.07.05.29.48; Mon, 07 Aug 2023 05:30:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232246AbjHGLnx (ORCPT + 99 others); Mon, 7 Aug 2023 07:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233445AbjHGLnb (ORCPT ); Mon, 7 Aug 2023 07:43:31 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B2744213E; Mon, 7 Aug 2023 04:41:31 -0700 (PDT) Received: from kwepemm600007.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RKDph6HGmz1KCLT; Mon, 7 Aug 2023 19:38:20 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 7 Aug 2023 19:39:28 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , Subject: [PATCH V2 net 2/4] net: hns3: refactor hclge_mac_link_status_wait for interface reuse Date: Mon, 7 Aug 2023 19:34:50 +0800 Message-ID: <20230807113452.474224-3-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230807113452.474224-1-shaojijie@huawei.com> References: <20230807113452.474224-1-shaojijie@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jie Wang Some nic configurations could only be performed after link is down. So this patch refactor this API for reuse. Signed-off-by: Jie Wang Signed-off-by: Jijie Shao --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 5594b8dd1e1d..b440e42e1d9c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -72,6 +72,8 @@ static void hclge_restore_hw_table(struct hclge_dev *hdev); static void hclge_sync_promisc_mode(struct hclge_dev *hdev); static void hclge_sync_fd_table(struct hclge_dev *hdev); static void hclge_update_fec_stats(struct hclge_dev *hdev); +static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret, + int wait_cnt); static struct hnae3_ae_algo ae_algo; @@ -7647,10 +7649,9 @@ static void hclge_phy_link_status_wait(struct hclge_dev *hdev, } while (++i < HCLGE_PHY_LINK_STATUS_NUM); } -static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret) +static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret, + int wait_cnt) { -#define HCLGE_MAC_LINK_STATUS_NUM 100 - int link_status; int i = 0; int ret; @@ -7663,13 +7664,15 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret) return 0; msleep(HCLGE_LINK_STATUS_MS); - } while (++i < HCLGE_MAC_LINK_STATUS_NUM); + } while (++i < wait_cnt); return -EBUSY; } static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en, bool is_phy) { +#define HCLGE_MAC_LINK_STATUS_NUM 100 + int link_ret; link_ret = en ? HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN; @@ -7677,7 +7680,8 @@ static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en, if (is_phy) hclge_phy_link_status_wait(hdev, link_ret); - return hclge_mac_link_status_wait(hdev, link_ret); + return hclge_mac_link_status_wait(hdev, link_ret, + HCLGE_MAC_LINK_STATUS_NUM); } static int hclge_set_app_loopback(struct hclge_dev *hdev, bool en) -- 2.30.0