Lines Matching defs:bip
152 #define KIINCR(vn) KIPINCR(bip, vn)
153 #define KIDECR(vn) KIPDECR(bip, vn)
247 bridge_inst_t *bip;
250 if ((bip = bmp->bm_inst) != NULL)
251 atomic_inc_uint(&bip->bi_refs);
253 return (bip);
262 bridge_inst_t *bip;
280 bip = blp->bl_inst;
281 bmp = bip->bi_mac;
283 for (blcmp = list_head(&bip->bi_links); blcmp != NULL;
284 blcmp = list_next(&bip->bi_links, blcmp)) {
338 send_up_messages(bridge_inst_t *bip, mblk_t *mp)
343 rq = bip->bi_control->bs_wq;
411 bridge_inst_t *bip;
415 bip = bridge_find_name(blf->blf_name);
416 if (bip == NULL)
421 rw_enter(&bip->bi_rwlock, RW_READER);
422 if ((bfp = avl_find(&bip->bi_fwd, &match, &where)) == NULL)
423 bfp = avl_nearest(&bip->bi_fwd, where, AVL_AFTER);
425 bfp = AVL_NEXT(&bip->bi_fwd, bfp);
437 rw_exit(&bip->bi_rwlock);
438 bridge_unref(bip);
447 bridge_inst_t *bip;
463 } else if ((bip = mac_to_inst(bmp)) == NULL) {
466 rw_enter(&bip->bi_rwlock, RW_WRITER);
468 for (blp = list_head(&bip->bi_links); blp != NULL;
469 blp = list_next(&bip->bi_links, blp)) {
477 rw_exit(&bip->bi_rwlock);
480 send_up_messages(bip, mlist);
481 bridge_unref(bip);
579 bmac_alloc(bridge_inst_t *bip, bridge_mac_t **bmacp)
594 if (strcmp(bip->bi_name, bmp->bm_name) == 0) {
596 bmp->bm_inst = bip;
628 bnew->bm_inst = bip;
629 (void) strcpy(bnew->bm_name, bip->bi_name);
654 bridge_inst_t *bip;
660 bip = bmp->bm_inst;
661 bip->bi_mac = NULL;
687 inst_free(bridge_inst_t *bip)
689 ASSERT(bip->bi_mac == NULL);
690 rw_destroy(&bip->bi_rwlock);
691 list_destroy(&bip->bi_links);
692 cv_destroy(&bip->bi_linkwait);
693 avl_destroy(&bip->bi_fwd);
694 if (bip->bi_ksp != NULL)
695 kstat_delete(bip->bi_ksp);
696 kmem_free(bip, sizeof (*bip));
702 bridge_inst_t *bip;
704 bip = kmem_zalloc(sizeof (*bip), KM_SLEEP);
705 bip->bi_refs = 1;
706 (void) strcpy(bip->bi_name, bridge);
707 rw_init(&bip->bi_rwlock, NULL, RW_DRIVER, NULL);
708 list_create(&bip->bi_links, sizeof (bridge_link_t),
710 cv_init(&bip->bi_linkwait, NULL, CV_DRIVER, NULL);
711 avl_create(&bip->bi_fwd, fwd_compare, sizeof (bridge_fwd_t),
713 return (bip);
719 bridge_inst_t *bip;
722 for (bip = list_head(&inst_list); bip != NULL;
723 bip = list_next(&inst_list, bip)) {
724 if (!(bip->bi_flags & BIF_SHUTDOWN) &&
725 strcmp(bridge, bip->bi_name) == 0) {
726 atomic_inc_uint(&bip->bi_refs);
732 return (bip);
739 bridge_inst_t *bip, *bipnew;
748 for (bip = list_head(&inst_list); bip != NULL;
749 bip = list_next(&inst_list, bip)) {
750 if (strcmp(bridge, bip->bi_name) == 0)
755 if (bip != NULL && (bip->bi_flags & BIF_SHUTDOWN)) {
760 if (bip == NULL) {
761 bip = bipnew;
763 list_insert_tail(&inst_list, bip);
772 bip->bi_ksp = kstat_setup((kstat_named_t *)&bip->bi_kstats,
773 inst_kstats_list, Dim(inst_kstats_list), bip->bi_name);
775 err = bmac_alloc(bip, &bmp);
776 if ((bip->bi_mac = bmp) == NULL)
790 bip->bi_dev = makedevice(bridge_major, mac_minor(bmp->bm_mh));
791 *bipc = bip;
795 ASSERT(bip->bi_trilldata == NULL);
796 bip->bi_flags |= BIF_SHUTDOWN;
797 bridge_unref(bip);
802 bridge_unref(bridge_inst_t *bip)
804 if (atomic_dec_uint_nv(&bip->bi_refs) == 0) {
805 ASSERT(bip->bi_flags & BIF_SHUTDOWN);
807 if (bip->bi_mac != NULL)
808 bmac_disconnect(bip->bi_mac);
810 list_remove(&inst_list, bip);
813 inst_free(bip);
862 bridge_inst_t *bip = blp->bl_inst;
874 bridge_unref(bip);
881 bridge_inst_t *bip = blp->bl_inst;
884 rw_enter(&bip->bi_rwlock, RW_WRITER);
886 list_remove(&bip->bi_links, blp);
887 rw_exit(&bip->bi_rwlock);
888 if (bip->bi_trilldata != NULL && list_is_empty(&bip->bi_links))
889 cv_broadcast(&bip->bi_linkwait);
912 fwd_find(bridge_inst_t *bip, const uint8_t *addr, uint16_t vlanid)
919 rw_enter(&bip->bi_rwlock, RW_READER);
920 if ((bfp = avl_find(&bip->bi_fwd, &match, NULL)) != NULL) {
924 vbfp = avl_find(&bip->bi_fwd, &match, NULL);
930 rw_exit(&bip->bi_rwlock);
938 bridge_inst_t *bip = bfp->bf_links[0]->bl_inst;
959 bridge_inst_t *bip;
964 bip = bfp->bf_links[0]->bl_inst;
965 rw_enter(&bip->bi_rwlock, RW_WRITER);
968 avl_remove(&bip->bi_fwd, bfp);
972 bfpzero = avl_find(&bip->bi_fwd, bfp, NULL);
976 rw_exit(&bip->bi_rwlock);
979 rw_exit(&bip->bi_rwlock);
985 fwd_insert(bridge_inst_t *bip, bridge_fwd_t *bfp)
990 rw_enter(&bip->bi_rwlock, RW_WRITER);
991 if (!(bip->bi_flags & BIF_SHUTDOWN) &&
992 avl_numnodes(&bip->bi_fwd) < bip->bi_tablemax &&
993 avl_find(&bip->bi_fwd, bfp, &idx) == NULL) {
994 avl_insert(&bip->bi_fwd, bfp, idx);
1001 rw_exit(&bip->bi_rwlock);
1009 bridge_inst_t *bip = blp->bl_inst;
1025 rw_enter(&bip->bi_rwlock, RW_WRITER);
1026 if ((bfp = avl_find(&bip->bi_fwd, &match, NULL)) != NULL) {
1049 avl_remove(&bip->bi_fwd, bfp);
1055 rw_exit(&bip->bi_rwlock);
1067 if ((bip->bi_flags & BIF_SHUTDOWN) ||
1072 rw_enter(&bip->bi_rwlock, RW_WRITER);
1073 if ((bfp = avl_find(&bip->bi_fwd, &match, &idx)) == NULL) {
1085 avl_remove(&bip->bi_fwd, bfp);
1091 (void) avl_find(&bip->bi_fwd, &match, &idx);
1104 avl_insert(&bip->bi_fwd, bfnew, idx);
1109 rw_exit(&bip->bi_rwlock);
1146 bridge_inst_t *bip;
1177 bip = blp->bl_inst;
1178 rw_enter(&bip->bi_rwlock, RW_WRITER);
1179 bfnext = avl_first(&bip->bi_fwd);
1181 bfnext = AVL_NEXT(&bip->bi_fwd, bfp);
1196 avl_remove(&bip->bi_fwd, bfp);
1201 rw_exit(&bip->bi_rwlock);
1223 shutdown_inst(bridge_inst_t *bip)
1229 if (bip->bi_flags & BIF_SHUTDOWN) {
1240 bip->bi_flags |= BIF_SHUTDOWN;
1243 bip->bi_control = NULL;
1245 rw_enter(&bip->bi_rwlock, RW_READER);
1246 blnext = list_head(&bip->bi_links);
1248 blnext = list_next(&bip->bi_links, blp);
1255 while ((bfp = avl_first(&bip->bi_fwd)) != NULL) {
1257 rw_exit(&bip->bi_rwlock);
1260 rw_enter(&bip->bi_rwlock, RW_READER);
1262 rw_exit(&bip->bi_rwlock);
1269 while (bip->bi_trilldata != NULL && !list_is_empty(&bip->bi_links))
1270 cv_wait(&bip->bi_linkwait, &inst_lock);
1272 if (bip->bi_trilldata != NULL)
1273 trill_brdstr_fn(bip->bi_trilldata, bip);
1275 bridge_unref(bip);
1294 bridge_inst_t *bip;
1298 for (bip = list_head(&inst_list); bip != NULL;
1299 bip = list_next(&inst_list, bip)) {
1300 ASSERT(bip->bi_trilldata == NULL);
1301 rw_enter(&bip->bi_rwlock, RW_READER);
1302 for (blp = list_head(&bip->bi_links); blp != NULL;
1303 blp = list_next(&bip->bi_links, blp)) {
1306 rw_exit(&bip->bi_rwlock);
1329 bridge_inst_t *bip;
1332 bip = bridge_find_name(bridge);
1333 if (bip != NULL) {
1334 ASSERT(bip->bi_trilldata == NULL && ptr != NULL);
1335 bip->bi_trilldata = ptr;
1337 return (bip);
1341 bridge_trill_brunref(bridge_inst_t *bip)
1343 ASSERT(bip->bi_trilldata != NULL);
1344 bip->bi_trilldata = NULL;
1345 bridge_unref(bip);
1355 bridge_trill_lnref(bridge_inst_t *bip, datalink_id_t linkid, void *ptr)
1360 rw_enter(&bip->bi_rwlock, RW_READER);
1361 for (blp = list_head(&bip->bi_links); blp != NULL;
1362 blp = list_next(&bip->bi_links, blp)) {
1372 rw_exit(&bip->bi_rwlock);
1403 bridge_inst_t *bip;
1416 for (bip = list_head(&inst_list); bip != NULL;
1417 bip = list_next(&inst_list, bip)) {
1418 if (bip->bi_flags & BIF_SHUTDOWN)
1420 rw_enter(&bip->bi_rwlock, RW_WRITER);
1422 if (avl_numnodes(&bip->bi_fwd) > bip->bi_tablemax)
1423 bip->bi_tshift++;
1425 bip->bi_tshift = 0;
1426 if ((age_limit = bridge_fwd_age >> bip->bi_tshift) == 0) {
1427 if (bip->bi_tshift != 0)
1428 bip->bi_tshift--;
1431 bfnext = avl_first(&bip->bi_fwd);
1433 bfnext = AVL_NEXT(&bip->bi_fwd, bfp);
1437 avl_remove(&bip->bi_fwd, bfp);
1442 for (blp = list_head(&bip->bi_links); blp != NULL;
1443 blp = list_next(&bip->bi_links, blp)) {
1450 rw_exit(&bip->bi_rwlock);
1546 bridge_inst_t *bip;
1558 if ((bip = bsp->bs_inst) != NULL)
1559 shutdown_inst(bip);
1562 if (bip != NULL)
1563 bridge_unref(bip);
1572 bridge_inst_t *bip = blp->bl_inst;
1586 if ((bfp = fwd_find(bip, saddr, vlanid)) != NULL) {
1669 if (!fwd_insert(bip, bfpnew))
1865 bridge_inst_t *bip = blp->bl_inst;
1887 if ((bfp = fwd_find(bip, daddr, vlanid)) != NULL) {
2040 rw_enter(&bip->bi_rwlock, RW_READER);
2041 for (blpnext = list_head(&bip->bi_links); blpnext != NULL;
2042 blpnext = list_next(&bip->bi_links, blpnext)) {
2050 rw_exit(&bip->bi_rwlock);
2052 rw_enter(&bip->bi_rwlock, RW_READER);
2053 for (blpnext = list_next(&bip->bi_links, blpsend);
2055 blpnext = list_next(&bip->bi_links, blpnext)) {
2063 rw_exit(&bip->bi_rwlock);
2183 bridge_inst_t *bip = blp->bl_inst;
2184 bridge_mac_t *bmp = bip->bi_mac;
2189 rw_enter(&bip->bi_rwlock, RW_READER);
2190 if (list_prev(&bip->bi_links, blp) == NULL &&
2191 list_next(&bip->bi_links, blp) == NULL) {
2200 rw_exit(&bip->bi_rwlock);
2201 send_up_messages(bip, mlist);
2217 bridge_inst_t *bip = blp->bl_inst;
2218 bridge_mac_t *bmp = bip->bi_mac;
2446 bridge_inst_t *bip = blp->bl_inst;
2447 bridge_mac_t *bmp = bip->bi_mac;
2556 bridge_inst_t *bip = blp->bl_inst; /* used by macros */
2608 bridge_inst_t *bip = blp->bl_inst; /* used by macros */
2640 bridge_inst_t *bip = blp->bl_inst;
2649 rw_enter(&bip->bi_rwlock, RW_WRITER);
2650 bfnext = avl_first(&bip->bi_fwd);
2652 bfnext = AVL_NEXT(&bip->bi_fwd, bfp);
2670 avl_remove(&bip->bi_fwd, bfp);
2674 rw_exit(&bip->bi_rwlock);
2714 bridge_inst_t *bip;
2728 bip = blp->bl_inst;
2729 rw_enter(&bip->bi_rwlock, RW_WRITER);
2730 for (blcmp = list_head(&bip->bi_links); blcmp != NULL;
2731 blcmp = list_next(&bip->bi_links, blcmp)) {
2753 for (blcmp = list_head(&bip->bi_links); blcmp != NULL;
2754 blcmp = list_next(&bip->bi_links, blcmp)) {
2758 bmp = bip->bi_mac;
2763 rw_exit(&bip->bi_rwlock);
2772 bridge_inst_t *bip, *bipt;
2789 bip = bsp->bs_inst;
2839 bmp = bip->bi_mac;
2840 if (list_is_empty(&bip->bi_links)) {
2851 (void) snprintf(kstatname, sizeof (kstatname), "%s-%s", bip->bi_name,
2867 atomic_inc_uint(&bip->bi_refs);
2868 blp->bl_inst = bip;
2913 rw_enter(&bip->bi_rwlock, RW_WRITER);
2914 list_insert_tail(&bip->bi_links, blp);
2924 rw_exit(&bip->bi_rwlock);
2925 send_up_messages(bip, mlist);
2960 bridge_inst_t *bip;
2969 bip = bsp->bs_inst;
2977 rw_enter(&bip->bi_rwlock, RW_READER);
2979 for (blp = list_head(&bip->bi_links); blp != NULL;
2980 blp = list_next(&bip->bi_links, blp)) {
2996 for (blp = list_head(&bip->bi_links); blp != NULL;
2997 blp = list_next(&bip->bi_links, blp)) {
3003 for (blp = list_head(&bip->bi_links); blp != NULL;
3004 blp = list_next(&bip->bi_links, blp)) {
3009 bmp = bip->bi_mac;
3020 for (blp = list_head(&bip->bi_links); blp != NULL;
3021 blp = list_next(&bip->bi_links, blp)) {
3030 bmp = bip->bi_mac;
3037 rw_exit(&bip->bi_rwlock);
3038 send_up_messages(bip, mlist);
3052 enter_link(bridge_inst_t *bip, datalink_id_t linkid)
3056 rw_enter(&bip->bi_rwlock, RW_READER);
3057 for (blp = list_head(&bip->bi_links); blp != NULL;
3058 blp = list_next(&bip->bi_links, blp)) {
3069 bridge_inst_t *bip;
3099 rc = bridge_create(bnb->bnb_linkid, bnb->bnb_name, &bip, cr);
3103 rw_enter(&bip->bi_rwlock, RW_WRITER);
3104 if (bip->bi_control != NULL) {
3105 rw_exit(&bip->bi_rwlock);
3106 bridge_unref(bip);
3109 atomic_inc_uint(&bip->bi_refs);
3110 bsp->bs_inst = bip; /* stream holds reference */
3111 bip->bi_control = bsp;
3112 rw_exit(&bip->bi_rwlock);
3119 if ((bip = bsp->bs_inst) == NULL ||
3134 if ((bip = bsp->bs_inst) == NULL ||
3151 if ((bip = bsp->bs_inst) == NULL ||
3156 if ((blp = enter_link(bip, bss->bss_linkid)) == NULL) {
3162 rw_exit(&bip->bi_rwlock);
3169 if ((bip = bsp->bs_inst) == NULL ||
3176 if ((blp = enter_link(bip, bsv->bsv_linkid)) == NULL) {
3187 rw_exit(&bip->bi_rwlock);
3194 if ((bip = bsp->bs_inst) == NULL ||
3201 if ((blp = enter_link(bip, bve->bve_linkid)) == NULL) {
3221 rw_exit(&bip->bi_rwlock);
3231 if ((bip = bsp->bs_inst) == NULL ||
3236 rw_enter(&bip->bi_rwlock, RW_WRITER);
3241 for (blp = list_head(&bip->bi_links); blp != NULL;
3242 blp = list_next(&bip->bi_links, blp)) {
3249 rw_exit(&bip->bi_rwlock);
3255 bfnext = avl_first(&bip->bi_fwd);
3257 bfnext = AVL_NEXT(&bip->bi_fwd, bfp);
3274 avl_remove(&bip->bi_fwd, bfp);
3278 rw_exit(&bip->bi_rwlock);
3290 if ((bip = bsp->bs_inst) == NULL ||
3294 bip->bi_tablemax = *(uint32_t *)mp->b_cont->b_rptr;