From patchwork Wed Jan 3 14:29:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 18678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5053044dyb; Wed, 3 Jan 2024 06:30:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFg4Rgysdusb+vSRwzGgkg/c4D914d/awlWmGOLyueWyL8flDF8ndtQDIT8wSjgb7pUBnYw X-Received: by 2002:a05:6a20:78a2:b0:194:a32d:b6aa with SMTP id d34-20020a056a2078a200b00194a32db6aamr18808183pzg.122.1704292246828; Wed, 03 Jan 2024 06:30:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704292246; cv=none; d=google.com; s=arc-20160816; b=a1jWjDzLx2UG9n/UJZb9U8Ka6FLVBxaclK14AKn80j1F1sRJoPyHa/MxX6rBvbwvn4 BRAe13lXPSl/Mfb15eCnFTNMlwgjftYosRDv/6bQBeatPE1O68jGTvcTA8vViufArCFM +/rHYxmSyaiCfBJkVDUjqyCEccdbtoIuyFsL+7i6THWhEgnfEn9h50UkpR1+HwXy2Sxg nxz4exOmemH1uwiUIbWQ7T6KD4X9ChNsFen2X4353Cr3ml5s49sSgLwIit+/66KVOX5F i8knEqadIGkpaPcu6WsfIQ1XlC0I1vnoqOAvmRSIiw0bdoclf11qcSnYRQCYOiMJp6gG 6szw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=a05ZpwCKD22ZpankEalL5FReENSo5C7nkPaSj2vZgPk=; fh=cZsmPTVz2r9Jo3aGrmrcNH+95xaznXh4wqYwdMnpQKk=; b=WLH7CnVci+XKuSezmX86VeMb3Nh8VlGUKHvT7HHQJKpiBZpHJvispi++xg46ND9r2j FME0zRNZtHSFsYMQ8W8pm7/DxJBxzKrTrfhvCVacUR4eQAapYhLnrwbHvstR26hYPTSD tcJ1CviuW3u9NJjmmpD+32sls7FS3eDi+YosegN6HTchhos2kNIwS2JPOSM3x9b5AggH oznJ/4eOLfScPZXNPKveufGBTeJzouOXOMcvLIiBqEnaDIUkhPVWZe05HK9/UN+RAXAV a9q0fBgfCAVTxBNjJJu/+B9pR5L6xV7fRYkK7azvepMnEpXDZzfjAM7Hor3rk3FIpKv8 uHPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=d2pFx7rU; spf=pass (google.com: domain of linux-kernel+bounces-15647-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15647-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g4-20020a636b04000000b005c672f5f9e9si21260488pgc.602.2024.01.03.06.30.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 06:30:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15647-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=@bootlin.com header.s=gm1 header.b=d2pFx7rU; spf=pass (google.com: domain of linux-kernel+bounces-15647-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15647-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 9926EB2311B for ; Wed, 3 Jan 2024 14:30:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E3281B27C; Wed, 3 Jan 2024 14:30:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="d2pFx7rU" X-Original-To: linux-kernel@vger.kernel.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 54CF51A70B; Wed, 3 Jan 2024 14:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 51F28FF816; Wed, 3 Jan 2024 14:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1704292197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=a05ZpwCKD22ZpankEalL5FReENSo5C7nkPaSj2vZgPk=; b=d2pFx7rU/3RPKqqnOSi6ocZqNZCPVlaRKeXfOzrTyxBpYU6xuf8FTilCOpmWwImvenDDCX s8A7u+oZLcojc5uQcil7otFw/0ERgOG2my9KgonZ8k08Z2hspT8sKgb6j75D6TpzcVUGSE lE6nX44WGP0TBbgncxZEJqAGB8+PF4CgXEJkBvg/wvjTzLdwHjXPPKcLVYXixWZJ+fWe3Z m106C5RjNVKP0ug6RVtrd2PHDiDVuqwsuav+GQgMB/uwXUC21l+VdZ9Qv+QiFVpiAWPT93 eSbXKK/GL+XrnIsoWsU25FfktsR66h0tCFKAuuO8Rp4Q08NI+28dGJMH+2v84A== From: Maxime Chevallier To: davem@davemloft.net, Michal Kubecek Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?utf-8?q?K=C3=B6ry_Maincent?= , Jesse Brandeburg , Jonathan Corbet , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman Subject: [PATCH ethtool-next 0/3] ethtool: Introduce PHY listing and targetting Date: Wed, 3 Jan 2024 15:29:45 +0100 Message-ID: <20240103142950.235888-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787079947221612643 X-GMAIL-MSGID: 1787079947221612643 Hello everyone, This series implements the ethtool part of the multi-PHY support that was recently merged into net-next : https://lore.kernel.org/netdev/20231221180047.1924733-1-maxime.chevallier@bootlin.com/ The series starts with a UAPI header copy (I don't really know if it's up to me to do this, let me know if I should drop it). The second patch adds the possibility of passing a PHY index for the PSE-PD, PLCA and Cable-testing commands, in such a manner : ethtool --phy 2 --cable-test eth0 The new '--phy' parameter is optional for PHY-targetting commands, if it's not there, we use the old behaviour of relying on the PHY directly attached to the netdevice to perform the command. The parameter comes before the actual command to make it generic, after all the PHY index is passed in the request header. The Third patch adds a new ethtool option to display the PHYs present on an interface, along with enough information to reconstruct the link topology. As it relies on the netlink DUMP messages, some internal helpers were added in ethtool to send DUMP requests that includes a devname in the header, to perform a filtered dump. Here are a few examples of what you can expect on an interface that has 2 PHYs (the 88x3310 PHY exposes an SFP bus, on which a module that also contains a PHY is plugged) # ethtool --show-phys eth0 PHY for eth0: PHY index: 1 Driver name: mv88x3310 PHY device name: f212a600.mdio-mii:00 Downstream SFP bus name: sfp-eth0 PHY id: 0 Upstream type: MAC PHY for eth0: PHY index: 2 Driver name: Marvell 88E1111 PHY device name: i2c:sfp-eth0:16 PHY id: 21040322 Upstream type: PHY Upstream PHY index: 1 Upstream SFP name: sfp-eth0 Here's another example using the wildcard devname, that lists all PHYs on all interfaces : # ethtool --show-phys * PHY for eth0: PHY index: 1 Driver name: mv88x3310 PHY device name: f212a600.mdio-mii:00 Downstream SFP bus name: sfp-eth0 PHY id: 0 Upstream type: MAC PHY for eth0: PHY index: 2 Driver name: Marvell 88E1111 PHY device name: i2c:sfp-eth0:16 PHY id: 21040322 Upstream type: PHY Upstream PHY index: 1 Upstream SFP name: sfp-eth0 PHY for eth2: PHY index: 1 Driver name: Marvell 88E1510 PHY device name: f212a200.mdio-mii:00 PHY id: 21040593 Upstream type: MAC Thanks, Maxime Maxime Chevallier (3): update UAPI header copies ethtool: Allow passing a PHY index for phy-targetting commands ethtool: Introduce a command to list PHYs Makefile.am | 1 + ethtool.c | 30 +- internal.h | 1 + netlink/cable_test.c | 4 +- netlink/extapi.h | 1 + netlink/msgbuff.c | 52 +++- netlink/msgbuff.h | 3 + netlink/nlsock.c | 25 ++ netlink/nlsock.h | 2 + netlink/phy.c | 139 +++++++++ netlink/plca.c | 4 +- netlink/pse-pd.c | 4 +- uapi/linux/ethtool.h | 56 +++- uapi/linux/ethtool_netlink.h | 31 ++ uapi/linux/if_link.h | 529 +++++++++++++++++++++++++++++++++++ uapi/linux/stddef.h | 2 +- 16 files changed, 851 insertions(+), 33 deletions(-) create mode 100644 netlink/phy.c