Lines Matching +full:sram +full:- +full:others
1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
18 * 4. Neither the name of the author nor the names of any co-contributors
48 * using the Tigon may have anywhere from 512K to 2MB of SRAM. The
69 * compiling it requires a GNU toolchain targeted for mips-sgi-irix5.3.
72 * - Terry Murphy of 3Com, for providing a 3c985 Tigon 1 board
74 * - Raymond Lee of Netgear, for providing a pair of Netgear
76 * - Ulf Zimmermann, for bringing the GA260 to my attention and
78 * - Andrew Gallatin for providing FreeBSD/Alpha support.
155 "3Com 3c985-SX Gigabit Ethernet" },
337 device_printf(sc->ti_dev, in ti_eeprom_getbyte()
347 device_printf(sc->ti_dev, "failed to send address, status: %x\n", in ti_eeprom_getbyte()
355 device_printf(sc->ti_dev, "failed to send address, status: %x\n", in ti_eeprom_getbyte()
366 device_printf(sc->ti_dev, in ti_eeprom_getbyte()
433 segsize = TI_WINLEN - (segptr % TI_WINLEN); in ti_mem_read()
435 bus_space_read_region_4(sc->ti_btag, sc->ti_bhandle, in ti_mem_read()
436 TI_WINDOW + (segptr & (TI_WINLEN - 1)), (uint32_t *)ptr, in ti_mem_read()
440 cnt -= segsize; in ti_mem_read()
462 segsize = TI_WINLEN - (segptr % TI_WINLEN); in ti_mem_write()
464 bus_space_write_region_4(sc->ti_btag, sc->ti_bhandle, in ti_mem_write()
465 TI_WINDOW + (segptr & (TI_WINLEN - 1)), (uint32_t *)ptr, in ti_mem_write()
469 cnt -= segsize; in ti_mem_write()
489 segsize = TI_WINLEN - (segptr % TI_WINLEN); in ti_mem_zero()
491 bus_space_set_region_4(sc->ti_btag, sc->ti_bhandle, in ti_mem_zero()
492 TI_WINDOW + (segptr & (TI_WINLEN - 1)), 0, segsize / 4); in ti_mem_zero()
494 cnt -= segsize; in ti_mem_zero()
513 * At the moment, we don't handle non-aligned cases, we just bail. in ti_copy_mem()
517 device_printf(sc->ti_dev, "%s: tigon address %#x isn't " in ti_copy_mem()
518 "word-aligned\n", __func__, tigon_addr); in ti_copy_mem()
519 device_printf(sc->ti_dev, "%s: unaligned writes aren't " in ti_copy_mem()
525 segresid = tigon_addr - segptr; in ti_copy_mem()
528 * This is the non-aligned amount left over that we'll need to in ti_copy_mem()
542 resid -= resid & ~0x3; in ti_copy_mem()
559 segsize = TI_WINLEN - (segptr % TI_WINLEN); in ti_copy_mem()
562 ti_offset = TI_WINDOW + (segptr & (TI_WINLEN -1)); in ti_copy_mem()
565 bus_space_read_region_4(sc->ti_btag, sc->ti_bhandle, in ti_copy_mem()
566 ti_offset, (uint32_t *)sc->ti_membuf, segsize >> 2); in ti_copy_mem()
573 ti_bcopy_swap(sc->ti_membuf, sc->ti_membuf2, in ti_copy_mem()
579 &sc->ti_membuf2[segresid], ptr, in ti_copy_mem()
580 segsize - segresid); in ti_copy_mem()
583 error = copyout(sc->ti_membuf2, ptr, in ti_copy_mem()
588 ti_bcopy_swap(sc->ti_membuf, in ti_copy_mem()
589 sc->ti_membuf2, segsize, in ti_copy_mem()
592 bcopy(&sc->ti_membuf2[segresid], ptr, in ti_copy_mem()
593 segsize - segresid); in ti_copy_mem()
597 ti_bcopy_swap(sc->ti_membuf, ptr, in ti_copy_mem()
604 error = copyin(ptr, sc->ti_membuf2, segsize); in ti_copy_mem()
606 ti_bcopy_swap(sc->ti_membuf2, sc->ti_membuf, in ti_copy_mem()
609 ti_bcopy_swap(ptr, sc->ti_membuf, segsize, in ti_copy_mem()
613 bus_space_write_region_4(sc->ti_btag, in ti_copy_mem()
614 sc->ti_bhandle, ti_offset, in ti_copy_mem()
615 (uint32_t *)sc->ti_membuf, segsize >> 2); in ti_copy_mem()
620 cnt -= segsize; in ti_copy_mem()
624 * Handle leftover, non-word-aligned bytes. in ti_copy_mem()
635 ti_offset = TI_WINDOW + (segptr & (TI_WINLEN - 1)); in ti_copy_mem()
642 bus_space_read_region_4(sc->ti_btag, sc->ti_bhandle, in ti_copy_mem()
646 * Next, translate this from little-endian to big-endian in ti_copy_mem()
684 bus_space_write_region_4(sc->ti_btag, in ti_copy_mem()
685 sc->ti_bhandle, ti_offset, &tmpval, 1); in ti_copy_mem()
707 * At the moment, we don't handle non-aligned cases, we just bail. in ti_copy_scratch()
711 device_printf(sc->ti_dev, "%s: tigon address %#x " in ti_copy_scratch()
712 "isn't word-aligned\n", __func__, tigon_addr); in ti_copy_scratch()
717 device_printf(sc->ti_dev, "%s: transfer length %d " in ti_copy_scratch()
718 "isn't word-aligned\n", __func__, len); in ti_copy_scratch()
759 device_printf(sc->ti_dev, "found 0xc0017c at " in ti_copy_scratch()
763 device_printf(sc->ti_dev, "found 0xc0017c at " in ti_copy_scratch()
783 cnt -= 4; in ti_copy_scratch()
799 printf("ti_bcopy_swap: length %zd isn't 32-bit aligned\n", len); in ti_bcopy_swap()
800 return (-1); in ti_bcopy_swap()
814 tmplen -= 4; in ti_bcopy_swap()
831 switch (sc->ti_hwrev) { in ti_loadfw()
836 device_printf(sc->ti_dev, "firmware revision mismatch; " in ti_loadfw()
855 device_printf(sc->ti_dev, "firmware revision mismatch; " in ti_loadfw()
873 device_printf(sc->ti_dev, in ti_loadfw()
887 index = sc->ti_cmd_saved_prodidx; in ti_cmd()
891 sc->ti_cmd_saved_prodidx = index; in ti_cmd()
904 index = sc->ti_cmd_saved_prodidx; in ti_cmd_ext()
913 sc->ti_cmd_saved_prodidx = index; in ti_cmd_ext()
924 if (sc->ti_rdata.ti_event_ring == NULL) in ti_handle_events()
927 bus_dmamap_sync(sc->ti_cdata.ti_event_ring_tag, in ti_handle_events()
928 sc->ti_cdata.ti_event_ring_map, BUS_DMASYNC_POSTREAD); in ti_handle_events()
929 while (sc->ti_ev_saved_considx != sc->ti_ev_prodidx.ti_idx) { in ti_handle_events()
930 e = &sc->ti_rdata.ti_event_ring[sc->ti_ev_saved_considx]; in ti_handle_events()
933 sc->ti_linkstat = TI_EVENT_CODE(e); in ti_handle_events()
934 if (sc->ti_linkstat == TI_EV_CODE_LINK_UP) { in ti_handle_events()
935 if_link_state_change(sc->ti_ifp, LINK_STATE_UP); in ti_handle_events()
936 if_setbaudrate(sc->ti_ifp, IF_Mbps(100)); in ti_handle_events()
938 device_printf(sc->ti_dev, in ti_handle_events()
940 } else if (sc->ti_linkstat == TI_EV_CODE_GIG_LINK_UP) { in ti_handle_events()
941 if_link_state_change(sc->ti_ifp, LINK_STATE_UP); in ti_handle_events()
942 if_setbaudrate(sc->ti_ifp, IF_Gbps(1UL)); in ti_handle_events()
944 device_printf(sc->ti_dev, in ti_handle_events()
946 } else if (sc->ti_linkstat == TI_EV_CODE_LINK_DOWN) { in ti_handle_events()
947 if_link_state_change(sc->ti_ifp, in ti_handle_events()
949 if_setbaudrate(sc->ti_ifp, 0); in ti_handle_events()
951 device_printf(sc->ti_dev, in ti_handle_events()
957 device_printf(sc->ti_dev, "invalid command\n"); in ti_handle_events()
959 device_printf(sc->ti_dev, "unknown command\n"); in ti_handle_events()
961 device_printf(sc->ti_dev, "bad config data\n"); in ti_handle_events()
972 device_printf(sc->ti_dev, "unknown event: %d\n", in ti_handle_events()
977 TI_INC(sc->ti_ev_saved_considx, TI_EVENT_RING_CNT); in ti_handle_events()
978 CSR_WRITE_4(sc, TI_GCR_EVENTCONS_IDX, sc->ti_ev_saved_considx); in ti_handle_events()
980 bus_dmamap_sync(sc->ti_cdata.ti_event_ring_tag, in ti_handle_events()
981 sc->ti_cdata.ti_event_ring_map, BUS_DMASYNC_PREREAD); in ti_handle_events()
999 ctx->ti_busaddr = segs->ds_addr; in ti_dma_map_addr()
1010 error = bus_dma_tag_create(sc->ti_cdata.ti_parent_tag, in ti_dma_ring_alloc()
1014 device_printf(sc->ti_dev, in ti_dma_ring_alloc()
1022 device_printf(sc->ti_dev, in ti_dma_ring_alloc()
1031 device_printf(sc->ti_dev, in ti_dma_ring_alloc()
1065 if (sc->ti_dac == 0) in ti_dma_alloc()
1068 error = bus_dma_tag_create(bus_get_dma_tag(sc->ti_dev), 1, 0, lowaddr, in ti_dma_alloc()
1071 &sc->ti_cdata.ti_parent_tag); in ti_dma_alloc()
1073 device_printf(sc->ti_dev, in ti_dma_alloc()
1079 &sc->ti_cdata.ti_gib_tag, (uint8_t **)&sc->ti_rdata.ti_info, in ti_dma_alloc()
1080 &sc->ti_cdata.ti_gib_map, &sc->ti_rdata.ti_info_paddr, "GIB"); in ti_dma_alloc()
1086 &sc->ti_cdata.ti_status_tag, (uint8_t **)&sc->ti_rdata.ti_status, in ti_dma_alloc()
1087 &sc->ti_cdata.ti_status_map, &sc->ti_rdata.ti_status_paddr, in ti_dma_alloc()
1094 &sc->ti_cdata.ti_event_ring_tag, in ti_dma_alloc()
1095 (uint8_t **)&sc->ti_rdata.ti_event_ring, in ti_dma_alloc()
1096 &sc->ti_cdata.ti_event_ring_map, &sc->ti_rdata.ti_event_ring_paddr, in ti_dma_alloc()
1105 &sc->ti_cdata.ti_rx_std_ring_tag, in ti_dma_alloc()
1106 (uint8_t **)&sc->ti_rdata.ti_rx_std_ring, in ti_dma_alloc()
1107 &sc->ti_cdata.ti_rx_std_ring_map, in ti_dma_alloc()
1108 &sc->ti_rdata.ti_rx_std_ring_paddr, "RX ring"); in ti_dma_alloc()
1114 &sc->ti_cdata.ti_rx_jumbo_ring_tag, in ti_dma_alloc()
1115 (uint8_t **)&sc->ti_rdata.ti_rx_jumbo_ring, in ti_dma_alloc()
1116 &sc->ti_cdata.ti_rx_jumbo_ring_map, in ti_dma_alloc()
1117 &sc->ti_rdata.ti_rx_jumbo_ring_paddr, "jumbo RX ring"); in ti_dma_alloc()
1123 &sc->ti_cdata.ti_rx_return_ring_tag, in ti_dma_alloc()
1124 (uint8_t **)&sc->ti_rdata.ti_rx_return_ring, in ti_dma_alloc()
1125 &sc->ti_cdata.ti_rx_return_ring_map, in ti_dma_alloc()
1126 &sc->ti_rdata.ti_rx_return_ring_paddr, "RX return ring"); in ti_dma_alloc()
1131 error = bus_dma_tag_create(sc->ti_cdata.ti_parent_tag, 1, 0, in ti_dma_alloc()
1133 MCLBYTES, 0, NULL, NULL, &sc->ti_cdata.ti_rx_std_tag); in ti_dma_alloc()
1135 device_printf(sc->ti_dev, "could not allocate RX dma tag\n"); in ti_dma_alloc()
1145 error = bus_dma_tag_create(sc->ti_cdata.ti_parent_tag, 1, 0, in ti_dma_alloc()
1147 PAGE_SIZE, 0, NULL, NULL, &sc->ti_cdata.ti_rx_jumbo_tag); in ti_dma_alloc()
1149 error = bus_dma_tag_create(sc->ti_cdata.ti_parent_tag, 1, 0, in ti_dma_alloc()
1151 MJUM9BYTES, 0, NULL, NULL, &sc->ti_cdata.ti_rx_jumbo_tag); in ti_dma_alloc()
1154 device_printf(sc->ti_dev, in ti_dma_alloc()
1160 error = bus_dma_tag_create(sc->ti_cdata.ti_parent_tag, 1, in ti_dma_alloc()
1163 &sc->ti_cdata.ti_tx_tag); in ti_dma_alloc()
1165 device_printf(sc->ti_dev, "could not allocate TX dma tag\n"); in ti_dma_alloc()
1171 error = bus_dmamap_create(sc->ti_cdata.ti_rx_std_tag, 0, in ti_dma_alloc()
1172 &sc->ti_cdata.ti_rx_std_maps[i]); in ti_dma_alloc()
1174 device_printf(sc->ti_dev, in ti_dma_alloc()
1179 error = bus_dmamap_create(sc->ti_cdata.ti_rx_std_tag, 0, in ti_dma_alloc()
1180 &sc->ti_cdata.ti_rx_std_sparemap); in ti_dma_alloc()
1182 device_printf(sc->ti_dev, in ti_dma_alloc()
1189 error = bus_dmamap_create(sc->ti_cdata.ti_rx_jumbo_tag, 0, in ti_dma_alloc()
1190 &sc->ti_cdata.ti_rx_jumbo_maps[i]); in ti_dma_alloc()
1192 device_printf(sc->ti_dev, in ti_dma_alloc()
1197 error = bus_dmamap_create(sc->ti_cdata.ti_rx_jumbo_tag, 0, in ti_dma_alloc()
1198 &sc->ti_cdata.ti_rx_jumbo_sparemap); in ti_dma_alloc()
1200 device_printf(sc->ti_dev, in ti_dma_alloc()
1207 error = bus_dmamap_create(sc->ti_cdata.ti_tx_tag, 0, in ti_dma_alloc()
1208 &sc->ti_cdata.ti_txdesc[i].tx_dmamap); in ti_dma_alloc()
1210 device_printf(sc->ti_dev, in ti_dma_alloc()
1217 if (sc->ti_hwrev == TI_HWREV_TIGON) in ti_dma_alloc()
1222 &sc->ti_cdata.ti_tx_ring_tag, (uint8_t **)&sc->ti_rdata.ti_tx_ring, in ti_dma_alloc()
1223 &sc->ti_cdata.ti_tx_ring_map, &sc->ti_rdata.ti_tx_ring_paddr, in ti_dma_alloc()
1230 &sc->ti_cdata.ti_rx_mini_ring_tag, in ti_dma_alloc()
1231 (uint8_t **)&sc->ti_rdata.ti_rx_mini_ring, in ti_dma_alloc()
1232 &sc->ti_cdata.ti_rx_mini_ring_map, in ti_dma_alloc()
1233 &sc->ti_rdata.ti_rx_mini_ring_paddr, "mini RX ring"); in ti_dma_alloc()
1238 error = bus_dma_tag_create(sc->ti_cdata.ti_parent_tag, 1, 0, in ti_dma_alloc()
1240 MHLEN, 0, NULL, NULL, &sc->ti_cdata.ti_rx_mini_tag); in ti_dma_alloc()
1242 device_printf(sc->ti_dev, in ti_dma_alloc()
1249 error = bus_dmamap_create(sc->ti_cdata.ti_rx_mini_tag, 0, in ti_dma_alloc()
1250 &sc->ti_cdata.ti_rx_mini_maps[i]); in ti_dma_alloc()
1252 device_printf(sc->ti_dev, in ti_dma_alloc()
1257 error = bus_dmamap_create(sc->ti_cdata.ti_rx_mini_tag, 0, in ti_dma_alloc()
1258 &sc->ti_cdata.ti_rx_mini_sparemap); in ti_dma_alloc()
1260 device_printf(sc->ti_dev, in ti_dma_alloc()
1275 if (sc->ti_cdata.ti_rx_std_maps[i]) { in ti_dma_free()
1276 bus_dmamap_destroy(sc->ti_cdata.ti_rx_std_tag, in ti_dma_free()
1277 sc->ti_cdata.ti_rx_std_maps[i]); in ti_dma_free()
1278 sc->ti_cdata.ti_rx_std_maps[i] = NULL; in ti_dma_free()
1281 if (sc->ti_cdata.ti_rx_std_sparemap) { in ti_dma_free()
1282 bus_dmamap_destroy(sc->ti_cdata.ti_rx_std_tag, in ti_dma_free()
1283 sc->ti_cdata.ti_rx_std_sparemap); in ti_dma_free()
1284 sc->ti_cdata.ti_rx_std_sparemap = NULL; in ti_dma_free()
1286 if (sc->ti_cdata.ti_rx_std_tag) { in ti_dma_free()
1287 bus_dma_tag_destroy(sc->ti_cdata.ti_rx_std_tag); in ti_dma_free()
1288 sc->ti_cdata.ti_rx_std_tag = NULL; in ti_dma_free()
1293 if (sc->ti_cdata.ti_rx_jumbo_maps[i]) { in ti_dma_free()
1294 bus_dmamap_destroy(sc->ti_cdata.ti_rx_jumbo_tag, in ti_dma_free()
1295 sc->ti_cdata.ti_rx_jumbo_maps[i]); in ti_dma_free()
1296 sc->ti_cdata.ti_rx_jumbo_maps[i] = NULL; in ti_dma_free()
1299 if (sc->ti_cdata.ti_rx_jumbo_sparemap) { in ti_dma_free()
1300 bus_dmamap_destroy(sc->ti_cdata.ti_rx_jumbo_tag, in ti_dma_free()
1301 sc->ti_cdata.ti_rx_jumbo_sparemap); in ti_dma_free()
1302 sc->ti_cdata.ti_rx_jumbo_sparemap = NULL; in ti_dma_free()
1304 if (sc->ti_cdata.ti_rx_jumbo_tag) { in ti_dma_free()
1305 bus_dma_tag_destroy(sc->ti_cdata.ti_rx_jumbo_tag); in ti_dma_free()
1306 sc->ti_cdata.ti_rx_jumbo_tag = NULL; in ti_dma_free()
1311 if (sc->ti_cdata.ti_rx_mini_maps[i]) { in ti_dma_free()
1312 bus_dmamap_destroy(sc->ti_cdata.ti_rx_mini_tag, in ti_dma_free()
1313 sc->ti_cdata.ti_rx_mini_maps[i]); in ti_dma_free()
1314 sc->ti_cdata.ti_rx_mini_maps[i] = NULL; in ti_dma_free()
1317 if (sc->ti_cdata.ti_rx_mini_sparemap) { in ti_dma_free()
1318 bus_dmamap_destroy(sc->ti_cdata.ti_rx_mini_tag, in ti_dma_free()
1319 sc->ti_cdata.ti_rx_mini_sparemap); in ti_dma_free()
1320 sc->ti_cdata.ti_rx_mini_sparemap = NULL; in ti_dma_free()
1322 if (sc->ti_cdata.ti_rx_mini_tag) { in ti_dma_free()
1323 bus_dma_tag_destroy(sc->ti_cdata.ti_rx_mini_tag); in ti_dma_free()
1324 sc->ti_cdata.ti_rx_mini_tag = NULL; in ti_dma_free()
1329 if (sc->ti_cdata.ti_txdesc[i].tx_dmamap) { in ti_dma_free()
1330 bus_dmamap_destroy(sc->ti_cdata.ti_tx_tag, in ti_dma_free()
1331 sc->ti_cdata.ti_txdesc[i].tx_dmamap); in ti_dma_free()
1332 sc->ti_cdata.ti_txdesc[i].tx_dmamap = NULL; in ti_dma_free()
1335 if (sc->ti_cdata.ti_tx_tag) { in ti_dma_free()
1336 bus_dma_tag_destroy(sc->ti_cdata.ti_tx_tag); in ti_dma_free()
1337 sc->ti_cdata.ti_tx_tag = NULL; in ti_dma_free()
1341 ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_std_ring_tag, in ti_dma_free()
1342 (void *)&sc->ti_rdata.ti_rx_std_ring, in ti_dma_free()
1343 sc->ti_cdata.ti_rx_std_ring_map, in ti_dma_free()
1344 &sc->ti_rdata.ti_rx_std_ring_paddr); in ti_dma_free()
1346 ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_jumbo_ring_tag, in ti_dma_free()
1347 (void *)&sc->ti_rdata.ti_rx_jumbo_ring, in ti_dma_free()
1348 sc->ti_cdata.ti_rx_jumbo_ring_map, in ti_dma_free()
1349 &sc->ti_rdata.ti_rx_jumbo_ring_paddr); in ti_dma_free()
1351 ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_mini_ring_tag, in ti_dma_free()
1352 (void *)&sc->ti_rdata.ti_rx_mini_ring, in ti_dma_free()
1353 sc->ti_cdata.ti_rx_mini_ring_map, in ti_dma_free()
1354 &sc->ti_rdata.ti_rx_mini_ring_paddr); in ti_dma_free()
1356 ti_dma_ring_free(sc, &sc->ti_cdata.ti_rx_return_ring_tag, in ti_dma_free()
1357 (void *)&sc->ti_rdata.ti_rx_return_ring, in ti_dma_free()
1358 sc->ti_cdata.ti_rx_return_ring_map, in ti_dma_free()
1359 &sc->ti_rdata.ti_rx_return_ring_paddr); in ti_dma_free()
1361 ti_dma_ring_free(sc, &sc->ti_cdata.ti_tx_ring_tag, in ti_dma_free()
1362 (void *)&sc->ti_rdata.ti_tx_ring, sc->ti_cdata.ti_tx_ring_map, in ti_dma_free()
1363 &sc->ti_rdata.ti_tx_ring_paddr); in ti_dma_free()
1365 ti_dma_ring_free(sc, &sc->ti_cdata.ti_status_tag, in ti_dma_free()
1366 (void *)&sc->ti_rdata.ti_status, sc->ti_cdata.ti_status_map, in ti_dma_free()
1367 &sc->ti_rdata.ti_status_paddr); in ti_dma_free()
1369 ti_dma_ring_free(sc, &sc->ti_cdata.ti_event_ring_tag, in ti_dma_free()
1370 (void *)&sc->ti_rdata.ti_event_ring, in ti_dma_free()
1371 sc->ti_cdata.ti_event_ring_map, &sc->ti_rdata.ti_event_ring_paddr); in ti_dma_free()
1373 ti_dma_ring_free(sc, &sc->ti_cdata.ti_gib_tag, in ti_dma_free()
1374 (void *)&sc->ti_rdata.ti_info, sc->ti_cdata.ti_gib_map, in ti_dma_free()
1375 &sc->ti_rdata.ti_info_paddr); in ti_dma_free()
1378 if (sc->ti_cdata.ti_parent_tag) { in ti_dma_free()
1379 bus_dma_tag_destroy(sc->ti_cdata.ti_parent_tag); in ti_dma_free()
1380 sc->ti_cdata.ti_parent_tag = NULL; in ti_dma_free()
1399 m->m_len = m->m_pkthdr.len = MCLBYTES; in ti_newbuf_std()
1402 error = bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_rx_std_tag, in ti_newbuf_std()
1403 sc->ti_cdata.ti_rx_std_sparemap, m, segs, &nsegs, 0); in ti_newbuf_std()
1410 if (sc->ti_cdata.ti_rx_std_chain[i] != NULL) { in ti_newbuf_std()
1411 bus_dmamap_sync(sc->ti_cdata.ti_rx_std_tag, in ti_newbuf_std()
1412 sc->ti_cdata.ti_rx_std_maps[i], BUS_DMASYNC_POSTREAD); in ti_newbuf_std()
1413 bus_dmamap_unload(sc->ti_cdata.ti_rx_std_tag, in ti_newbuf_std()
1414 sc->ti_cdata.ti_rx_std_maps[i]); in ti_newbuf_std()
1417 map = sc->ti_cdata.ti_rx_std_maps[i]; in ti_newbuf_std()
1418 sc->ti_cdata.ti_rx_std_maps[i] = sc->ti_cdata.ti_rx_std_sparemap; in ti_newbuf_std()
1419 sc->ti_cdata.ti_rx_std_sparemap = map; in ti_newbuf_std()
1420 sc->ti_cdata.ti_rx_std_chain[i] = m; in ti_newbuf_std()
1422 r = &sc->ti_rdata.ti_rx_std_ring[i]; in ti_newbuf_std()
1423 ti_hostaddr64(&r->ti_addr, segs[0].ds_addr); in ti_newbuf_std()
1424 r->ti_len = segs[0].ds_len; in ti_newbuf_std()
1425 r->ti_type = TI_BDTYPE_RECV_BD; in ti_newbuf_std()
1426 r->ti_flags = 0; in ti_newbuf_std()
1427 r->ti_vlan_tag = 0; in ti_newbuf_std()
1428 r->ti_tcp_udp_cksum = 0; in ti_newbuf_std()
1429 if (if_getcapenable(sc->ti_ifp) & IFCAP_RXCSUM) in ti_newbuf_std()
1430 r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM; in ti_newbuf_std()
1431 r->ti_idx = i; in ti_newbuf_std()
1433 bus_dmamap_sync(sc->ti_cdata.ti_rx_std_tag, in ti_newbuf_std()
1434 sc->ti_cdata.ti_rx_std_maps[i], BUS_DMASYNC_PREREAD); in ti_newbuf_std()
1454 m->m_len = m->m_pkthdr.len = MHLEN; in ti_newbuf_mini()
1457 error = bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_rx_mini_tag, in ti_newbuf_mini()
1458 sc->ti_cdata.ti_rx_mini_sparemap, m, segs, &nsegs, 0); in ti_newbuf_mini()
1465 if (sc->ti_cdata.ti_rx_mini_chain[i] != NULL) { in ti_newbuf_mini()
1466 bus_dmamap_sync(sc->ti_cdata.ti_rx_mini_tag, in ti_newbuf_mini()
1467 sc->ti_cdata.ti_rx_mini_maps[i], BUS_DMASYNC_POSTREAD); in ti_newbuf_mini()
1468 bus_dmamap_unload(sc->ti_cdata.ti_rx_mini_tag, in ti_newbuf_mini()
1469 sc->ti_cdata.ti_rx_mini_maps[i]); in ti_newbuf_mini()
1472 map = sc->ti_cdata.ti_rx_mini_maps[i]; in ti_newbuf_mini()
1473 sc->ti_cdata.ti_rx_mini_maps[i] = sc->ti_cdata.ti_rx_mini_sparemap; in ti_newbuf_mini()
1474 sc->ti_cdata.ti_rx_mini_sparemap = map; in ti_newbuf_mini()
1475 sc->ti_cdata.ti_rx_mini_chain[i] = m; in ti_newbuf_mini()
1477 r = &sc->ti_rdata.ti_rx_mini_ring[i]; in ti_newbuf_mini()
1478 ti_hostaddr64(&r->ti_addr, segs[0].ds_addr); in ti_newbuf_mini()
1479 r->ti_len = segs[0].ds_len; in ti_newbuf_mini()
1480 r->ti_type = TI_BDTYPE_RECV_BD; in ti_newbuf_mini()
1481 r->ti_flags = TI_BDFLAG_MINI_RING; in ti_newbuf_mini()
1482 r->ti_vlan_tag = 0; in ti_newbuf_mini()
1483 r->ti_tcp_udp_cksum = 0; in ti_newbuf_mini()
1484 if (if_getcapenable(sc->ti_ifp) & IFCAP_RXCSUM) in ti_newbuf_mini()
1485 r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM; in ti_newbuf_mini()
1486 r->ti_idx = i; in ti_newbuf_mini()
1488 bus_dmamap_sync(sc->ti_cdata.ti_rx_mini_tag, in ti_newbuf_mini()
1489 sc->ti_cdata.ti_rx_mini_maps[i], BUS_DMASYNC_PREREAD); in ti_newbuf_mini()
1513 m->m_len = m->m_pkthdr.len = MJUM9BYTES; in ti_newbuf_jumbo()
1516 error = bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_rx_jumbo_tag, in ti_newbuf_jumbo()
1517 sc->ti_cdata.ti_rx_jumbo_sparemap, m, segs, &nsegs, 0); in ti_newbuf_jumbo()
1524 if (sc->ti_cdata.ti_rx_jumbo_chain[i] != NULL) { in ti_newbuf_jumbo()
1525 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_tag, in ti_newbuf_jumbo()
1526 sc->ti_cdata.ti_rx_jumbo_maps[i], BUS_DMASYNC_POSTREAD); in ti_newbuf_jumbo()
1527 bus_dmamap_unload(sc->ti_cdata.ti_rx_jumbo_tag, in ti_newbuf_jumbo()
1528 sc->ti_cdata.ti_rx_jumbo_maps[i]); in ti_newbuf_jumbo()
1531 map = sc->ti_cdata.ti_rx_jumbo_maps[i]; in ti_newbuf_jumbo()
1532 sc->ti_cdata.ti_rx_jumbo_maps[i] = sc->ti_cdata.ti_rx_jumbo_sparemap; in ti_newbuf_jumbo()
1533 sc->ti_cdata.ti_rx_jumbo_sparemap = map; in ti_newbuf_jumbo()
1534 sc->ti_cdata.ti_rx_jumbo_chain[i] = m; in ti_newbuf_jumbo()
1536 r = &sc->ti_rdata.ti_rx_jumbo_ring[i]; in ti_newbuf_jumbo()
1537 ti_hostaddr64(&r->ti_addr, segs[0].ds_addr); in ti_newbuf_jumbo()
1538 r->ti_len = segs[0].ds_len; in ti_newbuf_jumbo()
1539 r->ti_type = TI_BDTYPE_RECV_JUMBO_BD; in ti_newbuf_jumbo()
1540 r->ti_flags = TI_BDFLAG_JUMBO_RING; in ti_newbuf_jumbo()
1541 r->ti_vlan_tag = 0; in ti_newbuf_jumbo()
1542 r->ti_tcp_udp_cksum = 0; in ti_newbuf_jumbo()
1543 if (if_getcapenable(sc->ti_ifp) & IFCAP_RXCSUM) in ti_newbuf_jumbo()
1544 r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM; in ti_newbuf_jumbo()
1545 r->ti_idx = i; in ti_newbuf_jumbo()
1547 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_tag, in ti_newbuf_jumbo()
1548 sc->ti_cdata.ti_rx_jumbo_maps[i], BUS_DMASYNC_PREREAD); in ti_newbuf_jumbo()
1585 cur = m_old->m_next; in ti_newbuf_jumbo()
1588 cur = cur->m_next; in ti_newbuf_jumbo()
1594 device_printf(sc->ti_dev, "mbuf allocation failed " in ti_newbuf_jumbo()
1595 "-- packet dropped!\n"); in ti_newbuf_jumbo()
1600 device_printf(sc->ti_dev, "cluster mbuf allocation " in ti_newbuf_jumbo()
1601 "failed -- packet dropped!\n"); in ti_newbuf_jumbo()
1605 device_printf(sc->ti_dev, "mbuf allocation failed " in ti_newbuf_jumbo()
1606 "-- packet dropped!\n"); in ti_newbuf_jumbo()
1609 m[NPAYLOAD]->m_len = MCLBYTES; in ti_newbuf_jumbo()
1614 device_printf(sc->ti_dev, "mbuf allocation " in ti_newbuf_jumbo()
1615 "failed -- packet dropped!\n"); in ti_newbuf_jumbo()
1621 device_printf(sc->ti_dev, "buffer allocation " in ti_newbuf_jumbo()
1622 "failed -- packet dropped!\n"); in ti_newbuf_jumbo()
1630 device_printf(sc->ti_dev, "buffer allocation " in ti_newbuf_jumbo()
1631 "failed -- packet dropped!\n"); in ti_newbuf_jumbo()
1638 m[i]->m_data = (void *)sf_buf_kva(sf[i]); in ti_newbuf_jumbo()
1639 m[i]->m_len = PAGE_SIZE; in ti_newbuf_jumbo()
1643 m[i]->m_next = m[i+1]; in ti_newbuf_jumbo()
1646 m_new->m_next = m[0]; in ti_newbuf_jumbo()
1647 m_new->m_data += ETHER_ALIGN; in ti_newbuf_jumbo()
1648 if (sc->ti_hdrsplit) in ti_newbuf_jumbo()
1649 m_new->m_len = MHLEN - ETHER_ALIGN; in ti_newbuf_jumbo()
1651 m_new->m_len = HDR_LEN; in ti_newbuf_jumbo()
1652 m_new->m_pkthdr.len = NPAYLOAD * PAGE_SIZE + m_new->m_len; in ti_newbuf_jumbo()
1656 r = &sc->ti_rdata.ti_rx_jumbo_ring[idx]; in ti_newbuf_jumbo()
1657 sc->ti_cdata.ti_rx_jumbo_chain[idx] = m_new; in ti_newbuf_jumbo()
1658 map = sc->ti_cdata.ti_rx_jumbo_maps[i]; in ti_newbuf_jumbo()
1659 if (bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_rx_jumbo_tag, map, m_new, in ti_newbuf_jumbo()
1664 ti_hostaddr64(&r->ti_addr0, segs[0].ds_addr); in ti_newbuf_jumbo()
1665 r->ti_len0 = m_new->m_len; in ti_newbuf_jumbo()
1667 ti_hostaddr64(&r->ti_addr1, segs[1].ds_addr); in ti_newbuf_jumbo()
1668 r->ti_len1 = PAGE_SIZE; in ti_newbuf_jumbo()
1670 ti_hostaddr64(&r->ti_addr2, segs[2].ds_addr); in ti_newbuf_jumbo()
1671 r->ti_len2 = m[1]->m_ext.ext_size; /* could be PAGE_SIZE or MCLBYTES */ in ti_newbuf_jumbo()
1674 ti_hostaddr64(&r->ti_addr3, segs[3].ds_addr); in ti_newbuf_jumbo()
1675 r->ti_len3 = MCLBYTES; in ti_newbuf_jumbo()
1677 r->ti_len3 = 0; in ti_newbuf_jumbo()
1679 r->ti_type = TI_BDTYPE_RECV_JUMBO_BD; in ti_newbuf_jumbo()
1681 r->ti_flags = TI_BDFLAG_JUMBO_RING|TI_RCB_FLAG_USE_EXT_RX_BD; in ti_newbuf_jumbo()
1683 if (if_getcapenable(sc->ti_ifp) & IFCAP_RXCSUM) in ti_newbuf_jumbo()
1684 r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM|TI_BDFLAG_IP_CKSUM; in ti_newbuf_jumbo()
1686 r->ti_idx = idx; in ti_newbuf_jumbo()
1688 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_tag, map, BUS_DMASYNC_PREREAD); in ti_newbuf_jumbo()
1729 sc->ti_std = TI_STD_RX_RING_CNT - 1; in ti_init_rx_ring_std()
1730 TI_UPDATE_STDPROD(sc, TI_STD_RX_RING_CNT - 1); in ti_init_rx_ring_std()
1742 if (sc->ti_cdata.ti_rx_std_chain[i] != NULL) { in ti_free_rx_ring_std()
1743 map = sc->ti_cdata.ti_rx_std_maps[i]; in ti_free_rx_ring_std()
1744 bus_dmamap_sync(sc->ti_cdata.ti_rx_std_tag, map, in ti_free_rx_ring_std()
1746 bus_dmamap_unload(sc->ti_cdata.ti_rx_std_tag, map); in ti_free_rx_ring_std()
1747 m_freem(sc->ti_cdata.ti_rx_std_chain[i]); in ti_free_rx_ring_std()
1748 sc->ti_cdata.ti_rx_std_chain[i] = NULL; in ti_free_rx_ring_std()
1751 bzero(sc->ti_rdata.ti_rx_std_ring, TI_STD_RX_RING_SZ); in ti_free_rx_ring_std()
1752 bus_dmamap_sync(sc->ti_cdata.ti_rx_std_ring_tag, in ti_free_rx_ring_std()
1753 sc->ti_cdata.ti_rx_std_ring_map, BUS_DMASYNC_PREWRITE); in ti_free_rx_ring_std()
1767 sc->ti_jumbo = TI_JUMBO_RX_RING_CNT - 1; in ti_init_rx_ring_jumbo()
1768 TI_UPDATE_JUMBOPROD(sc, TI_JUMBO_RX_RING_CNT - 1); in ti_init_rx_ring_jumbo()
1780 if (sc->ti_cdata.ti_rx_jumbo_chain[i] != NULL) { in ti_free_rx_ring_jumbo()
1781 map = sc->ti_cdata.ti_rx_jumbo_maps[i]; in ti_free_rx_ring_jumbo()
1782 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_tag, map, in ti_free_rx_ring_jumbo()
1784 bus_dmamap_unload(sc->ti_cdata.ti_rx_jumbo_tag, map); in ti_free_rx_ring_jumbo()
1785 m_freem(sc->ti_cdata.ti_rx_jumbo_chain[i]); in ti_free_rx_ring_jumbo()
1786 sc->ti_cdata.ti_rx_jumbo_chain[i] = NULL; in ti_free_rx_ring_jumbo()
1789 bzero(sc->ti_rdata.ti_rx_jumbo_ring, TI_JUMBO_RX_RING_SZ); in ti_free_rx_ring_jumbo()
1790 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_ring_tag, in ti_free_rx_ring_jumbo()
1791 sc->ti_cdata.ti_rx_jumbo_ring_map, BUS_DMASYNC_PREWRITE); in ti_free_rx_ring_jumbo()
1804 sc->ti_mini = TI_MINI_RX_RING_CNT - 1; in ti_init_rx_ring_mini()
1805 TI_UPDATE_MINIPROD(sc, TI_MINI_RX_RING_CNT - 1); in ti_init_rx_ring_mini()
1816 if (sc->ti_rdata.ti_rx_mini_ring == NULL) in ti_free_rx_ring_mini()
1820 if (sc->ti_cdata.ti_rx_mini_chain[i] != NULL) { in ti_free_rx_ring_mini()
1821 map = sc->ti_cdata.ti_rx_mini_maps[i]; in ti_free_rx_ring_mini()
1822 bus_dmamap_sync(sc->ti_cdata.ti_rx_mini_tag, map, in ti_free_rx_ring_mini()
1824 bus_dmamap_unload(sc->ti_cdata.ti_rx_mini_tag, map); in ti_free_rx_ring_mini()
1825 m_freem(sc->ti_cdata.ti_rx_mini_chain[i]); in ti_free_rx_ring_mini()
1826 sc->ti_cdata.ti_rx_mini_chain[i] = NULL; in ti_free_rx_ring_mini()
1829 bzero(sc->ti_rdata.ti_rx_mini_ring, TI_MINI_RX_RING_SZ); in ti_free_rx_ring_mini()
1830 bus_dmamap_sync(sc->ti_cdata.ti_rx_mini_ring_tag, in ti_free_rx_ring_mini()
1831 sc->ti_cdata.ti_rx_mini_ring_map, BUS_DMASYNC_PREWRITE); in ti_free_rx_ring_mini()
1840 if (sc->ti_rdata.ti_tx_ring == NULL) in ti_free_tx_ring()
1844 txd = &sc->ti_cdata.ti_txdesc[i]; in ti_free_tx_ring()
1845 if (txd->tx_m != NULL) { in ti_free_tx_ring()
1846 bus_dmamap_sync(sc->ti_cdata.ti_tx_tag, txd->tx_dmamap, in ti_free_tx_ring()
1848 bus_dmamap_unload(sc->ti_cdata.ti_tx_tag, in ti_free_tx_ring()
1849 txd->tx_dmamap); in ti_free_tx_ring()
1850 m_freem(txd->tx_m); in ti_free_tx_ring()
1851 txd->tx_m = NULL; in ti_free_tx_ring()
1854 bzero(sc->ti_rdata.ti_tx_ring, TI_TX_RING_SZ); in ti_free_tx_ring()
1855 bus_dmamap_sync(sc->ti_cdata.ti_tx_ring_tag, in ti_free_tx_ring()
1856 sc->ti_cdata.ti_tx_ring_map, BUS_DMASYNC_PREWRITE); in ti_free_tx_ring()
1865 STAILQ_INIT(&sc->ti_cdata.ti_txfreeq); in ti_init_tx_ring()
1866 STAILQ_INIT(&sc->ti_cdata.ti_txbusyq); in ti_init_tx_ring()
1868 txd = &sc->ti_cdata.ti_txdesc[i]; in ti_init_tx_ring()
1869 STAILQ_INSERT_TAIL(&sc->ti_cdata.ti_txfreeq, txd, tx_q); in ti_init_tx_ring()
1871 sc->ti_txcnt = 0; in ti_init_tx_ring()
1872 sc->ti_tx_saved_considx = 0; in ti_init_tx_ring()
1873 sc->ti_tx_saved_prodidx = 0; in ti_init_tx_ring()
1893 switch (sc->ti_hwrev) { in ti_add_mcast()
1905 device_printf(sc->ti_dev, "unknown hwrev\n"); in ti_add_mcast()
1921 switch (sc->ti_hwrev) { in ti_del_mcast()
1933 device_printf(sc->ti_dev, "unknown hwrev\n"); in ti_del_mcast()
1963 ifp = sc->ti_ifp; in ti_setmulti()
1982 /* Re-enable interrupts. */ in ti_setmulti()
2001 if (sc->ti_hwrev == TI_HWREV_TIGON) in ti_64bitslot_war()
2015 * Do endian, PCI and DMA initialization. Also check the on-board ROM
2016 * self-test results.
2026 sc->ti_linkstat = TI_EV_CODE_LINK_DOWN; in ti_chipinit()
2028 /* Set endianness before we access any non-PCI registers. */ in ti_chipinit()
2037 /* Check the ROM failed bit to see if self-tests passed. */ in ti_chipinit()
2039 device_printf(sc->ti_dev, "board self-diagnostics failed!\n"); in ti_chipinit()
2049 sc->ti_hwrev = TI_HWREV_TIGON; in ti_chipinit()
2052 sc->ti_hwrev = TI_HWREV_TIGON_II; in ti_chipinit()
2055 device_printf(sc->ti_dev, "unsupported chip revision\n"); in ti_chipinit()
2060 if (sc->ti_hwrev == TI_HWREV_TIGON_II) { in ti_chipinit()
2071 if (sc->ti_hwrev != TI_HWREV_TIGON) in ti_chipinit()
2072 sc->ti_hdrsplit = 1; in ti_chipinit()
2074 device_printf(sc->ti_dev, in ti_chipinit()
2080 if (sc->ti_hwrev == TI_HWREV_TIGON_II) { in ti_chipinit()
2109 device_printf(sc->ti_dev, "cache line size %d" in ti_chipinit()
2123 if (sc->ti_hdrsplit) in ti_chipinit()
2146 if ((if_getcapenable(sc->ti_ifp) & (IFCAP_TXCSUM | IFCAP_RXCSUM)) == 0) in ti_chipinit()
2154 device_printf(sc->ti_dev, "bios thinks we're in a 64 bit slot, " in ti_chipinit()
2175 ifp = sc->ti_ifp; in ti_gibinit()
2182 (uint64_t)sc->ti_rdata.ti_info_paddr >> 32); in ti_gibinit()
2184 sc->ti_rdata.ti_info_paddr & 0xFFFFFFFF); in ti_gibinit()
2186 /* Load the firmware into SRAM. */ in ti_gibinit()
2192 bzero(sc->ti_rdata.ti_event_ring, TI_EVENT_RING_SZ); in ti_gibinit()
2193 rcb = &sc->ti_rdata.ti_info->ti_ev_rcb; in ti_gibinit()
2194 ti_hostaddr64(&rcb->ti_hostaddr, sc->ti_rdata.ti_event_ring_paddr); in ti_gibinit()
2195 rcb->ti_flags = 0; in ti_gibinit()
2196 ti_hostaddr64(&sc->ti_rdata.ti_info->ti_ev_prodidx_ptr, in ti_gibinit()
2197 sc->ti_rdata.ti_status_paddr + in ti_gibinit()
2199 sc->ti_ev_prodidx.ti_idx = 0; in ti_gibinit()
2201 sc->ti_ev_saved_considx = 0; in ti_gibinit()
2204 rcb = &sc->ti_rdata.ti_info->ti_cmd_rcb; in ti_gibinit()
2205 ti_hostaddr64(&rcb->ti_hostaddr, TI_GCR_NIC_ADDR(TI_GCR_CMDRING)); in ti_gibinit()
2206 rcb->ti_flags = 0; in ti_gibinit()
2207 rcb->ti_max_len = 0; in ti_gibinit()
2213 sc->ti_cmd_saved_prodidx = 0; in ti_gibinit()
2217 * We re-use the current stats buffer for this to in ti_gibinit()
2220 bzero(&sc->ti_rdata.ti_info->ti_stats, sizeof(struct ti_stats)); in ti_gibinit()
2221 ti_hostaddr64(&sc->ti_rdata.ti_info->ti_refresh_stats_ptr, in ti_gibinit()
2222 sc->ti_rdata.ti_info_paddr + offsetof(struct ti_gib, ti_stats)); in ti_gibinit()
2225 rcb = &sc->ti_rdata.ti_info->ti_std_rx_rcb; in ti_gibinit()
2226 ti_hostaddr64(&rcb->ti_hostaddr, sc->ti_rdata.ti_rx_std_ring_paddr); in ti_gibinit()
2227 rcb->ti_max_len = TI_FRAMELEN; in ti_gibinit()
2228 rcb->ti_flags = 0; in ti_gibinit()
2230 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM | in ti_gibinit()
2233 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST; in ti_gibinit()
2236 rcb = &sc->ti_rdata.ti_info->ti_jumbo_rx_rcb; in ti_gibinit()
2237 ti_hostaddr64(&rcb->ti_hostaddr, sc->ti_rdata.ti_rx_jumbo_ring_paddr); in ti_gibinit()
2240 rcb->ti_max_len = MJUM9BYTES - ETHER_ALIGN; in ti_gibinit()
2241 rcb->ti_flags = 0; in ti_gibinit()
2243 rcb->ti_max_len = PAGE_SIZE; in ti_gibinit()
2244 rcb->ti_flags = TI_RCB_FLAG_USE_EXT_RX_BD; in ti_gibinit()
2247 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM | in ti_gibinit()
2250 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST; in ti_gibinit()
2257 rcb = &sc->ti_rdata.ti_info->ti_mini_rx_rcb; in ti_gibinit()
2258 ti_hostaddr64(&rcb->ti_hostaddr, sc->ti_rdata.ti_rx_mini_ring_paddr); in ti_gibinit()
2259 rcb->ti_max_len = MHLEN - ETHER_ALIGN; in ti_gibinit()
2260 if (sc->ti_hwrev == TI_HWREV_TIGON) in ti_gibinit()
2261 rcb->ti_flags = TI_RCB_FLAG_RING_DISABLED; in ti_gibinit()
2263 rcb->ti_flags = 0; in ti_gibinit()
2265 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM | in ti_gibinit()
2268 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST; in ti_gibinit()
2273 rcb = &sc->ti_rdata.ti_info->ti_return_rcb; in ti_gibinit()
2274 ti_hostaddr64(&rcb->ti_hostaddr, sc->ti_rdata.ti_rx_return_ring_paddr); in ti_gibinit()
2275 rcb->ti_flags = 0; in ti_gibinit()
2276 rcb->ti_max_len = TI_RETURN_RING_CNT; in ti_gibinit()
2277 ti_hostaddr64(&sc->ti_rdata.ti_info->ti_return_prodidx_ptr, in ti_gibinit()
2278 sc->ti_rdata.ti_status_paddr + in ti_gibinit()
2291 if (sc->ti_rdata.ti_tx_ring != NULL) in ti_gibinit()
2292 bzero(sc->ti_rdata.ti_tx_ring, TI_TX_RING_SZ); in ti_gibinit()
2293 rcb = &sc->ti_rdata.ti_info->ti_tx_rcb; in ti_gibinit()
2294 if (sc->ti_hwrev == TI_HWREV_TIGON) in ti_gibinit()
2295 rcb->ti_flags = 0; in ti_gibinit()
2297 rcb->ti_flags = TI_RCB_FLAG_HOST_RING; in ti_gibinit()
2299 rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST; in ti_gibinit()
2301 rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM | in ti_gibinit()
2303 rcb->ti_max_len = TI_TX_RING_CNT; in ti_gibinit()
2304 if (sc->ti_hwrev == TI_HWREV_TIGON) in ti_gibinit()
2305 ti_hostaddr64(&rcb->ti_hostaddr, TI_TX_RING_BASE); in ti_gibinit()
2307 ti_hostaddr64(&rcb->ti_hostaddr, in ti_gibinit()
2308 sc->ti_rdata.ti_tx_ring_paddr); in ti_gibinit()
2309 ti_hostaddr64(&sc->ti_rdata.ti_info->ti_tx_considx_ptr, in ti_gibinit()
2310 sc->ti_rdata.ti_status_paddr + in ti_gibinit()
2313 bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, sc->ti_cdata.ti_gib_map, in ti_gibinit()
2315 bus_dmamap_sync(sc->ti_cdata.ti_status_tag, sc->ti_cdata.ti_status_map, in ti_gibinit()
2317 bus_dmamap_sync(sc->ti_cdata.ti_event_ring_tag, in ti_gibinit()
2318 sc->ti_cdata.ti_event_ring_map, in ti_gibinit()
2320 if (sc->ti_rdata.ti_tx_ring != NULL) in ti_gibinit()
2321 bus_dmamap_sync(sc->ti_cdata.ti_tx_ring_tag, in ti_gibinit()
2322 sc->ti_cdata.ti_tx_ring_map, BUS_DMASYNC_PREWRITE); in ti_gibinit()
2328 (sc->ti_rx_coal_ticks / 10)); in ti_gibinit()
2331 CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS, sc->ti_rx_coal_ticks); in ti_gibinit()
2332 CSR_WRITE_4(sc, TI_GCR_TX_COAL_TICKS, sc->ti_tx_coal_ticks); in ti_gibinit()
2333 CSR_WRITE_4(sc, TI_GCR_STAT_TICKS, sc->ti_stat_ticks); in ti_gibinit()
2334 CSR_WRITE_4(sc, TI_GCR_RX_MAX_COAL_BD, sc->ti_rx_max_coal_bds); in ti_gibinit()
2335 CSR_WRITE_4(sc, TI_GCR_TX_MAX_COAL_BD, sc->ti_tx_max_coal_bds); in ti_gibinit()
2336 CSR_WRITE_4(sc, TI_GCR_TX_BUFFER_RATIO, sc->ti_tx_buf_ratio); in ti_gibinit()
2359 while (t->ti_name != NULL) { in ti_probe()
2360 if ((pci_get_vendor(dev) == t->ti_vid) && in ti_probe()
2361 (pci_get_device(dev) == t->ti_did)) { in ti_probe()
2362 device_set_desc(dev, t->ti_name); in ti_probe()
2380 sc->ti_dev = dev; in ti_attach()
2382 mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in ti_attach()
2384 callout_init_mtx(&sc->ti_watchdog, &sc->ti_mtx, 0); in ti_attach()
2385 ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts); in ti_attach()
2386 ifp = sc->ti_ifp = if_alloc(IFT_ETHER); in ti_attach()
2389 if_setcapenable(ifp, if_getcapabilities(sc->ti_ifp)); in ti_attach()
2397 sc->ti_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in ti_attach()
2400 if (sc->ti_res == NULL) { in ti_attach()
2406 sc->ti_btag = rman_get_bustag(sc->ti_res); in ti_attach()
2407 sc->ti_bhandle = rman_get_bushandle(sc->ti_res); in ti_attach()
2412 sc->ti_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in ti_attach()
2415 if (sc->ti_irq == NULL) { in ti_attach()
2427 /* Zero out the NIC's on-board SRAM. */ in ti_attach()
2428 ti_mem_zero(sc, 0x2000, 0x100000 - 0x2000); in ti_attach()
2430 /* Init again -- zeroing memory may have clobbered some registers. */ in ti_attach()
2451 sc->ti_membuf = malloc(sizeof(uint8_t) * TI_WINLEN, M_DEVBUF, M_NOWAIT); in ti_attach()
2452 sc->ti_membuf2 = malloc(sizeof(uint8_t) * TI_WINLEN, M_DEVBUF, in ti_attach()
2454 if (sc->ti_membuf == NULL || sc->ti_membuf2 == NULL) { in ti_attach()
2471 sc->ti_copper = 1; in ti_attach()
2475 sc->ti_copper = 1; in ti_attach()
2489 if_setsendqlen(ifp, TI_TX_RING_CNT - 1); in ti_attach()
2493 if (sc->ti_copper) { in ti_attach()
2502 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL); in ti_attach()
2503 ifmedia_add(&sc->ifmedia, in ti_attach()
2505 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_100_TX, 0, NULL); in ti_attach()
2506 ifmedia_add(&sc->ifmedia, in ti_attach()
2508 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_1000_T, 0, NULL); in ti_attach()
2509 ifmedia_add(&sc->ifmedia, in ti_attach()
2513 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_1000_SX, 0, NULL); in ti_attach()
2514 ifmedia_add(&sc->ifmedia, in ti_attach()
2517 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL); in ti_attach()
2518 ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO); in ti_attach()
2527 sc->dev = make_dev(&ti_cdevsw, device_get_unit(dev), UID_ROOT, in ti_attach()
2529 sc->dev->si_drv1 = sc; in ti_attach()
2540 /* Tell the upper layer we support VLAN over-sized frames. */ in ti_attach()
2548 error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET|INTR_MPSAFE, in ti_attach()
2549 NULL, ti_intr, sc, &sc->ti_intrhand); in ti_attach()
2577 if (sc->dev) in ti_detach()
2578 destroy_dev(sc->dev); in ti_detach()
2579 KASSERT(mtx_initialized(&sc->ti_mtx), ("ti mutex not initialized")); in ti_detach()
2580 ifp = sc->ti_ifp; in ti_detach()
2589 callout_drain(&sc->ti_watchdog); in ti_detach()
2592 ifmedia_removeall(&sc->ifmedia); in ti_detach()
2594 if (sc->ti_intrhand) in ti_detach()
2595 bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); in ti_detach()
2596 if (sc->ti_irq) in ti_detach()
2597 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq); in ti_detach()
2598 if (sc->ti_res) { in ti_detach()
2600 sc->ti_res); in ti_detach()
2604 if (sc->ti_membuf) in ti_detach()
2605 free(sc->ti_membuf, M_DEVBUF); in ti_detach()
2606 if (sc->ti_membuf2) in ti_detach()
2607 free(sc->ti_membuf2, M_DEVBUF); in ti_detach()
2609 mtx_destroy(&sc->ti_mtx); in ti_detach()
2621 * The header length, if it is non-zero, will always be the length of
2634 top->m_len = min(hdr_len, top->m_len); in ti_hdr_split()
2635 pkt_len -= top->m_len; in ti_hdr_split()
2636 lengths[i++] = top->m_len; in ti_hdr_split()
2639 for (m = top->m_next; m && pkt_len; m = m->m_next) { in ti_hdr_split()
2640 m->m_len = m->m_ext.ext_size = min(m->m_len, pkt_len); in ti_hdr_split()
2641 pkt_len -= m->m_len; in ti_hdr_split()
2642 lengths[i++] = m->m_len; in ti_hdr_split()
2650 printf("got non-split packet: "); in ti_hdr_split()
2663 mp->m_next = NULL; in ti_hdr_split()
2665 if (mp->m_next != NULL) in ti_hdr_split()
2676 r = &sc->ti_rdata.ti_rx_std_ring[i]; in ti_discard_std()
2677 r->ti_len = MCLBYTES - ETHER_ALIGN; in ti_discard_std()
2678 r->ti_type = TI_BDTYPE_RECV_BD; in ti_discard_std()
2679 r->ti_flags = 0; in ti_discard_std()
2680 r->ti_vlan_tag = 0; in ti_discard_std()
2681 r->ti_tcp_udp_cksum = 0; in ti_discard_std()
2682 if (if_getcapenable(sc->ti_ifp) & IFCAP_RXCSUM) in ti_discard_std()
2683 r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM; in ti_discard_std()
2684 r->ti_idx = i; in ti_discard_std()
2693 r = &sc->ti_rdata.ti_rx_mini_ring[i]; in ti_discard_mini()
2694 r->ti_len = MHLEN - ETHER_ALIGN; in ti_discard_mini()
2695 r->ti_type = TI_BDTYPE_RECV_BD; in ti_discard_mini()
2696 r->ti_flags = TI_BDFLAG_MINI_RING; in ti_discard_mini()
2697 r->ti_vlan_tag = 0; in ti_discard_mini()
2698 r->ti_tcp_udp_cksum = 0; in ti_discard_mini()
2699 if (if_getcapenable(sc->ti_ifp) & IFCAP_RXCSUM) in ti_discard_mini()
2700 r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM; in ti_discard_mini()
2701 r->ti_idx = i; in ti_discard_mini()
2711 r = &sc->ti_rdata.ti_rx_jumbo_ring[i]; in ti_discard_jumbo()
2712 r->ti_len = MJUM9BYTES - ETHER_ALIGN; in ti_discard_jumbo()
2713 r->ti_type = TI_BDTYPE_RECV_JUMBO_BD; in ti_discard_jumbo()
2714 r->ti_flags = TI_BDFLAG_JUMBO_RING; in ti_discard_jumbo()
2715 r->ti_vlan_tag = 0; in ti_discard_jumbo()
2716 r->ti_tcp_udp_cksum = 0; in ti_discard_jumbo()
2717 if (if_getcapenable(sc->ti_ifp) & IFCAP_RXCSUM) in ti_discard_jumbo()
2718 r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM | TI_BDFLAG_IP_CKSUM; in ti_discard_jumbo()
2719 r->ti_idx = i; in ti_discard_jumbo()
2746 ifp = sc->ti_ifp; in ti_rxeof()
2748 bus_dmamap_sync(sc->ti_cdata.ti_rx_std_ring_tag, in ti_rxeof()
2749 sc->ti_cdata.ti_rx_std_ring_map, BUS_DMASYNC_POSTWRITE); in ti_rxeof()
2751 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_ring_tag, in ti_rxeof()
2752 sc->ti_cdata.ti_rx_jumbo_ring_map, BUS_DMASYNC_POSTWRITE); in ti_rxeof()
2753 if (sc->ti_rdata.ti_rx_mini_ring != NULL) in ti_rxeof()
2754 bus_dmamap_sync(sc->ti_cdata.ti_rx_mini_ring_tag, in ti_rxeof()
2755 sc->ti_cdata.ti_rx_mini_ring_map, BUS_DMASYNC_POSTWRITE); in ti_rxeof()
2756 bus_dmamap_sync(sc->ti_cdata.ti_rx_return_ring_tag, in ti_rxeof()
2757 sc->ti_cdata.ti_rx_return_ring_map, BUS_DMASYNC_POSTREAD); in ti_rxeof()
2760 while (sc->ti_rx_saved_considx != sc->ti_return_prodidx.ti_idx) { in ti_rxeof()
2768 &sc->ti_rdata.ti_rx_return_ring[sc->ti_rx_saved_considx]; in ti_rxeof()
2769 rxidx = cur_rx->ti_idx; in ti_rxeof()
2770 ti_len = cur_rx->ti_len; in ti_rxeof()
2771 TI_INC(sc->ti_rx_saved_considx, TI_RETURN_RING_CNT); in ti_rxeof()
2773 if (cur_rx->ti_flags & TI_BDFLAG_VLAN_TAG) { in ti_rxeof()
2775 vlan_tag = cur_rx->ti_vlan_tag; in ti_rxeof()
2778 if (cur_rx->ti_flags & TI_BDFLAG_JUMBO_RING) { in ti_rxeof()
2780 TI_INC(sc->ti_jumbo, TI_JUMBO_RX_RING_CNT); in ti_rxeof()
2781 m = sc->ti_cdata.ti_rx_jumbo_chain[rxidx]; in ti_rxeof()
2783 if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { in ti_rxeof()
2793 m->m_len = ti_len; in ti_rxeof()
2795 sc->ti_cdata.ti_rx_jumbo_chain[rxidx] = NULL; in ti_rxeof()
2796 map = sc->ti_cdata.ti_rx_jumbo_maps[rxidx]; in ti_rxeof()
2797 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_tag, map, in ti_rxeof()
2799 bus_dmamap_unload(sc->ti_cdata.ti_rx_jumbo_tag, map); in ti_rxeof()
2800 if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { in ti_rxeof()
2802 ti_newbuf_jumbo(sc, sc->ti_jumbo, m); in ti_rxeof()
2805 if (ti_newbuf_jumbo(sc, sc->ti_jumbo, NULL) == ENOBUFS) { in ti_rxeof()
2807 ti_newbuf_jumbo(sc, sc->ti_jumbo, m); in ti_rxeof()
2811 if (sc->ti_hdrsplit) in ti_rxeof()
2812 ti_hdr_split(m, TI_HOSTADDR(cur_rx->ti_addr), in ti_rxeof()
2816 m_adj(m, ti_len - m->m_pkthdr.len); in ti_rxeof()
2818 } else if (cur_rx->ti_flags & TI_BDFLAG_MINI_RING) { in ti_rxeof()
2820 TI_INC(sc->ti_mini, TI_MINI_RX_RING_CNT); in ti_rxeof()
2821 m = sc->ti_cdata.ti_rx_mini_chain[rxidx]; in ti_rxeof()
2822 if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { in ti_rxeof()
2832 m->m_len = ti_len; in ti_rxeof()
2835 TI_INC(sc->ti_std, TI_STD_RX_RING_CNT); in ti_rxeof()
2836 m = sc->ti_cdata.ti_rx_std_chain[rxidx]; in ti_rxeof()
2837 if (cur_rx->ti_flags & TI_BDFLAG_ERROR) { in ti_rxeof()
2847 m->m_len = ti_len; in ti_rxeof()
2850 m->m_pkthdr.len = ti_len; in ti_rxeof()
2852 m->m_pkthdr.rcvif = ifp; in ti_rxeof()
2855 if (cur_rx->ti_flags & TI_BDFLAG_IP_CKSUM) { in ti_rxeof()
2856 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in ti_rxeof()
2857 if ((cur_rx->ti_ip_cksum ^ 0xffff) == 0) in ti_rxeof()
2858 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in ti_rxeof()
2860 if (cur_rx->ti_flags & TI_BDFLAG_TCP_UDP_CKSUM) { in ti_rxeof()
2861 m->m_pkthdr.csum_data = in ti_rxeof()
2862 cur_rx->ti_tcp_udp_cksum; in ti_rxeof()
2863 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; in ti_rxeof()
2872 m->m_pkthdr.ether_vtag = vlan_tag; in ti_rxeof()
2873 m->m_flags |= M_VLANTAG; in ti_rxeof()
2880 bus_dmamap_sync(sc->ti_cdata.ti_rx_return_ring_tag, in ti_rxeof()
2881 sc->ti_cdata.ti_rx_return_ring_map, BUS_DMASYNC_PREREAD); in ti_rxeof()
2883 if (sc->ti_hwrev == TI_HWREV_TIGON) in ti_rxeof()
2885 sc->ti_rx_saved_considx); in ti_rxeof()
2888 bus_dmamap_sync(sc->ti_cdata.ti_rx_std_ring_tag, in ti_rxeof()
2889 sc->ti_cdata.ti_rx_std_ring_map, BUS_DMASYNC_PREWRITE); in ti_rxeof()
2890 TI_UPDATE_STDPROD(sc, sc->ti_std); in ti_rxeof()
2893 bus_dmamap_sync(sc->ti_cdata.ti_rx_mini_ring_tag, in ti_rxeof()
2894 sc->ti_cdata.ti_rx_mini_ring_map, BUS_DMASYNC_PREWRITE); in ti_rxeof()
2895 TI_UPDATE_MINIPROD(sc, sc->ti_mini); in ti_rxeof()
2898 bus_dmamap_sync(sc->ti_cdata.ti_rx_jumbo_ring_tag, in ti_rxeof()
2899 sc->ti_cdata.ti_rx_jumbo_ring_map, BUS_DMASYNC_PREWRITE); in ti_rxeof()
2900 TI_UPDATE_JUMBOPROD(sc, sc->ti_jumbo); in ti_rxeof()
2913 ifp = sc->ti_ifp; in ti_txeof()
2915 txd = STAILQ_FIRST(&sc->ti_cdata.ti_txbusyq); in ti_txeof()
2919 if (sc->ti_rdata.ti_tx_ring != NULL) in ti_txeof()
2920 bus_dmamap_sync(sc->ti_cdata.ti_tx_ring_tag, in ti_txeof()
2921 sc->ti_cdata.ti_tx_ring_map, BUS_DMASYNC_POSTWRITE); in ti_txeof()
2926 for (idx = sc->ti_tx_saved_considx; idx != sc->ti_tx_considx.ti_idx; in ti_txeof()
2928 if (sc->ti_hwrev == TI_HWREV_TIGON) { in ti_txeof()
2933 cur_tx = &sc->ti_rdata.ti_tx_ring[idx]; in ti_txeof()
2934 sc->ti_txcnt--; in ti_txeof()
2936 if ((cur_tx->ti_flags & TI_BDFLAG_END) == 0) in ti_txeof()
2938 bus_dmamap_sync(sc->ti_cdata.ti_tx_tag, txd->tx_dmamap, in ti_txeof()
2940 bus_dmamap_unload(sc->ti_cdata.ti_tx_tag, txd->tx_dmamap); in ti_txeof()
2943 m_freem(txd->tx_m); in ti_txeof()
2944 txd->tx_m = NULL; in ti_txeof()
2945 STAILQ_REMOVE_HEAD(&sc->ti_cdata.ti_txbusyq, tx_q); in ti_txeof()
2946 STAILQ_INSERT_TAIL(&sc->ti_cdata.ti_txfreeq, txd, tx_q); in ti_txeof()
2947 txd = STAILQ_FIRST(&sc->ti_cdata.ti_txbusyq); in ti_txeof()
2949 sc->ti_tx_saved_considx = idx; in ti_txeof()
2950 if (sc->ti_txcnt == 0) in ti_txeof()
2951 sc->ti_timer = 0; in ti_txeof()
2962 ifp = sc->ti_ifp; in ti_intr()
2970 /* Ack interrupt and stop others from occurring. */ in ti_intr()
2974 bus_dmamap_sync(sc->ti_cdata.ti_status_tag, in ti_intr()
2975 sc->ti_cdata.ti_status_map, BUS_DMASYNC_POSTREAD); in ti_intr()
2981 bus_dmamap_sync(sc->ti_cdata.ti_status_tag, in ti_intr()
2982 sc->ti_cdata.ti_status_map, BUS_DMASYNC_PREREAD); in ti_intr()
2988 /* Re-enable interrupts. */ in ti_intr()
3009 s = &sc->ti_rdata.ti_info->ti_stats; in ti_get_counter()
3012 bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, in ti_get_counter()
3013 sc->ti_cdata.ti_gib_map, BUS_DMASYNC_POSTREAD); in ti_get_counter()
3014 rv = s->dot3StatsSingleCollisionFrames + in ti_get_counter()
3015 s->dot3StatsMultipleCollisionFrames + in ti_get_counter()
3016 s->dot3StatsExcessiveCollisions + in ti_get_counter()
3017 s->dot3StatsLateCollisions; in ti_get_counter()
3018 bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, in ti_get_counter()
3019 sc->ti_cdata.ti_gib_map, BUS_DMASYNC_PREREAD); in ti_get_counter()
3043 if ((txd = STAILQ_FIRST(&sc->ti_cdata.ti_txfreeq)) == NULL) in ti_encap()
3046 error = bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_tx_tag, txd->tx_dmamap, in ti_encap()
3056 error = bus_dmamap_load_mbuf_sg(sc->ti_cdata.ti_tx_tag, in ti_encap()
3057 txd->tx_dmamap, *m_head, txsegs, &nseg, 0); in ti_encap()
3071 if (sc->ti_txcnt + nseg >= TI_TX_RING_CNT) { in ti_encap()
3072 bus_dmamap_unload(sc->ti_cdata.ti_tx_tag, txd->tx_dmamap); in ti_encap()
3075 bus_dmamap_sync(sc->ti_cdata.ti_tx_tag, txd->tx_dmamap, in ti_encap()
3080 if (m->m_pkthdr.csum_flags & CSUM_IP) in ti_encap()
3082 if (m->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP)) in ti_encap()
3085 frag = sc->ti_tx_saved_prodidx; in ti_encap()
3087 if (sc->ti_hwrev == TI_HWREV_TIGON) { in ti_encap()
3091 f = &sc->ti_rdata.ti_tx_ring[frag]; in ti_encap()
3092 ti_hostaddr64(&f->ti_addr, txsegs[i].ds_addr); in ti_encap()
3093 f->ti_len = txsegs[i].ds_len; in ti_encap()
3094 f->ti_flags = csum_flags; in ti_encap()
3095 if (m->m_flags & M_VLANTAG) { in ti_encap()
3096 f->ti_flags |= TI_BDFLAG_VLAN_TAG; in ti_encap()
3097 f->ti_vlan_tag = m->m_pkthdr.ether_vtag; in ti_encap()
3099 f->ti_vlan_tag = 0; in ti_encap()
3102 if (sc->ti_hwrev == TI_HWREV_TIGON) in ti_encap()
3108 sc->ti_tx_saved_prodidx = frag; in ti_encap()
3110 frag = (frag + TI_TX_RING_CNT - 1) % TI_TX_RING_CNT; in ti_encap()
3111 if (sc->ti_hwrev == TI_HWREV_TIGON) { in ti_encap()
3116 sc->ti_rdata.ti_tx_ring[frag].ti_flags |= TI_BDFLAG_END; in ti_encap()
3118 STAILQ_REMOVE_HEAD(&sc->ti_cdata.ti_txfreeq, tx_q); in ti_encap()
3119 STAILQ_INSERT_TAIL(&sc->ti_cdata.ti_txbusyq, txd, tx_q); in ti_encap()
3120 txd->tx_m = m; in ti_encap()
3121 sc->ti_txcnt += nseg; in ti_encap()
3151 sc->ti_txcnt < (TI_TX_RING_CNT - 16);) { in ti_start_locked()
3178 if (sc->ti_rdata.ti_tx_ring != NULL) in ti_start_locked()
3179 bus_dmamap_sync(sc->ti_cdata.ti_tx_ring_tag, in ti_start_locked()
3180 sc->ti_cdata.ti_tx_ring_map, BUS_DMASYNC_PREWRITE); in ti_start_locked()
3182 CSR_WRITE_4(sc, TI_MB_SENDPROD_IDX, sc->ti_tx_saved_prodidx); in ti_start_locked()
3187 sc->ti_timer = 5; in ti_start_locked()
3207 if (if_getdrvflags(sc->ti_ifp) & IFF_DRV_RUNNING) in ti_init_locked()
3215 device_printf(sc->ti_dev, "initialization failure\n"); in ti_init_locked()
3230 ifp = sc->ti_ifp; in ti_init2()
3233 CSR_WRITE_4(sc, TI_GCR_IFINDEX, device_get_unit(sc->ti_dev)); in ti_init2()
3239 ea = if_getlladdr(sc->ti_ifp); in ti_init2()
3259 if (sc->ti_hwrev == TI_HWREV_TIGON) { in ti_init2()
3266 device_printf(sc->ti_dev, "no memory for std Rx buffers.\n"); in ti_init2()
3274 device_printf(sc->ti_dev, in ti_init2()
3284 if (sc->ti_hwrev == TI_HWREV_TIGON_II) { in ti_init2()
3287 device_printf(sc->ti_dev, in ti_init2()
3294 sc->ti_rx_saved_considx = 0; in ti_init2()
3307 callout_reset(&sc->ti_watchdog, hz, ti_watchdog, sc); in ti_init2()
3315 ifm = &sc->ifmedia; in ti_init2()
3316 tmp = ifm->ifm_media; in ti_init2()
3317 ifm->ifm_media = ifm->ifm_cur->ifm_media; in ti_init2()
3319 ifm->ifm_media = tmp; in ti_init2()
3346 ifm = &sc->ifmedia; in ti_ifmedia_upd_locked()
3348 if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) in ti_ifmedia_upd_locked()
3353 switch (IFM_SUBTYPE(ifm->ifm_media)) { in ti_ifmedia_upd_locked()
3367 if (sc->ti_hwrev != TI_HWREV_TIGON) in ti_ifmedia_upd_locked()
3377 if (sc->ti_hwrev != TI_HWREV_TIGON) in ti_ifmedia_upd_locked()
3391 if (sc->ti_hwrev != TI_HWREV_TIGON) in ti_ifmedia_upd_locked()
3398 if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) { in ti_ifmedia_upd_locked()
3410 if (sc->ti_hwrev != TI_HWREV_TIGON) in ti_ifmedia_upd_locked()
3416 if (IFM_SUBTYPE(ifm->ifm_media) == IFM_100_FX || in ti_ifmedia_upd_locked()
3417 IFM_SUBTYPE(ifm->ifm_media) == IFM_100_TX) { in ti_ifmedia_upd_locked()
3422 if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) { in ti_ifmedia_upd_locked()
3448 ifmr->ifm_status = IFM_AVALID; in ti_ifmedia_sts()
3449 ifmr->ifm_active = IFM_ETHER; in ti_ifmedia_sts()
3451 if (sc->ti_linkstat == TI_EV_CODE_LINK_DOWN) { in ti_ifmedia_sts()
3456 ifmr->ifm_status |= IFM_ACTIVE; in ti_ifmedia_sts()
3458 if (sc->ti_linkstat == TI_EV_CODE_GIG_LINK_UP) { in ti_ifmedia_sts()
3460 if (sc->ti_copper) in ti_ifmedia_sts()
3461 ifmr->ifm_active |= IFM_1000_T; in ti_ifmedia_sts()
3463 ifmr->ifm_active |= IFM_1000_SX; in ti_ifmedia_sts()
3465 ifmr->ifm_active |= IFM_FDX; in ti_ifmedia_sts()
3467 ifmr->ifm_active |= IFM_HDX; in ti_ifmedia_sts()
3468 } else if (sc->ti_linkstat == TI_EV_CODE_LINK_UP) { in ti_ifmedia_sts()
3470 if (sc->ti_copper) { in ti_ifmedia_sts()
3472 ifmr->ifm_active |= IFM_100_TX; in ti_ifmedia_sts()
3474 ifmr->ifm_active |= IFM_10_T; in ti_ifmedia_sts()
3477 ifmr->ifm_active |= IFM_100_FX; in ti_ifmedia_sts()
3479 ifmr->ifm_active |= IFM_10_FL; in ti_ifmedia_sts()
3482 ifmr->ifm_active |= IFM_FDX; in ti_ifmedia_sts()
3484 ifmr->ifm_active |= IFM_HDX; in ti_ifmedia_sts()
3500 if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > TI_JUMBO_MTU) in ti_ioctl()
3503 if_setmtu(ifp, ifr->ifr_mtu); in ti_ioctl()
3518 * a full re-init means reloading the firmware and in ti_ioctl()
3524 !(sc->ti_if_flags & IFF_PROMISC)) { in ti_ioctl()
3529 sc->ti_if_flags & IFF_PROMISC) { in ti_ioctl()
3539 sc->ti_if_flags = if_getflags(ifp); in ti_ioctl()
3551 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command); in ti_ioctl()
3555 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in ti_ioctl()
3596 sc = dev->si_drv1; in ti_open()
3601 sc->ti_flags |= TI_FLAG_DEBUGING; in ti_open()
3612 sc = dev->si_drv1; in ti_close()
3617 sc->ti_flags &= ~TI_FLAG_DEBUGING; in ti_close()
3633 sc = dev->si_drv1; in ti_ioctl2()
3647 bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, in ti_ioctl2()
3648 sc->ti_cdata.ti_gib_map, BUS_DMASYNC_POSTREAD); in ti_ioctl2()
3649 bcopy(&sc->ti_rdata.ti_info->ti_stats, outstats, in ti_ioctl2()
3651 bus_dmamap_sync(sc->ti_cdata.ti_gib_tag, in ti_ioctl2()
3652 sc->ti_cdata.ti_gib_map, BUS_DMASYNC_PREREAD); in ti_ioctl2()
3663 params->ti_stat_ticks = sc->ti_stat_ticks; in ti_ioctl2()
3664 params->ti_rx_coal_ticks = sc->ti_rx_coal_ticks; in ti_ioctl2()
3665 params->ti_tx_coal_ticks = sc->ti_tx_coal_ticks; in ti_ioctl2()
3666 params->ti_rx_max_coal_bds = sc->ti_rx_max_coal_bds; in ti_ioctl2()
3667 params->ti_tx_max_coal_bds = sc->ti_tx_max_coal_bds; in ti_ioctl2()
3668 params->ti_tx_buf_ratio = sc->ti_tx_buf_ratio; in ti_ioctl2()
3669 params->param_mask = TI_PARAM_ALL; in ti_ioctl2()
3680 if (params->param_mask & TI_PARAM_STAT_TICKS) { in ti_ioctl2()
3681 sc->ti_stat_ticks = params->ti_stat_ticks; in ti_ioctl2()
3682 CSR_WRITE_4(sc, TI_GCR_STAT_TICKS, sc->ti_stat_ticks); in ti_ioctl2()
3685 if (params->param_mask & TI_PARAM_RX_COAL_TICKS) { in ti_ioctl2()
3686 sc->ti_rx_coal_ticks = params->ti_rx_coal_ticks; in ti_ioctl2()
3688 sc->ti_rx_coal_ticks); in ti_ioctl2()
3691 if (params->param_mask & TI_PARAM_TX_COAL_TICKS) { in ti_ioctl2()
3692 sc->ti_tx_coal_ticks = params->ti_tx_coal_ticks; in ti_ioctl2()
3694 sc->ti_tx_coal_ticks); in ti_ioctl2()
3697 if (params->param_mask & TI_PARAM_RX_COAL_BDS) { in ti_ioctl2()
3698 sc->ti_rx_max_coal_bds = params->ti_rx_max_coal_bds; in ti_ioctl2()
3700 sc->ti_rx_max_coal_bds); in ti_ioctl2()
3703 if (params->param_mask & TI_PARAM_TX_COAL_BDS) { in ti_ioctl2()
3704 sc->ti_tx_max_coal_bds = params->ti_tx_max_coal_bds; in ti_ioctl2()
3706 sc->ti_tx_max_coal_bds); in ti_ioctl2()
3709 if (params->param_mask & TI_PARAM_TX_BUF_RATIO) { in ti_ioctl2()
3710 sc->ti_tx_buf_ratio = params->ti_tx_buf_ratio; in ti_ioctl2()
3712 sc->ti_tx_buf_ratio); in ti_ioctl2()
3743 if_printf(sc->ti_ifp, "trace_start = %#x, cur_trace_ptr = %#x, " in ti_ioctl2()
3746 if_printf(sc->ti_ifp, "trace_buf->buf_len = %d\n", in ti_ioctl2()
3747 trace_buf->buf_len); in ti_ioctl2()
3750 trace_buf->buf_len), (caddr_t)trace_buf->buf, 1, 1); in ti_ioctl2()
3752 trace_buf->fill_len = min(trace_len, in ti_ioctl2()
3753 trace_buf->buf_len); in ti_ioctl2()
3755 trace_buf->cur_trace_ptr = in ti_ioctl2()
3756 trace_start - cur_trace_ptr; in ti_ioctl2()
3758 trace_buf->cur_trace_ptr = in ti_ioctl2()
3759 cur_trace_ptr - trace_start; in ti_ioctl2()
3761 trace_buf->fill_len = 0; in ti_ioctl2()
3779 * like a not-so-good way to do things, since unless you in ti_ioctl2()
3793 if (sc->ti_hwrev == TI_HWREV_TIGON) { in ti_ioctl2()
3802 * For now, we'll only handle accessing regular SRAM, in ti_ioctl2()
3806 if (mem_param->tgAddr >= TI_BEG_SRAM && in ti_ioctl2()
3807 mem_param->tgAddr + mem_param->len <= sram_end) { in ti_ioctl2()
3812 error = ti_copy_mem(sc, mem_param->tgAddr, in ti_ioctl2()
3813 mem_param->len, mem_param->userAddr, 1, in ti_ioctl2()
3815 } else if (mem_param->tgAddr >= TI_BEG_SCRATCH && in ti_ioctl2()
3816 mem_param->tgAddr <= scratch_end) { in ti_ioctl2()
3817 error = ti_copy_scratch(sc, mem_param->tgAddr, in ti_ioctl2()
3818 mem_param->len, mem_param->userAddr, 1, in ti_ioctl2()
3820 } else if (mem_param->tgAddr >= TI_BEG_SCRATCH_B_DEBUG && in ti_ioctl2()
3821 mem_param->tgAddr <= TI_BEG_SCRATCH_B_DEBUG) { in ti_ioctl2()
3822 if (sc->ti_hwrev == TI_HWREV_TIGON) { in ti_ioctl2()
3823 if_printf(sc->ti_ifp, in ti_ioctl2()
3828 error = ti_copy_scratch(sc, mem_param->tgAddr - in ti_ioctl2()
3829 TI_SCRATCH_DEBUG_OFF, mem_param->len, in ti_ioctl2()
3830 mem_param->userAddr, 1, in ti_ioctl2()
3833 if_printf(sc->ti_ifp, "memory address %#x len %d is " in ti_ioctl2()
3835 mem_param->tgAddr, mem_param->len); in ti_ioctl2()
3852 if (regs->addr > TI_REG_MAX) { in ti_ioctl2()
3858 bus_space_read_region_4(sc->ti_btag, sc->ti_bhandle, in ti_ioctl2()
3859 regs->addr, &tmpval, 1); in ti_ioctl2()
3860 regs->data = ntohl(tmpval); in ti_ioctl2()
3862 if ((regs->addr == TI_CPU_STATE) in ti_ioctl2()
3863 || (regs->addr == TI_CPU_CTL_B)) { in ti_ioctl2()
3864 if_printf(sc->ti_ifp, "register %#x = %#x\n", in ti_ioctl2()
3865 regs->addr, tmpval); in ti_ioctl2()
3869 tmpval = htonl(regs->data); in ti_ioctl2()
3870 bus_space_write_region_4(sc->ti_btag, sc->ti_bhandle, in ti_ioctl2()
3871 regs->addr, &tmpval, 1); in ti_ioctl2()
3891 callout_reset(&sc->ti_watchdog, hz, ti_watchdog, sc); in ti_watchdog()
3892 if (sc->ti_timer == 0 || --sc->ti_timer > 0) in ti_watchdog()
3900 if (sc->ti_flags & TI_FLAG_DEBUGING) in ti_watchdog()
3903 ifp = sc->ti_ifp; in ti_watchdog()
3904 if_printf(ifp, "watchdog timeout -- resetting\n"); in ti_watchdog()
3923 ifp = sc->ti_ifp; in ti_stop()
3934 ti_mem_zero(sc, 0x2000, 0x100000 - 0x2000); in ti_stop()
3951 sc->ti_ev_prodidx.ti_idx = 0; in ti_stop()
3952 sc->ti_return_prodidx.ti_idx = 0; in ti_stop()
3953 sc->ti_tx_considx.ti_idx = 0; in ti_stop()
3954 sc->ti_tx_saved_considx = TI_TXCONS_UNSET; in ti_stop()
3957 callout_stop(&sc->ti_watchdog); in ti_stop()
3984 ctx = device_get_sysctl_ctx(sc->ti_dev); in ti_sysctl_node()
3985 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->ti_dev)); in ti_sysctl_node()
3988 sc->ti_dac = 1; in ti_sysctl_node()
3990 device_get_unit(sc->ti_dev)); in ti_sysctl_node()
3991 TUNABLE_INT_FETCH(tname, &sc->ti_dac); in ti_sysctl_node()
3994 &sc->ti_rx_coal_ticks, 0, "Receive coalcesced ticks"); in ti_sysctl_node()
3996 &sc->ti_rx_max_coal_bds, 0, "Receive max coalcesced BDs"); in ti_sysctl_node()
3999 &sc->ti_tx_coal_ticks, 0, "Send coalcesced ticks"); in ti_sysctl_node()
4001 &sc->ti_tx_max_coal_bds, 0, "Send max coalcesced BDs"); in ti_sysctl_node()
4003 &sc->ti_tx_buf_ratio, 0, in ti_sysctl_node()
4007 &sc->ti_stat_ticks, 0, in ti_sysctl_node()
4011 sc->ti_rx_coal_ticks = 170; in ti_sysctl_node()
4012 resource_int_value(device_get_name(sc->ti_dev), in ti_sysctl_node()
4013 device_get_unit(sc->ti_dev), "rx_coal_ticks", in ti_sysctl_node()
4014 &sc->ti_rx_coal_ticks); in ti_sysctl_node()
4015 sc->ti_rx_max_coal_bds = 64; in ti_sysctl_node()
4016 resource_int_value(device_get_name(sc->ti_dev), in ti_sysctl_node()
4017 device_get_unit(sc->ti_dev), "rx_max_coal_bds", in ti_sysctl_node()
4018 &sc->ti_rx_max_coal_bds); in ti_sysctl_node()
4020 sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500; in ti_sysctl_node()
4021 resource_int_value(device_get_name(sc->ti_dev), in ti_sysctl_node()
4022 device_get_unit(sc->ti_dev), "tx_coal_ticks", in ti_sysctl_node()
4023 &sc->ti_tx_coal_ticks); in ti_sysctl_node()
4024 sc->ti_tx_max_coal_bds = 32; in ti_sysctl_node()
4025 resource_int_value(device_get_name(sc->ti_dev), in ti_sysctl_node()
4026 device_get_unit(sc->ti_dev), "tx_max_coal_bds", in ti_sysctl_node()
4027 &sc->ti_tx_max_coal_bds); in ti_sysctl_node()
4028 sc->ti_tx_buf_ratio = 21; in ti_sysctl_node()
4029 resource_int_value(device_get_name(sc->ti_dev), in ti_sysctl_node()
4030 device_get_unit(sc->ti_dev), "tx_buf_ratio", in ti_sysctl_node()
4031 &sc->ti_tx_buf_ratio); in ti_sysctl_node()
4033 sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC; in ti_sysctl_node()
4034 resource_int_value(device_get_name(sc->ti_dev), in ti_sysctl_node()
4035 device_get_unit(sc->ti_dev), "stat_ticks", in ti_sysctl_node()
4036 &sc->ti_stat_ticks); in ti_sysctl_node()