Lines Matching +full:ultra +full:- +full:fast

17  *	are provided to you under the BSD-type license terms provided
22 * - Redistributions of source code must retain the above copyright
24 * - Redistributions in binary form must reproduce the above
28 * - Neither the name of Marvell nor the names of its contributors
48 /*-
49 * SPDX-License-Identifier: BSD-4-Clause AND BSD-3-Clause
65 * 4. Neither the name of the author nor the names of any co-contributors
81 /*-
171 "SK-9Sxx Gigabit Ethernet" },
173 "SK-9Exx Gigabit Ethernet"},
191 "Marvell Yukon 88E8035 Fast Ethernet" },
193 "Marvell Yukon 88E8036 Fast Ethernet" },
195 "Marvell Yukon 88E8038 Fast Ethernet" },
197 "Marvell Yukon 88E8039 Fast Ethernet" },
199 "Marvell Yukon 88E8040 Fast Ethernet" },
201 "Marvell Yukon 88E8040T Fast Ethernet" },
203 "Marvell Yukon 88E8042 Fast Ethernet" },
205 "Marvell Yukon 88E8048 Fast Ethernet" },
233 "D-Link 550SX Gigabit Ethernet" },
235 "D-Link 560SX Gigabit Ethernet" },
237 "D-Link 560T Gigabit Ethernet" }
242 "Yukon EC Ultra",
248 "Yukon Ultra 2",
378 { -1, 0, 0 }
383 { -1, 0, 0 }
388 { -1, 0, 0 }
393 { -1, 0, 0 }
412 sc = sc_if->msk_softc; in msk_phy_readreg()
414 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SMI_CTRL, in msk_phy_readreg()
419 val = GMAC_READ_2(sc, sc_if->msk_port, GM_SMI_CTRL); in msk_phy_readreg()
421 val = GMAC_READ_2(sc, sc_if->msk_port, GM_SMI_DATA); in msk_phy_readreg()
427 if_printf(sc_if->msk_ifp, "phy failed to come ready\n"); in msk_phy_readreg()
450 sc = sc_if->msk_softc; in msk_phy_writereg()
452 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SMI_DATA, val); in msk_phy_writereg()
453 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SMI_CTRL, in msk_phy_writereg()
457 if ((GMAC_READ_2(sc, sc_if->msk_port, GM_SMI_CTRL) & in msk_phy_writereg()
462 if_printf(sc_if->msk_ifp, "phy write timeout\n"); in msk_phy_writereg()
477 sc = sc_if->msk_softc; in msk_miibus_statchg()
481 mii = device_get_softc(sc_if->msk_miibus); in msk_miibus_statchg()
482 ifp = sc_if->msk_ifp; in msk_miibus_statchg()
487 sc_if->msk_flags &= ~MSK_FLAG_LINK; in msk_miibus_statchg()
488 if ((mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) == in msk_miibus_statchg()
490 switch (IFM_SUBTYPE(mii->mii_media_active)) { in msk_miibus_statchg()
493 sc_if->msk_flags |= MSK_FLAG_LINK; in msk_miibus_statchg()
499 if ((sc_if->msk_flags & MSK_FLAG_FASTETHER) == 0) in msk_miibus_statchg()
500 sc_if->msk_flags |= MSK_FLAG_LINK; in msk_miibus_statchg()
507 if ((sc_if->msk_flags & MSK_FLAG_LINK) != 0) { in msk_miibus_statchg()
509 CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_MSK), in msk_miibus_statchg()
514 * speed/flow-control/duplex updates. in msk_miibus_statchg()
517 switch (IFM_SUBTYPE(mii->mii_media_active)) { in msk_miibus_statchg()
529 if ((IFM_OPTIONS(mii->mii_media_active) & in msk_miibus_statchg()
532 if ((IFM_OPTIONS(mii->mii_media_active) & in msk_miibus_statchg()
535 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) in msk_miibus_statchg()
540 GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); in msk_miibus_statchg()
542 GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); in msk_miibus_statchg()
544 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { in msk_miibus_statchg()
545 if ((IFM_OPTIONS(mii->mii_media_active) & in msk_miibus_statchg()
549 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), gmac); in msk_miibus_statchg()
561 gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); in msk_miibus_statchg()
564 GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac); in msk_miibus_statchg()
566 GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); in msk_miibus_statchg()
594 sc = sc_if->msk_softc; in msk_rxfilter()
598 ifp = sc_if->msk_ifp; in msk_rxfilter()
601 mode = GMAC_READ_2(sc, sc_if->msk_port, GM_RX_CTRL); in msk_rxfilter()
615 GMAC_WRITE_2(sc, sc_if->msk_port, GM_MC_ADDR_H1, in msk_rxfilter()
617 GMAC_WRITE_2(sc, sc_if->msk_port, GM_MC_ADDR_H2, in msk_rxfilter()
619 GMAC_WRITE_2(sc, sc_if->msk_port, GM_MC_ADDR_H3, in msk_rxfilter()
621 GMAC_WRITE_2(sc, sc_if->msk_port, GM_MC_ADDR_H4, in msk_rxfilter()
623 GMAC_WRITE_2(sc, sc_if->msk_port, GM_RX_CTRL, mode); in msk_rxfilter()
631 sc = sc_if->msk_softc; in msk_setvlan()
633 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), in msk_setvlan()
635 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), in msk_setvlan()
638 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), in msk_setvlan()
640 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), in msk_setvlan()
651 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 && in msk_rx_fill()
652 (if_getcapenable(sc_if->msk_ifp) & IFCAP_RXCSUM) != 0) { in msk_rx_fill()
654 for (i = 100; i > 0; i--) { in msk_rx_fill()
656 idx = CSR_READ_2(sc_if->msk_softc, in msk_rx_fill()
657 Y2_PREF_Q_ADDR(sc_if->msk_rxq, in msk_rx_fill()
663 device_printf(sc_if->msk_if_dev, in msk_rx_fill()
670 * in fast handler. in msk_rx_fill()
675 bus_dmamap_sync(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, in msk_rx_fill()
676 sc_if->msk_cdata.msk_jumbo_rx_ring_map, in msk_rx_fill()
681 bus_dmamap_sync(sc_if->msk_cdata.msk_rx_ring_tag, in msk_rx_fill()
682 sc_if->msk_cdata.msk_rx_ring_map, in msk_rx_fill()
685 sc_if->msk_cdata.msk_rx_prod = 0; in msk_rx_fill()
686 CSR_WRITE_2(sc_if->msk_softc, in msk_rx_fill()
687 Y2_PREF_Q_ADDR(sc_if->msk_rxq, PREF_UNIT_PUT_IDX_REG), in msk_rx_fill()
688 sc_if->msk_cdata.msk_rx_prod); in msk_rx_fill()
702 sc_if->msk_cdata.msk_rx_cons = 0; in msk_init_rx_ring()
703 sc_if->msk_cdata.msk_rx_prod = 0; in msk_init_rx_ring()
704 sc_if->msk_cdata.msk_rx_putwm = MSK_PUT_WM; in msk_init_rx_ring()
706 rd = &sc_if->msk_rdata; in msk_init_rx_ring()
707 bzero(rd->msk_rx_ring, sizeof(struct msk_rx_desc) * MSK_RX_RING_CNT); in msk_init_rx_ring()
709 rxd = &sc_if->msk_cdata.msk_rxdesc[prod]; in msk_init_rx_ring()
710 rxd->rx_m = NULL; in msk_init_rx_ring()
711 rxd->rx_le = &rd->msk_rx_ring[prod]; in msk_init_rx_ring()
717 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 && in msk_init_rx_ring()
718 (if_getcapenable(sc_if->msk_ifp) & IFCAP_RXCSUM) != 0) { in msk_init_rx_ring()
720 rxd = &sc_if->msk_cdata.msk_rxdesc[prod]; in msk_init_rx_ring()
721 rxd->rx_m = NULL; in msk_init_rx_ring()
722 rxd->rx_le = &rd->msk_rx_ring[prod]; in msk_init_rx_ring()
723 rxd->rx_le->msk_addr = htole32(ETHER_HDR_LEN << 16 | in msk_init_rx_ring()
725 rxd->rx_le->msk_control = htole32(OP_TCPSTART | HW_OWNER); in msk_init_rx_ring()
727 MSK_INC(sc_if->msk_cdata.msk_rx_cons, MSK_RX_RING_CNT); in msk_init_rx_ring()
729 rxd = &sc_if->msk_cdata.msk_rxdesc[prod]; in msk_init_rx_ring()
730 rxd->rx_m = NULL; in msk_init_rx_ring()
731 rxd->rx_le = &rd->msk_rx_ring[prod]; in msk_init_rx_ring()
732 rxd->rx_le->msk_addr = htole32(ETHER_HDR_LEN << 16 | in msk_init_rx_ring()
734 rxd->rx_le->msk_control = htole32(OP_TCPSTART | HW_OWNER); in msk_init_rx_ring()
736 MSK_INC(sc_if->msk_cdata.msk_rx_cons, MSK_RX_RING_CNT); in msk_init_rx_ring()
737 nbuf--; in msk_init_rx_ring()
745 bus_dmamap_sync(sc_if->msk_cdata.msk_rx_ring_tag, in msk_init_rx_ring()
746 sc_if->msk_cdata.msk_rx_ring_map, in msk_init_rx_ring()
750 sc_if->msk_cdata.msk_rx_prod = prod; in msk_init_rx_ring()
751 CSR_WRITE_2(sc_if->msk_softc, in msk_init_rx_ring()
752 Y2_PREF_Q_ADDR(sc_if->msk_rxq, PREF_UNIT_PUT_IDX_REG), in msk_init_rx_ring()
753 (sc_if->msk_cdata.msk_rx_prod + MSK_RX_RING_CNT - 1) % in msk_init_rx_ring()
769 sc_if->msk_cdata.msk_rx_cons = 0; in msk_init_jumbo_rx_ring()
770 sc_if->msk_cdata.msk_rx_prod = 0; in msk_init_jumbo_rx_ring()
771 sc_if->msk_cdata.msk_rx_putwm = MSK_PUT_WM; in msk_init_jumbo_rx_ring()
773 rd = &sc_if->msk_rdata; in msk_init_jumbo_rx_ring()
774 bzero(rd->msk_jumbo_rx_ring, in msk_init_jumbo_rx_ring()
777 rxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[prod]; in msk_init_jumbo_rx_ring()
778 rxd->rx_m = NULL; in msk_init_jumbo_rx_ring()
779 rxd->rx_le = &rd->msk_jumbo_rx_ring[prod]; in msk_init_jumbo_rx_ring()
785 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 && in msk_init_jumbo_rx_ring()
786 (if_getcapenable(sc_if->msk_ifp) & IFCAP_RXCSUM) != 0) { in msk_init_jumbo_rx_ring()
788 rxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[prod]; in msk_init_jumbo_rx_ring()
789 rxd->rx_m = NULL; in msk_init_jumbo_rx_ring()
790 rxd->rx_le = &rd->msk_jumbo_rx_ring[prod]; in msk_init_jumbo_rx_ring()
791 rxd->rx_le->msk_addr = htole32(ETHER_HDR_LEN << 16 | in msk_init_jumbo_rx_ring()
793 rxd->rx_le->msk_control = htole32(OP_TCPSTART | HW_OWNER); in msk_init_jumbo_rx_ring()
795 MSK_INC(sc_if->msk_cdata.msk_rx_cons, MSK_JUMBO_RX_RING_CNT); in msk_init_jumbo_rx_ring()
797 rxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[prod]; in msk_init_jumbo_rx_ring()
798 rxd->rx_m = NULL; in msk_init_jumbo_rx_ring()
799 rxd->rx_le = &rd->msk_jumbo_rx_ring[prod]; in msk_init_jumbo_rx_ring()
800 rxd->rx_le->msk_addr = htole32(ETHER_HDR_LEN << 16 | in msk_init_jumbo_rx_ring()
802 rxd->rx_le->msk_control = htole32(OP_TCPSTART | HW_OWNER); in msk_init_jumbo_rx_ring()
804 MSK_INC(sc_if->msk_cdata.msk_rx_cons, MSK_JUMBO_RX_RING_CNT); in msk_init_jumbo_rx_ring()
805 nbuf--; in msk_init_jumbo_rx_ring()
813 bus_dmamap_sync(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, in msk_init_jumbo_rx_ring()
814 sc_if->msk_cdata.msk_jumbo_rx_ring_map, in msk_init_jumbo_rx_ring()
818 sc_if->msk_cdata.msk_rx_prod = prod; in msk_init_jumbo_rx_ring()
819 CSR_WRITE_2(sc_if->msk_softc, in msk_init_jumbo_rx_ring()
820 Y2_PREF_Q_ADDR(sc_if->msk_rxq, PREF_UNIT_PUT_IDX_REG), in msk_init_jumbo_rx_ring()
821 (sc_if->msk_cdata.msk_rx_prod + MSK_JUMBO_RX_RING_CNT - 1) % in msk_init_jumbo_rx_ring()
835 sc_if->msk_cdata.msk_tso_mtu = 0; in msk_init_tx_ring()
836 sc_if->msk_cdata.msk_last_csum = 0; in msk_init_tx_ring()
837 sc_if->msk_cdata.msk_tx_prod = 0; in msk_init_tx_ring()
838 sc_if->msk_cdata.msk_tx_cons = 0; in msk_init_tx_ring()
839 sc_if->msk_cdata.msk_tx_cnt = 0; in msk_init_tx_ring()
840 sc_if->msk_cdata.msk_tx_high_addr = 0; in msk_init_tx_ring()
842 rd = &sc_if->msk_rdata; in msk_init_tx_ring()
843 bzero(rd->msk_tx_ring, sizeof(struct msk_tx_desc) * MSK_TX_RING_CNT); in msk_init_tx_ring()
845 txd = &sc_if->msk_cdata.msk_txdesc[i]; in msk_init_tx_ring()
846 txd->tx_m = NULL; in msk_init_tx_ring()
847 txd->tx_le = &rd->msk_tx_ring[i]; in msk_init_tx_ring()
850 bus_dmamap_sync(sc_if->msk_cdata.msk_tx_ring_tag, in msk_init_tx_ring()
851 sc_if->msk_cdata.msk_tx_ring_map, in msk_init_tx_ring()
863 rxd = &sc_if->msk_cdata.msk_rxdesc[idx]; in msk_discard_rxbuf()
864 rx_le = rxd->rx_le; in msk_discard_rxbuf()
865 rx_le->msk_control = htole32(OP_ADDR64 | HW_OWNER); in msk_discard_rxbuf()
868 rxd = &sc_if->msk_cdata.msk_rxdesc[idx]; in msk_discard_rxbuf()
869 m = rxd->rx_m; in msk_discard_rxbuf()
870 rx_le = rxd->rx_le; in msk_discard_rxbuf()
871 rx_le->msk_control = htole32(m->m_len | OP_PACKET | HW_OWNER); in msk_discard_rxbuf()
882 rxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[idx]; in msk_discard_jumbo_rxbuf()
883 rx_le = rxd->rx_le; in msk_discard_jumbo_rxbuf()
884 rx_le->msk_control = htole32(OP_ADDR64 | HW_OWNER); in msk_discard_jumbo_rxbuf()
887 rxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[idx]; in msk_discard_jumbo_rxbuf()
888 m = rxd->rx_m; in msk_discard_jumbo_rxbuf()
889 rx_le = rxd->rx_le; in msk_discard_jumbo_rxbuf()
890 rx_le->msk_control = htole32(m->m_len | OP_PACKET | HW_OWNER); in msk_discard_jumbo_rxbuf()
907 m->m_len = m->m_pkthdr.len = MCLBYTES; in msk_newbuf()
908 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) in msk_newbuf()
915 if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_rx_tag, in msk_newbuf()
916 sc_if->msk_cdata.msk_rx_sparemap, m, segs, &nsegs, in msk_newbuf()
923 rxd = &sc_if->msk_cdata.msk_rxdesc[idx]; in msk_newbuf()
925 rx_le = rxd->rx_le; in msk_newbuf()
926 rx_le->msk_addr = htole32(MSK_ADDR_HI(segs[0].ds_addr)); in msk_newbuf()
927 rx_le->msk_control = htole32(OP_ADDR64 | HW_OWNER); in msk_newbuf()
929 rxd = &sc_if->msk_cdata.msk_rxdesc[idx]; in msk_newbuf()
931 if (rxd->rx_m != NULL) { in msk_newbuf()
932 bus_dmamap_sync(sc_if->msk_cdata.msk_rx_tag, rxd->rx_dmamap, in msk_newbuf()
934 bus_dmamap_unload(sc_if->msk_cdata.msk_rx_tag, rxd->rx_dmamap); in msk_newbuf()
935 rxd->rx_m = NULL; in msk_newbuf()
937 map = rxd->rx_dmamap; in msk_newbuf()
938 rxd->rx_dmamap = sc_if->msk_cdata.msk_rx_sparemap; in msk_newbuf()
939 sc_if->msk_cdata.msk_rx_sparemap = map; in msk_newbuf()
940 bus_dmamap_sync(sc_if->msk_cdata.msk_rx_tag, rxd->rx_dmamap, in msk_newbuf()
942 rxd->rx_m = m; in msk_newbuf()
943 rx_le = rxd->rx_le; in msk_newbuf()
944 rx_le->msk_addr = htole32(MSK_ADDR_LO(segs[0].ds_addr)); in msk_newbuf()
945 rx_le->msk_control = in msk_newbuf()
964 m->m_len = m->m_pkthdr.len = MJUM9BYTES; in msk_jumbo_newbuf()
965 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) in msk_jumbo_newbuf()
972 if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_jumbo_rx_tag, in msk_jumbo_newbuf()
973 sc_if->msk_cdata.msk_jumbo_rx_sparemap, m, segs, &nsegs, in msk_jumbo_newbuf()
980 rxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[idx]; in msk_jumbo_newbuf()
982 rx_le = rxd->rx_le; in msk_jumbo_newbuf()
983 rx_le->msk_addr = htole32(MSK_ADDR_HI(segs[0].ds_addr)); in msk_jumbo_newbuf()
984 rx_le->msk_control = htole32(OP_ADDR64 | HW_OWNER); in msk_jumbo_newbuf()
986 rxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[idx]; in msk_jumbo_newbuf()
988 if (rxd->rx_m != NULL) { in msk_jumbo_newbuf()
989 bus_dmamap_sync(sc_if->msk_cdata.msk_jumbo_rx_tag, in msk_jumbo_newbuf()
990 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in msk_jumbo_newbuf()
991 bus_dmamap_unload(sc_if->msk_cdata.msk_jumbo_rx_tag, in msk_jumbo_newbuf()
992 rxd->rx_dmamap); in msk_jumbo_newbuf()
993 rxd->rx_m = NULL; in msk_jumbo_newbuf()
995 map = rxd->rx_dmamap; in msk_jumbo_newbuf()
996 rxd->rx_dmamap = sc_if->msk_cdata.msk_jumbo_rx_sparemap; in msk_jumbo_newbuf()
997 sc_if->msk_cdata.msk_jumbo_rx_sparemap = map; in msk_jumbo_newbuf()
998 bus_dmamap_sync(sc_if->msk_cdata.msk_jumbo_rx_tag, rxd->rx_dmamap, in msk_jumbo_newbuf()
1000 rxd->rx_m = m; in msk_jumbo_newbuf()
1001 rx_le = rxd->rx_le; in msk_jumbo_newbuf()
1002 rx_le->msk_addr = htole32(MSK_ADDR_LO(segs[0].ds_addr)); in msk_jumbo_newbuf()
1003 rx_le->msk_control = in msk_jumbo_newbuf()
1022 mii = device_get_softc(sc_if->msk_miibus); in msk_mediachange()
1044 mii = device_get_softc(sc_if->msk_miibus); in msk_mediastatus()
1047 ifmr->ifm_active = mii->mii_media_active; in msk_mediastatus()
1048 ifmr->ifm_status = mii->mii_media_status; in msk_mediastatus()
1067 if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) in msk_ioctl()
1069 else if (if_getmtu(ifp) != ifr->ifr_mtu) { in msk_ioctl()
1070 if (ifr->ifr_mtu > ETHERMTU) { in msk_ioctl()
1071 if ((sc_if->msk_flags & MSK_FLAG_JUMBO) == 0) { in msk_ioctl()
1076 if ((sc_if->msk_flags & in msk_ioctl()
1085 if_setmtu(ifp, ifr->ifr_mtu); in msk_ioctl()
1097 ((if_getflags(ifp) ^ sc_if->msk_if_flags) & in msk_ioctl()
1100 else if ((sc_if->msk_flags & MSK_FLAG_DETACH) == 0) in msk_ioctl()
1104 sc_if->msk_if_flags = if_getflags(ifp); in msk_ioctl()
1116 mii = device_get_softc(sc_if->msk_miibus); in msk_ioctl()
1117 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); in msk_ioctl()
1122 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in msk_ioctl()
1134 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0) in msk_ioctl()
1160 (sc_if->msk_flags & MSK_FLAG_JUMBO_NOCSUM) != 0) { in msk_ioctl()
1190 if (vendor == mp->msk_vendorid && devid == mp->msk_deviceid) { in mskc_probe()
1191 device_set_desc(dev, mp->msk_name); in mskc_probe()
1206 sc->msk_ramsize = CSR_READ_1(sc, B2_E_0) * 4; in mskc_setup_rambuffer()
1208 device_printf(sc->msk_dev, in mskc_setup_rambuffer()
1209 "RAM buffer size : %dKB\n", sc->msk_ramsize); in mskc_setup_rambuffer()
1210 if (sc->msk_ramsize == 0) in mskc_setup_rambuffer()
1213 sc->msk_pflags |= MSK_FLAG_RAMBUF; in mskc_setup_rambuffer()
1219 sc->msk_rxqsize = rounddown((sc->msk_ramsize * 1024 * 2) / 3, 1024); in mskc_setup_rambuffer()
1220 sc->msk_txqsize = (sc->msk_ramsize * 1024) - sc->msk_rxqsize; in mskc_setup_rambuffer()
1221 for (i = 0, next = 0; i < sc->msk_num_port; i++) { in mskc_setup_rambuffer()
1222 sc->msk_rxqstart[i] = next; in mskc_setup_rambuffer()
1223 sc->msk_rxqend[i] = next + sc->msk_rxqsize - 1; in mskc_setup_rambuffer()
1224 next = sc->msk_rxqend[i] + 1; in mskc_setup_rambuffer()
1225 sc->msk_txqstart[i] = next; in mskc_setup_rambuffer()
1226 sc->msk_txqend[i] = next + sc->msk_txqsize - 1; in mskc_setup_rambuffer()
1227 next = sc->msk_txqend[i] + 1; in mskc_setup_rambuffer()
1229 device_printf(sc->msk_dev, in mskc_setup_rambuffer()
1231 sc->msk_rxqsize / 1024, sc->msk_rxqstart[i], in mskc_setup_rambuffer()
1232 sc->msk_rxqend[i]); in mskc_setup_rambuffer()
1233 device_printf(sc->msk_dev, in mskc_setup_rambuffer()
1235 sc->msk_txqsize / 1024, sc->msk_txqstart[i], in mskc_setup_rambuffer()
1236 sc->msk_txqend[i]); in mskc_setup_rambuffer()
1258 if (sc->msk_hw_id == CHIP_ID_YUKON_XL && in msk_phy_power()
1259 sc->msk_hw_rev > CHIP_REV_YU_XL_A1) { in msk_phy_power()
1272 if (sc->msk_hw_id == CHIP_ID_YUKON_XL) { in msk_phy_power()
1273 if (sc->msk_hw_rev > CHIP_REV_YU_XL_A1) { in msk_phy_power()
1276 if (sc->msk_num_port > 1) in msk_phy_power()
1280 if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U || in msk_phy_power()
1281 sc->msk_hw_id == CHIP_ID_YUKON_EX || in msk_phy_power()
1282 sc->msk_hw_id >= CHIP_ID_YUKON_FE_P) { in msk_phy_power()
1296 * Yukon EC Ultra & Yukon EX. in msk_phy_power()
1306 for (i = 0; i < sc->msk_num_port; i++) { in msk_phy_power()
1316 if (sc->msk_hw_id == CHIP_ID_YUKON_XL && in msk_phy_power()
1317 sc->msk_hw_rev > CHIP_REV_YU_XL_A1) { in msk_phy_power()
1319 if (sc->msk_num_port > 1) in msk_phy_power()
1327 if (sc->msk_hw_id == CHIP_ID_YUKON_XL && in msk_phy_power()
1328 sc->msk_hw_rev > CHIP_REV_YU_XL_A1) { in msk_phy_power()
1354 if (sc->msk_hw_id >= CHIP_ID_YUKON_XL && in mskc_reset()
1355 sc->msk_hw_id <= CHIP_ID_YUKON_SUPR) { in mskc_reset()
1356 if (sc->msk_hw_id == CHIP_ID_YUKON_EX || in mskc_reset()
1357 sc->msk_hw_id == CHIP_ID_YUKON_SUPR) { in mskc_reset()
1380 status = pci_read_config(sc->msk_dev, PCIR_STATUS, 2); in mskc_reset()
1383 pci_write_config(sc->msk_dev, PCIR_STATUS, status | in mskc_reset()
1388 switch (sc->msk_bustype) { in mskc_reset()
1394 sc->msk_intrmask &= ~Y2_IS_HW_ERR; in mskc_reset()
1395 sc->msk_intrhwemask &= ~Y2_IS_PCI_EXP; in mskc_reset()
1401 val = pci_read_config(sc->msk_dev, PCIR_CACHELNSZ, 1); in mskc_reset()
1403 pci_write_config(sc->msk_dev, PCIR_CACHELNSZ, 2, 1); in mskc_reset()
1404 if (sc->msk_bustype == MSK_PCIX_BUS) { in mskc_reset()
1406 val = pci_read_config(sc->msk_dev, PCI_OUR_REG_1, 4); in mskc_reset()
1408 pci_write_config(sc->msk_dev, PCI_OUR_REG_1, val, 4); in mskc_reset()
1416 for (i = 0; i < sc->msk_num_port; i++) { in mskc_reset()
1424 if (sc->msk_hw_id == CHIP_ID_YUKON_EX || in mskc_reset()
1425 sc->msk_hw_id == CHIP_ID_YUKON_SUPR) in mskc_reset()
1431 if (sc->msk_hw_id == CHIP_ID_YUKON_SUPR && in mskc_reset()
1432 sc->msk_hw_rev > CHIP_REV_YU_SU_B0) in mskc_reset()
1434 if (sc->msk_hw_id == CHIP_ID_YUKON_OPT && sc->msk_hw_rev == 0) { in mskc_reset()
1458 if (sc->msk_hw_id == CHIP_ID_YUKON_XL || in mskc_reset()
1459 sc->msk_hw_id == CHIP_ID_YUKON_EC || in mskc_reset()
1460 sc->msk_hw_id == CHIP_ID_YUKON_FE) in mskc_reset()
1464 for (i = 0; initram > 0 && i < sc->msk_num_port; i++) { in mskc_reset()
1500 * On dual port PCI-X card, there is an problem where status in mskc_reset()
1503 if (sc->msk_pcixcap != 0 && sc->msk_num_port > 1) { in mskc_reset()
1506 pcix_cmd = pci_read_config(sc->msk_dev, in mskc_reset()
1507 sc->msk_pcixcap + PCIXR_COMMAND, 2); in mskc_reset()
1511 pci_write_config(sc->msk_dev, in mskc_reset()
1512 sc->msk_pcixcap + PCIXR_COMMAND, pcix_cmd, 2); in mskc_reset()
1515 if (sc->msk_expcap != 0) { in mskc_reset()
1517 if (pci_get_max_read_req(sc->msk_dev) == 512) in mskc_reset()
1518 pci_set_max_read_req(sc->msk_dev, 2048); in mskc_reset()
1522 bzero(sc->msk_stat_ring, in mskc_reset()
1523 sizeof(struct msk_stat_desc) * sc->msk_stat_count); in mskc_reset()
1524 sc->msk_stat_cons = 0; in mskc_reset()
1525 bus_dmamap_sync(sc->msk_stat_tag, sc->msk_stat_map, in mskc_reset()
1530 addr = sc->msk_stat_ring_paddr; in mskc_reset()
1534 CSR_WRITE_2(sc, STAT_LAST_IDX, sc->msk_stat_count - 1); in mskc_reset()
1535 if (sc->msk_hw_id == CHIP_ID_YUKON_EC && in mskc_reset()
1536 sc->msk_hw_rev == CHIP_REV_YU_EC_A1) { in mskc_reset()
1545 if (sc->msk_hw_id == CHIP_ID_YUKON_XL && in mskc_reset()
1546 sc->msk_hw_rev == CHIP_REV_YU_XL_A0) in mskc_reset()
1579 model_name[sc->msk_hw_id - CHIP_ID_YUKON_XL], sc->msk_hw_id, in msk_probe()
1580 sc->msk_hw_rev); in msk_probe()
1602 port = mmd->port; in msk_attach()
1604 sc_if->msk_if_dev = dev; in msk_attach()
1605 sc_if->msk_port = port; in msk_attach()
1606 sc_if->msk_softc = sc; in msk_attach()
1607 sc_if->msk_flags = sc->msk_pflags; in msk_attach()
1608 sc->msk_if[port] = sc_if; in msk_attach()
1611 sc_if->msk_txq = Q_XA1; in msk_attach()
1612 sc_if->msk_txsq = Q_XS1; in msk_attach()
1613 sc_if->msk_rxq = Q_R1; in msk_attach()
1615 sc_if->msk_txq = Q_XA2; in msk_attach()
1616 sc_if->msk_txsq = Q_XS2; in msk_attach()
1617 sc_if->msk_rxq = Q_R2; in msk_attach()
1620 callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0); in msk_attach()
1627 ifp = sc_if->msk_ifp = if_alloc(IFT_ETHER); in msk_attach()
1636 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 && in msk_attach()
1637 sc->msk_hw_id != CHIP_ID_YUKON_XL) in msk_attach()
1639 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0 && in msk_attach()
1640 (sc_if->msk_flags & MSK_FLAG_NORX_CSUM) == 0) in msk_attach()
1647 if_setsendqlen(ifp, MSK_TX_RING_CNT - 1); in msk_attach()
1671 if ((sc_if->msk_flags & MSK_FLAG_NOHWVLAN) == 0) { in msk_attach()
1683 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0 && in msk_attach()
1684 (sc_if->msk_flags & MSK_FLAG_NORX_CSUM) == 0) in msk_attach()
1692 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0) in msk_attach()
1706 error = mii_attach(dev, &sc_if->msk_miibus, ifp, msk_mediachange, in msk_attach()
1708 mmd->mii_flags); in msk_attach()
1710 device_printf(sc_if->msk_if_dev, "attaching PHYs failed\n"); in msk_attach()
1719 sc->msk_if[port] = NULL; in msk_attach()
1738 sc->msk_dev = dev; in mskc_attach()
1739 mtx_init(&sc->msk_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in mskc_attach()
1749 sc->msk_res_spec = msk_res_spec_io; in mskc_attach()
1751 sc->msk_res_spec = msk_res_spec_mem; in mskc_attach()
1753 sc->msk_irq_spec = msk_irq_spec_legacy; in mskc_attach()
1754 error = bus_alloc_resources(dev, sc->msk_res_spec, sc->msk_res); in mskc_attach()
1756 if (sc->msk_res_spec == msk_res_spec_mem) in mskc_attach()
1757 sc->msk_res_spec = msk_res_spec_io; in mskc_attach()
1759 sc->msk_res_spec = msk_res_spec_mem; in mskc_attach()
1760 error = bus_alloc_resources(dev, sc->msk_res_spec, sc->msk_res); in mskc_attach()
1763 sc->msk_res_spec == msk_res_spec_mem ? "memory" : in mskc_attach()
1765 mtx_destroy(&sc->msk_mtx); in mskc_attach()
1774 sc->msk_hw_id = CSR_READ_1(sc, B2_CHIP_ID); in mskc_attach()
1775 sc->msk_hw_rev = (CSR_READ_1(sc, B2_MAC_CFG) >> 4) & 0x0f; in mskc_attach()
1777 if (sc->msk_hw_id < CHIP_ID_YUKON_XL || in mskc_attach()
1778 sc->msk_hw_id > CHIP_ID_YUKON_OPT || in mskc_attach()
1779 sc->msk_hw_id == CHIP_ID_YUKON_UNKNOWN) { in mskc_attach()
1781 sc->msk_hw_id, sc->msk_hw_rev); in mskc_attach()
1782 mtx_destroy(&sc->msk_mtx); in mskc_attach()
1790 &sc->msk_process_limit, 0, sysctl_hw_msk_proc_limit, "I", in mskc_attach()
1793 sc->msk_process_limit = MSK_PROC_DEFAULT; in mskc_attach()
1795 "process_limit", &sc->msk_process_limit); in mskc_attach()
1797 if (sc->msk_process_limit < MSK_PROC_MIN || in mskc_attach()
1798 sc->msk_process_limit > MSK_PROC_MAX) { in mskc_attach()
1801 sc->msk_process_limit = MSK_PROC_DEFAULT; in mskc_attach()
1805 sc->msk_int_holdoff = MSK_INT_HOLDOFF_DEFAULT; in mskc_attach()
1808 "int_holdoff", CTLFLAG_RW, &sc->msk_int_holdoff, 0, in mskc_attach()
1811 "int_holdoff", &sc->msk_int_holdoff); in mskc_attach()
1813 sc->msk_pmd = CSR_READ_1(sc, B2_PMD_TYP); in mskc_attach()
1815 sc->msk_num_port = 1; in mskc_attach()
1819 sc->msk_num_port++; in mskc_attach()
1823 if (pci_find_cap(sc->msk_dev, PCIY_EXPRESS, &reg) == 0) { in mskc_attach()
1824 sc->msk_bustype = MSK_PEX_BUS; in mskc_attach()
1825 sc->msk_expcap = reg; in mskc_attach()
1826 } else if (pci_find_cap(sc->msk_dev, PCIY_PCIX, &reg) == 0) { in mskc_attach()
1827 sc->msk_bustype = MSK_PCIX_BUS; in mskc_attach()
1828 sc->msk_pcixcap = reg; in mskc_attach()
1830 sc->msk_bustype = MSK_PCI_BUS; in mskc_attach()
1832 switch (sc->msk_hw_id) { in mskc_attach()
1834 sc->msk_clock = 125; /* 125 MHz */ in mskc_attach()
1835 sc->msk_pflags |= MSK_FLAG_JUMBO; in mskc_attach()
1838 sc->msk_clock = 125; /* 125 MHz */ in mskc_attach()
1839 sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_JUMBO_NOCSUM; in mskc_attach()
1842 sc->msk_clock = 125; /* 125 MHz */ in mskc_attach()
1843 sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_DESCV2 | in mskc_attach()
1849 if (sc->msk_hw_rev == CHIP_REV_YU_EX_B0) in mskc_attach()
1850 sc->msk_pflags &= ~MSK_FLAG_AUTOTX_CSUM; in mskc_attach()
1852 * Yukon Extreme A0 could not use store-and-forward in mskc_attach()
1856 if (sc->msk_hw_rev == CHIP_REV_YU_EX_A0) in mskc_attach()
1857 sc->msk_pflags |= MSK_FLAG_JUMBO_NOCSUM; in mskc_attach()
1860 sc->msk_clock = 100; /* 100 MHz */ in mskc_attach()
1861 sc->msk_pflags |= MSK_FLAG_FASTETHER; in mskc_attach()
1864 sc->msk_clock = 50; /* 50 MHz */ in mskc_attach()
1865 sc->msk_pflags |= MSK_FLAG_FASTETHER | MSK_FLAG_DESCV2 | in mskc_attach()
1867 if (sc->msk_hw_rev == CHIP_REV_YU_FE_P_A0) { in mskc_attach()
1878 sc->msk_pflags |= MSK_FLAG_NOHWVLAN | in mskc_attach()
1883 sc->msk_clock = 156; /* 156 MHz */ in mskc_attach()
1884 sc->msk_pflags |= MSK_FLAG_JUMBO; in mskc_attach()
1887 sc->msk_clock = 125; /* 125 MHz */ in mskc_attach()
1888 sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_DESCV2 | in mskc_attach()
1892 sc->msk_clock = 125; /* 125 MHz */ in mskc_attach()
1893 sc->msk_pflags |= MSK_FLAG_JUMBO; in mskc_attach()
1896 sc->msk_clock = 125; /* 125 MHz */ in mskc_attach()
1897 sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_DESCV2; in mskc_attach()
1900 sc->msk_clock = 156; /* 156 MHz */ in mskc_attach()
1914 sc->msk_pflags |= MSK_FLAG_MSI; in mskc_attach()
1915 sc->msk_irq_spec = msk_irq_spec_msi; in mskc_attach()
1921 error = bus_alloc_resources(dev, sc->msk_irq_spec, sc->msk_irq); in mskc_attach()
1931 sc->msk_intrmask = Y2_IS_HW_ERR | Y2_IS_STAT_BMU; in mskc_attach()
1932 sc->msk_intrhwemask = Y2_IS_TIST_OV | Y2_IS_MST_ERR | in mskc_attach()
1941 sc->msk_devs[MSK_PORT_A] = device_add_child(dev, "msk", DEVICE_UNIT_ANY); in mskc_attach()
1942 if (sc->msk_devs[MSK_PORT_A] == NULL) { in mskc_attach()
1948 mmd->port = MSK_PORT_A; in mskc_attach()
1949 mmd->pmd = sc->msk_pmd; in mskc_attach()
1950 mmd->mii_flags |= MIIF_DOPAUSE; in mskc_attach()
1951 if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S') in mskc_attach()
1952 mmd->mii_flags |= MIIF_HAVEFIBER; in mskc_attach()
1953 if (sc->msk_pmd == 'P') in mskc_attach()
1954 mmd->mii_flags |= MIIF_HAVEFIBER | MIIF_MACPRIV0; in mskc_attach()
1955 device_set_ivars(sc->msk_devs[MSK_PORT_A], mmd); in mskc_attach()
1957 if (sc->msk_num_port > 1) { in mskc_attach()
1958 sc->msk_devs[MSK_PORT_B] = device_add_child(dev, "msk", DEVICE_UNIT_ANY); in mskc_attach()
1959 if (sc->msk_devs[MSK_PORT_B] == NULL) { in mskc_attach()
1966 mmd->port = MSK_PORT_B; in mskc_attach()
1967 mmd->pmd = sc->msk_pmd; in mskc_attach()
1968 if (sc->msk_pmd == 'L' || sc->msk_pmd == 'S') in mskc_attach()
1969 mmd->mii_flags |= MIIF_HAVEFIBER; in mskc_attach()
1970 if (sc->msk_pmd == 'P') in mskc_attach()
1971 mmd->mii_flags |= MIIF_HAVEFIBER | MIIF_MACPRIV0; in mskc_attach()
1972 device_set_ivars(sc->msk_devs[MSK_PORT_B], mmd); in mskc_attach()
1978 error = bus_setup_intr(dev, sc->msk_irq[0], INTR_TYPE_NET | in mskc_attach()
1979 INTR_MPSAFE, NULL, msk_intr, sc, &sc->msk_intrhand); in mskc_attach()
2006 KASSERT(mtx_initialized(&sc_if->msk_softc->msk_mtx), in msk_detach()
2010 ifp = sc_if->msk_ifp; in msk_detach()
2013 sc_if->msk_flags |= MSK_FLAG_DETACH; in msk_detach()
2017 callout_drain(&sc_if->msk_tick_ch); in msk_detach()
2027 sc = sc_if->msk_softc; in msk_detach()
2028 sc->msk_if[sc_if->msk_port] = NULL; in msk_detach()
2048 KASSERT(mtx_initialized(&sc->msk_mtx), ("msk mutex not initialized")); in mskc_detach()
2066 if (sc->msk_intrhand) { in mskc_detach()
2067 bus_teardown_intr(dev, sc->msk_irq[0], sc->msk_intrhand); in mskc_detach()
2068 sc->msk_intrhand = NULL; in mskc_detach()
2070 bus_release_resources(dev, sc->msk_irq_spec, sc->msk_irq); in mskc_detach()
2071 if ((sc->msk_pflags & MSK_FLAG_MSI) != 0) in mskc_detach()
2073 bus_release_resources(dev, sc->msk_res_spec, sc->msk_res); in mskc_detach()
2074 mtx_destroy(&sc->msk_mtx); in mskc_detach()
2098 ctx->msk_busaddr = segs[0].ds_addr; in msk_dmamap_cb()
2112 * is 4096. For dual-port controllers, the number of status in msk_status_dma_alloc()
2118 sc->msk_stat_count = count; in msk_status_dma_alloc()
2121 bus_get_dma_tag(sc->msk_dev), /* parent */ in msk_status_dma_alloc()
2131 &sc->msk_stat_tag); in msk_status_dma_alloc()
2133 device_printf(sc->msk_dev, in msk_status_dma_alloc()
2139 error = bus_dmamem_alloc(sc->msk_stat_tag, in msk_status_dma_alloc()
2140 (void **)&sc->msk_stat_ring, BUS_DMA_WAITOK | BUS_DMA_COHERENT | in msk_status_dma_alloc()
2141 BUS_DMA_ZERO, &sc->msk_stat_map); in msk_status_dma_alloc()
2143 device_printf(sc->msk_dev, in msk_status_dma_alloc()
2149 error = bus_dmamap_load(sc->msk_stat_tag, sc->msk_stat_map, in msk_status_dma_alloc()
2150 sc->msk_stat_ring, stat_sz, msk_dmamap_cb, &ctx, BUS_DMA_NOWAIT); in msk_status_dma_alloc()
2152 device_printf(sc->msk_dev, in msk_status_dma_alloc()
2156 sc->msk_stat_ring_paddr = ctx.msk_busaddr; in msk_status_dma_alloc()
2166 if (sc->msk_stat_tag) { in msk_status_dma_free()
2167 if (sc->msk_stat_ring_paddr) { in msk_status_dma_free()
2168 bus_dmamap_unload(sc->msk_stat_tag, sc->msk_stat_map); in msk_status_dma_free()
2169 sc->msk_stat_ring_paddr = 0; in msk_status_dma_free()
2171 if (sc->msk_stat_ring) { in msk_status_dma_free()
2172 bus_dmamem_free(sc->msk_stat_tag, in msk_status_dma_free()
2173 sc->msk_stat_ring, sc->msk_stat_map); in msk_status_dma_free()
2174 sc->msk_stat_ring = NULL; in msk_status_dma_free()
2176 bus_dma_tag_destroy(sc->msk_stat_tag); in msk_status_dma_free()
2177 sc->msk_stat_tag = NULL; in msk_status_dma_free()
2192 bus_get_dma_tag(sc_if->msk_if_dev), /* parent */ in msk_txrx_dma_alloc()
2202 &sc_if->msk_cdata.msk_parent_tag); in msk_txrx_dma_alloc()
2204 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2209 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ in msk_txrx_dma_alloc()
2219 &sc_if->msk_cdata.msk_tx_ring_tag); in msk_txrx_dma_alloc()
2221 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2227 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ in msk_txrx_dma_alloc()
2237 &sc_if->msk_cdata.msk_rx_ring_tag); in msk_txrx_dma_alloc()
2239 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2245 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ in msk_txrx_dma_alloc()
2255 &sc_if->msk_cdata.msk_tx_tag); in msk_txrx_dma_alloc()
2257 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2267 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) in msk_txrx_dma_alloc()
2270 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ in msk_txrx_dma_alloc()
2280 &sc_if->msk_cdata.msk_rx_tag); in msk_txrx_dma_alloc()
2282 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2288 error = bus_dmamem_alloc(sc_if->msk_cdata.msk_tx_ring_tag, in msk_txrx_dma_alloc()
2289 (void **)&sc_if->msk_rdata.msk_tx_ring, BUS_DMA_WAITOK | in msk_txrx_dma_alloc()
2290 BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc_if->msk_cdata.msk_tx_ring_map); in msk_txrx_dma_alloc()
2292 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2298 error = bus_dmamap_load(sc_if->msk_cdata.msk_tx_ring_tag, in msk_txrx_dma_alloc()
2299 sc_if->msk_cdata.msk_tx_ring_map, sc_if->msk_rdata.msk_tx_ring, in msk_txrx_dma_alloc()
2302 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2306 sc_if->msk_rdata.msk_tx_ring_paddr = ctx.msk_busaddr; in msk_txrx_dma_alloc()
2309 error = bus_dmamem_alloc(sc_if->msk_cdata.msk_rx_ring_tag, in msk_txrx_dma_alloc()
2310 (void **)&sc_if->msk_rdata.msk_rx_ring, BUS_DMA_WAITOK | in msk_txrx_dma_alloc()
2311 BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc_if->msk_cdata.msk_rx_ring_map); in msk_txrx_dma_alloc()
2313 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2319 error = bus_dmamap_load(sc_if->msk_cdata.msk_rx_ring_tag, in msk_txrx_dma_alloc()
2320 sc_if->msk_cdata.msk_rx_ring_map, sc_if->msk_rdata.msk_rx_ring, in msk_txrx_dma_alloc()
2323 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2327 sc_if->msk_rdata.msk_rx_ring_paddr = ctx.msk_busaddr; in msk_txrx_dma_alloc()
2331 txd = &sc_if->msk_cdata.msk_txdesc[i]; in msk_txrx_dma_alloc()
2332 txd->tx_m = NULL; in msk_txrx_dma_alloc()
2333 txd->tx_dmamap = NULL; in msk_txrx_dma_alloc()
2334 error = bus_dmamap_create(sc_if->msk_cdata.msk_tx_tag, 0, in msk_txrx_dma_alloc()
2335 &txd->tx_dmamap); in msk_txrx_dma_alloc()
2337 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2343 if ((error = bus_dmamap_create(sc_if->msk_cdata.msk_rx_tag, 0, in msk_txrx_dma_alloc()
2344 &sc_if->msk_cdata.msk_rx_sparemap)) != 0) { in msk_txrx_dma_alloc()
2345 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2350 rxd = &sc_if->msk_cdata.msk_rxdesc[i]; in msk_txrx_dma_alloc()
2351 rxd->rx_m = NULL; in msk_txrx_dma_alloc()
2352 rxd->rx_dmamap = NULL; in msk_txrx_dma_alloc()
2353 error = bus_dmamap_create(sc_if->msk_cdata.msk_rx_tag, 0, in msk_txrx_dma_alloc()
2354 &rxd->rx_dmamap); in msk_txrx_dma_alloc()
2356 device_printf(sc_if->msk_if_dev, in msk_txrx_dma_alloc()
2374 if (jumbo_disable != 0 || (sc_if->msk_flags & MSK_FLAG_JUMBO) == 0) { in msk_rx_dma_jalloc()
2375 sc_if->msk_flags &= ~MSK_FLAG_JUMBO; in msk_rx_dma_jalloc()
2376 device_printf(sc_if->msk_if_dev, in msk_rx_dma_jalloc()
2381 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ in msk_rx_dma_jalloc()
2391 &sc_if->msk_cdata.msk_jumbo_rx_ring_tag); in msk_rx_dma_jalloc()
2393 device_printf(sc_if->msk_if_dev, in msk_rx_dma_jalloc()
2403 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) in msk_rx_dma_jalloc()
2406 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ in msk_rx_dma_jalloc()
2416 &sc_if->msk_cdata.msk_jumbo_rx_tag); in msk_rx_dma_jalloc()
2418 device_printf(sc_if->msk_if_dev, in msk_rx_dma_jalloc()
2424 error = bus_dmamem_alloc(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, in msk_rx_dma_jalloc()
2425 (void **)&sc_if->msk_rdata.msk_jumbo_rx_ring, in msk_rx_dma_jalloc()
2427 &sc_if->msk_cdata.msk_jumbo_rx_ring_map); in msk_rx_dma_jalloc()
2429 device_printf(sc_if->msk_if_dev, in msk_rx_dma_jalloc()
2435 error = bus_dmamap_load(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, in msk_rx_dma_jalloc()
2436 sc_if->msk_cdata.msk_jumbo_rx_ring_map, in msk_rx_dma_jalloc()
2437 sc_if->msk_rdata.msk_jumbo_rx_ring, MSK_JUMBO_RX_RING_SZ, in msk_rx_dma_jalloc()
2440 device_printf(sc_if->msk_if_dev, in msk_rx_dma_jalloc()
2444 sc_if->msk_rdata.msk_jumbo_rx_ring_paddr = ctx.msk_busaddr; in msk_rx_dma_jalloc()
2447 if ((error = bus_dmamap_create(sc_if->msk_cdata.msk_jumbo_rx_tag, 0, in msk_rx_dma_jalloc()
2448 &sc_if->msk_cdata.msk_jumbo_rx_sparemap)) != 0) { in msk_rx_dma_jalloc()
2449 device_printf(sc_if->msk_if_dev, in msk_rx_dma_jalloc()
2454 jrxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[i]; in msk_rx_dma_jalloc()
2455 jrxd->rx_m = NULL; in msk_rx_dma_jalloc()
2456 jrxd->rx_dmamap = NULL; in msk_rx_dma_jalloc()
2457 error = bus_dmamap_create(sc_if->msk_cdata.msk_jumbo_rx_tag, 0, in msk_rx_dma_jalloc()
2458 &jrxd->rx_dmamap); in msk_rx_dma_jalloc()
2460 device_printf(sc_if->msk_if_dev, in msk_rx_dma_jalloc()
2470 device_printf(sc_if->msk_if_dev, "disabling jumbo frame support " in msk_rx_dma_jalloc()
2472 sc_if->msk_flags &= ~MSK_FLAG_JUMBO; in msk_rx_dma_jalloc()
2484 if (sc_if->msk_cdata.msk_tx_ring_tag) { in msk_txrx_dma_free()
2485 if (sc_if->msk_rdata.msk_tx_ring_paddr) in msk_txrx_dma_free()
2486 bus_dmamap_unload(sc_if->msk_cdata.msk_tx_ring_tag, in msk_txrx_dma_free()
2487 sc_if->msk_cdata.msk_tx_ring_map); in msk_txrx_dma_free()
2488 if (sc_if->msk_rdata.msk_tx_ring) in msk_txrx_dma_free()
2489 bus_dmamem_free(sc_if->msk_cdata.msk_tx_ring_tag, in msk_txrx_dma_free()
2490 sc_if->msk_rdata.msk_tx_ring, in msk_txrx_dma_free()
2491 sc_if->msk_cdata.msk_tx_ring_map); in msk_txrx_dma_free()
2492 sc_if->msk_rdata.msk_tx_ring = NULL; in msk_txrx_dma_free()
2493 sc_if->msk_rdata.msk_tx_ring_paddr = 0; in msk_txrx_dma_free()
2494 bus_dma_tag_destroy(sc_if->msk_cdata.msk_tx_ring_tag); in msk_txrx_dma_free()
2495 sc_if->msk_cdata.msk_tx_ring_tag = NULL; in msk_txrx_dma_free()
2498 if (sc_if->msk_cdata.msk_rx_ring_tag) { in msk_txrx_dma_free()
2499 if (sc_if->msk_rdata.msk_rx_ring_paddr) in msk_txrx_dma_free()
2500 bus_dmamap_unload(sc_if->msk_cdata.msk_rx_ring_tag, in msk_txrx_dma_free()
2501 sc_if->msk_cdata.msk_rx_ring_map); in msk_txrx_dma_free()
2502 if (sc_if->msk_rdata.msk_rx_ring) in msk_txrx_dma_free()
2503 bus_dmamem_free(sc_if->msk_cdata.msk_rx_ring_tag, in msk_txrx_dma_free()
2504 sc_if->msk_rdata.msk_rx_ring, in msk_txrx_dma_free()
2505 sc_if->msk_cdata.msk_rx_ring_map); in msk_txrx_dma_free()
2506 sc_if->msk_rdata.msk_rx_ring = NULL; in msk_txrx_dma_free()
2507 sc_if->msk_rdata.msk_rx_ring_paddr = 0; in msk_txrx_dma_free()
2508 bus_dma_tag_destroy(sc_if->msk_cdata.msk_rx_ring_tag); in msk_txrx_dma_free()
2509 sc_if->msk_cdata.msk_rx_ring_tag = NULL; in msk_txrx_dma_free()
2512 if (sc_if->msk_cdata.msk_tx_tag) { in msk_txrx_dma_free()
2514 txd = &sc_if->msk_cdata.msk_txdesc[i]; in msk_txrx_dma_free()
2515 if (txd->tx_dmamap) { in msk_txrx_dma_free()
2516 bus_dmamap_destroy(sc_if->msk_cdata.msk_tx_tag, in msk_txrx_dma_free()
2517 txd->tx_dmamap); in msk_txrx_dma_free()
2518 txd->tx_dmamap = NULL; in msk_txrx_dma_free()
2521 bus_dma_tag_destroy(sc_if->msk_cdata.msk_tx_tag); in msk_txrx_dma_free()
2522 sc_if->msk_cdata.msk_tx_tag = NULL; in msk_txrx_dma_free()
2525 if (sc_if->msk_cdata.msk_rx_tag) { in msk_txrx_dma_free()
2527 rxd = &sc_if->msk_cdata.msk_rxdesc[i]; in msk_txrx_dma_free()
2528 if (rxd->rx_dmamap) { in msk_txrx_dma_free()
2529 bus_dmamap_destroy(sc_if->msk_cdata.msk_rx_tag, in msk_txrx_dma_free()
2530 rxd->rx_dmamap); in msk_txrx_dma_free()
2531 rxd->rx_dmamap = NULL; in msk_txrx_dma_free()
2534 if (sc_if->msk_cdata.msk_rx_sparemap) { in msk_txrx_dma_free()
2535 bus_dmamap_destroy(sc_if->msk_cdata.msk_rx_tag, in msk_txrx_dma_free()
2536 sc_if->msk_cdata.msk_rx_sparemap); in msk_txrx_dma_free()
2537 sc_if->msk_cdata.msk_rx_sparemap = 0; in msk_txrx_dma_free()
2539 bus_dma_tag_destroy(sc_if->msk_cdata.msk_rx_tag); in msk_txrx_dma_free()
2540 sc_if->msk_cdata.msk_rx_tag = NULL; in msk_txrx_dma_free()
2542 if (sc_if->msk_cdata.msk_parent_tag) { in msk_txrx_dma_free()
2543 bus_dma_tag_destroy(sc_if->msk_cdata.msk_parent_tag); in msk_txrx_dma_free()
2544 sc_if->msk_cdata.msk_parent_tag = NULL; in msk_txrx_dma_free()
2555 if (sc_if->msk_cdata.msk_jumbo_rx_ring_tag) { in msk_rx_dma_jfree()
2556 if (sc_if->msk_rdata.msk_jumbo_rx_ring_paddr) in msk_rx_dma_jfree()
2557 bus_dmamap_unload(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, in msk_rx_dma_jfree()
2558 sc_if->msk_cdata.msk_jumbo_rx_ring_map); in msk_rx_dma_jfree()
2559 if (sc_if->msk_rdata.msk_jumbo_rx_ring) in msk_rx_dma_jfree()
2560 bus_dmamem_free(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, in msk_rx_dma_jfree()
2561 sc_if->msk_rdata.msk_jumbo_rx_ring, in msk_rx_dma_jfree()
2562 sc_if->msk_cdata.msk_jumbo_rx_ring_map); in msk_rx_dma_jfree()
2563 sc_if->msk_rdata.msk_jumbo_rx_ring = NULL; in msk_rx_dma_jfree()
2564 sc_if->msk_rdata.msk_jumbo_rx_ring_paddr = 0; in msk_rx_dma_jfree()
2565 bus_dma_tag_destroy(sc_if->msk_cdata.msk_jumbo_rx_ring_tag); in msk_rx_dma_jfree()
2566 sc_if->msk_cdata.msk_jumbo_rx_ring_tag = NULL; in msk_rx_dma_jfree()
2569 if (sc_if->msk_cdata.msk_jumbo_rx_tag) { in msk_rx_dma_jfree()
2571 jrxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[i]; in msk_rx_dma_jfree()
2572 if (jrxd->rx_dmamap) { in msk_rx_dma_jfree()
2574 sc_if->msk_cdata.msk_jumbo_rx_tag, in msk_rx_dma_jfree()
2575 jrxd->rx_dmamap); in msk_rx_dma_jfree()
2576 jrxd->rx_dmamap = NULL; in msk_rx_dma_jfree()
2579 if (sc_if->msk_cdata.msk_jumbo_rx_sparemap) { in msk_rx_dma_jfree()
2580 bus_dmamap_destroy(sc_if->msk_cdata.msk_jumbo_rx_tag, in msk_rx_dma_jfree()
2581 sc_if->msk_cdata.msk_jumbo_rx_sparemap); in msk_rx_dma_jfree()
2582 sc_if->msk_cdata.msk_jumbo_rx_sparemap = 0; in msk_rx_dma_jfree()
2584 bus_dma_tag_destroy(sc_if->msk_cdata.msk_jumbo_rx_tag); in msk_rx_dma_jfree()
2585 sc_if->msk_cdata.msk_jumbo_rx_tag = NULL; in msk_rx_dma_jfree()
2605 if (((sc_if->msk_flags & MSK_FLAG_AUTOTX_CSUM) == 0 && in msk_encap()
2606 (m->m_pkthdr.csum_flags & MSK_CSUM_FEATURES) != 0) || in msk_encap()
2607 ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 && in msk_encap()
2608 (m->m_pkthdr.csum_flags & CSUM_TSO) != 0)) { in msk_encap()
2641 if (eh->ether_type == htons(ETHERTYPE_VLAN)) { in msk_encap()
2655 offset += (ip->ip_hl << 2); in msk_encap()
2657 if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in msk_encap()
2664 offset += (tcp->th_off << 2); in msk_encap()
2665 } else if ((sc_if->msk_flags & MSK_FLAG_AUTOTX_CSUM) == 0 && in msk_encap()
2666 (m->m_pkthdr.len < MSK_MIN_FRAMELEN) && in msk_encap()
2667 (m->m_pkthdr.csum_flags & CSUM_TCP) != 0) { in msk_encap()
2688 *(uint16_t *)(m->m_data + offset + in msk_encap()
2689 m->m_pkthdr.csum_data) = in_cksum_skip(m, in msk_encap()
2690 m->m_pkthdr.len, offset); in msk_encap()
2691 m->m_pkthdr.csum_flags &= ~CSUM_TCP; in msk_encap()
2696 prod = sc_if->msk_cdata.msk_tx_prod; in msk_encap()
2697 txd = &sc_if->msk_cdata.msk_txdesc[prod]; in msk_encap()
2699 map = txd->tx_dmamap; in msk_encap()
2700 error = bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_tx_tag, map, in msk_encap()
2710 error = bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_tx_tag, in msk_encap()
2726 if (sc_if->msk_cdata.msk_tx_cnt + nseg >= in msk_encap()
2727 (MSK_TX_RING_CNT - MSK_RESERVED_TX_DESC_CNT)) { in msk_encap()
2728 bus_dmamap_unload(sc_if->msk_cdata.msk_tx_tag, map); in msk_encap()
2737 if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in msk_encap()
2738 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0) in msk_encap()
2739 tso_mtu = m->m_pkthdr.tso_segsz; in msk_encap()
2741 tso_mtu = offset + m->m_pkthdr.tso_segsz; in msk_encap()
2742 if (tso_mtu != sc_if->msk_cdata.msk_tso_mtu) { in msk_encap()
2743 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2744 tx_le->msk_addr = htole32(tso_mtu); in msk_encap()
2745 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0) in msk_encap()
2746 tx_le->msk_control = htole32(OP_MSS | HW_OWNER); in msk_encap()
2748 tx_le->msk_control = in msk_encap()
2750 sc_if->msk_cdata.msk_tx_cnt++; in msk_encap()
2752 sc_if->msk_cdata.msk_tso_mtu = tso_mtu; in msk_encap()
2757 if ((m->m_flags & M_VLANTAG) != 0) { in msk_encap()
2759 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2760 tx_le->msk_addr = htole32(0); in msk_encap()
2761 tx_le->msk_control = htole32(OP_VLAN | HW_OWNER | in msk_encap()
2762 htons(m->m_pkthdr.ether_vtag)); in msk_encap()
2763 sc_if->msk_cdata.msk_tx_cnt++; in msk_encap()
2766 tx_le->msk_control |= htole32(OP_VLAN | in msk_encap()
2767 htons(m->m_pkthdr.ether_vtag)); in msk_encap()
2772 if (tso == 0 && (m->m_pkthdr.csum_flags & MSK_CSUM_FEATURES) != 0) { in msk_encap()
2773 if ((sc_if->msk_flags & MSK_FLAG_AUTOTX_CSUM) != 0) in msk_encap()
2777 if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0) in msk_encap()
2780 csum = (tcp_offset + m->m_pkthdr.csum_data) & 0xffff; in msk_encap()
2783 if (csum != sc_if->msk_cdata.msk_last_csum) { in msk_encap()
2784 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2785 tx_le->msk_addr = htole32(csum); in msk_encap()
2786 tx_le->msk_control = htole32(1 << 16 | in msk_encap()
2788 sc_if->msk_cdata.msk_tx_cnt++; in msk_encap()
2790 sc_if->msk_cdata.msk_last_csum = csum; in msk_encap()
2797 sc_if->msk_cdata.msk_tx_high_addr) { in msk_encap()
2798 sc_if->msk_cdata.msk_tx_high_addr = in msk_encap()
2800 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2801 tx_le->msk_addr = htole32(MSK_ADDR_HI(txsegs[0].ds_addr)); in msk_encap()
2802 tx_le->msk_control = htole32(OP_ADDR64 | HW_OWNER); in msk_encap()
2803 sc_if->msk_cdata.msk_tx_cnt++; in msk_encap()
2808 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2809 tx_le->msk_addr = htole32(MSK_ADDR_LO(txsegs[0].ds_addr)); in msk_encap()
2811 tx_le->msk_control = htole32(txsegs[0].ds_len | control | in msk_encap()
2814 tx_le->msk_control = htole32(txsegs[0].ds_len | control | in msk_encap()
2816 sc_if->msk_cdata.msk_tx_cnt++; in msk_encap()
2820 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2823 sc_if->msk_cdata.msk_tx_high_addr) { in msk_encap()
2824 sc_if->msk_cdata.msk_tx_high_addr = in msk_encap()
2826 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2827 tx_le->msk_addr = in msk_encap()
2829 tx_le->msk_control = htole32(OP_ADDR64 | HW_OWNER); in msk_encap()
2830 sc_if->msk_cdata.msk_tx_cnt++; in msk_encap()
2832 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2835 tx_le->msk_addr = htole32(MSK_ADDR_LO(txsegs[i].ds_addr)); in msk_encap()
2836 tx_le->msk_control = htole32(txsegs[i].ds_len | control | in msk_encap()
2838 sc_if->msk_cdata.msk_tx_cnt++; in msk_encap()
2842 sc_if->msk_cdata.msk_tx_prod = prod; in msk_encap()
2845 prod = (prod + MSK_TX_RING_CNT - 1) % MSK_TX_RING_CNT; in msk_encap()
2846 tx_le = &sc_if->msk_rdata.msk_tx_ring[prod]; in msk_encap()
2847 tx_le->msk_control |= htole32(EOP); in msk_encap()
2850 tx_le = &sc_if->msk_rdata.msk_tx_ring[si]; in msk_encap()
2851 tx_le->msk_control |= htole32(HW_OWNER); in msk_encap()
2853 txd = &sc_if->msk_cdata.msk_txdesc[prod]; in msk_encap()
2854 map = txd_last->tx_dmamap; in msk_encap()
2855 txd_last->tx_dmamap = txd->tx_dmamap; in msk_encap()
2856 txd->tx_dmamap = map; in msk_encap()
2857 txd->tx_m = m; in msk_encap()
2860 bus_dmamap_sync(sc_if->msk_cdata.msk_tx_tag, map, BUS_DMASYNC_PREWRITE); in msk_encap()
2861 bus_dmamap_sync(sc_if->msk_cdata.msk_tx_ring_tag, in msk_encap()
2862 sc_if->msk_cdata.msk_tx_ring_map, in msk_encap()
2890 IFF_DRV_RUNNING || (sc_if->msk_flags & MSK_FLAG_LINK) == 0) in msk_start_locked()
2894 sc_if->msk_cdata.msk_tx_cnt < in msk_start_locked()
2895 (MSK_TX_RING_CNT - MSK_RESERVED_TX_DESC_CNT); ) { in msk_start_locked()
2922 CSR_WRITE_2(sc_if->msk_softc, in msk_start_locked()
2923 Y2_PREF_Q_ADDR(sc_if->msk_txq, PREF_UNIT_PUT_IDX_REG), in msk_start_locked()
2924 sc_if->msk_cdata.msk_tx_prod); in msk_start_locked()
2927 sc_if->msk_watchdog_timer = MSK_TX_TIMEOUT; in msk_start_locked()
2938 if (sc_if->msk_watchdog_timer == 0 || --sc_if->msk_watchdog_timer) in msk_watchdog()
2940 ifp = sc_if->msk_ifp; in msk_watchdog()
2941 if ((sc_if->msk_flags & MSK_FLAG_LINK) == 0) { in msk_watchdog()
2943 if_printf(sc_if->msk_ifp, "watchdog timeout " in msk_watchdog()
2967 for (i = 0; i < sc->msk_num_port; i++) { in mskc_shutdown()
2968 if (sc->msk_if[i] != NULL && sc->msk_if[i]->msk_ifp != NULL && in mskc_shutdown()
2969 ((if_getdrvflags(sc->msk_if[i]->msk_ifp) & in mskc_shutdown()
2971 msk_stop(sc->msk_if[i]); in mskc_shutdown()
2990 for (i = 0; i < sc->msk_num_port; i++) { in mskc_suspend()
2991 if (sc->msk_if[i] != NULL && sc->msk_if[i]->msk_ifp != NULL && in mskc_suspend()
2992 ((if_getdrvflags(sc->msk_if[i]->msk_ifp) & in mskc_suspend()
2994 msk_stop(sc->msk_if[i]); in mskc_suspend()
3007 sc->msk_pflags |= MSK_FLAG_SUSPEND; in mskc_suspend()
3026 for (i = 0; i < sc->msk_num_port; i++) { in mskc_resume()
3027 if (sc->msk_if[i] != NULL && sc->msk_if[i]->msk_ifp != NULL && in mskc_resume()
3028 ((if_getflags(sc->msk_if[i]->msk_ifp) & IFF_UP) != 0)) { in mskc_resume()
3029 if_setdrvflagbits(sc->msk_if[i]->msk_ifp, 0, in mskc_resume()
3031 msk_init_locked(sc->msk_if[i]); in mskc_resume()
3034 sc->msk_pflags &= ~MSK_FLAG_SUSPEND; in mskc_resume()
3049 dst = src - 3; in msk_fixup_rx()
3051 for (i = 0; i < (m->m_len / sizeof(uint16_t) + 1); i++) in msk_fixup_rx()
3054 m->m_data -= (MSK_RX_BUF_ALIGN - ETHER_ALIGN); in msk_fixup_rx()
3067 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0) { in msk_rxcsum()
3069 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in msk_rxcsum()
3071 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in msk_rxcsum()
3074 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | in msk_rxcsum()
3076 m->m_pkthdr.csum_data = 0xffff; in msk_rxcsum()
3091 if ((sc_if->msk_csum & 0xFFFF) != (sc_if->msk_csum >> 16)) { in msk_rxcsum()
3093 device_printf(sc_if->msk_if_dev, in msk_rxcsum()
3097 pktlen = m->m_pkthdr.len; in msk_rxcsum()
3101 if (eh->ether_type != htons(ETHERTYPE_IP)) in msk_rxcsum()
3104 if (ip->ip_v != IPVERSION) in msk_rxcsum()
3107 hlen = ip->ip_hl << 2; in msk_rxcsum()
3108 pktlen -= sizeof(struct ether_header); in msk_rxcsum()
3111 if (ntohs(ip->ip_len) < hlen) in msk_rxcsum()
3113 if (ntohs(ip->ip_len) != pktlen) in msk_rxcsum()
3115 if (ip->ip_off & htons(IP_MF | IP_OFFMASK)) in msk_rxcsum()
3118 switch (ip->ip_p) { in msk_rxcsum()
3127 if (uh->uh_sum == 0) in msk_rxcsum()
3133 csum = bswap16(sc_if->msk_csum & 0xFFFF); in msk_rxcsum()
3135 len = hlen - sizeof(struct ip); in msk_rxcsum()
3138 for (; len > 0; len -= sizeof(uint16_t), opts++) { in msk_rxcsum()
3139 temp32 = csum - *opts; in msk_rxcsum()
3144 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; in msk_rxcsum()
3145 m->m_pkthdr.csum_data = csum; in msk_rxcsum()
3157 ifp = sc_if->msk_ifp; in msk_rxeof()
3161 cons = sc_if->msk_cdata.msk_rx_cons; in msk_rxeof()
3166 rxlen -= ETHER_VLAN_ENCAP_LEN; in msk_rxeof()
3167 if ((sc_if->msk_flags & MSK_FLAG_NORXCHK) != 0) { in msk_rxeof()
3178 } else if (len > sc_if->msk_framesize || in msk_rxeof()
3181 /* Don't count flow-control packet as errors. */ in msk_rxeof()
3188 rxd = &sc_if->msk_cdata.msk_rxdesc[(cons + 1) % in msk_rxeof()
3191 rxd = &sc_if->msk_cdata.msk_rxdesc[cons]; in msk_rxeof()
3193 m = rxd->rx_m; in msk_rxeof()
3200 m->m_pkthdr.rcvif = ifp; in msk_rxeof()
3201 m->m_pkthdr.len = m->m_len = len; in msk_rxeof()
3203 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) in msk_rxeof()
3212 m->m_pkthdr.ether_vtag = sc_if->msk_vtag; in msk_rxeof()
3213 m->m_flags |= M_VLANTAG; in msk_rxeof()
3220 MSK_RX_INC(sc_if->msk_cdata.msk_rx_cons, MSK_RX_RING_CNT); in msk_rxeof()
3221 MSK_RX_INC(sc_if->msk_cdata.msk_rx_prod, MSK_RX_RING_CNT); in msk_rxeof()
3233 ifp = sc_if->msk_ifp; in msk_jumbo_rxeof()
3237 cons = sc_if->msk_cdata.msk_rx_cons; in msk_jumbo_rxeof()
3242 rxlen -= ETHER_VLAN_ENCAP_LEN; in msk_jumbo_rxeof()
3243 if (len > sc_if->msk_framesize || in msk_jumbo_rxeof()
3246 /* Don't count flow-control packet as errors. */ in msk_jumbo_rxeof()
3253 jrxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[(cons + 1) % in msk_jumbo_rxeof()
3256 jrxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[cons]; in msk_jumbo_rxeof()
3258 m = jrxd->rx_m; in msk_jumbo_rxeof()
3265 m->m_pkthdr.rcvif = ifp; in msk_jumbo_rxeof()
3266 m->m_pkthdr.len = m->m_len = len; in msk_jumbo_rxeof()
3268 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) in msk_jumbo_rxeof()
3277 m->m_pkthdr.ether_vtag = sc_if->msk_vtag; in msk_jumbo_rxeof()
3278 m->m_flags |= M_VLANTAG; in msk_jumbo_rxeof()
3285 MSK_RX_INC(sc_if->msk_cdata.msk_rx_cons, MSK_JUMBO_RX_RING_CNT); in msk_jumbo_rxeof()
3286 MSK_RX_INC(sc_if->msk_cdata.msk_rx_prod, MSK_JUMBO_RX_RING_CNT); in msk_jumbo_rxeof()
3300 ifp = sc_if->msk_ifp; in msk_txeof()
3302 bus_dmamap_sync(sc_if->msk_cdata.msk_tx_ring_tag, in msk_txeof()
3303 sc_if->msk_cdata.msk_tx_ring_map, in msk_txeof()
3309 cons = sc_if->msk_cdata.msk_tx_cons; in msk_txeof()
3312 if (sc_if->msk_cdata.msk_tx_cnt <= 0) in msk_txeof()
3315 cur_tx = &sc_if->msk_rdata.msk_tx_ring[cons]; in msk_txeof()
3316 control = le32toh(cur_tx->msk_control); in msk_txeof()
3317 sc_if->msk_cdata.msk_tx_cnt--; in msk_txeof()
3321 txd = &sc_if->msk_cdata.msk_txdesc[cons]; in msk_txeof()
3322 bus_dmamap_sync(sc_if->msk_cdata.msk_tx_tag, txd->tx_dmamap, in msk_txeof()
3324 bus_dmamap_unload(sc_if->msk_cdata.msk_tx_tag, txd->tx_dmamap); in msk_txeof()
3327 KASSERT(txd->tx_m != NULL, ("%s: freeing NULL mbuf!", in msk_txeof()
3329 m_freem(txd->tx_m); in msk_txeof()
3330 txd->tx_m = NULL; in msk_txeof()
3334 sc_if->msk_cdata.msk_tx_cons = cons; in msk_txeof()
3335 if (sc_if->msk_cdata.msk_tx_cnt == 0) in msk_txeof()
3336 sc_if->msk_watchdog_timer = 0; in msk_txeof()
3352 mii = device_get_softc(sc_if->msk_miibus); in msk_tick()
3355 if ((sc_if->msk_flags & MSK_FLAG_LINK) == 0) in msk_tick()
3356 msk_miibus_statchg(sc_if->msk_if_dev); in msk_tick()
3358 msk_handle_events(sc_if->msk_softc); in msk_tick()
3361 callout_reset(&sc_if->msk_tick_ch, hz, msk_tick, sc_if); in msk_tick()
3373 device_printf(sc_if->msk_if_dev, in msk_intr_phy()
3383 sc = sc_if->msk_softc; in msk_intr_gmac()
3384 status = CSR_READ_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_SRC)); in msk_intr_gmac()
3388 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), in msk_intr_gmac()
3392 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), in msk_intr_gmac()
3394 device_printf(sc_if->msk_if_dev, "Tx FIFO underrun!\n"); in msk_intr_gmac()
3413 sc = sc_if->msk_softc; in msk_handle_hwerr()
3415 device_printf(sc_if->msk_if_dev, in msk_handle_hwerr()
3418 CSR_WRITE_2(sc, SELECT_RAM_BUFFER(sc_if->msk_port, B3_RI_CTRL), in msk_handle_hwerr()
3422 device_printf(sc_if->msk_if_dev, in msk_handle_hwerr()
3425 CSR_WRITE_2(sc, SELECT_RAM_BUFFER(sc_if->msk_port, B3_RI_CTRL), in msk_handle_hwerr()
3429 device_printf(sc_if->msk_if_dev, "Tx MAC parity error\n"); in msk_handle_hwerr()
3431 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), in msk_handle_hwerr()
3435 device_printf(sc_if->msk_if_dev, "Rx parity error\n"); in msk_handle_hwerr()
3437 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_CSR), BMU_CLR_IRQ_PAR); in msk_handle_hwerr()
3440 device_printf(sc_if->msk_if_dev, "TCP segmentation error\n"); in msk_handle_hwerr()
3442 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), BMU_CLR_IRQ_TCP); in msk_handle_hwerr()
3464 device_printf(sc->msk_dev, in msk_intr_hwerr()
3472 device_printf(sc->msk_dev, in msk_intr_hwerr()
3475 device_printf(sc->msk_dev, in msk_intr_hwerr()
3478 v16 = pci_read_config(sc->msk_dev, PCIR_STATUS, 2); in msk_intr_hwerr()
3480 pci_write_config(sc->msk_dev, PCIR_STATUS, v16 | in msk_intr_hwerr()
3501 device_printf(sc->msk_dev, in msk_intr_hwerr()
3513 sc->msk_intrhwemask &= ~Y2_IS_PCI_EXP; in msk_intr_hwerr()
3515 sc->msk_intrhwemask); in msk_intr_hwerr()
3525 if ((status & Y2_HWE_L1_MASK) != 0 && sc->msk_if[MSK_PORT_A] != NULL) in msk_intr_hwerr()
3526 msk_handle_hwerr(sc->msk_if[MSK_PORT_A], status); in msk_intr_hwerr()
3527 if ((status & Y2_HWE_L2_MASK) != 0 && sc->msk_if[MSK_PORT_B] != NULL) in msk_intr_hwerr()
3528 msk_handle_hwerr(sc->msk_if[MSK_PORT_B], status >> 8); in msk_intr_hwerr()
3536 sc = sc_if->msk_softc; in msk_rxput()
3537 if (sc_if->msk_framesize > (MCLBYTES - MSK_RX_BUF_ALIGN)) in msk_rxput()
3539 sc_if->msk_cdata.msk_jumbo_rx_ring_tag, in msk_rxput()
3540 sc_if->msk_cdata.msk_jumbo_rx_ring_map, in msk_rxput()
3544 sc_if->msk_cdata.msk_rx_ring_tag, in msk_rxput()
3545 sc_if->msk_cdata.msk_rx_ring_map, in msk_rxput()
3547 CSR_WRITE_2(sc, Y2_PREF_Q_ADDR(sc_if->msk_rxq, in msk_rxput()
3548 PREF_UNIT_PUT_IDX_REG), sc_if->msk_cdata.msk_rx_prod); in msk_rxput()
3560 if (sc->msk_stat_cons == CSR_READ_2(sc, STAT_PUT_IDX)) in msk_handle_events()
3564 bus_dmamap_sync(sc->msk_stat_tag, sc->msk_stat_map, in msk_handle_events()
3569 cons = sc->msk_stat_cons; in msk_handle_events()
3571 sd = &sc->msk_stat_ring[cons]; in msk_handle_events()
3572 control = le32toh(sd->msk_control); in msk_handle_events()
3576 sd->msk_control = htole32(control); in msk_handle_events()
3577 status = le32toh(sd->msk_status); in msk_handle_events()
3580 sc_if = sc->msk_if[port]; in msk_handle_events()
3582 device_printf(sc->msk_dev, "invalid port opcode " in msk_handle_events()
3589 sc_if->msk_vtag = ntohs(len); in msk_handle_events()
3592 sc_if->msk_vtag = ntohs(len); in msk_handle_events()
3595 sc_if->msk_csum = status; in msk_handle_events()
3598 if (!(if_getdrvflags(sc_if->msk_ifp) & IFF_DRV_RUNNING)) in msk_handle_events()
3600 if (sc_if->msk_framesize > in msk_handle_events()
3601 (MCLBYTES - MSK_RX_BUF_ALIGN)) in msk_handle_events()
3613 if (rxput[port] >= sc_if->msk_cdata.msk_rx_putwm) { in msk_handle_events()
3619 if (sc->msk_if[MSK_PORT_A] != NULL) in msk_handle_events()
3620 msk_txeof(sc->msk_if[MSK_PORT_A], in msk_handle_events()
3622 if (sc->msk_if[MSK_PORT_B] != NULL) in msk_handle_events()
3623 msk_txeof(sc->msk_if[MSK_PORT_B], in msk_handle_events()
3630 device_printf(sc->msk_dev, "unhandled opcode 0x%08x\n", in msk_handle_events()
3634 MSK_INC(cons, sc->msk_stat_count); in msk_handle_events()
3635 if (rxprog > sc->msk_process_limit) in msk_handle_events()
3639 sc->msk_stat_cons = cons; in msk_handle_events()
3640 bus_dmamap_sync(sc->msk_stat_tag, sc->msk_stat_map, in msk_handle_events()
3644 msk_rxput(sc->msk_if[MSK_PORT_A]); in msk_handle_events()
3646 msk_rxput(sc->msk_if[MSK_PORT_B]); in msk_handle_events()
3648 return (sc->msk_stat_cons != CSR_READ_2(sc, STAT_PUT_IDX)); in msk_handle_events()
3666 (sc->msk_pflags & MSK_FLAG_SUSPEND) != 0 || in msk_intr()
3667 (status & sc->msk_intrmask) == 0) { in msk_intr()
3673 sc_if0 = sc->msk_if[MSK_PORT_A]; in msk_intr()
3674 sc_if1 = sc->msk_if[MSK_PORT_B]; in msk_intr()
3677 ifp0 = sc_if0->msk_ifp; in msk_intr()
3679 ifp1 = sc_if1->msk_ifp; in msk_intr()
3690 device_printf(sc->msk_dev, "Rx descriptor error\n"); in msk_intr()
3691 sc->msk_intrmask &= ~(Y2_IS_CHK_RX1 | Y2_IS_CHK_RX2); in msk_intr()
3692 CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask); in msk_intr()
3696 device_printf(sc->msk_dev, "Tx descriptor error\n"); in msk_intr()
3697 sc->msk_intrmask &= ~(Y2_IS_CHK_TXA1 | Y2_IS_CHK_TXA2); in msk_intr()
3698 CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask); in msk_intr()
3727 ifp = sc_if->msk_ifp; in msk_set_tx_stfwd()
3728 sc = sc_if->msk_softc; in msk_set_tx_stfwd()
3729 if ((sc->msk_hw_id == CHIP_ID_YUKON_EX && in msk_set_tx_stfwd()
3730 sc->msk_hw_rev != CHIP_REV_YU_EX_A0) || in msk_set_tx_stfwd()
3731 sc->msk_hw_id >= CHIP_ID_YUKON_SUPR) { in msk_set_tx_stfwd()
3732 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), in msk_set_tx_stfwd()
3738 MR_ADDR(sc_if->msk_port, TX_GMF_AE_THR), in msk_set_tx_stfwd()
3741 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), in msk_set_tx_stfwd()
3744 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), in msk_set_tx_stfwd()
3773 ifp = sc_if->msk_ifp; in msk_init_locked()
3774 sc = sc_if->msk_softc; in msk_init_locked()
3775 mii = device_get_softc(sc_if->msk_miibus); in msk_init_locked()
3785 sc_if->msk_framesize = ETHERMTU; in msk_init_locked()
3787 sc_if->msk_framesize = if_getmtu(ifp); in msk_init_locked()
3788 sc_if->msk_framesize += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; in msk_init_locked()
3790 (sc_if->msk_flags & MSK_FLAG_JUMBO_NOCSUM) != 0) { in msk_init_locked()
3796 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_SET); in msk_init_locked()
3797 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_CLR); in msk_init_locked()
3798 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_F_LOOPB_OFF); in msk_init_locked()
3799 if (sc->msk_hw_id == CHIP_ID_YUKON_EX || in msk_init_locked()
3800 sc->msk_hw_id == CHIP_ID_YUKON_SUPR) in msk_init_locked()
3801 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), in msk_init_locked()
3806 * Initialize GMAC first such that speed/duplex/flow-control in msk_init_locked()
3809 GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, 0); in msk_init_locked()
3812 CSR_READ_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_SRC)); in msk_init_locked()
3818 GMAC_WRITE_2(sc, sc_if->msk_port, GM_RX_CTRL, GM_RXCR_CRC_DIS); in msk_init_locked()
3821 GMAC_WRITE_2(sc, sc_if->msk_port, GM_TX_CTRL, TX_COL_THR(TX_COL_DEF)); in msk_init_locked()
3824 GMAC_WRITE_2(sc, sc_if->msk_port, GM_TX_FLOW_CTRL, 0xffff); in msk_init_locked()
3827 GMAC_WRITE_2(sc, sc_if->msk_port, GM_TX_PARAM, in msk_init_locked()
3836 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SERIAL_MODE, gmac); in msk_init_locked()
3840 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SRC_ADDR_1L, in msk_init_locked()
3842 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SRC_ADDR_1M, in msk_init_locked()
3844 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SRC_ADDR_1H, in msk_init_locked()
3846 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SRC_ADDR_2L, in msk_init_locked()
3848 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SRC_ADDR_2M, in msk_init_locked()
3850 GMAC_WRITE_2(sc, sc_if->msk_port, GM_SRC_ADDR_2H, in msk_init_locked()
3854 GMAC_WRITE_2(sc, sc_if->msk_port, GM_TX_IRQ_MSK, 0); in msk_init_locked()
3855 GMAC_WRITE_2(sc, sc_if->msk_port, GM_RX_IRQ_MSK, 0); in msk_init_locked()
3856 GMAC_WRITE_2(sc, sc_if->msk_port, GM_TR_IRQ_MSK, 0); in msk_init_locked()
3859 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), GMF_RST_SET); in msk_init_locked()
3860 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), GMF_RST_CLR); in msk_init_locked()
3862 if (sc->msk_hw_id == CHIP_ID_YUKON_FE_P || in msk_init_locked()
3863 sc->msk_hw_id == CHIP_ID_YUKON_EX) in msk_init_locked()
3865 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), reg); in msk_init_locked()
3870 if (sc->msk_hw_id == CHIP_ID_YUKON_XL) { in msk_init_locked()
3871 /* Clear flush mask - HW bug. */ in msk_init_locked()
3872 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_FL_MSK), 0); in msk_init_locked()
3875 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_FL_MSK), in msk_init_locked()
3884 /* Another magic for Yukon FE+ - From Linux. */ in msk_init_locked()
3885 if (sc->msk_hw_id == CHIP_ID_YUKON_FE_P && in msk_init_locked()
3886 sc->msk_hw_rev == CHIP_REV_YU_FE_P_A0) in msk_init_locked()
3888 CSR_WRITE_2(sc, MR_ADDR(sc_if->msk_port, RX_GMF_FL_THR), reg); in msk_init_locked()
3891 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), GMF_RST_SET); in msk_init_locked()
3892 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), GMF_RST_CLR); in msk_init_locked()
3893 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), GMF_OPER_ON); in msk_init_locked()
3898 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) { in msk_init_locked()
3900 CSR_WRITE_2(sc, MR_ADDR(sc_if->msk_port, RX_GMF_LP_THR), in msk_init_locked()
3902 CSR_WRITE_2(sc, MR_ADDR(sc_if->msk_port, RX_GMF_UP_THR), in msk_init_locked()
3904 /* Configure store-and-forward for Tx. */ in msk_init_locked()
3908 if (sc->msk_hw_id == CHIP_ID_YUKON_FE_P && in msk_init_locked()
3909 sc->msk_hw_rev == CHIP_REV_YU_FE_P_A0) { in msk_init_locked()
3910 /* Disable dynamic watermark - from Linux. */ in msk_init_locked()
3911 reg = CSR_READ_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_EA)); in msk_init_locked()
3913 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_EA), reg); in msk_init_locked()
3920 CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, TXA_CTRL), in msk_init_locked()
3923 CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, TXA_CTRL), TXA_ENA_ARB); in msk_init_locked()
3929 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_txsq, RB_CTRL), RB_RST_SET); in msk_init_locked()
3932 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), BMU_CLR_RESET); in msk_init_locked()
3933 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), BMU_OPER_INIT); in msk_init_locked()
3934 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), BMU_FIFO_OP_ON); in msk_init_locked()
3935 CSR_WRITE_2(sc, Q_ADDR(sc_if->msk_txq, Q_WM), MSK_BMU_TX_WM); in msk_init_locked()
3936 switch (sc->msk_hw_id) { in msk_init_locked()
3938 if (sc->msk_hw_rev == CHIP_REV_YU_EC_U_A0) { in msk_init_locked()
3939 /* Fix for Yukon-EC Ultra: set BMU FIFO level */ in msk_init_locked()
3940 CSR_WRITE_2(sc, Q_ADDR(sc_if->msk_txq, Q_AL), in msk_init_locked()
3949 if (sc->msk_hw_rev == CHIP_REV_YU_EX_B0) in msk_init_locked()
3950 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_F), in msk_init_locked()
3956 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_CSR), BMU_CLR_RESET); in msk_init_locked()
3957 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_CSR), BMU_OPER_INIT); in msk_init_locked()
3958 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_CSR), BMU_FIFO_OP_ON); in msk_init_locked()
3959 CSR_WRITE_2(sc, Q_ADDR(sc_if->msk_rxq, Q_WM), MSK_BMU_RX_WM); in msk_init_locked()
3960 if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U && in msk_init_locked()
3961 sc->msk_hw_rev >= CHIP_REV_YU_EC_U_A1) { in msk_init_locked()
3963 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_F), F_M_RX_RAM_DIS); in msk_init_locked()
3966 msk_set_prefetch(sc, sc_if->msk_txq, in msk_init_locked()
3967 sc_if->msk_rdata.msk_tx_ring_paddr, MSK_TX_RING_CNT - 1); in msk_init_locked()
3972 if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 && in msk_init_locked()
3977 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_CSR), reg); in msk_init_locked()
3978 if (sc_if->msk_framesize > (MCLBYTES - MSK_RX_BUF_ALIGN)) { in msk_init_locked()
3979 msk_set_prefetch(sc, sc_if->msk_rxq, in msk_init_locked()
3980 sc_if->msk_rdata.msk_jumbo_rx_ring_paddr, in msk_init_locked()
3981 MSK_JUMBO_RX_RING_CNT - 1); in msk_init_locked()
3984 msk_set_prefetch(sc, sc_if->msk_rxq, in msk_init_locked()
3985 sc_if->msk_rdata.msk_rx_ring_paddr, in msk_init_locked()
3986 MSK_RX_RING_CNT - 1); in msk_init_locked()
3990 device_printf(sc_if->msk_if_dev, in msk_init_locked()
3995 if (sc->msk_hw_id == CHIP_ID_YUKON_EX || in msk_init_locked()
3996 sc->msk_hw_id == CHIP_ID_YUKON_SUPR) { in msk_init_locked()
3997 /* Disable flushing of non-ASF packets. */ in msk_init_locked()
3998 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), in msk_init_locked()
4003 if (sc_if->msk_port == MSK_PORT_A) { in msk_init_locked()
4004 sc->msk_intrmask |= Y2_IS_PORT_A; in msk_init_locked()
4005 sc->msk_intrhwemask |= Y2_HWE_L1_MASK; in msk_init_locked()
4007 sc->msk_intrmask |= Y2_IS_PORT_B; in msk_init_locked()
4008 sc->msk_intrhwemask |= Y2_HWE_L2_MASK; in msk_init_locked()
4011 CSR_WRITE_4(sc, B2_IRQM_MSK, sc->msk_intrmask); in msk_init_locked()
4012 if (sc->msk_int_holdoff > 0) { in msk_init_locked()
4015 MSK_USECS(sc, sc->msk_int_holdoff)); in msk_init_locked()
4017 MSK_USECS(sc, sc->msk_int_holdoff)); in msk_init_locked()
4021 CSR_WRITE_4(sc, B0_HWE_IMSK, sc->msk_intrhwemask); in msk_init_locked()
4023 CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask); in msk_init_locked()
4029 sc_if->msk_flags &= ~MSK_FLAG_LINK; in msk_init_locked()
4032 callout_reset(&sc_if->msk_tick_ch, hz, msk_tick, sc_if); in msk_init_locked()
4041 sc = sc_if->msk_softc; in msk_set_rambuffer()
4042 if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) in msk_set_rambuffer()
4046 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_rxq, RB_CTRL), RB_RST_CLR); in msk_set_rambuffer()
4047 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_rxq, RB_START), in msk_set_rambuffer()
4048 sc->msk_rxqstart[sc_if->msk_port] / 8); in msk_set_rambuffer()
4049 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_rxq, RB_END), in msk_set_rambuffer()
4050 sc->msk_rxqend[sc_if->msk_port] / 8); in msk_set_rambuffer()
4051 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_rxq, RB_WP), in msk_set_rambuffer()
4052 sc->msk_rxqstart[sc_if->msk_port] / 8); in msk_set_rambuffer()
4053 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_rxq, RB_RP), in msk_set_rambuffer()
4054 sc->msk_rxqstart[sc_if->msk_port] / 8); in msk_set_rambuffer()
4056 utpp = (sc->msk_rxqend[sc_if->msk_port] + 1 - in msk_set_rambuffer()
4057 sc->msk_rxqstart[sc_if->msk_port] - MSK_RB_ULPP) / 8; in msk_set_rambuffer()
4058 ltpp = (sc->msk_rxqend[sc_if->msk_port] + 1 - in msk_set_rambuffer()
4059 sc->msk_rxqstart[sc_if->msk_port] - MSK_RB_LLPP_B) / 8; in msk_set_rambuffer()
4060 if (sc->msk_rxqsize < MSK_MIN_RXQ_SIZE) in msk_set_rambuffer()
4061 ltpp += (MSK_RB_LLPP_B - MSK_RB_LLPP_S) / 8; in msk_set_rambuffer()
4062 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_rxq, RB_RX_UTPP), utpp); in msk_set_rambuffer()
4063 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_rxq, RB_RX_LTPP), ltpp); in msk_set_rambuffer()
4066 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_rxq, RB_CTRL), RB_ENA_OP_MD); in msk_set_rambuffer()
4067 CSR_READ_1(sc, RB_ADDR(sc_if->msk_rxq, RB_CTRL)); in msk_set_rambuffer()
4070 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_txq, RB_CTRL), RB_RST_CLR); in msk_set_rambuffer()
4071 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_txq, RB_START), in msk_set_rambuffer()
4072 sc->msk_txqstart[sc_if->msk_port] / 8); in msk_set_rambuffer()
4073 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_txq, RB_END), in msk_set_rambuffer()
4074 sc->msk_txqend[sc_if->msk_port] / 8); in msk_set_rambuffer()
4075 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_txq, RB_WP), in msk_set_rambuffer()
4076 sc->msk_txqstart[sc_if->msk_port] / 8); in msk_set_rambuffer()
4077 CSR_WRITE_4(sc, RB_ADDR(sc_if->msk_txq, RB_RP), in msk_set_rambuffer()
4078 sc->msk_txqstart[sc_if->msk_port] / 8); in msk_set_rambuffer()
4080 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_txq, RB_CTRL), RB_ENA_STFWD); in msk_set_rambuffer()
4081 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_txq, RB_CTRL), RB_ENA_OP_MD); in msk_set_rambuffer()
4082 CSR_READ_1(sc, RB_ADDR(sc_if->msk_txq, RB_CTRL)); in msk_set_rambuffer()
4122 sc = sc_if->msk_softc; in msk_stop()
4123 ifp = sc_if->msk_ifp; in msk_stop()
4125 callout_stop(&sc_if->msk_tick_ch); in msk_stop()
4126 sc_if->msk_watchdog_timer = 0; in msk_stop()
4129 if (sc_if->msk_port == MSK_PORT_A) { in msk_stop()
4130 sc->msk_intrmask &= ~Y2_IS_PORT_A; in msk_stop()
4131 sc->msk_intrhwemask &= ~Y2_HWE_L1_MASK; in msk_stop()
4133 sc->msk_intrmask &= ~Y2_IS_PORT_B; in msk_stop()
4134 sc->msk_intrhwemask &= ~Y2_HWE_L2_MASK; in msk_stop()
4136 CSR_WRITE_4(sc, B0_HWE_IMSK, sc->msk_intrhwemask); in msk_stop()
4138 CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask); in msk_stop()
4142 val = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); in msk_stop()
4144 GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, val); in msk_stop()
4146 GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); in msk_stop()
4151 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), BMU_STOP); in msk_stop()
4152 val = CSR_READ_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR)); in msk_stop()
4155 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), in msk_stop()
4157 val = CSR_READ_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR)); in msk_stop()
4163 device_printf(sc_if->msk_if_dev, "Tx BMU stop failed\n"); in msk_stop()
4164 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_txq, RB_CTRL), in msk_stop()
4168 CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_MSK), 0); in msk_stop()
4173 CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, TXA_CTRL), TXA_DIS_ARB); in msk_stop()
4176 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), in msk_stop()
4180 CSR_WRITE_4(sc, Y2_PREF_Q_ADDR(sc_if->msk_txq, PREF_UNIT_CTRL_REG), in msk_stop()
4184 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_txq, RB_CTRL), RB_RST_SET); in msk_stop()
4187 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), GMF_RST_SET); in msk_stop()
4189 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_PAUSE_OFF); in msk_stop()
4192 * The Rx Stop command will not work for Yukon-2 if the BMU does not in msk_stop()
4203 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_rxq, RB_CTRL), RB_DIS_OP_MD); in msk_stop()
4205 if (CSR_READ_1(sc, RB_ADDR(sc_if->msk_rxq, Q_RSL)) == in msk_stop()
4206 CSR_READ_1(sc, RB_ADDR(sc_if->msk_rxq, Q_RL))) in msk_stop()
4211 device_printf(sc_if->msk_if_dev, "Rx BMU stop failed\n"); in msk_stop()
4212 CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_CSR), in msk_stop()
4215 CSR_WRITE_4(sc, Y2_PREF_Q_ADDR(sc_if->msk_rxq, PREF_UNIT_CTRL_REG), in msk_stop()
4218 CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_rxq, RB_CTRL), RB_RST_SET); in msk_stop()
4220 CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), GMF_RST_SET); in msk_stop()
4224 rxd = &sc_if->msk_cdata.msk_rxdesc[i]; in msk_stop()
4225 if (rxd->rx_m != NULL) { in msk_stop()
4226 bus_dmamap_sync(sc_if->msk_cdata.msk_rx_tag, in msk_stop()
4227 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in msk_stop()
4228 bus_dmamap_unload(sc_if->msk_cdata.msk_rx_tag, in msk_stop()
4229 rxd->rx_dmamap); in msk_stop()
4230 m_freem(rxd->rx_m); in msk_stop()
4231 rxd->rx_m = NULL; in msk_stop()
4235 jrxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[i]; in msk_stop()
4236 if (jrxd->rx_m != NULL) { in msk_stop()
4237 bus_dmamap_sync(sc_if->msk_cdata.msk_jumbo_rx_tag, in msk_stop()
4238 jrxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in msk_stop()
4239 bus_dmamap_unload(sc_if->msk_cdata.msk_jumbo_rx_tag, in msk_stop()
4240 jrxd->rx_dmamap); in msk_stop()
4241 m_freem(jrxd->rx_m); in msk_stop()
4242 jrxd->rx_m = NULL; in msk_stop()
4246 txd = &sc_if->msk_cdata.msk_txdesc[i]; in msk_stop()
4247 if (txd->tx_m != NULL) { in msk_stop()
4248 bus_dmamap_sync(sc_if->msk_cdata.msk_tx_tag, in msk_stop()
4249 txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); in msk_stop()
4250 bus_dmamap_unload(sc_if->msk_cdata.msk_tx_tag, in msk_stop()
4251 txd->tx_dmamap); in msk_stop()
4252 m_freem(txd->tx_m); in msk_stop()
4253 txd->tx_m = NULL; in msk_stop()
4261 sc_if->msk_flags &= ~MSK_FLAG_LINK; in msk_stop()
4285 sc = sc_if->msk_softc; in msk_stats_clear()
4287 gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_PHY_ADDR); in msk_stats_clear()
4288 GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac | GM_PAR_MIB_CLR); in msk_stats_clear()
4291 (void)MSK_READ_MIB32(sc_if->msk_port, i); in msk_stats_clear()
4294 GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac); in msk_stats_clear()
4307 ifp = sc_if->msk_ifp; in msk_stats_update()
4310 sc = sc_if->msk_softc; in msk_stats_update()
4311 stats = &sc_if->msk_stats; in msk_stats_update()
4313 gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_PHY_ADDR); in msk_stats_update()
4314 GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac | GM_PAR_MIB_CLR); in msk_stats_update()
4317 stats->rx_ucast_frames += in msk_stats_update()
4318 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_UC_OK); in msk_stats_update()
4319 stats->rx_bcast_frames += in msk_stats_update()
4320 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_BC_OK); in msk_stats_update()
4321 stats->rx_pause_frames += in msk_stats_update()
4322 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_MPAUSE); in msk_stats_update()
4323 stats->rx_mcast_frames += in msk_stats_update()
4324 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_MC_OK); in msk_stats_update()
4325 stats->rx_crc_errs += in msk_stats_update()
4326 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_FCS_ERR); in msk_stats_update()
4327 stats->rx_good_octets += in msk_stats_update()
4328 MSK_READ_MIB64(sc_if->msk_port, GM_RXO_OK_LO); in msk_stats_update()
4329 stats->rx_bad_octets += in msk_stats_update()
4330 MSK_READ_MIB64(sc_if->msk_port, GM_RXO_ERR_LO); in msk_stats_update()
4331 stats->rx_runts += in msk_stats_update()
4332 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_SHT); in msk_stats_update()
4333 stats->rx_runt_errs += in msk_stats_update()
4334 MSK_READ_MIB32(sc_if->msk_port, GM_RXE_FRAG); in msk_stats_update()
4335 stats->rx_pkts_64 += in msk_stats_update()
4336 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_64B); in msk_stats_update()
4337 stats->rx_pkts_65_127 += in msk_stats_update()
4338 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_127B); in msk_stats_update()
4339 stats->rx_pkts_128_255 += in msk_stats_update()
4340 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_255B); in msk_stats_update()
4341 stats->rx_pkts_256_511 += in msk_stats_update()
4342 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_511B); in msk_stats_update()
4343 stats->rx_pkts_512_1023 += in msk_stats_update()
4344 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_1023B); in msk_stats_update()
4345 stats->rx_pkts_1024_1518 += in msk_stats_update()
4346 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_1518B); in msk_stats_update()
4347 stats->rx_pkts_1519_max += in msk_stats_update()
4348 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_MAX_SZ); in msk_stats_update()
4349 stats->rx_pkts_too_long += in msk_stats_update()
4350 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_LNG_ERR); in msk_stats_update()
4351 stats->rx_pkts_jabbers += in msk_stats_update()
4352 MSK_READ_MIB32(sc_if->msk_port, GM_RXF_JAB_PKT); in msk_stats_update()
4353 stats->rx_fifo_oflows += in msk_stats_update()
4354 MSK_READ_MIB32(sc_if->msk_port, GM_RXE_FIFO_OV); in msk_stats_update()
4357 stats->tx_ucast_frames += in msk_stats_update()
4358 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_UC_OK); in msk_stats_update()
4359 stats->tx_bcast_frames += in msk_stats_update()
4360 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_BC_OK); in msk_stats_update()
4361 stats->tx_pause_frames += in msk_stats_update()
4362 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MPAUSE); in msk_stats_update()
4363 stats->tx_mcast_frames += in msk_stats_update()
4364 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MC_OK); in msk_stats_update()
4365 stats->tx_octets += in msk_stats_update()
4366 MSK_READ_MIB64(sc_if->msk_port, GM_TXO_OK_LO); in msk_stats_update()
4367 stats->tx_pkts_64 += in msk_stats_update()
4368 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_64B); in msk_stats_update()
4369 stats->tx_pkts_65_127 += in msk_stats_update()
4370 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_127B); in msk_stats_update()
4371 stats->tx_pkts_128_255 += in msk_stats_update()
4372 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_255B); in msk_stats_update()
4373 stats->tx_pkts_256_511 += in msk_stats_update()
4374 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_511B); in msk_stats_update()
4375 stats->tx_pkts_512_1023 += in msk_stats_update()
4376 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_1023B); in msk_stats_update()
4377 stats->tx_pkts_1024_1518 += in msk_stats_update()
4378 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_1518B); in msk_stats_update()
4379 stats->tx_pkts_1519_max += in msk_stats_update()
4380 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MAX_SZ); in msk_stats_update()
4381 stats->tx_colls += in msk_stats_update()
4382 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_COL); in msk_stats_update()
4383 stats->tx_late_colls += in msk_stats_update()
4384 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_LAT_COL); in msk_stats_update()
4385 stats->tx_excess_colls += in msk_stats_update()
4386 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_ABO_COL); in msk_stats_update()
4387 stats->tx_multi_colls += in msk_stats_update()
4388 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MUL_COL); in msk_stats_update()
4389 stats->tx_single_colls += in msk_stats_update()
4390 MSK_READ_MIB32(sc_if->msk_port, GM_TXF_SNG_COL); in msk_stats_update()
4391 stats->tx_underflows += in msk_stats_update()
4392 MSK_READ_MIB32(sc_if->msk_port, GM_TXE_FIFO_UR); in msk_stats_update()
4395 GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac); in msk_stats_update()
4407 sc = sc_if->msk_softc; in msk_sysctl_stat32()
4409 stat = (uint32_t *)((uint8_t *)&sc_if->msk_stats + off); in msk_sysctl_stat32()
4412 result = MSK_READ_MIB32(sc_if->msk_port, GM_MIB_CNT_BASE + off * 2); in msk_sysctl_stat32()
4428 sc = sc_if->msk_softc; in msk_sysctl_stat64()
4430 stat = (uint64_t *)((uint8_t *)&sc_if->msk_stats + off); in msk_sysctl_stat64()
4433 result = MSK_READ_MIB64(sc_if->msk_port, GM_MIB_CNT_BASE + off * 2); in msk_sysctl_stat64()
4461 ctx = device_get_sysctl_ctx(sc_if->msk_if_dev); in msk_sysctl_node()
4462 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc_if->msk_if_dev)); in msk_sysctl_node()
4558 if (error || !req->newptr) in sysctl_int_range()