From nobody Sun Apr 5 19:43:39 2026 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 4FF582949E0 for ; Tue, 24 Feb 2026 04:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907536; cv=none; b=puosvtun3WyEYt29LvBDv8JpZcWnf7001p13ZGC0V9NUzvJ8sWwWAFPfwfUnrahH+6KvR+pJmvlGyv9h/QRS57LxSOlV6OhaW8PQCTUR/21ju8MWSfm4LIa2nHVr6k+JNgv4qhgmRfYHThc2qS9M0jWWRKILhSloa84w/h/Akfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907536; c=relaxed/simple; bh=UEnQcp4MGlJixya53SMjZLpT9RLhpMLIX7hTK536NMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VRr8WJkFYqdMZNGqrXmtemp3U1YFG4cOCxGTHFHsDCEVl8RJG5+jMHPHMcHxv0RJxZfK5njvWjXtFqPbhBS45SZ3nQlCZxrBWwDhbicjVaNIPSnAaVNgsxstvAdSzR3hPbhV9vIfNYKKmWUS94bXNHYQc4aJuJZiZpsi54r0M6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LZXfwg/4; arc=none smtp.client-ip=209.85.208.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LZXfwg/4" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-658b6757f7fso918975a12.1 for ; Mon, 23 Feb 2026 20:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771907534; x=1772512334; 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=q2TVn9WTr30egH9VBmZciSNVmo3+g7N5E2PAqbC/nLw=; b=LZXfwg/4tZ6HhrT9jl4EPeGkI3uDTT+znbzZuqrGm3vqHETOCp7DPPE4I3BJrlY4Ss gIM0R+yR0HQZ0LzBT26e1/i7HupkrLuAq+TathWp8I10RzEs8qkmUtzdkXGkQ5+avt/H G6Dyz1UOpDSv+woBt1K9ajTq7ncVzzwaXL8a7jty3Ww3nzipSa+BNaql3n9Dgx9JNZ6m aTMaK6pRB0Kpwnmwb6Tkc9K11m4ai/BG3huTEC/C0FYS03x1NonMLYM5d33e8darWG8M Wi39KgQVgU4MeZlc2Thf+hwyBZtPwjxRmc4RRhTj/JKoQBLccVXVliowTnGN3CHccqQ9 lTfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771907534; x=1772512334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=q2TVn9WTr30egH9VBmZciSNVmo3+g7N5E2PAqbC/nLw=; b=tyd5/IHK2QRnZ/KxOJ8pNB0Dc+PBWEc3rZteQE79ndAj5sRTbQbc9pLYlahnXplBl9 +fp2lJOwtXCOZd0au8rdBN9xTDLkOz27cLmxW4ucSKcoQ1i1cAjxTyGq1BRBXBvs7erj d4PKnPgaYx0xxEvffRwtxThkgM+1RRKqPG5ypIKFpM6IbDse9t6+k6XAqViXYESgY8ow MGBb5mCOc0+Yd6btFG8FSK9uhCa2AHwnDYJ5bg98ew9TcXN/p6fP4qdE+VtSz4jIgi2g Yu5F6JTJjO4k/Tr5VgCI1a+OiWdC7L0fYNdhy+uhDwAhZil0Gen4IQN+DboiuLdeibjd yQSQ== X-Forwarded-Encrypted: i=1; AJvYcCVdYN5JFuWVr3bF57FNzLlaiii8gS7DZXc+Gy9qu1C9hGvkkawPhMVykZ6y5J10ELEINqRzq3Uw0i5tUfU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0svD05SnpTpnkxRr8Qu2RQER3IROxx0mq5YNA8feHL7c3K9s9 XjPdq13Zn0/eb0z5321SgS/dLmUyeD+GqrYzLWNmA1wIJNIoupnMUmfg X-Gm-Gg: AZuq6aIlD9l2mxlA/kdj3AyIKeATRfHSGF29GV94OdXRM7db50xLrWtMGPRaRnw+bdZ qJS+hkfX2ITfXpHgiZkFMjjtHRGD28/L+7zz6rI9xWMHf1/I8wS1Ba3AnhcQHnrYUgy8NgxBHR+ OLWsjzOytAWHaWuEjgWRQSnqNJB4A9NevaBmyD/L+gIg4xsmSAPV7igF367Fs0UrjSw+cA8JF+3 XmjX0mEFbBrKzj2n+rLAH3wDEUNPm6p6045h9B+hxSkFaXz6qXwnJwIubWmxaN72QriNkYQ1pQt FH4gm+NpDicXHvDOYM0UdSS+NOJ6/u2ilM/CwH6+nLB7voQkMogi+5o5KuJUvaW8arq9UGSIEs8 LZ60RRGxnNcPAe640mbdKKtiIPVxos18HYsFRw4ElUfTYM+YJt1BdRBsCRNEFRcxGEhGLqVOsXu x7EH9eCu0MVOQD1rgxjy29kvZCbngEi/3vv8iHM2SZHUDUquTgJOY4xua8rI67WW0aLz+KkL0YC 3qvX+/az8A7PARpCJkqE2umxB+oXUlFfFOroENI7rKlomTNrkDF8+yj/weCsbknxyMnMLxSYw== X-Received: by 2002:a17:907:6e8c:b0:b87:19ae:eb36 with SMTP id a640c23a62f3a-b90541616bdmr926260366b.7.1771907533547; Mon, 23 Feb 2026 20:32:13 -0800 (PST) Received: from cs-874966990260-default.europe-west4-b.c.i2f7e30109524dc12-tp.internal (206.242.32.34.bc.googleusercontent.com. [34.32.242.206]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b9088c8fc30sm371284466b.63.2026.02.23.20.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 20:32:13 -0800 (PST) From: Artem Lytkin To: FUJITA Tomonori , Andrew Lunn , Heiner Kallweit Cc: Trevor Gross , Russell King , Miguel Ojeda , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Lytkin Subject: [PATCH net-next v2 1/3] rust: net: phy: add speed() getter to Device Date: Tue, 24 Feb 2026 04:32:09 +0000 Message-ID: <20260224043211.1747-2-iprintercanon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260224043211.1747-1-iprintercanon@gmail.com> References: <20260223220504.2102-1-iprintercanon@gmail.com> <20260224043211.1747-1-iprintercanon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a speed() method to phy::Device as a getter counterpart to the existing set_speed(). This is needed by PHY drivers that need to detect speed changes, such as drivers that must reconfigure hardware registers when the link speed changes. Signed-off-by: Artem Lytkin --- rust/kernel/net/phy.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs index 3ca99db5cccf..b86939b163e3 100644 --- a/rust/kernel/net/phy.rs +++ b/rust/kernel/net/phy.rs @@ -158,6 +158,14 @@ pub fn is_autoneg_completed(&self) -> bool { bit_field.get(15, 1) =3D=3D AUTONEG_COMPLETED } =20 + /// Gets the negotiated speed of the PHY. + pub fn speed(&self) -> i32 { + let phydev =3D self.0.get(); + // SAFETY: The struct invariant ensures that we may access + // this field without additional synchronization. + unsafe { (*phydev).speed } + } + /// Sets the speed of the PHY. pub fn set_speed(&mut self, speed: u32) { let phydev =3D self.0.get(); --=20 2.43.0 From nobody Sun Apr 5 19:43:39 2026 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.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 34A1A29A326 for ; Tue, 24 Feb 2026 04:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907537; cv=none; b=byDqp11p8FetP774jNqwsh5rGXfm00Fri/8V1U/ahwBgM69n5hT8AEbMUuMqF061HhXS8eLaC+il2743vAiZcnJa5ZqCHD0j8sNSYPoJ31cnYezTRx1W075C60hFvfCJCyKJWJGyfc2pdpiqZIOcbIrWsYFzIuwcQw/auk97UnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907537; c=relaxed/simple; bh=b1xLgounYgAgwix7HTIz89qnAwlJn9qu3/e7SYKIiwU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W2BwKredB4N4SDPHDIhb/FwPu94/ayi3sjWAuErI0DOtRW3iX0Gutl+okApxAJEkupnB6hDgS9UhNbVTCywi/M1QsZKjpA9B4YNRxptoEOpK/FTNhQUwZcrClGoSLES8wEUb/572qPUs6wHKyy9/sLIPGBuJiBpTzKCjzb+dHpY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TdGPyQGd; arc=none smtp.client-ip=209.85.208.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TdGPyQGd" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-65c5a778923so7727065a12.2 for ; Mon, 23 Feb 2026 20:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771907534; x=1772512334; 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=siyGLrMfYzfWpKFoliNweeMXGBRAFWTpZWYm7LAc1oE=; b=TdGPyQGdK3oSwAxxSiYzeVbtxiTigeB7wXXSHcKB/tzEtFkT33s8Hz3Cvupio/4+fr klYvKDU21KGDIAdLOCNqIxt4rHBw/yYG9r7OiXJObMaVQlUf2QKynR0yaHlGaAoXGrkV yW0Kz3GbEWjdrkhM2kE3gBnJEYsmR1GBNi8I1P1DCasNmF+lG7qWkJEMu5r4wdwfxY6l g+hsLmT3nyiEtJ9U/agFw/e/6Bv1NTOArq3MEKjZ2n5JFC6v0QrCgBRHNYnpnmZubgS7 p8+xgrVFMyUxMcQ9jF99lnJM8BN90nQeBTbBCtpBtiAJpV9iOGt6gcAcrZgisRW0gH4u pKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771907534; x=1772512334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=siyGLrMfYzfWpKFoliNweeMXGBRAFWTpZWYm7LAc1oE=; b=TC1cxt88s4PLyzL2UvpdxF5kNoJm4af5sRMN9ybxy6KFVp8voh7DNuVzl0BDI4cB2X 95F+UaUo0yl4WMpFlJp5ilJoA9jCA2XNkiua+1AgcYl80T6yrEph1ig79De3RigQVa9O LV/Xv56p6+gjHXsmHe9uYRwlqBVQCDcFeknYL+o2EHL3BF/Ym+Fdc6EchLcHV3xts6Gf IxZ0xhGOUdlsu7eNrmT02VRnQhOCzvkV/qK4GNx/TCqObTuPf3cnhdu8Nu3ipE7SrOuP MY004871Q3lEC95TCDDc4Zy2IldaRCbbJnt5yEUCaoWE74pKHfD9BqeqKfg2UHT9bXbR w/eQ== X-Forwarded-Encrypted: i=1; AJvYcCXTQ8p9y7AZp3pXqJtppzc2fJrgCtVu5n2OGIwENXkOj1WvY+lu8Y/KspdKG/X44UDUGdnA0EHVHf1U62o=@vger.kernel.org X-Gm-Message-State: AOJu0YwiqfVMM72rqcM9ylb/rKy6YnYDDGz9ggt/UbUURtgX4nHP1mFM nhivQMIAfC1ayqa8fIrokh0i1v4tD+KxpAqoH4zczwYo15Av/I3dEqDt X-Gm-Gg: AZuq6aIKeQRpUqwRU1CFaFRkuGYyi/CdTqvJIllOWFrSLZsSyoq0WPaW4bzfR9YhcMo GXilOhVziHJMRE30MKin3CSVhYDOLOfJvdstUTyL5pliikn4EGgv8xwIJLTfkxFqlJeimspoTpR LhTnX5l9I5PSBamvUZrTrInNH29aPXPJlL8oORVOUY1/7Ix7C2X/TLONqK+Qiz4JWhC+dSq7ncb WSywd5mWtCj4vhwQCa1Rn7BcafcaGI9Hw5LcaEPsyizFmRCtZh0Tq7CLyTKyjCCkaCn/mXFUOEx EAhgDEoAR5a74VfqQcNmUqF6maYuwG1dQ8W1hLGjpxX+ah6rwfAw5nQwG3Ss7Y71CrkTgtsDejg Bi8AbIxhfKQyEbQa1P8TKlkaRYmPzUDAp8+ub7rSlRiEAs/DjkaBgjFi3YawNxYkIxU6Dyiqrqe caKNWXtHFJO8kLhlxuXv9ELJd4Ud4cTI5nkEIjhtmT05CSQfSNi3dQtShFxIgz9GZOPCxhaluRq OkS0PbORL0+xaYIYvXnVHIy5iwYV52gcLXusQ0hp2yN8cJeGDdxUkMhOIVLrZL4Hl3MwjUSqA== X-Received: by 2002:a17:906:9f85:b0:b8e:d4ed:5eeb with SMTP id a640c23a62f3a-b9081a45252mr723264366b.26.1771907534454; Mon, 23 Feb 2026 20:32:14 -0800 (PST) Received: from cs-874966990260-default.europe-west4-b.c.i2f7e30109524dc12-tp.internal (206.242.32.34.bc.googleusercontent.com. [34.32.242.206]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b9088c8fc30sm371284466b.63.2026.02.23.20.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 20:32:13 -0800 (PST) From: Artem Lytkin To: FUJITA Tomonori , Andrew Lunn , Heiner Kallweit Cc: Trevor Gross , Russell King , Miguel Ojeda , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Lytkin Subject: [PATCH net-next v2 2/3] rust: net: phy: expose genphy_config_aneg() Date: Tue, 24 Feb 2026 04:32:10 +0000 Message-ID: <20260224043211.1747-3-iprintercanon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260224043211.1747-1-iprintercanon@gmail.com> References: <20260223220504.2102-1-iprintercanon@gmail.com> <20260224043211.1747-1-iprintercanon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add genphy_config_aneg() method to phy::Device, wrapping the C function __genphy_config_aneg(). This is needed by PHY drivers that perform custom BMCR configuration before calling the generic auto-negotiation setup. The wrapper calls __genphy_config_aneg(phydev, false) directly since genphy_config_aneg() is a static inline function not visible to bindgen. Signed-off-by: Artem Lytkin --- rust/kernel/net/phy.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs index b86939b163e3..01597f2616fd 100644 --- a/rust/kernel/net/phy.rs +++ b/rust/kernel/net/phy.rs @@ -284,6 +284,15 @@ pub fn genphy_read_abilities(&mut self) -> Result { // So it's just an FFI call. to_result(unsafe { bindings::genphy_read_abilities(phydev) }) } + + /// Configures the advertisement and resets auto-negotiation + /// if auto-negotiation is enabled. + pub fn genphy_config_aneg(&mut self) -> Result { + let phydev =3D self.0.get(); + // SAFETY: `phydev` is pointing to a valid object by the type inva= riant of `Self`. + // So it's just an FFI call. + to_result(unsafe { bindings::__genphy_config_aneg(phydev, false) }) + } } =20 impl AsRef for Device { --=20 2.43.0 From nobody Sun Apr 5 19:43:39 2026 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 3A48A29D28F for ; Tue, 24 Feb 2026 04:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907539; cv=none; b=tI/jPULjIrF+AwiOZs61gFZnL2plpK5xLIxjMZBK+YCt38DSA78rLdqhNs2gNGE6CzokVXzpNNsCKZCkBaHAK5a7eVLh+9qlUUm+fKr7kCZnruVklpuutzkggxR5QxchqUFmXPKNeshJ2TuumMkjI0T/ianG1VPhV/iMTdIDcWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771907539; c=relaxed/simple; bh=N7MWqqsHu380Gb5Rc2gHv1QWehPH/HCcbhJPVIYlH10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hIzuEV0/9v0nPobv4b/2VjGjcI8e6aRwBaMtbvqhlOJBXW1xwJfqguH0HGmnUN8FGcuNueqOEFZTBS+lP9klCBq+li32cnhPfGKkaNdmPdJM6yD2rHseN5+h/Ka0/PogwYtuIxUWK5lkkWhNipor5gn3FZ/QVa0gnBuj+URFQiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Bs/RvXXG; arc=none smtp.client-ip=209.85.208.53 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bs/RvXXG" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-65c0e2cbde1so8722989a12.0 for ; Mon, 23 Feb 2026 20:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771907535; x=1772512335; 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=cuF+2ZeNg9MZpifVmvjXA4TLhrwpvQWcio7F8T9WLuI=; b=Bs/RvXXGz9U82DjHrLFLC15NX/WSXX0MnohT3EfibFpWWrHFP33WcEdZy1q8CAFiX/ RpzMweMIyxHVag81blg0rAWaA9DNsnHqkxBPKI7P/1WblNEtr1nQj/ykF49digucILxD eWKYSjidUO/KLx8FtNGjodipQAWBkLwK4aDjXudCxgmoJ6NAQHzJxXticcOixFtS3g4C D+ZGz5HdCOMI6DOV2XCbHuEA6GhqxCqAfcnC31lWo4clwSxF9vpB1cr5dgSyxJuVe/x6 j9n343T9RI/oMm02UPE/OqzNV6lNtklWQ+xd9+Y2YaRIRYzsG6H6MG9v96nKUV9AtfV/ 0SbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771907535; x=1772512335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cuF+2ZeNg9MZpifVmvjXA4TLhrwpvQWcio7F8T9WLuI=; b=IOoMgmWpu+TdRmWlv5pAy3jNx2sQQnAWiAa/Mvr4bKQWGRfaQTp2+dfObgD+umhi3R 06k5CGBcHCvTzP8luSnrO3oy7ro3K81qKIsiEJIkZNBBfMkUMU0L5wCwxP3gDCfn8qr2 RyEZPzRttNM/IqCBLtbdBz3AyTF8PcS102vpyWGYHV3yUGZBxte+dW35yOOIP98PXlb/ zah1VoMqCQxoFgowhReJXaAGjUxPNCBO61QH5e69Rk+WddgFNMAiHpBbi3imvu23GNmk 78jHZ84P2nIxVz05+XI9CqasVJz99RHvoS2m9zL1uGqKvvqV2sDA5RheJiGQ7AVBSzAb QZdQ== X-Forwarded-Encrypted: i=1; AJvYcCXA/pqnXDnLqx7ElbIC2fz3UkTdE/n6AsBHwUSJ3yrSivjcr1oA5o9NxijtrLVR1p1WGmVF1GLUKTYjjmw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5t15BE4U2ozBrI+H2KhzU4UOCcc9Of2TKASPKTCYk1ahbTUx1 zfwFXZhBkBjHnVw13CBBrHdJKEE6SMiuL+Qrfu3aEbFjyf9qHyVjH5VN X-Gm-Gg: AZuq6aKQHm0TEIJDoFiVdgMdN+NPiLeOfSuir/qwQ74kN7UzS9qEYMjPrqlDRSYHtzS AoUUntsi3mgIsLmarEl33/d7chHynK/sYJ09FBooSEKCoeQCAYKwE3L+Ix6hYAdA7GHGYCawrou QtditWeyjQ+IbTeVmpCDxezsS4Pfw85x/kb+hoQRW/satvSirLlTRehM7Pz73eVEDqoJPFg2VOO U1nNrtTyT2Lb3Uw1zPa23CK+wst2FhHk7hRK+J7msG2/S27One8ym7xYNO1hnm4rF4f5nARibHK MHWO0BnT9Be2DEgHUmup+JERrD5aN6Lj5KkgkyXKJyn030LPaSK2Q0abdv1U+qk0b8fFOImYDLi pF1j87Fc5P3TiN1ak965DV5LmGePr8lDU89cMQryHGNyxV5iaFr6ShkiqD4phiFKeo505L6B5tg AgvHUCMVXkdbV1+zVQooiSEZPnkjSMGnXCEhtwN9afn9s/u5igWbC3rHBDgG1XllKXYeYHpvPqN FLtY7Uk6wZnsGXnFVOJ/HKgYh5I7qt7yJALpoy/HwxZaj0vh/WKual0buyWuoBfIAGh4bmszIqM UVnZlZe1 X-Received: by 2002:a17:907:fdcb:b0:b8f:a03c:ac22 with SMTP id a640c23a62f3a-b9081b77ae4mr722929966b.42.1771907535344; Mon, 23 Feb 2026 20:32:15 -0800 (PST) Received: from cs-874966990260-default.europe-west4-b.c.i2f7e30109524dc12-tp.internal (206.242.32.34.bc.googleusercontent.com. [34.32.242.206]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b9088c8fc30sm371284466b.63.2026.02.23.20.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 20:32:14 -0800 (PST) From: Artem Lytkin To: FUJITA Tomonori , Andrew Lunn , Heiner Kallweit Cc: Trevor Gross , Russell King , Miguel Ojeda , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Lytkin Subject: [PATCH net-next v2 3/3] net: phy: add Rust reference driver for ET1011C Date: Tue, 24 Feb 2026 04:32:11 +0000 Message-ID: <20260224043211.1747-4-iprintercanon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260224043211.1747-1-iprintercanon@gmail.com> References: <20260223220504.2102-1-iprintercanon@gmail.com> <20260224043211.1747-1-iprintercanon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a Rust implementation of the LSI ET1011C PHY driver, equivalent to the existing C driver in drivers/net/phy/et1011c.c. The driver implements config_aneg and read_status callbacks using the Rust PHY abstraction. The Rust driver uses the new speed() getter to detect speed changes, only reconfiguring the TX FIFO depth and GMII interface when the negotiated speed actually changes. This matches the C driver behavior. The Rust driver can be selected via the ET1011C_RUST_PHY Kconfig option, following the same pattern as AX88796B_RUST_PHY. Signed-off-by: Artem Lytkin --- drivers/net/phy/Kconfig | 9 ++++ drivers/net/phy/Makefile | 6 ++- drivers/net/phy/et1011c_rust.rs | 75 +++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 drivers/net/phy/et1011c_rust.rs diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 7b73332a13d9..5271898a38f7 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -254,6 +254,15 @@ config LSI_ET1011C_PHY help Supports the LSI ET1011C PHY. =20 +config ET1011C_RUST_PHY + bool "Rust reference driver for LSI ET1011C PHY" + depends on RUST_PHYLIB_ABSTRACTIONS && LSI_ET1011C_PHY + help + Uses the Rust reference driver for LSI ET1011C PHY + (et1011c_rust.ko). The features and behavior are + equivalent to the C driver. Selecting this option builds + the Rust version instead of the C version. + config MARVELL_PHY tristate "Marvell Alaska PHYs" help diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 3a34917adea7..491469457a67 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -62,7 +62,11 @@ obj-$(CONFIG_DP83TG720_PHY) +=3D dp83tg720.o obj-$(CONFIG_FIXED_PHY) +=3D fixed_phy.o obj-$(CONFIG_ICPLUS_PHY) +=3D icplus.o obj-$(CONFIG_INTEL_XWAY_PHY) +=3D intel-xway.o -obj-$(CONFIG_LSI_ET1011C_PHY) +=3D et1011c.o +ifdef CONFIG_ET1011C_RUST_PHY + obj-$(CONFIG_LSI_ET1011C_PHY) +=3D et1011c_rust.o +else + obj-$(CONFIG_LSI_ET1011C_PHY) +=3D et1011c.o +endif obj-$(CONFIG_LXT_PHY) +=3D lxt.o obj-$(CONFIG_MARVELL_10G_PHY) +=3D marvell10g.o obj-$(CONFIG_MARVELL_PHY) +=3D marvell.o diff --git a/drivers/net/phy/et1011c_rust.rs b/drivers/net/phy/et1011c_rust= .rs new file mode 100644 index 000000000000..7b8ae3bf492c --- /dev/null +++ b/drivers/net/phy/et1011c_rust.rs @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0+ +// Copyright (C) 2026 Artem Lytkin + +//! Rust LSI ET1011C PHY driver +//! +//! C version of this driver: [`drivers/net/phy/et1011c.c`](./et1011c.c) + +use kernel::{ + net::phy::{self, reg::C22, DeviceId, Driver}, + prelude::*, + uapi, +}; + +kernel::module_phy_driver! { + drivers: [PhyET1011C], + device_table: [ + DeviceId::new_with_driver::() + ], + name: "rust_et1011c_phy", + authors: ["Artem Lytkin "], + description: "Rust LSI ET1011C PHY driver", + license: "GPL", +} + +const ET1011C_STATUS_REG: C22 =3D C22::vendor_specific::<0x1A>(); +const ET1011C_CONFIG_REG: C22 =3D C22::vendor_specific::<0x16>(); + +const ET1011C_SPEED_MASK: u16 =3D 0x0300; +const ET1011C_GIGABIT_SPEED: u16 =3D 0x0200; +const ET1011C_TX_FIFO_MASK: u16 =3D 0x3000; +const ET1011C_TX_FIFO_DEPTH_16: u16 =3D 0x1000; +const ET1011C_GMII_INTERFACE: u16 =3D 0x0002; +const ET1011C_SYS_CLK_EN: u16 =3D 0x0010; + +const BMCR_FULLDPLX: u16 =3D uapi::BMCR_FULLDPLX as u16; +const BMCR_SPEED100: u16 =3D uapi::BMCR_SPEED100 as u16; +const BMCR_SPEED1000: u16 =3D uapi::BMCR_SPEED1000 as u16; +const BMCR_ANENABLE: u16 =3D uapi::BMCR_ANENABLE as u16; +const BMCR_RESET: u16 =3D uapi::BMCR_RESET as u16; + +struct PhyET1011C; + +#[vtable] +impl Driver for PhyET1011C { + const NAME: &'static CStr =3D c"ET1011C"; + const PHY_DEVICE_ID: DeviceId =3D DeviceId::new_with_model_mask(0x0282= f014); + + fn config_aneg(dev: &mut phy::Device) -> Result { + let ctl =3D dev.read(C22::BMCR)?; + let ctl =3D ctl & !(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_SPEED1000= | BMCR_ANENABLE); + dev.write(C22::BMCR, ctl | BMCR_RESET)?; + dev.genphy_config_aneg() + } + + fn read_status(dev: &mut phy::Device) -> Result { + let old_speed =3D dev.speed(); + dev.genphy_read_status::()?; + + if old_speed !=3D dev.speed() { + let val =3D dev.read(ET1011C_STATUS_REG)?; + if (val & ET1011C_SPEED_MASK) =3D=3D ET1011C_GIGABIT_SPEED { + let cfg =3D dev.read(ET1011C_CONFIG_REG)?; + let cfg =3D cfg & !ET1011C_TX_FIFO_MASK; + dev.write( + ET1011C_CONFIG_REG, + cfg | ET1011C_GMII_INTERFACE + | ET1011C_SYS_CLK_EN + | ET1011C_TX_FIFO_DEPTH_16, + )?; + } + } + + Ok(0) + } +} --=20 2.43.0