From patchwork Mon Sep 4 04:56:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renyong Wan X-Patchwork-Id: 131101 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 75280424E7; Mon, 4 Sep 2023 06:57:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35AE0402CA; Mon, 4 Sep 2023 06:57:26 +0200 (CEST) Received: from VLXDG1SPAM1.ramaxel.com (email.unionmem.com [221.4.138.186]) by mails.dpdk.org (Postfix) with ESMTP id 79A1D402C8 for ; Mon, 4 Sep 2023 06:57:24 +0200 (CEST) Received: from V12DG1MBS03.ramaxel.local ([172.26.18.33]) by VLXDG1SPAM1.ramaxel.com with ESMTP id 3844v8w4054227; Mon, 4 Sep 2023 12:57:09 +0800 (GMT-8) (envelope-from wanry@3snic.com) Received: from localhost.localdomain (10.64.136.151) by V12DG1MBS03.ramaxel.local (172.26.18.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.17; Mon, 4 Sep 2023 12:57:07 +0800 From: To: CC: , Renyong Wan , Steven Song Subject: [PATCH v5 02/32] net/sssnic: add log type and log macros Date: Mon, 4 Sep 2023 12:56:28 +0800 Message-ID: <20230904045658.238185-3-wanry@3snic.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230904045658.238185-1-wanry@3snic.com> References: <20230904045658.238185-1-wanry@3snic.com> MIME-Version: 1.0 X-Originating-IP: [10.64.136.151] X-ClientProxiedBy: V12DG1MBS03.ramaxel.local (172.26.18.33) To V12DG1MBS03.ramaxel.local (172.26.18.33) X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: VLXDG1SPAM1.ramaxel.com 3844v8w4054227 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Renyong Wan Adding log macros to print runtime messages and trace functions. Signed-off-by: Steven Song Signed-off-by: Renyong Wan --- 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 dcda01eeb8..0f1017af9d 100644 --- a/drivers/net/sssnic/sssnic_ethdev.c +++ b/drivers/net/sssnic/sssnic_ethdev.c @@ -5,11 +5,14 @@ #include #include +#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; } @@ -17,6 +20,7 @@ static int sssnic_pci_remove(struct rte_pci_device *pci_dev) { RTE_SET_USED(pci_dev); + PMD_INIT_FUNC_TRACE(); return -EINVAL; } @@ -26,3 +30,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 + +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_*/