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 E213B43325; Tue, 14 Nov 2023 09:05:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81F5A4027B; Tue, 14 Nov 2023 09:05:20 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 1AD7F40279 for ; Tue, 14 Nov 2023 09:05:19 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AE8546F017379 for ; Tue, 14 Nov 2023 00:05:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Nw9B3KwGMVF331KnVtSXp6amT15guvsL2GfVgE8Cbk8=; b=AH/7dd2EGwAIQ3B/jFSvtCxP/zlxkikVscx+BurhMTDZ/GNnODlHA/QgX/9dLT9BtS5c y7nNR1VlZKNVcoKPij41o4C6tRh8DQkn8ViYO9rHbqUlXgUPcSTVP+s/RgmcWHxfuKZv WBlsSiO0xIUVVCCvQsZAuMdqDycKK4fOPp77j5BE8WRVKgVbWsDvcVhXaMlumheUiPJ6 OMLPRvFOFV627Z5wsi1xjknCHbcaUfGFQIbspvACmVsvC6OSFDNoMDh+pIdCTA0MCFpZ 0jD0wQbY5HvSNNhUMG3zY/e8dgCIgqmaL5Ebdw1HaaagHCI8mHhgFunHte84GWl/R6PQ dg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3uaa0r06mx-16 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 14 Nov 2023 00:05:18 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 14 Nov 2023 00:04:54 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 14 Nov 2023 00:04:54 -0800 Received: from cavium-DT10.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id F26D93F708A; Tue, 14 Nov 2023 00:04:52 -0800 (PST) From: Tomasz Duszynski To: , Jakub Palider , Tomasz Duszynski CC: Subject: [PATCH] raw/cnxk_bphy: switch to dynamic logging Date: Tue, 14 Nov 2023 09:04:46 +0100 Message-ID: <20231114080446.3574237-1-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Ti5pS__Hhmdh-qDlkzrtHTbGV682yBLx X-Proofpoint-GUID: Ti5pS__Hhmdh-qDlkzrtHTbGV682yBLx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-14_07,2023-11-09_01,2023-05-22_02 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 Dynamically allocated log type is a standard approach among all drivers. Switch to it. Signed-off-by: Tomasz Duszynski --- drivers/raw/cnxk_bphy/cnxk_bphy.c | 32 +++++++++++++--------- drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c | 4 ++- drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h | 7 +++++ drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c | 32 ++++++++++------------ 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy.c b/drivers/raw/cnxk_bphy/cnxk_bphy.c index 15dbc4c1a6..af3bf97a4d 100644 --- a/drivers/raw/cnxk_bphy/cnxk_bphy.c +++ b/drivers/raw/cnxk_bphy/cnxk_bphy.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -15,6 +16,11 @@ #include "cnxk_bphy_irq.h" #include "rte_pmd_bphy.h" +extern int bphy_rawdev_logtype; + +#define BPHY_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, bphy_rawdev_logtype, "%s(): " fmt "\n", __func__, ##args) + static const struct rte_pci_id pci_bphy_map[] = { {RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CNXK_BPHY)}, { @@ -81,7 +87,7 @@ bphy_rawdev_selftest(uint16_t dev_id) goto err_desc; if (descs != 1) { ret = -ENODEV; - plt_err("Wrong number of descs reported\n"); + BPHY_LOG(ERR, "Wrong number of descs reported\n"); goto err_desc; } @@ -95,7 +101,7 @@ bphy_rawdev_selftest(uint16_t dev_id) ret = rte_pmd_bphy_intr_init(dev_id); if (ret) { - plt_err("intr init failed"); + BPHY_LOG(ERR, "intr init failed"); return ret; } @@ -103,7 +109,7 @@ bphy_rawdev_selftest(uint16_t dev_id) test = rte_zmalloc("BPHY", max_irq * sizeof(*test), 0); if (test == NULL) { - plt_err("intr alloc failed"); + BPHY_LOG(ERR, "intr alloc failed"); goto err_alloc; } @@ -132,7 +138,7 @@ bphy_rawdev_selftest(uint16_t dev_id) } if (ret) { - plt_err("intr register failed at irq %d", i); + BPHY_LOG(ERR, "intr register failed at irq %d", i); goto err_register; } } @@ -142,12 +148,12 @@ bphy_rawdev_selftest(uint16_t dev_id) for (i = 0; i < max_irq; i++) { if (!test[i].handled_intr) { - plt_err("intr %u not handled", i); + BPHY_LOG(ERR, "intr %u not handled", i); ret = -1; break; } if (test[i].handled_data != test[i].test_data) { - plt_err("intr %u has wrong handler", i); + BPHY_LOG(ERR, "intr %u has wrong handler", i); ret = -1; break; } @@ -251,7 +257,7 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev, /* get rid of last response if any */ if (qp->rsp) { - RTE_LOG(WARNING, PMD, "Previous response got overwritten\n"); + BPHY_LOG(WARNING, "Previous response got overwritten"); rte_free(qp->rsp); } qp->rsp = rsp; @@ -332,9 +338,8 @@ bphy_rawdev_probe(struct rte_pci_driver *pci_drv, return 0; if (!pci_dev->mem_resource[0].addr) { - plt_err("BARs have invalid values: BAR0 %p\n BAR2 %p", - pci_dev->mem_resource[0].addr, - pci_dev->mem_resource[2].addr); + BPHY_LOG(ERR, "BARs have invalid values: BAR0 %p\n BAR2 %p", + pci_dev->mem_resource[0].addr, pci_dev->mem_resource[2].addr); return -ENODEV; } @@ -346,7 +351,7 @@ bphy_rawdev_probe(struct rte_pci_driver *pci_drv, bphy_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*bphy_dev), rte_socket_id()); if (bphy_rawdev == NULL) { - plt_err("Failed to allocate rawdev"); + BPHY_LOG(ERR, "Failed to allocate rawdev"); return -ENOMEM; } @@ -381,14 +386,14 @@ bphy_rawdev_remove(struct rte_pci_device *pci_dev) return 0; if (pci_dev == NULL) { - plt_err("invalid pci_dev"); + BPHY_LOG(ERR, "invalid pci_dev"); return -EINVAL; } bphy_rawdev_get_name(name, pci_dev); rawdev = rte_rawdev_pmd_get_named_dev(name); if (rawdev == NULL) { - plt_err("invalid device name (%s)", name); + BPHY_LOG(ERR, "invalid device name (%s)", name); return -EINVAL; } @@ -410,3 +415,4 @@ static struct rte_pci_driver cnxk_bphy_rawdev_pmd = { RTE_PMD_REGISTER_PCI(bphy_rawdev_pci_driver, cnxk_bphy_rawdev_pmd); RTE_PMD_REGISTER_PCI_TABLE(bphy_rawdev_pci_driver, pci_bphy_map); RTE_PMD_REGISTER_KMOD_DEP(bphy_rawdev_pci_driver, "vfio-pci"); +RTE_LOG_REGISTER_DEFAULT(bphy_rawdev_logtype, WARNING); diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c index 2d8466ef91..9eb0da9ed4 100644 --- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c +++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -189,7 +190,7 @@ cnxk_bphy_cgx_process_buf(struct cnxk_bphy_cgx *cgx, unsigned int queue, /* get rid of last response if any */ if (qp->rsp) { - RTE_LOG(WARNING, PMD, "Previous response got overwritten\n"); + BPHY_CGX_LOG(WARNING, "Previous response got overwritten"); rte_free(qp->rsp); } qp->rsp = rsp; @@ -379,3 +380,4 @@ static struct rte_pci_driver bphy_cgx_rawdev_pmd = { RTE_PMD_REGISTER_PCI(cnxk_bphy_cgx_rawdev_pci_driver, bphy_cgx_rawdev_pmd); RTE_PMD_REGISTER_PCI_TABLE(cnxk_bphy_cgx_rawdev_pci_driver, cnxk_bphy_cgx_map); RTE_PMD_REGISTER_KMOD_DEP(cnxk_bphy_cgx_rawdev_pci_driver, "vfio-pci"); +RTE_LOG_REGISTER_DEFAULT(bphy_cgx_rawdev_logtype, INFO); diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h index fb6b31bf4d..fd85a2df33 100644 --- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h +++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.h @@ -5,6 +5,13 @@ #ifndef _CNXK_BPHY_CGX_H_ #define _CNXK_BPHY_CGX_H_ +#include + +extern int bphy_cgx_rawdev_logtype; + +#define BPHY_CGX_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, bphy_cgx_rawdev_logtype, "%s(): " fmt "\n", __func__, ##args) + int cnxk_bphy_cgx_dev_selftest(uint16_t dev_id); #endif /* _CNXK_BPHY_CGX_H_ */ diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c index a3021b4bb7..5d2a53be31 100644 --- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c +++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c @@ -4,7 +4,6 @@ #include #include -#include #include #include @@ -57,62 +56,61 @@ cnxk_bphy_cgx_dev_selftest(uint16_t dev_id) if (ret) break; if (descs != 1) { - RTE_LOG(ERR, PMD, "Wrong number of descs reported\n"); + BPHY_CGX_LOG(ERR, "Wrong number of descs reported"); ret = -ENODEV; break; } - RTE_LOG(INFO, PMD, "Testing queue %d\n", i); + BPHY_CGX_LOG(INFO, "Testing queue %d", i); ret = rte_pmd_bphy_cgx_stop_rxtx(dev_id, i); if (ret) { - RTE_LOG(ERR, PMD, "Failed to stop rx/tx\n"); + BPHY_CGX_LOG(ERR, "Failed to stop rx/tx"); break; } ret = rte_pmd_bphy_cgx_start_rxtx(dev_id, i); if (ret) { - RTE_LOG(ERR, PMD, "Failed to start rx/tx\n"); + BPHY_CGX_LOG(ERR, "Failed to start rx/tx"); break; } ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, false); if (ret) { - RTE_LOG(ERR, PMD, "Failed to set link down\n"); + BPHY_CGX_LOG(ERR, "Failed to set link down"); break; } ret = cnxk_bphy_cgx_link_cond(dev_id, i, 0); if (ret != 0) - RTE_LOG(ERR, PMD, - "Timed out waiting for a link down\n"); + BPHY_CGX_LOG(ERR, "Timed out waiting for a link down"); ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, true); if (ret) { - RTE_LOG(ERR, PMD, "Failed to set link up\n"); + BPHY_CGX_LOG(ERR, "Failed to set link up"); break; } ret = cnxk_bphy_cgx_link_cond(dev_id, i, 1); if (ret != 1) - RTE_LOG(ERR, PMD, "Timed out waiting for a link up\n"); + BPHY_CGX_LOG(ERR, "Timed out waiting for a link up"); ret = rte_pmd_bphy_cgx_intlbk_enable(dev_id, i); if (ret) { - RTE_LOG(ERR, PMD, "Failed to enable internal lbk\n"); + BPHY_CGX_LOG(ERR, "Failed to enable internal lbk"); break; } ret = rte_pmd_bphy_cgx_intlbk_disable(dev_id, i); if (ret) { - RTE_LOG(ERR, PMD, "Failed to disable internal lbk\n"); + BPHY_CGX_LOG(ERR, "Failed to disable internal lbk"); break; } ret = rte_pmd_bphy_cgx_ptp_rx_enable(dev_id, i); /* ptp not available on RPM */ if (ret < 0 && ret != -ENOTSUP) { - RTE_LOG(ERR, PMD, "Failed to enable ptp\n"); + BPHY_CGX_LOG(ERR, "Failed to enable ptp"); break; } ret = 0; @@ -120,27 +118,27 @@ cnxk_bphy_cgx_dev_selftest(uint16_t dev_id) ret = rte_pmd_bphy_cgx_ptp_rx_disable(dev_id, i); /* ptp not available on RPM */ if (ret < 0 && ret != -ENOTSUP) { - RTE_LOG(ERR, PMD, "Failed to disable ptp\n"); + BPHY_CGX_LOG(ERR, "Failed to disable ptp"); break; } ret = 0; ret = rte_pmd_bphy_cgx_get_supported_fec(dev_id, i, &fec); if (ret) { - RTE_LOG(ERR, PMD, "Failed to get supported FEC\n"); + BPHY_CGX_LOG(ERR, "Failed to get supported FEC"); break; } ret = rte_pmd_bphy_cgx_set_fec(dev_id, i, fec); if (ret) { - RTE_LOG(ERR, PMD, "Failed to set FEC to %d\n", fec); + BPHY_CGX_LOG(ERR, "Failed to set FEC to %d", fec); break; } fec = CNXK_BPHY_CGX_ETH_LINK_FEC_NONE; ret = rte_pmd_bphy_cgx_set_fec(dev_id, i, fec); if (ret) { - RTE_LOG(ERR, PMD, "Failed to disable FEC\n"); + BPHY_CGX_LOG(ERR, "Failed to disable FEC"); break; } } -- 2.34.1