Lines Matching defs:sdev
269 simnet_dev_t *sdev;
272 for (sdev = list_head(&simnet_dev_list); sdev != NULL;
273 sdev = list_next(&simnet_dev_list, sdev)) {
274 if (!(sdev->sd_flags & SDF_SHUTDOWN) &&
275 (sdev->sd_link_id == link_id)) {
276 atomic_inc_32(&sdev->sd_refcount);
277 return (sdev);
285 simnet_wifidev_free(simnet_dev_t *sdev)
287 simnet_wifidev_t *wdev = sdev->sd_wifidev;
298 simnet_dev_unref(simnet_dev_t *sdev)
301 ASSERT(sdev->sd_refcount > 0);
302 if (atomic_dec_32_nv(&sdev->sd_refcount) != 0)
305 if (sdev->sd_mh != NULL)
306 (void) mac_unregister(sdev->sd_mh);
308 if (sdev->sd_wifidev != NULL) {
309 ASSERT(sdev->sd_type == DL_WIFI);
310 simnet_wifidev_free(sdev);
313 mutex_destroy(&sdev->sd_instlock);
314 cv_destroy(&sdev->sd_threadwait);
315 kmem_free(sdev->sd_mcastaddrs, ETHERADDRL * sdev->sd_mcastaddr_count);
316 kmem_free(sdev, sizeof (*sdev));
321 simnet_init_wifi(simnet_dev_t *sdev, mac_register_t *mac)
326 sdev->sd_wifidev = kmem_zalloc(sizeof (simnet_wifidev_t), KM_NOSLEEP);
327 if (sdev->sd_wifidev == NULL)
330 sdev->sd_wifidev->swd_sdev = sdev;
331 sdev->sd_wifidev->swd_linkstatus = WL_NOTCONNECTED;
338 err = mac_register(mac, &sdev->sd_mh);
343 simnet_init_ether(simnet_dev_t *sdev, mac_register_t *mac)
350 err = mac_register(mac, &sdev->sd_mh);
355 simnet_init_mac(simnet_dev_t *sdev)
363 mac->m_driver = sdev;
366 mac->m_src_addr = sdev->sd_mac_addr;
370 if (sdev->sd_type == DL_ETHER)
371 err = simnet_init_ether(sdev, mac);
372 else if (sdev->sd_type == DL_WIFI)
373 err = simnet_init_wifi(sdev, mac);
386 simnet_dev_t *sdev;
390 sdev = kmem_zalloc(sizeof (*sdev), KM_NOSLEEP);
391 if (sdev == NULL)
398 kmem_free(sdev, sizeof (*sdev));
402 sdev->sd_type = create_arg->sic_type;
403 sdev->sd_link_id = create_arg->sic_link_id;
404 sdev->sd_zoneid = crgetzoneid(cred);
405 sdev->sd_refcount++;
406 mutex_init(&sdev->sd_instlock, NULL, MUTEX_DRIVER, NULL);
407 cv_init(&sdev->sd_threadwait, NULL, CV_DRIVER, NULL);
413 (void) random_get_pseudo_bytes(sdev->sd_mac_addr, ETHERADDRL);
415 sdev->sd_mac_addr[0] = (sdev->sd_mac_addr[0] & ~1) | 2;
416 sdev->sd_mac_len = ETHERADDRL;
418 (void) memcpy(sdev->sd_mac_addr, create_arg->sic_mac_addr,
420 sdev->sd_mac_len = create_arg->sic_mac_len;
423 if ((err = simnet_init_mac(sdev)) != 0) {
424 simnet_dev_unref(sdev);
428 if ((err = dls_devnet_create(sdev->sd_mh, sdev->sd_link_id,
430 simnet_dev_unref(sdev);
434 mac_link_update(sdev->sd_mh, LINK_STATE_UP);
435 mac_tx_update(sdev->sd_mh);
436 list_insert_tail(&simnet_dev_list, sdev);
439 (void) memcpy(create_arg->sic_mac_addr, sdev->sd_mac_addr,
440 sdev->sd_mac_len);
441 create_arg->sic_mac_len = sdev->sd_mac_len;
449 simnet_remove_peer(simnet_dev_t *sdev)
455 if ((sdev_peer = sdev->sd_peer_dev) != NULL) {
456 ASSERT(sdev == sdev_peer->sd_peer_dev);
458 sdev->sd_peer_dev = NULL;
462 simnet_dev_unref(sdev);
473 simnet_dev_t *sdev;
477 if ((sdev = simnet_dev_lookup(modify_arg->sim_link_id)) == NULL) {
482 if (sdev->sd_zoneid != crgetzoneid(cred)) {
484 simnet_dev_unref(sdev);
488 if (sdev->sd_link_id == modify_arg->sim_peer_link_id) {
491 simnet_dev_unref(sdev);
495 if (sdev->sd_peer_dev != NULL && sdev->sd_peer_dev->sd_link_id ==
499 simnet_dev_unref(sdev);
508 simnet_dev_unref(sdev);
511 if (sdev_peer->sd_zoneid != sdev->sd_zoneid) {
514 simnet_dev_unref(sdev);
521 (void) simnet_remove_peer(sdev);
527 sdev_peer->sd_peer_dev = sdev;
528 sdev->sd_peer_dev = sdev_peer;
531 /* Release sdev lookup reference */
532 simnet_dev_unref(sdev);
544 simnet_dev_t *sdev;
551 if ((sdev = simnet_dev_lookup(delete_arg->sid_link_id)) == NULL) {
556 if (sdev->sd_zoneid != crgetzoneid(cred)) {
558 simnet_dev_unref(sdev);
562 if ((err = dls_devnet_destroy(sdev->sd_mh, &tmpid, B_TRUE)) != 0) {
564 simnet_dev_unref(sdev);
568 ASSERT(sdev->sd_link_id == tmpid);
570 peerid = simnet_remove_peer(sdev);
573 mutex_enter(&sdev->sd_instlock);
574 sdev->sd_flags |= SDF_SHUTDOWN;
576 while (sdev->sd_threadcount > 0) {
577 if (cv_wait_sig(&sdev->sd_threadwait,
578 &sdev->sd_instlock) == 0) {
580 mutex_exit(&sdev->sd_instlock);
585 mutex_exit(&sdev->sd_instlock);
588 if ((err = mac_disable(sdev->sd_mh)) != 0)
591 list_remove(&simnet_dev_list, sdev);
593 simnet_dev_unref(sdev); /* Release lookup ref */
594 /* Releasing the last ref performs sdev/mem free */
595 simnet_dev_unref(sdev);
599 (void) dls_devnet_create(sdev->sd_mh, sdev->sd_link_id,
601 sdev->sd_flags &= ~SDF_SHUTDOWN;
603 ASSERT(sdev->sd_peer_dev == NULL);
608 sdev_peer->sd_peer_dev = sdev;
609 sdev->sd_peer_dev = sdev_peer;
616 simnet_dev_unref(sdev);
628 simnet_dev_t *sdev;
635 if ((sdev = simnet_dev_lookup(info_arg->sii_link_id)) == NULL) {
640 (void) memcpy(info_arg->sii_mac_addr, sdev->sd_mac_addr,
641 sdev->sd_mac_len);
642 info_arg->sii_mac_len = sdev->sd_mac_len;
643 info_arg->sii_type = sdev->sd_type;
644 if (sdev->sd_peer_dev != NULL)
645 info_arg->sii_peer_link_id = sdev->sd_peer_dev->sd_link_id;
647 simnet_dev_unref(sdev);
652 simnet_thread_ref(simnet_dev_t *sdev)
654 mutex_enter(&sdev->sd_instlock);
655 if (sdev->sd_flags & SDF_SHUTDOWN ||
656 !(sdev->sd_flags & SDF_STARTED)) {
657 mutex_exit(&sdev->sd_instlock);
660 sdev->sd_threadcount++;
661 mutex_exit(&sdev->sd_instlock);
666 simnet_thread_unref(simnet_dev_t *sdev)
668 mutex_enter(&sdev->sd_instlock);
669 if (--sdev->sd_threadcount == 0)
670 cv_broadcast(&sdev->sd_threadwait);
671 mutex_exit(&sdev->sd_instlock);
679 simnet_dev_t *sdev;
681 sdev = (simnet_dev_t *)mp->b_next;
685 if (mac_header_info(sdev->sd_mh, mp, &hdr_info) != 0) {
687 sdev->sd_stats.recv_errors++;
696 if (!sdev->sd_promisc &&
699 bcmp(hdr_info.mhi_daddr, sdev->sd_mac_addr,
704 mutex_enter(&sdev->sd_instlock);
705 if (mcastaddr_lookup(sdev, hdr_info.mhi_daddr) ==
707 mutex_exit(&sdev->sd_instlock);
711 mutex_exit(&sdev->sd_instlock);
715 sdev->sd_stats.recv_count++;
716 sdev->sd_stats.rbytes += msgdsize(mp);
717 mac_rx(sdev->sd_mh, NULL, mp);
719 simnet_thread_unref(sdev);
725 simnet_dev_t *sdev = arg;
731 if ((sdev_rx = sdev->sd_peer_dev) == NULL) {
756 if (!simnet_thread_ref(sdev)) {
777 sdev->sd_stats.xmit_errors++;
793 sdev->sd_stats.xmit_errors++;
800 sdev->sd_stats.xmit_errors++;
815 sdev->sd_stats.xmit_count++;
816 sdev->sd_stats.obytes += len;
825 simnet_thread_unref(sdev);
831 simnet_wifi_ioctl(simnet_dev_t *sdev, mblk_t *mp)
834 simnet_wifidev_t *wdev = sdev->sd_wifidev;
850 simnet_dev_t *sdev = arg;
856 if (sdev->sd_type != DL_WIFI) {
885 rc = simnet_wifi_ioctl(sdev, mp1);
893 simnet_dev_t *sdev = arg;
895 ASSERT(sdev->sd_mh != NULL);
905 if (sdev->sd_flags & SDF_STARTED)
918 *val = sdev->sd_stats.xmit_count;
921 *val = sdev->sd_stats.obytes;
924 *val = sdev->sd_stats.recv_errors;
927 *val = sdev->sd_stats.xmit_errors;
930 *val = sdev->sd_stats.rbytes;
933 *val = sdev->sd_stats.recv_count;
958 simnet_dev_t *sdev = arg;
960 sdev->sd_flags |= SDF_STARTED;
967 simnet_dev_t *sdev = arg;
969 sdev->sd_flags &= ~SDF_STARTED;
975 simnet_dev_t *sdev = arg;
977 sdev->sd_promisc = on;
986 mcastaddr_lookup(simnet_dev_t *sdev, const uint8_t *addrp)
991 ASSERT(MUTEX_HELD(&sdev->sd_instlock));
992 maddrptr = sdev->sd_mcastaddrs;
993 for (idx = 0; idx < sdev->sd_mcastaddr_count; idx++) {
1006 simnet_dev_t *sdev = arg;
1015 prevsize = sdev->sd_mcastaddr_count * ETHERADDRL;
1019 mutex_enter(&sdev->sd_instlock);
1020 if (prevsize != (sdev->sd_mcastaddr_count * ETHERADDRL)) {
1021 mutex_exit(&sdev->sd_instlock);
1026 maddrptr = mcastaddr_lookup(sdev, addrp);
1031 len = maddrptr - sdev->sd_mcastaddrs;
1032 (void) memcpy(newbuf, sdev->sd_mcastaddrs, len);
1037 sdev->sd_mcastaddr_count--;
1040 (void) memcpy(newbuf, sdev->sd_mcastaddrs, prevsize);
1042 sdev->sd_mcastaddr_count++;
1045 mutex_exit(&sdev->sd_instlock);
1052 kmem_free(sdev->sd_mcastaddrs, prevsize);
1053 sdev->sd_mcastaddrs = newbuf;
1054 mutex_exit(&sdev->sd_instlock);
1061 simnet_dev_t *sdev = arg;
1063 (void) memcpy(sdev->sd_mac_addr, macaddr, ETHERADDRL);
1145 simnet_set_priv_prop(simnet_dev_t *sdev, const char *pr_name,
1148 simnet_wifidev_t *wdev = sdev->sd_wifidev;
1171 simnet_dev_t *sdev = arg;
1172 simnet_wifidev_t *wdev = sdev->sd_wifidev;
1180 return (mac_maxsdu_update(sdev->sd_mh, mtu));
1187 if (sdev->sd_type == DL_ETHER)
1224 err = simnet_set_priv_prop(sdev, pr_name,
1235 simnet_get_priv_prop(simnet_dev_t *sdev, const char *pr_name,
1238 simnet_wifidev_t *wdev = sdev->sd_wifidev;
1260 simnet_dev_t *sdev = arg;
1261 simnet_wifidev_t *wdev = sdev->sd_wifidev;
1265 if (sdev->sd_type == DL_ETHER)
1312 err = simnet_get_priv_prop(sdev, pr_name, wldp_length,
1342 simnet_dev_t *sdev = arg;
1344 if (sdev->sd_type == DL_ETHER)