nvethernet: support to read/write PHY reg with mdio-tool

Adds IOCTL support to read and write a PHY register

Bug 200512251

Change-Id: I43461e7654ca2aa648c978eeaeca12930871006c
Signed-off-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2080717
GVS: Gerrit_Virtual_Submit
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-by: Rakesh Goyal <rgoyal@nvidia.com>
Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com>
Reviewed-by: Ashutosh Jha <ajha@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Bhadram Varka
2019-03-25 10:48:04 +05:30
committed by Revanth Kumar Uppala
parent 6e9c58de03
commit f9904e66af

View File

@@ -1077,10 +1077,51 @@ static int ether_start_xmit(struct sk_buff *skb, struct net_device *ndev)
return NETDEV_TX_OK;
}
/**
* ether_ioctl - network stack IOCTL hook to driver
* @ndev: network device structure
* @rq: Interface request structure used for socket
* @cmd: IOCTL command code
*
* Algorithm:
* 1) Invokes MII API for phy read/write based on IOCTL command
*
* Dependencies: Ethernet interface need to be up.
*
* Protection: None.
*
* Return: 0 - success, negative value - failure.
*/
static int ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
int ret = -EOPNOTSUPP;
if (!netif_running(dev))
return -EINVAL;
switch (cmd) {
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
if (!dev->phydev)
return -EINVAL;
/* generic PHY MII ioctl interface */
ret = phy_mii_ioctl(dev->phydev, rq, cmd);
break;
default:
break;
}
return ret;
}
static const struct net_device_ops ether_netdev_ops = {
.ndo_open = ether_open,
.ndo_stop = ether_close,
.ndo_start_xmit = ether_start_xmit,
.ndo_do_ioctl = ether_ioctl,
};
/**