Lines Matching refs:ctl

87 static void consider_resize(struct nh_control *ctl, uint32_t new_gr_buckets,
138 find_nhgrp(struct nh_control *ctl, const struct nhgrp_priv *key) in find_nhgrp() argument
142 NHOPS_RLOCK(ctl); in find_nhgrp()
143 CHT_SLIST_FIND_BYOBJ(&ctl->gr_head, mpath, key, priv_ret); in find_nhgrp()
150 NHOPS_RUNLOCK(ctl); in find_nhgrp()
156 link_nhgrp(struct nh_control *ctl, struct nhgrp_priv *grp_priv) in link_nhgrp() argument
161 NHOPS_WLOCK(ctl); in link_nhgrp()
163 new_num_buckets = CHT_SLIST_GET_RESIZE_BUCKETS(&ctl->gr_head); in link_nhgrp()
164 new_num_items = bitmask_get_resize_items(&ctl->nh_idx_head); in link_nhgrp()
166 if (bitmask_alloc_idx(&ctl->nh_idx_head, &idx) != 0) { in link_nhgrp()
167 NHOPS_WUNLOCK(ctl); in link_nhgrp()
168 FIB_RH_LOG(LOG_DEBUG, ctl->ctl_rh, "Unable to allocate nhg index"); in link_nhgrp()
169 consider_resize(ctl, new_num_buckets, new_num_items); in link_nhgrp()
174 grp_priv->nh_control = ctl; in link_nhgrp()
175 CHT_SLIST_INSERT_HEAD(&ctl->gr_head, mpath, grp_priv); in link_nhgrp()
177 NHOPS_WUNLOCK(ctl); in link_nhgrp()
181 FIB_RH_LOG(LOG_DEBUG2, ctl->ctl_rh, "linked %s", in link_nhgrp()
184 consider_resize(ctl, new_num_buckets, new_num_items); in link_nhgrp()
190 unlink_nhgrp(struct nh_control *ctl, struct nhgrp_priv *key) in unlink_nhgrp() argument
195 NHOPS_WLOCK(ctl); in unlink_nhgrp()
197 CHT_SLIST_REMOVE(&ctl->gr_head, mpath, key, nhg_priv_ret); in unlink_nhgrp()
200 FIB_RH_LOG(LOG_DEBUG, ctl->ctl_rh, "Unable to find nhg"); in unlink_nhgrp()
201 NHOPS_WUNLOCK(ctl); in unlink_nhgrp()
206 bitmask_free_idx(&ctl->nh_idx_head, idx); in unlink_nhgrp()
210 NHOPS_WUNLOCK(ctl); in unlink_nhgrp()
215 FIB_RH_LOG(LOG_DEBUG2, ctl->ctl_rh, "unlinked idx#%d %s", idx, in unlink_nhgrp()
227 consider_resize(struct nh_control *ctl, uint32_t new_gr_bucket, uint32_t new_idx_items) in consider_resize() argument
250 FIB_RH_LOG(LOG_DEBUG, ctl->ctl_rh, in consider_resize()
256 NHOPS_WLOCK(ctl); in consider_resize()
258 CHT_SLIST_RESIZE(&ctl->gr_head, mpath, gr_ptr, new_gr_bucket); in consider_resize()
261 if (bitmask_copy(&ctl->nh_idx_head, gr_idx_ptr, new_idx_items) == 0) in consider_resize()
262 bitmask_swap(&ctl->nh_idx_head, gr_idx_ptr, new_idx_items, &old_idx_ptr); in consider_resize()
264 NHOPS_WUNLOCK(ctl); in consider_resize()
276 nhgrp_ctl_alloc_default(struct nh_control *ctl, int malloc_flags) in nhgrp_ctl_alloc_default() argument
289 FIB_RH_LOG(LOG_WARNING, ctl->ctl_rh, "multipath init failed"); in nhgrp_ctl_alloc_default()
293 NHOPS_WLOCK(ctl); in nhgrp_ctl_alloc_default()
295 if (ctl->gr_head.hash_size == 0) { in nhgrp_ctl_alloc_default()
297 CHT_SLIST_INIT(&ctl->gr_head, cht_ptr, num_buckets); in nhgrp_ctl_alloc_default()
298 NHOPS_WUNLOCK(ctl); in nhgrp_ctl_alloc_default()
301 NHOPS_WUNLOCK(ctl); in nhgrp_ctl_alloc_default()
305 FIB_RH_LOG(LOG_DEBUG, ctl->ctl_rh, "multipath init done"); in nhgrp_ctl_alloc_default()
311 nhgrp_ctl_init(struct nh_control *ctl) in nhgrp_ctl_init() argument
318 CHT_SLIST_INIT(&ctl->gr_head, NULL, 0); in nhgrp_ctl_init()
323 nhgrp_ctl_free(struct nh_control *ctl) in nhgrp_ctl_free() argument
325 if (ctl->gr_head.ptr != NULL) in nhgrp_ctl_free()
326 free(ctl->gr_head.ptr, M_NHOP); in nhgrp_ctl_free()
330 nhgrp_ctl_unlink_all(struct nh_control *ctl) in nhgrp_ctl_unlink_all() argument
334 NHOPS_WLOCK_ASSERT(ctl); in nhgrp_ctl_unlink_all()
336 CHT_SLIST_FOREACH(&ctl->gr_head, mpath, nhg_priv) { in nhgrp_ctl_unlink_all()
339 FIB_RH_LOG(LOG_DEBUG2, ctl->ctl_rh, "marking %s unlinked", in nhgrp_ctl_unlink_all()