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 E77B941C33; Tue, 7 Feb 2023 21:44:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9457042D0C; Tue, 7 Feb 2023 21:44:43 +0100 (CET) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mails.dpdk.org (Postfix) with ESMTP id 1D184410F6 for ; Tue, 7 Feb 2023 21:44:40 +0100 (CET) Received: by mail-pl1-f176.google.com with SMTP id e19so9052103plc.9 for ; Tue, 07 Feb 2023 12:44:40 -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:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UpTet1GyA1n7NMsLggHkgFdnQKwxWl7iUtPSJR1Vmn0=; b=4vX+plThDnHeCvyIqCYkvzfpNLzeaWMi6NEBBOjkA7+5S6bEqmu0GCyhfccCVYSeSx 1PLU3TCXBjTs5ya0XjgtiQ+UrxB8fsRGdcI8JJ3umb39zjuKnmBQckItBSaOkbpzj8BW Ba0lA7QkgQ0Nq22uDvgZVcf9yNJvjWl08Q09FEA3ZbC5GRrCVnJqQk2PLxJFEvyPC3oR dwbdyhTCrvepSJ5isHaRKYxcArPo2xj9LY75y6/78ianUDYBKIo8ZMfXonRzsLfk1MDP qtoyUFIZSl3V/HtuceUGxtIHiVnWF39OTK52qya1Nku4G1+FLvGGDaMg9GrAAnJyxHBk Oj7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UpTet1GyA1n7NMsLggHkgFdnQKwxWl7iUtPSJR1Vmn0=; b=RPXqdm29IWUbxdyY6QytZNOdzZJ8SDvPf0+2tcENip72QOXjm2eos9/5L3xhkyeZ2t KGJZnMf93QdRE5QCkROtw17fyIpoPHyQiJMi68rBqTfby+lx4S0KpAtWcY892+hCSNGF BfIeq1NZdziS0zmKuFEPWwfJ5k0O0+i7J3+cXJqpzpEI90FBdBPfoYs1qtE1kQjDuw7o TsTOXa9CCcLDGUM3VJAcEsAhiwRUtXoYhsD6A58imJViVwxRMHhlNzlrnTrkwJCdRebq YNgqK989+KrvyxPFoQcp1TuGmpAeCklt9yu8htod6bAVABJWp/7eoYMY/824gxo/JiOE CMeQ== X-Gm-Message-State: AO0yUKU/YkUCk8sWlnWHwLUQhyys0FEU6bZJ2fpqEz35xfTSlxId5Obi xMGOIy6YiQLYVXHrdJh+bNKSvaeWEx3/LXqiSLc= X-Google-Smtp-Source: AK7set8+8nL3vuOqzJetga53DoEoFGooy36cC3B4t/NNRcHHhHJkW2BDZ4QBIMf4w6w0HLcmWCWvHw== X-Received: by 2002:a17:903:24f:b0:198:a08a:e52b with SMTP id j15-20020a170903024f00b00198a08ae52bmr5242399plh.13.1675802679076; Tue, 07 Feb 2023 12:44:39 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jk24-20020a170903331800b00194ab9a4febsm4725562plb.74.2023.02.07.12.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 12:44:38 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz Subject: [RFC 05/13] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Date: Tue, 7 Feb 2023 12:41:43 -0800 Message-Id: <20230207204151.1503491-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207204151.1503491-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> 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/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/mbuf/mbuf_log.h | 10 ++++++++++ lib/mbuf/rte_mbuf.c | 20 ++++++++++++-------- lib/mbuf/rte_mbuf_dyn.c | 15 ++++++++------- lib/mbuf/rte_mbuf_pool_ops.c | 5 +++-- 6 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 lib/mbuf/mbuf_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 675f3d07bbe3..128bfabd94e1 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -363,7 +363,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_PORT, "lib.port"}, {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, - {RTE_LOGTYPE_MBUF, "lib.mbuf"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index a90fa629168d..1f259b2abc5a 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -42,7 +42,7 @@ extern "C" { #define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ #define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ -#define RTE_LOGTYPE_MBUF 16 /**< Log related to mbuf. */ + /* was RTE_LOGTYPE_MBUF */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ /* was RTE_LOGTYPE_EFD */ #define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ 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..133fd3ba55be 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_DEFAULT(mbuf_logtype, INFO); diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c index 35839e938cc5..ef8d6069b37a 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,8 @@ __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 +492,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 +593,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 +602,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.1