bnx2x bug fixes patch series
cover bnx2x bug fixes patch series
Hello Dave,
This is a patch series correcting several bugs and erroneous behaviours in the bnx2x driver.
Please consider applying it to `net'.
Thanks,
Yuval
PATCH 1/6 bnx2x: credit-leakage fixup on vlan_mac_del_all
Upon insertion of elements into the execution queue, it is validated that there are enough credits to support additional vlan-macs, and the credits are consumed. However, when removing a pending command in `bnx2x_vland_mac_del_all' the consumed credits are not released, which might cause leakage and eventually the inability to add new vlan-macs in certain scenarios.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 44 +++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 11 ++++++ 2 files changed, 54 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +43 -1
@@ -50,6 +50,7 @@ static inline void bnx2x_exe_queue_init(struct bnx2x *bp,int exe_len, union bnx2x_qable_obj *owner, exe_q_validate validate, + exe_q_remove remove, exe_q_optimize optimize, exe_q_execute exec, exe_q_get get)
@@ -66,6 +67,7 @@ static inline void bnx2x_exe_queue_init(struct bnx2x *bp,/* Owner specific callbacks */ o->validate = validate; + o->remove = remove; o->optimize = optimize; o->execute = exec; o->get = get;
@@ -1340,6 +1342,35 @@ static int bnx2x_validate_vlan_mac(struct bnx2x *bp, } } +static int bnx2x_remove_vlan_mac (struct bnx2x *bp, +union bnx2x_qable_obj *qo, +struct bnx2x_exeq_elem *elem) +{ +int rc =0 ; + +/* If consumption wasn't required, nothing to do */ +if (test_bit (BNX2X_DONT_CONSUME_CAM_CREDIT , + &elem->cmd_data.vlan_mac.vlan_mac_flags)) +return 0 ; + +switch (elem->cmd_data.vlan_mac.cmd) { +case BNX2X_VLAN_MAC_ADD : +case BNX2X_VLAN_MAC_MOVE : + rc = qo->vlan_mac.put_credit (&qo->vlan_mac); +break ; +case BNX2X_VLAN_MAC_DEL : + rc = qo->vlan_mac.get_credit (&qo->vlan_mac); +break ; +default : +return -EINVAL ; + } + +if (rc != true) +return -EINVAL ; + +return 0 ; +} +/** * bnx2x_wait_vlan_mac - passivly wait for 5 seconds until all work completes. *
@@ -1801,8 +1832,14 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,list_for_each_entry_safe (exeq_pos, exeq_pos_n, &exeq->exe_queue, link) {if (exeq_pos->cmd_data.vlan_mac.vlan_mac_flags == - *vlan_mac_flags) + *vlan_mac_flags) { + rc = exeq->remove (bp, exeq->owner, exeq_pos); +if (rc) { +BNX2X_ERR ("Failed to remove command\n" ); +return rc; + }list_del (&exeq_pos->link); + } }spin_unlock_bh (&exeq->lock);
@@ -1908,6 +1945,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,bnx2x_exe_queue_init (bp, &mac_obj->exe_queue,1 , qable_obj, bnx2x_validate_vlan_mac, + bnx2x_remove_vlan_mac, bnx2x_optimize_vlan_mac, bnx2x_execute_vlan_mac, bnx2x_exeq_get_mac);
@@ -1924,6 +1962,7 @@ void bnx2x_init_mac_obj(struct bnx2x *bp,bnx2x_exe_queue_init (bp, &mac_obj->exe_queue,CLASSIFY_RULES_COUNT , qable_obj, bnx2x_validate_vlan_mac, + bnx2x_remove_vlan_mac, bnx2x_optimize_vlan_mac, bnx2x_execute_vlan_mac, bnx2x_exeq_get_mac);
@@ -1963,6 +2002,7 @@ void bnx2x_init_vlan_obj(struct bnx2x *bp,bnx2x_exe_queue_init (bp, &vlan_obj->exe_queue,CLASSIFY_RULES_COUNT , qable_obj, bnx2x_validate_vlan_mac, + bnx2x_remove_vlan_mac, bnx2x_optimize_vlan_mac, bnx2x_execute_vlan_mac, bnx2x_exeq_get_vlan);
@@ -2009,6 +2049,7 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,bnx2x_exe_queue_init (bp, &vlan_mac_obj->exe_queue,1 , qable_obj, bnx2x_validate_vlan_mac, + bnx2x_remove_vlan_mac, bnx2x_optimize_vlan_mac, bnx2x_execute_vlan_mac, bnx2x_exeq_get_vlan_mac);
@@ -2025,6 +2066,7 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp, &vlan_mac_obj->exe_queue,CLASSIFY_RULES_COUNT , qable_obj, bnx2x_validate_vlan_mac, + bnx2x_remove_vlan_mac, bnx2x_optimize_vlan_mac, bnx2x_execute_vlan_mac, bnx2x_exeq_get_vlan_mac);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +11 -0
@@ -161,6 +161,10 @@ typedef int (*exe_q_validate)(struct bnx2x *bp,union bnx2x_qable_obj *o, struct bnx2x_exeq_elem *elem); +typedef int (*exe_q_remove )(struct bnx2x *bp, +union bnx2x_qable_obj *o, +struct bnx2x_exeq_elem *elem); +/** * @return positive is entry was optimized, 0 - if not, negative * in case of an error.
@@ -203,11 +207,18 @@ struct bnx2x_exe_queue_obj {*/ exe_q_validate validate; +/** +* Called before removing pending commands, cleaning allocated +* resources (e.g., credits from validate) +*/ +exe_q_remove remove;/** * This will try to cancel the current pending commands list * considering the new command. * +* Returns the number of optimized commands or a negative error code +* * Must run under exe_queue->lock */ exe_q_optimize optimize;
Signature · 1 line
1.7.1
PATCH 2/6 bnx2x: fixed ethtool statistics for MF modes
In reply to Yuval MintzPreviosuly, in MF modes `ethtool -S' lacked some of the statistics which appeared in non-MF modes. This has been fixed.
--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 106 ++++++++------------ 1 files changed, 41 insertions(+), 65 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +41 -65
@@ -2121,18 +2121,16 @@ static int bnx2x_get_sset_count(struct net_device *dev, int stringset)case ETH_SS_STATS :if (is_multi (bp)) { num_stats =bnx2x_num_stat_queues (bp) * -BNX2X_NUM_Q_STATS ; -if (!IS_MF_MODE_STAT (bp)) - num_stats +=BNX2X_NUM_STATS ; - }else { -if (IS_MF_MODE_STAT (bp)) { - num_stats =0 ; -for (i =0 ; i <BNX2X_NUM_STATS ; i++) -if (IS_FUNC_STAT (i)) - num_stats++; - }else - num_stats =BNX2X_NUM_STATS ; - } +BNX2X_NUM_Q_STATS ; + }else + num_stats =0 ; +if (IS_MF_MODE_STAT (bp)) { +for (i =0 ; i <BNX2X_NUM_STATS ; i++) +if (IS_FUNC_STAT (i)) + num_stats++; + }else + num_stats +=BNX2X_NUM_STATS ; +return num_stats;case ETH_SS_TEST :
@@ -2151,8 +2149,8 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)switch (stringset) {case ETH_SS_STATS : + k =0 ;if (is_multi (bp)) { - k =0 ;for_each_eth_queue (bp, i) {memset (queue_name,0 ,sizeof (queue_name));sprintf (queue_name,"%d" , i);
@@ -2163,20 +2161,17 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf) queue_name); k +=BNX2X_NUM_Q_STATS ; } -if (IS_MF_MODE_STAT (bp)) -break ; -for (j =0 ; j <BNX2X_NUM_STATS ; j++) -strcpy (buf + (k + j)*ETH_GSTRING_LEN , - bnx2x_stats_arr[j].string); - }else { -for (i =0 , j =0 ; i <BNX2X_NUM_STATS ; i++) { -if (IS_MF_MODE_STAT (bp) &&IS_PORT_STAT (i)) -continue ; -strcpy (buf + j*ETH_GSTRING_LEN , - bnx2x_stats_arr[i].string); - j++; - } } + + +for (i =0 , j =0 ; i <BNX2X_NUM_STATS ; i++) { +if (IS_MF_MODE_STAT (bp) &&IS_PORT_STAT (i)) +continue ; +strcpy (buf + (k + j)*ETH_GSTRING_LEN , + bnx2x_stats_arr[i].string); + j++; + } +break ;case ETH_SS_TEST :
@@ -2190,10 +2185,9 @@ static void bnx2x_get_ethtool_stats(struct net_device *dev, {struct bnx2x *bp =netdev_priv (dev);u32 *hw_stats, *offset; -int i, j, k; +int i, j, k =0 ;if (is_multi (bp)) { - k =0 ;for_each_eth_queue (bp, i) { hw_stats = (u32 *)&bp->fp[i].eth_q_stats;for (j =0 ; j <BNX2X_NUM_Q_STATS ; j++) {
@@ -2214,46 +2208,28 @@ static void bnx2x_get_ethtool_stats(struct net_device *dev, } k +=BNX2X_NUM_Q_STATS ; } -if (IS_MF_MODE_STAT (bp)) -return ; - hw_stats = (u32 *)&bp->eth_stats; -for (j =0 ; j <BNX2X_NUM_STATS ; j++) { -if (bnx2x_stats_arr[j].size ==0 ) { -/* skip this counter */ - buf[k + j] =0 ; -continue ; - } - offset = (hw_stats + bnx2x_stats_arr[j].offset); -if (bnx2x_stats_arr[j].size ==4 ) { -/* 4-byte counter */ - buf[k + j] = (u64) *offset; -continue ; - } -/* 8-byte counter */ - buf[k + j] =HILO_U64 (*offset, *(offset +1 )); + } + + hw_stats = (u32 *)&bp->eth_stats; +for (i =0 , j =0 ; i <BNX2X_NUM_STATS ; i++) { +if (IS_MF_MODE_STAT (bp) &&IS_PORT_STAT (i)) +continue ; +if (bnx2x_stats_arr[i].size ==0 ) { +/* skip this counter */ + buf[k + j] =0 ; + j++; +continue ; } - }else { - hw_stats = (u32 *)&bp->eth_stats; -for (i =0 , j =0 ; i <BNX2X_NUM_STATS ; i++) { -if (IS_MF_MODE_STAT (bp) &&IS_PORT_STAT (i)) -continue ; -if (bnx2x_stats_arr[i].size ==0 ) { -/* skip this counter */ - buf[j] =0 ; - j++; -continue ; - } - offset = (hw_stats + bnx2x_stats_arr[i].offset); -if (bnx2x_stats_arr[i].size ==4 ) { -/* 4-byte counter */ - buf[j] = (u64) *offset; - j++; -continue ; - } -/* 8-byte counter */ - buf[j] =HILO_U64 (*offset, *(offset +1 )); + offset = (hw_stats + bnx2x_stats_arr[i].offset); +if (bnx2x_stats_arr[i].size ==4 ) { +/* 4-byte counter */ + buf[k + j] = (u64) *offset; j++; +continue ; } +/* 8-byte counter */ + buf[k + j] =HILO_U64 (*offset, *(offset +1 )); + j++; } }
Signature · 1 line
1.7.1
PATCH 3/6 bnx2x: fix Big-Endianess in ethtool -t
In reply to Yuval MintzFrom: Dmitry Kravkov <[email protected]>
--- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +2 -3
@@ -1738,7 +1738,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode)struct bnx2x_fp_txdata *txdata = &fp_tx->txdata[0 ];u16 tx_start_idx, tx_idx;u16 rx_start_idx, rx_idx; -u16 pkt_prod, bd_prod, rx_comp_cons; +u16 pkt_prod, bd_prod;struct sw_tx_bd *tx_buf;struct eth_tx_start_bd *tx_start_bd;struct eth_tx_parse_bd_e1x *pbd_e1x =NULL ;
@@ -1873,8 +1873,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode)if (rx_idx != rx_start_idx + num_pkts) goto test_loopback_exit; - rx_comp_cons =le16_to_cpu (fp_rx->rx_comp_cons); - cqe = &fp_rx->rx_comp_ring[RCQ_BD (rx_comp_cons)]; + cqe = &fp_rx->rx_comp_ring[RCQ_BD (fp_rx->rx_comp_cons)]; cqe_fp_flags = cqe->fast_path_cqe.type_error_flags; cqe_fp_type = cqe_fp_flags Ð_FAST_PATH_RX_CQE_TYPE ;if (!CQE_TYPE_FAST (cqe_fp_type) || (cqe_fp_flags Ð_RX_ERROR_FALGS ))
Signature · 1 line
1.7.1
PATCH 4/6 bnx2x: allow user to change ring size in ISCSI SD mode
In reply to Yuval MintzFrom: Dmitry Kravkov <[email protected]>
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
@@ -3117,7 +3117,7 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)int rx_ring_size =0 ;#ifdef BCM_CNIC -if (IS_MF_ISCSI_SD (bp)) { +if (!bp->rx_ring_size &&IS_MF_ISCSI_SD (bp)) { rx_ring_size =MIN_RX_SIZE_NONTPA ; bp->rx_ring_size = rx_ring_size; }else
Signature · 1 line
1.7.1
PATCH 5/6 bnx2x: handle CHIP_REVISION during init_one
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
The macro CHIP_IS_E1x' requires bp' to be initialized. As bp' is not yet initialized during this phase of bnx2x_init_dev', it accessed uninitialized fields in the struct.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +5 -4
@@ -10536,6 +10536,9 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, {struct bnx2x *bp;int rc; +bool chip_is_e1x = (board_type ==BCM57710 || + board_type ==BCM57711 || + board_type ==BCM57711E );SET_NETDEV_DEV (dev, &pdev->dev); bp =netdev_priv (dev);
@@ -10624,7 +10627,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,REG_WR (bp,PXP2_REG_PGL_ADDR_90_F0 ,0 );REG_WR (bp,PXP2_REG_PGL_ADDR_94_F0 ,0 ); -if (CHIP_IS_E1x (bp)) { +if (chip_is_e1x) {REG_WR (bp,PXP2_REG_PGL_ADDR_88_F1 ,0 );REG_WR (bp,PXP2_REG_PGL_ADDR_8C_F1 ,0 );REG_WR (bp,PXP2_REG_PGL_ADDR_90_F1 ,0 );
@@ -10635,9 +10638,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,* Enable internal target-read (in case we are probed after PF FLR). * Must be done prior to any BAR read access. Only for 57712 and up */ -if (board_type !=BCM57710 && - board_type !=BCM57711 && - board_type !=BCM57711E ) +if (!chip_is_e1x)REG_WR (bp,PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ ,1 );/* Reset the load counter */
Signature · 1 line
1.7.1
PATCH 6/6 bnx2x: fix compilation error with SOE in fw_dump
In reply to Yuval Mintz--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -1
@@ -941,7 +941,7 @@ void bnx2x_panic_dump(struct bnx2x *bp)struct sw_rx_bd *sw_bd = &fp->rx_buf_ring[j];BNX2X_ERR ("fp%d: rx_bd[%x]=[%x:%x] sw_bd=[%p]\n" , - i, j, rx_bd[1 ], rx_bd[0 ], sw_bd->skb); + i, j, rx_bd[1 ], rx_bd[0 ], sw_bd->data); } start =RX_SGE (fp->rx_sge_prod);
Signature · 1 line
1.7.1
From: "Yuval Mintz" <[email protected]>
Date: Mon, 23 Jan 2012 12:31:50 -0500
Quoted 6 lines
Hello Dave,
This is a patch series correcting several bugs and erroneous behaviours in the bnx2x driver.
Please consider applying it to `net'.
Applied, thanks.