Lines Matching defs:sc
345 ex_alloc_ring(elxl_t *sc, int count, ex_ring_t *r, uint_t dir)
347 dev_info_t *dip = sc->ex_dip;
360 elxl_error(sc, "unable to allocate descriptor dma handle");
368 elxl_error(sc, "unable to allocate descriptor memory");
377 elxl_error(sc, "unable to map descriptor memory");
397 elxl_error(sc, "can't allocate buf dma handle");
404 elxl_error(sc, "unable to allocate buf memory");
413 elxl_error(sc, "unable to map buf memory");
425 elxl_add_intr(elxl_t *sc)
433 dip = sc->ex_dip;
435 rv = ddi_intr_alloc(dip, &sc->ex_intrh, DDI_INTR_TYPE_FIXED,
438 elxl_error(sc, "Unable to allocate interrupt, %d, count %d",
443 if (ddi_intr_get_pri(sc->ex_intrh, &ipri) != DDI_SUCCESS) {
444 elxl_error(sc, "Unable to get interrupt priority");
448 if (ddi_intr_add_handler(sc->ex_intrh, elxl_intr, sc, NULL) !=
450 elxl_error(sc, "Can't add interrupt handler");
451 (void) ddi_intr_free(sc->ex_intrh);
452 sc->ex_intrh = NULL;
455 mutex_init(&sc->ex_intrlock, NULL, MUTEX_DRIVER, DDI_INTR_PRI(ipri));
456 mutex_init(&sc->ex_txlock, NULL, MUTEX_DRIVER, DDI_INTR_PRI(ipri));
464 elxl_t *sc;
471 sc = kmem_zalloc(sizeof (*sc), KM_SLEEP);
472 ddi_set_driver_private(dip, sc);
473 sc->ex_dip = dip;
475 if (pci_config_setup(dip, &sc->ex_pcih) != DDI_SUCCESS) {
476 elxl_error(sc, "unable to setup PCI config handle");
479 venid = pci_config_get16(sc->ex_pcih, PCI_CONF_VENID);
480 devid = pci_config_get16(sc->ex_pcih, PCI_CONF_DEVID);
484 elxl_error(sc, "Unsupported vendor id (0x%x)", venid);
493 sc->ex_conf = ex_products[i].epp_flags;
499 elxl_error(sc, "Unsupported device id (0x%x)", devid);
500 elxl_error(sc, "Driver may or may not function.");
503 pci_config_put16(sc->ex_pcih, PCI_CONF_COMM,
504 pci_config_get16(sc->ex_pcih, PCI_CONF_COMM) |
507 if (ddi_regs_map_setup(dip, 1, &sc->ex_regsva, 0, 0, &ex_dev_acc_attr,
508 &sc->ex_regsh) != DDI_SUCCESS) {
509 elxl_error(sc, "Unable to map device registers");
513 if (!elxl_add_intr(sc)) {
517 elxl_reset(sc);
519 val = elxl_read_eeprom(sc, EE_OEM_ADDR_0);
520 sc->ex_factaddr[0] = val >> 8;
521 sc->ex_factaddr[1] = val & 0xff;
522 val = elxl_read_eeprom(sc, EE_OEM_ADDR_1);
523 sc->ex_factaddr[2] = val >> 8;
524 sc->ex_factaddr[3] = val & 0xff;
525 val = elxl_read_eeprom(sc, EE_OEM_ADDR_2);
526 sc->ex_factaddr[4] = val >> 8;
527 sc->ex_factaddr[5] = val & 0xff;
528 bcopy(sc->ex_factaddr, sc->ex_curraddr, 6);
530 sc->ex_capab = elxl_read_eeprom(sc, EE_CAPABILITIES);
537 if ((sc->ex_capab & (1 << 2)) || !(sc->ex_capab & (1 << 9))) {
538 sc->ex_conf &= ~CONF_90XB;
540 sc->ex_conf |= CONF_90XB;
543 if (!ex_alloc_ring(sc, EX_NRX, &sc->ex_rxring, DDI_DMA_READ)) {
547 if (!ex_alloc_ring(sc, EX_NTX, &sc->ex_txring, DDI_DMA_WRITE)) {
551 elxl_probe_media(sc);
556 if (sc->ex_mediaopt & (MEDIAOPT_MII | MEDIAOPT_100TX)) {
557 sc->ex_miih = mii_alloc(sc, sc->ex_dip, &ex_mii_ops);
558 if (sc->ex_miih == NULL) {
568 mii_set_pauseable(sc->ex_miih, B_FALSE, B_FALSE);
571 elxl_error(sc, "MAC register allocation failed");
575 macp->m_driver = sc;
577 macp->m_src_addr = sc->ex_curraddr;
584 (void) ddi_intr_enable(sc->ex_intrh);
586 if (mac_register(macp, &sc->ex_mach) == DDI_SUCCESS) {
592 if (sc->ex_mediaopt &
596 sc->ex_linkcheck =
597 ddi_periodic_add(elxl_linkcheck, sc, 10000000, 0);
607 elxl_detach(sc);
615 elxl_probe_media(elxl_t *sc)
636 if (sc->ex_conf & CONF_90XB) {
664 sc->ex_conf |= CONF_INTPHY;
679 sc->ex_mediaopt = media_options;
687 APPEND_MEDIA(sc->ex_medias, (MEDIAOPT_MII|MEDIAOPT_100TX), "mii");
688 APPEND_MEDIA(sc->ex_medias, MEDIAOPT_10T, "tp-hdx,tp-fdx");
689 APPEND_MEDIA(sc->ex_medias, MEDIAOPT_100FX, "fx-hdx,fx-fdx");
690 APPEND_MEDIA(sc->ex_medias, MEDIAOPT_BNC, "bnc");
691 APPEND_MEDIA(sc->ex_medias, MEDIAOPT_AUI, "aui");
692 APPEND_MEDIA(sc->ex_medias, MEDIAOPT_10FL, "fl-hdx,fl-fdx");
704 elxl_error(sc,
710 sc->ex_xcvr = default_media;
717 sc->ex_xcvr = default_media;
721 sc->ex_xcvr = exm->exm_xcvr;
731 elxl_setup_tx(elxl_t *sc)
737 if (sc->ex_conf & CONF_90XB)
753 elxl_init(elxl_t *sc)
755 if (sc->ex_suspended)
758 WAIT_CMD(sc);
759 elxl_stop(sc);
762 WAIT_CMD(sc);
764 WAIT_CMD(sc);
767 elxl_setup_tx(sc);
776 elxl_set_media(sc);
777 elxl_set_rxfilter(sc);
781 if (sc->ex_conf & CONF_90XB) {
792 PUT32(REG_UPLISTPTR, sc->ex_rxring.r_paddr);
811 elxl_set_rxfilter(elxl_t *sc)
815 if (sc->ex_suspended)
824 PUT8(W2_STATION_ADDRESS + i, sc->ex_curraddr[i]);
828 if (sc->ex_mccount) {
831 if (sc->ex_promisc) {
838 elxl_set_media(elxl_t *sc)
850 switch (sc->ex_xcvr) {
852 sc->ex_mii_active = B_FALSE;
859 sc->ex_mii_active = B_FALSE;
865 sc->ex_mii_active = B_FALSE; /* Is this really true? */
871 sc->ex_mii_active = B_FALSE;
885 if (sc->ex_miih) {
886 sc->ex_mii_active = B_TRUE;
888 sc->ex_mii_active = B_FALSE;
893 sc->ex_mii_active = B_FALSE;
894 elxl_error(sc, "Impossible media setting!");
902 configreg |= (sc->ex_xcvr);
911 if (!sc->ex_mii_active) {
914 if (sc->ex_fdx) {
930 elxl_t *sc = arg;
934 mutex_enter(&sc->ex_txlock);
935 if (sc->ex_mii_active) {
936 mutex_exit(&sc->ex_txlock);
939 if (sc->ex_running && !sc->ex_suspended) {
940 switch (sc->ex_xcvr) {
946 sc->ex_link = LINK_STATE_UP;
947 sc->ex_speed = 100000000;
949 sc->ex_link = LINK_STATE_DOWN;
950 sc->ex_speed = 0;
959 sc->ex_link = LINK_STATE_UP;
960 sc->ex_speed = 10000000;
962 sc->ex_link = LINK_STATE_DOWN;
963 sc->ex_speed = 0;
978 sc->ex_speed = 10000000;
979 sc->ex_link = LINK_STATE_UP;
983 sc->ex_duplex = GET16(W3_MAC_CONTROL) & MAC_CONTROL_FDX ?
986 sc->ex_speed = 0;
987 sc->ex_duplex = LINK_DUPLEX_UNKNOWN;
988 sc->ex_link = LINK_STATE_UNKNOWN;
990 link = sc->ex_link;
991 mutex_exit(&sc->ex_txlock);
993 mac_link_update(sc->ex_mach, link);
999 elxl_t *sc = arg;
1001 mutex_enter(&sc->ex_intrlock);
1002 mutex_enter(&sc->ex_txlock);
1003 sc->ex_promisc = on;
1004 elxl_set_rxfilter(sc);
1005 mutex_exit(&sc->ex_txlock);
1006 mutex_exit(&sc->ex_intrlock);
1013 elxl_t *sc = arg;
1017 mutex_enter(&sc->ex_intrlock);
1018 mutex_enter(&sc->ex_txlock);
1020 sc->ex_mccount++;
1021 if (sc->ex_mccount == 1) {
1022 elxl_set_rxfilter(sc);
1025 sc->ex_mccount--;
1026 if (sc->ex_mccount == 0) {
1027 elxl_set_rxfilter(sc);
1030 mutex_exit(&sc->ex_txlock);
1031 mutex_exit(&sc->ex_intrlock);
1038 elxl_t *sc = arg;
1040 mutex_enter(&sc->ex_intrlock);
1041 mutex_enter(&sc->ex_txlock);
1042 bcopy(addr, sc->ex_curraddr, ETHERADDRL);
1043 elxl_set_rxfilter(sc);
1044 mutex_exit(&sc->ex_txlock);
1045 mutex_exit(&sc->ex_intrlock);
1053 elxl_t *sc = arg;
1066 r = &sc->ex_txring;
1067 mutex_enter(&sc->ex_txlock);
1068 if (sc->ex_suspended) {
1070 sc->ex_nocarrier++;
1075 mutex_exit(&sc->ex_txlock);
1086 sc->ex_excoll++;
1091 sc->ex_jabber++;
1094 sc->ex_txerr++;
1097 sc->ex_uflo++;
1106 WAIT_CMD(sc);
1108 WAIT_CMD(sc);
1109 elxl_setup_tx(sc);
1139 WAIT_CMD(sc);
1157 sc->ex_txerr++;
1164 if ((sc->ex_conf & CONF_90XB) != 0) {
1182 sc->ex_opackets++;
1183 sc->ex_obytes += len;
1186 sc->ex_multixmt++;
1188 sc->ex_brdcstxmt++;
1253 if (sc->ex_txring.r_head) {
1254 PUT32(REG_DNLISTPTR, sc->ex_txring.r_head->ed_descaddr);
1258 mutex_exit(&sc->ex_txlock);
1264 elxl_recv(elxl_t *sc, ex_desc_t *rxd, uint32_t stat)
1272 sc->ex_runt++;
1275 sc->ex_oflo++;
1278 sc->ex_fcs++;
1281 sc->ex_align++;
1284 sc->ex_toolong++;
1289 sc->ex_runt++;
1294 sc->ex_toolong++;
1298 sc->ex_allocbfail++;
1307 sc->ex_ipackets++;
1308 sc->ex_ibytes += len;
1311 sc->ex_multircv++;
1313 sc->ex_brdcstrcv++;
1320 if (((sc->ex_conf & CONF_90XB) != 0) &&
1339 elxl_t *sc = arg;
1341 mutex_enter(&sc->ex_intrlock);
1342 mutex_enter(&sc->ex_txlock);
1344 elxl_init(sc);
1345 sc->ex_running = B_TRUE;
1347 mutex_exit(&sc->ex_txlock);
1348 mutex_exit(&sc->ex_intrlock);
1350 if (sc->ex_miih) {
1351 mii_start(sc->ex_miih);
1359 elxl_t *sc = arg;
1361 if (sc->ex_miih) {
1362 mii_stop(sc->ex_miih);
1365 mutex_enter(&sc->ex_intrlock);
1366 mutex_enter(&sc->ex_txlock);
1368 elxl_stop(sc);
1369 sc->ex_running = B_FALSE;
1371 mutex_exit(&sc->ex_txlock);
1372 mutex_exit(&sc->ex_intrlock);
1378 elxl_t *sc = arg;
1382 if (sc->ex_conf & CONF_90XB) {
1397 elxl_t *sc = arg;
1400 if (sc->ex_mii_active) {
1401 rv = mii_m_getprop(sc->ex_miih, name, num, sz, val);
1408 *(uint8_t *)val = sc->ex_duplex;
1411 *(uint8_t *)val = sc->ex_speed;
1414 bcopy(&sc->ex_link, val, sizeof (link_state_t));
1421 switch (sc->ex_xcvr) {
1427 str = sc->ex_fdx ? "tp-fdx" : "tp-hdx";
1433 if (sc->ex_mediaopt & MEDIAOPT_10FL) {
1434 str = sc->ex_fdx ? "fl-fdx" : "fl-hdx";
1440 str = sc->ex_fdx ? "fx-fdx" : "fx-hdx";
1457 (void) snprintf(val, sz, "%s", sc->ex_medias);
1469 elxl_t *sc = arg;
1472 if (sc->ex_mii_active) {
1473 rv = mii_m_setprop(sc->ex_miih, name, num, sz, val);
1482 uint32_t mopt = sc->ex_mediaopt;
1486 sc->ex_xcvr = XCVR_SEL_AUTO;
1488 sc->ex_xcvr = XCVR_SEL_MII;
1495 sc->ex_xcvr = XCVR_SEL_10T;
1496 sc->ex_fdx = B_TRUE;
1503 sc->ex_xcvr = XCVR_SEL_10T;
1504 sc->ex_fdx = B_FALSE;
1510 sc->ex_xcvr = XCVR_SEL_100FX;
1511 sc->ex_fdx = B_TRUE;
1517 sc->ex_xcvr = XCVR_SEL_100FX;
1518 sc->ex_fdx = B_FALSE;
1524 sc->ex_xcvr = XCVR_SEL_BNC;
1525 sc->ex_fdx = B_FALSE;
1531 sc->ex_xcvr = XCVR_SEL_AUI;
1532 sc->ex_fdx = B_FALSE;
1538 sc->ex_xcvr = XCVR_SEL_AUI;
1539 sc->ex_fdx = B_TRUE;
1545 sc->ex_xcvr = XCVR_SEL_AUI;
1546 sc->ex_fdx = B_FALSE;
1564 mutex_enter(&sc->ex_intrlock);
1565 mutex_enter(&sc->ex_txlock);
1566 if (!sc->ex_suspended) {
1567 elxl_reset(sc);
1568 if (sc->ex_running) {
1569 elxl_init(sc);
1572 mutex_exit(&sc->ex_txlock);
1573 mutex_exit(&sc->ex_intrlock);
1581 elxl_t *sc = arg;
1583 if (sc->ex_mii_active)
1584 mii_m_propinfo(sc->ex_miih, name, num, prh);
1603 elxl_t *sc = arg;
1606 elxl_getstats(sc);
1609 if ((sc->ex_mii_active) &&
1610 (mii_m_getstat(sc->ex_miih, stat, val) == 0)) {
1616 *val = sc->ex_speed;
1620 *val = sc->ex_duplex;
1624 *val = sc->ex_multircv;
1628 *val = sc->ex_brdcstrcv;
1632 *val = sc->ex_multixmt;
1636 *val = sc->ex_brdcstxmt;
1640 *val = sc->ex_ipackets;
1644 *val = sc->ex_opackets;
1648 *val = sc->ex_ibytes;
1651 *val = sc->ex_obytes;
1656 *val = sc->ex_singlecol + sc->ex_multcol;
1660 *val = sc->ex_multcol;
1664 *val = sc->ex_latecol;
1668 *val = sc->ex_align;
1672 *val = sc->ex_fcs;
1676 *val = sc->ex_sqe;
1680 *val = sc->ex_defer;
1684 *val = sc->ex_nocarrier;
1688 *val = sc->ex_toolong;
1692 *val = sc->ex_excoll;
1696 *val = sc->ex_oflo;
1700 *val = sc->ex_uflo;
1704 *val = sc->ex_runt;
1708 *val = sc->ex_jabber;
1712 *val = sc->ex_allocbfail;
1716 *val = sc->ex_jabber + sc->ex_latecol + sc->ex_uflo;
1720 *val = sc->ex_align + sc->ex_fcs + sc->ex_runt +
1721 sc->ex_toolong + sc->ex_oflo + sc->ex_allocbfail;
1733 elxl_t *sc = (void *)arg;
1740 mutex_enter(&sc->ex_intrlock);
1741 if (sc->ex_suspended) {
1742 mutex_exit(&sc->ex_intrlock);
1749 mutex_exit(&sc->ex_intrlock);
1760 elxl_error(sc, "Adapter failure (%x)", stat);
1761 mutex_enter(&sc->ex_txlock);
1762 elxl_reset(sc);
1763 if (sc->ex_running)
1764 elxl_init(sc);
1765 mutex_exit(&sc->ex_txlock);
1766 mutex_exit(&sc->ex_intrlock);
1776 r = &sc->ex_rxring;
1794 if ((mp = elxl_recv(sc, rxd, pktstat)) != NULL) {
1816 mutex_enter(&sc->ex_txlock);
1817 if (sc->ex_running)
1818 elxl_init(sc);
1819 mutex_exit(&sc->ex_txlock);
1824 mutex_exit(&sc->ex_intrlock);
1827 mac_rx(sc->ex_mach, NULL, mphead);
1830 elxl_getstats(sc);
1833 mac_tx_update(sc->ex_mach);
1840 elxl_getstats(elxl_t *sc)
1842 mutex_enter(&sc->ex_txlock);
1843 if (sc->ex_suspended) {
1844 mutex_exit(&sc->ex_txlock);
1860 sc->ex_defer += GET8(W6_DEFER);
1861 sc->ex_latecol += GET8(W6_TX_LATE_COL);
1862 sc->ex_singlecol += GET8(W6_SINGLE_COL);
1863 sc->ex_multcol += GET8(W6_MULT_COL);
1864 sc->ex_sqe += GET8(W6_SQE_ERRORS);
1865 sc->ex_nocarrier += GET8(W6_NO_CARRIER);
1871 mutex_exit(&sc->ex_txlock);
1875 elxl_reset(elxl_t *sc)
1886 WAIT_CMD(sc);
1890 elxl_stop(elxl_t *sc)
1892 ASSERT(mutex_owned(&sc->ex_intrlock));
1893 ASSERT(mutex_owned(&sc->ex_txlock));
1895 if (sc->ex_suspended)
1902 elxl_reset_ring(&sc->ex_rxring, DDI_DMA_READ);
1903 elxl_reset_ring(&sc->ex_txring, DDI_DMA_WRITE);
1911 elxl_suspend(elxl_t *sc)
1913 if (sc->ex_miih) {
1914 mii_suspend(sc->ex_miih);
1917 mutex_enter(&sc->ex_intrlock);
1918 mutex_enter(&sc->ex_txlock);
1919 elxl_stop(sc);
1920 sc->ex_suspended = B_TRUE;
1921 mutex_exit(&sc->ex_txlock);
1922 mutex_exit(&sc->ex_intrlock);
1928 elxl_t *sc;
1931 sc = ddi_get_driver_private(dip);
1932 ASSERT(sc);
1934 mutex_enter(&sc->ex_intrlock);
1935 mutex_enter(&sc->ex_txlock);
1936 sc->ex_suspended = B_FALSE;
1937 elxl_reset(sc);
1938 if (sc->ex_running)
1939 elxl_init(sc);
1940 mutex_exit(&sc->ex_txlock);
1941 mutex_exit(&sc->ex_intrlock);
1943 if (sc->ex_miih) {
1944 mii_resume(sc->ex_miih);
1949 elxl_detach(elxl_t *sc)
1951 if (sc->ex_miih) {
1953 mii_free(sc->ex_miih);
1955 if (sc->ex_linkcheck) {
1956 ddi_periodic_delete(sc->ex_linkcheck);
1959 if (sc->ex_intrh != NULL) {
1960 (void) ddi_intr_disable(sc->ex_intrh);
1961 (void) ddi_intr_remove_handler(sc->ex_intrh);
1962 (void) ddi_intr_free(sc->ex_intrh);
1963 mutex_destroy(&sc->ex_intrlock);
1964 mutex_destroy(&sc->ex_txlock);
1967 if (sc->ex_pcih) {
1968 pci_config_teardown(&sc->ex_pcih);
1970 if (sc->ex_regsh) {
1971 ddi_regs_map_free(&sc->ex_regsh);
1973 ex_free_ring(&sc->ex_txring);
1974 ex_free_ring(&sc->ex_rxring);
1976 kmem_free(sc, sizeof (*sc));
1984 elxl_read_eeprom(elxl_t *sc, int offset)
1989 if (elxl_eeprom_busy(sc))
1993 if (elxl_eeprom_busy(sc))
2001 elxl_eeprom_busy(elxl_t *sc)
2010 elxl_error(sc, "Eeprom stays busy.");
2015 ex_mii_send_bits(struct ex_softc *sc, uint16_t bits, int cnt)
2039 ex_mii_sync(struct ex_softc *sc)
2058 elxl_t *sc = arg;
2062 if ((sc->ex_conf & CONF_INTPHY) && phy != INTPHY_ID)
2065 mutex_enter(&sc->ex_txlock);
2068 ex_mii_sync(sc);
2070 ex_mii_send_bits(sc, 1, 2); /* start */
2071 ex_mii_send_bits(sc, 2, 2); /* read command */
2072 ex_mii_send_bits(sc, phy, 5);
2073 ex_mii_send_bits(sc, reg, 5);
2102 mutex_exit(&sc->ex_txlock);
2110 elxl_t *sc = arg;
2112 if ((sc->ex_conf & CONF_INTPHY) && phy != INTPHY_ID)
2115 mutex_enter(&sc->ex_txlock);
2118 ex_mii_sync(sc);
2119 ex_mii_send_bits(sc, 1, 2); /* start */
2120 ex_mii_send_bits(sc, 1, 2); /* write */
2121 ex_mii_send_bits(sc, phy, 5);
2122 ex_mii_send_bits(sc, reg, 5);
2123 ex_mii_send_bits(sc, 2, 2); /* ack/turnaround */
2124 ex_mii_send_bits(sc, data, 16);
2130 mutex_exit(&sc->ex_txlock);
2136 elxl_t *sc = arg;
2140 duplex = mii_get_duplex(sc->ex_miih);
2142 mutex_enter(&sc->ex_txlock);
2143 if (!sc->ex_mii_active) {
2145 mutex_exit(&sc->ex_txlock);
2148 if (!sc->ex_suspended) {
2157 mutex_exit(&sc->ex_txlock);
2159 mac_link_update(sc->ex_mach, link);
2181 elxl_t *sc;
2183 sc = ddi_get_driver_private(dip);
2184 ASSERT(sc);
2188 if (mac_disable(sc->ex_mach) != 0) {
2191 (void) mac_unregister(sc->ex_mach);
2192 elxl_detach(sc);
2196 elxl_suspend(sc);
2207 elxl_t *sc;
2209 sc = ddi_get_driver_private(dip);
2210 ASSERT(sc);
2212 if (!sc->ex_suspended)
2213 elxl_reset(sc);
2218 elxl_error(elxl_t *sc, char *fmt, ...)
2228 ddi_driver_name(sc->ex_dip), ddi_get_instance(sc->ex_dip), buf);