aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2010-09-15 04:59:58 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-15 17:16:13 -0400
commit8fea32b9555726d35b91492d17fc21c7874d36f9 (patch)
treed7bdab4fa4020eaa483761fc8271a3a03121fc13 /drivers/net/tg3.c
parent6fd45cb814709767a1704b541aa91647b7f275cf (diff)
tg3: Move producer ring struct to tg3_napi
Now that each NAPI instance has its own producer ring, it no longer makes sense to keep the producer ring structure external. This patch migrates the producer ring struct to tg3_napi and pivots the code to the new implementation. Reviewed-by: Benjamin Li <benli@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7468479902ae..179eb6539bd0 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -4549,7 +4549,7 @@ static void tg3_recycle_rx(struct tg3_napi *tnapi,
4549 struct tg3 *tp = tnapi->tp; 4549 struct tg3 *tp = tnapi->tp;
4550 struct tg3_rx_buffer_desc *src_desc, *dest_desc; 4550 struct tg3_rx_buffer_desc *src_desc, *dest_desc;
4551 struct ring_info *src_map, *dest_map; 4551 struct ring_info *src_map, *dest_map;
4552 struct tg3_rx_prodring_set *spr = &tp->prodring[0]; 4552 struct tg3_rx_prodring_set *spr = &tp->napi[0].prodring;
4553 int dest_idx; 4553 int dest_idx;
4554 4554
4555 switch (opaque_key) { 4555 switch (opaque_key) {
@@ -4619,7 +4619,7 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4619 u32 sw_idx = tnapi->rx_rcb_ptr; 4619 u32 sw_idx = tnapi->rx_rcb_ptr;
4620 u16 hw_idx; 4620 u16 hw_idx;
4621 int received; 4621 int received;
4622 struct tg3_rx_prodring_set *tpr = tnapi->prodring; 4622 struct tg3_rx_prodring_set *tpr = &tnapi->prodring;
4623 4623
4624 hw_idx = *(tnapi->rx_rcb_prod_idx); 4624 hw_idx = *(tnapi->rx_rcb_prod_idx);
4625 /* 4625 /*
@@ -4644,13 +4644,13 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4644 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; 4644 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK;
4645 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; 4645 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK;
4646 if (opaque_key == RXD_OPAQUE_RING_STD) { 4646 if (opaque_key == RXD_OPAQUE_RING_STD) {
4647 ri = &tp->prodring[0].rx_std_buffers[desc_idx]; 4647 ri = &tp->napi[0].prodring.rx_std_buffers[desc_idx];
4648 dma_addr = dma_unmap_addr(ri, mapping); 4648 dma_addr = dma_unmap_addr(ri, mapping);
4649 skb = ri->skb; 4649 skb = ri->skb;
4650 post_ptr = &std_prod_idx; 4650 post_ptr = &std_prod_idx;
4651 rx_std_posted++; 4651 rx_std_posted++;
4652 } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) { 4652 } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) {
4653 ri = &tp->prodring[0].rx_jmb_buffers[desc_idx]; 4653 ri = &tp->napi[0].prodring.rx_jmb_buffers[desc_idx];
4654 dma_addr = dma_unmap_addr(ri, mapping); 4654 dma_addr = dma_unmap_addr(ri, mapping);
4655 skb = ri->skb; 4655 skb = ri->skb;
4656 post_ptr = &jmb_prod_idx; 4656 post_ptr = &jmb_prod_idx;
@@ -4981,14 +4981,14 @@ static int tg3_poll_work(struct tg3_napi *tnapi, int work_done, int budget)
4981 work_done += tg3_rx(tnapi, budget - work_done); 4981 work_done += tg3_rx(tnapi, budget - work_done);
4982 4982
4983 if ((tp->tg3_flags3 & TG3_FLG3_ENABLE_RSS) && tnapi == &tp->napi[1]) { 4983 if ((tp->tg3_flags3 & TG3_FLG3_ENABLE_RSS) && tnapi == &tp->napi[1]) {
4984 struct tg3_rx_prodring_set *dpr = &tp->prodring[0]; 4984 struct tg3_rx_prodring_set *dpr = &tp->napi[0].prodring;
4985 int i, err = 0; 4985 int i, err = 0;
4986 u32 std_prod_idx = dpr->rx_std_prod_idx; 4986 u32 std_prod_idx = dpr->rx_std_prod_idx;
4987 u32 jmb_prod_idx = dpr->rx_jmb_prod_idx; 4987 u32 jmb_prod_idx = dpr->rx_jmb_prod_idx;
4988 4988
4989 for (i = 1; i < tp->irq_cnt; i++) 4989 for (i = 1; i < tp->irq_cnt; i++)
4990 err |= tg3_rx_prodring_xfer(tp, dpr, 4990 err |= tg3_rx_prodring_xfer(tp, dpr,
4991 tp->napi[i].prodring); 4991 &tp->napi[i].prodring);
4992 4992
4993 wmb(); 4993 wmb();
4994 4994
@@ -6057,7 +6057,7 @@ static void tg3_rx_prodring_free(struct tg3 *tp,
6057{ 6057{
6058 int i; 6058 int i;
6059 6059
6060 if (tpr != &tp->prodring[0]) { 6060 if (tpr != &tp->napi[0].prodring) {
6061 for (i = tpr->rx_std_cons_idx; i != tpr->rx_std_prod_idx; 6061 for (i = tpr->rx_std_cons_idx; i != tpr->rx_std_prod_idx;
6062 i = (i + 1) % TG3_RX_RING_SIZE) 6062 i = (i + 1) % TG3_RX_RING_SIZE)
6063 tg3_rx_skb_free(tp, &tpr->rx_std_buffers[i], 6063 tg3_rx_skb_free(tp, &tpr->rx_std_buffers[i],
@@ -6103,7 +6103,7 @@ static int tg3_rx_prodring_alloc(struct tg3 *tp,
6103 tpr->rx_jmb_cons_idx = 0; 6103 tpr->rx_jmb_cons_idx = 0;
6104 tpr->rx_jmb_prod_idx = 0; 6104 tpr->rx_jmb_prod_idx = 0;
6105 6105
6106 if (tpr != &tp->prodring[0]) { 6106 if (tpr != &tp->napi[0].prodring) {
6107 memset(&tpr->rx_std_buffers[0], 0, TG3_RX_STD_BUFF_RING_SIZE); 6107 memset(&tpr->rx_std_buffers[0], 0, TG3_RX_STD_BUFF_RING_SIZE);
6108 if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) 6108 if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE)
6109 memset(&tpr->rx_jmb_buffers[0], 0, 6109 memset(&tpr->rx_jmb_buffers[0], 0,
@@ -6253,7 +6253,7 @@ static void tg3_free_rings(struct tg3 *tp)
6253 for (j = 0; j < tp->irq_cnt; j++) { 6253 for (j = 0; j < tp->irq_cnt; j++) {
6254 struct tg3_napi *tnapi = &tp->napi[j]; 6254 struct tg3_napi *tnapi = &tp->napi[j];
6255 6255
6256 tg3_rx_prodring_free(tp, &tp->prodring[j]); 6256 tg3_rx_prodring_free(tp, &tnapi->prodring);
6257 6257
6258 if (!tnapi->tx_buffers) 6258 if (!tnapi->tx_buffers)
6259 continue; 6259 continue;
@@ -6325,7 +6325,7 @@ static int tg3_init_rings(struct tg3 *tp)
6325 if (tnapi->rx_rcb) 6325 if (tnapi->rx_rcb)
6326 memset(tnapi->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp)); 6326 memset(tnapi->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));
6327 6327
6328 if (tg3_rx_prodring_alloc(tp, &tp->prodring[i])) { 6328 if (tg3_rx_prodring_alloc(tp, &tnapi->prodring)) {
6329 tg3_free_rings(tp); 6329 tg3_free_rings(tp);
6330 return -ENOMEM; 6330 return -ENOMEM;
6331 } 6331 }
@@ -6361,6 +6361,8 @@ static void tg3_free_consistent(struct tg3 *tp)
6361 tnapi->rx_rcb = NULL; 6361 tnapi->rx_rcb = NULL;
6362 } 6362 }
6363 6363
6364 tg3_rx_prodring_fini(tp, &tnapi->prodring);
6365
6364 if (tnapi->hw_status) { 6366 if (tnapi->hw_status) {
6365 pci_free_consistent(tp->pdev, TG3_HW_STATUS_SIZE, 6367 pci_free_consistent(tp->pdev, TG3_HW_STATUS_SIZE,
6366 tnapi->hw_status, 6368 tnapi->hw_status,
@@ -6374,9 +6376,6 @@ static void tg3_free_consistent(struct tg3 *tp)
6374 tp->hw_stats, tp->stats_mapping); 6376 tp->hw_stats, tp->stats_mapping);
6375 tp->hw_stats = NULL; 6377 tp->hw_stats = NULL;
6376 } 6378 }
6377
6378 for (i = 0; i < tp->irq_cnt; i++)
6379 tg3_rx_prodring_fini(tp, &tp->prodring[i]);
6380} 6379}
6381 6380
6382/* 6381/*
@@ -6387,11 +6386,6 @@ static int tg3_alloc_consistent(struct tg3 *tp)
6387{ 6386{
6388 int i; 6387 int i;
6389 6388
6390 for (i = 0; i < tp->irq_cnt; i++) {
6391 if (tg3_rx_prodring_init(tp, &tp->prodring[i]))
6392 goto err_out;
6393 }
6394
6395 tp->hw_stats = pci_alloc_consistent(tp->pdev, 6389 tp->hw_stats = pci_alloc_consistent(tp->pdev,
6396 sizeof(struct tg3_hw_stats), 6390 sizeof(struct tg3_hw_stats),
6397 &tp->stats_mapping); 6391 &tp->stats_mapping);
@@ -6413,6 +6407,9 @@ static int tg3_alloc_consistent(struct tg3 *tp)
6413 memset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE); 6407 memset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE);
6414 sblk = tnapi->hw_status; 6408 sblk = tnapi->hw_status;
6415 6409
6410 if (tg3_rx_prodring_init(tp, &tnapi->prodring))
6411 goto err_out;
6412
6416 /* If multivector TSS is enabled, vector 0 does not handle 6413 /* If multivector TSS is enabled, vector 0 does not handle
6417 * tx interrupts. Don't allocate any resources for it. 6414 * tx interrupts. Don't allocate any resources for it.
6418 */ 6415 */
@@ -6452,8 +6449,6 @@ static int tg3_alloc_consistent(struct tg3 *tp)
6452 break; 6449 break;
6453 } 6450 }
6454 6451
6455 tnapi->prodring = &tp->prodring[i];
6456
6457 /* 6452 /*
6458 * If multivector RSS is enabled, vector 0 does not handle 6453 * If multivector RSS is enabled, vector 0 does not handle
6459 * rx or tx interrupts. Don't allocate any resources for it. 6454 * rx or tx interrupts. Don't allocate any resources for it.
@@ -7647,7 +7642,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7647{ 7642{
7648 u32 val, rdmac_mode; 7643 u32 val, rdmac_mode;
7649 int i, err, limit; 7644 int i, err, limit;
7650 struct tg3_rx_prodring_set *tpr = &tp->prodring[0]; 7645 struct tg3_rx_prodring_set *tpr = &tp->napi[0].prodring;
7651 7646
7652 tg3_disable_ints(tp); 7647 tg3_disable_ints(tp);
7653 7648
@@ -10627,7 +10622,7 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
10627 int num_pkts, tx_len, rx_len, i, err; 10622 int num_pkts, tx_len, rx_len, i, err;
10628 struct tg3_rx_buffer_desc *desc; 10623 struct tg3_rx_buffer_desc *desc;
10629 struct tg3_napi *tnapi, *rnapi; 10624 struct tg3_napi *tnapi, *rnapi;
10630 struct tg3_rx_prodring_set *tpr = &tp->prodring[0]; 10625 struct tg3_rx_prodring_set *tpr = &tp->napi[0].prodring;
10631 10626
10632 tnapi = &tp->napi[0]; 10627 tnapi = &tp->napi[0];
10633 rnapi = &tp->napi[0]; 10628 rnapi = &tp->napi[0];