Lines Matching refs:htab

862 static struct bpf_shtab_bucket *sock_hash_select_bucket(struct bpf_shtab *htab,  in sock_hash_select_bucket()  argument
865 return &htab->buckets[hash & (htab->buckets_num - 1)]; in sock_hash_select_bucket()
885 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in __sock_hash_lookup_elem() local
893 bucket = sock_hash_select_bucket(htab, hash); in __sock_hash_lookup_elem()
899 static void sock_hash_free_elem(struct bpf_shtab *htab, in sock_hash_free_elem() argument
902 atomic_dec(&htab->count); in sock_hash_free_elem()
909 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_from_link() local
914 bucket = sock_hash_select_bucket(htab, elem->hash); in sock_hash_delete_from_link()
926 sock_hash_free_elem(htab, elem); in sock_hash_delete_from_link()
933 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_delete_elem() local
943 bucket = sock_hash_select_bucket(htab, hash); in sock_hash_delete_elem()
950 sock_hash_free_elem(htab, elem); in sock_hash_delete_elem()
957 static struct bpf_shtab_elem *sock_hash_alloc_elem(struct bpf_shtab *htab, in sock_hash_alloc_elem() argument
964 if (atomic_inc_return(&htab->count) > htab->map.max_entries) { in sock_hash_alloc_elem()
966 atomic_dec(&htab->count); in sock_hash_alloc_elem()
971 new = bpf_map_kmalloc_node(&htab->map, htab->elem_size, in sock_hash_alloc_elem()
973 htab->map.numa_node); in sock_hash_alloc_elem()
975 atomic_dec(&htab->count); in sock_hash_alloc_elem()
987 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_update_common() local
1011 bucket = sock_hash_select_bucket(htab, hash); in sock_hash_update_common()
1023 elem_new = sock_hash_alloc_elem(htab, key, key_size, hash, sk, elem); in sock_hash_update_common()
1037 sock_hash_free_elem(htab, elem); in sock_hash_update_common()
1052 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_get_next_key() local
1061 head = &sock_hash_select_bucket(htab, hash)->head; in sock_hash_get_next_key()
1073 i = hash & (htab->buckets_num - 1); in sock_hash_get_next_key()
1076 for (; i < htab->buckets_num; i++) { in sock_hash_get_next_key()
1077 head = &sock_hash_select_bucket(htab, i)->head; in sock_hash_get_next_key()
1091 struct bpf_shtab *htab; in sock_hash_alloc() local
1103 htab = bpf_map_area_alloc(sizeof(*htab), NUMA_NO_NODE); in sock_hash_alloc()
1104 if (!htab) in sock_hash_alloc()
1107 bpf_map_init_from_attr(&htab->map, attr); in sock_hash_alloc()
1109 htab->buckets_num = roundup_pow_of_two(htab->map.max_entries); in sock_hash_alloc()
1110 htab->elem_size = sizeof(struct bpf_shtab_elem) + in sock_hash_alloc()
1111 round_up(htab->map.key_size, 8); in sock_hash_alloc()
1112 if (htab->buckets_num == 0 || in sock_hash_alloc()
1113 htab->buckets_num > U32_MAX / sizeof(struct bpf_shtab_bucket)) { in sock_hash_alloc()
1118 htab->buckets = bpf_map_area_alloc(htab->buckets_num * in sock_hash_alloc()
1120 htab->map.numa_node); in sock_hash_alloc()
1121 if (!htab->buckets) { in sock_hash_alloc()
1126 for (i = 0; i < htab->buckets_num; i++) { in sock_hash_alloc()
1127 INIT_HLIST_HEAD(&htab->buckets[i].head); in sock_hash_alloc()
1128 spin_lock_init(&htab->buckets[i].lock); in sock_hash_alloc()
1131 return &htab->map; in sock_hash_alloc()
1133 bpf_map_area_free(htab); in sock_hash_alloc()
1139 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_free() local
1151 for (i = 0; i < htab->buckets_num; i++) { in sock_hash_free()
1152 bucket = sock_hash_select_bucket(htab, i); in sock_hash_free()
1178 sock_hash_free_elem(htab, elem); in sock_hash_free()
1185 bpf_map_area_free(htab->buckets); in sock_hash_free()
1186 bpf_map_area_free(htab); in sock_hash_free()
1300 struct bpf_shtab *htab; member
1307 const struct bpf_shtab *htab = info->htab; in sock_hash_seq_find_next() local
1323 for (; info->bucket_id < htab->buckets_num; info->bucket_id++) { in sock_hash_seq_find_next()
1324 bucket = &htab->buckets[info->bucket_id]; in sock_hash_seq_find_next()
1404 info->htab = container_of(aux->map, struct bpf_shtab, map); in sock_hash_init_seq_private()
1417 struct bpf_shtab *htab = container_of(map, struct bpf_shtab, map); in sock_hash_mem_usage() local
1418 u64 usage = sizeof(*htab); in sock_hash_mem_usage()
1420 usage += htab->buckets_num * sizeof(struct bpf_shtab_bucket); in sock_hash_mem_usage()
1421 usage += atomic_read(&htab->count) * (u64)htab->elem_size; in sock_hash_mem_usage()