Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp171652lqf; Fri, 26 Apr 2024 03:17:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW3GsK7nZPWgcjpZQYOfay5UJu4vAz75XejQNRevjLbdOBQaPS9AOhpxjz5LKUhRkhW/r7S3ybkPJBLJF8ypFuGjcLqbodqyrvWHydWTA== X-Google-Smtp-Source: AGHT+IEr12gH19f4Ztm9dnEZvz7i0n71jg22dR8LpBQXpEexUtjNCTT03C70yKmeaWqT31fb8nS+ X-Received: by 2002:aca:2206:0:b0:3c7:1054:b1b5 with SMTP id b6-20020aca2206000000b003c71054b1b5mr2305026oic.55.1714126668261; Fri, 26 Apr 2024 03:17:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714126668; cv=pass; d=google.com; s=arc-20160816; b=zGNjaCkXnlGx9Ip/RbxmnL1XG116dnaPwRWSOUn9Rh3Q2DsZHdLv5obKOgcppfmcxH UdC9d6mBjC0AZvqoz3DRK1K4KO6/z0vFk60fi5PskGdys5UqLA46CQi9gx6KdNY9w0FE kce/e6vZynKWbTwvxN6jq3sIwMCKL5NzsFtJ6MAL2V5tuXZiR3dMNOVWSicDvJ3vQYeb L8IfK8K5NLn9YzGyhO7mX7MaCxjTN5YeCEva06m1y+isV4ka8RrpxusQM3G/86nXEnGH 7FILls6O/aYghDUzfmk1mNc+BdJCMGfoB8slJlGgDz9DyASA/MHWw22uXqduYSGTKC1N T2cw== 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=0BYjhc+2Bu24AABc+fSBMktrfPQhgB7iZop7869aW/M=; fh=bH8wtoutavYA7YVow2Ey5eNMVKGylgpvzC5W/6gq12U=; b=RLhGbw0z1oONP7hTmFNuF3R+rMXbooJ2PVBq+aLIqljZG2Z4vsZnSir9IynP3DOwAt 9uxKxIAuvgf4OAgYmaL/ijd4DnRslMokYltGLPHC+2CUvtHntyYv9qRNIkC2EowS8GQB qmmUoRsd12i6+94c4UADHeIMeh9J0tBy8R4ITF4AzHU7gjADE76fSVHLto6pjh2Mv6os cVN78yB0gdDfSuJ/HbXvUjnG/fWyA03r1KhCayajRlBqpCqFKL9rS4yT9tr2W80qmQfq dvHIn9TCsG7B/vyWcJCG/k6TcgrngpDWkbnUUnTjpaYZFyyZDNEqNiDaqv8TgjfAKQZN lC/g==; 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-159851-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159851-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y5-20020a05620a09c500b0078f158474e1si18184425qky.581.2024.04.26.03.17.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 03:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159851-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-159851-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159851-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EB8001C20B74 for ; Fri, 26 Apr 2024 10:17:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45DA7146D4F; Fri, 26 Apr 2024 10:15:37 +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 5E032145349; Fri, 26 Apr 2024 10:15:34 +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=1714126536; cv=none; b=eAVCuXtX46D0BnGWXt835P/bohtm0IijB1dOqo1yY+Olr/zjGTtFsikY3wlckXcuv+BgqxFH9OYAT2BfltBJIj56+bOiPFTo5idBJ6vQVzZR2+K4gRPLLmjIjdXf674X+UAhXG+24O5agyjFyjxegDT8sP+MiU74AIuR8BR3aYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714126536; c=relaxed/simple; bh=yXo5+Apf42eIyYCkZPbdtCzXh/8stbdaBFZASXo2YQ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UFHr05r+enNDJdWssANaHcjVd2exNbECTHWFH8N3yZXVV6wEL8pUt298Eb8PbdHqkBHIBL2XppR56sB+bGnJQpDjsv9q8k3YwdkmEAWMautH6eCbbsZwAEqtWO3zNNMKEf5QLgsrQE6nA3iG1+QP5c3wK1/pOtDVdFNJcfkBM5Q= 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.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VQpS62bQHzvPsQ; Fri, 26 Apr 2024 18:12:22 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id 9ECBA1800C4; Fri, 26 Apr 2024 18:15:26 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) 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; Fri, 26 Apr 2024 18:15:21 +0800 From: Jijie Shao To: , , , , , , CC: , , , , , , Subject: [PATCH V2 net 5/7] net: hns3: using user configure after hardware reset Date: Fri, 26 Apr 2024 18:00:43 +0800 Message-ID: <20240426100045.1631295-6-shaojijie@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240426100045.1631295-1-shaojijie@huawei.com> References: <20240426100045.1631295-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: dggems701-chm.china.huawei.com (10.3.19.178) 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 6eda73f1e6ad..5dc8593c97be 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); @@ -3344,9 +3347,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; @@ -3364,9 +3367,9 @@ static int hclge_update_tp_port_info(struct hclge_dev *hdev) if (ret) return ret; - hdev->hw.mac.autoneg = cmd.base.autoneg; - hdev->hw.mac.speed = cmd.base.speed; - hdev->hw.mac.duplex = cmd.base.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(hdev->hw.mac.advertising, cmd.link_modes.advertising); return 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 37527b847f2f..3a9186457ad8 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