1feca14c965c0cbb7f6f6dbe034c2dd7ccdf8dbb
[openwrt.git] / target / linux / atheros / files / drivers / net / ar2313 / ar2313.c
1 /*
2 * ar2313.c: Linux driver for the Atheros AR231x Ethernet device.
3 *
4 * Copyright (C) 2004 by Sameer Dekate <sdekate@arubanetworks.com>
5 * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
6 * Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
7 *
8 * Thanks to Atheros for providing hardware and documentation
9 * enabling me to write this driver.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * Additional credits:
17 * This code is taken from John Taylor's Sibyte driver and then
18 * modified for the AR2313.
19 */
20
21 #include <linux/autoconf.h>
22 #include <linux/module.h>
23 #include <linux/version.h>
24 #include <linux/types.h>
25 #include <linux/errno.h>
26 #include <linux/ioport.h>
27 #include <linux/pci.h>
28 #include <linux/netdevice.h>
29 #include <linux/etherdevice.h>
30 #include <linux/skbuff.h>
31 #include <linux/init.h>
32 #include <linux/delay.h>
33 #include <linux/mm.h>
34 #include <linux/highmem.h>
35 #include <linux/sockios.h>
36 #include <linux/pkt_sched.h>
37 #include <linux/compile.h>
38 #include <linux/mii.h>
39 #include <linux/phy.h>
40 #include <linux/ethtool.h>
41 #include <linux/ctype.h>
42 #include <linux/platform_device.h>
43
44 #include <net/sock.h>
45 #include <net/ip.h>
46
47 #include <asm/system.h>
48 #include <asm/io.h>
49 #include <asm/irq.h>
50 #include <asm/byteorder.h>
51 #include <asm/uaccess.h>
52 #include <asm/bootinfo.h>
53
54 #define AR2313_MTU 1692
55 #define AR2313_PRIOS 1
56 #define AR2313_QUEUES (2*AR2313_PRIOS)
57 #define AR2313_DESCR_ENTRIES 64
58
59 #undef INDEX_DEBUG
60 #define DEBUG 0
61 #define DEBUG_TX 0
62 #define DEBUG_RX 0
63 #define DEBUG_INT 0
64 #define DEBUG_MC 0
65 #define DEBUG_ERR 1
66
67 #ifndef min
68 #define min(a,b) (((a)<(b))?(a):(b))
69 #endif
70
71 #ifndef SMP_CACHE_BYTES
72 #define SMP_CACHE_BYTES L1_CACHE_BYTES
73 #endif
74
75 #define AR2313_MBOX_SET_BIT 0x8
76
77 #define BOARD_IDX_STATIC 0
78 #define BOARD_IDX_OVERFLOW -1
79
80 #include "dma.h"
81 #include "ar2313.h"
82
83 /*
84 * New interrupt handler strategy:
85 *
86 * An old interrupt handler worked using the traditional method of
87 * replacing an skbuff with a new one when a packet arrives. However
88 * the rx rings do not need to contain a static number of buffer
89 * descriptors, thus it makes sense to move the memory allocation out
90 * of the main interrupt handler and do it in a bottom half handler
91 * and only allocate new buffers when the number of buffers in the
92 * ring is below a certain threshold. In order to avoid starving the
93 * NIC under heavy load it is however necessary to force allocation
94 * when hitting a minimum threshold. The strategy for alloction is as
95 * follows:
96 *
97 * RX_LOW_BUF_THRES - allocate buffers in the bottom half
98 * RX_PANIC_LOW_THRES - we are very low on buffers, allocate
99 * the buffers in the interrupt handler
100 * RX_RING_THRES - maximum number of buffers in the rx ring
101 *
102 * One advantagous side effect of this allocation approach is that the
103 * entire rx processing can be done without holding any spin lock
104 * since the rx rings and registers are totally independent of the tx
105 * ring and its registers. This of course includes the kmalloc's of
106 * new skb's. Thus start_xmit can run in parallel with rx processing
107 * and the memory allocation on SMP systems.
108 *
109 * Note that running the skb reallocation in a bottom half opens up
110 * another can of races which needs to be handled properly. In
111 * particular it can happen that the interrupt handler tries to run
112 * the reallocation while the bottom half is either running on another
113 * CPU or was interrupted on the same CPU. To get around this the
114 * driver uses bitops to prevent the reallocation routines from being
115 * reentered.
116 *
117 * TX handling can also be done without holding any spin lock, wheee
118 * this is fun! since tx_csm is only written to by the interrupt
119 * handler.
120 */
121
122 /*
123 * Threshold values for RX buffer allocation - the low water marks for
124 * when to start refilling the rings are set to 75% of the ring
125 * sizes. It seems to make sense to refill the rings entirely from the
126 * intrrupt handler once it gets below the panic threshold, that way
127 * we don't risk that the refilling is moved to another CPU when the
128 * one running the interrupt handler just got the slab code hot in its
129 * cache.
130 */
131 #define RX_RING_SIZE AR2313_DESCR_ENTRIES
132 #define RX_PANIC_THRES (RX_RING_SIZE/4)
133 #define RX_LOW_THRES ((3*RX_RING_SIZE)/4)
134 #define CRC_LEN 4
135 #define RX_OFFSET 2
136
137 #define AR2313_BUFSIZE (AR2313_MTU + ETH_HLEN + CRC_LEN + RX_OFFSET)
138
139 #ifdef MODULE
140 MODULE_LICENSE("GPL");
141 MODULE_AUTHOR("Sameer Dekate <sdekate@arubanetworks.com>, Imre Kaloz <kaloz@openwrt.org>, Felix Fietkau <nbd@openwrt.org>");
142 MODULE_DESCRIPTION("AR2313 Ethernet driver");
143 #endif
144
145 #define virt_to_phys(x) ((u32)(x) & 0x1fffffff)
146
147 // prototypes
148 #ifdef TX_TIMEOUT
149 static void ar2313_tx_timeout(struct net_device *dev);
150 #endif
151 static void ar2313_halt(struct net_device *dev);
152 static void rx_tasklet_func(unsigned long data);
153 static void rx_tasklet_cleanup(struct net_device *dev);
154 static void ar2313_multicast_list(struct net_device *dev);
155
156 static int mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum);
157 static int mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value);
158 static int mdiobus_reset(struct mii_bus *bus);
159 static int mdiobus_probe (struct net_device *dev);
160 static void ar2313_adjust_link(struct net_device *dev);
161
162 #ifndef ERR
163 #define ERR(fmt, args...) printk("%s: " fmt, __func__, ##args)
164 #endif
165
166
167 int __init ar2313_probe(struct platform_device *pdev)
168 {
169 struct net_device *dev;
170 struct ar2313_private *sp;
171 struct resource *res;
172 unsigned long ar_eth_base;
173 char buf[64];
174
175 dev = alloc_etherdev(sizeof(struct ar2313_private));
176
177 if (dev == NULL) {
178 printk(KERN_ERR
179 "ar2313: Unable to allocate net_device structure!\n");
180 return -ENOMEM;
181 }
182
183 SET_MODULE_OWNER(dev);
184 platform_set_drvdata(pdev, dev);
185
186 sp = dev->priv;
187 sp->dev = dev;
188 sp->cfg = pdev->dev.platform_data;
189
190 sprintf(buf, "eth%d_membase", pdev->id);
191 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, buf);
192 if (!res)
193 return -ENODEV;
194
195 sp->link = 0;
196 ar_eth_base = res->start;
197 sp->phy = sp->cfg->phy;
198
199 sprintf(buf, "eth%d_irq", pdev->id);
200 dev->irq = platform_get_irq_byname(pdev, buf);
201
202 spin_lock_init(&sp->lock);
203
204 /* initialize func pointers */
205 dev->open = &ar2313_open;
206 dev->stop = &ar2313_close;
207 dev->hard_start_xmit = &ar2313_start_xmit;
208
209 dev->get_stats = &ar2313_get_stats;
210 dev->set_multicast_list = &ar2313_multicast_list;
211 #ifdef TX_TIMEOUT
212 dev->tx_timeout = ar2313_tx_timeout;
213 dev->watchdog_timeo = AR2313_TX_TIMEOUT;
214 #endif
215 dev->do_ioctl = &ar2313_ioctl;
216
217 // SAMEER: do we need this?
218 dev->features |= NETIF_F_SG | NETIF_F_HIGHDMA;
219
220 tasklet_init(&sp->rx_tasklet, rx_tasklet_func, (unsigned long) dev);
221 tasklet_disable(&sp->rx_tasklet);
222
223 sp->eth_regs =
224 ioremap_nocache(virt_to_phys(ar_eth_base), sizeof(*sp->eth_regs));
225 if (!sp->eth_regs) {
226 printk("Can't remap eth registers\n");
227 return (-ENXIO);
228 }
229
230 /*
231 * When there's only one MAC, PHY regs are typically on ENET0,
232 * even though the MAC might be on ENET1.
233 * Needto remap PHY regs separately in this case
234 */
235 if (virt_to_phys(ar_eth_base) == virt_to_phys(sp->phy_regs))
236 sp->phy_regs = sp->eth_regs;
237 else {
238 sp->phy_regs =
239 ioremap_nocache(virt_to_phys(sp->cfg->phy_base),
240 sizeof(*sp->phy_regs));
241 if (!sp->phy_regs) {
242 printk("Can't remap phy registers\n");
243 return (-ENXIO);
244 }
245 }
246
247 sp->dma_regs =
248 ioremap_nocache(virt_to_phys(ar_eth_base + 0x1000),
249 sizeof(*sp->dma_regs));
250 dev->base_addr = (unsigned int) sp->dma_regs;
251 if (!sp->dma_regs) {
252 printk("Can't remap DMA registers\n");
253 return (-ENXIO);
254 }
255
256 sp->int_regs = ioremap_nocache(virt_to_phys(sp->cfg->reset_base), 4);
257 if (!sp->int_regs) {
258 printk("Can't remap INTERRUPT registers\n");
259 return (-ENXIO);
260 }
261
262 strncpy(sp->name, "Atheros AR231x", sizeof(sp->name) - 1);
263 sp->name[sizeof(sp->name) - 1] = '\0';
264 memcpy(dev->dev_addr, sp->cfg->macaddr, 6);
265 sp->board_idx = BOARD_IDX_STATIC;
266
267 if (ar2313_init(dev)) {
268 /*
269 * ar2313_init() calls ar2313_init_cleanup() on error.
270 */
271 kfree(dev);
272 return -ENODEV;
273 }
274
275 if (register_netdev(dev)) {
276 printk("%s: register_netdev failed\n", __func__);
277 return -1;
278 }
279
280 printk("%s: %s: %02x:%02x:%02x:%02x:%02x:%02x, irq %d\n",
281 dev->name, sp->name,
282 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
283 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5], dev->irq);
284
285 sp->mii_bus.priv = dev;
286 sp->mii_bus.read = mdiobus_read;
287 sp->mii_bus.write = mdiobus_write;
288 sp->mii_bus.reset = mdiobus_reset;
289 sp->mii_bus.name = "ar2313_eth_mii";
290 sp->mii_bus.id = 0;
291 sp->mii_bus.irq = kmalloc(sizeof(int), GFP_KERNEL);
292 *sp->mii_bus.irq = PHY_POLL;
293
294 mdiobus_register(&sp->mii_bus);
295
296 if (mdiobus_probe(dev) != 0) {
297 printk(KERN_ERR "ar2313: mdiobus_probe failed");
298 rx_tasklet_cleanup(dev);
299 ar2313_init_cleanup(dev);
300 unregister_netdev(dev);
301 kfree(dev);
302 } else {
303 /* start link poll timer */
304 ar2313_setup_timer(dev);
305 }
306
307 return 0;
308 }
309
310 #if 0
311 static void ar2313_dump_regs(struct net_device *dev)
312 {
313 unsigned int *ptr, i;
314 struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
315
316 ptr = (unsigned int *) sp->eth_regs;
317 for (i = 0; i < (sizeof(ETHERNET_STRUCT) / sizeof(unsigned int));
318 i++, ptr++) {
319 printk("ENET: %08x = %08x\n", (int) ptr, *ptr);
320 }
321
322 ptr = (unsigned int *) sp->dma_regs;
323 for (i = 0; i < (sizeof(DMA) / sizeof(unsigned int)); i++, ptr++) {
324 printk("DMA: %08x = %08x\n", (int) ptr, *ptr);
325 }
326
327 ptr = (unsigned int *) sp->int_regs;
328 for (i = 0; i < (sizeof(INTERRUPT) / sizeof(unsigned int)); i++, ptr++) {
329 printk("INT: %08x = %08x\n", (int) ptr, *ptr);
330 }
331
332 for (i = 0; i < AR2313_DESCR_ENTRIES; i++) {
333 ar2313_descr_t *td = &sp->tx_ring[i];
334 printk("Tx desc %2d: %08x %08x %08x %08x\n", i,
335 td->status, td->devcs, td->addr, td->descr);
336 }
337 }
338 #endif
339
340 #ifdef TX_TIMEOUT
341 static void ar2313_tx_timeout(struct net_device *dev)
342 {
343 struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
344 unsigned long flags;
345
346 #if DEBUG_TX
347 printk("Tx timeout\n");
348 #endif
349 spin_lock_irqsave(&sp->lock, flags);
350 ar2313_restart(dev);
351 spin_unlock_irqrestore(&sp->lock, flags);
352 }
353 #endif
354
355 #if DEBUG_MC
356 static void printMcList(struct net_device *dev)
357 {
358 struct dev_mc_list *list = dev->mc_list;
359 int num = 0, i;
360 while (list) {
361 printk("%d MC ADDR ", num);
362 for (i = 0; i < list->dmi_addrlen; i++) {
363 printk(":%02x", list->dmi_addr[i]);
364 }
365 list = list->next;
366 printk("\n");
367 }
368 }
369 #endif
370
371 /*
372 * Set or clear the multicast filter for this adaptor.
373 * THIS IS ABSOLUTE CRAP, disabled
374 */
375 static void ar2313_multicast_list(struct net_device *dev)
376 {
377 /*
378 * Always listen to broadcasts and
379 * treat IFF bits independently
380 */
381 struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
382 unsigned int recognise;
383
384 recognise = sp->eth_regs->mac_control;
385
386 if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */
387 recognise |= MAC_CONTROL_PR;
388 } else {
389 recognise &= ~MAC_CONTROL_PR;
390 }
391
392 if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 15)) {
393 #if DEBUG_MC
394 printMcList(dev);
395 printk("%s: all MULTICAST mc_count %d\n", __FUNCTION__,
396 dev->mc_count);
397 #endif
398 recognise |= MAC_CONTROL_PM; /* all multicast */
399 } else if (dev->mc_count > 0) {
400 #if DEBUG_MC
401 printMcList(dev);
402 printk("%s: mc_count %d\n", __FUNCTION__, dev->mc_count);
403 #endif
404 recognise |= MAC_CONTROL_PM; /* for the time being */
405 }
406 #if DEBUG_MC
407 printk("%s: setting %08x to %08x\n", __FUNCTION__, (int) sp->eth_regs,
408 recognise);
409 #endif
410
411 sp->eth_regs->mac_control = recognise;
412 }
413
414 static void rx_tasklet_cleanup(struct net_device *dev)
415 {
416 struct ar2313_private *sp = dev->priv;
417
418 /*
419 * Tasklet may be scheduled. Need to get it removed from the list
420 * since we're about to free the struct.
421 */
422
423 sp->unloading = 1;
424 tasklet_enable(&sp->rx_tasklet);
425 tasklet_kill(&sp->rx_tasklet);
426 }
427
428 static int __exit ar2313_remove(struct platform_device *pdev)
429 {
430 struct net_device *dev = platform_get_drvdata(pdev);
431 rx_tasklet_cleanup(dev);
432 ar2313_init_cleanup(dev);
433 unregister_netdev(dev);
434 kfree(dev);
435 return 0;
436 }
437
438
439 /*
440 * Restart the AR2313 ethernet controller.
441 */
442 static int ar2313_restart(struct net_device *dev)
443 {
444 /* disable interrupts */
445 disable_irq(dev->irq);
446
447 /* stop mac */
448 ar2313_halt(dev);
449
450 /* initialize */
451 ar2313_init(dev);
452
453 /* enable interrupts */
454 enable_irq(dev->irq);
455
456 return 0;
457 }
458
459 static struct platform_driver ar2313_driver = {
460 .driver.name = "ar531x-eth",
461 .probe = ar2313_probe,
462 .remove = ar2313_remove,
463 };
464
465 int __init ar2313_module_init(void)
466 {
467 return platform_driver_register(&ar2313_driver);
468 }
469
470 void __exit ar2313_module_cleanup(void)
471 {
472 platform_driver_unregister(&ar2313_driver);
473 }
474
475 module_init(ar2313_module_init);
476 module_exit(ar2313_module_cleanup);
477
478
479 static void ar2313_free_descriptors(struct net_device *dev)
480 {
481 struct ar2313_private *sp = dev->priv;
482 if (sp->rx_ring != NULL) {
483 kfree((void *) KSEG0ADDR(sp->rx_ring));
484 sp->rx_ring = NULL;
485 sp->tx_ring = NULL;
486 }
487 }
488
489
490 static int ar2313_allocate_descriptors(struct net_device *dev)
491 {
492 struct ar2313_private *sp = dev->priv;
493 int size;
494 int j;
495 ar2313_descr_t *space;
496
497 if (sp->rx_ring != NULL) {
498 printk("%s: already done.\n", __FUNCTION__);
499 return 0;
500 }
501
502 size =
503 (sizeof(ar2313_descr_t) * (AR2313_DESCR_ENTRIES * AR2313_QUEUES));
504 space = kmalloc(size, GFP_KERNEL);
505 if (space == NULL)
506 return 1;
507
508 /* invalidate caches */
509 dma_cache_inv((unsigned int) space, size);
510
511 /* now convert pointer to KSEG1 */
512 space = (ar2313_descr_t *) KSEG1ADDR(space);
513
514 memset((void *) space, 0, size);
515
516 sp->rx_ring = space;
517 space += AR2313_DESCR_ENTRIES;
518
519 sp->tx_ring = space;
520 space += AR2313_DESCR_ENTRIES;
521
522 /* Initialize the transmit Descriptors */
523 for (j = 0; j < AR2313_DESCR_ENTRIES; j++) {
524 ar2313_descr_t *td = &sp->tx_ring[j];
525 td->status = 0;
526 td->devcs = DMA_TX1_CHAINED;
527 td->addr = 0;
528 td->descr =
529 virt_to_phys(&sp->
530 tx_ring[(j + 1) & (AR2313_DESCR_ENTRIES - 1)]);
531 }
532
533 return 0;
534 }
535
536
537 /*
538 * Generic cleanup handling data allocated during init. Used when the
539 * module is unloaded or if an error occurs during initialization
540 */
541 static void ar2313_init_cleanup(struct net_device *dev)
542 {
543 struct ar2313_private *sp = dev->priv;
544 struct sk_buff *skb;
545 int j;
546
547 ar2313_free_descriptors(dev);
548
549 if (sp->eth_regs)
550 iounmap((void *) sp->eth_regs);
551 if (sp->dma_regs)
552 iounmap((void *) sp->dma_regs);
553
554 if (sp->rx_skb) {
555 for (j = 0; j < AR2313_DESCR_ENTRIES; j++) {
556 skb = sp->rx_skb[j];
557 if (skb) {
558 sp->rx_skb[j] = NULL;
559 dev_kfree_skb(skb);
560 }
561 }
562 kfree(sp->rx_skb);
563 sp->rx_skb = NULL;
564 }
565
566 if (sp->tx_skb) {
567 for (j = 0; j < AR2313_DESCR_ENTRIES; j++) {
568 skb = sp->tx_skb[j];
569 if (skb) {
570 sp->tx_skb[j] = NULL;
571 dev_kfree_skb(skb);
572 }
573 }
574 kfree(sp->tx_skb);
575 sp->tx_skb = NULL;
576 }
577 }
578
579 static int ar2313_setup_timer(struct net_device *dev)
580 {
581 struct ar2313_private *sp = dev->priv;
582
583 init_timer(&sp->link_timer);
584
585 sp->link_timer.function = ar2313_link_timer_fn;
586 sp->link_timer.data = (int) dev;
587 sp->link_timer.expires = jiffies + HZ;
588
589 add_timer(&sp->link_timer);
590 return 0;
591
592 }
593
594 static void ar2313_link_timer_fn(unsigned long data)
595 {
596 struct net_device *dev = (struct net_device *) data;
597 struct ar2313_private *sp = dev->priv;
598
599 // see if the link status changed
600 // This was needed to make sure we set the PHY to the
601 // autonegotiated value of half or full duplex.
602 ar2313_check_link(dev);
603
604 // Loop faster when we don't have link.
605 // This was needed to speed up the AP bootstrap time.
606 if (sp->link == 0) {
607 mod_timer(&sp->link_timer, jiffies + HZ / 2);
608 } else {
609 mod_timer(&sp->link_timer, jiffies + LINK_TIMER);
610 }
611 }
612
613 static void ar2313_check_link(struct net_device *dev)
614 {
615 struct ar2313_private *sp = dev->priv;
616 u16 phyData;
617
618 phyData = mdiobus_read(&sp->mii_bus, sp->phy, MII_BMSR);
619 if (sp->phyData != phyData) {
620 if (phyData & BMSR_LSTATUS) {
621 /* link is present, ready link partner ability to deterine
622 duplexity */
623 int duplex = 0;
624 u16 reg;
625
626 sp->link = 1;
627 reg = mdiobus_read(&sp->mii_bus, sp->phy, MII_BMCR);
628 if (reg & BMCR_ANENABLE) {
629 /* auto neg enabled */
630 reg = mdiobus_read(&sp->mii_bus, sp->phy, MII_LPA);
631 duplex = (reg & (LPA_100FULL | LPA_10FULL)) ? 1 : 0;
632 } else {
633 /* no auto neg, just read duplex config */
634 duplex = (reg & BMCR_FULLDPLX) ? 1 : 0;
635 }
636
637 printk(KERN_INFO "%s: Configuring MAC for %s duplex\n",
638 dev->name, (duplex) ? "full" : "half");
639
640 if (duplex) {
641 /* full duplex */
642 sp->eth_regs->mac_control =
643 ((sp->eth_regs->
644 mac_control | MAC_CONTROL_F) & ~MAC_CONTROL_DRO);
645 } else {
646 /* half duplex */
647 sp->eth_regs->mac_control =
648 ((sp->eth_regs->
649 mac_control | MAC_CONTROL_DRO) & ~MAC_CONTROL_F);
650 }
651 } else {
652 /* no link */
653 sp->link = 0;
654 }
655 sp->phyData = phyData;
656 }
657 }
658
659 static int ar2313_reset_reg(struct net_device *dev)
660 {
661 struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
662 unsigned int ethsal, ethsah;
663 unsigned int flags;
664
665 *sp->int_regs |= sp->cfg->reset_mac;
666 mdelay(10);
667 *sp->int_regs &= ~sp->cfg->reset_mac;
668 mdelay(10);
669 *sp->int_regs |= sp->cfg->reset_phy;
670 mdelay(10);
671 *sp->int_regs &= ~sp->cfg->reset_phy;
672 mdelay(10);
673
674 sp->dma_regs->bus_mode = (DMA_BUS_MODE_SWR);
675 mdelay(10);
676 sp->dma_regs->bus_mode =
677 ((32 << DMA_BUS_MODE_PBL_SHIFT) | DMA_BUS_MODE_BLE);
678
679 /* enable interrupts */
680 sp->dma_regs->intr_ena = (DMA_STATUS_AIS |
681 DMA_STATUS_NIS |
682 DMA_STATUS_RI |
683 DMA_STATUS_TI | DMA_STATUS_FBE);
684 sp->dma_regs->xmt_base = virt_to_phys(sp->tx_ring);
685 sp->dma_regs->rcv_base = virt_to_phys(sp->rx_ring);
686 sp->dma_regs->control =
687 (DMA_CONTROL_SR | DMA_CONTROL_ST | DMA_CONTROL_SF);
688
689 sp->eth_regs->flow_control = (FLOW_CONTROL_FCE);
690 sp->eth_regs->vlan_tag = (0x8100);
691
692 /* Enable Ethernet Interface */
693 flags = (MAC_CONTROL_TE | /* transmit enable */
694 MAC_CONTROL_PM | /* pass mcast */
695 MAC_CONTROL_F | /* full duplex */
696 MAC_CONTROL_HBD); /* heart beat disabled */
697
698 if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */
699 flags |= MAC_CONTROL_PR;
700 }
701 sp->eth_regs->mac_control = flags;
702
703 /* Set all Ethernet station address registers to their initial values */
704 ethsah = ((((u_int) (dev->dev_addr[5]) << 8) & (u_int) 0x0000FF00) |
705 (((u_int) (dev->dev_addr[4]) << 0) & (u_int) 0x000000FF));
706
707 ethsal = ((((u_int) (dev->dev_addr[3]) << 24) & (u_int) 0xFF000000) |
708 (((u_int) (dev->dev_addr[2]) << 16) & (u_int) 0x00FF0000) |
709 (((u_int) (dev->dev_addr[1]) << 8) & (u_int) 0x0000FF00) |
710 (((u_int) (dev->dev_addr[0]) << 0) & (u_int) 0x000000FF));
711
712 sp->eth_regs->mac_addr[0] = ethsah;
713 sp->eth_regs->mac_addr[1] = ethsal;
714
715 mdelay(10);
716
717 return (0);
718 }
719
720
721 static int ar2313_init(struct net_device *dev)
722 {
723 struct ar2313_private *sp = dev->priv;
724 int ecode = 0;
725
726 /*
727 * Allocate descriptors
728 */
729 if (ar2313_allocate_descriptors(dev)) {
730 printk("%s: %s: ar2313_allocate_descriptors failed\n",
731 dev->name, __FUNCTION__);
732 ecode = -EAGAIN;
733 goto init_error;
734 }
735
736 /*
737 * Get the memory for the skb rings.
738 */
739 if (sp->rx_skb == NULL) {
740 sp->rx_skb =
741 kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES,
742 GFP_KERNEL);
743 if (!(sp->rx_skb)) {
744 printk("%s: %s: rx_skb kmalloc failed\n",
745 dev->name, __FUNCTION__);
746 ecode = -EAGAIN;
747 goto init_error;
748 }
749 }
750 memset(sp->rx_skb, 0, sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES);
751
752 if (sp->tx_skb == NULL) {
753 sp->tx_skb =
754 kmalloc(sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES,
755 GFP_KERNEL);
756 if (!(sp->tx_skb)) {
757 printk("%s: %s: tx_skb kmalloc failed\n",
758 dev->name, __FUNCTION__);
759 ecode = -EAGAIN;
760 goto init_error;
761 }
762 }
763 memset(sp->tx_skb, 0, sizeof(struct sk_buff *) * AR2313_DESCR_ENTRIES);
764
765 /*
766 * Set tx_csm before we start receiving interrupts, otherwise
767 * the interrupt handler might think it is supposed to process
768 * tx ints before we are up and running, which may cause a null
769 * pointer access in the int handler.
770 */
771 sp->rx_skbprd = 0;
772 sp->cur_rx = 0;
773 sp->tx_prd = 0;
774 sp->tx_csm = 0;
775
776 /*
777 * Zero the stats before starting the interface
778 */
779 memset(&sp->stats, 0, sizeof(sp->stats));
780
781 /*
782 * We load the ring here as there seem to be no way to tell the
783 * firmware to wipe the ring without re-initializing it.
784 */
785 ar2313_load_rx_ring(dev, RX_RING_SIZE);
786
787 /*
788 * Init hardware
789 */
790 ar2313_reset_reg(dev);
791
792 /*
793 * Get the IRQ
794 */
795 ecode =
796 request_irq(dev->irq, &ar2313_interrupt,
797 IRQF_SHARED | IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
798 dev->name, dev);
799 if (ecode) {
800 printk(KERN_WARNING "%s: %s: Requested IRQ %d is busy\n",
801 dev->name, __FUNCTION__, dev->irq);
802 goto init_error;
803 }
804
805
806 tasklet_enable(&sp->rx_tasklet);
807
808 return 0;
809
810 init_error:
811 ar2313_init_cleanup(dev);
812 return ecode;
813 }
814
815 /*
816 * Load the rx ring.
817 *
818 * Loading rings is safe without holding the spin lock since this is
819 * done only before the device is enabled, thus no interrupts are
820 * generated and by the interrupt handler/tasklet handler.
821 */
822 static void ar2313_load_rx_ring(struct net_device *dev, int nr_bufs)
823 {
824
825 struct ar2313_private *sp = ((struct net_device *) dev)->priv;
826 short i, idx;
827
828 idx = sp->rx_skbprd;
829
830 for (i = 0; i < nr_bufs; i++) {
831 struct sk_buff *skb;
832 ar2313_descr_t *rd;
833
834 if (sp->rx_skb[idx]) {
835 #if DEBUG_RX
836 printk(KERN_INFO "ar2313 rx refill full\n");
837 #endif /* DEBUG */
838 break;
839 }
840 // partha: create additional room for the second GRE fragment
841 skb = alloc_skb(AR2313_BUFSIZE + 128, GFP_ATOMIC);
842 if (!skb) {
843 printk("\n\n\n\n %s: No memory in system\n\n\n\n",
844 __FUNCTION__);
845 break;
846 }
847 // partha: create additional room in the front for tx pkt capture
848 skb_reserve(skb, 32);
849
850 /*
851 * Make sure IP header starts on a fresh cache line.
852 */
853 skb->dev = dev;
854 skb_reserve(skb, RX_OFFSET);
855 sp->rx_skb[idx] = skb;
856
857 rd = (ar2313_descr_t *) & sp->rx_ring[idx];
858
859 /* initialize dma descriptor */
860 rd->devcs = ((AR2313_BUFSIZE << DMA_RX1_BSIZE_SHIFT) |
861 DMA_RX1_CHAINED);
862 rd->addr = virt_to_phys(skb->data);
863 rd->descr =
864 virt_to_phys(&sp->
865 rx_ring[(idx + 1) & (AR2313_DESCR_ENTRIES - 1)]);
866 rd->status = DMA_RX_OWN;
867
868 idx = DSC_NEXT(idx);
869 }
870
871 if (!i) {
872 #if DEBUG_ERR
873 printk(KERN_INFO
874 "Out of memory when allocating standard receive buffers\n");
875 #endif /* DEBUG */
876 } else {
877 sp->rx_skbprd = idx;
878 }
879
880 return;
881 }
882
883 #define AR2313_MAX_PKTS_PER_CALL 64
884
885 static int ar2313_rx_int(struct net_device *dev)
886 {
887 struct ar2313_private *sp = dev->priv;
888 struct sk_buff *skb, *skb_new;
889 ar2313_descr_t *rxdesc;
890 unsigned int status;
891 u32 idx;
892 int pkts = 0;
893 int rval;
894
895 idx = sp->cur_rx;
896
897 /* process at most the entire ring and then wait for another interrupt
898 */
899 while (1) {
900
901 rxdesc = &sp->rx_ring[idx];
902 status = rxdesc->status;
903 if (status & DMA_RX_OWN) {
904 /* SiByte owns descriptor or descr not yet filled in */
905 rval = 0;
906 break;
907 }
908
909 if (++pkts > AR2313_MAX_PKTS_PER_CALL) {
910 rval = 1;
911 break;
912 }
913 #if DEBUG_RX
914 printk("index %d\n", idx);
915 printk("RX status %08x\n", rxdesc->status);
916 printk("RX devcs %08x\n", rxdesc->devcs);
917 printk("RX addr %08x\n", rxdesc->addr);
918 printk("RX descr %08x\n", rxdesc->descr);
919 #endif
920
921 if ((status & (DMA_RX_ERROR | DMA_RX_ERR_LENGTH)) &&
922 (!(status & DMA_RX_LONG))) {
923 #if DEBUG_RX
924 printk("%s: rx ERROR %08x\n", __FUNCTION__, status);
925 #endif
926 sp->stats.rx_errors++;
927 sp->stats.rx_dropped++;
928
929 /* add statistics counters */
930 if (status & DMA_RX_ERR_CRC)
931 sp->stats.rx_crc_errors++;
932 if (status & DMA_RX_ERR_COL)
933 sp->stats.rx_over_errors++;
934 if (status & DMA_RX_ERR_LENGTH)
935 sp->stats.rx_length_errors++;
936 if (status & DMA_RX_ERR_RUNT)
937 sp->stats.rx_over_errors++;
938 if (status & DMA_RX_ERR_DESC)
939 sp->stats.rx_over_errors++;
940
941 } else {
942 /* alloc new buffer. */
943 skb_new = dev_alloc_skb(AR2313_BUFSIZE + RX_OFFSET + 128);
944 if (skb_new != NULL) {
945
946 skb = sp->rx_skb[idx];
947 /* set skb */
948 skb_put(skb,
949 ((status >> DMA_RX_LEN_SHIFT) & 0x3fff) - CRC_LEN);
950
951 sp->stats.rx_bytes += skb->len;
952 skb->protocol = eth_type_trans(skb, dev);
953 /* pass the packet to upper layers */
954 netif_rx(skb);
955
956 skb_new->dev = dev;
957 /* 16 bit align */
958 skb_reserve(skb_new, RX_OFFSET + 32);
959 /* reset descriptor's curr_addr */
960 rxdesc->addr = virt_to_phys(skb_new->data);
961
962 sp->stats.rx_packets++;
963 sp->rx_skb[idx] = skb_new;
964 } else {
965 sp->stats.rx_dropped++;
966 }
967 }
968
969 rxdesc->devcs = ((AR2313_BUFSIZE << DMA_RX1_BSIZE_SHIFT) |
970 DMA_RX1_CHAINED);
971 rxdesc->status = DMA_RX_OWN;
972
973 idx = DSC_NEXT(idx);
974 }
975
976 sp->cur_rx = idx;
977
978 return rval;
979 }
980
981
982 static void ar2313_tx_int(struct net_device *dev)
983 {
984 struct ar2313_private *sp = dev->priv;
985 u32 idx;
986 struct sk_buff *skb;
987 ar2313_descr_t *txdesc;
988 unsigned int status = 0;
989
990 idx = sp->tx_csm;
991
992 while (idx != sp->tx_prd) {
993
994 txdesc = &sp->tx_ring[idx];
995
996 #if DEBUG_TX
997 printk
998 ("%s: TXINT: csm=%d idx=%d prd=%d status=%x devcs=%x addr=%08x descr=%x\n",
999 dev->name, sp->tx_csm, idx, sp->tx_prd, txdesc->status,
1000 txdesc->devcs, txdesc->addr, txdesc->descr);
1001 #endif /* DEBUG */
1002
1003 if ((status = txdesc->status) & DMA_TX_OWN) {
1004 /* ar2313 dma still owns descr */
1005 break;
1006 }
1007 /* done with this descriptor */
1008 dma_unmap_single(NULL, txdesc->addr,
1009 txdesc->devcs & DMA_TX1_BSIZE_MASK,
1010 DMA_TO_DEVICE);
1011 txdesc->status = 0;
1012
1013 if (status & DMA_TX_ERROR) {
1014 sp->stats.tx_errors++;
1015 sp->stats.tx_dropped++;
1016 if (status & DMA_TX_ERR_UNDER)
1017 sp->stats.tx_fifo_errors++;
1018 if (status & DMA_TX_ERR_HB)
1019 sp->stats.tx_heartbeat_errors++;
1020 if (status & (DMA_TX_ERR_LOSS | DMA_TX_ERR_LINK))
1021 sp->stats.tx_carrier_errors++;
1022 if (status & (DMA_TX_ERR_LATE |
1023 DMA_TX_ERR_COL |
1024 DMA_TX_ERR_JABBER | DMA_TX_ERR_DEFER))
1025 sp->stats.tx_aborted_errors++;
1026 } else {
1027 /* transmit OK */
1028 sp->stats.tx_packets++;
1029 }
1030
1031 skb = sp->tx_skb[idx];
1032 sp->tx_skb[idx] = NULL;
1033 idx = DSC_NEXT(idx);
1034 sp->stats.tx_bytes += skb->len;
1035 dev_kfree_skb_irq(skb);
1036 }
1037
1038 sp->tx_csm = idx;
1039
1040 return;
1041 }
1042
1043
1044 static void rx_tasklet_func(unsigned long data)
1045 {
1046 struct net_device *dev = (struct net_device *) data;
1047 struct ar2313_private *sp = dev->priv;
1048
1049 if (sp->unloading) {
1050 return;
1051 }
1052
1053 if (ar2313_rx_int(dev)) {
1054 tasklet_hi_schedule(&sp->rx_tasklet);
1055 } else {
1056 unsigned long flags;
1057 spin_lock_irqsave(&sp->lock, flags);
1058 sp->dma_regs->intr_ena |= DMA_STATUS_RI;
1059 spin_unlock_irqrestore(&sp->lock, flags);
1060 }
1061 }
1062
1063 static void rx_schedule(struct net_device *dev)
1064 {
1065 struct ar2313_private *sp = dev->priv;
1066
1067 sp->dma_regs->intr_ena &= ~DMA_STATUS_RI;
1068
1069 tasklet_hi_schedule(&sp->rx_tasklet);
1070 }
1071
1072 static irqreturn_t ar2313_interrupt(int irq, void *dev_id)
1073 {
1074 struct net_device *dev = (struct net_device *) dev_id;
1075 struct ar2313_private *sp = dev->priv;
1076 unsigned int status, enabled;
1077
1078 /* clear interrupt */
1079 /*
1080 * Don't clear RI bit if currently disabled.
1081 */
1082 status = sp->dma_regs->status;
1083 enabled = sp->dma_regs->intr_ena;
1084 sp->dma_regs->status = status & enabled;
1085
1086 if (status & DMA_STATUS_NIS) {
1087 /* normal status */
1088 /*
1089 * Don't schedule rx processing if interrupt
1090 * is already disabled.
1091 */
1092 if (status & enabled & DMA_STATUS_RI) {
1093 /* receive interrupt */
1094 rx_schedule(dev);
1095 }
1096 if (status & DMA_STATUS_TI) {
1097 /* transmit interrupt */
1098 ar2313_tx_int(dev);
1099 }
1100 }
1101
1102 if (status & DMA_STATUS_AIS) {
1103 #if DEBUG_INT
1104 printk("%s: AIS set %08x & %x\n", __FUNCTION__,
1105 status, (DMA_STATUS_FBE | DMA_STATUS_TPS));
1106 #endif
1107 /* abnormal status */
1108 if (status & (DMA_STATUS_FBE | DMA_STATUS_TPS)) {
1109 ar2313_restart(dev);
1110 }
1111 }
1112 return IRQ_HANDLED;
1113 }
1114
1115
1116 static int ar2313_open(struct net_device *dev)
1117 {
1118 struct ar2313_private *sp;
1119
1120 sp = dev->priv;
1121
1122 dev->mtu = 1500;
1123 netif_start_queue(dev);
1124
1125 sp->eth_regs->mac_control |= MAC_CONTROL_RE;
1126
1127 return 0;
1128 }
1129
1130 static void ar2313_halt(struct net_device *dev)
1131 {
1132 struct ar2313_private *sp = dev->priv;
1133 int j;
1134
1135 tasklet_disable(&sp->rx_tasklet);
1136
1137 /* kill the MAC */
1138 sp->eth_regs->mac_control &= ~(MAC_CONTROL_RE | /* disable Receives */
1139 MAC_CONTROL_TE); /* disable Transmits */
1140 /* stop dma */
1141 sp->dma_regs->control = 0;
1142 sp->dma_regs->bus_mode = DMA_BUS_MODE_SWR;
1143
1144 /* place phy and MAC in reset */
1145 *sp->int_regs |= (sp->cfg->reset_mac | sp->cfg->reset_phy);
1146
1147 /* free buffers on tx ring */
1148 for (j = 0; j < AR2313_DESCR_ENTRIES; j++) {
1149 struct sk_buff *skb;
1150 ar2313_descr_t *txdesc;
1151
1152 txdesc = &sp->tx_ring[j];
1153 txdesc->descr = 0;
1154
1155 skb = sp->tx_skb[j];
1156 if (skb) {
1157 dev_kfree_skb(skb);
1158 sp->tx_skb[j] = NULL;
1159 }
1160 }
1161 }
1162
1163 /*
1164 * close should do nothing. Here's why. It's called when
1165 * 'ifconfig bond0 down' is run. If it calls free_irq then
1166 * the irq is gone forever ! When bond0 is made 'up' again,
1167 * the ar2313_open () does not call request_irq (). Worse,
1168 * the call to ar2313_halt() generates a WDOG reset due to
1169 * the write to 'sp->int_regs' and the box reboots.
1170 * Commenting this out is good since it allows the
1171 * system to resume when bond0 is made up again.
1172 */
1173 static int ar2313_close(struct net_device *dev)
1174 {
1175 #if 0
1176 /*
1177 * Disable interrupts
1178 */
1179 disable_irq(dev->irq);
1180
1181 /*
1182 * Without (or before) releasing irq and stopping hardware, this
1183 * is an absolute non-sense, by the way. It will be reset instantly
1184 * by the first irq.
1185 */
1186 netif_stop_queue(dev);
1187
1188 /* stop the MAC and DMA engines */
1189 ar2313_halt(dev);
1190
1191 /* release the interrupt */
1192 free_irq(dev->irq, dev);
1193
1194 #endif
1195 return 0;
1196 }
1197
1198 static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev)
1199 {
1200 struct ar2313_private *sp = dev->priv;
1201 ar2313_descr_t *td;
1202 u32 idx;
1203
1204 idx = sp->tx_prd;
1205 td = &sp->tx_ring[idx];
1206
1207 if (td->status & DMA_TX_OWN) {
1208 #if DEBUG_TX
1209 printk("%s: No space left to Tx\n", __FUNCTION__);
1210 #endif
1211 /* free skbuf and lie to the caller that we sent it out */
1212 sp->stats.tx_dropped++;
1213 dev_kfree_skb(skb);
1214
1215 /* restart transmitter in case locked */
1216 sp->dma_regs->xmt_poll = 0;
1217 return 0;
1218 }
1219
1220 /* Setup the transmit descriptor. */
1221 td->devcs = ((skb->len << DMA_TX1_BSIZE_SHIFT) |
1222 (DMA_TX1_LS | DMA_TX1_IC | DMA_TX1_CHAINED));
1223 td->addr = dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE);
1224 td->status = DMA_TX_OWN;
1225
1226 /* kick transmitter last */
1227 sp->dma_regs->xmt_poll = 0;
1228
1229 #if DEBUG_TX
1230 printk("index %d\n", idx);
1231 printk("TX status %08x\n", td->status);
1232 printk("TX devcs %08x\n", td->devcs);
1233 printk("TX addr %08x\n", td->addr);
1234 printk("TX descr %08x\n", td->descr);
1235 #endif
1236
1237 sp->tx_skb[idx] = skb;
1238 idx = DSC_NEXT(idx);
1239 sp->tx_prd = idx;
1240
1241 return 0;
1242 }
1243
1244 static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1245 {
1246 struct mii_ioctl_data *data = (struct mii_ioctl_data *) &ifr->ifr_data;
1247 struct ar2313_private *sp = dev->priv;
1248 int ret;
1249
1250 switch (cmd) {
1251
1252 case SIOCETHTOOL:
1253 spin_lock_irq(&sp->lock);
1254 ret = phy_ethtool_ioctl(sp->phy_dev, (void *) ifr->ifr_data);
1255 spin_unlock_irq(&sp->lock);
1256 return ret;
1257
1258 case SIOCSIFHWADDR:
1259 if (copy_from_user
1260 (dev->dev_addr, ifr->ifr_data, sizeof(dev->dev_addr)))
1261 return -EFAULT;
1262 return 0;
1263
1264 case SIOCGIFHWADDR:
1265 if (copy_to_user
1266 (ifr->ifr_data, dev->dev_addr, sizeof(dev->dev_addr)))
1267 return -EFAULT;
1268 return 0;
1269
1270 case SIOCGMIIPHY:
1271 case SIOCGMIIREG:
1272 case SIOCSMIIREG:
1273 return phy_mii_ioctl(sp->phy_dev, data, cmd);
1274
1275 default:
1276 break;
1277 }
1278
1279 return -EOPNOTSUPP;
1280 }
1281
1282 static struct net_device_stats *ar2313_get_stats(struct net_device *dev)
1283 {
1284 struct ar2313_private *sp = dev->priv;
1285 return &sp->stats;
1286 }
1287
1288
1289 static void ar2313_adjust_link(struct net_device *dev)
1290 {
1291 printk(KERN_ERR " ar2313_adjust_link implementation missing\n");
1292 }
1293
1294 #define MII_ADDR(phy, reg) \
1295 ((reg << MII_ADDR_REG_SHIFT) | (phy << MII_ADDR_PHY_SHIFT))
1296
1297 static int
1298 mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
1299 {
1300 struct net_device *const dev = bus->priv;
1301 struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
1302 volatile ETHERNET_STRUCT *ethernet = sp->phy_regs;
1303
1304 ethernet->mii_addr = MII_ADDR(phy_addr, regnum);
1305 while (ethernet->mii_addr & MII_ADDR_BUSY);
1306 return (ethernet->mii_data >> MII_DATA_SHIFT);
1307 }
1308
1309 static int
1310 mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
1311 u16 value)
1312 {
1313 struct net_device *const dev = bus->priv;
1314 struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
1315 volatile ETHERNET_STRUCT *ethernet = sp->phy_regs;
1316
1317 while (ethernet->mii_addr & MII_ADDR_BUSY);
1318 ethernet->mii_data = value << MII_DATA_SHIFT;
1319 ethernet->mii_addr = MII_ADDR(phy_addr, regnum) | MII_ADDR_WRITE;
1320
1321 return 0;
1322 }
1323
1324 static int mdiobus_reset(struct mii_bus *bus)
1325 {
1326 struct net_device *const dev = bus->priv;
1327
1328 ar2313_reset_reg(dev);
1329
1330 return 0;
1331 }
1332
1333 static int mdiobus_probe (struct net_device *dev)
1334 {
1335 struct ar2313_private *const sp = (struct ar2313_private *) dev->priv;
1336 struct phy_device *phydev = NULL;
1337 int phy_addr;
1338
1339 /* find the first (lowest address) PHY on the current MAC's MII bus */
1340 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++)
1341 if (sp->mii_bus.phy_map[phy_addr]) {
1342 phydev = sp->mii_bus.phy_map[phy_addr];
1343 break; /* break out with first one found */
1344 }
1345
1346 if (!phydev) {
1347 printk (KERN_ERR "ar2313:%s: no PHY found\n", dev->name);
1348 return -1;
1349 }
1350
1351 /* now we are supposed to have a proper phydev, to attach to... */
1352 BUG_ON(!phydev);
1353 BUG_ON(phydev->attached_dev);
1354
1355 phydev = phy_connect(dev, phydev->dev.bus_id, &ar2313_adjust_link, 0,
1356 PHY_INTERFACE_MODE_MII);
1357
1358 if (IS_ERR(phydev)) {
1359 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
1360 return PTR_ERR(phydev);
1361 }
1362
1363 /* mask with MAC supported features */
1364 phydev->supported &= (SUPPORTED_10baseT_Half
1365 | SUPPORTED_10baseT_Full
1366 | SUPPORTED_100baseT_Half
1367 | SUPPORTED_100baseT_Full
1368 | SUPPORTED_Autoneg
1369 /* | SUPPORTED_Pause | SUPPORTED_Asym_Pause */
1370 | SUPPORTED_MII
1371 | SUPPORTED_TP);
1372
1373 phydev->advertising = phydev->supported;
1374
1375 //sp->old_link = 0;
1376 //sp->old_speed = 0;
1377 //sp->old_duplex = -1;
1378 sp->phy_dev = phydev;
1379
1380 printk(KERN_INFO "%s: attached PHY driver [%s] "
1381 "(mii_bus:phy_addr=%s)\n",
1382 dev->name, phydev->drv->name, phydev->dev.bus_id);
1383
1384 return 0;
1385 }
1386
This page took 0.117985 seconds and 3 git commands to generate.