Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp156648lqa; Fri, 26 Apr 2024 18:55:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgtP59HDNf5j6x1KAzJuAXGV8A47nj9mpFCfkJ7L5PgtZj7IUQhsxlMweBsKXaVo5aZbfC0jsxqCcNe1J07/g/G/FqpF4AsrvOcQ9ZeQ== X-Google-Smtp-Source: AGHT+IHmCaWaYN2mHzuhMpqJatYLQsjgBFSaFRT7suErwQ6S1U+pCwnxYIhZIKLWzoSvvUi3NjjC X-Received: by 2002:a17:906:8312:b0:a56:2556:8e3 with SMTP id j18-20020a170906831200b00a56255608e3mr2951525ejx.73.1714182926976; Fri, 26 Apr 2024 18:55:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714182926; cv=pass; d=google.com; s=arc-20160816; b=alR3cofVfbXGkdoUbaM7YYkeEprajUeqPClCexD09/LBTOn6tfNYFnSH5O6GuMtmUH 1ThG9HvmRQvUsbfc+usIq80wmRXlxgToK37rVdlBfSs81vxdRV0loXJesD0r8yetO68B Fjehc/PCasswN5Uqo6UkTLIkx6RAdbrhX1f6MuWG7+DEjBOOM7u90I3prlQy4sHCrU4y fCvJdWx6M7GWLnKSJkDyH86ikQCJP+tq2bmyl+zeJ8DpGoNBed0IJeaRt6aez6y1nrpW EjSdwkDrOhCX8rxcSfXPZuoD8KODS71riQHZhxfzNPlgoOtX4VZkCl6mSO4y0QdkniCH boog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=xC+Wq2NeguQc2WvQitBOxzmrCHOw8Xh3tDYQPVO/dHc=; fh=FDbu6HHvWmLN/xuS0ajO9hm8shWpYMUgRsYnBHewYXY=; b=j5j8AmKvn4Mgo61g66HWAX0oz9sw4c1T+/7LZFAToJ1+Lc//UK8s+BDmXkNKij5Brc 9rxbkRE4T9uA/p6FBhLw1vWVOfJpcDpjCAtdVtEqJIRQIIVH2RtT9xDPbPSyEVdCUX5q oT2EvNJVPs+9OEbzVKVfyaHcdg2V/2YzavfX14X4T0x4Q6Cd65wT7ozgNwSxZomvOfgS OvpktBzJlhmDS3Jsamn3bNoY/0WC8/M457NM35lihcjD/3Vt0RTjkXWOB+iMHJjpPMhs E4u7xA4TF7o1LT/AJ3zHnkfmsANUvFt4Imm+XXjzu+dtZcNzf4jUQdUgg7JhReHaGnDO MFbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="W/693MwE"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-160862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o5-20020a170906288500b00a522ef880d4si11179733ejd.559.2024.04.26.18.55.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 18:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160862-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; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="W/693MwE"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-160862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.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 884331F22A0C for ; Sat, 27 Apr 2024 01:55:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5EC73FB81; Sat, 27 Apr 2024 01:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="W/693MwE" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 7A7FE3FBB0; Sat, 27 Apr 2024 01:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714182870; cv=none; b=f+qRbKc7i5lWVeJxykMfScxWlwbOWim5VNxQ+ki++X6P/lV5GxNxTB3SOgbHe98yQxka+U+kFo47syGvtVUE7bvSaYAD1NWLkNhwYhJTdxIwodPSI4RnCVHK8MuxziM6Aa+vPrPNjakexzDqMX4NVH4JVB+jvzBQTx1zG1K3v/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714182870; c=relaxed/simple; bh=C8I6H8q1CsCEilGm6xZcUAtD7gbeIhxcNcTyYkuj3Vo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=h8E3kkKivePtFgSa8go8oH7ofN38IWkBkf40vOFpXB+tkpG4TI8Ek4dPUWUZVodxHDuwPcZVE6F0aZyY8cD4b3f283WgnC4/aIEhr33KtVM1TXON5P2RvGUlbsY+/FQ3SK+vykrb0W0ObeGx2fYTlKw6xIKLqT1MSyAcTxKumFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=W/693MwE; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43R1dvRG020303; Sat, 27 Apr 2024 01:54:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:date:subject:mime-version:content-type :content-transfer-encoding:message-id:references:in-reply-to:to :cc; s=qcppdkim1; bh=xC+Wq2NeguQc2WvQitBOxzmrCHOw8Xh3tDYQPVO/dHc =; b=W/693MwE6Yy9xwiWfNukarOdVYbWAfKnh0YQoQw3j1oRGsrgmZHYbdXQ4xv r7K3VBoUKaumwEwDccVdMVSv4WLK57W7Fq6H2MJ09cjvm6MytH+R2n+AGVmmAQ3+ UgapaqW0r64LG6GC11qh62pJjKcNVeJuIeBqITqLf5RG/vkUu4977ftyAawyEDi5 RbBybxR9sVWhGtVKZPivtfCAQkG520sowTBAIpw49/yLLgHj81cGT+Ln/Rqek4pr ilAMKvHGt3lFOixQ9fVo9Wwi3x9/aPB8ENdMDNBjOuaY9Zeg7LbZNE6HSF14lc+Z MvTnYPX39B4l29pi2gvegGpr8ag== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xr359389p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 27 Apr 2024 01:54:18 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43R1sHqX011459 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 27 Apr 2024 01:54:17 GMT Received: from hu-krichai-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Fri, 26 Apr 2024 18:54:11 -0700 From: Krishna chaitanya chundru Date: Sat, 27 Apr 2024 07:22:38 +0530 Subject: [PATCH v12 5/6] PCI: Bring the PCIe speed to MBps logic to new pcie_link_speed_to_mbps() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20240427-opp_support-v12-5-f6beb0a1f2fc@quicinc.com> References: <20240427-opp_support-v12-0-f6beb0a1f2fc@quicinc.com> In-Reply-To: <20240427-opp_support-v12-0-f6beb0a1f2fc@quicinc.com> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , , , CC: , , , , , , , , , , X-Mailer: b4 0.13-dev-83828 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714182818; l=2081; i=quic_krichai@quicinc.com; s=20230907; h=from:subject:message-id; bh=C8I6H8q1CsCEilGm6xZcUAtD7gbeIhxcNcTyYkuj3Vo=; b=Pd8Qd0S1hHUNP1ypiDdPppi9bRRwTFvvcUE4KN+bn4f16j1ZadytP8yyhKOaeD6PRK5oAzQgl +z+1m8GBqaTAqAu7cUYG28f2JSaSlZhvjCOlhuGJDVd23VQckz1AwtI X-Developer-Key: i=quic_krichai@quicinc.com; a=ed25519; pk=10CL2pdAKFyzyOHbfSWHCD0X0my7CXxj8gJScmn1FAg= X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: OKii83pv3LAwAoPEtK8hz0mK_dkkPCf8 X-Proofpoint-ORIG-GUID: OKii83pv3LAwAoPEtK8hz0mK_dkkPCf8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-26_22,2024-04-26_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 clxscore=1015 mlxscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404270012 Bring the switch case in pcie_link_speed_mbps() to new function to the header file so that it can be used in other places like in controller driver. Signed-off-by: Krishna chaitanya chundru Reviewed-by: Manivannan Sadhasivam Acked-by: Bjorn Helgaas --- drivers/pci/pci.c | 19 +------------------ drivers/pci/pci.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e5f243dd4288..40487b86a75e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5922,24 +5922,7 @@ int pcie_link_speed_mbps(struct pci_dev *pdev) if (err) return err; - switch (to_pcie_link_speed(lnksta)) { - case PCIE_SPEED_2_5GT: - return 2500; - case PCIE_SPEED_5_0GT: - return 5000; - case PCIE_SPEED_8_0GT: - return 8000; - case PCIE_SPEED_16_0GT: - return 16000; - case PCIE_SPEED_32_0GT: - return 32000; - case PCIE_SPEED_64_0GT: - return 64000; - default: - break; - } - - return -EINVAL; + return pcie_link_speed_to_mbps(to_pcie_link_speed(lnksta)); } EXPORT_SYMBOL(pcie_link_speed_mbps); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 17fed1846847..4de10087523e 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -290,6 +290,28 @@ void pci_bus_put(struct pci_bus *bus); (speed) == PCIE_SPEED_2_5GT ? 2500*8/10 : \ 0) +static inline int pcie_link_speed_to_mbps(enum pci_bus_speed speed) +{ + switch (speed) { + case PCIE_SPEED_2_5GT: + return 2500; + case PCIE_SPEED_5_0GT: + return 5000; + case PCIE_SPEED_8_0GT: + return 8000; + case PCIE_SPEED_16_0GT: + return 16000; + case PCIE_SPEED_32_0GT: + return 32000; + case PCIE_SPEED_64_0GT: + return 64000; + default: + break; + } + + return -EINVAL; +} + const char *pci_speed_string(enum pci_bus_speed speed); enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev); enum pcie_link_width pcie_get_width_cap(struct pci_dev *dev); -- 2.42.0