From patchwork Wed Jan 3 12:46:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4995690dyb; Wed, 3 Jan 2024 04:47:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCRa1WjZOM61qevSVY9TDW4ArtGt9MSLbCRChjiUAupOXiMI+pnU7dgUDT7lwiqrMjDpWn X-Received: by 2002:a05:6870:5686:b0:204:1fb4:2896 with SMTP id p6-20020a056870568600b002041fb42896mr15225969oao.116.1704286067332; Wed, 03 Jan 2024 04:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704286067; cv=none; d=google.com; s=arc-20160816; b=RWOCnR2MWiFVmlUDxUV1ilaJNdg9RksgJbwFVN/NBit3WeYE/11Rursn6ayuinsZIg aZiI3x73fomq6yVmaIxy6iCvdO+74YV6mS7+T9ysQd6rucCKapGEnwgBEpjnyN+hNAD9 8kQxccw7+QLoyZjycK9G23in1Nm3GLan0Wrv1rGWdyf0KdEHFwX9MAow2PdRq15ZxdhR Yd6nHyEwsuYG0xk3ZyKfDwseyUqf6dEc//GSrh6ZbE4myL89l68k9cXgLtRC2JacEOTr qc8Cblsd2ujXzpPHefi7qIUfEZeena4XuCZ3do2L4y9k5HnA8jjKMVyUgoCBzoI8v/4R H7Og== 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=mndGvtpI2oeo6GQDcXQC8VQnYdadwT7o6axDFA5/9kY=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=BcBoSLh9Qjz6RnT0JoUXys4PGsF7bsbzhpW+DcsN6bHZ9wALfuj3XNVu0wgdXOBA8w Fpd+/69OygiSXd+mN0ejNjma5+n4eJZd5zyy+pcjU974nG5/xIP8ErYNMPcW4ku6K1v1 rL7H7XLeACfLDnfMiA6YEjM0HQCqQQFfbMBnuAqaG7FbPyOHwJHzk4f8j2VlM0ShAls0 7DXgq073q9EwWwXwM1fKVd76C8w8tfnyJu7Yfp8h6PawU8S5meO2QkokkB0nDGhRvygi sC0FTLCFU/yH/HbB1QSRVkLYw4Sfr5OVvlDPozL73XvTjaB/hiico3lp5998+PKf0SZu uWlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QekCfjTI; spf=pass (google.com: domain of linux-kernel+bounces-15532-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15532-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c13-20020a05620a134d00b00781c56106a6si5813544qkl.645.2024.01.03.04.47.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15532-ouuuleilei=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; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QekCfjTI; spf=pass (google.com: domain of linux-kernel+bounces-15532-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15532-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2028A1C2337A for ; Wed, 3 Jan 2024 12:47:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 367EB19BB9; Wed, 3 Jan 2024 12:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QekCfjTI" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 399A619442; Wed, 3 Jan 2024 12:46:52 +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-f41.google.com with SMTP id 5b1f17b1804b1-40d894764e7so22499105e9.1; Wed, 03 Jan 2024 04:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704286010; x=1704890810; 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=mndGvtpI2oeo6GQDcXQC8VQnYdadwT7o6axDFA5/9kY=; b=QekCfjTIL8QQj5Qe+8uR6eAWOlRqBAcLned5f27TgXvSPU32Qo6lLGnCtOUK94vYJH d6ZlCDduT6KD+TxB6ZQNQSLxDxHy3vCYKvGdtwF6T6hY5l8qfO56QBluN6VHDhktGt6b /E0aEGL9lq0RvyJPZr6N2N1wX4x2Y8GYU99Ls/Bn+qNTCpj0SYS3BoUbSPEtJGMukjMV j97s83+cSQALXLTEi/bfvf0Fl+NAfGqYvm/Jk6F6AeKcY8QoT26lWQLF8DSVZXzOURsu wE28t5Q4amt8Uj2m6icv05dYBC7jX6mhDwp/jC3ydF1YPf9IM59mVtHMhR+0dUh/22mK oZOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704286010; x=1704890810; 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=mndGvtpI2oeo6GQDcXQC8VQnYdadwT7o6axDFA5/9kY=; b=dAO+moEnP2fHxB0OJLWnGKqwJ2wJaQkuMJmUfxMp1IigxAUnc01wGDlOs9RWNhW4GX 5z726PqhtBIOyC0TP7cy7aQovD55RupynsnlCVBh5nlntEg+TnDAWqwxo/svRK0bLU2R sDYy0Hzb7SUUkcVYJRVcMihllht0qB0PZTccNPLUMFqqCWHLZm9ieLHjf5Y1e4t2QsZI UYueXs96o3AlzzRfKZ6OBeDbdE/MODQnSikgaflxpBBxQUlIN1NaE2/j4TiGb9f7YfTU KyKlxWgtv2ZrK2NtU8bsCkqLgkP6pil1+JEjVNpM/dVWn8FO1+Jce92JGkAJ1K0huLR8 v7qg== X-Gm-Message-State: AOJu0YzYsHHg6HU/wS2Q0rIxlTvT1fIqploikDZoCQEPidZDYC/Lw+Hu P5x6mouY33taXQn0hPZxX0g= X-Received: by 2002:a05:600c:1c11:b0:40d:88fd:e1 with SMTP id j17-20020a05600c1c1100b0040d88fd00e1mr1453451wms.24.1704286010370; Wed, 03 Jan 2024 04:46:50 -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 fc16-20020a05600c525000b0040d5c58c41dsm2219676wmb.24.2024.01.03.04.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:46:49 -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 v3 1/4] net: phy: at803x: generalize cdt fault length function Date: Wed, 3 Jan 2024 13:46:32 +0100 Message-ID: <20240103124637.3078-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103124637.3078-1-ansuelsmth@gmail.com> References: <20240103124637.3078-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: 1787073467386363013 X-GMAIL-MSGID: 1787073467386363013 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 Reviewed-by: Simon Horman --- 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 aaf6c654aaed..acf483fa0887 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1192,10 +1192,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. * @@ -1211,8 +1209,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; } @@ -1265,9 +1261,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; } @@ -1994,7 +1992,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 Wed Jan 3 12:46:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4995827dyb; Wed, 3 Jan 2024 04:48:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvr77uYFzYA7sDu+xXCeX25YnNUm7AoYss1RnMb5wAzOQxsmUOl/KnBLlMwXYRzYMPri1A X-Received: by 2002:a17:907:970e:b0:a27:7079:4499 with SMTP id jg14-20020a170907970e00b00a2770794499mr3306681ejc.55.1704286087049; Wed, 03 Jan 2024 04:48:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704286087; cv=none; d=google.com; s=arc-20160816; b=mDAvw3rFERy+mOHxadVUU52gYnCj7Quucxcc230h1ldPogcZy1nJznQm0cZnkMBjhC LfAXwEzf0o1+1ar0Yhp8fHUL1bkIx6cupAJVDS58r8i+uYlhFvw1zxpPnSefdC1R49kE xSTNX+U8O/JwgvaZbFdkTyc9EH3tmw0jBxEwjGcVvpywp74EdI5EgkokItIfrTzIIFBf 2A7eWuQI0eCxQHmflPKllO3phyDcePFVitjYTk05kPH5gkrLkaAhmZkpJV9XEgbSeDXY AZWQCloCbrfbXY7bbFVN5Qk8LrE4MLZUlViiiOrLgZWVqTShb66yHOnysIISvgwdD6Ia Ph2w== 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=XCJqZdq/iqlteXCIkR1kOvJH/pGADA5Hu358ETfwzNc=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=bX1D19X1T8QHRmETdghMgH4e13qnCnGfrUxBqCRH25AzZ6xOr6iMsMYMe5iWs3aA/c jknAPRihe66sRLooQ+T2ctSqOJFQrY0HQpwF+7iVXHe5noHtNKdStVDYVym4aQMQjPkU +ccrrbqwEEiIGghEUTrgQQpqA/UPkFCNjc7klMyRNNRY024Ew/VxBigSItIcoxIScGqx QIl4ih7EhR1qL9+iwCbAjsSn0hegAgumvHBhIL0Wk6XAIMMrvzycbKB+r7ULlqiIfaFU ksRy07RbDQuCHg/YkV08WtddWbXRVFyMreCrqUppL9ltWp73Y+E/tKRVkKP8SZeT6A6Q 9Tug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AfUaXq8i; spf=pass (google.com: domain of linux-kernel+bounces-15533-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15533-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c7-20020a17090654c700b00a2687e6d11asi11062010ejp.476.2024.01.03.04.48.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:48:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15533-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AfUaXq8i; spf=pass (google.com: domain of linux-kernel+bounces-15533-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15533-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 A555C1F2438A for ; Wed, 3 Jan 2024 12:48:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3E521A28A; Wed, 3 Jan 2024 12:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AfUaXq8i" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 A8C461946B; Wed, 3 Jan 2024 12:46:53 +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-f43.google.com with SMTP id ffacd0b85a97d-3366e78d872so10037963f8f.3; Wed, 03 Jan 2024 04:46:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704286012; x=1704890812; 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=XCJqZdq/iqlteXCIkR1kOvJH/pGADA5Hu358ETfwzNc=; b=AfUaXq8i4gzX5Cr8POjULLsWuAI9CKSmUcLkoZ5qAtyot0H2gULh2UXLs1cMiiRFdl rBkpadouheHNioCl4MAs2wexM8UHTD2tvkI8jUV144WrjsQnmF1XmQ01zZ/uPefLK/oh +TdJw1sQx14b2vu6zMnyCO3zTnBAyjsG7Ya3m+W4IYMRvJxKvdNV/jG5TD5AJsdWPl8q I8QoK43xQk4jXHre4iRKjQLK5GEq8UeFvQF1VDOQTZru1uKvxpTBlF7GViGls3ElBDFi dT0J2Qxq4+KNwbC2BCZOqO3wBu8zkDq7NQ+1L4INVe7uDN/jfzzbmwxFPs9jOvDrSK3O UMYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704286012; x=1704890812; 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=XCJqZdq/iqlteXCIkR1kOvJH/pGADA5Hu358ETfwzNc=; b=gzKH6mpKaKFEJRdgTbpF5TGomyqYuR6DD2vKWTxeYbux0vyNE7oQUYxefuGThd4x1u X5Uo3mMvRE7JvXEh5az3xT3d6UVQuLaUYNGH0lMv6GD+YuHiE66tY1phHKJ9dpuW2CYo wo8fS+l/RXeTXHt7WJEIYCFIHzDUi5/BxLOgsDp4z+YMsJ/e5bgFvZWxIrr/RV+wq7y2 TVO5mI57kMaNAp+SfNX/TdxtSHOgBHfHcl7SXg5413jWjazsRxokCJOYCPc+yIvgqEo7 cbdFvGcmqA2OO4R2HljlxOArVfMHB3xcj9qQzSiDM3TP81E1XMhvKDarnPkFkqQyPZl+ X5pA== X-Gm-Message-State: AOJu0YwvKXzv1D53F/65NTsNqpwX+Uj1vh2BZnSszBVmBcsMN1bKZSTb W9cKeiNysRT52mrntBk1CvE= X-Received: by 2002:a05:600c:3c94:b0:40d:62f9:8e5f with SMTP id bg20-20020a05600c3c9400b0040d62f98e5fmr2631717wmb.214.1704286011846; Wed, 03 Jan 2024 04:46:51 -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 fc16-20020a05600c525000b0040d5c58c41dsm2219676wmb.24.2024.01.03.04.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:46:51 -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 v3 2/4] net: phy: at803x: refactor qca808x cable test get status function Date: Wed, 3 Jan 2024 13:46:33 +0100 Message-ID: <20240103124637.3078-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103124637.3078-1-ansuelsmth@gmail.com> References: <20240103124637.3078-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: 1787073487682601657 X-GMAIL-MSGID: 1787073487682601657 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 acf483fa0887..b87293ee736c 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -2037,10 +2037,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; @@ -2059,36 +2088,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 Wed Jan 3 12:46:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4996028dyb; Wed, 3 Jan 2024 04:48:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6tZXdyMbH/kSwqQLrBK9yPTtbxDgvJ4RwAJXoElwR96aXFxvdzoWq8TU/PAnu2xizafyj X-Received: by 2002:a0c:f942:0:b0:680:d1f2:5cd0 with SMTP id i2-20020a0cf942000000b00680d1f25cd0mr338513qvo.15.1704286115016; Wed, 03 Jan 2024 04:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704286115; cv=none; d=google.com; s=arc-20160816; b=d+QkXljOWBH3m0+nE4+mIMtUqnkExDtnqQfquGQMGiyvM2Na6pOxTsgzJetrC8fz+d xJvLZu55iR3k7ELSVe2Kj+l/AARgFUJzrN3q+OUHIlV1EG2v5u+QMDz6bqiqu8RBbE6P Fiyypft5qW2S9sJYQ48WggGz8Pj54C1qpNIticouSD8zykp9+W5BuPdsgaMyOpGi4NWA tH02GNzl+KVUFanPoPYT/q9175CGHiQAnbJYYKvGt9zXi5/pQOVl0LyoAhibSKTzf+Ot B9lKjn7hSG8VeybBOIoIfUpYbkmOws2mL66V5UsFGsGEy1SRg5DdGo6Qa/Ja8BKug3p7 BCSg== 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=sLK5iCROUw8443l+GbLHNZT9zorVpYX24QDPt5c4KHg=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=r7zaKlLPc8hKP1MjzTAxBK/ahCf/JzApoT7jzgV729PYktreAuMCsOFwBEfI507ucC yl3xM37KggsXacF8XhOUWk6O1FoSZFgwDL8mTJbXuhVqp7adXSncKBwiA4bFRFU/55Nn hAP+U/E4jFWYI/SQkXxfpJX74iXx9zSpLZRBjlnB7k3pbF8chZF3pVs09wfbXT83Lh2s 5kP16xW6k7cfioV/hfiuDGe9pL8DJyw/Qoy2szTYeRidD1Sh8V4kgR4l0xg/RVW7SZMu N2/ixUQrUV+Xz61poeChr41bNrjMB7HPrGZCMwlyiYaJQo9zhzin67CJ+tmjymaOd6Ff oZEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=awWjsNRz; spf=pass (google.com: domain of linux-kernel+bounces-15534-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15534-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c8-20020a0ce148000000b0067f69b6e7b1si29735824qvl.558.2024.01.03.04.48.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:48:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15534-ouuuleilei=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; dkim=pass header.i=@gmail.com header.s=20230601 header.b=awWjsNRz; spf=pass (google.com: domain of linux-kernel+bounces-15534-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15534-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BB2581C233A4 for ; Wed, 3 Jan 2024 12:48:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E3EC1A5B2; Wed, 3 Jan 2024 12:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="awWjsNRz" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 56497199C9; Wed, 3 Jan 2024 12:46:55 +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-f49.google.com with SMTP id 5b1f17b1804b1-40d5336986cso102026845e9.1; Wed, 03 Jan 2024 04:46:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704286013; x=1704890813; 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=sLK5iCROUw8443l+GbLHNZT9zorVpYX24QDPt5c4KHg=; b=awWjsNRzxWzjNKbRpyb9EfVhZK4mOld2FfmKStzXa0GPLKb3ebDsARcXQE4YafpV9x CkHHg8k89tAHbVWVIXPAPu8hsFBr5Ou1tA2gvKPIcur+NyDrB84KXqnYoIOvnb2alkVK buWgznT2QcxQAcD6lw7SDWC9Dgy2xcBlH6+kSrDT/HmpC1MJnJ8nhssP7FQ0o9zWBvjH 7OkJ0LPqGcxpGGUxg1d+S6mSi7F2zwpUf8XF6ODV4r3NuggzZKDh5dU3AMgp3cCMK3qC Az7b1t3pKEuJYtk8pCWTHrFeanXClcf3SZLqqxPYU4dKmPhFh8ZHgqWimgbKMEhBJerm rf9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704286013; x=1704890813; 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=sLK5iCROUw8443l+GbLHNZT9zorVpYX24QDPt5c4KHg=; b=ppHcK/E+H3zVxYn5nChhTVgCPh4RApjt00JMCfFjS7Pb90F6+kScq1KAb51WWquvCj iBCRiryQEuxAaZ1Yesw2DAxwUKg8P2QNIlp0UhHUZfW3Lxi5eIEAT1Kq8fmLRG1XrPHk LDZtwlMogfGb8m8vhd0Af+glxzRKBT+FtzIm736wMFCSEgnH/Q1WmeNqcyxGRyNoerSL ABDahY9UwuuuldSRKYgRk02YXX6mVDad7z3CEariv66PuVtyv8rsBhnBuJT/NaTqogar K5T5UMaDmXdlXNzuXcP+2nmHtbWOBrPVjnAKBqblVsihsAvOlAcObOIHaliHy0MXFAfZ 5Kdg== X-Gm-Message-State: AOJu0Yw0ZGu7F0/p8rGjYUnnzVvtv7cY2xmqCAttjH3/0g+7SSnEDWVF JkKsxXLCkTKtDTVrm6D9fy0= X-Received: by 2002:a05:600c:3652:b0:40d:5c54:9bb5 with SMTP id y18-20020a05600c365200b0040d5c549bb5mr6167204wmq.170.1704286013288; Wed, 03 Jan 2024 04:46:53 -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 fc16-20020a05600c525000b0040d5c58c41dsm2219676wmb.24.2024.01.03.04.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:46:52 -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 v3 3/4] net: phy: at803x: add support for cdt cross short test for qca808x Date: Wed, 3 Jan 2024 13:46:34 +0100 Message-ID: <20240103124637.3078-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103124637.3078-1-ansuelsmth@gmail.com> References: <20240103124637.3078-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: 1787073517642341185 X-GMAIL-MSGID: 1787073517642341185 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 b87293ee736c..d6dfe906cb62 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)) /* QCA808X 1G chip type */ #define QCA808X_PHY_MMD7_CHIP_TYPE 0x901d @@ -1943,8 +1972,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; @@ -1956,17 +1994,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; @@ -1992,7 +2041,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); } @@ -2040,8 +2093,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: @@ -2058,11 +2111,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); } } @@ -2074,8 +2127,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;