Lines Matching refs:ctl
78 struct nh_control *ctl; in nhops_init_rib() local
83 ctl = malloc(sizeof(struct nh_control), M_NHOP, M_WAITOK | M_ZERO); in nhops_init_rib()
92 CHT_SLIST_INIT(&ctl->nh_head, ptr, num_buckets); in nhops_init_rib()
99 bitmask_init(&ctl->nh_idx_head, ptr, num_items); in nhops_init_rib()
101 NHOPS_LOCK_INIT(ctl); in nhops_init_rib()
103 rh->nh_control = ctl; in nhops_init_rib()
104 ctl->ctl_rh = rh; in nhops_init_rib()
106 FIB_CTL_LOG(LOG_DEBUG2, ctl, "nhops init: ctl %p rh %p", ctl, rh); in nhops_init_rib()
112 destroy_ctl(struct nh_control *ctl) in destroy_ctl() argument
115 NHOPS_LOCK_DESTROY(ctl); in destroy_ctl()
116 free(ctl->nh_head.ptr, M_NHOP); in destroy_ctl()
117 free(ctl->nh_idx_head.idx, M_NHOP); in destroy_ctl()
119 nhgrp_ctl_free(ctl); in destroy_ctl()
121 free(ctl, M_NHOP); in destroy_ctl()
130 struct nh_control *ctl; in destroy_ctl_epoch() local
132 ctl = __containerof(ctx, struct nh_control, ctl_epoch_ctx); in destroy_ctl_epoch()
134 destroy_ctl(ctl); in destroy_ctl_epoch()
140 struct nh_control *ctl; in nhops_destroy_rib() local
143 ctl = rh->nh_control; in nhops_destroy_rib()
158 NHOPS_WLOCK(ctl); in nhops_destroy_rib()
159 CHT_SLIST_FOREACH(&ctl->nh_head, nhops, nh_priv) { in nhops_destroy_rib()
164 nhgrp_ctl_unlink_all(ctl); in nhops_destroy_rib()
166 NHOPS_WUNLOCK(ctl); in nhops_destroy_rib()
172 NET_EPOCH_CALL(destroy_ctl_epoch, &ctl->ctl_epoch_ctx); in nhops_destroy_rib()
233 consider_resize(struct nh_control *ctl, uint32_t new_nh_buckets, uint32_t new_idx_items) in consider_resize() argument
256 FIB_CTL_LOG(LOG_DEBUG, ctl, in consider_resize()
262 NHOPS_WLOCK(ctl); in consider_resize()
264 CHT_SLIST_RESIZE(&ctl->nh_head, nhops, nh_ptr, new_nh_buckets); in consider_resize()
267 if (bitmask_copy(&ctl->nh_idx_head, nh_idx_ptr, new_idx_items) == 0) in consider_resize()
268 bitmask_swap(&ctl->nh_idx_head, nh_idx_ptr, new_idx_items, &old_idx_ptr); in consider_resize()
270 NHOPS_WUNLOCK(ctl); in consider_resize()
284 link_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv) in link_nhop() argument
290 NHOPS_WLOCK(ctl); in link_nhop()
297 num_buckets_new = CHT_SLIST_GET_RESIZE_BUCKETS(&ctl->nh_head); in link_nhop()
298 num_items_new = bitmask_get_resize_items(&ctl->nh_idx_head); in link_nhop()
300 if (bitmask_alloc_idx(&ctl->nh_idx_head, &idx) != 0) { in link_nhop()
301 NHOPS_WUNLOCK(ctl); in link_nhop()
302 FIB_CTL_LOG(LOG_INFO, ctl, "Unable to allocate nhop index"); in link_nhop()
304 consider_resize(ctl, num_buckets_new, num_items_new); in link_nhop()
309 nh_priv->nh_control = ctl; in link_nhop()
312 CHT_SLIST_INSERT_HEAD(&ctl->nh_head, nhops, nh_priv); in link_nhop()
314 NHOPS_WUNLOCK(ctl); in link_nhop()
316 FIB_RH_LOG(LOG_DEBUG2, ctl->ctl_rh, in link_nhop()
318 nh_priv, idx, hash_priv(nh_priv), ctl); in link_nhop()
319 consider_resize(ctl, num_buckets_new, num_items_new); in link_nhop()
330 unlink_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv_del) in unlink_nhop() argument
338 NHOPS_WLOCK(ctl); in unlink_nhop()
339 CHT_SLIST_REMOVE(&ctl->nh_head, nhops, nh_priv_del, priv_ret); in unlink_nhop()
346 if ((bitmask_free_idx(&ctl->nh_idx_head, idx)) != 0) { in unlink_nhop()
347 FIB_CTL_LOG(LOG_DEBUG, ctl, in unlink_nhop()
349 idx, ctl->ctl_rh->rib_fibnum, ctl->ctl_rh->rib_family); in unlink_nhop()
354 num_buckets_new = CHT_SLIST_GET_RESIZE_BUCKETS(&ctl->nh_head); in unlink_nhop()
355 num_items_new = bitmask_get_resize_items(&ctl->nh_idx_head); in unlink_nhop()
357 NHOPS_WUNLOCK(ctl); in unlink_nhop()
360 FIB_CTL_LOG(LOG_INFO, ctl, in unlink_nhop()
362 nh_priv_del, hash_priv(nh_priv_del), ctl); in unlink_nhop()
364 FIB_CTL_LOG(LOG_DEBUG2, ctl, "Unlinked nhop %p priv idx %d", in unlink_nhop()
368 consider_resize(ctl, num_buckets_new, num_items_new); in unlink_nhop()
378 find_nhop(struct nh_control *ctl, const struct nhop_priv *nh_priv) in find_nhop() argument
382 NHOPS_RLOCK(ctl); in find_nhop()
383 CHT_SLIST_FIND_BYOBJ(&ctl->nh_head, nhops, nh_priv, nh_priv_ret); in find_nhop()
390 NHOPS_RUNLOCK(ctl); in find_nhop()