Lines Matching +full:update +full:- +full:fc +full:- +full:fixup

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
94 * the first thing in the packet is a 14-byte Ethernet header.
97 * alignes the packet after the Ethernet header at a 32-bit
156 * sub-vendor and sub-device field are extensively used to identify
161 { 0x8086, 0x1029, -1, 0, "Intel 82559 PCI/CardBus Pro/100" },
162 { 0x8086, 0x1030, -1, 0, "Intel 82559 Pro/100 Ethernet" },
163 { 0x8086, 0x1031, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
164 { 0x8086, 0x1032, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
165 { 0x8086, 0x1033, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
166 { 0x8086, 0x1034, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
167 { 0x8086, 0x1035, -1, 3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
168 { 0x8086, 0x1036, -1, 3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
169 { 0x8086, 0x1037, -1, 3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
170 { 0x8086, 0x1038, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
171 { 0x8086, 0x1039, -1, 4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
172 { 0x8086, 0x103A, -1, 4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
173 { 0x8086, 0x103B, -1, 4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
174 { 0x8086, 0x103C, -1, 4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
175 { 0x8086, 0x103D, -1, 4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
176 { 0x8086, 0x103E, -1, 4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
177 { 0x8086, 0x1050, -1, 5, "Intel 82801BA (D865) Pro/100 VE Ethernet" },
178 { 0x8086, 0x1051, -1, 5, "Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet" },
179 { 0x8086, 0x1059, -1, 0, "Intel 82551QM Pro/100 M Mobile Connection" },
180 { 0x8086, 0x1064, -1, 6, "Intel 82562EZ (ICH6)" },
181 { 0x8086, 0x1065, -1, 6, "Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" },
182 { 0x8086, 0x1068, -1, 6, "Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" },
183 { 0x8086, 0x1069, -1, 6, "Intel 82562EM/EX/GX Pro/100 Ethernet" },
184 { 0x8086, 0x1091, -1, 7, "Intel 82562GX Pro/100 Ethernet" },
185 { 0x8086, 0x1092, -1, 7, "Intel Pro/100 VE Network Connection" },
186 { 0x8086, 0x1093, -1, 7, "Intel Pro/100 VM Network Connection" },
187 { 0x8086, 0x1094, -1, 7, "Intel Pro/100 946GZ (ICH7) Network Connection" },
188 { 0x8086, 0x1209, -1, 0, "Intel 82559ER Embedded 10/100 Ethernet" },
203 { 0x8086, 0x1229, -1, 0, "Intel 82557/8/9 Pro/100 Ethernet" },
204 { 0x8086, 0x2449, -1, 2, "Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet" },
205 { 0x8086, 0x27dc, -1, 7, "Intel 82801GB (ICH7) 10/100 Ethernet" },
206 { 0, 0, -1, 0, NULL },
306 nitems(fxp_ident_table) - 1);
312 { -1, 0 }
318 { -1, 0 }
334 while (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) && --i) in fxp_scb_wait()
339 device_printf(sc->dev, "SCB timeout: 0x%x 0x%x 0x%x 0x%x\n", in fxp_scb_wait()
350 if (cmd == FXP_SCB_COMMAND_CU_RESUME && sc->cu_resume_bug) { in fxp_scb_cmd()
363 for (i = 10000; i > 0; i--) { in fxp_dma_wait()
371 device_printf(sc->dev, "DMA timeout\n"); in fxp_dma_wait()
385 for (ident = fxp_ident_table; ident->name != NULL; ident++) { in fxp_find_ident()
386 if (ident->vendor == vendor && ident->device == device && in fxp_find_ident()
387 (ident->revid == revid || ident->revid == -1)) { in fxp_find_ident()
404 device_set_desc(dev, ident->name); in fxp_probe()
420 *addr = segs->ds_addr; in fxp_dma_map_addr()
438 sc->dev = dev; in fxp_attach()
439 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in fxp_attach()
441 callout_init_mtx(&sc->stat_ch, &sc->sc_mtx, 0); in fxp_attach()
442 ifmedia_init(&sc->sc_media, 0, fxp_serial_ifmedia_upd, in fxp_attach()
445 ifp = sc->ifp = if_gethandle(IFT_ETHER); in fxp_attach()
453 * Figure out which we should try first - memory mapping or i/o mapping? in fxp_attach()
461 sc->fxp_spec = fxp_res_spec_io; in fxp_attach()
463 sc->fxp_spec = fxp_res_spec_mem; in fxp_attach()
465 error = bus_alloc_resources(dev, sc->fxp_spec, sc->fxp_res); in fxp_attach()
467 if (sc->fxp_spec == fxp_res_spec_mem) in fxp_attach()
468 sc->fxp_spec = fxp_res_spec_io; in fxp_attach()
470 sc->fxp_spec = fxp_res_spec_mem; in fxp_attach()
471 error = bus_alloc_resources(dev, sc->fxp_spec, sc->fxp_res); in fxp_attach()
481 sc->fxp_spec == fxp_res_spec_mem ? "memory" : "I/O"); in fxp_attach()
503 sc->ident = fxp_find_ident(dev); in fxp_attach()
504 if (sc->ident->ich > 0) { in fxp_attach()
506 sc->revision = FXP_REV_82559_A0; in fxp_attach()
508 data = sc->eeprom[FXP_EEPROM_MAP_CNTR]; in fxp_attach()
510 sc->revision = FXP_REV_82557; in fxp_attach()
512 sc->revision = pci_get_revid(dev); in fxp_attach()
518 if (sc->revision >= FXP_REV_82558_A4 && in fxp_attach()
519 sc->revision != FXP_REV_82559S_A) { in fxp_attach()
520 data = sc->eeprom[FXP_EEPROM_MAP_ID]; in fxp_attach()
521 if ((data & 0x20) != 0 && pci_has_pm(sc->dev)) in fxp_attach()
522 sc->flags |= FXP_FLAG_WOLCAP; in fxp_attach()
525 if (sc->revision == FXP_REV_82550_C) { in fxp_attach()
529 * microcode is used for client-only featured 82550C in fxp_attach()
532 data = sc->eeprom[FXP_EEPROM_MAP_COMPAT]; in fxp_attach()
534 sc->flags |= FXP_FLAG_NO_UCODE; in fxp_attach()
537 /* Receiver lock-up workaround detection. */ in fxp_attach()
538 if (sc->revision < FXP_REV_82558_A4) { in fxp_attach()
539 data = sc->eeprom[FXP_EEPROM_MAP_COMPAT]; in fxp_attach()
541 sc->flags |= FXP_FLAG_RXBUG; in fxp_attach()
542 device_printf(dev, "Enabling Rx lock-up workaround\n"); in fxp_attach()
549 data = sc->eeprom[FXP_EEPROM_MAP_PRI_PHY]; in fxp_attach()
550 if (sc->revision == FXP_REV_82557 && (data & FXP_PHY_DEVICE_MASK) != 0 in fxp_attach()
552 sc->flags |= FXP_FLAG_SERIAL_MEDIA; in fxp_attach()
558 * Systems based on the ICH2/ICH2-M chip from Intel, and possibly in fxp_attach()
565 * See Intel 82801BA/82801BAM Specification Update, Errata #30. in fxp_attach()
567 if ((sc->ident->ich >= 2 && sc->ident->ich <= 3) || in fxp_attach()
568 (sc->ident->ich == 0 && sc->revision >= FXP_REV_82559_A0)) { in fxp_attach()
569 data = sc->eeprom[FXP_EEPROM_MAP_ID]; in fxp_attach()
577 sc->eeprom[FXP_EEPROM_MAP_ID] = data; in fxp_attach()
581 for (i = 0; i < (1 << sc->eeprom_size) - 1; i++) in fxp_attach()
582 cksum += sc->eeprom[i]; in fxp_attach()
583 i = (1 << sc->eeprom_size) - 1; in fxp_attach()
584 cksum = 0xBABA - cksum; in fxp_attach()
587 "EEPROM checksum @ 0x%x: 0x%x -> 0x%x\n", in fxp_attach()
588 i, sc->eeprom[i], cksum); in fxp_attach()
589 sc->eeprom[i] = cksum; in fxp_attach()
594 sc->flags |= FXP_FLAG_CU_RESUME_BUG; in fxp_attach()
601 if (sc->revision != FXP_REV_82557) { in fxp_attach()
610 sc->flags |= FXP_FLAG_MWI_ENABLE; in fxp_attach()
613 sc->flags |= FXP_FLAG_EXT_TXCB; in fxp_attach()
616 sc->flags |= FXP_FLAG_LONG_PKT_EN; in fxp_attach()
619 sc->flags |= FXP_FLAG_SAVE_BAD; in fxp_attach()
623 if (sc->revision >= FXP_REV_82559_A0) { in fxp_attach()
625 if (sc->ident->device != 0x1209) in fxp_attach()
626 sc->flags |= FXP_FLAG_82559_RXCSUM; in fxp_attach()
634 if (sc->revision == FXP_REV_82550 || sc->revision == FXP_REV_82550_C || in fxp_attach()
635 sc->revision == FXP_REV_82551_E || sc->revision == FXP_REV_82551_F in fxp_attach()
636 || sc->revision == FXP_REV_82551_10) { in fxp_attach()
637 sc->rfa_size = sizeof (struct fxp_rfa); in fxp_attach()
638 sc->tx_cmd = FXP_CB_COMMAND_IPCBXMIT; in fxp_attach()
639 sc->flags |= FXP_FLAG_EXT_RFA; in fxp_attach()
641 sc->flags &= ~FXP_FLAG_82559_RXCSUM; in fxp_attach()
643 sc->rfa_size = sizeof (struct fxp_rfa) - FXP_RFAX_LEN; in fxp_attach()
644 sc->tx_cmd = FXP_CB_COMMAND_XMIT; in fxp_attach()
650 sc->maxtxseg = FXP_NTXSEG; in fxp_attach()
651 sc->maxsegsize = MCLBYTES; in fxp_attach()
652 if (sc->flags & FXP_FLAG_EXT_RFA) { in fxp_attach()
653 sc->maxtxseg--; in fxp_attach()
654 sc->maxsegsize = FXP_TSO_SEGSIZE; in fxp_attach()
658 sc->maxsegsize * sc->maxtxseg + sizeof(struct ether_vlan_header), in fxp_attach()
659 sc->maxtxseg, sc->maxsegsize, 0, NULL, NULL, &sc->fxp_txmtag); in fxp_attach()
667 MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->fxp_rxmtag); in fxp_attach()
676 NULL, NULL, &sc->fxp_stag); in fxp_attach()
682 error = bus_dmamem_alloc(sc->fxp_stag, (void **)&sc->fxp_stats, in fxp_attach()
683 BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->fxp_smap); in fxp_attach()
688 error = bus_dmamap_load(sc->fxp_stag, sc->fxp_smap, sc->fxp_stats, in fxp_attach()
689 sizeof(struct fxp_stats), fxp_dma_map_addr, &sc->stats_addr, in fxp_attach()
698 FXP_TXCB_SZ, 1, FXP_TXCB_SZ, 0, NULL, NULL, &sc->cbl_tag); in fxp_attach()
704 error = bus_dmamem_alloc(sc->cbl_tag, (void **)&sc->fxp_desc.cbl_list, in fxp_attach()
705 BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->cbl_map); in fxp_attach()
711 error = bus_dmamap_load(sc->cbl_tag, sc->cbl_map, in fxp_attach()
712 sc->fxp_desc.cbl_list, FXP_TXCB_SZ, fxp_dma_map_addr, in fxp_attach()
713 &sc->fxp_desc.cbl_addr, BUS_DMA_NOWAIT); in fxp_attach()
722 NULL, NULL, &sc->mcs_tag); in fxp_attach()
729 error = bus_dmamem_alloc(sc->mcs_tag, (void **)&sc->mcsp, in fxp_attach()
730 BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->mcs_map); in fxp_attach()
736 error = bus_dmamap_load(sc->mcs_tag, sc->mcs_map, sc->mcsp, in fxp_attach()
737 sizeof(struct fxp_cb_mcs), fxp_dma_map_addr, &sc->mcs_addr, in fxp_attach()
746 * Pre-allocate the TX DMA maps and setup the pointers to in fxp_attach()
749 txp = sc->fxp_desc.tx_list; in fxp_attach()
750 tcbp = sc->fxp_desc.cbl_list; in fxp_attach()
753 error = bus_dmamap_create(sc->fxp_txmtag, 0, &txp[i].tx_map); in fxp_attach()
759 error = bus_dmamap_create(sc->fxp_rxmtag, 0, &sc->spare_map); in fxp_attach()
766 * Pre-allocate our receive buffers. in fxp_attach()
768 sc->fxp_desc.rx_head = sc->fxp_desc.rx_tail = NULL; in fxp_attach()
770 rxp = &sc->fxp_desc.rx_list[i]; in fxp_attach()
771 error = bus_dmamap_create(sc->fxp_rxmtag, 0, &rxp->rx_map); in fxp_attach()
786 eaddr[0] = sc->eeprom[FXP_EEPROM_MAP_IA0] & 0xff; in fxp_attach()
787 eaddr[1] = sc->eeprom[FXP_EEPROM_MAP_IA0] >> 8; in fxp_attach()
788 eaddr[2] = sc->eeprom[FXP_EEPROM_MAP_IA1] & 0xff; in fxp_attach()
789 eaddr[3] = sc->eeprom[FXP_EEPROM_MAP_IA1] >> 8; in fxp_attach()
790 eaddr[4] = sc->eeprom[FXP_EEPROM_MAP_IA2] & 0xff; in fxp_attach()
791 eaddr[5] = sc->eeprom[FXP_EEPROM_MAP_IA2] >> 8; in fxp_attach()
798 sc->eeprom[FXP_EEPROM_MAP_ID] & 0x02 ? "enabled" : in fxp_attach()
811 if (sc->flags & FXP_FLAG_SERIAL_MEDIA) { in fxp_attach()
812 ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL); in fxp_attach()
813 ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL); in fxp_attach()
819 if (sc->revision >= FXP_REV_82558_A4) in fxp_attach()
821 error = mii_attach(dev, &sc->miibus, ifp, in fxp_attach()
843 if (sc->flags & FXP_FLAG_EXT_RFA) { in fxp_attach()
849 if (sc->flags & FXP_FLAG_82559_RXCSUM) { in fxp_attach()
854 if (sc->flags & FXP_FLAG_WOLCAP) { in fxp_attach()
877 if ((sc->flags & FXP_FLAG_EXT_RFA) != 0) { in fxp_attach()
888 if_setsendqlen(ifp, FXP_NTXCB - 1); in fxp_attach()
894 error = bus_setup_intr(dev, sc->fxp_res[1], INTR_TYPE_NET | INTR_MPSAFE, in fxp_attach()
895 NULL, fxp_intr, sc, &sc->ih); in fxp_attach()
898 ether_ifdetach(sc->ifp); in fxp_attach()
906 if ((sc->flags & FXP_FLAG_WOLCAP) != 0) { in fxp_attach()
933 KASSERT(sc->ih == NULL, in fxp_release()
935 bus_generic_detach(sc->dev); in fxp_release()
936 ifmedia_removeall(&sc->sc_media); in fxp_release()
937 if (sc->fxp_desc.cbl_list) { in fxp_release()
938 bus_dmamap_unload(sc->cbl_tag, sc->cbl_map); in fxp_release()
939 bus_dmamem_free(sc->cbl_tag, sc->fxp_desc.cbl_list, in fxp_release()
940 sc->cbl_map); in fxp_release()
942 if (sc->fxp_stats) { in fxp_release()
943 bus_dmamap_unload(sc->fxp_stag, sc->fxp_smap); in fxp_release()
944 bus_dmamem_free(sc->fxp_stag, sc->fxp_stats, sc->fxp_smap); in fxp_release()
946 if (sc->mcsp) { in fxp_release()
947 bus_dmamap_unload(sc->mcs_tag, sc->mcs_map); in fxp_release()
948 bus_dmamem_free(sc->mcs_tag, sc->mcsp, sc->mcs_map); in fxp_release()
950 bus_release_resources(sc->dev, sc->fxp_spec, sc->fxp_res); in fxp_release()
951 if (sc->fxp_rxmtag) { in fxp_release()
953 rxp = &sc->fxp_desc.rx_list[i]; in fxp_release()
954 if (rxp->rx_mbuf != NULL) { in fxp_release()
955 bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map, in fxp_release()
957 bus_dmamap_unload(sc->fxp_rxmtag, rxp->rx_map); in fxp_release()
958 m_freem(rxp->rx_mbuf); in fxp_release()
960 bus_dmamap_destroy(sc->fxp_rxmtag, rxp->rx_map); in fxp_release()
962 bus_dmamap_destroy(sc->fxp_rxmtag, sc->spare_map); in fxp_release()
963 bus_dma_tag_destroy(sc->fxp_rxmtag); in fxp_release()
965 if (sc->fxp_txmtag) { in fxp_release()
967 txp = &sc->fxp_desc.tx_list[i]; in fxp_release()
968 if (txp->tx_mbuf != NULL) { in fxp_release()
969 bus_dmamap_sync(sc->fxp_txmtag, txp->tx_map, in fxp_release()
971 bus_dmamap_unload(sc->fxp_txmtag, txp->tx_map); in fxp_release()
972 m_freem(txp->tx_mbuf); in fxp_release()
974 bus_dmamap_destroy(sc->fxp_txmtag, txp->tx_map); in fxp_release()
976 bus_dma_tag_destroy(sc->fxp_txmtag); in fxp_release()
978 if (sc->fxp_stag) in fxp_release()
979 bus_dma_tag_destroy(sc->fxp_stag); in fxp_release()
980 if (sc->cbl_tag) in fxp_release()
981 bus_dma_tag_destroy(sc->cbl_tag); in fxp_release()
982 if (sc->mcs_tag) in fxp_release()
983 bus_dma_tag_destroy(sc->mcs_tag); in fxp_release()
984 if (sc->ifp) in fxp_release()
985 if_free(sc->ifp); in fxp_release()
987 mtx_destroy(&sc->sc_mtx); in fxp_release()
999 if (if_getcapenable(sc->ifp) & IFCAP_POLLING) in fxp_detach()
1000 ether_poll_deregister(sc->ifp); in fxp_detach()
1010 callout_drain(&sc->stat_ch); in fxp_detach()
1015 ether_ifdetach(sc->ifp); in fxp_detach()
1021 bus_teardown_intr(sc->dev, sc->fxp_res[1], sc->ih); in fxp_detach()
1022 sc->ih = NULL; in fxp_detach()
1059 ifp = sc->ifp; in fxp_suspend()
1062 pci_enable_pme(sc->dev); in fxp_suspend()
1063 sc->flags |= FXP_FLAG_WOL; in fxp_suspend()
1070 sc->suspended = 1; in fxp_suspend()
1077 * Device resume routine. re-enable busmastering, and restart the interface if
1084 if_t ifp = sc->ifp; in fxp_resume()
1088 if (pci_has_pm(sc->dev)) { in fxp_resume()
1089 sc->flags &= ~FXP_FLAG_WOL; in fxp_resume()
1090 if ((sc->flags & FXP_FLAG_WOLCAP) != 0) in fxp_resume()
1102 sc->suspended = 0; in fxp_resume()
1117 for (x = 1 << (length - 1); x; x >>= 1) { in fxp_eeprom_shiftin()
1153 for (x = 1 << (sc->eeprom_size - 1); x; x >>= 1) { in fxp_eeprom_getword()
1167 sc->eeprom_size = data; in fxp_eeprom_getword()
1200 fxp_eeprom_shiftin(sc, 0x03 << (sc->eeprom_size - 2), sc->eeprom_size); in fxp_eeprom_putword()
1208 fxp_eeprom_shiftin(sc, offset, sc->eeprom_size); in fxp_eeprom_putword()
1229 fxp_eeprom_shiftin(sc, 0, sc->eeprom_size); in fxp_eeprom_putword()
1239 * 559's can have either 64-word or 256-word EEPROMs, the 558
1240 * datasheet only talks about 64-word EEPROMs, and the 557 datasheet
1246 * The address is shifted in msb-to-lsb, and after the last
1247 * address-bit the EEPROM is supposed to output a `dummy zero' bit,
1249 * probing the data-out bit in the EEPROM control register just after
1251 * shifted enough address bits. The data-out should be tri-state,
1259 sc->eeprom_size = 8; in fxp_autosize_eeprom()
1289 fxp_read_eeprom(sc, sc->eeprom, 0, 1 << sc->eeprom_size); in fxp_load_eeprom()
1291 for (i = 0; i < (1 << sc->eeprom_size) - 1; i++) in fxp_load_eeprom()
1292 cksum += sc->eeprom[i]; in fxp_load_eeprom()
1293 cksum = 0xBABA - cksum; in fxp_load_eeprom()
1294 if (cksum != sc->eeprom[(1 << sc->eeprom_size) - 1]) in fxp_load_eeprom()
1295 device_printf(sc->dev, in fxp_load_eeprom()
1296 "EEPROM checksum mismatch! (0x%04x -> 0x%04x)\n", in fxp_load_eeprom()
1297 cksum, sc->eeprom[(1 << sc->eeprom_size) - 1]); in fxp_load_eeprom()
1331 if (sc->tx_queued > FXP_NTXCB_HIWAT) in fxp_start_body()
1340 while (!if_sendq_empty(ifp) && sc->tx_queued < FXP_NTXCB - 1) { in fxp_start_body()
1367 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_start_body()
1375 sc->watchdog_timer = 5; in fxp_start_body()
1396 txp = sc->fxp_desc.tx_last->tx_next; in fxp_encap()
1411 if (sc->flags & FXP_FLAG_EXT_RFA) in fxp_encap()
1412 txp->tx_cb->ipcb_ip_activation_high = in fxp_encap()
1416 if (m->m_pkthdr.csum_flags & CSUM_TSO) { in fxp_encap()
1443 if (eh->ether_type == htons(ETHERTYPE_VLAN)) { in fxp_encap()
1457 poff = ip_off + (ip->ip_hl << 2); in fxp_encap()
1464 m = m_pullup(m, poff + (tcp->th_off << 2)); in fxp_encap()
1476 ip->ip_sum = 0; in fxp_encap()
1477 ip->ip_len = htons(m->m_pkthdr.tso_segsz + (ip->ip_hl << 2) + in fxp_encap()
1478 (tcp->th_off << 2)); in fxp_encap()
1479 tcp->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, in fxp_encap()
1480 htons(IPPROTO_TCP + (tcp->th_off << 2) + in fxp_encap()
1481 m->m_pkthdr.tso_segsz)); in fxp_encap()
1483 tcp_payload = m->m_pkthdr.len - ip_off - (ip->ip_hl << 2); in fxp_encap()
1484 tcp_payload -= tcp->th_off << 2; in fxp_encap()
1486 } else if (m->m_pkthdr.csum_flags & FXP_CSUM_FEATURES) { in fxp_encap()
1495 txp->tx_cb->ipcb_ip_schedule = FXP_IPCB_TCPUDP_CHECKSUM_ENABLE; in fxp_encap()
1496 if (m->m_pkthdr.csum_flags & CSUM_TCP) in fxp_encap()
1497 txp->tx_cb->ipcb_ip_schedule |= FXP_IPCB_TCP_PACKET; in fxp_encap()
1508 * botch the header checksum on the 1-byte fragment. in fxp_encap()
1522 if (m->m_pkthdr.csum_flags & CSUM_IP) { in fxp_encap()
1523 if (m->m_pkthdr.len < 38) { in fxp_encap()
1525 m->m_data += ETHER_HDR_LEN; in fxp_encap()
1527 ip->ip_sum = in_cksum(m, ip->ip_hl << 2); in fxp_encap()
1528 m->m_data -= ETHER_HDR_LEN; in fxp_encap()
1529 m->m_pkthdr.csum_flags &= ~CSUM_IP; in fxp_encap()
1531 txp->tx_cb->ipcb_ip_activation_high = in fxp_encap()
1533 txp->tx_cb->ipcb_ip_schedule |= in fxp_encap()
1540 error = bus_dmamap_load_mbuf_sg(sc->fxp_txmtag, txp->tx_map, *m_head, in fxp_encap()
1543 m = m_collapse(*m_head, M_NOWAIT, sc->maxtxseg); in fxp_encap()
1550 error = bus_dmamap_load_mbuf_sg(sc->fxp_txmtag, txp->tx_map, in fxp_encap()
1565 KASSERT(nseg <= sc->maxtxseg, ("too many DMA segments")); in fxp_encap()
1566 bus_dmamap_sync(sc->fxp_txmtag, txp->tx_map, BUS_DMASYNC_PREWRITE); in fxp_encap()
1568 cbp = txp->tx_cb; in fxp_encap()
1583 if (sc->flags & FXP_FLAG_EXT_RFA) { in fxp_encap()
1584 cbp->tbd[i + 1].tb_addr = htole32(segs[i].ds_addr); in fxp_encap()
1585 cbp->tbd[i + 1].tb_size = htole32(segs[i].ds_len); in fxp_encap()
1587 cbp->tbd[i].tb_addr = htole32(segs[i].ds_addr); in fxp_encap()
1588 cbp->tbd[i].tb_size = htole32(segs[i].ds_len); in fxp_encap()
1591 if (sc->flags & FXP_FLAG_EXT_RFA) { in fxp_encap()
1593 cbp->tbd_number = 0xFF; in fxp_encap()
1594 cbp->tbd[nseg].tb_size |= htole32(0x8000); in fxp_encap()
1596 cbp->tbd_number = nseg; in fxp_encap()
1598 if (m->m_pkthdr.csum_flags & CSUM_TSO) { in fxp_encap()
1599 cbp->tbdtso.tb_size = htole32(m->m_pkthdr.tso_segsz << 16); in fxp_encap()
1600 cbp->tbd[1].tb_size |= htole32(tcp_payload << 16); in fxp_encap()
1601 cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE | in fxp_encap()
1607 if ((m->m_flags & M_VLANTAG) != 0) { in fxp_encap()
1608 cbp->ipcb_vlan_id = htons(m->m_pkthdr.ether_vtag); in fxp_encap()
1609 txp->tx_cb->ipcb_ip_activation_high |= in fxp_encap()
1613 txp->tx_mbuf = m; in fxp_encap()
1614 txp->tx_cb->cb_status = 0; in fxp_encap()
1615 txp->tx_cb->byte_count = 0; in fxp_encap()
1616 if (sc->tx_queued != FXP_CXINT_THRESH - 1) in fxp_encap()
1617 txp->tx_cb->cb_command = in fxp_encap()
1618 htole16(sc->tx_cmd | FXP_CB_COMMAND_SF | in fxp_encap()
1621 txp->tx_cb->cb_command = in fxp_encap()
1622 htole16(sc->tx_cmd | FXP_CB_COMMAND_SF | in fxp_encap()
1624 if ((m->m_pkthdr.csum_flags & CSUM_TSO) == 0) in fxp_encap()
1625 txp->tx_cb->tx_threshold = tx_threshold; in fxp_encap()
1630 sc->fxp_desc.tx_last->tx_cb->cb_command &= htole16(~FXP_CB_COMMAND_S); in fxp_encap()
1631 sc->fxp_desc.tx_last = txp; in fxp_encap()
1638 if (sc->tx_queued == 0) in fxp_encap()
1639 sc->fxp_desc.tx_first = txp; in fxp_encap()
1641 sc->tx_queued++; in fxp_encap()
1691 if_t ifp = sc->ifp; in fxp_intr()
1695 if (sc->suspended) { in fxp_intr()
1723 fxp_intr_body(sc, ifp, statack, -1); in fxp_intr()
1734 ifp = sc->ifp; in fxp_txeof()
1735 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_txeof()
1737 for (txp = sc->fxp_desc.tx_first; sc->tx_queued && in fxp_txeof()
1738 (le16toh(txp->tx_cb->cb_status) & FXP_CB_STATUS_C) != 0; in fxp_txeof()
1739 txp = txp->tx_next) { in fxp_txeof()
1740 if (txp->tx_mbuf != NULL) { in fxp_txeof()
1741 bus_dmamap_sync(sc->fxp_txmtag, txp->tx_map, in fxp_txeof()
1743 bus_dmamap_unload(sc->fxp_txmtag, txp->tx_map); in fxp_txeof()
1744 m_freem(txp->tx_mbuf); in fxp_txeof()
1745 txp->tx_mbuf = NULL; in fxp_txeof()
1747 txp->tx_cb->tbd[0].tb_addr = 0; in fxp_txeof()
1749 sc->tx_queued--; in fxp_txeof()
1752 sc->fxp_desc.tx_first = txp; in fxp_txeof()
1753 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_txeof()
1755 if (sc->tx_queued == 0) in fxp_txeof()
1756 sc->watchdog_timer = 0; in fxp_txeof()
1769 if ((sc->flags & FXP_FLAG_82559_RXCSUM) == 0) { in fxp_rxcsum()
1772 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in fxp_rxcsum()
1774 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in fxp_rxcsum()
1777 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | in fxp_rxcsum()
1779 m->m_pkthdr.csum_data = 0xffff; in fxp_rxcsum()
1785 pktlen = m->m_pkthdr.len; in fxp_rxcsum()
1789 if (eh->ether_type != htons(ETHERTYPE_IP)) in fxp_rxcsum()
1792 if (ip->ip_v != IPVERSION) in fxp_rxcsum()
1795 hlen = ip->ip_hl << 2; in fxp_rxcsum()
1796 pktlen -= sizeof(struct ether_header); in fxp_rxcsum()
1799 if (ntohs(ip->ip_len) < hlen) in fxp_rxcsum()
1801 if (ntohs(ip->ip_len) != pktlen) in fxp_rxcsum()
1803 if (ip->ip_off & htons(IP_MF | IP_OFFMASK)) in fxp_rxcsum()
1806 switch (ip->ip_p) { in fxp_rxcsum()
1815 if (uh->uh_sum == 0) in fxp_rxcsum()
1823 /* checksum fixup for IP options */ in fxp_rxcsum()
1824 len = hlen - sizeof(struct ip); in fxp_rxcsum()
1827 for (; len > 0; len -= sizeof(uint16_t), opts++) { in fxp_rxcsum()
1828 temp32 = csum - *opts; in fxp_rxcsum()
1833 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; in fxp_rxcsum()
1834 m->m_pkthdr.csum_data = csum; in fxp_rxcsum()
1852 sc->rnr++; in fxp_intr_body()
1855 if (sc->flags & FXP_FLAG_DEFERRED_RNR) { in fxp_intr_body()
1856 sc->flags &= ~FXP_FLAG_DEFERRED_RNR; in fxp_intr_body()
1890 * Process receiver interrupts. If a no-resource (RNR) in fxp_intr_body()
1892 * re-start the receiver. in fxp_intr_body()
1902 rxp = sc->fxp_desc.rx_head; in fxp_intr_body()
1903 m = rxp->rx_mbuf; in fxp_intr_body()
1904 rfa = (struct fxp_rfa *)(m->m_ext.ext_buf + in fxp_intr_body()
1906 bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map, in fxp_intr_body()
1910 if (count >= 0 && count-- == 0) { in fxp_intr_body()
1913 sc->flags |= FXP_FLAG_DEFERRED_RNR; in fxp_intr_body()
1920 status = le16toh(rfa->rfa_status); in fxp_intr_body()
1929 sc->fxp_desc.rx_head = rxp->rx_next; in fxp_intr_body()
1945 total_len = le16toh(rfa->actual_size) & 0x3fff; in fxp_intr_body()
1946 if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 && in fxp_intr_body()
1949 total_len -= 2; in fxp_intr_body()
1952 total_len > (MCLBYTES - RFA_ALIGNMENT_FUDGE - in fxp_intr_body()
1953 sc->rfa_size) || in fxp_intr_body()
1961 m->m_pkthdr.len = m->m_len = total_len; in fxp_intr_body()
1969 m->m_pkthdr.ether_vtag = in fxp_intr_body()
1970 ntohs(rfa->rfax_vlan_id); in fxp_intr_body()
1971 m->m_flags |= M_VLANTAG; in fxp_intr_body()
1975 * may re-enter fxp_start() in the netisr case. in fxp_intr_body()
1997 sc->fxp_desc.rx_head->rx_addr); in fxp_intr_body()
2006 if_t ifp = sc->ifp; in fxp_update_stats()
2007 struct fxp_stats *sp = sc->fxp_stats; in fxp_update_stats()
2013 bus_dmamap_sync(sc->fxp_stag, sc->fxp_smap, in fxp_update_stats()
2015 /* Update statistical counters. */ in fxp_update_stats()
2016 if (sc->revision >= FXP_REV_82559_A0) in fxp_update_stats()
2017 status = &sp->completion_status; in fxp_update_stats()
2018 else if (sc->revision >= FXP_REV_82558_A4) in fxp_update_stats()
2019 status = (uint32_t *)&sp->tx_tco; in fxp_update_stats()
2021 status = &sp->tx_pause; in fxp_update_stats()
2023 hsp = &sc->fxp_hwstats; in fxp_update_stats()
2024 hsp->tx_good += le32toh(sp->tx_good); in fxp_update_stats()
2025 hsp->tx_maxcols += le32toh(sp->tx_maxcols); in fxp_update_stats()
2026 hsp->tx_latecols += le32toh(sp->tx_latecols); in fxp_update_stats()
2027 hsp->tx_underruns += le32toh(sp->tx_underruns); in fxp_update_stats()
2028 hsp->tx_lostcrs += le32toh(sp->tx_lostcrs); in fxp_update_stats()
2029 hsp->tx_deffered += le32toh(sp->tx_deffered); in fxp_update_stats()
2030 hsp->tx_single_collisions += le32toh(sp->tx_single_collisions); in fxp_update_stats()
2031 hsp->tx_multiple_collisions += in fxp_update_stats()
2032 le32toh(sp->tx_multiple_collisions); in fxp_update_stats()
2033 hsp->tx_total_collisions += le32toh(sp->tx_total_collisions); in fxp_update_stats()
2034 hsp->rx_good += le32toh(sp->rx_good); in fxp_update_stats()
2035 hsp->rx_crc_errors += le32toh(sp->rx_crc_errors); in fxp_update_stats()
2036 hsp->rx_alignment_errors += le32toh(sp->rx_alignment_errors); in fxp_update_stats()
2037 hsp->rx_rnr_errors += le32toh(sp->rx_rnr_errors); in fxp_update_stats()
2038 hsp->rx_overrun_errors += le32toh(sp->rx_overrun_errors); in fxp_update_stats()
2039 hsp->rx_cdt_errors += le32toh(sp->rx_cdt_errors); in fxp_update_stats()
2040 hsp->rx_shortframes += le32toh(sp->rx_shortframes); in fxp_update_stats()
2041 hsp->tx_pause += le32toh(sp->tx_pause); in fxp_update_stats()
2042 hsp->rx_pause += le32toh(sp->rx_pause); in fxp_update_stats()
2043 hsp->rx_controls += le32toh(sp->rx_controls); in fxp_update_stats()
2044 hsp->tx_tco += le16toh(sp->tx_tco); in fxp_update_stats()
2045 hsp->rx_tco += le16toh(sp->rx_tco); in fxp_update_stats()
2047 if_inc_counter(ifp, IFCOUNTER_OPACKETS, le32toh(sp->tx_good)); in fxp_update_stats()
2049 le32toh(sp->tx_total_collisions)); in fxp_update_stats()
2050 if (sp->rx_good) { in fxp_update_stats()
2052 le32toh(sp->rx_good)); in fxp_update_stats()
2053 sc->rx_idle_secs = 0; in fxp_update_stats()
2054 } else if (sc->flags & FXP_FLAG_RXBUG) { in fxp_update_stats()
2058 sc->rx_idle_secs++; in fxp_update_stats()
2061 le32toh(sp->rx_crc_errors) + in fxp_update_stats()
2062 le32toh(sp->rx_alignment_errors) + in fxp_update_stats()
2063 le32toh(sp->rx_rnr_errors) + in fxp_update_stats()
2064 le32toh(sp->rx_overrun_errors)); in fxp_update_stats()
2069 if (sp->tx_underruns) { in fxp_update_stats()
2071 le32toh(sp->tx_underruns)); in fxp_update_stats()
2076 bus_dmamap_sync(sc->fxp_stag, sc->fxp_smap, in fxp_update_stats()
2082 * Update packet in/out/collision statistics. The i82557 doesn't
2086 * counters in the kernel are updated from the previous dump-stats
2087 * DMA and then a new dump-stats DMA is started. The on-chip
2089 * the DMA immediately, we don't wait - we just prepare to read
2096 if_t ifp = sc->ifp; in fxp_tick()
2100 /* Update statistical counters. */ in fxp_tick()
2116 * a work-around for a bug in the 82557 where the receiver locks in fxp_tick()
2122 if (sc->rx_idle_secs > FXP_MAX_RX_IDLE) { in fxp_tick()
2123 sc->rx_idle_secs = 0; in fxp_tick()
2140 if (sc->miibus != NULL) in fxp_tick()
2141 mii_tick(device_get_softc(sc->miibus)); in fxp_tick()
2151 callout_reset(&sc->stat_ch, hz, fxp_tick, sc); in fxp_tick()
2161 if_t ifp = sc->ifp; in fxp_stop()
2166 sc->watchdog_timer = 0; in fxp_stop()
2171 callout_stop(&sc->stat_ch); in fxp_stop()
2187 txp = sc->fxp_desc.tx_list; in fxp_stop()
2190 bus_dmamap_sync(sc->fxp_txmtag, txp[i].tx_map, in fxp_stop()
2192 bus_dmamap_unload(sc->fxp_txmtag, txp[i].tx_map); in fxp_stop()
2196 txp[i].tx_cb->tbd[0].tb_addr = 0; in fxp_stop()
2199 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_stop()
2201 sc->tx_queued = 0; in fxp_stop()
2213 if_t ifp = sc->ifp; in fxp_watchdog()
2217 if (sc->watchdog_timer == 0 || --sc->watchdog_timer) in fxp_watchdog()
2220 device_printf(sc->dev, "device timeout\n"); in fxp_watchdog()
2249 if_t ifp = sc->ifp; in fxp_init_body()
2270 sc->flags &= ~FXP_FLAG_UCODE; in fxp_init_body()
2287 * Initialize base of dump-stats buffer. in fxp_init_body()
2290 bzero(sc->fxp_stats, sizeof(struct fxp_stats)); in fxp_init_body()
2291 bus_dmamap_sync(sc->fxp_stag, sc->fxp_smap, in fxp_init_body()
2293 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->stats_addr); in fxp_init_body()
2300 if (sc->ident->ich == 0) { in fxp_init_body()
2302 (sc->flags & FXP_FLAG_UCODE) == 0) in fxp_init_body()
2317 cbp = (struct fxp_cb_config *)sc->fxp_desc.cbl_list; in fxp_init_body()
2326 cbp->cb_status = 0; in fxp_init_body()
2327 cbp->cb_command = htole16(FXP_CB_COMMAND_CONFIG | in fxp_init_body()
2329 cbp->link_addr = 0xffffffff; /* (no) next command */ in fxp_init_body()
2330 cbp->byte_count = sc->flags & FXP_FLAG_EXT_RFA ? 32 : 22; in fxp_init_body()
2331 cbp->rx_fifo_limit = 8; /* rx fifo threshold (32 bytes) */ in fxp_init_body()
2332 cbp->tx_fifo_limit = 0; /* tx fifo threshold (0 bytes) */ in fxp_init_body()
2333 cbp->adaptive_ifs = 0; /* (no) adaptive interframe spacing */ in fxp_init_body()
2334 cbp->mwi_enable = sc->flags & FXP_FLAG_MWI_ENABLE ? 1 : 0; in fxp_init_body()
2335 cbp->type_enable = 0; /* actually reserved */ in fxp_init_body()
2336 cbp->read_align_en = sc->flags & FXP_FLAG_READ_ALIGN ? 1 : 0; in fxp_init_body()
2337 cbp->end_wr_on_cl = sc->flags & FXP_FLAG_WRITE_ALIGN ? 1 : 0; in fxp_init_body()
2338 cbp->rx_dma_bytecount = 0; /* (no) rx DMA max */ in fxp_init_body()
2339 cbp->tx_dma_bytecount = 0; /* (no) tx DMA max */ in fxp_init_body()
2340 cbp->dma_mbce = 0; /* (disable) dma max counters */ in fxp_init_body()
2341 cbp->late_scb = 0; /* (don't) defer SCB update */ in fxp_init_body()
2342 cbp->direct_dma_dis = 1; /* disable direct rcv dma mode */ in fxp_init_body()
2343 cbp->tno_int_or_tco_en =0; /* (disable) tx not okay interrupt */ in fxp_init_body()
2344 cbp->ci_int = 1; /* interrupt on CU idle */ in fxp_init_body()
2345 cbp->ext_txcb_dis = sc->flags & FXP_FLAG_EXT_TXCB ? 0 : 1; in fxp_init_body()
2346 cbp->ext_stats_dis = 1; /* disable extended counters */ in fxp_init_body()
2347 cbp->keep_overrun_rx = 0; /* don't pass overrun frames to host */ in fxp_init_body()
2348 cbp->save_bf = sc->flags & FXP_FLAG_SAVE_BAD ? 1 : prm; in fxp_init_body()
2349 cbp->disc_short_rx = !prm; /* discard short packets */ in fxp_init_body()
2350 cbp->underrun_retry = 1; /* retry mode (once) on DMA underrun */ in fxp_init_body()
2351 cbp->two_frames = 0; /* do not limit FIFO to 2 frames */ in fxp_init_body()
2352 cbp->dyn_tbd = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0; in fxp_init_body()
2353 cbp->ext_rfa = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0; in fxp_init_body()
2354 cbp->mediatype = sc->flags & FXP_FLAG_SERIAL_MEDIA ? 0 : 1; in fxp_init_body()
2355 cbp->csma_dis = 0; /* (don't) disable link */ in fxp_init_body()
2356 cbp->tcp_udp_cksum = ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 && in fxp_init_body()
2358 cbp->vlan_tco = 0; /* (don't) enable vlan wakeup */ in fxp_init_body()
2359 cbp->link_wake_en = 0; /* (don't) assert PME# on link change */ in fxp_init_body()
2360 cbp->arp_wake_en = 0; /* (don't) assert PME# on arp */ in fxp_init_body()
2361 cbp->mc_wake_en = 0; /* (don't) enable PME# on mcmatch */ in fxp_init_body()
2362 cbp->nsai = 1; /* (don't) disable source addr insert */ in fxp_init_body()
2363 cbp->preamble_length = 2; /* (7 byte) preamble */ in fxp_init_body()
2364 cbp->loopback = 0; /* (don't) loopback */ in fxp_init_body()
2365 cbp->linear_priority = 0; /* (normal CSMA/CD operation) */ in fxp_init_body()
2366 cbp->linear_pri_mode = 0; /* (wait after xmit only) */ in fxp_init_body()
2367 cbp->interfrm_spacing = 6; /* (96 bits of) interframe spacing */ in fxp_init_body()
2368 cbp->promiscuous = prm; /* promiscuous mode */ in fxp_init_body()
2369 cbp->bcast_disable = 0; /* (don't) disable broadcasts */ in fxp_init_body()
2370 cbp->wait_after_win = 0; /* (don't) enable modified backoff alg*/ in fxp_init_body()
2371 cbp->ignore_ul = 0; /* consider U/L bit in IA matching */ in fxp_init_body()
2372 cbp->crc16_en = 0; /* (don't) enable crc-16 algorithm */ in fxp_init_body()
2373 cbp->crscdt = sc->flags & FXP_FLAG_SERIAL_MEDIA ? 1 : 0; in fxp_init_body()
2375 cbp->stripping = !prm; /* truncate rx packet to byte count */ in fxp_init_body()
2376 cbp->padding = 1; /* (do) pad short tx packets */ in fxp_init_body()
2377 cbp->rcv_crc_xfer = 0; /* (don't) xfer CRC to host */ in fxp_init_body()
2378 cbp->long_rx_en = sc->flags & FXP_FLAG_LONG_PKT_EN ? 1 : 0; in fxp_init_body()
2379 cbp->ia_wake_en = 0; /* (don't) wake up on address match */ in fxp_init_body()
2380 cbp->magic_pkt_dis = sc->flags & FXP_FLAG_WOL ? 0 : 1; in fxp_init_body()
2381 cbp->force_fdx = 0; /* (don't) force full duplex */ in fxp_init_body()
2382 cbp->fdx_pin_en = 1; /* (enable) FDX# pin */ in fxp_init_body()
2383 cbp->multi_ia = 0; /* (don't) accept multiple IAs */ in fxp_init_body()
2384 cbp->mc_all = if_getflags(ifp) & IFF_ALLMULTI ? 1 : prm; in fxp_init_body()
2385 cbp->gamla_rx = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0; in fxp_init_body()
2386 cbp->vlan_strip_en = ((sc->flags & FXP_FLAG_EXT_RFA) != 0 && in fxp_init_body()
2389 if (sc->revision == FXP_REV_82557) { in fxp_init_body()
2394 cbp->fc_delay_lsb = 0; in fxp_init_body()
2395 cbp->fc_delay_msb = 0x40; in fxp_init_body()
2396 cbp->pri_fc_thresh = 3; in fxp_init_body()
2397 cbp->tx_fc_dis = 0; in fxp_init_body()
2398 cbp->rx_fc_restop = 0; in fxp_init_body()
2399 cbp->rx_fc_restart = 0; in fxp_init_body()
2400 cbp->fc_filter = 0; in fxp_init_body()
2401 cbp->pri_fc_loc = 1; in fxp_init_body()
2406 cbp->fc_delay_lsb = 0xff; in fxp_init_body()
2407 cbp->fc_delay_msb = 0xff; in fxp_init_body()
2408 cbp->pri_fc_thresh = 3; in fxp_init_body()
2409 mii = device_get_softc(sc->miibus); in fxp_init_body()
2410 if ((IFM_OPTIONS(mii->mii_media_active) & in fxp_init_body()
2412 /* enable transmit FC */ in fxp_init_body()
2413 cbp->tx_fc_dis = 0; in fxp_init_body()
2415 /* disable transmit FC */ in fxp_init_body()
2416 cbp->tx_fc_dis = 1; in fxp_init_body()
2417 if ((IFM_OPTIONS(mii->mii_media_active) & in fxp_init_body()
2419 /* enable FC restart/restop frames */ in fxp_init_body()
2420 cbp->rx_fc_restart = 1; in fxp_init_body()
2421 cbp->rx_fc_restop = 1; in fxp_init_body()
2423 /* disable FC restart/restop frames */ in fxp_init_body()
2424 cbp->rx_fc_restart = 0; in fxp_init_body()
2425 cbp->rx_fc_restop = 0; in fxp_init_body()
2427 cbp->fc_filter = !prm; /* drop FC frames to host */ in fxp_init_body()
2428 cbp->pri_fc_loc = 1; /* FC pri location (byte31) */ in fxp_init_body()
2432 if (sc->revision >= FXP_REV_82558_A4) { in fxp_init_body()
2433 if (sc->revision >= FXP_REV_82559_A0) { in fxp_init_body()
2438 cbp->byte_count = 32; in fxp_init_body()
2439 cbp->ext_stats_dis = 1; in fxp_init_body()
2441 cbp->tno_int_or_tco_en = 1; in fxp_init_body()
2442 cbp->gamla_rx = 1; in fxp_init_body()
2444 cbp->ext_stats_dis = 0; in fxp_init_body()
2451 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_init_body()
2453 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr); in fxp_init_body()
2456 fxp_dma_wait(sc, &cbp->cb_status, sc->cbl_tag, sc->cbl_map); in fxp_init_body()
2462 cb_ias = (struct fxp_cb_ias *)sc->fxp_desc.cbl_list; in fxp_init_body()
2463 cb_ias->cb_status = 0; in fxp_init_body()
2464 cb_ias->cb_command = htole16(FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL); in fxp_init_body()
2465 cb_ias->link_addr = 0xffffffff; in fxp_init_body()
2466 bcopy(if_getlladdr(sc->ifp), cb_ias->macaddr, ETHER_ADDR_LEN); in fxp_init_body()
2472 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_init_body()
2474 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr); in fxp_init_body()
2477 fxp_dma_wait(sc, &cb_ias->cb_status, sc->cbl_tag, sc->cbl_map); in fxp_init_body()
2487 txp = sc->fxp_desc.tx_list; in fxp_init_body()
2488 tcbp = sc->fxp_desc.cbl_list; in fxp_init_body()
2494 tcbp[i].link_addr = htole32(sc->fxp_desc.cbl_addr + in fxp_init_body()
2496 if (sc->flags & FXP_FLAG_EXT_TXCB) in fxp_init_body()
2508 tcbp->cb_command = htole16(FXP_CB_COMMAND_NOP | FXP_CB_COMMAND_S); in fxp_init_body()
2509 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_init_body()
2511 sc->fxp_desc.tx_first = sc->fxp_desc.tx_last = txp; in fxp_init_body()
2512 sc->tx_queued = 1; in fxp_init_body()
2515 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr); in fxp_init_body()
2519 * Initialize receiver buffer area - RFA. in fxp_init_body()
2522 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.rx_head->rx_addr); in fxp_init_body()
2525 if (sc->miibus != NULL && setmedia != 0) in fxp_init_body()
2526 mii_mediachg(device_get_softc(sc->miibus)); in fxp_init_body()
2547 callout_reset(&sc->stat_ch, hz, fxp_tick, sc); in fxp_init_body()
2561 ifmr->ifm_active = IFM_ETHER|IFM_MANUAL; in fxp_serial_ifmedia_sts()
2574 mii = device_get_softc(sc->miibus); in fxp_ifmedia_upd()
2576 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in fxp_ifmedia_upd()
2592 mii = device_get_softc(sc->miibus); in fxp_ifmedia_sts()
2595 ifmr->ifm_active = mii->mii_media_active; in fxp_ifmedia_sts()
2596 ifmr->ifm_status = mii->mii_media_status; in fxp_ifmedia_sts()
2621 * will be 32-bit aligned. in fxp_new_rfabuf()
2623 m->m_data += RFA_ALIGNMENT_FUDGE; in fxp_new_rfabuf()
2630 m->m_data += sc->rfa_size; in fxp_new_rfabuf()
2631 rfa->size = htole16(MCLBYTES - sc->rfa_size - RFA_ALIGNMENT_FUDGE); in fxp_new_rfabuf()
2633 rfa->rfa_status = 0; in fxp_new_rfabuf()
2634 rfa->rfa_control = htole16(FXP_RFA_CONTROL_EL); in fxp_new_rfabuf()
2635 rfa->actual_size = 0; in fxp_new_rfabuf()
2636 m->m_len = m->m_pkthdr.len = MCLBYTES - RFA_ALIGNMENT_FUDGE - in fxp_new_rfabuf()
2637 sc->rfa_size; in fxp_new_rfabuf()
2643 * is also alignment-safe. in fxp_new_rfabuf()
2645 le32enc(&rfa->link_addr, 0xffffffff); in fxp_new_rfabuf()
2646 le32enc(&rfa->rbd_addr, 0xffffffff); in fxp_new_rfabuf()
2649 error = bus_dmamap_load(sc->fxp_rxmtag, sc->spare_map, rfa, in fxp_new_rfabuf()
2650 MCLBYTES - RFA_ALIGNMENT_FUDGE, fxp_dma_map_addr, in fxp_new_rfabuf()
2651 &rxp->rx_addr, BUS_DMA_NOWAIT); in fxp_new_rfabuf()
2657 if (rxp->rx_mbuf != NULL) in fxp_new_rfabuf()
2658 bus_dmamap_unload(sc->fxp_rxmtag, rxp->rx_map); in fxp_new_rfabuf()
2659 tmp_map = sc->spare_map; in fxp_new_rfabuf()
2660 sc->spare_map = rxp->rx_map; in fxp_new_rfabuf()
2661 rxp->rx_map = tmp_map; in fxp_new_rfabuf()
2662 rxp->rx_mbuf = m; in fxp_new_rfabuf()
2664 bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map, in fxp_new_rfabuf()
2679 if (sc->fxp_desc.rx_head != NULL) { in fxp_add_rfabuf()
2680 p_rx = sc->fxp_desc.rx_tail; in fxp_add_rfabuf()
2682 (p_rx->rx_mbuf->m_ext.ext_buf + RFA_ALIGNMENT_FUDGE); in fxp_add_rfabuf()
2683 p_rx->rx_next = rxp; in fxp_add_rfabuf()
2684 le32enc(&p_rfa->link_addr, rxp->rx_addr); in fxp_add_rfabuf()
2685 p_rfa->rfa_control = 0; in fxp_add_rfabuf()
2686 bus_dmamap_sync(sc->fxp_rxmtag, p_rx->rx_map, in fxp_add_rfabuf()
2689 rxp->rx_next = NULL; in fxp_add_rfabuf()
2690 sc->fxp_desc.rx_head = rxp; in fxp_add_rfabuf()
2692 sc->fxp_desc.rx_tail = rxp; in fxp_add_rfabuf()
2701 m = rxp->rx_mbuf; in fxp_discard_rfabuf()
2702 m->m_data = m->m_ext.ext_buf; in fxp_discard_rfabuf()
2705 * will be 32-bit aligned. in fxp_discard_rfabuf()
2707 m->m_data += RFA_ALIGNMENT_FUDGE; in fxp_discard_rfabuf()
2714 m->m_data += sc->rfa_size; in fxp_discard_rfabuf()
2715 rfa->size = htole16(MCLBYTES - sc->rfa_size - RFA_ALIGNMENT_FUDGE); in fxp_discard_rfabuf()
2717 rfa->rfa_status = 0; in fxp_discard_rfabuf()
2718 rfa->rfa_control = htole16(FXP_RFA_CONTROL_EL); in fxp_discard_rfabuf()
2719 rfa->actual_size = 0; in fxp_discard_rfabuf()
2725 * is also alignment-safe. in fxp_discard_rfabuf()
2727 le32enc(&rfa->link_addr, 0xffffffff); in fxp_discard_rfabuf()
2728 le32enc(&rfa->rbd_addr, 0xffffffff); in fxp_discard_rfabuf()
2730 bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map, in fxp_discard_rfabuf()
2745 && count--) in fxp_miibus_readreg()
2765 count--) in fxp_miibus_writereg()
2781 mii = device_get_softc(sc->miibus); in fxp_miibus_statchg()
2782 ifp = sc->ifp; in fxp_miibus_statchg()
2785 (mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) != in fxp_miibus_statchg()
2789 if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T && in fxp_miibus_statchg()
2790 sc->flags & FXP_FLAG_CU_RESUME_BUG) in fxp_miibus_statchg()
2791 sc->cu_resume_bug = 1; in fxp_miibus_statchg()
2793 sc->cu_resume_bug = 0; in fxp_miibus_statchg()
2798 if (sc->revision == FXP_REV_82557) in fxp_miibus_statchg()
2818 * XXX If it's up then re-initialize it. This is so flags in fxp_ioctl()
2823 ((if_getflags(ifp) ^ sc->if_flags) & in fxp_ioctl()
2833 sc->if_flags = if_getflags(ifp); in fxp_ioctl()
2849 if (sc->miibus != NULL) { in fxp_ioctl()
2850 mii = device_get_softc(sc->miibus); in fxp_ioctl()
2852 &mii->mii_media, command); in fxp_ioctl()
2854 error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command); in fxp_ioctl()
2860 mask = if_getcapenable(ifp) ^ ifr->ifr_reqcap; in fxp_ioctl()
2863 if (ifr->ifr_reqcap & IFCAP_POLLING) { in fxp_ioctl()
2894 if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0) in fxp_ioctl()
2911 if (sc->revision != FXP_REV_82557) in fxp_ioctl()
2915 sc->flags ^= flag; in fxp_ioctl()
2952 struct fxp_cb_mcs *mcsp = sc->mcsp; in fxp_setup_maddr()
2954 if (mcsp->mc_cnt < MAXMCADDR) in fxp_setup_maddr()
2955 bcopy(LLADDR(sdl), mcsp->mc_addr[mcsp->mc_cnt * ETHER_ADDR_LEN], in fxp_setup_maddr()
2957 mcsp->mc_cnt++; in fxp_setup_maddr()
2967 struct fxp_cb_mcs *mcsp = sc->mcsp; in fxp_mc_addrs()
2968 if_t ifp = sc->ifp; in fxp_mc_addrs()
2971 mcsp->mc_cnt = 0; in fxp_mc_addrs()
2972 if_foreach_llmaddr(sc->ifp, fxp_setup_maddr, sc); in fxp_mc_addrs()
2973 if (mcsp->mc_cnt >= MAXMCADDR) { in fxp_mc_addrs()
2975 mcsp->mc_cnt = 0; in fxp_mc_addrs()
2978 mcsp->mc_cnt = htole16(mcsp->mc_cnt * ETHER_ADDR_LEN); in fxp_mc_addrs()
2987 * the pre-initialized command ring (esp. link pointers) by not actually
2988 * inserting the mcsetup command in the ring - i.e. its link pointer
3001 mcsp = sc->mcsp; in fxp_mc_setup()
3002 mcsp->cb_status = 0; in fxp_mc_setup()
3003 mcsp->cb_command = htole16(FXP_CB_COMMAND_MCAS | FXP_CB_COMMAND_EL); in fxp_mc_setup()
3004 mcsp->link_addr = 0xffffffff; in fxp_mc_setup()
3013 FXP_SCB_CUS_IDLE && --count) in fxp_mc_setup()
3016 device_printf(sc->dev, "command queue timeout\n"); in fxp_mc_setup()
3024 bus_dmamap_sync(sc->mcs_tag, sc->mcs_map, in fxp_mc_setup()
3026 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->mcs_addr); in fxp_mc_setup()
3029 fxp_dma_wait(sc, &mcsp->cb_status, sc->mcs_tag, sc->mcs_map); in fxp_mc_setup()
3073 if (sc->flags & FXP_FLAG_NO_UCODE) in fxp_load_ucode()
3076 for (uc = ucode_table; uc->ucode != NULL; uc++) in fxp_load_ucode()
3077 if (sc->revision == uc->revision) in fxp_load_ucode()
3079 if (uc->ucode == NULL) in fxp_load_ucode()
3081 cbp = (struct fxp_cb_ucode *)sc->fxp_desc.cbl_list; in fxp_load_ucode()
3082 cbp->cb_status = 0; in fxp_load_ucode()
3083 cbp->cb_command = htole16(FXP_CB_COMMAND_UCODE | FXP_CB_COMMAND_EL); in fxp_load_ucode()
3084 cbp->link_addr = 0xffffffff; /* (no) next command */ in fxp_load_ucode()
3085 for (i = 0; i < uc->length; i++) in fxp_load_ucode()
3086 cbp->ucode[i] = htole32(uc->ucode[i]); in fxp_load_ucode()
3087 if (uc->int_delay_offset) in fxp_load_ucode()
3088 *(uint16_t *)&cbp->ucode[uc->int_delay_offset] = in fxp_load_ucode()
3089 htole16(sc->tunable_int_delay + sc->tunable_int_delay / 2); in fxp_load_ucode()
3090 if (uc->bundle_max_offset) in fxp_load_ucode()
3091 *(uint16_t *)&cbp->ucode[uc->bundle_max_offset] = in fxp_load_ucode()
3092 htole16(sc->tunable_bundle_max); in fxp_load_ucode()
3097 bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, in fxp_load_ucode()
3099 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr); in fxp_load_ucode()
3102 fxp_dma_wait(sc, &cbp->cb_status, sc->cbl_tag, sc->cbl_map); in fxp_load_ucode()
3103 device_printf(sc->dev, in fxp_load_ucode()
3105 sc->tunable_int_delay, in fxp_load_ucode()
3106 uc->bundle_max_offset == 0 ? 0 : sc->tunable_bundle_max); in fxp_load_ucode()
3107 sc->flags |= FXP_FLAG_UCODE; in fxp_load_ucode()
3122 ctx = device_get_sysctl_ctx(sc->dev); in fxp_sysctl_node()
3123 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)); in fxp_sysctl_node()
3127 &sc->tunable_int_delay, 0, sysctl_hw_fxp_int_delay, "I", in fxp_sysctl_node()
3131 &sc->tunable_bundle_max, 0, sysctl_hw_fxp_bundle_max, "I", in fxp_sysctl_node()
3133 SYSCTL_ADD_INT(ctx, child,OID_AUTO, "rnr", CTLFLAG_RD, &sc->rnr, 0, in fxp_sysctl_node()
3139 sc->tunable_int_delay = TUNABLE_INT_DELAY; in fxp_sysctl_node()
3140 sc->tunable_bundle_max = TUNABLE_BUNDLE_MAX; in fxp_sysctl_node()
3141 (void) resource_int_value(device_get_name(sc->dev), in fxp_sysctl_node()
3142 device_get_unit(sc->dev), "int_delay", &sc->tunable_int_delay); in fxp_sysctl_node()
3143 (void) resource_int_value(device_get_name(sc->dev), in fxp_sysctl_node()
3144 device_get_unit(sc->dev), "bundle_max", &sc->tunable_bundle_max); in fxp_sysctl_node()
3145 sc->rnr = 0; in fxp_sysctl_node()
3147 hsp = &sc->fxp_hwstats; in fxp_sysctl_node()
3157 &hsp->rx_good, "Good frames"); in fxp_sysctl_node()
3159 &hsp->rx_crc_errors, "CRC errors"); in fxp_sysctl_node()
3161 &hsp->rx_alignment_errors, "Alignment errors"); in fxp_sysctl_node()
3163 &hsp->rx_rnr_errors, "RNR errors"); in fxp_sysctl_node()
3165 &hsp->rx_overrun_errors, "Overrun errors"); in fxp_sysctl_node()
3167 &hsp->rx_cdt_errors, "Collision detect errors"); in fxp_sysctl_node()
3169 &hsp->rx_shortframes, "Short frame errors"); in fxp_sysctl_node()
3170 if (sc->revision >= FXP_REV_82558_A4) { in fxp_sysctl_node()
3172 &hsp->rx_pause, "Pause frames"); in fxp_sysctl_node()
3174 &hsp->rx_controls, "Unsupported control frames"); in fxp_sysctl_node()
3176 if (sc->revision >= FXP_REV_82559_A0) in fxp_sysctl_node()
3178 &hsp->rx_tco, "TCO frames"); in fxp_sysctl_node()
3185 &hsp->tx_good, "Good frames"); in fxp_sysctl_node()
3187 &hsp->tx_maxcols, "Maximum collisions errors"); in fxp_sysctl_node()
3189 &hsp->tx_latecols, "Late collisions errors"); in fxp_sysctl_node()
3191 &hsp->tx_underruns, "Underrun errors"); in fxp_sysctl_node()
3193 &hsp->tx_lostcrs, "Lost carrier sense"); in fxp_sysctl_node()
3195 &hsp->tx_deffered, "Deferred"); in fxp_sysctl_node()
3197 &hsp->tx_single_collisions, "Single collisions"); in fxp_sysctl_node()
3199 &hsp->tx_multiple_collisions, "Multiple collisions"); in fxp_sysctl_node()
3201 &hsp->tx_total_collisions, "Total collisions"); in fxp_sysctl_node()
3202 if (sc->revision >= FXP_REV_82558_A4) in fxp_sysctl_node()
3204 &hsp->tx_pause, "Pause frames"); in fxp_sysctl_node()
3205 if (sc->revision >= FXP_REV_82559_A0) in fxp_sysctl_node()
3207 &hsp->tx_tco, "TCO frames"); in fxp_sysctl_node()
3219 if (error || !req->newptr) in sysctl_int_range()