Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2933031iog; Mon, 20 Jun 2022 07:46:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sL3DHQuLF5SXidbsZdLzLVYnEbXSb/dX7oav/PZ4N8WcC3xbJggT8Yk+vSYYUwP8noV4+g X-Received: by 2002:a17:90b:1c11:b0:1e7:8bd2:697d with SMTP id oc17-20020a17090b1c1100b001e78bd2697dmr38151966pjb.90.1655736383397; Mon, 20 Jun 2022 07:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736383; cv=none; d=google.com; s=arc-20160816; b=rXHFpU48HME5XJyBgs1izwYfhERw6Szmy+R0SlOYO3lmMa7+jQyaEeYeT2zHAcWYOa Qn25EYEQZ33Nu+2ua5gt24pMcJKNps9esjw5WcQSTcK04x9bp81Cwq2uGuB3hekAzosr eYrFGcdNpfN+rcWOSGFl6QGXNxibLlE+Y1XBv5Av0tDxE5Qzfjsn/iQVKy3cibO7VwaN GvP+rIAWSeoRwMZKKZRDrlSEU+eU9bbWZmPalEZkhkN/kjO7doYtLk3YUYwEoVmJU9dB Kb7GJFukuQ9dnBmh8vh9xRL2ErN43FhyLDdZ4Bmk3avzX9VH4h3miqsE64uBGU5mCFF5 v83Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VOgjxm9TzIfWBHFiYli9K03Mpl2Xndc4HxoTR7q/5/Q=; b=f0a7/ps4pRd1CveTsJI2N+7a4atZAGeXdj+Q7hKXac9aUnoggkxA3HAxbfJYrBVG1q IMgxdiiPlylunn8mNfezX2h5C9vMuBPf7j7kf7HzeOCZk9Oa+92XRXbOPfghQRUMc7Ho NgJI5QUkCqmbOoyxykC7wfXbLlwzFRBL2V0nmN4WFZ8AFkEiVybqR9ti/DiVTM4UR9O/ epLz7NK1aDVHuxgsCI0QlD76uTpWPHBIY5clm8+FypSwRa4mYTr5BqNUyI3krI85UfJ/ J2SbYLxPpkO2puKehUEfSilsgJfM72Ur89cG0VBB+lyTpzmNCgmY1HzIpn3efTYJ+AAs mvAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yp9kk/nh"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a056a000cc700b005252ffbda2esi1151928pfv.36.2022.06.20.07.46.11; Mon, 20 Jun 2022 07:46:23 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yp9kk/nh"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243637AbiFTNCe (ORCPT + 99 others); Mon, 20 Jun 2022 09:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244915AbiFTNAD (ORCPT ); Mon, 20 Jun 2022 09:00:03 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCCEB1A3A9; Mon, 20 Jun 2022 05:56:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 81487CE138A; Mon, 20 Jun 2022 12:56:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C32AC341C6; Mon, 20 Jun 2022 12:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655729810; bh=Rl2yJlwfl/wqcLveA/n079p33M4Fb+zHO8zRFtpI5zA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yp9kk/nhS3xWs3+5eGQHqv7obEehVvUZxs2z3Lq7pGZzS+0hFtmc/uT6vMcIlq8CW Oc/xP3Ao6e3hbtESD8P4O8q7S7csiqk+22qb14LgAPvcfJ1f5uLBOsk55Ena5iX+nF uuWJD4x1LO8TYmA8Su66IBT6HK740NdIeIT4+tYA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guangbin Huang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 073/141] net: hns3: fix tm port shapping of fibre port is incorrect after driver initialization Date: Mon, 20 Jun 2022 14:50:11 +0200 Message-Id: <20220620124731.697043679@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124729.509745706@linuxfoundation.org> References: <20220620124729.509745706@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: Guangbin Huang [ Upstream commit 12a3670887725df364cc3e030cf3bede6f13b364 ] Currently in driver initialization process, driver will set shapping parameters of tm port to default speed read from firmware. However, the speed of SFP module may not be default speed, so shapping parameters of tm port may be incorrect. To fix this problem, driver sets new shapping parameters for tm port after getting exact speed of SFP module in this case. Fixes: 88d10bd6f730 ("net: hns3: add support for multiple media type") Signed-off-by: Guangbin Huang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 11 ++++++++--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index c8c99ab60ec1..c0b4ff73128f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3276,7 +3276,7 @@ static int hclge_tp_port_init(struct hclge_dev *hdev) static int hclge_update_port_info(struct hclge_dev *hdev) { struct hclge_mac *mac = &hdev->hw.mac; - int speed = HCLGE_MAC_SPEED_UNKNOWN; + int speed; int ret; /* get the port info from SFP cmd if not copper port */ @@ -3287,10 +3287,13 @@ static int hclge_update_port_info(struct hclge_dev *hdev) if (!hdev->support_sfp_query) return 0; - if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) + if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { + speed = mac->speed; ret = hclge_get_sfp_info(hdev, mac); - else + } else { + speed = HCLGE_MAC_SPEED_UNKNOWN; ret = hclge_get_sfp_speed(hdev, &speed); + } if (ret == -EOPNOTSUPP) { hdev->support_sfp_query = false; @@ -3302,6 +3305,8 @@ static int hclge_update_port_info(struct hclge_dev *hdev) if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { if (mac->speed_type == QUERY_ACTIVE_SPEED) { hclge_update_port_capability(hdev, mac); + if (mac->speed != speed) + (void)hclge_tm_port_shaper_cfg(hdev); return 0; } return hclge_cfg_mac_speed_dup(hdev, mac->speed, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index f5296ff60694..2f33b036a47a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -420,7 +420,7 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev, return hclge_cmd_send(&hdev->hw, &desc, 1); } -static int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev) +int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev) { struct hclge_port_shapping_cmd *shap_cfg_cmd; struct hclge_shaper_ir_para ir_para; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h index 619cc30a2dfc..d943943912f7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h @@ -237,6 +237,7 @@ int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr); void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats); void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats); int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate); +int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev); int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num); int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num); int hclge_tm_get_qset_map_pri(struct hclge_dev *hdev, u16 qset_id, u8 *priority, -- 2.35.1