Lines Matching refs:htab

835 static struct bpf_shtab_bucket *sock_hash_select_bucket(struct bpf_shtab *htab,  in sock_hash_select_bucket()  argument
838 return &htab->buckets[hash & (htab->buckets_num - 1)]; in sock_hash_select_bucket()
858 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in __sock_hash_lookup_elem() local
866 bucket = sock_hash_select_bucket(htab, hash); in __sock_hash_lookup_elem()
872 static void sock_hash_free_elem(struct bpf_shtab *htab, in sock_hash_free_elem() argument
875 atomic_dec(&htab->count); in sock_hash_free_elem()
882 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_from_link() local
887 bucket = sock_hash_select_bucket(htab, elem->hash); in sock_hash_delete_from_link()
899 sock_hash_free_elem(htab, elem); in sock_hash_delete_from_link()
906 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_elem() local
913 bucket = sock_hash_select_bucket(htab, hash); in sock_hash_delete_elem()
920 sock_hash_free_elem(htab, elem); in sock_hash_delete_elem()
927 static struct bpf_shtab_elem *sock_hash_alloc_elem(struct bpf_shtab *htab, in sock_hash_alloc_elem() argument
934 if (atomic_inc_return(&htab->count) > htab->map.max_entries) { in sock_hash_alloc_elem()
936 atomic_dec(&htab->count); in sock_hash_alloc_elem()
941 new = bpf_map_kmalloc_node(&htab->map, htab->elem_size, in sock_hash_alloc_elem()
943 htab->map.numa_node); in sock_hash_alloc_elem()
945 atomic_dec(&htab->count); in sock_hash_alloc_elem()
957 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_update_common() local
981 bucket = sock_hash_select_bucket(htab, hash); in sock_hash_update_common()
993 elem_new = sock_hash_alloc_elem(htab, key, key_size, hash, sk, elem); in sock_hash_update_common()
1007 sock_hash_free_elem(htab, elem); in sock_hash_update_common()
1022 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_get_next_key() local
1031 head = &sock_hash_select_bucket(htab, hash)->head; in sock_hash_get_next_key()
1043 i = hash & (htab->buckets_num - 1); in sock_hash_get_next_key()
1046 for (; i < htab->buckets_num; i++) { in sock_hash_get_next_key()
1047 head = &sock_hash_select_bucket(htab, i)->head; in sock_hash_get_next_key()
1061 struct bpf_shtab *htab; in sock_hash_alloc() local
1075 htab = kzalloc(sizeof(*htab), GFP_USER | __GFP_ACCOUNT); in sock_hash_alloc()
1076 if (!htab) in sock_hash_alloc()
1079 bpf_map_init_from_attr(&htab->map, attr); in sock_hash_alloc()
1081 htab->buckets_num = roundup_pow_of_two(htab->map.max_entries); in sock_hash_alloc()
1082 htab->elem_size = sizeof(struct bpf_shtab_elem) + in sock_hash_alloc()
1083 round_up(htab->map.key_size, 8); in sock_hash_alloc()
1084 if (htab->buckets_num == 0 || in sock_hash_alloc()
1085 htab->buckets_num > U32_MAX / sizeof(struct bpf_shtab_bucket)) { in sock_hash_alloc()
1090 htab->buckets = bpf_map_area_alloc(htab->buckets_num * in sock_hash_alloc()
1092 htab->map.numa_node); in sock_hash_alloc()
1093 if (!htab->buckets) { in sock_hash_alloc()
1098 for (i = 0; i < htab->buckets_num; i++) { in sock_hash_alloc()
1099 INIT_HLIST_HEAD(&htab->buckets[i].head); in sock_hash_alloc()
1100 raw_spin_lock_init(&htab->buckets[i].lock); in sock_hash_alloc()
1103 return &htab->map; in sock_hash_alloc()
1105 kfree(htab); in sock_hash_alloc()
1111 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_free() local
1123 for (i = 0; i < htab->buckets_num; i++) { in sock_hash_free()
1124 bucket = sock_hash_select_bucket(htab, i); in sock_hash_free()
1150 sock_hash_free_elem(htab, elem); in sock_hash_free()
1157 bpf_map_area_free(htab->buckets); in sock_hash_free()
1158 kfree(htab); in sock_hash_free()
1270 struct bpf_shtab *htab; member
1277 const struct bpf_shtab *htab = info->htab; in sock_hash_seq_find_next() local
1293 for (; info->bucket_id < htab->buckets_num; info->bucket_id++) { in sock_hash_seq_find_next()
1294 bucket = &htab->buckets[info->bucket_id]; in sock_hash_seq_find_next()
1373 info->htab = container_of(aux->map, struct bpf_shtab, map); in sock_hash_init_seq_private()