aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x/bnx2x_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bnx2x/bnx2x_main.c')
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c189
1 files changed, 17 insertions, 172 deletions
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 660c94560266..4be5480ecc5b 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -4447,7 +4447,7 @@ static void bnx2x_init_fp_sb(struct bnx2x *bp, int fp_idx)
4447 4447
4448 fp->state = BNX2X_FP_STATE_CLOSED; 4448 fp->state = BNX2X_FP_STATE_CLOSED;
4449 4449
4450 fp->index = fp->cid = fp_idx; 4450 fp->cid = fp_idx;
4451 fp->cl_id = BP_L_ID(bp) + fp_idx; 4451 fp->cl_id = BP_L_ID(bp) + fp_idx;
4452 fp->fw_sb_id = bp->base_fw_ndsb + fp->cl_id + CNIC_CONTEXT_USE; 4452 fp->fw_sb_id = bp->base_fw_ndsb + fp->cl_id + CNIC_CONTEXT_USE;
4453 fp->igu_sb_id = bp->igu_base_sb + fp_idx + CNIC_CONTEXT_USE; 4453 fp->igu_sb_id = bp->igu_base_sb + fp_idx + CNIC_CONTEXT_USE;
@@ -4559,9 +4559,11 @@ gunzip_nomem1:
4559 4559
4560static void bnx2x_gunzip_end(struct bnx2x *bp) 4560static void bnx2x_gunzip_end(struct bnx2x *bp)
4561{ 4561{
4562 kfree(bp->strm->workspace); 4562 if (bp->strm) {
4563 kfree(bp->strm); 4563 kfree(bp->strm->workspace);
4564 bp->strm = NULL; 4564 kfree(bp->strm);
4565 bp->strm = NULL;
4566 }
4565 4567
4566 if (bp->gunzip_buf) { 4568 if (bp->gunzip_buf) {
4567 dma_free_coherent(&bp->pdev->dev, FW_BUF_SIZE, bp->gunzip_buf, 4569 dma_free_coherent(&bp->pdev->dev, FW_BUF_SIZE, bp->gunzip_buf,
@@ -5869,9 +5871,6 @@ int bnx2x_init_hw(struct bnx2x *bp, u32 load_code)
5869 5871
5870 bp->dmae_ready = 0; 5872 bp->dmae_ready = 0;
5871 spin_lock_init(&bp->dmae_lock); 5873 spin_lock_init(&bp->dmae_lock);
5872 rc = bnx2x_gunzip_init(bp);
5873 if (rc)
5874 return rc;
5875 5874
5876 switch (load_code) { 5875 switch (load_code) {
5877 case FW_MSG_CODE_DRV_LOAD_COMMON: 5876 case FW_MSG_CODE_DRV_LOAD_COMMON:
@@ -5915,80 +5914,10 @@ init_hw_err:
5915 5914
5916void bnx2x_free_mem(struct bnx2x *bp) 5915void bnx2x_free_mem(struct bnx2x *bp)
5917{ 5916{
5918 5917 bnx2x_gunzip_end(bp);
5919#define BNX2X_PCI_FREE(x, y, size) \
5920 do { \
5921 if (x) { \
5922 dma_free_coherent(&bp->pdev->dev, size, (void *)x, y); \
5923 x = NULL; \
5924 y = 0; \
5925 } \
5926 } while (0)
5927
5928#define BNX2X_FREE(x) \
5929 do { \
5930 if (x) { \
5931 kfree((void *)x); \
5932 x = NULL; \
5933 } \
5934 } while (0)
5935
5936 int i;
5937 5918
5938 /* fastpath */ 5919 /* fastpath */
5939 /* Common */ 5920 bnx2x_free_fp_mem(bp);
5940 for_each_queue(bp, i) {
5941#ifdef BCM_CNIC
5942 /* FCoE client uses default status block */
5943 if (IS_FCOE_IDX(i)) {
5944 union host_hc_status_block *sb =
5945 &bnx2x_fp(bp, i, status_blk);
5946 memset(sb, 0, sizeof(union host_hc_status_block));
5947 bnx2x_fp(bp, i, status_blk_mapping) = 0;
5948 } else {
5949#endif
5950 /* status blocks */
5951 if (CHIP_IS_E2(bp))
5952 BNX2X_PCI_FREE(bnx2x_fp(bp, i, status_blk.e2_sb),
5953 bnx2x_fp(bp, i, status_blk_mapping),
5954 sizeof(struct host_hc_status_block_e2));
5955 else
5956 BNX2X_PCI_FREE(bnx2x_fp(bp, i, status_blk.e1x_sb),
5957 bnx2x_fp(bp, i, status_blk_mapping),
5958 sizeof(struct host_hc_status_block_e1x));
5959#ifdef BCM_CNIC
5960 }
5961#endif
5962 }
5963 /* Rx */
5964 for_each_rx_queue(bp, i) {
5965
5966 /* fastpath rx rings: rx_buf rx_desc rx_comp */
5967 BNX2X_FREE(bnx2x_fp(bp, i, rx_buf_ring));
5968 BNX2X_PCI_FREE(bnx2x_fp(bp, i, rx_desc_ring),
5969 bnx2x_fp(bp, i, rx_desc_mapping),
5970 sizeof(struct eth_rx_bd) * NUM_RX_BD);
5971
5972 BNX2X_PCI_FREE(bnx2x_fp(bp, i, rx_comp_ring),
5973 bnx2x_fp(bp, i, rx_comp_mapping),
5974 sizeof(struct eth_fast_path_rx_cqe) *
5975 NUM_RCQ_BD);
5976
5977 /* SGE ring */
5978 BNX2X_FREE(bnx2x_fp(bp, i, rx_page_ring));
5979 BNX2X_PCI_FREE(bnx2x_fp(bp, i, rx_sge_ring),
5980 bnx2x_fp(bp, i, rx_sge_mapping),
5981 BCM_PAGE_SIZE * NUM_RX_SGE_PAGES);
5982 }
5983 /* Tx */
5984 for_each_tx_queue(bp, i) {
5985
5986 /* fastpath tx rings: tx_buf tx_desc */
5987 BNX2X_FREE(bnx2x_fp(bp, i, tx_buf_ring));
5988 BNX2X_PCI_FREE(bnx2x_fp(bp, i, tx_desc_ring),
5989 bnx2x_fp(bp, i, tx_desc_mapping),
5990 sizeof(union eth_tx_bd_types) * NUM_TX_BD);
5991 }
5992 /* end of fastpath */ 5921 /* end of fastpath */
5993 5922
5994 BNX2X_PCI_FREE(bp->def_status_blk, bp->def_status_blk_mapping, 5923 BNX2X_PCI_FREE(bp->def_status_blk, bp->def_status_blk_mapping,
@@ -6021,101 +5950,13 @@ void bnx2x_free_mem(struct bnx2x *bp)
6021 BCM_PAGE_SIZE * NUM_EQ_PAGES); 5950 BCM_PAGE_SIZE * NUM_EQ_PAGES);
6022 5951
6023 BNX2X_FREE(bp->rx_indir_table); 5952 BNX2X_FREE(bp->rx_indir_table);
6024
6025#undef BNX2X_PCI_FREE
6026#undef BNX2X_KFREE
6027} 5953}
6028 5954
6029static inline void set_sb_shortcuts(struct bnx2x *bp, int index)
6030{
6031 union host_hc_status_block status_blk = bnx2x_fp(bp, index, status_blk);
6032 if (CHIP_IS_E2(bp)) {
6033 bnx2x_fp(bp, index, sb_index_values) =
6034 (__le16 *)status_blk.e2_sb->sb.index_values;
6035 bnx2x_fp(bp, index, sb_running_index) =
6036 (__le16 *)status_blk.e2_sb->sb.running_index;
6037 } else {
6038 bnx2x_fp(bp, index, sb_index_values) =
6039 (__le16 *)status_blk.e1x_sb->sb.index_values;
6040 bnx2x_fp(bp, index, sb_running_index) =
6041 (__le16 *)status_blk.e1x_sb->sb.running_index;
6042 }
6043}
6044 5955
6045int bnx2x_alloc_mem(struct bnx2x *bp) 5956int bnx2x_alloc_mem(struct bnx2x *bp)
6046{ 5957{
6047#define BNX2X_PCI_ALLOC(x, y, size) \ 5958 if (bnx2x_gunzip_init(bp))
6048 do { \ 5959 return -ENOMEM;
6049 x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
6050 if (x == NULL) \
6051 goto alloc_mem_err; \
6052 memset(x, 0, size); \
6053 } while (0)
6054
6055#define BNX2X_ALLOC(x, size) \
6056 do { \
6057 x = kzalloc(size, GFP_KERNEL); \
6058 if (x == NULL) \
6059 goto alloc_mem_err; \
6060 } while (0)
6061
6062 int i;
6063
6064 /* fastpath */
6065 /* Common */
6066 for_each_queue(bp, i) {
6067 union host_hc_status_block *sb = &bnx2x_fp(bp, i, status_blk);
6068 bnx2x_fp(bp, i, bp) = bp;
6069 /* status blocks */
6070#ifdef BCM_CNIC
6071 if (!IS_FCOE_IDX(i)) {
6072#endif
6073 if (CHIP_IS_E2(bp))
6074 BNX2X_PCI_ALLOC(sb->e2_sb,
6075 &bnx2x_fp(bp, i, status_blk_mapping),
6076 sizeof(struct host_hc_status_block_e2));
6077 else
6078 BNX2X_PCI_ALLOC(sb->e1x_sb,
6079 &bnx2x_fp(bp, i, status_blk_mapping),
6080 sizeof(struct host_hc_status_block_e1x));
6081#ifdef BCM_CNIC
6082 }
6083#endif
6084 set_sb_shortcuts(bp, i);
6085 }
6086 /* Rx */
6087 for_each_queue(bp, i) {
6088
6089 /* fastpath rx rings: rx_buf rx_desc rx_comp */
6090 BNX2X_ALLOC(bnx2x_fp(bp, i, rx_buf_ring),
6091 sizeof(struct sw_rx_bd) * NUM_RX_BD);
6092 BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, rx_desc_ring),
6093 &bnx2x_fp(bp, i, rx_desc_mapping),
6094 sizeof(struct eth_rx_bd) * NUM_RX_BD);
6095
6096 BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, rx_comp_ring),
6097 &bnx2x_fp(bp, i, rx_comp_mapping),
6098 sizeof(struct eth_fast_path_rx_cqe) *
6099 NUM_RCQ_BD);
6100
6101 /* SGE ring */
6102 BNX2X_ALLOC(bnx2x_fp(bp, i, rx_page_ring),
6103 sizeof(struct sw_rx_page) * NUM_RX_SGE);
6104 BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, rx_sge_ring),
6105 &bnx2x_fp(bp, i, rx_sge_mapping),
6106 BCM_PAGE_SIZE * NUM_RX_SGE_PAGES);
6107 }
6108 /* Tx */
6109 for_each_queue(bp, i) {
6110
6111 /* fastpath tx rings: tx_buf tx_desc */
6112 BNX2X_ALLOC(bnx2x_fp(bp, i, tx_buf_ring),
6113 sizeof(struct sw_tx_bd) * NUM_TX_BD);
6114 BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, tx_desc_ring),
6115 &bnx2x_fp(bp, i, tx_desc_mapping),
6116 sizeof(union eth_tx_bd_types) * NUM_TX_BD);
6117 }
6118 /* end of fastpath */
6119 5960
6120#ifdef BCM_CNIC 5961#ifdef BCM_CNIC
6121 if (CHIP_IS_E2(bp)) 5962 if (CHIP_IS_E2(bp))
@@ -6155,14 +5996,18 @@ int bnx2x_alloc_mem(struct bnx2x *bp)
6155 5996
6156 BNX2X_ALLOC(bp->rx_indir_table, sizeof(bp->rx_indir_table[0]) * 5997 BNX2X_ALLOC(bp->rx_indir_table, sizeof(bp->rx_indir_table[0]) *
6157 TSTORM_INDIRECTION_TABLE_SIZE); 5998 TSTORM_INDIRECTION_TABLE_SIZE);
5999
6000 /* fastpath */
6001 /* need to be done at the end, since it's self adjusting to amount
6002 * of memory available for RSS queues
6003 */
6004 if (bnx2x_alloc_fp_mem(bp))
6005 goto alloc_mem_err;
6158 return 0; 6006 return 0;
6159 6007
6160alloc_mem_err: 6008alloc_mem_err:
6161 bnx2x_free_mem(bp); 6009 bnx2x_free_mem(bp);
6162 return -ENOMEM; 6010 return -ENOMEM;
6163
6164#undef BNX2X_PCI_ALLOC
6165#undef BNX2X_ALLOC
6166} 6011}
6167 6012
6168/* 6013/*