Lines Matching refs:offmap
333 static int nsim_map_key_find(struct bpf_offloaded_map *offmap, void *key) in nsim_map_key_find() argument
335 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_key_find()
339 if (nsim_map_key_match(&offmap->map, &nmap->entry[i], key)) in nsim_map_key_find()
346 nsim_map_alloc_elem(struct bpf_offloaded_map *offmap, unsigned int idx) in nsim_map_alloc_elem() argument
348 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_alloc_elem()
350 nmap->entry[idx].key = kmalloc(offmap->map.key_size, in nsim_map_alloc_elem()
354 nmap->entry[idx].value = kmalloc(offmap->map.value_size, in nsim_map_alloc_elem()
366 nsim_map_get_next_key(struct bpf_offloaded_map *offmap, in nsim_map_get_next_key() argument
369 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_get_next_key()
375 idx = nsim_map_key_find(offmap, key); in nsim_map_get_next_key()
384 offmap->map.key_size); in nsim_map_get_next_key()
397 nsim_map_lookup_elem(struct bpf_offloaded_map *offmap, void *key, void *value) in nsim_map_lookup_elem() argument
399 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_lookup_elem()
404 idx = nsim_map_key_find(offmap, key); in nsim_map_lookup_elem()
406 memcpy(value, nmap->entry[idx].value, offmap->map.value_size); in nsim_map_lookup_elem()
414 nsim_map_update_elem(struct bpf_offloaded_map *offmap, in nsim_map_update_elem() argument
417 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_update_elem()
422 idx = nsim_map_key_find(offmap, key); in nsim_map_update_elem()
441 err = nsim_map_alloc_elem(offmap, idx); in nsim_map_update_elem()
446 memcpy(nmap->entry[idx].key, key, offmap->map.key_size); in nsim_map_update_elem()
447 memcpy(nmap->entry[idx].value, value, offmap->map.value_size); in nsim_map_update_elem()
454 static int nsim_map_delete_elem(struct bpf_offloaded_map *offmap, void *key) in nsim_map_delete_elem() argument
456 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_delete_elem()
459 if (offmap->map.map_type == BPF_MAP_TYPE_ARRAY) in nsim_map_delete_elem()
464 idx = nsim_map_key_find(offmap, key); in nsim_map_delete_elem()
484 nsim_bpf_map_alloc(struct netdevsim *ns, struct bpf_offloaded_map *offmap) in nsim_bpf_map_alloc() argument
489 if (WARN_ON(offmap->map.map_type != BPF_MAP_TYPE_ARRAY && in nsim_bpf_map_alloc()
490 offmap->map.map_type != BPF_MAP_TYPE_HASH)) in nsim_bpf_map_alloc()
492 if (offmap->map.max_entries > NSIM_BPF_MAX_KEYS) in nsim_bpf_map_alloc()
494 if (offmap->map.map_flags) in nsim_bpf_map_alloc()
501 offmap->dev_priv = nmap; in nsim_bpf_map_alloc()
503 nmap->map = offmap; in nsim_bpf_map_alloc()
506 if (offmap->map.map_type == BPF_MAP_TYPE_ARRAY) { in nsim_bpf_map_alloc()
510 err = nsim_map_alloc_elem(offmap, i); in nsim_bpf_map_alloc()
515 memset(nmap->entry[i].value, 0, offmap->map.value_size); in nsim_bpf_map_alloc()
519 offmap->dev_ops = &nsim_bpf_map_ops; in nsim_bpf_map_alloc()
533 static void nsim_bpf_map_free(struct bpf_offloaded_map *offmap) in nsim_bpf_map_free() argument
535 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_bpf_map_free()
571 return nsim_bpf_map_alloc(ns, bpf->offmap); in nsim_bpf()
573 nsim_bpf_map_free(bpf->offmap); in nsim_bpf()