Lines Matching refs:dp

103 #define	DEFAULT_PIPE(dp)	((dp)->reg_data->dev_default_ph)
113 #define MAXPKTLEN(dp) ((dp)->mtu + ETHERHEADERL)
114 #define MAXPKTBUF(dp) ((dp)->mtu + ETHERHEADERL + ETHERFCSL)
123 static int usbgem_open_pipes(struct usbgem_dev *dp);
124 static int usbgem_close_pipes(struct usbgem_dev *dp);
250 usbgem_prop_get_int(struct usbgem_dev *dp, char *prop_template, int def_val)
254 (void) sprintf(propname, prop_template, dp->name);
256 return (ddi_prop_get_int(DDI_DEV_T_ANY, dp->dip,
289 usbgem_dump_packet(struct usbgem_dev *dp, char *title, mblk_t *mp,
423 cmn_err(CE_CONT, "!%s: %s: %s", dp->name, title, msg);
478 usbgem_hal_reset_chip(struct usbgem_dev *dp)
482 sema_p(&dp->hal_op_lock);
483 err = (*dp->ugc.usbgc_reset_chip)(dp);
484 sema_v(&dp->hal_op_lock);
489 usbgem_hal_init_chip(struct usbgem_dev *dp)
493 sema_p(&dp->hal_op_lock);
494 err = (*dp->ugc.usbgc_init_chip)(dp);
495 sema_v(&dp->hal_op_lock);
500 usbgem_hal_attach_chip(struct usbgem_dev *dp)
504 sema_p(&dp->hal_op_lock);
505 err = (*dp->ugc.usbgc_attach_chip)(dp);
506 sema_v(&dp->hal_op_lock);
511 usbgem_hal_set_rx_filter(struct usbgem_dev *dp)
515 sema_p(&dp->hal_op_lock);
516 err = (*dp->ugc.usbgc_set_rx_filter)(dp);
517 sema_v(&dp->hal_op_lock);
522 usbgem_hal_set_media(struct usbgem_dev *dp)
526 sema_p(&dp->hal_op_lock);
527 err = (*dp->ugc.usbgc_set_media)(dp);
528 sema_v(&dp->hal_op_lock);
533 usbgem_hal_start_chip(struct usbgem_dev *dp)
537 sema_p(&dp->hal_op_lock);
538 err = (*dp->ugc.usbgc_start_chip)(dp);
539 sema_v(&dp->hal_op_lock);
544 usbgem_hal_stop_chip(struct usbgem_dev *dp)
548 sema_p(&dp->hal_op_lock);
549 err = (*dp->ugc.usbgc_stop_chip)(dp);
550 sema_v(&dp->hal_op_lock);
555 usbgem_hal_get_stats(struct usbgem_dev *dp)
559 sema_p(&dp->hal_op_lock);
560 err = (*dp->ugc.usbgc_get_stats)(dp);
561 sema_v(&dp->hal_op_lock);
572 usbgem_rx_start_unit(struct usbgem_dev *dp, usb_bulk_req_t *req)
580 mp = allocb(dp->rx_buf_len, BPRI_MED);
583 dp->name, __func__);
587 req->bulk_len = dp->rx_buf_len;
589 req->bulk_client_private = (usb_opaque_t)dp;
598 err = usb_pipe_bulk_xfer(dp->bulkin_pipe, req, flags);
602 dp->name, err);
619 usbgem_init_rx_buf(struct usbgem_dev *dp)
624 ASSERT(dp->mac_state == MAC_STATE_ONLINE);
626 for (i = 0; i < dp->ugc.usbgc_rx_list_max; i++) {
627 req = usb_alloc_bulk_req(dp->dip, 0, USB_FLAGS_SLEEP);
631 dp->name, __func__);
634 if (!usbgem_rx_start_unit(dp, req)) {
637 mutex_enter(&dp->rxlock);
638 dp->rx_busy_cnt++;
639 mutex_exit(&dp->rxlock);
650 usbgem_free_memory(struct usbgem_dev *dp)
655 while ((req = dp->tx_free_list) != NULL) {
656 dp->tx_free_list =
665 usbgem_alloc_memory(struct usbgem_dev *dp)
671 dp->tx_free_list = NULL;
672 for (i = 0; i < dp->ugc.usbgc_tx_list_max; i++) {
673 req = usb_alloc_bulk_req(dp->dip, 0, USB_FLAGS_SLEEP);
677 dp->name, __func__);
680 (void) usbgem_free_memory(dp);
685 req->bulk_client_private = (usb_opaque_t)dp->tx_free_list;
686 dp->tx_free_list = req;
707 usbgem_send_common(struct usbgem_dev *dp, mblk_t *mp, uint32_t flags)
720 DPRINTF(2, (CE_CONT, "!%s: %s: called", dp->name, __func__));
733 new = (*dp->ugc.usbgc_tx_make_packet)(dp, mp);
740 dp->name, __func__));
743 mutex_enter(&dp->txlock);
744 dp->stats.noxmtbuf++;
745 dp->stats.errxmt++;
746 mutex_exit(&dp->txlock);
753 mutex_enter(&dp->txlock);
754 if (dp->tx_free_list == NULL) {
758 ASSERT(dp->tx_busy_cnt == dp->ugc.usbgc_tx_list_max);
759 mutex_exit(&dp->txlock);
762 dp->name, __func__));
769 req = dp->tx_free_list;
770 dp->tx_free_list = (usb_bulk_req_t *)req->bulk_client_private;
771 dp->tx_busy_cnt++;
773 if (dp->tx_free_list == NULL) {
777 dp->tx_intr_pended++;
781 new->b_datap->db_cksum32 = dp->tx_seq_num;
782 dp->tx_seq_num++;
784 dp->stats.obytes += len;
785 dp->stats.opackets++;
787 dp->stats.obcast += bcast;
788 dp->stats.omcast += mcast;
790 mutex_exit(&dp->txlock);
792 DPRINTF(2, (CE_CONT, "!%s: %s: sending", dp->name, __func__));
796 req->bulk_client_private = (usb_opaque_t)dp;
797 req->bulk_timeout = dp->bulkout_timeout; /* in second */
807 if ((err = usb_pipe_bulk_xfer(dp->bulkout_pipe, req, usb_flags))
815 mutex_enter(&dp->txlock);
816 dp->tx_busy_cnt--;
817 req->bulk_client_private = (usb_opaque_t)dp->tx_free_list;
818 dp->tx_free_list = req;
819 mutex_exit(&dp->txlock);
823 dp->name, __func__, err);
826 if (dp->fatal_error == (clock_t)0) {
827 dp->fatal_error = usbgem_timestamp_nz();
831 dp->tx_start_time = ddi_get_lbolt();
835 usbgem_bulkout_cb(dp->bulkout_pipe, req);
845 usbgem_restart_nic(struct usbgem_dev *dp)
850 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
852 ASSERT(dp->mac_state != MAC_STATE_DISCONNECTED);
857 if (dp->mac_state == MAC_STATE_ONLINE) {
858 (void) usbgem_mac_stop(dp, MAC_STATE_STOPPED, STOP_GRACEFUL);
862 if (usbgem_hal_reset_chip(dp) != USB_SUCCESS) {
864 dp->name, __func__);
871 if (dp->nic_state < NIC_STATE_INITIALIZED) {
875 if (usbgem_mac_init(dp) != USB_SUCCESS) {
877 dp->name, __func__);
882 sema_p(&dp->rxfilter_lock);
883 dp->rxmode |= RXMODE_ENABLE;
884 ret = usbgem_hal_set_rx_filter(dp);
885 sema_v(&dp->rxfilter_lock);
893 cv_signal(&dp->link_watcher_wait_cv);
902 if (dp->mii_state == MII_STATE_LINKUP) {
903 if (usbgem_hal_set_media(dp) != USB_SUCCESS) {
906 if (dp->nic_state < NIC_STATE_ONLINE) {
910 (void) usbgem_mac_start(dp);
917 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
923 usbgem_tx_timeout(struct usbgem_dev *dp)
930 mutex_enter(&dp->tx_watcher_lock);
931 ret = cv_timedwait(&dp->tx_watcher_cv, &dp->tx_watcher_lock,
932 dp->tx_watcher_interval + ddi_get_lbolt());
933 mutex_exit(&dp->tx_watcher_lock);
935 if (dp->tx_watcher_stop) {
943 rw_enter(&dp->dev_state_lock, rwlock);
945 if ((dp->mac_state != MAC_STATE_DISCONNECTED &&
946 dp->fatal_error &&
947 now - dp->fatal_error >= dp->ugc.usbgc_tx_timeout) ||
948 (dp->mac_state == MAC_STATE_ONLINE &&
949 dp->mii_state == MII_STATE_LINKUP &&
950 dp->tx_busy_cnt != 0 &&
951 now - dp->tx_start_time >= dp->ugc.usbgc_tx_timeout)) {
958 rw_exit(&dp->dev_state_lock);
964 dp->name, __func__,
965 dp->fatal_error ? now - dp->fatal_error: 0,
966 dp->nic_state, dp->mac_state,
967 dp->tx_busy_cnt ? now - dp->tx_start_time : 0);
969 (void) usbgem_restart_nic(dp);
972 rw_exit(&dp->dev_state_lock);
977 usbgem_tx_watcher_start(struct usbgem_dev *dp)
982 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
985 dp->tx_watcher_stop = 0;
986 dp->tx_watcher_interval = drv_usectohz(1000*1000);
988 wdth = thread_create(NULL, 0, usbgem_tx_timeout, dp, 0, &p0,
993 dp->name, __func__);
996 dp->tx_watcher_did = wdth->t_did;
1002 usbgem_tx_watcher_stop(struct usbgem_dev *dp)
1004 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
1005 if (dp->tx_watcher_did) {
1007 dp->tx_watcher_stop = 1;
1008 cv_signal(&dp->tx_watcher_cv);
1009 thread_join(dp->tx_watcher_did);
1010 dp->tx_watcher_did = NULL;
1030 struct usbgem_dev *dp;
1032 dp = (struct usbgem_dev *)req->bulk_client_private;
1037 dp->name, __func__, mp,
1050 dp->nic_state == NIC_STATE_ONLINE) {
1051 newmp = (*dp->ugc.usbgc_rx_make_packet)(dp, mp);
1074 mac_rx(dp->mh, NULL, newmp);
1080 gld_recv(dp->macinfo, tp);
1088 mutex_enter(&dp->rxlock);
1090 if (dp->rx_active) {
1091 dp->rx_active = dp->mac_state == MAC_STATE_ONLINE;
1094 dp->stats.rbytes += len;
1095 dp->stats.rpackets += pkts;
1097 dp->stats.rbcast += bcast;
1098 dp->stats.rmcast += mcast;
1100 mutex_exit(&dp->rxlock);
1102 if (dp->rx_active) {
1104 if (usbgem_rx_start_unit(dp, req)) {
1110 dp->name, __func__);
1116 if (dp->fatal_error == (clock_t)0) {
1117 dp->fatal_error = usbgem_timestamp_nz();
1124 mutex_enter(&dp->rxlock);
1125 dp->rx_active = B_FALSE;
1126 dp->rx_busy_cnt--;
1127 if (dp->rx_busy_cnt == 0) {
1129 cv_broadcast(&dp->rx_drain_cv);
1131 mutex_exit(&dp->rxlock);
1141 struct usbgem_dev *dp;
1143 dp = (struct usbgem_dev *)req->bulk_client_private;
1148 dp->name, __func__,
1152 dp->tx_busy_cnt));
1159 dp->fatal_error == (clock_t)0) {
1160 dp->fatal_error = usbgem_timestamp_nz();
1163 mutex_enter(&dp->txlock);
1166 ASSERT(dp->tx_intr_pended > 0);
1168 if (--(dp->tx_intr_pended) == 0) {
1173 ASSERT(dp->tx_busy_cnt > 0);
1174 req->bulk_client_private = (usb_opaque_t)dp->tx_free_list;
1175 dp->tx_free_list = req;
1176 dp->tx_busy_cnt--;
1180 dp->tx_max_packets =
1181 min(dp->tx_max_packets + 1, dp->ugc.usbgc_tx_list_max);
1184 if (dp->mac_state != MAC_STATE_ONLINE && dp->tx_busy_cnt == 0) {
1185 cv_broadcast(&dp->tx_drain_cv);
1188 mutex_exit(&dp->txlock);
1192 mac_tx_update(dp->mh);
1194 gld_sched(dp->macinfo);
1202 struct usbgem_dev *dp;
1204 dp = (struct usbgem_dev *)req->intr_client_private;
1205 dp->stats.intr++;
1208 (*dp->ugc.usbgc_interrupt)(dp, req->intr_data);
1221 usbgem_choose_forcedmode(struct usbgem_dev *dp)
1224 if (dp->anadv_1000fdx || dp->anadv_1000hdx) {
1225 dp->speed = USBGEM_SPD_1000;
1226 dp->full_duplex = dp->anadv_1000fdx;
1227 } else if (dp->anadv_100fdx || dp->anadv_100t4) {
1228 dp->speed = USBGEM_SPD_100;
1229 dp->full_duplex = B_TRUE;
1230 } else if (dp->anadv_100hdx) {
1231 dp->speed = USBGEM_SPD_100;
1232 dp->full_duplex = B_FALSE;
1234 dp->speed = USBGEM_SPD_10;
1235 dp->full_duplex = dp->anadv_10fdx;
1240 usbgem_mii_read(struct usbgem_dev *dp, uint_t reg, int *errp)
1244 sema_p(&dp->hal_op_lock);
1245 val = (*dp->ugc.usbgc_mii_read)(dp, reg, errp);
1246 sema_v(&dp->hal_op_lock);
1252 usbgem_mii_write(struct usbgem_dev *dp, uint_t reg, uint16_t val, int *errp)
1254 sema_p(&dp->hal_op_lock);
1255 (*dp->ugc.usbgc_mii_write)(dp, reg, val, errp);
1256 sema_v(&dp->hal_op_lock);
1260 usbgem_mii_probe(struct usbgem_dev *dp)
1264 err = (*dp->ugc.usbgc_mii_probe)(dp);
1269 usbgem_mii_init(struct usbgem_dev *dp)
1273 err = (*dp->ugc.usbgc_mii_init)(dp);
1282 usbgem_mii_config_default(struct usbgem_dev *dp, int *errp)
1287 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
1292 mii_stat = dp->mii_status;
1295 dp->name, __func__, mii_stat, MII_STATUS_BITS));
1300 dp->name, mii_stat, MII_STATUS_BITS);
1305 val = usbgem_mii_read(dp, MII_AN_ADVERT, errp) & ~MII_ABILITY_ALL;
1312 dp->name, __func__,
1313 dp->anadv_100t4, dp->anadv_100fdx, dp->anadv_100hdx,
1314 dp->anadv_10fdx, dp->anadv_10hdx));
1317 if (dp->anadv_100t4) {
1320 if (dp->anadv_100fdx) {
1323 if (dp->anadv_100hdx) {
1326 if (dp->anadv_10fdx) {
1329 if (dp->anadv_10hdx) {
1334 if (dp->anadv_pause) {
1337 if (dp->anadv_asmpause) {
1343 dp->name, __func__, val, MII_ABILITY_BITS,
1344 dp->anadv_pause, dp->anadv_asmpause));
1346 usbgem_mii_write(dp, MII_AN_ADVERT, val, errp);
1351 if (dp->mii_status & MII_STATUS_XSTATUS) {
1355 if (!dp->anadv_autoneg) {
1358 if (dp->anadv_1000t_ms == 2) {
1363 if (dp->anadv_1000fdx) {
1366 if (dp->anadv_1000hdx) {
1369 switch (dp->anadv_1000t_ms) {
1387 dp->name, __func__, val, MII_1000TC_BITS));
1389 usbgem_mii_write(dp, MII_1000TC, val, errp);
1408 #define USBGEM_LINKUP(dp) mac_link_update((dp)->mh, LINK_STATE_UP)
1409 #define USBGEM_LINKDOWN(dp) mac_link_update((dp)->mh, LINK_STATE_DOWN)
1411 #define USBGEM_LINKUP(dp) \
1413 gld_linkstate((dp)->macinfo, GLD_LINKSTATE_UP); \
1415 #define USBGEM_LINKDOWN(dp) \
1417 gld_linkstate((dp)->macinfo, GLD_LINKSTATE_DOWN); \
1446 usbgem_mii_link_check(struct usbgem_dev *dp, int *oldstatep, int *newstatep)
1464 dp->name, __func__, ddi_get_lbolt(), dp->mii_state));
1466 if (dp->mii_state != MII_STATE_LINKUP) {
1472 rw_enter(&dp->dev_state_lock, rwlock);
1475 *oldstatep = dp->mii_state;
1477 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
1479 dp->mii_interval = 0;
1485 diff = now - dp->mii_last_check;
1486 dp->mii_last_check = now;
1492 if (dp->linkup_delay > 0) {
1493 if (dp->linkup_delay > diff) {
1494 dp->linkup_delay -= diff;
1497 dp->linkup_delay = -1;
1502 switch (dp->mii_state) {
1507 dp->mii_timer -= diff;
1508 if (dp->mii_timer > 0) {
1510 dp->mii_interval = WATCH_INTERVAL_FAST;
1514 val = usbgem_mii_read(dp, MII_CONTROL, &err);
1522 dp->name, ddi_get_lbolt(),
1527 usbgem_mii_write(dp, MII_CONTROL, 0, &err);
1532 val = usbgem_mii_read(dp, MII_CONTROL, &err);
1534 dp->name, val, MII_CONTROL_BITS);
1537 if ((*dp->ugc.usbgc_mii_config)(dp, &err) != USB_SUCCESS) {
1543 usbgem_choose_forcedmode(dp);
1545 dp->mii_lpable = 0;
1546 dp->mii_advert = 0;
1547 dp->mii_exp = 0;
1548 dp->mii_ctl1000 = 0;
1549 dp->mii_stat1000 = 0;
1551 dp->flow_control = FLOW_CONTROL_NONE;
1553 if (!dp->anadv_autoneg) {
1555 dp->mii_state = MII_STATE_MEDIA_SETUP;
1556 dp->mii_timer = dp->ugc.usbgc_mii_linkdown_timeout;
1567 dp->mii_timer -= diff;
1568 if (dp->mii_timer -
1569 (dp->ugc.usbgc_mii_an_timeout - dp->ugc.usbgc_mii_an_wait)
1572 dp->mii_interval = WATCH_INTERVAL_FAST;
1577 status = usbgem_mii_read(dp, MII_STATUS, &err);
1583 dp->name, __func__, dp->mii_state,
1593 dp->name);
1598 if (dp->mii_timer <= 0) {
1603 if (!dp->mii_supress_msg) {
1607 dp->name);
1608 dp->mii_supress_msg = B_TRUE;
1615 dp->mii_interval = dp->ugc.usbgc_mii_an_watch_interval;
1622 dp->mii_state = MII_STATE_AN_DONE;
1623 dp->mii_supress_msg = B_FALSE;
1626 dp->name, status, MII_STATUS_BITS));
1628 if (dp->ugc.usbgc_mii_an_delay > 0) {
1629 dp->mii_timer = dp->ugc.usbgc_mii_an_delay;
1630 dp->mii_interval = drv_usectohz(20*1000);
1634 dp->mii_timer = 0;
1642 dp->mii_timer -= diff;
1643 if (dp->mii_timer > 0) {
1645 dp->mii_interval = WATCH_INTERVAL_FAST;
1658 if (dp->ugc.usbgc_mii_an_delay > 0) {
1660 status = usbgem_mii_read(dp, MII_STATUS, &err);
1665 advert = usbgem_mii_read(dp, MII_AN_ADVERT, &err);
1669 lpable = usbgem_mii_read(dp, MII_AN_LPABLE, &err);
1673 exp = usbgem_mii_read(dp, MII_AN_EXPANSION, &err);
1684 if (dp->mii_status & MII_STATUS_XSTATUS) {
1685 ctl1000 = usbgem_mii_read(dp, MII_1000TC, &err);
1689 stat1000 = usbgem_mii_read(dp, MII_1000TS, &err);
1694 dp->mii_lpable = lpable;
1695 dp->mii_advert = advert;
1696 dp->mii_exp = exp;
1697 dp->mii_ctl1000 = ctl1000;
1698 dp->mii_stat1000 = stat1000;
1703 dp->name,
1710 dp->name, status, MII_STATUS_BITS));
1712 if (dp->mii_status & MII_STATUS_XSTATUS) {
1726 dp->name);
1739 cmn_err(CE_WARN, "!%s: wrong lpable.", dp->name);
1749 dp->speed = USBGEM_SPD_1000;
1750 dp->full_duplex = B_TRUE;
1754 dp->speed = USBGEM_SPD_1000;
1755 dp->full_duplex = B_FALSE;
1758 dp->speed = USBGEM_SPD_100;
1759 dp->full_duplex = B_TRUE;
1762 dp->speed = USBGEM_SPD_100;
1763 dp->full_duplex = B_TRUE;
1766 dp->speed = USBGEM_SPD_100;
1767 dp->full_duplex = B_FALSE;
1770 dp->speed = USBGEM_SPD_10;
1771 dp->full_duplex = B_TRUE;
1774 dp->speed = USBGEM_SPD_10;
1775 dp->full_duplex = B_FALSE;
1783 val = usbgem_mii_read(dp, MII_CONTROL, &err);
1789 dp->speed = (val & MII_CONTROL_100MB) ?
1791 dp->full_duplex = B_FALSE;
1799 dp->name,
1803 usbgem_speed_value[dp->speed],
1804 dp->full_duplex ? "full" : "half");
1807 if (dp->full_duplex) {
1808 dp->flow_control =
1812 dp->flow_control = FLOW_CONTROL_NONE;
1814 dp->mii_state = MII_STATE_MEDIA_SETUP;
1815 dp->mii_timer = dp->ugc.usbgc_mii_linkdown_timeout;
1819 DPRINTF(2, (CE_CONT, "!%s: setup midia mode", dp->name));
1822 dp->mii_state = MII_STATE_LINKDOWN;
1823 dp->mii_supress_msg = B_FALSE;
1826 dp->mii_interval = WATCH_INTERVAL_FAST;
1828 if ((!dp->anadv_autoneg) ||
1829 dp->ugc.usbgc_mii_an_oneshot || fix_phy) {
1834 val = usbgem_mii_read(dp, MII_CONTROL, &err);
1841 if (dp->full_duplex) {
1845 switch (dp->speed) {
1856 dp->name, dp->speed);
1864 if (dp->mii_status & MII_STATUS_XSTATUS) {
1865 usbgem_mii_write(dp,
1871 usbgem_mii_write(dp, MII_CONTROL, val, &err);
1883 if (dp->nic_state >= NIC_STATE_INITIALIZED) {
1885 if (usbgem_hal_set_media(dp) != USB_SUCCESS) {
1892 status = usbgem_mii_read(dp, MII_STATUS, &err);
1900 dp->mii_state = MII_STATE_LINKUP;
1901 dp->mii_supress_msg = B_FALSE;
1905 dp->name, status, MII_STATUS_BITS));
1913 dp->name,
1914 usbgem_speed_value[dp->speed],
1915 dp->full_duplex ? "full" : "half",
1916 usbgem_fc_type[dp->flow_control]);
1918 dp->mii_interval =
1919 dp->ugc.usbgc_mii_link_watch_interval;
1921 if (dp->ugc.usbgc_mii_hw_link_detection &&
1922 dp->nic_state == NIC_STATE_ONLINE) {
1923 dp->mii_interval = 0;
1926 if (dp->nic_state == NIC_STATE_ONLINE) {
1927 if (dp->mac_state == MAC_STATE_INITIALIZED) {
1928 (void) usbgem_mac_start(dp);
1936 dp->mii_supress_msg = B_TRUE;
1937 if (dp->anadv_autoneg) {
1938 dp->mii_timer -= diff;
1939 if (dp->mii_timer <= 0) {
1945 dp->ugc.usbgc_mii_linkdown_timeout_action;
1955 status = usbgem_mii_read(dp, MII_STATUS, &err);
1966 dp->name, status, MII_STATUS_BITS);
1972 rw_exit(&dp->dev_state_lock);
1976 dp->mii_state = MII_STATE_LINKDOWN;
1977 dp->mii_timer = dp->ugc.usbgc_mii_linkdown_timeout;
1983 if (dp->nic_state == NIC_STATE_ONLINE &&
1984 dp->mac_state == MAC_STATE_ONLINE &&
1985 dp->ugc.usbgc_mii_stop_mac_on_linkdown) {
1986 (void) usbgem_restart_nic(dp);
1991 if (dp->anadv_autoneg) {
1994 dp->ugc.usbgc_mii_linkdown_action;
2001 dp->mii_interval =
2002 dp->ugc.usbgc_mii_link_watch_interval;
2010 if (dp->ugc.usbgc_mii_hw_link_detection &&
2011 dp->nic_state == NIC_STATE_ONLINE) {
2016 dp->mii_interval = 0;
2021 cmn_err(CE_PANIC, "!%s: %s: not reached", dp->name, __func__);
2029 if (!dp->mii_supress_msg) {
2030 cmn_err(CE_CONT, "!%s: resetting PHY", dp->name);
2032 dp->mii_supress_msg = B_TRUE;
2036 dp->mii_supress_msg = B_TRUE;
2037 if (dp->ugc.usbgc_mii_an_oneshot) {
2041 dp->mii_state = MII_STATE_AUTONEGOTIATING;
2042 dp->mii_timer = dp->ugc.usbgc_mii_an_timeout;
2043 dp->mii_interval = dp->ugc.usbgc_mii_an_watch_interval;
2047 if (!dp->mii_supress_msg) {
2049 dp->name);
2051 dp->mii_supress_msg = B_TRUE;
2056 dp->name, dp->ugc.usbgc_mii_linkdown_action);
2057 dp->mii_supress_msg = B_TRUE;
2062 if (!dp->mii_supress_msg) {
2063 cmn_err(CE_CONT, "!%s: resetting PHY", dp->name);
2065 dp->mii_state = MII_STATE_RESETTING;
2066 dp->mii_timer = dp->ugc.usbgc_mii_reset_timeout;
2067 if (!dp->ugc.usbgc_mii_dont_reset) {
2068 usbgem_mii_write(dp, MII_CONTROL, MII_CONTROL_RESET, &err);
2073 dp->mii_interval = WATCH_INTERVAL_FAST;
2077 if (!dp->mii_supress_msg) {
2078 cmn_err(CE_CONT, "!%s: auto-negotiation started", dp->name);
2080 dp->mii_state = MII_STATE_AUTONEGOTIATING;
2081 dp->mii_timer = dp->ugc.usbgc_mii_an_timeout;
2084 val = usbgem_mii_read(dp, MII_CONTROL, &err) &
2092 usbgem_mii_write(dp, MII_CONTROL,
2093 val | dp->ugc.usbgc_mii_an_cmd | MII_CONTROL_ANE, &err);
2098 dp->mii_interval = dp->ugc.usbgc_mii_an_watch_interval;
2102 dp->mii_state = MII_STATE_UNKNOWN;
2103 dp->mii_interval = dp->ugc.usbgc_mii_link_watch_interval;
2107 *newstatep = dp->mii_state;
2108 rw_exit(&dp->dev_state_lock);
2113 usbgem_mii_link_watcher(struct usbgem_dev *dp)
2119 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2123 mutex_enter(&dp->link_watcher_lock);
2124 if (dp->mii_interval) {
2125 (void) cv_timedwait(&dp->link_watcher_wait_cv,
2126 &dp->link_watcher_lock,
2127 dp->mii_interval + ddi_get_lbolt());
2129 cv_wait(&dp->link_watcher_wait_cv,
2130 &dp->link_watcher_lock);
2132 mutex_exit(&dp->link_watcher_lock);
2134 if (dp->link_watcher_stop) {
2139 tx_sched = usbgem_mii_link_check(dp,
2149 mac_tx_update(dp->mh);
2151 gld_sched(dp->macinfo);
2158 dp->linkup_delay = 0;
2159 USBGEM_LINKUP(dp);
2160 } else if (dp->linkup_delay <= 0) {
2161 USBGEM_LINKDOWN(dp);
2163 } else if (dp->linkup_delay < 0) {
2165 dp->linkup_delay = 0;
2166 USBGEM_LINKDOWN(dp);
2174 usbgem_mii_update_link(struct usbgem_dev *dp)
2176 cv_signal(&dp->link_watcher_wait_cv);
2180 usbgem_mii_probe_default(struct usbgem_dev *dp)
2189 DPRINTF(3, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2194 dp->mii_status = 0;
2197 if (dp->mii_phy_addr) {
2198 status = usbgem_mii_read(dp, MII_STATUS, &err);
2206 if (dp->mii_phy_addr < 0) {
2209 dp->name);
2215 dp->name, dp->mii_phy_addr);
2219 for (phy = dp->ugc.usbgc_mii_addr_min; phy < 32; phy++) {
2220 dp->mii_phy_addr = phy;
2221 status = usbgem_mii_read(dp, MII_STATUS, &err);
2225 dp->name, __func__));
2230 usbgem_mii_write(dp, MII_CONTROL, 0, &err);
2234 dp->name, __func__));
2240 for (phy = dp->ugc.usbgc_mii_addr_min; phy < 32; phy++) {
2241 dp->mii_phy_addr = phy;
2242 usbgem_mii_write(dp, MII_CONTROL, 0, &err);
2246 dp->name, __func__));
2249 status = usbgem_mii_read(dp, MII_STATUS, &err);
2253 dp->name, __func__));
2262 cmn_err(CE_NOTE, "!%s: no MII PHY found", dp->name);
2266 dp->mii_status = status;
2267 dp->mii_status_ro = ~status;
2268 dp->mii_phy_id = usbgem_mii_read(dp, MII_PHYIDH, &err) << 16;
2272 dp->name, __func__));
2275 dp->mii_phy_id |= usbgem_mii_read(dp, MII_PHYIDL, &err);
2279 dp->name, __func__));
2283 if (dp->mii_phy_addr < 0) {
2285 dp->name, dp->mii_phy_id);
2288 dp->name, dp->mii_phy_id, dp->mii_phy_addr);
2293 dp->name,
2294 usbgem_mii_read(dp, MII_CONTROL, &err), MII_CONTROL_BITS,
2296 usbgem_mii_read(dp, MII_AN_ADVERT, &err), MII_ABILITY_BITS,
2297 usbgem_mii_read(dp, MII_AN_LPABLE, &err), MII_ABILITY_BITS,
2298 usbgem_mii_read(dp, MII_AN_EXPANSION, &err), MII_AN_EXP_BITS);
2300 dp->mii_xstatus = 0;
2302 dp->mii_xstatus = usbgem_mii_read(dp, MII_XSTATUS, &err);
2305 dp->name, dp->mii_xstatus, MII_XSTATUS_BITS);
2307 dp->mii_xstatus_ro = ~dp->mii_xstatus;
2310 adv_org = usbgem_mii_read(dp, MII_AN_ADVERT, &err);
2315 usbgem_mii_write(dp, MII_AN_ADVERT,
2321 adv = usbgem_mii_read(dp, MII_AN_ADVERT, &err);
2327 dp->ugc.usbgc_flow_control &= ~1;
2331 dp->ugc.usbgc_flow_control &= ~2;
2334 usbgem_mii_write(dp, MII_AN_ADVERT, adv_org, &err);
2345 usbgem_mii_init_default(struct usbgem_dev *dp)
2352 usbgem_mii_start(struct usbgem_dev *dp)
2357 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2360 dp->link_watcher_stop = 0;
2361 dp->mii_state = MII_STATE_UNKNOWN;
2362 dp->mii_interval = drv_usectohz(1000*1000); /* 1sec */
2363 dp->mii_last_check = ddi_get_lbolt();
2364 dp->linkup_delay = 600 * drv_usectohz(1000*1000); /* 10 minutes */
2366 lwth = thread_create(NULL, 0, usbgem_mii_link_watcher, dp, 0, &p0,
2371 dp->name, __func__);
2374 dp->link_watcher_did = lwth->t_did;
2380 usbgem_mii_stop(struct usbgem_dev *dp)
2382 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2385 dp->link_watcher_stop = 1;
2386 cv_signal(&dp->link_watcher_wait_cv);
2387 thread_join(dp->link_watcher_did);
2399 usbgem_mac_init(struct usbgem_dev *dp)
2403 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2405 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
2410 ASSERT(dp->mac_state == MAC_STATE_STOPPED);
2413 dp->fatal_error = (clock_t)0;
2416 mutex_enter(&dp->txlock);
2417 dp->tx_busy_cnt = 0;
2418 dp->tx_max_packets = dp->ugc.usbgc_tx_list_max;
2419 mutex_exit(&dp->txlock);
2422 mutex_enter(&dp->rxlock);
2423 dp->rx_busy_cnt = 0;
2424 mutex_exit(&dp->rxlock);
2426 err = usbgem_hal_init_chip(dp);
2428 dp->mac_state = MAC_STATE_INITIALIZED;
2438 usbgem_mac_start(struct usbgem_dev *dp)
2447 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2449 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
2454 if (dp->mac_state != MAC_STATE_INITIALIZED) {
2458 dp->name, __func__, dp->mac_state));
2462 dp->mac_state = MAC_STATE_ONLINE;
2464 if (usbgem_hal_start_chip(dp) != USB_SUCCESS) {
2467 dp->name, __func__);
2472 usb_pipe_get_state(dp->intr_pipe, &p_state, 0);
2476 if (dp->ugc.usbgc_interrupt && dp->intr_pipe) {
2480 req = usb_alloc_intr_req(dp->dip, 0, USB_FLAGS_SLEEP);
2483 dp->name, __func__);
2487 req->intr_client_private = (usb_opaque_t)dp;
2491 req->intr_len = dp->ep_intr->wMaxPacketSize;
2497 err = usb_pipe_intr_xfer(dp->intr_pipe, req, flags);
2501 dp->name, err);
2507 if (usbgem_init_rx_buf(dp) != USB_SUCCESS) {
2510 dp->rx_active = B_TRUE;
2516 DPRINTF(0, (CE_CONT, "!%s: %s: FAULURE", dp->name, __func__));
2517 if (dp->ugc.usbgc_interrupt && dp->intr_pipe) {
2518 usb_pipe_stop_intr_polling(dp->intr_pipe, USB_FLAGS_SLEEP);
2521 ASSERT(dp->mac_state == MAC_STATE_ONLINE);
2523 if (dp->fatal_error == (clock_t)0) {
2524 dp->fatal_error = usbgem_timestamp_nz();
2530 usbgem_mac_stop(struct usbgem_dev *dp, int new_state, boolean_t graceful)
2532 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2541 if (dp->ugc.usbgc_interrupt && dp->intr_pipe) {
2542 usb_pipe_stop_intr_polling(dp->intr_pipe, USB_FLAGS_SLEEP);
2547 if (usbgem_hal_stop_chip(dp) != USB_SUCCESS) {
2548 (void) usbgem_hal_reset_chip(dp);
2553 dp->mac_state = new_state;
2559 usb_pipe_reset(dp->dip, dp->bulkin_pipe, USB_FLAGS_SLEEP, NULL, 0);
2560 usb_pipe_reset(dp->dip, dp->bulkout_pipe, USB_FLAGS_SLEEP, NULL, 0);
2564 dp->name, __func__, dp->rx_busy_cnt, dp->tx_busy_cnt));
2572 mutex_enter(&dp->rxlock);
2573 while (dp->rx_busy_cnt > 0) {
2574 cv_wait(&dp->rx_drain_cv, &dp->rxlock);
2576 mutex_exit(&dp->rxlock);
2579 dp->name, __func__, dp->rx_busy_cnt));
2581 mutex_enter(&dp->txlock);
2582 while (dp->tx_busy_cnt > 0) {
2583 cv_wait(&dp->tx_drain_cv, &dp->txlock);
2585 mutex_exit(&dp->txlock);
2588 dp->name, __func__, dp->tx_busy_cnt));
2594 usbgem_add_multicast(struct usbgem_dev *dp, const uint8_t *ep)
2599 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2601 sema_p(&dp->rxfilter_lock);
2602 if (dp->mc_count_req++ < USBGEM_MAXMC) {
2604 cnt = dp->mc_count;
2605 bcopy(ep, dp->mc_list[cnt].addr.ether_addr_octet,
2607 if (dp->ugc.usbgc_multicast_hash) {
2608 dp->mc_list[cnt].hash =
2609 (*dp->ugc.usbgc_multicast_hash)(dp, ep);
2611 dp->mc_count = cnt + 1;
2614 if (dp->mc_count_req != dp->mc_count) {
2616 dp->rxmode |= RXMODE_MULTI_OVF;
2618 dp->rxmode &= ~RXMODE_MULTI_OVF;
2621 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
2623 err = usbgem_hal_set_rx_filter(dp);
2625 sema_v(&dp->rxfilter_lock);
2631 usbgem_remove_multicast(struct usbgem_dev *dp, const uint8_t *ep)
2638 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
2640 sema_p(&dp->rxfilter_lock);
2641 dp->mc_count_req--;
2642 cnt = dp->mc_count;
2644 if (bcmp(ep, &dp->mc_list[i].addr, ETHERADDRL)) {
2648 len = (cnt - (i + 1)) * sizeof (*dp->mc_list);
2650 bcopy(&dp->mc_list[i+1], &dp->mc_list[i], len);
2652 dp->mc_count--;
2656 if (dp->mc_count_req != dp->mc_count) {
2658 dp->rxmode |= RXMODE_MULTI_OVF;
2660 dp->rxmode &= ~RXMODE_MULTI_OVF;
2663 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
2664 err = usbgem_hal_set_rx_filter(dp);
2666 sema_v(&dp->rxfilter_lock);
2689 usbgem_get_def_val(struct usbgem_dev *dp, mac_prop_id_t pr_num,
2699 BOOLEAN(dp->mii_status & MII_STATUS_CANAUTONEG);
2706 switch (dp->ugc.usbgc_flow_control) {
2726 (dp->mii_xstatus & MII_XSTATUS_1000BASET_FD) ||
2727 (dp->mii_xstatus & MII_XSTATUS_1000BASEX_FD);
2733 (dp->mii_xstatus & MII_XSTATUS_1000BASET) ||
2734 (dp->mii_xstatus & MII_XSTATUS_1000BASEX);
2740 BOOLEAN(dp->mii_status & MII_STATUS_100_BASE_T4);
2746 BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX_FD);
2752 BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX);
2758 BOOLEAN(dp->mii_status & MII_STATUS_10_FD);
2764 BOOLEAN(dp->mii_status & MII_STATUS_10);
2779 struct usbgem_dev *dp = arg;
2803 if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASET_FD) == 0) {
2806 dp->mii_xstatus & MII_XSTATUS_1000BASET_FD));
2807 } else if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASEX_FD)
2811 dp->mii_xstatus & MII_XSTATUS_1000BASEX_FD));
2818 if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASET) == 0) {
2821 dp->mii_xstatus & MII_XSTATUS_1000BASET));
2822 } else if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASEX) == 0) {
2825 dp->mii_xstatus & MII_XSTATUS_1000BASEX));
2832 if ((dp->mii_status_ro & MII_STATUS_100_BASEX_FD) == 0) {
2834 BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX_FD));
2841 if ((dp->mii_status_ro & MII_STATUS_100_BASEX) == 0) {
2843 BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX));
2850 if ((dp->mii_status_ro & MII_STATUS_10_FD) == 0) {
2852 BOOLEAN(dp->mii_status & MII_STATUS_10_FD));
2859 if ((dp->mii_status_ro & MII_STATUS_10) == 0) {
2861 BOOLEAN(dp->mii_status & MII_STATUS_10));
2868 if ((dp->mii_status_ro & MII_STATUS_CANAUTONEG) == 0) {
2870 BOOLEAN(dp->mii_status & MII_STATUS_CANAUTONEG));
2877 switch (dp->ugc.usbgc_flow_control) {
2896 dp->ugc.usbgc_min_mtu, dp->ugc.usbgc_max_mtu);
2909 struct usbgem_dev *dp = arg;
2915 rw_enter(&dp->dev_state_lock, RW_WRITER);
2918 if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASET_FD) == 0 ||
2919 (dp->mii_xstatus_ro & MII_XSTATUS_1000BASEX_FD) == 0) {
2920 if (dp->anadv_1000fdx != *(uint8_t *)pr_val) {
2921 dp->anadv_1000fdx = *(uint8_t *)pr_val;
2930 if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASET) == 0 ||
2931 (dp->mii_xstatus_ro & MII_XSTATUS_1000BASEX) == 0) {
2932 if (dp->anadv_1000hdx != *(uint8_t *)pr_val) {
2933 dp->anadv_1000hdx = *(uint8_t *)pr_val;
2942 if ((dp->mii_status_ro & MII_STATUS_100_BASEX_FD) == 0) {
2943 if (dp->anadv_100fdx != *(uint8_t *)pr_val) {
2944 dp->anadv_100fdx = *(uint8_t *)pr_val;
2953 if ((dp->mii_status_ro & MII_STATUS_100_BASEX) == 0) {
2954 if (dp->anadv_100hdx != *(uint8_t *)pr_val) {
2955 dp->anadv_100hdx = *(uint8_t *)pr_val;
2964 if ((dp->mii_status_ro & MII_STATUS_10_FD) == 0) {
2965 if (dp->anadv_10fdx != *(uint8_t *)pr_val) {
2966 dp->anadv_10fdx = *(uint8_t *)pr_val;
2975 if ((dp->mii_status_ro & MII_STATUS_10_FD) == 0) {
2976 if (dp->anadv_10hdx != *(uint8_t *)pr_val) {
2977 dp->anadv_10hdx = *(uint8_t *)pr_val;
2986 if ((dp->mii_status_ro & MII_STATUS_CANAUTONEG) == 0) {
2987 if (dp->anadv_autoneg != *(uint8_t *)pr_val) {
2988 dp->anadv_autoneg = *(uint8_t *)pr_val;
3005 if (dp->flow_control != FLOW_CONTROL_NONE) {
3006 dp->flow_control = FLOW_CONTROL_NONE;
3012 if (dp->flow_control != FLOW_CONTROL_RX_PAUSE) {
3013 dp->flow_control = FLOW_CONTROL_RX_PAUSE;
3019 if (dp->flow_control != FLOW_CONTROL_TX_PAUSE) {
3020 dp->flow_control = FLOW_CONTROL_TX_PAUSE;
3026 if (dp->flow_control != FLOW_CONTROL_SYMMETRIC) {
3027 dp->flow_control = FLOW_CONTROL_SYMMETRIC;
3048 if (new_mtu != dp->mtu) {
3064 usbgem_choose_forcedmode(dp);
3065 dp->mii_state = MII_STATE_UNKNOWN;
3066 cv_signal(&dp->link_watcher_wait_cv);
3068 rw_exit(&dp->dev_state_lock);
3081 struct usbgem_dev *dp = arg;
3095 return (usbgem_get_def_val(dp, pr_num, pr_valsize, pr_val));
3098 rw_enter(&dp->dev_state_lock, RW_READER);
3105 if (dp->mii_state != MII_STATE_LINKUP) {
3107 } else if (dp->full_duplex) {
3121 switch (dp->speed) {
3142 if (dp->mii_status_ro & MII_STATUS_CANAUTONEG) {
3146 *(uint8_t *)pr_val = dp->anadv_autoneg;
3151 switch (dp->flow_control) {
3178 usbgem_get_def_val(dp, pr_num, pr_valsize, pr_val);
3183 if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASET_FD) &&
3184 (dp->mii_xstatus_ro & MII_XSTATUS_1000BASEX_FD)) {
3188 *(uint8_t *)pr_val = dp->anadv_1000fdx;
3193 if ((dp->mii_xstatus_ro & MII_XSTATUS_1000BASET) &&
3194 (dp->mii_xstatus_ro & MII_XSTATUS_1000BASEX)) {
3198 *(uint8_t *)pr_val = dp->anadv_1000hdx;
3203 if (dp->mii_status_ro & MII_STATUS_100_BASEX_FD) {
3207 *(uint8_t *)pr_val = dp->anadv_100fdx;
3212 if (dp->mii_status_ro & MII_STATUS_100_BASEX) {
3216 *(uint8_t *)pr_val = dp->anadv_100hdx;
3221 if (dp->mii_status_ro & MII_STATUS_10_FD) {
3225 *(uint8_t *)pr_val = dp->anadv_10fdx;
3230 if (dp->mii_status_ro & MII_STATUS_10) {
3234 *(uint8_t *)pr_val = dp->anadv_10hdx;
3239 if (dp->mii_status_ro & MII_STATUS_100_BASE_T4) {
3243 *(uint8_t *)pr_val = dp->anadv_100t4;
3264 range.range_uint32[0].mpur_max = dp->mtu;
3274 rw_exit(&dp->dev_state_lock);
3338 struct usbgem_dev *dp;
3345 struct usbgem_dev *dp = ((struct usbgem_nd_arg *)(void *)arg)->dp;
3350 dp->name, __func__, item));
3354 val = BOOLEAN(dp->mii_status & MII_STATUS_CANAUTONEG);
3359 val = dp->ugc.usbgc_flow_control != FLOW_CONTROL_NONE;
3363 val = dp->ugc.usbgc_flow_control > FLOW_CONTROL_SYMMETRIC;
3367 val = (dp->mii_xstatus & MII_XSTATUS_1000BASET_FD) ||
3368 (dp->mii_xstatus & MII_XSTATUS_1000BASEX_FD);
3372 val = (dp->mii_xstatus & MII_XSTATUS_1000BASET) ||
3373 (dp->mii_xstatus & MII_XSTATUS_1000BASEX);
3377 val = BOOLEAN(dp->mii_status & MII_STATUS_100_BASE_T4);
3381 val = BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX_FD);
3385 val = BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX);
3389 val = BOOLEAN(dp->mii_status & MII_STATUS_10_FD);
3393 val = BOOLEAN(dp->mii_status & MII_STATUS_10);
3397 val = dp->anadv_autoneg;
3401 val = dp->anadv_pause;
3405 val = dp->anadv_asmpause;
3409 val = dp->anadv_1000fdx;
3413 val = dp->anadv_1000hdx;
3417 val = dp->anadv_100t4;
3421 val = dp->anadv_100fdx;
3425 val = dp->anadv_100hdx;
3429 val = dp->anadv_10fdx;
3433 val = dp->anadv_10hdx;
3437 val = dp->anadv_1000t_ms;
3441 val = BOOLEAN(dp->mii_exp & MII_AN_EXP_LPCANAN);
3445 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_PAUSE);
3449 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_ASM_DIR);
3453 val = BOOLEAN(dp->mii_stat1000 & MII_1000TS_LP_FULL);
3457 val = BOOLEAN(dp->mii_stat1000 & MII_1000TS_LP_HALF);
3461 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_T4);
3465 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_TX_FD);
3469 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_TX);
3473 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_10BASE_T_FD);
3477 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_10BASE_T);
3481 val = (dp->mii_state == MII_STATE_LINKUP);
3485 val = usbgem_speed_value[dp->speed];
3490 if (dp->mii_state == MII_STATE_LINKUP) {
3491 val = dp->full_duplex ? 2 : 1;
3496 val = BOOLEAN(dp->mii_exp & MII_AN_EXP_LPCANAN);
3500 val = (dp->flow_control == FLOW_CONTROL_SYMMETRIC) ||
3501 (dp->flow_control == FLOW_CONTROL_RX_PAUSE);
3505 val = (dp->flow_control == FLOW_CONTROL_SYMMETRIC) ||
3506 (dp->flow_control == FLOW_CONTROL_TX_PAUSE);
3516 dp->name, item);
3529 struct usbgem_dev *dp = ((struct usbgem_nd_arg *)(void *)arg)->dp;
3534 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
3547 if (val && (dp->mii_status & MII_STATUS_CANAUTONEG) == 0) {
3550 dp->anadv_autoneg = (int)val;
3557 if (val && dp->ugc.usbgc_flow_control == FLOW_CONTROL_NONE) {
3560 dp->anadv_pause = (int)val;
3568 dp->ugc.usbgc_flow_control <= FLOW_CONTROL_SYMMETRIC) {
3571 dp->anadv_asmpause = (int)val;
3578 if (val && (dp->mii_xstatus &
3583 dp->anadv_1000fdx = (int)val;
3590 if (val && (dp->mii_xstatus &
3594 dp->anadv_1000hdx = (int)val;
3601 if (val && (dp->mii_status & MII_STATUS_100_BASE_T4) == 0) {
3604 dp->anadv_100t4 = (int)val;
3611 if (val && (dp->mii_status & MII_STATUS_100_BASEX_FD) == 0) {
3614 dp->anadv_100fdx = (int)val;
3621 if (val && (dp->mii_status & MII_STATUS_100_BASEX) == 0) {
3624 dp->anadv_100hdx = (int)val;
3631 if (val && (dp->mii_status & MII_STATUS_10_FD) == 0) {
3634 dp->anadv_10fdx = (int)val;
3641 if (val && (dp->mii_status & MII_STATUS_10) == 0) {
3644 dp->anadv_10hdx = (int)val;
3651 if (val && (dp->mii_xstatus &
3655 dp->anadv_1000t_ms = (int)val;
3660 mutex_exit(&dp->xmitlock);
3661 mutex_exit(&dp->intrlock);
3662 gem_suspend(dp->dip);
3663 gem_resume(dp->dip);
3664 mutex_enter(&dp->intrlock);
3665 mutex_enter(&dp->xmitlock);
3671 usbgem_choose_forcedmode(dp);
3673 dp->mii_state = MII_STATE_UNKNOWN;
3674 if (dp->ugc.usbgc_mii_hw_link_detection) {
3676 cv_signal(&dp->link_watcher_wait_cv);
3685 usbgem_nd_load(struct usbgem_dev *dp,
3693 arg = &((struct usbgem_nd_arg *)(void *)dp->nd_arg_p)[item];
3694 arg->dp = dp;
3698 dp->name, __func__, name, item));
3699 (void) nd_load(&dp->nd_data_p, name, gf, sf, (caddr_t)arg);
3703 usbgem_nd_setup(struct usbgem_dev *dp)
3706 dp->name, __func__, dp->mii_status, MII_STATUS_BITS));
3708 ASSERT(dp->nd_arg_p == NULL);
3710 dp->nd_arg_p =
3715 usbgem_nd_load(dp, "autoneg_cap",
3717 usbgem_nd_load(dp, "pause_cap",
3719 usbgem_nd_load(dp, "asym_pause_cap",
3721 usbgem_nd_load(dp, "1000fdx_cap",
3723 usbgem_nd_load(dp, "1000hdx_cap",
3725 usbgem_nd_load(dp, "100T4_cap",
3727 usbgem_nd_load(dp, "100fdx_cap",
3729 usbgem_nd_load(dp, "100hdx_cap",
3731 usbgem_nd_load(dp, "10fdx_cap",
3733 usbgem_nd_load(dp, "10hdx_cap",
3737 usbgem_nd_load(dp, "adv_autoneg_cap", usbgem_param_get,
3738 SETFUNC(dp->mii_status & MII_STATUS_CANAUTONEG),
3740 usbgem_nd_load(dp, "adv_pause_cap", usbgem_param_get,
3741 SETFUNC(dp->ugc.usbgc_flow_control & 1),
3743 usbgem_nd_load(dp, "adv_asym_pause_cap", usbgem_param_get,
3744 SETFUNC(dp->ugc.usbgc_flow_control & 2),
3746 usbgem_nd_load(dp, "adv_1000fdx_cap", usbgem_param_get,
3747 SETFUNC(dp->mii_xstatus &
3750 usbgem_nd_load(dp, "adv_1000hdx_cap", usbgem_param_get,
3751 SETFUNC(dp->mii_xstatus &
3754 usbgem_nd_load(dp, "adv_100T4_cap", usbgem_param_get,
3755 SETFUNC((dp->mii_status & MII_STATUS_100_BASE_T4) &&
3756 !dp->mii_advert_ro),
3758 usbgem_nd_load(dp, "adv_100fdx_cap", usbgem_param_get,
3759 SETFUNC((dp->mii_status & MII_STATUS_100_BASEX_FD) &&
3760 !dp->mii_advert_ro),
3762 usbgem_nd_load(dp, "adv_100hdx_cap", usbgem_param_get,
3763 SETFUNC((dp->mii_status & MII_STATUS_100_BASEX) &&
3764 !dp->mii_advert_ro),
3766 usbgem_nd_load(dp, "adv_10fdx_cap", usbgem_param_get,
3767 SETFUNC((dp->mii_status & MII_STATUS_10_FD) &&
3768 !dp->mii_advert_ro),
3770 usbgem_nd_load(dp, "adv_10hdx_cap", usbgem_param_get,
3771 SETFUNC((dp->mii_status & MII_STATUS_10) &&
3772 !dp->mii_advert_ro),
3774 usbgem_nd_load(dp, "adv_1000t_ms", usbgem_param_get,
3775 SETFUNC(dp->mii_xstatus &
3781 usbgem_nd_load(dp, "lp_autoneg_cap",
3783 usbgem_nd_load(dp, "lp_pause_cap",
3785 usbgem_nd_load(dp, "lp_asym_pause_cap",
3787 usbgem_nd_load(dp, "lp_1000fdx_cap",
3789 usbgem_nd_load(dp, "lp_1000hdx_cap",
3791 usbgem_nd_load(dp, "lp_100T4_cap",
3793 usbgem_nd_load(dp, "lp_100fdx_cap",
3795 usbgem_nd_load(dp, "lp_100hdx_cap",
3797 usbgem_nd_load(dp, "lp_10fdx_cap",
3799 usbgem_nd_load(dp, "lp_10hdx_cap",
3803 usbgem_nd_load(dp, "link_status",
3805 usbgem_nd_load(dp, "link_speed",
3807 usbgem_nd_load(dp, "link_duplex",
3809 usbgem_nd_load(dp, "link_autoneg",
3811 usbgem_nd_load(dp, "link_rx_pause",
3813 usbgem_nd_load(dp, "link_tx_pause",
3816 usbgem_nd_load(dp, "resume_test",
3824 usbgem_nd_ioctl(struct usbgem_dev *dp,
3829 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
3833 ok = nd_getset(wq, dp->nd_data_p, mp);
3835 "%s: get %s", dp->name, ok ? "OK" : "FAIL"));
3839 ok = nd_getset(wq, dp->nd_data_p, mp);
3842 dp->name, ok ? "OK" : "FAIL", iocp->ioc_error));
3855 cmn_err(CE_WARN, "%s: invalid cmd 0x%x", dp->name, iocp->ioc_cmd);
3861 usbgem_nd_cleanup(struct usbgem_dev *dp)
3863 ASSERT(dp->nd_data_p != NULL);
3864 ASSERT(dp->nd_arg_p != NULL);
3866 nd_free(&dp->nd_data_p);
3868 kmem_free(dp->nd_arg_p, sizeof (struct usbgem_nd_arg) * PARAM_COUNT);
3869 dp->nd_arg_p = NULL;
3874 usbgem_mac_ioctl(struct usbgem_dev *dp, queue_t *wq, mblk_t *mp)
3880 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
3889 DPRINTF(1, (CE_CONT, "%s: %s cmd:0x%x", dp->name, __func__, cmd));
3900 status = usbgem_nd_ioctl(dp, wq, mp, iocp);
3958 usbgem_mac_xcvr_inuse(struct usbgem_dev *dp)
3962 if ((dp->mii_status & MII_STATUS_XSTATUS) == 0) {
3963 if (dp->mii_status & MII_STATUS_100_BASE_T4) {
3965 } else if (dp->mii_status &
3969 } else if (dp->mii_status &
3973 } else if (dp->mii_status &
3977 } else if (dp->mii_xstatus &
3980 } else if (dp->mii_xstatus &
4062 struct usbgem_dev *dp = arg;
4064 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4068 rw_enter(&dp->dev_state_lock, RW_WRITER);
4069 dp->nic_state = NIC_STATE_ONLINE;
4071 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
4075 if (usbgem_mac_init(dp) != USB_SUCCESS) {
4080 sema_p(&dp->rxfilter_lock);
4081 dp->mc_count = 0;
4082 dp->mc_count_req = 0;
4084 bcopy(dp->dev_addr.ether_addr_octet,
4085 dp->cur_addr.ether_addr_octet, ETHERADDRL);
4086 dp->rxmode |= RXMODE_ENABLE;
4088 ret = usbgem_hal_set_rx_filter(dp);
4089 sema_v(&dp->rxfilter_lock);
4095 if (dp->mii_state == MII_STATE_LINKUP) {
4097 if (usbgem_hal_set_media(dp) != USB_SUCCESS) {
4100 if (usbgem_mac_start(dp) != USB_SUCCESS) {
4107 rw_exit(&dp->dev_state_lock);
4114 struct usbgem_dev *dp = arg;
4116 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4119 rw_enter(&dp->dev_state_lock, RW_READER);
4120 sema_p(&dp->rxfilter_lock);
4121 dp->rxmode &= ~RXMODE_ENABLE;
4123 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4124 (void) usbgem_hal_set_rx_filter(dp);
4126 sema_v(&dp->rxfilter_lock);
4127 rw_exit(&dp->dev_state_lock);
4130 rw_enter(&dp->dev_state_lock, RW_WRITER);
4131 dp->nic_state = NIC_STATE_STOPPED;
4134 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4135 (void) usbgem_mac_stop(dp, MAC_STATE_STOPPED, STOP_GRACEFUL);
4137 rw_exit(&dp->dev_state_lock);
4145 struct usbgem_dev *dp = arg;
4147 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4149 rw_enter(&dp->dev_state_lock, RW_READER);
4151 ret = usbgem_add_multicast(dp, ep);
4153 ret = usbgem_remove_multicast(dp, ep);
4155 rw_exit(&dp->dev_state_lock);
4160 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
4172 struct usbgem_dev *dp = arg;
4174 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4176 rw_enter(&dp->dev_state_lock, RW_READER);
4178 sema_p(&dp->rxfilter_lock);
4180 dp->rxmode |= RXMODE_PROMISC;
4182 dp->rxmode &= ~RXMODE_PROMISC;
4186 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4187 if (usbgem_hal_set_rx_filter(dp) != USB_SUCCESS) {
4191 sema_v(&dp->rxfilter_lock);
4193 rw_exit(&dp->dev_state_lock);
4197 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
4208 struct usbgem_dev *dp = arg;
4209 struct usbgem_stats *gstp = &dp->stats;
4211 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4213 rw_enter(&dp->dev_state_lock, RW_READER);
4214 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
4215 rw_exit(&dp->dev_state_lock);
4218 ret = usbgem_hal_get_stats(dp);
4219 rw_exit(&dp->dev_state_lock);
4223 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
4230 val = usbgem_speed_value[dp->speed] *1000000ull;
4342 val = dp->mii_phy_addr;
4346 val = dp->mii_phy_id;
4350 val = usbgem_mac_xcvr_inuse(dp);
4354 val = (dp->mii_xstatus & MII_XSTATUS_1000BASET_FD) ||
4355 (dp->mii_xstatus & MII_XSTATUS_1000BASEX_FD);
4359 val = (dp->mii_xstatus & MII_XSTATUS_1000BASET) ||
4360 (dp->mii_xstatus & MII_XSTATUS_1000BASEX);
4364 val = BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX_FD);
4368 val = BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX);
4372 val = BOOLEAN(dp->mii_status & MII_STATUS_10_FD);
4376 val = BOOLEAN(dp->mii_status & MII_STATUS_10);
4380 val = dp->ugc.usbgc_flow_control > FLOW_CONTROL_SYMMETRIC;
4384 val = dp->ugc.usbgc_flow_control != FLOW_CONTROL_NONE;
4388 val = BOOLEAN(dp->mii_status & MII_STATUS_CANAUTONEG);
4392 val = dp->anadv_1000fdx;
4396 val = dp->anadv_1000hdx;
4400 val = dp->anadv_100fdx;
4404 val = dp->anadv_100hdx;
4408 val = dp->anadv_10fdx;
4412 val = dp->anadv_10hdx;
4416 val = dp->anadv_asmpause;
4420 val = dp->anadv_pause;
4424 val = dp->anadv_autoneg;
4428 val = BOOLEAN(dp->mii_stat1000 & MII_1000TS_LP_FULL);
4432 val = BOOLEAN(dp->mii_stat1000 & MII_1000TS_LP_HALF);
4436 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_TX_FD);
4440 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_TX);
4444 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_10BASE_T_FD);
4448 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_10BASE_T);
4452 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_ASM_DIR);
4456 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_PAUSE);
4460 val = BOOLEAN(dp->mii_exp & MII_AN_EXP_LPCANAN);
4464 val = BOOLEAN(dp->flow_control & 2);
4468 val = BOOLEAN(dp->flow_control & 1);
4472 val = dp->anadv_autoneg &&
4473 BOOLEAN(dp->mii_exp & MII_AN_EXP_LPCANAN);
4477 val = (dp->mii_state == MII_STATE_LINKUP) ?
4478 (dp->full_duplex ? 2 : 1) : 0;
4490 val = dp->anadv_remfault;
4494 val = BOOLEAN(dp->mii_lpable & MII_AN_ADVERT_REMFAULT);
4502 val = BOOLEAN(dp->mii_status & MII_STATUS_100_BASE_T4);
4506 val = dp->anadv_100t4;
4510 val = BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_T4);
4532 struct usbgem_dev *dp = arg;
4534 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4536 rw_enter(&dp->dev_state_lock, RW_READER);
4538 sema_p(&dp->rxfilter_lock);
4539 bcopy(mac, dp->cur_addr.ether_addr_octet, ETHERADDRL);
4540 dp->rxmode |= RXMODE_ENABLE;
4543 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4544 if (usbgem_hal_set_rx_filter(dp) != USB_SUCCESS) {
4548 sema_v(&dp->rxfilter_lock);
4549 rw_exit(&dp->dev_state_lock);
4553 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
4569 struct usbgem_dev *dp = arg;
4571 DPRINTF(4, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4576 rw_enter(&dp->dev_state_lock, RW_READER);
4578 if (dp->mii_state != MII_STATE_LINKUP ||
4579 dp->mac_state != MAC_STATE_ONLINE) {
4589 ASSERT(dp->nic_state == NIC_STATE_ONLINE);
4591 limit = dp->tx_max_packets;
4595 if (usbgem_send_common(dp, mp,
4604 mutex_enter(&dp->txlock);
4605 dp->tx_max_packets = max(dp->tx_max_packets - 1, 1);
4606 mutex_exit(&dp->txlock);
4610 rw_exit(&dp->dev_state_lock);
4618 struct usbgem_dev *dp = arg;
4623 rw_enter(&dp->dev_state_lock, RW_READER);
4625 rw_exit(&dp->dev_state_lock);
4629 usbgem_gld3_init(struct usbgem_dev *dp, mac_register_t *macp)
4632 macp->m_driver = dp;
4633 macp->m_dip = dp->dip;
4634 macp->m_src_addr = dp->dev_addr.ether_addr_octet;
4637 macp->m_max_sdu = dp->mtu;
4639 if (dp->misc_flag & USBGEM_VLAN) {
4663 struct usbgem_dev *dp;
4666 dp = (struct usbgem_dev *)macinfo->gldm_private;
4668 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4670 rw_enter(&dp->dev_state_lock, RW_WRITER);
4671 if (usbgem_mac_init(dp) != USB_SUCCESS) {
4676 dp->nic_state = NIC_STATE_INITIALIZED;
4679 if (dp->mii_state == MII_STATE_LINKUP) {
4680 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4681 (void) usbgem_hal_set_media(dp);
4685 rw_exit(&dp->dev_state_lock);
4693 struct usbgem_dev *dp;
4695 dp = (struct usbgem_dev *)macinfo->gldm_private;
4697 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4699 rw_enter(&dp->dev_state_lock, RW_WRITER);
4701 dp->nic_state = NIC_STATE_ONLINE;
4703 if (dp->mii_state == MII_STATE_LINKUP) {
4704 if (usbgem_mac_start(dp) != USB_SUCCESS) {
4705 /* sema_v(&dp->mii_lock); */
4717 rw_exit(&dp->dev_state_lock);
4726 struct usbgem_dev *dp;
4728 dp = (struct usbgem_dev *)macinfo->gldm_private;
4730 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4733 rw_enter(&dp->dev_state_lock, RW_READER);
4734 sema_p(&dp->rxfilter_lock);
4735 dp->rxmode &= ~RXMODE_ENABLE;
4737 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4738 (void) usbgem_hal_set_rx_filter(dp);
4740 sema_v(&dp->rxfilter_lock);
4741 rw_exit(&dp->dev_state_lock);
4744 rw_enter(&dp->dev_state_lock, RW_WRITER);
4745 dp->nic_state = NIC_STATE_STOPPED;
4747 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4748 if (usbgem_mac_stop(dp, MAC_STATE_STOPPED, STOP_GRACEFUL)
4753 rw_exit(&dp->dev_state_lock);
4763 struct usbgem_dev *dp;
4765 dp = (struct usbgem_dev *)macinfo->gldm_private;
4767 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4769 rw_enter(&dp->dev_state_lock, RW_READER);
4771 ret = usbgem_add_multicast(dp, ep);
4773 ret = usbgem_remove_multicast(dp, ep);
4775 rw_exit(&dp->dev_state_lock);
4780 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
4791 struct usbgem_dev *dp;
4793 dp = (struct usbgem_dev *)macinfo->gldm_private;
4795 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4797 sema_p(&dp->rxfilter_lock);
4799 dp->rxmode &= ~(RXMODE_PROMISC | RXMODE_ALLMULTI_REQ);
4801 dp->rxmode |= RXMODE_ALLMULTI_REQ;
4803 dp->rxmode |= RXMODE_PROMISC;
4810 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4811 (void) usbgem_hal_set_rx_filter(dp);
4814 sema_v(&dp->rxfilter_lock);
4822 struct usbgem_dev *dp;
4823 dp = (struct usbgem_dev *)macinfo->gldm_private;
4825 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
4827 sema_p(&dp->rxfilter_lock);
4828 bcopy(mac, dp->cur_addr.ether_addr_octet, ETHERADDRL);
4829 dp->rxmode |= RXMODE_ENABLE;
4831 if (dp->mac_state != MAC_STATE_DISCONNECTED) {
4832 (void) usbgem_hal_set_rx_filter(dp);
4834 sema_v(&dp->rxfilter_lock);
4842 struct usbgem_dev *dp;
4845 dp = (struct usbgem_dev *)macinfo->gldm_private;
4847 if ((*dp->ugc.usbgc_get_stats)(dp) != USB_SUCCESS) {
4849 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
4854 vs = &dp->stats;
4875 gs->glds_speed = usbgem_speed_value[dp->speed] * 1000000;
4877 gs->glds_duplex = dp->full_duplex ? GLD_DUPLEX_FULL : GLD_DUPLEX_HALF;
4893 struct usbgem_dev *dp;
4895 dp = (struct usbgem_dev *)macinfo->gldm_private;
4896 usbgem_mac_ioctl(dp, wq, mp);
4909 struct usbgem_dev *dp;
4911 dp = (struct usbgem_dev *)macinfo->gldm_private;
4914 rw_enter(&dp->dev_state_lock, RW_READER);
4916 ASSERT(dp->nic_state == NIC_STATE_ONLINE);
4919 if (dp->mii_state != MII_STATE_LINKUP) {
4922 rw_exit(&dp->dev_state_lock);
4927 ddi_fm_service_impact(dp->dip, DDI_SERVICE_DEGRADED);
4932 ret = (usbgem_send_common(dp, mp, flags) == NULL)
4934 rw_exit(&dp->dev_state_lock);
4946 struct usbgem_dev *dp;
4948 dp = (struct usbgem_dev *)macinfo->gldm_private;
4953 if (dp->mii_state != MII_STATE_LINKUP) {
4958 ddi_fm_service_impact(dp->dip, DDI_SERVICE_UNAFFECTED);
4965 return ((usbgem_send_common(dp, mp, 0) == NULL) ?
4970 usbgem_gld_init(struct usbgem_dev *dp, gld_mac_info_t *macinfo, char *ident)
4975 macinfo->gldm_devinfo = dp->dip;
4976 macinfo->gldm_private = (caddr_t)dp;
4993 macinfo->gldm_maxpkt = dp->mtu;
4996 macinfo->gldm_ppa = ddi_get_instance(dp->dip);
5000 macinfo->gldm_vendor_addr = dp->dev_addr.ether_addr_octet;
5012 usbgem_generate_macaddr(struct usbgem_dev *dp, uint8_t *mac)
5023 dp->name);
5031 if (dp->name[i] == 0) {
5034 key ^= dp->name[i];
5036 key ^= ddi_get_instance(dp->dip);
5049 usbgem_get_mac_addr_conf(struct usbgem_dev *dp)
5062 DPRINTF(3, (CE_CONT, "!%s: %s: called", dp->name, __func__));
5067 if ((ddi_prop_lookup_string(DDI_DEV_T_ANY, dp->dip,
5110 usbgem_generate_macaddr(dp, mac);
5113 dp->dev_addr.ether_addr_octet[i] = mac[i];
5121 dp->name, valstr);
5128 usbgem_read_conf(struct usbgem_dev *dp)
5132 DPRINTF(1, (CE_CONT, "!%s: %s: called", dp->name, __func__));
5137 dp->anadv_autoneg = usbgem_prop_get_int(dp, "adv_autoneg_cap", 1) != 0;
5138 dp->anadv_1000fdx = usbgem_prop_get_int(dp, "adv_1000fdx_cap", 1) != 0;
5139 dp->anadv_1000hdx = usbgem_prop_get_int(dp, "adv_1000hdx_cap", 1) != 0;
5140 dp->anadv_100t4 = usbgem_prop_get_int(dp, "adv_100T4_cap", 1) != 0;
5141 dp->anadv_100fdx = usbgem_prop_get_int(dp, "adv_100fdx_cap", 1) != 0;
5142 dp->anadv_100hdx = usbgem_prop_get_int(dp, "adv_100hdx_cap", 1) != 0;
5143 dp->anadv_10fdx = usbgem_prop_get_int(dp, "adv_10fdx_cap", 1) != 0;
5144 dp->anadv_10hdx = usbgem_prop_get_int(dp, "adv_10hdx_cap", 1) != 0;
5145 dp->anadv_1000t_ms = usbgem_prop_get_int(dp, "adv_1000t_ms", 0);
5147 if ((ddi_prop_exists(DDI_DEV_T_ANY, dp->dip,
5149 dp->full_duplex =
5150 usbgem_prop_get_int(dp, "full-duplex", 1) != 0;
5151 dp->anadv_autoneg = B_FALSE;
5152 if (dp->full_duplex) {
5153 dp->anadv_1000hdx = B_FALSE;
5154 dp->anadv_100hdx = B_FALSE;
5155 dp->anadv_10hdx = B_FALSE;
5157 dp->anadv_1000fdx = B_FALSE;
5158 dp->anadv_100fdx = B_FALSE;
5159 dp->anadv_10fdx = B_FALSE;
5163 if ((val = usbgem_prop_get_int(dp, "speed", 0)) > 0) {
5164 dp->anadv_autoneg = B_FALSE;
5167 dp->speed = USBGEM_SPD_1000;
5168 dp->anadv_100t4 = B_FALSE;
5169 dp->anadv_100fdx = B_FALSE;
5170 dp->anadv_100hdx = B_FALSE;
5171 dp->anadv_10fdx = B_FALSE;
5172 dp->anadv_10hdx = B_FALSE;
5175 dp->speed = USBGEM_SPD_100;
5176 dp->anadv_1000fdx = B_FALSE;
5177 dp->anadv_1000hdx = B_FALSE;
5178 dp->anadv_10fdx = B_FALSE;
5179 dp->anadv_10hdx = B_FALSE;
5182 dp->speed = USBGEM_SPD_10;
5183 dp->anadv_1000fdx = B_FALSE;
5184 dp->anadv_1000hdx = B_FALSE;
5185 dp->anadv_100t4 = B_FALSE;
5186 dp->anadv_100fdx = B_FALSE;
5187 dp->anadv_100hdx = B_FALSE;
5192 dp->name, "speed", val);
5193 dp->anadv_autoneg = B_TRUE;
5197 val = usbgem_prop_get_int(dp,
5198 "adv_pause", dp->ugc.usbgc_flow_control & 1);
5199 val |= usbgem_prop_get_int(dp,
5200 "adv_asmpause", BOOLEAN(dp->ugc.usbgc_flow_control & 2)) << 1;
5204 dp->name, "flow-control", val);
5206 val = min(val, dp->ugc.usbgc_flow_control);
5208 dp->anadv_pause = BOOLEAN(val & 1);
5209 dp->anadv_asmpause = BOOLEAN(val & 2);
5211 dp->mtu = usbgem_prop_get_int(dp, "mtu", dp->mtu);
5212 dp->txthr = usbgem_prop_get_int(dp, "txthr", dp->txthr);
5213 dp->rxthr = usbgem_prop_get_int(dp, "rxthr", dp->rxthr);
5214 dp->txmaxdma = usbgem_prop_get_int(dp, "txmaxdma", dp->txmaxdma);
5215 dp->rxmaxdma = usbgem_prop_get_int(dp, "rxmaxdma", dp->rxmaxdma);
5217 dp->poll_pkt_delay =
5218 usbgem_prop_get_int(dp, "pkt_delay", dp->poll_pkt_delay);
5220 dp->max_poll_interval[GEM_SPD_10] =
5221 usbgem_prop_get_int(dp, "max_poll_interval_10",
5222 dp->max_poll_interval[GEM_SPD_10]);
5223 dp->max_poll_interval[GEM_SPD_100] =
5224 usbgem_prop_get_int(dp, "max_poll_interval_100",
5225 dp->max_poll_interval[GEM_SPD_100]);
5226 dp->max_poll_interval[GEM_SPD_1000] =
5227 usbgem_prop_get_int(dp, "max_poll_interval_1000",
5228 dp->max_poll_interval[GEM_SPD_1000]);
5230 dp->min_poll_interval[GEM_SPD_10] =
5231 usbgem_prop_get_int(dp, "min_poll_interval_10",
5232 dp->min_poll_interval[GEM_SPD_10]);
5233 dp->min_poll_interval[GEM_SPD_100] =
5234 usbgem_prop_get_int(dp, "min_poll_interval_100",
5235 dp->min_poll_interval[GEM_SPD_100]);
5236 dp->min_poll_interval[GEM_SPD_1000] =
5237 usbgem_prop_get_int(dp, "min_poll_interval_1000",
5238 dp->min_poll_interval[GEM_SPD_1000]);
5289 struct usbgem_dev *dp = (struct usbgem_dev *)ksp->ks_private;
5297 knp->ks_xcvr_addr.value.ul = dp->mii_phy_addr;
5298 knp->ks_xcvr_id.value.ul = dp->mii_phy_id;
5299 knp->ks_xcvr_inuse.value.ul = usbgem_mac_xcvr_inuse(dp);
5300 knp->ks_link_up.value.ul = dp->mii_state == MII_STATE_LINKUP;
5302 (dp->mii_state == MII_STATE_LINKUP) ?
5303 (dp->full_duplex ? 2 : 1) : 0;
5306 (dp->mii_xstatus & MII_XSTATUS_1000BASET_FD) ||
5307 (dp->mii_xstatus & MII_XSTATUS_1000BASEX_FD);
5309 (dp->mii_xstatus & MII_XSTATUS_1000BASET) ||
5310 (dp->mii_xstatus & MII_XSTATUS_1000BASEX);
5312 BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX_FD);
5314 BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX);
5316 BOOLEAN(dp->mii_status & MII_STATUS_10_FD);
5318 BOOLEAN(dp->mii_status & MII_STATUS_10);
5323 BOOLEAN(dp->mii_status & MII_STATUS_CANAUTONEG);
5325 knp->ks_adv_cap_1000fdx.value.ul = dp->anadv_1000fdx;
5326 knp->ks_adv_cap_1000hdx.value.ul = dp->anadv_1000hdx;
5327 knp->ks_adv_cap_100fdx.value.ul = dp->anadv_100fdx;
5328 knp->ks_adv_cap_100hdx.value.ul = dp->anadv_100hdx;
5329 knp->ks_adv_cap_10fdx.value.ul = dp->anadv_10fdx;
5330 knp->ks_adv_cap_10hdx.value.ul = dp->anadv_10hdx;
5334 knp->ks_adv_cap_autoneg.value.ul = dp->anadv_autoneg;
5337 BOOLEAN(dp->mii_stat1000 & MII_1000TS_LP_FULL);
5339 BOOLEAN(dp->mii_stat1000 & MII_1000TS_LP_HALF);
5341 BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_TX_FD);
5343 BOOLEAN(dp->mii_lpable & MII_ABILITY_100BASE_TX);
5345 BOOLEAN(dp->mii_lpable & MII_ABILITY_10BASE_T_FD);
5347 BOOLEAN(dp->mii_lpable & MII_ABILITY_10BASE_T);
5349 BOOLEAN(dp->mii_exp & MII_AN_EXP_PARFAULT);
5351 BOOLEAN(dp->mii_exp & MII_AN_EXP_LPCANAN);
5358 usbgem_kstat_init(struct usbgem_dev *dp)
5365 (char *)ddi_driver_name(dp->dip), ddi_get_instance(dp->dip),
5371 dp->name, __func__);
5441 ksp->ks_private = (void *) dp;
5443 dp->ksp = ksp;
5456 usbgem_ctrl_out(struct usbgem_dev *dp,
5471 dp->name, __func__, reqt, req, val, ix, len, bp, dp->nic_state));
5473 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
5498 ret = usb_pipe_ctrl_xfer_wait(DEFAULT_PIPE(dp),
5509 dp->name, __func__, reqt, req, val, ix, len,
5525 usbgem_ctrl_in(struct usbgem_dev *dp,
5541 dp->name, __func__, reqt, req, val, ix, len, bp, dp->mac_state));
5543 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
5559 ret = usb_pipe_ctrl_xfer_wait(DEFAULT_PIPE(dp), &setup, &data,
5572 dp->name, __func__,
5589 usbgem_ctrl_out_val(struct usbgem_dev *dp,
5608 return (usbgem_ctrl_out(dp, reqt, req, val, ix, len, buf, len));
5612 usbgem_ctrl_in_val(struct usbgem_dev *dp,
5623 err = usbgem_ctrl_in(dp, reqt, req, val, ix, len, buf, len);
5657 usbgem_open_pipes(struct usbgem_dev *dp)
5666 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
5668 ifnum = dp->ugc.usbgc_ifnum;
5669 alt = dp->ugc.usbgc_alt;
5671 ep_tree_node = usb_lookup_ep_data(dp->dip, dp->reg_data, ifnum, alt,
5675 dp->name, __func__);
5678 dp->ep_bulkin = &ep_tree_node->ep_descr;
5680 ep_tree_node = usb_lookup_ep_data(dp->dip, dp->reg_data, ifnum, alt,
5684 dp->name, __func__);
5687 dp->ep_bulkout = &ep_tree_node->ep_descr;
5689 ep_tree_node = usb_lookup_ep_data(dp->dip, dp->reg_data, ifnum, alt,
5692 dp->ep_intr = &ep_tree_node->ep_descr;
5696 dp->name, __func__));
5697 dp->ep_intr = NULL;
5703 bzero(&dp->policy_bulkout, sizeof (usb_pipe_policy_t));
5704 dp->policy_bulkout.pp_max_async_reqs = 1;
5706 if ((ret = usb_pipe_open(dp->dip,
5707 dp->ep_bulkout, &dp->policy_bulkout, USB_FLAGS_SLEEP,
5708 &dp->bulkout_pipe)) != USB_SUCCESS) {
5711 dp->name, __func__, ret);
5712 dp->bulkout_pipe = NULL;
5716 dp->name, __func__));
5719 bzero(&dp->policy_bulkin, sizeof (usb_pipe_policy_t));
5720 dp->policy_bulkin.pp_max_async_reqs = 1;
5721 if ((ret = usb_pipe_open(dp->dip,
5722 dp->ep_bulkin, &dp->policy_bulkin, USB_FLAGS_SLEEP,
5723 &dp->bulkin_pipe)) != USB_SUCCESS) {
5726 dp->name, __func__, ret);
5727 dp->bulkin_pipe = NULL;
5731 dp->name, __func__));
5733 if (dp->ep_intr) {
5735 bzero(&dp->policy_interrupt, sizeof (usb_pipe_policy_t));
5736 dp->policy_interrupt.pp_max_async_reqs = 1;
5737 if ((ret = usb_pipe_open(dp->dip, dp->ep_intr,
5738 &dp->policy_interrupt, USB_FLAGS_SLEEP,
5739 &dp->intr_pipe)) != USB_SUCCESS) {
5742 dp->name, __func__, ret);
5743 dp->intr_pipe = NULL;
5748 dp->name, __func__));
5753 if (dp->bulkin_pipe) {
5754 usb_pipe_close(dp->dip,
5755 dp->bulkin_pipe, USB_FLAGS_SLEEP, NULL, 0);
5756 dp->bulkin_pipe = NULL;
5758 if (dp->bulkout_pipe) {
5759 usb_pipe_close(dp->dip,
5760 dp->bulkout_pipe, USB_FLAGS_SLEEP, NULL, 0);
5761 dp->bulkout_pipe = NULL;
5763 if (dp->intr_pipe) {
5764 usb_pipe_close(dp->dip,
5765 dp->intr_pipe, USB_FLAGS_SLEEP, NULL, 0);
5766 dp->intr_pipe = NULL;
5773 usbgem_close_pipes(struct usbgem_dev *dp)
5775 DPRINTF(0, (CE_CONT, "!%s: %s: called", dp->name, __func__));
5777 if (dp->intr_pipe) {
5778 usb_pipe_close(dp->dip,
5779 dp->intr_pipe, USB_FLAGS_SLEEP, NULL, 0);
5780 dp->intr_pipe = NULL;
5782 DPRINTF(1, (CE_CONT, "!%s: %s: 1", dp->name, __func__));
5784 ASSERT(dp->bulkin_pipe);
5785 usb_pipe_close(dp->dip, dp->bulkin_pipe, USB_FLAGS_SLEEP, NULL, 0);
5786 dp->bulkin_pipe = NULL;
5787 DPRINTF(1, (CE_CONT, "!%s: %s: 2", dp->name, __func__));
5789 ASSERT(dp->bulkout_pipe);
5790 usb_pipe_close(dp->dip, dp->bulkout_pipe, USB_FLAGS_SLEEP, NULL, 0);
5791 dp->bulkout_pipe = NULL;
5792 DPRINTF(1, (CE_CONT, "!%s: %s: 3", dp->name, __func__));
5800 usbgem_freeze_device(struct usbgem_dev *dp, boolean_t graceful)
5802 DPRINTF(0, (CE_NOTE, "!%s: %s: called", dp->name, __func__));
5805 (void) usbgem_mac_stop(dp, MAC_STATE_DISCONNECTED, graceful);
5812 (void) usbgem_free_memory(dp);
5821 struct usbgem_dev *dp;
5823 dp = USBGEM_GET_DEV(dip);
5825 cmn_err(CE_NOTE, "!%s: the usb device was disconnected (dp=%p)",
5826 dp->name, (void *)dp);
5829 rw_enter(&dp->dev_state_lock, RW_WRITER);
5831 ret = usbgem_freeze_device(dp, 0);
5834 rw_exit(&dp->dev_state_lock);
5840 usbgem_recover_device(struct usbgem_dev *dp)
5844 DPRINTF(0, (CE_NOTE, "!%s: %s: called", dp->name, __func__));
5849 usbgem_close_pipes(dp);
5850 if ((err = usbgem_open_pipes(dp)) != USB_SUCCESS) {
5855 dp->mac_state = MAC_STATE_STOPPED;
5856 dp->mii_state = MII_STATE_UNKNOWN;
5859 if ((err = usbgem_alloc_memory(dp)) != USB_SUCCESS) {
5864 (void) usbgem_restart_nic(dp);
5866 usbgem_mii_init(dp);
5869 cv_signal(&dp->link_watcher_wait_cv);
5878 struct usbgem_dev *dp;
5880 dp = USBGEM_GET_DEV(dip);
5881 DPRINTF(0, (CE_CONT, "!%s: dp=%p", ddi_get_name(dip), dp));
5884 if (usb_check_same_device(dp->dip, NULL, USB_LOG_L2, -1,
5887 "!%s: no or different device installed", dp->name);
5891 cmn_err(CE_NOTE, "%s: the usb device was reconnected", dp->name);
5894 rw_enter(&dp->dev_state_lock, RW_WRITER);
5896 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
5897 err = usbgem_recover_device(dp);
5901 rw_exit(&dp->dev_state_lock);
5910 struct usbgem_dev *dp;
5912 dp = USBGEM_GET_DEV(dip);
5914 DPRINTF(0, (CE_CONT, "!%s: %s: callded", dp->name, __func__));
5917 rw_enter(&dp->dev_state_lock, RW_WRITER);
5919 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
5920 err = usbgem_freeze_device(dp, STOP_GRACEFUL);
5924 rw_exit(&dp->dev_state_lock);
5933 struct usbgem_dev *dp;
5935 dp = USBGEM_GET_DEV(dip);
5937 DPRINTF(0, (CE_CONT, "!%s: %s: callded", dp->name, __func__));
5940 if (usb_check_same_device(dp->dip, NULL, USB_LOG_L2, -1,
5943 "!%s: no or different device installed", dp->name);
5948 rw_enter(&dp->dev_state_lock, RW_WRITER);
5950 if (dp->mac_state == MAC_STATE_DISCONNECTED) {
5951 err = usbgem_recover_device(dp);
5955 rw_exit(&dp->dev_state_lock);
5967 struct usbgem_dev *dp;
5986 dp = kmem_zalloc(USBGEM_LOCAL_DATA_SIZE(gc), KM_SLEEP);
5987 if (dp == NULL) {
6001 dp->macinfo = macinfo;
6005 dp->private = lp;
6006 dp->priv_size = lmsize;
6007 dp->mc_list = (struct mcast_addr *)&dp[1];
6009 dp->dip = dip;
6010 bcopy(gc->usbgc_name, dp->name, USBGEM_NAME_LEN);
6018 dp->name, __func__);
6022 if (usb_get_dev_data(dip, &dp->reg_data,
6024 dp->reg_data = NULL;
6028 usb_print_descr_tree(dp->dip, dp->reg_data);
6031 if (usbgem_open_pipes(dp) != USB_SUCCESS) {
6034 dp->name, __func__);
6041 mutex_init(&dp->rxlock, NULL, MUTEX_DRIVER, NULL);
6042 mutex_init(&dp->txlock, NULL, MUTEX_DRIVER, NULL);
6043 cv_init(&dp->rx_drain_cv, NULL, CV_DRIVER, NULL);
6044 cv_init(&dp->tx_drain_cv, NULL, CV_DRIVER, NULL);
6045 rw_init(&dp->dev_state_lock, NULL, RW_DRIVER, NULL);
6046 mutex_init(&dp->link_watcher_lock, NULL, MUTEX_DRIVER, NULL);
6047 cv_init(&dp->link_watcher_wait_cv, NULL, CV_DRIVER, NULL);
6048 sema_init(&dp->hal_op_lock, 1, NULL, SEMA_DRIVER, NULL);
6049 sema_init(&dp->rxfilter_lock, 1, NULL, SEMA_DRIVER, NULL);
6054 dp->ugc = *gc;
6056 dp->mtu = ETHERMTU;
6057 dp->rxmode = 0;
6058 dp->speed = USBGEM_SPD_10; /* default is 10Mbps */
6059 dp->full_duplex = B_FALSE; /* default is half */
6060 dp->flow_control = FLOW_CONTROL_NONE;
6062 dp->nic_state = NIC_STATE_STOPPED;
6063 dp->mac_state = MAC_STATE_STOPPED;
6064 dp->mii_state = MII_STATE_UNKNOWN;
6067 dp->txthr = ETHERMAX; /* tx fifo threshoold */
6068 dp->txmaxdma = 16*4; /* tx max dma burst size */
6069 dp->rxthr = 128; /* rx fifo threshoold */
6070 dp->rxmaxdma = 16*4; /* rx max dma burst size */
6075 usbgem_read_conf(dp);
6078 dp->rx_buf_len = MAXPKTBUF(dp) + dp->ugc.usbgc_rx_header_len;
6083 if (usbgem_hal_reset_chip(dp) != USB_SUCCESS) {
6086 dp->name, __func__);
6093 if (usbgem_hal_attach_chip(dp) != USB_SUCCESS) {
6096 dp->name, __func__);
6101 if (usbgem_alloc_memory(dp) != USB_SUCCESS) {
6107 dp->name,
6108 dp->dev_addr.ether_addr_octet[0],
6109 dp->dev_addr.ether_addr_octet[1],
6110 dp->dev_addr.ether_addr_octet[2],
6111 dp->dev_addr.ether_addr_octet[3],
6112 dp->dev_addr.ether_addr_octet[4],
6113 dp->dev_addr.ether_addr_octet[5]));
6116 dp->cur_addr = dp->dev_addr;
6119 dp->bulkout_timeout =
6120 dp->ugc.usbgc_tx_timeout / drv_usectohz(1000*1000);
6123 usbgem_gld3_init(dp, macp);
6125 usbgem_gld_init(dp, macinfo, ident);
6129 dp->mii_lpable = 0;
6130 dp->mii_advert = 0;
6131 dp->mii_exp = 0;
6132 dp->mii_ctl1000 = 0;
6133 dp->mii_stat1000 = 0;
6135 dp->mii_status_ro = 0;
6136 dp->mii_xstatus_ro = 0;
6138 if (usbgem_mii_probe(dp) != USB_SUCCESS) {
6140 dp->name, __func__);
6145 dp->anadv_autoneg &= BOOLEAN(dp->mii_status & MII_STATUS_CANAUTONEG);
6146 dp->anadv_1000fdx &=
6147 BOOLEAN(dp->mii_xstatus &
6149 dp->anadv_1000hdx &=
6150 BOOLEAN(dp->mii_xstatus &
6152 dp->anadv_100t4 &= BOOLEAN(dp->mii_status & MII_STATUS_100_BASE_T4);
6153 dp->anadv_100fdx &= BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX_FD);
6154 dp->anadv_100hdx &= BOOLEAN(dp->mii_status & MII_STATUS_100_BASEX);
6155 dp->anadv_10fdx &= BOOLEAN(dp->mii_status & MII_STATUS_10_FD);
6156 dp->anadv_10hdx &= BOOLEAN(dp->mii_status & MII_STATUS_10);
6158 if (usbgem_mii_init(dp) != USB_SUCCESS) {
6160 dp->name, __func__);
6169 usbgem_nd_setup(dp);
6172 if (usbgem_kstat_init(dp) != USB_SUCCESS) {
6181 if (ret = mac_register(macp, &dp->mh)) {
6183 dp->name, ret);
6194 dp->name, __func__);
6205 dp->name, __func__);
6210 if (usbgem_mii_start(dp) != USB_SUCCESS) {
6215 if (usbgem_tx_watcher_start(dp)) {
6219 ddi_set_driver_private(dip, (caddr_t)dp);
6221 DPRINTF(2, (CE_CONT, "!%s: %s: return: success", dp->name, __func__));
6223 return (dp);
6226 usbgem_mii_stop(dp);
6233 mac_unregister(dp->mh);
6242 usbgem_nd_cleanup(dp);
6245 kstat_delete(dp->ksp);
6249 usbgem_free_memory(dp);
6252 cv_destroy(&dp->tx_drain_cv);
6253 cv_destroy(&dp->rx_drain_cv);
6254 mutex_destroy(&dp->txlock);
6255 mutex_destroy(&dp->rxlock);
6256 rw_destroy(&dp->dev_state_lock);
6257 mutex_destroy(&dp->link_watcher_lock);
6258 cv_destroy(&dp->link_watcher_wait_cv);
6259 sema_destroy(&dp->hal_op_lock);
6260 sema_destroy(&dp->rxfilter_lock);
6263 (void) usbgem_close_pipes(dp);
6266 usb_client_detach(dp->dip, dp->reg_data);
6276 kmem_free((caddr_t)dp, USBGEM_LOCAL_DATA_SIZE(gc));
6284 struct usbgem_dev *dp;
6286 dp = USBGEM_GET_DEV(dip);
6290 if (mac_unregister(dp->mh) != DDI_SUCCESS) {
6295 if (gld_unregister(dp->macinfo) != DDI_SUCCESS) {
6303 usbgem_tx_watcher_stop(dp);
6306 usbgem_mii_stop(dp);
6309 (void) usbgem_free_memory(dp);
6310 (void) usbgem_close_pipes(dp);
6311 usb_client_detach(dp->dip, dp->reg_data);
6312 dp->reg_data = NULL;
6318 usbgem_nd_cleanup(dp);
6322 kstat_delete(dp->ksp);
6326 mutex_destroy(&dp->txlock);
6327 mutex_destroy(&dp->rxlock);
6328 cv_destroy(&dp->tx_drain_cv);
6329 cv_destroy(&dp->rx_drain_cv);
6330 rw_destroy(&dp->dev_state_lock);
6331 mutex_destroy(&dp->link_watcher_lock);
6332 cv_destroy(&dp->link_watcher_wait_cv);
6333 sema_destroy(&dp->hal_op_lock);
6334 sema_destroy(&dp->rxfilter_lock);
6338 gld_mac_free(dp->macinfo);
6340 kmem_free((caddr_t)(dp->private), dp->priv_size);
6341 kmem_free((caddr_t)dp, USBGEM_LOCAL_DATA_SIZE(&dp->ugc));
6374 struct usbgem_dev *dp;
6376 dp = USBGEM_GET_DEV(dip);
6378 ASSERT(dp != NULL);
6380 if (dp->mac_state != MAC_STATE_DISCONNECTED &&
6381 dp->mac_state != MAC_STATE_STOPPED) {
6382 if (usbgem_hal_stop_chip(dp) != USB_SUCCESS) {
6383 (void) usbgem_hal_reset_chip(dp);