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 9FBACA0566; Mon, 8 Mar 2021 23:29:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6BB0622A4E8; Mon, 8 Mar 2021 23:29:10 +0100 (CET) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mails.dpdk.org (Postfix) with ESMTP id C0B2322A4E7 for ; Mon, 8 Mar 2021 23:29:08 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 741F75C00F2; Mon, 8 Mar 2021 17:29:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 08 Mar 2021 17:29:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=YZXHQb6Y1Jukg ECUqPem3RIUbav6hHgkjvuq/eNFNYQ=; b=RtDK3dIxuZsf302IlCc8WxDra6Zog iA6nYupBBXTr8Ok+UwJSsXqPFlVLn4liUsLU+xlKBTGV7aND/gx/wJLiPVH9cvwc GNybwSvl4KxWWN6GpJ7pufc2VSTYl2LuhaDVi6AkhN0EapY5c6XwWjqh1S3yfDsk vlDjTVPQhr6rA7OQqooyaOZJjesS2ohAO8uqrezTu/HHyYBSIxcQG+Ap4m0k4kzq oGYHTxNaJXjG1a/tggu1CcvZbXhQfqyqFiST/gBOy6155gUOlCCO0uzvE7AJJqGi rhgkqlr5v7glbJly3svz+bzsJ9C7TqEn7Ho1hGxUwhMX0SgJrtD3MPKDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=YZXHQb6Y1JukgECUqPem3RIUbav6hHgkjvuq/eNFNYQ=; b=v8LkZUgj 8grWoDLkOK2Q2zwX6pblUKmRDzXuXo9j8ArsusmCJFcb9L57V0wf2nKEUNg1hXsK gj1+b0Vodyre4Bfolx1XtzRqDPFN6oT/AsxIm7xf1VYKHCix7s369Htavov9lGvE B0ovPXkmfoW23528qDgLpJXAIhb7rT0w852NDPPPFreEJkBKTSEpZjfs4xEae1YE 4bZtbBzZDuNmn2QNyDOyKBDulbXkLmM/Zc8sGIaCntNmOzF4Yw/8Zk4nRYDz/n/K JH3//nktd6/f6t/9DUIbdNfyaMRFSy0z/0hLeeGB6HPPOtdCL2YMGOi6x3N7EPiV eEJq2mMXx/6tew== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddugedgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepgefhuefggeeugeelfeevjeelieevhfegveefteejfefgteejueeu jeduleffkeetnecuffhomhgrihhnpehpmhgurdhnvghtpdgurhhivhgvrhdrnhgrmhgvne cukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id CEEFC1080057; Mon, 8 Mar 2021 17:29:07 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Date: Mon, 8 Mar 2021 23:28:54 +0100 Message-Id: <20210308222855.823670-3-thomas@monjalon.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308222855.823670-1-thomas@monjalon.net> References: <20210308222855.823670-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/3] common/mlx5: enable debug logs dynamically 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 Sender: "dev" Most debug logs are using DRV_LOG(DEBUG,) but some were using DEBUG(). The macro DEBUG is doing nothing if not compiled with RTE_LIBRTE_MLX5_DEBUG. As it is not used in the data path, the macro DEBUG can be replaced with DRV_LOG. Then all debug logs can be enabled at runtime with: --log-level pmd.net.mlx5:debug Signed-off-by: Thomas Monjalon --- drivers/common/mlx5/mlx5_common.h | 2 -- drivers/common/mlx5/mlx5_common_mr.c | 45 ++++++++++++++------------- drivers/common/mlx5/mlx5_common_pci.c | 4 +-- drivers/net/mlx5/linux/mlx5_verbs.c | 13 ++++---- drivers/net/mlx5/mlx5_mr.c | 12 +++---- drivers/net/mlx5/mlx5_rxq.c | 11 ++++--- 6 files changed, 46 insertions(+), 41 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 3855582d0d..5028a05b49 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -92,14 +92,12 @@ pmd_drv_log_basename(const char *s) /* claim_zero() does not perform any check when debugging is disabled. */ #ifdef RTE_LIBRTE_MLX5_DEBUG -#define DEBUG(...) DRV_LOG(DEBUG, __VA_ARGS__) #define MLX5_ASSERT(exp) RTE_VERIFY(exp) #define claim_zero(...) MLX5_ASSERT((__VA_ARGS__) == 0) #define claim_nonzero(...) MLX5_ASSERT((__VA_ARGS__) != 0) #else /* RTE_LIBRTE_MLX5_DEBUG */ -#define DEBUG(...) (void)0 #define MLX5_ASSERT(exp) RTE_ASSERT(exp) #define claim_zero(...) (__VA_ARGS__) #define claim_nonzero(...) (__VA_ARGS__) diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 7c25541dc4..e1ed0caf3a 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -187,8 +187,9 @@ mlx5_mr_btree_init(struct mlx5_mr_btree *bt, int n, int socket) 0, socket); if (bt->table == NULL) { rte_errno = ENOMEM; - DEBUG("failed to allocate memory for btree cache on socket %d", - socket); + DRV_LOG(DEBUG, + "failed to allocate memory for btree cache on socket " + "%d", socket); return -rte_errno; } bt->size = n; @@ -196,7 +197,7 @@ mlx5_mr_btree_init(struct mlx5_mr_btree *bt, int n, int socket) (*bt->table)[bt->len++] = (struct mr_cache_entry) { .lkey = UINT32_MAX, }; - DEBUG("initialized B-tree %p with table %p", + DRV_LOG(DEBUG, "initialized B-tree %p with table %p", (void *)bt, (void *)bt->table); return 0; } @@ -212,7 +213,7 @@ mlx5_mr_btree_free(struct mlx5_mr_btree *bt) { if (bt == NULL) return; - DEBUG("freeing B-tree %p with table %p", + DRV_LOG(DEBUG, "freeing B-tree %p with table %p", (void *)bt, (void *)bt->table); mlx5_free(bt->table); memset(bt, 0, sizeof(*bt)); @@ -237,7 +238,7 @@ mlx5_mr_btree_dump(struct mlx5_mr_btree *bt __rte_unused) for (idx = 0; idx < bt->len; ++idx) { struct mr_cache_entry *entry = &lkp_tbl[idx]; - DEBUG("B-tree(%p)[%u]," + DRV_LOG(DEBUG, "B-tree(%p)[%u]," " [0x%" PRIxPTR ", 0x%" PRIxPTR ") lkey=0x%x", (void *)bt, idx, entry->start, entry->end, entry->lkey); } @@ -543,11 +544,11 @@ mlx5_mr_create_secondary(void *pd __rte_unused, { int ret; - DEBUG("port %u requesting MR creation for address (%p)", + DRV_LOG(DEBUG, "port %u requesting MR creation for address (%p)", mp_id->port_id, (void *)addr); ret = mlx5_mp_req_mr_create(mp_id, addr); if (ret) { - DEBUG("Fail to request MR creation for address (%p)", + DRV_LOG(DEBUG, "Fail to request MR creation for address (%p)", (void *)addr); return UINT32_MAX; } @@ -557,7 +558,7 @@ mlx5_mr_create_secondary(void *pd __rte_unused, /* Lookup can't fail. */ MLX5_ASSERT(entry->lkey != UINT32_MAX); rte_rwlock_read_unlock(&share_cache->rwlock); - DEBUG("MR CREATED by primary process for %p:\n" + DRV_LOG(DEBUG, "MR CREATED by primary process for %p:\n" " [0x%" PRIxPTR ", 0x%" PRIxPTR "), lkey=0x%x", (void *)addr, entry->start, entry->end, entry->lkey); return entry->lkey; @@ -647,7 +648,7 @@ mlx5_mr_create_primary(void *pd, MLX5_ASSERT(msl->page_sz == ms->hugepage_sz); /* Number of memsegs in the range. */ ms_n = len / msl->page_sz; - DEBUG("Extending %p to [0x%" PRIxPTR ", 0x%" PRIxPTR ")," + DRV_LOG(DEBUG, "Extending %p to [0x%" PRIxPTR ", 0x%" PRIxPTR ")," " page_sz=0x%" PRIx64 ", ms_n=%u", (void *)addr, data.start, data.end, msl->page_sz, ms_n); /* Size of memory for bitmap. */ @@ -656,7 +657,7 @@ mlx5_mr_create_primary(void *pd, RTE_ALIGN_CEIL(sizeof(*mr), RTE_CACHE_LINE_SIZE) + bmp_size, RTE_CACHE_LINE_SIZE, msl->socket_id); if (mr == NULL) { - DEBUG("Unable to allocate memory for a new MR of" + DRV_LOG(DEBUG, "Unable to allocate memory for a new MR of" " address (%p).", (void *)addr); rte_errno = ENOMEM; goto err_nolock; @@ -671,7 +672,7 @@ mlx5_mr_create_primary(void *pd, bmp_mem = RTE_PTR_ALIGN_CEIL(mr + 1, RTE_CACHE_LINE_SIZE); mr->ms_bmp = rte_bitmap_init(ms_n, bmp_mem, bmp_size); if (mr->ms_bmp == NULL) { - DEBUG("Unable to initialize bitmap for a new MR of" + DRV_LOG(DEBUG, "Unable to initialize bitmap for a new MR of" " address (%p).", (void *)addr); rte_errno = EINVAL; goto err_nolock; @@ -688,9 +689,9 @@ mlx5_mr_create_primary(void *pd, data_re = data; if (len > msl->page_sz && !rte_memseg_contig_walk(mr_find_contig_memsegs_cb, &data_re)) { - DEBUG("Unable to find virtually contiguous" - " chunk for address (%p)." - " rte_memseg_contig_walk() failed.", (void *)addr); + DRV_LOG(DEBUG, + "Unable to find virtually contiguous chunk for address " + "(%p). rte_memseg_contig_walk() failed.", (void *)addr); rte_errno = ENXIO; goto err_memlock; } @@ -718,7 +719,8 @@ mlx5_mr_create_primary(void *pd, * here again. */ mr_btree_insert(&share_cache->cache, entry); - DEBUG("Found MR for %p on final lookup, abort", (void *)addr); + DRV_LOG(DEBUG, "Found MR for %p on final lookup, abort", + (void *)addr); rte_rwlock_write_unlock(&share_cache->rwlock); rte_mcfg_mem_read_unlock(); /* @@ -767,7 +769,7 @@ mlx5_mr_create_primary(void *pd, */ share_cache->reg_mr_cb(pd, (void *)data.start, len, &mr->pmd_mr); if (mr->pmd_mr.obj == NULL) { - DEBUG("Fail to create an MR for address (%p)", + DRV_LOG(DEBUG, "Fail to create an MR for address (%p)", (void *)addr); rte_errno = EINVAL; goto err_mrlock; @@ -775,7 +777,7 @@ mlx5_mr_create_primary(void *pd, MLX5_ASSERT((uintptr_t)mr->pmd_mr.addr == data.start); MLX5_ASSERT(mr->pmd_mr.len); LIST_INSERT_HEAD(&share_cache->mr_list, mr, mr); - DEBUG("MR CREATED (%p) for %p:\n" + DRV_LOG(DEBUG, "MR CREATED (%p) for %p:\n" " [0x%" PRIxPTR ", 0x%" PRIxPTR ")," " lkey=0x%x base_idx=%u ms_n=%u, ms_bmp_n=%u", (void *)mr, (void *)addr, data.start, data.end, @@ -1079,7 +1081,7 @@ mlx5_mr_dump_cache(struct mlx5_mr_share_cache *share_cache __rte_unused) LIST_FOREACH(mr, &share_cache->mr_list, mr) { unsigned int n; - DEBUG("MR[%u], LKey = 0x%x, ms_n = %u, ms_bmp_n = %u", + DRV_LOG(DEBUG, "MR[%u], LKey = 0x%x, ms_n = %u, ms_bmp_n = %u", mr_n++, rte_cpu_to_be_32(mr->pmd_mr.lkey), mr->ms_n, mr->ms_bmp_n); if (mr->ms_n == 0) @@ -1090,11 +1092,12 @@ mlx5_mr_dump_cache(struct mlx5_mr_share_cache *share_cache __rte_unused) n = mr_find_next_chunk(mr, &ret, n); if (!ret.end) break; - DEBUG(" chunk[%u], [0x%" PRIxPTR ", 0x%" PRIxPTR ")", - chunk_n++, ret.start, ret.end); + DRV_LOG(DEBUG, + " chunk[%u], [0x%" PRIxPTR ", 0x%" PRIxPTR ")", + chunk_n++, ret.start, ret.end); } } - DEBUG("Dumping global cache %p", (void *)share_cache); + DRV_LOG(DEBUG, "Dumping global cache %p", (void *)share_cache); mlx5_mr_btree_dump(&share_cache->cache); rte_rwlock_read_unlock(&share_cache->rwlock); #endif diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 2b657686d1..a7f541a90c 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -245,14 +245,14 @@ drivers_probe(struct mlx5_pci_device *dev, struct rte_pci_driver *pci_drv, already_loaded = dev->classes_loaded & driver->driver_class; if (already_loaded && !(driver->pci_driver.drv_flags & RTE_PCI_DRV_PROBE_AGAIN)) { - DRV_LOG(ERR, "Device %s is already probed\n", + DRV_LOG(ERR, "Device %s is already probed", pci_dev->device.name); ret = -EEXIST; goto probe_err; } ret = driver->pci_driver.probe(pci_drv, pci_dev); if (ret < 0) { - DRV_LOG(ERR, "Failed to load driver = %s.\n", + DRV_LOG(ERR, "Failed to load driver %s", driver->pci_driver.driver.name); goto probe_err; } diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index ade241b806..c7d4b177a0 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -721,7 +721,7 @@ mlx5_rxq_ibv_obj_drop_create(struct rte_eth_dev *dev) return 0; rxq = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rxq), 0, SOCKET_ID_ANY); if (!rxq) { - DEBUG("Port %u cannot allocate drop Rx queue memory.", + DRV_LOG(DEBUG, "Port %u cannot allocate drop Rx queue memory.", dev->data->port_id); rte_errno = ENOMEM; return -rte_errno; @@ -729,7 +729,7 @@ mlx5_rxq_ibv_obj_drop_create(struct rte_eth_dev *dev) priv->drop_queue.rxq = rxq; rxq->ibv_cq = mlx5_glue->create_cq(ctx, 1, NULL, NULL, 0); if (!rxq->ibv_cq) { - DEBUG("Port %u cannot allocate CQ for drop queue.", + DRV_LOG(DEBUG, "Port %u cannot allocate CQ for drop queue.", dev->data->port_id); rte_errno = errno; goto error; @@ -742,7 +742,7 @@ mlx5_rxq_ibv_obj_drop_create(struct rte_eth_dev *dev) .cq = rxq->ibv_cq, }); if (!rxq->wq) { - DEBUG("Port %u cannot allocate WQ for drop queue.", + DRV_LOG(DEBUG, "Port %u cannot allocate WQ for drop queue.", dev->data->port_id); rte_errno = errno; goto error; @@ -785,8 +785,9 @@ mlx5_ibv_drop_action_create(struct rte_eth_dev *dev) .comp_mask = 0, }); if (!ind_tbl) { - DEBUG("Port %u cannot allocate indirection table for drop" - " queue.", dev->data->port_id); + DRV_LOG(DEBUG, "Port %u" + " cannot allocate indirection table for drop queue.", + dev->data->port_id); rte_errno = errno; goto error; } @@ -806,7 +807,7 @@ mlx5_ibv_drop_action_create(struct rte_eth_dev *dev) .pd = priv->sh->pd }); if (!hrxq->qp) { - DEBUG("Port %u cannot allocate QP for drop queue.", + DRV_LOG(DEBUG, "Port %u cannot allocate QP for drop queue.", dev->data->port_id); rte_errno = errno; goto error; diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index da4e91fc24..3255393ca2 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -57,7 +57,7 @@ mlx5_mr_mem_event_free_cb(struct mlx5_dev_ctx_shared *sh, int i; int rebuild = 0; - DEBUG("device %s free callback: addr=%p, len=%zu", + DRV_LOG(DEBUG, "device %s free callback: addr=%p, len=%zu", sh->ibdev_name, addr, len); msl = rte_mem_virt2memseg_list(addr); /* addr and len must be page-aligned. */ @@ -87,13 +87,13 @@ mlx5_mr_mem_event_free_cb(struct mlx5_dev_ctx_shared *sh, pos = ms_idx - mr->ms_base_idx; MLX5_ASSERT(rte_bitmap_get(mr->ms_bmp, pos)); MLX5_ASSERT(pos < mr->ms_bmp_n); - DEBUG("device %s MR(%p): clear bitmap[%u] for addr %p", + DRV_LOG(DEBUG, "device %s MR(%p): clear bitmap[%u] for addr %p", sh->ibdev_name, (void *)mr, pos, (void *)start); rte_bitmap_clear(mr->ms_bmp, pos); if (--mr->ms_n == 0) { LIST_REMOVE(mr, mr); LIST_INSERT_HEAD(&sh->share_cache.mr_free_list, mr, mr); - DEBUG("device %s remove MR(%p) from list", + DRV_LOG(DEBUG, "device %s remove MR(%p) from list", sh->ibdev_name, (void *)mr); } /* @@ -114,7 +114,7 @@ mlx5_mr_mem_event_free_cb(struct mlx5_dev_ctx_shared *sh, * before the core sees the newly allocated memory. */ ++sh->share_cache.dev_gen; - DEBUG("broadcasting local cache flush, gen=%d", + DRV_LOG(DEBUG, "broadcasting local cache flush, gen=%d", sh->share_cache.dev_gen); rte_smp_wmb(); } @@ -405,7 +405,7 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, } LIST_REMOVE(mr, mr); mlx5_mr_free(mr, sh->share_cache.dereg_mr_cb); - DEBUG("port %u remove MR(%p) from list", dev->data->port_id, + DRV_LOG(DEBUG, "port %u remove MR(%p) from list", dev->data->port_id, (void *)mr); mlx5_mr_rebuild_cache(&sh->share_cache); /* @@ -418,7 +418,7 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, * before the core sees the newly allocated memory. */ ++sh->share_cache.dev_gen; - DEBUG("broadcasting local cache flush, gen=%d", + DRV_LOG(DEBUG, "broadcasting local cache flush, gen=%d", sh->share_cache.dev_gen); rte_smp_wmb(); rte_rwlock_read_unlock(&sh->share_cache.rwlock); diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 8f9ee97f7a..9009eb8d18 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1972,7 +1972,8 @@ mlx5_ind_table_obj_setup(struct rte_eth_dev *dev, for (j = 0; j < i; j++) mlx5_rxq_release(dev, ind_tbl->queues[j]); rte_errno = err; - DEBUG("Port %u cannot setup indirection table.", dev->data->port_id); + DRV_LOG(DEBUG, "Port %u cannot setup indirection table.", + dev->data->port_id); return ret; } @@ -2056,8 +2057,9 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev, * reference unsupported. Intended for standalone indirection * tables only. */ - DEBUG("Port %u cannot modify indirection table (refcnt> 1).", - dev->data->port_id); + DRV_LOG(DEBUG, + "Port %u cannot modify indirection table (refcnt> 1).", + dev->data->port_id); rte_errno = EINVAL; return -rte_errno; } @@ -2081,7 +2083,8 @@ mlx5_ind_table_obj_modify(struct rte_eth_dev *dev, for (j = 0; j < i; j++) mlx5_rxq_release(dev, ind_tbl->queues[j]); rte_errno = err; - DEBUG("Port %u cannot setup indirection table.", dev->data->port_id); + DRV_LOG(DEBUG, "Port %u cannot setup indirection table.", + dev->data->port_id); return ret; } -- 2.30.1