ixgbe: fix wrong offset to fc_frame_header in ixgbe_fcoe_ddp
[safe/jmp/linux-2.6] / drivers / net / eth16i.c
index b7b8bc2..874973f 100644 (file)
@@ -152,7 +152,6 @@ static char *version =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -170,7 +169,6 @@ static char *version =
 
 
 /* Few macros */
-#define BIT(a)                ( (1 << (a)) )
 #define BITSET(ioaddr, bnum)   ((outb(((inb(ioaddr)) | (bnum)), ioaddr)))
 #define BITCLR(ioaddr, bnum)   ((outb(((inb(ioaddr)) & (~(bnum))), ioaddr)))
 
@@ -380,7 +378,6 @@ static unsigned int eth16i_debug = ETH16I_DEBUG;
 /* Information for each board */
 
 struct eth16i_local {
-       struct net_device_stats stats;
        unsigned char     tx_started;
        unsigned char     tx_buf_busy;
        unsigned short    tx_queue;  /* Number of packets in transmit buffer */
@@ -407,7 +404,7 @@ static int     eth16i_read_eeprom_word(int ioaddr);
 static void    eth16i_eeprom_cmd(int ioaddr, unsigned char command);
 static int     eth16i_open(struct net_device *dev);
 static int     eth16i_close(struct net_device *dev);
-static int     eth16i_tx(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t eth16i_tx(struct sk_buff *skb, struct net_device *dev);
 static void    eth16i_rx(struct net_device *dev);
 static void    eth16i_timeout(struct net_device *dev);
 static irqreturn_t eth16i_interrupt(int irq, void *dev_id);
@@ -426,8 +423,6 @@ static int     eth16i_set_irq(struct net_device *dev);
 static ushort  eth16i_parse_mediatype(const char* s);
 #endif
 
-static struct net_device_stats *eth16i_get_stats(struct net_device *dev);
-
 static char cardname[] __initdata = "ICL EtherTeam 16i/32";
 
 static int __init do_eth16i_probe(struct net_device *dev)
@@ -436,8 +431,6 @@ static int __init do_eth16i_probe(struct net_device *dev)
        int ioaddr;
        int base_addr = dev->base_addr;
 
-       SET_MODULE_OWNER(dev);
-
        if(eth16i_debug > 4)
                printk(KERN_DEBUG "Probing started for %s\n", cardname);
 
@@ -481,6 +474,17 @@ out:
 }
 #endif
 
+static const struct net_device_ops eth16i_netdev_ops = {
+       .ndo_open               = eth16i_open,
+       .ndo_stop               = eth16i_close,
+       .ndo_start_xmit         = eth16i_tx,
+       .ndo_set_multicast_list = eth16i_multicast,
+       .ndo_tx_timeout         = eth16i_timeout,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
 {
        struct eth16i_local *lp = netdev_priv(dev);
@@ -555,13 +559,7 @@ static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
        BITCLR(ioaddr + CONFIG_REG_1, POWERUP);
 
        /* Initialize the device structure */
-       memset(lp, 0, sizeof(struct eth16i_local));
-       dev->open               = eth16i_open;
-       dev->stop               = eth16i_close;
-       dev->hard_start_xmit    = eth16i_tx;
-       dev->get_stats          = eth16i_get_stats;
-       dev->set_multicast_list = eth16i_multicast;
-       dev->tx_timeout         = eth16i_timeout;
+       dev->netdev_ops         = &eth16i_netdev_ops;
        dev->watchdog_timeo     = TX_TIMEOUT;
        spin_lock_init(&lp->lock);
 
@@ -1029,7 +1027,7 @@ static void eth16i_timeout(struct net_device *dev)
        inw(ioaddr + TX_STATUS_REG),  (inb(ioaddr + TX_STATUS_REG) & TX_DONE) ?
                       "IRQ conflict" : "network cable problem");
 
-       dev->trans_start = jiffies;
+       dev->trans_start = jiffies; /* prevent tx timeout */
 
        /* Let's dump all registers */
        if(eth16i_debug > 0) {
@@ -1047,14 +1045,14 @@ static void eth16i_timeout(struct net_device *dev)
                printk(KERN_DEBUG "lp->tx_queue_len = %d\n", lp->tx_queue_len);
                printk(KERN_DEBUG "lp->tx_started = %d\n", lp->tx_started);
        }
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
        eth16i_reset(dev);
-       dev->trans_start = jiffies;
+       dev->trans_start = jiffies; /* prevent tx timeout */
        outw(ETH16I_INTR_ON, ioaddr + TX_INTR_REG);
        netif_wake_queue(dev);
 }
 
-static int eth16i_tx(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t eth16i_tx(struct sk_buff *skb, struct net_device *dev)
 {
        struct eth16i_local *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
@@ -1065,7 +1063,7 @@ static int eth16i_tx(struct sk_buff *skb, struct net_device *dev)
 
        if (length < ETH_ZLEN) {
                if (skb_padto(skb, ETH_ZLEN))
-                       return 0;
+                       return NETDEV_TX_OK;
                length = ETH_ZLEN;
        }
        buf = skb->data;
@@ -1111,7 +1109,6 @@ static int eth16i_tx(struct sk_buff *skb, struct net_device *dev)
                outb(TX_START | lp->tx_queue, ioaddr + TRANSMIT_START_REG);
                lp->tx_queue = 0;
                lp->tx_queue_len = 0;
-               dev->trans_start = jiffies;
                lp->tx_started = 1;
                netif_wake_queue(dev);
        }
@@ -1127,12 +1124,11 @@ static int eth16i_tx(struct sk_buff *skb, struct net_device *dev)
        /* outb(TX_INTR_DONE | TX_INTR_16_COL, ioaddr + TX_INTR_REG); */
        status = 0;
        dev_kfree_skb(skb);
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void eth16i_rx(struct net_device *dev)
 {
-       struct eth16i_local *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
        int boguscount = MAX_RX_LOOP;
 
@@ -1151,16 +1147,16 @@ static void eth16i_rx(struct net_device *dev)
                               inb(ioaddr + RECEIVE_MODE_REG), status);
 
                if( !(status & PKT_GOOD) ) {
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_errors++;
 
                        if( (pkt_len < ETH_ZLEN) || (pkt_len > ETH_FRAME_LEN) ) {
-                               lp->stats.rx_length_errors++;
+                               dev->stats.rx_length_errors++;
                                eth16i_reset(dev);
                                return;
                        }
                        else {
                                eth16i_skip_packet(dev);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                        }
                }
                else {   /* Ok so now we should have a good packet */
@@ -1171,11 +1167,10 @@ static void eth16i_rx(struct net_device *dev)
                                printk(KERN_WARNING "%s: Could'n allocate memory for packet (len %d)\n",
                                       dev->name, pkt_len);
                                eth16i_skip_packet(dev);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                break;
                        }
 
-                       skb->dev = dev;
                        skb_reserve(skb,2);
 
                        /*
@@ -1214,9 +1209,8 @@ static void eth16i_rx(struct net_device *dev)
                                printk(KERN_DEBUG ".\n");
                        }
                        netif_rx(skb);
-                       dev->last_rx = jiffies;
-                       lp->stats.rx_packets++;
-                       lp->stats.rx_bytes += pkt_len;
+                       dev->stats.rx_packets++;
+                       dev->stats.rx_bytes += pkt_len;
 
                } /* else */
 
@@ -1253,32 +1247,32 @@ static irqreturn_t eth16i_interrupt(int irq, void *dev_id)
 
        if( status & 0x7f00 ) {
 
-               lp->stats.rx_errors++;
+               dev->stats.rx_errors++;
 
                if(status & (BUS_RD_ERR << 8) )
                        printk(KERN_WARNING "%s: Bus read error.\n",dev->name);
-               if(status & (SHORT_PKT_ERR << 8) )   lp->stats.rx_length_errors++;
-               if(status & (ALIGN_ERR << 8) )       lp->stats.rx_frame_errors++;
-               if(status & (CRC_ERR << 8) )        lp->stats.rx_crc_errors++;
-               if(status & (RX_BUF_OVERFLOW << 8) ) lp->stats.rx_over_errors++;
+               if(status & (SHORT_PKT_ERR << 8) )   dev->stats.rx_length_errors++;
+               if(status & (ALIGN_ERR << 8) )       dev->stats.rx_frame_errors++;
+               if(status & (CRC_ERR << 8) )        dev->stats.rx_crc_errors++;
+               if(status & (RX_BUF_OVERFLOW << 8) ) dev->stats.rx_over_errors++;
        }
        if( status & 0x001a) {
 
-               lp->stats.tx_errors++;
+               dev->stats.tx_errors++;
 
-               if(status & CR_LOST) lp->stats.tx_carrier_errors++;
-               if(status & TX_JABBER_ERR) lp->stats.tx_window_errors++;
+               if(status & CR_LOST) dev->stats.tx_carrier_errors++;
+               if(status & TX_JABBER_ERR) dev->stats.tx_window_errors++;
 
 #if 0
                if(status & COLLISION) {
-                       lp->stats.collisions +=
+                       dev->stats.collisions +=
                                ((inb(ioaddr+TRANSMIT_MODE_REG) & 0xF0) >> 4);
                }
 #endif
                if(status & COLLISIONS_16) {
                        if(lp->col_16 < MAX_COL_16) {
                                lp->col_16++;
-                               lp->stats.collisions++;
+                               dev->stats.collisions++;
                                /* Resume transmitting, skip failed packet */
                                outb(0x02, ioaddr + COL_16_REG);
                        }
@@ -1291,8 +1285,8 @@ static irqreturn_t eth16i_interrupt(int irq, void *dev_id)
        if( status & 0x00ff ) {          /* Let's check the transmit status reg */
 
                if(status & TX_DONE) {         /* The transmit has been done */
-                       lp->stats.tx_packets = lp->tx_buffered_packets;
-                       lp->stats.tx_bytes += lp->tx_buffered_bytes;
+                       dev->stats.tx_packets = lp->tx_buffered_packets;
+                       dev->stats.tx_bytes += lp->tx_buffered_bytes;
                        lp->col_16 = 0;
 
                        if(lp->tx_queue) {           /* Is there still packets ? */
@@ -1363,21 +1357,14 @@ static void eth16i_multicast(struct net_device *dev)
 {
        int ioaddr = dev->base_addr;
 
-       if(dev->mc_count || dev->flags&(IFF_ALLMULTI|IFF_PROMISC))
+       if (!netdev_mc_empty(dev) || dev->flags&(IFF_ALLMULTI|IFF_PROMISC))
        {
-               dev->flags|=IFF_PROMISC;        /* Must do this */
                outb(3, ioaddr + RECEIVE_MODE_REG);
        } else {
                outb(2, ioaddr + RECEIVE_MODE_REG);
        }
 }
 
-static struct net_device_stats *eth16i_get_stats(struct net_device *dev)
-{
-       struct eth16i_local *lp = netdev_priv(dev);
-       return &lp->stats;
-}
-
 static void eth16i_select_regbank(unsigned char banknbr, int ioaddr)
 {
        unsigned char data;
@@ -1475,14 +1462,14 @@ int __init init_module(void)
        return -ENXIO;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        int this_dev;
 
        for(this_dev = 0; this_dev < MAX_ETH16I_CARDS; this_dev++) {
                struct net_device *dev = dev_eth16i[this_dev];
 
-               if(dev->priv) {
+               if (netdev_priv(dev)) {
                        unregister_netdev(dev);
                        free_irq(dev->irq, dev);
                        release_region(dev->base_addr, ETH16I_IO_EXTENT);
@@ -1491,15 +1478,3 @@ void cleanup_module(void)
        }
 }
 #endif /* MODULE */
-
-/*
- * Local variables:
- *  compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c eth16i.c"
- *  alt-compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict -prototypes -O6 -c eth16i.c"
- *  tab-width: 8
- *  c-basic-offset: 8
- *  c-indent-level: 8
- * End:
- */
-
-/* End of file eth16i.c */