Lines Matching refs:cd
137 npf_conndb_t *cd; in npf_conndb_create() local
139 cd = kmem_zalloc(sizeof(npf_conndb_t), KM_SLEEP); in npf_conndb_create()
140 cd->cd_map = thmap_create(0, NULL, THMAP_NOCOPY); in npf_conndb_create()
141 KASSERT(cd->cd_map != NULL); in npf_conndb_create()
143 LIST_INIT(&cd->cd_list); in npf_conndb_create()
144 LIST_INIT(&cd->cd_gclist); in npf_conndb_create()
145 return cd; in npf_conndb_create()
149 npf_conndb_destroy(npf_conndb_t *cd) in npf_conndb_destroy() argument
151 KASSERT(cd->cd_new == NULL); in npf_conndb_destroy()
152 KASSERT(cd->cd_marker == NULL); in npf_conndb_destroy()
153 KASSERT(LIST_EMPTY(&cd->cd_list)); in npf_conndb_destroy()
154 KASSERT(LIST_EMPTY(&cd->cd_gclist)); in npf_conndb_destroy()
156 thmap_destroy(cd->cd_map); in npf_conndb_destroy()
157 kmem_free(cd, sizeof(npf_conndb_t)); in npf_conndb_destroy()
166 npf_conndb_t *cd = atomic_load_relaxed(&npf->conn_db); in npf_conndb_lookup() local
175 val = thmap_get(cd->cd_map, ck->ck_key, keylen); in npf_conndb_lookup()
203 npf_conndb_insert(npf_conndb_t *cd, const npf_connkey_t *ck, in npf_conndb_insert() argument
218 ok = thmap_put(cd->cd_map, ck->ck_key, keylen, val) == val; in npf_conndb_insert()
229 npf_conndb_remove(npf_conndb_t *cd, npf_connkey_t *ck) in npf_conndb_remove() argument
235 val = thmap_del(cd->cd_map, ck->ck_key, keylen); in npf_conndb_remove()
246 npf_conndb_enqueue(npf_conndb_t *cd, npf_conn_t *con) in npf_conndb_enqueue() argument
251 head = atomic_load_relaxed(&cd->cd_new); in npf_conndb_enqueue()
253 } while (atomic_cas_ptr(&cd->cd_new, head, con) != head); in npf_conndb_enqueue()
262 npf_conndb_update(npf_conndb_t *cd) in npf_conndb_update() argument
266 con = atomic_swap_ptr(&cd->cd_new, NULL); in npf_conndb_update()
269 LIST_INSERT_HEAD(&cd->cd_list, con, c_entry); in npf_conndb_update()
278 npf_conndb_getlist(npf_conndb_t *cd) in npf_conndb_getlist() argument
280 npf_conndb_update(cd); in npf_conndb_getlist()
281 return LIST_FIRST(&cd->cd_list); in npf_conndb_getlist()
289 npf_conndb_getnext(npf_conndb_t *cd, npf_conn_t *con) in npf_conndb_getnext() argument
293 con = LIST_FIRST(&cd->cd_list); in npf_conndb_getnext()
302 npf_conndb_gc_incr(npf_t *npf, npf_conndb_t *cd, const time_t now) in npf_conndb_gc_incr() argument
315 if ((con = cd->cd_marker) == NULL) { in npf_conndb_gc_incr()
316 con = npf_conndb_getnext(cd, NULL); in npf_conndb_gc_incr()
317 cd->cd_marker = con; in npf_conndb_gc_incr()
327 npf_conn_t *next = npf_conndb_getnext(cd, con); in npf_conndb_gc_incr()
335 LIST_INSERT_HEAD(&cd->cd_gclist, con, c_entry); in npf_conndb_gc_incr()
336 npf_conn_remove(cd, con); in npf_conndb_gc_incr()
343 if (con == cd->cd_marker) { in npf_conndb_gc_incr()
344 cd->cd_marker = next; in npf_conndb_gc_incr()
355 if (con == cd->cd_marker) { in npf_conndb_gc_incr()
359 cd->cd_marker = con; in npf_conndb_gc_incr()
373 gc_freq_tune(const npf_t *npf, const npf_conndb_t *cd, const unsigned n) in gc_freq_tune() argument
389 npf_conndb_gc(npf_t *npf, npf_conndb_t *cd, bool flush, bool sync) in npf_conndb_gc() argument
400 npf_conndb_update(cd); in npf_conndb_gc()
403 while ((con = LIST_FIRST(&cd->cd_list)) != NULL) { in npf_conndb_gc()
405 LIST_INSERT_HEAD(&cd->cd_gclist, con, c_entry); in npf_conndb_gc()
406 npf_conn_remove(cd, con); in npf_conndb_gc()
408 cd->cd_marker = NULL; in npf_conndb_gc()
411 gc_conns = npf_conndb_gc_incr(npf, cd, tsnow.tv_sec); in npf_conndb_gc()
419 gcref = thmap_stage_gc(cd->cd_map); in npf_conndb_gc()
420 if (sync && (gcref || !LIST_EMPTY(&cd->cd_gclist))) { in npf_conndb_gc()
425 thmap_gc(cd->cd_map, gcref); in npf_conndb_gc()
428 npf->worker_wait_time = gc_freq_tune(npf, cd, gc_conns); in npf_conndb_gc()
430 if (LIST_EMPTY(&cd->cd_gclist)) { in npf_conndb_gc()
438 while ((con = LIST_FIRST(&cd->cd_gclist)) != NULL) { in npf_conndb_gc()