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 776E741C24; Mon, 6 Feb 2023 18:39:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EEEC410D1; Mon, 6 Feb 2023 18:39:46 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id B198340ED7 for ; Mon, 6 Feb 2023 18:39:44 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id ge21-20020a17090b0e1500b002308aac5b5eso6117649pjb.4 for ; Mon, 06 Feb 2023 09:39:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=n5MYTG/61u16G/yCBHK0jyfej3yJ2UOCfGg2yh4Uzho=; b=xTTlqIyVk6vAVUWiR2ECq6C23dwwH4MMm0hn+30S72WX16RZTUznS8OqAfFAIzZQmo f4z+1BSyeoQE+9ubrAZKv2I1fj5EfnNyyIg+lO3Smu8Ue9Bl079J/L8chMVc8JXvGRRP xIEDqvRRAli59ikfa7xv55cAgpbam0X3eE3S9+e75B/BLE/2w7fj6l62WSCTU8dOY4Cg MFTp/zJuoUp9GiyOfz3Od0w0dz34cH5aUKlcP3YilIeqXA+XBmgDQdA3mPiPcytqhdR4 THIpyuHSDnbwFdGrrJg46Re6E84rm/xm5GP3gb5LK4iJnoGiS2f5CxEJBZHJGUDl8sBC sWVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n5MYTG/61u16G/yCBHK0jyfej3yJ2UOCfGg2yh4Uzho=; b=UcDCxf9aKR6qt3jNs1mUV8aqZlKdUBjkJRe1cugVvgxc9IriiGmFS5GArpbLWfpsRg Ze4iHgipnCwd9oZkHQv9DfnOuyK2AnwhCNJDyt0pOy+55mRgoSQ3QpzbSAma4AbH9m2O TZbvCHBmS6EYq4hX0p3CtrOSW9InPYvAj/etAxyVdXLekkJfpvtmzCtL3cNFM9idRj1b zD3peS2HCenzg/nSMjDvdBK9SMYB9meflitn+cAqsIFWYkU8npJ/C0PKDOoPidcGE7h/ Rt0n5sr23xFVzN43wpRATTKcOwHA6dBHMaQWAVS78mtBMM7tiRRG1l393FZFc2fwTm8l Wu+w== X-Gm-Message-State: AO0yUKVISvwO/uDdqOTKNzFOgEWvUbcIeLMfunlVMuyZRW/G6p10yfdU hLQlsiSXwXnrrLwzr8uOS7zRz/DIBQEdHPGj7FCIHg== X-Google-Smtp-Source: AK7set9hEFrf10b5ZeF2n5i+nPGpiy+XsdnHq7DOAztkLxtnAX9jK3/UV5fr/F4i1JK6ZYfRWFb9Hw== X-Received: by 2002:a17:903:283:b0:198:de07:f3d with SMTP id j3-20020a170903028300b00198de070f3dmr16508446plr.41.1675705183407; Mon, 06 Feb 2023 09:39:43 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jg5-20020a17090326c500b001990c6c16ebsm3140014plb.37.2023.02.06.09.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 09:39:43 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz Subject: [PATCH] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Date: Mon, 6 Feb 2023 09:39:41 -0800 Message-Id: <20230206173941.783305-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Introduce a new dynamic logtype for mbuf related messages. Since this is used in multiple files put one macro in mbuf_log.h Signed-off-by: Stephen Hemminger --- lib/mbuf/mbuf_log.h | 10 ++++++++++ lib/mbuf/rte_mbuf.c | 20 ++++++++++++-------- lib/mbuf/rte_mbuf_dyn.c | 14 +++++++------- lib/mbuf/rte_mbuf_pool_ops.c | 5 +++-- 4 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 lib/mbuf/mbuf_log.h diff --git a/lib/mbuf/mbuf_log.h b/lib/mbuf/mbuf_log.h new file mode 100644 index 000000000000..fe97f338c9b7 --- /dev/null +++ b/lib/mbuf/mbuf_log.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation. + * Copyright 2014 6WIND S.A. + */ + +extern int mbuf_logtype; + +#define MBUF_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, mbuf_logtype, \ + "%s(): " fmt "\n", __func__, ##args) diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c index cfd8062f1e6a..64847afbf931 100644 --- a/lib/mbuf/rte_mbuf.c +++ b/lib/mbuf/rte_mbuf.c @@ -20,6 +20,8 @@ #include #include +#include "mbuf_log.h" + /* * pktmbuf pool constructor, given as a callback function to * rte_mempool_create(), or called directly if using @@ -227,8 +229,8 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, int ret; if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { - RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", - priv_size); + MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned", + priv_size); rte_errno = EINVAL; return NULL; } @@ -247,7 +249,7 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, mp_ops_name = rte_mbuf_best_mempool_ops(); ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL); if (ret != 0) { - RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); + MBUF_LOG(ERR, "error setting mempool handler"); rte_mempool_free(mp); rte_errno = -ret; return NULL; @@ -293,7 +295,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, int ret; if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { - RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", + MBUF_LOG(ERR, "mbuf priv_size=%u is not aligned", priv_size); rte_errno = EINVAL; return NULL; @@ -303,12 +305,12 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, const struct rte_pktmbuf_extmem *extm = ext_mem + i; if (!extm->elt_size || !extm->buf_len || !extm->buf_ptr) { - RTE_LOG(ERR, MBUF, "invalid extmem descriptor\n"); + MBUF_LOG(ERR, "invalid extmem descriptor"); rte_errno = EINVAL; return NULL; } if (data_room_size > extm->elt_size) { - RTE_LOG(ERR, MBUF, "ext elt_size=%u is too small\n", + MBUF_LOG(ERR, "ext elt_size=%u is too small", priv_size); rte_errno = EINVAL; return NULL; @@ -317,7 +319,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, } /* Check whether enough external memory provided. */ if (n_elts < n) { - RTE_LOG(ERR, MBUF, "not enough extmem\n"); + MBUF_LOG(ERR, "not enough extmem"); rte_errno = ENOMEM; return NULL; } @@ -338,7 +340,7 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, mp_ops_name = rte_mbuf_best_mempool_ops(); ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL); if (ret != 0) { - RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); + MBUF_LOG(ERR, "error setting mempool handler"); rte_mempool_free(mp); rte_errno = -ret; return NULL; @@ -936,3 +938,5 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen) return 0; } + +RTE_LOG_REGISTER(mbuf_logtype, "lib/mbuf", INFO); diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c index 35839e938cc5..d8da912c8df0 100644 --- a/lib/mbuf/rte_mbuf_dyn.c +++ b/lib/mbuf/rte_mbuf_dyn.c @@ -17,6 +17,8 @@ #include #include +#include "mbuf_log.h" + #define RTE_MBUF_DYN_MZNAME "rte_mbuf_dyn" struct mbuf_dynfield_elt { @@ -116,7 +118,7 @@ init_shared_mem(void) mz = rte_memzone_lookup(RTE_MBUF_DYN_MZNAME); } if (mz == NULL) { - RTE_LOG(ERR, MBUF, "Failed to get mbuf dyn shared memory\n"); + MBUF_LOG(ERR, "Failed to get mbuf dyn shared memory"); return -1; } @@ -315,7 +317,7 @@ __rte_mbuf_dynfield_register_offset(const struct rte_mbuf_dynfield *params, shm->free_space[i] = 0; process_score(); - RTE_LOG(DEBUG, MBUF, "Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd\n", + MBUF_LOG(DEBUG,"Registered dynamic field %s (sz=%zu, al=%zu, fl=0x%x) -> %zd", params->name, params->size, params->align, params->flags, offset); @@ -489,7 +491,7 @@ __rte_mbuf_dynflag_register_bitnum(const struct rte_mbuf_dynflag *params, shm->free_flags &= ~(1ULL << bitnum); - RTE_LOG(DEBUG, MBUF, "Registered dynamic flag %s (fl=0x%x) -> %u\n", + MBUF_LOG(DEBUG, "Registered dynamic flag %s (fl=0x%x) -> %u", params->name, params->flags, bitnum); return bitnum; @@ -590,8 +592,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag, offset = rte_mbuf_dynfield_register(&field_desc); if (offset < 0) { - RTE_LOG(ERR, MBUF, - "Failed to register mbuf field for timestamp\n"); + MBUF_LOG(ERR, "Failed to register mbuf field for timestamp"); return -1; } if (field_offset != NULL) @@ -600,8 +601,7 @@ rte_mbuf_dyn_timestamp_register(int *field_offset, uint64_t *flag, strlcpy(flag_desc.name, flag_name, sizeof(flag_desc.name)); offset = rte_mbuf_dynflag_register(&flag_desc); if (offset < 0) { - RTE_LOG(ERR, MBUF, - "Failed to register mbuf flag for %s timestamp\n", + MBUF_LOG(ERR, "Failed to register mbuf flag for %s timestamp", direction); return -1; } diff --git a/lib/mbuf/rte_mbuf_pool_ops.c b/lib/mbuf/rte_mbuf_pool_ops.c index 4c91f4ce8569..8ec2710dc86d 100644 --- a/lib/mbuf/rte_mbuf_pool_ops.c +++ b/lib/mbuf/rte_mbuf_pool_ops.c @@ -8,6 +8,8 @@ #include #include +#include "mbuf_log.h" + int rte_mbuf_set_platform_mempool_ops(const char *ops_name) { @@ -31,8 +33,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name) return 0; } - RTE_LOG(ERR, MBUF, - "%s is already registered as platform mbuf pool ops\n", + MBUF_LOG(ERR, "%s is already registered as platform mbuf pool ops", (char *)mz->addr); return -EEXIST; } -- 2.39.0