Lines Matching refs:htab
872 static struct bpf_shtab_bucket *sock_hash_select_bucket(struct bpf_shtab *htab, in sock_hash_select_bucket() argument
875 return &htab->buckets[hash & (htab->buckets_num - 1)]; in sock_hash_select_bucket()
895 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in __sock_hash_lookup_elem() local
903 bucket = sock_hash_select_bucket(htab, hash); in __sock_hash_lookup_elem()
909 static void sock_hash_free_elem(struct bpf_shtab *htab, in sock_hash_free_elem() argument
912 atomic_dec(&htab->count); in sock_hash_free_elem()
919 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_from_link() local
924 bucket = sock_hash_select_bucket(htab, elem->hash); in sock_hash_delete_from_link()
936 sock_hash_free_elem(htab, elem); in sock_hash_delete_from_link()
943 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_elem() local
950 bucket = sock_hash_select_bucket(htab, hash); in sock_hash_delete_elem()
957 sock_hash_free_elem(htab, elem); in sock_hash_delete_elem()
964 static struct bpf_shtab_elem *sock_hash_alloc_elem(struct bpf_shtab *htab, in sock_hash_alloc_elem() argument
971 if (atomic_inc_return(&htab->count) > htab->map.max_entries) { in sock_hash_alloc_elem()
973 atomic_dec(&htab->count); in sock_hash_alloc_elem()
978 new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, in sock_hash_alloc_elem()
979 htab->map.numa_node); in sock_hash_alloc_elem()
981 atomic_dec(&htab->count); in sock_hash_alloc_elem()
993 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_update_common() local
1014 ret = sock_map_link(map, &htab->progs, sk); in sock_hash_update_common()
1024 bucket = sock_hash_select_bucket(htab, hash); in sock_hash_update_common()
1036 elem_new = sock_hash_alloc_elem(htab, key, key_size, hash, sk, elem); in sock_hash_update_common()
1050 sock_hash_free_elem(htab, elem); in sock_hash_update_common()
1065 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_get_next_key() local
1074 head = &sock_hash_select_bucket(htab, hash)->head; in sock_hash_get_next_key()
1086 i = hash & (htab->buckets_num - 1); in sock_hash_get_next_key()
1089 for (; i < htab->buckets_num; i++) { in sock_hash_get_next_key()
1090 head = &sock_hash_select_bucket(htab, i)->head; in sock_hash_get_next_key()
1104 struct bpf_shtab *htab; in sock_hash_alloc() local
1119 htab = kzalloc(sizeof(*htab), GFP_USER); in sock_hash_alloc()
1120 if (!htab) in sock_hash_alloc()
1123 bpf_map_init_from_attr(&htab->map, attr); in sock_hash_alloc()
1125 htab->buckets_num = roundup_pow_of_two(htab->map.max_entries); in sock_hash_alloc()
1126 htab->elem_size = sizeof(struct bpf_shtab_elem) + in sock_hash_alloc()
1127 round_up(htab->map.key_size, 8); in sock_hash_alloc()
1128 if (htab->buckets_num == 0 || in sock_hash_alloc()
1129 htab->buckets_num > U32_MAX / sizeof(struct bpf_shtab_bucket)) { in sock_hash_alloc()
1134 cost = (u64) htab->buckets_num * sizeof(struct bpf_shtab_bucket) + in sock_hash_alloc()
1135 (u64) htab->elem_size * htab->map.max_entries; in sock_hash_alloc()
1140 err = bpf_map_charge_init(&htab->map.memory, cost); in sock_hash_alloc()
1144 htab->buckets = bpf_map_area_alloc(htab->buckets_num * in sock_hash_alloc()
1146 htab->map.numa_node); in sock_hash_alloc()
1147 if (!htab->buckets) { in sock_hash_alloc()
1148 bpf_map_charge_finish(&htab->map.memory); in sock_hash_alloc()
1153 for (i = 0; i < htab->buckets_num; i++) { in sock_hash_alloc()
1154 INIT_HLIST_HEAD(&htab->buckets[i].head); in sock_hash_alloc()
1155 raw_spin_lock_init(&htab->buckets[i].lock); in sock_hash_alloc()
1158 return &htab->map; in sock_hash_alloc()
1160 kfree(htab); in sock_hash_alloc()
1166 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_free() local
1178 for (i = 0; i < htab->buckets_num; i++) { in sock_hash_free()
1179 bucket = sock_hash_select_bucket(htab, i); in sock_hash_free()
1205 sock_hash_free_elem(htab, elem); in sock_hash_free()
1212 bpf_map_area_free(htab->buckets); in sock_hash_free()
1213 kfree(htab); in sock_hash_free()
1327 struct bpf_shtab *htab; member
1334 const struct bpf_shtab *htab = info->htab; in sock_hash_seq_find_next() local
1350 for (; info->bucket_id < htab->buckets_num; info->bucket_id++) { in sock_hash_seq_find_next()
1351 bucket = &htab->buckets[info->bucket_id]; in sock_hash_seq_find_next()
1430 info->htab = container_of(aux->map, struct bpf_shtab, map); in sock_hash_init_seq_private()