[PATCH net] microchip: lan865x: fix missing ndo_eth_ioctl handler to support PHY ioctl

Parthiban Veerasooran posted 1 patch 1 month, 1 week ago
drivers/net/ethernet/microchip/lan865x/lan865x.c | 10 ++++++++++
1 file changed, 10 insertions(+)
[PATCH net] microchip: lan865x: fix missing ndo_eth_ioctl handler to support PHY ioctl
Posted by Parthiban Veerasooran 1 month, 1 week ago
The LAN865x Ethernet driver is missing an .ndo_eth_ioctl implementation,
which is required to handle standard MII ioctl commands such as
SIOCGMIIREG and SIOCSMIIREG. These commands are used by userspace tools
(e.g., ethtool, mii-tool) to access and configure PHY registers.

This patch adds the lan865x_eth_ioctl() function to pass ioctl calls to
the PHY layer via phy_mii_ioctl() when the interface is up.

Without this handler, MII ioctl operations return -EINVAL, breaking PHY
diagnostics and configuration from userspace.

Fixes: 5cd2340cb6a3 ("microchip: lan865x: add driver support for Microchip's LAN865X MAC-PHY")
Signed-off-by: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
---
 drivers/net/ethernet/microchip/lan865x/lan865x.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/microchip/lan865x/lan865x.c b/drivers/net/ethernet/microchip/lan865x/lan865x.c
index dd436bdff0f8..09e6a0406350 100644
--- a/drivers/net/ethernet/microchip/lan865x/lan865x.c
+++ b/drivers/net/ethernet/microchip/lan865x/lan865x.c
@@ -314,12 +314,22 @@ static int lan865x_net_open(struct net_device *netdev)
 	return 0;
 }
 
+static int lan865x_eth_ioctl(struct net_device *netdev, struct ifreq *rq,
+			     int cmd)
+{
+	if (!netif_running(netdev))
+		return -EINVAL;
+
+	return phy_mii_ioctl(netdev->phydev, rq, cmd);
+}
+
 static const struct net_device_ops lan865x_netdev_ops = {
 	.ndo_open		= lan865x_net_open,
 	.ndo_stop		= lan865x_net_close,
 	.ndo_start_xmit		= lan865x_send_packet,
 	.ndo_set_rx_mode	= lan865x_set_multicast_list,
 	.ndo_set_mac_address	= lan865x_set_mac_address,
+	.ndo_eth_ioctl          = lan865x_eth_ioctl,
 };
 
 static int lan865x_probe(struct spi_device *spi)

base-commit: 62a2b3502573091dc5de3f9acd9e47f4b5aac9a1
-- 
2.34.1
Re: [PATCH net] microchip: lan865x: fix missing ndo_eth_ioctl handler to support PHY ioctl
Posted by Andrew Lunn 1 month, 1 week ago
On Thu, Aug 21, 2025 at 01:58:32PM +0530, Parthiban Veerasooran wrote:
> The LAN865x Ethernet driver is missing an .ndo_eth_ioctl implementation,
> which is required to handle standard MII ioctl commands such as
> SIOCGMIIREG and SIOCSMIIREG. These commands are used by userspace tools
> (e.g., ethtool, mii-tool) to access and configure PHY registers.
> 
> This patch adds the lan865x_eth_ioctl() function to pass ioctl calls to
> the PHY layer via phy_mii_ioctl() when the interface is up.
> 
> Without this handler, MII ioctl operations return -EINVAL, breaking PHY
> diagnostics and configuration from userspace.

I'm not sure this classes as a fix. This IOCTL is optional, not
mandatory. Returning EINVAL is valid behaviour. So for me, this is
just ongoing development work, adding more features to the driver.

Please submit to net-next.

    Andrew

---
pw-bot: cr
Re: [PATCH net] microchip: lan865x: fix missing ndo_eth_ioctl handler to support PHY ioctl
Posted by Parthiban.Veerasooran@microchip.com 1 month, 1 week ago
Hi Andrew,

Thank you for reviewing this patch.

On 22/08/25 5:47 am, Andrew Lunn wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Thu, Aug 21, 2025 at 01:58:32PM +0530, Parthiban Veerasooran wrote:
>> The LAN865x Ethernet driver is missing an .ndo_eth_ioctl implementation,
>> which is required to handle standard MII ioctl commands such as
>> SIOCGMIIREG and SIOCSMIIREG. These commands are used by userspace tools
>> (e.g., ethtool, mii-tool) to access and configure PHY registers.
>>
>> This patch adds the lan865x_eth_ioctl() function to pass ioctl calls to
>> the PHY layer via phy_mii_ioctl() when the interface is up.
>>
>> Without this handler, MII ioctl operations return -EINVAL, breaking PHY
>> diagnostics and configuration from userspace.
> 
> I'm not sure this classes as a fix. This IOCTL is optional, not
> mandatory. Returning EINVAL is valid behaviour. So for me, this is
> just ongoing development work, adding more features to the driver.
> 
> Please submit to net-next.
Sure I will submit it to net-next as it is a feature.

By the way, is there a possibility to submit or apply this patch to the 
older stable kernels as well, so that users on those versions can also 
benefit from this feature?

Best regards,
Parthiban V
> 
>      Andrew
> 
> ---
> pw-bot: cr

Re: [PATCH net] microchip: lan865x: fix missing ndo_eth_ioctl handler to support PHY ioctl
Posted by Andrew Lunn 1 month, 1 week ago
> By the way, is there a possibility to submit or apply this patch to the 
> older stable kernels as well, so that users on those versions can also 
> benefit from this feature?

This is the sort of patch the machine learning bot picks up for back
porting to stable. The Fixes: tag is only one indicator it looks for,
it being a one liner and the words in the commit message might trigger
it as well.

	Andrew
Re: [PATCH net] microchip: lan865x: fix missing ndo_eth_ioctl handler to support PHY ioctl
Posted by Parthiban.Veerasooran@microchip.com 1 month, 1 week ago
On 22/08/25 6:29 pm, Andrew Lunn wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
>> By the way, is there a possibility to submit or apply this patch to the
>> older stable kernels as well, so that users on those versions can also
>> benefit from this feature?
> 
> This is the sort of patch the machine learning bot picks up for back
> porting to stable. The Fixes: tag is only one indicator it looks for,
> it being a one liner and the words in the commit message might trigger
> it as well.
Thank you for the explanation. As per your suggestion, I’ve moved this 
feature patch to net-next, so I assume there’s no possibility of getting 
it into the older stable kernels, as it is not a fix—is that correct?

Best regards,
Parthiban V
> 
>          Andrew