diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2009-04-29 04:07:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-04-29 20:32:32 -0400 |
commit | 0f07c4ee8c800923ae7918c231532a9256233eed (patch) | |
tree | 659322e8607f681af12a43671b17c5b65f94f4d5 /drivers/net/cxgb3/cxgb3_main.c | |
parent | 23c3320cb039debfb94b27e8e9bfe26dd47692c3 (diff) |
cxgb3: Use generic MDIO definitions and mdio_mii_ioctl()
Compile-tested only.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cxgb3/cxgb3_main.c')
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 71 |
1 files changed, 13 insertions, 58 deletions
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index 7ea48414c6cb..0b87fee023f5 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/netdevice.h> | 37 | #include <linux/netdevice.h> |
38 | #include <linux/etherdevice.h> | 38 | #include <linux/etherdevice.h> |
39 | #include <linux/if_vlan.h> | 39 | #include <linux/if_vlan.h> |
40 | #include <linux/mii.h> | 40 | #include <linux/mdio.h> |
41 | #include <linux/sockios.h> | 41 | #include <linux/sockios.h> |
42 | #include <linux/workqueue.h> | 42 | #include <linux/workqueue.h> |
43 | #include <linux/proc_fs.h> | 43 | #include <linux/proc_fs.h> |
@@ -1593,7 +1593,7 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1593 | } | 1593 | } |
1594 | 1594 | ||
1595 | cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; | 1595 | cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; |
1596 | cmd->phy_address = p->phy.addr; | 1596 | cmd->phy_address = p->phy.mdio.prtad; |
1597 | cmd->transceiver = XCVR_EXTERNAL; | 1597 | cmd->transceiver = XCVR_EXTERNAL; |
1598 | cmd->autoneg = p->link_config.autoneg; | 1598 | cmd->autoneg = p->link_config.autoneg; |
1599 | cmd->maxtxpkt = 0; | 1599 | cmd->maxtxpkt = 0; |
@@ -2308,70 +2308,25 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
2308 | struct mii_ioctl_data *data = if_mii(req); | 2308 | struct mii_ioctl_data *data = if_mii(req); |
2309 | struct port_info *pi = netdev_priv(dev); | 2309 | struct port_info *pi = netdev_priv(dev); |
2310 | struct adapter *adapter = pi->adapter; | 2310 | struct adapter *adapter = pi->adapter; |
2311 | int ret, mmd; | ||
2312 | 2311 | ||
2313 | switch (cmd) { | 2312 | switch (cmd) { |
2314 | case SIOCGMIIPHY: | 2313 | case SIOCGMIIREG: |
2315 | data->phy_id = pi->phy.addr; | 2314 | case SIOCSMIIREG: |
2315 | /* Convert phy_id from older PRTAD/DEVAD format */ | ||
2316 | if (is_10G(adapter) && | ||
2317 | !mdio_phy_id_is_c45(data->phy_id) && | ||
2318 | (data->phy_id & 0x1f00) && | ||
2319 | !(data->phy_id & 0xe0e0)) | ||
2320 | data->phy_id = mdio_phy_id_c45(data->phy_id >> 8, | ||
2321 | data->phy_id & 0x1f); | ||
2316 | /* FALLTHRU */ | 2322 | /* FALLTHRU */ |
2317 | case SIOCGMIIREG:{ | 2323 | case SIOCGMIIPHY: |
2318 | u32 val; | 2324 | return mdio_mii_ioctl(&pi->phy.mdio, data, cmd); |
2319 | struct cphy *phy = &pi->phy; | ||
2320 | |||
2321 | if (!phy->mdio_read) | ||
2322 | return -EOPNOTSUPP; | ||
2323 | if (is_10G(adapter)) { | ||
2324 | mmd = data->phy_id >> 8; | ||
2325 | if (!mmd) | ||
2326 | mmd = MDIO_DEV_PCS; | ||
2327 | else if (mmd > MDIO_DEV_VEND2) | ||
2328 | return -EINVAL; | ||
2329 | |||
2330 | ret = | ||
2331 | phy->mdio_read(adapter, data->phy_id & 0x1f, | ||
2332 | mmd, data->reg_num, &val); | ||
2333 | } else | ||
2334 | ret = | ||
2335 | phy->mdio_read(adapter, data->phy_id & 0x1f, | ||
2336 | 0, data->reg_num & 0x1f, | ||
2337 | &val); | ||
2338 | if (!ret) | ||
2339 | data->val_out = val; | ||
2340 | break; | ||
2341 | } | ||
2342 | case SIOCSMIIREG:{ | ||
2343 | struct cphy *phy = &pi->phy; | ||
2344 | |||
2345 | if (!capable(CAP_NET_ADMIN)) | ||
2346 | return -EPERM; | ||
2347 | if (!phy->mdio_write) | ||
2348 | return -EOPNOTSUPP; | ||
2349 | if (is_10G(adapter)) { | ||
2350 | mmd = data->phy_id >> 8; | ||
2351 | if (!mmd) | ||
2352 | mmd = MDIO_DEV_PCS; | ||
2353 | else if (mmd > MDIO_DEV_VEND2) | ||
2354 | return -EINVAL; | ||
2355 | |||
2356 | ret = | ||
2357 | phy->mdio_write(adapter, | ||
2358 | data->phy_id & 0x1f, mmd, | ||
2359 | data->reg_num, | ||
2360 | data->val_in); | ||
2361 | } else | ||
2362 | ret = | ||
2363 | phy->mdio_write(adapter, | ||
2364 | data->phy_id & 0x1f, 0, | ||
2365 | data->reg_num & 0x1f, | ||
2366 | data->val_in); | ||
2367 | break; | ||
2368 | } | ||
2369 | case SIOCCHIOCTL: | 2325 | case SIOCCHIOCTL: |
2370 | return cxgb_extension_ioctl(dev, req->ifr_data); | 2326 | return cxgb_extension_ioctl(dev, req->ifr_data); |
2371 | default: | 2327 | default: |
2372 | return -EOPNOTSUPP; | 2328 | return -EOPNOTSUPP; |
2373 | } | 2329 | } |
2374 | return ret; | ||
2375 | } | 2330 | } |
2376 | 2331 | ||
2377 | static int cxgb_change_mtu(struct net_device *dev, int new_mtu) | 2332 | static int cxgb_change_mtu(struct net_device *dev, int new_mtu) |