Skip to content

Commit

Permalink
manager: add mtlm_version (#911)
Browse files Browse the repository at this point in the history
[2024-06-25 10:12:24] [INFO] MTL Manager version: 24.6.0.REL Tue Jun 25
10:08:21 2024 4856224-dirty clang-14.0.0-1ubuntu

Signed-off-by: Frank Du <frank.du@intel.com>
  • Loading branch information
frankdjx authored Jun 25, 2024
1 parent 4856224 commit 509eb8f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/path_filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ src: &src
- 'tests/src/**'
- tests/meson.build
- tests/meson_options.txt
- 'manager/**'

app_src: &app_src
- 'app/**'
Expand Down
15 changes: 2 additions & 13 deletions lib/src/dev/mt_af_xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions lib/src/mt_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
21 changes: 20 additions & 1 deletion manager/meson.build
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions manager/mtl_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
16 changes: 16 additions & 0 deletions manager/mtl_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,31 @@
#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;
int epfd = -1, sockfd = -1;
std::vector<std::unique_ptr<mtl_instance>> 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();
Expand Down Expand Up @@ -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<struct epoll_event> events(clients.size() + 2);
Expand Down

0 comments on commit 509eb8f

Please sign in to comment.