From patchwork Tue Sep 10 09:56:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L6aKi?= X-Patchwork-Id: 143904 X-Patchwork-Delegate: thomas@monjalon.net 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 6640145954; Tue, 10 Sep 2024 11:56:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 250E642D90; Tue, 10 Sep 2024 11:56:37 +0200 (CEST) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by mails.dpdk.org (Postfix) with ESMTP id 02196427B6 for ; Tue, 10 Sep 2024 11:56:34 +0200 (CEST) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 48A9uUozD1876420, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realsil.com.cn; s=dkim; t=1725962192; bh=7p5PJO/LdT9NQ+K54UgytRHF6PVpSxS4NQevcr/m7TA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:Content-Type; b=a9YsEsHQPqpZjKiv61cSyb5Wfmp8Rg1c0i1tW6roALttyTaC3r6rM+g0P/nPypAD6 qYn9k5Vg2/NZK/gW5Xft2jtfCZtmEq4K/ZtHKJVwwotovt0NGfPXnzS5y6ib1VUqfl oSQ076BNEZl9w7fNo86mJt+2giNFIi9p3QdFmvA6CXcB4LQCAgE5GgepaEIhgaUXUg 78K2BI2ZYEmHX0NZmDfNV/xeMId4O3D6bk6FIBbaP385j4DPIUd7PGYtbjU0fV3duZ NavfLaeql0MpuZNkldncvF8USq/6S4+fYJnm7JvICV6/Pwi+Mxc//xxpUW3CY5xzGK hez00MJyHP/Cg== Received: from RSEXMBS03.realsil.com.cn ([172.29.17.197]) by rtits2.realtek.com.tw (8.15.2/3.05/5.92) with ESMTPS id 48A9uUozD1876420 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 10 Sep 2024 17:56:31 +0800 Received: from RSEXH36501.realsil.com.cn (172.29.17.2) by RSEXMBS03.realsil.com.cn (172.29.17.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 10 Sep 2024 17:56:31 +0800 Received: from 172.29.32.27 (172.29.32.27) by RSEXH36501.realsil.com.cn (172.29.17.2) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Tue, 10 Sep 2024 17:56:31 +0800 From: Howard Wang To: CC: , Howard Wang Subject: [PATCH] net/r8169: add logging structure Date: Tue, 10 Sep 2024 17:56:19 +0800 Message-ID: <20240910095619.15653-1-howard_wang@realsil.com.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 Implement logging macros for debug purposes. Signed-off-by: Howard Wang --- drivers/net/r8169/r8169_ethdev.c | 40 ++++++++++++++++++++++++ drivers/net/r8169/r8169_logs.h | 53 ++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 drivers/net/r8169/r8169_logs.h diff --git a/drivers/net/r8169/r8169_ethdev.c b/drivers/net/r8169/r8169_ethdev.c index b3db7fdaab..755d06f907 100644 --- a/drivers/net/r8169/r8169_ethdev.c +++ b/drivers/net/r8169/r8169_ethdev.c @@ -179,3 +179,43 @@ RTE_PMD_REGISTER_PCI(net_r8169, rte_r8169_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_r8169, pci_id_r8169_map); RTE_PMD_REGISTER_KMOD_DEP(net_r8169, "* igb_uio | uio_pci_generic | vfio-pci"); +int r8169_logtype_init; +int r8169_logtype_driver; + +#ifdef RTE_LIBRTE_R8169_DEBUG_RX +int r8169_logtype_rx; +#endif +#ifdef RTE_LIBRTE_R8169_DEBUG_TX +int r8169_logtype_tx; +#endif +#ifdef RTE_LIBRTE_R8169_DEBUG_TX_FREE +int r8169_logtype_tx_free; +#endif + +RTE_INIT(r8169_init_log) +{ + r8169_logtype_init = rte_log_register("pmd.net.r8169.init"); + if (r8169_logtype_init >= 0) + rte_log_set_level(r8169_logtype_init, RTE_LOG_NOTICE); + r8169_logtype_driver = rte_log_register("pmd.net.r8169.driver"); + if (r8169_logtype_driver >= 0) + rte_log_set_level(r8169_logtype_driver, RTE_LOG_NOTICE); +#ifdef RTE_LIBRTE_R8169_DEBUG_RX + r8169_logtype_rx = rte_log_register("pmd.net.r8169.rx"); + if (r8169_logtype_rx >= 0) + rte_log_set_level(r8169_logtype_rx, RTE_LOG_DEBUG); +#endif + +#ifdef RTE_LIBRTE_R8169_DEBUG_TX + r8169_logtype_tx = rte_log_register("pmd.net.r8169.tx"); + if (r8169_logtype_tx >= 0) + rte_log_set_level(r8169_logtype_tx, RTE_LOG_DEBUG); +#endif + +#ifdef RTE_LIBRTE_R8169_DEBUG_TX_FREE + r8169_logtype_tx_free = rte_log_register("pmd.net.r8169.tx_free"); + if (r8169_logtype_tx_free >= 0) + rte_log_set_level(r8169_logtype_tx_free, RTE_LOG_DEBUG); +#endif +} + diff --git a/drivers/net/r8169/r8169_logs.h b/drivers/net/r8169/r8169_logs.h new file mode 100644 index 0000000000..6ce5b4b5ac --- /dev/null +++ b/drivers/net/r8169/r8169_logs.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Realtek Corporation. All rights reserved + */ + +#ifndef _R8169_LOGS_H_ +#define _R8169_LOGS_H_ + +#include + +extern int r8169_logtype_init; +#define PMD_INIT_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, r8169_logtype_init, \ + "%s(): " fmt "\n", __func__, ##args) + +#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>") + +#ifdef RTE_LIBRTE_R8169_DEBUG_RX +extern int r8169_logtype_rx; +#define PMD_RX_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, r8169_logtype_rx, \ + "%s(): " fmt "\n", __func__, ## args) +#else +#define PMD_RX_LOG(level, fmt, args...) do { } while (0) +#endif + +#ifdef RTE_LIBRTE_R8169_DEBUG_TX +extern int r8169_logtype_tx; +#define PMD_TX_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, r8169_logtype_tx, \ + "%s(): " fmt "\n", __func__, ## args) +#else +#define PMD_TX_LOG(level, fmt, args...) do { } while (0) +#endif + +#ifdef RTE_LIBRTE_R8169_DEBUG_TX_FREE +extern int r8169_logtype_tx_free; +#define PMD_TX_FREE_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, r8169_logtype_tx_free, \ + "%s(): " fmt "\n", __func__, ## args) +#else +#define PMD_TX_FREE_LOG(level, fmt, args...) do { } while (0) +#endif + +extern int r8169_logtype_driver; +#define PMD_DRV_LOG_RAW(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, r8169_logtype_driver, "%s(): " fmt, \ + __func__, ## args) + +#define PMD_DRV_LOG(level, fmt, args...) \ + PMD_DRV_LOG_RAW(level, fmt "\n", ## args) + +#endif /* _R8169_LOGS_H_ */ +