Home | History | Annotate | Download | only in npf

Lines Matching refs:cd

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