diff options
author | Anuradha Karuppiah <anuradhak@nvidia.com> | 2021-12-30 23:49:19 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2022-06-27 13:56:55 +0200 |
commit | 67f5a232408af238d88f4c85691ff56227f002be (patch) | |
tree | fb45ec0ddb20b6fdf2ca051c4322179e94ddb1a5 /zebra | |
parent | configure, zebra: include DPDK headers and shared libs in the dp-dpdk build (diff) | |
download | frr-67f5a232408af238d88f4c85691ff56227f002be.tar.xz frr-67f5a232408af238d88f4c85691ff56227f002be.zip |
zebra: initialize hw via DPDK
Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/dpdk/zebra_dplane_dpdk.c | 31 | ||||
-rw-r--r-- | zebra/dpdk/zebra_dplane_dpdk_private.h | 2 |
2 files changed, 30 insertions, 3 deletions
diff --git a/zebra/dpdk/zebra_dplane_dpdk.c b/zebra/dpdk/zebra_dplane_dpdk.c index a8dfdf86d..44c6bac94 100644 --- a/zebra/dpdk/zebra_dplane_dpdk.c +++ b/zebra/dpdk/zebra_dplane_dpdk.c @@ -35,6 +35,8 @@ static const char *plugin_name = "zebra_dplane_dpdk"; +extern struct zebra_privs_t zserv_privs; + static struct zd_dpdk_ctx dpdk_ctx_buf, *dpdk_ctx = &dpdk_ctx_buf; #define dpdk_stat (&dpdk_ctx->stats) @@ -159,19 +161,37 @@ static int zd_dpdk_process(struct zebra_dplane_provider *prov) return 0; } +static int zd_dpdk_init(void) +{ + int rc; + char *argv[] = {(char *)"/usr/lib/frr/zebra", (char *)"--"}; + + zd_dpdk_vty_init(); + + frr_with_privs (&zserv_privs) { + rc = rte_eal_init(sizeof(argv) / sizeof(argv[0]), argv); + } + if (rc < 0) { + zlog_warn("EAL init failed %s", rte_strerror(rte_errno)); + return -1; + } + + return 0; +} static int zd_dpdk_start(struct zebra_dplane_provider *prov) { if (IS_ZEBRA_DEBUG_DPLANE_DPDK) zlog_debug("%s start", dplane_provider_get_name(prov)); - /* XXX - place holder */ - return 0; + return zd_dpdk_init(); } static int zd_dpdk_finish(struct zebra_dplane_provider *prov, bool early) { + int rc; + if (early) { if (IS_ZEBRA_DEBUG_DPLANE_DPDK) zlog_debug("%s early finish", @@ -184,7 +204,12 @@ static int zd_dpdk_finish(struct zebra_dplane_provider *prov, bool early) zlog_debug("%s finish", dplane_provider_get_name(prov)); - /* XXX - place holder */ + frr_with_privs (&zserv_privs) { + rc = rte_eal_cleanup(); + } + if (rc < 0) + zlog_warn("EAL cleanup failed %s", rte_strerror(rte_errno)); + return 0; } diff --git a/zebra/dpdk/zebra_dplane_dpdk_private.h b/zebra/dpdk/zebra_dplane_dpdk_private.h index 24b943ddd..8f5029608 100644 --- a/zebra/dpdk/zebra_dplane_dpdk_private.h +++ b/zebra/dpdk/zebra_dplane_dpdk_private.h @@ -24,6 +24,8 @@ #include <zebra.h> +#include <rte_ethdev.h> + #include "zebra_dplane_dpdk.h" |