DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nicolas Chautru <nicolas.chautru@intel.com>
To: dev@dpdk.org, maxime.coquelin@redhat.com
Cc: hemant.agrawal@nxp.com, hernan.vargas@intel.com,
	Nicolas Chautru <nicolas.chautru@intel.com>
Subject: [PATCH v2 3/3] baseband/acc: add internal logging
Date: Thu, 23 Jan 2025 14:55:19 -0800	[thread overview]
Message-ID: <20250123225519.2469167-4-nicolas.chautru@intel.com> (raw)
In-Reply-To: <20250123225519.2469167-1-nicolas.chautru@intel.com>

Adds internal buffer for more flexible logging.

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
---
 drivers/baseband/acc/acc_common.h  | 22 +++++++++++++++++++---
 drivers/baseband/acc/rte_vrb_pmd.c | 18 +++++++++++++++++-
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/drivers/baseband/acc/acc_common.h b/drivers/baseband/acc/acc_common.h
index 4880444450..06255ff5f1 100644
--- a/drivers/baseband/acc/acc_common.h
+++ b/drivers/baseband/acc/acc_common.h
@@ -152,6 +152,8 @@
 #define ACC_MAX_FFT_WIN      16
 #define ACC_MAX_RING_BUFFER  64
 #define VRB2_MAX_Q_PER_OP 256
+#define ACC_MAX_LOGLEN    256
+#define ACC_MAX_BUFFERLEN 256
 
 extern int acc_common_logtype;
 #define RTE_LOGTYPE_ACC_COMMON acc_common_logtype
@@ -652,6 +654,9 @@ struct __rte_cache_aligned acc_queue {
 	rte_iova_t fcw_ring_addr_iova;
 	int8_t *derm_buffer; /* interim buffer for de-rm in SDK */
 	struct acc_device *d;
+	char error_bufs[ACC_MAX_BUFFERLEN][ACC_MAX_LOGLEN]; /**< Buffer for error log. */
+	uint16_t error_head;  /**< Head - Buffer for error log. */
+	uint16_t  error_wrap; /**< Wrap Counter - Buffer for error log. */
 };
 
 /* These strings for rte_trace must be limited to RTE_TRACE_EMIT_STRING_LEN_MAX. */
@@ -690,11 +695,21 @@ __rte_format_printf(4, 5)
 static inline void
 acc_error_log(struct acc_queue *q, void *op, uint8_t acc_error_idx, const char *fmt, ...)
 {
-	va_list args;
-	RTE_SET_USED(op);
+	va_list args, args2;
+	static char str[1024];
+
 	va_start(args, fmt);
+	va_copy(args2, args);
 	rte_vlog(RTE_LOG_ERR, acc_common_logtype, fmt, args);
-
+	vsnprintf(q->error_bufs[q->error_head], ACC_MAX_LOGLEN, fmt, args2);
+	q->error_head++;
+	snprintf(q->error_bufs[q->error_head], ACC_MAX_LOGLEN,
+			"%s", rte_bbdev_ops_param_string(op, q->op_type, str, sizeof(str)));
+	q->error_head++;
+	if (q->error_head == ACC_MAX_LOGLEN) {
+		q->error_head = 0;
+		q->error_wrap++;
+	}
 	if (acc_error_idx > ACC_ERR_MAX)
 		acc_error_idx = ACC_ERR_MAX;
 
@@ -702,6 +717,7 @@ acc_error_log(struct acc_queue *q, void *op, uint8_t acc_error_idx, const char *
 			acc_error_string[acc_error_idx]);
 
 	va_end(args);
+	va_end(args2);
 }
 
 /* Write to MMIO register address */
diff --git a/drivers/baseband/acc/rte_vrb_pmd.c b/drivers/baseband/acc/rte_vrb_pmd.c
index 27620ccc10..d81c5d460c 100644
--- a/drivers/baseband/acc/rte_vrb_pmd.c
+++ b/drivers/baseband/acc/rte_vrb_pmd.c
@@ -1135,6 +1135,10 @@ vrb_queue_setup(struct rte_bbdev *dev, uint16_t queue_id,
 	q->mmio_reg_enqueue = RTE_PTR_ADD(d->mmio_base,
 			d->queue_offset(d->pf_device, q->vf_id, q->qgrp_id, q->aq_id));
 
+	/** initialize the error buffer. */
+	q->error_head = 0;
+	q->error_wrap = 0;
+
 	rte_bbdev_log_debug(
 			"Setup dev%u q%u: qgrp_id=%u, vf_id=%u, aq_id=%u, aq_depth=%u, mmio_reg_enqueue=%p base %p",
 			dev->data->dev_id, queue_id, q->qgrp_id, q->vf_id,
@@ -1516,7 +1520,7 @@ vrb_queue_ops_dump(struct rte_bbdev *dev, uint16_t queue_id, FILE *f)
 {
 	struct acc_queue *q = dev->data->queues[queue_id].queue_private;
 	struct rte_bbdev_dec_op *op;
-	uint16_t i, int_nb;
+	uint16_t start_err, end_err, i, int_nb;
 	volatile union acc_info_ring_data *ring_data;
 	uint16_t info_ring_head = q->d->info_ring_head;
 	static char str[1024];
@@ -1533,6 +1537,18 @@ vrb_queue_ops_dump(struct rte_bbdev *dev, uint16_t queue_id, FILE *f)
 			q->aq_enqueued, q->aq_dequeued, q->aq_depth,
 			acc_ring_avail_enq(q), acc_ring_avail_deq(q));
 
+	/** Print information captured in the error buffer. */
+	if (q->error_wrap == 0) {
+		start_err = 0;
+		end_err = q->error_head;
+	} else {
+		start_err = q->error_head;
+		end_err = q->error_head + ACC_MAX_BUFFERLEN;
+	}
+	fprintf(f, "Error Buffer - Head %d Wrap %d\n", q->error_head, q->error_wrap);
+	for (i = start_err; i < end_err; ++i)
+		fprintf(f, "  %d\t%s", i, q->error_bufs[i % ACC_MAX_BUFFERLEN]);
+
 	/** Print information captured in the info ring. */
 	if (q->d->info_ring != NULL) {
 		fprintf(f, "Info Ring Buffer - Head %d\n", q->d->info_ring_head);
-- 
2.34.1


  parent reply	other threads:[~2025-01-23 23:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 22:55 [PATCH v2 0/3] bbdev: trace point and logging Nicolas Chautru
2025-01-23 22:55 ` [PATCH v2 1/3] bbdev: add trace point Nicolas Chautru
2025-01-23 22:55 ` [PATCH v2 2/3] baseband/acc: " Nicolas Chautru
2025-01-23 22:55 ` Nicolas Chautru [this message]
2025-01-23 23:24   ` [PATCH v2 3/3] baseband/acc: add internal logging Stephen Hemminger

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=20250123225519.2469167-4-nicolas.chautru@intel.com \
    --to=nicolas.chautru@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=hernan.vargas@intel.com \
    --cc=maxime.coquelin@redhat.com \
    /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).