From 509eb8f7c1ee665d98a52c38837c4e9030fa0355 Mon Sep 17 00:00:00 2001 From: Frank Du Date: Tue, 25 Jun 2024 14:24:55 +0800 Subject: [PATCH] manager: add mtlm_version (#911) [2024-06-25 10:12:24] [INFO] MTL Manager version: 24.6.0.REL Tue Jun 25 10:08:21 2024 4856224b-dirty clang-14.0.0-1ubuntu Signed-off-by: Frank Du --- .github/path_filters.yml | 1 + lib/src/dev/mt_af_xdp.c | 15 ++------------- lib/src/mt_util.c | 5 ++--- manager/meson.build | 21 ++++++++++++++++++++- manager/mtl_interface.hpp | 2 ++ manager/mtl_manager.cpp | 16 ++++++++++++++++ 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/.github/path_filters.yml b/.github/path_filters.yml index 14e6de248..9ed888ae6 100644 --- a/.github/path_filters.yml +++ b/.github/path_filters.yml @@ -8,6 +8,7 @@ src: &src - 'tests/src/**' - tests/meson.build - tests/meson_options.txt + - 'manager/**' app_src: &app_src - 'app/**' diff --git a/lib/src/dev/mt_af_xdp.c b/lib/src/dev/mt_af_xdp.c index d18b55589..1eec1ae22 100644 --- a/lib/src/dev/mt_af_xdp.c +++ b/lib/src/dev/mt_af_xdp.c @@ -195,19 +195,8 @@ static int xdp_stat_dump(void* priv) { } static void xdp_queue_clean_mbuf(struct mt_xdp_queue* xq) { - struct xsk_ring_prod* rpq = &xq->rx_prod; - struct rte_mempool* mp = xq->mbuf_pool; - uint32_t size = xq->umem_ring_size * 2 + 128 /* max burst size */; - uint32_t idx = 0; - - /* clean rx prod ring */ - xsk_ring_prod__reserve(rpq, 0, &idx); - for (uint32_t i = 0; i < size; i++) { - __u64* fq_addr = xsk_ring_prod__fill_addr(rpq, idx--); - if (!fq_addr) break; - struct rte_mbuf* m = *fq_addr + xq->umem_buffer + mp->header_size; - rte_pktmbuf_free(m); - } + /* todo: find a way to safe free the mbuf in xsk_ring_prod__fill_addr */ + MTL_MAY_UNUSED(xq); } static int xdp_queue_uinit(struct mt_xdp_queue* xq) { diff --git a/lib/src/mt_util.c b/lib/src/mt_util.c index 1c0e26375..da7348298 100644 --- a/lib/src/mt_util.c +++ b/lib/src/mt_util.c @@ -65,8 +65,7 @@ int mt_asan_check(void) { mt_pthread_mutex_destroy(&g_bt_mutex); if (g_mt_mempool_create_cnt != 0) { - rte_panic("%s, detect not free mempool, leak cnt %d\n", __func__, - g_mt_mempool_create_cnt); + err("%s, detect not free mempool, leak cnt %d\n", __func__, g_mt_mempool_create_cnt); } return 0; @@ -497,7 +496,7 @@ int mt_mempool_free(struct rte_mempool* mp) { unsigned int in_use_count = rte_mempool_in_use_count(mp); if (in_use_count) { /* failed to free the mempool, caused by the mbuf is still in nix tx queues? */ - err("%s, still has %d mbuf in mempool %s\n", __func__, in_use_count, mp->name); + warn("%s, still has %d mbuf in mempool %s\n", __func__, in_use_count, mp->name); return 0; } diff --git a/manager/meson.build b/manager/meson.build index 270e521ae..0318d596b 100644 --- a/manager/meson.build +++ b/manager/meson.build @@ -1,7 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2023 Intel Corporation -project('mtl_manager', 'cpp', default_options: ['buildtype=release', 'cpp_std=c++17'], version: '0.3.0') +project('mtl_manager', 'cpp', default_options: ['buildtype=release', 'cpp_std=c++17'], + version: run_command(find_program('cat'), files('../VERSION'), check: true).stdout().strip(), +) exec_env = host_machine.system() set_variable('is_windows', exec_env == 'windows') @@ -34,6 +36,23 @@ if get_option('enable_asan') == true asan_dep = cpp_c.find_library('asan', required : true) endif +mtlm_conf = configuration_data() +# get external variables +add_global_arguments('-D__MTLM_GIT__="'+ run_command('git', 'describe', '--abbrev=8', '--dirty', '--always', check: false).stdout().strip() + '"', language : 'cpp') +# parse mtlm config +# parse build config +prj_ver = meson.project_version().split('.') +mtlm_conf.set('MTLM_VERSION_MAJOR', prj_ver.get(0).to_int()) +mtlm_conf.set('MTLM_VERSION_MINOR', prj_ver.get(1).to_int()) +mtlm_conf.set('MTLM_VERSION_LAST', prj_ver.get(2).to_int()) +mtlm_conf.set_quoted('MTLM_VERSION_EXTRA', prj_ver.get(3)) +# parse compiler config +cpp_c_ver = cpp_c.get_id() + '-' + cpp_c.version() +mtlm_conf.set_quoted('MTLM_COMPILER', cpp_c_ver) +# build config file +build_cfg = 'mtlm_build_config.h' +configure_file(output: build_cfg, configuration: mtlm_conf) + # xdp check libxdp_dep = dependency('libxdp', required: false) libbpf_dep = dependency('libbpf', required: false) diff --git a/manager/mtl_interface.hpp b/manager/mtl_interface.hpp index b009f4bde..5cef1ee99 100644 --- a/manager/mtl_interface.hpp +++ b/manager/mtl_interface.hpp @@ -79,6 +79,8 @@ mtl_interface::mtl_interface(unsigned int ifindex) udp4_dp_filter_fd = -1; xdp_mode = XDP_MODE_UNSPEC; if (load_xdp() < 0) throw std::runtime_error("Failed to load XDP program."); +#else + throw std::runtime_error("No XDP support for this build"); #endif if (parse_combined_info() < 0) throw std::runtime_error("Failed to parse combined info."); diff --git a/manager/mtl_manager.cpp b/manager/mtl_manager.cpp index e7c067332..062949991 100644 --- a/manager/mtl_manager.cpp +++ b/manager/mtl_manager.cpp @@ -15,11 +15,23 @@ #include "logging.hpp" #include "mtl_instance.hpp" #include "mtl_mproto.h" +#include "mtlm_build_config.h" namespace fs = std::filesystem; static const int MAX_CLIENTS = 10; +static const char* mtlm_version(void) { + static char version[128]; + if (version[0] != 0) return version; + + snprintf(version, sizeof(version), "%d.%d.%d.%s %s %s %s", MTLM_VERSION_MAJOR, + MTLM_VERSION_MINOR, MTLM_VERSION_LAST, MTLM_VERSION_EXTRA, __TIMESTAMP__, + __MTLM_GIT__, MTLM_COMPILER); + + return version; +} + int main() { int ret = 0; bool is_running = true; @@ -27,6 +39,7 @@ int main() { std::vector> clients; logger::set_log_level(log_level::INFO); + logger::log(log_level::INFO, "MTL Manager version: " + std::string(mtlm_version())); fs::path directory_path(MTL_MANAGER_SOCK_PATH); directory_path.remove_filename(); @@ -116,6 +129,9 @@ int main() { logger::log(log_level::INFO, "MTL Manager is running. Press Ctrl+C or use SIGINT to stop it."); +#ifndef MTL_HAS_XDP_BACKEND + logger::log(log_level::WARNING, "No XDP support for this build"); +#endif while (is_running) { std::vector events(clients.size() + 2);