DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <mb@smartsharesystems.com>,
	<david.marchand@redhat.com>, Kevin Laatz <kevin.laatz@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>
Subject: [PATCH] dmadev: add tracepoints at control path APIs
Date: Fri, 20 Oct 2023 02:21:36 +0000	[thread overview]
Message-ID: <20231020022136.44720-1-fengchengwen@huawei.com> (raw)
In-Reply-To: <20230412024808.41339-1-fengchengwen@huawei.com>

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 <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@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


  parent reply	other threads:[~2023-10-20  2:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12  2:48 [PATCH] dmadev: add tracepoints Chengwen Feng
2023-04-12  9:52 ` Bruce Richardson
2023-04-13  3:44   ` fengchengwen
2023-04-13  8:45     ` Bruce Richardson
2023-04-12 11:00 ` Morten Brørup
2023-04-13  6:30   ` fengchengwen
2023-04-13  8:25     ` Morten Brørup
2023-04-15  0:33 ` [PATCH v3] " Chengwen Feng
2023-05-24 21:12   ` Thomas Monjalon
2023-05-27  0:17     ` fengchengwen
2023-05-26  8:42 ` [PATCH v4] " Chengwen Feng
2023-07-03  3:54   ` fengchengwen
2023-07-07 10:40   ` Thomas Monjalon
2023-07-09  3:23     ` fengchengwen
2023-07-10  6:49       ` Thomas Monjalon
2023-07-10  7:50         ` fengchengwen
2023-07-31 12:48           ` Thomas Monjalon
2023-08-03  7:52             ` fengchengwen
2023-08-14 14:16               ` Thomas Monjalon
2023-10-11  9:55                 ` fengchengwen
2023-11-06 20:59                   ` Thomas Monjalon
2023-11-07  1:26                     ` fengchengwen
2024-01-12 10:38                     ` fengchengwen
2023-10-20  2:21 ` Chengwen Feng [this message]
2023-11-06 20:55   ` [PATCH] dmadev: add tracepoints at control path APIs Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231020022136.44720-1-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=kevin.laatz@intel.com \
    --cc=mb@smartsharesystems.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).