Commit 2f9271b8 authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

sock: Add sock_map_find_free



This function finds a placement_id that does not have a group
associated with it.

Change-Id: I1306690e980fd4661f46dba9fb283f048a962eba
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7223


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent d88ccda6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -324,6 +324,11 @@ void spdk_sock_map_release(struct spdk_sock_map *map, int placement_id);
int spdk_sock_map_lookup(struct spdk_sock_map *map, int placement_id,
			 struct spdk_sock_group_impl **group_impl);

/**
 * Find a placement id with no associated group
 */
int spdk_sock_map_find_free(struct spdk_sock_map *map);

/**
 * Clean up all memory associated with the given map
 */
+19 −0
Original line number Diff line number Diff line
@@ -155,6 +155,25 @@ spdk_sock_map_cleanup(struct spdk_sock_map *map)
	pthread_mutex_unlock(&map->mtx);
}

int
spdk_sock_map_find_free(struct spdk_sock_map *map)
{
	struct spdk_sock_placement_id_entry *entry;
	int placement_id = -1;

	pthread_mutex_lock(&map->mtx);
	STAILQ_FOREACH(entry, &map->entries, link) {
		if (entry->group == NULL) {
			placement_id = entry->placement_id;
			break;
		}
	}

	pthread_mutex_unlock(&map->mtx);

	return placement_id;
}

int
spdk_sock_get_optimal_sock_group(struct spdk_sock *sock, struct spdk_sock_group **group)
{
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
	spdk_sock_map_insert;
	spdk_sock_map_release;
	spdk_sock_map_lookup;
	spdk_sock_map_find_free;
	spdk_sock_map_cleanup;

	local: *;
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ DEFINE_STUB(spdk_sock_map_insert, int, (struct spdk_sock_map *map, int placement
DEFINE_STUB_V(spdk_sock_map_release, (struct spdk_sock_map *map, int placement_id));
DEFINE_STUB(spdk_sock_map_lookup, int, (struct spdk_sock_map *map, int placement_id,
					struct spdk_sock_group_impl **group), 0);
DEFINE_STUB(spdk_sock_map_find_free, int, (struct spdk_sock_map *map), -1);
DEFINE_STUB_V(spdk_sock_map_cleanup, (struct spdk_sock_map *map));

DEFINE_STUB_V(spdk_net_impl_register, (struct spdk_net_impl *impl, int priority));
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ DEFINE_STUB(spdk_sock_map_insert, int, (struct spdk_sock_map *map, int placement
DEFINE_STUB_V(spdk_sock_map_release, (struct spdk_sock_map *map, int placement_id));
DEFINE_STUB(spdk_sock_map_lookup, int, (struct spdk_sock_map *map, int placement_id,
					struct spdk_sock_group_impl **group), 0);
DEFINE_STUB(spdk_sock_map_find_free, int, (struct spdk_sock_map *map), -1);
DEFINE_STUB_V(spdk_sock_map_cleanup, (struct spdk_sock_map *map));

DEFINE_STUB_V(spdk_net_impl_register, (struct spdk_net_impl *impl, int priority));