Commit 7b77e068 authored by yidong0635's avatar yidong0635 Committed by Tomasz Zawadzki
Browse files

sock/net_framework: Adding a static inline function to get next framework.



This can remove these duplicated codes.

Signed-off-by: default avataryidong0635 <dongx.yi@intel.com>
Change-Id: Ie6590fc10e72471dbc6f0c1ac9c14eb3edfa3599
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2769


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent ea02571d
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -46,6 +46,12 @@ static void *g_fini_cb_arg = NULL;

struct spdk_net_framework *g_next_net_framework = NULL;

static inline struct spdk_net_framework *
get_next_net_framework(struct spdk_net_framework *net)
{
	return net ? STAILQ_NEXT(net, link) : STAILQ_FIRST(&g_net_frameworks);
}

void
spdk_net_framework_init_next(int rc)
{
@@ -55,12 +61,7 @@ spdk_net_framework_init_next(int rc)
		return;
	}

	if (g_next_net_framework == NULL) {
		g_next_net_framework = STAILQ_FIRST(&g_net_frameworks);
	} else {
		g_next_net_framework = STAILQ_NEXT(g_next_net_framework, link);
	}

	g_next_net_framework = get_next_net_framework(g_next_net_framework);
	if (g_next_net_framework == NULL) {
		g_init_cb_fn(g_init_cb_arg, 0);
		return;
@@ -81,12 +82,7 @@ spdk_net_framework_start(spdk_net_init_cb cb_fn, void *cb_arg)
void
spdk_net_framework_fini_next(void)
{
	if (g_next_net_framework == NULL) {
		g_next_net_framework = STAILQ_FIRST(&g_net_frameworks);
	} else {
		g_next_net_framework = STAILQ_NEXT(g_next_net_framework, link);
	}

	g_next_net_framework = get_next_net_framework(g_next_net_framework);
	if (g_next_net_framework == NULL) {
		g_fini_cb_fn(g_fini_cb_arg);
		return;