Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp531280lqh; Tue, 7 May 2024 06:50:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8zQ1ZH/GJOJwV9e/oVLjf0Ni4q1VE+Xb2RJXTz3FyvlKATf+25WgKzNB4/pwhVyiaQFZYu3NrGN+Sqzu/0705gOXXYqdIFAl7ETlMJQ== X-Google-Smtp-Source: AGHT+IHA0EEjMO9u9OxXF0lKJf1UV50ys6wQFbbi8WIBHp8L1cfIqJJ74Rc/vVuEjTCNLng1/hTs X-Received: by 2002:ac2:5466:0:b0:51b:223f:ac41 with SMTP id e6-20020ac25466000000b0051b223fac41mr11521963lfn.42.1715089820619; Tue, 07 May 2024 06:50:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715089820; cv=pass; d=google.com; s=arc-20160816; b=yAjPsVJj7cFPEWSYIgJt8gToNRbK8UTM5JhLQRF2y/GiW0Y6jS/6BpyuaMbEc0W72z hkuMNtbkMFvSj4Ufvb6s2EeaAU8mUmR8DBIdTNS4oG3jQJpaWfeivH0BetLqFXu9Qm68 rWqNzozA3U5wlCAJV79owRtC3TK58qA9w1r651YQEvMgKXIV695RxbcpDyQiARR7x4Sl zlyTIDxK1Kv6+3gUy8ndLzd7f4QZk/8Dt1aec7GP3j7nDMLCrdv4+It519A4BAGmiNGQ lBdH54ZzGolkzdQtbQLoMyadDE0FUGgjwh3lhk/hIdUaTvU7TK2pjKJFkEX5/5h7GIHz 0RxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=15qfMZ3TaTiWxHuk3OYN7NYoxtBdyfAThLKU+IajKyc=; fh=mENY5E4eClWonIkCOtlFWWTx/Dt7WFkfxCrepuo/4GQ=; b=OTPyqaMN/ntllCnNbTKTE2TyLWPfAQQiGlA7q3GD9LD4Flsk4KrpBDvflP67IhrJVb 67wRrWbC8lzcwLaGXP0Koi1TLXwLh5Xi5zRrQ+H1+dYGQ/MB+mlHMK+lw3H0nRr6Spz1 OB2NcmlIsgKTuhgv0NCWxQ4Zn2eOmqhvx6ZiJJnxcqbro4s22kmEs24YiXgg/KGk9yem xBc2LSqyTM3Wc6CD/COzbRHjN0Q3TQMsWftB5XpZ8YAJ/UVWCHH4OfTgnGJnrSMKnNbf fNQ4+O51n8wbfam9ZpbOhq2YY5LAQKvqmuSpmizoSx/y8gRNN6KAQqlIBa+GRiVkYFWP 58Cg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-171461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f26-20020a056402151a00b00572ac74aeabsi5806654edw.253.2024.05.07.06.50.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-171461-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 270A01F226D8 for ; Tue, 7 May 2024 13:50:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C585915E810; Tue, 7 May 2024 13:49:55 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C166413CF9C; Tue, 7 May 2024 13:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715089795; cv=none; b=Tyh+Oi9bW97O4WdtzzeOODqfU8MGWeIlz/E0xHwtV4BZZBCoXpEj4lOt+f++Xm4TifTXyQMNpLY9LD9PJcR8ray2hLC7eWN/3p9OTg9YvVu472lVsaIfQAYmdIiYrqQ+iJqSSRT5lw4/G0bPi9P5V2iajL+AtQbe/LDdjOlk3s4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715089795; c=relaxed/simple; bh=Q38qHfEOo4FrF79laZBUX0gryLfICrknwgxFjslCNew=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vms8C3XC9dXE6RkWJiXze7EzFXNOnPnPf7MiAxqYPK40Aos+8lomtKKALVcC+xJEsrjCTj9ZqGWa/NiBFITkwGCuQ7xaJ1/IWlPhd0Wx+7QlmQRH9WNIlPslroqmuvYKyBDfqYaiGqgz8oCvzLE38L6ASWSlhamKvtIM/be0tKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VYfh10CjmztT2C; Tue, 7 May 2024 21:46:25 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 2C926180065; Tue, 7 May 2024 21:49:50 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 7 May 2024 21:49:49 +0800 From: Jijie Shao To: , , , , , , , CC: , , , , , , Subject: [PATCH V3 net 1/7] net: hns3: using user configure after hardware reset Date: Tue, 7 May 2024 21:42:18 +0800 Message-ID: <20240507134224.2646246-2-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240507134224.2646246-1-shaojijie@huawei.com> References: <20240507134224.2646246-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600007.china.huawei.com (7.193.23.208) From: Peiyang Wang When a reset occurring, it's supposed to recover user's configuration. Currently, the port info(speed, duplex and autoneg) is stored in hclge_mac and will be scheduled updated. Consider the case that reset was happened consecutively. During the first reset, the port info is configured with a temporary value cause the PHY is reset and looking for best link config. Second reset start and use pervious configuration which is not the user's. The specific process is as follows: +------+ +----+ +----+ | USER | | PF | | HW | +---+--+ +-+--+ +-+--+ | ethtool --reset | | +------------------->| reset command | | ethtool --reset +-------------------->| +------------------->| +---+ | +---+ | | | | |reset currently | | HW RESET | | |and wait to do | | | |<--+ | | | | send pervious cfg |<--+ | | (1000M FULL AN_ON) | | +-------------------->| | | read cfg(time task) | | | (10M HALF AN_OFF) +---+ | |<--------------------+ | cfg take effect | | reset command |<--+ | +-------------------->| | | +---+ | | send pervious cfg | | HW RESET | | (10M HALF AN_OFF) |<--+ | +-------------------->| | | read cfg(time task) | | | (10M HALF AN_OFF) +---+ | |<--------------------+ | cfg take effect | | | | | | read cfg(time task) |<--+ | | (10M HALF AN_OFF) | | |<--------------------+ | | | v v v To avoid aboved situation, this patch introduced req_speed, req_duplex, req_autoneg to store user's configuration and it only be used after hardware reset and to recover user's configuration Fixes: f5f2b3e4dcc0 ("net: hns3: add support for imp-controlled PHYs") Signed-off-by: Peiyang Wang Signed-off-by: Jijie Shao --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 15 +++++++++------ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index ff6a2ed23ddb..8043f1795dc7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1537,6 +1537,9 @@ static int hclge_configure(struct hclge_dev *hdev) cfg.default_speed, ret); return ret; } + hdev->hw.mac.req_speed = hdev->hw.mac.speed; + hdev->hw.mac.req_autoneg = AUTONEG_ENABLE; + hdev->hw.mac.req_duplex = DUPLEX_FULL; hclge_parse_link_mode(hdev, cfg.speed_ability); @@ -3342,9 +3345,9 @@ hclge_set_phy_link_ksettings(struct hnae3_handle *handle, return ret; } - hdev->hw.mac.autoneg = cmd->base.autoneg; - hdev->hw.mac.speed = cmd->base.speed; - hdev->hw.mac.duplex = cmd->base.duplex; + hdev->hw.mac.req_autoneg = cmd->base.autoneg; + hdev->hw.mac.req_speed = cmd->base.speed; + hdev->hw.mac.req_duplex = cmd->base.duplex; linkmode_copy(hdev->hw.mac.advertising, cmd->link_modes.advertising); return 0; @@ -3377,9 +3380,9 @@ static int hclge_tp_port_init(struct hclge_dev *hdev) if (!hnae3_dev_phy_imp_supported(hdev)) return 0; - cmd.base.autoneg = hdev->hw.mac.autoneg; - cmd.base.speed = hdev->hw.mac.speed; - cmd.base.duplex = hdev->hw.mac.duplex; + cmd.base.autoneg = hdev->hw.mac.req_autoneg; + cmd.base.speed = hdev->hw.mac.req_speed; + cmd.base.duplex = hdev->hw.mac.req_duplex; linkmode_copy(cmd.link_modes.advertising, hdev->hw.mac.advertising); return hclge_set_phy_link_ksettings(&hdev->vport->nic, &cmd); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index e821dd2f1528..e3c69be8256f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -279,11 +279,14 @@ struct hclge_mac { u8 media_type; /* port media type, e.g. fibre/copper/backplane */ u8 mac_addr[ETH_ALEN]; u8 autoneg; + u8 req_autoneg; u8 duplex; + u8 req_duplex; u8 support_autoneg; u8 speed_type; /* 0: sfp speed, 1: active speed */ u8 lane_num; u32 speed; + u32 req_speed; u32 max_speed; u32 speed_ability; /* speed ability supported by current media */ u32 module_type; /* sub media type, e.g. kr/cr/sr/lr */ -- 2.30.0