aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet/be_ethtool.c
diff options
context:
space:
mode:
authorAjit Khaparde <ajitk@serverengines.com>2009-11-29 12:57:46 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-02 03:50:26 -0500
commit0dffc83e5b831df1df83dfe32a0c267347f9950b (patch)
treedad072dd1c206cdcb0e55ccfa92276a1bca54123 /drivers/net/benet/be_ethtool.c
parentb7b83ac39a177741a378d728d82e87de9b0a01a5 (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.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 3c05f2b99ab6..329560f9e543 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)
297 u8 mac_speed = 0, connector = 0; 297 u8 mac_speed = 0, connector = 0;
298 u16 link_speed = 0; 298 u16 link_speed = 0;
299 bool link_up = false; 299 bool link_up = false;
300 int status;
300 301
301 be_cmd_link_status_query(adapter, &link_up, &mac_speed, &link_speed); 302 if (adapter->link_speed < 0) {
303 status = be_cmd_link_status_query(adapter, &link_up,
304 &mac_speed, &link_speed);
305
306 /* link_speed is in units of 10 Mbps */
307 if (link_speed) {
308 ecmd->speed = link_speed*10;
309 } else {
310 switch (mac_speed) {
311 case PHY_LINK_SPEED_1GBPS:
312 ecmd->speed = SPEED_1000;
313 break;
314 case PHY_LINK_SPEED_10GBPS:
315 ecmd->speed = SPEED_10000;
316 break;
317 }
318 }
302 319
303 /* link_speed is in units of 10 Mbps */ 320 status = be_cmd_read_port_type(adapter, adapter->port_num,
304 if (link_speed) { 321 &connector);
305 ecmd->speed = link_speed*10; 322 switch (connector) {
306 } else { 323 case 7:
307 switch (mac_speed) { 324 ecmd->port = PORT_FIBRE;
308 case PHY_LINK_SPEED_1GBPS:
309 ecmd->speed = SPEED_1000;
310 break; 325 break;
311 case PHY_LINK_SPEED_10GBPS: 326 default:
312 ecmd->speed = SPEED_10000; 327 ecmd->port = PORT_TP;
313 break; 328 break;
314 } 329 }
330
331 /* Save for future use */
332 adapter->link_speed = ecmd->speed;
333 adapter->port_type = ecmd->port;
334 } else {
335 ecmd->speed = adapter->link_speed;
336 ecmd->port = adapter->port_type;
315 } 337 }
338
316 ecmd->duplex = DUPLEX_FULL; 339 ecmd->duplex = DUPLEX_FULL;
317 ecmd->autoneg = AUTONEG_DISABLE; 340 ecmd->autoneg = AUTONEG_DISABLE;
318 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP); 341 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP);
319
320 be_cmd_read_port_type(adapter, adapter->port_num, &connector);
321 switch (connector) {
322 case 7:
323 ecmd->port = PORT_FIBRE;
324 break;
325 default:
326 ecmd->port = PORT_TP;
327 break;
328 }
329
330 ecmd->phy_address = adapter->port_num; 342 ecmd->phy_address = adapter->port_num;
331 ecmd->transceiver = XCVR_INTERNAL; 343 ecmd->transceiver = XCVR_INTERNAL;
332 344