staging: et131x: Fix stats->rx_packets accounting
[pandora-kernel.git] / drivers / staging / et131x / et131x_netdev.c
1 /*
2  * Agere Systems Inc.
3  * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4  *
5  * Copyright © 2005 Agere Systems Inc.
6  * All rights reserved.
7  *   http://www.agere.com
8  *
9  *------------------------------------------------------------------------------
10  *
11  * et131x_netdev.c - Routines and data required by all Linux network devices.
12  *
13  *------------------------------------------------------------------------------
14  *
15  * SOFTWARE LICENSE
16  *
17  * This software is provided subject to the following terms and conditions,
18  * which you should read carefully before using the software.  Using this
19  * software indicates your acceptance of these terms and conditions.  If you do
20  * not agree with these terms and conditions, do not use the software.
21  *
22  * Copyright © 2005 Agere Systems Inc.
23  * All rights reserved.
24  *
25  * Redistribution and use in source or binary forms, with or without
26  * modifications, are permitted provided that the following conditions are met:
27  *
28  * . Redistributions of source code must retain the above copyright notice, this
29  *    list of conditions and the following Disclaimer as comments in the code as
30  *    well as in the documentation and/or other materials provided with the
31  *    distribution.
32  *
33  * . Redistributions in binary form must reproduce the above copyright notice,
34  *    this list of conditions and the following Disclaimer in the documentation
35  *    and/or other materials provided with the distribution.
36  *
37  * . Neither the name of Agere Systems Inc. nor the names of the contributors
38  *    may be used to endorse or promote products derived from this software
39  *    without specific prior written permission.
40  *
41  * Disclaimer
42  *
43  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
44  * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
45  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
46  * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
47  * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
48  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51  * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
52  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
54  * DAMAGE.
55  *
56  */
57
58 #include "et131x_version.h"
59 #include "et131x_defs.h"
60
61 #include <linux/init.h>
62 #include <linux/module.h>
63 #include <linux/types.h>
64 #include <linux/kernel.h>
65
66 #include <linux/sched.h>
67 #include <linux/ptrace.h>
68 #include <linux/ctype.h>
69 #include <linux/string.h>
70 #include <linux/timer.h>
71 #include <linux/interrupt.h>
72 #include <linux/in.h>
73 #include <linux/delay.h>
74 #include <linux/io.h>
75 #include <linux/bitops.h>
76 #include <linux/pci.h>
77 #include <asm/system.h>
78
79 #include <linux/mii.h>
80 #include <linux/netdevice.h>
81 #include <linux/etherdevice.h>
82 #include <linux/skbuff.h>
83 #include <linux/if_arp.h>
84 #include <linux/ioport.h>
85
86 #include "et1310_phy.h"
87 #include "et1310_tx.h"
88 #include "et131x_adapter.h"
89 #include "et131x.h"
90
91 struct net_device_stats *et131x_stats(struct net_device *netdev);
92
93 /**
94  * et131x_stats - Return the current device statistics.
95  * @netdev: device whose stats are being queried
96  *
97  * Returns 0 on success, errno on failure (as defined in errno.h)
98  */
99 struct net_device_stats *et131x_stats(struct net_device *netdev)
100 {
101         struct et131x_adapter *adapter = netdev_priv(netdev);
102         struct net_device_stats *stats = &adapter->net_stats;
103         struct ce_stats *devstat = &adapter->stats;
104
105         stats->rx_packets = devstat->ipackets;
106         stats->tx_packets = devstat->opackets;
107         stats->rx_errors = devstat->length_err + devstat->alignment_err +
108             devstat->crc_err + devstat->code_violations + devstat->other_errors;
109         stats->tx_errors = devstat->max_pkt_error;
110         stats->multicast = devstat->multircv;
111         stats->collisions = devstat->collisions;
112
113         stats->rx_length_errors = devstat->length_err;
114         stats->rx_over_errors = devstat->rx_ov_flow;
115         stats->rx_crc_errors = devstat->crc_err;
116
117         /* NOTE: These stats don't have corresponding values in CE_STATS,
118          * so we're going to have to update these directly from within the
119          * TX/RX code
120          */
121         /* stats->rx_bytes            = 20; devstat->; */
122         /* stats->tx_bytes            = 20;  devstat->; */
123         /* stats->rx_dropped          = devstat->; */
124         /* stats->tx_dropped          = devstat->; */
125
126         /*  NOTE: Not used, can't find analogous statistics */
127         /* stats->rx_frame_errors     = devstat->; */
128         /* stats->rx_fifo_errors      = devstat->; */
129         /* stats->rx_missed_errors    = devstat->; */
130
131         /* stats->tx_aborted_errors   = devstat->; */
132         /* stats->tx_carrier_errors   = devstat->; */
133         /* stats->tx_fifo_errors      = devstat->; */
134         /* stats->tx_heartbeat_errors = devstat->; */
135         /* stats->tx_window_errors    = devstat->; */
136         return stats;
137 }
138
139 /**
140  * et131x_open - Open the device for use.
141  * @netdev: device to be opened
142  *
143  * Returns 0 on success, errno on failure (as defined in errno.h)
144  */
145 int et131x_open(struct net_device *netdev)
146 {
147         int result = 0;
148         struct et131x_adapter *adapter = netdev_priv(netdev);
149
150         /* Start the timer to track NIC errors */
151         add_timer(&adapter->ErrorTimer);
152
153         /* Register our IRQ */
154         result = request_irq(netdev->irq, et131x_isr, IRQF_SHARED,
155                                         netdev->name, netdev);
156         if (result) {
157                 dev_err(&adapter->pdev->dev, "c ould not register IRQ %d\n",
158                         netdev->irq);
159                 return result;
160         }
161
162         /* Enable the Tx and Rx DMA engines (if not already enabled) */
163         et131x_rx_dma_enable(adapter);
164         et131x_tx_dma_enable(adapter);
165
166         /* Enable device interrupts */
167         et131x_enable_interrupts(adapter);
168
169         adapter->Flags |= fMP_ADAPTER_INTERRUPT_IN_USE;
170
171         /* We're ready to move some data, so start the queue */
172         netif_start_queue(netdev);
173         return result;
174 }
175
176 /**
177  * et131x_close - Close the device
178  * @netdev: device to be closed
179  *
180  * Returns 0 on success, errno on failure (as defined in errno.h)
181  */
182 int et131x_close(struct net_device *netdev)
183 {
184         struct et131x_adapter *adapter = netdev_priv(netdev);
185
186         /* First thing is to stop the queue */
187         netif_stop_queue(netdev);
188
189         /* Stop the Tx and Rx DMA engines */
190         et131x_rx_dma_disable(adapter);
191         et131x_tx_dma_disable(adapter);
192
193         /* Disable device interrupts */
194         et131x_disable_interrupts(adapter);
195
196         /* Deregistering ISR */
197         adapter->Flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE;
198         free_irq(netdev->irq, netdev);
199
200         /* Stop the error timer */
201         del_timer_sync(&adapter->ErrorTimer);
202         return 0;
203 }
204
205 /**
206  * et131x_ioctl_mii - The function which handles MII IOCTLs
207  * @netdev: device on which the query is being made
208  * @reqbuf: the request-specific data buffer
209  * @cmd: the command request code
210  *
211  * Returns 0 on success, errno on failure (as defined in errno.h)
212  */
213 int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
214 {
215         int status = 0;
216         struct et131x_adapter *etdev = netdev_priv(netdev);
217         struct mii_ioctl_data *data = if_mii(reqbuf);
218
219         switch (cmd) {
220         case SIOCGMIIPHY:
221                 data->phy_id = etdev->stats.xcvr_addr;
222                 break;
223
224         case SIOCGMIIREG:
225                 if (!capable(CAP_NET_ADMIN))
226                         status = -EPERM;
227                 else
228                         status = MiRead(etdev,
229                                         data->reg_num, &data->val_out);
230                 break;
231
232         case SIOCSMIIREG:
233                 if (!capable(CAP_NET_ADMIN))
234                         status = -EPERM;
235                 else
236                         status = MiWrite(etdev, data->reg_num,
237                                          data->val_in);
238                 break;
239
240         default:
241                 status = -EOPNOTSUPP;
242         }
243         return status;
244 }
245
246 /**
247  * et131x_ioctl - The I/O Control handler for the driver
248  * @netdev: device on which the control request is being made
249  * @reqbuf: a pointer to the IOCTL request buffer
250  * @cmd: the IOCTL command code
251  *
252  * Returns 0 on success, errno on failure (as defined in errno.h)
253  */
254 int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
255 {
256         int status = 0;
257
258         switch (cmd) {
259         case SIOCGMIIPHY:
260         case SIOCGMIIREG:
261         case SIOCSMIIREG:
262                 status = et131x_ioctl_mii(netdev, reqbuf, cmd);
263                 break;
264
265         default:
266                 status = -EOPNOTSUPP;
267         }
268         return status;
269 }
270
271 /**
272  * et131x_set_packet_filter - Configures the Rx Packet filtering on the device
273  * @adapter: pointer to our private adapter structure
274  *
275  * FIXME: lot of dups with MAC code
276  *
277  * Returns 0 on success, errno on failure
278  */
279 int et131x_set_packet_filter(struct et131x_adapter *adapter)
280 {
281         int status = 0;
282         uint32_t filter = adapter->PacketFilter;
283         u32 ctrl;
284         u32 pf_ctrl;
285
286         ctrl = readl(&adapter->regs->rxmac.ctrl);
287         pf_ctrl = readl(&adapter->regs->rxmac.pf_ctrl);
288
289         /* Default to disabled packet filtering.  Enable it in the individual
290          * case statements that require the device to filter something
291          */
292         ctrl |= 0x04;
293
294         /* Set us to be in promiscuous mode so we receive everything, this
295          * is also true when we get a packet filter of 0
296          */
297         if ((filter & ET131X_PACKET_TYPE_PROMISCUOUS) || filter == 0)
298                 pf_ctrl &= ~7;  /* Clear filter bits */
299         else {
300                 /*
301                  * Set us up with Multicast packet filtering.  Three cases are
302                  * possible - (1) we have a multi-cast list, (2) we receive ALL
303                  * multicast entries or (3) we receive none.
304                  */
305                 if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST)
306                         pf_ctrl &= ~2;  /* Multicast filter bit */
307                 else {
308                         SetupDeviceForMulticast(adapter);
309                         pf_ctrl |= 2;
310                         ctrl &= ~0x04;
311                 }
312
313                 /* Set us up with Unicast packet filtering */
314                 if (filter & ET131X_PACKET_TYPE_DIRECTED) {
315                         SetupDeviceForUnicast(adapter);
316                         pf_ctrl |= 4;
317                         ctrl &= ~0x04;
318                 }
319
320                 /* Set us up with Broadcast packet filtering */
321                 if (filter & ET131X_PACKET_TYPE_BROADCAST) {
322                         pf_ctrl |= 1;   /* Broadcast filter bit */
323                         ctrl &= ~0x04;
324                 } else
325                         pf_ctrl &= ~1;
326
327                 /* Setup the receive mac configuration registers - Packet
328                  * Filter control + the enable / disable for packet filter
329                  * in the control reg.
330                  */
331                 writel(pf_ctrl, &adapter->regs->rxmac.pf_ctrl);
332                 writel(ctrl, &adapter->regs->rxmac.ctrl);
333         }
334         return status;
335 }
336
337 /**
338  * et131x_multicast - The handler to configure multicasting on the interface
339  * @netdev: a pointer to a net_device struct representing the device
340  */
341 void et131x_multicast(struct net_device *netdev)
342 {
343         struct et131x_adapter *adapter = netdev_priv(netdev);
344         uint32_t PacketFilter = 0;
345         unsigned long flags;
346         struct netdev_hw_addr *ha;
347         int i;
348
349         spin_lock_irqsave(&adapter->Lock, flags);
350
351         /* Before we modify the platform-independent filter flags, store them
352          * locally. This allows us to determine if anything's changed and if
353          * we even need to bother the hardware
354          */
355         PacketFilter = adapter->PacketFilter;
356
357         /* Clear the 'multicast' flag locally; because we only have a single
358          * flag to check multicast, and multiple multicast addresses can be
359          * set, this is the easiest way to determine if more than one
360          * multicast address is being set.
361          */
362         PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST;
363
364         /* Check the net_device flags and set the device independent flags
365          * accordingly
366          */
367
368         if (netdev->flags & IFF_PROMISC)
369                 adapter->PacketFilter |= ET131X_PACKET_TYPE_PROMISCUOUS;
370         else
371                 adapter->PacketFilter &= ~ET131X_PACKET_TYPE_PROMISCUOUS;
372
373         if (netdev->flags & IFF_ALLMULTI)
374                 adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
375
376         if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST)
377                 adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
378
379         if (netdev_mc_count(netdev) < 1) {
380                 adapter->PacketFilter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST;
381                 adapter->PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST;
382         } else
383                 adapter->PacketFilter |= ET131X_PACKET_TYPE_MULTICAST;
384
385         /* Set values in the private adapter struct */
386         i = 0;
387         netdev_for_each_mc_addr(ha, netdev) {
388                 if (i == NIC_MAX_MCAST_LIST)
389                         break;
390                 memcpy(adapter->MCList[i++], ha->addr, ETH_ALEN);
391         }
392         adapter->MCAddressCount = i;
393
394         /* Are the new flags different from the previous ones? If not, then no
395          * action is required
396          *
397          * NOTE - This block will always update the MCList with the hardware,
398          *        even if the addresses aren't the same.
399          */
400         if (PacketFilter != adapter->PacketFilter) {
401                 /* Call the device's filter function */
402                 et131x_set_packet_filter(adapter);
403         }
404         spin_unlock_irqrestore(&adapter->Lock, flags);
405 }
406
407 /**
408  * et131x_tx - The handler to tx a packet on the device
409  * @skb: data to be Tx'd
410  * @netdev: device on which data is to be Tx'd
411  *
412  * Returns 0 on success, errno on failure (as defined in errno.h)
413  */
414 int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
415 {
416         int status = 0;
417
418         /* Save the timestamp for the TX timeout watchdog */
419         netdev->trans_start = jiffies;
420
421         /* Call the device-specific data Tx routine */
422         status = et131x_send_packets(skb, netdev);
423
424         /* Check status and manage the netif queue if necessary */
425         if (status != 0) {
426                 if (status == -ENOMEM) {
427                         /* Put the queue to sleep until resources are
428                          * available
429                          */
430                         netif_stop_queue(netdev);
431                         status = NETDEV_TX_BUSY;
432                 } else {
433                         status = NETDEV_TX_OK;
434                 }
435         }
436         return status;
437 }
438
439 /**
440  * et131x_tx_timeout - Timeout handler
441  * @netdev: a pointer to a net_device struct representing the device
442  *
443  * The handler called when a Tx request times out. The timeout period is
444  * specified by the 'tx_timeo" element in the net_device structure (see
445  * et131x_alloc_device() to see how this value is set).
446  */
447 void et131x_tx_timeout(struct net_device *netdev)
448 {
449         struct et131x_adapter *etdev = netdev_priv(netdev);
450         struct tcb *tcb;
451         unsigned long flags;
452
453         /* Any nonrecoverable hardware error?
454          * Checks adapter->flags for any failure in phy reading
455          */
456         if (etdev->Flags & fMP_ADAPTER_NON_RECOVER_ERROR)
457                 return;
458
459         /* Hardware failure? */
460         if (etdev->Flags & fMP_ADAPTER_HARDWARE_ERROR) {
461                 dev_err(&etdev->pdev->dev, "hardware error - reset\n");
462                 return;
463         }
464
465         /* Is send stuck? */
466         spin_lock_irqsave(&etdev->TCBSendQLock, flags);
467
468         tcb = etdev->tx_ring.send_head;
469
470         if (tcb != NULL) {
471                 tcb->count++;
472
473                 if (tcb->count > NIC_SEND_HANG_THRESHOLD) {
474                         spin_unlock_irqrestore(&etdev->TCBSendQLock,
475                                                flags);
476
477                         dev_warn(&etdev->pdev->dev,
478                                 "Send stuck - reset.  tcb->WrIndex %x, Flags 0x%08x\n",
479                                 tcb->index,
480                                 tcb->flags);
481
482                         et131x_close(netdev);
483                         et131x_open(netdev);
484
485                         return;
486                 }
487         }
488
489         spin_unlock_irqrestore(&etdev->TCBSendQLock, flags);
490 }
491
492 /**
493  * et131x_change_mtu - The handler called to change the MTU for the device
494  * @netdev: device whose MTU is to be changed
495  * @new_mtu: the desired MTU
496  *
497  * Returns 0 on success, errno on failure (as defined in errno.h)
498  */
499 int et131x_change_mtu(struct net_device *netdev, int new_mtu)
500 {
501         int result = 0;
502         struct et131x_adapter *adapter = netdev_priv(netdev);
503
504         /* Make sure the requested MTU is valid */
505         if (new_mtu < 64 || new_mtu > 9216)
506                 return -EINVAL;
507
508         /* Stop the netif queue */
509         netif_stop_queue(netdev);
510
511         /* Stop the Tx and Rx DMA engines */
512         et131x_rx_dma_disable(adapter);
513         et131x_tx_dma_disable(adapter);
514
515         /* Disable device interrupts */
516         et131x_disable_interrupts(adapter);
517         et131x_handle_send_interrupt(adapter);
518         et131x_handle_recv_interrupt(adapter);
519
520         /* Set the new MTU */
521         netdev->mtu = new_mtu;
522
523         /* Free Rx DMA memory */
524         et131x_adapter_memory_free(adapter);
525
526         /* Set the config parameter for Jumbo Packet support */
527         adapter->RegistryJumboPacket = new_mtu + 14;
528         et131x_soft_reset(adapter);
529
530         /* Alloc and init Rx DMA memory */
531         result = et131x_adapter_memory_alloc(adapter);
532         if (result != 0) {
533                 dev_warn(&adapter->pdev->dev,
534                         "Change MTU failed; couldn't re-alloc DMA memory\n");
535                 return result;
536         }
537
538         et131x_init_send(adapter);
539
540         et131x_hwaddr_init(adapter);
541         memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
542
543         /* Init the device with the new settings */
544         et131x_adapter_setup(adapter);
545
546         /* Enable interrupts */
547         if (adapter->Flags & fMP_ADAPTER_INTERRUPT_IN_USE)
548                 et131x_enable_interrupts(adapter);
549
550         /* Restart the Tx and Rx DMA engines */
551         et131x_rx_dma_enable(adapter);
552         et131x_tx_dma_enable(adapter);
553
554         /* Restart the netif queue */
555         netif_wake_queue(netdev);
556         return result;
557 }
558
559 /**
560  * et131x_set_mac_addr - handler to change the MAC address for the device
561  * @netdev: device whose MAC is to be changed
562  * @new_mac: the desired MAC address
563  *
564  * Returns 0 on success, errno on failure (as defined in errno.h)
565  *
566  * IMPLEMENTED BY : blux http://berndlux.de 22.01.2007 21:14
567  */
568 int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
569 {
570         int result = 0;
571         struct et131x_adapter *adapter = netdev_priv(netdev);
572         struct sockaddr *address = new_mac;
573
574         /* begin blux */
575
576         if (adapter == NULL)
577                 return -ENODEV;
578
579         /* Make sure the requested MAC is valid */
580         if (!is_valid_ether_addr(address->sa_data))
581                 return -EINVAL;
582
583         /* Stop the netif queue */
584         netif_stop_queue(netdev);
585
586         /* Stop the Tx and Rx DMA engines */
587         et131x_rx_dma_disable(adapter);
588         et131x_tx_dma_disable(adapter);
589
590         /* Disable device interrupts */
591         et131x_disable_interrupts(adapter);
592         et131x_handle_send_interrupt(adapter);
593         et131x_handle_recv_interrupt(adapter);
594
595         /* Set the new MAC */
596         /* netdev->set_mac_address  = &new_mac; */
597         /* netdev->mtu = new_mtu; */
598
599         memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);
600
601         printk(KERN_INFO "%s: Setting MAC address to %pM\n",
602                         netdev->name, netdev->dev_addr);
603
604         /* Free Rx DMA memory */
605         et131x_adapter_memory_free(adapter);
606
607         /* Set the config parameter for Jumbo Packet support */
608         /* adapter->RegistryJumboPacket = new_mtu + 14; */
609         /* blux: not needet here, we'll change the MAC */
610
611         et131x_soft_reset(adapter);
612
613         /* Alloc and init Rx DMA memory */
614         result = et131x_adapter_memory_alloc(adapter);
615         if (result != 0) {
616                 dev_err(&adapter->pdev->dev,
617                         "Change MAC failed; couldn't re-alloc DMA memory\n");
618                 return result;
619         }
620
621         et131x_init_send(adapter);
622
623         et131x_hwaddr_init(adapter);
624
625         /* Init the device with the new settings */
626         et131x_adapter_setup(adapter);
627
628         /* Enable interrupts */
629         if (adapter->Flags & fMP_ADAPTER_INTERRUPT_IN_USE)
630                 et131x_enable_interrupts(adapter);
631
632         /* Restart the Tx and Rx DMA engines */
633         et131x_rx_dma_enable(adapter);
634         et131x_tx_dma_enable(adapter);
635
636         /* Restart the netif queue */
637         netif_wake_queue(netdev);
638         return result;
639 }
640
641 static const struct net_device_ops et131x_netdev_ops = {
642         .ndo_open               = et131x_open,
643         .ndo_stop               = et131x_close,
644         .ndo_start_xmit         = et131x_tx,
645         .ndo_set_multicast_list = et131x_multicast,
646         .ndo_tx_timeout         = et131x_tx_timeout,
647         .ndo_change_mtu         = et131x_change_mtu,
648         .ndo_set_mac_address    = et131x_set_mac_addr,
649         .ndo_validate_addr      = eth_validate_addr,
650         .ndo_get_stats          = et131x_stats,
651         .ndo_do_ioctl           = et131x_ioctl,
652 };
653
654 /**
655  * et131x_device_alloc
656  *
657  * Returns pointer to the allocated and initialized net_device struct for
658  * this device.
659  *
660  * Create instances of net_device and wl_private for the new adapter and
661  * register the device's entry points in the net_device structure.
662  */
663 struct net_device *et131x_device_alloc(void)
664 {
665         struct net_device *netdev;
666
667         /* Alloc net_device and adapter structs */
668         netdev = alloc_etherdev(sizeof(struct et131x_adapter));
669
670         if (netdev == NULL) {
671                 printk(KERN_ERR "et131x: Alloc of net_device struct failed\n");
672                 return NULL;
673         }
674
675         /* Setup the function registration table (and other data) for a
676          * net_device
677          */
678         /* netdev->init               = &et131x_init; */
679         /* netdev->set_config = &et131x_config; */
680         netdev->watchdog_timeo = ET131X_TX_TIMEOUT;
681         netdev->netdev_ops = &et131x_netdev_ops;
682
683         /* netdev->ethtool_ops        = &et131x_ethtool_ops; */
684
685         /* Poll? */
686         /* netdev->poll               = &et131x_poll; */
687         /* netdev->poll_controller    = &et131x_poll_controller; */
688         return netdev;
689 }
690