forked from DPDK/dpdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init: defer component init in EAL init
Signed-off-by: David Marchand <[email protected]>
- Loading branch information
1 parent
58aec28
commit d9a7bfb
Showing
5 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2024 Red Hat, Inc. | ||
|
||
includes += global_inc | ||
sources = files('rte_init.c') | ||
headers = files('rte_init.h') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause | ||
* Copyright (c) 2024 Red Hat, Inc. | ||
*/ | ||
|
||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
|
||
#include <rte_common.h> | ||
#include <rte_tailq.h> | ||
|
||
static bool init_called; | ||
|
||
static RTE_TAILQ_HEAD(, rte_init) init_list = TAILQ_HEAD_INITIALIZER(init_list); | ||
struct rte_init { | ||
RTE_TAILQ_ENTRY(rte_init) next; | ||
unsigned int priority; | ||
const char *func; | ||
void (*init)(void); | ||
}; | ||
|
||
void | ||
rte_init_register(const char *func, void (*init)(void), unsigned int priority) | ||
{ | ||
struct rte_init *p; | ||
struct rte_init *i; | ||
|
||
/* | ||
* This code has been invoked after rte_eal_init() (common case is with drivers loaded | ||
* as shared libraries). | ||
*/ | ||
if (init_called) { | ||
init(); | ||
return; | ||
} | ||
|
||
i = malloc(sizeof(*i)); | ||
if (i == NULL) | ||
return; | ||
|
||
i->priority = priority; | ||
i->func = func; | ||
i->init = init; | ||
|
||
TAILQ_FOREACH(p, &init_list, next) { | ||
if (i->priority >= p->priority) | ||
continue; | ||
TAILQ_INSERT_BEFORE(p, i, next); | ||
return; | ||
} | ||
|
||
TAILQ_INSERT_TAIL(&init_list, i, next); | ||
} | ||
|
||
void | ||
eal_init_early(void) | ||
{ | ||
struct rte_init *i; | ||
|
||
init_called = true; | ||
|
||
TAILQ_FOREACH(i, &init_list, next) | ||
i->init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
DPDK_25 { | ||
global: | ||
|
||
rte_init_register; | ||
|
||
local: *; | ||
}; | ||
|
||
INTERNAL { | ||
global: | ||
|
||
eal_init_early; | ||
}; |