bnx2x: Bug fixes patch series
cover bnx2x: Bug fixes patch series
Hi Dave,
This patch series contains VF bug fixes (with the exception of one unrelated bug fix).
Please consider applying these patches to `net'.
Thanks,
Yuval Mintz
PATCH 1/5 bnx2x: vf mark stats started
From: Ariel Elior <[email protected]>
Solve issue where no stats were being collected for VF devices due to missing configuration in the stats' atomic synchronization mechanism.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +8 -12
@@ -522,20 +522,16 @@ static void bnx2x_func_stats_init(struct bnx2x *bp)/* should be called under stats_sema */ static void __bnx2x_stats_start (struct bnx2x *bp) { -/* vfs travel through here as part of the statistics FSM, but no action -* is required -*/ -if (IS_VF (bp)) -return ; - -if (bp->port.pmf) -bnx2x_port_stats_init (bp); +if (IS_PF (bp)) { +if (bp->port.pmf) +bnx2x_port_stats_init (bp); -else if (bp->func_stx) -bnx2x_func_stats_init (bp); +else if (bp->func_stx) +bnx2x_func_stats_init (bp); -bnx2x_hw_stats_post (bp); -bnx2x_storm_stats_post (bp); +bnx2x_hw_stats_post (bp); +bnx2x_storm_stats_post (bp); + } bp->stats_started = true; }
Signature · 1 line
1.8.1.227.g44fe835
PATCH 2/5 bnx2x: Fix move FP memory deallocations
In reply to Yuval MintzIf driver will fail to allocate all queues, it will shrink the number of queues and move the storage queue to its correct place (i.e., the last queue among the newly supported number).
When changing the pointers of the new location of the FCoE queue, we need to pay special attention to the aggregations pointer - that memory is allocated during probe and released upon driver removal. Current implementation has 2 pointers pointing to the same chunk of allocated memory, meaning upon removal there will be two kfree() of the same chunk while the other won't be released.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +6 -0
@@ -53,6 +53,7 @@ static inline void bnx2x_move_fp(struct bnx2x *bp, int from, int to)struct bnx2x_fp_stats *to_fp_stats = &bp->fp_stats[to];int old_max_eth_txqs, new_max_eth_txqs;int old_txdata_index =0 , new_txdata_index =0 ; +struct bnx2x_agg_info *old_tpa_info = to_fp->tpa_info;/* Copy the NAPI object as it has been already initialized */ from_fp->napi = to_fp->napi;
@@ -61,6 +62,11 @@ static inline void bnx2x_move_fp(struct bnx2x *bp, int from, int to)memcpy (to_fp, from_fp,sizeof (*to_fp)); to_fp->index = to; +/* Retain the tpa_info of the original `to' version as we don't want +* 2 FPs to contain the same tpa_info pointer. +*/ + to_fp->tpa_info = old_tpa_info; +/* move sp_objs contents as well, as their indices match fp ones */ memcpy (to_sp_objs, from_sp_objs,sizeof (*to_sp_objs));
Signature · 1 line
1.8.1.227.g44fe835
PATCH 3/5 bnx2x: Fix functionality of configuring vlan list
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
The check on return code of bnx2x_vfop_config_vlan0() would lead to error handling flow as the return value indicating an existing pending ramrod would be erroneously considered as an error.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 37 ++--------------------- 1 file changed, 2 insertions(+), 35 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +2 -35
@@ -522,23 +522,6 @@ static int bnx2x_vfop_set_user_req(struct bnx2x *bp,return 0 ; } -static int -bnx2x_vfop_config_vlan0 (struct bnx2x *bp, -struct bnx2x_vlan_mac_ramrod_params *vlan_mac, -bool add) -{ -int rc; - - vlan_mac->user_req.cmd = add ?BNX2X_VLAN_MAC_ADD : -BNX2X_VLAN_MAC_DEL ; - vlan_mac->user_req.u.vlan.vlan =0 ; - - rc =bnx2x_config_vlan_mac (bp, vlan_mac); -if (rc == -EEXIST ) - rc =0 ; -return rc; -} -static int bnx2x_vfop_config_list (struct bnx2x *bp,struct bnx2x_vfop_filters *filters,struct bnx2x_vlan_mac_ramrod_params *vlan_mac)
@@ -643,30 +626,14 @@ static void bnx2x_vfop_vlan_mac(struct bnx2x *bp, struct bnx2x_virtf *vf)case BNX2X_VFOP_VLAN_CONFIG_LIST :/* next state */ - vfop->state =BNX2X_VFOP_VLAN_CONFIG_LIST_0 ; - -/* remove vlan0 - could be no-op */ - vfop->rc =bnx2x_vfop_config_vlan0 (bp, vlan_mac, false); -if (vfop->rc) - goto op_err; + vfop->state =BNX2X_VFOP_VLAN_MAC_CHK_DONE ; -/* Do vlan list config. if this operation fails we try to -* restore vlan0 to keep the queue is working order -*/ +/* do list config */ vfop->rc =bnx2x_vfop_config_list (bp, filters, vlan_mac);if (!vfop->rc) {set_bit (RAMROD_CONT , &vlan_mac->ramrod_flags); vfop->rc =bnx2x_config_vlan_mac (bp, vlan_mac); } -bnx2x_vfop_finalize (vf, vfop->rc,VFOP_CONT );/* fall-through */ - -case BNX2X_VFOP_VLAN_CONFIG_LIST_0 : -/* next state */ - vfop->state =BNX2X_VFOP_VLAN_MAC_CHK_DONE ; - -if (list_empty (&obj->head)) -/* add vlan0 */ - vfop->rc =bnx2x_vfop_config_vlan0 (bp, vlan_mac, true);bnx2x_vfop_finalize (vf, vfop->rc,VFOP_DONE );default :
Signature · 1 line
1.8.1.227.g44fe835
PATCH 4/5 bnx2x: Fix VF memory leak unload
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
Due to incorrect VF/PF conditions, when unloading a VF it will not release part of the memory it has previously allocated.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 ++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +2 -1
@@ -2962,8 +2962,9 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)if (IS_PF (bp)) {if (CNIC_LOADED (bp))bnx2x_free_mem_cnic (bp); -bnx2x_free_mem (bp); } +bnx2x_free_mem (bp); + bp->state =BNX2X_STATE_CLOSED ; bp->cnic_loaded = false;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +6 -3
@@ -7855,12 +7855,15 @@ void bnx2x_free_mem(struct bnx2x *bp) {int i; -BNX2X_PCI_FREE (bp->def_status_blk, bp->def_status_blk_mapping, -sizeof (struct host_sp_status_block )); -BNX2X_PCI_FREE (bp->fw_stats, bp->fw_stats_mapping, bp->fw_stats_data_sz + bp->fw_stats_req_sz); +if (IS_VF (bp)) +return ; + +BNX2X_PCI_FREE (bp->def_status_blk, bp->def_status_blk_mapping, +sizeof (struct host_sp_status_block )); +BNX2X_PCI_FREE (bp->slowpath, bp->slowpath_mapping,sizeof (struct bnx2x_slowpath ));
Signature · 1 line
1.8.1.227.g44fe835
PATCH 5/5 bnx2x: Fix VF stats sync
In reply to Yuval MintzFrom: Ariel Elior <[email protected]>
Since the PF gathers statistics for the VF, when the VF is about to unload we must synchronize the release of its statistics buffer with the PF, so that no DMA operation will be made to that address after the buffer release.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 26 ++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c | 11 ++++++++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h | 3 +++ 3 files changed, 39 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +25 -1
@@ -2786,6 +2786,18 @@ int bnx2x_vf_init(struct bnx2x *bp, struct bnx2x_virtf *vf, dma_addr_t *sb_map)return 0 ; } +struct set_vf_state_cookie { +struct bnx2x_virtf *vf; +u8 state; +}; + +void bnx2x_set_vf_state (void *cookie) +{ +struct set_vf_state_cookie *p = (struct set_vf_state_cookie *)cookie; + + p->vf->state = p->state; +} +/* VFOP close (teardown the queues, delete mcasts and close HW) */ static void bnx2x_vfop_close (struct bnx2x *bp,struct bnx2x_virtf *vf) {
@@ -2836,7 +2848,19 @@ static void bnx2x_vfop_close(struct bnx2x *bp, struct bnx2x_virtf *vf) op_err:BNX2X_ERR ("VF[%d] CLOSE error: rc %d\n" , vf->abs_vfid, vfop->rc); op_done: - vf->state =VF_ACQUIRED ; + +/* need to make sure there are no outstanding stats ramrods which may +* cause the device to access the VF's stats buffer which it will free +* as soon as we return from the close flow. +*/ + { +struct set_vf_state_cookie cookie; + + cookie.vf = vf; + cookie.state =VF_ACQUIRED ; +bnx2x_stats_safe_exec (bp, bnx2x_set_vf_state, &cookie); + } +DP (BNX2X_MSG_IOV ,"set state to acquired\n" );bnx2x_vfop_end (bp, vf, vfop); }
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +11 -0
@@ -1993,3 +1993,14 @@ void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats, estats->mac_discard); } } + +void bnx2x_stats_safe_exec (struct bnx2x *bp, +void (func_to_exec )(void *cookie), +void *cookie){ +if (down_timeout (&bp->stats_sema,HZ /10 )) +BNX2X_ERR ("Unable to acquire stats lock\n" ); +bnx2x_stats_comp (bp); +func_to_exec (cookie); +__bnx2x_stats_start (bp); +up (&bp->stats_sema); +}
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h +3 -0
@@ -539,6 +539,9 @@ struct bnx2x;void bnx2x_memset_stats (struct bnx2x *bp);void bnx2x_stats_init (struct bnx2x *bp);void bnx2x_stats_handle (struct bnx2x *bp,enum bnx2x_stats_event event); +void bnx2x_stats_safe_exec (struct bnx2x *bp, +void (func_to_exec )(void *cookie), +void *cookie);/** * bnx2x_save_statistics - save statistics when unloading.
Signature · 1 line
1.8.1.227.g44fe835
David Miller
maintainerFrom: "Yuval Mintz" <[email protected]>
Date: Wed, 28 Aug 2013 01:12:59 +0300
Quoted 4 lines
This patch series contains VF bug fixes (with the exception of one unrelated bug fix).
Please consider applying these patches to `net'.
Series applied, thanks.