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