aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuval Mintz <yuvalmin@broadcom.com>2013-05-27 00:08:31 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-28 00:41:49 -0400
commit3fb43eb20aec3f5ceed5813a035f200dafb51257 (patch)
treea6233da1138995d17b87d39d48ca7d07fb28c473
parentb030ed2fdc8a396dba71e4d550236a0f1bb38b40 (diff)
bnx2x: Change to D3hot only on removal
This changes the PCI power management scheme of the bnx2x driver to be similar to those of most network drivers - the driver will now changes the power state into D3hot whenever the driver will be removed, instead of whenever an interface is unloaded. This change enables the driver to access its eeprom via ethtool callbacks even when interfaces are unloaded (such access requires the function to be in D0active). Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com> Signed-off-by: Ariel Elior <ariele@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c31
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c3
2 files changed, 24 insertions, 10 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 32aa88f520dc..263950cddfe2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -1381,12 +1381,28 @@ static int bnx2x_nvram_read32(struct bnx2x *bp, u32 offset, u32 *buf,
1381 return rc; 1381 return rc;
1382} 1382}
1383 1383
1384static bool bnx2x_is_nvm_accessible(struct bnx2x *bp)
1385{
1386 int rc = 1;
1387 u16 pm = 0;
1388 struct net_device *dev = pci_get_drvdata(bp->pdev);
1389
1390 if (bp->pm_cap)
1391 rc = pci_read_config_word(bp->pdev,
1392 bp->pm_cap + PCI_PM_CTRL, &pm);
1393
1394 if ((rc && !netif_running(dev)) || (!rc && ((pm & PCI_D0) != PCI_D0)))
1395 return false;
1396
1397 return true;
1398}
1399
1384static int bnx2x_get_eeprom(struct net_device *dev, 1400static int bnx2x_get_eeprom(struct net_device *dev,
1385 struct ethtool_eeprom *eeprom, u8 *eebuf) 1401 struct ethtool_eeprom *eeprom, u8 *eebuf)
1386{ 1402{
1387 struct bnx2x *bp = netdev_priv(dev); 1403 struct bnx2x *bp = netdev_priv(dev);
1388 1404
1389 if (!netif_running(dev)) { 1405 if (!bnx2x_is_nvm_accessible(bp)) {
1390 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 1406 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
1391 "cannot access eeprom when the interface is down\n"); 1407 "cannot access eeprom when the interface is down\n");
1392 return -EAGAIN; 1408 return -EAGAIN;
@@ -1411,7 +1427,7 @@ static int bnx2x_get_module_eeprom(struct net_device *dev,
1411 u8 *user_data = data; 1427 u8 *user_data = data;
1412 unsigned int start_addr = ee->offset, xfer_size = 0; 1428 unsigned int start_addr = ee->offset, xfer_size = 0;
1413 1429
1414 if (!netif_running(dev)) { 1430 if (!bnx2x_is_nvm_accessible(bp)) {
1415 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 1431 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
1416 "cannot access eeprom when the interface is down\n"); 1432 "cannot access eeprom when the interface is down\n");
1417 return -EAGAIN; 1433 return -EAGAIN;
@@ -1474,7 +1490,7 @@ static int bnx2x_get_module_info(struct net_device *dev,
1474 int phy_idx, rc; 1490 int phy_idx, rc;
1475 u8 sff8472_comp, diag_type; 1491 u8 sff8472_comp, diag_type;
1476 1492
1477 if (!netif_running(dev)) { 1493 if (!bnx2x_is_nvm_accessible(bp)) {
1478 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 1494 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
1479 "cannot access eeprom when the interface is down\n"); 1495 "cannot access eeprom when the interface is down\n");
1480 return -EAGAIN; 1496 return -EAGAIN;
@@ -1676,7 +1692,8 @@ static int bnx2x_set_eeprom(struct net_device *dev,
1676 int port = BP_PORT(bp); 1692 int port = BP_PORT(bp);
1677 int rc = 0; 1693 int rc = 0;
1678 u32 ext_phy_config; 1694 u32 ext_phy_config;
1679 if (!netif_running(dev)) { 1695
1696 if (!bnx2x_is_nvm_accessible(bp)) {
1680 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 1697 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
1681 "cannot access eeprom when the interface is down\n"); 1698 "cannot access eeprom when the interface is down\n");
1682 return -EAGAIN; 1699 return -EAGAIN;
@@ -2173,7 +2190,7 @@ static int bnx2x_test_registers(struct bnx2x *bp)
2173 { BNX2X_CHIP_MASK_ALL, 0xffffffff, 0, 0x00000000 } 2190 { BNX2X_CHIP_MASK_ALL, 0xffffffff, 0, 0x00000000 }
2174 }; 2191 };
2175 2192
2176 if (!netif_running(bp->dev)) { 2193 if (!bnx2x_is_nvm_accessible(bp)) {
2177 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 2194 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
2178 "cannot access eeprom when the interface is down\n"); 2195 "cannot access eeprom when the interface is down\n");
2179 return rc; 2196 return rc;
@@ -2277,7 +2294,7 @@ static int bnx2x_test_memory(struct bnx2x *bp)
2277 { NULL, 0xffffffff, {0, 0, 0, 0} } 2294 { NULL, 0xffffffff, {0, 0, 0, 0} }
2278 }; 2295 };
2279 2296
2280 if (!netif_running(bp->dev)) { 2297 if (!bnx2x_is_nvm_accessible(bp)) {
2281 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 2298 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
2282 "cannot access eeprom when the interface is down\n"); 2299 "cannot access eeprom when the interface is down\n");
2283 return rc; 2300 return rc;
@@ -3140,7 +3157,7 @@ static int bnx2x_set_phys_id(struct net_device *dev,
3140{ 3157{
3141 struct bnx2x *bp = netdev_priv(dev); 3158 struct bnx2x *bp = netdev_priv(dev);
3142 3159
3143 if (!netif_running(dev)) { 3160 if (!bnx2x_is_nvm_accessible(bp)) {
3144 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, 3161 DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
3145 "cannot access eeprom when the interface is down\n"); 3162 "cannot access eeprom when the interface is down\n");
3146 return -EAGAIN; 3163 return -EAGAIN;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 13f814485a36..f6d0e209c44e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -11643,9 +11643,6 @@ static int bnx2x_close(struct net_device *dev)
11643 /* Unload the driver, release IRQs */ 11643 /* Unload the driver, release IRQs */
11644 bnx2x_nic_unload(bp, UNLOAD_CLOSE, false); 11644 bnx2x_nic_unload(bp, UNLOAD_CLOSE, false);
11645 11645
11646 /* Power off */
11647 bnx2x_set_power_state(bp, PCI_D3hot);
11648
11649 return 0; 11646 return 0;
11650} 11647}
11651 11648