[NET]: Make NAPI polling independent of struct net_device objects.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / net / amd8111e.c
index 9c399aaefbdd1b6b045c97fab94e28dfaef3b990..cf06fc067e92ad6b58f8e5b6d14800ce56a4e56f 100644 (file)
@@ -155,7 +155,7 @@ This function will write into PHY registers.
 */
 static int amd8111e_write_phy(struct amd8111e_priv* lp,int phy_id, int reg, u32 val)
 {
-       unsigned int repeat = REPEAT_CNT
+       unsigned int repeat = REPEAT_CNT;
        void __iomem *mmio = lp->mmio;
        unsigned int reg_val;
 
@@ -723,9 +723,10 @@ static int amd8111e_tx(struct net_device *dev)
 
 #ifdef CONFIG_AMD8111E_NAPI
 /* This function handles the driver receive operation in polling mode */
-static int amd8111e_rx_poll(struct net_device *dev, int * budget)
+static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
 {
-       struct amd8111e_priv *lp = netdev_priv(dev);
+       struct amd8111e_priv *lp = container_of(napi, struct amd8111e_priv, napi);
+       struct net_device *dev = lp->amd8111e_net_dev;
        int rx_index = lp->rx_idx & RX_RING_DR_MOD_MASK;
        void __iomem *mmio = lp->mmio;
        struct sk_buff *skb,*new_skb;
@@ -737,7 +738,7 @@ static int amd8111e_rx_poll(struct net_device *dev, int * budget)
 #if AMD8111E_VLAN_TAG_USED
        short vtag;
 #endif
-       int rx_pkt_limit = dev->quota;
+       int rx_pkt_limit = budget;
        unsigned long flags;
 
        do{
@@ -798,9 +799,7 @@ static int amd8111e_rx_poll(struct net_device *dev, int * budget)
                        pci_unmap_single(lp->pci_dev,lp->rx_dma_addr[rx_index],
                                         lp->rx_buff_len-2, PCI_DMA_FROMDEVICE);
                        skb_put(skb, pkt_len);
-                       skb->dev = dev;
                        lp->rx_skbuff[rx_index] = new_skb;
-                       new_skb->dev = dev;
                        lp->rx_dma_addr[rx_index] = pci_map_single(lp->pci_dev,
                                                                   new_skb->data,
                                                                   lp->rx_buff_len-2,
@@ -840,21 +839,14 @@ static int amd8111e_rx_poll(struct net_device *dev, int * budget)
        } while(intr0 & RINT0);
 
        /* Receive descriptor is empty now */
-       dev->quota -= num_rx_pkt;
-       *budget -= num_rx_pkt;
-
        spin_lock_irqsave(&lp->lock, flags);
-       netif_rx_complete(dev);
+       __netif_rx_complete(dev, napi);
        writel(VAL0|RINTEN0, mmio + INTEN0);
        writel(VAL2 | RDMD0, mmio + CMD0);
        spin_unlock_irqrestore(&lp->lock, flags);
-       return 0;
 
 rx_not_empty:
-       /* Do not call a netif_rx_complete */
-       dev->quota -= num_rx_pkt;
-       *budget -= num_rx_pkt;
-       return 1;
+       return num_rx_pkt;
 }
 
 #else
@@ -926,9 +918,7 @@ static int amd8111e_rx(struct net_device *dev)
                pci_unmap_single(lp->pci_dev,lp->rx_dma_addr[rx_index],
                        lp->rx_buff_len-2, PCI_DMA_FROMDEVICE);
                skb_put(skb, pkt_len);
-               skb->dev = dev;
                lp->rx_skbuff[rx_index] = new_skb;
-               new_skb->dev = dev;
                lp->rx_dma_addr[rx_index] = pci_map_single(lp->pci_dev,
                        new_skb->data, lp->rx_buff_len-2,PCI_DMA_FROMDEVICE);
 
@@ -1291,11 +1281,11 @@ static irqreturn_t amd8111e_interrupt(int irq, void *dev_id)
        /* Check if Receive Interrupt has occurred. */
 #ifdef CONFIG_AMD8111E_NAPI
        if(intr0 & RINT0){
-               if(netif_rx_schedule_prep(dev)){
+               if(netif_rx_schedule_prep(dev, &lp->napi)){
                        /* Disable receive interupts */
                        writel(RINTEN0, mmio + INTEN0);
                        /* Schedule a polling routine */
-                       __netif_rx_schedule(dev);
+                       __netif_rx_schedule(dev, &lp->napi);
                }
                else if (intren0 & RINTEN0) {
                        printk("************Driver bug! \
@@ -1349,6 +1339,8 @@ static int amd8111e_close(struct net_device * dev)
        struct amd8111e_priv *lp = netdev_priv(dev);
        netif_stop_queue(dev);
 
+       napi_disable(&lp->napi);
+
        spin_lock_irq(&lp->lock);
 
        amd8111e_disable_interrupt(lp);
@@ -1379,12 +1371,15 @@ static int amd8111e_open(struct net_device * dev )
                                         dev->name, dev))
                return -EAGAIN;
 
+       napi_enable(&lp->napi);
+
        spin_lock_irq(&lp->lock);
 
        amd8111e_init_hw_default(lp);
 
        if(amd8111e_restart(dev)){
                spin_unlock_irq(&lp->lock);
+               napi_disable(&lp->napi);
                if (dev->irq)
                        free_irq(dev->irq, dev);
                return -ENOMEM;
@@ -1732,16 +1727,8 @@ static void amd8111e_vlan_rx_register(struct net_device *dev, struct vlan_group
        lp->vlgrp = grp;
        spin_unlock_irq(&lp->lock);
 }
-
-static void amd8111e_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
-{
-       struct amd8111e_priv *lp = netdev_priv(dev);
-       spin_lock_irq(&lp->lock);
-       if (lp->vlgrp)
-               lp->vlgrp->vlan_devices[vid] = NULL;
-       spin_unlock_irq(&lp->lock);
-}
 #endif
+
 static int amd8111e_enable_magicpkt(struct amd8111e_priv* lp)
 {
        writel( VAL1|MPPLBA, lp->mmio + CMD3);
@@ -2001,7 +1988,6 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
 #if AMD8111E_VLAN_TAG_USED
        dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX ;
        dev->vlan_rx_register =amd8111e_vlan_rx_register;
-       dev->vlan_rx_kill_vid = amd8111e_vlan_rx_kill_vid;
 #endif
 
        lp = netdev_priv(dev);
@@ -2044,8 +2030,7 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
        dev->tx_timeout = amd8111e_tx_timeout;
        dev->watchdog_timeo = AMD8111E_TX_TIMEOUT;
 #ifdef CONFIG_AMD8111E_NAPI
-       dev->poll = amd8111e_rx_poll;
-       dev->weight = 32;
+       netif_napi_add(dev, &lp->napi, amd8111e_rx_poll, 32);
 #endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
        dev->poll_controller = amd8111e_poll;
@@ -2054,7 +2039,6 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
 #if AMD8111E_VLAN_TAG_USED
        dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
        dev->vlan_rx_register =amd8111e_vlan_rx_register;
-       dev->vlan_rx_kill_vid = amd8111e_vlan_rx_kill_vid;
 #endif
        /* Probe the external PHY */
        amd8111e_probe_ext_phy(dev);