cnic: Fine-tune CID memory space calculation.
Subsystems (2)
PATCH 1/6 cnic: Fine-tune CID memory space calculation.
The current code makes assumptions about the CID (context ID) memory space and starting CID that may not be always correct when firmware changes. In particular, BNX2_ISCSI_START_CID may not always be fixed. We now calculate cp->max_cid_space and cp->iscsi_start_cid dynamically instead of using fixed constants. The unused cp->max_iscsi_conn is also eliminated.
--- drivers/net/cnic.c | 32 ++++++++++++++++++-------------- drivers/net/cnic.h | 4 +++- 2 files changed, 21 insertions(+), 15 deletions(-)
drivers/net/cnic.c +18 -14
@@ -257,7 +257,7 @@ static int cnic_get_l5_cid(struct cnic_local *cp, u32 cid, u32 *l5_cid) {u32 i; -for (i =0 ; i <MAX_ISCSI_TBL_SZ ; i++) { +for (i =0 ; i < cp->max_cid_space; i++) {if (cp->ctx_tbl[i].cid == cid) { *l5_cid = i;return 0 ;
@@ -981,17 +981,10 @@ error:static int cnic_alloc_bnx2x_context (struct cnic_dev *dev) {struct cnic_local *cp = dev->cnic_priv; -struct cnic_eth_dev *ethdev = cp->ethdev;int ctx_blk_size = cp->ethdev->ctx_blk_size; -int total_mem, blks, i, cid_space; - -if (BNX2X_ISCSI_START_CID < ethdev->starting_cid) -return -EINVAL ; - - cid_space =MAX_ISCSI_TBL_SZ + - (BNX2X_ISCSI_START_CID - ethdev->starting_cid); +int total_mem, blks, i; - total_mem =BNX2X_CONTEXT_MEM_SIZE * cid_space; + total_mem =BNX2X_CONTEXT_MEM_SIZE * cp->max_cid_space; blks = total_mem / ctx_blk_size;if (total_mem % ctx_blk_size) blks++;
@@ -1035,16 +1028,27 @@ static int cnic_alloc_bnx2x_context(struct cnic_dev *dev)static int cnic_alloc_bnx2x_resc (struct cnic_dev *dev) {struct cnic_local *cp = dev->cnic_priv; +struct cnic_eth_dev *ethdev = cp->ethdev; +u32 start_cid = ethdev->starting_cid;int i, j, n, ret, pages;struct cnic_dma *kwq_16_dma = &cp->kwq_16_data_info; + cp->max_cid_space =MAX_ISCSI_TBL_SZ ; + cp->iscsi_start_cid = start_cid; +if (start_cid <BNX2X_ISCSI_START_CID ) { +u32 delta =BNX2X_ISCSI_START_CID - start_cid; + + cp->iscsi_start_cid =BNX2X_ISCSI_START_CID ; + cp->max_cid_space += delta; + } + cp->iscsi_tbl =kzalloc (sizeof (struct cnic_iscsi ) *MAX_ISCSI_TBL_SZ ,GFP_KERNEL );if (!cp->iscsi_tbl) goto error; cp->ctx_tbl =kzalloc (sizeof (struct cnic_context ) * -MAX_CNIC_L5_CONTEXT ,GFP_KERNEL ); + cp->max_cid_space,GFP_KERNEL );if (!cp->ctx_tbl) goto error;
@@ -1053,7 +1057,7 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) cp->ctx_tbl[i].ulp_proto_id =CNIC_ULP_ISCSI ; } - pages =PAGE_ALIGN (MAX_CNIC_L5_CONTEXT *CNIC_KWQ16_DATA_SIZE ) / + pages =PAGE_ALIGN (cp->max_cid_space *CNIC_KWQ16_DATA_SIZE ) /PAGE_SIZE ; ret =cnic_alloc_dma (dev, kwq_16_dma, pages,0 );
@@ -1061,7 +1065,7 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev)return -ENOMEM ; n =PAGE_SIZE /CNIC_KWQ16_DATA_SIZE ; -for (i =0 , j =0 ; i <MAX_ISCSI_TBL_SZ ; i++) { +for (i =0 , j =0 ; i < cp->max_cid_space; i++) {long off =CNIC_KWQ16_DATA_SIZE * (i % n); cp->ctx_tbl[i].kwqe_data = kwq_16_dma->pg_arr[j] + off;
@@ -4116,7 +4120,7 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev)u8 sb_id = cp->status_blk_num; ret =cnic_init_id_tbl (&cp->cid_tbl,MAX_ISCSI_TBL_SZ , -BNX2X_ISCSI_START_CID ); + cp->iscsi_start_cid);if (ret)return -ENOMEM ;
drivers/net/cnic.h +3 -1
@@ -248,8 +248,10 @@ struct cnic_local {struct cnic_iscsi *iscsi_tbl;struct cnic_context *ctx_tbl;struct cnic_id_tbl cid_tbl; -int max_iscsi_conn;atomic_t iscsi_conn; +u32 iscsi_start_cid; + +u32 max_cid_space;/* per connection parameters */ int num_iscsi_tasks;
Signature · 1 line
1.6.4.GIT
PATCH 2/6 cnic: Unify IRQ code for all hardware types.
By creating a common cnic_doirq().
--- drivers/net/cnic.c | 33 ++++++++++++++++++++------------- 1 files changed, 20 insertions(+), 13 deletions(-)
drivers/net/cnic.c +20 -13
@@ -2188,6 +2188,9 @@ static void cnic_chk_pkt_rings(struct cnic_local *cp)u16 tx_cons = *cp->tx_cons_ptr;int comp =0 ; +if (!test_bit (CNIC_F_CNIC_UP , &cp->dev->flags)) +return ; +if (cp->tx_cons != tx_cons || cp->rx_cons != rx_cons) {if (test_bit (CNIC_LCL_FL_L2_WAIT , &cp->cnic_local_flags)) comp =cnic_l2_completion (cp);
@@ -2284,20 +2287,28 @@ done: BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | cp->last_status_idx); } +static void cnic_doirq (struct cnic_dev *dev) +{ +struct cnic_local *cp = dev->cnic_priv; +u16 prod = cp->kcq_prod_idx &MAX_KCQ_IDX ; + +if (likely (test_bit (CNIC_F_CNIC_UP , &dev->flags))) { +prefetch (cp->status_blk.gen); +prefetch (&cp->kcq[KCQ_PG (prod)][KCQ_IDX (prod)]); + +tasklet_schedule (&cp->cnic_irq_task); + } +} +static irqreturn_t cnic_irq (int irq,void *dev_instance) {struct cnic_dev *dev = dev_instance;struct cnic_local *cp = dev->cnic_priv; -u16 prod = cp->kcq_prod_idx &MAX_KCQ_IDX ;if (cp->ack_int) cp->ack_int (dev); -prefetch (cp->status_blk.gen); -prefetch (&cp->kcq[KCQ_PG (prod)][KCQ_IDX (prod)]); - -if (likely (test_bit (CNIC_F_CNIC_UP , &dev->flags))) -tasklet_schedule (&cp->cnic_irq_task); +cnic_doirq (dev);return IRQ_HANDLED ; }
@@ -2373,15 +2384,11 @@ static int cnic_service_bnx2x(void *data, void *status_blk) {struct cnic_dev *dev = data;struct cnic_local *cp = dev->cnic_priv; -u16 prod = cp->kcq_prod_idx &MAX_KCQ_IDX ; -if (likely (test_bit (CNIC_F_CNIC_UP , &dev->flags))) { -prefetch (cp->status_blk.bnx2x); -prefetch (&cp->kcq[KCQ_PG (prod)][KCQ_IDX (prod)]); +if (!(cp->ethdev->drv_state &CNIC_DRV_STATE_USING_MSIX )) +cnic_doirq (dev); -tasklet_schedule (&cp->cnic_irq_task); -cnic_chk_pkt_rings (cp); - } +cnic_chk_pkt_rings (cp);return 0 ; }
Signature · 1 line
1.6.4.GIT
PATCH 3/6 cnic: Unify kcq allocation for all devices.
By creating a common data stucture kcq_info for all devices, the kcq (kernel completion queue) for all devices can be allocated by common code.
--- drivers/net/cnic.c | 143 +++++++++++++++++++++++++++++++-------------------- drivers/net/cnic.h | 19 ++++--- 2 files changed, 98 insertions(+), 64 deletions(-)
drivers/net/cnic.c +87 -56
@@ -804,7 +804,7 @@ static void cnic_free_resc(struct cnic_dev *dev)cnic_free_dma (dev, &cp->conn_buf_info);cnic_free_dma (dev, &cp->kwq_info);cnic_free_dma (dev, &cp->kwq_16_data_info); -cnic_free_dma (dev, &cp->kcq_info); +cnic_free_dma (dev, &cp->kcq1.dma);kfree (cp->iscsi_tbl); cp->iscsi_tbl =NULL ;kfree (cp->ctx_tbl);
@@ -863,6 +863,37 @@ static int cnic_alloc_context(struct cnic_dev *dev)return 0 ; } +static int cnic_alloc_kcq (struct cnic_dev *dev,struct kcq_info *info) +{ +int err, i, is_bnx2 =0 ; +struct kcqe **kcq; + +if (test_bit (CNIC_F_BNX2_CLASS , &dev->flags)) + is_bnx2 =1 ; + + err =cnic_alloc_dma (dev, &info->dma,KCQ_PAGE_CNT , is_bnx2); +if (err) +return err; + + kcq = (struct kcqe **) info->dma.pg_arr; + info->kcq = kcq; + +if (is_bnx2) +return 0 ; + +for (i =0 ; i <KCQ_PAGE_CNT ; i++) { +struct bnx2x_bd_chain_next *next = + (struct bnx2x_bd_chain_next *) &kcq[i][MAX_KCQE_CNT ]; +int j = i +1 ; + +if (j >=KCQ_PAGE_CNT ) + j =0 ; + next->addr_hi = (u64 ) info->dma.pg_map_arr[j] >>32 ; + next->addr_lo = info->dma.pg_map_arr[j] &0xffffffff ; + } +return 0 ; +} +static int cnic_alloc_l2_rings (struct cnic_dev *dev,int pages) {struct cnic_local *cp = dev->cnic_priv;
@@ -954,10 +985,9 @@ static int cnic_alloc_bnx2_resc(struct cnic_dev *dev) goto error; cp->kwq = (struct kwqe **) cp->kwq_info.pg_arr; - ret =cnic_alloc_dma (dev, &cp->kcq_info,KCQ_PAGE_CNT ,1 ); + ret =cnic_alloc_kcq (dev, &cp->kcq1);if (ret) goto error; - cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr; ret =cnic_alloc_context (dev);if (ret)
@@ -1076,22 +1106,9 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) j++; } - ret =cnic_alloc_dma (dev, &cp->kcq_info,KCQ_PAGE_CNT ,0 ); + ret =cnic_alloc_kcq (dev, &cp->kcq1);if (ret) goto error; - cp->kcq = (struct kcqe **) cp->kcq_info.pg_arr; - -for (i =0 ; i <KCQ_PAGE_CNT ; i++) { -struct bnx2x_bd_chain_next *next = - (struct bnx2x_bd_chain_next *) - &cp->kcq[i][MAX_KCQE_CNT ]; -int j = i +1 ; - -if (j >=KCQ_PAGE_CNT ) - j =0 ; - next->addr_hi = (u64 ) cp->kcq_info.pg_map_arr[j] >>32 ; - next->addr_lo = cp->kcq_info.pg_map_arr[j] &0xffffffff ; - } pages =PAGE_ALIGN (BNX2X_ISCSI_NUM_CONNECTIONS *BNX2X_ISCSI_CONN_BUF_SIZE ) /PAGE_SIZE ;
@@ -2135,7 +2152,7 @@ static int cnic_get_kcqes(struct cnic_dev *dev, u16 hw_prod, u16 *sw_prod) ri &=MAX_KCQ_IDX ;while ((i != hw_prod) && (kcqe_cnt <MAX_COMPLETED_KCQE )) { - kcqe = &cp->kcq[KCQ_PG (ri)][KCQ_IDX (ri)]; + kcqe = &cp->kcq1.kcq[KCQ_PG (ri)][KCQ_IDX (ri)]; cp->completed_kcq[kcqe_cnt++] = kcqe; i = cp->next_idx (i); ri = i &MAX_KCQ_IDX ;
@@ -2219,7 +2236,7 @@ static int cnic_service_bnx2(void *data, void *status_blk) cp->kwq_con_idx = *cp->kwq_con_idx_ptr; hw_prod = sblk->status_completion_producer_index; - sw_prod = cp->kcq_prod_idx; + sw_prod = cp->kcq1.sw_prod_idx;while (sw_prod != hw_prod) { kcqe_cnt =cnic_get_kcqes (dev, hw_prod, &sw_prod);if (kcqe_cnt ==0 )
@@ -2238,9 +2255,9 @@ static int cnic_service_bnx2(void *data, void *status_blk) } done: -CNIC_WR16 (dev, cp->kcq_io_addr, sw_prod); +CNIC_WR16 (dev, cp->kcq1.io_addr, sw_prod); - cp->kcq_prod_idx = sw_prod; + cp->kcq1.sw_prod_idx = sw_prod;cnic_chk_pkt_rings (cp);return status_idx;
@@ -2258,7 +2275,7 @@ static void cnic_service_bnx2_msix(unsigned long data) cp->kwq_con_idx = status_blk->status_cmd_consumer_index; hw_prod = status_blk->status_completion_producer_index; - sw_prod = cp->kcq_prod_idx; + sw_prod = cp->kcq1.sw_prod_idx;while (sw_prod != hw_prod) { kcqe_cnt =cnic_get_kcqes (dev, hw_prod, &sw_prod);if (kcqe_cnt ==0 )
@@ -2277,8 +2294,8 @@ static void cnic_service_bnx2_msix(unsigned long data) } done: -CNIC_WR16 (dev, cp->kcq_io_addr, sw_prod); - cp->kcq_prod_idx = sw_prod; +CNIC_WR16 (dev, cp->kcq1.io_addr, sw_prod); + cp->kcq1.sw_prod_idx = sw_prod;cnic_chk_pkt_rings (cp);
@@ -2290,11 +2307,11 @@ done:static void cnic_doirq (struct cnic_dev *dev) {struct cnic_local *cp = dev->cnic_priv; -u16 prod = cp->kcq_prod_idx &MAX_KCQ_IDX ; +u16 prod = cp->kcq1.sw_prod_idx &MAX_KCQ_IDX ;if (likely (test_bit (CNIC_F_CNIC_UP , &dev->flags))) {prefetch (cp->status_blk.gen); -prefetch (&cp->kcq[KCQ_PG (prod)][KCQ_IDX (prod)]); +prefetch (&cp->kcq1.kcq[KCQ_PG (prod)][KCQ_IDX (prod)]);tasklet_schedule (&cp->cnic_irq_task); }
@@ -2354,7 +2371,7 @@ static void cnic_service_bnx2x_bh(unsigned long data) hw_prod = sblk->index_values[HC_INDEX_C_ISCSI_EQ_CONS ]; hw_prod = cp->hw_idx (hw_prod); - sw_prod = cp->kcq_prod_idx; + sw_prod = cp->kcq1.sw_prod_idx;while (sw_prod != hw_prod) { kcqe_cnt =cnic_get_kcqes (dev, hw_prod, &sw_prod);if (kcqe_cnt ==0 )
@@ -2373,11 +2390,11 @@ static void cnic_service_bnx2x_bh(unsigned long data) } done: -CNIC_WR16 (dev, cp->kcq_io_addr, sw_prod +MAX_KCQ_IDX ); +CNIC_WR16 (dev, cp->kcq1.io_addr, sw_prod +MAX_KCQ_IDX );cnic_ack_bnx2x_int (dev, cp->status_blk_num,CSTORM_ID , status_idx,IGU_INT_ENABLE ,1 ); - cp->kcq_prod_idx = sw_prod; + cp->kcq1.sw_prod_idx = sw_prod; }static int cnic_service_bnx2x (void *data,void *status_blk)
@@ -3711,7 +3728,7 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)struct cnic_local *cp = dev->cnic_priv;struct cnic_eth_dev *ethdev = cp->ethdev;struct status_block *sblk = cp->status_blk.gen; -u32 val; +u32 val, kcq_cid_addr, kwq_cid_addr;int err;cnic_set_bnx2_mac (dev);
@@ -3736,7 +3753,7 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)cnic_init_context (dev,KWQ_CID );cnic_init_context (dev,KCQ_CID ); - cp->kwq_cid_addr =GET_CID_ADDR (KWQ_CID ); + kwq_cid_addr =GET_CID_ADDR (KWQ_CID ); cp->kwq_io_addr =MB_GET_CID_ADDR (KWQ_CID ) +L5_KRNLQ_HOST_QIDX ; cp->max_kwq_idx =MAX_KWQ_IDX ;
@@ -3752,50 +3769,58 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)/* Initialize the kernel work queue context. */ val =KRNLQ_TYPE_TYPE_KRNLQ |KRNLQ_SIZE_TYPE_SIZE | (BCM_PAGE_BITS -8 ) |KRNLQ_FLAGS_QE_SELF_SEQ ; -cnic_ctx_wr (dev, cp->kwq_cid_addr,L5_KRNLQ_TYPE , val); +cnic_ctx_wr (dev, kwq_cid_addr,L5_KRNLQ_TYPE , val); val = (BCM_PAGE_SIZE /sizeof (struct kwqe ) -1 ) <<16 ; -cnic_ctx_wr (dev, cp->kwq_cid_addr,L5_KRNLQ_QE_SELF_SEQ_MAX , val); +cnic_ctx_wr (dev, kwq_cid_addr,L5_KRNLQ_QE_SELF_SEQ_MAX , val); val = ((BCM_PAGE_SIZE /sizeof (struct kwqe )) <<16 ) |KWQ_PAGE_CNT ; -cnic_ctx_wr (dev, cp->kwq_cid_addr,L5_KRNLQ_PGTBL_NPAGES , val); +cnic_ctx_wr (dev, kwq_cid_addr,L5_KRNLQ_PGTBL_NPAGES , val); val = (u32) ((u64 ) cp->kwq_info.pgtbl_map >>32 ); -cnic_ctx_wr (dev, cp->kwq_cid_addr,L5_KRNLQ_PGTBL_HADDR_HI , val); +cnic_ctx_wr (dev, kwq_cid_addr,L5_KRNLQ_PGTBL_HADDR_HI , val); val = (u32 ) cp->kwq_info.pgtbl_map; -cnic_ctx_wr (dev, cp->kwq_cid_addr,L5_KRNLQ_PGTBL_HADDR_LO , val); +cnic_ctx_wr (dev, kwq_cid_addr,L5_KRNLQ_PGTBL_HADDR_LO , val); + + kcq_cid_addr =GET_CID_ADDR (KCQ_CID ); + cp->kcq1.io_addr =MB_GET_CID_ADDR (KCQ_CID ) +L5_KRNLQ_HOST_QIDX ; - cp->kcq_cid_addr =GET_CID_ADDR (KCQ_CID ); - cp->kcq_io_addr =MB_GET_CID_ADDR (KCQ_CID ) +L5_KRNLQ_HOST_QIDX ; + cp->kcq1.sw_prod_idx =0 ; + cp->kcq1.hw_prod_idx_ptr = + (u16 *) &sblk->status_completion_producer_index; - cp->kcq_prod_idx =0 ; + cp->kcq1.status_idx_ptr = (u16 *) &sblk->status_idx;/* Initialize the kernel complete queue context. */ val =KRNLQ_TYPE_TYPE_KRNLQ |KRNLQ_SIZE_TYPE_SIZE | (BCM_PAGE_BITS -8 ) |KRNLQ_FLAGS_QE_SELF_SEQ ; -cnic_ctx_wr (dev, cp->kcq_cid_addr,L5_KRNLQ_TYPE , val); +cnic_ctx_wr (dev, kcq_cid_addr,L5_KRNLQ_TYPE , val); val = (BCM_PAGE_SIZE /sizeof (struct kcqe ) -1 ) <<16 ; -cnic_ctx_wr (dev, cp->kcq_cid_addr,L5_KRNLQ_QE_SELF_SEQ_MAX , val); +cnic_ctx_wr (dev, kcq_cid_addr,L5_KRNLQ_QE_SELF_SEQ_MAX , val); val = ((BCM_PAGE_SIZE /sizeof (struct kcqe )) <<16 ) |KCQ_PAGE_CNT ; -cnic_ctx_wr (dev, cp->kcq_cid_addr,L5_KRNLQ_PGTBL_NPAGES , val); +cnic_ctx_wr (dev, kcq_cid_addr,L5_KRNLQ_PGTBL_NPAGES , val); - val = (u32) ((u64 ) cp->kcq_info.pgtbl_map >>32 ); -cnic_ctx_wr (dev, cp->kcq_cid_addr,L5_KRNLQ_PGTBL_HADDR_HI , val); + val = (u32) ((u64 ) cp->kcq1.dma.pgtbl_map >>32 ); +cnic_ctx_wr (dev, kcq_cid_addr,L5_KRNLQ_PGTBL_HADDR_HI , val); - val = (u32 ) cp->kcq_info.pgtbl_map; -cnic_ctx_wr (dev, cp->kcq_cid_addr,L5_KRNLQ_PGTBL_HADDR_LO , val); + val = (u32 ) cp->kcq1.dma.pgtbl_map; +cnic_ctx_wr (dev, kcq_cid_addr,L5_KRNLQ_PGTBL_HADDR_LO , val); cp->int_num =0 ;if (ethdev->drv_state &CNIC_DRV_STATE_USING_MSIX ) { +struct status_block_msix *msblk = cp->status_blk.bnx2;u32 sb_id = cp->status_blk_num;u32 sb =BNX2_L2CTX_L5_STATUSB_NUM (sb_id); + cp->kcq1.hw_prod_idx_ptr = + (u16 *) &msblk->status_completion_producer_index; + cp->kcq1.status_idx_ptr = (u16 *) &msblk->status_idx; cp->int_num = sb_id <<BNX2_PCICFG_INT_ACK_CMD_INT_NUM_SHIFT ; -cnic_ctx_wr (dev, cp->kwq_cid_addr,L5_KRNLQ_HOST_QIDX , sb); -cnic_ctx_wr (dev, cp->kcq_cid_addr,L5_KRNLQ_HOST_QIDX , sb); +cnic_ctx_wr (dev, kwq_cid_addr,L5_KRNLQ_HOST_QIDX , sb); +cnic_ctx_wr (dev, kcq_cid_addr,L5_KRNLQ_HOST_QIDX , sb); }/* Enable Commnad Scheduler notification when we write to the
@@ -4132,28 +4157,34 @@ static int cnic_start_bnx2x_hw(struct cnic_dev *dev)if (ret)return -ENOMEM ; - cp->kcq_io_addr =BAR_CSTRORM_INTMEM + + cp->kcq1.io_addr =BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_PROD_OFFSET (func,0 ); - cp->kcq_prod_idx =0 ; + cp->kcq1.sw_prod_idx =0 ; + + cp->kcq1.hw_prod_idx_ptr = + &cp->status_blk.bnx2x->c_status_block.index_values[ +HC_INDEX_C_ISCSI_EQ_CONS ]; + cp->kcq1.status_idx_ptr = + &cp->status_blk.bnx2x->c_status_block.status_block_index;cnic_get_bnx2x_iscsi_info (dev);/* Only 1 EQ */ -CNIC_WR16 (dev, cp->kcq_io_addr,MAX_KCQ_IDX ); +CNIC_WR16 (dev, cp->kcq1.io_addr,MAX_KCQ_IDX );CNIC_WR (dev,BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_CONS_OFFSET (func,0 ),0 );CNIC_WR (dev,BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET (func,0 ), - cp->kcq_info.pg_map_arr[1 ] &0xffffffff ); + cp->kcq1.dma.pg_map_arr[1 ] &0xffffffff );CNIC_WR (dev,BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_OFFSET (func,0 ) +4 , - (u64 ) cp->kcq_info.pg_map_arr[1 ] >>32 ); + (u64 ) cp->kcq1.dma.pg_map_arr[1 ] >>32 );CNIC_WR (dev,BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET (func,0 ), - cp->kcq_info.pg_map_arr[0 ] &0xffffffff ); + cp->kcq1.dma.pg_map_arr[0 ] &0xffffffff );CNIC_WR (dev,BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_NEXT_EQE_ADDR_OFFSET (func,0 ) +4 , - (u64 ) cp->kcq_info.pg_map_arr[0 ] >>32 ); + (u64 ) cp->kcq1.dma.pg_map_arr[0 ] >>32 );CNIC_WR8 (dev,BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_NEXT_PAGE_ADDR_VALID_OFFSET (func,0 ),1 ); CNIC_WR16(dev, BAR_CSTRORM_INTMEM +
@@ -4381,7 +4412,7 @@ static void cnic_stop_bnx2x_hw(struct cnic_dev *dev) 0);CNIC_WR (dev,BAR_CSTRORM_INTMEM +CSTORM_ISCSI_EQ_CONS_OFFSET (cp->func,0 ),0 ); -CNIC_WR16 (dev, cp->kcq_io_addr,0 ); +CNIC_WR16 (dev, cp->kcq1.io_addr,0 );cnic_free_resc (dev); }
drivers/net/cnic.h +11 -8
@@ -169,6 +169,16 @@ struct cnic_context { } proto; }; +struct kcq_info { +struct cnic_dma dma; +struct kcqe **kcq; + +u16 *hw_prod_idx_ptr; +u16 sw_prod_idx; +u16 *status_idx_ptr; +u32 io_addr; +}; +struct cnic_local {spinlock_t cnic_ulp_lock;
@@ -202,9 +212,6 @@ struct cnic_local {u16 rx_cons;u16 tx_cons; -u32 kwq_cid_addr; -u32 kcq_cid_addr; -struct cnic_dma kwq_info;struct kwqe **kwq;
@@ -218,11 +225,7 @@ struct cnic_local {u16 *kwq_con_idx_ptr;u16 kwq_con_idx; -struct cnic_dma kcq_info; -struct kcqe **kcq; - -u16 kcq_prod_idx; -u32 kcq_io_addr; +struct kcq_info kcq1;union {void *gen;
Signature · 1 line
1.6.4.GIT
PATCH 4/6 cnic: Restructure kcq processing.
By doing more work in the common function cnic_get_kcqes(), and making full use of the kcq_info structure.
--- drivers/net/cnic.c | 76 +++++++++++++++------------------------------------- 1 files changed, 22 insertions(+), 54 deletions(-)
drivers/net/cnic.c +22 -54
@@ -2141,18 +2141,20 @@ static u16 cnic_bnx2x_hw_idx(u16 idx)return idx; } -static int cnic_get_kcqes (struct cnic_dev *dev,u16 hw_prod,u16 *sw_prod) +static int cnic_get_kcqes (struct cnic_dev *dev,struct kcq_info *info) {struct cnic_local *cp = dev->cnic_priv; -u16 i, ri, last; +u16 i, ri, hw_prod, last;struct kcqe *kcqe;int kcqe_cnt =0 , last_cnt =0 ; - i = ri = last = *sw_prod; + i = ri = last = info->sw_prod_idx; ri &=MAX_KCQ_IDX ; + hw_prod = *info->hw_prod_idx_ptr; + hw_prod = cp->hw_idx (hw_prod);while ((i != hw_prod) && (kcqe_cnt <MAX_COMPLETED_KCQE )) { - kcqe = &cp->kcq1.kcq[KCQ_PG (ri)][KCQ_IDX (ri)]; + kcqe = &info->kcq[KCQ_PG (ri)][KCQ_IDX (ri)]; cp->completed_kcq[kcqe_cnt++] = kcqe; i = cp->next_idx (i); ri = i &MAX_KCQ_IDX ;
@@ -2162,7 +2164,7 @@ static int cnic_get_kcqes(struct cnic_dev *dev, u16 hw_prod, u16 *sw_prod) } } - *sw_prod = last; + info->sw_prod_idx = last;return last_cnt; }
@@ -2224,10 +2226,8 @@ static void cnic_chk_pkt_rings(struct cnic_local *cp)static int cnic_service_bnx2 (void *data,void *status_blk) {struct cnic_dev *dev = data; -struct status_block *sblk = status_blk;struct cnic_local *cp = dev->cnic_priv; -u32 status_idx = sblk->status_idx; -u16 hw_prod, sw_prod; +u32 status_idx = *cp->kcq1.status_idx_ptr;int kcqe_cnt;if (unlikely (!test_bit (CNIC_F_CNIC_UP , &dev->flags)))
@@ -2235,29 +2235,20 @@ static int cnic_service_bnx2(void *data, void *status_blk) cp->kwq_con_idx = *cp->kwq_con_idx_ptr; - hw_prod = sblk->status_completion_producer_index; - sw_prod = cp->kcq1.sw_prod_idx; -while (sw_prod != hw_prod) { - kcqe_cnt =cnic_get_kcqes (dev, hw_prod, &sw_prod); -if (kcqe_cnt ==0 ) - goto done; +while ((kcqe_cnt =cnic_get_kcqes (dev, &cp->kcq1))) {service_kcqes (dev, kcqe_cnt);/* Tell compiler that status_blk fields can change. */ barrier (); -if (status_idx != sblk->status_idx) { - status_idx = sblk->status_idx; +if (status_idx != *cp->kcq1.status_idx_ptr) { + status_idx = *cp->kcq1.status_idx_ptr; cp->kwq_con_idx = *cp->kwq_con_idx_ptr; - hw_prod = sblk->status_completion_producer_index; }else break ; } -done: -CNIC_WR16 (dev, cp->kcq1.io_addr, sw_prod); - - cp->kcq1.sw_prod_idx = sw_prod; +CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx);cnic_chk_pkt_rings (cp);return status_idx;
@@ -2268,34 +2259,25 @@ static void cnic_service_bnx2_msix(unsigned long data)struct cnic_dev *dev = (struct cnic_dev *) data;struct cnic_local *cp = dev->cnic_priv;struct status_block_msix *status_blk = cp->status_blk.bnx2; -u32 status_idx = status_blk->status_idx; -u16 hw_prod, sw_prod; +u32 status_idx = *cp->kcq1.status_idx_ptr;int kcqe_cnt; cp->kwq_con_idx = status_blk->status_cmd_consumer_index; - hw_prod = status_blk->status_completion_producer_index; - sw_prod = cp->kcq1.sw_prod_idx; -while (sw_prod != hw_prod) { - kcqe_cnt =cnic_get_kcqes (dev, hw_prod, &sw_prod); -if (kcqe_cnt ==0 ) - goto done; +while ((kcqe_cnt =cnic_get_kcqes (dev, &cp->kcq1))) {service_kcqes (dev, kcqe_cnt);/* Tell compiler that status_blk fields can change. */ barrier (); -if (status_idx != status_blk->status_idx) { - status_idx = status_blk->status_idx; +if (status_idx != *cp->kcq1.status_idx_ptr) { + status_idx = *cp->kcq1.status_idx_ptr; cp->kwq_con_idx = status_blk->status_cmd_consumer_index; - hw_prod = status_blk->status_completion_producer_index; }else break ; } -done: -CNIC_WR16 (dev, cp->kcq1.io_addr, sw_prod); - cp->kcq1.sw_prod_idx = sw_prod; +CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx);cnic_chk_pkt_rings (cp);
@@ -2360,41 +2342,27 @@ static void cnic_service_bnx2x_bh(unsigned long data) {struct cnic_dev *dev = (struct cnic_dev *) data;struct cnic_local *cp = dev->cnic_priv; -u16 hw_prod, sw_prod; -struct cstorm_status_block_c *sblk = - &cp->status_blk.bnx2x->c_status_block; -u32 status_idx = sblk->status_block_index; +u32 status_idx = *cp->kcq1.status_idx_ptr;int kcqe_cnt;if (unlikely (!test_bit (CNIC_F_CNIC_UP , &dev->flags)))return ; - hw_prod = sblk->index_values[HC_INDEX_C_ISCSI_EQ_CONS ]; - hw_prod = cp->hw_idx (hw_prod); - sw_prod = cp->kcq1.sw_prod_idx; -while (sw_prod != hw_prod) { - kcqe_cnt =cnic_get_kcqes (dev, hw_prod, &sw_prod); -if (kcqe_cnt ==0 ) - goto done; +while ((kcqe_cnt =cnic_get_kcqes (dev, &cp->kcq1))) {service_kcqes (dev, kcqe_cnt);/* Tell compiler that sblk fields can change. */ barrier (); -if (status_idx == sblk->status_block_index) +if (status_idx == *cp->kcq1.status_idx_ptr)break ; - status_idx = sblk->status_block_index; - hw_prod = sblk->index_values[HC_INDEX_C_ISCSI_EQ_CONS ]; - hw_prod = cp->hw_idx (hw_prod); + status_idx = *cp->kcq1.status_idx_ptr; } -done: -CNIC_WR16 (dev, cp->kcq1.io_addr, sw_prod +MAX_KCQ_IDX ); +CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx +MAX_KCQ_IDX );cnic_ack_bnx2x_int (dev, cp->status_blk_num,CSTORM_ID , status_idx,IGU_INT_ENABLE ,1 ); - - cp->kcq1.sw_prod_idx = sw_prod; }static int cnic_service_bnx2x (void *data,void *status_blk)
Signature · 1 line
1.6.4.GIT
PATCH 5/6 cnic: Further unify kcq handling code.
This eliminates some of the duplicate code for the various devices that require the same basic kcq handling.
--- drivers/net/cnic.c | 71 +++++++++++++++++++++++++--------------------------- 1 files changed, 34 insertions(+), 37 deletions(-)
drivers/net/cnic.c +34 -37
@@ -2223,16 +2223,12 @@ static void cnic_chk_pkt_rings(struct cnic_local *cp)clear_bit (CNIC_LCL_FL_L2_WAIT , &cp->cnic_local_flags); } -static int cnic_service_bnx2 (void *data,void *status_blk) +static u32 cnic_service_bnx2_queues (struct cnic_dev *dev) { -struct cnic_dev *dev = data;struct cnic_local *cp = dev->cnic_priv; -u32 status_idx = *cp->kcq1.status_idx_ptr; +u32 status_idx = (u16) *cp->kcq1.status_idx_ptr;int kcqe_cnt; -if (unlikely (!test_bit (CNIC_F_CNIC_UP , &dev->flags))) -return status_idx; - cp->kwq_con_idx = *cp->kwq_con_idx_ptr;while ((kcqe_cnt =cnic_get_kcqes (dev, &cp->kcq1))) {
@@ -2242,7 +2238,7 @@ static int cnic_service_bnx2(void *data, void *status_blk)/* Tell compiler that status_blk fields can change. */ barrier ();if (status_idx != *cp->kcq1.status_idx_ptr) { - status_idx = *cp->kcq1.status_idx_ptr; + status_idx = (u16) *cp->kcq1.status_idx_ptr; cp->kwq_con_idx = *cp->kwq_con_idx_ptr; }else break ;
@@ -2251,37 +2247,29 @@ static int cnic_service_bnx2(void *data, void *status_blk)CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx);cnic_chk_pkt_rings (cp); +return status_idx; } -static void cnic_service_bnx2_msix (unsigned long data) +static int cnic_service_bnx2 (void *data,void *status_blk) { -struct cnic_dev *dev = (struct cnic_dev *) data; +struct cnic_dev *dev = data;struct cnic_local *cp = dev->cnic_priv; -struct status_block_msix *status_blk = cp->status_blk.bnx2;u32 status_idx = *cp->kcq1.status_idx_ptr; -int kcqe_cnt; - - cp->kwq_con_idx = status_blk->status_cmd_consumer_index; -while ((kcqe_cnt =cnic_get_kcqes (dev, &cp->kcq1))) { - -service_kcqes (dev, kcqe_cnt); +if (unlikely (!test_bit (CNIC_F_CNIC_UP , &dev->flags))) +return status_idx; -/* Tell compiler that status_blk fields can change. */ -barrier (); -if (status_idx != *cp->kcq1.status_idx_ptr) { - status_idx = *cp->kcq1.status_idx_ptr; - cp->kwq_con_idx = status_blk->status_cmd_consumer_index; - }else -break ; - } +return cnic_service_bnx2_queues (dev); +} -CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx); +static void cnic_service_bnx2_msix (unsigned long data) +{ +struct cnic_dev *dev = (struct cnic_dev *) data; +struct cnic_local *cp = dev->cnic_priv; -cnic_chk_pkt_rings (cp); + cp->last_status_idx =cnic_service_bnx2_queues (dev); - cp->last_status_idx = status_idx;CNIC_WR (dev,BNX2_PCICFG_INT_ACK_CMD , cp->int_num |BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | cp->last_status_idx); }
@@ -2338,27 +2326,35 @@ static void cnic_ack_bnx2x_msix(struct cnic_dev *dev) IGU_INT_DISABLE, 0); } -static void cnic_service_bnx2x_bh (unsigned long data) +static u32 cnic_service_bnx2x_kcq (struct cnic_dev *dev,struct kcq_info *info) { -struct cnic_dev *dev = (struct cnic_dev *) data; -struct cnic_local *cp = dev->cnic_priv; -u32 status_idx = *cp->kcq1.status_idx_ptr; +u32 last_status = *info->status_idx_ptr;int kcqe_cnt; -if (unlikely (!test_bit (CNIC_F_CNIC_UP , &dev->flags))) -return ; - -while ((kcqe_cnt =cnic_get_kcqes (dev, &cp->kcq1))) { +while ((kcqe_cnt =cnic_get_kcqes (dev, info))) {service_kcqes (dev, kcqe_cnt);/* Tell compiler that sblk fields can change. */ barrier (); -if (status_idx == *cp->kcq1.status_idx_ptr) +if (last_status == *info->status_idx_ptr)break ; - status_idx = *cp->kcq1.status_idx_ptr; + last_status = *info->status_idx_ptr; } +return last_status; +} + +static void cnic_service_bnx2x_bh (unsigned long data) +{ +struct cnic_dev *dev = (struct cnic_dev *) data; +struct cnic_local *cp = dev->cnic_priv; +u32 status_idx; + +if (unlikely (!test_bit (CNIC_F_CNIC_UP , &dev->flags))) +return ; + + status_idx =cnic_service_bnx2x_kcq (dev, &cp->kcq1);CNIC_WR16 (dev, cp->kcq1.io_addr, cp->kcq1.sw_prod_idx +MAX_KCQ_IDX ); cnic_ack_bnx2x_int(dev, cp->status_blk_num, CSTORM_ID,
@@ -3786,6 +3782,7 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev) cp->kcq1.hw_prod_idx_ptr = (u16 *) &msblk->status_completion_producer_index; cp->kcq1.status_idx_ptr = (u16 *) &msblk->status_idx; + cp->kwq_con_idx_ptr = (u16 *) &msblk->status_cmd_consumer_index; cp->int_num = sb_id <<BNX2_PCICFG_INT_ACK_CMD_INT_NUM_SHIFT ;cnic_ctx_wr (dev, kwq_cid_addr,L5_KRNLQ_HOST_QIDX , sb);cnic_ctx_wr (dev, kcq_cid_addr,L5_KRNLQ_HOST_QIDX , sb);
Signature · 1 line
1.6.4.GIT
PATCH 6/6 cnic: Update version to 2.1.3.
--- drivers/net/cnic_if.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/cnic_if.h +2 -2
@@ -12,8 +12,8 @@#ifndef CNIC_IF_H #define CNIC_IF_H -#define CNIC_MODULE_VERSION "2.1.2" -#define CNIC_MODULE_RELDATE "May 26, 2010" +#define CNIC_MODULE_VERSION "2.1.3" +#define CNIC_MODULE_RELDATE "June 24, 2010"#define CNIC_ULP_RDMA 0#define CNIC_ULP_ISCSI 1
Signature · 1 line
1.6.4.GIT
From: "Michael Chan" <[email protected]>
Date: Thu, 24 Jun 2010 17:58:37 -0700
Quoted 8 lines
The current code makes assumptions about the CID (context ID) memory space and starting CID that may not be always correct when firmware changes. In particular,
BNX2_ISCSI_START_CIDmay not always be fixed. We now calculatecp->max_cid_spaceandcp->iscsi_start_ciddynamically instead of using fixed constants. The unusedcp->max_iscsi_connis also eliminated.Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 2/6] cnic: Unify IRQ code for all hardware types.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 24 Jun 2010 17:58:38 -0700
Quoted 3 lines
By creating a common
cnic_doirq().Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 3/6] cnic: Unify kcq allocation for all devices.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 24 Jun 2010 17:58:39 -0700
Quoted 5 lines
By creating a common data stucture
kcq_infofor all devices, the kcq (kernel completion queue) for all devices can be allocated by common code.Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 4/6] cnic: Restructure kcq processing.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 24 Jun 2010 17:58:40 -0700
Quoted 4 lines
By doing more work in the common function
cnic_get_kcqes(), and making full use of thekcq_infostructure.Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 5/6] cnic: Further unify kcq handling code.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 24 Jun 2010 17:58:41 -0700
Quoted 4 lines
This eliminates some of the duplicate code for the various devices that require the same basic kcq handling.
Signed-off-by Michael Chan <[email protected]>
Applied.
Re: [PATCH net-next 6/6] cnic: Update version to 2.1.3.
In reply to Michael ChanFrom: "Michael Chan" <[email protected]>
Date: Thu, 24 Jun 2010 17:58:42 -0700
Quoted 1 line
---
Applied. This was missing a proper Signoff...
Please don't elide those, even for simple version bump patches.