bnxt_en: Misc. bug fixes.
Michael Chan
maintainercover bnxt_en: Misc. bug fixes.
6 miscellaneous bug fixes covering several issues in error code paths, a setup issue for statistics DMA, and an improvement for setting up multicast address filters.
Please queue these for stable as well.
Patch #5 (bnxt_en: Fix statistics context reservation logic) is for the most recent 5.0 stable only. Thanks.
Michael Chan (5):
bnxt_en: Improve multicast address setup logic.
bnxt_en: Fix possible crash in bnxt_hwrm_ring_free() under error
conditions.
bnxt_en: Pass correct extended TX port statistics size to firmware.
bnxt_en: Fix statistics context reservation logic.
bnxt_en: Fix uninitialized variable usage in bnxt_rx_pkt().
Vasundhara Volam (1):
bnxt_en: Free short FW command HWRM memory in error path in
bnxt_init_one()
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 53 +++++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-)
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 1/6 bnxt_en: Improve multicast address setup logic.
The driver builds a list of multicast addresses and sends it to the firmware when the driver's ndo_set_rx_mode() is called. In rare cases, the firmware can fail this call if internal resources to add multicast addresses are exhausted. In that case, we should try the call again by setting the ALL_MCAST flag which is more guaranteed to succeed.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -1
@@ -8961,8 +8961,15 @@ static int bnxt_cfg_rx_mode(struct bnxt *bp) skip_uc: rc =bnxt_hwrm_cfa_l2_set_rx_mask (bp,0 ); +if (rc && vnic->mc_list_count) { +netdev_info (bp->dev,"Failed setting MC filters rc: %d, turning on ALL_MCAST mode\n" , + rc); + vnic->rx_mask |=CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST ; + vnic->mc_list_count =0 ; + rc =bnxt_hwrm_cfa_l2_set_rx_mask (bp,0 ); + }if (rc) -netdev_err (bp->dev,"HWRM cfa l2 rx mask failure rc: %x\n" , +netdev_err (bp->dev,"HWRM cfa l2 rx mask failure rc: %d\n" , rc);return rc;
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 2/6 bnxt_en: Free short FW command HWRM memory in error path in bnxt_init_one()
In reply to Michael ChanFrom: Vasundhara Volam <[email protected]>
In the bnxt_init_one() error path, short FW command request memory is not freed. This patch fixes it.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -0
@@ -10692,6 +10692,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)bnxt_clear_int_mode (bp); init_err_pci_clean: +bnxt_free_hwrm_short_cmd_req (bp);bnxt_free_hwrm_resources (bp);bnxt_free_ctx_mem (bp);kfree (bp->ctx);
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 3/6 bnxt_en: Fix possible crash in bnxt_hwrm_ring_free() under error conditions.
In reply to Michael ChanIf we encounter errors during open and proceed to clean up, bnxt_hwrm_ring_free() may crash if the rings we try to free have never been allocated. bnxt_cp_ring_for_rx() or bnxt_cp_ring_for_tx() may reference pointers that have not been allocated.
Fix it by checking for valid fw_ring_id first before calling bnxt_cp_ring_for_rx() or bnxt_cp_ring_for_tx().
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -6
@@ -5135,10 +5135,10 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)for (i =0 ; i < bp->tx_nr_rings; i++) {struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];struct bnxt_ring_struct *ring = &txr->tx_ring_struct; -u32 cmpl_ring_id; - cmpl_ring_id =bnxt_cp_ring_for_tx (bp, txr);if (ring->fw_ring_id !=INVALID_HW_RING_ID ) { +u32 cmpl_ring_id =bnxt_cp_ring_for_tx (bp, txr); + hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX, close_path ? cmpl_ring_id :
@@ -5151,10 +5151,10 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];struct bnxt_ring_struct *ring = &rxr->rx_ring_struct;u32 grp_idx = rxr->bnapi->index; -u32 cmpl_ring_id; - cmpl_ring_id =bnxt_cp_ring_for_rx (bp, rxr);if (ring->fw_ring_id !=INVALID_HW_RING_ID ) { +u32 cmpl_ring_id =bnxt_cp_ring_for_rx (bp, rxr); + hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_RX, close_path ? cmpl_ring_id :
@@ -5173,10 +5173,10 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];struct bnxt_ring_struct *ring = &rxr->rx_agg_ring_struct;u32 grp_idx = rxr->bnapi->index; -u32 cmpl_ring_id; - cmpl_ring_id =bnxt_cp_ring_for_rx (bp, rxr);if (ring->fw_ring_id !=INVALID_HW_RING_ID ) { +u32 cmpl_ring_id =bnxt_cp_ring_for_rx (bp, rxr); +hwrm_ring_free_send_msg (bp, ring, type, close_path ? cmpl_ring_id :INVALID_HW_RING_ID );
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 4/6 bnxt_en: Pass correct extended TX port statistics size to firmware.
In reply to Michael ChanIf driver determines that extended TX port statistics are not supported or allocation of the data structure fails, make sure to pass 0 TX stats size to firmware to disable it. The firmware returned TX stats size should also be set to 0 for consistency. This will prevent bnxt_get_ethtool_stats() from accessing the NULL TX stats pointer in case there is mismatch between firmware and driver.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -2
@@ -6753,6 +6753,7 @@ static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp)struct hwrm_queue_pri2cos_qcfg_input req2 = {0 };struct hwrm_port_qstats_ext_input req = {0 };struct bnxt_pf_info *pf = &bp->pf; +u32 tx_stat_size;int rc;if (!(bp->flags &BNXT_FLAG_PORT_STATS_EXT ))
@@ -6762,13 +6763,16 @@ static int bnxt_hwrm_port_qstats_ext(struct bnxt *bp) req.port_id =cpu_to_le16 (pf->port_id); req.rx_stat_size =cpu_to_le16 (sizeof (struct rx_port_stats_ext )); req.rx_stat_host_addr =cpu_to_le64 (bp->hw_rx_port_stats_ext_map); - req.tx_stat_size =cpu_to_le16 (sizeof (struct tx_port_stats_ext )); + tx_stat_size = bp->hw_tx_port_stats_ext ? +sizeof (*bp->hw_tx_port_stats_ext) :0 ; + req.tx_stat_size =cpu_to_le16 (tx_stat_size); req.tx_stat_host_addr =cpu_to_le64 (bp->hw_tx_port_stats_ext_map);mutex_lock (&bp->hwrm_cmd_lock); rc =_hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT );if (!rc) { bp->fw_rx_stats_ext_size =le16_to_cpu (resp->rx_stat_size) /8 ; - bp->fw_tx_stats_ext_size =le16_to_cpu (resp->tx_stat_size) /8 ; + bp->fw_tx_stats_ext_size = tx_stat_size ? +le16_to_cpu (resp->tx_stat_size) /8 :0 ; }else { bp->fw_rx_stats_ext_size =0 ; bp->fw_tx_stats_ext_size =0 ;
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 5/6 bnxt_en: Fix statistics context reservation logic.
In reply to Michael ChanIn an earlier commit that fixes the number of stats contexts to reserve for the RDMA driver, we added a function parameter to pass in the number of stats contexts to all the relevant functions. The passed in parameter should have been used to set the enables field of the firmware message.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -8
@@ -5315,17 +5315,16 @@ __bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, struct hwrm_func_cfg_input *req, req->num_tx_rings =cpu_to_le16 (tx_rings);if (BNXT_NEW_RM (bp)) { enables |= rx_rings ?FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS :0 ; + enables |= stats ?FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS :0 ;if (bp->flags &BNXT_FLAG_CHIP_P5 ) { enables |= cp_rings ?FUNC_CFG_REQ_ENABLES_NUM_MSIX :0 ; enables |= tx_rings + ring_grps ? -FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS | -FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS :0 ; +FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS :0 ; enables |= rx_rings ?FUNC_CFG_REQ_ENABLES_NUM_RSSCOS_CTXS :0 ; }else { enables |= cp_rings ? -FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS | -FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS :0 ; +FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS :0 ; enables |= ring_grps ?FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS |FUNC_CFG_REQ_ENABLES_NUM_RSSCOS_CTXS :0 ;
@@ -5365,14 +5364,13 @@ __bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, enables |= tx_rings ?FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS :0 ; enables |= rx_rings ?FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS |FUNC_VF_CFG_REQ_ENABLES_NUM_RSSCOS_CTXS :0 ; + enables |= stats ?FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS :0 ;if (bp->flags &BNXT_FLAG_CHIP_P5 ) { enables |= tx_rings + ring_grps ? -FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS | -FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS :0 ; +FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS :0 ; }else { enables |= cp_rings ? -FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS | -FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS :0 ; +FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS :0 ; enables |= ring_grps ?FUNC_VF_CFG_REQ_ENABLES_NUM_HW_RING_GRPS :0 ; }
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 6/6 bnxt_en: Fix uninitialized variable usage in bnxt_rx_pkt().
In reply to Michael ChanIn bnxt_rx_pkt(), if the driver encounters BD errors, it will recycle the buffers and jump to the end where the uninitailized variable "len" is referenced. Fix it by adding a new jump label that will skip the length update. This is the most correct fix since the length may not be valid when we get this type of error.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -4
@@ -1625,7 +1625,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,netdev_warn (bp->dev,"RX buffer error %x\n" , rx_err);bnxt_sched_reset (bp, rxr); } - goto next_rx; + goto next_rx_no_len; } len =le32_to_cpu (rxcmp->rx_cmp_len_flags_type) >>RX_CMP_LEN_SHIFT ;
@@ -1706,12 +1706,13 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, rc =1 ; next_rx: - rxr->rx_prod =NEXT_RX (prod); - rxr->rx_next_cons =NEXT_RX (cons); - cpr->rx_packets +=1 ; cpr->rx_bytes += len; +next_rx_no_len: + rxr->rx_prod =NEXT_RX (prod); + rxr->rx_next_cons =NEXT_RX (cons); + next_rx_no_prod_no_len: *raw_cons = tmp_raw_cons;
Signature · 1 line
2.5.1
Re: [PATCH net 6/6] bnxt_en: Fix uninitialized variable usage in bnxt_rx_pkt().
Quoted 10 lines · Michael Chan
In
bnxt_rx_pkt(), if the driver encounters BD errors, it will recycle the buffers and jump to the end where the uninitailized variable "len" is referenced. Fix it by adding a new jump label that will skip the length update. This is the most correct fix since the length may not be valid when we get this type of error.Fixes 6a8788f25625 ("bnxt_en: add support for software dynamic interrupt moderation")Reported-by Nathan Chancellor <[email protected]>Cc Nathan Chancellor <[email protected]>Signed-off-by Michael Chan <[email protected]>
This indeed fixes the warning, thank you!
Quoted 37 lines
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/net/ethernet/broadcom/bnxt/bnxt.c +5
-4@@ -1625,7 +1625,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,netdev_warn (bp->dev,"RX buffer error %x\n" , rx_err);bnxt_sched_reset (bp, rxr); } - goto next_rx; + goto next_rx_no_len; } len =le32_to_cpu (rxcmp->rx_cmp_len_flags_type) >>RX_CMP_LEN_SHIFT ;@@ -1706,12 +1706,13 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, rc =1 ; next_rx: - rxr->rx_prod =NEXT_RX (prod); - rxr->rx_next_cons =NEXT_RX (cons); - cpr->rx_packets +=1 ; cpr->rx_bytes += len; +next_rx_no_len: + rxr->rx_prod =NEXT_RX (prod); + rxr->rx_next_cons =NEXT_RX (cons); + next_rx_no_prod_no_len: *raw_cons = tmp_raw_cons;Signature · 1 line
2.5.1
David Miller
maintainerFrom: Michael Chan <[email protected]>
Date: Thu, 25 Apr 2019 22:31:49 -0400
Quoted 7 lines
6 miscellaneous bug fixes covering several issues in error code paths, a setup issue for statistics DMA, and an improvement for setting up multicast address filters.
Please queue these for stable as well.
Patch #5 (bnxt_en: Fix statistics context reservation logic) is for the most recent 5.0 stable only. Thanks.
Series applied and queued up for -stable, thanks.