DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Shahaf Shuler <shahafs@mellanox.com>, Yongseok Koh <yskoh@mellanox.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v1 2/9] net/mlx5: add log file procedure for debug data
Date: Thu, 30 May 2019 10:20:32 +0000	[thread overview]
Message-ID: <1559211639-17442-3-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1559211639-17442-1-git-send-email-matan@mellanox.com>

Add a global function in the PMD which dumps debug information to
specific file.

The data can be printed in hexadecimal format or as regular string.

The number of debug files per PMD entity should be limited by a new PMD
probe parameter called max_dump_files_num.

The files will be created in the /var/log directory or in the current
directory.

Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 doc/guides/nics/mlx5.rst     |  7 +++++++
 drivers/net/mlx5/mlx5.c      |  8 ++++++++
 drivers/net/mlx5/mlx5.h      |  1 +
 drivers/net/mlx5/mlx5_rxtx.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_rxtx.h |  2 ++
 5 files changed, 62 insertions(+)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 325e9f6..aa89bd9 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -507,6 +507,13 @@ Run-time configuration
 
     representor=[0-2]
 
+- ``max_dump_files_num`` parameter [int]
+
+  The maximum number of files per PMD entity that may be created for debug information.
+  The files will be created in /var/log directory or in current directory.
+
+  set to 128 by default.
+
 Firmware configuration
 ~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 9f5ec97..ebb49c8 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -116,6 +116,9 @@
 /* Select port representors to instantiate. */
 #define MLX5_REPRESENTOR "representor"
 
+/* Device parameter to configure the maximum number of dump files per queue. */
+#define MLX5_MAX_DUMP_FILES_NUM "max_dump_files_num"
+
 #ifndef HAVE_IBV_MLX5_MOD_MPW
 #define MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED (1 << 2)
 #define MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW (1 << 3)
@@ -926,6 +929,8 @@ struct mlx5_dev_spawn_data {
 		config->dv_flow_en = !!tmp;
 	} else if (strcmp(MLX5_MR_EXT_MEMSEG_EN, key) == 0) {
 		config->mr_ext_memseg_en = !!tmp;
+	} else if (strcmp(MLX5_MAX_DUMP_FILES_NUM, key) == 0) {
+		config->max_dump_files_num = tmp;
 	} else {
 		DRV_LOG(WARNING, "%s: unknown parameter", key);
 		rte_errno = EINVAL;
@@ -970,6 +975,7 @@ struct mlx5_dev_spawn_data {
 		MLX5_DV_FLOW_EN,
 		MLX5_MR_EXT_MEMSEG_EN,
 		MLX5_REPRESENTOR,
+		MLX5_MAX_DUMP_FILES_NUM,
 		NULL,
 	};
 	struct rte_kvargs *kvlist;
@@ -1433,6 +1439,8 @@ struct mlx5_dev_spawn_data {
 		DRV_LOG(WARNING, "Multi-Packet RQ isn't supported");
 		config.mprq.enabled = 0;
 	}
+	if (config.max_dump_files_num == 0)
+		config.max_dump_files_num = 128;
 	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		DRV_LOG(ERR, "can not allocate rte ethdev");
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 3eaaafd..4c339d0 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -204,6 +204,7 @@ struct mlx5_dev_config {
 	unsigned int flow_prio; /* Number of flow priorities. */
 	unsigned int tso_max_payload_sz; /* Maximum TCP payload for TSO. */
 	unsigned int ind_table_max_size; /* Maximum indirection table size. */
+	unsigned int max_dump_files_num; /* Maximum dump files per queue. */
 	int txq_inline; /* Maximum packet size for inlining. */
 	int txqs_inline; /* Queue number threshold for inlining. */
 	int txqs_vec; /* Queue number threshold for vectorized Tx. */
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 3da3f62..2c8d066 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -524,6 +524,50 @@
 	return rx_queue_count(rxq);
 }
 
+#define MLX5_SYSTEM_LOG_DIR "/var/log"
+/**
+ * Dump debug information to log file.
+ *
+ * @param fname
+ *   The file name.
+ * @param hex_title
+ *   If not NULL this string is printed as a header to the output
+ *   and the output will be in hexadecimal view.
+ * @param buf
+ *   This is the buffer address to print out.
+ * @param len
+ *   The number of bytes to dump out.
+ */
+void
+mlx5_dump_debug_information(const char *fname, const char *hex_title,
+			    const void *buf, unsigned int hex_len)
+{
+	FILE *fd;
+
+	MKSTR(path, "%s/%s", MLX5_SYSTEM_LOG_DIR, fname);
+	fd = fopen(path, "a+");
+	if (!fd) {
+		DRV_LOG(WARNING, "cannot open %s for debug dump\n",
+			path);
+		MKSTR(path2, "./%s", fname);
+		fd = fopen(path2, "a+");
+		if (!fd) {
+			DRV_LOG(ERR, "cannot open %s for debug dump\n",
+				path2);
+			return;
+		}
+		DRV_LOG(INFO, "New debug dump in file %s\n", path2);
+	} else {
+		DRV_LOG(INFO, "New debug dump in file %s\n", path);
+	}
+	if (hex_title)
+		rte_hexdump(fd, hex_title, buf, hex_len);
+	else
+		fprintf(fd, "%s", (const char *)buf);
+	fprintf(fd, "\n\n\n");
+	fclose(fd);
+}
+
 /**
  * DPDK callback for TX.
  *
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 7bacdba..35e53fc 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -356,6 +356,8 @@ uint16_t removed_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts,
 int mlx5_rx_descriptor_status(void *rx_queue, uint16_t offset);
 int mlx5_tx_descriptor_status(void *tx_queue, uint16_t offset);
 uint32_t mlx5_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+void mlx5_dump_debug_information(const char *path, const char *title,
+				 const void *buf, unsigned int len);
 
 /* Vectorized version of mlx5_rxtx.c */
 int mlx5_check_raw_vec_tx_support(struct rte_eth_dev *dev);
-- 
1.8.3.1


  parent reply	other threads:[~2019-05-30 10:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 10:20 [dpdk-dev] [PATCH v1 0/9] mlx5: Handle data-path completions with error Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 1/9] net/mlx5: remove Rx queues indexes correlation Matan Azrad
2019-05-30 10:20 ` Matan Azrad [this message]
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 3/9] net/mlx5: fix device arguments error detection Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 4/9] net/mlx5: mitigate Rx doorbell memory barrier Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 5/9] net/mlx5: separate Rx queue initialization Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 6/9] net/mlx5: extend Rx completion with error handling Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 7/9] net/mlx5: handle Tx completion with error Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 8/9] net/mlx5: recover secondary process Rx errors Matan Azrad
2019-05-30 10:20 ` [dpdk-dev] [PATCH v1 9/9] net/mlx5: recover secondary process Tx errors Matan Azrad
2019-09-12 12:14 ` [dpdk-dev] [PATCH v1 0/9] mlx5: Handle data-path completions with error Kevin Traynor
2019-09-22  7:03   ` Matan Azrad

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=1559211639-17442-3-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=yskoh@mellanox.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).