Add tracepoints at control path APIs for tracing support.

Note: Fast path APIs don't support tracepoints because the APIs contains
struct and enum, if adding tracepints will lead to chkincs failure.

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
Acked-by: Morten Brørup <m...@smartsharesystems.com>

---
v5: Only support control path APIs tracepoints.
v4: Fix asan smoke fail.
v3: Address Morten's comment:
    Move stats_get and vchan_status and to trace_fp.h.
v2: Address Morten's comment:
    Make stats_get as fast-path trace-points.
    Place fast-path trace-point functions behind in version.map.

---
 lib/dmadev/meson.build               |   2 +-
 lib/dmadev/rte_dmadev.c              |  25 +++++-
 lib/dmadev/rte_dmadev_trace.h        | 123 +++++++++++++++++++++++++++
 lib/dmadev/rte_dmadev_trace_points.c |  31 +++++++
 4 files changed, 176 insertions(+), 5 deletions(-)
 create mode 100644 lib/dmadev/rte_dmadev_trace.h
 create mode 100644 lib/dmadev/rte_dmadev_trace_points.c

diff --git a/lib/dmadev/meson.build b/lib/dmadev/meson.build
index 2f17587b75..e0d90aea67 100644
--- a/lib/dmadev/meson.build
+++ b/lib/dmadev/meson.build
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2021 HiSilicon Limited.
 
-sources = files('rte_dmadev.c')
+sources = files('rte_dmadev.c', 'rte_dmadev_trace_points.c')
 headers = files('rte_dmadev.h')
 indirect_headers += files('rte_dmadev_core.h')
 driver_sdk_headers += files('rte_dmadev_pmd.h')
diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index bf7d5ec519..4e5e420c82 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -17,6 +17,7 @@
 
 #include "rte_dmadev.h"
 #include "rte_dmadev_pmd.h"
+#include "rte_dmadev_trace.h"
 
 static int16_t dma_devices_max;
 
@@ -434,6 +435,8 @@ rte_dma_info_get(int16_t dev_id, struct rte_dma_info 
*dev_info)
        dev_info->numa_node = dev->device->numa_node;
        dev_info->nb_vchans = dev->data->dev_conf.nb_vchans;
 
+       rte_dma_trace_info_get(dev_id, dev_info);
+
        return 0;
 }
 
@@ -483,6 +486,8 @@ rte_dma_configure(int16_t dev_id, const struct rte_dma_conf 
*dev_conf)
                memcpy(&dev->data->dev_conf, dev_conf,
                       sizeof(struct rte_dma_conf));
 
+       rte_dma_trace_configure(dev_id, dev_conf, ret);
+
        return ret;
 }
 
@@ -509,6 +514,7 @@ rte_dma_start(int16_t dev_id)
                goto mark_started;
 
        ret = (*dev->dev_ops->dev_start)(dev);
+       rte_dma_trace_start(dev_id, ret);
        if (ret != 0)
                return ret;
 
@@ -535,6 +541,7 @@ rte_dma_stop(int16_t dev_id)
                goto mark_stopped;
 
        ret = (*dev->dev_ops->dev_stop)(dev);
+       rte_dma_trace_stop(dev_id, ret);
        if (ret != 0)
                return ret;
 
@@ -565,6 +572,8 @@ rte_dma_close(int16_t dev_id)
        if (ret == 0)
                dma_release(dev);
 
+       rte_dma_trace_close(dev_id, ret);
+
        return ret;
 }
 
@@ -655,8 +664,11 @@ rte_dma_vchan_setup(int16_t dev_id, uint16_t vchan,
 
        if (*dev->dev_ops->vchan_setup == NULL)
                return -ENOTSUP;
-       return (*dev->dev_ops->vchan_setup)(dev, vchan, conf,
+       ret = (*dev->dev_ops->vchan_setup)(dev, vchan, conf,
                                        sizeof(struct rte_dma_vchan_conf));
+       rte_dma_trace_vchan_setup(dev_id, vchan, conf, ret);
+
+       return ret;
 }
 
 int
@@ -685,6 +697,7 @@ int
 rte_dma_stats_reset(int16_t dev_id, uint16_t vchan)
 {
        struct rte_dma_dev *dev = &rte_dma_devices[dev_id];
+       int ret;
 
        if (!rte_dma_is_valid(dev_id))
                return -EINVAL;
@@ -698,7 +711,10 @@ rte_dma_stats_reset(int16_t dev_id, uint16_t vchan)
 
        if (*dev->dev_ops->stats_reset == NULL)
                return -ENOTSUP;
-       return (*dev->dev_ops->stats_reset)(dev, vchan);
+       ret = (*dev->dev_ops->stats_reset)(dev, vchan);
+       rte_dma_trace_stats_reset(dev_id, vchan, ret);
+
+       return ret;
 }
 
 int
@@ -792,9 +808,10 @@ rte_dma_dump(int16_t dev_id, FILE *f)
                dev->data->dev_conf.enable_silent ? "on" : "off");
 
        if (dev->dev_ops->dev_dump != NULL)
-               return (*dev->dev_ops->dev_dump)(dev, f);
+               ret = (*dev->dev_ops->dev_dump)(dev, f);
+       rte_dma_trace_dump(dev_id, f, ret);
 
-       return 0;
+       return ret;
 }
 
 static int
diff --git a/lib/dmadev/rte_dmadev_trace.h b/lib/dmadev/rte_dmadev_trace.h
new file mode 100644
index 0000000000..e55c4c6091
--- /dev/null
+++ b/lib/dmadev/rte_dmadev_trace.h
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 HiSilicon Limited
+ */
+
+#ifndef RTE_DMADEV_TRACE_H
+#define RTE_DMADEV_TRACE_H
+
+/**
+ * @file
+ *
+ * API for dmadev trace support.
+ */
+
+#include <rte_trace_point.h>
+
+#include "rte_dmadev.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+RTE_TRACE_POINT(
+       rte_dma_trace_info_get,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, struct rte_dma_info *dev_info),
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
+       struct rte_dma_info __dev_info = {0};
+       dev_info = &__dev_info;
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_string(dev_info->dev_name);
+       rte_trace_point_emit_u64(dev_info->dev_capa);
+       rte_trace_point_emit_u16(dev_info->max_vchans);
+       rte_trace_point_emit_u16(dev_info->max_desc);
+       rte_trace_point_emit_u16(dev_info->min_desc);
+       rte_trace_point_emit_u16(dev_info->max_sges);
+       rte_trace_point_emit_i16(dev_info->numa_node);
+       rte_trace_point_emit_u16(dev_info->nb_vchans);
+)
+
+RTE_TRACE_POINT(
+       rte_dma_trace_configure,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, const struct rte_dma_conf 
*dev_conf,
+                            int ret),
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
+       const struct rte_dma_conf __dev_conf = {0};
+       dev_conf = &__dev_conf;
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
+       int enable_silent = (int)dev_conf->enable_silent;
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_u16(dev_conf->nb_vchans);
+       rte_trace_point_emit_int(enable_silent);
+       rte_trace_point_emit_int(ret);
+)
+
+RTE_TRACE_POINT(
+       rte_dma_trace_start,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, int ret),
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_int(ret);
+)
+
+RTE_TRACE_POINT(
+       rte_dma_trace_stop,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, int ret),
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_int(ret);
+)
+
+RTE_TRACE_POINT(
+       rte_dma_trace_close,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, int ret),
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_int(ret);
+)
+
+RTE_TRACE_POINT(
+       rte_dma_trace_vchan_setup,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan,
+                            const struct rte_dma_vchan_conf *conf, int ret),
+#ifdef _RTE_TRACE_POINT_REGISTER_H_
+       const struct rte_dma_vchan_conf __conf = {0};
+       conf = &__conf;
+#endif /* _RTE_TRACE_POINT_REGISTER_H_ */
+       int src_port_type = conf->src_port.port_type;
+       int dst_port_type = conf->dst_port.port_type;
+       int direction = conf->direction;
+       uint64_t src_pcie_cfg;
+       uint64_t dst_pcie_cfg;
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_u16(vchan);
+       rte_trace_point_emit_int(direction);
+       rte_trace_point_emit_u16(conf->nb_desc);
+       rte_trace_point_emit_int(src_port_type);
+       memcpy(&src_pcie_cfg, &conf->src_port.pcie, sizeof(uint64_t));
+       rte_trace_point_emit_u64(src_pcie_cfg);
+       memcpy(&dst_pcie_cfg, &conf->dst_port.pcie, sizeof(uint64_t));
+       rte_trace_point_emit_int(dst_port_type);
+       rte_trace_point_emit_u64(dst_pcie_cfg);
+       rte_trace_point_emit_ptr(conf->auto_free.m2d.pool);
+       rte_trace_point_emit_int(ret);
+)
+
+RTE_TRACE_POINT(
+       rte_dma_trace_stats_reset,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, uint16_t vchan, int ret),
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_u16(vchan);
+       rte_trace_point_emit_int(ret);
+)
+
+RTE_TRACE_POINT(
+       rte_dma_trace_dump,
+       RTE_TRACE_POINT_ARGS(int16_t dev_id, FILE *f, int ret),
+       rte_trace_point_emit_i16(dev_id);
+       rte_trace_point_emit_ptr(f);
+       rte_trace_point_emit_int(ret);
+)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RTE_DMADEV_TRACE_H */
diff --git a/lib/dmadev/rte_dmadev_trace_points.c 
b/lib/dmadev/rte_dmadev_trace_points.c
new file mode 100644
index 0000000000..2a83b90cb3
--- /dev/null
+++ b/lib/dmadev/rte_dmadev_trace_points.c
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2023 HiSilicon Limited
+ */
+
+#include <rte_trace_point_register.h>
+
+#include "rte_dmadev_trace.h"
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_info_get,
+       lib.dmadev.info_get)
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_configure,
+       lib.dmadev.configure)
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_start,
+       lib.dmadev.start)
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_stop,
+       lib.dmadev.stop)
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_close,
+       lib.dmadev.close)
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_vchan_setup,
+       lib.dmadev.vchan_setup)
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_stats_reset,
+       lib.dmadev.stats_reset)
+
+RTE_TRACE_POINT_REGISTER(rte_dma_trace_dump,
+       lib.dmadev.dump)
-- 
2.17.1

Reply via email to