From patchwork Thu Feb 9 17:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123604 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E894741C54; Thu, 9 Feb 2023 18:11:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12B64427F2; Thu, 9 Feb 2023 18:11:48 +0100 (CET) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id 232E241611 for ; Thu, 9 Feb 2023 18:11:47 +0100 (CET) Received: by mail-pl1-f177.google.com with SMTP id k13so3610652plg.0 for ; Thu, 09 Feb 2023 09:11:46 -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=jXG5ZQ4AyXMkrwQdfU+XTtmvkY/wvBN7I4jdcbPPMuE=; b=qB48/+lOPLC3YG+kF22AZ+kySDrgcySNfH4lSP2X6lW5HGBfl55CxSNGcoz8omaWGn D5xBtdePy+NT41ZFfKQ6yhNFK+z1fl8Vp/XQKVhbTCABhj/I18Itvedhnb6SsOUKP/Z0 nV4sxiThXwmHxWzvvxWncB4zmYU77yiO2vQo2unUEfVntX8znjuE/qxldiSpaq0N9CWm AifFpiNuaLIMnq09ddP0YNrhClT2NTPqsbFF3I1oVAPbG970LDjH2nxqY4mRzZ4HeNuY jHVFFnkZ5pZfTPLo/wUZzMIT6GYAhx11doBTCBVF1l5J3eZ9zpDziUIlEm3PhJdRJtaB Av4Q== 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=jXG5ZQ4AyXMkrwQdfU+XTtmvkY/wvBN7I4jdcbPPMuE=; b=vMzQ33EcqpsaZIHpzCmdMkxsA9N5jPrsKGsHwEHkya5YMWFey4iKn+cm8ccDaxsnWI MVvCajNQ6SWRTE/uYENQETIekTw40Cyk2UxHZkrHmhW5ebC3/ZAsLd0FO97KpFCCZjhW fJQCp9nTgiAqvr6DCzRumxfLw/Eab0nLjTypuk9EBfofvbsHRnLJH+6A3SSQg01G3pSo TG7GpvjQzRzKqF2f2ovdsKUcUa1G4m2Mp3z1R2i+6GTN2DwMj15dJQiHsO0VoJeRDD4d kbN/JXZ18sfeDfnHLe6RoifnX+On53AS0rrxn3INc8NDPlEtK9/6RHPA5icObcpxyVPa Gfsg== X-Gm-Message-State: AO0yUKU4hVWk4iibdRThGri4hVSFPhtckd550rqsLsNl8uire+U10RO7 aJ2MIFC0j4X+HMUnhowLI647NF9Z0cEzWRPrq78= X-Google-Smtp-Source: AK7set91fhBESNXo8bhlFexqokSnmXrxQDsO8WKXaafNW7rZCy3x+PZoXG4ImKd6w30Odfte7MgorQ== X-Received: by 2002:a17:903:1206:b0:196:15af:e6de with SMTP id l6-20020a170903120600b0019615afe6demr13770564plh.68.1675962705738; Thu, 09 Feb 2023 09:11:45 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l5-20020a170902d34500b00188fc6766d6sm1732649plk.219.2023.02.09.09.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 09:11:45 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev , Thomas Monjalon , Anatoly Burakov Subject: [PATCH v2 1/5] ip_frag: use a dynamic logtype Date: Thu, 9 Feb 2023 09:11:38 -0800 Message-Id: <20230209171142.94938-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209171142.94938-1-stephen@networkplumber.org> References: <[200~https://inbox.dpdk.org/dev/20230208044825.1682620-1-stephen@networkplumber.org> <20230209171142.94938-1-stephen@networkplumber.org> MIME-Version: 1.0 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 DPDK libraries should not be reusing RTE_LOGTYPE_USER1 in lieu of doing proper logtype registration. Acked-by: Konstantin Ananyev Fixes: 416707812c03 ("ip_frag: refactor reassembly code into a proper library") Signed-off-by: Stephen Hemminger --- lib/ip_frag/ip_frag_common.h | 16 ++- lib/ip_frag/ip_frag_internal.c | 174 +++++++++++++++--------------- lib/ip_frag/rte_ip_frag_common.c | 13 +-- lib/ip_frag/rte_ipv4_reassembly.c | 14 ++- lib/ip_frag/rte_ipv6_reassembly.c | 59 +++++----- 5 files changed, 138 insertions(+), 138 deletions(-) diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h index 9c0dbdeb6eb9..134072f3e810 100644 --- a/lib/ip_frag/ip_frag_common.h +++ b/lib/ip_frag/ip_frag_common.h @@ -9,8 +9,16 @@ #include "ip_reassembly.h" /* logging macros. */ +extern int ipfrag_logtype; + +#define IP_FRAG_ERR(fmt, args...) \ + rte_log(RTE_LOG_ERR, ipfrag_logtype, \ + "%s: " fmt "\n", __func__, ## args) + #ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, USER1, fmt, ##args) +#define IP_FRAG_LOG(lvl, fmt, args...) \ + rte_log(RTE_LOG ## lvl, ipfrag_logtype, \ + "%s: " fmt "\n", __func__, ## args) #else #define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) #endif /* IP_FRAG_DEBUG */ @@ -111,9 +119,9 @@ ip_frag_free_immediate(struct ip_frag_pkt *fp) for (i = 0; i < fp->last_idx; i++) { if (fp->frags[i].mb != NULL) { - IP_FRAG_LOG(DEBUG, "%s:%d\n" - "mbuf: %p, tms: %" PRIu64", key: <%" PRIx64 ", %#x>\n", - __func__, __LINE__, fp->frags[i].mb, fp->start, + IP_FRAG_LOG(DEBUG, + "mbuf: %p, tms: %" PRIu64", key: <%" PRIx64 ", %#x>", + fp->frags[i].mb, fp->start, fp->key.src_dst[0], fp->key.id); rte_pktmbuf_free(fp->frags[i].mb); fp->frags[i].mb = NULL; diff --git a/lib/ip_frag/ip_frag_internal.c b/lib/ip_frag/ip_frag_internal.c index b436a4c9313b..c633216419a2 100644 --- a/lib/ip_frag/ip_frag_internal.c +++ b/lib/ip_frag/ip_frag_internal.c @@ -89,7 +89,7 @@ ipv6_frag_hash(const struct ip_frag_key *key, uint32_t *v1, uint32_t *v2) struct rte_mbuf * ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, - struct rte_mbuf *mb, uint16_t ofs, uint16_t len, uint16_t more_frags) + struct rte_mbuf *mb, uint16_t ofs, uint16_t len, uint16_t more_frags) { uint32_t idx; @@ -98,15 +98,15 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, /* this is the first fragment. */ if (ofs == 0) { idx = (fp->frags[IP_FIRST_FRAG_IDX].mb == NULL) ? - IP_FIRST_FRAG_IDX : UINT32_MAX; + IP_FIRST_FRAG_IDX : UINT32_MAX; - /* this is the last fragment. */ + /* this is the last fragment. */ } else if (more_frags == 0) { fp->total_size = ofs + len; idx = (fp->frags[IP_LAST_FRAG_IDX].mb == NULL) ? - IP_LAST_FRAG_IDX : UINT32_MAX; + IP_LAST_FRAG_IDX : UINT32_MAX; - /* this is the intermediate fragment. */ + /* this is the intermediate fragment. */ } else if ((idx = fp->last_idx) < RTE_DIM(fp->frags)) { fp->last_idx++; } @@ -119,31 +119,31 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, /* report an error. */ if (fp->key.key_len == IPV4_KEYLEN) - IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n" - "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, " - "total_size: %u, frag_size: %u, last_idx: %u\n" - "first fragment: ofs: %u, len: %u\n" - "last fragment: ofs: %u, len: %u\n\n", - __func__, __LINE__, - fp, fp->key.src_dst[0], fp->key.id, - fp->total_size, fp->frag_size, fp->last_idx, - fp->frags[IP_FIRST_FRAG_IDX].ofs, - fp->frags[IP_FIRST_FRAG_IDX].len, - fp->frags[IP_LAST_FRAG_IDX].ofs, - fp->frags[IP_LAST_FRAG_IDX].len); + IP_FRAG_LOG(DEBUG, + "invalid fragmented packet:\n" + "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, " + "total_size: %u, frag_size: %u, last_idx: %u\n" + "first fragment: ofs: %u, len: %u\n" + "last fragment: ofs: %u, len: %u\n", + fp, fp->key.src_dst[0], fp->key.id, + fp->total_size, fp->frag_size, fp->last_idx, + fp->frags[IP_FIRST_FRAG_IDX].ofs, + fp->frags[IP_FIRST_FRAG_IDX].len, + fp->frags[IP_LAST_FRAG_IDX].ofs, + fp->frags[IP_LAST_FRAG_IDX].len); else - IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n" - "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, " - "total_size: %u, frag_size: %u, last_idx: %u\n" - "first fragment: ofs: %u, len: %u\n" - "last fragment: ofs: %u, len: %u\n\n", - __func__, __LINE__, - fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, - fp->total_size, fp->frag_size, fp->last_idx, - fp->frags[IP_FIRST_FRAG_IDX].ofs, - fp->frags[IP_FIRST_FRAG_IDX].len, - fp->frags[IP_LAST_FRAG_IDX].ofs, - fp->frags[IP_LAST_FRAG_IDX].len); + IP_FRAG_LOG(DEBUG, + "invalid fragmented packet:\n" + "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, " + "total_size: %u, frag_size: %u, last_idx: %u\n" + "first fragment: ofs: %u, len: %u\n" + "last fragment: ofs: %u, len: %u\n", + fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, + fp->total_size, fp->frag_size, fp->last_idx, + fp->frags[IP_FIRST_FRAG_IDX].ofs, + fp->frags[IP_FIRST_FRAG_IDX].len, + fp->frags[IP_LAST_FRAG_IDX].ofs, + fp->frags[IP_LAST_FRAG_IDX].len); /* free all fragments, invalidate the entry. */ ip_frag_free(fp, dr); @@ -163,9 +163,9 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, if (likely (fp->frag_size < fp->total_size)) { return mb; - /* if we collected all fragments, then try to reassemble. */ + /* if we collected all fragments, then try to reassemble. */ } else if (fp->frag_size == fp->total_size && - fp->frags[IP_FIRST_FRAG_IDX].mb != NULL) { + fp->frags[IP_FIRST_FRAG_IDX].mb != NULL) { if (fp->key.key_len == IPV4_KEYLEN) mb = ipv4_frag_reassemble(fp); else @@ -177,31 +177,31 @@ ip_frag_process(struct ip_frag_pkt *fp, struct rte_ip_frag_death_row *dr, /* report an error. */ if (fp->key.key_len == IPV4_KEYLEN) - IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n" - "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, " - "total_size: %u, frag_size: %u, last_idx: %u\n" - "first fragment: ofs: %u, len: %u\n" - "last fragment: ofs: %u, len: %u\n\n", - __func__, __LINE__, - fp, fp->key.src_dst[0], fp->key.id, - fp->total_size, fp->frag_size, fp->last_idx, - fp->frags[IP_FIRST_FRAG_IDX].ofs, - fp->frags[IP_FIRST_FRAG_IDX].len, - fp->frags[IP_LAST_FRAG_IDX].ofs, - fp->frags[IP_LAST_FRAG_IDX].len); + IP_FRAG_LOG(DEBUG, + "invalid fragmented packet:\n" + "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, " + "total_size: %u, frag_size: %u, last_idx: %u\n" + "first fragment: ofs: %u, len: %u\n" + "last fragment: ofs: %u, len: %u\n, + fp, fp->key.src_dst[0], fp->key.id, + fp->total_size, fp->frag_size, fp->last_idx, + fp->frags[IP_FIRST_FRAG_IDX].ofs, + fp->frags[IP_FIRST_FRAG_IDX].len, + fp->frags[IP_LAST_FRAG_IDX].ofs, + fp->frags[IP_LAST_FRAG_IDX].len); else - IP_FRAG_LOG(DEBUG, "%s:%d invalid fragmented packet:\n" - "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, " - "total_size: %u, frag_size: %u, last_idx: %u\n" - "first fragment: ofs: %u, len: %u\n" - "last fragment: ofs: %u, len: %u\n\n", - __func__, __LINE__, - fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, - fp->total_size, fp->frag_size, fp->last_idx, - fp->frags[IP_FIRST_FRAG_IDX].ofs, - fp->frags[IP_FIRST_FRAG_IDX].len, - fp->frags[IP_LAST_FRAG_IDX].ofs, - fp->frags[IP_LAST_FRAG_IDX].len); + IP_FRAG_LOG(DEBUG, + "invalid fragmented packet:\n" + "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, " + "total_size: %u, frag_size: %u, last_idx: %u\n" + "first fragment: ofs: %u, len: %u\n" + "last fragment: ofs: %u, len: %u\n", + fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, + fp->total_size, fp->frag_size, fp->last_idx, + fp->frags[IP_FIRST_FRAG_IDX].ofs, + fp->frags[IP_FIRST_FRAG_IDX].len, + fp->frags[IP_LAST_FRAG_IDX].ofs, + fp->frags[IP_LAST_FRAG_IDX].len); /* free associated resources. */ ip_frag_free(fp, dr); @@ -282,8 +282,8 @@ ip_frag_find(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr, struct ip_frag_pkt * ip_frag_lookup(struct rte_ip_frag_tbl *tbl, - const struct ip_frag_key *key, uint64_t tms, - struct ip_frag_pkt **free, struct ip_frag_pkt **stale) + const struct ip_frag_key *key, uint64_t tms, + struct ip_frag_pkt **free, struct ip_frag_pkt **stale) { struct ip_frag_pkt *p1, *p2; struct ip_frag_pkt *empty, *old; @@ -310,23 +310,21 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl, for (i = 0; i != assoc; i++) { if (p1->key.key_len == IPV4_KEYLEN) - IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "tbl: %p, max_entries: %u, use_entries: %u\n" - "ipv4_frag_pkt line0: %p, index: %u from %u\n" - "key: <%" PRIx64 ", %#x>, start: %" PRIu64 "\n", - __func__, __LINE__, - tbl, tbl->max_entries, tbl->use_entries, - p1, i, assoc, - p1[i].key.src_dst[0], p1[i].key.id, p1[i].start); + IP_FRAG_LOG(DEBUG, + "tbl: %p, max_entries: %u, use_entries: %u\n" + "ipv4_frag_pkt line0: %p, index: %u from %u\n" + "key: <%" PRIx64 ", %#x>, start: %" PRIu64, + tbl, tbl->max_entries, tbl->use_entries, + p1, i, assoc, + p1[i].key.src_dst[0], p1[i].key.id, p1[i].start); else - IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "tbl: %p, max_entries: %u, use_entries: %u\n" - "ipv6_frag_pkt line0: %p, index: %u from %u\n" - "key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 "\n", - __func__, __LINE__, - tbl, tbl->max_entries, tbl->use_entries, - p1, i, assoc, - IPv6_KEY_BYTES(p1[i].key.src_dst), p1[i].key.id, p1[i].start); + IP_FRAG_LOG(DEBUG, + "tbl: %p, max_entries: %u, use_entries: %u\n" + "ipv6_frag_pkt line0: %p, index: %u from %u\n" + "key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64, + tbl, tbl->max_entries, tbl->use_entries, + p1, i, assoc, + IPv6_KEY_BYTES(p1[i].key.src_dst), p1[i].key.id, p1[i].start); if (ip_frag_key_cmp(key, &p1[i].key) == 0) return p1 + i; @@ -336,23 +334,21 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl, old = (old == NULL) ? (p1 + i) : old; if (p2->key.key_len == IPV4_KEYLEN) - IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "tbl: %p, max_entries: %u, use_entries: %u\n" - "ipv4_frag_pkt line1: %p, index: %u from %u\n" - "key: <%" PRIx64 ", %#x>, start: %" PRIu64 "\n", - __func__, __LINE__, - tbl, tbl->max_entries, tbl->use_entries, - p2, i, assoc, - p2[i].key.src_dst[0], p2[i].key.id, p2[i].start); + IP_FRAG_LOG(DEBUG, + "tbl: %p, max_entries: %u, use_entries: %u\n" + "ipv4_frag_pkt line1: %p, index: %u from %u\n" + "key: <%" PRIx64 ", %#x>, start: %" PRIu64, + tbl, tbl->max_entries, tbl->use_entries, + p2, i, assoc, + p2[i].key.src_dst[0], p2[i].key.id, p2[i].start); else - IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "tbl: %p, max_entries: %u, use_entries: %u\n" - "ipv6_frag_pkt line1: %p, index: %u from %u\n" - "key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 "\n", - __func__, __LINE__, - tbl, tbl->max_entries, tbl->use_entries, - p2, i, assoc, - IPv6_KEY_BYTES(p2[i].key.src_dst), p2[i].key.id, p2[i].start); + IP_FRAG_LOG(DEBUG, + "tbl: %p, max_entries: %u, use_entries: %u\n" + "ipv6_frag_pkt line1: %p, index: %u from %u\n" + "key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64, + tbl, tbl->max_entries, tbl->use_entries, + p2, i, assoc, + IPv6_KEY_BYTES(p2[i].key.src_dst), p2[i].key.id, p2[i].start); if (ip_frag_key_cmp(key, &p2[i].key) == 0) return p2 + i; diff --git a/lib/ip_frag/rte_ip_frag_common.c b/lib/ip_frag/rte_ip_frag_common.c index c1de2e81b6d0..b8ca9e019c54 100644 --- a/lib/ip_frag/rte_ip_frag_common.c +++ b/lib/ip_frag/rte_ip_frag_common.c @@ -52,21 +52,20 @@ rte_ip_frag_table_create(uint32_t bucket_num, uint32_t bucket_entries, if (rte_is_power_of_2(bucket_entries) == 0 || nb_entries > UINT32_MAX || nb_entries == 0 || nb_entries < max_entries) { - RTE_LOG(ERR, USER1, "%s: invalid input parameter\n", __func__); + IP_FRAG_ERR("invalid input parameter"); return NULL; } sz = sizeof (*tbl) + nb_entries * sizeof (tbl->pkt[0]); if ((tbl = rte_zmalloc_socket(__func__, sz, RTE_CACHE_LINE_SIZE, socket_id)) == NULL) { - RTE_LOG(ERR, USER1, - "%s: allocation of %zu bytes at socket %d failed do\n", - __func__, sz, socket_id); + IP_FRAG_ERR("allocation of %zu bytes at socket %d failed do", + sz, socket_id); return NULL; } - RTE_LOG(INFO, USER1, "%s: allocated of %zu bytes at socket %d\n", - __func__, sz, socket_id); + IP_FRAG_LOG(INFO, "allocated of %zu bytes at socket %d", + sz, socket_id); tbl->max_cycles = max_cycles; tbl->max_entries = max_entries; @@ -142,3 +141,5 @@ rte_ip_frag_table_del_expired_entries(struct rte_ip_frag_tbl *tbl, } else return; } + +RTE_LOG_REGISTER_DEFAULT(ipfrag_logtype, INFO); diff --git a/lib/ip_frag/rte_ipv4_reassembly.c b/lib/ip_frag/rte_ipv4_reassembly.c index 4a89a5f5365a..2cdbdc4ee87f 100644 --- a/lib/ip_frag/rte_ipv4_reassembly.c +++ b/lib/ip_frag/rte_ipv4_reassembly.c @@ -120,12 +120,11 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, ip_len = rte_be_to_cpu_16(ip_hdr->total_length) - mb->l3_len; trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len); - IP_FRAG_LOG(DEBUG, "%s:%d:\n" + IP_FRAG_LOG(DEBUG, "mbuf: %p, tms: %" PRIu64 ", key: <%" PRIx64 ", %#x>" "ofs: %u, len: %d, padding: %d, flags: %#x\n" "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, " - "max_entries: %u, use_entries: %u\n\n", - __func__, __LINE__, + "max_entries: %u, use_entries: %u\n", mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, trim, ip_flag, tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, tbl->use_entries); @@ -145,11 +144,10 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, return NULL; } - IP_FRAG_LOG(DEBUG, "%s:%d:\n" + IP_FRAG_LOG(DEBUG, "tbl: %p, max_entries: %u, use_entries: %u\n" "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, start: %" PRIu64 - ", total_size: %u, frag_size: %u, last_idx: %u\n\n", - __func__, __LINE__, + ", total_size: %u, frag_size: %u, last_idx: %u\n", tbl, tbl->max_entries, tbl->use_entries, fp, fp->key.src_dst[0], fp->key.id, fp->start, fp->total_size, fp->frag_size, fp->last_idx); @@ -159,11 +157,11 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, mb = ip_frag_process(fp, dr, mb, ip_ofs, ip_len, ip_flag); ip_frag_inuse(tbl, fp); - IP_FRAG_LOG(DEBUG, "%s:%d:\n" + IP_FRAG_LOG(DEBUG, "mbuf: %p\n" "tbl: %p, max_entries: %u, use_entries: %u\n" "ipv4_frag_pkt: %p, key: <%" PRIx64 ", %#x>, start: %" PRIu64 - ", total_size: %u, frag_size: %u, last_idx: %u\n\n", + ", total_size: %u, frag_size: %u, last_idx: %u\n", __func__, __LINE__, mb, tbl, tbl->max_entries, tbl->use_entries, fp, fp->key.src_dst[0], fp->key.id, fp->start, diff --git a/lib/ip_frag/rte_ipv6_reassembly.c b/lib/ip_frag/rte_ipv6_reassembly.c index d4019e87e63a..c3e369f4ce42 100644 --- a/lib/ip_frag/rte_ipv6_reassembly.c +++ b/lib/ip_frag/rte_ipv6_reassembly.c @@ -135,8 +135,8 @@ ipv6_frag_reassemble(struct ip_frag_pkt *fp) #define FRAG_OFFSET(x) (rte_cpu_to_be_16(x) >> 3) struct rte_mbuf * rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, - struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms, - struct rte_ipv6_hdr *ip_hdr, struct rte_ipv6_fragment_ext *frag_hdr) + struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms, + struct rte_ipv6_hdr *ip_hdr, struct rte_ipv6_fragment_ext *frag_hdr) { struct ip_frag_pkt *fp; struct ip_frag_key key; @@ -161,17 +161,16 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, ip_len = rte_be_to_cpu_16(ip_hdr->payload_len) - sizeof(*frag_hdr); trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len); - IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "mbuf: %p, tms: %" PRIu64 - ", key: <" IPv6_KEY_BYTES_FMT ", %#x>, " - "ofs: %u, len: %d, padding: %d, flags: %#x\n" - "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, " - "max_entries: %u, use_entries: %u\n\n", - __func__, __LINE__, - mb, tms, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs, ip_len, - trim, RTE_IPV6_GET_MF(frag_hdr->frag_data), - tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, - tbl->use_entries); + IP_FRAG_LOG(DEBUG, + "mbuf: %p, tms: %" PRIu64 + ", key: <" IPv6_KEY_BYTES_FMT ", %#x>, " + "ofs: %u, len: %d, padding: %d, flags: %#x\n" + "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, " + "max_entries: %u, use_entries: %u\n", + mb, tms, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs, ip_len, + trim, RTE_IPV6_GET_MF(frag_hdr->frag_data), + tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, + tbl->use_entries); /* check that fragment length is greater then zero. */ if (ip_len <= 0) { @@ -189,30 +188,28 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, return NULL; } - IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "tbl: %p, max_entries: %u, use_entries: %u\n" - "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 - ", total_size: %u, frag_size: %u, last_idx: %u\n\n", - __func__, __LINE__, - tbl, tbl->max_entries, tbl->use_entries, - fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start, - fp->total_size, fp->frag_size, fp->last_idx); + IP_FRAG_LOG(DEBUG, + "tbl: %p, max_entries: %u, use_entries: %u\n" + "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 + ", total_size: %u, frag_size: %u, last_idx: %u\n", + tbl, tbl->max_entries, tbl->use_entries, + fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start, + fp->total_size, fp->frag_size, fp->last_idx); /* process the fragmented packet. */ mb = ip_frag_process(fp, dr, mb, ip_ofs, ip_len, - MORE_FRAGS(frag_hdr->frag_data)); + MORE_FRAGS(frag_hdr->frag_data)); ip_frag_inuse(tbl, fp); - IP_FRAG_LOG(DEBUG, "%s:%d:\n" - "mbuf: %p\n" - "tbl: %p, max_entries: %u, use_entries: %u\n" - "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 - ", total_size: %u, frag_size: %u, last_idx: %u\n\n", - __func__, __LINE__, mb, - tbl, tbl->max_entries, tbl->use_entries, - fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start, - fp->total_size, fp->frag_size, fp->last_idx); + IP_FRAG_LOG(DEBUG, + "mbuf: %p\n" + "tbl: %p, max_entries: %u, use_entries: %u\n" + "ipv6_frag_pkt: %p, key: <" IPv6_KEY_BYTES_FMT ", %#x>, start: %" PRIu64 + ", total_size: %u, frag_size: %u, last_idx: %u\n", + mb, tbl, tbl->max_entries, tbl->use_entries, + fp, IPv6_KEY_BYTES(fp->key.src_dst), fp->key.id, fp->start, + fp->total_size, fp->frag_size, fp->last_idx); return mb; } From patchwork Thu Feb 9 17:11:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123605 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E629241C54; Thu, 9 Feb 2023 18:11:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3865F42B8E; Thu, 9 Feb 2023 18:11:50 +0100 (CET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id CBCE54161A for ; Thu, 9 Feb 2023 18:11:47 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id o13so2727156pjg.2 for ; Thu, 09 Feb 2023 09:11:47 -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=KZgfsFOvebHmT9+dLkYUNEfM3BYjfInGf2AA4yLuCd4=; b=QNR/R36DWteJ4xrr9eAbWbHCXPIHfr84miLYBslREHm0u4AhRekyN6qMn0tYYwfelE 0Ya613t4acSdpsI2J+Oo9dGmLK3ijQRaS5f5D6hzmEbpzQ71mP4uaSDXzuNeq/uIMcr2 j3iTlDA2LVcHYSIkVxlD/gJqoMtouEJjxpdmK2E3WFWzgdOEE0RbWPIRZLBeNyr0t08g C7/rZZVaDf089Lt9YMBU/LZp/HVg0Tz2mneZlxuX81SwBUNck6ZqwdTMJqvRIa/xK3Gl 5QiaLFjY7rlgQ2pLyKj1BydGvK19LUliL3p7MwmAU7un051dA15QnKHP5Zhb8W1mNG9F Qhvg== 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=KZgfsFOvebHmT9+dLkYUNEfM3BYjfInGf2AA4yLuCd4=; b=VUXUFskuAFNdZ6+yIY3yOMZ/qtNQESxwM+smFna+dDjmcq0HGhmsVoc0tmWqegRYxE 2jZ/BiLnrdq1xQ81u/Vv9KjO2AyDUvNkIR3BV06tY9e8fUU99dFwXFLdvDDG5I5bh6MC UoLDizIUhrV+4GUO2By+Gb8Y8mztJyLiETy1m2fzX09VKZPxm87TcCwjyZ8vgZwt1Tbq 3AzopYZx/o1BqtQtbI62l0HH8DY0T8lY/g8Hz15TecRbuHfEgbrYFe0gBgPAk4H3Be49 l0d5Zg06NQ1utd++KG1XJFZJNTABuy6iezAaPIRF6AvQxAa+NP/vtia9sg4hqZd2x7vv WylQ== X-Gm-Message-State: AO0yUKUuql12/DmmoavBqR11b+eXHwBpJqJPC093MoLATHvBdsGUlMHm t8kecMQmMrcFEnGPsSgDRYQHDn7TxtH4JhAelKo= X-Google-Smtp-Source: AK7set9ujD1oUUl1xXwtKvjctY3ehiq/zPvyQlMWhRzGCrlt39idD+/kCznHmHIf9Zg3t7GvRkw8Ug== X-Received: by 2002:a17:902:f30c:b0:196:82b6:3d8d with SMTP id c12-20020a170902f30c00b0019682b63d8dmr8439802ple.46.1675962706733; Thu, 09 Feb 2023 09:11:46 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l5-20020a170902d34500b00188fc6766d6sm1732649plk.219.2023.02.09.09.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 09:11:46 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , sergio.gonzalez.monroy@intel.com, Reshma Pattan , Neil Horman , Declan Doherty , Richardson Bruce Subject: [PATCH v2 2/5] reorder: use a dynamic logtype Date: Thu, 9 Feb 2023 09:11:39 -0800 Message-Id: <20230209171142.94938-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209171142.94938-1-stephen@networkplumber.org> References: <[200~https://inbox.dpdk.org/dev/20230208044825.1682620-1-stephen@networkplumber.org> <20230209171142.94938-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Libraries should not be reusing RTE_LOGTYPE_USER1 instead of doing proper logtype registration. Fixes: b70b56032bff ("reorder: new library") Cc: sergio.gonzalez.monroy@intel.com Signed-off-by: Stephen Hemminger --- lib/reorder/rte_reorder.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/reorder/rte_reorder.c b/lib/reorder/rte_reorder.c index 385ee479da42..c9ae42e71783 100644 --- a/lib/reorder/rte_reorder.c +++ b/lib/reorder/rte_reorder.c @@ -27,7 +27,11 @@ EAL_REGISTER_TAILQ(rte_reorder_tailq) #define RTE_REORDER_NAMESIZE 32 /* Macros for printing using RTE_LOG */ -#define RTE_LOGTYPE_REORDER RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_DEFAULT(reorder_logtype, INFO); + +#define REORDER_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, reorder_logtype, \ + "%s(): " fmt "\n", __func__, ##args) #define RTE_REORDER_SEQN_DYNFIELD_NAME "rte_reorder_seqn_dynfield" int rte_reorder_seqn_dynfield_offset = -1; @@ -62,26 +66,25 @@ rte_reorder_init(struct rte_reorder_buffer *b, unsigned int bufsize, (2 * size * sizeof(struct rte_mbuf *)); if (b == NULL) { - RTE_LOG(ERR, REORDER, "Invalid reorder buffer parameter:" - " NULL\n"); + REORDER_LOG(ERR, "Invalid reorder buffer parameter: NULL"); rte_errno = EINVAL; return NULL; } if (!rte_is_power_of_2(size)) { - RTE_LOG(ERR, REORDER, "Invalid reorder buffer size" - " - Not a power of 2\n"); + REORDER_LOG(ERR, + "Invalid reorder buffer size - Not a power of 2"); rte_errno = EINVAL; return NULL; } if (name == NULL) { - RTE_LOG(ERR, REORDER, "Invalid reorder buffer name ptr:" - " NULL\n"); + REORDER_LOG(ERR, "Invalid reorder buffer name ptr: NULL"); rte_errno = EINVAL; return NULL; } if (bufsize < min_bufsize) { - RTE_LOG(ERR, REORDER, "Invalid reorder buffer memory size: %u, " - "minimum required: %u\n", bufsize, min_bufsize); + REORDER_LOG(ERR, + "Invalid reorder buffer memory size: %u, minimum required: %u", + bufsize, min_bufsize); rte_errno = EINVAL; return NULL; } @@ -116,14 +119,13 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) /* Check user arguments. */ if (!rte_is_power_of_2(size)) { - RTE_LOG(ERR, REORDER, "Invalid reorder buffer size" - " - Not a power of 2\n"); + REORDER_LOG(ERR, + "Invalid reorder buffer size - Not a power of 2"); rte_errno = EINVAL; return NULL; } if (name == NULL) { - RTE_LOG(ERR, REORDER, "Invalid reorder buffer name ptr:" - " NULL\n"); + REORDER_LOG(ERR, "Invalid reorder buffer name ptr: NULL"); rte_errno = EINVAL; return NULL; } @@ -131,7 +133,8 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) rte_reorder_seqn_dynfield_offset = rte_mbuf_dynfield_register(&reorder_seqn_dynfield_desc); if (rte_reorder_seqn_dynfield_offset < 0) { - RTE_LOG(ERR, REORDER, "Failed to register mbuf field for reorder sequence number\n"); + REORDER_LOG(ERR, + "Failed to register mbuf field for reorder sequence number"); rte_errno = ENOMEM; return NULL; } @@ -150,7 +153,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) /* allocate tailq entry */ te = rte_zmalloc("REORDER_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, REORDER, "Failed to allocate tailq entry\n"); + REORDER_LOG(ERR, "Failed to allocate tailq entry"); rte_errno = ENOMEM; b = NULL; goto exit; @@ -159,7 +162,7 @@ rte_reorder_create(const char *name, unsigned socket_id, unsigned int size) /* Allocate memory to store the reorder buffer structure. */ b = rte_zmalloc_socket("REORDER_BUFFER", bufsize, 0, socket_id); if (b == NULL) { - RTE_LOG(ERR, REORDER, "Memzone allocation failed\n"); + REORDER_LOG(ERR, "Memzone allocation failed"); rte_errno = ENOMEM; rte_free(te); } else { From patchwork Thu Feb 9 17:11:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123606 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E29BF41C54; Thu, 9 Feb 2023 18:12:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C06042C54; Thu, 9 Feb 2023 18:11:51 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id BE52D42B8C for ; Thu, 9 Feb 2023 18:11:48 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id gj9-20020a17090b108900b0023114156d36so6507199pjb.4 for ; Thu, 09 Feb 2023 09:11:48 -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=gvTgzcLHWczeKJnkpsC+rJhEoBxEk1W8Qv+jCAnORCk=; b=iZVmB+WVRQBtz+ry2gD88lsXZQ7WR6AdgSq38YlRz3F8cLdycnuJDC993vu6loJzt8 fqCMf0d24343wzArEyM1cPUNKHnjf2oYWKHMGzA6IhRzIwQpd0daelFdvktDgVRWGP3B yo4R/BVzwaZEWpNV8/iRzTEx934FKJf3GFBz7QkB7oBQBMTFlomucUQB8PKP9QKPdC1t GL8EY5hl8cFBoeXt6QM+WrpitnVkcsehF6muuRfQJQ1OW5rQw3sRgrmSr5yz4yVTk4sT sJifQyo/4cnSksVW1ErOZYe0SFCML/jhyAPloeCzgdlf9WMgh32Wa1sbTTeERPtLEqFF zhdw== 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=gvTgzcLHWczeKJnkpsC+rJhEoBxEk1W8Qv+jCAnORCk=; b=BD+fx01A6QRKzg0vgLJNeQfUGERZSxlhKueoEBb3d7okbxJPsjc0kA2WThnI6KN96N CjhCuxacqpIfdlWSPni4FW9Go5Oh3sow+KvKWDD70C6BLvHaQZPSMfNSihdFAmKB7Qj3 5MZ5qsHh4/Mn8qWYv8QZ4V/+wyEmxEx84lX9ZKGWyWbO72jYqFZOeGTvo5Zl7WZFcbur Tp75VFeUsizlfw9t+BtkVU4II8BUmoALqURIhEfcoLwLw+DOqIKT8RXAy70ATUg7pSZo DXeQ+V9+WXZZGOQT8hJpOUfS8bQWEkoJPXf0W0vn2TPR9MSgKwRim6OXEZPltryrL20t TNqQ== X-Gm-Message-State: AO0yUKXpB9zNho8OPfPPDWyCJuCxY2wQhDX6xvHRLhCQcbyokIOGi9h1 5IINqA9+v+DsIJ5VjFxSYZXqZwLyHoWCz0QOaFk= X-Google-Smtp-Source: AK7set+gOcBIq9aOqyaqVn0yL1nZjiLesHFjzV3oBTJ+E52ydImQfQ69axD6sqAk7kXLRfBbBYhNfA== X-Received: by 2002:a17:902:c611:b0:198:f245:63b3 with SMTP id r17-20020a170902c61100b00198f24563b3mr8921179plr.36.1675962707649; Thu, 09 Feb 2023 09:11:47 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l5-20020a170902d34500b00188fc6766d6sm1732649plk.219.2023.02.09.09.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 09:11:47 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , reshma.pattan@intel.com, Remy Horton , Harry van Haaren Subject: [PATCH v2 3/5] latencystats: use dynamic logtype Date: Thu, 9 Feb 2023 09:11:40 -0800 Message-Id: <20230209171142.94938-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209171142.94938-1-stephen@networkplumber.org> References: <[200~https://inbox.dpdk.org/dev/20230208044825.1682620-1-stephen@networkplumber.org> <20230209171142.94938-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Libraries should not reuse RTE_LOGTYPE_USER1 for their logging. Instead they should register their own type. Fixes: 5cd3cac9ed22 ("latency: added new library for latency stats") Cc: reshma.pattan@intel.com Signed-off-by: Stephen Hemminger --- lib/latencystats/rte_latencystats.c | 55 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 8985a377db4e..3a4c47e2b34a 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -26,7 +26,10 @@ latencystat_cycles_per_ns(void) } /* Macros for printing using RTE_LOG */ -#define RTE_LOGTYPE_LATENCY_STATS RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_DEFAULT(latencystat_logtype, INFO); +#define LATENCYSTATS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, latencystat_logtype, \ + "%s(): " fmt "\n", __func__, ## args) static uint64_t timestamp_dynflag; static int timestamp_dynfield_offset = -1; @@ -95,7 +98,7 @@ rte_latencystats_update(void) latency_stats_index, values, NUM_LATENCY_STATS); if (ret < 0) - RTE_LOG(INFO, LATENCY_STATS, "Failed to push the stats\n"); + LATENCYSTATS_LOG(INFO, "Failed to push the stats"); return ret; } @@ -227,8 +230,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, mz = rte_memzone_reserve(MZ_RTE_LATENCY_STATS, sizeof(*glob_stats), rte_socket_id(), flags); if (mz == NULL) { - RTE_LOG(ERR, LATENCY_STATS, "Cannot reserve memory: %s:%d\n", - __func__, __LINE__); + LATENCYSTATS_LOG(ERR, "Cannot reserve memory"); return -ENOMEM; } @@ -243,8 +245,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, latency_stats_index = rte_metrics_reg_names(ptr_strings, NUM_LATENCY_STATS); if (latency_stats_index < 0) { - RTE_LOG(DEBUG, LATENCY_STATS, - "Failed to register latency stats names\n"); + LATENCYSTATS_LOG(ERR, "Failed to register latency stats names"); return -1; } @@ -252,8 +253,8 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret = rte_mbuf_dyn_rx_timestamp_register(×tamp_dynfield_offset, ×tamp_dynflag); if (ret != 0) { - RTE_LOG(ERR, LATENCY_STATS, - "Cannot register mbuf field/flag for timestamp\n"); + LATENCYSTATS_LOG(ERR, + "Cannot register mbuf field/flag for timestamp"); return -rte_errno; } @@ -263,9 +264,9 @@ rte_latencystats_init(uint64_t app_samp_intvl, ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - RTE_LOG(INFO, LATENCY_STATS, - "Error during getting device (port %u) info: %s\n", - pid, strerror(-ret)); + LATENCYSTATS_LOG(INFO, + "Error during getting device (port %u) info: %s", + pid, strerror(-ret)); continue; } @@ -275,18 +276,18 @@ rte_latencystats_init(uint64_t app_samp_intvl, cbs->cb = rte_eth_add_first_rx_callback(pid, qid, add_time_stamps, user_cb); if (!cbs->cb) - RTE_LOG(INFO, LATENCY_STATS, "Failed to " - "register Rx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "Failed to register Rx callback for pid=%d, qid=%d", + pid, qid); } for (qid = 0; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; cbs->cb = rte_eth_add_tx_callback(pid, qid, calc_latency, user_cb); if (!cbs->cb) - RTE_LOG(INFO, LATENCY_STATS, "Failed to " - "register Tx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "Failed to register Tx callback for pid=%d, qid=%d", + pid, qid); } } return 0; @@ -307,8 +308,8 @@ rte_latencystats_uninit(void) ret = rte_eth_dev_info_get(pid, &dev_info); if (ret != 0) { - RTE_LOG(INFO, LATENCY_STATS, - "Error during getting device (port %u) info: %s\n", + LATENCYSTATS_LOG(INFO, + "Error during getting device (port %u) info: %s", pid, strerror(-ret)); continue; @@ -318,17 +319,17 @@ rte_latencystats_uninit(void) cbs = &rx_cbs[pid][qid]; ret = rte_eth_remove_rx_callback(pid, qid, cbs->cb); if (ret) - RTE_LOG(INFO, LATENCY_STATS, "failed to " - "remove Rx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "failed to remove Rx callback for pid=%d, qid=%d", + pid, qid); } for (qid = 0; qid < dev_info.nb_tx_queues; qid++) { cbs = &tx_cbs[pid][qid]; ret = rte_eth_remove_tx_callback(pid, qid, cbs->cb); if (ret) - RTE_LOG(INFO, LATENCY_STATS, "failed to " - "remove Tx callback for pid=%d, " - "qid=%d\n", pid, qid); + LATENCYSTATS_LOG(INFO, + "failed to remove Tx callback for pid=%d, qid=%d", + pid, qid); } } @@ -365,8 +366,8 @@ rte_latencystats_get(struct rte_metric_value *values, uint16_t size) const struct rte_memzone *mz; mz = rte_memzone_lookup(MZ_RTE_LATENCY_STATS); if (mz == NULL) { - RTE_LOG(ERR, LATENCY_STATS, - "Latency stats memzone not found\n"); + LATENCYSTATS_LOG(ERR, + "Latency stats memzone not found"); return -ENOMEM; } glob_stats = mz->addr; From patchwork Thu Feb 9 17:11:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123607 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E71A441C54; Thu, 9 Feb 2023 18:12:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 68DE642D0E; Thu, 9 Feb 2023 18:11:52 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id A07A742B8E for ; Thu, 9 Feb 2023 18:11:49 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id f6so3505148pln.12 for ; Thu, 09 Feb 2023 09:11:49 -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=pzbVpFyp0lPmiM1bVIT351NHQTAvRw8JlayunUmnas4=; b=ShiHcdgSdniYLAHCNCXrTrjhoY1rdjNWn1Cgau19c3rYecebgN+0ItfJgElpBOjBr8 q3QQ9XfagrPZzz/DfDTnNI+22Cg4dMSvWV88FGHqnzN2ZeFf1r8xfWM57IPptQ+vlc1v q7EKucYLddp8j9gxqOkZ6si1mIMukD/ljnsKZpFd1C+KLBI1h7Qtivcqel1dfrN8BDol UdXGGPmcWT2GxGBiLfH09zvPD3bzwaMgbepJy5hRrv9N3R+DLB16g5tvhPn8FRBuiAUU /3qgxbrdAtUW1TE4JEC6KWUZlm+UngfkX1UOb8+ed8bZM7LyvcDdLyrBamIFzi141/BI O+lQ== 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=pzbVpFyp0lPmiM1bVIT351NHQTAvRw8JlayunUmnas4=; b=wnIIEFR0NCRjNGcM4ik8cxEYJ1ZNj/VQ2Qmy8t9EvDXwI4KHgppBdwvfucic0lG69w W5aZSJNDuUayRsfCxpafq6KP0BSH1KDXemGYE8tYgQfa7vf+FKg+9iwDOvgl227Jo3Wg mCuwcU83c7eYUIUpmlicaY4KKsHMLgF3FcGxGdix9ijkA5t/v4gzY/IAJ0H3bHRZs4pm ppq53KD6b+S4AHltT5IW8zFan5AsEpjtuDfAZsZhkMZPuWWDdRB+NnFTB6eWPHeIyNUT iY+Xf4DXB//yrF7PkBe0cSg9gRwlCUYG0ABm9N93Lyz/4ENxX8bcVI+K/UwDpZYwHfGs 03nQ== X-Gm-Message-State: AO0yUKXUuEo6mgBn+kDIm0oULZRnOP2JNWP+29G3k2Wzw6GUM1sB9KCB f+rGd691P3RHza6lB8yJtcxkxL3JS80BL2Qu6k4= X-Google-Smtp-Source: AK7set+/cFVCfwvuUQdabxHzZBeX8v5rFM8LHaosyYcHnF8L+6aYPM8zdtQeDc2w79NZVKiTiinxOw== X-Received: by 2002:a17:903:1386:b0:198:a715:d26e with SMTP id jx6-20020a170903138600b00198a715d26emr8408487plb.36.1675962708635; Thu, 09 Feb 2023 09:11:48 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l5-20020a170902d34500b00188fc6766d6sm1732649plk.219.2023.02.09.09.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 09:11:48 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Chenbo Xia , Maxime Coquelin Subject: [PATCH v2 4/5] vhost: use logtype instead of RTE_LOGTYPE_USER1 Date: Thu, 9 Feb 2023 09:11:41 -0800 Message-Id: <20230209171142.94938-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209171142.94938-1-stephen@networkplumber.org> References: <[200~https://inbox.dpdk.org/dev/20230208044825.1682620-1-stephen@networkplumber.org> <20230209171142.94938-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Fix instances of USER1 logtype in fdset and crypto sections. Acked-by: Chenbo Xia Signed-off-by: Stephen Hemminger --- lib/vhost/fd_man.c | 16 +++++++++------- lib/vhost/vhost_crypto.c | 25 +++++++++++-------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/vhost/fd_man.c b/lib/vhost/fd_man.c index 1876fada3354..172f7dc03ab2 100644 --- a/lib/vhost/fd_man.c +++ b/lib/vhost/fd_man.c @@ -10,8 +10,10 @@ #include "fd_man.h" - -#define RTE_LOGTYPE_VHOST_FDMAN RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_SUFFIX(vhost_fdset_logtype, fdset, INFO); +#define FDSET_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, vhost_fdset_logtype, \ + "%s(): " fmt "\n", __func__, ## args) #define FDPOLLERR (POLLERR | POLLHUP | POLLNVAL) @@ -334,8 +336,8 @@ fdset_pipe_init(struct fdset *fdset) int ret; if (pipe(fdset->u.pipefd) < 0) { - RTE_LOG(ERR, VHOST_FDMAN, - "failed to create pipe for vhost fdset\n"); + FDSET_LOG(ERR, + "failed to create pipe for vhost fdset"); return -1; } @@ -343,9 +345,9 @@ fdset_pipe_init(struct fdset *fdset) fdset_pipe_read_cb, NULL, NULL); if (ret < 0) { - RTE_LOG(ERR, VHOST_FDMAN, - "failed to add pipe readfd %d into vhost server fdset\n", - fdset->u.readfd); + FDSET_LOG(ERR, + "failed to add pipe readfd %d into vhost server fdset", + fdset->u.readfd); fdset_pipe_uninit(fdset); return -1; diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c index f02bf865c349..3be46614c22a 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -16,22 +17,18 @@ #define IV_OFFSET (sizeof(struct rte_crypto_op) + \ sizeof(struct rte_crypto_sym_op)) +RTE_LOG_REGISTER_SUFFIX(vhost_crypto_logtype, crypto, INFO); + +#define VC_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, vhost_crypto_logtype, \ + "%s():%u: " fmt "\n", __func__, __LINE__, ## args) + +#define VC_LOG_ERR(fmt, args...) VC_LOG(ERR, fmt, ## args) +#define VC_LOG_INFO(fmt, args...) VC_LOG(INFO, fmt, ## args) + #ifdef RTE_LIBRTE_VHOST_DEBUG -#define VC_LOG_ERR(fmt, args...) \ - RTE_LOG(ERR, USER1, "[%s] %s() line %u: " fmt "\n", \ - "Vhost-Crypto", __func__, __LINE__, ## args) -#define VC_LOG_INFO(fmt, args...) \ - RTE_LOG(INFO, USER1, "[%s] %s() line %u: " fmt "\n", \ - "Vhost-Crypto", __func__, __LINE__, ## args) - -#define VC_LOG_DBG(fmt, args...) \ - RTE_LOG(DEBUG, USER1, "[%s] %s() line %u: " fmt "\n", \ - "Vhost-Crypto", __func__, __LINE__, ## args) +#define VC_LOG_DBG(fmt, args...) VC_LOG(DEBUG, fmt, ## args) #else -#define VC_LOG_ERR(fmt, args...) \ - RTE_LOG(ERR, USER1, "[VHOST-Crypto]: " fmt "\n", ## args) -#define VC_LOG_INFO(fmt, args...) \ - RTE_LOG(INFO, USER1, "[VHOST-Crypto]: " fmt "\n", ## args) #define VC_LOG_DBG(fmt, args...) #endif From patchwork Thu Feb 9 17:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123608 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C4DA41C54; Thu, 9 Feb 2023 18:12:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6739942D17; Thu, 9 Feb 2023 18:11:53 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 569BA42BC9 for ; Thu, 9 Feb 2023 18:11:50 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id gj9-20020a17090b108900b0023114156d36so6507317pjb.4 for ; Thu, 09 Feb 2023 09:11:50 -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=XQmC9K3TeXMgFqeLevvNO7XT0CzfA3gO5d2+9bnbNsc=; b=45yHHDOTzIRYsqTIBzudnV7ulv7o8bZ4S0U9eYYKUkPpZBZvL/2jumz1qcKIq65j9t XS4DO+vLNVTTLDriGScpRo57esLsbLDC5Xh3DhxGz5AuL0Nqw6OUbGsYWIwbWckje1Xl vTsMSZWzuHwq3YJ2CPdUaPX4hA9BKHdgQGoypclYiM3aBmumRDKel1zqrSIJvfxJ9v11 in3dq8GPpzHFFgzwXCK9f0iIQ+UM3IfK5r/3HxMNVhysBNlE1RCbw8vOwmyCyMADQIvk 4yddLTwQvCO2JNvheLW1khATC/pRYpDr4Tsrixc1wwfMT5N5KqGuYWpmiRRVMo0qOEFL NPSA== 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=XQmC9K3TeXMgFqeLevvNO7XT0CzfA3gO5d2+9bnbNsc=; b=LNjw0mscSUg5wc8vzRjOSMXE3626ObYngk0P/xBMwOyqQ6UIr0yuDg1Sjj12JqEWIT ZA1ahSwLjxlftZ+TwRYslzBZqPhhHptos6qGt+Vlns0PdED6B/AIqrvYbRKlfTvc1ain abQD2GxMM8W5v9x8s0HFPrIpDgfhgtniDMa1rb6eaWyPzY4cN/oJvwYn4Ym6eWmF7EkI bGY4hEmwDFyTt2M739qbTjMhKwQBt10BXCmGzRUi1swxfZm4WWBrUQayrye6UYw44poH fB6nqKbLUx9CJftzezsC1f2wzwFBYqCnwb70pNN4j6t1PQ0c7lAPgm4ai33QRsvmvmo3 FjpQ== X-Gm-Message-State: AO0yUKWQG/KGXE/jqsWq1Od2ADnm1/V0Rh1/AjKBXf+a+OAW7OseLAzb c0XyYADeUCfAQv/MtNvmau/YFvJm/PPML66ECN0= X-Google-Smtp-Source: AK7set981O1bWXgJo46z7S8fafeiw5pmJGT4MY1EYcsFOlljYee7G7d36gzotJ0opTALxB2Wj2Nh+g== X-Received: by 2002:a17:903:1107:b0:196:8d48:8744 with SMTP id n7-20020a170903110700b001968d488744mr13742919plh.40.1675962709639; Thu, 09 Feb 2023 09:11:49 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l5-20020a170902d34500b00188fc6766d6sm1732649plk.219.2023.02.09.09.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 09:11:49 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , kai.ji@intel.com, Pablo de Lara , Arkadiusz Kusztal Subject: [PATCH v2 5/5] ipsec: fix usage of RTE_LOGTYPE_USER1 Date: Thu, 9 Feb 2023 09:11:42 -0800 Message-Id: <20230209171142.94938-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209171142.94938-1-stephen@networkplumber.org> References: <[200~https://inbox.dpdk.org/dev/20230208044825.1682620-1-stephen@networkplumber.org> <20230209171142.94938-1-stephen@networkplumber.org> MIME-Version: 1.0 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 There already is a logtype in this driver, use it! Fixes: b35848bc01f6 ("crypto/ipsec_mb: add multi-process IPC request handler") Cc: kai.ji@intel.com Signed-off-by: Stephen Hemminger --- drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c index 3e52f9567401..e9eb0d15b794 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c @@ -7,6 +7,7 @@ #include #include +#include #include "ipsec_mb_private.h" @@ -125,7 +126,7 @@ ipsec_mb_secondary_qp_op(int dev_id, int qp_id, qp_req_msg.num_fds = 0; ret = rte_mp_request_sync(&qp_req_msg, &qp_resp, &ts); if (ret) { - RTE_LOG(ERR, USER1, "Create MR request to primary process failed."); + IPSEC_MB_LOG(ERR, "Create MR request to primary process failed."); return -1; } qp_resp_msg = &qp_resp.msgs[0];