Lines Matching +full:force +full:- +full:external +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0
10 * 2000/11/11 Willy Tarreau <willy AT meta-x.org>
11 * - port to non-sparc architectures. Tested only on x86 and
13 * - ability to specify the MAC address at module load time by passing this
38 #include <linux/dma-mapping.h>
86 /* "Auto Switch Debug" aka phy debug */
114 tlp->tstamp = (unsigned int)jiffies;
115 tlp->tx_new = hp->tx_new;
116 tlp->tx_old = hp->tx_old;
117 tlp->action = a;
118 tlp->status = s;
119 txlog_cur_entry = (txlog_cur_entry + 1) & (TX_LOG_LEN - 1);
132 this = (this + 1) & (TX_LOG_LEN - 1);
140 #define DEFAULT_IPG0 16 /* For lance-mode only */
149 * the two stores so that I can sleep well at night... -DaveM
165 rxd->rx_addr = (__force hme32)addr; in sbus_hme_write_rxd()
167 rxd->rx_flags = (__force hme32)flags; in sbus_hme_write_rxd()
172 txd->tx_addr = (__force hme32)addr; in sbus_hme_write_txd()
174 txd->tx_flags = (__force hme32)flags; in sbus_hme_write_txd()
194 rxd->rx_addr = (__force hme32)cpu_to_le32(addr); in pci_hme_write_rxd()
196 rxd->rx_flags = (__force hme32)cpu_to_le32(flags); in pci_hme_write_rxd()
201 txd->tx_addr = (__force hme32)cpu_to_le32(addr); in pci_hme_write_txd()
203 txd->tx_flags = (__force hme32)cpu_to_le32(flags); in pci_hme_write_txd()
212 ((__hp)->write32((__reg), (__val)))
214 ((__hp)->read32(__reg))
216 ((__hp)->write_rxd((__rxd), (__flags), (__addr)))
218 ((__hp)->write_txd((__txd), (__flags), (__addr)))
220 ((__hp)->read_desc32(__p))
229 do { (__rxd)->rx_addr = (__force hme32)(u32)(__addr); \
231 (__rxd)->rx_flags = (__force hme32)(u32)(__flags); \
234 do { (__txd)->tx_addr = (__force hme32)(u32)(__addr); \
236 (__txd)->tx_flags = (__force hme32)(u32)(__flags); \
246 do { (__rxd)->rx_addr = (__force hme32)cpu_to_le32(__addr); \
248 (__rxd)->rx_flags = (__force hme32)cpu_to_le32(__flags); \
251 do { (__txd)->tx_addr = (__force hme32)cpu_to_le32(__addr); \
253 (__txd)->tx_flags = (__force hme32)cpu_to_le32(__flags); \
316 /* Force BitBang into the idle state. */ in happy_meal_bb_read()
326 /* Give it the PHY address. */ in happy_meal_bb_read()
327 tmp = hp->paddr & 0xff; in happy_meal_bb_read()
328 for (i = 4; i >= 0; i--) in happy_meal_bb_read()
333 for (i = 4; i >= 0; i--) in happy_meal_bb_read()
340 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
341 for (i = 15; i >= 0; i--) in happy_meal_bb_read()
342 retval |= BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
343 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
344 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
345 (void) BB_GET_BIT2(hp, tregs, (hp->tcvr_type == internal)); in happy_meal_bb_read()
362 /* Force BitBang into the idle state. */ in happy_meal_bb_write()
372 /* Give it the PHY address. */ in happy_meal_bb_write()
373 tmp = (hp->paddr & 0xff); in happy_meal_bb_write()
374 for (i = 4; i >= 0; i--) in happy_meal_bb_write()
379 for (i = 4; i >= 0; i--) in happy_meal_bb_write()
386 for (i = 15; i >= 0; i--) in happy_meal_bb_write()
401 if (hp->tcvr_type == none) { in happy_meal_tcvr_read()
406 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_read()
412 (FRAME_READ | (hp->paddr << 23) | ((reg & 0xff) << 18))); in happy_meal_tcvr_read()
413 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_read()
416 netdev_err(hp->dev, "Aieee, transceiver MIF read bolixed\n"); in happy_meal_tcvr_read()
435 if (!(hp->happy_flags & HFLAG_FENABLE)) { in happy_meal_tcvr_write()
442 (FRAME_WRITE | (hp->paddr << 23) | in happy_meal_tcvr_write()
444 while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries) in happy_meal_tcvr_write()
449 netdev_err(hp->dev, "Aieee, transceiver MIF write bolixed\n"); in happy_meal_tcvr_write()
451 /* Fifty-two cents is your change, have a nice day. */ in happy_meal_tcvr_write()
460 * if the auto negotiation has completed, we assume here that the DP83840 PHY
464 * This "other" strategy is to force the interface into various speed/duplex
465 * configurations and we stop when we see a link-up condition before the
472 * 100 Base-T Full Duplex
473 * 100 Base-T Half Duplex
474 * 10 Base-T Full Duplex
475 * 10 Base-T Half Duplex
478 * been detected. This timer just waits for the link-up bit to get set in
488 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in try_next_permutation()
493 if (hp->sw_bmcr & BMCR_FULLDPLX) { in try_next_permutation()
494 hp->sw_bmcr &= ~(BMCR_FULLDPLX); in try_next_permutation()
495 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
500 if (hp->sw_bmcr & BMCR_SPEED100) { in try_next_permutation()
501 hp->sw_bmcr &= ~(BMCR_SPEED100); in try_next_permutation()
502 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in try_next_permutation()
507 return -1; in try_next_permutation()
512 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in display_link_mode()
514 netdev_info(hp->dev, in display_link_mode()
516 hp->tcvr_type == external ? "external" : "internal", in display_link_mode()
517 hp->sw_lpa & (LPA_100HALF | LPA_100FULL) ? 100 : 10, in display_link_mode()
518 hp->sw_lpa & (LPA_100FULL | LPA_10FULL) ? "Full" : "Half"); in display_link_mode()
523 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in display_forced_link_mode()
525 netdev_info(hp->dev, in display_forced_link_mode()
527 hp->tcvr_type == external ? "external" : "internal", in display_forced_link_mode()
528 hp->sw_bmcr & BMCR_SPEED100 ? 100 : 10, in display_forced_link_mode()
529 hp->sw_bmcr & BMCR_FULLDPLX ? "Full" : "Half"); in display_forced_link_mode()
539 if (hp->timer_state == arbwait) { in set_happy_link_modes()
540 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in set_happy_link_modes()
541 if (!(hp->sw_lpa & (LPA_10HALF | LPA_10FULL | LPA_100HALF | LPA_100FULL))) in set_happy_link_modes()
543 if (hp->sw_lpa & LPA_100FULL) in set_happy_link_modes()
545 else if (hp->sw_lpa & LPA_100HALF) in set_happy_link_modes()
547 else if (hp->sw_lpa & LPA_10FULL) in set_happy_link_modes()
553 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in set_happy_link_modes()
554 if (hp->sw_bmcr & BMCR_FULLDPLX) in set_happy_link_modes()
568 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
569 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
571 while (hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & BIGMAC_TXCFG_ENABLE) in set_happy_link_modes()
574 hp->happy_flags |= HFLAG_FULL; in set_happy_link_modes()
575 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
576 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
579 hp->happy_flags &= ~(HFLAG_FULL); in set_happy_link_modes()
580 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
581 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) & in set_happy_link_modes()
584 hme_write32(hp, hp->bigmacregs + BMAC_TXCFG, in set_happy_link_modes()
585 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG) | in set_happy_link_modes()
596 void __iomem *tregs = hp->tcvregs; in is_lucent_phy()
612 void __iomem *tregs = hp->tcvregs; in happy_meal_timer()
615 spin_lock_irq(&hp->happy_lock); in happy_meal_timer()
617 hp->timer_ticks++; in happy_meal_timer()
618 switch(hp->timer_state) { in happy_meal_timer()
623 if (hp->timer_ticks >= 10) { in happy_meal_timer()
624 /* Enter force mode. */ in happy_meal_timer()
626 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_timer()
627 netdev_notice(hp->dev, in happy_meal_timer()
628 "Auto-Negotiation unsuccessful, trying force link mode\n"); in happy_meal_timer()
629 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_timer()
630 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_timer()
637 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
638 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
639 happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
641 hp->timer_state = ltrywait; in happy_meal_timer()
642 hp->timer_ticks = 0; in happy_meal_timer()
646 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
647 if (hp->sw_bmsr & BMSR_ANEGCOMPLETE) { in happy_meal_timer()
653 /* Ooops, something bad happened, go to force in happy_meal_timer()
657 * XXX auto-negotiation make this happen as well. in happy_meal_timer()
663 hp->timer_state = lupwait; in happy_meal_timer()
677 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
678 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
683 hp->timer_state = asleep; in happy_meal_timer()
686 if (hp->timer_ticks >= 10) { in happy_meal_timer()
687 netdev_notice(hp->dev, in happy_meal_timer()
689 hp->timer_ticks = 0; in happy_meal_timer()
703 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_timer()
704 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, DP83840_CSCONFIG); in happy_meal_timer()
705 if (hp->timer_ticks == 1) { in happy_meal_timer()
707 /* Re-enable transceiver, we'll re-enable the transceiver next in happy_meal_timer()
710 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
712 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
717 if (hp->timer_ticks == 2) { in happy_meal_timer()
719 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_timer()
721 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
726 if (hp->sw_bmsr & BMSR_LSTATUS) { in happy_meal_timer()
727 /* Force mode selection success. */ in happy_meal_timer()
730 hp->timer_state = asleep; in happy_meal_timer()
733 if (hp->timer_ticks >= 4) { /* 6 seconds or so... */ in happy_meal_timer()
737 if (ret == -1) { in happy_meal_timer()
743 netdev_notice(hp->dev, in happy_meal_timer()
749 netdev_err(hp->dev, in happy_meal_timer()
750 "Error, cannot re-init the Happy Meal.\n"); in happy_meal_timer()
755 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_timer()
757 hp->sw_csconfig |= CSCONFIG_TCVDISAB; in happy_meal_timer()
759 DP83840_CSCONFIG, hp->sw_csconfig); in happy_meal_timer()
761 hp->timer_ticks = 0; in happy_meal_timer()
772 netdev_err(hp->dev, in happy_meal_timer()
775 hp->timer_ticks = 0; in happy_meal_timer()
776 hp->timer_state = asleep; /* foo on you */ in happy_meal_timer()
781 hp->happy_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2 sec. */ in happy_meal_timer()
782 add_timer(&hp->happy_timer); in happy_meal_timer()
786 spin_unlock_irq(&hp->happy_lock); in happy_meal_timer()
792 /* hp->happy_lock must be held */
801 while ((hme_read32(hp, bregs + BMAC_TXSWRESET) & 1) && --tries) in happy_meal_tx_reset()
806 netdev_err(hp->dev, "Transceiver BigMac ATTACK!"); in happy_meal_tx_reset()
812 /* hp->happy_lock must be held */
821 while ((hme_read32(hp, bregs + BMAC_RXSWRESET) & 1) && --tries) in happy_meal_rx_reset()
826 netdev_err(hp->dev, "Receiver BigMac ATTACK!\n"); in happy_meal_rx_reset()
834 /* hp->happy_lock must be held */
843 while (hme_read32(hp, gregs + GREG_SWRESET) && --tries) in happy_meal_stop()
848 netdev_err(hp->dev, "Fry guys.\n"); in happy_meal_stop()
854 /* hp->happy_lock must be held */
857 struct net_device_stats *stats = &hp->dev->stats; in happy_meal_get_counters()
859 stats->rx_crc_errors += hme_read32(hp, bregs + BMAC_RCRCECTR); in happy_meal_get_counters()
862 stats->rx_frame_errors += hme_read32(hp, bregs + BMAC_UNALECTR); in happy_meal_get_counters()
865 stats->rx_length_errors += hme_read32(hp, bregs + BMAC_GLECTR); in happy_meal_get_counters()
868 stats->tx_aborted_errors += hme_read32(hp, bregs + BMAC_EXCTR); in happy_meal_get_counters()
870 stats->collisions += in happy_meal_get_counters()
877 /* hp->happy_lock must be held */
881 if ((hp->happy_flags & (HFLAG_POLLENABLE | HFLAG_POLL)) != in happy_meal_poll_stop()
896 hp->happy_flags &= ~(HFLAG_POLL); in happy_meal_poll_stop()
907 #define TCVR_UNISOLATE_TRIES 32 /* Dis-isolation can take longer. */
909 /* hp->happy_lock must be held */
917 if (hp->tcvr_type == external) { in happy_meal_tcvr_reset()
919 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
920 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
926 return -1; in happy_meal_tcvr_reset()
928 ASD("external: ISOLATE, phyread_ok, PSELECT\n"); in happy_meal_tcvr_reset()
930 hp->tcvr_type = external; in happy_meal_tcvr_reset()
931 hp->paddr = TCV_PADDR_ETX; in happy_meal_tcvr_reset()
940 return -1; in happy_meal_tcvr_reset()
944 hp->tcvr_type = internal; in happy_meal_tcvr_reset()
945 hp->paddr = TCV_PADDR_ITX; in happy_meal_tcvr_reset()
952 while (--tries) { in happy_meal_tcvr_reset()
955 return -1; in happy_meal_tcvr_reset()
956 hp->sw_bmcr = result; in happy_meal_tcvr_reset()
963 return -1; in happy_meal_tcvr_reset()
967 /* Get fresh copies of the PHY registers. */ in happy_meal_tcvr_reset()
968 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_tcvr_reset()
969 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_tcvr_reset()
970 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_tcvr_reset()
971 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_tcvr_reset()
974 hp->sw_bmcr &= ~(BMCR_ISOLATE); in happy_meal_tcvr_reset()
975 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_tcvr_reset()
978 while (--tries) { in happy_meal_tcvr_reset()
981 return -1; in happy_meal_tcvr_reset()
988 return -1; in happy_meal_tcvr_reset()
1000 /* Figure out whether we have an internal or external transceiver.
1002 * hp->happy_lock must be held
1009 if (hp->happy_flags & HFLAG_POLL) { in happy_meal_transceiver_check()
1011 if (hp->tcvr_type == internal) { in happy_meal_transceiver_check()
1014 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1015 hp->tcvr_type = external; in happy_meal_transceiver_check()
1019 ASD("poll stop, internal->external\n"); in happy_meal_transceiver_check()
1022 if (hp->tcvr_type == external) { in happy_meal_transceiver_check()
1025 hp->paddr = TCV_PADDR_ITX; in happy_meal_transceiver_check()
1026 hp->tcvr_type = internal; in happy_meal_transceiver_check()
1030 ASD("poll stop, external->internal\n"); in happy_meal_transceiver_check()
1042 hp->paddr = TCV_PADDR_ETX; in happy_meal_transceiver_check()
1043 hp->tcvr_type = external; in happy_meal_transceiver_check()
1044 ASD("not polling, external\n"); in happy_meal_transceiver_check()
1049 hp->paddr = TCV_PADDR_ITX; in happy_meal_transceiver_check()
1050 hp->tcvr_type = internal; in happy_meal_transceiver_check()
1053 netdev_err(hp->dev, in happy_meal_transceiver_check()
1055 hp->tcvr_type = none; /* Grrr... */ in happy_meal_transceiver_check()
1069 * also program the etxregs->cfg register to use an offset of 2. This
1090 * this from the skb->length. Then we just pass the packet up to the
1101 * skb->csum = rxd->rx_flags & 0xffff;
1102 * skb->ip_summed = CHECKSUM_COMPLETE;
1111 if (hp->rx_skbs[i] != NULL) { in happy_meal_clean_rings()
1112 struct sk_buff *skb = hp->rx_skbs[i]; in happy_meal_clean_rings()
1116 rxd = &hp->happy_block->happy_meal_rxd[i]; in happy_meal_clean_rings()
1117 dma_addr = hme_read_desc32(hp, &rxd->rx_addr); in happy_meal_clean_rings()
1118 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1121 hp->rx_skbs[i] = NULL; in happy_meal_clean_rings()
1126 if (hp->tx_skbs[i] != NULL) { in happy_meal_clean_rings()
1127 struct sk_buff *skb = hp->tx_skbs[i]; in happy_meal_clean_rings()
1132 hp->tx_skbs[i] = NULL; in happy_meal_clean_rings()
1134 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { in happy_meal_clean_rings()
1135 txd = &hp->happy_block->happy_meal_txd[i]; in happy_meal_clean_rings()
1136 dma_addr = hme_read_desc32(hp, &txd->tx_addr); in happy_meal_clean_rings()
1138 dma_unmap_single(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1139 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1143 dma_unmap_page(hp->dma_dev, dma_addr, in happy_meal_clean_rings()
1144 (hme_read_desc32(hp, &txd->tx_flags) in happy_meal_clean_rings()
1148 if (frag != skb_shinfo(skb)->nr_frags) in happy_meal_clean_rings()
1157 /* hp->happy_lock must be held */
1160 struct hmeal_init_block *hb = hp->happy_block; in happy_meal_init_rings()
1164 hp->rx_new = hp->rx_old = hp->tx_new = hp->tx_old = 0; in happy_meal_init_rings()
1177 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1180 hp->rx_skbs[i] = skb; in happy_meal_init_rings()
1184 mapping = dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, in happy_meal_init_rings()
1186 if (dma_mapping_error(hp->dma_dev, mapping)) { in happy_meal_init_rings()
1188 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0); in happy_meal_init_rings()
1191 hme_write_rxd(hp, &hb->happy_meal_rxd[i], in happy_meal_init_rings()
1192 (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), in happy_meal_init_rings()
1199 hme_write_txd(hp, &hb->happy_meal_txd[i], 0, 0); in happy_meal_init_rings()
1204 /* hp->happy_lock must be held */
1213 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_begin_auto_negotiation()
1214 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1215 hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); in happy_meal_begin_auto_negotiation()
1216 hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); in happy_meal_begin_auto_negotiation()
1220 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_begin_auto_negotiation()
1221 if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { in happy_meal_begin_auto_negotiation()
1223 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_begin_auto_negotiation()
1224 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1226 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_begin_auto_negotiation()
1228 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_begin_auto_negotiation()
1229 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1231 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_begin_auto_negotiation()
1232 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_begin_auto_negotiation()
1233 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1235 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_begin_auto_negotiation()
1236 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_begin_auto_negotiation()
1237 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1239 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_begin_auto_negotiation()
1240 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_begin_auto_negotiation()
1249 hp->sw_advertise & ADVERTISE_10HALF ? "10H " : "", in happy_meal_begin_auto_negotiation()
1250 hp->sw_advertise & ADVERTISE_10FULL ? "10F " : "", in happy_meal_begin_auto_negotiation()
1251 hp->sw_advertise & ADVERTISE_100HALF ? "100H " : "", in happy_meal_begin_auto_negotiation()
1252 hp->sw_advertise & ADVERTISE_100FULL ? "100F " : ""); in happy_meal_begin_auto_negotiation()
1254 /* Enable Auto-Negotiation, this is usually on already... */ in happy_meal_begin_auto_negotiation()
1255 hp->sw_bmcr |= BMCR_ANENABLE; in happy_meal_begin_auto_negotiation()
1256 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1259 hp->sw_bmcr |= BMCR_ANRESTART; in happy_meal_begin_auto_negotiation()
1260 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1265 while (--timeout) { in happy_meal_begin_auto_negotiation()
1266 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_begin_auto_negotiation()
1267 if (!(hp->sw_bmcr & BMCR_ANRESTART)) in happy_meal_begin_auto_negotiation()
1272 netdev_err(hp->dev, in happy_meal_begin_auto_negotiation()
1274 hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1275 netdev_notice(hp->dev, in happy_meal_begin_auto_negotiation()
1276 "Performing force link detection.\n"); in happy_meal_begin_auto_negotiation()
1279 hp->timer_state = arbwait; in happy_meal_begin_auto_negotiation()
1283 /* Force the link up, trying first a particular mode. in happy_meal_begin_auto_negotiation()
1288 /* Disable auto-negotiation in BMCR, enable the duplex and in happy_meal_begin_auto_negotiation()
1291 if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { in happy_meal_begin_auto_negotiation()
1292 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1294 if (ep->base.speed == SPEED_100) in happy_meal_begin_auto_negotiation()
1295 hp->sw_bmcr = BMCR_SPEED100; in happy_meal_begin_auto_negotiation()
1297 hp->sw_bmcr = 0; in happy_meal_begin_auto_negotiation()
1298 if (ep->base.duplex == DUPLEX_FULL) in happy_meal_begin_auto_negotiation()
1299 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_begin_auto_negotiation()
1301 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_begin_auto_negotiation()
1308 hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, in happy_meal_begin_auto_negotiation()
1310 hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); in happy_meal_begin_auto_negotiation()
1312 hp->sw_csconfig); in happy_meal_begin_auto_negotiation()
1314 hp->timer_state = ltrywait; in happy_meal_begin_auto_negotiation()
1317 hp->timer_ticks = 0; in happy_meal_begin_auto_negotiation()
1318 hp->happy_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */ in happy_meal_begin_auto_negotiation()
1319 add_timer(&hp->happy_timer); in happy_meal_begin_auto_negotiation()
1322 /* hp->happy_lock must be held */
1325 const unsigned char *e = &hp->dev->dev_addr[0]; in happy_meal_init()
1326 void __iomem *gregs = hp->gregs; in happy_meal_init()
1327 void __iomem *etxregs = hp->etxregs; in happy_meal_init()
1328 void __iomem *erxregs = hp->erxregs; in happy_meal_init()
1329 void __iomem *bregs = hp->bigmacregs; in happy_meal_init()
1330 void __iomem *tregs = hp->tcvregs; in happy_meal_init()
1334 /* If auto-negotiation timer is running, kill it. */ in happy_meal_init()
1335 del_timer(&hp->happy_timer); in happy_meal_init()
1337 HMD("happy_flags[%08x]\n", hp->happy_flags); in happy_meal_init()
1338 if (!(hp->happy_flags & HFLAG_INIT)) { in happy_meal_init()
1340 hp->happy_flags |= HFLAG_INIT; in happy_meal_init()
1362 if (hp->happy_flags & HFLAG_FENABLE) { in happy_meal_init()
1379 switch(hp->tcvr_type) { in happy_meal_init()
1383 return -EAGAIN; in happy_meal_init()
1391 case external: in happy_meal_init()
1393 HMD("external, disable MII\n"); in happy_meal_init()
1399 return -EAGAIN; in happy_meal_init()
1406 /* Set jam size and inter-packet gaps to reasonable defaults. */ in happy_meal_init()
1420 if ((hp->dev->flags & IFF_ALLMULTI) || in happy_meal_init()
1421 (netdev_mc_count(hp->dev) > 64)) { in happy_meal_init()
1426 } else if ((hp->dev->flags & IFF_PROMISC) == 0) { in happy_meal_init()
1432 netdev_for_each_mc_addr(ha, hp->dev) { in happy_meal_init()
1433 crc = ether_crc_le(6, ha->addr); in happy_meal_init()
1450 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)), in happy_meal_init()
1451 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))); in happy_meal_init()
1453 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))); in happy_meal_init()
1455 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_txd, 0))); in happy_meal_init()
1463 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0))) in happy_meal_init()
1465 ((__u32)hp->hblock_dvma + hblock_offset(happy_meal_rxd, 0)) in happy_meal_init()
1473 if ((hp->happy_bursts & DMA_BURST64) && in happy_meal_init()
1474 ((hp->happy_flags & HFLAG_PCI) != 0 in happy_meal_init()
1483 * do not. -DaveM in happy_meal_init()
1486 if ((hp->happy_flags & HFLAG_PCI) == 0) { in happy_meal_init()
1487 struct platform_device *op = hp->happy_dev; in happy_meal_init()
1489 sbus_set_sbus64(&op->dev, in happy_meal_init()
1490 hp->happy_bursts); in happy_meal_init()
1498 } else if (hp->happy_bursts & DMA_BURST32) { in happy_meal_init()
1501 } else if (hp->happy_bursts & DMA_BURST16) { in happy_meal_init()
1521 hme_write32(hp, etxregs + ETX_RSIZE, (TX_RING_SIZE >> ETX_RSIZE_SHIFT) - 1); in happy_meal_init()
1539 netdev_err(hp->dev, in happy_meal_init()
1541 netdev_err(hp->dev, in happy_meal_init()
1551 if (hp->dev->flags & IFF_PROMISC) in happy_meal_init()
1561 if (hp->happy_flags & HFLAG_FULL) in happy_meal_init()
1565 * to deadlock with the PHY if a Jabber occurs. in happy_meal_init()
1576 if (hp->happy_flags & HFLAG_LANCE) in happy_meal_init()
1579 /* Disable the MII buffers if using external transceiver. */ in happy_meal_init()
1580 if (hp->tcvr_type == external) in happy_meal_init()
1607 /* hp->happy_lock must be held */
1610 void __iomem *tregs = hp->tcvregs; in happy_meal_set_initial_advertisement()
1611 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_initial_advertisement()
1612 void __iomem *gregs = hp->gregs; in happy_meal_set_initial_advertisement()
1616 if (hp->happy_flags & HFLAG_FENABLE) in happy_meal_set_initial_advertisement()
1623 switch(hp->tcvr_type) { in happy_meal_set_initial_advertisement()
1629 case external: in happy_meal_set_initial_advertisement()
1636 /* Latch PHY registers as of now. */ in happy_meal_set_initial_advertisement()
1637 hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); in happy_meal_set_initial_advertisement()
1638 hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); in happy_meal_set_initial_advertisement()
1641 if (hp->sw_bmsr & BMSR_10HALF) in happy_meal_set_initial_advertisement()
1642 hp->sw_advertise |= (ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1644 hp->sw_advertise &= ~(ADVERTISE_10HALF); in happy_meal_set_initial_advertisement()
1646 if (hp->sw_bmsr & BMSR_10FULL) in happy_meal_set_initial_advertisement()
1647 hp->sw_advertise |= (ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1649 hp->sw_advertise &= ~(ADVERTISE_10FULL); in happy_meal_set_initial_advertisement()
1650 if (hp->sw_bmsr & BMSR_100HALF) in happy_meal_set_initial_advertisement()
1651 hp->sw_advertise |= (ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1653 hp->sw_advertise &= ~(ADVERTISE_100HALF); in happy_meal_set_initial_advertisement()
1654 if (hp->sw_bmsr & BMSR_100FULL) in happy_meal_set_initial_advertisement()
1655 hp->sw_advertise |= (ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1657 hp->sw_advertise &= ~(ADVERTISE_100FULL); in happy_meal_set_initial_advertisement()
1659 /* Update the PHY advertisement register. */ in happy_meal_set_initial_advertisement()
1660 happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); in happy_meal_set_initial_advertisement()
1664 * the hardware, so we cannot re-read it and get a correct value.
1666 * hp->happy_lock must be held
1672 /* Only print messages for non-counter related interrupts. */ in happy_meal_is_not_so_happy()
1679 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1686 netdev_dbg(hp->dev, "Happy Meal receive FIFO overflow.\n"); in happy_meal_is_not_so_happy()
1691 netdev_err(hp->dev, "Happy Meal BigMAC SQE test failed.\n"); in happy_meal_is_not_so_happy()
1697 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1706 netdev_err(hp->dev, "Happy Meal MAX Packet size error.\n"); in happy_meal_is_not_so_happy()
1716 netdev_info(hp->dev, in happy_meal_is_not_so_happy()
1722 netdev_err(hp->dev, "Happy Meal rx DMA errors [ %s%s%s]\n", in happy_meal_is_not_so_happy()
1733 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1740 netdev_err(hp->dev, "Happy Meal MIF interrupt.\n"); in happy_meal_is_not_so_happy()
1746 netdev_err(hp->dev, "Happy Meal tx DMA errors [ %s%s%s%s]\n", in happy_meal_is_not_so_happy()
1758 netdev_err(hp->dev, in happy_meal_is_not_so_happy()
1765 netdev_notice(hp->dev, "Resetting...\n"); in happy_meal_is_not_so_happy()
1772 /* hp->happy_lock must be held */
1775 void __iomem *tregs = hp->tcvregs; in happy_meal_mif_interrupt()
1777 netdev_info(hp->dev, "Link status change.\n"); in happy_meal_mif_interrupt()
1778 hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); in happy_meal_mif_interrupt()
1779 hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); in happy_meal_mif_interrupt()
1782 if (hp->sw_lpa & LPA_100FULL) { in happy_meal_mif_interrupt()
1783 netdev_info(hp->dev, "Switching to 100Mbps at full duplex.\n"); in happy_meal_mif_interrupt()
1784 hp->sw_bmcr |= (BMCR_FULLDPLX | BMCR_SPEED100); in happy_meal_mif_interrupt()
1785 } else if (hp->sw_lpa & LPA_100HALF) { in happy_meal_mif_interrupt()
1786 netdev_info(hp->dev, "Switching to 100MBps at half duplex.\n"); in happy_meal_mif_interrupt()
1787 hp->sw_bmcr |= BMCR_SPEED100; in happy_meal_mif_interrupt()
1788 } else if (hp->sw_lpa & LPA_10FULL) { in happy_meal_mif_interrupt()
1789 netdev_info(hp->dev, "Switching to 10MBps at full duplex.\n"); in happy_meal_mif_interrupt()
1790 hp->sw_bmcr |= BMCR_FULLDPLX; in happy_meal_mif_interrupt()
1792 netdev_info(hp->dev, "Using 10Mbps at half duplex.\n"); in happy_meal_mif_interrupt()
1794 happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); in happy_meal_mif_interrupt()
1800 /* hp->happy_lock must be held */
1803 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in happy_meal_tx()
1805 struct net_device *dev = hp->dev; in happy_meal_tx()
1808 elem = hp->tx_old; in happy_meal_tx()
1809 while (elem != hp->tx_new) { in happy_meal_tx()
1814 netdev_vdbg(hp->dev, "TX[%d]\n", elem); in happy_meal_tx()
1816 flags = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1819 skb = hp->tx_skbs[elem]; in happy_meal_tx()
1820 if (skb_shinfo(skb)->nr_frags) { in happy_meal_tx()
1823 last = elem + skb_shinfo(skb)->nr_frags; in happy_meal_tx()
1824 last &= (TX_RING_SIZE - 1); in happy_meal_tx()
1829 hp->tx_skbs[elem] = NULL; in happy_meal_tx()
1830 dev->stats.tx_bytes += skb->len; in happy_meal_tx()
1832 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { in happy_meal_tx()
1833 dma_addr = hme_read_desc32(hp, &this->tx_addr); in happy_meal_tx()
1834 dma_len = hme_read_desc32(hp, &this->tx_flags); in happy_meal_tx()
1838 dma_unmap_single(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1840 dma_unmap_page(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); in happy_meal_tx()
1847 dev->stats.tx_packets++; in happy_meal_tx()
1849 hp->tx_old = elem; in happy_meal_tx()
1863 * hp->happy_lock must be held
1867 struct happy_meal_rxd *rxbase = &hp->happy_block->happy_meal_rxd[0]; in happy_meal_rx()
1869 int elem = hp->rx_new, drops = 0; in happy_meal_rx()
1873 while (!((flags = hme_read_desc32(hp, &this->rx_flags)) & RXFLAG_OWN)) { in happy_meal_rx()
1877 u32 dma_addr = hme_read_desc32(hp, &this->rx_addr); in happy_meal_rx()
1882 dev->stats.rx_errors++; in happy_meal_rx()
1884 dev->stats.rx_length_errors++; in happy_meal_rx()
1886 dev->stats.rx_over_errors++; in happy_meal_rx()
1887 dev->stats.rx_fifo_errors++; in happy_meal_rx()
1892 dev->stats.rx_dropped++; in happy_meal_rx()
1894 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), in happy_meal_rx()
1898 skb = hp->rx_skbs[elem]; in happy_meal_rx()
1910 mapping = dma_map_single(hp->dma_dev, new_skb->data, in happy_meal_rx()
1913 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_rx()
1919 dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); in happy_meal_rx()
1920 hp->rx_skbs[elem] = new_skb; in happy_meal_rx()
1922 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), in happy_meal_rx()
1938 dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); in happy_meal_rx()
1939 skb_copy_from_linear_data(skb, copy_skb->data, len); in happy_meal_rx()
1940 dma_sync_single_for_device(hp->dma_dev, dma_addr, len + 2, DMA_FROM_DEVICE); in happy_meal_rx()
1943 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), in happy_meal_rx()
1950 skb->csum = csum_unfold(~(__force __sum16)htons(csum)); in happy_meal_rx()
1951 skb->ip_summed = CHECKSUM_COMPLETE; in happy_meal_rx()
1954 skb->protocol = eth_type_trans(skb, dev); in happy_meal_rx()
1957 dev->stats.rx_packets++; in happy_meal_rx()
1958 dev->stats.rx_bytes += len; in happy_meal_rx()
1963 hp->rx_new = elem; in happy_meal_rx()
1965 netdev_info(hp->dev, "Memory squeeze, deferring packet.\n"); in happy_meal_rx()
1972 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); in happy_meal_interrupt()
1976 spin_lock(&hp->happy_lock); in happy_meal_interrupt()
1979 if (happy_meal_is_not_so_happy(hp, /* un- */ happy_status)) in happy_meal_interrupt()
1994 spin_unlock(&hp->happy_lock); in happy_meal_interrupt()
2006 struct net_device *dev = qp->happy_meals[i]; in quattro_sbus_interrupt()
2008 u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); in quattro_sbus_interrupt()
2018 spin_lock(&hp->happy_lock); in quattro_sbus_interrupt()
2034 spin_unlock(&hp->happy_lock); in quattro_sbus_interrupt()
2050 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) { in happy_meal_open()
2051 res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED, in happy_meal_open()
2052 dev->name, dev); in happy_meal_open()
2055 netdev_err(dev, "Can't order irq %d to go.\n", hp->irq); in happy_meal_open()
2057 return -EAGAIN; in happy_meal_open()
2063 spin_lock_irq(&hp->happy_lock); in happy_meal_open()
2065 spin_unlock_irq(&hp->happy_lock); in happy_meal_open()
2067 if (res && ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO)) in happy_meal_open()
2068 free_irq(hp->irq, dev); in happy_meal_open()
2076 spin_lock_irq(&hp->happy_lock); in happy_meal_close()
2077 happy_meal_stop(hp, hp->gregs); in happy_meal_close()
2080 /* If auto-negotiation timer is running, kill it. */ in happy_meal_close()
2081 del_timer(&hp->happy_timer); in happy_meal_close()
2083 spin_unlock_irq(&hp->happy_lock); in happy_meal_close()
2089 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) in happy_meal_close()
2090 free_irq(hp->irq, dev); in happy_meal_close()
2102 hme_read32(hp, hp->gregs + GREG_STAT), in happy_meal_tx_timeout()
2103 hme_read32(hp, hp->etxregs + ETX_CFG), in happy_meal_tx_timeout()
2104 hme_read32(hp, hp->bigmacregs + BMAC_TXCFG)); in happy_meal_tx_timeout()
2106 spin_lock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
2108 spin_unlock_irq(&hp->happy_lock); in happy_meal_tx_timeout()
2116 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0]; in unmap_partial_tx_skb()
2118 dma_unmap_single(hp->dma_dev, first_mapping, first_len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
2125 addr = hme_read_desc32(hp, &this->tx_addr); in unmap_partial_tx_skb()
2126 len = hme_read_desc32(hp, &this->tx_flags); in unmap_partial_tx_skb()
2128 dma_unmap_page(hp->dma_dev, addr, len, DMA_TO_DEVICE); in unmap_partial_tx_skb()
2140 if (skb->ip_summed == CHECKSUM_PARTIAL) { in happy_meal_start_xmit()
2142 const u32 csum_stuff_off = csum_start_off + skb->csum_offset; in happy_meal_start_xmit()
2149 spin_lock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2151 if (TX_BUFFS_AVAIL(hp) <= (skb_shinfo(skb)->nr_frags + 1)) { in happy_meal_start_xmit()
2153 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2158 entry = hp->tx_new; in happy_meal_start_xmit()
2159 netdev_vdbg(dev, "SX<l[%d]e[%d]>\n", skb->len, entry); in happy_meal_start_xmit()
2160 hp->tx_skbs[entry] = skb; in happy_meal_start_xmit()
2162 if (skb_shinfo(skb)->nr_frags == 0) { in happy_meal_start_xmit()
2165 len = skb->len; in happy_meal_start_xmit()
2166 mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); in happy_meal_start_xmit()
2167 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) in happy_meal_start_xmit()
2170 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2182 first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, in happy_meal_start_xmit()
2184 if (unlikely(dma_mapping_error(hp->dma_dev, first_mapping))) in happy_meal_start_xmit()
2188 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { in happy_meal_start_xmit()
2189 const skb_frag_t *this_frag = &skb_shinfo(skb)->frags[frag]; in happy_meal_start_xmit()
2193 mapping = skb_frag_dma_map(hp->dma_dev, this_frag, in happy_meal_start_xmit()
2195 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) { in happy_meal_start_xmit()
2201 if (frag == skb_shinfo(skb)->nr_frags - 1) in happy_meal_start_xmit()
2203 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], in happy_meal_start_xmit()
2208 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[first_entry], in happy_meal_start_xmit()
2213 hp->tx_new = entry; in happy_meal_start_xmit()
2219 hme_write32(hp, hp->etxregs + ETX_PENDING, ETX_TP_DMAWAKEUP); in happy_meal_start_xmit()
2221 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2227 hp->tx_skbs[hp->tx_new] = NULL; in happy_meal_start_xmit()
2228 spin_unlock_irq(&hp->happy_lock); in happy_meal_start_xmit()
2231 dev->stats.tx_dropped++; in happy_meal_start_xmit()
2239 spin_lock_irq(&hp->happy_lock); in happy_meal_get_stats()
2240 happy_meal_get_counters(hp, hp->bigmacregs); in happy_meal_get_stats()
2241 spin_unlock_irq(&hp->happy_lock); in happy_meal_get_stats()
2243 return &dev->stats; in happy_meal_get_stats()
2249 void __iomem *bregs = hp->bigmacregs; in happy_meal_set_multicast()
2253 spin_lock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2255 if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 64)) { in happy_meal_set_multicast()
2260 } else if (dev->flags & IFF_PROMISC) { in happy_meal_set_multicast()
2268 crc = ether_crc_le(6, ha->addr); in happy_meal_set_multicast()
2278 spin_unlock_irq(&hp->happy_lock); in happy_meal_set_multicast()
2295 cmd->base.port = PORT_TP; /* XXX no MII support */ in hme_get_link_ksettings()
2296 cmd->base.phy_address = 0; /* XXX fixed PHYAD */ in hme_get_link_ksettings()
2298 /* Record PHY settings. */ in hme_get_link_ksettings()
2299 spin_lock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2300 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link_ksettings()
2301 hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA); in hme_get_link_ksettings()
2302 spin_unlock_irq(&hp->happy_lock); in hme_get_link_ksettings()
2304 if (hp->sw_bmcr & BMCR_ANENABLE) { in hme_get_link_ksettings()
2305 cmd->base.autoneg = AUTONEG_ENABLE; in hme_get_link_ksettings()
2306 speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ? in hme_get_link_ksettings()
2309 cmd->base.duplex = in hme_get_link_ksettings()
2310 (hp->sw_lpa & (LPA_100FULL)) ? in hme_get_link_ksettings()
2313 cmd->base.duplex = in hme_get_link_ksettings()
2314 (hp->sw_lpa & (LPA_10FULL)) ? in hme_get_link_ksettings()
2317 cmd->base.autoneg = AUTONEG_DISABLE; in hme_get_link_ksettings()
2318 speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10; in hme_get_link_ksettings()
2319 cmd->base.duplex = in hme_get_link_ksettings()
2320 (hp->sw_bmcr & BMCR_FULLDPLX) ? in hme_get_link_ksettings()
2323 cmd->base.speed = speed; in hme_get_link_ksettings()
2324 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in hme_get_link_ksettings()
2336 if (cmd->base.autoneg != AUTONEG_ENABLE && in hme_set_link_ksettings()
2337 cmd->base.autoneg != AUTONEG_DISABLE) in hme_set_link_ksettings()
2338 return -EINVAL; in hme_set_link_ksettings()
2339 if (cmd->base.autoneg == AUTONEG_DISABLE && in hme_set_link_ksettings()
2340 ((cmd->base.speed != SPEED_100 && in hme_set_link_ksettings()
2341 cmd->base.speed != SPEED_10) || in hme_set_link_ksettings()
2342 (cmd->base.duplex != DUPLEX_HALF && in hme_set_link_ksettings()
2343 cmd->base.duplex != DUPLEX_FULL))) in hme_set_link_ksettings()
2344 return -EINVAL; in hme_set_link_ksettings()
2347 spin_lock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2348 del_timer(&hp->happy_timer); in hme_set_link_ksettings()
2349 happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd); in hme_set_link_ksettings()
2350 spin_unlock_irq(&hp->happy_lock); in hme_set_link_ksettings()
2359 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in hme_get_drvinfo()
2360 if (hp->happy_flags & HFLAG_PCI) { in hme_get_drvinfo()
2361 struct pci_dev *pdev = hp->happy_dev; in hme_get_drvinfo()
2362 strscpy(info->bus_info, pci_name(pdev), sizeof(info->bus_info)); in hme_get_drvinfo()
2367 struct platform_device *op = hp->happy_dev; in hme_get_drvinfo()
2368 regs = of_get_property(op->dev.of_node, "regs", NULL); in hme_get_drvinfo()
2370 snprintf(info->bus_info, sizeof(info->bus_info), in hme_get_drvinfo()
2372 regs->which_io); in hme_get_drvinfo()
2381 spin_lock_irq(&hp->happy_lock); in hme_get_link()
2382 hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR); in hme_get_link()
2383 spin_unlock_irq(&hp->happy_lock); in hme_get_link()
2385 return hp->sw_bmsr & BMSR_LSTATUS; in hme_get_link()
2403 struct device *parent = child->dev.parent; in quattro_sbus_find()
2416 qp->quattro_dev = child; in quattro_sbus_find()
2417 qp->next = qfe_sbus_list; in quattro_sbus_find()
2432 for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { in quattro_sbus_register_irqs()
2433 struct platform_device *op = qp->quattro_dev; in quattro_sbus_register_irqs()
2437 if (!qp->happy_meals[qfe_slot]) in quattro_sbus_register_irqs()
2443 err = request_irq(op->archdata.irqs[0], in quattro_sbus_register_irqs()
2448 dev_err(&op->dev, in quattro_sbus_register_irqs()
2462 for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { in quattro_sbus_free_irqs()
2463 struct platform_device *op = qp->quattro_dev; in quattro_sbus_free_irqs()
2467 if (!qp->happy_meals[qfe_slot]) in quattro_sbus_free_irqs()
2473 free_irq(op->archdata.irqs[0], qp); in quattro_sbus_free_irqs()
2482 struct pci_dev *bdev = pdev->bus->self; in quattro_pci_find()
2486 return ERR_PTR(-ENODEV); in quattro_pci_find()
2488 for (qp = qfe_pci_list; qp != NULL; qp = qp->next) { in quattro_pci_find()
2489 struct pci_dev *qpdev = qp->quattro_dev; in quattro_pci_find()
2497 return ERR_PTR(-ENOMEM); in quattro_pci_find()
2500 qp->happy_meals[i] = NULL; in quattro_pci_find()
2502 qp->quattro_dev = bdev; in quattro_pci_find()
2503 qp->next = qfe_pci_list; in quattro_pci_find()
2507 qp->nranges = 0; in quattro_pci_find()
2526 struct device_node *dp = op->dev.of_node, *sbus_dp; in happy_meal_sbus_probe_one()
2530 int i, qfe_slot = -1; in happy_meal_sbus_probe_one()
2532 int err = -ENODEV; in happy_meal_sbus_probe_one()
2534 sbus_dp = op->dev.parent->of_node; in happy_meal_sbus_probe_one()
2545 if (qp->happy_meals[qfe_slot] == NULL) in happy_meal_sbus_probe_one()
2551 err = -ENOMEM; in happy_meal_sbus_probe_one()
2555 SET_NETDEV_DEV(dev, &op->dev); in happy_meal_sbus_probe_one()
2558 * the Quattro local-mac-address property... in happy_meal_sbus_probe_one()
2573 addr = of_get_property(dp, "local-mac-address", &len); in happy_meal_sbus_probe_one()
2575 if (qfe_slot != -1 && addr && len == ETH_ALEN) in happy_meal_sbus_probe_one()
2578 eth_hw_addr_set(dev, idprom->id_ethaddr); in happy_meal_sbus_probe_one()
2583 hp->happy_dev = op; in happy_meal_sbus_probe_one()
2584 hp->dma_dev = &op->dev; in happy_meal_sbus_probe_one()
2586 spin_lock_init(&hp->happy_lock); in happy_meal_sbus_probe_one()
2588 err = -ENODEV; in happy_meal_sbus_probe_one()
2590 hp->qfe_parent = qp; in happy_meal_sbus_probe_one()
2591 hp->qfe_ent = qfe_slot; in happy_meal_sbus_probe_one()
2592 qp->happy_meals[qfe_slot] = dev; in happy_meal_sbus_probe_one()
2595 hp->gregs = of_ioremap(&op->resource[0], 0, in happy_meal_sbus_probe_one()
2597 if (!hp->gregs) { in happy_meal_sbus_probe_one()
2598 dev_err(&op->dev, "Cannot map global registers.\n"); in happy_meal_sbus_probe_one()
2602 hp->etxregs = of_ioremap(&op->resource[1], 0, in happy_meal_sbus_probe_one()
2604 if (!hp->etxregs) { in happy_meal_sbus_probe_one()
2605 dev_err(&op->dev, "Cannot map MAC TX registers.\n"); in happy_meal_sbus_probe_one()
2609 hp->erxregs = of_ioremap(&op->resource[2], 0, in happy_meal_sbus_probe_one()
2611 if (!hp->erxregs) { in happy_meal_sbus_probe_one()
2612 dev_err(&op->dev, "Cannot map MAC RX registers.\n"); in happy_meal_sbus_probe_one()
2616 hp->bigmacregs = of_ioremap(&op->resource[3], 0, in happy_meal_sbus_probe_one()
2618 if (!hp->bigmacregs) { in happy_meal_sbus_probe_one()
2619 dev_err(&op->dev, "Cannot map BIGMAC registers.\n"); in happy_meal_sbus_probe_one()
2623 hp->tcvregs = of_ioremap(&op->resource[4], 0, in happy_meal_sbus_probe_one()
2625 if (!hp->tcvregs) { in happy_meal_sbus_probe_one()
2626 dev_err(&op->dev, "Cannot map TCVR registers.\n"); in happy_meal_sbus_probe_one()
2630 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_sbus_probe_one()
2631 if (hp->hm_revision == 0xff) in happy_meal_sbus_probe_one()
2632 hp->hm_revision = 0xa0; in happy_meal_sbus_probe_one()
2635 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_sbus_probe_one()
2636 hp->happy_flags = HFLAG_20_21; in happy_meal_sbus_probe_one()
2637 else if (hp->hm_revision != 0xa0) in happy_meal_sbus_probe_one()
2638 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_sbus_probe_one()
2641 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_sbus_probe_one()
2644 hp->happy_bursts = of_getintprop_default(sbus_dp, in happy_meal_sbus_probe_one()
2645 "burst-sizes", 0x00); in happy_meal_sbus_probe_one()
2647 hp->happy_block = dma_alloc_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2649 &hp->hblock_dvma, in happy_meal_sbus_probe_one()
2651 err = -ENOMEM; in happy_meal_sbus_probe_one()
2652 if (!hp->happy_block) in happy_meal_sbus_probe_one()
2655 /* Force check of the link first time we are brought up. */ in happy_meal_sbus_probe_one()
2656 hp->linkcheck = 0; in happy_meal_sbus_probe_one()
2658 /* Force timer state to 'asleep' with count of zero. */ in happy_meal_sbus_probe_one()
2659 hp->timer_state = asleep; in happy_meal_sbus_probe_one()
2660 hp->timer_ticks = 0; in happy_meal_sbus_probe_one()
2662 timer_setup(&hp->happy_timer, happy_meal_timer, 0); in happy_meal_sbus_probe_one()
2664 hp->dev = dev; in happy_meal_sbus_probe_one()
2665 dev->netdev_ops = &hme_netdev_ops; in happy_meal_sbus_probe_one()
2666 dev->watchdog_timeo = 5*HZ; in happy_meal_sbus_probe_one()
2667 dev->ethtool_ops = &hme_ethtool_ops; in happy_meal_sbus_probe_one()
2670 dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; in happy_meal_sbus_probe_one()
2671 dev->features |= dev->hw_features | NETIF_F_RXCSUM; in happy_meal_sbus_probe_one()
2673 hp->irq = op->archdata.irqs[0]; in happy_meal_sbus_probe_one()
2677 hp->read_desc32 = sbus_hme_read_desc32; in happy_meal_sbus_probe_one()
2678 hp->write_txd = sbus_hme_write_txd; in happy_meal_sbus_probe_one()
2679 hp->write_rxd = sbus_hme_write_rxd; in happy_meal_sbus_probe_one()
2680 hp->read32 = sbus_hme_read32; in happy_meal_sbus_probe_one()
2681 hp->write32 = sbus_hme_write32; in happy_meal_sbus_probe_one()
2687 spin_lock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2689 spin_unlock_irq(&hp->happy_lock); in happy_meal_sbus_probe_one()
2691 err = register_netdev(hp->dev); in happy_meal_sbus_probe_one()
2693 dev_err(&op->dev, "Cannot register net device, aborting.\n"); in happy_meal_sbus_probe_one()
2699 if (qfe_slot != -1) in happy_meal_sbus_probe_one()
2702 qfe_slot, dev->dev_addr); in happy_meal_sbus_probe_one()
2705 dev->dev_addr); in happy_meal_sbus_probe_one()
2710 dma_free_coherent(hp->dma_dev, in happy_meal_sbus_probe_one()
2712 hp->happy_block, in happy_meal_sbus_probe_one()
2713 hp->hblock_dvma); in happy_meal_sbus_probe_one()
2716 if (hp->gregs) in happy_meal_sbus_probe_one()
2717 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in happy_meal_sbus_probe_one()
2718 if (hp->etxregs) in happy_meal_sbus_probe_one()
2719 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in happy_meal_sbus_probe_one()
2720 if (hp->erxregs) in happy_meal_sbus_probe_one()
2721 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in happy_meal_sbus_probe_one()
2722 if (hp->bigmacregs) in happy_meal_sbus_probe_one()
2723 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in happy_meal_sbus_probe_one()
2724 if (hp->tcvregs) in happy_meal_sbus_probe_one()
2725 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in happy_meal_sbus_probe_one()
2728 qp->happy_meals[qfe_slot] = NULL; in happy_meal_sbus_probe_one()
2742 struct pci_dev *busdev = pdev->bus->self; in is_quattro_p()
2747 busdev->vendor != PCI_VENDOR_ID_DEC || in is_quattro_p()
2748 busdev->device != PCI_DEVICE_ID_DEC_21153) in is_quattro_p()
2752 list_for_each_entry(this_pdev, &pdev->bus->devices, bus_list) { in is_quattro_p()
2753 if (this_pdev->vendor == PCI_VENDOR_ID_SUN && in is_quattro_p()
2754 this_pdev->device == PCI_DEVICE_ID_SUN_HAPPYMEAL) in is_quattro_p()
2790 index--; in find_eth_addr_in_vpd()
2805 index = PCI_SLOT(pdev->devfn); in get_hme_mac_nonsparc()
2834 int i, qfe_slot = -1; in happy_meal_pci_probe()
2863 if (!qp->happy_meals[qfe_slot]) in happy_meal_pci_probe()
2870 dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct happy_meal)); in happy_meal_pci_probe()
2872 err = -ENOMEM; in happy_meal_pci_probe()
2875 SET_NETDEV_DEV(dev, &pdev->dev); in happy_meal_pci_probe()
2879 hp->happy_dev = pdev; in happy_meal_pci_probe()
2880 hp->dma_dev = &pdev->dev; in happy_meal_pci_probe()
2882 spin_lock_init(&hp->happy_lock); in happy_meal_pci_probe()
2885 hp->qfe_parent = qp; in happy_meal_pci_probe()
2886 hp->qfe_ent = qfe_slot; in happy_meal_pci_probe()
2887 qp->happy_meals[qfe_slot] = dev; in happy_meal_pci_probe()
2890 err = -EINVAL; in happy_meal_pci_probe()
2892 dev_err(&pdev->dev, in happy_meal_pci_probe()
2897 hpreg_res = devm_request_region(&pdev->dev, pci_resource_start(pdev, 0), in happy_meal_pci_probe()
2900 err = -EBUSY; in happy_meal_pci_probe()
2901 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting.\n"); in happy_meal_pci_probe()
2907 err = -ENOMEM; in happy_meal_pci_probe()
2908 dev_err(&pdev->dev, "Unable to remap card memory.\n"); in happy_meal_pci_probe()
2926 if (qfe_slot != -1 && in happy_meal_pci_probe()
2927 (addr = of_get_property(dp, "local-mac-address", &len)) in happy_meal_pci_probe()
2932 eth_hw_addr_set(dev, idprom->id_ethaddr); in happy_meal_pci_probe()
2943 hp->gregs = (hpreg_base + 0x0000UL); in happy_meal_pci_probe()
2944 hp->etxregs = (hpreg_base + 0x2000UL); in happy_meal_pci_probe()
2945 hp->erxregs = (hpreg_base + 0x4000UL); in happy_meal_pci_probe()
2946 hp->bigmacregs = (hpreg_base + 0x6000UL); in happy_meal_pci_probe()
2947 hp->tcvregs = (hpreg_base + 0x7000UL); in happy_meal_pci_probe()
2950 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); in happy_meal_pci_probe()
2951 if (hp->hm_revision == 0xff) in happy_meal_pci_probe()
2952 hp->hm_revision = 0xc0 | (pdev->revision & 0x0f); in happy_meal_pci_probe()
2954 /* works with this on non-sparc hosts */ in happy_meal_pci_probe()
2955 hp->hm_revision = 0x20; in happy_meal_pci_probe()
2959 if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) in happy_meal_pci_probe()
2960 hp->happy_flags = HFLAG_20_21; in happy_meal_pci_probe()
2961 else if (hp->hm_revision != 0xa0 && hp->hm_revision != 0xc0) in happy_meal_pci_probe()
2962 hp->happy_flags = HFLAG_NOT_A0; in happy_meal_pci_probe()
2965 hp->happy_flags |= HFLAG_QUATTRO; in happy_meal_pci_probe()
2968 hp->happy_flags |= HFLAG_PCI; in happy_meal_pci_probe()
2972 hp->happy_bursts = DMA_BURSTBITS; in happy_meal_pci_probe()
2975 hp->happy_block = dmam_alloc_coherent(&pdev->dev, PAGE_SIZE, in happy_meal_pci_probe()
2976 &hp->hblock_dvma, GFP_KERNEL); in happy_meal_pci_probe()
2977 if (!hp->happy_block) { in happy_meal_pci_probe()
2978 err = -ENOMEM; in happy_meal_pci_probe()
2982 hp->linkcheck = 0; in happy_meal_pci_probe()
2983 hp->timer_state = asleep; in happy_meal_pci_probe()
2984 hp->timer_ticks = 0; in happy_meal_pci_probe()
2986 timer_setup(&hp->happy_timer, happy_meal_timer, 0); in happy_meal_pci_probe()
2988 hp->irq = pdev->irq; in happy_meal_pci_probe()
2989 hp->dev = dev; in happy_meal_pci_probe()
2990 dev->netdev_ops = &hme_netdev_ops; in happy_meal_pci_probe()
2991 dev->watchdog_timeo = 5*HZ; in happy_meal_pci_probe()
2992 dev->ethtool_ops = &hme_ethtool_ops; in happy_meal_pci_probe()
2995 dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; in happy_meal_pci_probe()
2996 dev->features |= dev->hw_features | NETIF_F_RXCSUM; in happy_meal_pci_probe()
3000 hp->read_desc32 = pci_hme_read_desc32; in happy_meal_pci_probe()
3001 hp->write_txd = pci_hme_write_txd; in happy_meal_pci_probe()
3002 hp->write_rxd = pci_hme_write_rxd; in happy_meal_pci_probe()
3003 hp->read32 = pci_hme_read32; in happy_meal_pci_probe()
3004 hp->write32 = pci_hme_write32; in happy_meal_pci_probe()
3010 spin_lock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3012 spin_unlock_irq(&hp->happy_lock); in happy_meal_pci_probe()
3014 err = devm_register_netdev(&pdev->dev, dev); in happy_meal_pci_probe()
3016 dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); in happy_meal_pci_probe()
3023 struct pci_dev *qpdev = qp->quattro_dev; in happy_meal_pci_probe()
3026 if (!strncmp(dev->name, "eth", 3)) { in happy_meal_pci_probe()
3027 int i = simple_strtoul(dev->name + 3, NULL, 10); in happy_meal_pci_probe()
3028 sprintf(prom_name, "-%d", i + 3); in happy_meal_pci_probe()
3032 prom_name, qpdev->vendor, qpdev->device); in happy_meal_pci_probe()
3035 if (qfe_slot != -1) in happy_meal_pci_probe()
3038 qfe_slot, dev->dev_addr); in happy_meal_pci_probe()
3042 dev->dev_addr); in happy_meal_pci_probe()
3048 qp->happy_meals[qfe_slot] = NULL; in happy_meal_pci_probe()
3078 struct quattro *next = qfe->next; in happy_meal_pci_exit()
3093 struct device_node *dp = op->dev.of_node; in hme_sbus_probe()
3097 match = of_match_device(hme_sbus_match, &op->dev); in hme_sbus_probe()
3099 return -EINVAL; in hme_sbus_probe()
3100 is_qfe = (match->data != NULL); in hme_sbus_probe()
3102 if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) in hme_sbus_probe()
3111 struct net_device *net_dev = hp->dev; in hme_sbus_remove()
3117 of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); in hme_sbus_remove()
3118 of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); in hme_sbus_remove()
3119 of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); in hme_sbus_remove()
3120 of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); in hme_sbus_remove()
3121 of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); in hme_sbus_remove()
3122 dma_free_coherent(hp->dma_dev, in hme_sbus_remove()
3124 hp->happy_block, in hme_sbus_remove()
3125 hp->hblock_dvma); in hme_sbus_remove()
3176 struct quattro *next = qfe->next; in happy_meal_sbus_exit()