Message ID | 361f63095be92df10e8e953af3b981cdac58d98e.1576520432.git.richardcochran@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: axienet: Fix random driver issues. | expand |
> -----Original Message----- > From: Richard Cochran <richardcochran@gmail.com> > Sent: Tuesday, December 17, 2019 12:03 AM > To: netdev@vger.kernel.org > Cc: linux-arm-kernel@lists.infradead.org; David Miller > <davem@davemloft.net>; Michal Simek <michals@xilinx.com>; Radhey > Shyam Pandey <radheys@xilinx.com> > Subject: [PATCH net-next 3/3] net: axienet: Pass ioctls to the phy. > > In order to allow PHY drivers to handle ioctls, the MAC driver must pass > the calls through. However, the axienet driver does not support ioctls > at all. This patch fixes the issue by handing off the invocations to the > PHY appropriately. > > Signed-off-by: Richard Cochran <richardcochran@gmail.com> > --- > .../net/ethernet/xilinx/xilinx_axienet_main.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > index 05fa7371c39a..d0b996f220f5 100644 > --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > @@ -1067,6 +1067,23 @@ static int axienet_change_mtu(struct net_device > *ndev, int new_mtu) > return 0; > } > > +static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) > +{ > + if (!netif_running(dev)) > + return -EINVAL; > + > + switch (cmd) { > + case SIOCGMIIPHY: > + case SIOCGMIIREG: > + case SIOCSMIIREG: > + case SIOCSHWTSTAMP: For hw timestamp we are passing the request to phy? > + case SIOCGHWTSTAMP: > + return phy_mii_ioctl(dev->phydev, rq, cmd); Driver migrated to phylink so now we have to use phylink_mii_ioctl. > + default: > + return -EOPNOTSUPP; > + } > +} > + > #ifdef CONFIG_NET_POLL_CONTROLLER > /** > * axienet_poll_controller - Axi Ethernet poll mechanism. > @@ -1095,6 +1112,7 @@ static const struct net_device_ops > axienet_netdev_ops = { > .ndo_set_mac_address = netdev_set_mac_address, > .ndo_validate_addr = eth_validate_addr, > .ndo_set_rx_mode = axienet_set_multicast_list, > + .ndo_do_ioctl = axienet_ioctl, > #ifdef CONFIG_NET_POLL_CONTROLLER > .ndo_poll_controller = axienet_poll_controller, > #endif > -- > 2.20.1
> +static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) > +{ > + if (!netif_running(dev)) > + return -EINVAL; > + > + switch (cmd) { > + case SIOCGMIIPHY: > + case SIOCGMIIREG: > + case SIOCSMIIREG: > + case SIOCSHWTSTAMP: > + case SIOCGHWTSTAMP: > + return phy_mii_ioctl(dev->phydev, rq, cmd); > + default: > + return -EOPNOTSUPP; > + } > +} Hi Richard You don't need to be conditional. phy_mii_ioctl() and phylink_mii_ioctl() will return -EOPNOTSUPP for anything it does not support. Andrew
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 05fa7371c39a..d0b996f220f5 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1067,6 +1067,23 @@ static int axienet_change_mtu(struct net_device *ndev, int new_mtu) return 0; } +static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + if (!netif_running(dev)) + return -EINVAL; + + switch (cmd) { + case SIOCGMIIPHY: + case SIOCGMIIREG: + case SIOCSMIIREG: + case SIOCSHWTSTAMP: + case SIOCGHWTSTAMP: + return phy_mii_ioctl(dev->phydev, rq, cmd); + default: + return -EOPNOTSUPP; + } +} + #ifdef CONFIG_NET_POLL_CONTROLLER /** * axienet_poll_controller - Axi Ethernet poll mechanism. @@ -1095,6 +1112,7 @@ static const struct net_device_ops axienet_netdev_ops = { .ndo_set_mac_address = netdev_set_mac_address, .ndo_validate_addr = eth_validate_addr, .ndo_set_rx_mode = axienet_set_multicast_list, + .ndo_do_ioctl = axienet_ioctl, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = axienet_poll_controller, #endif
In order to allow PHY drivers to handle ioctls, the MAC driver must pass the calls through. However, the axienet driver does not support ioctls at all. This patch fixes the issue by handing off the invocations to the PHY appropriately. Signed-off-by: Richard Cochran <richardcochran@gmail.com> --- .../net/ethernet/xilinx/xilinx_axienet_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)