
From: wenglianfa <wenglianfa@huawei.com> Add initial support for HNS LTTng tracing. Add a new libhns_trace so that the original libhns does not need to have a dependency on LTTng. Signed-off-by: wenglianfa <wenglianfa@huawei.com> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> --- providers/hns/CMakeLists.txt | 12 ++++++ providers/hns/hns_roce_u_hw_v2.c | 3 ++ providers/hns/hns_roce_u_trace.c | 36 ++++++++++++++++++ providers/hns/hns_roce_u_trace.h | 63 ++++++++++++++++++++++++++++++++ providers/hns/libhns_trace.map | 5 +++ 5 files changed, 119 insertions(+) create mode 100644 providers/hns/hns_roce_u_trace.c create mode 100644 providers/hns/hns_roce_u_trace.h create mode 100644 providers/hns/libhns_trace.map diff --git a/providers/hns/CMakeLists.txt b/providers/hns/CMakeLists.txt index 58139ae2b..84ddd6912 100644 --- a/providers/hns/CMakeLists.txt +++ b/providers/hns/CMakeLists.txt @@ -1,3 +1,10 @@ +if (ENABLE_LTTNG AND LTTNGUST_FOUND) + rdma_shared_provider(hns_trace libhns_trace.map + 1 1.0.${PACKAGE_VERSION} + hns_roce_u_trace.c +) +endif() + rdma_shared_provider(hns libhns.map 1 1.0.${PACKAGE_VERSION} hns_roce_u.c @@ -12,3 +19,8 @@ publish_headers(infiniband ) rdma_pkg_config("hns" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}") + +if (ENABLE_LTTNG AND LTTNGUST_FOUND) + target_include_directories(hns_trace PUBLIC ".") + target_link_libraries(hns_trace LINK_PRIVATE LTTng::UST) +endif() diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index c02d2c1b8..b4b335fba 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -39,6 +39,9 @@ #include "hns_roce_u_db.h" #include "hns_roce_u_hw_v2.h" +#define LTTNG_UST_TRACEPOINT_DEFINE +#define LTTNG_UST_TRACEPOINT_PROBE_DYNAMIC_LINKAGE + #define HR_IBV_OPC_MAP(ib_key, hr_key) \ [IBV_WR_ ## ib_key] = HNS_ROCE_WQE_OP_ ## hr_key diff --git a/providers/hns/hns_roce_u_trace.c b/providers/hns/hns_roce_u_trace.c new file mode 100644 index 000000000..65aa45ca3 --- /dev/null +++ b/providers/hns/hns_roce_u_trace.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +/* + * Copyright (c) 2025 Hisilicon Limited. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define LTTNG_UST_TRACEPOINT_CREATE_PROBES + +#include "hns_roce_u_trace.h" diff --git a/providers/hns/hns_roce_u_trace.h b/providers/hns/hns_roce_u_trace.h new file mode 100644 index 000000000..74d33344d --- /dev/null +++ b/providers/hns/hns_roce_u_trace.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ +/* + * Copyright (c) 2025 Hisilicon Limited. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#if defined(LTTNG_ENABLED) + +#undef LTTNG_UST_TRACEPOINT_PROVIDER +#define LTTNG_UST_TRACEPOINT_PROVIDER rdma_core_hns + +#undef LTTNG_UST_TRACEPOINT_INCLUDE +#define LTTNG_UST_TRACEPOINT_INCLUDE "hns_roce_u_trace.h" + +#if !defined(__HNS_TRACE_H__) || defined(LTTNG_UST_TRACEPOINT_HEADER_MULTI_READ) +#define __HNS_TRACE_H__ + +#include <lttng/tracepoint.h> +#include <infiniband/verbs.h> + +#define rdma_tracepoint(arg...) lttng_ust_tracepoint(arg) + +#endif /* __HNS_TRACE_H__*/ + +#include <lttng/tracepoint-event.h> + +#else + +#ifndef __HNS_TRACE_H__ +#define __HNS_TRACE_H__ + +#define rdma_tracepoint(arg...) + +#endif /* __HNS_TRACE_H__*/ + +#endif /* defined(LTTNG_ENABLED) */ diff --git a/providers/hns/libhns_trace.map b/providers/hns/libhns_trace.map new file mode 100644 index 000000000..e74bc7479 --- /dev/null +++ b/providers/hns/libhns_trace.map @@ -0,0 +1,5 @@ +/* Export symbols should be added below according to + Documentation/versioning.md document. */ +HNS_TRACE_1.0 { + global:*; +}; \ No newline at end of file -- 2.33.0