aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2009-03-26 11:11:40 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-27 03:46:53 -0400
commitc6bca821e66c5fec8ffc11ff24a82adf338bcf6b (patch)
treec394e261ebc039263426637d33f8f776fea47488 /drivers/net
parent2c7669e3a9f748dd35743f06cbdaf4340263c3bf (diff)
netdev: convert ni65 to net_device_ops
Also, use internal net_device_stats. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ni65.c75
1 files changed, 32 insertions, 43 deletions
diff --git a/drivers/net/ni65.c b/drivers/net/ni65.c
index df5f869e8d8f..6474f02bf783 100644
--- a/drivers/net/ni65.c
+++ b/drivers/net/ni65.c
@@ -237,7 +237,7 @@ struct priv
237 void *tmdbounce[TMDNUM]; 237 void *tmdbounce[TMDNUM];
238 int tmdbouncenum; 238 int tmdbouncenum;
239 int lock,xmit_queued; 239 int lock,xmit_queued;
240 struct net_device_stats stats; 240
241 void *self; 241 void *self;
242 int cmdr_addr; 242 int cmdr_addr;
243 int cardno; 243 int cardno;
@@ -257,7 +257,6 @@ static void ni65_timeout(struct net_device *dev);
257static int ni65_close(struct net_device *dev); 257static int ni65_close(struct net_device *dev);
258static int ni65_alloc_buffer(struct net_device *dev); 258static int ni65_alloc_buffer(struct net_device *dev);
259static void ni65_free_buffer(struct priv *p); 259static void ni65_free_buffer(struct priv *p);
260static struct net_device_stats *ni65_get_stats(struct net_device *);
261static void set_multicast_list(struct net_device *dev); 260static void set_multicast_list(struct net_device *dev);
262 261
263static int irqtab[] __initdata = { 9,12,15,5 }; /* irq config-translate */ 262static int irqtab[] __initdata = { 9,12,15,5 }; /* irq config-translate */
@@ -401,6 +400,17 @@ out:
401 return ERR_PTR(err); 400 return ERR_PTR(err);
402} 401}
403 402
403static const struct net_device_ops ni65_netdev_ops = {
404 .ndo_open = ni65_open,
405 .ndo_stop = ni65_close,
406 .ndo_start_xmit = ni65_send_packet,
407 .ndo_tx_timeout = ni65_timeout,
408 .ndo_set_multicast_list = set_multicast_list,
409 .ndo_change_mtu = eth_change_mtu,
410 .ndo_set_mac_address = eth_mac_addr,
411 .ndo_validate_addr = eth_validate_addr,
412};
413
404/* 414/*
405 * this is the real card probe .. 415 * this is the real card probe ..
406 */ 416 */
@@ -549,13 +559,9 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
549 } 559 }
550 560
551 dev->base_addr = ioaddr; 561 dev->base_addr = ioaddr;
552 dev->open = ni65_open; 562 dev->netdev_ops = &ni65_netdev_ops;
553 dev->stop = ni65_close;
554 dev->hard_start_xmit = ni65_send_packet;
555 dev->tx_timeout = ni65_timeout;
556 dev->watchdog_timeo = HZ/2; 563 dev->watchdog_timeo = HZ/2;
557 dev->get_stats = ni65_get_stats; 564
558 dev->set_multicast_list = set_multicast_list;
559 return 0; /* everything is OK */ 565 return 0; /* everything is OK */
560} 566}
561 567
@@ -901,13 +907,13 @@ static irqreturn_t ni65_interrupt(int irq, void * dev_id)
901 if(debuglevel > 1) 907 if(debuglevel > 1)
902 printk(KERN_ERR "%s: general error: %04x.\n",dev->name,csr0); 908 printk(KERN_ERR "%s: general error: %04x.\n",dev->name,csr0);
903 if(csr0 & CSR0_BABL) 909 if(csr0 & CSR0_BABL)
904 p->stats.tx_errors++; 910 dev->stats.tx_errors++;
905 if(csr0 & CSR0_MISS) { 911 if(csr0 & CSR0_MISS) {
906 int i; 912 int i;
907 for(i=0;i<RMDNUM;i++) 913 for(i=0;i<RMDNUM;i++)
908 printk("%02x ",p->rmdhead[i].u.s.status); 914 printk("%02x ",p->rmdhead[i].u.s.status);
909 printk("\n"); 915 printk("\n");
910 p->stats.rx_errors++; 916 dev->stats.rx_errors++;
911 } 917 }
912 if(csr0 & CSR0_MERR) { 918 if(csr0 & CSR0_MERR) {
913 if(debuglevel > 1) 919 if(debuglevel > 1)
@@ -997,12 +1003,12 @@ static void ni65_xmit_intr(struct net_device *dev,int csr0)
997#endif 1003#endif
998 /* checking some errors */ 1004 /* checking some errors */
999 if(tmdp->status2 & XMIT_RTRY) 1005 if(tmdp->status2 & XMIT_RTRY)
1000 p->stats.tx_aborted_errors++; 1006 dev->stats.tx_aborted_errors++;
1001 if(tmdp->status2 & XMIT_LCAR) 1007 if(tmdp->status2 & XMIT_LCAR)
1002 p->stats.tx_carrier_errors++; 1008 dev->stats.tx_carrier_errors++;
1003 if(tmdp->status2 & (XMIT_BUFF | XMIT_UFLO )) { 1009 if(tmdp->status2 & (XMIT_BUFF | XMIT_UFLO )) {
1004 /* this stops the xmitter */ 1010 /* this stops the xmitter */
1005 p->stats.tx_fifo_errors++; 1011 dev->stats.tx_fifo_errors++;
1006 if(debuglevel > 0) 1012 if(debuglevel > 0)
1007 printk(KERN_ERR "%s: Xmit FIFO/BUFF error\n",dev->name); 1013 printk(KERN_ERR "%s: Xmit FIFO/BUFF error\n",dev->name);
1008 if(p->features & INIT_RING_BEFORE_START) { 1014 if(p->features & INIT_RING_BEFORE_START) {
@@ -1016,12 +1022,12 @@ static void ni65_xmit_intr(struct net_device *dev,int csr0)
1016 if(debuglevel > 2) 1022 if(debuglevel > 2)
1017 printk(KERN_ERR "%s: xmit-error: %04x %02x-%04x\n",dev->name,csr0,(int) tmdstat,(int) tmdp->status2); 1023 printk(KERN_ERR "%s: xmit-error: %04x %02x-%04x\n",dev->name,csr0,(int) tmdstat,(int) tmdp->status2);
1018 if(!(csr0 & CSR0_BABL)) /* don't count errors twice */ 1024 if(!(csr0 & CSR0_BABL)) /* don't count errors twice */
1019 p->stats.tx_errors++; 1025 dev->stats.tx_errors++;
1020 tmdp->status2 = 0; 1026 tmdp->status2 = 0;
1021 } 1027 }
1022 else { 1028 else {
1023 p->stats.tx_bytes -= (short)(tmdp->blen); 1029 dev->stats.tx_bytes -= (short)(tmdp->blen);
1024 p->stats.tx_packets++; 1030 dev->stats.tx_packets++;
1025 } 1031 }
1026 1032
1027#ifdef XMT_VIA_SKB 1033#ifdef XMT_VIA_SKB
@@ -1057,7 +1063,7 @@ static void ni65_recv_intr(struct net_device *dev,int csr0)
1057 if(!(rmdstat & RCV_ERR)) { 1063 if(!(rmdstat & RCV_ERR)) {
1058 if(rmdstat & RCV_START) 1064 if(rmdstat & RCV_START)
1059 { 1065 {
1060 p->stats.rx_length_errors++; 1066 dev->stats.rx_length_errors++;
1061 printk(KERN_ERR "%s: recv, packet too long: %d\n",dev->name,rmdp->mlen & 0x0fff); 1067 printk(KERN_ERR "%s: recv, packet too long: %d\n",dev->name,rmdp->mlen & 0x0fff);
1062 } 1068 }
1063 } 1069 }
@@ -1066,16 +1072,16 @@ static void ni65_recv_intr(struct net_device *dev,int csr0)
1066 printk(KERN_ERR "%s: receive-error: %04x, lance-status: %04x/%04x\n", 1072 printk(KERN_ERR "%s: receive-error: %04x, lance-status: %04x/%04x\n",
1067 dev->name,(int) rmdstat,csr0,(int) inw(PORT+L_DATAREG) ); 1073 dev->name,(int) rmdstat,csr0,(int) inw(PORT+L_DATAREG) );
1068 if(rmdstat & RCV_FRAM) 1074 if(rmdstat & RCV_FRAM)
1069 p->stats.rx_frame_errors++; 1075 dev->stats.rx_frame_errors++;
1070 if(rmdstat & RCV_OFLO) 1076 if(rmdstat & RCV_OFLO)
1071 p->stats.rx_over_errors++; 1077 dev->stats.rx_over_errors++;
1072 if(rmdstat & RCV_CRC) 1078 if(rmdstat & RCV_CRC)
1073 p->stats.rx_crc_errors++; 1079 dev->stats.rx_crc_errors++;
1074 if(rmdstat & RCV_BUF_ERR) 1080 if(rmdstat & RCV_BUF_ERR)
1075 p->stats.rx_fifo_errors++; 1081 dev->stats.rx_fifo_errors++;
1076 } 1082 }
1077 if(!(csr0 & CSR0_MISS)) /* don't count errors twice */ 1083 if(!(csr0 & CSR0_MISS)) /* don't count errors twice */
1078 p->stats.rx_errors++; 1084 dev->stats.rx_errors++;
1079 } 1085 }
1080 else if( (len = (rmdp->mlen & 0x0fff) - 4) >= 60) 1086 else if( (len = (rmdp->mlen & 0x0fff) - 4) >= 60)
1081 { 1087 {
@@ -1106,20 +1112,20 @@ static void ni65_recv_intr(struct net_device *dev,int csr0)
1106 skb_put(skb,len); 1112 skb_put(skb,len);
1107 skb_copy_to_linear_data(skb, (unsigned char *) p->recvbounce[p->rmdnum],len); 1113 skb_copy_to_linear_data(skb, (unsigned char *) p->recvbounce[p->rmdnum],len);
1108#endif 1114#endif
1109 p->stats.rx_packets++; 1115 dev->stats.rx_packets++;
1110 p->stats.rx_bytes += len; 1116 dev->stats.rx_bytes += len;
1111 skb->protocol=eth_type_trans(skb,dev); 1117 skb->protocol=eth_type_trans(skb,dev);
1112 netif_rx(skb); 1118 netif_rx(skb);
1113 } 1119 }
1114 else 1120 else
1115 { 1121 {
1116 printk(KERN_ERR "%s: can't alloc new sk_buff\n",dev->name); 1122 printk(KERN_ERR "%s: can't alloc new sk_buff\n",dev->name);
1117 p->stats.rx_dropped++; 1123 dev->stats.rx_dropped++;
1118 } 1124 }
1119 } 1125 }
1120 else { 1126 else {
1121 printk(KERN_INFO "%s: received runt packet\n",dev->name); 1127 printk(KERN_INFO "%s: received runt packet\n",dev->name);
1122 p->stats.rx_errors++; 1128 dev->stats.rx_errors++;
1123 } 1129 }
1124 rmdp->blen = -(R_BUF_SIZE-8); 1130 rmdp->blen = -(R_BUF_SIZE-8);
1125 rmdp->mlen = 0; 1131 rmdp->mlen = 0;
@@ -1213,23 +1219,6 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev)
1213 return 0; 1219 return 0;
1214} 1220}
1215 1221
1216static struct net_device_stats *ni65_get_stats(struct net_device *dev)
1217{
1218
1219#if 0
1220 int i;
1221 struct priv *p = dev->ml_priv;
1222 for(i=0;i<RMDNUM;i++)
1223 {
1224 struct rmd *rmdp = p->rmdhead + ((p->rmdnum + i) & (RMDNUM-1));
1225 printk("%02x ",rmdp->u.s.status);
1226 }
1227 printk("\n");
1228#endif
1229
1230 return &((struct priv *)dev->ml_priv)->stats;
1231}
1232
1233static void set_multicast_list(struct net_device *dev) 1222static void set_multicast_list(struct net_device *dev)
1234{ 1223{
1235 if(!ni65_lance_reinit(dev)) 1224 if(!ni65_lance_reinit(dev))