* [PATCH net-next 0/6] bnx2x: enhancement patch series
@ 2013-05-27 14:08 Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 1/6] bnx2x: Zero VFs starting MACs Yuval Mintz
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Yuval Mintz @ 2013-05-27 14:08 UTC (permalink / raw)
To: davem, netdev; +Cc: eilong, ariele
Hi Dave,
This series contains several enhancements, mainly the implementation of the
PCI shutdown callback which improves the bnx2x support in un-orderly shutdowns,
and following that a change in the driver's power scheme which lowers PCI power
state only when driver is removed (and as a result enable eeprom access on
unloaded interfaces).
Please consider applying these patches to `net-next'.
Thanks,
Yuval Mintz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 1/6] bnx2x: Zero VFs starting MACs
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
@ 2013-05-27 14:08 ` Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 2/6] bnx2x: Add and correct PCI link speed prints Yuval Mintz
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yuval Mintz @ 2013-05-27 14:08 UTC (permalink / raw)
To: davem, netdev; +Cc: eilong, ariele, Yuval Mintz
From: Ariel Elior <ariele@broadcom.com>
Hypervisor/Supervisor should set the VF's MAC prior to its load;
Using a randomly generated MAC as a default is a bad practice.
Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 7ed9cdf..80982c3 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -11406,7 +11406,7 @@ static int bnx2x_init_bp(struct bnx2x *bp)
if (rc)
return rc;
} else {
- random_ether_addr(bp->dev->dev_addr);
+ eth_zero_addr(bp->dev->dev_addr);
}
bnx2x_set_modes_bitmap(bp);
@@ -11865,6 +11865,10 @@ static int bnx2x_validate_addr(struct net_device *dev)
{
struct bnx2x *bp = netdev_priv(dev);
+ /* query the bulletin board for mac address configured by the PF */
+ if (IS_VF(bp))
+ bnx2x_sample_bulletin(bp);
+
if (!bnx2x_is_valid_ether_addr(bp, dev->dev_addr)) {
BNX2X_ERR("Non-valid Ethernet address\n");
return -EADDRNOTAVAIL;
--
1.8.1.227.g44fe835
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/6] bnx2x: Add and correct PCI link speed prints
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 1/6] bnx2x: Zero VFs starting MACs Yuval Mintz
@ 2013-05-27 14:08 ` Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 3/6] bnx2x: Ack unknown VF messages Yuval Mintz
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yuval Mintz @ 2013-05-27 14:08 UTC (permalink / raw)
To: davem, netdev; +Cc: eilong, ariele, Dmitry Kravkov, Yuval Mintz
From: Dmitry Kravkov <dmitry@broadcom.com>
This adds the print of the PCI gen3 link speed (8GHz), as well as correcting
the same print for 57712 boards (the print erroneously showed a 2.5GHz speed).
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 5 +++
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 40 +++++++++++++++---------
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 946450d..47b06fc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -2342,4 +2342,9 @@ enum {
#define NUM_MACS 8
+enum bnx2x_pci_bus_speed {
+ BNX2X_PCI_LINK_SPEED_2500 = 2500,
+ BNX2X_PCI_LINK_SPEED_5000 = 5000,
+ BNX2X_PCI_LINK_SPEED_8000 = 8000
+};
#endif /* bnx2x.h */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 80982c3..04fa510 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -12111,15 +12111,26 @@ err_out:
return rc;
}
-static void bnx2x_get_pcie_width_speed(struct bnx2x *bp, int *width, int *speed)
+static void bnx2x_get_pcie_width_speed(struct bnx2x *bp, int *width,
+ enum bnx2x_pci_bus_speed *speed)
{
- u32 val = 0;
+ u32 link_speed, val = 0;
pci_read_config_dword(bp->pdev, PCICFG_LINK_CONTROL, &val);
*width = (val & PCICFG_LINK_WIDTH) >> PCICFG_LINK_WIDTH_SHIFT;
- /* return value of 1=2.5GHz 2=5GHz */
- *speed = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT;
+ link_speed = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT;
+
+ switch (link_speed) {
+ case 3:
+ *speed = BNX2X_PCI_LINK_SPEED_8000;
+ break;
+ case 2:
+ *speed = BNX2X_PCI_LINK_SPEED_5000;
+ break;
+ default:
+ *speed = BNX2X_PCI_LINK_SPEED_2500;
+ }
}
static int bnx2x_check_firmware(struct bnx2x *bp)
@@ -12482,7 +12493,8 @@ static int bnx2x_init_one(struct pci_dev *pdev,
{
struct net_device *dev = NULL;
struct bnx2x *bp;
- int pcie_width, pcie_speed;
+ int pcie_width;
+ enum bnx2x_pci_bus_speed pcie_speed;
int rc, max_non_def_sbs;
int rx_count, tx_count, rss_count, doorbell_size;
int max_cos_est;
@@ -12634,15 +12646,15 @@ static int bnx2x_init_one(struct pci_dev *pdev,
BNX2X_DEV_INFO("got pcie width %d and speed %d\n",
pcie_width, pcie_speed);
- BNX2X_DEV_INFO(
- "%s (%c%d) PCI-E x%d %s found at mem %lx, IRQ %d, node addr %pM\n",
- board_info[ent->driver_data].name,
- (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4),
- pcie_width,
- ((!CHIP_IS_E2(bp) && pcie_speed == 2) ||
- (CHIP_IS_E2(bp) && pcie_speed == 1)) ?
- "5GHz (Gen2)" : "2.5GHz",
- dev->base_addr, bp->pdev->irq, dev->dev_addr);
+ BNX2X_DEV_INFO("%s (%c%d) PCI-E x%d %s found at mem %lx, IRQ %d, node addr %pM\n",
+ board_info[ent->driver_data].name,
+ (CHIP_REV(bp) >> 12) + 'A', (CHIP_METAL(bp) >> 4),
+ pcie_width,
+ pcie_speed == BNX2X_PCI_LINK_SPEED_2500 ? "2.5GHz" :
+ pcie_speed == BNX2X_PCI_LINK_SPEED_5000 ? "5.0GHz" :
+ pcie_speed == BNX2X_PCI_LINK_SPEED_8000 ? "8.0GHz" :
+ "Unknown",
+ dev->base_addr, bp->pdev->irq, dev->dev_addr);
return 0;
--
1.8.1.227.g44fe835
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/6] bnx2x: Ack unknown VF messages
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 1/6] bnx2x: Zero VFs starting MACs Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 2/6] bnx2x: Add and correct PCI link speed prints Yuval Mintz
@ 2013-05-27 14:08 ` Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 4/6] bnx2x: Count number of possible FCoE interfaces Yuval Mintz
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yuval Mintz @ 2013-05-27 14:08 UTC (permalink / raw)
To: davem, netdev; +Cc: eilong, ariele, Yuval Mintz
From: Ariel Elior <ariele@broadcom.com>
A PF should ack the firmware when receiving unknown messages through the VF's
mailbox. This prevents the VF mailbox from being stuck in case of a VF sending
a message unknown to the PF (e.g. VF with more advanced version).
Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 928b074..2826066 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -1605,8 +1605,11 @@ static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
bnx2x_vf_mbx_resp(bp, vf);
} else {
/* can't send a response since this VF is unknown to us
- * just unlock the channel and be done with.
+ * just ack the FW to release the mailbox and unlock
+ * the channel.
*/
+ storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
+ mmiowb();
bnx2x_unlock_vf_pf_channel(bp, vf,
mbx->first_tlv.tl.type);
}
--
1.8.1.227.g44fe835
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 4/6] bnx2x: Count number of possible FCoE interfaces
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
` (2 preceding siblings ...)
2013-05-27 14:08 ` [PATCH net-next 3/6] bnx2x: Ack unknown VF messages Yuval Mintz
@ 2013-05-27 14:08 ` Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 5/6] bnx2x: Implement PCI shutdown Yuval Mintz
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yuval Mintz @ 2013-05-27 14:08 UTC (permalink / raw)
To: davem, netdev
Cc: eilong, ariele, Dmitry Kravkov, Bhanu Prakash Gollapudi,
Yuval Mintz
From: Dmitry Kravkov <dmitry@broadcom.com>
Commit 0eb43b4bb081a1a22574daab9c05286a600dd7fe
"bnx2x, bnx2fc: Use per port max exchange resources" has changed the number
of available FCoE exchanges, even in scenarios when some of the functions has
no FCoE support; This needlessly degraded the available resources.
Remedy this by calculating the maximal number of functions that may actually
utilize said connection.
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
CC: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 51 ++++++++++++++++++++++--
1 file changed, 48 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 04fa510..0a3bb53 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -10795,12 +10795,56 @@ static void bnx2x_get_ext_wwn_info(struct bnx2x *bp, int func)
bp->cnic_eth_dev.fcoe_wwn_node_name_lo =
MF_CFG_RD(bp, func_ext_config[func].fcoe_wwn_node_name_lower);
}
+
+static int bnx2x_shared_fcoe_funcs(struct bnx2x *bp)
+{
+ u8 count = 0;
+
+ if (IS_MF(bp)) {
+ u8 fid;
+
+ /* iterate over absolute function ids for this path: */
+ for (fid = BP_PATH(bp); fid < E2_FUNC_MAX * 2; fid += 2) {
+ if (IS_MF_SD(bp)) {
+ u32 cfg = MF_CFG_RD(bp,
+ func_mf_config[fid].config);
+
+ if (!(cfg & FUNC_MF_CFG_FUNC_HIDE) &&
+ ((cfg & FUNC_MF_CFG_PROTOCOL_MASK) ==
+ FUNC_MF_CFG_PROTOCOL_FCOE))
+ count++;
+ } else {
+ u32 cfg = MF_CFG_RD(bp,
+ func_ext_config[fid].
+ func_cfg);
+
+ if ((cfg & MACP_FUNC_CFG_FLAGS_ENABLED) &&
+ (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD))
+ count++;
+ }
+ }
+ } else { /* SF */
+ int port, port_cnt = CHIP_MODE_IS_4_PORT(bp) ? 2 : 1;
+
+ for (port = 0; port < port_cnt; port++) {
+ u32 lic = SHMEM_RD(bp,
+ drv_lic_key[port].max_fcoe_conn) ^
+ FW_ENCODE_32BIT_PATTERN;
+ if (lic)
+ count++;
+ }
+ }
+
+ return count;
+}
+
static void bnx2x_get_fcoe_info(struct bnx2x *bp)
{
int port = BP_PORT(bp);
int func = BP_ABS_FUNC(bp);
u32 max_fcoe_conn = FW_ENCODE_32BIT_PATTERN ^ SHMEM_RD(bp,
drv_lic_key[port].max_fcoe_conn);
+ u8 num_fcoe_func = bnx2x_shared_fcoe_funcs(bp);
if (!CNIC_SUPPORT(bp)) {
bp->flags |= NO_FCOE_FLAG;
@@ -10814,9 +10858,10 @@ static void bnx2x_get_fcoe_info(struct bnx2x *bp)
/* Calculate the number of maximum allowed FCoE tasks */
bp->cnic_eth_dev.max_fcoe_exchanges = MAX_NUM_FCOE_TASKS_PER_ENGINE;
- if (IS_MF(bp) || CHIP_MODE_IS_4_PORT(bp))
- bp->cnic_eth_dev.max_fcoe_exchanges /=
- MAX_FCOE_FUNCS_PER_ENGINE;
+
+ /* check if FCoE resources must be shared between different functions */
+ if (num_fcoe_func)
+ bp->cnic_eth_dev.max_fcoe_exchanges /= num_fcoe_func;
/* Read the WWN: */
if (!IS_MF(bp)) {
--
1.8.1.227.g44fe835
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 5/6] bnx2x: Implement PCI shutdown
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
` (3 preceding siblings ...)
2013-05-27 14:08 ` [PATCH net-next 4/6] bnx2x: Count number of possible FCoE interfaces Yuval Mintz
@ 2013-05-27 14:08 ` Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 6/6] bnx2x: Change to D3hot only on removal Yuval Mintz
2013-05-28 4:42 ` [PATCH net-next 0/6] bnx2x: enhancement patch series David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Yuval Mintz @ 2013-05-27 14:08 UTC (permalink / raw)
To: davem, netdev; +Cc: eilong, ariele, Yuval Mintz
Implement the PCI shutdown callback to support un-orderly shutdown, i.e.,
shutdowns in which the remove callback will not be called.
Due to the lack of this functionality, when an un-orderly shutdown occurred,
it was possible for wake-on-lan to remain disabled.
This is now fixed as the callback introduces the correct place in which
`system_state' can be queried and wake-on-lan be configured accordingly.
Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 71 ++++++++++++++++++++----
1 file changed, 59 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 0a3bb53..13f8144 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -12721,17 +12721,11 @@ init_one_exit:
return rc;
}
-static void bnx2x_remove_one(struct pci_dev *pdev)
+static void __bnx2x_remove(struct pci_dev *pdev,
+ struct net_device *dev,
+ struct bnx2x *bp,
+ bool remove_netdev)
{
- struct net_device *dev = pci_get_drvdata(pdev);
- struct bnx2x *bp;
-
- if (!dev) {
- dev_err(&pdev->dev, "BAD net device from bnx2x_init_one\n");
- return;
- }
- bp = netdev_priv(dev);
-
/* Delete storage MAC address */
if (!NO_FCOE(bp)) {
rtnl_lock();
@@ -12744,7 +12738,15 @@ static void bnx2x_remove_one(struct pci_dev *pdev)
bnx2x_dcbnl_update_applist(bp, true);
#endif
- unregister_netdev(dev);
+ /* Close the interface - either directly or implicitly */
+ if (remove_netdev) {
+ unregister_netdev(dev);
+ } else {
+ rtnl_lock();
+ if (netif_running(dev))
+ bnx2x_close(dev);
+ rtnl_unlock();
+ }
/* Power on: we can't let PCI layer write to us while we are in D3 */
if (IS_PF(bp))
@@ -12766,6 +12768,12 @@ static void bnx2x_remove_one(struct pci_dev *pdev)
if (IS_VF(bp))
bnx2x_vfpf_release(bp);
+ /* Assumes no further PCIe PM changes will occur */
+ if (system_state == SYSTEM_POWER_OFF) {
+ pci_wake_from_d3(pdev, bp->wol);
+ pci_set_power_state(pdev, PCI_D3hot);
+ }
+
if (bp->regview)
iounmap(bp->regview);
@@ -12780,7 +12788,8 @@ static void bnx2x_remove_one(struct pci_dev *pdev)
}
bnx2x_free_mem_bp(bp);
- free_netdev(dev);
+ if (remove_netdev)
+ free_netdev(dev);
if (atomic_read(&pdev->enable_cnt) == 1)
pci_release_regions(pdev);
@@ -12789,6 +12798,20 @@ static void bnx2x_remove_one(struct pci_dev *pdev)
pci_set_drvdata(pdev, NULL);
}
+static void bnx2x_remove_one(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2x *bp;
+
+ if (!dev) {
+ dev_err(&pdev->dev, "BAD net device from bnx2x_init_one\n");
+ return;
+ }
+ bp = netdev_priv(dev);
+
+ __bnx2x_remove(pdev, dev, bp, true);
+}
+
static int bnx2x_eeh_nic_unload(struct bnx2x *bp)
{
bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT;
@@ -12968,6 +12991,29 @@ static const struct pci_error_handlers bnx2x_err_handler = {
.resume = bnx2x_io_resume,
};
+static void bnx2x_shutdown(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ struct bnx2x *bp;
+
+ if (!dev)
+ return;
+
+ bp = netdev_priv(dev);
+ if (!bp)
+ return;
+
+ rtnl_lock();
+ netif_device_detach(dev);
+ rtnl_unlock();
+
+ /* Don't remove the netdevice, as there are scenarios which will cause
+ * the kernel to hang, e.g., when trying to remove bnx2i while the
+ * rootfs is mounted from SAN.
+ */
+ __bnx2x_remove(pdev, dev, bp, false);
+}
+
static struct pci_driver bnx2x_pci_driver = {
.name = DRV_MODULE_NAME,
.id_table = bnx2x_pci_tbl,
@@ -12979,6 +13025,7 @@ static struct pci_driver bnx2x_pci_driver = {
#ifdef CONFIG_BNX2X_SRIOV
.sriov_configure = bnx2x_sriov_configure,
#endif
+ .shutdown = bnx2x_shutdown,
};
static int __init bnx2x_init(void)
--
1.8.1.227.g44fe835
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 6/6] bnx2x: Change to D3hot only on removal
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
` (4 preceding siblings ...)
2013-05-27 14:08 ` [PATCH net-next 5/6] bnx2x: Implement PCI shutdown Yuval Mintz
@ 2013-05-27 14:08 ` Yuval Mintz
2013-05-28 4:42 ` [PATCH net-next 0/6] bnx2x: enhancement patch series David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Yuval Mintz @ 2013-05-27 14:08 UTC (permalink / raw)
To: davem, netdev; +Cc: eilong, ariele, Yuval Mintz
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>
---
.../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 31 +++++++++++++++++-----
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 ---
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 32aa88f..263950c 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,
return rc;
}
+static bool bnx2x_is_nvm_accessible(struct bnx2x *bp)
+{
+ int rc = 1;
+ u16 pm = 0;
+ struct net_device *dev = pci_get_drvdata(bp->pdev);
+
+ if (bp->pm_cap)
+ rc = pci_read_config_word(bp->pdev,
+ bp->pm_cap + PCI_PM_CTRL, &pm);
+
+ if ((rc && !netif_running(dev)) || (!rc && ((pm & PCI_D0) != PCI_D0)))
+ return false;
+
+ return true;
+}
+
static int bnx2x_get_eeprom(struct net_device *dev,
struct ethtool_eeprom *eeprom, u8 *eebuf)
{
struct bnx2x *bp = netdev_priv(dev);
- if (!netif_running(dev)) {
+ if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n");
return -EAGAIN;
@@ -1411,7 +1427,7 @@ static int bnx2x_get_module_eeprom(struct net_device *dev,
u8 *user_data = data;
unsigned int start_addr = ee->offset, xfer_size = 0;
- if (!netif_running(dev)) {
+ if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n");
return -EAGAIN;
@@ -1474,7 +1490,7 @@ static int bnx2x_get_module_info(struct net_device *dev,
int phy_idx, rc;
u8 sff8472_comp, diag_type;
- if (!netif_running(dev)) {
+ if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n");
return -EAGAIN;
@@ -1676,7 +1692,8 @@ static int bnx2x_set_eeprom(struct net_device *dev,
int port = BP_PORT(bp);
int rc = 0;
u32 ext_phy_config;
- if (!netif_running(dev)) {
+
+ if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n");
return -EAGAIN;
@@ -2173,7 +2190,7 @@ static int bnx2x_test_registers(struct bnx2x *bp)
{ BNX2X_CHIP_MASK_ALL, 0xffffffff, 0, 0x00000000 }
};
- if (!netif_running(bp->dev)) {
+ if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n");
return rc;
@@ -2277,7 +2294,7 @@ static int bnx2x_test_memory(struct bnx2x *bp)
{ NULL, 0xffffffff, {0, 0, 0, 0} }
};
- if (!netif_running(bp->dev)) {
+ if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n");
return rc;
@@ -3140,7 +3157,7 @@ static int bnx2x_set_phys_id(struct net_device *dev,
{
struct bnx2x *bp = netdev_priv(dev);
- if (!netif_running(dev)) {
+ if (!bnx2x_is_nvm_accessible(bp)) {
DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM,
"cannot access eeprom when the interface is down\n");
return -EAGAIN;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 13f8144..f6d0e20 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)
/* Unload the driver, release IRQs */
bnx2x_nic_unload(bp, UNLOAD_CLOSE, false);
- /* Power off */
- bnx2x_set_power_state(bp, PCI_D3hot);
-
return 0;
}
--
1.8.1.227.g44fe835
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/6] bnx2x: enhancement patch series
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
` (5 preceding siblings ...)
2013-05-27 14:08 ` [PATCH net-next 6/6] bnx2x: Change to D3hot only on removal Yuval Mintz
@ 2013-05-28 4:42 ` David Miller
6 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2013-05-28 4:42 UTC (permalink / raw)
To: yuvalmin; +Cc: netdev, eilong, ariele
From: "Yuval Mintz" <yuvalmin@broadcom.com>
Date: Mon, 27 May 2013 17:08:25 +0300
> This series contains several enhancements, mainly the implementation of the
> PCI shutdown callback which improves the bnx2x support in un-orderly shutdowns,
> and following that a change in the driver's power scheme which lowers PCI power
> state only when driver is removed (and as a result enable eeprom access on
> unloaded interfaces).
>
> Please consider applying these patches to `net-next'.
Series applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-05-28 4:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-27 14:08 [PATCH net-next 0/6] bnx2x: enhancement patch series Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 1/6] bnx2x: Zero VFs starting MACs Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 2/6] bnx2x: Add and correct PCI link speed prints Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 3/6] bnx2x: Ack unknown VF messages Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 4/6] bnx2x: Count number of possible FCoE interfaces Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 5/6] bnx2x: Implement PCI shutdown Yuval Mintz
2013-05-27 14:08 ` [PATCH net-next 6/6] bnx2x: Change to D3hot only on removal Yuval Mintz
2013-05-28 4:42 ` [PATCH net-next 0/6] bnx2x: enhancement patch series David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).