Lines Matching refs:dmfep
275 dmfe_chip_get32(dmfe_t *dmfep, off_t offset) in dmfe_chip_get32() argument
279 addr = (void *)(dmfep->io_reg + offset); in dmfe_chip_get32()
280 return (ddi_get32(dmfep->io_handle, addr)); in dmfe_chip_get32()
284 dmfe_chip_put32(dmfe_t *dmfep, off_t offset, uint32_t value) in dmfe_chip_put32() argument
288 addr = (void *)(dmfep->io_reg + offset); in dmfe_chip_put32()
289 ddi_put32(dmfep->io_handle, addr, value); in dmfe_chip_put32()
343 dmfe_set_opmode(dmfe_t *dmfep) in dmfe_set_opmode() argument
345 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_set_opmode()
347 dmfe_chip_put32(dmfep, OPN_MODE_REG, dmfep->opmode); in dmfe_set_opmode()
355 dmfe_stop_chip(dmfe_t *dmfep, enum chip_state newstate) in dmfe_stop_chip() argument
357 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_stop_chip()
367 dmfe_chip_put32(dmfep, INT_MASK_REG, 0); in dmfe_stop_chip()
368 dmfep->opmode &= ~(START_TRANSMIT | START_RECEIVE); in dmfe_stop_chip()
369 dmfe_set_opmode(dmfep); in dmfe_stop_chip()
370 dmfe_chip_put32(dmfep, STATUS_REG, TX_STOPPED_INT | RX_STOPPED_INT); in dmfe_stop_chip()
382 dmfe_chip_put32(dmfep, BUS_MODE_REG, SW_RESET); in dmfe_stop_chip()
384 dmfe_chip_put32(dmfep, BUS_MODE_REG, 0); in dmfe_stop_chip()
386 dmfe_chip_put32(dmfep, BUS_MODE_REG, dmfe_bus_modes); in dmfe_stop_chip()
390 dmfep->chip_state = newstate; in dmfe_stop_chip()
398 dmfe_init_rings(dmfe_t *dmfep) in dmfe_init_rings() argument
410 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_init_rings()
411 ASSERT(mutex_owned(dmfep->rxlock)); in dmfe_init_rings()
412 ASSERT(mutex_owned(dmfep->txlock)); in dmfe_init_rings()
417 descp = &dmfep->rx_desc; in dmfe_init_rings()
420 pbuff = dmfep->rx_buff.mem_dvma; in dmfe_init_rings()
423 for (i = 0; i < dmfep->rx.n_desc; ++i) { in dmfe_init_rings()
438 dmfep->rx.next_free = 0; in dmfe_init_rings()
443 dmfe_chip_put32(dmfep, RX_BASE_ADDR_REG, descp->mem_dvma); in dmfe_init_rings()
448 descp = &dmfep->tx_desc; in dmfe_init_rings()
451 pbuff = dmfep->tx_buff.mem_dvma; in dmfe_init_rings()
454 for (i = 0; i < dmfep->tx.n_desc; ++i) { in dmfe_init_rings()
469 dmfep->tx.n_free = dmfep->tx.n_desc; in dmfe_init_rings()
470 dmfep->tx.next_free = dmfep->tx.next_busy = 0; in dmfe_init_rings()
475 dmfe_chip_put32(dmfep, TX_BASE_ADDR_REG, descp->mem_dvma); in dmfe_init_rings()
482 dmfe_start_chip(dmfe_t *dmfep, int mode) in dmfe_start_chip() argument
484 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_start_chip()
486 dmfep->opmode |= mode; in dmfe_start_chip()
487 dmfe_set_opmode(dmfep); in dmfe_start_chip()
489 dmfe_chip_put32(dmfep, W_J_TIMER_REG, 0); in dmfe_start_chip()
493 dmfe_chip_put32(dmfep, W_J_TIMER_REG, VLAN_ENABLE); in dmfe_start_chip()
498 dmfe_chip_put32(dmfep, STATUS_REG, TX_STOPPED_INT | RX_STOPPED_INT); in dmfe_start_chip()
499 dmfep->chip_state = mode & START_RECEIVE ? CHIP_TX_RX : in dmfe_start_chip()
529 dmfe_enable_interrupts(dmfe_t *dmfep) in dmfe_enable_interrupts() argument
531 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_enable_interrupts()
536 dmfep->imask = RX_PKTDONE_INT | TX_PKTDONE_INT | in dmfe_enable_interrupts()
539 dmfe_chip_put32(dmfep, INT_MASK_REG, in dmfe_enable_interrupts()
540 NORMAL_SUMMARY_INT | ABNORMAL_SUMMARY_INT | dmfep->imask); in dmfe_enable_interrupts()
541 dmfep->chip_state = CHIP_RUNNING; in dmfe_enable_interrupts()
552 dmfe_update_rx_stats(dmfe_t *dmfep, uint32_t desc0) in dmfe_update_rx_stats() argument
554 ASSERT(mutex_owned(dmfep->rxlock)); in dmfe_update_rx_stats()
563 dmfep->rx_stats_ierrors += 1; in dmfe_update_rx_stats()
577 dmfep->rx_stats_overflow += 1; in dmfe_update_rx_stats()
580 dmfep->rx_stats_short += 1; in dmfe_update_rx_stats()
583 dmfep->rx_stats_fcs += 1; in dmfe_update_rx_stats()
586 dmfep->rx_stats_toolong += 1; in dmfe_update_rx_stats()
595 dmfep->rx_stats_macrcv_errors += 1; in dmfe_update_rx_stats()
598 dmfep->rx_stats_align += 1; in dmfe_update_rx_stats()
601 dmfep->rx_stats_macrcv_errors += 1; in dmfe_update_rx_stats()
608 dmfe_getp(dmfe_t *dmfep) in dmfe_getp() argument
621 mutex_enter(dmfep->rxlock); in dmfe_getp()
626 misses = dmfe_chip_get32(dmfep, MISSED_FRAME_REG); in dmfe_getp()
627 dmfep->rx_stats_norcvbuf += (misses & MISSED_FRAME_MASK); in dmfe_getp()
632 descp = &dmfep->rx_desc; in dmfe_getp()
639 index = dmfep->rx.next_free; in dmfe_getp()
648 dmfe_update_rx_stats(dmfep, desc0); in dmfe_getp()
696 (void) ddi_dma_sync(dmfep->rx_buff.dma_hdl, in dmfe_getp()
699 rxb = &dmfep->rx_buff.mem_va[index*DMFE_BUF_SIZE]; in dmfe_getp()
720 dmfep->rx_stats_norcvbuf += 1; in dmfe_getp()
727 dmfep->rx_stats_ipackets += 1; in dmfe_getp()
728 dmfep->rx_stats_rbytes += packet_length; in dmfe_getp()
731 dmfep->rx_stats_multi += 1; in dmfe_getp()
733 dmfep->rx_stats_bcast += 1; in dmfe_getp()
761 index = NEXT(index, dmfep->rx.n_desc); in dmfe_getp()
768 dmfep->rx.next_free = index; in dmfe_getp()
776 dmfe_chip_put32(dmfep, RX_POLL_REG, 0); in dmfe_getp()
778 mutex_exit(dmfep->rxlock); in dmfe_getp()
853 dmfe_update_tx_stats(dmfe_t *dmfep, int index, uint32_t desc0, uint32_t desc1) in dmfe_update_tx_stats() argument
859 ASSERT(mutex_owned(dmfep->txlock)); in dmfe_update_tx_stats()
866 dmfe_log(dmfep, "dubious TX error status 0x%x", desc0); in dmfe_update_tx_stats()
871 dmfep->tx_stats_oerrors += 1; in dmfe_update_tx_stats()
880 dmfep->tx_stats_macxmt_errors += 1; in dmfe_update_tx_stats()
881 dmfep->tx_stats_jabber += 1; in dmfe_update_tx_stats()
885 dmfep->tx_stats_underflow += 1; in dmfe_update_tx_stats()
887 dmfep->tx_stats_xmtlatecoll += 1; in dmfe_update_tx_stats()
890 dmfep->tx_stats_nocarrier += 1; in dmfe_update_tx_stats()
893 dmfep->tx_stats_excoll += 1; in dmfe_update_tx_stats()
900 if (dmfep->tx_mcast[byt] & bit) { in dmfe_update_tx_stats()
901 dmfep->tx_mcast[byt] &= ~bit; in dmfe_update_tx_stats()
902 dmfep->tx_stats_multi += 1; in dmfe_update_tx_stats()
904 } else if (dmfep->tx_bcast[byt] & bit) { in dmfe_update_tx_stats()
905 dmfep->tx_bcast[byt] &= ~bit; in dmfe_update_tx_stats()
906 dmfep->tx_stats_bcast += 1; in dmfe_update_tx_stats()
909 dmfep->tx_stats_opackets += 1; in dmfe_update_tx_stats()
910 dmfep->tx_stats_obytes += desc1 & TX_BUFFER_SIZE1; in dmfe_update_tx_stats()
914 dmfep->tx_stats_first_coll += 1; in dmfe_update_tx_stats()
916 dmfep->tx_stats_multi_coll += 1; in dmfe_update_tx_stats()
917 dmfep->tx_stats_collisions += collisions; in dmfe_update_tx_stats()
920 dmfep->tx_stats_defer += 1; in dmfe_update_tx_stats()
930 dmfe_reclaim_tx_desc(dmfe_t *dmfep) in dmfe_reclaim_tx_desc() argument
937 ASSERT(mutex_owned(dmfep->txlock)); in dmfe_reclaim_tx_desc()
942 descp = &dmfep->tx_desc; in dmfe_reclaim_tx_desc()
950 i = dmfep->tx.next_busy; in dmfe_reclaim_tx_desc()
951 if (i == dmfep->tx.next_free) in dmfe_reclaim_tx_desc()
968 dmfe_update_tx_stats(dmfep, i, desc0, desc1); in dmfe_reclaim_tx_desc()
976 dmfep->tx.n_free += 1; in dmfe_reclaim_tx_desc()
977 i = NEXT(i, dmfep->tx.n_desc); in dmfe_reclaim_tx_desc()
978 if (i == dmfep->tx.next_free) in dmfe_reclaim_tx_desc()
985 dmfep->tx.next_busy = i; in dmfe_reclaim_tx_desc()
986 dmfep->tx_pending_tix = 0; in dmfe_reclaim_tx_desc()
1005 dmfe_send_msg(dmfe_t *dmfep, mblk_t *mp) in dmfe_send_msg() argument
1022 mutex_enter(dmfep->txlock); in dmfe_send_msg()
1023 if (dmfep->suspended) in dmfe_send_msg()
1026 if (dmfep->tx.n_free <= dmfe_tx_reclaim_level && in dmfe_send_msg()
1027 dmfe_reclaim_tx_desc(dmfep) == B_FALSE && in dmfe_send_msg()
1028 dmfep->tx.n_free <= dmfe_tx_min_free) { in dmfe_send_msg()
1034 mutex_exit(dmfep->txlock); in dmfe_send_msg()
1051 index = dmfep->tx.next_free; in dmfe_send_msg()
1052 dmfep->tx.next_free = NEXT(index, dmfep->tx.n_desc); in dmfe_send_msg()
1053 ASSERT(dmfep->tx.next_free != dmfep->tx.next_busy); in dmfe_send_msg()
1054 if (dmfep->tx.n_free-- == dmfep->tx.n_desc) in dmfe_send_msg()
1055 dmfep->tx_pending_tix = 0; in dmfe_send_msg()
1056 ASSERT(dmfep->tx.n_free >= 1); in dmfe_send_msg()
1057 mutex_exit(dmfep->txlock); in dmfe_send_msg()
1062 descp = &dmfep->tx_desc; in dmfe_send_msg()
1091 txb = &dmfep->tx_buff.mem_va[index*DMFE_BUF_SIZE]; in dmfe_send_msg()
1111 txb = &dmfep->tx_buff.mem_va[index*DMFE_BUF_SIZE]; in dmfe_send_msg()
1114 dmfep->tx_bcast[index / NBBY] |= in dmfe_send_msg()
1117 dmfep->tx_mcast[index / NBBY] |= in dmfe_send_msg()
1132 paddr = dmfep->tx_buff.mem_dvma + index*DMFE_BUF_SIZE; in dmfe_send_msg()
1134 (void) ddi_dma_sync(dmfep->tx_buff.dma_hdl, in dmfe_send_msg()
1149 dmfe_chip_put32(dmfep, TX_POLL_REG, 0); in dmfe_send_msg()
1173 dmfe_t *dmfep = arg; /* private device info */ in dmfe_m_tx() local
1177 ASSERT(dmfep->mac_state == DMFE_MAC_STARTED); in dmfe_m_tx()
1179 if (dmfep->chip_state != CHIP_RUNNING) in dmfe_m_tx()
1185 if (!dmfe_send_msg(dmfep, mp)) { in dmfe_m_tx()
1239 dmfe_update_hash(dmfe_t *dmfep, uint32_t index, boolean_t val) in dmfe_update_hash() argument
1244 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_update_hash()
1246 descp = &dmfep->tx_desc; in dmfe_update_hash()
1263 dmfe_update_mcast(dmfe_t *dmfep, const uint8_t *mca, boolean_t val) in dmfe_update_mcast() argument
1270 refp = &dmfep->mcast_refs[index]; in dmfe_update_mcast()
1274 dmfe_update_hash(dmfep, index, val); in dmfe_update_mcast()
1283 dmfe_send_setup(dmfe_t *dmfep) in dmfe_send_setup() argument
1287 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_send_setup()
1289 if (dmfep->suspended) in dmfe_send_setup()
1297 if ((dmfep->opmode & START_TRANSMIT) == 0) in dmfe_send_setup()
1307 status = dmfe_send_msg(dmfep, NULL); in dmfe_send_setup()
1308 dmfep->need_setup = status ? B_FALSE : B_TRUE; in dmfe_send_setup()
1318 dmfe_t *dmfep = arg; in dmfe_m_unicst() local
1356 mutex_enter(dmfep->oplock); in dmfe_m_unicst()
1358 if (dmfep->addr_set && dmfe_setup_desc1 & TX_FILTER_TYPE1) in dmfe_m_unicst()
1359 (void) dmfe_update_mcast(dmfep, dmfep->curr_addr, B_FALSE); in dmfe_m_unicst()
1361 (void) dmfe_update_mcast(dmfep, macaddr, B_TRUE); in dmfe_m_unicst()
1362 if (!dmfep->addr_set) in dmfe_m_unicst()
1363 (void) dmfe_update_mcast(dmfep, dmfe_broadcast_addr, B_TRUE); in dmfe_m_unicst()
1368 ethaddr_copy(macaddr, dmfep->curr_addr); in dmfe_m_unicst()
1369 dmfep->addr_set = B_TRUE; in dmfe_m_unicst()
1378 dmfe_setup_put32(&dmfep->tx_desc, SETUPBUF_PHYS+index/2, in dmfe_m_unicst()
1384 status = dmfe_send_setup(dmfep); in dmfe_m_unicst()
1385 mutex_exit(dmfep->oplock); in dmfe_m_unicst()
1403 dmfe_t *dmfep = arg; /* private device info */ in dmfe_m_multicst() local
1406 mutex_enter(dmfep->oplock); in dmfe_m_multicst()
1407 if (dmfe_update_mcast(dmfep, mca, add)) in dmfe_m_multicst()
1408 status = dmfe_send_setup(dmfep); in dmfe_m_multicst()
1409 mutex_exit(dmfep->oplock); in dmfe_m_multicst()
1430 dmfe_stop(dmfe_t *dmfep) in dmfe_stop() argument
1432 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_stop()
1434 dmfe_stop_chip(dmfep, CHIP_STOPPED); in dmfe_stop()
1441 dmfe_reset(dmfe_t *dmfep) in dmfe_reset() argument
1443 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_reset()
1444 ASSERT(mutex_owned(dmfep->rxlock)); in dmfe_reset()
1445 ASSERT(mutex_owned(dmfep->txlock)); in dmfe_reset()
1447 dmfe_stop_chip(dmfep, CHIP_RESET); in dmfe_reset()
1448 dmfe_init_rings(dmfep); in dmfe_reset()
1455 dmfe_start(dmfe_t *dmfep) in dmfe_start() argument
1459 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_start()
1461 ASSERT(dmfep->chip_state == CHIP_RESET || in dmfe_start()
1462 dmfep->chip_state == CHIP_STOPPED); in dmfe_start()
1467 gpsr = dmfe_chip_get32(dmfep, PHY_STATUS_REG); in dmfe_start()
1469 dmfep->opmode |= FULL_DUPLEX; in dmfe_start()
1471 dmfep->opmode &= ~FULL_DUPLEX; in dmfe_start()
1479 dmfe_start_chip(dmfep, START_TRANSMIT); in dmfe_start()
1480 (void) dmfe_send_setup(dmfep); in dmfe_start()
1482 dmfe_start_chip(dmfep, START_RECEIVE); in dmfe_start()
1483 dmfe_enable_interrupts(dmfep); in dmfe_start()
1490 dmfe_restart(dmfe_t *dmfep) in dmfe_restart() argument
1492 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_restart()
1499 mutex_enter(dmfep->rxlock); in dmfe_restart()
1500 mutex_enter(dmfep->txlock); in dmfe_restart()
1501 dmfe_reset(dmfep); in dmfe_restart()
1502 mutex_exit(dmfep->txlock); in dmfe_restart()
1503 mutex_exit(dmfep->rxlock); in dmfe_restart()
1504 if (dmfep->mac_state == DMFE_MAC_STARTED) { in dmfe_restart()
1505 dmfe_start(dmfep); in dmfe_restart()
1520 dmfe_t *dmfep = arg; /* private device info */ in dmfe_m_stop() local
1525 mii_stop(dmfep->mii); in dmfe_m_stop()
1527 mutex_enter(dmfep->oplock); in dmfe_m_stop()
1528 if (!dmfep->suspended) in dmfe_m_stop()
1529 dmfe_stop(dmfep); in dmfe_m_stop()
1530 dmfep->mac_state = DMFE_MAC_STOPPED; in dmfe_m_stop()
1531 mutex_exit(dmfep->oplock); in dmfe_m_stop()
1540 dmfe_t *dmfep = arg; /* private device info */ in dmfe_m_start() local
1545 mutex_enter(dmfep->oplock); in dmfe_m_start()
1546 if (!dmfep->suspended) in dmfe_m_start()
1547 dmfe_start(dmfep); in dmfe_m_start()
1548 dmfep->mac_state = DMFE_MAC_STARTED; in dmfe_m_start()
1549 mutex_exit(dmfep->oplock); in dmfe_m_start()
1551 mii_start(dmfep->mii); in dmfe_m_start()
1567 dmfe_t *dmfep = arg; in dmfe_m_promisc() local
1569 mutex_enter(dmfep->oplock); in dmfe_m_promisc()
1570 dmfep->opmode &= ~(PROMISC_MODE | PASS_MULTICAST); in dmfe_m_promisc()
1572 dmfep->opmode |= PROMISC_MODE; in dmfe_m_promisc()
1573 if (!dmfep->suspended) in dmfe_m_promisc()
1574 dmfe_set_opmode(dmfep); in dmfe_m_promisc()
1575 mutex_exit(dmfep->oplock); in dmfe_m_promisc()
1594 dmfe_t *dmfep; in dmfe_factotum() local
1596 dmfep = (void *)arg; in dmfe_factotum()
1597 ASSERT(dmfep->dmfe_guard == DMFE_GUARD); in dmfe_factotum()
1599 mutex_enter(dmfep->oplock); in dmfe_factotum()
1600 if (dmfep->suspended) { in dmfe_factotum()
1601 mutex_exit(dmfep->oplock); in dmfe_factotum()
1605 dmfep->factotum_flag = 0; in dmfe_factotum()
1606 DRV_KS_INC(dmfep, KS_FACTOTUM_RUN); in dmfe_factotum()
1611 if (dmfep->chip_state == CHIP_ERROR) { in dmfe_factotum()
1616 DRV_KS_INC(dmfep, KS_RECOVERY); in dmfe_factotum()
1617 dmfe_restart(dmfep); in dmfe_factotum()
1618 mutex_exit(dmfep->oplock); in dmfe_factotum()
1620 mii_reset(dmfep->mii); in dmfe_factotum()
1622 } else if (dmfep->need_setup) { in dmfe_factotum()
1623 (void) dmfe_send_setup(dmfep); in dmfe_factotum()
1624 mutex_exit(dmfep->oplock); in dmfe_factotum()
1631 dmfe_wake_factotum(dmfe_t *dmfep, int ks_id, const char *why) in dmfe_wake_factotum() argument
1634 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_wake_factotum()
1635 DRV_KS_INC(dmfep, ks_id); in dmfe_wake_factotum()
1637 if (dmfep->factotum_flag++ == 0) in dmfe_wake_factotum()
1638 ddi_trigger_softintr(dmfep->factotum_id); in dmfe_wake_factotum()
1652 dmfe_tick_stall_check(dmfe_t *dmfep, uint32_t gpsr, uint32_t istat) in dmfe_tick_stall_check() argument
1658 ASSERT(mutex_owned(dmfep->oplock)); in dmfe_tick_stall_check()
1681 if (mutex_tryenter(dmfep->txlock)) { in dmfe_tick_stall_check()
1682 if (dmfep->tx.n_free < dmfep->tx.n_desc) { in dmfe_tick_stall_check()
1688 if (++dmfep->tx_pending_tix >= limit && in dmfe_tick_stall_check()
1689 dmfe_reclaim_tx_desc(dmfep) == B_FALSE) { in dmfe_tick_stall_check()
1690 dmfe_log(dmfep, "TX stall detected " in dmfe_tick_stall_check()
1693 dmfep->tx_pending_tix, tx_state); in dmfe_tick_stall_check()
1697 mutex_exit(dmfep->txlock); in dmfe_tick_stall_check()
1701 dmfe_stop_chip(dmfep, CHIP_ERROR); in dmfe_tick_stall_check()
1702 dmfe_wake_factotum(dmfep, KS_TX_STALL, "tick (TX stall)"); in dmfe_tick_stall_check()
1712 dmfe_t *dmfep = arg; /* private device info */ in dmfe_cyclic() local
1721 if (mutex_tryenter(dmfep->oplock) == 0) in dmfe_cyclic()
1723 if ((dmfep->suspended) || (dmfep->chip_state != CHIP_RUNNING)) { in dmfe_cyclic()
1724 mutex_exit(dmfep->oplock); in dmfe_cyclic()
1733 if (dmfep->chip_state == CHIP_RUNNING) { in dmfe_cyclic()
1734 istat = dmfe_chip_get32(dmfep, STATUS_REG); in dmfe_cyclic()
1735 gpsr = dmfe_chip_get32(dmfep, PHY_STATUS_REG); in dmfe_cyclic()
1736 dmfe_tick_stall_check(dmfep, gpsr, istat); in dmfe_cyclic()
1739 DRV_KS_INC(dmfep, KS_CYCLIC_RUN); in dmfe_cyclic()
1740 mutex_exit(dmfep->oplock); in dmfe_cyclic()
1753 dmfe_t *dmfep; /* private device info */ in dmfe_interrupt() local
1760 dmfep = (void *)arg; in dmfe_interrupt()
1762 mutex_enter(dmfep->oplock); in dmfe_interrupt()
1763 if (dmfep->suspended) { in dmfe_interrupt()
1764 mutex_exit(dmfep->oplock); in dmfe_interrupt()
1777 istat = dmfe_chip_get32(dmfep, STATUS_REG); in dmfe_interrupt()
1780 mutex_exit(dmfep->oplock); in dmfe_interrupt()
1784 DRV_KS_INC(dmfep, KS_INTERRUPT); in dmfe_interrupt()
1789 istat |= dmfe_chip_get32(dmfep, STATUS_REG); in dmfe_interrupt()
1790 interrupts = istat & dmfep->imask; in dmfe_interrupt()
1856 dmfe_warning(dmfep, "abnormal interrupt, " in dmfe_interrupt()
1865 dmfe_stop_chip(dmfep, CHIP_ERROR); in dmfe_interrupt()
1866 dmfe_wake_factotum(dmfep, KS_CHIP_ERROR, in dmfe_interrupt()
1884 if (dmfep->chip_state != CHIP_ERROR) { in dmfe_interrupt()
1885 (void) dmfe_chip_put32(dmfep, STATUS_REG, istat); in dmfe_interrupt()
1890 (void) dmfe_chip_get32(dmfep, STATUS_REG); in dmfe_interrupt()
1899 mutex_exit(dmfep->oplock); in dmfe_interrupt()
1902 if ((mp = dmfe_getp(dmfep)) != NULL) in dmfe_interrupt()
1903 mac_rx(dmfep->mh, NULL, mp); in dmfe_interrupt()
1914 if (dmfe_reclaim_on_done && mutex_tryenter(dmfep->txlock)) { in dmfe_interrupt()
1915 (void) dmfe_reclaim_tx_desc(dmfep); in dmfe_interrupt()
1916 mutex_exit(dmfep->txlock); in dmfe_interrupt()
1918 mac_tx_update(dmfep->mh); in dmfe_interrupt()
1931 dmfe_t *dmfep = arg; in dmfe_m_stat() local
1935 if (mii_m_getstat(dmfep->mii, stat, val) == 0) { in dmfe_m_stat()
1939 mutex_enter(dmfep->oplock); in dmfe_m_stat()
1940 mutex_enter(dmfep->rxlock); in dmfe_m_stat()
1941 mutex_enter(dmfep->txlock); in dmfe_m_stat()
1944 (void) dmfe_reclaim_tx_desc(dmfep); in dmfe_m_stat()
1949 *val = dmfep->rx_stats_ipackets; in dmfe_m_stat()
1953 *val = dmfep->rx_stats_multi; in dmfe_m_stat()
1957 *val = dmfep->rx_stats_bcast; in dmfe_m_stat()
1961 *val = dmfep->rx_stats_rbytes; in dmfe_m_stat()
1965 *val = dmfep->rx_stats_ierrors; in dmfe_m_stat()
1969 *val = dmfep->rx_stats_norcvbuf; in dmfe_m_stat()
1973 *val = dmfep->tx_stats_collisions; in dmfe_m_stat()
1977 *val = dmfep->tx_stats_oerrors; in dmfe_m_stat()
1981 *val = dmfep->tx_stats_opackets; in dmfe_m_stat()
1985 *val = dmfep->tx_stats_multi; in dmfe_m_stat()
1989 *val = dmfep->tx_stats_bcast; in dmfe_m_stat()
1993 *val = dmfep->tx_stats_obytes; in dmfe_m_stat()
1997 *val = dmfep->rx_stats_overflow; in dmfe_m_stat()
2001 *val = dmfep->tx_stats_underflow; in dmfe_m_stat()
2005 *val = dmfep->rx_stats_align; in dmfe_m_stat()
2009 *val = dmfep->rx_stats_fcs; in dmfe_m_stat()
2013 *val = dmfep->rx_stats_toolong; in dmfe_m_stat()
2017 *val = dmfep->rx_stats_short; in dmfe_m_stat()
2021 *val = dmfep->rx_stats_macrcv_errors; in dmfe_m_stat()
2025 *val = dmfep->tx_stats_macxmt_errors; in dmfe_m_stat()
2029 *val = dmfep->tx_stats_jabber; in dmfe_m_stat()
2033 *val = dmfep->tx_stats_nocarrier; in dmfe_m_stat()
2037 *val = dmfep->tx_stats_xmtlatecoll; in dmfe_m_stat()
2041 *val = dmfep->tx_stats_excoll; in dmfe_m_stat()
2045 *val = dmfep->tx_stats_defer; in dmfe_m_stat()
2049 *val = dmfep->tx_stats_first_coll; in dmfe_m_stat()
2053 *val = dmfep->tx_stats_multi_coll; in dmfe_m_stat()
2060 mutex_exit(dmfep->txlock); in dmfe_m_stat()
2061 mutex_exit(dmfep->rxlock); in dmfe_m_stat()
2062 mutex_exit(dmfep->oplock); in dmfe_m_stat()
2086 dmfe_t *dmfep = arg; in dmfe_m_ioctl() local
2127 mutex_enter(dmfep->oplock); in dmfe_m_ioctl()
2128 switch (dmfep->opmode & LOOPBACK_MODE_MASK) { in dmfe_m_ioctl()
2139 mutex_exit(dmfep->oplock); in dmfe_m_ioctl()
2154 mutex_enter(dmfep->oplock); in dmfe_m_ioctl()
2155 dmfep->opmode &= ~LOOPBACK_MODE_MASK; in dmfe_m_ioctl()
2158 dmfep->opmode |= LOOPBACK_PHY_D; in dmfe_m_ioctl()
2161 dmfep->opmode |= LOOPBACK_INTERNAL; in dmfe_m_ioctl()
2166 if (!dmfep->suspended) { in dmfe_m_ioctl()
2167 dmfe_restart(dmfep); in dmfe_m_ioctl()
2169 mutex_exit(dmfep->oplock); in dmfe_m_ioctl()
2188 dmfe_t *dmfep = arg; in dmfe_m_getprop() local
2190 return (mii_m_getprop(dmfep->mii, name, num, sz, val)); in dmfe_m_getprop()
2197 dmfe_t *dmfep = arg; in dmfe_m_setprop() local
2199 return (mii_m_setprop(dmfep->mii, name, num, sz, val)); in dmfe_m_setprop()
2206 dmfe_t *dmfep = arg; in dmfe_m_propinfo() local
2208 mii_m_propinfo(dmfep->mii, name, num, mph); in dmfe_m_propinfo()
2219 dmfe_find_mac_address(dmfe_t *dmfep) in dmfe_find_mac_address() argument
2233 bzero(dmfep->curr_addr, sizeof (dmfep->curr_addr)); in dmfe_find_mac_address()
2234 err = ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, dmfep->devinfo, in dmfe_find_mac_address()
2238 ethaddr_copy(prop, dmfep->curr_addr); in dmfe_find_mac_address()
2242 dmfe_read_eeprom(dmfep, EEPROM_EN_ADDR, dmfep->curr_addr, in dmfe_find_mac_address()
2248 dmfe_alloc_dma_mem(dmfe_t *dmfep, size_t memsize, in dmfe_alloc_dma_mem() argument
2259 err = ddi_dma_alloc_handle(dmfep->devinfo, &dma_attr, in dmfe_alloc_dma_mem()
2262 dmfe_error(dmfep, "DMA handle allocation failed"); in dmfe_alloc_dma_mem()
2274 dmfe_error(dmfep, "DMA memory allocation failed: %d", err); in dmfe_alloc_dma_mem()
2285 dmfe_error(dmfep, "DMA mapping failed: %d", err); in dmfe_alloc_dma_mem()
2289 dmfe_error(dmfep, "Too many DMA cookeis: %d", ncookies); in dmfe_alloc_dma_mem()
2309 dmfe_alloc_bufs(dmfe_t *dmfep) in dmfe_alloc_bufs() argument
2317 memsize = dmfep->tx.n_desc * sizeof (struct tx_desc_type); in dmfe_alloc_bufs()
2318 err = dmfe_alloc_dma_mem(dmfep, memsize, SETUPBUF_SIZE, DMFE_SLOP, in dmfe_alloc_bufs()
2320 &dmfep->tx_desc); in dmfe_alloc_bufs()
2322 dmfe_error(dmfep, "TX descriptor allocation failed"); in dmfe_alloc_bufs()
2329 memsize = dmfep->tx.n_desc * DMFE_BUF_SIZE; in dmfe_alloc_bufs()
2330 err = dmfe_alloc_dma_mem(dmfep, memsize, 0, 0, in dmfe_alloc_bufs()
2332 &dmfep->tx_buff); in dmfe_alloc_bufs()
2334 dmfe_error(dmfep, "TX buffer allocation failed"); in dmfe_alloc_bufs()
2341 memsize = dmfep->rx.n_desc * sizeof (struct rx_desc_type); in dmfe_alloc_bufs()
2342 err = dmfe_alloc_dma_mem(dmfep, memsize, 0, DMFE_SLOP, in dmfe_alloc_bufs()
2344 &dmfep->rx_desc); in dmfe_alloc_bufs()
2346 dmfe_error(dmfep, "RX descriptor allocation failed"); in dmfe_alloc_bufs()
2353 memsize = dmfep->rx.n_desc * DMFE_BUF_SIZE; in dmfe_alloc_bufs()
2354 err = dmfe_alloc_dma_mem(dmfep, memsize, 0, 0, in dmfe_alloc_bufs()
2355 &dmfe_data_accattr, DDI_DMA_READ | DMFE_DMA_MODE, &dmfep->rx_buff); in dmfe_alloc_bufs()
2357 dmfe_error(dmfep, "RX buffer allocation failed"); in dmfe_alloc_bufs()
2364 dmfep->tx_mcast = kmem_zalloc(dmfep->tx.n_desc / NBBY, KM_SLEEP); in dmfe_alloc_bufs()
2365 dmfep->tx_bcast = kmem_zalloc(dmfep->tx.n_desc / NBBY, KM_SLEEP); in dmfe_alloc_bufs()
2397 dmfe_free_bufs(dmfe_t *dmfep) in dmfe_free_bufs() argument
2399 dmfe_free_dma_mem(&dmfep->rx_buff); in dmfe_free_bufs()
2400 dmfe_free_dma_mem(&dmfep->rx_desc); in dmfe_free_bufs()
2401 dmfe_free_dma_mem(&dmfep->tx_buff); in dmfe_free_bufs()
2402 dmfe_free_dma_mem(&dmfep->tx_desc); in dmfe_free_bufs()
2403 if (dmfep->tx_mcast) in dmfe_free_bufs()
2404 kmem_free(dmfep->tx_mcast, dmfep->tx.n_desc / NBBY); in dmfe_free_bufs()
2405 if (dmfep->tx_bcast) in dmfe_free_bufs()
2406 kmem_free(dmfep->tx_bcast, dmfep->tx.n_desc / NBBY); in dmfe_free_bufs()
2410 dmfe_unattach(dmfe_t *dmfep) in dmfe_unattach() argument
2415 if (dmfep->cycid != NULL) { in dmfe_unattach()
2416 ddi_periodic_delete(dmfep->cycid); in dmfe_unattach()
2417 dmfep->cycid = NULL; in dmfe_unattach()
2420 if (dmfep->ksp_drv != NULL) in dmfe_unattach()
2421 kstat_delete(dmfep->ksp_drv); in dmfe_unattach()
2422 if (dmfep->progress & PROGRESS_HWINT) { in dmfe_unattach()
2423 ddi_remove_intr(dmfep->devinfo, 0, dmfep->iblk); in dmfe_unattach()
2425 if (dmfep->progress & PROGRESS_SOFTINT) in dmfe_unattach()
2426 ddi_remove_softintr(dmfep->factotum_id); in dmfe_unattach()
2427 if (dmfep->mii != NULL) in dmfe_unattach()
2428 mii_free(dmfep->mii); in dmfe_unattach()
2429 if (dmfep->progress & PROGRESS_MUTEX) { in dmfe_unattach()
2430 mutex_destroy(dmfep->txlock); in dmfe_unattach()
2431 mutex_destroy(dmfep->rxlock); in dmfe_unattach()
2432 mutex_destroy(dmfep->oplock); in dmfe_unattach()
2434 dmfe_free_bufs(dmfep); in dmfe_unattach()
2435 if (dmfep->io_handle != NULL) in dmfe_unattach()
2436 ddi_regs_map_free(&dmfep->io_handle); in dmfe_unattach()
2438 kmem_free(dmfep, sizeof (*dmfep)); in dmfe_unattach()
2442 dmfe_config_init(dmfe_t *dmfep, chip_id_t *idp) in dmfe_config_init() argument
2447 if (pci_config_setup(dmfep->devinfo, &handle) != DDI_SUCCESS) in dmfe_config_init()
2491 dmfe_init_kstats(dmfe_t *dmfep, int instance) in dmfe_init_kstats() argument
2508 dmfep->ksp_drv = ksp; in dmfe_init_kstats()
2509 dmfep->knp_drv = knp; in dmfe_init_kstats()
2512 dmfe_error(dmfep, "kstat_create() for dmfe_events failed"); in dmfe_init_kstats()
2519 dmfe_t *dmfep; /* Our private data */ in dmfe_resume() local
2523 dmfep = ddi_get_driver_private(devinfo); in dmfe_resume()
2524 if (dmfep == NULL) in dmfe_resume()
2530 if (dmfep->devinfo != devinfo) in dmfe_resume()
2536 if (dmfe_config_init(dmfep, &chipid) != DDI_SUCCESS) in dmfe_resume()
2538 if (chipid.vendor != dmfep->chipid.vendor) in dmfe_resume()
2540 if (chipid.device != dmfep->chipid.device) in dmfe_resume()
2542 if (chipid.revision != dmfep->chipid.revision) in dmfe_resume()
2545 mutex_enter(dmfep->oplock); in dmfe_resume()
2546 mutex_enter(dmfep->txlock); in dmfe_resume()
2547 dmfep->suspended = B_FALSE; in dmfe_resume()
2548 mutex_exit(dmfep->txlock); in dmfe_resume()
2553 if (dmfep->mac_state == DMFE_MAC_STARTED) { in dmfe_resume()
2554 dmfe_restart(dmfep); in dmfe_resume()
2557 mutex_exit(dmfep->oplock); in dmfe_resume()
2560 mii_resume(dmfep->mii); in dmfe_resume()
2561 mac_tx_update(dmfep->mh); in dmfe_resume()
2575 dmfe_t *dmfep; /* Our private data */ in dmfe_attach() local
2593 dmfep = kmem_zalloc(sizeof (*dmfep), KM_SLEEP); in dmfe_attach()
2594 ddi_set_driver_private(devinfo, dmfep); in dmfe_attach()
2595 dmfep->devinfo = devinfo; in dmfe_attach()
2596 dmfep->dmfe_guard = DMFE_GUARD; in dmfe_attach()
2603 dmfep->debug = ddi_prop_get_int(DDI_DEV_T_ANY, devinfo, 0, in dmfe_attach()
2606 dmfep->cycid = NULL; in dmfe_attach()
2607 (void) snprintf(dmfep->ifname, sizeof (dmfep->ifname), "dmfe%d", in dmfe_attach()
2615 dmfep->opmode = ddi_prop_get_int(DDI_DEV_T_ANY, devinfo, in dmfe_attach()
2621 if (dmfe_config_init(dmfep, &dmfep->chipid) != DDI_SUCCESS) { in dmfe_attach()
2622 dmfe_error(dmfep, "dmfe_config_init() failed"); in dmfe_attach()
2630 &dmfep->io_reg, 0, 0, &dmfe_reg_accattr, &dmfep->io_handle); in dmfe_attach()
2632 dmfe_error(dmfep, "ddi_regs_map_setup() failed"); in dmfe_attach()
2639 dmfe_find_mac_address(dmfep); in dmfe_attach()
2644 dmfep->tx.n_desc = dmfe_tx_desc; in dmfe_attach()
2645 dmfep->rx.n_desc = dmfe_rx_desc; in dmfe_attach()
2646 err = dmfe_alloc_bufs(dmfep); in dmfe_attach()
2654 if (ddi_add_softintr(devinfo, DDI_SOFTINT_LOW, &dmfep->factotum_id, in dmfe_attach()
2655 NULL, NULL, dmfe_factotum, (caddr_t)dmfep) != DDI_SUCCESS) { in dmfe_attach()
2656 dmfe_error(dmfep, "ddi_add_softintr() failed"); in dmfe_attach()
2659 dmfep->progress |= PROGRESS_SOFTINT; in dmfe_attach()
2664 if (ddi_get_iblock_cookie(devinfo, 0, &dmfep->iblk) != DDI_SUCCESS) { in dmfe_attach()
2665 dmfe_error(dmfep, "ddi_get_iblock_cookie() failed"); in dmfe_attach()
2669 mutex_init(dmfep->milock, NULL, MUTEX_DRIVER, NULL); in dmfe_attach()
2670 mutex_init(dmfep->oplock, NULL, MUTEX_DRIVER, dmfep->iblk); in dmfe_attach()
2671 mutex_init(dmfep->rxlock, NULL, MUTEX_DRIVER, dmfep->iblk); in dmfe_attach()
2672 mutex_init(dmfep->txlock, NULL, MUTEX_DRIVER, dmfep->iblk); in dmfe_attach()
2673 dmfep->progress |= PROGRESS_MUTEX; in dmfe_attach()
2676 dmfe_interrupt, (caddr_t)dmfep) != DDI_SUCCESS) { in dmfe_attach()
2677 dmfe_error(dmfep, "ddi_add_intr() failed"); in dmfe_attach()
2680 dmfep->progress |= PROGRESS_HWINT; in dmfe_attach()
2685 dmfe_init_kstats(dmfep, instance); in dmfe_attach()
2691 mutex_enter(dmfep->oplock); in dmfe_attach()
2692 mutex_enter(dmfep->rxlock); in dmfe_attach()
2693 mutex_enter(dmfep->txlock); in dmfe_attach()
2695 dmfe_reset(dmfep); in dmfe_attach()
2700 bzero(dmfep->tx_desc.setup_va, SETUPBUF_SIZE); in dmfe_attach()
2701 bzero(dmfep->mcast_refs, MCASTBUF_SIZE); in dmfe_attach()
2702 dmfep->addr_set = B_FALSE; in dmfe_attach()
2703 dmfep->opmode &= ~(PROMISC_MODE | PASS_MULTICAST); in dmfe_attach()
2704 dmfep->mac_state = DMFE_MAC_RESET; in dmfe_attach()
2706 mutex_exit(dmfep->txlock); in dmfe_attach()
2707 mutex_exit(dmfep->rxlock); in dmfe_attach()
2708 mutex_exit(dmfep->oplock); in dmfe_attach()
2710 if (dmfe_init_phy(dmfep) != B_TRUE) in dmfe_attach()
2717 (void) dmfe_m_unicst(dmfep, dmfep->curr_addr); in dmfe_attach()
2726 macp->m_driver = dmfep; in dmfe_attach()
2728 macp->m_src_addr = dmfep->curr_addr; in dmfe_attach()
2738 err = mac_register(macp, &dmfep->mh); in dmfe_attach()
2742 ASSERT(dmfep->dmfe_guard == DMFE_GUARD); in dmfe_attach()
2749 ASSERT(dmfep->cycid == NULL); in dmfe_attach()
2750 dmfep->cycid = ddi_periodic_add(dmfe_cyclic, dmfep, in dmfe_attach()
2755 dmfe_unattach(dmfep); in dmfe_attach()
2763 dmfe_suspend(dmfe_t *dmfep) in dmfe_suspend() argument
2768 mii_suspend(dmfep->mii); in dmfe_suspend()
2769 mutex_enter(dmfep->oplock); in dmfe_suspend()
2770 dmfe_stop(dmfep); in dmfe_suspend()
2772 mutex_enter(dmfep->txlock); in dmfe_suspend()
2773 dmfep->suspended = B_TRUE; in dmfe_suspend()
2774 mutex_exit(dmfep->txlock); in dmfe_suspend()
2775 mutex_exit(dmfep->oplock); in dmfe_suspend()
2786 dmfe_t *dmfep; in dmfe_detach() local
2788 dmfep = ddi_get_driver_private(devinfo); in dmfe_detach()
2795 return (dmfe_suspend(dmfep)); in dmfe_detach()
2807 if (mac_unregister(dmfep->mh) != DDI_SUCCESS) in dmfe_detach()
2813 dmfe_unattach(dmfep); in dmfe_detach()