Lines Matching refs:nmap

335 	struct nsim_bpf_bound_map *nmap = offmap->dev_priv;  in nsim_map_key_find()  local
338 for (i = 0; i < ARRAY_SIZE(nmap->entry); i++) in nsim_map_key_find()
339 if (nsim_map_key_match(&offmap->map, &nmap->entry[i], key)) in nsim_map_key_find()
348 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_alloc_elem() local
350 nmap->entry[idx].key = kmalloc(offmap->map.key_size, in nsim_map_alloc_elem()
352 if (!nmap->entry[idx].key) in nsim_map_alloc_elem()
354 nmap->entry[idx].value = kmalloc(offmap->map.value_size, in nsim_map_alloc_elem()
356 if (!nmap->entry[idx].value) { in nsim_map_alloc_elem()
357 kfree(nmap->entry[idx].key); in nsim_map_alloc_elem()
358 nmap->entry[idx].key = NULL; in nsim_map_alloc_elem()
369 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_get_next_key() local
372 mutex_lock(&nmap->mutex); in nsim_map_get_next_key()
381 for (; idx < ARRAY_SIZE(nmap->entry); idx++) { in nsim_map_get_next_key()
382 if (nmap->entry[idx].key) { in nsim_map_get_next_key()
383 memcpy(next_key, nmap->entry[idx].key, in nsim_map_get_next_key()
389 mutex_unlock(&nmap->mutex); in nsim_map_get_next_key()
391 if (idx == ARRAY_SIZE(nmap->entry)) in nsim_map_get_next_key()
399 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_lookup_elem() local
402 mutex_lock(&nmap->mutex); in nsim_map_lookup_elem()
406 memcpy(value, nmap->entry[idx].value, offmap->map.value_size); in nsim_map_lookup_elem()
408 mutex_unlock(&nmap->mutex); in nsim_map_lookup_elem()
417 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_update_elem() local
420 mutex_lock(&nmap->mutex); in nsim_map_update_elem()
433 for (idx = 0; idx < ARRAY_SIZE(nmap->entry); idx++) in nsim_map_update_elem()
434 if (!nmap->entry[idx].key) in nsim_map_update_elem()
436 if (idx == ARRAY_SIZE(nmap->entry)) { 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()
449 mutex_unlock(&nmap->mutex); in nsim_map_update_elem()
456 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_map_delete_elem() local
462 mutex_lock(&nmap->mutex); in nsim_map_delete_elem()
466 kfree(nmap->entry[idx].key); in nsim_map_delete_elem()
467 kfree(nmap->entry[idx].value); in nsim_map_delete_elem()
468 memset(&nmap->entry[idx], 0, sizeof(nmap->entry[idx])); in nsim_map_delete_elem()
471 mutex_unlock(&nmap->mutex); in nsim_map_delete_elem()
486 struct nsim_bpf_bound_map *nmap; in nsim_bpf_map_alloc() local
497 nmap = kzalloc(sizeof(*nmap), GFP_KERNEL_ACCOUNT); in nsim_bpf_map_alloc()
498 if (!nmap) in nsim_bpf_map_alloc()
501 offmap->dev_priv = nmap; in nsim_bpf_map_alloc()
502 nmap->ns = ns; in nsim_bpf_map_alloc()
503 nmap->map = offmap; in nsim_bpf_map_alloc()
504 mutex_init(&nmap->mutex); in nsim_bpf_map_alloc()
507 for (i = 0; i < ARRAY_SIZE(nmap->entry); i++) { in nsim_bpf_map_alloc()
513 key = nmap->entry[i].key; in nsim_bpf_map_alloc()
515 memset(nmap->entry[i].value, 0, offmap->map.value_size); in nsim_bpf_map_alloc()
520 list_add_tail(&nmap->l, &ns->nsim_dev->bpf_bound_maps); in nsim_bpf_map_alloc()
526 kfree(nmap->entry[i].key); in nsim_bpf_map_alloc()
527 kfree(nmap->entry[i].value); in nsim_bpf_map_alloc()
529 kfree(nmap); in nsim_bpf_map_alloc()
535 struct nsim_bpf_bound_map *nmap = offmap->dev_priv; in nsim_bpf_map_free() local
538 for (i = 0; i < ARRAY_SIZE(nmap->entry); i++) { in nsim_bpf_map_free()
539 kfree(nmap->entry[i].key); in nsim_bpf_map_free()
540 kfree(nmap->entry[i].value); in nsim_bpf_map_free()
542 list_del_init(&nmap->l); in nsim_bpf_map_free()
543 mutex_destroy(&nmap->mutex); in nsim_bpf_map_free()
544 kfree(nmap); in nsim_bpf_map_free()