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