bnx2: Prevent ethtool -s from crashing when device is down.
Subsystems (2)
PATCH 1/6 bnx2: Prevent ethtool -s from crashing when device is down.
The device may be in D3-hot state and may crash if we try to configure the speed settings by accessing the registers.
--- drivers/net/bnx2.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
drivers/net/bnx2.c +12 -1
@@ -6215,6 +6215,12 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) !(bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP)) goto err_out_unlock; +/* If device is down, we can store the settings only if the user +* is setting the currently active port. +*/ +if (!netif_running (dev) && cmd->port != bp->phy_port) + goto err_out_unlock; +if (cmd->autoneg ==AUTONEG_ENABLE ) { autoneg |=AUTONEG_SPEED ;
@@ -6272,7 +6278,12 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) bp->req_line_speed = req_line_speed; bp->req_duplex = req_duplex; - err =bnx2_setup_phy (bp, cmd->port); + err =0 ; +/* If device is down, the new settings will be picked up when it is +* brought up. +*/ +if (netif_running (dev)) + err =bnx2_setup_phy (bp, cmd->port); err_out_unlock:spin_unlock_bh (&bp->phy_lock);
Signature · 1 line
1.5.5.GIT
PATCH 3/6 bnx2: Add ack parameter to bnx2_fw_sync().
ack=1 means wait for firmware acknowledgement, and ack=0 means don't wait. All current callers will set it to 1.
In the next patch, new calls will set ack=0.
--- drivers/net/bnx2.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-)
drivers/net/bnx2.c +11 -7
@@ -1491,7 +1491,7 @@ bnx2_phy_get_pause_adv(struct bnx2 *bp)return adv; } -static int bnx2_fw_sync (struct bnx2 *,u32 ,int ); +static int bnx2_fw_sync (struct bnx2 *,u32 ,int ,int );static int bnx2_setup_remote_phy (struct bnx2 *bp,u8 port)
@@ -1544,7 +1544,7 @@ bnx2_setup_remote_phy(struct bnx2 *bp, u8 port)bnx2_shmem_wr (bp,BNX2_DRV_MB_ARG0 , speed_arg);spin_unlock_bh (&bp->phy_lock); -bnx2_fw_sync (bp,BNX2_DRV_MSG_CODE_CMD_SET_LINK ,0 ); +bnx2_fw_sync (bp,BNX2_DRV_MSG_CODE_CMD_SET_LINK ,1 ,0 );spin_lock_bh (&bp->phy_lock);return 0 ;
@@ -2262,7 +2262,7 @@ bnx2_set_phy_loopback(struct bnx2 *bp) }static int -bnx2_fw_sync (struct bnx2 *bp,u32 msg_data,int silent) +bnx2_fw_sync (struct bnx2 *bp,u32 msg_data,int ack,int silent) {int i;u32 val;
@@ -2272,6 +2272,9 @@ bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int silent)bnx2_shmem_wr (bp,BNX2_DRV_MB , msg_data); +if (!ack) +return 0 ; +/* wait for an acknowledgement. */ for (i =0 ; i < (FW_ACK_TIME_OUT_MS /10 ); i++) {msleep (10 );
@@ -3610,7 +3613,8 @@ bnx2_set_power_state(struct bnx2 *bp, pci_power_t state) }if (!(bp->flags &BNX2_FLAG_NO_WOL )) -bnx2_fw_sync (bp,BNX2_DRV_MSG_DATA_WAIT3 | wol_msg,0 ); +bnx2_fw_sync (bp,BNX2_DRV_MSG_DATA_WAIT3 | wol_msg, +1 ,0 ); pmcsr &= ~PCI_PM_CTRL_STATE_MASK ; if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
@@ -4309,7 +4313,7 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)udelay (5 );/* Wait for the firmware to tell us it is ok to issue a reset. */ -bnx2_fw_sync (bp,BNX2_DRV_MSG_DATA_WAIT0 | reset_code,1 ); +bnx2_fw_sync (bp,BNX2_DRV_MSG_DATA_WAIT0 | reset_code,1 ,1 );/* Deposit a driver reset signature so the firmware knows that * this is a soft reset. */
@@ -4370,7 +4374,7 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code) }/* Wait for the firmware to finish its initialization. */ - rc =bnx2_fw_sync (bp,BNX2_DRV_MSG_DATA_WAIT1 | reset_code,0 ); + rc =bnx2_fw_sync (bp,BNX2_DRV_MSG_DATA_WAIT1 | reset_code,1 ,0 );if (rc)return rc;
@@ -4596,7 +4600,7 @@ bnx2_init_chip(struct bnx2 *bp)REG_WR (bp,BNX2_MISC_NEW_CORE_CTL , val); } rc =bnx2_fw_sync (bp,BNX2_DRV_MSG_DATA_WAIT2 |BNX2_DRV_MSG_CODE_RESET , -0 ); +1 ,0 );REG_WR (bp,BNX2_MISC_ENABLE_SET_BITS ,BNX2_MISC_ENABLE_DEFAULT );REG_RD (bp,BNX2_MISC_ENABLE_SET_BITS );
Signature · 1 line
1.5.5.GIT
PATCH 6/6 bnx2: Update version to 1.7.8.
In reply to Michael Chan--- drivers/net/bnx2.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/bnx2.c +2 -2
@@ -56,8 +56,8 @@#define DRV_MODULE_NAME "bnx2"#define PFX DRV_MODULE_NAME ": " -#define DRV_MODULE_VERSION "1.7.7" -#define DRV_MODULE_RELDATE "June 17, 2008" +#define DRV_MODULE_VERSION "1.7.8" +#define DRV_MODULE_RELDATE "July 10, 2008"#define RUN_AT (x) (jiffies + (x))
Signature · 1 line
1.5.5.GIT
PATCH 4/6 bnx2: Allow flexible VLAN tag settings.
In reply to Michael ChanNegotiate with boot code and ASF firmware to see if it can support keeping VLAN tags in the RX packets. If supported by firmware, the VLAN tag will be kept in the RX packet unless VLAN acceleration is registered.
--- drivers/net/bnx2.c | 44 +++++++++++++++++++++++++++----------------- drivers/net/bnx2.h | 6 ++++++ 2 files changed, 33 insertions(+), 17 deletions(-)
drivers/net/bnx2.c +27 -17
@@ -4255,35 +4255,43 @@ nvram_write_end: }static void -bnx2_init_remote_phy (struct bnx2 *bp) +bnx2_init_fw_cap (struct bnx2 *bp) { -u32 val; +u32 val, sig =0 ; bp->phy_flags &= ~BNX2_PHY_FLAG_REMOTE_PHY_CAP ; -if (!(bp->phy_flags &BNX2_PHY_FLAG_SERDES )) -return ; + bp->flags &= ~BNX2_FLAG_CAN_KEEP_VLAN ; + +if (!(bp->flags &BNX2_FLAG_ASF_ENABLE )) + bp->flags |=BNX2_FLAG_CAN_KEEP_VLAN ; val =bnx2_shmem_rd (bp,BNX2_FW_CAP_MB );if ((val &BNX2_FW_CAP_SIGNATURE_MASK ) !=BNX2_FW_CAP_SIGNATURE )return ; -if (val &BNX2_FW_CAP_REMOTE_PHY_CAPABLE ) { +if ((val &BNX2_FW_CAP_CAN_KEEP_VLAN ) ==BNX2_FW_CAP_CAN_KEEP_VLAN ) { + bp->flags |=BNX2_FLAG_CAN_KEEP_VLAN ; + sig |=BNX2_DRV_ACK_CAP_SIGNATURE |BNX2_FW_CAP_CAN_KEEP_VLAN ; + } + +if ((bp->phy_flags &BNX2_PHY_FLAG_SERDES ) && + (val &BNX2_FW_CAP_REMOTE_PHY_CAPABLE )) { +u32 link; + bp->phy_flags |=BNX2_PHY_FLAG_REMOTE_PHY_CAP ; - val =bnx2_shmem_rd (bp,BNX2_LINK_STATUS ); -if (val &BNX2_LINK_STATUS_SERDES_LINK ) + link =bnx2_shmem_rd (bp,BNX2_LINK_STATUS ); +if (link &BNX2_LINK_STATUS_SERDES_LINK ) bp->phy_port =PORT_FIBRE ;else bp->phy_port =PORT_TP ; -if (netif_running (bp->dev)) { -u32 sig; - - sig =BNX2_DRV_ACK_CAP_SIGNATURE | -BNX2_FW_CAP_REMOTE_PHY_CAPABLE ; -bnx2_shmem_wr (bp,BNX2_DRV_ACK_CAP_MB , sig); - } + sig |=BNX2_DRV_ACK_CAP_SIGNATURE | +BNX2_FW_CAP_REMOTE_PHY_CAPABLE ; } + +if (netif_running (bp->dev) && sig) +bnx2_shmem_wr (bp,BNX2_DRV_ACK_CAP_MB , sig); } static void
@@ -4380,7 +4388,7 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)spin_lock_bh (&bp->phy_lock); old_port = bp->phy_port; -bnx2_init_remote_phy (bp); +bnx2_init_fw_cap (bp);if ((bp->phy_flags &BNX2_PHY_FLAG_REMOTE_PHY_CAP ) && old_port != bp->phy_port)bnx2_set_default_remote_link (bp);
@@ -5879,6 +5887,8 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp) bp->vlgrp = vlgrp;bnx2_set_rx_mode (dev); +if (bp->flags &BNX2_FLAG_CAN_KEEP_VLAN ) +bnx2_fw_sync (bp,BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE ,0 ,1 );bnx2_netif_start (bp); }
@@ -7483,8 +7493,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)if (reg &BNX2_SHARED_HW_CFG_PHY_2_5G ) bp->phy_flags |=BNX2_PHY_FLAG_2_5G_CAPABLE ; } -bnx2_init_remote_phy (bp); - }else if (CHIP_NUM (bp) ==CHIP_NUM_5706 ||CHIP_NUM (bp) ==CHIP_NUM_5708 ) bp->phy_flags |=BNX2_PHY_FLAG_CRC_FIX ;
@@ -7493,6 +7501,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) CHIP_REV(bp) == CHIP_REV_Bx)) bp->phy_flags |=BNX2_PHY_FLAG_DIS_EARLY_DAC ; +bnx2_init_fw_cap (bp); +if ((CHIP_ID (bp) ==CHIP_ID_5708_A0 ) || (CHIP_ID (bp) ==CHIP_ID_5708_B0 ) || (CHIP_ID (bp) ==CHIP_ID_5708_B1 )) {
drivers/net/bnx2.h +6 -0
@@ -6670,6 +6670,7 @@ struct bnx2 {#define BNX2_FLAG_USING_MSI_OR_MSIX (BNX2_FLAG_USING_MSI | \ BNX2_FLAG_USING_MSIX)#define BNX2_FLAG_JUMBO_BROKEN 0x00000800 +#define BNX2_FLAG_CAN_KEEP_VLAN 0x00001000struct bnx2_napi bnx2_napi[BNX2_MAX_MSIX_VEC ];
@@ -6951,6 +6952,7 @@ struct fw_info {#define BNX2_DRV_MSG_CODE_DIAG 0x07000000#define BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL 0x09000000#define BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN 0x0b000000 +#define BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE 0x0d000000#define BNX2_DRV_MSG_CODE_CMD_SET_LINK 0x10000000#define BNX2_DRV_MSG_DATA 0x00ff0000
@@ -7279,6 +7281,10 @@ struct fw_info {#define BNX2_FW_CAP_SIGNATURE_MASK 0xffff0000#define BNX2_FW_CAP_REMOTE_PHY_CAPABLE 0x00000001#define BNX2_FW_CAP_REMOTE_PHY_PRESENT 0x00000002 +#define BNX2_FW_CAP_MFW_CAN_KEEP_VLAN 0x00000008 +#define BNX2_FW_CAP_BC_CAN_KEEP_VLAN 0x00000010 +#define BNX2_FW_CAP_CAN_KEEP_VLAN (BNX2_FW_CAP_BC_CAN_KEEP_VLAN | \ + BNX2_FW_CAP_MFW_CAN_KEEP_VLAN)#define BNX2_RPHY_SIGNATURE 0x36c#define BNX2_RPHY_LOAD_SIGNATURE 0x5a5a5a5a
Signature · 1 line
1.5.5.GIT
PATCH 5/6 bnx2: Support secondary MAC addresses.
In reply to Michael ChanAdd support for configuring secondary unicast addresses. There are 4 additional perfect match filters which can be used for secondary unicast address support.
* Modified bnx2_set_mac_addr() to be more generic in handling the setting of the perfect match filters
* Changed bnx2_set_rx_mode() to handle the unicast dev_addr_list
--- drivers/net/bnx2.c | 35 +++++++++++++++++++++++++++-------- drivers/net/bnx2.h | 5 +++++ 2 files changed, 32 insertions(+), 8 deletions(-)
drivers/net/bnx2.c +27 -8
@@ -2451,19 +2451,18 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp) }static void -bnx2_set_mac_addr (struct bnx2 *bp) +bnx2_set_mac_addr (struct bnx2 *bp,u8 *mac_addr,u32 pos) {u32 val; -u8 *mac_addr = bp->dev->dev_addr; val = (mac_addr[0 ] <<8 ) | mac_addr[1 ]; -REG_WR (bp,BNX2_EMAC_MAC_MATCH0 , val); +REG_WR (bp,BNX2_EMAC_MAC_MATCH0 + (pos *8 ), val); val = (mac_addr[2 ] <<24 ) | (mac_addr[3 ] <<16 ) | (mac_addr[4 ] <<8 ) | mac_addr[5 ]; -REG_WR (bp,BNX2_EMAC_MAC_MATCH1 , val); +REG_WR (bp,BNX2_EMAC_MAC_MATCH1 + (pos *8 ), val); } static inline int
@@ -3223,6 +3222,7 @@ bnx2_set_rx_mode(struct net_device *dev) {struct bnx2 *bp =netdev_priv (dev);u32 rx_mode, sort_mode; +struct dev_addr_list *uc_ptr;int i;spin_lock_bh (&bp->phy_lock);
@@ -3278,6 +3278,25 @@ bnx2_set_rx_mode(struct net_device *dev) sort_mode |=BNX2_RPM_SORT_USER0_MC_HSH_EN ; } + uc_ptr =NULL ; +if (dev->uc_count >BNX2_MAX_UNICAST_ADDRESSES ) { + rx_mode |=BNX2_EMAC_RX_MODE_PROMISCUOUS ; + sort_mode |=BNX2_RPM_SORT_USER0_PROM_EN | +BNX2_RPM_SORT_USER0_PROM_VLAN ; + }else if (!(dev->flags &IFF_PROMISC )) { + uc_ptr = dev->uc_list; + +/* Add all entries into to the match filter list */ +for (i =0 ; i < dev->uc_count; i++) { +bnx2_set_mac_addr (bp, uc_ptr->da_addr, + i +BNX2_START_UNICAST_ADDRESS_INDEX ); + sort_mode |= (1 << + (i +BNX2_START_UNICAST_ADDRESS_INDEX )); + uc_ptr = uc_ptr->next; + } + + } +if (rx_mode != bp->rx_mode) { bp->rx_mode = rx_mode;REG_WR (bp,BNX2_EMAC_RX_MODE , rx_mode);
@@ -3562,7 +3581,7 @@ bnx2_set_power_state(struct bnx2 *bp, pci_power_t state) bp->autoneg = autoneg; bp->advertising = advertising; -bnx2_set_mac_addr (bp); +bnx2_set_mac_addr (bp, bp->dev->dev_addr,0 ); val =REG_RD (bp,BNX2_EMAC_MODE );
@@ -4472,7 +4491,7 @@ bnx2_init_chip(struct bnx2 *bp)bnx2_init_nvram (bp); -bnx2_set_mac_addr (bp); +bnx2_set_mac_addr (bp, bp->dev->dev_addr,0 ); val =REG_RD (bp,BNX2_MQ_CONFIG ); val &= ~BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE ;
@@ -7100,7 +7119,7 @@ bnx2_change_mac_addr(struct net_device *dev, void *p)memcpy (dev->dev_addr, addr->sa_data, dev->addr_len);if (netif_running (dev)) -bnx2_set_mac_addr (bp); +bnx2_set_mac_addr (bp, bp->dev->dev_addr,0 );return 0 ; }
@@ -7643,7 +7662,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->hard_start_xmit = bnx2_start_xmit; dev->stop = bnx2_close; dev->get_stats = bnx2_get_stats; - dev->set_multicast_list = bnx2_set_rx_mode; + dev->set_rx_mode = bnx2_set_rx_mode; dev->do_ioctl = bnx2_ioctl; dev->set_mac_address = bnx2_change_mac_addr; dev->change_mtu = bnx2_change_mtu;
drivers/net/bnx2.h +5 -0
@@ -6440,6 +6440,11 @@ struct l2_fhdr {#define BNX2_MISC_ENABLE_DEFAULT 0x17ffffff +#define BNX2_START_UNICAST_ADDRESS_INDEX 4 +#define BNX2_END_UNICAST_ADDRESS_INDEX 7 +#define BNX2_MAX_UNICAST_ADDRESSES (BNX2_END_UNICAST_ADDRESS_INDEX - \ + BNX2_START_UNICAST_ADDRESS_INDEX + 1) +#define DMA_READ_CHANS 5#define DMA_WRITE_CHANS 3
Signature · 1 line
1.5.5.GIT
PATCH 2/6 bnx2: Add PCI ID for 5716.
In reply to Michael Chan--- drivers/net/bnx2.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/net/bnx2.c +5 -1
@@ -87,6 +87,7 @@ typedef enum {BCM5708S ,BCM5709 ,BCM5709S , +BCM5716 , } board_t;/* indexed by board_t, above */
@@ -102,9 +103,10 @@ static struct { { "Broadcom NetXtreme II BCM5708 1000Base-SX" }, { "Broadcom NetXtreme II BCM5709 1000Base-T" }, { "Broadcom NetXtreme II BCM5709 1000Base-SX" }, + { "Broadcom NetXtreme II BCM5716 1000Base-T" }, }; -static struct pci_device_id bnx2_pci_tbl[] = { +static DEFINE_PCI_DEVICE_TABLE(bnx2_pci_tbl) = { { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706, PCI_VENDOR_ID_HP, 0x3101, 0, 0, NC370T }, { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706,
@@ -123,6 +125,8 @@ static struct pci_device_id bnx2_pci_tbl[] = { PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709 }, { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5709S, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709S }, + { PCI_VENDOR_ID_BROADCOM, 0x163b, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716 }, { 0, } };
Signature · 1 line
1.5.5.GIT
From: "Michael Chan" <[email protected]>
Date: Thu, 10 Jul 2008 18:29:10 -0700
Quoted 4 lines
The device may be in D3-hot state and may crash if we try to configure the speed settings by accessing the registers.
Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 2/6] bnx2: Add PCI ID for 5716.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 10 Jul 2008 18:29:11 -0700
Quoted 2 lines
Signed-off-by Michael Chan <[email protected]>Signed-off-by Benjamin Li <[email protected]>
Applied.
Re: [PATCH net-next 3/6] bnx2: Add ack parameter to bnx2_fw_sync().
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 10 Jul 2008 18:29:12 -0700
Quoted 6 lines
ack=1 means wait for firmware acknowledgement, and ack=0 means don't wait. All current callers will set it to 1.
In the next patch, new calls will set ack=0.
Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 4/6] bnx2: Allow flexible VLAN tag settings.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 10 Jul 2008 18:29:13 -0700
Quoted 6 lines
Negotiate with boot code and ASF firmware to see if it can support keeping VLAN tags in the RX packets. If supported by firmware, the VLAN tag will be kept in the RX packet unless VLAN acceleration is registered.
Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 5/6] bnx2: Support secondary MAC addresses.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 10 Jul 2008 18:29:14 -0700
Quoted 10 lines
Add support for configuring secondary unicast addresses. There are 4 additional perfect match filters which can be used for secondary unicast address support.
* Modified
bnx2_set_mac_addr()to be more generic in handling the setting of the perfect match filters
* Changedbnx2_set_rx_mode()to handle the unicastdev_addr_listSigned-off-by Benjamin Li <[email protected]>Signed-off-by Michael Chan <[email protected]>
Applied.
David Miller
maintainerRe: [PATCH net-next 6/6] bnx2: Update version to 1.7.8.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 10 Jul 2008 18:29:15 -0700
Quoted 1 line
Signed-off-by Michael Chan <[email protected]>
Also applied, thanks a lot.