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/broadcom | |
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/broadcom')
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2.c | 12 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 14 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/tg3.c | 8 |
3 files changed, 17 insertions, 17 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 6ff7636e73a2..965c7235804d 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c | |||
@@ -2871,7 +2871,7 @@ bnx2_tx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
2871 | dma_unmap_addr( | 2871 | dma_unmap_addr( |
2872 | &txr->tx_buf_ring[TX_RING_IDX(sw_cons)], | 2872 | &txr->tx_buf_ring[TX_RING_IDX(sw_cons)], |
2873 | mapping), | 2873 | mapping), |
2874 | skb_shinfo(skb)->frags[i].size, | 2874 | skb_frag_size(&skb_shinfo(skb)->frags[i]), |
2875 | PCI_DMA_TODEVICE); | 2875 | PCI_DMA_TODEVICE); |
2876 | } | 2876 | } |
2877 | 2877 | ||
@@ -3049,7 +3049,7 @@ bnx2_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr, struct sk_buff *skb, | |||
3049 | } else { | 3049 | } else { |
3050 | skb_frag_t *frag = | 3050 | skb_frag_t *frag = |
3051 | &skb_shinfo(skb)->frags[i - 1]; | 3051 | &skb_shinfo(skb)->frags[i - 1]; |
3052 | frag->size -= tail; | 3052 | skb_frag_size_sub(frag, tail); |
3053 | skb->data_len -= tail; | 3053 | skb->data_len -= tail; |
3054 | } | 3054 | } |
3055 | return 0; | 3055 | return 0; |
@@ -5395,7 +5395,7 @@ bnx2_free_tx_skbs(struct bnx2 *bp) | |||
5395 | tx_buf = &txr->tx_buf_ring[TX_RING_IDX(j)]; | 5395 | tx_buf = &txr->tx_buf_ring[TX_RING_IDX(j)]; |
5396 | dma_unmap_page(&bp->pdev->dev, | 5396 | dma_unmap_page(&bp->pdev->dev, |
5397 | dma_unmap_addr(tx_buf, mapping), | 5397 | dma_unmap_addr(tx_buf, mapping), |
5398 | skb_shinfo(skb)->frags[k].size, | 5398 | skb_frag_size(&skb_shinfo(skb)->frags[k]), |
5399 | PCI_DMA_TODEVICE); | 5399 | PCI_DMA_TODEVICE); |
5400 | } | 5400 | } |
5401 | dev_kfree_skb(skb); | 5401 | dev_kfree_skb(skb); |
@@ -6530,13 +6530,13 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
6530 | tx_buf->is_gso = skb_is_gso(skb); | 6530 | tx_buf->is_gso = skb_is_gso(skb); |
6531 | 6531 | ||
6532 | for (i = 0; i < last_frag; i++) { | 6532 | for (i = 0; i < last_frag; i++) { |
6533 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 6533 | const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
6534 | 6534 | ||
6535 | prod = NEXT_TX_BD(prod); | 6535 | prod = NEXT_TX_BD(prod); |
6536 | ring_prod = TX_RING_IDX(prod); | 6536 | ring_prod = TX_RING_IDX(prod); |
6537 | txbd = &txr->tx_desc_ring[ring_prod]; | 6537 | txbd = &txr->tx_desc_ring[ring_prod]; |
6538 | 6538 | ||
6539 | len = frag->size; | 6539 | len = skb_frag_size(frag); |
6540 | mapping = skb_frag_dma_map(&bp->pdev->dev, frag, 0, len, | 6540 | mapping = skb_frag_dma_map(&bp->pdev->dev, frag, 0, len, |
6541 | DMA_TO_DEVICE); | 6541 | DMA_TO_DEVICE); |
6542 | if (dma_mapping_error(&bp->pdev->dev, mapping)) | 6542 | if (dma_mapping_error(&bp->pdev->dev, mapping)) |
@@ -6594,7 +6594,7 @@ dma_error: | |||
6594 | ring_prod = TX_RING_IDX(prod); | 6594 | ring_prod = TX_RING_IDX(prod); |
6595 | tx_buf = &txr->tx_buf_ring[ring_prod]; | 6595 | tx_buf = &txr->tx_buf_ring[ring_prod]; |
6596 | dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(tx_buf, mapping), | 6596 | dma_unmap_page(&bp->pdev->dev, dma_unmap_addr(tx_buf, mapping), |
6597 | skb_shinfo(skb)->frags[i].size, | 6597 | skb_frag_size(&skb_shinfo(skb)->frags[i]), |
6598 | PCI_DMA_TODEVICE); | 6598 | PCI_DMA_TODEVICE); |
6599 | } | 6599 | } |
6600 | 6600 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index e575e89c7d46..dd8ee56396b2 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | |||
@@ -2363,7 +2363,7 @@ static int bnx2x_pkt_req_lin(struct bnx2x *bp, struct sk_buff *skb, | |||
2363 | /* Calculate the first sum - it's special */ | 2363 | /* Calculate the first sum - it's special */ |
2364 | for (frag_idx = 0; frag_idx < wnd_size - 1; frag_idx++) | 2364 | for (frag_idx = 0; frag_idx < wnd_size - 1; frag_idx++) |
2365 | wnd_sum += | 2365 | wnd_sum += |
2366 | skb_shinfo(skb)->frags[frag_idx].size; | 2366 | skb_frag_size(&skb_shinfo(skb)->frags[frag_idx]); |
2367 | 2367 | ||
2368 | /* If there was data on linear skb data - check it */ | 2368 | /* If there was data on linear skb data - check it */ |
2369 | if (first_bd_sz > 0) { | 2369 | if (first_bd_sz > 0) { |
@@ -2379,14 +2379,14 @@ static int bnx2x_pkt_req_lin(struct bnx2x *bp, struct sk_buff *skb, | |||
2379 | check all windows */ | 2379 | check all windows */ |
2380 | for (wnd_idx = 0; wnd_idx <= num_wnds; wnd_idx++) { | 2380 | for (wnd_idx = 0; wnd_idx <= num_wnds; wnd_idx++) { |
2381 | wnd_sum += | 2381 | wnd_sum += |
2382 | skb_shinfo(skb)->frags[wnd_idx + wnd_size - 1].size; | 2382 | skb_frag_size(&skb_shinfo(skb)->frags[wnd_idx + wnd_size - 1]); |
2383 | 2383 | ||
2384 | if (unlikely(wnd_sum < lso_mss)) { | 2384 | if (unlikely(wnd_sum < lso_mss)) { |
2385 | to_copy = 1; | 2385 | to_copy = 1; |
2386 | break; | 2386 | break; |
2387 | } | 2387 | } |
2388 | wnd_sum -= | 2388 | wnd_sum -= |
2389 | skb_shinfo(skb)->frags[wnd_idx].size; | 2389 | skb_frag_size(&skb_shinfo(skb)->frags[wnd_idx]); |
2390 | } | 2390 | } |
2391 | } else { | 2391 | } else { |
2392 | /* in non-LSO too fragmented packet should always | 2392 | /* in non-LSO too fragmented packet should always |
@@ -2796,8 +2796,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2796 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 2796 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
2797 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 2797 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
2798 | 2798 | ||
2799 | mapping = skb_frag_dma_map(&bp->pdev->dev, frag, 0, frag->size, | 2799 | mapping = skb_frag_dma_map(&bp->pdev->dev, frag, 0, |
2800 | DMA_TO_DEVICE); | 2800 | skb_frag_size(frag), DMA_TO_DEVICE); |
2801 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { | 2801 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { |
2802 | 2802 | ||
2803 | DP(NETIF_MSG_TX_QUEUED, "Unable to map page - " | 2803 | DP(NETIF_MSG_TX_QUEUED, "Unable to map page - " |
@@ -2821,8 +2821,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2821 | 2821 | ||
2822 | tx_data_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); | 2822 | tx_data_bd->addr_hi = cpu_to_le32(U64_HI(mapping)); |
2823 | tx_data_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); | 2823 | tx_data_bd->addr_lo = cpu_to_le32(U64_LO(mapping)); |
2824 | tx_data_bd->nbytes = cpu_to_le16(frag->size); | 2824 | tx_data_bd->nbytes = cpu_to_le16(skb_frag_size(frag)); |
2825 | le16_add_cpu(&pkt_size, frag->size); | 2825 | le16_add_cpu(&pkt_size, skb_frag_size(frag)); |
2826 | nbd++; | 2826 | nbd++; |
2827 | 2827 | ||
2828 | DP(NETIF_MSG_TX_QUEUED, | 2828 | DP(NETIF_MSG_TX_QUEUED, |
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index fe712f955110..b89027c61937 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
@@ -5356,7 +5356,7 @@ static void tg3_tx(struct tg3_napi *tnapi) | |||
5356 | 5356 | ||
5357 | pci_unmap_page(tp->pdev, | 5357 | pci_unmap_page(tp->pdev, |
5358 | dma_unmap_addr(ri, mapping), | 5358 | dma_unmap_addr(ri, mapping), |
5359 | skb_shinfo(skb)->frags[i].size, | 5359 | skb_frag_size(&skb_shinfo(skb)->frags[i]), |
5360 | PCI_DMA_TODEVICE); | 5360 | PCI_DMA_TODEVICE); |
5361 | 5361 | ||
5362 | while (ri->fragmented) { | 5362 | while (ri->fragmented) { |
@@ -6510,14 +6510,14 @@ static void tg3_tx_skb_unmap(struct tg3_napi *tnapi, u32 entry, int last) | |||
6510 | } | 6510 | } |
6511 | 6511 | ||
6512 | for (i = 0; i < last; i++) { | 6512 | for (i = 0; i < last; i++) { |
6513 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 6513 | const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
6514 | 6514 | ||
6515 | entry = NEXT_TX(entry); | 6515 | entry = NEXT_TX(entry); |
6516 | txb = &tnapi->tx_buffers[entry]; | 6516 | txb = &tnapi->tx_buffers[entry]; |
6517 | 6517 | ||
6518 | pci_unmap_page(tnapi->tp->pdev, | 6518 | pci_unmap_page(tnapi->tp->pdev, |
6519 | dma_unmap_addr(txb, mapping), | 6519 | dma_unmap_addr(txb, mapping), |
6520 | frag->size, PCI_DMA_TODEVICE); | 6520 | skb_frag_size(frag), PCI_DMA_TODEVICE); |
6521 | 6521 | ||
6522 | while (txb->fragmented) { | 6522 | while (txb->fragmented) { |
6523 | txb->fragmented = false; | 6523 | txb->fragmented = false; |
@@ -6777,7 +6777,7 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
6777 | for (i = 0; i <= last; i++) { | 6777 | for (i = 0; i <= last; i++) { |
6778 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | 6778 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
6779 | 6779 | ||
6780 | len = frag->size; | 6780 | len = skb_frag_size(frag); |
6781 | mapping = skb_frag_dma_map(&tp->pdev->dev, frag, 0, | 6781 | mapping = skb_frag_dma_map(&tp->pdev->dev, frag, 0, |
6782 | len, DMA_TO_DEVICE); | 6782 | len, DMA_TO_DEVICE); |
6783 | 6783 | ||