Skip to content

Commit 509eb8f

Browse files
authored
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 4856224-dirty clang-14.0.0-1ubuntu Signed-off-by: Frank Du <[email protected]>
1 parent 4856224 commit 509eb8f

File tree

6 files changed

+43
-17
lines changed

6 files changed

+43
-17
lines changed

.github/path_filters.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ src: &src
88
- 'tests/src/**'
99
- tests/meson.build
1010
- tests/meson_options.txt
11+
- 'manager/**'
1112

1213
app_src: &app_src
1314
- 'app/**'

lib/src/dev/mt_af_xdp.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,8 @@ static int xdp_stat_dump(void* priv) {
195195
}
196196

197197
static void xdp_queue_clean_mbuf(struct mt_xdp_queue* xq) {
198-
struct xsk_ring_prod* rpq = &xq->rx_prod;
199-
struct rte_mempool* mp = xq->mbuf_pool;
200-
uint32_t size = xq->umem_ring_size * 2 + 128 /* max burst size */;
201-
uint32_t idx = 0;
202-
203-
/* clean rx prod ring */
204-
xsk_ring_prod__reserve(rpq, 0, &idx);
205-
for (uint32_t i = 0; i < size; i++) {
206-
__u64* fq_addr = xsk_ring_prod__fill_addr(rpq, idx--);
207-
if (!fq_addr) break;
208-
struct rte_mbuf* m = *fq_addr + xq->umem_buffer + mp->header_size;
209-
rte_pktmbuf_free(m);
210-
}
198+
/* todo: find a way to safe free the mbuf in xsk_ring_prod__fill_addr */
199+
MTL_MAY_UNUSED(xq);
211200
}
212201

213202
static int xdp_queue_uinit(struct mt_xdp_queue* xq) {

lib/src/mt_util.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ int mt_asan_check(void) {
6565
mt_pthread_mutex_destroy(&g_bt_mutex);
6666

6767
if (g_mt_mempool_create_cnt != 0) {
68-
rte_panic("%s, detect not free mempool, leak cnt %d\n", __func__,
69-
g_mt_mempool_create_cnt);
68+
err("%s, detect not free mempool, leak cnt %d\n", __func__, g_mt_mempool_create_cnt);
7069
}
7170

7271
return 0;
@@ -497,7 +496,7 @@ int mt_mempool_free(struct rte_mempool* mp) {
497496
unsigned int in_use_count = rte_mempool_in_use_count(mp);
498497
if (in_use_count) {
499498
/* failed to free the mempool, caused by the mbuf is still in nix tx queues? */
500-
err("%s, still has %d mbuf in mempool %s\n", __func__, in_use_count, mp->name);
499+
warn("%s, still has %d mbuf in mempool %s\n", __func__, in_use_count, mp->name);
501500
return 0;
502501
}
503502

manager/meson.build

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright 2023 Intel Corporation
33

4-
project('mtl_manager', 'cpp', default_options: ['buildtype=release', 'cpp_std=c++17'], version: '0.3.0')
4+
project('mtl_manager', 'cpp', default_options: ['buildtype=release', 'cpp_std=c++17'],
5+
version: run_command(find_program('cat'), files('../VERSION'), check: true).stdout().strip(),
6+
)
57

68
exec_env = host_machine.system()
79
set_variable('is_windows', exec_env == 'windows')
@@ -34,6 +36,23 @@ if get_option('enable_asan') == true
3436
asan_dep = cpp_c.find_library('asan', required : true)
3537
endif
3638

39+
mtlm_conf = configuration_data()
40+
# get external variables
41+
add_global_arguments('-D__MTLM_GIT__="'+ run_command('git', 'describe', '--abbrev=8', '--dirty', '--always', check: false).stdout().strip() + '"', language : 'cpp')
42+
# parse mtlm config
43+
# parse build config
44+
prj_ver = meson.project_version().split('.')
45+
mtlm_conf.set('MTLM_VERSION_MAJOR', prj_ver.get(0).to_int())
46+
mtlm_conf.set('MTLM_VERSION_MINOR', prj_ver.get(1).to_int())
47+
mtlm_conf.set('MTLM_VERSION_LAST', prj_ver.get(2).to_int())
48+
mtlm_conf.set_quoted('MTLM_VERSION_EXTRA', prj_ver.get(3))
49+
# parse compiler config
50+
cpp_c_ver = cpp_c.get_id() + '-' + cpp_c.version()
51+
mtlm_conf.set_quoted('MTLM_COMPILER', cpp_c_ver)
52+
# build config file
53+
build_cfg = 'mtlm_build_config.h'
54+
configure_file(output: build_cfg, configuration: mtlm_conf)
55+
3756
# xdp check
3857
libxdp_dep = dependency('libxdp', required: false)
3958
libbpf_dep = dependency('libbpf', required: false)

manager/mtl_interface.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ mtl_interface::mtl_interface(unsigned int ifindex)
7979
udp4_dp_filter_fd = -1;
8080
xdp_mode = XDP_MODE_UNSPEC;
8181
if (load_xdp() < 0) throw std::runtime_error("Failed to load XDP program.");
82+
#else
83+
throw std::runtime_error("No XDP support for this build");
8284
#endif
8385
if (parse_combined_info() < 0)
8486
throw std::runtime_error("Failed to parse combined info.");

manager/mtl_manager.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,31 @@
1515
#include "logging.hpp"
1616
#include "mtl_instance.hpp"
1717
#include "mtl_mproto.h"
18+
#include "mtlm_build_config.h"
1819

1920
namespace fs = std::filesystem;
2021

2122
static const int MAX_CLIENTS = 10;
2223

24+
static const char* mtlm_version(void) {
25+
static char version[128];
26+
if (version[0] != 0) return version;
27+
28+
snprintf(version, sizeof(version), "%d.%d.%d.%s %s %s %s", MTLM_VERSION_MAJOR,
29+
MTLM_VERSION_MINOR, MTLM_VERSION_LAST, MTLM_VERSION_EXTRA, __TIMESTAMP__,
30+
__MTLM_GIT__, MTLM_COMPILER);
31+
32+
return version;
33+
}
34+
2335
int main() {
2436
int ret = 0;
2537
bool is_running = true;
2638
int epfd = -1, sockfd = -1;
2739
std::vector<std::unique_ptr<mtl_instance>> clients;
2840

2941
logger::set_log_level(log_level::INFO);
42+
logger::log(log_level::INFO, "MTL Manager version: " + std::string(mtlm_version()));
3043

3144
fs::path directory_path(MTL_MANAGER_SOCK_PATH);
3245
directory_path.remove_filename();
@@ -116,6 +129,9 @@ int main() {
116129

117130
logger::log(log_level::INFO,
118131
"MTL Manager is running. Press Ctrl+C or use SIGINT to stop it.");
132+
#ifndef MTL_HAS_XDP_BACKEND
133+
logger::log(log_level::WARNING, "No XDP support for this build");
134+
#endif
119135

120136
while (is_running) {
121137
std::vector<struct epoll_event> events(clients.size() + 2);

0 commit comments

Comments
 (0)