ipmi: fix statistics counting issues
[safe/jmp/linux-2.6] / drivers / net / sun3_82586.c
index 4757aa6..a39c0b9 100644 (file)
@@ -209,7 +209,7 @@ static int sun3_82586_open(struct net_device *dev)
 static int check586(struct net_device *dev,char *where,unsigned size)
 {
        struct priv pb;
-       struct priv *p = /* (struct priv *) dev->priv*/ &pb;
+       struct priv *p = &pb;
        char *iscp_addr;
        int i;
 
@@ -247,7 +247,7 @@ static int check586(struct net_device *dev,char *where,unsigned size)
  */
 static void alloc586(struct net_device *dev)
 {
-       struct priv *p =        (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        sun3_reset586();
        DELAY(1);
@@ -311,7 +311,6 @@ struct net_device * __init sun3_82586_probe(int unit)
                sprintf(dev->name, "eth%d", unit);
                netdev_boot_setup_check(dev);
        }
-       SET_MODULE_OWNER(dev);
 
        dev->irq = IE_IRQ;
        dev->base_addr = ioaddr;
@@ -332,6 +331,18 @@ out:
        return ERR_PTR(err);
 }
 
+static const struct net_device_ops sun3_82586_netdev_ops = {
+       .ndo_open               = sun3_82586_open,
+       .ndo_stop               = sun3_82586_close,
+       .ndo_start_xmit         = sun3_82586_send_packet,
+       .ndo_set_multicast_list = set_multicast_list,
+       .ndo_tx_timeout         = sun3_82586_timeout,
+       .ndo_get_stats          = sun3_82586_get_stats,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_change_mtu         = eth_change_mtu,
+};
+
 static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
 {
        int i, size, retval;
@@ -364,27 +375,26 @@ static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
                goto out;
        }
 
-       ((struct priv *) (dev->priv))->memtop = (char *)dvma_btov(dev->mem_start);
-       ((struct priv *) (dev->priv))->base = (unsigned long) dvma_btov(0);
+       ((struct priv *)netdev_priv(dev))->memtop =
+                                       (char *)dvma_btov(dev->mem_start);
+       ((struct priv *)netdev_priv(dev))->base = (unsigned long) dvma_btov(0);
        alloc586(dev);
 
        /* set number of receive-buffs according to memsize */
        if(size == 0x2000)
-               ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8;
+               ((struct priv *)netdev_priv(dev))->num_recv_buffs =
+                                                       NUM_RECV_BUFFS_8;
        else if(size == 0x4000)
-               ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16;
+               ((struct priv *)netdev_priv(dev))->num_recv_buffs =
+                                                       NUM_RECV_BUFFS_16;
        else
-               ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_32;
+               ((struct priv *)netdev_priv(dev))->num_recv_buffs =
+                                                       NUM_RECV_BUFFS_32;
 
        printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq);
 
-       dev->open               = sun3_82586_open;
-       dev->stop               = sun3_82586_close;
-       dev->get_stats          = sun3_82586_get_stats;
-       dev->tx_timeout         = sun3_82586_timeout;
+       dev->netdev_ops         = &sun3_82586_netdev_ops;
        dev->watchdog_timeo     = HZ/20;
-       dev->hard_start_xmit    = sun3_82586_send_packet;
-       dev->set_multicast_list = set_multicast_list;
 
        dev->if_port            = 0;
        return 0;
@@ -398,7 +408,7 @@ static int init586(struct net_device *dev)
 {
        void *ptr;
        int i,result=0;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
        volatile struct configure_cmd_struct    *cfg_cmd;
        volatile struct iasetup_cmd_struct *ias_cmd;
        volatile struct tdr_cmd_struct *tdr_cmd;
@@ -426,14 +436,11 @@ static int init586(struct net_device *dev)
                int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
                if(num_addrs > len)     {
                        printk("%s: switching to promisc. mode\n",dev->name);
-                       dev->flags|=IFF_PROMISC;
+                       cfg_cmd->promisc = 1;
                }
        }
        if(dev->flags&IFF_PROMISC)
-       {
-                        cfg_cmd->promisc=1;
-                        dev->flags|=IFF_PROMISC;
-       }
+               cfg_cmd->promisc = 1;
        cfg_cmd->carr_coll      = 0x00;
 
        p->scb->cbl_offset      = make16(cfg_cmd);
@@ -635,7 +642,7 @@ static void *alloc_rfa(struct net_device *dev,void *ptr)
        volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
        volatile struct rbd_struct *rbd;
        int i;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
        p->rfd_first = rfd;
@@ -687,7 +694,7 @@ static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id)
                printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
                return IRQ_NONE;
        }
-       p = (struct priv *) dev->priv;
+       p = netdev_priv(dev);
 
        if(debuglevel > 1)
                printk("I");
@@ -757,7 +764,7 @@ static void sun3_82586_rcv_int(struct net_device *dev)
        unsigned short totlen;
        struct sk_buff *skb;
        struct rbd_struct *rbd;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        if(debuglevel > 0)
                printk("R");
@@ -775,10 +782,9 @@ static void sun3_82586_rcv_int(struct net_device *dev)
                                        skb = (struct sk_buff *) dev_alloc_skb(totlen+2);
                                        if(skb != NULL)
                                        {
-                                               skb->dev = dev;
                                                skb_reserve(skb,2);
                                                skb_put(skb,totlen);
-                                               eth_copy_and_sum(skb,(char *) p->base+swab32((unsigned long) rbd->buffer),totlen,0);
+                                               skb_copy_to_linear_data(skb,(char *) p->base+swab32((unsigned long) rbd->buffer),totlen);
                                                skb->protocol=eth_type_trans(skb,dev);
                                                netif_rx(skb);
                                                p->stats.rx_packets++;
@@ -876,7 +882,7 @@ static void sun3_82586_rcv_int(struct net_device *dev)
 
 static void sun3_82586_rnr_int(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        p->stats.rx_errors++;
 
@@ -900,7 +906,7 @@ static void sun3_82586_rnr_int(struct net_device *dev)
 static void sun3_82586_xmt_int(struct net_device *dev)
 {
        int status;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        if(debuglevel > 0)
                printk("X");
@@ -950,7 +956,7 @@ static void sun3_82586_xmt_int(struct net_device *dev)
 
 static void startrecv586(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        WAIT_4_SCB_CMD();
        WAIT_4_SCB_CMD_RUC();
@@ -962,7 +968,7 @@ static void startrecv586(struct net_device *dev)
 
 static void sun3_82586_timeout(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 #ifndef NO_NOPCOMMANDS
        if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
        {
@@ -1004,7 +1010,7 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
 #ifndef NO_NOPCOMMANDS
        int next_nop;
 #endif
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        if(skb->len > XMIT_BUFF_SIZE)
        {
@@ -1024,10 +1030,11 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
        {
                len = skb->len;
                if (len < ETH_ZLEN) {
-                       memset((char *)p->xmit_cbuffs[p->xmit_count], 0, ETH_ZLEN);
+                       memset((void *)p->xmit_cbuffs[p->xmit_count], 0,
+                              ETH_ZLEN);
                        len = ETH_ZLEN;
                }
-               memcpy((char *)p->xmit_cbuffs[p->xmit_count],(char *)(skb->data),skb->len);
+               skb_copy_from_linear_data(skb, (void *)p->xmit_cbuffs[p->xmit_count], skb->len);
 
 #if (NUM_XMIT_BUFFS == 1)
 #      ifdef NO_NOPCOMMANDS
@@ -1112,7 +1119,7 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
 
 static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
        unsigned short crc,aln,rsc,ovrn;
 
        crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */
@@ -1175,7 +1182,7 @@ void cleanup_module(void)
  */
 void sun3_82586_dump(struct net_device *dev,void *ptr)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
        struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
        int i;