Commit a220eabc authored by Vasundhara Volam's avatar Vasundhara Volam Committed by David S. Miller

bnxt_en: Refactor bnxt_alloc_stats().

Reverse the condition of the large "if" block and return early.  This
will simplify the follow up patch to add PCIe statistics.
Signed-off-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a50ddc2
......@@ -3440,7 +3440,9 @@ static int bnxt_alloc_stats(struct bnxt *bp)
cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID;
}
if (BNXT_PF(bp) && bp->chip_num != CHIP_NUM_58700) {
if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700)
return 0;
if (bp->hw_rx_port_stats)
goto alloc_ext_stats;
......@@ -3454,26 +3456,22 @@ static int bnxt_alloc_stats(struct bnxt *bp)
if (!bp->hw_rx_port_stats)
return -ENOMEM;
bp->hw_tx_port_stats = (void *)(bp->hw_rx_port_stats + 1) +
512;
bp->hw_tx_port_stats = (void *)(bp->hw_rx_port_stats + 1) + 512;
bp->hw_tx_port_stats_map = bp->hw_rx_port_stats_map +
sizeof(struct rx_port_stats) + 512;
bp->flags |= BNXT_FLAG_PORT_STATS;
alloc_ext_stats:
/* Display extended statistics only if FW supports it */
if (bp->hwrm_spec_code < 0x10804 ||
bp->hwrm_spec_code == 0x10900)
if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900)
return 0;
if (bp->hw_rx_port_stats_ext)
goto alloc_tx_ext_stats;
bp->hw_rx_port_stats_ext =
dma_alloc_coherent(&pdev->dev,
sizeof(struct rx_port_stats_ext),
&bp->hw_rx_port_stats_ext_map,
GFP_KERNEL);
dma_alloc_coherent(&pdev->dev, sizeof(struct rx_port_stats_ext),
&bp->hw_rx_port_stats_ext_map, GFP_KERNEL);
if (!bp->hw_rx_port_stats_ext)
return 0;
......@@ -3489,7 +3487,6 @@ static int bnxt_alloc_stats(struct bnxt *bp)
GFP_KERNEL);
}
bp->flags |= BNXT_FLAG_PORT_STATS_EXT;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment