]> Pileus Git - ~andy/linux/blob - drivers/staging/et131x/et131x_netdev.c
staging: et131x: Update tx trans_start on device close to prevent tx_timeout
[~andy/linux] / 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 /**
92  * et131x_stats - Return the current device statistics.
93  * @netdev: device whose stats are being queried
94  *
95  * Returns 0 on success, errno on failure (as defined in errno.h)
96  */
97 static struct net_device_stats *et131x_stats(struct net_device *netdev)
98 {
99         struct et131x_adapter *adapter = netdev_priv(netdev);
100         struct net_device_stats *stats = &adapter->net_stats;
101         struct ce_stats *devstat = &adapter->stats;
102
103         stats->rx_errors = devstat->rx_length_errs +
104                            devstat->rx_align_errs +
105                            devstat->rx_crc_errs +
106                            devstat->rx_code_violations +
107                            devstat->rx_other_errs;
108         stats->tx_errors = devstat->tx_max_pkt_errs;
109         stats->multicast = devstat->multicast_pkts_rcvd;
110         stats->collisions = devstat->tx_collisions;
111
112         stats->rx_length_errors = devstat->rx_length_errs;
113         stats->rx_over_errors = devstat->rx_overflows;
114         stats->rx_crc_errors = devstat->rx_crc_errs;
115
116         /* NOTE: These stats don't have corresponding values in CE_STATS,
117          * so we're going to have to update these directly from within the
118          * TX/RX code
119          */
120         /* stats->rx_bytes            = 20; devstat->; */
121         /* stats->tx_bytes            = 20;  devstat->; */
122         /* stats->rx_dropped          = devstat->; */
123         /* stats->tx_dropped          = devstat->; */
124
125         /*  NOTE: Not used, can't find analogous statistics */
126         /* stats->rx_frame_errors     = devstat->; */
127         /* stats->rx_fifo_errors      = devstat->; */
128         /* stats->rx_missed_errors    = devstat->; */
129
130         /* stats->tx_aborted_errors   = devstat->; */
131         /* stats->tx_carrier_errors   = devstat->; */
132         /* stats->tx_fifo_errors      = devstat->; */
133         /* stats->tx_heartbeat_errors = devstat->; */
134         /* stats->tx_window_errors    = devstat->; */
135         return stats;
136 }
137
138 /**
139  * et131x_open - Open the device for use.
140  * @netdev: device to be opened
141  *
142  * Returns 0 on success, errno on failure (as defined in errno.h)
143  */
144 int et131x_open(struct net_device *netdev)
145 {
146         int result = 0;
147         struct et131x_adapter *adapter = netdev_priv(netdev);
148
149         /* Start the timer to track NIC errors */
150         add_timer(&adapter->error_timer);
151
152         /* Register our IRQ */
153         result = request_irq(netdev->irq, et131x_isr, IRQF_SHARED,
154                                         netdev->name, netdev);
155         if (result) {
156                 dev_err(&adapter->pdev->dev, "could not register IRQ %d\n",
157                         netdev->irq);
158                 return result;
159         }
160
161         /* Enable the Tx and Rx DMA engines (if not already enabled) */
162         et131x_rx_dma_enable(adapter);
163         et131x_tx_dma_enable(adapter);
164
165         /* Enable device interrupts */
166         et131x_enable_interrupts(adapter);
167
168         adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE;
169
170         /* We're ready to move some data, so start the queue */
171         netif_start_queue(netdev);
172         return result;
173 }
174
175 /**
176  * et131x_close - Close the device
177  * @netdev: device to be closed
178  *
179  * Returns 0 on success, errno on failure (as defined in errno.h)
180  */
181 int et131x_close(struct net_device *netdev)
182 {
183         struct et131x_adapter *adapter = netdev_priv(netdev);
184
185         /* Save the timestamp for the TX watchdog, prevent a timeout */
186         netdev->trans_start = jiffies;
187
188         /* First thing is to stop the queue */
189         netif_stop_queue(netdev);
190
191         /* Stop the Tx and Rx DMA engines */
192         et131x_rx_dma_disable(adapter);
193         et131x_tx_dma_disable(adapter);
194
195         /* Disable device interrupts */
196         et131x_disable_interrupts(adapter);
197
198         /* Deregistering ISR */
199         adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE;
200         free_irq(netdev->irq, netdev);
201
202         /* Stop the error timer */
203         del_timer_sync(&adapter->error_timer);
204         return 0;
205 }
206
207 /**
208  * et131x_ioctl_mii - The function which handles MII IOCTLs
209  * @netdev: device on which the query is being made
210  * @reqbuf: the request-specific data buffer
211  * @cmd: the command request code
212  *
213  * Returns 0 on success, errno on failure (as defined in errno.h)
214  */
215 int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
216 {
217         int status = 0;
218         struct et131x_adapter *adapter = netdev_priv(netdev);
219         struct mii_ioctl_data *data = if_mii(reqbuf);
220
221         switch (cmd) {
222         case SIOCGMIIPHY:
223                 data->phy_id = adapter->stats.xcvr_addr;
224                 break;
225
226         case SIOCGMIIREG:
227                 if (!capable(CAP_NET_ADMIN))
228                         status = -EPERM;
229                 else
230                         status = et131x_mii_read(adapter,
231                                         data->reg_num, &data->val_out);
232                 break;
233
234         case SIOCSMIIREG:
235                 if (!capable(CAP_NET_ADMIN))
236                         status = -EPERM;
237                 else
238                         status = et131x_mii_write(adapter, data->reg_num,
239                                          data->val_in);
240                 break;
241
242         default:
243                 status = -EOPNOTSUPP;
244         }
245         return status;
246 }
247
248 /**
249  * et131x_ioctl - The I/O Control handler for the driver
250  * @netdev: device on which the control request is being made
251  * @reqbuf: a pointer to the IOCTL request buffer
252  * @cmd: the IOCTL command code
253  *
254  * Returns 0 on success, errno on failure (as defined in errno.h)
255  */
256 int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
257 {
258         int status = 0;
259
260         switch (cmd) {
261         case SIOCGMIIPHY:
262         case SIOCGMIIREG:
263         case SIOCSMIIREG:
264                 status = et131x_ioctl_mii(netdev, reqbuf, cmd);
265                 break;
266
267         default:
268                 status = -EOPNOTSUPP;
269         }
270         return status;
271 }
272
273 /**
274  * et131x_set_packet_filter - Configures the Rx Packet filtering on the device
275  * @adapter: pointer to our private adapter structure
276  *
277  * FIXME: lot of dups with MAC code
278  *
279  * Returns 0 on success, errno on failure
280  */
281 int et131x_set_packet_filter(struct et131x_adapter *adapter)
282 {
283         int status = 0;
284         uint32_t filter = adapter->packet_filter;
285         u32 ctrl;
286         u32 pf_ctrl;
287
288         ctrl = readl(&adapter->regs->rxmac.ctrl);
289         pf_ctrl = readl(&adapter->regs->rxmac.pf_ctrl);
290
291         /* Default to disabled packet filtering.  Enable it in the individual
292          * case statements that require the device to filter something
293          */
294         ctrl |= 0x04;
295
296         /* Set us to be in promiscuous mode so we receive everything, this
297          * is also true when we get a packet filter of 0
298          */
299         if ((filter & ET131X_PACKET_TYPE_PROMISCUOUS) || filter == 0)
300                 pf_ctrl &= ~7;  /* Clear filter bits */
301         else {
302                 /*
303                  * Set us up with Multicast packet filtering.  Three cases are
304                  * possible - (1) we have a multi-cast list, (2) we receive ALL
305                  * multicast entries or (3) we receive none.
306                  */
307                 if (filter & ET131X_PACKET_TYPE_ALL_MULTICAST)
308                         pf_ctrl &= ~2;  /* Multicast filter bit */
309                 else {
310                         et1310_setup_device_for_multicast(adapter);
311                         pf_ctrl |= 2;
312                         ctrl &= ~0x04;
313                 }
314
315                 /* Set us up with Unicast packet filtering */
316                 if (filter & ET131X_PACKET_TYPE_DIRECTED) {
317                         et1310_setup_device_for_unicast(adapter);
318                         pf_ctrl |= 4;
319                         ctrl &= ~0x04;
320                 }
321
322                 /* Set us up with Broadcast packet filtering */
323                 if (filter & ET131X_PACKET_TYPE_BROADCAST) {
324                         pf_ctrl |= 1;   /* Broadcast filter bit */
325                         ctrl &= ~0x04;
326                 } else
327                         pf_ctrl &= ~1;
328
329                 /* Setup the receive mac configuration registers - Packet
330                  * Filter control + the enable / disable for packet filter
331                  * in the control reg.
332                  */
333                 writel(pf_ctrl, &adapter->regs->rxmac.pf_ctrl);
334                 writel(ctrl, &adapter->regs->rxmac.ctrl);
335         }
336         return status;
337 }
338
339 /**
340  * et131x_multicast - The handler to configure multicasting on the interface
341  * @netdev: a pointer to a net_device struct representing the device
342  */
343 void et131x_multicast(struct net_device *netdev)
344 {
345         struct et131x_adapter *adapter = netdev_priv(netdev);
346         uint32_t packet_filter = 0;
347         unsigned long flags;
348         struct netdev_hw_addr *ha;
349         int i;
350
351         spin_lock_irqsave(&adapter->lock, flags);
352
353         /* Before we modify the platform-independent filter flags, store them
354          * locally. This allows us to determine if anything's changed and if
355          * we even need to bother the hardware
356          */
357         packet_filter = adapter->packet_filter;
358
359         /* Clear the 'multicast' flag locally; because we only have a single
360          * flag to check multicast, and multiple multicast addresses can be
361          * set, this is the easiest way to determine if more than one
362          * multicast address is being set.
363          */
364         packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST;
365
366         /* Check the net_device flags and set the device independent flags
367          * accordingly
368          */
369
370         if (netdev->flags & IFF_PROMISC)
371                 adapter->packet_filter |= ET131X_PACKET_TYPE_PROMISCUOUS;
372         else
373                 adapter->packet_filter &= ~ET131X_PACKET_TYPE_PROMISCUOUS;
374
375         if (netdev->flags & IFF_ALLMULTI)
376                 adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
377
378         if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST)
379                 adapter->packet_filter |= ET131X_PACKET_TYPE_ALL_MULTICAST;
380
381         if (netdev_mc_count(netdev) < 1) {
382                 adapter->packet_filter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST;
383                 adapter->packet_filter &= ~ET131X_PACKET_TYPE_MULTICAST;
384         } else
385                 adapter->packet_filter |= ET131X_PACKET_TYPE_MULTICAST;
386
387         /* Set values in the private adapter struct */
388         i = 0;
389         netdev_for_each_mc_addr(ha, netdev) {
390                 if (i == NIC_MAX_MCAST_LIST)
391                         break;
392                 memcpy(adapter->multicast_list[i++], ha->addr, ETH_ALEN);
393         }
394         adapter->multicast_addr_count = i;
395
396         /* Are the new flags different from the previous ones? If not, then no
397          * action is required
398          *
399          * NOTE - This block will always update the multicast_list with the
400          *        hardware, even if the addresses aren't the same.
401          */
402         if (packet_filter != adapter->packet_filter) {
403                 /* Call the device's filter function */
404                 et131x_set_packet_filter(adapter);
405         }
406         spin_unlock_irqrestore(&adapter->lock, flags);
407 }
408
409 /**
410  * et131x_tx - The handler to tx a packet on the device
411  * @skb: data to be Tx'd
412  * @netdev: device on which data is to be Tx'd
413  *
414  * Returns 0 on success, errno on failure (as defined in errno.h)
415  */
416 int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
417 {
418         int status = 0;
419
420         /* Save the timestamp for the TX timeout watchdog */
421         netdev->trans_start = jiffies;
422
423         /* Call the device-specific data Tx routine */
424         status = et131x_send_packets(skb, netdev);
425
426         /* Check status and manage the netif queue if necessary */
427         if (status != 0) {
428                 if (status == -ENOMEM) {
429                         /* Put the queue to sleep until resources are
430                          * available
431                          */
432                         netif_stop_queue(netdev);
433                         status = NETDEV_TX_BUSY;
434                 } else {
435                         status = NETDEV_TX_OK;
436                 }
437         }
438         return status;
439 }
440
441 /**
442  * et131x_tx_timeout - Timeout handler
443  * @netdev: a pointer to a net_device struct representing the device
444  *
445  * The handler called when a Tx request times out. The timeout period is
446  * specified by the 'tx_timeo" element in the net_device structure (see
447  * et131x_alloc_device() to see how this value is set).
448  */
449 void et131x_tx_timeout(struct net_device *netdev)
450 {
451         struct et131x_adapter *adapter = netdev_priv(netdev);
452         struct tcb *tcb;
453         unsigned long flags;
454
455         /* If the device is closed, ignore the timeout */
456         if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE));
457                 return;
458
459         /* Any nonrecoverable hardware error?
460          * Checks adapter->flags for any failure in phy reading
461          */
462         if (adapter->flags & fMP_ADAPTER_NON_RECOVER_ERROR)
463                 return;
464
465         /* Hardware failure? */
466         if (adapter->flags & fMP_ADAPTER_HARDWARE_ERROR) {
467                 dev_err(&adapter->pdev->dev, "hardware error - reset\n");
468                 return;
469         }
470
471         /* Is send stuck? */
472         spin_lock_irqsave(&adapter->tcb_send_qlock, flags);
473
474         tcb = adapter->tx_ring.send_head;
475
476         if (tcb != NULL) {
477                 tcb->count++;
478
479                 if (tcb->count > NIC_SEND_HANG_THRESHOLD) {
480                         spin_unlock_irqrestore(&adapter->tcb_send_qlock,
481                                                flags);
482
483                         dev_warn(&adapter->pdev->dev,
484                                 "Send stuck - reset.  tcb->WrIndex %x, flags 0x%08x\n",
485                                 tcb->index,
486                                 tcb->flags);
487
488                         adapter->net_stats.tx_errors++;
489
490                         /* perform reset */
491                         /* First thing is to stop the queue */
492                         netif_stop_queue(netdev);
493
494                         /* Stop the Tx and Rx DMA engines */
495                         et131x_rx_dma_disable(adapter);
496                         et131x_tx_dma_disable(adapter);
497
498                         /* Disable device interrupts */
499                         et131x_disable_interrupts(adapter);
500
501                         /* Enable the Tx and Rx DMA engines (if not already enabled) */
502                         et131x_rx_dma_enable(adapter);
503                         et131x_tx_dma_enable(adapter);
504
505                         /* Enable device interrupts */
506                         et131x_enable_interrupts(adapter);
507
508                         /* We're ready to move some data, so start the queue */
509                         netif_start_queue(netdev);
510                         return;
511                 }
512         }
513
514         spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags);
515 }
516
517 /**
518  * et131x_change_mtu - The handler called to change the MTU for the device
519  * @netdev: device whose MTU is to be changed
520  * @new_mtu: the desired MTU
521  *
522  * Returns 0 on success, errno on failure (as defined in errno.h)
523  */
524 int et131x_change_mtu(struct net_device *netdev, int new_mtu)
525 {
526         int result = 0;
527         struct et131x_adapter *adapter = netdev_priv(netdev);
528
529         /* Make sure the requested MTU is valid */
530         if (new_mtu < 64 || new_mtu > 9216)
531                 return -EINVAL;
532
533         /* Stop the netif queue */
534         netif_stop_queue(netdev);
535
536         /* Stop the Tx and Rx DMA engines */
537         et131x_rx_dma_disable(adapter);
538         et131x_tx_dma_disable(adapter);
539
540         /* Disable device interrupts */
541         et131x_disable_interrupts(adapter);
542         et131x_handle_send_interrupt(adapter);
543         et131x_handle_recv_interrupt(adapter);
544
545         /* Set the new MTU */
546         netdev->mtu = new_mtu;
547
548         /* Free Rx DMA memory */
549         et131x_adapter_memory_free(adapter);
550
551         /* Set the config parameter for Jumbo Packet support */
552         adapter->registry_jumbo_packet = new_mtu + 14;
553         et131x_soft_reset(adapter);
554
555         /* Alloc and init Rx DMA memory */
556         result = et131x_adapter_memory_alloc(adapter);
557         if (result != 0) {
558                 dev_warn(&adapter->pdev->dev,
559                         "Change MTU failed; couldn't re-alloc DMA memory\n");
560                 return result;
561         }
562
563         et131x_init_send(adapter);
564
565         et131x_hwaddr_init(adapter);
566         memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
567
568         /* Init the device with the new settings */
569         et131x_adapter_setup(adapter);
570
571         /* Enable interrupts */
572         if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)
573                 et131x_enable_interrupts(adapter);
574
575         /* Restart the Tx and Rx DMA engines */
576         et131x_rx_dma_enable(adapter);
577         et131x_tx_dma_enable(adapter);
578
579         /* Restart the netif queue */
580         netif_wake_queue(netdev);
581         return result;
582 }
583
584 /**
585  * et131x_set_mac_addr - handler to change the MAC address for the device
586  * @netdev: device whose MAC is to be changed
587  * @new_mac: the desired MAC address
588  *
589  * Returns 0 on success, errno on failure (as defined in errno.h)
590  *
591  * IMPLEMENTED BY : blux http://berndlux.de 22.01.2007 21:14
592  */
593 int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
594 {
595         int result = 0;
596         struct et131x_adapter *adapter = netdev_priv(netdev);
597         struct sockaddr *address = new_mac;
598
599         /* begin blux */
600
601         if (adapter == NULL)
602                 return -ENODEV;
603
604         /* Make sure the requested MAC is valid */
605         if (!is_valid_ether_addr(address->sa_data))
606                 return -EINVAL;
607
608         /* Stop the netif queue */
609         netif_stop_queue(netdev);
610
611         /* Stop the Tx and Rx DMA engines */
612         et131x_rx_dma_disable(adapter);
613         et131x_tx_dma_disable(adapter);
614
615         /* Disable device interrupts */
616         et131x_disable_interrupts(adapter);
617         et131x_handle_send_interrupt(adapter);
618         et131x_handle_recv_interrupt(adapter);
619
620         /* Set the new MAC */
621         /* netdev->set_mac_address  = &new_mac; */
622
623         memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);
624
625         printk(KERN_INFO "%s: Setting MAC address to %pM\n",
626                         netdev->name, netdev->dev_addr);
627
628         /* Free Rx DMA memory */
629         et131x_adapter_memory_free(adapter);
630
631         et131x_soft_reset(adapter);
632
633         /* Alloc and init Rx DMA memory */
634         result = et131x_adapter_memory_alloc(adapter);
635         if (result != 0) {
636                 dev_err(&adapter->pdev->dev,
637                         "Change MAC failed; couldn't re-alloc DMA memory\n");
638                 return result;
639         }
640
641         et131x_init_send(adapter);
642
643         et131x_hwaddr_init(adapter);
644
645         /* Init the device with the new settings */
646         et131x_adapter_setup(adapter);
647
648         /* Enable interrupts */
649         if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)
650                 et131x_enable_interrupts(adapter);
651
652         /* Restart the Tx and Rx DMA engines */
653         et131x_rx_dma_enable(adapter);
654         et131x_tx_dma_enable(adapter);
655
656         /* Restart the netif queue */
657         netif_wake_queue(netdev);
658         return result;
659 }
660
661 static const struct net_device_ops et131x_netdev_ops = {
662         .ndo_open               = et131x_open,
663         .ndo_stop               = et131x_close,
664         .ndo_start_xmit         = et131x_tx,
665         .ndo_set_multicast_list = et131x_multicast,
666         .ndo_tx_timeout         = et131x_tx_timeout,
667         .ndo_change_mtu         = et131x_change_mtu,
668         .ndo_set_mac_address    = et131x_set_mac_addr,
669         .ndo_validate_addr      = eth_validate_addr,
670         .ndo_get_stats          = et131x_stats,
671         .ndo_do_ioctl           = et131x_ioctl,
672 };
673
674 /**
675  * et131x_device_alloc
676  *
677  * Returns pointer to the allocated and initialized net_device struct for
678  * this device.
679  *
680  * Create instances of net_device and wl_private for the new adapter and
681  * register the device's entry points in the net_device structure.
682  */
683 struct net_device *et131x_device_alloc(void)
684 {
685         struct net_device *netdev;
686
687         /* Alloc net_device and adapter structs */
688         netdev = alloc_etherdev(sizeof(struct et131x_adapter));
689
690         if (netdev == NULL) {
691                 printk(KERN_ERR "et131x: Alloc of net_device struct failed\n");
692                 return NULL;
693         }
694
695         /*
696          * Setup the function registration table (and other data) for a
697          * net_device
698          */
699         netdev->watchdog_timeo = ET131X_TX_TIMEOUT;
700         netdev->netdev_ops     = &et131x_netdev_ops;
701
702         /* netdev->ethtool_ops        = &et131x_ethtool_ops; */
703
704         /* Poll? */
705         /* netdev->poll               = &et131x_poll; */
706         /* netdev->poll_controller    = &et131x_poll_controller; */
707         return netdev;
708 }
709