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