OSDN Git Service

xen-netfront: refactor skb slot counting
[uclinux-h8/linux.git] / drivers / net / xen-netfront.c
index 2f0a9ce..803ff53 100644 (file)
@@ -144,10 +144,6 @@ struct netfront_queue {
        struct sk_buff *rx_skbs[NET_RX_RING_SIZE];
        grant_ref_t gref_rx_head;
        grant_ref_t grant_rx_ref[NET_RX_RING_SIZE];
-
-       unsigned long rx_pfn_array[NET_RX_RING_SIZE];
-       struct multicall_entry rx_mcl[NET_RX_RING_SIZE+1];
-       struct mmu_update rx_mmu[NET_RX_RING_SIZE];
 };
 
 struct netfront_info {
@@ -521,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;
@@ -597,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);
@@ -977,7 +974,6 @@ static int xennet_poll(struct napi_struct *napi, int budget)
        struct sk_buff_head rxq;
        struct sk_buff_head errq;
        struct sk_buff_head tmpq;
-       unsigned long flags;
        int err;
 
        spin_lock(&queue->rx_lock);
@@ -1050,15 +1046,11 @@ err:
        if (work_done < budget) {
                int more_to_do = 0;
 
-               napi_gro_flush(napi, false);
-
-               local_irq_save(flags);
+               napi_complete(napi);
 
                RING_FINAL_CHECK_FOR_RESPONSES(&queue->rx, more_to_do);
-               if (!more_to_do)
-                       __napi_complete(napi);
-
-               local_irq_restore(flags);
+               if (more_to_do)
+                       napi_schedule(napi);
        }
 
        spin_unlock(&queue->rx_lock);