summaryrefslogtreecommitdiff
path: root/drivers/net/xen-netfront.c
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@citrix.com>2015-01-13 20:16:43 +0300
committerDavid S. Miller <davem@davemloft.net>2015-01-14 08:22:00 +0300
commite84448d52190413400663736067f826f28a04ad6 (patch)
tree0302a5f4f7399eae1fdd8ebd8475947af51fa3c4 /drivers/net/xen-netfront.c
parent28e98c2c20e9d791cf58a624a5a2b1fca63ea47b (diff)
downloadlinux-e84448d52190413400663736067f826f28a04ad6.tar.xz
xen-netfront: refactor skb slot counting
A function to count the number of slots an skb needs is more useful than one that counts the slots needed for only the frags. Signed-off-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netfront.c')
-rw-r--r--drivers/net/xen-netfront.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index a4e50482a230..803ff5356faa 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -517,13 +517,15 @@ static void xennet_make_frags(struct sk_buff *skb, struct netfront_queue *queue,
}
/*
- * Count how many ring slots are required to send the frags of this
- * skb. Each frag might be a compound page.
+ * Count how many ring slots are required to send this skb. Each frag
+ * might be a compound page.
*/
-static int xennet_count_skb_frag_slots(struct sk_buff *skb)
+static int xennet_count_skb_slots(struct sk_buff *skb)
{
int i, frags = skb_shinfo(skb)->nr_frags;
- int pages = 0;
+ int pages;
+
+ pages = PFN_UP(offset_in_page(skb->data) + skb_headlen(skb));
for (i = 0; i < frags; i++) {
skb_frag_t *frag = skb_shinfo(skb)->frags + i;
@@ -593,8 +595,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
goto drop;
}
- slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) +
- xennet_count_skb_frag_slots(skb);
+ slots = xennet_count_skb_slots(skb);
if (unlikely(slots > MAX_SKB_FRAGS + 1)) {
net_dbg_ratelimited("xennet: skb rides the rocket: %d slots, %d bytes\n",
slots, skb->len);