diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2009-11-13 08:03:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-16 01:14:46 -0500 |
commit | afc081f83c59a7cf2c025a3ed89d011b5db556eb (patch) | |
tree | 509ef4581f8be885a28a7b69a215aab835984765 /drivers/net/tg3.c | |
parent | 78f90dcf184b8225a24217605c4289f1986451a3 (diff) |
tg3: Make tg3_alloc_rx_skb() a dst-only operation
This patch removes the source index parameter of tg3_alloc_rx_skb(). A
later patch will make it possible for the source and destination
producer rings to be different. This patch opts to make
tg3_alloc_rx_skb() a destination-only implementation and move the code
sensitive to the difference elsewhere.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index f0360f8b8f7b..ef6408018d2f 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -4409,7 +4409,7 @@ static void tg3_tx(struct tg3_napi *tnapi) | |||
4409 | * (to fetch the error flags, vlan tag, checksum, and opaque cookie). | 4409 | * (to fetch the error flags, vlan tag, checksum, and opaque cookie). |
4410 | */ | 4410 | */ |
4411 | static int tg3_alloc_rx_skb(struct tg3_napi *tnapi, u32 opaque_key, | 4411 | static int tg3_alloc_rx_skb(struct tg3_napi *tnapi, u32 opaque_key, |
4412 | int src_idx, u32 dest_idx_unmasked) | 4412 | u32 dest_idx_unmasked) |
4413 | { | 4413 | { |
4414 | struct tg3 *tp = tnapi->tp; | 4414 | struct tg3 *tp = tnapi->tp; |
4415 | struct tg3_rx_buffer_desc *desc; | 4415 | struct tg3_rx_buffer_desc *desc; |
@@ -4425,8 +4425,6 @@ static int tg3_alloc_rx_skb(struct tg3_napi *tnapi, u32 opaque_key, | |||
4425 | dest_idx = dest_idx_unmasked % TG3_RX_RING_SIZE; | 4425 | dest_idx = dest_idx_unmasked % TG3_RX_RING_SIZE; |
4426 | desc = &tpr->rx_std[dest_idx]; | 4426 | desc = &tpr->rx_std[dest_idx]; |
4427 | map = &tpr->rx_std_buffers[dest_idx]; | 4427 | map = &tpr->rx_std_buffers[dest_idx]; |
4428 | if (src_idx >= 0) | ||
4429 | src_map = &tpr->rx_std_buffers[src_idx]; | ||
4430 | skb_size = tp->rx_pkt_map_sz; | 4428 | skb_size = tp->rx_pkt_map_sz; |
4431 | break; | 4429 | break; |
4432 | 4430 | ||
@@ -4434,8 +4432,6 @@ static int tg3_alloc_rx_skb(struct tg3_napi *tnapi, u32 opaque_key, | |||
4434 | dest_idx = dest_idx_unmasked % TG3_RX_JUMBO_RING_SIZE; | 4432 | dest_idx = dest_idx_unmasked % TG3_RX_JUMBO_RING_SIZE; |
4435 | desc = &tpr->rx_jmb[dest_idx].std; | 4433 | desc = &tpr->rx_jmb[dest_idx].std; |
4436 | map = &tpr->rx_jmb_buffers[dest_idx]; | 4434 | map = &tpr->rx_jmb_buffers[dest_idx]; |
4437 | if (src_idx >= 0) | ||
4438 | src_map = &tpr->rx_jmb_buffers[src_idx]; | ||
4439 | skb_size = TG3_RX_JMB_MAP_SZ; | 4435 | skb_size = TG3_RX_JMB_MAP_SZ; |
4440 | break; | 4436 | break; |
4441 | 4437 | ||
@@ -4465,9 +4461,6 @@ static int tg3_alloc_rx_skb(struct tg3_napi *tnapi, u32 opaque_key, | |||
4465 | map->skb = skb; | 4461 | map->skb = skb; |
4466 | pci_unmap_addr_set(map, mapping, mapping); | 4462 | pci_unmap_addr_set(map, mapping, mapping); |
4467 | 4463 | ||
4468 | if (src_map != NULL) | ||
4469 | src_map->skb = NULL; | ||
4470 | |||
4471 | desc->addr_hi = ((u64)mapping >> 32); | 4464 | desc->addr_hi = ((u64)mapping >> 32); |
4472 | desc->addr_lo = ((u64)mapping & 0xffffffff); | 4465 | desc->addr_lo = ((u64)mapping & 0xffffffff); |
4473 | 4466 | ||
@@ -4559,6 +4552,7 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) | |||
4559 | work_mask = 0; | 4552 | work_mask = 0; |
4560 | received = 0; | 4553 | received = 0; |
4561 | while (sw_idx != hw_idx && budget > 0) { | 4554 | while (sw_idx != hw_idx && budget > 0) { |
4555 | struct ring_info *ri; | ||
4562 | struct tg3_rx_buffer_desc *desc = &tnapi->rx_rcb[sw_idx]; | 4556 | struct tg3_rx_buffer_desc *desc = &tnapi->rx_rcb[sw_idx]; |
4563 | unsigned int len; | 4557 | unsigned int len; |
4564 | struct sk_buff *skb; | 4558 | struct sk_buff *skb; |
@@ -4568,13 +4562,13 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) | |||
4568 | desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; | 4562 | desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; |
4569 | opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; | 4563 | opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; |
4570 | if (opaque_key == RXD_OPAQUE_RING_STD) { | 4564 | if (opaque_key == RXD_OPAQUE_RING_STD) { |
4571 | struct ring_info *ri = &tpr->rx_std_buffers[desc_idx]; | 4565 | ri = &tpr->rx_std_buffers[desc_idx]; |
4572 | dma_addr = pci_unmap_addr(ri, mapping); | 4566 | dma_addr = pci_unmap_addr(ri, mapping); |
4573 | skb = ri->skb; | 4567 | skb = ri->skb; |
4574 | post_ptr = &tpr->rx_std_ptr; | 4568 | post_ptr = &tpr->rx_std_ptr; |
4575 | rx_std_posted++; | 4569 | rx_std_posted++; |
4576 | } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) { | 4570 | } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) { |
4577 | struct ring_info *ri = &tpr->rx_jmb_buffers[desc_idx]; | 4571 | ri = &tpr->rx_jmb_buffers[desc_idx]; |
4578 | dma_addr = pci_unmap_addr(ri, mapping); | 4572 | dma_addr = pci_unmap_addr(ri, mapping); |
4579 | skb = ri->skb; | 4573 | skb = ri->skb; |
4580 | post_ptr = &tpr->rx_jmb_ptr; | 4574 | post_ptr = &tpr->rx_jmb_ptr; |
@@ -4607,10 +4601,12 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget) | |||
4607 | int skb_size; | 4601 | int skb_size; |
4608 | 4602 | ||
4609 | skb_size = tg3_alloc_rx_skb(tnapi, opaque_key, | 4603 | skb_size = tg3_alloc_rx_skb(tnapi, opaque_key, |
4610 | desc_idx, *post_ptr); | 4604 | *post_ptr); |
4611 | if (skb_size < 0) | 4605 | if (skb_size < 0) |
4612 | goto drop_it; | 4606 | goto drop_it; |
4613 | 4607 | ||
4608 | ri->skb = NULL; | ||
4609 | |||
4614 | pci_unmap_single(tp->pdev, dma_addr, skb_size, | 4610 | pci_unmap_single(tp->pdev, dma_addr, skb_size, |
4615 | PCI_DMA_FROMDEVICE); | 4611 | PCI_DMA_FROMDEVICE); |
4616 | 4612 | ||
@@ -5774,7 +5770,7 @@ static int tg3_rx_prodring_alloc(struct tg3 *tp, | |||
5774 | 5770 | ||
5775 | /* Now allocate fresh SKBs for each rx ring. */ | 5771 | /* Now allocate fresh SKBs for each rx ring. */ |
5776 | for (i = 0; i < tp->rx_pending; i++) { | 5772 | for (i = 0; i < tp->rx_pending; i++) { |
5777 | if (tg3_alloc_rx_skb(tnapi, RXD_OPAQUE_RING_STD, -1, i) < 0) { | 5773 | if (tg3_alloc_rx_skb(tnapi, RXD_OPAQUE_RING_STD, i) < 0) { |
5778 | printk(KERN_WARNING PFX | 5774 | printk(KERN_WARNING PFX |
5779 | "%s: Using a smaller RX standard ring, " | 5775 | "%s: Using a smaller RX standard ring, " |
5780 | "only %d out of %d buffers were allocated " | 5776 | "only %d out of %d buffers were allocated " |
@@ -5806,7 +5802,7 @@ static int tg3_rx_prodring_alloc(struct tg3 *tp, | |||
5806 | 5802 | ||
5807 | for (i = 0; i < tp->rx_jumbo_pending; i++) { | 5803 | for (i = 0; i < tp->rx_jumbo_pending; i++) { |
5808 | if (tg3_alloc_rx_skb(tnapi, RXD_OPAQUE_RING_JUMBO, | 5804 | if (tg3_alloc_rx_skb(tnapi, RXD_OPAQUE_RING_JUMBO, |
5809 | -1, i) < 0) { | 5805 | i) < 0) { |
5810 | printk(KERN_WARNING PFX | 5806 | printk(KERN_WARNING PFX |
5811 | "%s: Using a smaller RX jumbo ring, " | 5807 | "%s: Using a smaller RX jumbo ring, " |
5812 | "only %d out of %d buffers were " | 5808 | "only %d out of %d buffers were " |