diff options
author | Ajit Khaparde <ajitk@serverengines.com> | 2009-11-29 17:57:46 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-02 00:50:26 -0800 |
commit | 0dffc83e5b831df1df83dfe32a0c267347f9950b (patch) | |
tree | dad072dd1c206cdcb0e55ccfa92276a1bca54123 /drivers/net/benet/be_ethtool.c | |
parent | b7b83ac39a177741a378d728d82e87de9b0a01a5 (diff) |
be2net: fix unnecessary access to hardware to get link, port info
Every time while doing ethtool->get_settings we are accessing
the hardware to get link status and port information.
This is not necessary. We now use the cached copy for this info
and update it when the link status changes.
From: Suresh R <sureshr@serverengines.com>
Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet/be_ethtool.c')
-rw-r--r-- | drivers/net/benet/be_ethtool.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c index 3c05f2b99ab..329560f9e54 100644 --- a/drivers/net/benet/be_ethtool.c +++ b/drivers/net/benet/be_ethtool.c @@ -297,36 +297,48 @@ static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) u8 mac_speed = 0, connector = 0; u16 link_speed = 0; bool link_up = false; + int status; - be_cmd_link_status_query(adapter, &link_up, &mac_speed, &link_speed); + if (adapter->link_speed < 0) { + status = be_cmd_link_status_query(adapter, &link_up, + &mac_speed, &link_speed); + + /* link_speed is in units of 10 Mbps */ + if (link_speed) { + ecmd->speed = link_speed*10; + } else { + switch (mac_speed) { + case PHY_LINK_SPEED_1GBPS: + ecmd->speed = SPEED_1000; + break; + case PHY_LINK_SPEED_10GBPS: + ecmd->speed = SPEED_10000; + break; + } + } - /* link_speed is in units of 10 Mbps */ - if (link_speed) { - ecmd->speed = link_speed*10; - } else { - switch (mac_speed) { - case PHY_LINK_SPEED_1GBPS: - ecmd->speed = SPEED_1000; + status = be_cmd_read_port_type(adapter, adapter->port_num, + &connector); + switch (connector) { + case 7: + ecmd->port = PORT_FIBRE; break; - case PHY_LINK_SPEED_10GBPS: - ecmd->speed = SPEED_10000; + default: + ecmd->port = PORT_TP; break; } + + /* Save for future use */ + adapter->link_speed = ecmd->speed; + adapter->port_type = ecmd->port; + } else { + ecmd->speed = adapter->link_speed; + ecmd->port = adapter->port_type; } + ecmd->duplex = DUPLEX_FULL; ecmd->autoneg = AUTONEG_DISABLE; ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP); - - be_cmd_read_port_type(adapter, adapter->port_num, &connector); - switch (connector) { - case 7: - ecmd->port = PORT_FIBRE; - break; - default: - ecmd->port = PORT_TP; - break; - } - ecmd->phy_address = adapter->port_num; ecmd->transceiver = XCVR_INTERNAL; |