diff options
author | Michael Chan <mchan@broadcom.com> | 2010-02-24 09:42:08 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-26 05:10:14 -0500 |
commit | a4dde3abbf87a495154a876576e1ab34b17b5ef1 (patch) | |
tree | 0a1faff1e54932ebb616fc5f0e412b187a433e94 /drivers/net | |
parent | c76284af9ec8a010c502a70249cb74b3bb69ec6f (diff) |
cnic: Use union for the status blocks of different devices.
We only need to assign the status block address once and it also saves
space in the structure.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: Eddie Wai <waie@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/cnic.c | 35 | ||||
-rw-r--r-- | drivers/net/cnic.h | 9 |
2 files changed, 23 insertions, 21 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 0defe61d5bf3..463408f46ba6 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
@@ -900,7 +900,8 @@ static int cnic_alloc_uio(struct cnic_dev *dev) { | |||
900 | uinfo->mem[0].memtype = UIO_MEM_PHYS; | 900 | uinfo->mem[0].memtype = UIO_MEM_PHYS; |
901 | 901 | ||
902 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { | 902 | if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) { |
903 | uinfo->mem[1].addr = (unsigned long) cp->status_blk & PAGE_MASK; | 903 | uinfo->mem[1].addr = (unsigned long) cp->status_blk.gen & |
904 | PAGE_MASK; | ||
904 | if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) | 905 | if (cp->ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) |
905 | uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9; | 906 | uinfo->mem[1].size = BNX2_SBLK_MSIX_ALIGN_SIZE * 9; |
906 | else | 907 | else |
@@ -1103,10 +1104,9 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
1103 | if (ret) | 1104 | if (ret) |
1104 | goto error; | 1105 | goto error; |
1105 | 1106 | ||
1106 | cp->bnx2x_status_blk = cp->status_blk; | ||
1107 | cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1].status_blk; | 1107 | cp->bnx2x_def_status_blk = cp->ethdev->irq_arr[1].status_blk; |
1108 | 1108 | ||
1109 | memset(cp->bnx2x_status_blk, 0, sizeof(struct host_status_block)); | 1109 | memset(cp->status_blk.bnx2x, 0, sizeof(*cp->status_blk.bnx2x)); |
1110 | 1110 | ||
1111 | cp->l2_rx_ring_size = 15; | 1111 | cp->l2_rx_ring_size = 15; |
1112 | 1112 | ||
@@ -2205,7 +2205,7 @@ static void cnic_service_bnx2_msix(unsigned long data) | |||
2205 | { | 2205 | { |
2206 | struct cnic_dev *dev = (struct cnic_dev *) data; | 2206 | struct cnic_dev *dev = (struct cnic_dev *) data; |
2207 | struct cnic_local *cp = dev->cnic_priv; | 2207 | struct cnic_local *cp = dev->cnic_priv; |
2208 | struct status_block_msix *status_blk = cp->bnx2_status_blk; | 2208 | struct status_block_msix *status_blk = cp->status_blk.bnx2; |
2209 | u32 status_idx = status_blk->status_idx; | 2209 | u32 status_idx = status_blk->status_idx; |
2210 | u16 hw_prod, sw_prod; | 2210 | u16 hw_prod, sw_prod; |
2211 | int kcqe_cnt; | 2211 | int kcqe_cnt; |
@@ -2251,7 +2251,7 @@ static irqreturn_t cnic_irq(int irq, void *dev_instance) | |||
2251 | if (cp->ack_int) | 2251 | if (cp->ack_int) |
2252 | cp->ack_int(dev); | 2252 | cp->ack_int(dev); |
2253 | 2253 | ||
2254 | prefetch(cp->status_blk); | 2254 | prefetch(cp->status_blk.gen); |
2255 | prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); | 2255 | prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); |
2256 | 2256 | ||
2257 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) | 2257 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) |
@@ -2292,7 +2292,7 @@ static void cnic_service_bnx2x_bh(unsigned long data) | |||
2292 | struct cnic_local *cp = dev->cnic_priv; | 2292 | struct cnic_local *cp = dev->cnic_priv; |
2293 | u16 hw_prod, sw_prod; | 2293 | u16 hw_prod, sw_prod; |
2294 | struct cstorm_status_block_c *sblk = | 2294 | struct cstorm_status_block_c *sblk = |
2295 | &cp->bnx2x_status_blk->c_status_block; | 2295 | &cp->status_blk.bnx2x->c_status_block; |
2296 | u32 status_idx = sblk->status_block_index; | 2296 | u32 status_idx = sblk->status_block_index; |
2297 | int kcqe_cnt; | 2297 | int kcqe_cnt; |
2298 | 2298 | ||
@@ -2334,7 +2334,7 @@ static int cnic_service_bnx2x(void *data, void *status_blk) | |||
2334 | struct cnic_local *cp = dev->cnic_priv; | 2334 | struct cnic_local *cp = dev->cnic_priv; |
2335 | u16 prod = cp->kcq_prod_idx & MAX_KCQ_IDX; | 2335 | u16 prod = cp->kcq_prod_idx & MAX_KCQ_IDX; |
2336 | 2336 | ||
2337 | prefetch(cp->status_blk); | 2337 | prefetch(cp->status_blk.bnx2x); |
2338 | prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); | 2338 | prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); |
2339 | 2339 | ||
2340 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) | 2340 | if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) |
@@ -3409,8 +3409,7 @@ static int cnic_init_bnx2_irq(struct cnic_dev *dev) | |||
3409 | CNIC_WR(dev, base + BNX2_HC_COM_TICKS_OFF, (64 << 16) | 220); | 3409 | CNIC_WR(dev, base + BNX2_HC_COM_TICKS_OFF, (64 << 16) | 220); |
3410 | CNIC_WR(dev, base + BNX2_HC_CMD_TICKS_OFF, (64 << 16) | 220); | 3410 | CNIC_WR(dev, base + BNX2_HC_CMD_TICKS_OFF, (64 << 16) | 220); |
3411 | 3411 | ||
3412 | cp->bnx2_status_blk = cp->status_blk; | 3412 | cp->last_status_idx = cp->status_blk.bnx2->status_idx; |
3413 | cp->last_status_idx = cp->bnx2_status_blk->status_idx; | ||
3414 | tasklet_init(&cp->cnic_irq_task, cnic_service_bnx2_msix, | 3413 | tasklet_init(&cp->cnic_irq_task, cnic_service_bnx2_msix, |
3415 | (unsigned long) dev); | 3414 | (unsigned long) dev); |
3416 | err = request_irq(ethdev->irq_arr[0].vector, cnic_irq, 0, | 3415 | err = request_irq(ethdev->irq_arr[0].vector, cnic_irq, 0, |
@@ -3419,7 +3418,7 @@ static int cnic_init_bnx2_irq(struct cnic_dev *dev) | |||
3419 | tasklet_disable(&cp->cnic_irq_task); | 3418 | tasklet_disable(&cp->cnic_irq_task); |
3420 | return err; | 3419 | return err; |
3421 | } | 3420 | } |
3422 | while (cp->bnx2_status_blk->status_completion_producer_index && | 3421 | while (cp->status_blk.bnx2->status_completion_producer_index && |
3423 | i < 10) { | 3422 | i < 10) { |
3424 | CNIC_WR(dev, BNX2_HC_COALESCE_NOW, | 3423 | CNIC_WR(dev, BNX2_HC_COALESCE_NOW, |
3425 | 1 << (11 + sblk_num)); | 3424 | 1 << (11 + sblk_num)); |
@@ -3427,13 +3426,13 @@ static int cnic_init_bnx2_irq(struct cnic_dev *dev) | |||
3427 | i++; | 3426 | i++; |
3428 | barrier(); | 3427 | barrier(); |
3429 | } | 3428 | } |
3430 | if (cp->bnx2_status_blk->status_completion_producer_index) { | 3429 | if (cp->status_blk.bnx2->status_completion_producer_index) { |
3431 | cnic_free_irq(dev); | 3430 | cnic_free_irq(dev); |
3432 | goto failed; | 3431 | goto failed; |
3433 | } | 3432 | } |
3434 | 3433 | ||
3435 | } else { | 3434 | } else { |
3436 | struct status_block *sblk = cp->status_blk; | 3435 | struct status_block *sblk = cp->status_blk.gen; |
3437 | u32 hc_cmd = CNIC_RD(dev, BNX2_HC_COMMAND); | 3436 | u32 hc_cmd = CNIC_RD(dev, BNX2_HC_COMMAND); |
3438 | int i = 0; | 3437 | int i = 0; |
3439 | 3438 | ||
@@ -3490,7 +3489,7 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev) | |||
3490 | int i; | 3489 | int i; |
3491 | struct tx_bd *txbd; | 3490 | struct tx_bd *txbd; |
3492 | dma_addr_t buf_map; | 3491 | dma_addr_t buf_map; |
3493 | struct status_block *s_blk = cp->status_blk; | 3492 | struct status_block *s_blk = cp->status_blk.gen; |
3494 | 3493 | ||
3495 | sb_id = cp->status_blk_num; | 3494 | sb_id = cp->status_blk_num; |
3496 | tx_cid = 20; | 3495 | tx_cid = 20; |
@@ -3498,7 +3497,7 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev) | |||
3498 | cnic_init_context(dev, tx_cid + 1); | 3497 | cnic_init_context(dev, tx_cid + 1); |
3499 | cp->tx_cons_ptr = &s_blk->status_tx_quick_consumer_index2; | 3498 | cp->tx_cons_ptr = &s_blk->status_tx_quick_consumer_index2; |
3500 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { | 3499 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { |
3501 | struct status_block_msix *sblk = cp->status_blk; | 3500 | struct status_block_msix *sblk = cp->status_blk.bnx2; |
3502 | 3501 | ||
3503 | tx_cid = TX_TSS_CID + sb_id - 1; | 3502 | tx_cid = TX_TSS_CID + sb_id - 1; |
3504 | cnic_init_context(dev, tx_cid); | 3503 | cnic_init_context(dev, tx_cid); |
@@ -3554,7 +3553,7 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev) | |||
3554 | u32 cid_addr, sb_id, val, coal_reg, coal_val; | 3553 | u32 cid_addr, sb_id, val, coal_reg, coal_val; |
3555 | int i; | 3554 | int i; |
3556 | struct rx_bd *rxbd; | 3555 | struct rx_bd *rxbd; |
3557 | struct status_block *s_blk = cp->status_blk; | 3556 | struct status_block *s_blk = cp->status_blk.gen; |
3558 | 3557 | ||
3559 | sb_id = cp->status_blk_num; | 3558 | sb_id = cp->status_blk_num; |
3560 | cnic_init_context(dev, 2); | 3559 | cnic_init_context(dev, 2); |
@@ -3562,7 +3561,7 @@ static void cnic_init_bnx2_rx_ring(struct cnic_dev *dev) | |||
3562 | coal_reg = BNX2_HC_COMMAND; | 3561 | coal_reg = BNX2_HC_COMMAND; |
3563 | coal_val = CNIC_RD(dev, coal_reg); | 3562 | coal_val = CNIC_RD(dev, coal_reg); |
3564 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { | 3563 | if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { |
3565 | struct status_block_msix *sblk = cp->status_blk; | 3564 | struct status_block_msix *sblk = cp->status_blk.bnx2; |
3566 | 3565 | ||
3567 | cp->rx_cons_ptr = &sblk->status_rx_quick_consumer_index; | 3566 | cp->rx_cons_ptr = &sblk->status_rx_quick_consumer_index; |
3568 | coal_reg = BNX2_HC_COALESCE_NOW; | 3567 | coal_reg = BNX2_HC_COALESCE_NOW; |
@@ -3661,7 +3660,7 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev) | |||
3661 | { | 3660 | { |
3662 | struct cnic_local *cp = dev->cnic_priv; | 3661 | struct cnic_local *cp = dev->cnic_priv; |
3663 | struct cnic_eth_dev *ethdev = cp->ethdev; | 3662 | struct cnic_eth_dev *ethdev = cp->ethdev; |
3664 | struct status_block *sblk = cp->status_blk; | 3663 | struct status_block *sblk = cp->status_blk.gen; |
3665 | u32 val; | 3664 | u32 val; |
3666 | int err; | 3665 | int err; |
3667 | 3666 | ||
@@ -4250,7 +4249,7 @@ static int cnic_start_hw(struct cnic_dev *dev) | |||
4250 | cp->chip_id = ethdev->chip_id; | 4249 | cp->chip_id = ethdev->chip_id; |
4251 | pci_dev_get(dev->pcidev); | 4250 | pci_dev_get(dev->pcidev); |
4252 | cp->func = PCI_FUNC(dev->pcidev->devfn); | 4251 | cp->func = PCI_FUNC(dev->pcidev->devfn); |
4253 | cp->status_blk = ethdev->irq_arr[0].status_blk; | 4252 | cp->status_blk.gen = ethdev->irq_arr[0].status_blk; |
4254 | cp->status_blk_num = ethdev->irq_arr[0].status_blk_num; | 4253 | cp->status_blk_num = ethdev->irq_arr[0].status_blk_num; |
4255 | 4254 | ||
4256 | err = cp->alloc_resc(dev); | 4255 | err = cp->alloc_resc(dev); |
diff --git a/drivers/net/cnic.h b/drivers/net/cnic.h index 1921597ab4a3..d566390b8c4d 100644 --- a/drivers/net/cnic.h +++ b/drivers/net/cnic.h | |||
@@ -224,9 +224,12 @@ struct cnic_local { | |||
224 | u16 kcq_prod_idx; | 224 | u16 kcq_prod_idx; |
225 | u32 kcq_io_addr; | 225 | u32 kcq_io_addr; |
226 | 226 | ||
227 | void *status_blk; | 227 | union { |
228 | struct status_block_msix *bnx2_status_blk; | 228 | void *gen; |
229 | struct host_status_block *bnx2x_status_blk; | 229 | struct status_block_msix *bnx2; |
230 | struct host_status_block *bnx2x; | ||
231 | } status_blk; | ||
232 | |||
230 | struct host_def_status_block *bnx2x_def_status_blk; | 233 | struct host_def_status_block *bnx2x_def_status_blk; |
231 | 234 | ||
232 | u32 status_blk_num; | 235 | u32 status_blk_num; |