From patchwork Tue Jan 2 14:03:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4462074dyb; Tue, 2 Jan 2024 06:04:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzWKNe1TUX/h8MorFqy0nHfBnmNHkx8XZz+ENbjTtlCXMQ3EBItCSi1ofgYiu6kP8UWpN1 X-Received: by 2002:a2e:9995:0:b0:2cc:e48d:d0f7 with SMTP id w21-20020a2e9995000000b002cce48dd0f7mr3146016lji.97.1704204288480; Tue, 02 Jan 2024 06:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704204288; cv=none; d=google.com; s=arc-20160816; b=O5QBSYPzfpZYEtBQFAzggCU9nSM4RU0Ygps9FFXj3kbQ4hYORoWwdzJkYA+USQcaan 2xDJNnlbUh3nALICtQixREiOrkuOFgomrvWMRxJ2Jr9AdTEqUnTE1m1hQ00fnw/d9umC hOrOC7QfQ/j+fyOQ8SyjFHf0t8lZtIwvhJ7zzPWFx6sD4/eQDvpLuXeZW4OIFULq5Iom crUTh4zjddd0x/IGM0IGaegiMqH+Pn/VcYUdlrMDG/jksNu1QMOZX+TNAP+O8DQBaB30 cWbWOt8B6qlUfPWWy7tlFlenxVbYMVNyOPbvhl0uMeO4JEKxzHDmqY7+aCCP782ozfU4 tKIQ== ARC-Message-Signature: i=1; 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:dkim-signature; bh=8jgtefRyhyrs3KbL6OkxtQpjnArsTGVLXR9LSgz6WQg=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=iyVThpfrFauxeBT91LJSs9llC54Q4ul+6Zu4NWT+Epr7fDjAKcTYRcNTZ5fLgaXRtZ p3aGl9c7XzArkeEZy44iPKkVfg5SOLlvexMTmdSyrPQPuwQfoLn1LnEq1PzaLpYMqeWp mZpSni9NpdtK39p6o/KgE4afJUV1/UKZQdhskDbbpqRb/kPdXtNoR9eUsIwpew46SC2w SrZWevu/yQ8sVLfdBfHnM435+RptsWOwP+VM+qxw9/wYIZ6Zu0XV1cNWbiUldioJHV/w b/o6NuhmpKjaUxISXs+kp/MFypW+G5G3pZLlULI73a57BooX+owHgHsjD5xUSjC33Vwi lVKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZS7uY0GR; spf=pass (google.com: domain of linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i18-20020a50d752000000b00555d5a33cdasi3420821edj.463.2024.01.02.06.04.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14456-ouuuleilei=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=@gmail.com header.s=20230601 header.b=ZS7uY0GR; spf=pass (google.com: domain of linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14456-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 1980F1F22C9E for ; Tue, 2 Jan 2024 14:04:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AD4114F61; Tue, 2 Jan 2024 14:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZS7uY0GR" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D643A10961; Tue, 2 Jan 2024 14:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-40d4a7f0c4dso88502835e9.1; Tue, 02 Jan 2024 06:03:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704204217; x=1704809017; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8jgtefRyhyrs3KbL6OkxtQpjnArsTGVLXR9LSgz6WQg=; b=ZS7uY0GRaybditMsCXYaw3+7xG+3LZHBcUnz9PbpOIuGrnPDf+j77TV80JwLyjFh7f rHLzMie/2DSog+CeQydm+USPHRdm3wgFDx7iurlW+BdDnR6xe5JVLgg40YqS+AnttYG/ WAixcMlL/dj5xZnrpZxawq20Ht/vETs2ZrFWO8kug9FJrcsSkGzwqVnWFhd+lVMyGbpC hBp0LZFyR0ieOzKNvR+VxyQEVROmHHkM4RbucVP6GfixuiIIoieqa9JoC1p2WHKPSdZw VJgZ8zWprlkjCRCYO2x71+sthkLROh0CJ/iVbTlJt1NlmT3n99nBCcnABoncUfPE3d29 UFSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704204217; x=1704809017; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8jgtefRyhyrs3KbL6OkxtQpjnArsTGVLXR9LSgz6WQg=; b=Ewb88ueYTMwCzXWjtnmfYpiVlfWVEa/FFkEVCtGz5IJ1dSFXsA0rnxp8NQEy7S1KSS Yvqzg5RdP8estQMNDg1+5OIrFq8U+5vfE/8evvnDHzCvMzPRDMM8e5Hdkp+ZRCoPUf71 MO673r+fDR9F6xOxjp3aA2cZU//Vj42pgpRRe0xwCQjvg11vdJ1ic2FIHR6xPcaElYuy MUB8CFFvY1MzPj8lKzkopML+2MvCXJybRrMUuki5OITlpui8GHgSDGElzUIMAzf1m5Sg wbO6lFpoOhaxMa4Ael2bSzNCx4Rpd/ZtS4zZBF39sgeOgp351/RXKpMUGmryoXDDM/PN xnvg== X-Gm-Message-State: AOJu0Yzf5+hHoT+Peb+u94qZjOIEgRI0KFN+CAjqIMioRi79qpy8Okjf MLyMOd7OIKvBoEHrN/mIYb4= X-Received: by 2002:a05:600c:19cb:b0:40d:8638:bf5 with SMTP id u11-20020a05600c19cb00b0040d86380bf5mr1924814wmq.22.1704204216844; Tue, 02 Jan 2024 06:03:36 -0800 (PST) Received: from localhost.localdomain (host-87-10-250-100.retail.telecomitalia.it. [87.10.250.100]) by smtp.googlemail.com with ESMTPSA id e17-20020a5d5311000000b0033672cfca96sm28427527wrv.89.2024.01.02.06.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:03:36 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v2 1/4] net: phy: at803x: generalize cdt fault length function Date: Tue, 2 Jan 2024 15:03:25 +0100 Message-ID: <20240102140330.7371-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240102140330.7371-1-ansuelsmth@gmail.com> References: <20240102140330.7371-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786987715626137639 X-GMAIL-MSGID: 1786987715626137639 Generalize cable test fault length function since they all base on the same magic values (already reverse engineered to understand the meaning of it) to have consistenct values on every PHY. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 0db653b57494..072bcd670ef0 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1259,10 +1259,8 @@ static bool at803x_cdt_fault_length_valid(u16 status) return false; } -static int at803x_cdt_fault_length(u16 status) +static int at803x_cdt_fault_length(int dt) { - int dt; - /* According to the datasheet the distance to the fault is * DELTA_TIME * 0.824 meters. * @@ -1278,8 +1276,6 @@ static int at803x_cdt_fault_length(u16 status) * With a VF of 0.69 we get the factor 0.824 mentioned in the * datasheet. */ - dt = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, status); - return (dt * 824) / 10; } @@ -1332,9 +1328,11 @@ static int at803x_cable_test_one_pair(struct phy_device *phydev, int pair) ethnl_cable_test_result(phydev, ethtool_pair[pair], at803x_cable_test_result_trans(val)); - if (at803x_cdt_fault_length_valid(val)) + if (at803x_cdt_fault_length_valid(val)) { + val = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, val); ethnl_cable_test_fault_length(phydev, ethtool_pair[pair], at803x_cdt_fault_length(val)); + } return 1; } @@ -2059,7 +2057,8 @@ static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair) if (val < 0) return val; - return (FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val) * 824) / 10; + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val); + return at803x_cdt_fault_length(val); } static int qca808x_cable_test_start(struct phy_device *phydev) From patchwork Tue Jan 2 14:03:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4463067dyb; Tue, 2 Jan 2024 06:05:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoZCVnDghKz1egjEz4woA3ODjyI1ptJrj93ul/fTPfmK8+aNMdcS73z6YBP5dwlCRUzXc2 X-Received: by 2002:a17:903:44b:b0:1d3:838f:156 with SMTP id iw11-20020a170903044b00b001d3838f0156mr6635248plb.121.1704204358067; Tue, 02 Jan 2024 06:05:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704204358; cv=none; d=google.com; s=arc-20160816; b=Hq7MOyz5vKFA9HBYgmLM9Qu49jx/Rr5maKneY7NkJqDle3yuz2VfnGkhakm8sW5iCv EYy9g8kQkaNd4uQxDT5LmiVU5qx43Q65x/LAxwIYVQaag8i9qtsve6EbSPYeT6fV8RPc ROcxK9xsI9wrYEV5aHdc5nTO5fCJW5FZYUQuWC7uScO66Y5GPFe1knWZsSaswt48t9mH Con7cwNkDEp7iaIrV+xu+rumI/Cm1om1hYOKiJxxZuS97+t1Z5ooYD56doXbwHaLhHTV faBJ0cKLZdnZPAHIHlwa+AesL4dB461gSwhbD8/VUwQhHSSsnMqfAJzoZl8eKIIbCtf8 IETw== ARC-Message-Signature: i=1; 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:dkim-signature; bh=lsA0JDN11Q2nz8SUx5kA6LiRo/4zS6VELKeRkM4TXVA=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=gzlkGY1MFFb+Z7DZCT1HY37HBzbJeaYVaCe70osuPevIo67rtwXRYz5j1QCnaCswUy VNKs0uztcvyLdWP2YiEQVPYnPfBuyZQT6aUHH82URSQwweXjr4Zgz7Vfizq2qWrLrYIR lIMpPd7nfXf4nYwQ1OLbr0BCX6pc6Qs7HqeizXzJCUUT3Gx1NUarJE1rR+wWIcMPISlQ KtOIGshAF4YZ2G/0bZdyDi2ZnfzNUfF0dQXU4ovlmR6s7v9w1bg7cSTXrIPbHAetV1Cp K9Pg02F5YQNKTYMWbdi2GAdkS9TX27hAHMdELIptP+vL7ne7PtptAIG8fXjZTsVRCMnS tQoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OZM2Fg+s; spf=pass (google.com: domain of linux-kernel+bounces-14457-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14457-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l17-20020a170902f69100b001d3e44faf1bsi20360691plg.242.2024.01.02.06.05.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:05:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14457-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OZM2Fg+s; spf=pass (google.com: domain of linux-kernel+bounces-14457-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14457-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 545F4B222DD for ; Tue, 2 Jan 2024 14:05:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C16E14F75; Tue, 2 Jan 2024 14:03:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OZM2Fg+s" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C1A911704; Tue, 2 Jan 2024 14:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40d8e7a50c1so1611995e9.2; Tue, 02 Jan 2024 06:03:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704204218; x=1704809018; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lsA0JDN11Q2nz8SUx5kA6LiRo/4zS6VELKeRkM4TXVA=; b=OZM2Fg+skPXGCyBQJKo57m5mD6aNcZCZsqlMcRxX2ZotQXN4yI7Y8y5B1OESfyDdT5 +ZJAFRSnqM/kLDIYj5kJ8TBj4+A/lXMEJB7GeWQ222HXprEQWZ2wTLV5Ee2TaGGWeOq1 PR7qdkEuuTSSKtW81woIcOSDyS3b66EuZ7FttPdRqX0hKuAnsLdvDrpM/NbmxwYA+Dni rcSjy91n+cCWh8Ryoe0KpHqWXjsupA7KLVDdHK76VBIhOkCFdO+gPrVPm57zxbDQeDD9 uyMUf3QHOT2iRiYxdgGbUXhj/1faJsVIgTHZ+WXSZmsUF/UmFFA4nzfXri/XrA4r3Jg6 oZeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704204218; x=1704809018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lsA0JDN11Q2nz8SUx5kA6LiRo/4zS6VELKeRkM4TXVA=; b=OmJnbu8cMmocmHp1gR/RnOK0gEDHNC6/F39XXo156Z2NWpTO22VyNNdYtB1VxOLZXO 0/hrMl2doLYFN7xLEq6ZJytX/feqiKeWfcjX6pN61syH5mRIKa/BbBJZAR/T6Ddj1P/P aTzKQ+LUaclloFUBH6BPu88ZsjQHByMQDlX7bth33BO9rgKQjXZiNIh0LM9eQdHLB8bx dWK3GGRHTFBo9oZlgFjG4YNu8hpd2vi7/ikQHXV2qiuj+wgAOdk+//TR70KPv4jCQeAu 7twxijmpBBbVR2WlhFR1nbtnXNThy8anWwtcCNKZ5rIXi6sNZCf2mqtc14bHw7KtwowB tqrg== X-Gm-Message-State: AOJu0Yyw+cxiFOAmryyga/v5bq5Plnvr3Sd6/+D8p4HkYVatAPZv1n6b hXwHele6RSZ9fsaqsOMWxsM= X-Received: by 2002:a7b:c4cc:0:b0:40d:88c4:a59e with SMTP id g12-20020a7bc4cc000000b0040d88c4a59emr1239494wmk.164.1704204218226; Tue, 02 Jan 2024 06:03:38 -0800 (PST) Received: from localhost.localdomain (host-87-10-250-100.retail.telecomitalia.it. [87.10.250.100]) by smtp.googlemail.com with ESMTPSA id e17-20020a5d5311000000b0033672cfca96sm28427527wrv.89.2024.01.02.06.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:03:37 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v2 2/4] net: phy: at803x: refactor qca808x cable test get status function Date: Tue, 2 Jan 2024 15:03:26 +0100 Message-ID: <20240102140330.7371-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240102140330.7371-1-ansuelsmth@gmail.com> References: <20240102140330.7371-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786987788536674980 X-GMAIL-MSGID: 1786987788536674980 Refactor qca808x cable test get status function to remove code duplication and clean things up. The same logic is applied to each pair hence it can be generalized and moved to a common function. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 65 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 072bcd670ef0..9610b51a5928 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -2102,10 +2102,39 @@ static int qca808x_cable_test_start(struct phy_device *phydev) return 0; } +static void qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair, + u16 status) +{ + u16 pair_code; + int length; + + switch (pair) { + case ETHTOOL_A_CABLE_PAIR_A: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_A, status); + break; + case ETHTOOL_A_CABLE_PAIR_B: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_B, status); + break; + case ETHTOOL_A_CABLE_PAIR_C: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_C, status); + break; + case ETHTOOL_A_CABLE_PAIR_D: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_D, status); + break; + } + + ethnl_cable_test_result(phydev, pair, + qca808x_cable_test_result_trans(pair_code)); + + if (qca808x_cdt_fault_length_valid(pair_code)) { + length = qca808x_cdt_fault_length(phydev, pair); + ethnl_cable_test_fault_length(phydev, pair, length); + } +} + static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) { int ret, val; - int pair_a, pair_b, pair_c, pair_d; *finished = false; @@ -2124,36 +2153,10 @@ static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finish if (val < 0) return val; - pair_a = FIELD_GET(QCA808X_CDT_CODE_PAIR_A, val); - pair_b = FIELD_GET(QCA808X_CDT_CODE_PAIR_B, val); - pair_c = FIELD_GET(QCA808X_CDT_CODE_PAIR_C, val); - pair_d = FIELD_GET(QCA808X_CDT_CODE_PAIR_D, val); - - ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, - qca808x_cable_test_result_trans(pair_a)); - ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, - qca808x_cable_test_result_trans(pair_b)); - ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C, - qca808x_cable_test_result_trans(pair_c)); - ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D, - qca808x_cable_test_result_trans(pair_d)); - - if (qca808x_cdt_fault_length_valid(pair_a)) { - val = qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A); - ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_A, val); - } - if (qca808x_cdt_fault_length_valid(pair_b)) { - val = qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B); - ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_B, val); - } - if (qca808x_cdt_fault_length_valid(pair_c)) { - val = qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C); - ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_C, val); - } - if (qca808x_cdt_fault_length_valid(pair_d)) { - val = qca808x_cdt_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D); - ethnl_cable_test_fault_length(phydev, ETHTOOL_A_CABLE_PAIR_D, val); - } + qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_A, val); + qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_B, val); + qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_C, val); + qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_D, val); *finished = true; From patchwork Tue Jan 2 14:03:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4463004dyb; Tue, 2 Jan 2024 06:05:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgw0F53xQXNWrXPruOm67wUclUZJTUKW3fU7g7DiNKo2lBsXsy9eQ94YvWpCkW0B/eBlwq X-Received: by 2002:a05:6602:2108:b0:7b7:f972:c016 with SMTP id x8-20020a056602210800b007b7f972c016mr17706926iox.43.1704204353668; Tue, 02 Jan 2024 06:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704204353; cv=none; d=google.com; s=arc-20160816; b=ZbV40q1GWhZTSdOihfQ+goVgTE3g2ENNIC5eQ3XmCpAstI8Ii1hKnqwRGGXQFRV/uE K4GLPKWJpTJgBcZj/9DxcScEwNSJBG5b3U65x5adMua28jxdZTxVLIj49cPI5J77LNkc BWOKz7e4dVqb/x/P7m35mAb81Zg9GKLNkDQl1XT68Drw6OPirg4infwZOP+bxBPXWpXk xMcb4wh5s7FTc1x/Pdih17X7fnK4bxGu0rgglSH/K1jA3FhbsHW0lMdhQr1gX6zVjOGh PX5XGkDHxFu8G2myMG6Y+mvfKcYitErSIWjg/Xd45WzWLDrQW0+Cq2ErpCd+i9kTWS9u JJUQ== ARC-Message-Signature: i=1; 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:dkim-signature; bh=MCe7bi22I9OO+O1jPW0w/LAeUi3E0GH8xhFVY0QzJoM=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=rerFSKpQTo7cNZvF0aI6N6gqb66yZk36bWwIkT7jTGw/RrTZvUOqeYxfnE/uY4cv2c oct8ftsd83DhE206ZLW6dWNEbGObEbqeN5AOaAFTb/kHdS+3/zE2N84gB4bCa+nHMDdk 6yPZuHr/Nb61GWTXLeS3Lrz2s0CVaorK3VeEKMPKlWgsertfTLwA865SKE6JHnp6jilS zZVjNZwic5nt5HplGULCa6gZ/9r8lvC/y0TzaFOXjM87GdYbmMxfsWDM6QxRjvrcvYTF Pq99o6vtk1xdC6YvxgjUP2dYQnBkOHe20YpPGrafz8d8JqJUSn0HwnFMHOxa2qk+3sSS QIZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fLCHUUNk; spf=pass (google.com: domain of linux-kernel+bounces-14458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14458-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g3-20020a636b03000000b005c6bc10835fsi19915274pgc.84.2024.01.02.06.05.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:05:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fLCHUUNk; spf=pass (google.com: domain of linux-kernel+bounces-14458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14458-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 27D0E28393A for ; Tue, 2 Jan 2024 14:05:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 266F8154AB; Tue, 2 Jan 2024 14:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fLCHUUNk" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C622313ADA; Tue, 2 Jan 2024 14:03:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-33686649b72so9638710f8f.3; Tue, 02 Jan 2024 06:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704204220; x=1704809020; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MCe7bi22I9OO+O1jPW0w/LAeUi3E0GH8xhFVY0QzJoM=; b=fLCHUUNkmQDujZtVtblj+Zr0aey0ivB+dSQQvLzAvQkeYcoh7jIfzQFsrhbNHvaOLW +hLEaWuVc20PMzK0/QD1FYd6C3LckqLTUnVWcz3vuaNVFTNTFkLLH0M/DDmhtoJe4mTx yFfJkQdd00nLB3WeTP2yWJkEQR6ywUUf0TpUu3zNagBzuQSMuBjJrgoC/pA+YytA4Que ET4hKkbo6ptiHq75QswTfqUlz6fIpsCe7W0x44dzHgm56RYBUTCiemYNu1rzMXcF4gT3 dKULmC/wgr4CkTwjNUXNX7ArQa8rBqgjvfF2drd+ZOmIgBxCFhVfniu5KHLw7S0xlhQU AwRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704204220; x=1704809020; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MCe7bi22I9OO+O1jPW0w/LAeUi3E0GH8xhFVY0QzJoM=; b=Ox85IbzxNNvr0Rw/YPdMMlZmGBlqJc7J5Rnyyz55fo2MQ/Y/b++j98Ledkxcdwbmxu VFmILtbz4QehaNRHPpSP/2K4w5HvQrjNs7qrZvTrjV/Oj+1tpBWXF1CMfiD42M/Mo57B 2ILv70QKmAfyPM3M6G5iYlUQsaPbmjMGYC7jK01/Fmuo0iFohUFQCU9RPPT0oTMwV2Nh v5lGhxXQGHtoF1hjb5PQS08rDyHjGz3WAmOrXTkcJGAZdCY6q44ioIHYhh8RZLqZSkTg X/ykjw41SXNrLx5ysp1fODHRnYm8tHVVbHq/+v5aV69ish3yQkuIWZBtOBsrQYp0Xcvh G1XA== X-Gm-Message-State: AOJu0YxgZ3XUIypEC02qXirSIFUxKuQ9iLKtXSb48weYZ5kioXnwsaQ7 k4tDBSHeWUFZIW5BVybfLgs= X-Received: by 2002:adf:fa84:0:b0:336:b937:3d0e with SMTP id h4-20020adffa84000000b00336b9373d0emr9009616wrr.14.1704204219894; Tue, 02 Jan 2024 06:03:39 -0800 (PST) Received: from localhost.localdomain (host-87-10-250-100.retail.telecomitalia.it. [87.10.250.100]) by smtp.googlemail.com with ESMTPSA id e17-20020a5d5311000000b0033672cfca96sm28427527wrv.89.2024.01.02.06.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:03:39 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v2 3/4] net: phy: at803x: add support for cdt cross short test for qca808x Date: Tue, 2 Jan 2024 15:03:27 +0100 Message-ID: <20240102140330.7371-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240102140330.7371-1-ansuelsmth@gmail.com> References: <20240102140330.7371-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786987784233202845 X-GMAIL-MSGID: 1786987784233202845 QCA808x PHY Family supports Cable Diagnostic Test also for Cross Pair Short. Add all the define to make enable and support these additional tests. Cross Short test was previously disabled by default, this is now changed and enabled by default. In this mode, the mask changed a bit and length is shifted based on the fault condition. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 86 ++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 17 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 9610b51a5928..3d3d34ef594c 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -254,6 +254,7 @@ #define QCA808X_CDT_ENABLE_TEST BIT(15) #define QCA808X_CDT_INTER_CHECK_DIS BIT(13) +#define QCA808X_CDT_STATUS BIT(11) #define QCA808X_CDT_LENGTH_UNIT BIT(10) #define QCA808X_MMD3_CDT_STATUS 0x8064 @@ -261,16 +262,44 @@ #define QCA808X_MMD3_CDT_DIAG_PAIR_B 0x8066 #define QCA808X_MMD3_CDT_DIAG_PAIR_C 0x8067 #define QCA808X_MMD3_CDT_DIAG_PAIR_D 0x8068 -#define QCA808X_CDT_DIAG_LENGTH GENMASK(7, 0) +#define QCA808X_CDT_DIAG_LENGTH_SAME_SHORT GENMASK(15, 8) +#define QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT GENMASK(7, 0) #define QCA808X_CDT_CODE_PAIR_A GENMASK(15, 12) #define QCA808X_CDT_CODE_PAIR_B GENMASK(11, 8) #define QCA808X_CDT_CODE_PAIR_C GENMASK(7, 4) #define QCA808X_CDT_CODE_PAIR_D GENMASK(3, 0) -#define QCA808X_CDT_STATUS_STAT_FAIL 0 -#define QCA808X_CDT_STATUS_STAT_NORMAL 1 -#define QCA808X_CDT_STATUS_STAT_OPEN 2 -#define QCA808X_CDT_STATUS_STAT_SHORT 3 + +#define QCA808X_CDT_STATUS_STAT_TYPE GENMASK(1, 0) +#define QCA808X_CDT_STATUS_STAT_FAIL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 0) +#define QCA808X_CDT_STATUS_STAT_NORMAL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 1) +#define QCA808X_CDT_STATUS_STAT_SAME_OPEN FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 2) +#define QCA808X_CDT_STATUS_STAT_SAME_SHORT FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 3) + +#define QCA808X_CDT_STATUS_STAT_MDI GENMASK(3, 2) +#define QCA808X_CDT_STATUS_STAT_MDI1 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 1) +#define QCA808X_CDT_STATUS_STAT_MDI2 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 2) +#define QCA808X_CDT_STATUS_STAT_MDI3 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 3) + +/* NORMAL are MDI with type set to 0 */ +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI1 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ + QCA808X_CDT_STATUS_STAT_MDI1) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ + QCA808X_CDT_STATUS_STAT_MDI1) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI2 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ + QCA808X_CDT_STATUS_STAT_MDI2) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ + QCA808X_CDT_STATUS_STAT_MDI2) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI3 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ + QCA808X_CDT_STATUS_STAT_MDI3) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ + QCA808X_CDT_STATUS_STAT_MDI3) + +/* Added for reference of existence but should be handled by wait_for_completion already */ +#define QCA808X_CDT_STATUS_STAT_BUSY (BIT(1) | BIT(3)) #define QCA808X_MMD7_LED2_CTRL 0x8074 #define QCA808X_MMD7_LED2_FORCE_CTRL 0x8075 @@ -2008,8 +2037,17 @@ static int qca808x_soft_reset(struct phy_device *phydev) static bool qca808x_cdt_fault_length_valid(int cdt_code) { switch (cdt_code) { - case QCA808X_CDT_STATUS_STAT_SHORT: - case QCA808X_CDT_STATUS_STAT_OPEN: + case QCA808X_CDT_STATUS_STAT_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT: return true; default: return false; @@ -2021,17 +2059,28 @@ static int qca808x_cable_test_result_trans(int cdt_code) switch (cdt_code) { case QCA808X_CDT_STATUS_STAT_NORMAL: return ETHTOOL_A_CABLE_RESULT_CODE_OK; - case QCA808X_CDT_STATUS_STAT_SHORT: + case QCA808X_CDT_STATUS_STAT_SAME_SHORT: return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT; - case QCA808X_CDT_STATUS_STAT_OPEN: + case QCA808X_CDT_STATUS_STAT_SAME_OPEN: return ETHTOOL_A_CABLE_RESULT_CODE_OPEN; + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT: + return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT; case QCA808X_CDT_STATUS_STAT_FAIL: default: return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC; } } -static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair) +static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair, + int result) { int val; u32 cdt_length_reg = 0; @@ -2057,7 +2106,11 @@ static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair) if (val < 0) return val; - val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val); + if (result == ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT) + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_SAME_SHORT, val); + else + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT, val); + return at803x_cdt_fault_length(val); } @@ -2105,8 +2158,8 @@ static int qca808x_cable_test_start(struct phy_device *phydev) static void qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair, u16 status) { + int length, result; u16 pair_code; - int length; switch (pair) { case ETHTOOL_A_CABLE_PAIR_A: @@ -2123,11 +2176,11 @@ static void qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pai break; } - ethnl_cable_test_result(phydev, pair, - qca808x_cable_test_result_trans(pair_code)); + result = qca808x_cable_test_result_trans(pair_code); + ethnl_cable_test_result(phydev, pair, result); if (qca808x_cdt_fault_length_valid(pair_code)) { - length = qca808x_cdt_fault_length(phydev, pair); + length = qca808x_cdt_fault_length(phydev, pair, result); ethnl_cable_test_fault_length(phydev, pair, length); } } @@ -2139,8 +2192,7 @@ static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finish *finished = false; val = QCA808X_CDT_ENABLE_TEST | - QCA808X_CDT_LENGTH_UNIT | - QCA808X_CDT_INTER_CHECK_DIS; + QCA808X_CDT_LENGTH_UNIT; ret = at803x_cdt_start(phydev, val); if (ret) return ret; From patchwork Tue Jan 2 14:03:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4462846dyb; Tue, 2 Jan 2024 06:05:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJdVd9r+bk0znipaWoWpCsPyXX87HGFc6M9vtgzh48wjdnVBaS0RSyBvwTAbFFno5kU4gp X-Received: by 2002:a17:906:28d:b0:a25:1ace:2c20 with SMTP id 13-20020a170906028d00b00a251ace2c20mr7614797ejf.86.1704204343245; Tue, 02 Jan 2024 06:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704204343; cv=none; d=google.com; s=arc-20160816; b=TCseuCbe4Pl6FuAbk1ExfbkWbNbzujw7iRwk3nJ6FHF7nX5EOvDZq9jrdAvPUHujPD EesZhVVvZ6DuE99wJMDJDG6q521QUK6ymOXA7mGTDhonwXeSBJuyt3eqkXMLJpWq0p3D S9phWlkfBE4xAg81N0Dph1fzHEKand24kNfc47G+E6tDSFUYIAlbNUcgzgJQxG3ecZmp sPHpHdAs1p/Qbpa2+KlK6AYLTGk72ZMhB4lyzTJfSfaWKKuo8d0YAV0Bm0A1+2xeMWIB De7fKjj2iNMal8/jcbR8O3CgM9AHCBNOz4HNyq7ty8r/41FC1gPW48w1XLSP+4NUdigq KmaA== ARC-Message-Signature: i=1; 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:dkim-signature; bh=PUohTBda7ifVie9oF2zeFzpU4spjHotK8dJMRsvSxYc=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=INkwwuSlCUtDc3KbkQaDYEVQbHK1GP+eN2XA6DpyJMvCvzbcBPBRdedX0Rx0cUizug YbI8krTPPsJwuLz4+y06H4TnfwA00Y8qOSHmUjDgIq4yFTc4Na/AI7jy+EV4nccwO6C7 9b+fhyAxw5k2rXqSpaxesooNW6FYrJyP0lQzFFj1MTipUQp3fl9XB0TGzpW8BBaaG6mp asFw+jung/kokYDiNRWJFb75PvKyf0v01PW4D8C8d7vxjy/OhUPRrDmsmnJUXtpvpicQ fcDRHtt1UYiYupFSg+/CByaGYzdB5F1L8H5Kbxz9TJZJaI0SCpT5BWA/Usbu4PPPOJkO khbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VKijXRKW; spf=pass (google.com: domain of linux-kernel+bounces-14460-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14460-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i21-20020a170906115500b00a1e431f49besi10118878eja.339.2024.01.02.06.05.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:05:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14460-ouuuleilei=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=@gmail.com header.s=20230601 header.b=VKijXRKW; spf=pass (google.com: domain of linux-kernel+bounces-14460-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14460-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 D47551F22CA0 for ; Tue, 2 Jan 2024 14:05:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA56D156C7; Tue, 2 Jan 2024 14:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VKijXRKW" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB38F14AB9; Tue, 2 Jan 2024 14:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40d5ac76667so46739365e9.1; Tue, 02 Jan 2024 06:03:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704204221; x=1704809021; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PUohTBda7ifVie9oF2zeFzpU4spjHotK8dJMRsvSxYc=; b=VKijXRKWadf1g9R9WVnwTIsLieRj1TNncnM+dQyBcCHbvYkJXnB1OpLe9PsgpVulGp i6sjjw8+8ycLADviEGywndF7wTI6NYz0Vy3+RObC5B4gazQWAqECtqIbPbf7DlyIJhIB R2p/xBDJfO9sPWi8I/bljiCK8lyedDNKP+iodmvEDpt0q6Ari5dZ6Aj1OQ0cjvfuRX/j 2qxILrmca5DjMcj+F2u2B8sekRURsxajei1G7tAmUd0xqVPkouCmasAvABNnV7dCaGrU Vb0gB7I/MytERw8amJtmly5cGWDbDwvZEdLD5jplX9OL3/PaGoSXmFNEBCWVnRAqbs1P K+rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704204221; x=1704809021; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PUohTBda7ifVie9oF2zeFzpU4spjHotK8dJMRsvSxYc=; b=FSLKUXnR3hvy4lYWdtuNd7ZZhiRCRRuGnvIaOjpHH+gw16D6VuM/oZBFEtXOF+wu88 ZgIm3Y9wzj0yXL8DWXWLPYRID3rYR3zAwtZpmOJ1QGSi90J7V6suNIisxRUOYy/wlHQa J0GAfw/3JDZr+JyfwUiuDG+RiHufveN7jPQ2CQKMLlQdxRD812k71SOrIKTFQYS60E3O 48Vo5MtwB3gtTd4fyTGHsqASV+V+okMoMa0ItvT0s0bZYTyqapGJL49hPt/i0QVBE8qC /nvL4xHLojoa3wjItfYDpYdiVoSE66ppw6fbfPwmfs00BkvZThwOC9bhJ5hdAbUXLAhv p6uQ== X-Gm-Message-State: AOJu0YwGNRKtEVtf6BQw96ELZleiggLFDAkIujiRIfmjUVMmmvt/E+pT xUqdOdmnjBDqvnmnCew/JhQ= X-Received: by 2002:a05:600c:13c3:b0:40d:350f:dc8f with SMTP id e3-20020a05600c13c300b0040d350fdc8fmr9558667wmg.87.1704204221242; Tue, 02 Jan 2024 06:03:41 -0800 (PST) Received: from localhost.localdomain (host-87-10-250-100.retail.telecomitalia.it. [87.10.250.100]) by smtp.googlemail.com with ESMTPSA id e17-20020a5d5311000000b0033672cfca96sm28427527wrv.89.2024.01.02.06.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:03:40 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v2 4/4] net: phy: at803x: make read_status more generic Date: Tue, 2 Jan 2024 15:03:28 +0100 Message-ID: <20240102140330.7371-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240102140330.7371-1-ansuelsmth@gmail.com> References: <20240102140330.7371-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786987772992008039 X-GMAIL-MSGID: 1786987772992008039 Make read_status more generic in preparation on moving it to shared library as other PHY Family Driver will have the exact same implementation. The only specific part was a check for AR8031/33 if 1000basex was used. The check is moved to a dedicated function specific for those PHYs. Signed-off-by: Christian Marangi --- drivers/net/phy/at803x.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 3d3d34ef594c..d52b0ec81994 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1087,13 +1087,9 @@ static int at803x_read_specific_status(struct phy_device *phydev, static int at803x_read_status(struct phy_device *phydev) { - struct at803x_priv *priv = phydev->priv; struct at803x_ss_mask ss_mask = { 0 }; int err, old_link = phydev->link; - if (priv->is_1000basex) - return genphy_c37_read_status(phydev); - /* Update the link, but return if there was an error */ err = genphy_update_link(phydev); if (err) @@ -1685,6 +1681,17 @@ static int at8031_config_intr(struct phy_device *phydev) return at803x_config_intr(phydev); } +/* AR8031 and AR8033 share the same read status logic */ +static int at8031_read_status(struct phy_device *phydev) +{ + struct at803x_priv *priv = phydev->priv; + + if (priv->is_1000basex) + return genphy_c37_read_status(phydev); + + return at803x_read_status(phydev); +} + /* AR8031 and AR8035 share the same cable test get status reg */ static int at8031_cable_test_get_status(struct phy_device *phydev, bool *finished) @@ -2568,7 +2575,7 @@ static struct phy_driver at803x_driver[] = { .read_page = at803x_read_page, .write_page = at803x_write_page, .get_features = at803x_get_features, - .read_status = at803x_read_status, + .read_status = at8031_read_status, .config_intr = at8031_config_intr, .handle_interrupt = at803x_handle_interrupt, .get_tunable = at803x_get_tunable,