lib/sock: create common lookup for spdk_sock_group_impl
Next patch in series will look up the struct spdk_sock_group_impl from spdk_sock_group in spdk_sock_get_optimal_sock_group(). Since this is third place it will be used, make this function common. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I43d6472016782e78709c1d52aa74abf594e5bfe6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10347 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
d619f6c2cf
commit
41c309b430
@ -53,6 +53,19 @@ struct spdk_sock_placement_id_entry {
|
||||
STAILQ_ENTRY(spdk_sock_placement_id_entry) link;
|
||||
};
|
||||
|
||||
static inline struct spdk_sock_group_impl *
|
||||
sock_get_group_impl_from_group(struct spdk_sock *sock, struct spdk_sock_group *group)
|
||||
{
|
||||
struct spdk_sock_group_impl *group_impl = NULL;
|
||||
|
||||
STAILQ_FOREACH_FROM(group_impl, &group->group_impls, link) {
|
||||
if (sock->net_impl == group_impl->net_impl) {
|
||||
return group_impl;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_sock_map_insert(struct spdk_sock_map *map, int placement_id,
|
||||
struct spdk_sock_group_impl *group)
|
||||
@ -541,12 +554,7 @@ spdk_sock_group_add_sock(struct spdk_sock_group *group, struct spdk_sock *sock,
|
||||
return -1;
|
||||
}
|
||||
|
||||
STAILQ_FOREACH_FROM(group_impl, &group->group_impls, link) {
|
||||
if (sock->net_impl == group_impl->net_impl) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
group_impl = sock_get_group_impl_from_group(sock, group);
|
||||
if (group_impl == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@ -571,12 +579,7 @@ spdk_sock_group_remove_sock(struct spdk_sock_group *group, struct spdk_sock *soc
|
||||
struct spdk_sock_group_impl *group_impl = NULL;
|
||||
int rc;
|
||||
|
||||
STAILQ_FOREACH_FROM(group_impl, &group->group_impls, link) {
|
||||
if (sock->net_impl == group_impl->net_impl) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
group_impl = sock_get_group_impl_from_group(sock, group);
|
||||
if (group_impl == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user