diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2006-01-28 19:31:13 -0500 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2006-08-31 16:15:39 -0400 |
commit | 3598b57be449a2ee9178e5c511bdb1a8aaccba20 (patch) | |
tree | ac100c84aa1afbfc8e9dd66bd3c47c3f788f4ee6 /drivers/net | |
parent | dc709bd190c130b299ac19d596594256265c042a (diff) |
8139cp: trim ring_info
Fat removal: the mapping address is available from the Rx/Tx descriptors.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/8139cp.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 1428bb7715af..8f5d77923c7d 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c | |||
@@ -316,7 +316,6 @@ struct cp_desc { | |||
316 | 316 | ||
317 | struct ring_info { | 317 | struct ring_info { |
318 | struct sk_buff *skb; | 318 | struct sk_buff *skb; |
319 | dma_addr_t mapping; | ||
320 | u32 len; | 319 | u32 len; |
321 | }; | 320 | }; |
322 | 321 | ||
@@ -551,7 +550,7 @@ rx_status_loop: | |||
551 | break; | 550 | break; |
552 | 551 | ||
553 | len = (status & 0x1fff) - 4; | 552 | len = (status & 0x1fff) - 4; |
554 | mapping = cp->rx_skb[rx_tail].mapping; | 553 | mapping = le64_to_cpu(desc->addr); |
555 | 554 | ||
556 | if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag)) { | 555 | if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag)) { |
557 | /* we don't support incoming fragmented frames. | 556 | /* we don't support incoming fragmented frames. |
@@ -595,10 +594,8 @@ rx_status_loop: | |||
595 | 594 | ||
596 | skb_put(skb, len); | 595 | skb_put(skb, len); |
597 | 596 | ||
598 | mapping = | 597 | mapping = pci_map_single(cp->pdev, new_skb->data, buflen, |
599 | cp->rx_skb[rx_tail].mapping = | 598 | PCI_DMA_FROMDEVICE); |
600 | pci_map_single(cp->pdev, new_skb->data, | ||
601 | buflen, PCI_DMA_FROMDEVICE); | ||
602 | cp->rx_skb[rx_tail].skb = new_skb; | 599 | cp->rx_skb[rx_tail].skb = new_skb; |
603 | 600 | ||
604 | cp_rx_skb(cp, skb, desc); | 601 | cp_rx_skb(cp, skb, desc); |
@@ -717,18 +714,19 @@ static void cp_tx (struct cp_private *cp) | |||
717 | unsigned tx_tail = cp->tx_tail; | 714 | unsigned tx_tail = cp->tx_tail; |
718 | 715 | ||
719 | while (tx_tail != tx_head) { | 716 | while (tx_tail != tx_head) { |
717 | struct cp_desc *txd = cp->tx_ring + tx_tail; | ||
720 | struct sk_buff *skb; | 718 | struct sk_buff *skb; |
721 | u32 status; | 719 | u32 status; |
722 | 720 | ||
723 | rmb(); | 721 | rmb(); |
724 | status = le32_to_cpu(cp->tx_ring[tx_tail].opts1); | 722 | status = le32_to_cpu(txd->opts1); |
725 | if (status & DescOwn) | 723 | if (status & DescOwn) |
726 | break; | 724 | break; |
727 | 725 | ||
728 | skb = cp->tx_skb[tx_tail].skb; | 726 | skb = cp->tx_skb[tx_tail].skb; |
729 | BUG_ON(!skb); | 727 | BUG_ON(!skb); |
730 | 728 | ||
731 | pci_unmap_single(cp->pdev, cp->tx_skb[tx_tail].mapping, | 729 | pci_unmap_single(cp->pdev, le64_to_cpu(txd->addr), |
732 | cp->tx_skb[tx_tail].len, PCI_DMA_TODEVICE); | 730 | cp->tx_skb[tx_tail].len, PCI_DMA_TODEVICE); |
733 | 731 | ||
734 | if (status & LastFrag) { | 732 | if (status & LastFrag) { |
@@ -827,7 +825,6 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
827 | wmb(); | 825 | wmb(); |
828 | 826 | ||
829 | cp->tx_skb[entry].skb = skb; | 827 | cp->tx_skb[entry].skb = skb; |
830 | cp->tx_skb[entry].mapping = mapping; | ||
831 | cp->tx_skb[entry].len = len; | 828 | cp->tx_skb[entry].len = len; |
832 | entry = NEXT_TX(entry); | 829 | entry = NEXT_TX(entry); |
833 | } else { | 830 | } else { |
@@ -845,7 +842,6 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
845 | first_mapping = pci_map_single(cp->pdev, skb->data, | 842 | first_mapping = pci_map_single(cp->pdev, skb->data, |
846 | first_len, PCI_DMA_TODEVICE); | 843 | first_len, PCI_DMA_TODEVICE); |
847 | cp->tx_skb[entry].skb = skb; | 844 | cp->tx_skb[entry].skb = skb; |
848 | cp->tx_skb[entry].mapping = first_mapping; | ||
849 | cp->tx_skb[entry].len = first_len; | 845 | cp->tx_skb[entry].len = first_len; |
850 | entry = NEXT_TX(entry); | 846 | entry = NEXT_TX(entry); |
851 | 847 | ||
@@ -888,7 +884,6 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
888 | wmb(); | 884 | wmb(); |
889 | 885 | ||
890 | cp->tx_skb[entry].skb = skb; | 886 | cp->tx_skb[entry].skb = skb; |
891 | cp->tx_skb[entry].mapping = mapping; | ||
892 | cp->tx_skb[entry].len = len; | 887 | cp->tx_skb[entry].len = len; |
893 | entry = NEXT_TX(entry); | 888 | entry = NEXT_TX(entry); |
894 | } | 889 | } |
@@ -1091,6 +1086,7 @@ static int cp_refill_rx (struct cp_private *cp) | |||
1091 | 1086 | ||
1092 | for (i = 0; i < CP_RX_RING_SIZE; i++) { | 1087 | for (i = 0; i < CP_RX_RING_SIZE; i++) { |
1093 | struct sk_buff *skb; | 1088 | struct sk_buff *skb; |
1089 | dma_addr_t mapping; | ||
1094 | 1090 | ||
1095 | skb = dev_alloc_skb(cp->rx_buf_sz + RX_OFFSET); | 1091 | skb = dev_alloc_skb(cp->rx_buf_sz + RX_OFFSET); |
1096 | if (!skb) | 1092 | if (!skb) |
@@ -1099,12 +1095,12 @@ static int cp_refill_rx (struct cp_private *cp) | |||
1099 | skb->dev = cp->dev; | 1095 | skb->dev = cp->dev; |
1100 | skb_reserve(skb, RX_OFFSET); | 1096 | skb_reserve(skb, RX_OFFSET); |
1101 | 1097 | ||
1102 | cp->rx_skb[i].mapping = pci_map_single(cp->pdev, | 1098 | mapping = pci_map_single(cp->pdev, skb->data, cp->rx_buf_sz, |
1103 | skb->data, cp->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1099 | PCI_DMA_FROMDEVICE); |
1104 | cp->rx_skb[i].skb = skb; | 1100 | cp->rx_skb[i].skb = skb; |
1105 | 1101 | ||
1106 | cp->rx_ring[i].opts2 = 0; | 1102 | cp->rx_ring[i].opts2 = 0; |
1107 | cp->rx_ring[i].addr = cpu_to_le64(cp->rx_skb[i].mapping); | 1103 | cp->rx_ring[i].addr = cpu_to_le64(mapping); |
1108 | if (i == (CP_RX_RING_SIZE - 1)) | 1104 | if (i == (CP_RX_RING_SIZE - 1)) |
1109 | cp->rx_ring[i].opts1 = | 1105 | cp->rx_ring[i].opts1 = |
1110 | cpu_to_le32(DescOwn | RingEnd | cp->rx_buf_sz); | 1106 | cpu_to_le32(DescOwn | RingEnd | cp->rx_buf_sz); |
@@ -1152,11 +1148,13 @@ static int cp_alloc_rings (struct cp_private *cp) | |||
1152 | 1148 | ||
1153 | static void cp_clean_rings (struct cp_private *cp) | 1149 | static void cp_clean_rings (struct cp_private *cp) |
1154 | { | 1150 | { |
1151 | struct cp_desc *desc; | ||
1155 | unsigned i; | 1152 | unsigned i; |
1156 | 1153 | ||
1157 | for (i = 0; i < CP_RX_RING_SIZE; i++) { | 1154 | for (i = 0; i < CP_RX_RING_SIZE; i++) { |
1158 | if (cp->rx_skb[i].skb) { | 1155 | if (cp->rx_skb[i].skb) { |
1159 | pci_unmap_single(cp->pdev, cp->rx_skb[i].mapping, | 1156 | desc = cp->rx_ring + i; |
1157 | pci_unmap_single(cp->pdev, le64_to_cpu(desc->addr), | ||
1160 | cp->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1158 | cp->rx_buf_sz, PCI_DMA_FROMDEVICE); |
1161 | dev_kfree_skb(cp->rx_skb[i].skb); | 1159 | dev_kfree_skb(cp->rx_skb[i].skb); |
1162 | } | 1160 | } |
@@ -1166,9 +1164,10 @@ static void cp_clean_rings (struct cp_private *cp) | |||
1166 | if (cp->tx_skb[i].skb) { | 1164 | if (cp->tx_skb[i].skb) { |
1167 | struct sk_buff *skb = cp->tx_skb[i].skb; | 1165 | struct sk_buff *skb = cp->tx_skb[i].skb; |
1168 | 1166 | ||
1169 | pci_unmap_single(cp->pdev, cp->tx_skb[i].mapping, | 1167 | desc = cp->tx_ring + i; |
1168 | pci_unmap_single(cp->pdev, le64_to_cpu(desc->addr), | ||
1170 | cp->tx_skb[i].len, PCI_DMA_TODEVICE); | 1169 | cp->tx_skb[i].len, PCI_DMA_TODEVICE); |
1171 | if (le32_to_cpu(cp->tx_ring[i].opts1) & LastFrag) | 1170 | if (le32_to_cpu(desc->opts1) & LastFrag) |
1172 | dev_kfree_skb(skb); | 1171 | dev_kfree_skb(skb); |
1173 | cp->net_stats.tx_dropped++; | 1172 | cp->net_stats.tx_dropped++; |
1174 | } | 1173 | } |