From: Tom Jones Date: Thu, 25 Jan 2024 10:28:16 +0000 (+0000) Subject: vppinfra: Put clib_perf* behind Linux checks and provide stubs for FreeBSD X-Git-Tag: v24.10-rc0~255 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F51%2F40251%2F3;hp=a0b85388377913118ee8437ee23ab3d1ff4bee99;p=vpp.git vppinfra: Put clib_perf* behind Linux checks and provide stubs for FreeBSD As a placeholder stub out clib_perf functions on FreeBSD, the interface for performance counters on FreeBSD is different and will require its own implementation. Type: improvement Change-Id: I61511ebe5ee1fd6fe93d3179c7843c811f47a846 Signed-off-by: Tom Jones --- diff --git a/src/vppinfra/perfmon/perfmon.h b/src/vppinfra/perfmon/perfmon.h index d940921d6bf..5b904a632e3 100644 --- a/src/vppinfra/perfmon/perfmon.h +++ b/src/vppinfra/perfmon/perfmon.h @@ -68,6 +68,7 @@ extern clib_perfmon_main_t clib_perfmon_main; static_always_inline void clib_perfmon_ioctl (int fd, u32 req) { +#ifdef __linux__ #ifdef __x86_64__ asm volatile("syscall" : @@ -76,6 +77,7 @@ clib_perfmon_ioctl (int fd, u32 req) #else ioctl (fd, req, PERF_IOC_FLAG_GROUP); #endif +#endif /* linux */ } clib_error_t *clib_perfmon_init_by_bundle_name (clib_perfmon_ctx_t *ctx, @@ -87,6 +89,7 @@ u64 *clib_perfmon_capture (clib_perfmon_ctx_t *ctx, u32 n_ops, char *fmt, ...); void clib_perfmon_capture_group (clib_perfmon_ctx_t *ctx, char *fmt, ...); format_function_t format_perfmon_bundle; +#ifdef __linux__ static_always_inline void clib_perfmon_reset (clib_perfmon_ctx_t *ctx) { @@ -102,6 +105,23 @@ clib_perfmon_disable (clib_perfmon_ctx_t *ctx) { clib_perfmon_ioctl (ctx->group_fd, PERF_EVENT_IOC_DISABLE); } +#elif __FreeBSD__ +static_always_inline void +clib_perfmon_reset (clib_perfmon_ctx_t *ctx) +{ + /* TODO: Implement for FreeBSD */ +} +static_always_inline void +clib_perfmon_enable (clib_perfmon_ctx_t *ctx) +{ + /* TODO: Implement for FreeBSD */ +} +static_always_inline void +clib_perfmon_disable (clib_perfmon_ctx_t *ctx) +{ + /* TODO: Implement for FreeBSD */ +} +#endif /* linux */ #define CLIB_PERFMON_BUNDLE(x) \ static clib_perfmon_bundle_reg_t clib_perfmon_bundle_reg_##x; \ diff --git a/src/vppinfra/test/test.h b/src/vppinfra/test/test.h index a0e5f6db669..8d756366163 100644 --- a/src/vppinfra/test/test.h +++ b/src/vppinfra/test/test.h @@ -84,6 +84,7 @@ extern test_main_t test_main; __VA_ARGS__, {} \ } +#ifdef __linux__ static_always_inline void test_perf_event_reset (test_perf_t *t) { @@ -99,6 +100,23 @@ test_perf_event_disable (test_perf_t *t) { clib_perfmon_ioctl (t->fd, PERF_EVENT_IOC_DISABLE); } +#elif __FreeBSD__ +static_always_inline void +test_perf_event_reset (test_perf_t *t) +{ + /* TODO: Implement for FreeBSD */ +} +static_always_inline void +test_perf_event_enable (test_perf_t *t) +{ + /* TODO: Implement for FreeBSD */ +} +static_always_inline void +test_perf_event_disable (test_perf_t *t) +{ + /* TODO: Implement for FreeBSD */ +} +#endif void *test_mem_alloc (uword size); void *test_mem_alloc_and_fill_inc_u8 (uword size, u8 start, u8 mask);