diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-10-18 17:00:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-19 03:10:46 -0400 |
commit | 9e903e085262ffbf1fc44a17ac06058aca03524a (patch) | |
tree | 4acefc97ba38c1733474d25c0b2053b56af97db1 /drivers/net/ethernet/marvell/sky2.c | |
parent | dd767856a36e00b631d65ebc4bb81b19915532d6 (diff) |
net: add skb frag size accessors
To ease skb->truesize sanitization, its better to be able to localize
all references to skb frags size.
Define accessors : skb_frag_size() to fetch frag size, and
skb_frag_size_{set|add|sub}() to manipulate it.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell/sky2.c')
-rw-r--r-- | drivers/net/ethernet/marvell/sky2.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index 92634907bf8..7b083c438a1 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c | |||
@@ -1225,10 +1225,10 @@ static int sky2_rx_map_skb(struct pci_dev *pdev, struct rx_ring_info *re, | |||
1225 | dma_unmap_len_set(re, data_size, size); | 1225 | dma_unmap_len_set(re, data_size, size); |
1226 | 1226 | ||
1227 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 1227 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
1228 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 1228 | const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
1229 | 1229 | ||
1230 | re->frag_addr[i] = skb_frag_dma_map(&pdev->dev, frag, 0, | 1230 | re->frag_addr[i] = skb_frag_dma_map(&pdev->dev, frag, 0, |
1231 | frag->size, | 1231 | skb_frag_size(frag), |
1232 | DMA_FROM_DEVICE); | 1232 | DMA_FROM_DEVICE); |
1233 | 1233 | ||
1234 | if (dma_mapping_error(&pdev->dev, re->frag_addr[i])) | 1234 | if (dma_mapping_error(&pdev->dev, re->frag_addr[i])) |
@@ -1239,7 +1239,7 @@ static int sky2_rx_map_skb(struct pci_dev *pdev, struct rx_ring_info *re, | |||
1239 | map_page_error: | 1239 | map_page_error: |
1240 | while (--i >= 0) { | 1240 | while (--i >= 0) { |
1241 | pci_unmap_page(pdev, re->frag_addr[i], | 1241 | pci_unmap_page(pdev, re->frag_addr[i], |
1242 | skb_shinfo(skb)->frags[i].size, | 1242 | skb_frag_size(&skb_shinfo(skb)->frags[i]), |
1243 | PCI_DMA_FROMDEVICE); | 1243 | PCI_DMA_FROMDEVICE); |
1244 | } | 1244 | } |
1245 | 1245 | ||
@@ -1263,7 +1263,7 @@ static void sky2_rx_unmap_skb(struct pci_dev *pdev, struct rx_ring_info *re) | |||
1263 | 1263 | ||
1264 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) | 1264 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) |
1265 | pci_unmap_page(pdev, re->frag_addr[i], | 1265 | pci_unmap_page(pdev, re->frag_addr[i], |
1266 | skb_shinfo(skb)->frags[i].size, | 1266 | skb_frag_size(&skb_shinfo(skb)->frags[i]), |
1267 | PCI_DMA_FROMDEVICE); | 1267 | PCI_DMA_FROMDEVICE); |
1268 | } | 1268 | } |
1269 | 1269 | ||
@@ -1936,7 +1936,7 @@ static netdev_tx_t sky2_xmit_frame(struct sk_buff *skb, | |||
1936 | const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 1936 | const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
1937 | 1937 | ||
1938 | mapping = skb_frag_dma_map(&hw->pdev->dev, frag, 0, | 1938 | mapping = skb_frag_dma_map(&hw->pdev->dev, frag, 0, |
1939 | frag->size, DMA_TO_DEVICE); | 1939 | skb_frag_size(frag), DMA_TO_DEVICE); |
1940 | 1940 | ||
1941 | if (dma_mapping_error(&hw->pdev->dev, mapping)) | 1941 | if (dma_mapping_error(&hw->pdev->dev, mapping)) |
1942 | goto mapping_unwind; | 1942 | goto mapping_unwind; |
@@ -1952,11 +1952,11 @@ static netdev_tx_t sky2_xmit_frame(struct sk_buff *skb, | |||
1952 | re = sky2->tx_ring + slot; | 1952 | re = sky2->tx_ring + slot; |
1953 | re->flags = TX_MAP_PAGE; | 1953 | re->flags = TX_MAP_PAGE; |
1954 | dma_unmap_addr_set(re, mapaddr, mapping); | 1954 | dma_unmap_addr_set(re, mapaddr, mapping); |
1955 | dma_unmap_len_set(re, maplen, frag->size); | 1955 | dma_unmap_len_set(re, maplen, skb_frag_size(frag)); |
1956 | 1956 | ||
1957 | le = get_tx_le(sky2, &slot); | 1957 | le = get_tx_le(sky2, &slot); |
1958 | le->addr = cpu_to_le32(lower_32_bits(mapping)); | 1958 | le->addr = cpu_to_le32(lower_32_bits(mapping)); |
1959 | le->length = cpu_to_le16(frag->size); | 1959 | le->length = cpu_to_le16(skb_frag_size(frag)); |
1960 | le->ctrl = ctrl; | 1960 | le->ctrl = ctrl; |
1961 | le->opcode = OP_BUFFER | HW_OWNER; | 1961 | le->opcode = OP_BUFFER | HW_OWNER; |
1962 | } | 1962 | } |
@@ -2484,7 +2484,7 @@ static void skb_put_frags(struct sk_buff *skb, unsigned int hdr_space, | |||
2484 | } else { | 2484 | } else { |
2485 | size = min(length, (unsigned) PAGE_SIZE); | 2485 | size = min(length, (unsigned) PAGE_SIZE); |
2486 | 2486 | ||
2487 | frag->size = size; | 2487 | skb_frag_size_set(frag, size); |
2488 | skb->data_len += size; | 2488 | skb->data_len += size; |
2489 | skb->truesize += PAGE_SIZE; | 2489 | skb->truesize += PAGE_SIZE; |
2490 | skb->len += size; | 2490 | skb->len += size; |