Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2901841rwb; Mon, 7 Aug 2023 05:30:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYZ0o9FPQCB7uMaIxMH840p15k5qS/8Mdzym2hkSIFxgY+z6xvZR+ZC/0BExVYLYcGRnnH X-Received: by 2002:a17:906:3f12:b0:99c:b65b:54e2 with SMTP id c18-20020a1709063f1200b0099cb65b54e2mr6968031ejj.55.1691411406535; Mon, 07 Aug 2023 05:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691411406; cv=none; d=google.com; s=arc-20160816; b=fA9GYqS50HFJq7E9xpqJRezIHflv7Kh96GxPF/nfn60p7mq7ST41oykOzn9qrn4s6S n5yj1asMPtYJM9k0BpD3qegbj/MtCQj/eFZhwt1S5wRJFjjdHRG0I4LiKeH5cu7foSaN c3l4kXcD6wH6yOHqfbCZQvOfKr7/UNmD2L66AiOV0gnDArZqK+1YLwcbII2KlY7iTZOy SdalRQMFpENQI8PFOoXvNJyAVw3zzPL+HsEMJ84WZqzW+YkNZmREz6v3HZpuS6rjqGMK /mXOBWoYaBTbIZGqV68LmMVV9cR2Cz4P2HLfwkqAAyBEtOjlNu7Pvmw1/TOz5JMEv24e vDOQ== 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=bYqvWYz/EZn5EFmsrKpvJ50B3lRhZT3dvF5JnXeI2KE=; fh=5sQmHR+cd4KCALmk2NFamhtulCAFoYw71Vmcb9fEMq0=; b=lYeyd4cJ1sFkntHOR6684eX3yuS8GBciaiRDwK0ge4QvnpW9C2teWIAflhAl0OE+zG wglHtteA0QKP92yNFjinDqfGPb/RttzUlxctW6A1L/fkIVHj3LIMfrSvWwHIEVqawhRA 3oO8RoZk3QGP0ab4nG408uY6OvxIyK5Ox2mJyw4u1iQDFYYAsyaIcCJ+IvX5WU0MYgxP aC1egW8VjGk/b8rX7ZKOzrW25ajGoP2z1ly3+y1SPPtJkLaAujjO0ilMXAlTmWB0x91d f5jIktiITnhASTKlBMNfhTKmWV2M+QCtdA+u6iRbgI8JgKkz83feToeQijBMedHzqc6C 3Y4w== 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 bv5-20020a170906b1c500b0099b4222f51fsi4698994ejb.266.2023.08.07.05.29.41; Mon, 07 Aug 2023 05:30:06 -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 S231404AbjHGLnt (ORCPT + 99 others); Mon, 7 Aug 2023 07:43:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233097AbjHGLmx (ORCPT ); Mon, 7 Aug 2023 07:42:53 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F6BE3A92; Mon, 7 Aug 2023 04:40:34 -0700 (PDT) Received: from kwepemm600007.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RKDph447zzfbnL; 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:29 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , Subject: [PATCH V2 net 3/4] net: hns3: add wait until mac link down Date: Mon, 7 Aug 2023 19:34:51 +0800 Message-ID: <20230807113452.474224-4-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 In some configure flow of hns3 driver, for example, change mtu, it will disable MAC through firmware before configuration. But firmware disables MAC asynchronously. The rx traffic may be not stopped in this case. So fixes it by waiting until mac link is down. Fixes: a9775bb64aa7 ("net: hns3: fix set and get link ksettings issue") Signed-off-by: Jie Wang Signed-off-by: Jijie Shao --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index b440e42e1d9c..a940e35aef29 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -7560,6 +7560,8 @@ static void hclge_enable_fd(struct hnae3_handle *handle, bool enable) static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable) { +#define HCLGE_LINK_STATUS_WAIT_CNT 3 + struct hclge_desc desc; struct hclge_config_mac_mode_cmd *req = (struct hclge_config_mac_mode_cmd *)desc.data; @@ -7584,9 +7586,15 @@ static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable) req->txrx_pad_fcs_loop_en = cpu_to_le32(loop_en); ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) + if (ret) { dev_err(&hdev->pdev->dev, "mac enable fail, ret =%d.\n", ret); + return; + } + + if (!enable) + hclge_mac_link_status_wait(hdev, HCLGE_LINK_STATUS_DOWN, + HCLGE_LINK_STATUS_WAIT_CNT); } static int hclge_config_switch_param(struct hclge_dev *hdev, int vfid, -- 2.30.0