From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3BA0C45B60; Thu, 17 Oct 2024 18:44:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7E94E40677; Thu, 17 Oct 2024 18:44:14 +0200 (CEST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 5C9FF4065A for ; Thu, 17 Oct 2024 18:44:12 +0200 (CEST) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20c8c50fdd9so15697705ad.0 for ; Thu, 17 Oct 2024 09:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729183451; x=1729788251; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=bGv9jzJ7dI+KKpM7SQSul0rzJ9YOXkvs1uFg+pqnDUI=; b=VNja2SWgyxy7i+o+Q1Zq6+zQcMucrnJEhRyzRJbmaG4YpuBTtkXHmqpwXFMxjRhwOZ /ZZA9KttjMFXpQHeldzSvoNHEZtPYLxY+xadw6Lwhjnw/wCVon3s6Qa8pOairHSsKBro xyM+QZTMdeLZeyNjmfXJEvXCGVctlj0/RXjBT5sxSPQf64o6adKj1D2jlehMNVqJBupz z0dFkYcEPvn5gvs9KxtT+JpxDvlLhs8zctDoHrgPd7eINKqzfhrR1CZ7gpsV/L61rIHW KthXe/LRU3xc4Us/dpuj+K0KI9tUbaEE6wxIIxyXvh0FAmaYKzrMFG5C0+57r2Lc84Uv Sf3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729183451; x=1729788251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bGv9jzJ7dI+KKpM7SQSul0rzJ9YOXkvs1uFg+pqnDUI=; b=pCDmmNbIA9JUSrm+udNUI2jQkK+MBvE2G6+juuPNqj6EoAw6GhqQ7z8bu5k8ozTmrr 0zHgfxJuRMSTbb77rJZfHWwKaKudrx1dzKlAdJR1Sd/pQN/zWr78/T4DUPHDhbk03aB+ zxwRuYhXmiS5bTkfhwBo76V+KWKzGZNgTIwHxGq9cGCkneU6LQRGDBxpSGpZTdcAF0aJ wrt7DrsvfT6sQ1gIYLclazR6KXBWJ4YjAQiTCRWJAsFz+tNa/7/ecalD+3fT9paLOxWh sBET3yrTx73BNLcDk2ENKABenB0s0DL2tnyeLyRjVL4c0Msn4NK1FQwPT6gRVrAFXHgR nYZA== X-Gm-Message-State: AOJu0YzDXWs1E/OiKkMEYnPF9PDcIeGuBTKM2JT9JEtYZtLyzrhQxqif 1tgy4QlHg9OkFYVubv33Zx8/50k45cWCC7pmMQqjwjhlcLo6FXso2eF80F1h20Q= X-Google-Smtp-Source: AGHT+IFK3OGi/F04wcHc5IHErpDyueXsxklVdXyE5gZGQ8lllrW36r+P6tBwRbl6V5Pomcuq6Pc4iQ== X-Received: by 2002:a17:902:e802:b0:20b:5ef8:10a6 with SMTP id d9443c01a7336-20d4721e3famr53000415ad.8.1729183451463; Thu, 17 Oct 2024 09:44:11 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20d17fa5d55sm46684745ad.109.2024.10.17.09.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 09:44:11 -0700 (PDT) Date: Thu, 17 Oct 2024 09:32:01 -0700 From: Stephen Hemminger To: Howard Wang Cc: , Subject: Re: [PATCH v2 02/18] net/r8169: add logging structure Message-ID: <20241017093201.061c3407@hermes.local> In-Reply-To: <20241017063200.26101-3-howard_wang@realsil.com.cn> References: <20241017063200.26101-1-howard_wang@realsil.com.cn> <20241017063200.26101-3-howard_wang@realsil.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Thu, 17 Oct 2024 14:31:44 +0800 Howard Wang wrote: > 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 e5f8857304..09e12fb56d 100644 > --- a/drivers/net/r8169/r8169_ethdev.c > +++ b/drivers/net/r8169/r8169_ethdev.c > @@ -177,3 +177,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_ */ Latest DPDK has different better macros for this which you could use. _coding style issues_ Warning in drivers/net/r8169/r8169_logs.h: Prefer RTE_LOG_LINE/RTE_LOG_DP_LINE Warning in drivers/net/r8169/r8169_logs.h: Do not use variadic argument pack in macros