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/myricom | |
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/myricom')
-rw-r--r-- | drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c index 26637279cd67..c970a48436dc 100644 --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c | |||
@@ -1216,7 +1216,7 @@ myri10ge_rx_skb_build(struct sk_buff *skb, u8 * va, | |||
1216 | skb_frags = skb_shinfo(skb)->frags; | 1216 | skb_frags = skb_shinfo(skb)->frags; |
1217 | while (len > 0) { | 1217 | while (len > 0) { |
1218 | memcpy(skb_frags, rx_frags, sizeof(*skb_frags)); | 1218 | memcpy(skb_frags, rx_frags, sizeof(*skb_frags)); |
1219 | len -= rx_frags->size; | 1219 | len -= skb_frag_size(rx_frags); |
1220 | skb_frags++; | 1220 | skb_frags++; |
1221 | rx_frags++; | 1221 | rx_frags++; |
1222 | skb_shinfo(skb)->nr_frags++; | 1222 | skb_shinfo(skb)->nr_frags++; |
@@ -1228,7 +1228,7 @@ myri10ge_rx_skb_build(struct sk_buff *skb, u8 * va, | |||
1228 | * manually */ | 1228 | * manually */ |
1229 | skb_copy_to_linear_data(skb, va, hlen); | 1229 | skb_copy_to_linear_data(skb, va, hlen); |
1230 | skb_shinfo(skb)->frags[0].page_offset += hlen; | 1230 | skb_shinfo(skb)->frags[0].page_offset += hlen; |
1231 | skb_shinfo(skb)->frags[0].size -= hlen; | 1231 | skb_frag_size_sub(&skb_shinfo(skb)->frags[0], hlen); |
1232 | skb->data_len -= hlen; | 1232 | skb->data_len -= hlen; |
1233 | skb->tail += hlen; | 1233 | skb->tail += hlen; |
1234 | skb_pull(skb, MXGEFW_PAD); | 1234 | skb_pull(skb, MXGEFW_PAD); |
@@ -1345,9 +1345,9 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum, | |||
1345 | __skb_frag_set_page(&rx_frags[i], rx->info[idx].page); | 1345 | __skb_frag_set_page(&rx_frags[i], rx->info[idx].page); |
1346 | rx_frags[i].page_offset = rx->info[idx].page_offset; | 1346 | rx_frags[i].page_offset = rx->info[idx].page_offset; |
1347 | if (remainder < MYRI10GE_ALLOC_SIZE) | 1347 | if (remainder < MYRI10GE_ALLOC_SIZE) |
1348 | rx_frags[i].size = remainder; | 1348 | skb_frag_size_set(&rx_frags[i], remainder); |
1349 | else | 1349 | else |
1350 | rx_frags[i].size = MYRI10GE_ALLOC_SIZE; | 1350 | skb_frag_size_set(&rx_frags[i], MYRI10GE_ALLOC_SIZE); |
1351 | rx->cnt++; | 1351 | rx->cnt++; |
1352 | idx = rx->cnt & rx->mask; | 1352 | idx = rx->cnt & rx->mask; |
1353 | remainder -= MYRI10GE_ALLOC_SIZE; | 1353 | remainder -= MYRI10GE_ALLOC_SIZE; |
@@ -1355,7 +1355,7 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum, | |||
1355 | 1355 | ||
1356 | if (lro_enabled) { | 1356 | if (lro_enabled) { |
1357 | rx_frags[0].page_offset += MXGEFW_PAD; | 1357 | rx_frags[0].page_offset += MXGEFW_PAD; |
1358 | rx_frags[0].size -= MXGEFW_PAD; | 1358 | skb_frag_size_sub(&rx_frags[0], MXGEFW_PAD); |
1359 | len -= MXGEFW_PAD; | 1359 | len -= MXGEFW_PAD; |
1360 | lro_receive_frags(&ss->rx_done.lro_mgr, rx_frags, | 1360 | lro_receive_frags(&ss->rx_done.lro_mgr, rx_frags, |
1361 | /* opaque, will come back in get_frag_header */ | 1361 | /* opaque, will come back in get_frag_header */ |
@@ -1382,7 +1382,7 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum, | |||
1382 | 1382 | ||
1383 | /* Attach the pages to the skb, and trim off any padding */ | 1383 | /* Attach the pages to the skb, and trim off any padding */ |
1384 | myri10ge_rx_skb_build(skb, va, rx_frags, len, hlen); | 1384 | myri10ge_rx_skb_build(skb, va, rx_frags, len, hlen); |
1385 | if (skb_shinfo(skb)->frags[0].size <= 0) { | 1385 | if (skb_frag_size(&skb_shinfo(skb)->frags[0]) <= 0) { |
1386 | skb_frag_unref(skb, 0); | 1386 | skb_frag_unref(skb, 0); |
1387 | skb_shinfo(skb)->nr_frags = 0; | 1387 | skb_shinfo(skb)->nr_frags = 0; |
1388 | } | 1388 | } |
@@ -2926,7 +2926,7 @@ again: | |||
2926 | idx = (count + tx->req) & tx->mask; | 2926 | idx = (count + tx->req) & tx->mask; |
2927 | frag = &skb_shinfo(skb)->frags[frag_idx]; | 2927 | frag = &skb_shinfo(skb)->frags[frag_idx]; |
2928 | frag_idx++; | 2928 | frag_idx++; |
2929 | len = frag->size; | 2929 | len = skb_frag_size(frag); |
2930 | bus = skb_frag_dma_map(&mgp->pdev->dev, frag, 0, len, | 2930 | bus = skb_frag_dma_map(&mgp->pdev->dev, frag, 0, len, |
2931 | DMA_TO_DEVICE); | 2931 | DMA_TO_DEVICE); |
2932 | dma_unmap_addr_set(&tx->info[idx], bus, bus); | 2932 | dma_unmap_addr_set(&tx->info[idx], bus, bus); |