net: Add init_dummy_netdev() and fix EMAC driver using it
[deliverable/linux.git] / net / core / dev.c
index 5f736f1ceeae0200ba77371d6373384e398233f1..8d675975d85b97cd6352e56999d6f3a1c13d4b0b 100644 (file)
@@ -1087,6 +1087,11 @@ int dev_open(struct net_device *dev)
                 */
                dev->flags |= IFF_UP;
 
+               /*
+                *      Enable NET_DMA
+                */
+               dmaengine_get();
+
                /*
                 *      Initialize multicasting status
                 */
@@ -1164,6 +1169,11 @@ int dev_close(struct net_device *dev)
         */
        call_netdevice_notifiers(NETDEV_DOWN, dev);
 
+       /*
+        *      Shutdown NET_DMA
+        */
+       dmaengine_put();
+
        return 0;
 }
 
@@ -2382,6 +2392,9 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
        if (!(skb->dev->features & NETIF_F_GRO))
                goto normal;
 
+       if (skb_is_gso(skb) || skb_shinfo(skb)->frag_list)
+               goto normal;
+
        rcu_read_lock();
        list_for_each_entry_rcu(ptype, head, list) {
                struct sk_buff *p;
@@ -2478,12 +2491,6 @@ EXPORT_SYMBOL(napi_gro_receive);
 
 void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
 {
-       skb_shinfo(skb)->nr_frags = 0;
-
-       skb->len -= skb->data_len;
-       skb->truesize -= skb->data_len;
-       skb->data_len = 0;
-
        __skb_pull(skb, skb_headlen(skb));
        skb_reserve(skb, NET_IP_ALIGN - skb_headroom(skb));
 
@@ -4423,6 +4430,45 @@ err_uninit:
        goto out;
 }
 
+/**
+ *     init_dummy_netdev       - init a dummy network device for NAPI
+ *     @dev: device to init
+ *
+ *     This takes a network device structure and initialize the minimum
+ *     amount of fields so it can be used to schedule NAPI polls without
+ *     registering a full blown interface. This is to be used by drivers
+ *     that need to tie several hardware interfaces to a single NAPI
+ *     poll scheduler due to HW limitations.
+ */
+int init_dummy_netdev(struct net_device *dev)
+{
+       /* Clear everything. Note we don't initialize spinlocks
+        * are they aren't supposed to be taken by any of the
+        * NAPI code and this dummy netdev is supposed to be
+        * only ever used for NAPI polls
+        */
+       memset(dev, 0, sizeof(struct net_device));
+
+       /* make sure we BUG if trying to hit standard
+        * register/unregister code path
+        */
+       dev->reg_state = NETREG_DUMMY;
+
+       /* initialize the ref count */
+       atomic_set(&dev->refcnt, 1);
+
+       /* NAPI wants this */
+       INIT_LIST_HEAD(&dev->napi_list);
+
+       /* a dummy interface is started by default */
+       set_bit(__LINK_STATE_PRESENT, &dev->state);
+       set_bit(__LINK_STATE_START, &dev->state);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(init_dummy_netdev);
+
+
 /**
  *     register_netdev - register a network device
  *     @dev: device to register
@@ -5151,9 +5197,6 @@ static int __init net_dev_init(void)
        hotcpu_notifier(dev_cpu_callback, 0);
        dst_init();
        dev_mcast_init();
-       #ifdef CONFIG_NET_DMA
-       dmaengine_get();
-       #endif
        rc = 0;
 out:
        return rc;
This page took 0.025056 seconds and 5 git commands to generate.