DPDK patches and discussions
 help / color / mirror / Atom feed
From: <wanry@3snic.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, Renyong Wan <wanry@3snic.com>,
	Steven Song <steven.song@3snic.com>
Subject: [PATCH 02/32] net/sssnic: add log type and log macros
Date: Tue, 29 Aug 2023 15:57:59 +0800	[thread overview]
Message-ID: <20230829075829.208413-3-wanry@3snic.com> (raw)
In-Reply-To: <20230829075829.208413-1-wanry@3snic.com>

From: Renyong Wan <wanry@3snic.com>

Adding log macros to print runtime messages and trace functions.

Signed-off-by: Steven Song <steven.song@3snic.com>
Signed-off-by: Renyong Wan <wanry@3snic.com>
---
 drivers/net/sssnic/sssnic_ethdev.c | 13 ++++++++
 drivers/net/sssnic/sssnic_log.h    | 51 ++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 drivers/net/sssnic/sssnic_log.h

diff --git a/drivers/net/sssnic/sssnic_ethdev.c b/drivers/net/sssnic/sssnic_ethdev.c
index 049fda705a..12438d2ee9 100644
--- a/drivers/net/sssnic/sssnic_ethdev.c
+++ b/drivers/net/sssnic/sssnic_ethdev.c
@@ -6,11 +6,14 @@
 #include <rte_common.h>
 #include <ethdev_pci.h>
 
+#include "sssnic_log.h"
+
 static int
 sssnic_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 {
 	RTE_SET_USED(pci_drv);
 	RTE_SET_USED(pci_dev);
+	PMD_INIT_FUNC_TRACE();
 	return -EINVAL;
 }
 
@@ -18,6 +21,7 @@ static int
 sssnic_pci_remove(struct rte_pci_device *pci_dev)
 {
 	RTE_SET_USED(pci_dev);
+	PMD_INIT_FUNC_TRACE();
 	return -EINVAL;
 }
 
@@ -27,3 +31,12 @@ static struct rte_pci_driver sssnic_pmd = {
 };
 
 RTE_PMD_REGISTER_PCI(net_sssnic, sssnic_pmd);
+
+RTE_LOG_REGISTER_SUFFIX(sssnic_logtype_driver, driver, INFO);
+RTE_LOG_REGISTER_SUFFIX(sssnic_logtype_init, init, NOTICE);
+#ifdef RTE_ETHDEV_DEBUG_RX
+RTE_LOG_REGISTER_SUFFIX(sssnic_logtype_rx, rx, DEBUG);
+#endif /*RTE_ETHDEV_DEBUG_RX*/
+#ifdef RTE_ETHDEV_DEBUG_TX
+RTE_LOG_REGISTER_SUFFIX(sssnic_logtype_tx, tx, DEBUG);
+#endif /*RTE_ETHDEV_DEBUG_TX*/
diff --git a/drivers/net/sssnic/sssnic_log.h b/drivers/net/sssnic/sssnic_log.h
new file mode 100644
index 0000000000..629e12100c
--- /dev/null
+++ b/drivers/net/sssnic/sssnic_log.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2022 Shenzhen 3SNIC Information Technology Co., Ltd.
+ */
+
+#ifndef _SSSNIC_LOG_H_
+#define _SSSNIC_LOG_H_
+
+#include <rte_log.h>
+
+extern int sssnic_logtype_driver;
+extern int sssnic_logtype_init;
+
+#define SSSNIC_LOG_NAME "sssnic"
+#define PMD_DRV_LOG(level, fmt, args...)                                       \
+	rte_log(RTE_LOG_##level, sssnic_logtype_driver,                        \
+		SSSNIC_LOG_NAME ": " fmt "\n", ##args)
+#define PMD_INIT_LOG(level, fmt, args...)                                      \
+	rte_log(RTE_LOG_##level, sssnic_logtype_init, "%s(): " fmt "\n",       \
+		__func__, ##args)
+
+#define SSSNIC_DEBUG(fmt, args...)                                             \
+	PMD_DRV_LOG(DEBUG, "[%s():%d] " fmt, __func__, __LINE__, ##args)
+
+/*
+ * Trace driver init and uninit.
+ */
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+#ifdef RTE_ETHDEV_DEBUG_RX
+extern int sssnic_logtype_rx;
+#define SSSNIC_RX_LOG(level, fmt, args...)                                     \
+	rte_log(RTE_LOG_##level, sssnic_logtype_rx,                            \
+		"sssnic_rx: [%s():%d] " fmt "\n", __func__, __LINE__, ##args)
+#else
+#define SSSNIC_RX_LOG(level, fmt, args...)                                     \
+	do {                                                                   \
+	} while (0)
+#endif /*RTE_ETHDEV_DEBUG_RX*/
+
+#ifdef RTE_ETHDEV_DEBUG_TX
+extern int sssnic_logtype_tx;
+#define SSSNIC_TX_LOG(level, fmt, args...)                                     \
+	rte_log(RTE_LOG_##level, sssnic_logtype_rx,                            \
+		"sssnic_tx: [%s():%d] " fmt "\n", __func__, __LINE__, ##args)
+#else
+#define SSSNIC_TX_LOG(level, fmt, args...)                                     \
+	do {                                                                   \
+	} while (0)
+#endif /*RTE_ETHDEV_DEBUG_TX*/
+
+#endif /*_SSSNIC_LOG_H_*/
-- 
2.27.0


  parent reply	other threads:[~2023-08-29  7:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29  7:57 [PATCH 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters wanry
2023-08-29  7:57 ` [PATCH 01/32] net/sssnic: add build and doc infrastructure wanry
2023-08-29  7:57 ` wanry [this message]
2023-08-29  7:58 ` [PATCH 03/32] net/sssnic: support probe and remove wanry
2023-08-29  7:58 ` [PATCH 04/32] net/sssnic: initialize hardware base wanry
2023-08-29  7:58 ` [PATCH 05/32] net/sssnic: add event queue wanry
2023-08-29  7:58 ` [PATCH 06/32] net/sssnic/base: add message definition and utility wanry
2023-08-29  7:58 ` [PATCH 07/32] net/sssnic/base: add mailbox support wanry
2023-08-29  7:58 ` [PATCH 08/32] net/sssnic/base: add work queue wanry
2023-09-06 15:09   ` Stephen Hemminger
2023-09-07  2:09     ` Renyong Wan
2023-08-29  7:58 ` [PATCH 09/32] net/sssnic/base: add control queue wanry
2023-08-29  7:58 ` [PATCH 10/32] net/sssnic: add dev configure and infos get wanry
2023-08-29  7:58 ` [PATCH 11/32] net/sssnic: add dev MAC ops wanry
2023-08-29  7:58 ` [PATCH 12/32] net/sssnic: support dev link status wanry
2023-08-29  7:58 ` [PATCH 13/32] net/sssnic: support link status event wanry
2023-08-29  7:58 ` [PATCH 14/32] net/sssnic: support Rx queue setup and release wanry
2023-08-29  7:58 ` [PATCH 15/32] net/sssnic: support Tx " wanry
2023-08-29  7:58 ` [PATCH 16/32] net/sssnic: support Rx queue start and stop wanry
2023-08-29  7:58 ` [PATCH 17/32] net/sssnic: support Tx " wanry
2023-08-29  7:58 ` [PATCH 18/32] net/sssnic: add Rx interrupt support wanry
2023-08-29  7:58 ` [PATCH 19/32] net/sssnic: support dev start and stop wanry
2023-08-29  7:58 ` [PATCH 20/32] net/sssnic: support dev close and reset wanry
2023-08-29  7:58 ` [PATCH 21/32] net/sssnic: add allmulticast and promiscuous ops wanry
2023-08-29  7:58 ` [PATCH 22/32] net/sssnic: add basic and extended stats ops wanry
2023-08-29  7:58 ` [PATCH 23/32] net/sssnic: support Rx packet burst wanry
2023-08-29  7:58 ` [PATCH 24/32] net/sssnic: support Tx " wanry
2023-08-29  7:58 ` [PATCH 25/32] net/sssnic: add RSS support wanry
2023-08-29  7:58 ` [PATCH 26/32] net/sssnic: support dev MTU set wanry
2023-08-29  7:58 ` [PATCH 27/32] net/sssnic: support dev queue info get wanry
2023-08-29  7:58 ` [PATCH 28/32] net/sssnic: support dev firmware version get wanry
2023-08-29  7:58 ` [PATCH 29/32] net/sssnic: add dev flow control ops wanry
2023-08-29  7:58 ` [PATCH 30/32] net/sssnic: support VLAN offload and filter wanry
2023-08-29  7:58 ` [PATCH 31/32] net/sssnic: add generic flow ops wanry
2023-08-29  7:58 ` [PATCH 32/32] net/sssnic: add VF dev support wanry

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=20230829075829.208413-3-wanry@3snic.com \
    --to=wanry@3snic.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=steven.song@3snic.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).