libertas: implement new scanning logic
[safe/jmp/linux-2.6] / drivers / net / pci-skeleton.c
index e0e2939..ed402e0 100644 (file)
@@ -98,7 +98,7 @@ IVc. Errata
 #include <linux/crc32.h>
 #include <asm/io.h>
 
-#define NETDRV_VERSION         "1.0.0"
+#define NETDRV_VERSION         "1.0.1"
 #define MODNAME                        "netdrv"
 #define NETDRV_DRIVER_LOAD_MSG "MyVendor Fast Ethernet driver " NETDRV_VERSION " loaded"
 #define PFX                    MODNAME ": "
@@ -457,7 +457,6 @@ struct netdrv_private {
        void *mmio_addr;
        int drv_flags;
        struct pci_dev *pci_dev;
-       struct net_device_stats stats;
        struct timer_list timer;        /* Media selection timer. */
        unsigned char *rx_ring;
        unsigned int cur_rx;    /* Index into the Rx buffer of next Rx pkt. */
@@ -502,11 +501,9 @@ static void netdrv_tx_timeout (struct net_device *dev);
 static void netdrv_init_ring (struct net_device *dev);
 static int netdrv_start_xmit (struct sk_buff *skb,
                               struct net_device *dev);
-static irqreturn_t netdrv_interrupt (int irq, void *dev_instance,
-                              struct pt_regs *regs);
+static irqreturn_t netdrv_interrupt (int irq, void *dev_instance);
 static int netdrv_close (struct net_device *dev);
 static int netdrv_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
-static struct net_device_stats *netdrv_get_stats (struct net_device *dev);
 static void netdrv_set_rx_mode (struct net_device *dev);
 static void netdrv_hw_start (struct net_device *dev);
 
@@ -605,7 +602,6 @@ static int __devinit netdrv_init_board (struct pci_dev *pdev,
                DPRINTK ("EXIT, returning -ENOMEM\n");
                return -ENOMEM;
        }
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
        tp = dev->priv;
 
@@ -711,8 +707,8 @@ match:
                tp->chipset,
                rtl_chip_info[tp->chipset].name);
 
-       i = register_netdev (dev);
-       if (i)
+       rc = register_netdev (dev);
+       if (rc)
                goto err_out_unmap;
 
        DPRINTK ("EXIT, returning 0\n");
@@ -741,6 +737,7 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
        int i, addr_len, option;
        void *ioaddr = NULL;
        static int board_idx = -1;
+       DECLARE_MAC_BUF(mac);
 
 /* when built into the kernel, we only print version if device is found */
 #ifndef MODULE
@@ -777,7 +774,6 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
        dev->open = netdrv_open;
        dev->hard_start_xmit = netdrv_start_xmit;
        dev->stop = netdrv_close;
-       dev->get_stats = netdrv_get_stats;
        dev->set_multicast_list = netdrv_set_rx_mode;
        dev->do_ioctl = netdrv_ioctl;
        dev->tx_timeout = netdrv_tx_timeout;
@@ -801,15 +797,11 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
 
        tp->phys[0] = 32;
 
-       printk (KERN_INFO "%s: %s at 0x%lx, "
-               "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, "
-               "IRQ %d\n",
+       printk (KERN_INFO "%s: %s at 0x%lx, %sIRQ %d\n",
                dev->name,
                board_info[ent->driver_data].name,
                dev->base_addr,
-               dev->dev_addr[0], dev->dev_addr[1],
-               dev->dev_addr[2], dev->dev_addr[3],
-               dev->dev_addr[4], dev->dev_addr[5],
+               print_mac(mac, dev->dev_addr),
                dev->irq);
 
        printk (KERN_DEBUG "%s:  Identified 8139 chip type '%s'\n",
@@ -1278,7 +1270,7 @@ static void netdrv_tx_clear (struct netdrv_private *tp)
                if (rp->skb) {
                        dev_kfree_skb (rp->skb);
                        rp->skb = NULL;
-                       tp->stats.tx_dropped++;
+                       dev->stats.tx_dropped++;
                }
        }
 }
@@ -1318,7 +1310,7 @@ static void netdrv_tx_timeout (struct net_device *dev)
 
        /* Stop a shared interrupt from scavenging while we are. */
        spin_lock_irqsave (&tp->lock, flags);
-       
+
        netdrv_tx_clear (tp);
 
        spin_unlock_irqrestore (&tp->lock, flags);
@@ -1345,7 +1337,7 @@ static int netdrv_start_xmit (struct sk_buff *skb, struct net_device *dev)
 
        tp->tx_info[entry].skb = skb;
        /* tp->tx_info[entry].mapping = 0; */
-       memcpy (tp->tx_buf[entry], skb->data, skb->len);
+       skb_copy_from_linear_data(skb, tp->tx_buf[entry], skb->len);
 
        /* Note: the chip doesn't have auto-pad! */
        NETDRV_W32 (TxStatus0 + (entry * sizeof(u32)),
@@ -1391,25 +1383,25 @@ static void netdrv_tx_interrupt (struct net_device *dev,
                        /* There was an major error, log it. */
                        DPRINTK ("%s: Transmit error, Tx status %8.8x.\n",
                                 dev->name, txstatus);
-                       tp->stats.tx_errors++;
+                       dev->stats.tx_errors++;
                        if (txstatus & TxAborted) {
-                               tp->stats.tx_aborted_errors++;
+                               dev->stats.tx_aborted_errors++;
                                NETDRV_W32 (TxConfig, TxClearAbt | (TX_DMA_BURST << TxDMAShift));
                        }
                        if (txstatus & TxCarrierLost)
-                               tp->stats.tx_carrier_errors++;
+                               dev->stats.tx_carrier_errors++;
                        if (txstatus & TxOutOfWindow)
-                               tp->stats.tx_window_errors++;
+                               dev->stats.tx_window_errors++;
                } else {
                        if (txstatus & TxUnderrun) {
                                /* Add 64 to the Tx FIFO threshold. */
                                if (tp->tx_flag < 0x00300000)
                                        tp->tx_flag += 0x00020000;
-                               tp->stats.tx_fifo_errors++;
+                               dev->stats.tx_fifo_errors++;
                        }
-                       tp->stats.collisions += (txstatus >> 24) & 15;
-                       tp->stats.tx_bytes += txstatus & 0x7ff;
-                       tp->stats.tx_packets++;
+                       dev->stats.collisions += (txstatus >> 24) & 15;
+                       dev->stats.tx_bytes += txstatus & 0x7ff;
+                       dev->stats.tx_packets++;
                }
 
                /* Free the original skb. */
@@ -1462,13 +1454,13 @@ static void netdrv_rx_err (u32 rx_status, struct net_device *dev,
                         dev->name, rx_status);
                /* A.C.: The chip hangs here. */
        }
-       tp->stats.rx_errors++;
+       dev->stats.rx_errors++;
        if (rx_status & (RxBadSymbol | RxBadAlign))
-               tp->stats.rx_frame_errors++;
+               dev->stats.rx_frame_errors++;
        if (rx_status & (RxRunt | RxTooLong))
-               tp->stats.rx_length_errors++;
+               dev->stats.rx_length_errors++;
        if (rx_status & RxCRCErr)
-               tp->stats.rx_crc_errors++;
+               dev->stats.rx_crc_errors++;
        /* Reset the receiver, based on RealTek recommendation. (Bug?) */
        tp->cur_rx = 0;
 
@@ -1566,22 +1558,21 @@ static void netdrv_rx_interrupt (struct net_device *dev,
 
                skb = dev_alloc_skb (pkt_size + 2);
                if (skb) {
-                       skb->dev = dev;
                        skb_reserve (skb, 2);   /* 16 byte align the IP fields. */
 
-                       eth_copy_and_sum (skb, &rx_ring[ring_offset + 4], pkt_size, 0);
+                       skb_copy_to_linear_data (skb, &rx_ring[ring_offset + 4], pkt_size);
                        skb_put (skb, pkt_size);
 
                        skb->protocol = eth_type_trans (skb, dev);
                        netif_rx (skb);
                        dev->last_rx = jiffies;
-                       tp->stats.rx_bytes += pkt_size;
-                       tp->stats.rx_packets++;
+                       dev->stats.rx_bytes += pkt_size;
+                       dev->stats.rx_packets++;
                } else {
                        printk (KERN_WARNING
                                "%s: Memory squeeze, dropping packet.\n",
                                dev->name);
-                       tp->stats.rx_dropped++;
+                       dev->stats.rx_dropped++;
                }
 
                cur_rx = (cur_rx + rx_size + 4 + 3) & ~3;
@@ -1610,7 +1601,7 @@ static void netdrv_weird_interrupt (struct net_device *dev,
        assert (ioaddr != NULL);
 
        /* Update the error count. */
-       tp->stats.rx_missed_errors += NETDRV_R32 (RxMissed);
+       dev->stats.rx_missed_errors += NETDRV_R32 (RxMissed);
        NETDRV_W32 (RxMissed, 0);
 
        if ((status & RxUnderrun) && link_changed &&
@@ -1631,14 +1622,14 @@ static void netdrv_weird_interrupt (struct net_device *dev,
        /* XXX along with netdrv_rx_err, are we double-counting errors? */
        if (status &
            (RxUnderrun | RxOverflow | RxErr | RxFIFOOver))
-               tp->stats.rx_errors++;
+               dev->stats.rx_errors++;
 
        if (status & (PCSTimeout))
-               tp->stats.rx_length_errors++;
+               dev->stats.rx_length_errors++;
        if (status & (RxUnderrun | RxFIFOOver))
-               tp->stats.rx_fifo_errors++;
+               dev->stats.rx_fifo_errors++;
        if (status & RxOverflow) {
-               tp->stats.rx_over_errors++;
+               dev->stats.rx_over_errors++;
                tp->cur_rx = NETDRV_R16 (RxBufAddr) % RX_BUF_LEN;
                NETDRV_W16_F (RxBufPtr, tp->cur_rx - 16);
        }
@@ -1654,8 +1645,7 @@ static void netdrv_weird_interrupt (struct net_device *dev,
 
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
-static irqreturn_t netdrv_interrupt (int irq, void *dev_instance,
-                              struct pt_regs *regs)
+static irqreturn_t netdrv_interrupt (int irq, void *dev_instance)
 {
        struct net_device *dev = (struct net_device *) dev_instance;
        struct netdrv_private *tp = dev->priv;
@@ -1743,7 +1733,7 @@ static int netdrv_close (struct net_device *dev)
        NETDRV_W16 (IntrMask, 0x0000);
 
        /* Update the error counts. */
-       tp->stats.rx_missed_errors += NETDRV_R32 (RxMissed);
+       dev->stats.rx_missed_errors += NETDRV_R32 (RxMissed);
        NETDRV_W32 (RxMissed, 0);
 
        spin_unlock_irqrestore (&tp->lock, flags);
@@ -1810,31 +1800,6 @@ static int netdrv_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
        return rc;
 }
 
-
-static struct net_device_stats *netdrv_get_stats (struct net_device *dev)
-{
-       struct netdrv_private *tp = dev->priv;
-       void *ioaddr = tp->mmio_addr;
-
-       DPRINTK ("ENTER\n");
-
-       assert (tp != NULL);
-
-       if (netif_running(dev)) {
-               unsigned long flags;
-
-               spin_lock_irqsave (&tp->lock, flags);
-
-               tp->stats.rx_missed_errors += NETDRV_R32 (RxMissed);
-               NETDRV_W32 (RxMissed, 0);
-
-               spin_unlock_irqrestore (&tp->lock, flags);
-       }
-
-       DPRINTK ("EXIT\n");
-       return &tp->stats;
-}
-
 /* Set or clear the multicast filter for this adaptor.
    This routine is not state sensitive and need not be SMP locked. */
 
@@ -1853,9 +1818,6 @@ static void netdrv_set_rx_mode (struct net_device *dev)
 
        /* Note: do not reorder, GCC is clever about common statements. */
        if (dev->flags & IFF_PROMISC) {
-               /* Unconditionally log net taps. */
-               printk (KERN_NOTICE "%s: Promiscuous mode enabled.\n",
-                       dev->name);
                rx_mode =
                    AcceptBroadcast | AcceptMulticast | AcceptMyPhys |
                    AcceptAllPhys;
@@ -1915,7 +1877,7 @@ static int netdrv_suspend (struct pci_dev *pdev, pm_message_t state)
        NETDRV_W8 (ChipCmd, (NETDRV_R8 (ChipCmd) & ChipCmdClear));
 
        /* Update the error counts. */
-       tp->stats.rx_missed_errors += NETDRV_R32 (RxMissed);
+       dev->stats.rx_missed_errors += NETDRV_R32 (RxMissed);
        NETDRV_W32 (RxMissed, 0);
 
        spin_unlock_irqrestore (&tp->lock, flags);
@@ -1963,7 +1925,7 @@ static int __init netdrv_init_module (void)
 #ifdef MODULE
        printk(version);
 #endif
-       return pci_module_init (&netdrv_pci_driver);
+       return pci_register_driver(&netdrv_pci_driver);
 }