Lines Matching refs:wp

393 	eib_wqe_pool_t *wp = ss->ei_tx;  in eib_rsrc_txwqes_needed()  local
397 mutex_enter(&wp->wp_lock); in eib_rsrc_txwqes_needed()
398 if ((wp->wp_status & EIB_TXWQE_SHORT) == 0) { in eib_rsrc_txwqes_needed()
399 wp->wp_status |= EIB_TXWQE_SHORT; in eib_rsrc_txwqes_needed()
400 cv_broadcast(&wp->wp_cv); in eib_rsrc_txwqes_needed()
402 mutex_exit(&wp->wp_lock); in eib_rsrc_txwqes_needed()
431 eib_wqe_pool_t *wp = wqe->qe_pool; in eib_rsrc_rxpool_low() local
440 mutex_enter(&wp->wp_lock); in eib_rsrc_rxpool_low()
442 if (wp->wp_nfree <= EIB_NFREE_RWQES_LOW) { in eib_rsrc_rxpool_low()
443 wp->wp_status |= (EIB_RXWQE_SHORT); in eib_rsrc_rxpool_low()
444 } else if (wp->wp_nfree >= EIB_NFREE_RWQES_HWM) { in eib_rsrc_rxpool_low()
445 wp->wp_status &= (~EIB_RXWQE_SHORT); in eib_rsrc_rxpool_low()
448 if ((wp->wp_status & EIB_RXWQE_SHORT) == EIB_RXWQE_SHORT) in eib_rsrc_rxpool_low()
451 mutex_exit(&wp->wp_lock); in eib_rsrc_rxpool_low()
851 eib_wqe_pool_t *wp; in eib_rsrc_init_wqe_pool() local
861 wp = kmem_zalloc(sizeof (eib_wqe_pool_t), KM_SLEEP); in eib_rsrc_init_wqe_pool()
863 wp->wp_wqe = (eib_wqe_t *)kmem_zalloc(wp_wqesz, KM_SLEEP); in eib_rsrc_init_wqe_pool()
864 wp->wp_memsz = EIB_WQES_PER_POOL * bufsz; in eib_rsrc_init_wqe_pool()
865 wp->wp_vaddr = (ib_vaddr_t)(uintptr_t)kmem_zalloc(wp->wp_memsz, in eib_rsrc_init_wqe_pool()
867 wp->wp_ss = ss; in eib_rsrc_init_wqe_pool()
868 wp->wp_type = wp_type; in eib_rsrc_init_wqe_pool()
869 wp->wp_nfree_lwm = (wp_type == EIB_WP_TYPE_TX) ? in eib_rsrc_init_wqe_pool()
878 mutex_init(&wp->wp_lock, NULL, MUTEX_DRIVER, NULL); in eib_rsrc_init_wqe_pool()
879 cv_init(&wp->wp_cv, NULL, CV_DEFAULT, NULL); in eib_rsrc_init_wqe_pool()
881 wp->wp_nfree = EIB_WQES_PER_POOL; in eib_rsrc_init_wqe_pool()
882 wp->wp_free_blks = (EIB_BLKS_PER_POOL >= 64) ? (~0) : in eib_rsrc_init_wqe_pool()
885 wp->wp_free_wqes[i] = ~0; in eib_rsrc_init_wqe_pool()
887 *wpp = wp; in eib_rsrc_init_wqe_pool()
894 eib_wqe_pool_t *wp; in eib_rsrc_fini_wqe_pool() local
898 wp = *wpp; in eib_rsrc_fini_wqe_pool()
901 cv_destroy(&wp->wp_cv); in eib_rsrc_fini_wqe_pool()
902 mutex_destroy(&wp->wp_lock); in eib_rsrc_fini_wqe_pool()
904 kmem_free((void *)(uintptr_t)(wp->wp_vaddr), wp->wp_memsz); in eib_rsrc_fini_wqe_pool()
905 kmem_free(wp->wp_wqe, EIB_WQES_PER_POOL * sizeof (eib_wqe_t)); in eib_rsrc_fini_wqe_pool()
906 kmem_free(wp, sizeof (eib_wqe_pool_t)); in eib_rsrc_fini_wqe_pool()
913 eib_rsrc_ok_to_free_pool(eib_t *ss, eib_wqe_pool_t *wp, boolean_t force) in eib_rsrc_ok_to_free_pool() argument
926 ASSERT(wp != NULL); in eib_rsrc_ok_to_free_pool()
935 mutex_enter(&wp->wp_lock); in eib_rsrc_ok_to_free_pool()
943 if (wp->wp_free_blks != free_blks) { in eib_rsrc_ok_to_free_pool()
944 mutex_exit(&wp->wp_lock); in eib_rsrc_ok_to_free_pool()
953 if (wp->wp_free_wqes[i] != (~0)) { in eib_rsrc_ok_to_free_pool()
954 mutex_exit(&wp->wp_lock); in eib_rsrc_ok_to_free_pool()
959 mutex_exit(&wp->wp_lock); in eib_rsrc_ok_to_free_pool()
966 eib_rsrc_grab_wqes(eib_t *ss, eib_wqe_pool_t *wp, eib_wqe_t **wqes, in eib_rsrc_grab_wqes() argument
974 ASSERT(wp != NULL); in eib_rsrc_grab_wqes()
977 mutex_enter(&wp->wp_lock); in eib_rsrc_grab_wqes()
984 if (wp->wp_nfree <= wp->wp_nfree_lwm) in eib_rsrc_grab_wqes()
986 else if ((wp->wp_nfree - n_req) < wp->wp_nfree_lwm) in eib_rsrc_grab_wqes()
987 n_req = wp->wp_nfree - wp->wp_nfree_lwm; in eib_rsrc_grab_wqes()
994 if (wp->wp_free_blks == 0) in eib_rsrc_grab_wqes()
1000 blk = EIB_FIND_LSB_SET(wp->wp_free_blks); in eib_rsrc_grab_wqes()
1002 ndx = EIB_FIND_LSB_SET(wp->wp_free_wqes[blk]); in eib_rsrc_grab_wqes()
1008 wp->wp_free_wqes[blk] &= (~((uint64_t)1 << ndx)); in eib_rsrc_grab_wqes()
1014 if (wp->wp_free_wqes[blk] == 0) in eib_rsrc_grab_wqes()
1015 wp->wp_free_blks &= (~((uint64_t)1 << blk)); in eib_rsrc_grab_wqes()
1021 wqes[n_allocd] = &(wp->wp_wqe[wqe_ndx]); in eib_rsrc_grab_wqes()
1024 wp->wp_nfree -= n_allocd; in eib_rsrc_grab_wqes()
1026 mutex_exit(&wp->wp_lock); in eib_rsrc_grab_wqes()
1040 eib_rsrc_return_wqes(eib_t *ss, eib_wqe_pool_t *wp, eib_wqe_t **wqes, in eib_rsrc_return_wqes() argument
1048 ASSERT(wp != NULL); in eib_rsrc_return_wqes()
1051 mutex_enter(&wp->wp_lock); in eib_rsrc_return_wqes()
1074 wp->wp_free_wqes[blk] |= ((uint64_t)1 << ndx); in eib_rsrc_return_wqes()
1081 wp->wp_free_blks |= ((uint64_t)1 << blk); in eib_rsrc_return_wqes()
1084 wp->wp_nfree += n_freed; in eib_rsrc_return_wqes()
1090 if ((wp->wp_type == EIB_WP_TYPE_TX) && in eib_rsrc_return_wqes()
1091 ((wp->wp_nfree - n_freed) < EIB_NFREE_SWQES_HWM) && in eib_rsrc_return_wqes()
1092 (wp->wp_nfree >= EIB_NFREE_SWQES_HWM)) { in eib_rsrc_return_wqes()
1093 cv_broadcast(&wp->wp_cv); in eib_rsrc_return_wqes()
1096 mutex_exit(&wp->wp_lock); in eib_rsrc_return_wqes()
1102 eib_wqe_pool_t *wp = ss->ei_tx; in eib_rb_rsrc_setup_txbufs() local
1109 if (wp == NULL) in eib_rb_rsrc_setup_txbufs()
1118 if (eib_rsrc_ok_to_free_pool(ss, wp, force)) { in eib_rb_rsrc_setup_txbufs()
1122 wqe = &wp->wp_wqe[i]; in eib_rb_rsrc_setup_txbufs()
1136 if (wp->wp_mr) { in eib_rb_rsrc_setup_txbufs()
1138 wp->wp_mr)) != IBT_SUCCESS) { in eib_rb_rsrc_setup_txbufs()
1143 wp->wp_mr = NULL; in eib_rb_rsrc_setup_txbufs()