Lines Matching defs:hmep

102 #define	KIOIP	KSTAT_INTR_PTR(hmep->hme_intrstats)
204 static void hmeuninit(struct hme *hmep);
285 hme_check_acc_handle(__FILE__, __LINE__, hmep, hmep->hme_mifregh)
287 hme_check_acc_handle(__FILE__, __LINE__, hmep, hmep->hme_etxregh)
289 hme_check_acc_handle(__FILE__, __LINE__, hmep, hmep->hme_erxregh)
291 hme_check_acc_handle(__FILE__, __LINE__, hmep, hmep->hme_bmacregh)
293 hme_check_acc_handle(__FILE__, __LINE__, hmep, hmep->hme_globregh)
352 ddi_get32(hmep->hme_mifregh, (uint32_t *)&hmep->hme_mifregp->reg)
354 ddi_put32(hmep->hme_mifregh, (uint32_t *)&hmep->hme_mifregp->reg, value)
357 ddi_get32(hmep->hme_etxregh, (uint32_t *)&hmep->hme_etxregp->reg)
359 ddi_put32(hmep->hme_etxregh, (uint32_t *)&hmep->hme_etxregp->reg, value)
361 ddi_get32(hmep->hme_erxregh, (uint32_t *)&hmep->hme_erxregp->reg)
363 ddi_put32(hmep->hme_erxregh, (uint32_t *)&hmep->hme_erxregp->reg, value)
365 ddi_get32(hmep->hme_bmacregh, (uint32_t *)&hmep->hme_bmacregp->reg)
367 ddi_put32(hmep->hme_bmacregh, \
368 (uint32_t *)&hmep->hme_bmacregp->reg, value)
370 ddi_get32(hmep->hme_globregh, (uint32_t *)&hmep->hme_globregp->reg)
372 ddi_put32(hmep->hme_globregh, \
373 (uint32_t *)&hmep->hme_globregp->reg, value)
375 ddi_put32(hmep->hme_tmd_acch, &hmep->hme_tmdp[ptr].tmd_addr, paddr); \
376 ddi_put32(hmep->hme_tmd_acch, &hmep->hme_tmdp[ptr].tmd_flags, \
379 ddi_get32(hmep->hme_tmd_acch, &hmep->hme_tmdp[ptr].tmd_flags)
381 ddi_put32(hmep->hme_rmd_acch, &hmep->hme_rmdp[ptr].rmd_addr, paddr); \
382 ddi_put32(hmep->hme_rmd_acch, &hmep->hme_rmdp[ptr].rmd_flags, \
385 ddi_get32(hmep->hme_rmd_acch, &hmep->hme_rmdp[ptr].rmd_flags)
388 ddi_get8((hmep->hme_romh), (offset))
429 send_bit(struct hme *hmep, uint16_t x)
441 get_bit_std(uint8_t phyad, struct hme *hmep)
455 #define SEND_BIT(x) send_bit(hmep, x)
456 #define GET_BIT_STD(phyad, x) x = get_bit_std(phyad, hmep)
460 hme_bb_mii_write(struct hme *hmep, uint8_t phyad, uint8_t regad, uint16_t data)
465 (void) hme_bb_force_idle(hmep);
489 hme_bb_mii_read(struct hme *hmep, uint8_t phyad, uint8_t regad)
496 (void) hme_bb_force_idle(hmep);
526 hme_bb_force_idle(struct hme *hmep)
544 struct hme *hmep = arg;
565 if (!hmep->hme_frame_enable) {
566 frame = (hme_bb_mii_read(hmep, phyad, regad));
588 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, MII_MSG,
598 struct hme *hmep = arg;
619 if (!hmep->hme_frame_enable) {
620 hme_bb_mii_write(hmep, phyad, regad, data);
638 HME_FAULT_MSG1(hmep, SEVERITY_MID, MII_MSG,
646 struct hme *hmep = arg;
649 (void) hmeinit(hmep);
651 mac_link_update(hmep->hme_mh, link);
689 (void) ddi_dma_sync(hmep->hme_rmd_dmah, \
695 (void) ddi_dma_sync(hmep->hme_tmd_dmah, \
712 #define BUMP_InNUcast(hmep, pkt) \
715 hmep->hme_brdcstrcv++; \
717 hmep->hme_multircv++; \
720 #define BUMP_OutNUcast(hmep, pkt) \
723 hmep->hme_brdcstxmt++; \
725 hmep->hme_multixmt++; \
777 struct hme *hmep;
783 hmep = ddi_get_driver_private(dip);
787 if ((GET_ROM8(&hmep->hme_romp[vpd_start]) & 0xff) != 0x90) {
797 kw_namestr[0] = GET_ROM8(&hmep->hme_romp[kw_ptr]);
798 kw_namestr[1] = GET_ROM8(&hmep->hme_romp[kw_ptr+1]);
800 kw_len = (int)(GET_ROM8(&hmep->hme_romp[kw_ptr+2]) & 0xff);
802 kw_fieldstr[i] = GET_ROM8(&hmep->hme_romp[kw_ptr+i]);
825 struct hme *hmep;
831 hmep = ddi_get_driver_private(dip);
835 vpd_start = (int)((GET_ROM8(&(hmep->hme_romp[vpd_base+1])) & 0xff) |
836 ((GET_ROM8(&hmep->hme_romp[vpd_base+2]) & 0xff) << 8)) +3;
839 if ((GET_ROM8(&hmep->hme_romp[vpd_start]) & 0xff) != 0x90) {
842 vpd_len = (int)((GET_ROM8(&hmep->hme_romp[vpd_start
843 + 1]) & 0xff) | (GET_ROM8(&hmep->hme_romp[vpd_start
850 kw_namestr[0] = GET_ROM8(&hmep->hme_romp[kw_ptr]);
851 kw_namestr[1] = GET_ROM8(&hmep->hme_romp[kw_ptr+1]);
854 (int)(GET_ROM8(&hmep->hme_romp[kw_ptr+2]) & 0xff);
857 GET_ROM8(&hmep->hme_romp[kw_ptr+i]);
877 struct hme *hmep;
882 hmep = ddi_get_driver_private(dip);
884 v0 = (int)(GET_ROM8(&(hmep->hme_romp[0])));
885 v1 = (int)(GET_ROM8(&(hmep->hme_romp[1])));
896 if (((GET_ROM8(&(hmep->hme_romp[i])) & 0xff) == 'P') &&
897 ((GET_ROM8(&(hmep->hme_romp[i+1])) & 0xff) == 'C') &&
898 ((GET_ROM8(&(hmep->hme_romp[i+2])) & 0xff) == 'I') &&
899 ((GET_ROM8(&(hmep->hme_romp[i+3])) & 0xff) == 'R')) {
901 (int)((GET_ROM8(&(hmep->hme_romp[i+8])) & 0xff) |
902 (GET_ROM8(&(hmep->hme_romp[i+9])) & 0xff) << 8);
913 v0 = (int)(GET_ROM8(&(hmep->hme_romp[vpd_base])));
920 if ((GET_ROM8(&hmep->hme_romp[vpd_base + 12]) != 0x79) &&
921 GET_ROM8(&hmep->hme_romp[vpd_base + 4 * 12]) == 0x79) {
922 vpd_base += hmep->hme_devno * 12;
940 struct hme *hmep;
954 struct hme *hmep = rom->hmep;
989 (void) ddi_regs_map_setup(dip, 1, &rom->romp, 0, 0, &hmep->hme_dev_attr,
1004 struct hme *hmep;
1006 hmep = ddi_get_driver_private(dip);
1024 rom.hmep = hmep;
1027 hmep->hme_devno = rom.dev;
1042 hmep->hme_romh = rom.acch;
1043 hmep->hme_romp = (unsigned char *)rom.romp;
1052 struct hme *hmep;
1076 hmep = ddi_get_driver_private(dip);
1082 if (ddi_regs_map_setup(hmep->dip, 0, (caddr_t *)&cfg_ptr,
1083 0, 0, &hmep->hme_dev_attr, &cfg_handle)) {
1101 if ((ddi_regs_map_setup(dip, 2, (caddr_t *)&(hmep->hme_romp), 0, 0,
1102 &hmep->hme_dev_attr, &hmep->hme_romh) != DDI_SUCCESS) &&
1112 if (hmep->hme_romp)
1113 ddi_regs_map_free(&hmep->hme_romh);
1121 hmeget_hm_rev_property(struct hme *hmep)
1126 hm_rev = hmep->asic_rev;
1130 HME_FAULT_MSG2(hmep, SEVERITY_NONE, DISPLAY_MSG,
1132 hmep->hme_frame_enable = 1;
1136 HME_FAULT_MSG2(hmep, SEVERITY_NONE, DISPLAY_MSG,
1141 HME_FAULT_MSG2(hmep, SEVERITY_NONE, DISPLAY_MSG,
1146 HME_FAULT_MSG3(hmep, SEVERITY_NONE, DISPLAY_MSG,
1149 hmep->hme_frame_enable = 1;
1150 hmep->hme_lance_mode_enable = 1;
1151 hmep->hme_rxcv_enable = 1;
1164 struct hme *hmep;
1185 if ((hmep = ddi_get_driver_private(dip)) == NULL)
1188 hmep->hme_flags &= ~HMESUSPENDED;
1190 mii_resume(hmep->hme_mii);
1192 if (hmep->hme_started)
1193 (void) hmeinit(hmep);
1203 hmep = kmem_zalloc(sizeof (*hmep), KM_SLEEP);
1208 hmep->dip = dip;
1209 hmep->instance = ddi_get_instance(dip);
1210 hmep->pagesize = ddi_ptob(dip, (ulong_t)1); /* IOMMU PSize */
1216 ddi_set_driver_private(dip, hmep);
1222 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1237 HME_FAULT_MSG2(hmep, SEVERITY_HIGH, INIT_MSG,
1244 hmep->hme_cheerio_mode = 0;
1248 hmep->hme_cheerio_mode = 1;
1251 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
1257 hmep->hme_dev_attr.devacc_attr_version = DDI_DEVICE_ATTR_V0;
1259 if (hmep->hme_cheerio_mode)
1260 hmep->hme_dev_attr.devacc_attr_endian_flags =
1263 hmep->hme_dev_attr.devacc_attr_endian_flags =
1266 hmep->hme_dev_attr.devacc_attr_dataorder = DDI_STRICTORDER_ACC;
1268 if (hmep->hme_cheerio_mode) {
1277 if (pci_config_setup(dip, &hmep->pci_config_handle) !=
1279 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1285 (caddr_t *)&(hmep->hme_globregp), 0, 0,
1286 &hmep->hme_dev_attr, &hmep->hme_globregh)) {
1287 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1291 hmep->hme_etxregh = hmep->hme_erxregh = hmep->hme_bmacregh =
1292 hmep->hme_mifregh = hmep->hme_globregh;
1294 hmep->hme_etxregp =
1295 (void *)(((caddr_t)hmep->hme_globregp) + 0x2000);
1296 hmep->hme_erxregp =
1297 (void *)(((caddr_t)hmep->hme_globregp) + 0x4000);
1298 hmep->hme_bmacregp =
1299 (void *)(((caddr_t)hmep->hme_globregp) + 0x6000);
1300 hmep->hme_mifregp =
1301 (void *)(((caddr_t)hmep->hme_globregp) + 0x7000);
1309 oldLT = pci_config_get8(hmep->pci_config_handle,
1336 pci_config_put8(hmep->pci_config_handle,
1340 (caddr_t *)&(hmep->hme_globregp), 0, 0,
1341 &hmep->hme_dev_attr, &hmep->hme_globregh)) {
1342 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1347 (caddr_t *)&(hmep->hme_etxregp), 0, 0,
1348 &hmep->hme_dev_attr, &hmep->hme_etxregh)) {
1349 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1354 (caddr_t *)&(hmep->hme_erxregp), 0, 0,
1355 &hmep->hme_dev_attr, &hmep->hme_erxregh)) {
1356 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1361 (caddr_t *)&(hmep->hme_bmacregp), 0, 0,
1362 &hmep->hme_dev_attr, &hmep->hme_bmacregh)) {
1363 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1369 (caddr_t *)&(hmep->hme_mifregp), 0, 0,
1370 &hmep->hme_dev_attr, &hmep->hme_mifregh)) {
1371 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1381 hmep->hme_frame_enable = 0;
1382 hmep->hme_lance_mode_enable = 0;
1383 hmep->hme_rxcv_enable = 0;
1387 if (ddi_getlongprop_buf(DDI_DEV_T_ANY, hmep->dip, 0, "hm-rev",
1390 hmep->asic_rev = hm_rev;
1391 hmeget_hm_rev_property(hmep);
1398 if (ddi_regs_map_setup(hmep->dip, 0, (caddr_t *)&cfg_ptr,
1399 0, 0, &hmep->hme_dev_attr, &cfg_handle)) {
1409 hmep->asic_rev = hm_rev;
1413 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, AUTOCONFIG_MSG,
1418 hmeget_hm_rev_property(hmep);
1422 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, AUTOCONFIG_MSG,
1428 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, NFATAL_ERR_MSG,
1436 if (ddi_get_iblock_cookie(dip, 0, &hmep->hme_cookie) != DDI_SUCCESS)
1442 mutex_init(&hmep->hme_xmitlock, NULL, MUTEX_DRIVER, hmep->hme_cookie);
1443 mutex_init(&hmep->hme_intrlock, NULL, MUTEX_DRIVER, hmep->hme_cookie);
1448 (void) hmestop(hmep);
1454 (ddi_idevice_cookie_t *)NULL, hmeintr, (caddr_t)hmep)) {
1455 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, CONFIG_MSG,
1463 hme_setup_mac_address(hmep, dip);
1465 if (!hmeinit_xfer_params(hmep))
1468 if (hmeburstsizes(hmep) == DDI_FAILURE) {
1469 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG, burst_size_msg);
1473 if (hmeallocthings(hmep) != DDI_SUCCESS) {
1474 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, CONFIG_MSG,
1479 if (hmeallocbufs(hmep) != DDI_SUCCESS) {
1480 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, CONFIG_MSG,
1485 hmestatinit(hmep);
1490 hmep->hme_mii = mii_alloc(hmep, dip, &hme_mii_ops);
1491 if (hmep->hme_mii == NULL) {
1492 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, CONFIG_MSG,
1497 mii_probe(hmep->hme_mii);
1500 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, CONFIG_MSG,
1505 macp->m_driver = hmep;
1507 macp->m_src_addr = hmep->hme_ouraddr.ether_addr_octet;
1513 if (mac_register(macp, &hmep->hme_mh) != 0) {
1528 if (hmep->hme_cookie)
1531 if (hmep->hme_mii)
1532 mii_free(hmep->hme_mii);
1535 mutex_destroy(&hmep->hme_xmitlock);
1536 mutex_destroy(&hmep->hme_intrlock);
1539 if (hmep->hme_globregh)
1540 ddi_regs_map_free(&hmep->hme_globregh);
1541 if (hmep->hme_cheerio_mode == 0) {
1542 if (hmep->hme_etxregh)
1543 ddi_regs_map_free(&hmep->hme_etxregh);
1544 if (hmep->hme_erxregh)
1545 ddi_regs_map_free(&hmep->hme_erxregh);
1546 if (hmep->hme_bmacregh)
1547 ddi_regs_map_free(&hmep->hme_bmacregh);
1548 if (hmep->hme_mifregh)
1549 ddi_regs_map_free(&hmep->hme_mifregh);
1551 if (hmep->pci_config_handle)
1552 (void) pci_config_teardown(&hmep->pci_config_handle);
1553 hmep->hme_etxregh = hmep->hme_erxregh = hmep->hme_bmacregh =
1554 hmep->hme_mifregh = hmep->hme_globregh = NULL;
1558 hmefreethings(hmep);
1559 hmefreebufs(hmep);
1561 if (hmep) {
1562 kmem_free((caddr_t)hmep, sizeof (*hmep));
1572 struct hme *hmep;
1574 if ((hmep = ddi_get_driver_private(dip)) == NULL)
1582 mii_suspend(hmep->hme_mii);
1583 hmep->hme_flags |= HMESUSPENDED;
1584 hmeuninit(hmep);
1592 if (mac_unregister(hmep->hme_mh) != 0) {
1601 if (!(hmep->hme_flags & HMESUSPENDED)) {
1602 (void) hmestop(hmep);
1605 if (hmep->hme_mii)
1606 mii_free(hmep->hme_mii);
1616 if (hmep->hme_ksp != NULL)
1617 kstat_delete(hmep->hme_ksp);
1618 if (hmep->hme_intrstats != NULL)
1619 kstat_delete(hmep->hme_intrstats);
1621 hmep->hme_ksp = NULL;
1622 hmep->hme_intrstats = NULL;
1632 if (hmep->hme_globregh)
1633 ddi_regs_map_free(&hmep->hme_globregh);
1634 if (hmep->hme_cheerio_mode == 0) {
1635 if (hmep->hme_etxregh)
1636 ddi_regs_map_free(&hmep->hme_etxregh);
1637 if (hmep->hme_erxregh)
1638 ddi_regs_map_free(&hmep->hme_erxregh);
1639 if (hmep->hme_bmacregh)
1640 ddi_regs_map_free(&hmep->hme_bmacregh);
1641 if (hmep->hme_mifregh)
1642 ddi_regs_map_free(&hmep->hme_mifregh);
1644 if (hmep->pci_config_handle)
1645 (void) pci_config_teardown(&hmep->pci_config_handle);
1646 hmep->hme_etxregh = hmep->hme_erxregh = hmep->hme_bmacregh =
1647 hmep->hme_mifregh = hmep->hme_globregh = NULL;
1650 mutex_destroy(&hmep->hme_xmitlock);
1651 mutex_destroy(&hmep->hme_intrlock);
1653 hmefreethings(hmep);
1654 hmefreebufs(hmep);
1657 kmem_free(hmep, sizeof (struct hme));
1665 struct hme *hmep;
1667 if ((hmep = ddi_get_driver_private(dip)) == NULL)
1670 (void) hmestop(hmep);
1675 hmeinit_xfer_params(struct hme *hmep)
1682 dip = hmep->dip;
1689 hmep->hme_ipg1 = hme_ipg1 & HME_MASK_8BIT;
1690 hmep->hme_ipg2 = hme_ipg2 & HME_MASK_8BIT;
1691 hmep->hme_ipg0 = hme_ipg0 & HME_MASK_5BIT;
1698 hmep->hme_ipg1 = hme_ipg1_conf & HME_MASK_8BIT;
1703 hmep->hme_ipg2 = hme_ipg2_conf & HME_MASK_8BIT;
1708 hmep->hme_ipg0 = hme_ipg0_conf & HME_MASK_5BIT;
1713 hmep->hme_lance_mode = hme_lance_mode_conf & HME_MASK_1BIT;
1723 hmestop(struct hme *hmep)
1755 struct hme *hmep;
1758 hmep = (struct hme *)ksp->ks_private;
1770 mutex_enter(&hmep->hme_xmitlock);
1771 if (hmep->hme_flags & HMERUNNING) {
1772 hmereclaim(hmep);
1773 hmesavecntrs(hmep);
1775 mutex_exit(&hmep->hme_xmitlock);
1777 hkp->hk_cvc.value.ul = hmep->hme_cvc;
1778 hkp->hk_lenerr.value.ul = hmep->hme_lenerr;
1779 hkp->hk_buff.value.ul = hmep->hme_buff;
1780 hkp->hk_missed.value.ul = hmep->hme_missed;
1781 hkp->hk_allocbfail.value.ul = hmep->hme_allocbfail;
1782 hkp->hk_babl.value.ul = hmep->hme_babl;
1783 hkp->hk_tmder.value.ul = hmep->hme_tmder;
1784 hkp->hk_txlaterr.value.ul = hmep->hme_txlaterr;
1785 hkp->hk_rxlaterr.value.ul = hmep->hme_rxlaterr;
1786 hkp->hk_slvparerr.value.ul = hmep->hme_slvparerr;
1787 hkp->hk_txparerr.value.ul = hmep->hme_txparerr;
1788 hkp->hk_rxparerr.value.ul = hmep->hme_rxparerr;
1789 hkp->hk_slverrack.value.ul = hmep->hme_slverrack;
1790 hkp->hk_txerrack.value.ul = hmep->hme_txerrack;
1791 hkp->hk_rxerrack.value.ul = hmep->hme_rxerrack;
1792 hkp->hk_txtagerr.value.ul = hmep->hme_txtagerr;
1793 hkp->hk_rxtagerr.value.ul = hmep->hme_rxtagerr;
1794 hkp->hk_eoperr.value.ul = hmep->hme_eoperr;
1795 hkp->hk_notmds.value.ul = hmep->hme_notmds;
1796 hkp->hk_notbufs.value.ul = hmep->hme_notbufs;
1797 hkp->hk_norbufs.value.ul = hmep->hme_norbufs;
1802 hkp->hk_inits.value.ul = hmep->inits;
1803 hkp->hk_phyfail.value.ul = hmep->phyfail;
1808 hkp->hk_asic_rev.value.ul = hmep->asic_rev;
1814 hmestatinit(struct hme *hmep)
1822 instance = hmep->instance;
1823 driver = ddi_driver_name(hmep->dip);
1828 HME_FAULT_MSG1(hmep, SEVERITY_UNKNOWN, INIT_MSG,
1834 hmep->hme_intrstats = kstat_create(driver, instance, buf, "controller",
1836 if (hmep->hme_intrstats)
1837 kstat_install(hmep->hme_intrstats);
1839 hmep->hme_ksp = ksp;
1901 ksp->ks_private = (void *) hmep;
1909 struct hme *hmep = arg;
1913 rv = mii_m_getprop(hmep->hme_mii, name, num, sz, val);
1925 value = hmep->hme_ipg0;
1927 value = hmep->hme_ipg1;
1929 value = hmep->hme_ipg2;
1931 value = hmep->hme_lance_mode;
1943 struct hme *hmep = arg;
1945 mii_m_propinfo(hmep->hme_mii, name, num, mph);
1975 struct hme *hmep = arg;
1980 rv = mii_m_setprop(hmep->hme_mii, name, num, sz, val);
1996 hmep->hme_ipg1 = lval & 0xff;
2004 hmep->hme_ipg2 = lval & 0xff;
2012 hmep->hme_ipg0 = lval & 0xff;
2019 hmep->hme_lance_mode = lval & 0xff;
2030 (void) hmeinit(hmep);
2052 struct hme *hmep = arg;
2054 hmep->hme_promisc = on;
2055 (void) hmeinit(hmep);
2062 struct hme *hmep = arg;
2069 mutex_enter(&hmep->hme_intrlock);
2070 bcopy(macaddr, &hmep->hme_ouraddr, ETHERADDRL);
2071 mutex_exit(&hmep->hme_intrlock);
2072 (void) hmeinit(hmep);
2079 struct hme *hmep = arg;
2089 mutex_enter(&hmep->hme_intrlock);
2091 hmep->hme_ladrf_refcnt[ladrf_bit]++;
2092 if (hmep->hme_ladrf_refcnt[ladrf_bit] == 1) {
2093 hmep->hme_ladrf[ladrf_bit >> 4] |=
2095 hmep->hme_multi++;
2099 hmep->hme_ladrf_refcnt[ladrf_bit]--;
2100 if (hmep->hme_ladrf_refcnt[ladrf_bit] == 0) {
2101 hmep->hme_ladrf[ladrf_bit >> 4] &=
2106 mutex_exit(&hmep->hme_intrlock);
2109 (void) hmeinit(hmep);
2118 struct hme *hmep = arg;
2120 if (hmeinit(hmep) != 0) {
2124 hmep->hme_started = B_TRUE;
2125 mii_start(hmep->hme_mii);
2133 struct hme *hmep = arg;
2135 mii_stop(hmep->hme_mii);
2136 hmep->hme_started = B_FALSE;
2137 hmeuninit(hmep);
2143 struct hme *hmep = arg;
2145 mutex_enter(&hmep->hme_xmitlock);
2146 if (hmep->hme_flags & HMERUNNING) {
2147 hmereclaim(hmep);
2148 hmesavecntrs(hmep);
2150 mutex_exit(&hmep->hme_xmitlock);
2153 if (mii_m_getstat(hmep->hme_mii, stat, val) == 0) {
2158 *val = hmep->hme_ipackets;
2161 *val = hmep->hme_rbytes;
2164 *val = hmep->hme_ierrors;
2167 *val = hmep->hme_opackets;
2170 *val = hmep->hme_obytes;
2173 *val = hmep->hme_oerrors;
2176 *val = hmep->hme_multircv;
2179 *val = hmep->hme_multixmt;
2182 *val = hmep->hme_brdcstrcv;
2185 *val = hmep->hme_brdcstxmt;
2188 *val = hmep->hme_uflo;
2191 *val = hmep->hme_oflo;
2194 *val = hmep->hme_coll;
2197 *val = hmep->hme_norcvbuf;
2200 *val = hmep->hme_noxmtbuf;
2203 *val = hmep->hme_duplex;
2206 *val = hmep->hme_align_errors;
2209 *val = hmep->hme_fcs_errors;
2212 *val = hmep->hme_excol;
2215 *val = hmep->hme_defer_xmts;
2218 *val = hmep->hme_sqe_errors;
2221 *val = hmep->hme_fstcol;
2224 *val = hmep->hme_tlcol;
2227 *val = hmep->hme_toolong_errors;
2230 *val = hmep->hme_runt;
2233 *val = hmep->hme_carrier_errors;
2244 struct hme *hmep = arg;
2250 if (!hmestart(hmep, mp)) {
2287 hmestart(struct hme *hmep, mblk_t *mp)
2314 mutex_enter(&hmep->hme_xmitlock);
2316 if (hmep->hme_flags & HMESUSPENDED) {
2317 hmep->hme_carrier_errors++;
2318 hmep->hme_oerrors++;
2322 if (hmep->hme_txindex != hmep->hme_txreclaim) {
2323 hmereclaim(hmep);
2325 if ((hmep->hme_txindex - HME_TMDMAX) == hmep->hme_txreclaim)
2327 txptr = hmep->hme_txindex % HME_TMDMAX;
2328 tbuf = &hmep->hme_tbuf[txptr];
2356 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, DDI_MSG,
2363 BUMP_OutNUcast(hmep, tbuf->kaddr);
2369 hmep->hme_txindex++;
2374 mutex_exit(&hmep->hme_xmitlock);
2376 hmep->hme_starts++;
2380 mutex_exit(&hmep->hme_xmitlock);
2385 hmep->hme_notmds++;
2386 hmep->hme_wantw = B_TRUE;
2387 hmereclaim(hmep);
2390 mutex_exit(&hmep->hme_xmitlock);
2433 hmeinit(struct hme *hmep)
2444 mutex_enter(&hmep->hme_intrlock);
2452 if (hmep->hme_flags & HMESUSPENDED) {
2453 mutex_exit(&hmep->hme_intrlock);
2471 mutex_enter(&hmep->hme_xmitlock);
2473 hmep->hme_flags = 0;
2474 hmep->hme_wantw = B_FALSE;
2476 if (hmep->inits)
2477 hmesavecntrs(hmep);
2482 (void) hmestop(hmep);
2487 bzero(hmep->hme_rmdp, HME_RMDMAX * sizeof (struct hme_rmd));
2488 bzero(hmep->hme_tmdp, HME_TMDMAX * sizeof (struct hme_tmd));
2494 PUT_RMD(i, hmep->hme_rbuf[i].paddr);
2500 (void) ddi_dma_sync(hmep->hme_rmd_dmah, 0, 0, DDI_DMA_SYNC_FORDEV);
2501 (void) ddi_dma_sync(hmep->hme_tmd_dmah, 0, 0, DDI_DMA_SYNC_FORDEV);
2506 hmep->hme_rxindex = 0;
2507 hmep->hme_txindex = hmep->hme_txreclaim = 0;
2515 if (!hmep->hme_frame_enable)
2528 switch ((phyad = mii_get_addr(hmep->hme_mii))) {
2530 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, XCVR_MSG, no_xcvr_msg);
2542 hmep->inits++;
2577 PUT_MACREG(ipg1, hmep->hme_ipg1);
2578 PUT_MACREG(ipg2, hmep->hme_ipg2);
2581 ((hmep->hme_ouraddr.ether_addr_octet[0] << 8) & 0x3) |
2582 hmep->hme_ouraddr.ether_addr_octet[1]);
2589 PUT_MACREG(madd2, (hmep->hme_ouraddr.ether_addr_octet[4] << 8) |
2590 hmep->hme_ouraddr.ether_addr_octet[5]);
2591 PUT_MACREG(madd1, (hmep->hme_ouraddr.ether_addr_octet[2] << 8) |
2592 hmep->hme_ouraddr.ether_addr_octet[3]);
2593 PUT_MACREG(madd0, (hmep->hme_ouraddr.ether_addr_octet[0] << 8) |
2594 hmep->hme_ouraddr.ether_addr_octet[1]);
2603 PUT_MACREG(hash0, hmep->hme_ladrf[0]);
2604 PUT_MACREG(hash1, hmep->hme_ladrf[1]);
2605 PUT_MACREG(hash2, hmep->hme_ladrf[2]);
2606 PUT_MACREG(hash3, hmep->hme_ladrf[3]);
2619 PUT_ETXREG(txring, hmep->hme_tmd_paddr);
2620 PUT_ERXREG(rxring, hmep->hme_rmd_paddr);
2630 temp = hmep->hme_rmd_paddr;
2636 PUT_GLOBREG(config, (hmep->hme_config |
2637 (hmep->hme_64bit_xfer << HMEG_CONFIG_64BIT_SHIFT)));
2665 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2691 HME_FAULT_MSG4(hmep, SEVERITY_UNKNOWN, ERX_MSG,
2708 ((hmep->hme_promisc ? BMAC_RXCFG_PROMIS : 0) |
2712 ((hmep->hme_promisc ? BMAC_RXCFG_PROMIS : 0) |
2718 fdx = (mii_get_duplex(hmep->hme_mii) == LINK_DUPLEX_FULL);
2727 if ((hmep->hme_lance_mode) && (hmep->hme_lance_mode_enable))
2728 i = ((hmep->hme_ipg0 & HME_MASK_5BIT) << BMAC_XIFC_IPG0_SHIFT)
2738 hmep->hme_flags |= (HMERUNNING | HMEINITIALIZED);
2743 mac_tx_update(hmep->hme_mh);
2749 mutex_exit(&hmep->hme_xmitlock);
2750 mutex_exit(&hmep->hme_intrlock);
2752 ret = !(hmep->hme_flags & HMERUNNING);
2754 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2779 hmeburstsizes(struct hme *hmep)
2784 if (ddi_dma_alloc_handle(hmep->dip, &hme_dma_attr,
2789 hmep->hme_burstsizes = burstsizes = ddi_dma_burstsizes(handle);
2795 burstsizes = (hmep->hme_burstsizes >> 16);
2797 hmep->hme_64bit_xfer = hme_64bit_enable; /* user config value */
2799 burstsizes = hmep->hme_burstsizes;
2801 if (hmep->hme_cheerio_mode)
2802 hmep->hme_64bit_xfer = 0; /* Disable for cheerio */
2805 hmep->hme_config = HMEG_CONFIG_BURST64;
2807 hmep->hme_config = HMEG_CONFIG_BURST32;
2809 hmep->hme_config = HMEG_CONFIG_BURST16;
2815 hmeallocbuf(struct hme *hmep, hmebuf_t *buf, int dir)
2821 if (ddi_dma_alloc_handle(hmep->dip, &hme_dma_attr,
2823 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2831 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2839 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2847 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2855 hmeallocbufs(struct hme *hmep)
2857 hmep->hme_tbuf = kmem_zalloc(HME_TMDMAX * sizeof (hmebuf_t), KM_SLEEP);
2858 hmep->hme_rbuf = kmem_zalloc(HME_RMDMAX * sizeof (hmebuf_t), KM_SLEEP);
2862 if (hmeallocbuf(hmep, &hmep->hme_rbuf[i], DDI_DMA_READ) !=
2870 if (hmeallocbuf(hmep, &hmep->hme_tbuf[i], DDI_DMA_WRITE) !=
2879 hmefreebufs(struct hme *hmep)
2883 if (hmep->hme_rbuf == NULL)
2893 hmebuf_t *tbuf = &hmep->hme_tbuf[i];
2905 hmebuf_t *rbuf = &hmep->hme_rbuf[i];
2916 kmem_free(hmep->hme_rbuf, HME_RMDMAX * sizeof (hmebuf_t));
2917 kmem_free(hmep->hme_tbuf, HME_TMDMAX * sizeof (hmebuf_t));
2924 hmeuninit(struct hme *hmep)
2929 HMEDELAY((hmep->hme_txindex == hmep->hme_txreclaim), HMEDRAINTIME);
2931 mutex_enter(&hmep->hme_intrlock);
2932 mutex_enter(&hmep->hme_xmitlock);
2934 hmep->hme_flags &= ~HMERUNNING;
2936 (void) hmestop(hmep);
2938 mutex_exit(&hmep->hme_xmitlock);
2939 mutex_exit(&hmep->hme_intrlock);
2948 hmeallocthings(struct hme *hmep)
2955 dev_info_t *dip = hmep->dip;
2962 &hmep->hme_rmd_dmah);
2964 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2969 rval = ddi_dma_mem_alloc(hmep->hme_rmd_dmah, size,
2970 &hmep->hme_dev_attr, DDI_DMA_CONSISTENT, DDI_DMA_DONTWAIT, NULL,
2971 &hmep->hme_rmd_kaddr, &real_len, &hmep->hme_rmd_acch);
2973 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2977 hmep->hme_rmdp = (void *)(hmep->hme_rmd_kaddr);
2978 rval = ddi_dma_addr_bind_handle(hmep->hme_rmd_dmah, NULL,
2979 hmep->hme_rmd_kaddr, size, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
2982 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2986 hmep->hme_rmd_paddr = dmac.dmac_address;
2988 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
2994 &hmep->hme_tmd_dmah);
2996 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
3001 rval = ddi_dma_mem_alloc(hmep->hme_tmd_dmah, size,
3002 &hmep->hme_dev_attr, DDI_DMA_CONSISTENT, DDI_DMA_DONTWAIT, NULL,
3003 &hmep->hme_tmd_kaddr, &real_len, &hmep->hme_tmd_acch);
3005 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
3009 hmep->hme_tmdp = (void *)(hmep->hme_tmd_kaddr);
3010 rval = ddi_dma_addr_bind_handle(hmep->hme_tmd_dmah, NULL,
3011 hmep->hme_tmd_kaddr, size, DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
3014 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
3018 hmep->hme_tmd_paddr = dmac.dmac_address;
3020 HME_FAULT_MSG1(hmep, SEVERITY_HIGH, INIT_MSG,
3029 hmefreethings(struct hme *hmep)
3031 if (hmep->hme_rmd_paddr) {
3032 (void) ddi_dma_unbind_handle(hmep->hme_rmd_dmah);
3033 hmep->hme_rmd_paddr = 0;
3035 if (hmep->hme_rmd_acch)
3036 ddi_dma_mem_free(&hmep->hme_rmd_acch);
3037 if (hmep->hme_rmd_dmah)
3038 ddi_dma_free_handle(&hmep->hme_rmd_dmah);
3040 if (hmep->hme_tmd_paddr) {
3041 (void) ddi_dma_unbind_handle(hmep->hme_tmd_dmah);
3042 hmep->hme_tmd_paddr = 0;
3044 if (hmep->hme_tmd_acch)
3045 ddi_dma_mem_free(&hmep->hme_tmd_acch);
3046 if (hmep->hme_tmd_dmah)
3047 ddi_dma_free_handle(&hmep->hme_tmd_dmah);
3056 struct hme *hmep = (void *)arg;
3067 mutex_enter(&hmep->hme_intrlock);
3084 if (hmep->hme_flags & HMEINITIALIZED) {
3085 hmep->hme_flags &= ~HMEINITIALIZED;
3091 if (hmep->hme_intrstats) {
3097 mutex_exit(&hmep->hme_intrlock);
3103 if (!(hmep->hme_flags & HMERUNNING)) {
3104 if (hmep->hme_intrstats)
3106 mutex_exit(&hmep->hme_intrlock);
3107 hmeuninit(hmep);
3114 if (hmep->hme_intrstats)
3116 hme_fatal_err(hmep, hmesbits);
3118 mutex_exit(&hmep->hme_intrlock);
3119 (void) hmeinit(hmep);
3122 hme_nonfatal_err(hmep, hmesbits);
3126 mutex_enter(&hmep->hme_xmitlock);
3128 hmereclaim(hmep);
3129 mutex_exit(&hmep->hme_xmitlock);
3147 rxptr = hmep->hme_rxindex % HME_RMDMAX;
3161 rbuf = &hmep->hme_rbuf[rxptr];
3162 mp = hmeread(hmep, rbuf, rflags);
3178 hmep->hme_rxindex++;
3182 if (hmep->hme_intrstats)
3185 mutex_exit(&hmep->hme_intrlock);
3188 mac_rx(hmep->hme_mh, NULL, head);
3197 hmereclaim(struct hme *hmep)
3204 while (hmep->hme_txindex > hmep->hme_txreclaim) {
3209 reclaim = hmep->hme_txreclaim % HME_TMDMAX;
3224 hmep->hme_opackets++;
3230 hmep->hme_obytes += flags & HMETMD_BUFSIZE;
3233 hmep->hme_txreclaim++;
3240 if (hmep->hme_wantw) {
3244 hmep->hme_wantw = B_FALSE;
3245 mac_tx_update(hmep->hme_mh);
3252 if (hmep->hme_wantw)
3264 hme_fatal_err(struct hme *hmep, uint_t hmesbits)
3268 hmep->hme_slvparerr++;
3272 hmep->hme_slverrack++;
3276 hmep->hme_txtagerr++;
3277 hmep->hme_oerrors++;
3281 hmep->hme_txparerr++;
3282 hmep->hme_oerrors++;
3286 hmep->hme_txlaterr++;
3287 hmep->hme_oerrors++;
3291 hmep->hme_txerrack++;
3292 hmep->hme_oerrors++;
3296 hmep->hme_eoperr++;
3300 hmep->hme_rxtagerr++;
3301 hmep->hme_ierrors++;
3305 hmep->hme_rxparerr++;
3306 hmep->hme_ierrors++;
3310 hmep->hme_rxlaterr++;
3311 hmep->hme_ierrors++;
3315 hmep->hme_rxerrack++;
3316 hmep->hme_ierrors++;
3324 hme_nonfatal_err(struct hme *hmep, uint_t hmesbits)
3328 hmep->hme_missed++;
3329 hmep->hme_ierrors++;
3333 hmep->hme_defer_xmts++;
3337 hmep->hme_fstcol += 256;
3341 hmep->hme_tlcol += 256;
3342 hmep->hme_oerrors += 256;
3346 hmep->hme_excol += 256;
3347 hmep->hme_oerrors += 256;
3351 hmep->hme_coll += 256;
3355 hmep->hme_babl++;
3356 hmep->hme_oerrors++;
3364 hmep->hme_uflo++;
3365 hmep->hme_oerrors++;
3369 hmep->hme_sqe_errors++;
3373 if (hmep->hme_rxcv_enable) {
3374 hmep->hme_cvc += 256;
3379 hmep->hme_oflo++;
3380 hmep->hme_ierrors++;
3384 hmep->hme_lenerr += 256;
3385 hmep->hme_ierrors += 256;
3389 hmep->hme_align_errors += 256;
3390 hmep->hme_ierrors += 256;
3394 hmep->hme_fcs_errors += 256;
3395 hmep->hme_ierrors += 256;
3400 hmeread(struct hme *hmep, hmebuf_t *rbuf, uint32_t rflags)
3417 hmep->hme_runt++;
3420 hmep->hme_buff++;
3421 hmep->hme_toolong_errors++;
3423 hmep->hme_ierrors++;
3439 hmep->hme_allocbfail++;
3440 hmep->hme_norcvbuf++;
3447 hmep->hme_ipackets++;
3456 BUMP_InNUcast(hmep, bp->b_rptr);
3457 hmep->hme_rbytes += len;
3475 hme_fault_msg(struct hme *hmep, uint_t severity, msg_t type, char *fmt, ...)
3483 if (hmep == NULL) {
3487 cmn_err(CE_CONT, "?%s%d : %s\n", ddi_driver_name(hmep->dip),
3488 hmep->instance, msg_buffer);
3491 ddi_driver_name(hmep->dip), hmep->instance,
3494 cmn_err(CE_CONT, "%s%d : %s\n", ddi_driver_name(hmep->dip),
3495 hmep->instance, msg_buffer);
3505 hmesavecntrs(struct hme *hmep)
3515 hmep->hme_align_errors += aecnt;
3519 hmep->hme_lenerr += lecnt;
3527 if (!hmep->hme_rxcv_enable) {
3531 hmep->hme_cvc += rxcv;
3535 hmep->hme_tlcol += ltcnt;
3539 hmep->hme_excol += excnt;
3542 hmep->hme_fcs_errors += fecnt;
3543 hmep->hme_ierrors += (fecnt + aecnt + lecnt);
3544 hmep->hme_oerrors += (ltcnt + excnt);
3545 hmep->hme_coll += (GET_MACREG(nccnt) + ltcnt);
3566 hme_setup_mac_address(struct hme *hmep, dev_info_t *dip)
3571 hmep->hme_addrflags = 0;
3582 hmep->hme_addrflags = HME_FACTADDR_PRESENT;
3583 ether_bcopy(prop, &hmep->hme_factaddr);
3584 HME_FAULT_MSG2(hmep, SEVERITY_NONE, DISPLAY_MSG,
3586 ether_sprintf(&hmep->hme_factaddr));
3598 ether_bcopy(prop, &hmep->hme_ouraddr);
3614 (hmep->hme_addrflags & HME_FACTADDR_PRESENT)) {
3615 hmep->hme_addrflags |= HME_FACTADDR_USE;
3616 ether_bcopy(&hmep->hme_factaddr, &hmep->hme_ouraddr);
3618 HME_FAULT_MSG1(hmep, SEVERITY_NONE, DISPLAY_MSG,
3628 (void) localetheraddr((struct ether_addr *)NULL, &hmep->hme_ouraddr);
3630 ether_bcopy(&hmep->hme_factaddr, &hmep->hme_ouraddr);
3636 hme_check_acc_handle(char *file, uint_t line, struct hme *hmep,