From patchwork Tue Feb 7 23:04:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123387 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 35B3A41C34; Wed, 8 Feb 2023 00:04:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE07B42670; Wed, 8 Feb 2023 00:04:46 +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 7931B40DDB for ; Wed, 8 Feb 2023 00:04:43 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id pj3so16585283pjb.1 for ; Tue, 07 Feb 2023 15:04:43 -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=yqxpGzyhnbg0vLuxvbJa55A/oxbok2U1f3+mHeGfhNc=; b=Byf0F6MSZTcyUrXFrwAsBh48ArMHaX3W+zJCVTDeq+sW2M4coOEU7bPITi7H1fOqdW AfH1jW23A5HZUVp1qwYi1jqypz+KuPbxbngjZKOdsfMlqjeXIeC7jou3t30ibivr2Wfe EG1iWIgaxKd6o0tmN6SCMV4QlCwEjjA6YXk9bNu7X770SIbbeMmFpm1ZGIssJbzbTDct kXwKcvU89eW6NBoHzETrIOmO0fCXk5V5UW1QoAAMZkq3MiaKXK9BWYD5iycoM/6zOr8E CaE4kmjm0XM7leJM+iv9mlLUsD6P4asM0nKcd1XtQUCIsEYTZFoOVETw1Tp14GuWDQMy F/cg== 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=yqxpGzyhnbg0vLuxvbJa55A/oxbok2U1f3+mHeGfhNc=; b=6v/O9hIxQOeRrg1Ejg2rO2ie7HovHAQ7q5bdMGVlMRdyXpcNcflKQeP+izlHEESYnM +cBSdgqAbNhcSPAiBEw334UGFeTv15mrMGyw+igZgNDkynf/1iy9QYQUThTOqe94uxRs 2BeV7eRb/DrJoxx1zwa71+68hlajY1CdtZ/2N+m6J/XQ8c4x/wy8OX5gmqKiptpX4TLw DQDjCwDMr8rtKynxRIb//H6ysRdC+zYJRXjjHHh8e0KDG/n/aOlf/t1ROmupZtjxtTNg Af26u5wH/erzKYU1drU0DcdIPISNYRRS3gtffKSO52ibuMckQyrq/GpR/0c0TRsr8gGk 2kJA== X-Gm-Message-State: AO0yUKVyIucZCZQAyNyC+rLizMZ/2H2NGozikK7UKkZuGd2q8yXrpt9Q qqD2jKTJDAXMNYjKTv5+eRSchftc5r9C4YYaG8w= X-Google-Smtp-Source: AK7set+Zzs4gEVrZ2g0kptqcSbMT8n+TEFJ+h0HzjQG6yDYpAq7co2OF17ct48li2kPIB5XM4ULd9Q== X-Received: by 2002:a05:6a20:ba4:b0:c2:f930:45e8 with SMTP id i36-20020a056a200ba400b000c2f93045e8mr873744pzh.46.1675811082344; Tue, 07 Feb 2023 15:04:42 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:04:41 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC v2 01/17] doc: document intention to deprecate RTE_LOGTYPE_USER* Date: Tue, 7 Feb 2023 15:04:22 -0800 Message-Id: <20230207230438.1617331-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 These static log types should be deprecated in next stable release. Also, remove use of USER1 from example of doing mlockall. Signed-off-by: Stephen Hemminger --- doc/guides/prog_guide/writing_efficient_code.rst | 3 +-- doc/guides/rel_notes/deprecation.rst | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/guides/prog_guide/writing_efficient_code.rst b/doc/guides/prog_guide/writing_efficient_code.rst index e6c26efdd3a3..250e06bd734f 100644 --- a/doc/guides/prog_guide/writing_efficient_code.rst +++ b/doc/guides/prog_guide/writing_efficient_code.rst @@ -89,8 +89,7 @@ To avoid these you could pre-load, and lock them into memory with the ``mlockall .. code-block:: c if (mlockall(MCL_CURRENT | MCL_FUTURE)) { - RTE_LOG(NOTICE, USER1, "mlockall() failed with error \"%s\"\n", - strerror(errno)); + perror("mlockall"); } Communication Between lcores diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index ac9aa7630b61..935e68134d0e 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -136,3 +136,7 @@ Deprecation Notices Its removal has been postponed to let potential users report interest in maintaining it. In the absence of such interest, this library will be removed in DPDK 23.11. + +* rte_log: The pre-defined RTE_LOGTYPE_USER* macros are planned to be + deprecated starting with the 23.07 release. Applications should use the + dynamic log types available with RTE_LOG_REGISTER instead. From patchwork Tue Feb 7 23:04:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123388 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 5B62941C34; Wed, 8 Feb 2023 00:05:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F27C042B71; Wed, 8 Feb 2023 00:04:47 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id 4D43F41153 for ; Wed, 8 Feb 2023 00:04:45 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id o16-20020a17090ad25000b00230759a8c06so368217pjw.2 for ; Tue, 07 Feb 2023 15:04:45 -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=4gV0O0VnYNfSB8tFuKqX/jOKhvrAo4J4DDvDqke1AhM=; b=rbSmu4nVP+Ik2sBf/b8hMXftFzUhYegW2ccn631uR8sTs8ENYQAfUzkGpVLKHc9b0Q tMrIJgSc+Hu/DgNk3jdYcI2Nlx1wcwWDyMGGgSAdToKY/iR0VKZYWz+p/pDHxockVjug 2Z6Uop76oK6aQN9vdyI5Gap37tk8VAptg53OgkrxdMQl/PwBGSs4EH2NRLAgx2D9INQd ejSYD4hdcEK+3y6q7FAtmvUOHvqMwjRbUFiYNpMXuJNomH3b2OLjXYQuOBuB/PIMpJ29 4vccDICtZKQD49GWSNmdr6UDmQtnLZIHVW6eaFYUkuH2SVsZkn6ZePsaipEscgSDSLwo UP0g== 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=4gV0O0VnYNfSB8tFuKqX/jOKhvrAo4J4DDvDqke1AhM=; b=n6WJrUNo6XSI+ZSXK/Sg8gI8bRSWwff3VjIs+5k7e40u4R38YPQ44YdwAGmnmwEpmf yO4mdOp8Os/OhkhUORiM+3VRZ6i2GyDIBHxzY45Jw4kQXZ6cxaAeAERJeEYo141XJ+Z+ xXm422YT6xmhxM/a3BCEewi3aS8l4HM7leC3RjSUiWHGV7zO8n/67o9fwbqwrJ9KxGm2 mCsCvUUdcckwN1nXV3E9jnohlE2OJ74tAV9J6vLTxtsBTdSPqOE0HeWDkRNUzJG04DZf oSPWj+81Pfa7wEjINnVDTRq5crPr4Su2mq+NktNe11vxesyN59yWDaeO8o87XLi86NmW w1ug== X-Gm-Message-State: AO0yUKXCwK8Ucm90EFjku/9e7KieT4arqMUbvhij3yV+NOOJm9F1OpUr eZA1Um7+ZMHZ2ji5GRalNgCrHMSEqtje6JoujBE= X-Google-Smtp-Source: AK7set9Dw0L4mwKONRkZ6Q2hC7lygJnT4R2NRd6Djy6MMzpYGo5a/is1IM3iDIYyI8Ix7bqDU0tYZA== X-Received: by 2002:a17:90b:4a8a:b0:230:66c2:78f1 with SMTP id lp10-20020a17090b4a8a00b0023066c278f1mr6239792pjb.14.1675811083764; Tue, 07 Feb 2023 15:04:43 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:04:43 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev , Thomas Monjalon , Anatoly Burakov Subject: [RFC v2 02/17] ip_frag: use a dynamic logtype Date: Tue, 7 Feb 2023 15:04:23 -0800 Message-Id: <20230207230438.1617331-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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. 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..935878cc6cdc 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 Tue Feb 7 23:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123389 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 3420141C34; Wed, 8 Feb 2023 00:05:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CF1042D0E; Wed, 8 Feb 2023 00:04:49 +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 2ADC341153 for ; Wed, 8 Feb 2023 00:04:46 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id o13so16585678pjg.2 for ; Tue, 07 Feb 2023 15:04: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=KZgfsFOvebHmT9+dLkYUNEfM3BYjfInGf2AA4yLuCd4=; b=jdIPPf16hsQ4qmaE7igDIzFnAzB6o2XOoTV+RnrCWALNwsBJTg060pWLda+kCxDuzn Yk2994636gmCxg/Gl7Ornt24MVx6m1P59EQdoctvEry0Tk48v9vClkVPaogXldhr9aWD Y3rzOn89M2lHBHfKNgYcZcXBo3u1MXes3UvFgzPhKjYyeVDZisDyM5+0ZQ5miXy/Ykcq jBvfV8eiDIBAFUqiFxljf7D9y++EHIV7HEvd/CVJbIFweSBy9Oc0GhoBSAcloCOSGlvJ s3svYrfVMOCDw9kffGEq0udnmfOiHpInFKrE9wHe64xdlah5a1+kYpQtVbakkDtbCrLZ A/AQ== 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=i4czgO3d8j+7gmq1WjKNqqq4IrLB38HL5ZXg8oNmDu7dgkrj/i1q/CfzIh5bQbCrzT dF1Y1/HfJ/4isNhrS1BJx91xb9rJhNyDLJPfHU7lhQIr929BRAheP06F6o8TJA8zBzD7 rtnlJgPMjxBURUZ1dHn47KHNizZMDhkE3awmgtWQoqPOtV4ksOgok5yc1VxBv+4hYyQ+ 0skY/bhNcmYJkocRVnMa8dGAC4qI0eDSAbmO+TO9Nm++4GwhRyxyUg7A5QoV/jOGAVKp PY1HeFL7+KzBLBZuGLNGMNuPmpUxi/Gb2BuSqeY4YonliEWb3KY8KPVJghSklza+ErjE CFDw== X-Gm-Message-State: AO0yUKWYg8aPVhkfQhv5QCW/Wnupv9WFLFQrutBJxJhdecmJDut37MtE 9XCYpkBVrLvkbS4JNlAtmP32/fMr/n/UgwECz4U= X-Google-Smtp-Source: AK7set9f8+kuHHktpfC0G+vwDZ98vPS/2+Y7H4BtRxhRafa+WTm+tT43GbBEg4d1L02Xc1/bIHQvmw== X-Received: by 2002:a17:90b:1bc8:b0:230:c6b8:87c0 with SMTP id oa8-20020a17090b1bc800b00230c6b887c0mr5798843pjb.31.1675811085009; Tue, 07 Feb 2023 15:04:45 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:04:44 -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: [RFC v2 03/17] reorder: use a dynamic logtype Date: Tue, 7 Feb 2023 15:04:24 -0800 Message-Id: <20230207230438.1617331-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Tue Feb 7 23:04:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123390 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 DF8EC41C34; Wed, 8 Feb 2023 00:05:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7AB4442D17; Wed, 8 Feb 2023 00:04:50 +0100 (CET) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 3E382427F2 for ; Wed, 8 Feb 2023 00:04:47 +0100 (CET) Received: by mail-pj1-f44.google.com with SMTP id e10-20020a17090a630a00b0022bedd66e6dso376361pjj.1 for ; Tue, 07 Feb 2023 15:04: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=NvdUuNsyahgHaUTI/xF7yC88g8W9RGQN1t1NkC5FbQU=; b=mCuL52doveGUk0LF+XmN92KommblHLCOcQUxKX2NBH8R+lRCAjydXfXiOkeOdlUu6J rvyiL5cBp89/aO8/jd8moWT/+1ZH6jBOhRViN6IGyeGsJEQvF3ocnV9GpzW0/wIL6opJ nxzmtIGbWRD7zBCo9iq2TcQHM8bqxyGT0ob6L4S+iR1nuQc4rH7kY7PKwBYC05ox0up6 SFVzZth1tSJzLdZl5vAHQ7C9Oq/0NUnQ9C7xV15409jgw91zLhqIIv2FVeozvZiivGVH MJSHFrfNRdJCWWKQ5PVf+WRYPW1Thqrsp1ujWvUs+oO5QJmoZT19Ed02WKQnlj6cnB+J A8YA== 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=NvdUuNsyahgHaUTI/xF7yC88g8W9RGQN1t1NkC5FbQU=; b=uIMbFAVeOMw8anWjzTmjuokXXA0FrCTolse8DAExWcikKIg5SYqNGBP0XKVk9mdbi5 HoG3OdY6AJZVoQ/7lgF/vLmYtU/FwyzXc/HgZBSEsrBGZDlBJ6adjwKQazpKGi3Xkz6v XqJamP4V/GzYjL085w5DC+sS+v3katwJmUzW/qrB27KWP4bAgJsUjG8jSZk9oAkm2rAj YAYNJge0aM7oXgaFILurMuxmnrcORvtxQVdD1rrKmlbwSqhmmhAwp8ITnfaN+71OzMqA /Y2CjqVCbxxFhSmoGCW3Crqsa4QDf45RCy1SQ2Q1tEwJjeewnO0w5UD/GrMCLsx3WKww eedA== X-Gm-Message-State: AO0yUKXWlOTLi5wT819jkLH0g8R0cJkONQQAdFxWStJOUQeA+btdkPNb 5bHBH/CO1H3kjc1TQlsz/izBLgYkkREaiVdHvBU= X-Google-Smtp-Source: AK7set9gtj8sOyGFds0ry0QFfHBwVjtaenaQVHUICGzNIr8Ae3FYz/RaINbV4CN1mfQ3vAqDrxEZag== X-Received: by 2002:a17:90a:2:b0:229:9aac:abb6 with SMTP id 2-20020a17090a000200b002299aacabb6mr5980858pja.47.1675811086150; Tue, 07 Feb 2023 15:04:46 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:04:45 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , reshma.pattan@intel.com, Remy Horton , Harry van Haaren Subject: [RFC v2 04/17] latencystats: use dynamic logtype Date: Tue, 7 Feb 2023 15:04:25 -0800 Message-Id: <20230207230438.1617331-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 loggging. 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 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 Tue Feb 7 23:04:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123391 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 720D041C34; Wed, 8 Feb 2023 00:05:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D443942D29; Wed, 8 Feb 2023 00:05:11 +0100 (CET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 2406E42D29 for ; Wed, 8 Feb 2023 00:05:11 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id w5so7288753plg.8 for ; Tue, 07 Feb 2023 15:05:11 -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=xEjvKrBAUqZeBvyRL0ll8ue+hM/7XowkxMi6ngrjkWo=; b=YCFc74BF/HyjUP3BKVtIehS72NMimPlfPy0qt7hznt9SKoAR2nWcrgAT1EG4SuvSXY +TzZUtFhxdHPWaqgsR90CiyRxNPqDO6k6FT2zpxlLTIQqYYbtujxIAgL0fMYpzetNYNu fWm3ORFHyHif1ulvuL/qSIkMq0qRQVrmbQ/isKuV3VgTb+om1v0IlCzdYuj9XGK6NWlK BISb1oMXdm/rSs/ZFLbP1QQiCsuv4a81RGrJya83us93lQMjtz07WYMBvNhQ5uOCtiOC WHwSsCLeAhEDfnxzSB1pP8S23oVb3R4vsTY1oyzL3QJfbslPjJTdXtX8OwSPN3OUdWHl V2yg== 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=xEjvKrBAUqZeBvyRL0ll8ue+hM/7XowkxMi6ngrjkWo=; b=rARxXTH5vKyDbyfcN2ZKkWhS7KLY97Kwb2gxIEqNBO5zQETbkhuo88GfEec7uyKP49 tSXZWwKd0T8Z1ouBM46ilORZdArySy83N0qdcZN7P3YNQIthfsy+kAw7NGC4jw46nj1g BcWc1mD2o3mduhYGC0vZ1H2kA9ihY9UMISeJNFe24hYyuiPEyrLBf+rgddCz7SepVZe5 nnCg/5DvhN909sTnBcgL6OK6Mg8xIpx9+KYeBLv96TPlGozXwXj0fsaObbRIZ7v9ztyg bj/TZxkng5muTofSDwtV88ddPIpRGgFLFm9Z9vTCabFAlx7boUvgPa9lP6GMOZuud9zz Aj1g== X-Gm-Message-State: AO0yUKU+as+s67pEMwef7JZ59FgNA/+BPyifpXal+DH48zM0fb5usq4J 0WNAmp0czSw0igU09ZAuexFwkoWvebjbnMpRnfI= X-Google-Smtp-Source: AK7set82fPvAeZzfvYjjU079BqEzY8r6N1htQxyDDJzTPONYYcNDga99BrYxctSbwieZusP2OtnGFQ== X-Received: by 2002:a17:90b:1bca:b0:22c:79bf:bee1 with SMTP id oa10-20020a17090b1bca00b0022c79bfbee1mr6186097pjb.10.1675811110104; Tue, 07 Feb 2023 15:05:10 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:09 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , jiayu.hu@intel.com, Konstantin Ananyev , Mark Kavanagh Subject: [RFC v2 05/17] gso: remove logtype Date: Tue, 7 Feb 2023 15:04:26 -0800 Message-Id: <20230207230438.1617331-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 If a large packet is passed into GSO routines of unknown protocol then library would log a message and pass it through. This is incorrect behaviour on many levels: - it allows oversize packet to get passed on to NIC driver - no direct return is visible to applications - if it happens once, many more will follow and log will fill. - bonus it is only log message with GSO type. The fix is to just return -EINVAL which is what this library does in many other places when looking at headers. Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO") Cc: jiayu.hu@intel.com Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 2 +- lib/eal/include/rte_log.h | 1 - lib/gso/rte_gso.c | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index bd7b188ceb4a..c369154cb1ea 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -368,7 +368,7 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, - {RTE_LOGTYPE_GSO, "lib.gso"}, + {RTE_LOGTYPE_USER1, "user1"}, {RTE_LOGTYPE_USER2, "user2"}, {RTE_LOGTYPE_USER3, "user3"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 6d2b0856a565..97d6b26a9967 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -46,7 +46,6 @@ extern "C" { #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ #define RTE_LOGTYPE_EFD 18 /**< Log related to EFD. */ #define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ -#define RTE_LOGTYPE_GSO 20 /**< Log related to GSO. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 24 /**< User-defined log type 1. */ diff --git a/lib/gso/rte_gso.c b/lib/gso/rte_gso.c index 4b59217c16ee..19c351769fcc 100644 --- a/lib/gso/rte_gso.c +++ b/lib/gso/rte_gso.c @@ -81,8 +81,7 @@ rte_gso_segment(struct rte_mbuf *pkt, indirect_pool, pkts_out, nb_pkts_out); } else { /* unsupported packet, skip */ - RTE_LOG(DEBUG, GSO, "Unsupported packet type\n"); - ret = 0; + ret = -EINVAL; } if (ret < 0) { From patchwork Tue Feb 7 23:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123392 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 DEA6841C34; Wed, 8 Feb 2023 00:05:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAF7342D35; Wed, 8 Feb 2023 00:05:12 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 1A86B42D30 for ; Wed, 8 Feb 2023 00:05:12 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id g13so12517074ple.10 for ; Tue, 07 Feb 2023 15:05:12 -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=UPtCDG0D5nzLcLmm+TqbH2Ry/IqpvLKXmxojNPcvGac=; b=XvK1MFtBPbv5Gl8mpN0vFLNitU+UqDh+zUfWR1U1aNrd3S3VwhDbQ6CLorx4h00Ej7 iomujLmjrZyvx3p7EaszicVtO0+TlvYMab4wmUFhQde+CWG7vP6rSeY+RLyV+PrHbrfh JkJUjYz8aJeyCWD03bpp98Bgg/9EEpBT8mQahMoSbxR1CjCMOpVnSWwpJE4wBs2Lk7LX dafv9tVEmbGGcUjbiqzyXi20599jmaC3KdQxD/LR6CA0p44NbNWV0al11OpQatkYFOc9 cfx48fMeyfHViAqH5rPwZokzIb5GR+F8oIoczv9/a7iX51wYD/hLh+8+y8s7lC5GjasI aOeg== 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=UPtCDG0D5nzLcLmm+TqbH2Ry/IqpvLKXmxojNPcvGac=; b=TmaufR/ii0Jx+o9X1mPibzPgjS5MCpgqt9M99mNC5Matyd40FrGCoUrERgIOCQb8Vd o4x4z3ee7cz9/HdaoB2yDdLSpqeD68b/BGf+mLZ3/p5bXiLD7PeI0EeANTiZMzqUs1mB c9UyVMul6i016TztFySe7BI0XAEFq6h4lzXJnkRlmZgYUBbkSnxTT3CuU6fD7bZsmFFc utTEV2okjoWsXyWE67mxfG3N/zgnp87x7Yd3B8cPjBSM5T8QRDelDWOJfYiczEUzPh00 RjI0JhkO5ArT4zPu9Jnucaq8t+NAPtIOxBb6PEy7T8GEGn+wYmB0CHDA9PTNETLiorQk SmdQ== X-Gm-Message-State: AO0yUKUqvKJPl0H592N5jqVLI1BGbFeaKkiJPMUDiT412ipBlSBSGN6I cv84a4Tdp4RXq9TlP9G1j5RaFR2d7pCjlBjlFFM= X-Google-Smtp-Source: AK7set/gBmgPIM1xAIk8mXBm6dY66wQgLiFSf1MXIhkJBBvIIlnA/rhBX4sje/h7Ozekq4MnFYIClg== X-Received: by 2002:a17:90b:4c47:b0:225:e88c:33c2 with SMTP id np7-20020a17090b4c4700b00225e88c33c2mr6072336pjb.7.1675811111065; Tue, 07 Feb 2023 15:05:11 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:10 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC v2 06/17] log: drop unused RTE_LOGTYPE_TIMER Date: Tue, 7 Feb 2023 15:04:27 -0800 Message-Id: <20230207230438.1617331-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 The timer code does not use rte_log. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index c369154cb1ea..e7ccde1c9ccd 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -352,7 +352,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_MALLOC, "lib.malloc"}, {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, - {RTE_LOGTYPE_TIMER, "lib.timer"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 97d6b26a9967..361d1ad96299 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -30,7 +30,7 @@ extern "C" { #define RTE_LOGTYPE_MALLOC 1 /**< Log related to malloc. */ #define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ -#define RTE_LOGTYPE_TIMER 4 /**< Log related to timers. */ + /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ #define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ From patchwork Tue Feb 7 23:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123393 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 D906741C34; Wed, 8 Feb 2023 00:05:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3924F42D3E; Wed, 8 Feb 2023 00:05:15 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 35C7E42D39 for ; Wed, 8 Feb 2023 00:05:13 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id c10-20020a17090a1d0a00b0022e63a94799so372038pjd.2 for ; Tue, 07 Feb 2023 15:05:13 -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=XC9Z/WZcbYJRMRfGGnRbWvLq8XyY7AHTqG0rf0Z88tw=; b=qvwzapTcuZqBaC2c59y5lWyW/p7KpRhoxl1W09jOILgBQMky5PQ+IderW/RGMJz7QN hNH2NQ7XOTb0hdrL1wEAEwjLnKDhv+gZJyAiqwMOUrQNb4UkaD1jn/A6TIcOnvy00LjN rurWW8puYFeeLdkd0rlLbsatTfHDijdtjiEV61EREZjaKLVwLzrj200pHKJ2K+rjSYJ1 Xv8DLvcmkUi5VcfNOm/lwTEdiEzPq67PupAL3NLM9wMrAayLmNR7yyiGRJHkm6HCUwRT NtnpGB3NHuGODWCOo8LgqEBclMKPMde6llI2rBwwsp3f39QHctzuRlACHWoUoj75Q580 iR+A== 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=XC9Z/WZcbYJRMRfGGnRbWvLq8XyY7AHTqG0rf0Z88tw=; b=nG6tJ3eG/kOJ6on3YihM7wvdlQgAOrqI+bpVLDdr+KeioR0AgxIDOnAPe/sOywV0uR c75G05k5s6X/I6BXQakJehBCXnfSY8BYEGTppcfDrbXc1kR5jztcUn0Bp6wY446Z57XV 6Ayqf1xDOqtkkRZZyJfL3P7PHCMf76N31apC2L6v79LNnl4mw++NUQpzmQawDa+E/Ao5 rKHdLQY64OjC5twtqjvxo70/atBj75zZNfBjV4ClgrUo2nkST/17ZtU5qfxsxNyV2i2N RviZRh/39bWwjS46Xl75wuXWHRkvt2DWZE6oiJa81pYkMMRlqFfZeq1J3OHfTHqq50Lx JBzw== X-Gm-Message-State: AO0yUKW2D0ugmHIrN7f/0tBxqtr6pSFfD4BI9xULTXx7kxqgenvAMJPY kJ0EIUdNLRGK2zcRku8lZg4zGcsRdgCCo9SVzdA= X-Google-Smtp-Source: AK7set9dEZ39NxY0Cu+n8kqjXMI4REE3Vnj40fzCcaAH9neG33SV8ZDA3Thf0cksmZrFtT48/AIbew== X-Received: by 2002:a17:90b:1a8c:b0:22c:9078:178 with SMTP id ng12-20020a17090b1a8c00b0022c90780178mr5899977pjb.27.1675811112075; Tue, 07 Feb 2023 15:05:12 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:11 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Byron Marohn , Yipeng Wang Subject: [RFC v2 07/17] efd: replace RTE_LOGTYPE_EFD with local type Date: Tue, 7 Feb 2023 15:04:28 -0800 Message-Id: <20230207230438.1617331-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Replace all uses of global logtype with a local log type. Do not break message formats across source lines. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/efd/rte_efd.c | 106 +++++++++++++++----------------- 3 files changed, 52 insertions(+), 57 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index e7ccde1c9ccd..675f3d07bbe3 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -365,7 +365,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_MBUF, "lib.mbuf"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, - {RTE_LOGTYPE_EFD, "lib.efd"}, {RTE_LOGTYPE_EVENTDEV, "lib.eventdev"}, {RTE_LOGTYPE_USER1, "user1"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 361d1ad96299..a90fa629168d 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -44,7 +44,7 @@ extern "C" { #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ #define RTE_LOGTYPE_MBUF 16 /**< Log related to mbuf. */ #define RTE_LOGTYPE_CRYPTODEV 17 /**< Log related to cryptodev. */ -#define RTE_LOGTYPE_EFD 18 /**< Log related to EFD. */ + /* was RTE_LOGTYPE_EFD */ #define RTE_LOGTYPE_EVENTDEV 19 /**< Log related to eventdev. */ /* these log types can be used in an application */ diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c index 686a13775742..23316ef7300f 100644 --- a/lib/efd/rte_efd.c +++ b/lib/efd/rte_efd.c @@ -87,6 +87,11 @@ static struct rte_tailq_elem rte_efd_tailq = { }; EAL_REGISTER_TAILQ(rte_efd_tailq); +RTE_LOG_REGISTER_DEFAULT(efd_logtype, INFO); + +#define EFD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, efd_logtype, "%s(): " fmt "\n", __func__, ##args) + /** Internal permutation array used to shuffle bins into pseudorandom groups */ const uint32_t efd_bin_to_group[EFD_CHUNK_NUM_BIN_TO_GROUP_SETS][EFD_CHUNK_NUM_BINS] = { { @@ -509,13 +514,12 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list); if (online_cpu_socket_bitmask == 0) { - RTE_LOG(ERR, EFD, "At least one CPU socket must be enabled " - "in the bitmask\n"); + EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask"); return NULL; } if (max_num_rules == 0) { - RTE_LOG(ERR, EFD, "Max num rules must be higher than 0\n"); + EFD_LOG(ERR, "Max num rules must be higher than 0"); return NULL; } @@ -554,7 +558,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, te = rte_zmalloc("EFD_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, EFD, "tailq entry allocation failed\n"); + EFD_LOG(ERR, "tailq entry allocation failed"); goto error_unlock_exit; } @@ -564,15 +568,15 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (table == NULL) { - RTE_LOG(ERR, EFD, "Allocating EFD table management structure" - " on socket %u failed\n", - offline_cpu_socket); + EFD_LOG(ERR, + "Allocating EFD table management structureon socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, "Allocated EFD table management structure " - "on socket %u\n", offline_cpu_socket); + EFD_LOG(DEBUG, "Allocated EFD table management structure on socket %u", + offline_cpu_socket); table->max_num_rules = num_chunks * EFD_TARGET_CHUNK_MAX_NUM_RULES; table->num_rules = 0; @@ -586,17 +590,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (key_array == NULL) { - RTE_LOG(ERR, EFD, "Allocating key array" - " on socket %u failed\n", - offline_cpu_socket); + EFD_LOG(ERR, + "Allocating key array on socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } table->keys = key_array; strlcpy(table->name, name, sizeof(table->name)); - RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks," - " which potentially supports %u entries\n", - num_chunks, table->max_num_rules); + EFD_LOG(DEBUG, + "Creating an EFD table with %u chunks, which potentially supports %u entries", + num_chunks, table->max_num_rules); /* Make sure all the allocatable table pointers are NULL initially */ for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++) @@ -623,19 +627,16 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, socket_id); if (table->chunks[socket_id] == NULL) { - RTE_LOG(ERR, EFD, - "Allocating EFD online table on " - "socket %u failed\n", - socket_id); + EFD_LOG(ERR, + "Allocating EFD online table on socket %u failed", + socket_id); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, - "Allocated EFD online table of size " - "%"PRIu64" bytes (%.2f MB) on socket %u\n", - online_table_size, - (float) online_table_size / - (1024.0F * 1024.0F), - socket_id); + EFD_LOG(DEBUG, + "Allocated EFD online table of size %" PRIu64 " bytes (%.2f MB) on socket %u", + online_table_size, + (float) online_table_size / (1024.0F * 1024.0F), + socket_id); } } @@ -675,16 +676,17 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, RTE_CACHE_LINE_SIZE, offline_cpu_socket); if (table->offline_chunks == NULL) { - RTE_LOG(ERR, EFD, "Allocating EFD offline table on socket %u " - "failed\n", offline_cpu_socket); + EFD_LOG(ERR, + "Allocating EFD offline table on socket %u failed", + offline_cpu_socket); goto error_unlock_exit; } - RTE_LOG(DEBUG, EFD, - "Allocated EFD offline table of size %"PRIu64" bytes " - " (%.2f MB) on socket %u\n", offline_table_size, - (float) offline_table_size / (1024.0F * 1024.0F), - offline_cpu_socket); + EFD_LOG(DEBUG, + "Allocated EFD offline table of size %" PRIu64 " bytes (%.2f MB) on socket %u", + offline_table_size, + (float) offline_table_size / (1024.0F * 1024.0F), + offline_cpu_socket); te->data = (void *) table; TAILQ_INSERT_TAIL(efd_list, te, next); @@ -695,7 +697,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, r = rte_ring_create(ring_name, rte_align32pow2(table->max_num_rules), offline_cpu_socket, 0); if (r == NULL) { - RTE_LOG(ERR, EFD, "memory allocation failed\n"); + EFD_LOG(ERR, "ring memory allocation failed"); rte_efd_free(table); return NULL; } @@ -1015,20 +1017,17 @@ efd_compute_update(struct rte_efd_table * const table, if (found == 0) { /* Key does not exist. Insert the rule into the bin/group */ if (unlikely(current_group->num_rules >= EFD_MAX_GROUP_NUM_RULES)) { - RTE_LOG(ERR, EFD, - "Fatal: No room remaining for insert into " - "chunk %u group %u bin %u\n", - *chunk_id, - current_group_id, *bin_id); + EFD_LOG(ERR, + "Fatal: No room remaining for insert into chunk %u group %u bin %u", + *chunk_id, current_group_id, *bin_id); return RTE_EFD_UPDATE_FAILED; } if (unlikely(current_group->num_rules == (EFD_MAX_GROUP_NUM_RULES - 1))) { - RTE_LOG(INFO, EFD, "Warn: Insert into last " - "available slot in chunk %u " - "group %u bin %u\n", *chunk_id, - current_group_id, *bin_id); + EFD_LOG(NOTICE, + "Insert into last available slot in chunk %u group %u bin %u", + *chunk_id, current_group_id, *bin_id); status = RTE_EFD_UPDATE_WARN_GROUP_FULL; } @@ -1112,14 +1111,11 @@ efd_compute_update(struct rte_efd_table * const table, uint8_t choice = 0; for (;;) { if (current_group != new_group && - new_group->num_rules + bin_size > - EFD_MAX_GROUP_NUM_RULES) { - RTE_LOG(DEBUG, EFD, - "Unable to move_groups to dest group " - "containing %u entries." - "bin_size:%u choice:%02x\n", - new_group->num_rules, bin_size, - choice - 1); + new_group->num_rules + bin_size > EFD_MAX_GROUP_NUM_RULES) { + EFD_LOG(DEBUG, + "Unable to move_groups to dest group containing %u entries. bin_size:%u choice:%02x", + new_group->num_rules, bin_size, + choice - 1); goto next_choice; } move_groups(*bin_id, bin_size, new_group, current_group); @@ -1132,10 +1128,10 @@ efd_compute_update(struct rte_efd_table * const table, if (!ret) return status; - RTE_LOG(DEBUG, EFD, - "Failed to find perfect hash for group " - "containing %u entries. bin_size:%u choice:%02x\n", - new_group->num_rules, bin_size, choice - 1); + EFD_LOG(DEBUG, + "Failed to find perfect hash for group containing %u entries. bin_size:%u choice:%02x", + new_group->num_rules, bin_size, choice - 1); + /* Restore groups modified to their previous state */ revert_groups(current_group, new_group, bin_size); From patchwork Tue Feb 7 23:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123394 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 97C4841C34; Wed, 8 Feb 2023 00:05:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0678E42D52; Wed, 8 Feb 2023 00:05:17 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id BADCD42D3C for ; Wed, 8 Feb 2023 00:05:14 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id b5so17323987plz.5 for ; Tue, 07 Feb 2023 15:05:14 -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=Xo+otsQcPQyq6SKTaE0VhZg1FrQyBLKt/XSOLAASBEF+Ia7neqbarkyRjwuV0d8GpI eN5Umr5DkG7dg93QrBgJGGVtonrG1iFLuyi77odyhCN16wAiyHmGtVTnWoOjpLGWMNeQ nunxP8bsLvX0DjuGaODljrdYmqHZOBAq53MnwHC7nc9hxVELse9vMYx+BMa8YLMSs0w5 aLD0y8D2eBK0aK9E4AnCa3v+JUXLKEMaG/I8uuzUGVCbS59TiQDj1/NitKAc/i83fWlh EFf33avokua9p85zNAKtAPOlusDbTUtZ+fu24gp82UmElwkJYeMMhjKHCA8J+ioI+5dn JMjg== 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=cYIIOxbaMDRqdOWgU9L6XPc/5aJxKn8XLpr9lFlwcwFXoluOkQceBC9J3IfRtrKq0p Oqv59/v6qNKoDM33Bq4r7QkwYI8pCiVqCoPIh5bOfdsZ8VgRMCZHCvRiIO0UTPypc2lu /pVJm5/j9S6JFA8V78cX5oCCClGlYk4OCuvDgt1192a7fR+GclQW3rCoTug6MpdOiH9V dGH5cYEOsjm2kF4CCHBRKfdPEl38rjCo+7L2a6GfNyoo9SHuhNBO6r8rKXRsGDNpop0L Zrngc/4PIuarUvZGeI7sUuP8CEssWrIq4MWYfDmH8ZTW/NXaFyQRu0iiakFv54UHK8s3 Jehg== X-Gm-Message-State: AO0yUKV3KTQQkbQ/DyPAXDadFuh/NCd2bXlq7Cp5UXdMWTfEC4RScgkr ww5H6ov2Q9Yp1rOUuHY2d0MbCU7E7ONCSSKH0DE= X-Google-Smtp-Source: AK7set9FfmZ+f5q/kGoNSGrN+qq5HhsM1kccDdzmVA2aCymnrpUNoGCvYxv7VfXzVFyorRWRxbI6vg== X-Received: by 2002:a17:90b:4f83:b0:230:cfc4:962d with SMTP id qe3-20020a17090b4f8300b00230cfc4962dmr6276694pjb.16.1675811113611; Tue, 07 Feb 2023 15:05:13 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:13 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz Subject: [RFC v2 08/17] mbuf: replace RTE_LOGTYPE_MBUF with dynamic type Date: Tue, 7 Feb 2023 15:04:29 -0800 Message-Id: <20230207230438.1617331-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 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; } From patchwork Tue Feb 7 23:04:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123395 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 9581541C34; Wed, 8 Feb 2023 00:06:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4522F42D59; Wed, 8 Feb 2023 00:05:18 +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 C770F42D40 for ; Wed, 8 Feb 2023 00:05:15 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id j1so10707156pjd.0 for ; Tue, 07 Feb 2023 15:05:15 -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=eVSpNaCMpdSLcdDy2JPj4FQ20idLaspbXmJCNoYTWJU=; b=Doo8k/oxbv0q8kTMmI7hjjr0uRMSxkaF2gaEdUZj0sHnHlAAgTqzykz4xY7bCXnlQ+ C92bKbuewM6jWaDRBbRVBXU3QP/V96F4UqmhQq+u3NirX5D7L1CVkBoybTa2sH3zl5ew rlKhVzvPFjzBKVyJ45lNFxXk1UzukLKmDxFzyxk/Oiko/WlWFRfmUK1WKp3TRnpslzU8 x/4wYL/275dIam7Gg6you0kTCtXC0espwvmfBf0cUGPkYSIWJU9PEfJem4ikxfdsWmB5 pFciQSiq2R7ydc24Q6uIfx3r2fHNVN8JoS+9yLGzi6RH84NJQTThIFO7q28ykgCzsG+D X5/Q== 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=eVSpNaCMpdSLcdDy2JPj4FQ20idLaspbXmJCNoYTWJU=; b=2zd8l+zUfVaekURVpzNTsOGpjNqo6sAhlfDtSl/Z4udl9HgFEQ9b6ieon07rqEpy9l 1H3Wrb9ZkHEAIGTAaRZYUMfVh0SxF4GfEdRExetriG4GzhF0UFOABCf6+cjtFIS6LJtj z3UkS6dBQeUz/xTyOsnMQCsowcaX6/8wja4v/iuiZksM6sYAeumwsn7tZKZCkDokf2Fx b3uFm81mvrMZ+4pU+rHZIOXFk4Ax+gsU/KGfq+w/zW+UCyzeDTDKdPSvzxT1wOOagcsP 7QQDqLTeB+NK6HCxEhzk5H2WpgbsPbL5rJTjffjXySObWfAx5B24LHsmDzFeTw8t7Ncp f9zQ== X-Gm-Message-State: AO0yUKULij7YLvGTbwXtetdESiPj8pdT3MFz+gLf+sI3n1jMN2PaX8/4 3sQtYwtqil57BS9ohdU6/iZfPZ01PTYLE1fFwmI= X-Google-Smtp-Source: AK7set+X0OFqGJsb0/A3+ZOFLF2n4n9VbVWgZyzBwFAdozZLWIRe3VFOPLaxbbhSE7CW1yKFyTRgTw== X-Received: by 2002:a17:90a:1c4:b0:22c:1920:27e5 with SMTP id 4-20020a17090a01c400b0022c192027e5mr417925pjd.41.1675811114616; Tue, 07 Feb 2023 15:05:14 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:14 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Konstantin Ananyev Subject: [RFC v2 09/17] acl: replace LOGTYPE_ACL with dynamic type Date: Tue, 7 Feb 2023 15:04:30 -0800 Message-Id: <20230207230438.1617331-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Get rid of RTE_LOGTYPE_ACL and RTE_LOGTYPE_MALLOC. For ACL library use a dynamic type. The one message using RTE_LOGTYPE_MALLOC should have been under the ACL logtype anyway. The test code should not have been using fixed log type so just change that to stderr. Signed-off-by: Stephen Hemminger --- app/test/test_acl.c | 3 ++- lib/acl/acl_bld.c | 35 +++++++++++++++++---------------- lib/acl/acl_gen.c | 20 ++++++++++--------- lib/acl/acl_log.h | 13 ++++++++++++ lib/acl/rte_acl.c | 14 ++++++++----- lib/acl/tb_mem.c | 8 ++++++-- lib/eal/common/eal_common_log.c | 2 -- lib/eal/include/rte_log.h | 4 ++-- 8 files changed, 61 insertions(+), 38 deletions(-) create mode 100644 lib/acl/acl_log.h diff --git a/app/test/test_acl.c b/app/test/test_acl.c index 623f34682e69..75588978a720 100644 --- a/app/test/test_acl.c +++ b/app/test/test_acl.c @@ -154,7 +154,8 @@ rte_acl_ipv4vlan_add_rules(struct rte_acl_ctx *ctx, for (i = 0; i != num; i++) { rc = acl_ipv4vlan_check_rule(rules + i); if (rc != 0) { - RTE_LOG(ERR, ACL, "%s: rule #%u is invalid\n", + fprintf(stderr, + "%s: rule #%u is invalid\n", __func__, i + 1); return rc; } diff --git a/lib/acl/acl_bld.c b/lib/acl/acl_bld.c index 2816632803bd..143564151e29 100644 --- a/lib/acl/acl_bld.c +++ b/lib/acl/acl_bld.c @@ -5,6 +5,7 @@ #include #include "tb_mem.h" #include "acl.h" +#include "acl_log.h" #define ACL_POOL_ALIGN 8 #define ACL_POOL_ALLOC_MIN 0x800000 @@ -1014,8 +1015,8 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head, break; default: - RTE_LOG(ERR, ACL, - "Error in rule[%u] type - %hhu\n", + ACL_LOG(ERR, + "Error in rule[%u] type - %hhu", rule->f->data.userdata, rule->config->defs[n].type); return NULL; @@ -1371,7 +1372,7 @@ acl_build_tries(struct acl_build_context *context, last = build_one_trie(context, rule_sets, n, context->node_max); if (context->bld_tries[n].trie == NULL) { - RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n); + ACL_LOG(ERR, "Build of %u-th trie failed", n); return -ENOMEM; } @@ -1380,8 +1381,7 @@ acl_build_tries(struct acl_build_context *context, break; if (num_tries == RTE_DIM(context->tries)) { - RTE_LOG(ERR, ACL, - "Exceeded max number of tries: %u\n", + ACL_LOG(ERR, "Exceeded max number of tries: %u", num_tries); return -ENOMEM; } @@ -1406,7 +1406,7 @@ acl_build_tries(struct acl_build_context *context, */ last = build_one_trie(context, rule_sets, n, INT32_MAX); if (context->bld_tries[n].trie == NULL || last != NULL) { - RTE_LOG(ERR, ACL, "Build of %u-th trie failed\n", n); + ACL_LOG(ERR, "Build of %u-th trie failed", n); return -ENOMEM; } @@ -1421,10 +1421,11 @@ acl_build_log(const struct acl_build_context *ctx) { uint32_t n; - RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n" + ACL_LOG(DEBUG, + "Build phase for ACL \"%s\":\n" "node limit for tree split: %u\n" "nodes created: %u\n" - "memory consumed: %zu\n", + "memory consumed: %zu", ctx->acx->name, ctx->node_max, ctx->num_nodes, @@ -1432,7 +1433,7 @@ acl_build_log(const struct acl_build_context *ctx) for (n = 0; n < RTE_DIM(ctx->tries); n++) { if (ctx->tries[n].count != 0) - RTE_LOG(DEBUG, ACL, + ACL_LOG(DEBUG, "trie %u: number of rules: %u, indexes: %u\n", n, ctx->tries[n].count, ctx->tries[n].num_data_indexes); @@ -1523,8 +1524,8 @@ acl_bld(struct acl_build_context *bcx, struct rte_acl_ctx *ctx, /* build phase runs out of memory. */ if (rc != 0) { - RTE_LOG(ERR, ACL, - "ACL context: %s, %s() failed with error code: %d\n", + ACL_LOG(ERR, + "ACL context: %s, %s() failed with error code: %d", bcx->acx->name, __func__, rc); return rc; } @@ -1565,9 +1566,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg) for (i = 0; i != cfg->num_fields; i++) { if (cfg->defs[i].type > RTE_ACL_FIELD_TYPE_BITMASK) { - RTE_LOG(ERR, ACL, - "ACL context: %s, invalid type: %hhu for %u-th field\n", - ctx->name, cfg->defs[i].type, i); + ACL_LOG(ERR, + "ACL context: %s, invalid type: %hhu for %u-th field", + ctx->name, cfg->defs[i].type, i); return -EINVAL; } for (j = 0; @@ -1577,9 +1578,9 @@ acl_check_bld_param(struct rte_acl_ctx *ctx, const struct rte_acl_config *cfg) ; if (j == RTE_DIM(field_sizes)) { - RTE_LOG(ERR, ACL, - "ACL context: %s, invalid size: %hhu for %u-th field\n", - ctx->name, cfg->defs[i].size, i); + ACL_LOG(ERR, + "ACL context: %s, invalid size: %hhu for %u-th field\n", + ctx->name, cfg->defs[i].size, i); return -EINVAL; } } diff --git a/lib/acl/acl_gen.c b/lib/acl/acl_gen.c index e759a2ca1598..84369b103947 100644 --- a/lib/acl/acl_gen.c +++ b/lib/acl/acl_gen.c @@ -4,6 +4,7 @@ #include #include "acl.h" +#include "acl_log.h" #define QRANGE_MIN ((uint8_t)INT8_MIN) @@ -32,18 +33,19 @@ struct rte_acl_indices { static void acl_gen_log_stats(const struct rte_acl_ctx *ctx, - const struct acl_node_counters *counts, - const struct rte_acl_indices *indices, - size_t max_size) + const struct acl_node_counters *counts, + const struct rte_acl_indices *indices, + size_t max_size) { - RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n" + ACL_LOG(DEBUG, + "Gen phase for ACL \"%s\":\n" "runtime memory footprint on socket %d:\n" "single nodes/bytes used: %d/%zu\n" "quad nodes/vectors/bytes used: %d/%d/%zu\n" "DFA nodes/group64/bytes used: %d/%d/%zu\n" "match nodes/bytes used: %d/%zu\n" "total: %zu bytes\n" - "max limit: %zu bytes\n", + "max limit: %zu bytes", ctx->name, ctx->socket_id, counts->single, counts->single * sizeof(uint64_t), counts->quad, counts->quad_vectors, @@ -470,9 +472,9 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie, XMM_SIZE; if (total_size > max_size) { - RTE_LOG(DEBUG, ACL, + ACL_LOG(DEBUG, "Gen phase for ACL ctx \"%s\" exceeds max_size limit, " - "bytes required: %zu, allowed: %zu\n", + "bytes required: %zu, allowed: %zu", ctx->name, total_size, max_size); return -ERANGE; } @@ -480,8 +482,8 @@ rte_acl_gen(struct rte_acl_ctx *ctx, struct rte_acl_trie *trie, mem = rte_zmalloc_socket(ctx->name, total_size, RTE_CACHE_LINE_SIZE, ctx->socket_id); if (mem == NULL) { - RTE_LOG(ERR, ACL, - "allocation of %zu bytes on socket %d for %s failed\n", + ACL_LOG(ERR, + "allocation of %zu bytes on socket %d for %s failed", total_size, ctx->socket_id, ctx->name); return -ENOMEM; } diff --git a/lib/acl/acl_log.h b/lib/acl/acl_log.h new file mode 100644 index 000000000000..4d5adf965cd2 --- /dev/null +++ b/lib/acl/acl_log.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + */ + +#ifndef _ACL_LOG_H_ +#define _ACL_LOG_H_ + +extern int acl_logtype; +#define ACL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, acl_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + +#endif /* _ACL_LOG_H_ */ diff --git a/lib/acl/rte_acl.c b/lib/acl/rte_acl.c index a61c3ba188da..5c8a9cd2f693 100644 --- a/lib/acl/rte_acl.c +++ b/lib/acl/rte_acl.c @@ -6,8 +6,10 @@ #include #include #include +#include #include "acl.h" +#include "acl_log.h" TAILQ_HEAD(rte_acl_list, rte_tailq_entry); @@ -400,15 +402,15 @@ rte_acl_create(const struct rte_acl_param *param) te = rte_zmalloc("ACL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, ACL, "Cannot allocate tailq entry!\n"); + ACL_LOG(ERR, "Cannot allocate tailq entry!"); goto exit; } ctx = rte_zmalloc_socket(name, sz, RTE_CACHE_LINE_SIZE, param->socket_id); if (ctx == NULL) { - RTE_LOG(ERR, ACL, - "allocation of %zu bytes on socket %d for %s failed\n", + ACL_LOG(ERR, + "allocation of %zu bytes on socket %d for %s failed", sz, param->socket_id, name); rte_free(te); goto exit; @@ -474,8 +476,8 @@ rte_acl_add_rules(struct rte_acl_ctx *ctx, const struct rte_acl_rule *rules, ((uintptr_t)rules + i * ctx->rule_sz); rc = acl_check_rule(&rv->data); if (rc != 0) { - RTE_LOG(ERR, ACL, "%s(%s): rule #%u is invalid\n", - __func__, ctx->name, i + 1); + ACL_LOG(ERR, "%s: rule #%u is invalid", + ctx->name, i + 1); return rc; } } @@ -544,3 +546,5 @@ rte_acl_list_dump(void) } rte_mcfg_tailq_read_unlock(); } + +RTE_LOG_REGISTER_DEFAULT(acl_logtype, INFO); diff --git a/lib/acl/tb_mem.c b/lib/acl/tb_mem.c index f14d7b4fa26e..74a12159b868 100644 --- a/lib/acl/tb_mem.c +++ b/lib/acl/tb_mem.c @@ -3,6 +3,9 @@ */ #include "tb_mem.h" +#include "acl_log.h" + +#include /* * Memory management routines for temporary memory. @@ -25,8 +28,9 @@ tb_pool(struct tb_mem_pool *pool, size_t sz) size = sz + pool->alignment - 1; block = calloc(1, size + sizeof(*pool->block)); if (block == NULL) { - RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated " - "by pool: %zu bytes\n", __func__, sz, pool->alloc); + ACL_LOG(ERR, + "allocation size %zu failed, currently allocated by pool: %zu bytes\n", + sz, pool->alloc); siglongjmp(pool->fail, -ENOMEM); return NULL; } diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 128bfabd94e1..871f2c38298c 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,14 +349,12 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_MALLOC, "lib.malloc"}, {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, {RTE_LOGTYPE_KNI, "lib.kni"}, - {RTE_LOGTYPE_ACL, "lib.acl"}, {RTE_LOGTYPE_POWER, "lib.power"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 1f259b2abc5a..d707098b6359 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -27,7 +27,7 @@ extern "C" { /* SDK log type */ #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ -#define RTE_LOGTYPE_MALLOC 1 /**< Log related to malloc. */ + /* was RTE_LOGTYPE_MALLOC */ #define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ /* was RTE_LOGTYPE_TIMER */ @@ -35,7 +35,7 @@ extern "C" { #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ #define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ #define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ -#define RTE_LOGTYPE_ACL 9 /**< Log related to ACL. */ + /* was RTE_LOGTYPE_ACL */ #define RTE_LOGTYPE_POWER 10 /**< Log related to power. */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ #define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ From patchwork Tue Feb 7 23:04:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123397 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 9494741C34; Wed, 8 Feb 2023 00:06:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95AAF42D65; Wed, 8 Feb 2023 00:05:21 +0100 (CET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 8D8E442D42 for ; Wed, 8 Feb 2023 00:05:17 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id w5so7288993plg.8 for ; Tue, 07 Feb 2023 15:05:17 -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=BJdOPNceKl+2k+D4hFkNoufubnVwgSL275lDH7ilqvw=; b=srcK2/bTJ22UcdZFJN+sZKgYb+BwpYzkKpf2OLA6FBx5OknJcnnp43BrPNkNsVLirG vjt/IssnQfwvJ+bhtxRzZJBUCy53Bv+etQhOU74PW/KVGUWQUSjzVe6o269G22PKmnC4 ORkv+I1JfRm2x3kbt5NPuiqhmAdNUBDyEMFErlJcyPq5fSdwNzUxno7ywIYD2elPxXCR AnK9twhksVNxNa0wUTW2PKNILyR7gLWjZjNoQNcthWuR7fKbctp0hcPw5CALORui7wTW TYKvbgdb+1Sgb8Xh0xjTLo3Yu77bpDIdMAwhTQQ5Mak206ui6XIRgaqlT8/UeUpTTVOD j+0g== 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=BJdOPNceKl+2k+D4hFkNoufubnVwgSL275lDH7ilqvw=; b=zLRaIS8E+O47YXOrk7qAuMhJd/vtFZ3ruMHyPFSx6HWR4QWVJwX4xc0jkc1nHDcxrV R7Fvlbm9gfRqdP5drwlaUQS07fXUT8O1/25JkRJBf+u8tGiUDdqSzKFIGf+qb9bSvS0H 2fDAkWFhc09Qb7fRLhrCDOAOT7A62n4ebDq13+VjmiT+Qh86gWxonT6IqNnilbeqilB2 Z7c05hFBJN+b3F/VSQ++oS/veDi9e89Q9Lx4ypameMOu4zzstjdX/cz5aOnsRp7+O0zy gdgv3CmiDPGnuOx5DPrw+mHO3PKUA0YM/JXnosF8NI15XlgJ9SPNWr0VIMEFxCVDruRr rZjA== X-Gm-Message-State: AO0yUKWXcX40xblZZqWwbKzcJWChuQxlPXaxD8amfzSP6oJN08+b+33w IiYGZ+A6m0UtdLRrgPZyxGhzAOdXR2oWVV7VTwE= X-Google-Smtp-Source: AK7set8Vb4B3EAtguOlHm4BdxsZJmorzkOUz3nNFVzasX1CcgToQ/vsrx6TfaCuCZaS6+pSYG1Sg5Q== X-Received: by 2002:a17:90b:1c02:b0:230:58bc:abf2 with SMTP id oc2-20020a17090b1c0200b0023058bcabf2mr6114984pjb.0.1675811115735; Tue, 07 Feb 2023 15:05:15 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:15 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , David Hunt Subject: [RFC v2 10/17] power: replace RTE_LOGTYPE_POWER with dynamic type Date: Tue, 7 Feb 2023 15:04:31 -0800 Message-Id: <20230207230438.1617331-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Use dynamic log type for power library. Also replace use of RTE_LOGTYPE_USER1 with lib.power.guest. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/power/guest_channel.c | 48 +++++---- lib/power/power_acpi_cpufreq.c | 118 ++++++++++---------- lib/power/power_common.c | 11 +- lib/power/power_common.h | 7 +- lib/power/power_cppc_cpufreq.c | 129 +++++++++++----------- lib/power/power_kvm_vm.c | 24 +++-- lib/power/power_pstate_cpufreq.c | 166 ++++++++++++++++------------- lib/power/rte_power.c | 25 +++-- lib/power/rte_power_empty_poll.c | 36 +++---- lib/power/rte_power_intel_uncore.c | 75 ++++++------- lib/power/rte_power_pmd_mgmt.c | 37 ++++--- 13 files changed, 365 insertions(+), 314 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 871f2c38298c..7dbf1df3b979 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -355,7 +355,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, {RTE_LOGTYPE_KNI, "lib.kni"}, - {RTE_LOGTYPE_POWER, "lib.power"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index d707098b6359..5b7850af4e2b 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -36,7 +36,7 @@ extern "C" { #define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ #define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ /* was RTE_LOGTYPE_ACL */ -#define RTE_LOGTYPE_POWER 10 /**< Log related to power. */ + /* was RTE_LOGTYPE_POWER */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ #define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ #define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ diff --git a/lib/power/guest_channel.c b/lib/power/guest_channel.c index 969a9e5aaa06..0e836fc3f578 100644 --- a/lib/power/guest_channel.c +++ b/lib/power/guest_channel.c @@ -17,7 +17,11 @@ #include "guest_channel.h" -#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 +RTE_LOG_REGISTER_SUFFIX(guest_channel_logtype, "power.guest", INFO); + +#define GUEST_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, guest_channel_logtype, \ + "%s(): " fmt "\n", __func__, ## args) /* Timeout for incoming message in milliseconds. */ #define TIMEOUT 10 @@ -58,38 +62,38 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id) int fd = -1; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } /* check if path is already open */ if (global_fds[lcore_id] != -1) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is already open with fd %d\n", + GUEST_LOG(ERR, "Channel(%u) is already open with fd %d", lcore_id, global_fds[lcore_id]); return -1; } snprintf(fd_path, PATH_MAX, "%s.%u", path, lcore_id); - RTE_LOG(INFO, GUEST_CHANNEL, "Opening channel '%s' for lcore %u\n", + GUEST_LOG(INFO, "Opening channel '%s' for lcore %u", fd_path, lcore_id); fd = open(fd_path, O_RDWR); if (fd < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Unable to to connect to '%s' with error " - "%s\n", fd_path, strerror(errno)); + GUEST_LOG(ERR, "Unable to connect to '%s' with error %s", + fd_path, strerror(errno)); return -1; } flags = fcntl(fd, F_GETFL, 0); if (flags < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Failed on fcntl get flags for file %s\n", + GUEST_LOG(ERR, "Failed on fcntl get flags for file %s", fd_path); goto error; } flags |= O_NONBLOCK; if (fcntl(fd, F_SETFL, flags) < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Failed on setting non-blocking mode for " - "file %s", fd_path); + GUEST_LOG(ERR, "Failed on setting non-blocking mode for file %s", + fd_path); goto error; } /* QEMU needs a delay after connection */ @@ -102,13 +106,13 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id) global_fds[lcore_id] = fd; ret = guest_channel_send_msg(&pkt, lcore_id); if (ret != 0) { - RTE_LOG(ERR, GUEST_CHANNEL, - "Error on channel '%s' communications test: %s\n", - fd_path, ret > 0 ? strerror(ret) : - "channel not connected"); + GUEST_LOG(ERR, + "Error on channel '%s' communications test: %s", + fd_path, ret > 0 ? strerror(ret) : + "channel not connected"); goto error; } - RTE_LOG(INFO, GUEST_CHANNEL, "Channel '%s' is now connected\n", fd_path); + GUEST_LOG(INFO, "Channel '%s' is now connected", fd_path); return 0; error: close(fd); @@ -124,13 +128,13 @@ guest_channel_send_msg(struct rte_power_channel_packet *pkt, void *buffer = pkt; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } if (global_fds[lcore_id] < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n"); + GUEST_LOG(ERR, "Channel is not connected"); return -1; } while (buffer_len > 0) { @@ -165,13 +169,13 @@ int power_guest_channel_read_msg(void *pkt, return -1; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } if (global_fds[lcore_id] < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n"); + GUEST_LOG(ERR, "Channel is not connected"); return -1; } @@ -180,10 +184,10 @@ int power_guest_channel_read_msg(void *pkt, ret = poll(&fds, 1, TIMEOUT); if (ret == 0) { - RTE_LOG(DEBUG, GUEST_CHANNEL, "Timeout occurred during poll function.\n"); + GUEST_LOG(DEBUG, "Timeout occurred during poll function."); return -1; } else if (ret < 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Error occurred during poll function: %s\n", + GUEST_LOG(ERR, "Error occurred during poll function: %s", strerror(errno)); return -1; } @@ -199,7 +203,7 @@ int power_guest_channel_read_msg(void *pkt, } if (ret == 0) { - RTE_LOG(ERR, GUEST_CHANNEL, "Expected more data, but connection has been closed.\n"); + GUEST_LOG(ERR, "Expected more data, but connection has been closed."); return -1; } pkt = (char *)pkt + ret; @@ -220,7 +224,7 @@ void guest_channel_host_disconnect(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 0...%d\n", + GUEST_LOG(ERR, "Channel(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return; } diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c index 6e57aca53513..3643044d9ef0 100644 --- a/lib/power/power_acpi_cpufreq.c +++ b/lib/power/power_acpi_cpufreq.c @@ -62,8 +62,9 @@ static int set_freq_internal(struct acpi_power_info *pi, uint32_t idx) { if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Invalid frequency index %u, which " - "should be less than %u\n", idx, pi->nb_freqs); + POWER_LOG(ERR, + "Invalid frequency index %u, which should be less than %u", + idx, pi->nb_freqs); return -1; } @@ -74,13 +75,15 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx) POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n", idx, pi->freqs[idx], pi->lcore_id); if (fseek(pi->f, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } fflush(pi->f); @@ -126,14 +129,14 @@ power_get_available_freqs(struct acpi_power_info *pi) open_core_sysfs_file(&f, "r", POWER_SYSFILE_AVAIL_FREQ, pi->lcore_id); if (f == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_AVAIL_FREQ); goto out; } ret = read_core_sysfs_s(f, buf, sizeof(buf)); if ((ret) < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_AVAIL_FREQ); goto out; } @@ -142,12 +145,13 @@ power_get_available_freqs(struct acpi_power_info *pi) count = rte_strsplit(buf, sizeof(buf), freqs, RTE_MAX_LCORE_FREQS, ' '); if (count <= 0) { - RTE_LOG(ERR, POWER, "No available frequency in " - ""POWER_SYSFILE_AVAIL_FREQ"\n", pi->lcore_id); + POWER_LOG(ERR, + "No available frequency in " POWER_SYSFILE_AVAIL_FREQ, + pi->lcore_id); goto out; } if (count >= RTE_MAX_LCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n", + POWER_LOG(ERR, "Too many available frequencies : %d", count); goto out; } @@ -195,14 +199,14 @@ power_init_for_setting_freq(struct acpi_power_info *pi) open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id); if (f == NULL) { - RTE_LOG(ERR, POWER, "Failed to open %s\n", + POWER_LOG(ERR, "Failed to open %s", POWER_SYSFILE_SETSPEED); goto err; } ret = read_core_sysfs_s(f, buf, sizeof(buf)); if ((ret) < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SETSPEED); goto err; } @@ -236,7 +240,7 @@ power_acpi_cpufreq_init(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -252,42 +256,47 @@ power_acpi_cpufreq_init(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "in use\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is in use", lcore_id); return -1; } pi->lcore_id = lcore_id; /* Check and set the governor */ if (power_set_governor_userspace(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to " - "userspace\n", lcore_id); + POWER_LOG(ERR, + "Cannot set governor of lcore %u to userspace", + lcore_id); goto fail; } /* Get the available frequencies */ if (power_get_available_freqs(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get available frequencies of " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get available frequencies of lcore %u", + lcore_id); goto fail; } /* Init for setting lcore frequency */ if (power_init_for_setting_freq(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot init for setting frequency for " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot init for setting frequency for lcore %u", + lcore_id); goto fail; } /* Set freq to max by default */ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u " - "to max\n", lcore_id); + POWER_LOG(ERR, + "Cannot set frequency of lcore %u to max", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u " - "power management\n", lcore_id); + POWER_LOG(INFO, + "Initialized successfully for lcore %u power management", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -309,7 +318,7 @@ power_acpi_cpufreq_exit(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -324,8 +333,8 @@ power_acpi_cpufreq_exit(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "not used\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is not used", lcore_id); return -1; } @@ -335,14 +344,15 @@ power_acpi_cpufreq_exit(unsigned int lcore_id) /* Set the governor back to the original */ if (power_set_governor_original(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set the governor of %u back " - "to the original\n", lcore_id); + POWER_LOG(ERR, + "Cannot set the governor of %u back to the original", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from " - "'userspace' mode and been set back to the " - "original\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u has exited from 'userspace' mode and been set back to the original", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -363,18 +373,18 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return 0; } if (freqs == NULL) { - RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + POWER_LOG(ERR, "NULL buffer supplied"); return 0; } pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Buffer size is not enough\n"); + POWER_LOG(ERR, "Buffer size is not enough"); return 0; } rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t)); @@ -386,7 +396,7 @@ uint32_t power_acpi_cpufreq_get_freq(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return RTE_POWER_INVALID_FREQ_INDEX; } @@ -397,7 +407,7 @@ int power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -410,7 +420,7 @@ power_acpi_cpufreq_freq_down(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -428,7 +438,7 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -445,7 +455,7 @@ int power_acpi_cpufreq_freq_max(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -469,7 +479,7 @@ power_acpi_cpufreq_freq_min(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -486,7 +496,7 @@ power_acpi_turbo_status(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -502,7 +512,7 @@ power_acpi_enable_turbo(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -512,16 +522,16 @@ power_acpi_enable_turbo(unsigned int lcore_id) pi->turbo_enable = 1; else { pi->turbo_enable = 0; - RTE_LOG(ERR, POWER, - "Failed to enable turbo on lcore %u\n", + POWER_LOG(ERR, + "Failed to enable turbo on lcore %u", lcore_id); return -1; } /* Max may have changed, so call to max function */ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -535,7 +545,7 @@ power_acpi_disable_turbo(unsigned int lcore_id) struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -546,8 +556,8 @@ power_acpi_disable_turbo(unsigned int lcore_id) if ((pi->turbo_available) && (pi->curr_idx <= 1)) { /* Try to set freq to max by default coming out of turbo */ if (power_acpi_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -562,11 +572,11 @@ int power_acpi_get_capabilities(unsigned int lcore_id, struct acpi_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } if (caps == NULL) { - RTE_LOG(ERR, POWER, "Invalid argument\n"); + POWER_LOG(ERR, "Invalid argument"); return -1; } diff --git a/lib/power/power_common.c b/lib/power/power_common.c index 1e09facb863f..3a374f6b8431 100644 --- a/lib/power/power_common.c +++ b/lib/power/power_common.c @@ -161,14 +161,14 @@ power_set_governor(unsigned int lcore_id, const char *new_governor, open_core_sysfs_file(&f_governor, "rw+", POWER_SYSFILE_GOVERNOR, lcore_id); if (f_governor == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_GOVERNOR); goto out; } ret = read_core_sysfs_s(f_governor, buf, sizeof(buf)); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_GOVERNOR); goto out; } @@ -188,14 +188,15 @@ power_set_governor(unsigned int lcore_id, const char *new_governor, /* Write the new governor */ ret = write_core_sysfs_s(f_governor, new_governor); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to write %s\n", + POWER_LOG(ERR, "Failed to write %s", POWER_SYSFILE_GOVERNOR); goto out; } ret = 0; - RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been " - "set to '%s' successfully\n", lcore_id, new_governor); + POWER_LOG(INFO, + "Power management governor of lcore %u has been set to '%s' successfully", + lcore_id, new_governor); out: if (f_governor != NULL) fclose(f_governor); diff --git a/lib/power/power_common.h b/lib/power/power_common.h index c1c713927621..8e5309bbbaff 100644 --- a/lib/power/power_common.h +++ b/lib/power/power_common.h @@ -10,10 +10,15 @@ #define RTE_POWER_INVALID_FREQ_INDEX (~0) +extern int power_logtype; + +#define POWER_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, power_logtype, \ + "%s(): " fmt "\n", __func__, ## args) #ifdef RTE_LIBRTE_POWER_DEBUG #define POWER_DEBUG_TRACE(fmt, args...) \ - RTE_LOG(ERR, POWER, "%s: " fmt, __func__, ## args) + POWER_LOG(ERR, fmt, ## args) #else #define POWER_DEBUG_TRACE(fmt, args...) #endif diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c index fc9cffef91a8..7ffda90ce7a7 100644 --- a/lib/power/power_cppc_cpufreq.c +++ b/lib/power/power_cppc_cpufreq.c @@ -72,8 +72,9 @@ static int set_freq_internal(struct cppc_power_info *pi, uint32_t idx) { if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Invalid frequency index %u, which " - "should be less than %u\n", idx, pi->nb_freqs); + POWER_LOG(ERR, + "Invalid frequency index %u, which should be less than %u", + idx, pi->nb_freqs); return -1; } @@ -84,13 +85,15 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx) POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n", idx, pi->freqs[idx], pi->lcore_id); if (fseek(pi->f, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } fflush(pi->f); @@ -121,7 +124,7 @@ power_check_turbo(struct cppc_power_info *pi) open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_HIGHEST_PERF, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_HIGHEST_PERF); goto err; } @@ -129,7 +132,7 @@ power_check_turbo(struct cppc_power_info *pi) open_core_sysfs_file(&f_nom, "r", POWER_SYSFILE_NOMINAL_PERF, pi->lcore_id); if (f_nom == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_NOMINAL_PERF); goto err; } @@ -137,28 +140,28 @@ power_check_turbo(struct cppc_power_info *pi) open_core_sysfs_file(&f_cmax, "r", POWER_SYSFILE_SYS_MAX, pi->lcore_id); if (f_cmax == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SYS_MAX); goto err; } ret = read_core_sysfs_u32(f_max, &highest_perf); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_HIGHEST_PERF); goto err; } ret = read_core_sysfs_u32(f_nom, &nominal_perf); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_NOMINAL_PERF); goto err; } ret = read_core_sysfs_u32(f_cmax, &cpuinfo_max_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SYS_MAX); goto err; } @@ -208,7 +211,7 @@ power_get_available_freqs(struct cppc_power_info *pi) open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_SCALING_MAX_FREQ, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SCALING_MAX_FREQ); goto out; } @@ -216,21 +219,21 @@ power_get_available_freqs(struct cppc_power_info *pi) open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_SCALING_MIN_FREQ, pi->lcore_id); if (f_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SCALING_MIN_FREQ); goto out; } ret = read_core_sysfs_u32(f_max, &scaling_max_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SCALING_MAX_FREQ); goto out; } ret = read_core_sysfs_u32(f_min, &scaling_min_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SCALING_MIN_FREQ); goto out; } @@ -248,7 +251,7 @@ power_get_available_freqs(struct cppc_power_info *pi) num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 + pi->turbo_available; if (num_freqs >= RTE_MAX_LCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n", + POWER_LOG(ERR, "Too many available frequencies: %d", num_freqs); goto out; } @@ -289,14 +292,14 @@ power_init_for_setting_freq(struct cppc_power_info *pi) open_core_sysfs_file(&f, "rw+", POWER_SYSFILE_SETSPEED, pi->lcore_id); if (f == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_SETSPEED); goto err; } ret = read_core_sysfs_s(f, buf, sizeof(buf)); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_SETSPEED); goto err; } @@ -340,7 +343,7 @@ power_cppc_cpufreq_init(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -356,42 +359,46 @@ power_cppc_cpufreq_init(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "in use\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is in use", lcore_id); return -1; } pi->lcore_id = lcore_id; /* Check and set the governor */ if (power_set_governor_userspace(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to " - "userspace\n", lcore_id); + POWER_LOG(ERR, "Cannot set governor of lcore %u to userspace", + lcore_id); goto fail; } /* Get the available frequencies */ if (power_get_available_freqs(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get available frequencies of " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get available frequencies of lcore %u", + lcore_id); goto fail; } /* Init for setting lcore frequency */ if (power_init_for_setting_freq(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot init for setting frequency for " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot init for setting frequency for lcore %u", + lcore_id); goto fail; } /* Set freq to max by default */ if (power_cppc_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u " - "to max\n", lcore_id); + POWER_LOG(ERR, + "Cannot set frequency of lcore %u to max", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u " - "power management\n", lcore_id); + POWER_LOG(INFO, + "Initialized successfully for lcore %u power management", + lcore_id); __atomic_store_n(&(pi->state), POWER_USED, __ATOMIC_RELEASE); @@ -419,7 +426,7 @@ power_cppc_cpufreq_exit(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -434,8 +441,9 @@ power_cppc_cpufreq_exit(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "not used\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is not used", + lcore_id); return -1; } @@ -445,14 +453,15 @@ power_cppc_cpufreq_exit(unsigned int lcore_id) /* Set the governor back to the original */ if (power_set_governor_original(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set the governor of %u back " - "to the original\n", lcore_id); + POWER_LOG(ERR, + "Cannot set the governor of %u back to the original", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from " - "'userspace' mode and been set back to the " - "original\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u has exited from 'userspace' mode and been set back to the original", + lcore_id); __atomic_store_n(&(pi->state), POWER_IDLE, __ATOMIC_RELEASE); return 0; @@ -469,18 +478,18 @@ power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return 0; } if (freqs == NULL) { - RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + POWER_LOG(ERR, "NULL buffer supplied"); return 0; } pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Buffer size is not enough\n"); + POWER_LOG(ERR, "Buffer size is not enough"); return 0; } rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t)); @@ -492,7 +501,7 @@ uint32_t power_cppc_cpufreq_get_freq(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return RTE_POWER_INVALID_FREQ_INDEX; } @@ -503,7 +512,7 @@ int power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -516,7 +525,7 @@ power_cppc_cpufreq_freq_down(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -534,7 +543,7 @@ power_cppc_cpufreq_freq_up(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -551,7 +560,7 @@ int power_cppc_cpufreq_freq_max(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -575,7 +584,7 @@ power_cppc_cpufreq_freq_min(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -591,7 +600,7 @@ power_cppc_turbo_status(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -606,7 +615,7 @@ power_cppc_enable_turbo(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -616,8 +625,8 @@ power_cppc_enable_turbo(unsigned int lcore_id) pi->turbo_enable = 1; else { pi->turbo_enable = 0; - RTE_LOG(ERR, POWER, - "Failed to enable turbo on lcore %u\n", + POWER_LOG(ERR, + "Failed to enable turbo on lcore %u", lcore_id); return -1; } @@ -627,8 +636,8 @@ power_cppc_enable_turbo(unsigned int lcore_id) */ /* Max may have changed, so call to max function */ if (power_cppc_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -642,7 +651,7 @@ power_cppc_disable_turbo(unsigned int lcore_id) struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -653,8 +662,8 @@ power_cppc_disable_turbo(unsigned int lcore_id) if ((pi->turbo_available) && (pi->curr_idx <= 1)) { /* Try to set freq to max by default coming out of turbo */ if (power_cppc_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -670,11 +679,11 @@ power_cppc_get_capabilities(unsigned int lcore_id, struct cppc_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } if (caps == NULL) { - RTE_LOG(ERR, POWER, "Invalid argument\n"); + POWER_LOG(ERR, "Invalid argument"); return -1; } diff --git a/lib/power/power_kvm_vm.c b/lib/power/power_kvm_vm.c index 6a8109d44959..74a1094ffaa0 100644 --- a/lib/power/power_kvm_vm.c +++ b/lib/power/power_kvm_vm.c @@ -8,6 +8,7 @@ #include "rte_power_guest_channel.h" #include "guest_channel.h" +#include "power_common.h" #include "power_kvm_vm.h" #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent" @@ -24,7 +25,7 @@ int power_kvm_vm_init(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n", + POWER_LOG(ERR, "Core(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } @@ -45,16 +46,16 @@ power_kvm_vm_freqs(__rte_unused unsigned int lcore_id, __rte_unused uint32_t *freqs, __rte_unused uint32_t num) { - RTE_LOG(ERR, POWER, "rte_power_freqs is not implemented " - "for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "not implemented for Virtual Machine Power Management"); return -ENOTSUP; } uint32_t power_kvm_vm_get_freq(__rte_unused unsigned int lcore_id) { - RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented " - "for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "not implemented for Virtual Machine Power Management"); return -ENOTSUP; } @@ -62,8 +63,8 @@ int power_kvm_vm_set_freq(__rte_unused unsigned int lcore_id, __rte_unused uint32_t index) { - RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented " - "for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "not implemented for Virtual Machine Power Management"); return -ENOTSUP; } @@ -73,7 +74,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction) int ret; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n", + POWER_LOG(ERR, "Core(%u) is out of range 0...%d", lcore_id, RTE_MAX_LCORE-1); return -1; } @@ -81,7 +82,7 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction) ret = guest_channel_send_msg(&pkt[lcore_id], lcore_id); if (ret == 0) return 1; - RTE_LOG(DEBUG, POWER, "Error sending message: %s\n", + POWER_LOG(DEBUG, "Error sending message: %s", ret > 0 ? strerror(ret) : "channel not connected"); return -1; } @@ -113,7 +114,7 @@ power_kvm_vm_freq_min(unsigned int lcore_id) int power_kvm_vm_turbo_status(__rte_unused unsigned int lcore_id) { - RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for Virtual Machine Power Management\n"); + POWER_LOG(ERR, "rte_power_turbo_status is not implemented for Virtual Machine Power Management"); return -ENOTSUP; } @@ -133,6 +134,7 @@ struct rte_power_core_capabilities; int power_kvm_vm_get_capabilities(__rte_unused unsigned int lcore_id, __rte_unused struct rte_power_core_capabilities *caps) { - RTE_LOG(ERR, POWER, "rte_power_get_capabilities is not implemented for Virtual Machine Power Management\n"); + POWER_LOG(ERR, + "rte_power_get_capabilities is not implemented for Virtual Machine Power Management"); return -ENOTSUP; } diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 52aa64510e21..c6869bbd3c59 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -81,7 +81,7 @@ power_read_turbo_pct(uint64_t *outVal) fd = open(POWER_SYSFILE_TURBO_PCT, O_RDONLY); if (fd < 0) { - RTE_LOG(ERR, POWER, "Error opening '%s': %s\n", POWER_SYSFILE_TURBO_PCT, + POWER_LOG(ERR, "Error opening '%s': %s", POWER_SYSFILE_TURBO_PCT, strerror(errno)); return fd; } @@ -89,7 +89,7 @@ power_read_turbo_pct(uint64_t *outVal) ret = read(fd, val, sizeof(val)); if (ret < 0) { - RTE_LOG(ERR, POWER, "Error reading '%s': %s\n", POWER_SYSFILE_TURBO_PCT, + POWER_LOG(ERR, "Error reading '%s': %s", POWER_SYSFILE_TURBO_PCT, strerror(errno)); goto out; } @@ -97,7 +97,7 @@ power_read_turbo_pct(uint64_t *outVal) errno = 0; *outVal = (uint64_t) strtol(val, &endptr, 10); if (errno != 0 || (*endptr != 0 && *endptr != '\n')) { - RTE_LOG(ERR, POWER, "Error converting str to digits, read from %s: %s\n", + POWER_LOG(ERR, "Error converting str to digits, read from %s: %s", POWER_SYSFILE_TURBO_PCT, strerror(errno)); ret = -1; goto out; @@ -125,7 +125,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_base_max, "r", POWER_SYSFILE_BASE_MAX_FREQ, pi->lcore_id); if (f_base_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MAX_FREQ); goto err; } @@ -133,7 +133,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_base_min, "r", POWER_SYSFILE_BASE_MIN_FREQ, pi->lcore_id); if (f_base_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MIN_FREQ); goto err; } @@ -141,7 +141,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_min, "rw+", POWER_SYSFILE_MIN_FREQ, pi->lcore_id); if (f_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_MIN_FREQ); goto err; } @@ -149,7 +149,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) open_core_sysfs_file(&f_max, "rw+", POWER_SYSFILE_MAX_FREQ, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_MAX_FREQ); goto err; } @@ -161,7 +161,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) /* read base max ratio */ ret = read_core_sysfs_u32(f_base_max, &base_max_ratio); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MAX_FREQ); goto err; } @@ -169,7 +169,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) /* read base min ratio */ ret = read_core_sysfs_u32(f_base_min, &base_min_ratio); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MIN_FREQ); goto err; } @@ -178,7 +178,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) if (f_base != NULL) { ret = read_core_sysfs_u32(f_base, &base_ratio); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_FREQ); goto err; } @@ -256,8 +256,9 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) uint32_t target_freq = 0; if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Invalid frequency index %u, which " - "should be less than %u\n", idx, pi->nb_freqs); + POWER_LOG(ERR, + "Invalid frequency index %u, which should be less than %u", + idx, pi->nb_freqs); return -1; } @@ -269,16 +270,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) * User need change the min/max as same value. */ if (fseek(pi->f_cur_min, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", - pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } if (fseek(pi->f_cur_max, 0, SEEK_SET) < 0) { - RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " - "for setting frequency for lcore %u\n", - pi->lcore_id); + POWER_LOG(ERR, + "Fail to set file position indicator to 0 for setting frequency for lcore %u", + pi->lcore_id); return -1; } @@ -287,7 +288,8 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) if (pi->turbo_enable) target_freq = pi->sys_max_freq; else { - RTE_LOG(ERR, POWER, "Turbo is off, frequency can't be scaled up more %u\n", + POWER_LOG(ERR, + "Turbo is off, frequency can't be scaled up more %u", pi->lcore_id); return -1; } @@ -298,14 +300,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) if (idx > pi->curr_idx) { if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } @@ -321,14 +325,16 @@ set_freq_internal(struct pstate_power_info *pi, uint32_t idx) if (idx < pi->curr_idx) { if (fprintf(pi->f_cur_max, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } if (fprintf(pi->f_cur_min, "%u", target_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new frequency for " - "lcore %u\n", pi->lcore_id); + POWER_LOG(ERR, + "Fail to write new frequency for lcore %u", + pi->lcore_id); return -1; } @@ -383,7 +389,7 @@ power_get_available_freqs(struct pstate_power_info *pi) open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_BASE_MAX_FREQ, pi->lcore_id); if (f_max == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MAX_FREQ); goto out; } @@ -391,7 +397,7 @@ power_get_available_freqs(struct pstate_power_info *pi) open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_BASE_MIN_FREQ, pi->lcore_id); if (f_min == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_BASE_MIN_FREQ); goto out; } @@ -399,14 +405,14 @@ power_get_available_freqs(struct pstate_power_info *pi) /* read base ratios */ ret = read_core_sysfs_u32(f_max, &sys_max_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MAX_FREQ); goto out; } ret = read_core_sysfs_u32(f_min, &sys_min_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_BASE_MIN_FREQ); goto out; } @@ -449,7 +455,7 @@ power_get_available_freqs(struct pstate_power_info *pi) num_freqs = (RTE_MIN(base_max_freq, sys_max_freq) - sys_min_freq) / BUS_FREQ + 1 + pi->turbo_available; if (num_freqs >= RTE_MAX_LCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n", + POWER_LOG(ERR, "Too many available frequencies: %d", num_freqs); goto out; } @@ -493,14 +499,14 @@ power_get_cur_idx(struct pstate_power_info *pi) open_core_sysfs_file(&f_cur, "r", POWER_SYSFILE_CUR_FREQ, pi->lcore_id); if (f_cur == NULL) { - RTE_LOG(ERR, POWER, "failed to open %s\n", + POWER_LOG(ERR, "failed to open %s", POWER_SYSFILE_CUR_FREQ); goto fail; } ret = read_core_sysfs_u32(f_cur, &sys_cur_freq); if (ret < 0) { - RTE_LOG(ERR, POWER, "Failed to read %s\n", + POWER_LOG(ERR, "Failed to read %s", POWER_SYSFILE_CUR_FREQ); goto fail; } @@ -542,7 +548,7 @@ power_pstate_cpufreq_init(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceed %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceed %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -558,47 +564,52 @@ power_pstate_cpufreq_init(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "in use\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is in use", lcore_id); return -1; } pi->lcore_id = lcore_id; /* Check and set the governor */ if (power_set_governor_performance(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to " - "performance\n", lcore_id); + POWER_LOG(ERR, + "Cannot set governor of lcore %u to performance", + lcore_id); goto fail; } /* Init for setting lcore frequency */ if (power_init_for_setting_freq(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot init for setting frequency for " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot init for setting frequency for lcore %u", + lcore_id); goto fail; } /* Get the available frequencies */ if (power_get_available_freqs(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get available frequencies of " - "lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get available frequencies of lcore %u", + lcore_id); goto fail; } if (power_get_cur_idx(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot get current frequency " - "index of lcore %u\n", lcore_id); + POWER_LOG(ERR, + "Cannot get current frequency index of lcore %u", + lcore_id); goto fail; } /* Set freq to max by default */ if (power_pstate_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u " - "to max\n", lcore_id); + POWER_LOG(ERR, + "Cannot set frequency of lcore %u to max", lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Initialized successfully for lcore %u " - "power management\n", lcore_id); + POWER_LOG(INFO, + "Initialized successfully for lcore %u power management", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_USED, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -620,7 +631,7 @@ power_pstate_cpufreq_exit(unsigned int lcore_id) uint32_t exp_state; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", + POWER_LOG(ERR, "Lcore id %u can not exceeds %u", lcore_id, RTE_MAX_LCORE - 1U); return -1; } @@ -636,8 +647,8 @@ power_pstate_cpufreq_exit(unsigned int lcore_id) if (!__atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_ONGOING, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { - RTE_LOG(INFO, POWER, "Power management of lcore %u is " - "not used\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u is not used", lcore_id); return -1; } @@ -649,14 +660,15 @@ power_pstate_cpufreq_exit(unsigned int lcore_id) /* Set the governor back to the original */ if (power_set_governor_original(pi) < 0) { - RTE_LOG(ERR, POWER, "Cannot set the governor of %u back " - "to the original\n", lcore_id); + POWER_LOG(ERR, + "Cannot set the governor of %u back to the original", + lcore_id); goto fail; } - RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from " - "'performance' mode and been set back to the " - "original\n", lcore_id); + POWER_LOG(INFO, + "Power management of lcore %u has exited from 'performance' mode and been set back to the original", + lcore_id); exp_state = POWER_ONGOING; __atomic_compare_exchange_n(&(pi->state), &exp_state, POWER_IDLE, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED); @@ -678,18 +690,18 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return 0; } if (freqs == NULL) { - RTE_LOG(ERR, POWER, "NULL buffer supplied\n"); + POWER_LOG(ERR, "NULL buffer supplied"); return 0; } pi = &lcore_power_info[lcore_id]; if (num < pi->nb_freqs) { - RTE_LOG(ERR, POWER, "Buffer size is not enough\n"); + POWER_LOG(ERR, "Buffer size is not enough"); return 0; } rte_memcpy(freqs, pi->freqs, pi->nb_freqs * sizeof(uint32_t)); @@ -701,7 +713,7 @@ uint32_t power_pstate_cpufreq_get_freq(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return RTE_POWER_INVALID_FREQ_INDEX; } @@ -713,7 +725,7 @@ int power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -726,7 +738,7 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -745,7 +757,7 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -761,7 +773,7 @@ int power_pstate_cpufreq_freq_max(unsigned int lcore_id) { if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -786,7 +798,7 @@ power_pstate_cpufreq_freq_min(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -803,7 +815,7 @@ power_pstate_turbo_status(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -818,7 +830,7 @@ power_pstate_enable_turbo(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -828,10 +840,10 @@ power_pstate_enable_turbo(unsigned int lcore_id) pi->turbo_enable = 1; else { pi->turbo_enable = 0; - RTE_LOG(ERR, POWER, - "Failed to enable turbo on lcore %u\n", - lcore_id); - return -1; + POWER_LOG(ERR, + "Failed to enable turbo on lcore %u", + lcore_id); + return -1; } return 0; @@ -844,7 +856,7 @@ power_pstate_disable_turbo(unsigned int lcore_id) struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } @@ -855,8 +867,8 @@ power_pstate_disable_turbo(unsigned int lcore_id) if (pi->turbo_available && pi->curr_idx <= 1) { /* Try to set freq to max by default coming out of turbo */ if (power_pstate_cpufreq_freq_max(lcore_id) < 0) { - RTE_LOG(ERR, POWER, - "Failed to set frequency of lcore %u to max\n", + POWER_LOG(ERR, + "Failed to set frequency of lcore %u to max", lcore_id); return -1; } @@ -872,11 +884,11 @@ int power_pstate_get_capabilities(unsigned int lcore_id, struct pstate_power_info *pi; if (lcore_id >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); + POWER_LOG(ERR, "Invalid lcore ID"); return -1; } if (caps == NULL) { - RTE_LOG(ERR, POWER, "Invalid argument\n"); + POWER_LOG(ERR, "Invalid argument"); return -1; } diff --git a/lib/power/rte_power.c b/lib/power/rte_power.c index 63a43bd8f5ae..23a97fa77f53 100644 --- a/lib/power/rte_power.c +++ b/lib/power/rte_power.c @@ -10,6 +10,7 @@ #include "rte_power.h" #include "power_acpi_cpufreq.h" #include "power_cppc_cpufreq.h" +#include "power_common.h" #include "power_kvm_vm.h" #include "power_pstate_cpufreq.h" @@ -70,7 +71,7 @@ rte_power_set_env(enum power_management_env env) rte_spinlock_lock(&global_env_cfg_lock); if (global_default_env != PM_ENV_NOT_SET) { - RTE_LOG(ERR, POWER, "Power Management Environment already set.\n"); + POWER_LOG(ERR, "Power Management Environment already set."); rte_spinlock_unlock(&global_env_cfg_lock); return -1; } @@ -127,7 +128,7 @@ rte_power_set_env(enum power_management_env env) rte_power_freq_disable_turbo = power_cppc_disable_turbo; rte_power_get_capabilities = power_cppc_get_capabilities; } else { - RTE_LOG(ERR, POWER, "Invalid Power Management Environment(%d) set\n", + POWER_LOG(ERR, "Invalid Power Management Environment(%d) set", env); ret = -1; } @@ -172,39 +173,40 @@ rte_power_init(unsigned int lcore_id) case PM_ENV_CPPC_CPUFREQ: return power_cppc_cpufreq_init(lcore_id); default: - RTE_LOG(INFO, POWER, "Env isn't set yet!\n"); + POWER_LOG(INFO, "Env isn't set yet!"); } /* Auto detect Environment */ - RTE_LOG(INFO, POWER, "Attempting to initialise ACPI cpufreq power management...\n"); + POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq power management..."); ret = power_acpi_cpufreq_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_ACPI_CPUFREQ); goto out; } - RTE_LOG(INFO, POWER, "Attempting to initialise PSTAT power management...\n"); + POWER_LOG(INFO, "Attempting to initialise PSTAT power management..."); ret = power_pstate_cpufreq_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_PSTATE_CPUFREQ); goto out; } - RTE_LOG(INFO, POWER, "Attempting to initialise CPPC power management...\n"); + POWER_LOG(INFO, "Attempting to initialise CPPC power management..."); ret = power_cppc_cpufreq_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_CPPC_CPUFREQ); goto out; } - RTE_LOG(INFO, POWER, "Attempting to initialise VM power management...\n"); + POWER_LOG(INFO, "Attempting to initialise VM power management..."); ret = power_kvm_vm_init(lcore_id); if (ret == 0) { rte_power_set_env(PM_ENV_KVM_VM); goto out; } - RTE_LOG(ERR, POWER, "Unable to set Power Management Environment for lcore " - "%u\n", lcore_id); + POWER_LOG(ERR, + "Unable to set Power Management Environment for lcore %u", + lcore_id); out: return ret; } @@ -222,9 +224,12 @@ rte_power_exit(unsigned int lcore_id) case PM_ENV_CPPC_CPUFREQ: return power_cppc_cpufreq_exit(lcore_id); default: - RTE_LOG(ERR, POWER, "Environment has not been set, unable to exit gracefully\n"); + POWER_LOG(ERR, + "Environment has not been set, unable to exit gracefully"); } return -1; } + +RTE_LOG_REGISTER_DEFAULT(power_logtype, INFO); diff --git a/lib/power/rte_power_empty_poll.c b/lib/power/rte_power_empty_poll.c index 4a4db512474e..da4b1ec3068a 100644 --- a/lib/power/rte_power_empty_poll.c +++ b/lib/power/rte_power_empty_poll.c @@ -10,6 +10,7 @@ #include "rte_power.h" #include "rte_power_empty_poll.h" +#include "power_common.h" #define INTERVALS_PER_SECOND 100 /* (10ms) */ #define SECONDS_TO_TRAIN_FOR 2 @@ -75,7 +76,7 @@ enter_normal_state(struct priority_worker *poll_stats) poll_stats->iter_counter = 0; poll_stats->threshold_ctr = 0; poll_stats->queue_state = MED_NORMAL; - RTE_LOG(INFO, POWER, "Set the power freq to MED\n"); + POWER_LOG(INFO, "Set the power freq to MED"); set_power_freq(poll_stats->lcore_id, MED, false); poll_stats->thresh[MED].threshold_percent = med_to_high_threshold; @@ -213,11 +214,9 @@ update_stats(struct priority_worker *poll_stats) if (s->thresh[s->cur_freq].base_edpi < cur_edpi) { /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "cur_edpi is too large " - "cur edpi %"PRId64" " - "base edpi %"PRId64"\n", - cur_edpi, - s->thresh[s->cur_freq].base_edpi); + POWER_LOG(DEBUG, + "cur_edpi is too large cur edpi %"PRId64" base edpi %"PRId64, + cur_edpi, s->thresh[s->cur_freq].base_edpi); /* Value to make us fail need debug log*/ return 1000UL; } @@ -247,7 +246,7 @@ update_stats_normal(struct priority_worker *poll_stats) enum freq_val cur_freq = poll_stats->cur_freq; /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "cure freq is %d, edpi is %"PRIu64"\n", + POWER_LOG(DEBUG, "cure freq is %d, edpi is %"PRIu64"", cur_freq, poll_stats->thresh[cur_freq].base_edpi); return; @@ -257,12 +256,12 @@ update_stats_normal(struct priority_worker *poll_stats) if (percent > 100) { /* edpi mean empty poll counter difference per interval */ - RTE_LOG(DEBUG, POWER, "Edpi is bigger than threshold\n"); + POWER_LOG(DEBUG, "Edpi is bigger than threshold"); return; } if (poll_stats->cur_freq == LOW) - RTE_LOG(INFO, POWER, "Purge Mode is not currently supported\n"); + POWER_LOG(INFO, "Purge Mode is not currently supported"); else if (poll_stats->cur_freq == MED) { if (percent > @@ -272,7 +271,7 @@ update_stats_normal(struct priority_worker *poll_stats) poll_stats->threshold_ctr++; else { set_state(poll_stats, HGH_BUSY); - RTE_LOG(INFO, POWER, "MOVE to HGH\n"); + POWER_LOG(INFO, "MOVE to HGH"); } } else { @@ -289,7 +288,7 @@ update_stats_normal(struct priority_worker *poll_stats) poll_stats->threshold_ctr++; else { set_state(poll_stats, MED_NORMAL); - RTE_LOG(INFO, POWER, "MOVE to MED\n"); + POWER_LOG(INFO, "MOVE to MED"); } } else { /* reset */ @@ -332,17 +331,17 @@ empty_poll_training(struct priority_worker *poll_stats, set_state(poll_stats, MED_NORMAL); - RTE_LOG(INFO, POWER, "LOW threshold is %"PRIu64"\n", + POWER_LOG(INFO, "LOW threshold is %"PRIu64"", poll_stats->thresh[LOW].base_edpi); - RTE_LOG(INFO, POWER, "MED threshold is %"PRIu64"\n", + POWER_LOG(INFO, "MED threshold is %"PRIu64"", poll_stats->thresh[MED].base_edpi); - RTE_LOG(INFO, POWER, "HIGH threshold is %"PRIu64"\n", + POWER_LOG(INFO, "HIGH threshold is %"PRIu64"", poll_stats->thresh[HGH].base_edpi); - RTE_LOG(INFO, POWER, "Training is Complete for %d\n", + POWER_LOG(INFO, "Training is Complete for %d", poll_stats->lcore_id); } @@ -414,7 +413,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, freq_index[HGH] = freq_tlb[HGH]; } - RTE_LOG(INFO, POWER, "Initialize the Empty Poll\n"); + POWER_LOG(INFO, "Initialize the Empty Poll"); /* Train for pre-defined period */ ep_params->max_train_iter = INTERVALS_PER_SECOND * SECONDS_TO_TRAIN_FOR; @@ -433,7 +432,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, avail_freqs[i], NUM_FREQS); - RTE_LOG(INFO, POWER, "total avail freq is %d , lcoreid %d\n", + POWER_LOG(INFO, "total avail freq is %d , lcoreid %d", total_avail_freqs[i], i); @@ -452,8 +451,7 @@ rte_power_empty_poll_stat_init(struct ep_params **eptr, uint8_t *freq_tlb, void rte_power_empty_poll_stat_free(void) { - - RTE_LOG(INFO, POWER, "Close the Empty Poll\n"); + POWER_LOG(INFO, "Close the Empty Poll"); rte_free(ep_params); } diff --git a/lib/power/rte_power_intel_uncore.c b/lib/power/rte_power_intel_uncore.c index 3b8724385fb7..ee6412a3ed34 100644 --- a/lib/power/rte_power_intel_uncore.c +++ b/lib/power/rte_power_intel_uncore.c @@ -52,8 +52,9 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx) int ret; if (idx >= MAX_UNCORE_FREQS || idx >= ui->nb_freqs) { - RTE_LOG(DEBUG, POWER, "Invalid uncore frequency index %u, which " - "should be less than %u\n", idx, ui->nb_freqs); + POWER_LOG(DEBUG, + "Invalid uncore frequency index %u, which should be less than %u", + idx, ui->nb_freqs); return -1; } @@ -65,13 +66,13 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx) open_core_sysfs_file(&ui->f_cur_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ, ui->pkg, ui->die); if (ui->f_cur_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); return -1; } ret = read_core_sysfs_u32(ui->f_cur_max, &curr_max_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); fclose(ui->f_cur_max); return -1; @@ -79,14 +80,16 @@ set_uncore_freq_internal(struct uncore_power_info *ui, uint32_t idx) /* check this value first before fprintf value to f_cur_max, so value isn't overwritten */ if (fprintf(ui->f_cur_min, "%u", target_uncore_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write new uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } if (fprintf(ui->f_cur_max, "%u", target_uncore_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write new uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write new uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } @@ -121,13 +124,13 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_base_max, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ, ui->pkg, ui->die); if (f_base_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ); goto err; } ret = read_core_sysfs_u32(f_base_max, &base_max_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MAX_FREQ); goto err; } @@ -136,14 +139,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_base_min, "r", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ, ui->pkg, ui->die); if (f_base_min == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ); goto err; } if (f_base_min != NULL) { ret = read_core_sysfs_u32(f_base_min, &base_min_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_BASE_MIN_FREQ); goto err; } @@ -153,14 +156,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_min, "rw+", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ, ui->pkg, ui->die); if (f_min == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ); goto err; } if (f_min != NULL) { ret = read_core_sysfs_u32(f_min, &min_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_MIN_FREQ); goto err; } @@ -170,14 +173,14 @@ power_init_for_setting_uncore_freq(struct uncore_power_info *ui) open_core_sysfs_file(&f_max, "rw+", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ, ui->pkg, ui->die); if (f_max == NULL) { - RTE_LOG(DEBUG, POWER, "failed to open %s\n", + POWER_LOG(DEBUG, "failed to open %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); goto err; } if (f_max != NULL) { ret = read_core_sysfs_u32(f_max, &max_freq); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to read %s\n", + POWER_LOG(DEBUG, "Failed to read %s", POWER_INTEL_UNCORE_SYSFILE_MAX_FREQ); goto err; } @@ -222,7 +225,7 @@ power_get_available_uncore_freqs(struct uncore_power_info *ui) num_uncore_freqs = (ui->init_max_freq - ui->init_min_freq) / BUS_FREQ + 1; if (num_uncore_freqs >= MAX_UNCORE_FREQS) { - RTE_LOG(ERR, POWER, "Too many available uncore frequencies: %d\n", + POWER_LOG(ERR, "Too many available uncore frequencies: %d", num_uncore_freqs); goto out; } @@ -250,7 +253,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die) if (max_pkgs == 0) return -1; if (pkg >= max_pkgs) { - RTE_LOG(DEBUG, POWER, "Package number %02u can not exceed %u\n", + POWER_LOG(DEBUG, "Package number %02u can not exceed %u", pkg, max_pkgs); return -1; } @@ -259,7 +262,7 @@ check_pkg_die_values(unsigned int pkg, unsigned int die) if (max_dies == 0) return -1; if (die >= max_dies) { - RTE_LOG(DEBUG, POWER, "Die number %02u can not exceed %u\n", + POWER_LOG(DEBUG, "Die number %02u can not exceed %u", die, max_dies); return -1; } @@ -282,15 +285,17 @@ rte_power_uncore_init(unsigned int pkg, unsigned int die) /* Init for setting uncore die frequency */ if (power_init_for_setting_uncore_freq(ui) < 0) { - RTE_LOG(DEBUG, POWER, "Cannot init for setting uncore frequency for " - "pkg %02u die %02u\n", pkg, die); + POWER_LOG(DEBUG, + "Cannot init for setting uncore frequency for pkg %02u die %02u", + pkg, die); return -1; } /* Get the available frequencies */ if (power_get_available_uncore_freqs(ui) < 0) { - RTE_LOG(DEBUG, POWER, "Cannot get available uncore frequencies of " - "pkg %02u die %02u\n", pkg, die); + POWER_LOG(DEBUG, + "Cannot get available uncore frequencies of pkg %02u die %02u", + pkg, die); return -1; } @@ -309,14 +314,16 @@ rte_power_uncore_exit(unsigned int pkg, unsigned int die) ui = &uncore_info[pkg][die]; if (fprintf(ui->f_cur_min, "%u", ui->org_min_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write original uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } if (fprintf(ui->f_cur_max, "%u", ui->org_max_freq) < 0) { - RTE_LOG(ERR, POWER, "Fail to write original uncore frequency for " - "pkg %02u die %02u\n", ui->pkg, ui->die); + POWER_LOG(ERR, + "Fail to write original uncore frequency for pkg %02u die %02u", + ui->pkg, ui->die); return -1; } @@ -395,10 +402,8 @@ rte_power_uncore_get_num_pkgs(void) d = opendir(INTEL_UNCORE_FREQUENCY_DIR); if (d == NULL) { - RTE_LOG(ERR, POWER, - "Uncore frequency management not supported/enabled on this kernel. " - "Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel" - " >= 5.6\n"); + POWER_LOG(ERR, + "Uncore frequency management not supported/enabled on this kernel"); return 0; } @@ -427,16 +432,14 @@ rte_power_uncore_get_num_dies(unsigned int pkg) if (max_pkgs == 0) return 0; if (pkg >= max_pkgs) { - RTE_LOG(DEBUG, POWER, "Invalid package number\n"); + POWER_LOG(DEBUG, "Invalid package number"); return 0; } d = opendir(INTEL_UNCORE_FREQUENCY_DIR); if (d == NULL) { - RTE_LOG(ERR, POWER, - "Uncore frequency management not supported/enabled on this kernel. " - "Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL if on x86 with linux kernel" - " >= 5.6\n"); + POWER_LOG(ERR, + "Uncore frequency management not supported/enabled on this kernel"); return 0; } diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index ca1840387c74..e691e754ccb0 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -146,7 +146,7 @@ get_monitor_addresses(struct pmd_core_cfg *cfg, /* attempted out of bounds access */ if (i >= len) { - RTE_LOG(ERR, POWER, "Too many queues being monitored\n"); + POWER_LOG(ERR, "Too many queues being monitored"); return -1; } @@ -422,7 +422,7 @@ check_scale(unsigned int lcore) /* only PSTATE and ACPI modes are supported */ if (!rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ) && !rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) { - RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes are supported\n"); + POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes are supported"); return -ENOTSUP; } /* ensure we could initialize the power library */ @@ -432,7 +432,7 @@ check_scale(unsigned int lcore) /* ensure we initialized the correct env */ env = rte_power_get_env(); if (env != PM_ENV_ACPI_CPUFREQ && env != PM_ENV_PSTATE_CPUFREQ) { - RTE_LOG(DEBUG, POWER, "Neither ACPI nor PSTATE modes were initialized\n"); + POWER_LOG(DEBUG, "Neither ACPI nor PSTATE modes were initialized"); return -ENOTSUP; } @@ -448,7 +448,7 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata) /* check if rte_power_monitor is supported */ if (!global_data.intrinsics_support.power_monitor) { - RTE_LOG(DEBUG, POWER, "Monitoring intrinsics are not supported\n"); + POWER_LOG(DEBUG, "Monitoring intrinsics are not supported"); return -ENOTSUP; } /* check if multi-monitor is supported */ @@ -457,14 +457,14 @@ check_monitor(struct pmd_core_cfg *cfg, const union queue *qdata) /* if we're adding a new queue, do we support multiple queues? */ if (cfg->n_queues > 0 && !multimonitor_supported) { - RTE_LOG(DEBUG, POWER, "Monitoring multiple queues is not supported\n"); + POWER_LOG(DEBUG, "Monitoring multiple queues is not supported"); return -ENOTSUP; } /* check if the device supports the necessary PMD API */ if (rte_eth_get_monitor_addr(qdata->portid, qdata->qid, &dummy) == -ENOTSUP) { - RTE_LOG(DEBUG, POWER, "The device does not support rte_eth_get_monitor_addr\n"); + POWER_LOG(DEBUG, "The device does not support rte_eth_get_monitor_addr"); return -ENOTSUP; } @@ -564,14 +564,14 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id, clb = clb_pause; break; default: - RTE_LOG(DEBUG, POWER, "Invalid power management type\n"); + POWER_LOG(DEBUG, "Invalid power management type"); ret = -EINVAL; goto end; } /* add this queue to the list */ ret = queue_list_add(lcore_cfg, &qdata); if (ret < 0) { - RTE_LOG(DEBUG, POWER, "Failed to add queue to list: %s\n", + POWER_LOG(DEBUG, "Failed to add queue to list: %s", strerror(-ret)); goto end; } @@ -684,7 +684,8 @@ int rte_power_pmd_mgmt_set_pause_duration(unsigned int duration) { if (duration == 0) { - RTE_LOG(ERR, POWER, "Pause duration must be greater than 0, value unchanged"); + POWER_LOG(ERR, + "Pause duration must be greater than 0, value unchanged"); return -EINVAL; } pause_duration = duration; @@ -702,12 +703,13 @@ int rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } if (min > scale_freq_max[lcore]) { - RTE_LOG(ERR, POWER, "Invalid min frequency: Cannot be greater than max frequency"); + POWER_LOG(ERR, + "Invalid min frequency: Cannot be greater than max frequency"); return -EINVAL; } scale_freq_min[lcore] = min; @@ -719,7 +721,7 @@ int rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } @@ -727,7 +729,8 @@ rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max) if (max == 0) max = UINT32_MAX; if (max < scale_freq_min[lcore]) { - RTE_LOG(ERR, POWER, "Invalid max frequency: Cannot be less than min frequency"); + POWER_LOG(ERR, + "Invalid max frequency: Cannot be less than min frequency"); return -EINVAL; } @@ -740,12 +743,12 @@ int rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } if (scale_freq_max[lcore] == 0) - RTE_LOG(DEBUG, POWER, "Scaling freq min config not set. Using sysfs min freq.\n"); + POWER_LOG(DEBUG, "Scaling freq min config not set. Using sysfs min freq."); return scale_freq_min[lcore]; } @@ -754,12 +757,12 @@ int rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore) { if (lcore >= RTE_MAX_LCORE) { - RTE_LOG(ERR, POWER, "Invalid lcore ID: %u\n", lcore); + POWER_LOG(ERR, "Invalid lcore ID: %u", lcore); return -EINVAL; } if (scale_freq_max[lcore] == UINT32_MAX) { - RTE_LOG(DEBUG, POWER, "Scaling freq max config not set. Using sysfs max freq.\n"); + POWER_LOG(DEBUG, "Scaling freq max config not set. Using sysfs max freq."); return 0; } From patchwork Tue Feb 7 23:04:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123396 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 C0AD341C34; Wed, 8 Feb 2023 00:06:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DD2642D5F; Wed, 8 Feb 2023 00:05:20 +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 B2C1942D56 for ; Wed, 8 Feb 2023 00:05:17 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id ge21-20020a17090b0e1500b002308aac5b5eso345711pjb.4 for ; Tue, 07 Feb 2023 15:05:17 -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=TGI+362xtBNoVKpNbOlux/TIyZ9au9Qd1CJOZexwK04=; b=sRgNBZMQXOSp5I+WWgSeo5hk292AWpiZs5bMgRaDRrvb+NuWpSIiXdlyJDKxdcvFeH hgn47fSoH1t0ECn5LpD4Bgkmz8fv2+BxQZFkTALw10Qc8CgDzv0vOZXsUESOeYhx8nWP OSAk98SVEzRkdLIiMMRvpOTNErtxf1m4wQuWcoXNV96v3riB9ra2ONEv4COnK+ngdHwV oONm+2/2Gp+XlxIowQNrc9aLXDe1v6TPLPO/fU6O9OLpUfeNS19Tu7vVcDgoGKdwvVgG eTqqHQncFAY0dVDADCcg+1TJ3xAu1zc3Drx+seRz8oQXjZDXpuGWf1kaQSRyBkcjPx/I TBIQ== 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=TGI+362xtBNoVKpNbOlux/TIyZ9au9Qd1CJOZexwK04=; b=V5eaVx0NyfupuIIhTe4W0muPouS39x5Ar7Qkv8CpJE7ukou+Jcb6KFV+hs5Zf0Dga5 raA/S4pYZNPIpqiTeY9jcpYjiUGJ/RLJnxxO3yANa8OEUPTiX5tTcIgvdyKPLv2KM1L4 aINXPaBjeErRjyo63ZQaNbMTMkvPkZd2lkHhzfAgjY8Egdy/XNAC7I1vEOCPOT1x7TAq pnGToJVS1iMuf0e8cRz00lpwqztB1u9Al5vuZLJNLw/XllEs92rLtcfXXj5bhfH8mkNP nggxJCqKo5rwH7ft9ei/RAFzAbHHLiHU/2Ww4kJCMGaKbW8p0gF/KcKCxNNu8CEwg8O2 1UAA== X-Gm-Message-State: AO0yUKVoLRIZJicRcoBXnF0RC6rfqawVKHEu4tCKhFBtdT1SoA20qxBL KOb/GO8x6aRASKJyA7LEmXL/QiJ/34+CnxzX5V4= X-Google-Smtp-Source: AK7set+aES/601rvoOIJjnhqIjpN0OEAFaMDoc+rP+vjKz4KH+gJ7CfaTnzPaF+RBY6uOUW2bbR0mg== X-Received: by 2002:a17:90a:313:b0:230:c87e:2b2d with SMTP id 19-20020a17090a031300b00230c87e2b2dmr5639302pje.40.1675811116614; Tue, 07 Feb 2023 15:05:16 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Subject: [RFC v2 11/17] ring: replace RTE_LOGTYPE_RING with dynamic type Date: Tue, 7 Feb 2023 15:04:32 -0800 Message-Id: <20230207230438.1617331-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 The logtype for ring only used in library. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/ring/rte_ring.c | 31 +++++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 7dbf1df3b979..04c9d43351da 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,7 +349,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_RING, "lib.ring"}, {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 5b7850af4e2b..a99fe383c89b 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -28,7 +28,7 @@ extern "C" { /* SDK log type */ #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ /* was RTE_LOGTYPE_MALLOC */ -#define RTE_LOGTYPE_RING 2 /**< Log related to ring. */ + /* was RTE_LOGTYPE_RING */ #define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index cddaf6b2876f..1b4633468a2a 100644 --- a/lib/ring/rte_ring.c +++ b/lib/ring/rte_ring.c @@ -26,6 +26,13 @@ #include "rte_ring.h" #include "rte_ring_elem.h" +RTE_LOG_REGISTER_DEFAULT(ring_logtype, INFO); + +#define RING_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ring_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + + TAILQ_HEAD(rte_ring_list, rte_tailq_entry); static struct rte_tailq_elem rte_ring_tailq = { @@ -52,15 +59,15 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count) /* Check if element size is a multiple of 4B */ if (esize % 4 != 0) { - RTE_LOG(ERR, RING, "element size is not a multiple of 4\n"); + RING_LOG(ERR, "element size is not a multiple of 4"); return -EINVAL; } /* count must be a power of 2 */ if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK )) { - RTE_LOG(ERR, RING, - "Requested number of elements is invalid, must be power of 2, and not exceed %u\n", + RING_LOG(ERR, + "Requested number of elements is invalid, must be power of 2, and not exceed %u", RTE_RING_SZ_MASK); return -EINVAL; @@ -195,8 +202,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, /* future proof flags, only allow supported values */ if (flags & ~RING_F_MASK) { - RTE_LOG(ERR, RING, - "Unsupported flags requested %#x\n", flags); + RING_LOG(ERR, + "Unsupported flags requested %#x", flags); return -EINVAL; } @@ -216,8 +223,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned int count, r->capacity = count; } else { if ((!POWEROF2(count)) || (count > RTE_RING_SZ_MASK)) { - RTE_LOG(ERR, RING, - "Requested size is invalid, must be power of 2, and not exceed the size limit %u\n", + RING_LOG(ERR, + "Requested size is invalid, must be power of 2, and not exceed the size limit %u", RTE_RING_SZ_MASK); return -EINVAL; } @@ -271,7 +278,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n"); + RING_LOG(ERR, "Cannot reserve memory for tailq"); rte_errno = ENOMEM; return NULL; } @@ -295,7 +302,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, TAILQ_INSERT_TAIL(ring_list, te, next); } else { r = NULL; - RTE_LOG(ERR, RING, "Cannot reserve memory\n"); + RING_LOG(ERR, "Cannot reserve memory"); rte_free(te); } rte_mcfg_tailq_write_unlock(); @@ -327,13 +334,13 @@ rte_ring_free(struct rte_ring *r) * therefore, there is no memzone to free. */ if (r->memzone == NULL) { - RTE_LOG(ERR, RING, - "Cannot free ring, not created with rte_ring_create()\n"); + RING_LOG(ERR, + "Cannot free ring, not created with rte_ring_create()"); return; } if (rte_memzone_free(r->memzone) != 0) { - RTE_LOG(ERR, RING, "Cannot free memory\n"); + RING_LOG(ERR, "Cannot free memory"); return; } From patchwork Tue Feb 7 23:04:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123398 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 ABDBF41C34; Wed, 8 Feb 2023 00:06:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B757542D6D; Wed, 8 Feb 2023 00:05:22 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id D144A42D46 for ; Wed, 8 Feb 2023 00:05:18 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id o16-20020a17090ad25000b00230759a8c06so369682pjw.2 for ; Tue, 07 Feb 2023 15:05:18 -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=C/T7O65KQL1uw1reJ66M8VpF4ow9LLidnK25FdG2Lis=; b=OvZuTXFTQ4UOxDx8jj0Orh/bImhGZn7A7tgZ1rZIxzDWSkAuNc5NheVp1+2PJlJXtJ FlXe0SWqDcX3t1ij961yE+CxKIpUfJ2QxYFY0XW7j4FV3OsiFTQHGfI3Mu2nDqg5mnjX /eh0UVJywu7hcUJrc8pqVmsaYf/uK7Oo3R/gPyN9Ste/NFTvoutdXJ7VA1ti/+3Ve52M 7jvzpfoNYJ+En49TJeieQvtnc707L4mt7eP35/PAQ91e04Jls1X1GJ5l5G8cxd+1+zTF P7FGEzoWvD1+glNtiPQ2Z+BwCFQ5lUDW8IFFhz3pQ2w/sn7jDUMjN0qGgxTkf9hGP3d7 bHeA== 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=C/T7O65KQL1uw1reJ66M8VpF4ow9LLidnK25FdG2Lis=; b=4F0j/BGp+/Jri0FwGPsyTzCQlnk4vMNKAfQ2whd0tmCQ/IHgD8qj469fAo6rHoeLod VuY354GKoAksMK9/3++Nul0eKpYxOybte1w63M8kwcXl4x3elEOZmo6jBrR5Vv8kHzUv 28qMzECjGUIgkXG46YMqSwmv9IAJRQ8aEtHANHdGEPTy11naAj5FyFD0vEGI2DrLa14Q Z/vkiGxdxkdfXbMBiPqFhK+burbUwRE0pFYHgayJxMT+WwRTaJ6+MWj4stRTJbNiehm8 M6du2CGbF/U5dh4lOllSAcrH1kpjU33QX+dvmrwuJz+SIutUleUuTfwEB8Ybj7L4G7F/ FiBg== X-Gm-Message-State: AO0yUKXRbUHgKfl4XC8w6/aNeuoWAfhvqohQR0ZWW6PLQ7ry8/AQi2xM sfCewH0w6I984AXZXr1YeeIabUvdkdT7hNHpxQk= X-Google-Smtp-Source: AK7set9tU1o6XZk1+0lE+ik8uGln6B/8tzA52RZMwzHQCRSfGDR6moJMfnYpTUhn81OaAr/DKflzMw== X-Received: by 2002:a17:90a:1a52:b0:22c:1b3:b72b with SMTP id 18-20020a17090a1a5200b0022c01b3b72bmr6281046pjl.14.1675811117813; Tue, 07 Feb 2023 15:05:17 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Andrew Rybchenko Subject: [RFC v2 12/17] mempool: replace RTE_LOGTYPE_MEMPOOL with dynamic type Date: Tue, 7 Feb 2023 15:04:33 -0800 Message-Id: <20230207230438.1617331-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Convert from RTE_LOGTYPE_MEMPOOL to logtype_mempool. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/mempool/rte_mempool.c | 33 ++++++++++++++++++--------------- lib/mempool/rte_mempool_log.h | 10 ++++++++++ lib/mempool/rte_mempool_ops.c | 12 ++++++------ 5 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 lib/mempool/rte_mempool_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 04c9d43351da..90d388192712 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -349,7 +349,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, - {RTE_LOGTYPE_MEMPOOL, "lib.mempool"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_LPM, "lib.lpm"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index a99fe383c89b..f583352ec1ea 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -29,7 +29,7 @@ extern "C" { #define RTE_LOGTYPE_EAL 0 /**< Log related to eal. */ /* was RTE_LOGTYPE_MALLOC */ /* was RTE_LOGTYPE_RING */ -#define RTE_LOGTYPE_MEMPOOL 3 /**< Log related to mempool. */ + /* was RTE_LOGTYPE_MEMPOOL */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index 45b5df6199b0..911a2b4dd850 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -30,6 +30,7 @@ #include "rte_mempool.h" #include "rte_mempool_trace.h" +#include "rte_mempool_log.h" TAILQ_HEAD(rte_mempool_list, rte_tailq_entry); @@ -774,7 +775,7 @@ rte_mempool_cache_create(uint32_t size, int socket_id) cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache), RTE_CACHE_LINE_SIZE, socket_id); if (cache == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n"); + MEMPOOL_LOG(ERR, "Cannot allocate mempool cache."); rte_errno = ENOMEM; return NULL; } @@ -876,7 +877,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, /* try to allocate tailq entry */ te = rte_zmalloc("MEMPOOL_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate tailq entry!\n"); + MEMPOOL_LOG(ERR, "Cannot allocate tailq entry!"); goto exit_unlock; } @@ -1088,25 +1089,25 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp, if (free == 0) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE1) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (put)\n"); } hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2; } else if (free == 1) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE2) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (get)\n"); } hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE1; } else if (free == 2) { if (cookie != RTE_MEMPOOL_HEADER_COOKIE1 && cookie != RTE_MEMPOOL_HEADER_COOKIE2) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", + MEMPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad header cookie (audit)\n"); } @@ -1114,9 +1115,9 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp, tlr = rte_mempool_get_trailer(obj); cookie = tlr->cookie; if (cookie != RTE_MEMPOOL_TRAILER_COOKIE) { - RTE_LOG(CRIT, MEMPOOL, - "obj=%p, mempool=%p, cookie=%" PRIx64 "\n", - obj, (const void *) mp, cookie); + MEPOOL_LOG(CRIT, + "obj=%p, mempool=%p, cookie=%" PRIx64, + obj, (const void *) mp, cookie); rte_panic("MEMPOOL: bad trailer cookie\n"); } } @@ -1200,7 +1201,7 @@ mempool_audit_cache(const struct rte_mempool *mp) const struct rte_mempool_cache *cache; cache = &mp->local_cache[lcore_id]; if (cache->len > RTE_DIM(cache->objs)) { - RTE_LOG(CRIT, MEMPOOL, "badness on cache[%u]\n", + MEMPOOL_LOG(CRIT, "badness on cache[%u]", lcore_id); rte_panic("MEMPOOL: invalid cache len\n"); } @@ -1429,7 +1430,7 @@ rte_mempool_event_callback_register(rte_mempool_event_callback *func, cb = calloc(1, sizeof(*cb)); if (cb == NULL) { - RTE_LOG(ERR, MEMPOOL, "Cannot allocate event callback!\n"); + MEMPOOL_LOG(ERR, "Cannot allocate event callback!"); ret = -ENOMEM; goto exit; } @@ -1563,3 +1564,5 @@ RTE_INIT(mempool_init_telemetry) rte_telemetry_register_cmd("/mempool/info", mempool_handle_info, "Returns mempool info. Parameters: pool_name"); } + +RTE_LOG_REGISTER_DEFAULT(mempool_logtype, INFO); diff --git a/lib/mempool/rte_mempool_log.h b/lib/mempool/rte_mempool_log.h new file mode 100644 index 000000000000..3d252f761408 --- /dev/null +++ b/lib/mempool/rte_mempool_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 mempool_logtype; + +#define MEMPOOL_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, mempool_logtype, \ + "%s(): " fmt "\n", __func__, ##args) diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c index 3b43edc548a0..e04e75b91ba6 100644 --- a/lib/mempool/rte_mempool_ops.c +++ b/lib/mempool/rte_mempool_ops.c @@ -12,6 +12,7 @@ #include #include "rte_mempool_trace.h" +#include "rte_mempool_log.h" /* indirect jump table to support external memory pools. */ struct rte_mempool_ops_table rte_mempool_ops_table = { @@ -31,23 +32,22 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h) if (rte_mempool_ops_table.num_ops >= RTE_MEMPOOL_MAX_OPS_IDX) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(ERR, MEMPOOL, - "Maximum number of mempool ops structs exceeded\n"); + MEMPOOL_LOG(ERR, + "Maximum number of mempool ops structs exceeded"); return -ENOSPC; } if (h->alloc == NULL || h->enqueue == NULL || h->dequeue == NULL || h->get_count == NULL) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(ERR, MEMPOOL, - "Missing callback while registering mempool ops\n"); + MEMPOOL_LOG(ERR, + "Missing callback while registering mempool ops"); return -EINVAL; } if (strlen(h->name) >= sizeof(ops->name) - 1) { rte_spinlock_unlock(&rte_mempool_ops_table.sl); - RTE_LOG(DEBUG, EAL, "%s(): mempool_ops <%s>: name too long\n", - __func__, h->name); + MEMPOOL_LOG(DEBUG, "mempool_ops <%s>: name too long\n", h->name); rte_errno = EEXIST; return -EEXIST; } From patchwork Tue Feb 7 23:04:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123399 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 A198941C34; Wed, 8 Feb 2023 00:06:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C849442D93; Wed, 8 Feb 2023 00:05:24 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id 357D642D4A for ; Wed, 8 Feb 2023 00:05:20 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id bg10-20020a17090b0d8a00b00230c7f312d4so368232pjb.3 for ; Tue, 07 Feb 2023 15:05:20 -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=I/t267Q4Mx5FSR1VVjXRdtB5eKzqCvuevQu1xHH15Wo=; b=WQhxHvDUaKWSALxv3XmQB8a6M3sPJWYCMLfAGdO9ARpwT9Gq3ZlLo6uyb5yAI+QpXp vQ6pKnWxzz8tLFRxhmC1nTKe/Bu41mTWJy7YIoX3pFFJmasDVQLl5xIgymAfBZpST8zn LhWIRs/MN1hwqD4SuD0ZLOxvVYaenfsR2ibcTRFNI8/YEWLiMiU0D3ZCW9oTh0s19e8x CM709zJ8Tb0otT0bFoFwdzGV0pIvk3m4x30dHtfzyOoBkrTE7zpRNiGs91BdMTQ+qGY4 mPDRUdmwio4eP2mVP6T6ikS1fNG1cf/hyEnFI5muxmBu0myUL88Kto/JYONlYkrif+LD 97yQ== 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=I/t267Q4Mx5FSR1VVjXRdtB5eKzqCvuevQu1xHH15Wo=; b=yvW+iUvU0OnaNUgKsRPx8sQjQDO147yCB25gthcREqufnEW+QYphueazYlhrO/b4bi NhQGKqKiiQ4BhFGkulOcfZtr8vbS0tWWdtunVgBm1P8W97hIDdlK8PwTSTpsVKgo2OKA x4I9Z+nZtaNCamjsvTrwkFAKq4LkB6Uyxnyi7vrB25E6x6Sojr0BDge4O9KVYCTd6cjC qno7kE43PuwuYtNu4qO6SStuQJUp6oK7XIZkrsbcN5kbVWLI03Zzx/e+2d25lvzJbTBK Xi2ORArD4mrm/0G/EMhFogo6niMwQNZ+uF05TobttpFDzqr7CITmedFj2BG4OkVbsfay sR2w== X-Gm-Message-State: AO0yUKWrlbva57RzgJxQaUUA6KHp/9YyWFxAmj9IeYrMpTF4FKlXfXK1 AXKeToLVIolVCK7OoUS1eGjaG3kLppER4tZ/hB0= X-Google-Smtp-Source: AK7set+xeGuhio+53V4PZwFujF3Q5M+sKRTDlCc+sLQXkrZK65kB6U91d+Ch0LHV3/gWjmAXMAGbyw== X-Received: by 2002:a17:90b:4d92:b0:22b:f009:2e6 with SMTP id oj18-20020a17090b4d9200b0022bf00902e6mr5860724pjb.18.1675811118817; Tue, 07 Feb 2023 15:05:18 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:18 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin , Bruce Richardson Subject: [RFC v2 13/17] lpm: replace RTE_LOGTYPE_LPM with dynamic types Date: Tue, 7 Feb 2023 15:04:34 -0800 Message-Id: <20230207230438.1617331-14-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Split lpm and lpm6 into separate log types since they are in different files and user may want to change log levels for IPv4 vs IPv6. For rib and fib libraries give them own types as well. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/fib/rte_fib.c | 23 +++++++++++++++-------- lib/fib/rte_fib6.c | 21 ++++++++++++++------- lib/lpm/rte_lpm.c | 18 ++++++++++++------ lib/lpm/rte_lpm6.c | 25 +++++++++++++++++-------- lib/rib/rte_rib.c | 14 +++++++++----- lib/rib/rte_rib6.c | 16 +++++++++++----- 8 files changed, 79 insertions(+), 41 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 90d388192712..ff250b9a6d56 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, - {RTE_LOGTYPE_LPM, "lib.lpm"}, {RTE_LOGTYPE_KNI, "lib.kni"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index f583352ec1ea..55067efb0a84 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -33,7 +33,7 @@ extern "C" { /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ -#define RTE_LOGTYPE_LPM 7 /**< Log related to LPM. */ + /* was RTE_LOGTYPE_LPM */ #define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ /* was RTE_LOGTYPE_ACL */ /* was RTE_LOGTYPE_POWER */ diff --git a/lib/fib/rte_fib.c b/lib/fib/rte_fib.c index 8af4c4091908..7fda4263f841 100644 --- a/lib/fib/rte_fib.c +++ b/lib/fib/rte_fib.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -17,6 +18,12 @@ #include "dir24_8.h" +RTE_LOG_REGISTER_DEFAULT(fib_logtype, INFO); + +#define FIB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, fib_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_fib_list, rte_tailq_entry); static struct rte_tailq_elem rte_fib_tailq = { .name = "RTE_FIB", @@ -167,8 +174,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) rib = rte_rib_create(name, socket_id, &rib_conf); if (rib == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate RIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate RIB %s", name); return NULL; } @@ -192,8 +199,8 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) /* allocate tailq entry */ te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for FIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate tailq entry for FIB %s", name); rte_errno = ENOMEM; goto exit; } @@ -202,7 +209,7 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) fib = rte_zmalloc_socket(mem_name, sizeof(struct rte_fib), RTE_CACHE_LINE_SIZE, socket_id); if (fib == NULL) { - RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name); + FIB_LOG(ERR, "FIB %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } @@ -213,9 +220,9 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) fib->def_nh = conf->default_nh; ret = init_dataplane(fib, socket_id, conf); if (ret < 0) { - RTE_LOG(ERR, LPM, - "FIB dataplane struct %s memory allocation failed " - "with err %d\n", name, ret); + FIB_LOG(ERR, + "FIB dataplane struct %s memory allocation failed with err %d", + name, ret); rte_errno = -ret; goto free_fib; } diff --git a/lib/fib/rte_fib6.c b/lib/fib/rte_fib6.c index 4b8e22b142b9..b6631fc19481 100644 --- a/lib/fib/rte_fib6.c +++ b/lib/fib/rte_fib6.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -17,6 +18,12 @@ #include "trie.h" +RTE_LOG_REGISTER_SUFFIX(fib6_logtype, "fib6", INFO); + +#define FIB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, fib6_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_fib6_list, rte_tailq_entry); static struct rte_tailq_elem rte_fib6_tailq = { .name = "RTE_FIB6", @@ -168,8 +175,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) rib = rte_rib6_create(name, socket_id, &rib_conf); if (rib == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate RIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate RIB %s", name); return NULL; } @@ -193,8 +200,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) /* allocate tailq entry */ te = rte_zmalloc("FIB_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for FIB %s\n", name); + FIB_LOG(ERR, + "Can not allocate tailq entry for FIB %s", name); rte_errno = ENOMEM; goto exit; } @@ -203,7 +210,7 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) fib = rte_zmalloc_socket(mem_name, sizeof(struct rte_fib6), RTE_CACHE_LINE_SIZE, socket_id); if (fib == NULL) { - RTE_LOG(ERR, LPM, "FIB %s memory allocation failed\n", name); + FIB_LOG(ERR, "FIB %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } @@ -214,8 +221,8 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) fib->def_nh = conf->default_nh; ret = init_dataplane(fib, socket_id, conf); if (ret < 0) { - RTE_LOG(ERR, LPM, - "FIB dataplane struct %s memory allocation failed\n", + FIB_LOG(ERR, + "FIB dataplane struct %s memory allocation failed", name); rte_errno = -ret; goto free_fib; diff --git a/lib/lpm/rte_lpm.c b/lib/lpm/rte_lpm.c index cdcd1b7f9e47..ba3912a775a3 100644 --- a/lib/lpm/rte_lpm.c +++ b/lib/lpm/rte_lpm.c @@ -19,6 +19,12 @@ #include "rte_lpm.h" +RTE_LOG_REGISTER_DEFAULT(lpm_logtype, INFO); + +#define LPM_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, lpm_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_lpm_list, rte_tailq_entry); static struct rte_tailq_elem rte_lpm_tailq = { @@ -189,7 +195,7 @@ rte_lpm_create(const char *name, int socket_id, /* allocate tailq entry */ te = rte_zmalloc("LPM_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, "Failed to allocate tailq entry\n"); + LPM_LOG(ERR, "Failed to allocate tailq entry"); rte_errno = ENOMEM; goto exit; } @@ -198,7 +204,7 @@ rte_lpm_create(const char *name, int socket_id, i_lpm = rte_zmalloc_socket(mem_name, mem_size, RTE_CACHE_LINE_SIZE, socket_id); if (i_lpm == NULL) { - RTE_LOG(ERR, LPM, "LPM memory allocation failed\n"); + LPM_LOG(ERR, "LPM memory allocation failed"); rte_free(te); rte_errno = ENOMEM; goto exit; @@ -208,7 +214,7 @@ rte_lpm_create(const char *name, int socket_id, (size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id); if (i_lpm->rules_tbl == NULL) { - RTE_LOG(ERR, LPM, "LPM rules_tbl memory allocation failed\n"); + LPM_LOG(ERR, "LPM rules_tbl memory allocation failed"); rte_free(i_lpm); i_lpm = NULL; rte_free(te); @@ -220,7 +226,7 @@ rte_lpm_create(const char *name, int socket_id, (size_t)tbl8s_size, RTE_CACHE_LINE_SIZE, socket_id); if (i_lpm->lpm.tbl8 == NULL) { - RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n"); + LPM_LOG(ERR, "LPM tbl8 memory allocation failed"); rte_free(i_lpm->rules_tbl); rte_free(i_lpm); i_lpm = NULL; @@ -335,7 +341,7 @@ rte_lpm_rcu_qsbr_add(struct rte_lpm *lpm, struct rte_lpm_rcu_config *cfg) params.v = cfg->v; i_lpm->dq = rte_rcu_qsbr_dq_create(¶ms); if (i_lpm->dq == NULL) { - RTE_LOG(ERR, LPM, "LPM defer queue creation failed\n"); + LPM_LOG(ERR, "LPM defer queue creation failed"); return 1; } } else { @@ -562,7 +568,7 @@ tbl8_free(struct __rte_lpm *i_lpm, uint32_t tbl8_group_start) status = rte_rcu_qsbr_dq_enqueue(i_lpm->dq, (void *)&tbl8_group_start); if (status == 1) { - RTE_LOG(ERR, LPM, "Failed to push QSBR FIFO\n"); + LPM_LOG(ERR, "Failed to push QSBR FIFO"); return -rte_errno; } } diff --git a/lib/lpm/rte_lpm6.c b/lib/lpm/rte_lpm6.c index 8d21aeddb83c..7701e8112ed2 100644 --- a/lib/lpm/rte_lpm6.c +++ b/lib/lpm/rte_lpm6.c @@ -45,6 +45,12 @@ enum valid_flag { VALID }; +RTE_LOG_REGISTER_SUFFIX(lpm6_logtype, "lpm6", INFO); + +#define LPM_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, lpm6_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_lpm6_list, rte_tailq_entry); static struct rte_tailq_elem rte_lpm6_tailq = { @@ -279,8 +285,9 @@ rte_lpm6_create(const char *name, int socket_id, rules_tbl = rte_hash_create(&rule_hash_tbl_params); if (rules_tbl == NULL) { - RTE_LOG(ERR, LPM, "LPM rules hash table allocation failed: %s (%d)", - rte_strerror(rte_errno), rte_errno); + LPM_LOG(ERR, + "LPM rules hash table allocation failed: %s (%d)", + rte_strerror(rte_errno), rte_errno); goto fail_wo_unlock; } @@ -289,8 +296,9 @@ rte_lpm6_create(const char *name, int socket_id, sizeof(uint32_t) * config->number_tbl8s, RTE_CACHE_LINE_SIZE); if (tbl8_pool == NULL) { - RTE_LOG(ERR, LPM, "LPM tbl8 pool allocation failed: %s (%d)", - rte_strerror(rte_errno), rte_errno); + LPM_LOG(ERR, + "LPM tbl8 pool allocation failed: %s (%d)", + rte_strerror(rte_errno), rte_errno); rte_errno = ENOMEM; goto fail_wo_unlock; } @@ -300,8 +308,9 @@ rte_lpm6_create(const char *name, int socket_id, sizeof(struct rte_lpm_tbl8_hdr) * config->number_tbl8s, RTE_CACHE_LINE_SIZE); if (tbl8_hdrs == NULL) { - RTE_LOG(ERR, LPM, "LPM tbl8 headers allocation failed: %s (%d)", - rte_strerror(rte_errno), rte_errno); + LPM_LOG(ERR, + "LPM tbl8 headers allocation failed: %s (%d)", + rte_strerror(rte_errno), rte_errno); rte_errno = ENOMEM; goto fail_wo_unlock; } @@ -329,7 +338,7 @@ rte_lpm6_create(const char *name, int socket_id, /* allocate tailq entry */ te = rte_zmalloc("LPM6_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, LPM, "Failed to allocate tailq entry!\n"); + LPM_LOG(ERR, "Failed to allocate tailq entry!"); rte_errno = ENOMEM; goto fail; } @@ -339,7 +348,7 @@ rte_lpm6_create(const char *name, int socket_id, RTE_CACHE_LINE_SIZE, socket_id); if (lpm == NULL) { - RTE_LOG(ERR, LPM, "LPM memory allocation failed\n"); + LPM_LOG(ERR, "LPM memory allocation failed"); rte_free(te); rte_errno = ENOMEM; goto fail; diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c index b0794edf66f5..a81b4ed1cc04 100644 --- a/lib/rib/rte_rib.c +++ b/lib/rib/rte_rib.c @@ -15,6 +15,12 @@ #include +RTE_LOG_REGISTER_DEFAULT(rib_logtype, INFO); + +#define RIB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rib_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_rib_list, rte_tailq_entry); static struct rte_tailq_elem rte_rib_tailq = { .name = "RTE_RIB", @@ -412,8 +418,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf) NULL, NULL, NULL, NULL, socket_id, 0); if (node_pool == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate mempool for RIB %s\n", name); + RIB_LOG(ERR, "Can not allocate mempool for RIB %s", name); return NULL; } @@ -437,8 +442,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf) /* allocate tailq entry */ te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0); if (unlikely(te == NULL)) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for RIB %s\n", name); + RIB_LOG(ERR, "Can not allocate tailq entry for RIB %s", name); rte_errno = ENOMEM; goto exit; } @@ -447,7 +451,7 @@ rte_rib_create(const char *name, int socket_id, const struct rte_rib_conf *conf) rib = rte_zmalloc_socket(mem_name, sizeof(struct rte_rib), RTE_CACHE_LINE_SIZE, socket_id); if (unlikely(rib == NULL)) { - RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name); + RIB_LOG(ERR, "RIB %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c index 19e4ff97c479..39eba4d7032b 100644 --- a/lib/rib/rte_rib6.c +++ b/lib/rib/rte_rib6.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -15,6 +16,12 @@ #include +RTE_LOG_REGISTER_SUFFIX(rib6_logtype, "rib6", INFO); + +#define RIB_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rib6_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + #define RTE_RIB_VALID_NODE 1 #define RIB6_MAXDEPTH 128 /* Maximum length of a RIB6 name. */ @@ -481,8 +488,7 @@ rte_rib6_create(const char *name, int socket_id, NULL, NULL, NULL, NULL, socket_id, 0); if (node_pool == NULL) { - RTE_LOG(ERR, LPM, - "Can not allocate mempool for RIB6 %s\n", name); + RIB_LOG(ERR, "Can not allocate mempool for RIB6 %s", name); return NULL; } @@ -506,8 +512,8 @@ rte_rib6_create(const char *name, int socket_id, /* allocate tailq entry */ te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0); if (unlikely(te == NULL)) { - RTE_LOG(ERR, LPM, - "Can not allocate tailq entry for RIB6 %s\n", name); + RIB_LOG(ERR, + "Can not allocate tailq entry for RIB6 %s", name); rte_errno = ENOMEM; goto exit; } @@ -516,7 +522,7 @@ rte_rib6_create(const char *name, int socket_id, rib = rte_zmalloc_socket(mem_name, sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id); if (unlikely(rib == NULL)) { - RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name); + RIB_LOG(ERR, "RIB6 %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; } From patchwork Tue Feb 7 23:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123400 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 1064C41C34; Wed, 8 Feb 2023 00:06:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E901D42DA2; Wed, 8 Feb 2023 00:05:25 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id A192B42BC9 for ; Wed, 8 Feb 2023 00:05:20 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id rm7-20020a17090b3ec700b0022c05558d22so360110pjb.5 for ; Tue, 07 Feb 2023 15:05:20 -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=F63Q3+OzR2yVFeUNq5eBJMBVmfpDBbBM8IfALOhQmPw=; b=FjAAoNpyuqekKYa9VoH6QycZ/evTgYkXLwJ68cNfwJAgwLk9GZJi34y3gxnAL7QEbK ixrN0w/Snk13qDZUCvFQJ3j47BTP7hV0GpnGDE1ytBH4RjXwvtfqMEiQ6l0jEHFZRBds e5h16vjZpCzFLJg/eD67sXHwfJmw7P6Nx30ChNLwA6JT+xTT6tz5H9WiYZiXLO05faui b5C37Mp9SEpRFSIrgh5JPE+NTkrqP9HqbcumtfAwzqDaMEVk+JGYa6fuYQJn3xwycc4l +VB+f5vzVWnXdb+9yOF1ll4O3jlNhzaaiWilyBLhEs1rcDKfheyeLO8TCDVnOHCINuAo HVUA== 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=F63Q3+OzR2yVFeUNq5eBJMBVmfpDBbBM8IfALOhQmPw=; b=A/xNesUa4ieYfdb1cdnPoDgKgKrAfZgJMCIbwvLsRZgExWzhrr6NRkePE4yB00Kz9T syujTk2dwHJWW/hfUyZT5la8CSSDCyWh0IU+xpo0pYMueE/0XP0Kr2aqGWo73UzItN8H S2J5o5r0nhydLrRQKfwhfxQqPm4dtl5yX9zr6IUdiFnQhArbxnXbhUO26GNQy70nBjR7 svluN2+pE/LawecZJaEdK+dY0H827WTTRv4Myl8Rptb/Ny6UD5sc0iMzMVWtBgakmkfQ mUqhil2PRc//SarGM0u3DttK9gb2Wl6l9r6fhg9dEYi+dv1luKSGsulkvTrMrkGPxnWm 7g7Q== X-Gm-Message-State: AO0yUKVCfR9N0/pXM/7I4SoXuDe4uP52js2hMbdj4OcMhAYZp+0+aqRV jQV3PZ0MNGstXbcMV+zkmBOKSbssa5KQix9JYDI= X-Google-Smtp-Source: AK7set94GAae4TNTIiBRXosG88rNhRWBJiWFq5o9KW96U6WVy368SgCBrs09Q705IPe4p0BiQ/bLDg== X-Received: by 2002:a17:90b:3847:b0:22b:f214:a919 with SMTP id nl7-20020a17090b384700b0022bf214a919mr5779093pjb.49.1675811119590; Tue, 07 Feb 2023 15:05:19 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:19 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC v2 14/17] kni: replace RTE_LOGTYPE_KNI with dynamic type Date: Tue, 7 Feb 2023 15:04:35 -0800 Message-Id: <20230207230438.1617331-15-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Even though KNI will eventually disappear, fix the logtype now. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/kni/rte_kni.c | 63 ++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index ff250b9a6d56..b0c625a02cdf 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, - {RTE_LOGTYPE_KNI, "lib.kni"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 55067efb0a84..69d3d07252ec 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -34,7 +34,7 @@ extern "C" { #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ /* was RTE_LOGTYPE_LPM */ -#define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ + /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ /* was RTE_LOGTYPE_POWER */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c index 8ab6c4715314..baf732017a43 100644 --- a/lib/kni/rte_kni.c +++ b/lib/kni/rte_kni.c @@ -92,15 +92,20 @@ static void kni_allocate_mbufs(struct rte_kni *kni); static volatile int kni_fd = -1; +RTE_LOG_REGISTER_SUFFIX(kni_logtype, "kni", INFO); + +#define KNI_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, kni_logtype, fmt, ## args) + /* Shall be called before any allocation happens */ int rte_kni_init(unsigned int max_kni_ifaces __rte_unused) { - RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n"); + KNI_LOG(WARNING, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) if (rte_eal_iova_mode() != RTE_IOVA_PA) { - RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n"); + KNI_LOG(ERR, "KNI requires IOVA as PA\n"); return -1; } #endif @@ -109,7 +114,7 @@ rte_kni_init(unsigned int max_kni_ifaces __rte_unused) if (kni_fd < 0) { kni_fd = open("/dev/" KNI_DEVICE, O_RDWR); if (kni_fd < 0) { - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Can not open /dev/%s\n", KNI_DEVICE); return -1; } @@ -225,7 +230,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, /* Check if KNI subsystem has been initialized */ if (kni_fd < 0) { - RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n"); + KNI_LOG(ERR, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n"); return NULL; } @@ -233,19 +238,19 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, kni = __rte_kni_get(conf->name); if (kni != NULL) { - RTE_LOG(ERR, KNI, "KNI already exists\n"); + KNI_LOG(ERR, "KNI already exists\n"); goto unlock; } te = rte_zmalloc("KNI_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, KNI, "Failed to allocate tailq entry\n"); + KNI_LOG(ERR, "Failed to allocate tailq entry\n"); goto unlock; } kni = rte_zmalloc("KNI", sizeof(struct rte_kni), RTE_CACHE_LINE_SIZE); if (kni == NULL) { - RTE_LOG(ERR, KNI, "KNI memory allocation failed\n"); + KNI_LOG(ERR, "KNI memory allocation failed\n"); goto kni_fail; } @@ -424,7 +429,7 @@ rte_kni_release(struct rte_kni *kni) strlcpy(dev_info.name, kni->name, sizeof(dev_info.name)); if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) { - RTE_LOG(ERR, KNI, "Fail to release kni device\n"); + KNI_LOG(ERR, "Fail to release kni device\n"); goto unlock; } @@ -439,7 +444,7 @@ rte_kni_release(struct rte_kni *kni) usleep(1000); if (kni_fifo_count(kni->rx_q)) - RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n"); + KNI_LOG(ERR, "Fail to free all Rx-q items\n"); kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q); kni_free_fifo(kni->tx_q); @@ -466,16 +471,16 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[]) int ret = 0; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id); + KNI_LOG(INFO, "Configure mac address of %d", port_id); ret = rte_eth_dev_default_mac_addr_set(port_id, (struct rte_ether_addr *)mac_addr); if (ret < 0) - RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n", + KNI_LOG(ERR, "Failed to config mac_addr for port %d\n", port_id); return ret; @@ -488,11 +493,11 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) int ret; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n", + KNI_LOG(INFO, "Configure promiscuous mode of %d to %d\n", port_id, to_on); if (to_on) @@ -501,7 +506,7 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) ret = rte_eth_promiscuous_disable(port_id); if (ret != 0) - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Failed to %s promiscuous mode for port %u: %s\n", to_on ? "enable" : "disable", port_id, rte_strerror(-ret)); @@ -516,11 +521,11 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on) int ret; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure allmulticast mode of %d to %d\n", + KNI_LOG(INFO, "Configure allmulticast mode of %d to %d\n", port_id, to_on); if (to_on) @@ -528,7 +533,7 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on) else ret = rte_eth_allmulticast_disable(port_id); if (ret != 0) - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Failed to %s allmulticast mode for port %u: %s\n", to_on ? "enable" : "disable", port_id, rte_strerror(-ret)); @@ -551,7 +556,7 @@ rte_kni_handle_request(struct rte_kni *kni) return 0; /* It is OK of can not getting the request mbuf */ if (req != kni->sync_addr) { - RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req); + KNI_LOG(ERR, "Wrong req pointer %p\n", req); return -1; } @@ -592,7 +597,7 @@ rte_kni_handle_request(struct rte_kni *kni) kni->ops.port_id, req->allmulti); break; default: - RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id); + KNI_LOG(ERR, "Unknown request id %u\n", req->req_id); req->result = -EINVAL; break; } @@ -603,7 +608,7 @@ rte_kni_handle_request(struct rte_kni *kni) else ret = 1; if (ret != 1) { - RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n"); + KNI_LOG(ERR, "Fail to put the muf back to resp_q\n"); return -1; /* It is an error of can't putting the mbuf back */ } @@ -679,7 +684,7 @@ kni_allocate_mbufs(struct rte_kni *kni) /* Check if pktmbuf pool has been configured */ if (kni->pktmbuf_pool == NULL) { - RTE_LOG(ERR, KNI, "No valid mempool for allocating mbufs\n"); + KNI_LOG(ERR, "No valid mempool for allocating mbufs\n"); return; } @@ -690,7 +695,7 @@ kni_allocate_mbufs(struct rte_kni *kni) pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); if (unlikely(pkts[i] == NULL)) { /* Out of memory */ - RTE_LOG(ERR, KNI, "Out of memory\n"); + KNI_LOG(ERR, "Out of memory\n"); break; } phys[i] = va2pa(pkts[i]); @@ -757,18 +762,18 @@ rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops) enum kni_ops_status req_status; if (ops == NULL) { - RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n"); + KNI_LOG(ERR, "Invalid KNI request operation.\n"); return -1; } if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); + KNI_LOG(ERR, "Invalid kni info.\n"); return -1; } req_status = kni_check_request_register(&kni->ops); if (req_status == KNI_REQ_REGISTERED) { - RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n"); + KNI_LOG(ERR, "The KNI request operation has already registered.\n"); return -1; } @@ -780,7 +785,7 @@ int rte_kni_unregister_handlers(struct rte_kni *kni) { if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); + KNI_LOG(ERR, "Invalid kni info.\n"); return -1; } @@ -806,7 +811,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) fd = open(path, O_RDWR); if (fd == -1) { - RTE_LOG(ERR, KNI, "Failed to open file: %s.\n", path); + KNI_LOG(ERR, "Failed to open file: %s.\n", path); return -1; } @@ -823,7 +828,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) new_carrier = linkup ? "1" : "0"; ret = write(fd, new_carrier, 1); if (ret < 1) { - RTE_LOG(ERR, KNI, "Failed to write file: %s.\n", path); + KNI_LOG(ERR, "Failed to write file: %s.\n", path); close(fd); return -1; } From patchwork Tue Feb 7 23:04:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123401 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 0E4FA41C34; Wed, 8 Feb 2023 00:07:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EC90142DB3; Wed, 8 Feb 2023 00:05:27 +0100 (CET) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id E81DC42BC9 for ; Wed, 8 Feb 2023 00:05:21 +0100 (CET) Received: by mail-pl1-f173.google.com with SMTP id k13so17362845plg.0 for ; Tue, 07 Feb 2023 15:05:21 -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=h7vvkXOOqJ++uZx/DPmlrAKTzmYsK82YUCjmSnus9Pc=; b=ejt7PaPXrGk4g4TakvrZYUY5R9rhSg3p/WC/wr21Zy8kfldXmQN4Oyf2i9Vnp32bDi jOO8nqOtL4SBPLdXJ26UU1ysEm3VE90wbeSQke2+L+ZvMPeSIT5BhbBVljNNDIncgAdz TNDLKmaNzEAPnJw7FPYP8rtdz9hnBlgJY6IBrE9aZj6WXFtMxEsA7qdYf4mYoCDz+Zd3 sxsKwwqLmg5gVzhRMIhj1S8OZNQQfRlnZ5HCRvJ8386iWz9nnf6SSLoyNovqQ/dDqg3f GQ5pghd7LN95gdVax+qgV0+fsCGq+Vb7/0wyoa6tCdgKF60H6ROg2ZhxeGWfhR7dKZl6 tMkA== 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=h7vvkXOOqJ++uZx/DPmlrAKTzmYsK82YUCjmSnus9Pc=; b=3JKxcAI33PmRD841btpEp0zQWue5It8jkMlb2lVaVE0r3ciUB6fasMTNQLc3jB4QhZ oTlhzt2qUQetM0yjVqrpJf1Vn5AOZGdhWEtnTOw4H82Gcm3kAvlInq8W4Nyzr5+49gDz DfCOx+Qs86XeQS8fVwSeRFSn5uoC5QZvpmiKiQhy4EPbXErqufO2UIKzQUoZAJlFoFlk Pb8iOSxuR8lAG8760r4M9IDIzuqX6qnBl6b0FRTyONKJnZee1NMFh//ZTUClgHSIoBAh n4tAnzOrA8+3jTYrUu/vQofByJ4rMft+FPQ6xkUfGVXCVBR0yt/1a2GsBISlEkYXvGxw 85dQ== X-Gm-Message-State: AO0yUKVtusYOC4SKjrjVapU6jcIO8dmUon/RLYWeHQjd+Bmv9xCURRl9 MwutfzTBj9Gna/NpdiXlvw2nLHOI02or+zrReDE= X-Google-Smtp-Source: AK7set8E33ckHO8W4E04ZUv9ug9NRZrs6d0tSq1uLnTZfeqWUkr3XwK3RIOApNoKJ8fT/kvrWzQhwA== X-Received: by 2002:a17:90b:3908:b0:22c:6238:ad0c with SMTP id ob8-20020a17090b390800b0022c6238ad0cmr6306903pjb.24.1675811120715; Tue, 07 Feb 2023 15:05:20 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:20 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [RFC v2 15/17] hash: replace RTE_LOGTYPE_HASH with dynamic type Date: Tue, 7 Feb 2023 15:04:36 -0800 Message-Id: <20230207230438.1617331-16-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 A little more complex here since the one hash library actually has multiple routines in it. Split up the logtypes for hash and toeplitz. The hash crc file has another issue around logging. It is calling RTE_LOG during a constructor which is maybe problematic because this will all run before the DPDK library has finished initializing logging. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/hash/rte_cuckoo_hash.c | 60 ++++++++++++++++++--------------- lib/hash/rte_fbk_hash.c | 10 ++++-- lib/hash/rte_hash_crc.h | 6 ++-- lib/hash/rte_thash.c | 53 ++++++++++++++++++++++------- lib/hash/rte_thash_gfni.h | 24 ++++--------- lib/hash/version.map | 4 +++ 8 files changed, 95 insertions(+), 65 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index b0c625a02cdf..97120543d808 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_HASH, "lib.hash"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 69d3d07252ec..afbd67d55b45 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -32,7 +32,7 @@ extern "C" { /* was RTE_LOGTYPE_MEMPOOL */ /* was RTE_LOGTYPE_TIMER */ #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ -#define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ + /* was RTE_LOGTYPE_HASH */ /* was RTE_LOGTYPE_LPM */ /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 829b79c89a27..607aa9c8d04c 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -26,6 +26,12 @@ #include "rte_hash.h" #include "rte_cuckoo_hash.h" +RTE_LOG_REGISTER_SUFFIX(hash_logtype, "hash", INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, hash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + /* Mask of all flags supported by this version */ #define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \ RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \ @@ -159,7 +165,7 @@ rte_hash_create(const struct rte_hash_parameters *params) hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list); if (params == NULL) { - RTE_LOG(ERR, HASH, "rte_hash_create has no parameters\n"); + HASH_LOG(ERR, "null parameters"); return NULL; } @@ -168,13 +174,13 @@ rte_hash_create(const struct rte_hash_parameters *params) (params->entries < RTE_HASH_BUCKET_ENTRIES) || (params->key_len == 0)) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n"); + HASH_LOG(ERR, "invalid parameters"); return NULL; } if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n"); + HASH_LOG(ERR, "unsupported extra flags"); return NULL; } @@ -182,8 +188,8 @@ rte_hash_create(const struct rte_hash_parameters *params) if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) && (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) { rte_errno = EINVAL; - RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or " - "rw concurrency lock free\n"); + HASH_LOG(ERR, + "choose rw concurrency or rw concurrency lock free"); return NULL; } @@ -233,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params) r = rte_ring_create_elem(ring_name, sizeof(uint32_t), rte_align32pow2(num_key_slots), params->socket_id, 0); if (r == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err; } @@ -249,8 +255,8 @@ rte_hash_create(const struct rte_hash_parameters *params) params->socket_id, 0); if (r_ext == NULL) { - RTE_LOG(ERR, HASH, "ext buckets memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext buckets memory allocation failed"); goto err; } } @@ -275,7 +281,7 @@ rte_hash_create(const struct rte_hash_parameters *params) te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, "tailq entry allocation failed\n"); + HASH_LOG(ERR, "tailq entry allocation failed"); goto err_unlock; } @@ -283,7 +289,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (h == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -292,7 +298,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (buckets == NULL) { - RTE_LOG(ERR, HASH, "buckets memory allocation failed\n"); + HASH_LOG(ERR, "buckets memory allocation failed"); goto err_unlock; } @@ -302,8 +308,8 @@ rte_hash_create(const struct rte_hash_parameters *params) num_buckets * sizeof(struct rte_hash_bucket), RTE_CACHE_LINE_SIZE, params->socket_id); if (buckets_ext == NULL) { - RTE_LOG(ERR, HASH, "ext buckets memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext buckets memory allocation failed"); goto err_unlock; } /* Populate ext bkt ring. We reserve 0 similar to the @@ -318,8 +324,8 @@ rte_hash_create(const struct rte_hash_parameters *params) ext_bkt_to_free = rte_zmalloc(NULL, sizeof(uint32_t) * num_key_slots, 0); if (ext_bkt_to_free == NULL) { - RTE_LOG(ERR, HASH, "ext bkt to free memory allocation " - "failed\n"); + HASH_LOG(ERR, + "ext bkt to free memory allocation failed"); goto err_unlock; } } @@ -334,7 +340,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (k == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -342,7 +348,7 @@ rte_hash_create(const struct rte_hash_parameters *params) RTE_CACHE_LINE_SIZE, params->socket_id); if (tbl_chng_cnt == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); goto err_unlock; } @@ -390,7 +396,7 @@ rte_hash_create(const struct rte_hash_parameters *params) sizeof(struct lcore_cache) * RTE_MAX_LCORE, RTE_CACHE_LINE_SIZE, params->socket_id); if (local_free_slots == NULL) { - RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n"); + HASH_LOG(ERR, "local free slots memory allocation failed"); goto err_unlock; } } @@ -624,7 +630,7 @@ rte_hash_reset(struct rte_hash *h) /* Reclaim all the resources */ rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL); if (pending != 0) - RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n"); + HASH_LOG(ERR, "RCU reclaim all resources failed"); } memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket)); @@ -1498,9 +1504,8 @@ __hash_rcu_qsbr_free_resource(void *p, void *e, unsigned int n) /* Return key indexes to free slot ring */ ret = free_slot(h, rcu_dq_entry.key_idx); if (ret < 0) { - RTE_LOG(ERR, HASH, - "%s: could not enqueue free slots in global ring\n", - __func__); + HASH_LOG(ERR, + "could not enqueue free slots in global ring"); } } @@ -1527,7 +1532,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg) hash_rcu_cfg = rte_zmalloc(NULL, sizeof(struct rte_hash_rcu_config), 0); if (hash_rcu_cfg == NULL) { - RTE_LOG(ERR, HASH, "memory allocation failed\n"); + HASH_LOG(ERR, "memory allocation failed"); return 1; } @@ -1551,7 +1556,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg) h->dq = rte_rcu_qsbr_dq_create(¶ms); if (h->dq == NULL) { rte_free(hash_rcu_cfg); - RTE_LOG(ERR, HASH, "HASH defer queue creation failed\n"); + HASH_LOG(ERR, "HASH defer queue creation failed"); return 1; } } else { @@ -1580,9 +1585,8 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, int ret = free_slot(h, bkt->key_idx[i]); if (ret < 0) { - RTE_LOG(ERR, HASH, - "%s: could not enqueue free slots in global ring\n", - __func__); + HASH_LOG(ERR, + "could not enqueue free slots in global ring"); } } @@ -1770,7 +1774,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, } else if (h->dq) /* Push into QSBR FIFO if using RTE_HASH_QSBR_MODE_DQ */ if (rte_rcu_qsbr_dq_enqueue(h->dq, &rcu_dq_entry) != 0) - RTE_LOG(ERR, HASH, "Failed to push QSBR FIFO\n"); + HASH_LOG(ERR, "Failed to push QSBR FIFO"); } __hash_rw_writer_unlock(h); return ret; diff --git a/lib/hash/rte_fbk_hash.c b/lib/hash/rte_fbk_hash.c index 538b23a4030a..7a0e4272ffa9 100644 --- a/lib/hash/rte_fbk_hash.c +++ b/lib/hash/rte_fbk_hash.c @@ -18,6 +18,12 @@ #include "rte_fbk_hash.h" +RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, "hash.fbk", INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, fbk_hash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry); static struct rte_tailq_elem rte_fbk_hash_tailq = { @@ -114,7 +120,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params) te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, "Failed to allocate tailq entry\n"); + HASH_LOG(ERR, "Failed to allocate tailq entry"); goto exit; } @@ -122,7 +128,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params) ht = rte_zmalloc_socket(hash_name, mem_size, 0, params->socket_id); if (ht == NULL) { - RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n"); + HASH_LOG(ERR, "Failed to allocate fbk hash table"); rte_free(te); goto exit; } diff --git a/lib/hash/rte_hash_crc.h b/lib/hash/rte_hash_crc.h index 0249ad16c5b6..3bb38880c4ea 100644 --- a/lib/hash/rte_hash_crc.h +++ b/lib/hash/rte_hash_crc.h @@ -63,7 +63,7 @@ rte_hash_crc_set_alg(uint8_t alg) #if defined RTE_ARCH_X86 if (!(alg & CRC32_SSE42_x64)) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n"); if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42) crc32_alg = CRC32_SSE42; @@ -73,14 +73,14 @@ rte_hash_crc_set_alg(uint8_t alg) #if defined RTE_ARCH_ARM64 if (!(alg & CRC32_ARM64)) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_ARM64\n"); if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32)) crc32_alg = CRC32_ARM64; #endif if (crc32_alg == CRC32_SW) - RTE_LOG(WARNING, HASH, + fprintf(stderr, "Unsupported CRC32 algorithm requested using CRC32_SW\n"); } diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 0249883b8d07..cb94f77f1f9b 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -13,6 +13,12 @@ #include #include +RTE_LOG_REGISTER_SUFFIX(rte_thash_logtype, "thash", INFO); + +#define HASH_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, rte_thash_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + #define THASH_NAME_LEN 64 #define TOEPLITZ_HASH_LEN 32 @@ -104,6 +110,28 @@ rte_thash_gfni_supported(void) return 0; }; +#ifndef RTE_THASH_GFNI_DEFINED +uint32_t +rte_thash_gfni(const uint64_t *mtrx __rte_unused, + const uint8_t *key __rte_unused, int len __rte_unused) +{ + HASH_LOG(ERR, "is undefined under given arch"); + return 0; +} + +void +rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused, + int len __rte_unused, uint8_t *tuple[] __rte_unused, + uint32_t val[], uint32_t num) +{ + unsigned int i; + + HASH_LOG(ERR, "is undefined under given arch"); + for (i = 0; i < num; i++) + val[i] = 0; +} +#endif + void rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size) { @@ -240,8 +268,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, /* allocate tailq entry */ te = rte_zmalloc("THASH_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, HASH, - "Can not allocate tailq entry for thash context %s\n", + HASH_LOG(ERR, + "Can not allocate tailq entry for thash context %s", name); rte_errno = ENOMEM; goto exit; @@ -249,7 +277,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0); if (ctx == NULL) { - RTE_LOG(ERR, HASH, "thash ctx %s memory allocation failed\n", + HASH_LOG(ERR, + "thash ctx %s memory allocation failed", name); rte_errno = ENOMEM; goto free_te; @@ -272,7 +301,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t), RTE_CACHE_LINE_SIZE); if (ctx->matrices == NULL) { - RTE_LOG(ERR, HASH, "Cannot allocate matrices\n"); + HASH_LOG(ERR, "Cannot allocate matrices"); rte_errno = ENOMEM; goto free_ctx; } @@ -387,8 +416,8 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr, if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) && ((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) != RTE_THASH_IGNORE_PERIOD_OVERFLOW)) { - RTE_LOG(ERR, HASH, - "Can't generate m-sequence due to period overflow\n"); + HASH_LOG(ERR, + "Can't generate m-sequence due to period overflow"); return -ENOSPC; } @@ -467,9 +496,9 @@ insert_before(struct rte_thash_ctx *ctx, return ret; } } else if ((next_ent != NULL) && (end > next_ent->offset)) { - RTE_LOG(ERR, HASH, - "Can't add helper %s due to conflict with existing" - " helper %s\n", ent->name, next_ent->name); + HASH_LOG(ERR, + "Can't add helper %s due to conflict with existing helper %s", + ent->name, next_ent->name); rte_free(ent); return -ENOSPC; } @@ -516,9 +545,9 @@ insert_after(struct rte_thash_ctx *ctx, int ret; if ((next_ent != NULL) && (end > next_ent->offset)) { - RTE_LOG(ERR, HASH, - "Can't add helper %s due to conflict with existing" - " helper %s\n", ent->name, next_ent->name); + HASH_LOG(ERR, + "Can't add helper %s due to conflict with existing helper %s", + ent->name, next_ent->name); rte_free(ent); return -EEXIST; } diff --git a/lib/hash/rte_thash_gfni.h b/lib/hash/rte_thash_gfni.h index ef90faa302d1..c3a5cf7e7b2d 100644 --- a/lib/hash/rte_thash_gfni.h +++ b/lib/hash/rte_thash_gfni.h @@ -38,13 +38,8 @@ extern "C" { * Calculated Toeplitz hash value. */ __rte_experimental -static inline uint32_t -rte_thash_gfni(const uint64_t *mtrx __rte_unused, - const uint8_t *key __rte_unused, int len __rte_unused) -{ - RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__); - return 0; -} +uint32_t +rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len); /** * Bulk implementation for Toeplitz hash. @@ -67,17 +62,10 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused, * Number of tuples to hash. */ __rte_experimental -static inline void -rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused, - int len __rte_unused, uint8_t *tuple[] __rte_unused, - uint32_t val[], uint32_t num) -{ - unsigned int i; - - RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__); - for (i = 0; i < num; i++) - val[i] = 0; -} +void +rte_thash_gfni_bulk(const uint64_t *mtrx, + int len, uint8_t *tuple[], + uint32_t val[], uint32_t num); #endif /* RTE_THASH_GFNI_DEFINED */ diff --git a/lib/hash/version.map b/lib/hash/version.map index bdcebd19c29b..c30ac81307a7 100644 --- a/lib/hash/version.map +++ b/lib/hash/version.map @@ -51,4 +51,8 @@ EXPERIMENTAL { rte_thash_complete_matrix; rte_thash_get_gfni_matrices; rte_thash_gfni_supported; + + # added in 23.07 + rte_thash_gfni; + rte_thash_gfni_bulk; }; From patchwork Tue Feb 7 23:04:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 123402 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 8D53541C34; Wed, 8 Feb 2023 00:07:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41FA642DA5; Wed, 8 Feb 2023 00:05:29 +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 559C642D73 for ; Wed, 8 Feb 2023 00:05:23 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id e10-20020a17090a630a00b0022bedd66e6dso377997pjj.1 for ; Tue, 07 Feb 2023 15:05:23 -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=Z+wmaSSoy8aaI5pi1EkqvTqOEEno0t2lQiUQebYpykc=; b=wKrsXw01rdYPOYG9is6pG9tBWw1Vfnoj4ZD5yZhqIMk4DuWi7v/oImcIFI12YKu1F3 ACUn6WsbtwttOk5KtDwWN9fo6PMi295rZ/5XDLDeb7GPFszR4U375M5yNWElAYhJLHhj e70kSYWGAfeWKs1CPXUZ3VXAGPC/NpzMjS6quMl0Jd4PC3YmG3ccSDY7zokN5+bb1B2x 6XZdylw2yGjM3aE1YsZDaGXa51VjJg77sDXyYsHHRXxlFnuNZJoa0LKqh4OXmcMXp1Dj P/K58EFW7C5SkMFyNOn5wRgDnyDvbaHzEpcP8nQcPC6y+QZYG43IQltqvxjHp8XWhe9R yG1w== 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=Z+wmaSSoy8aaI5pi1EkqvTqOEEno0t2lQiUQebYpykc=; b=t+fNtO04Sa7nsXKprC9dSuuYIKeNHo24l5HmY94EpDZustLgjyzbQcTF1YxcL5XsUy 8EDbh+BRw9qYb4Cp6uSqeSqKbWSfPFeJkBKOSf6VDcSyvUU6Fzoq94rm/pCxehJYfCoX 0qGZg5qVnaHTWl3TUa+YEXcfRVUg7wIuaOHoiJzRd/HlTJlLnJLc8zMgEKEQBprT7Eoh pi8Mr1vuLpKf3h7I2sisvbUmzG/neAAvK54uVYV7VmDyoKLfGONI8ZDVfh+yDAqXYgMX hhI35sV8/dFaAgCsyZNIYGwSp4MYr9CwioGwDu4EYx3HoXF84/wgkjD2KPJffgU41L+P 0++w== X-Gm-Message-State: AO0yUKWvKtnG3/0GkpmpeI3dDIrpk7fI/fBrMb06yLuVtAXKoYkgoux2 dwId0HA7m+E7YoHn+ESmvEf9CXOjPx9mLf0qZAA= X-Google-Smtp-Source: AK7set/VYNYbNuVuocpnlOnpkqPoDuA3VU0mN4lXf+2fMGZ7KoOoEGW4LKp+H3LDx86YQaT5LCikHQ== X-Received: by 2002:a17:90a:1906:b0:230:7a31:b9ac with SMTP id 6-20020a17090a190600b002307a31b9acmr6009363pjg.48.1675811121792; Tue, 07 Feb 2023 15:05:21 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:21 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [RFC v2 16/17] sched: replace RTE_LOGTYPE_SCHED with dynamic type Date: Tue, 7 Feb 2023 15:04:37 -0800 Message-Id: <20230207230438.1617331-17-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Also can remove unused RTE_LOGTYPE_METER Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 2 - lib/eal/include/rte_log.h | 4 +- lib/sched/rte_pie.c | 16 +- lib/sched/rte_sched.c | 297 +++++++++++++------------------- lib/sched/rte_sched_log.h | 11 ++ 5 files changed, 140 insertions(+), 190 deletions(-) create mode 100644 lib/sched/rte_sched_log.h diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 97120543d808..212ccda0a6e8 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,8 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_METER, "lib.meter"}, - {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index afbd67d55b45..a1549b372767 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -37,8 +37,8 @@ extern "C" { /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ /* was RTE_LOGTYPE_POWER */ -#define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ -#define RTE_LOGTYPE_SCHED 12 /**< Log related to QoS port scheduler. */ + /* was RTE_LOGTYPE_METER */ + /* was RTE_LOGTYPE_SCHED */ #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. */ diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c index 947e2a059f6f..28ed01e8f11d 100644 --- a/lib/sched/rte_pie.c +++ b/lib/sched/rte_pie.c @@ -6,6 +6,8 @@ #include #include +#include "rte_sched_log.h" + #include "rte_pie.h" #ifdef __INTEL_COMPILER @@ -16,7 +18,7 @@ int rte_pie_rt_data_init(struct rte_pie *pie) { if (pie == NULL) { - RTE_LOG(ERR, SCHED, "%s: Invalid addr for pie\n", __func__); + SCHED_LOG(ERR, "Invalid addr for pie"); return -EINVAL; } @@ -38,26 +40,22 @@ rte_pie_config_init(struct rte_pie_config *pie_cfg, return -1; if (qdelay_ref <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for qdelay_ref\n", __func__); + SCHED_LOG(ERR, "Incorrect value for qdelay_ref"); return -EINVAL; } if (dp_update_interval <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for dp_update_interval\n", __func__); + SCHED_LOG(ERR, "Incorrect value for dp_update_interval"); return -EINVAL; } if (max_burst <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for max_burst\n", __func__); + SCHED_LOG(ERR, "Incorrect value for max_burst"); return -EINVAL; } if (tailq_th <= 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tailq_th\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tailq_th"); return -EINVAL; } diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c index c91697131d3e..fd5bd38070fa 100644 --- a/lib/sched/rte_sched.c +++ b/lib/sched/rte_sched.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -17,6 +16,7 @@ #include "rte_sched.h" #include "rte_sched_common.h" +#include "rte_sched_log.h" #include "rte_approx.h" #ifdef __INTEL_COMPILER @@ -324,23 +324,20 @@ pipe_profile_check(struct rte_sched_pipe_params *params, /* Pipe parameters */ if (params == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } /* TB rate: non-zero, not greater than port rate */ if (params->tb_rate == 0 || params->tb_rate > rate) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tb rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb rate"); return -EINVAL; } /* TB size: non-zero */ if (params->tb_size == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tb size\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb size"); return -EINVAL; } @@ -349,38 +346,33 @@ pipe_profile_check(struct rte_sched_pipe_params *params, if ((qsize[i] == 0 && params->tc_rate[i] != 0) || (qsize[i] != 0 && (params->tc_rate[i] == 0 || params->tc_rate[i] > params->tb_rate))) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for qsize or tc_rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for qsize or tc_rate"); return -EINVAL; } } if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 || qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for be traffic class rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for be traffic class rate"); return -EINVAL; } /* TC period: non-zero */ if (params->tc_period == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc period\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc period"); return -EINVAL; } /* Best effort tc oversubscription weight: non-zero */ if (params->tc_ov_weight == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc ov weight\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc ov weight"); return -EINVAL; } /* Queue WRR weights: non-zero */ for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) { if (params->wrr_weights[i] == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for wrr weight\n", __func__); + SCHED_LOG(ERR, "Incorrect value for wrr weight"); return -EINVAL; } } @@ -396,20 +388,17 @@ subport_profile_check(struct rte_sched_subport_profile_params *params, /* Check user parameters */ if (params == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } if (params->tb_rate == 0 || params->tb_rate > rate) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tb rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb rate"); return -EINVAL; } if (params->tb_size == 0) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tb size\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tb size"); return -EINVAL; } @@ -417,21 +406,18 @@ subport_profile_check(struct rte_sched_subport_profile_params *params, uint64_t tc_rate = params->tc_rate[i]; if (tc_rate == 0 || (tc_rate > params->tb_rate)) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tc rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc rate"); return -EINVAL; } } if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect tc rate(best effort)\n", __func__); + SCHED_LOG(ERR, "Incorrect tc rate(best effort)"); return -EINVAL; } if (params->tc_period == 0) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for tc period\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc period"); return -EINVAL; } @@ -444,29 +430,25 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) uint32_t i; if (params == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } /* socket */ if (params->socket < 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for socket id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for socket id"); return -EINVAL; } /* rate */ if (params->rate == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for rate\n", __func__); + SCHED_LOG(ERR, "Incorrect value for rate"); return -EINVAL; } /* mtu */ if (params->mtu == 0) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for mtu\n", __func__); + SCHED_LOG(ERR, "Incorrect value for mtu"); return -EINVAL; } @@ -474,8 +456,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) if (params->n_subports_per_port == 0 || params->n_subports_per_port > 1u << 16 || !rte_is_power_of_2(params->n_subports_per_port)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for number of subports\n", __func__); + SCHED_LOG(ERR, "Incorrect value for number of subports"); return -EINVAL; } @@ -483,8 +464,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) params->n_subport_profiles == 0 || params->n_max_subport_profiles == 0 || params->n_subport_profiles > params->n_max_subport_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport profiles\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport profiles"); return -EINVAL; } @@ -495,9 +475,8 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) status = subport_profile_check(p, params->rate); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: subport profile check failed(%d)\n", - __func__, status); + SCHED_LOG(ERR, "subport profile check failed(%d)", + status); return -EINVAL; } } @@ -505,8 +484,7 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) /* n_pipes_per_subport: non-zero, power of 2 */ if (params->n_pipes_per_subport == 0 || !rte_is_power_of_2(params->n_pipes_per_subport)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for maximum pipes number\n", __func__); + SCHED_LOG(ERR, "Incorrect value for maximum pipes number"); return -EINVAL; } @@ -605,14 +583,15 @@ rte_sched_port_log_pipe_profile(struct rte_sched_subport *subport, uint32_t i) { struct rte_sched_pipe_profile *p = subport->pipe_profiles + i; - RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n" + SCHED_LOG(DEBUG, + "Low level config for pipe profile %u:\n" " Token bucket: period = %"PRIu64", credits per period = %"PRIu64", size = %"PRIu64"\n" " Traffic classes: period = %"PRIu64",\n" " credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 ", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 ", %"PRIu64", %"PRIu64", %"PRIu64"]\n" " Best-effort traffic class oversubscription: weight = %hhu\n" - " WRR cost: [%hhu, %hhu, %hhu, %hhu]\n", + " WRR cost: [%hhu, %hhu, %hhu, %hhu]", i, /* Token bucket */ @@ -648,35 +627,36 @@ rte_sched_port_log_subport_profile(struct rte_sched_port *port, uint32_t i) { struct rte_sched_subport_profile *p = port->subport_profiles + i; - RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n" - "Token bucket: period = %"PRIu64", credits per period = %"PRIu64"," - "size = %"PRIu64"\n" - "Traffic classes: period = %"PRIu64",\n" - "credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 - " %"PRIu64", %"PRIu64", %"PRIu64"]\n", - i, - - /* Token bucket */ - p->tb_period, - p->tb_credits_per_period, - p->tb_size, - - /* Traffic classes */ - p->tc_period, - p->tc_credits_per_period[0], - p->tc_credits_per_period[1], - p->tc_credits_per_period[2], - p->tc_credits_per_period[3], - p->tc_credits_per_period[4], - p->tc_credits_per_period[5], - p->tc_credits_per_period[6], - p->tc_credits_per_period[7], - p->tc_credits_per_period[8], - p->tc_credits_per_period[9], - p->tc_credits_per_period[10], - p->tc_credits_per_period[11], - p->tc_credits_per_period[12]); + SCHED_LOG(DEBUG, + "Low level config for subport profile %u:\n" + "Token bucket: period = %"PRIu64", credits per period = %"PRIu64"," + "size = %"PRIu64"\n" + "Traffic classes: period = %"PRIu64",\n" + "credits per period = [%"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 + " %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64", %"PRIu64 + " %"PRIu64", %"PRIu64", %"PRIu64"]", + i, + + /* Token bucket */ + p->tb_period, + p->tb_credits_per_period, + p->tb_size, + + /* Traffic classes */ + p->tc_period, + p->tc_credits_per_period[0], + p->tc_credits_per_period[1], + p->tc_credits_per_period[2], + p->tc_credits_per_period[3], + p->tc_credits_per_period[4], + p->tc_credits_per_period[5], + p->tc_credits_per_period[6], + p->tc_credits_per_period[7], + p->tc_credits_per_period[8], + p->tc_credits_per_period[9], + p->tc_credits_per_period[10], + p->tc_credits_per_period[11], + p->tc_credits_per_period[12]); } static inline uint64_t @@ -829,8 +809,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, /* Check user parameters */ if (params == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter params\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter params"); return -EINVAL; } @@ -841,14 +820,13 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, uint16_t qsize = params->qsize[i]; if (qsize != 0 && !rte_is_power_of_2(qsize)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for qsize\n", __func__); + SCHED_LOG(ERR, "Incorrect value for qsize"); return -EINVAL; } } if (params->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) { - RTE_LOG(ERR, SCHED, "%s: Incorrect qsize\n", __func__); + SCHED_LOG(ERR, "Incorrect qsize"); return -EINVAL; } @@ -856,8 +834,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, if (params->n_pipes_per_subport_enabled == 0 || params->n_pipes_per_subport_enabled > n_max_pipes_per_subport || !rte_is_power_of_2(params->n_pipes_per_subport_enabled)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for pipes number\n", __func__); + SCHED_LOG(ERR, "Incorrect value for pipes number"); return -EINVAL; } @@ -866,8 +843,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, params->n_pipe_profiles == 0 || params->n_max_pipe_profiles == 0 || params->n_pipe_profiles > params->n_max_pipe_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for pipe profiles\n", __func__); + SCHED_LOG(ERR, "Incorrect value for pipe profiles"); return -EINVAL; } @@ -877,8 +853,7 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params, status = pipe_profile_check(p, rate, ¶ms->qsize[0]); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Pipe profile check failed(%d)\n", __func__, status); + SCHED_LOG(ERR, "Pipe profile check failed(%d)", status); return -EINVAL; } } @@ -895,9 +870,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params, status = rte_sched_port_check_params(port_params); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Port scheduler port params check failed (%d)\n", - __func__, status); + SCHED_LOG(ERR, + "Port scheduler port params check failed (%d)", + status); return 0; } @@ -909,9 +884,9 @@ rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params, port_params->n_pipes_per_subport, port_params->rate); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Port scheduler subport params check failed (%d)\n", - __func__, status); + SCHED_LOG(ERR, + "Port scheduler subport params check failed (%d)", + status); return 0; } @@ -940,8 +915,7 @@ rte_sched_port_config(struct rte_sched_port_params *params) status = rte_sched_port_check_params(params); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Port scheduler params check failed (%d)\n", + SCHED_LOG(ERR, "Port scheduler params check failed (%d)\n", __func__, status); return NULL; } @@ -955,7 +929,7 @@ rte_sched_port_config(struct rte_sched_port_params *params) port = rte_zmalloc_socket("qos_params", size0 + size1, RTE_CACHE_LINE_SIZE, params->socket); if (port == NULL) { - RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); + SCHED_LOG(ERR, "Memory allocation fails"); return NULL; } @@ -964,7 +938,7 @@ rte_sched_port_config(struct rte_sched_port_params *params) port->subport_profiles = rte_zmalloc_socket("subport_profile", size2, RTE_CACHE_LINE_SIZE, params->socket); if (port->subport_profiles == NULL) { - RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); + SCHED_LOG(ERR, "Memory allocation fails"); rte_free(port); return NULL; } @@ -1106,8 +1080,7 @@ rte_sched_red_config(struct rte_sched_port *port, params->cman_params->red_params[i][j].maxp_inv) != 0) { rte_sched_free_memory(port, n_subports); - RTE_LOG(NOTICE, SCHED, - "%s: RED configuration init fails\n", __func__); + SCHED_LOG(NOTICE, "RED configuration init fails"); return -EINVAL; } } @@ -1126,8 +1099,7 @@ rte_sched_pie_config(struct rte_sched_port *port, for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) { if (params->cman_params->pie_params[i].tailq_th > params->qsize[i]) { - RTE_LOG(NOTICE, SCHED, - "%s: PIE tailq threshold incorrect\n", __func__); + SCHED_LOG(NOTICE, "PIE tailq threshold incorrect"); return -EINVAL; } @@ -1138,8 +1110,7 @@ rte_sched_pie_config(struct rte_sched_port *port, params->cman_params->pie_params[i].tailq_th) != 0) { rte_sched_free_memory(port, n_subports); - RTE_LOG(NOTICE, SCHED, - "%s: PIE configuration init fails\n", __func__); + SCHED_LOG(NOTICE, "PIE configuration init fails"); return -EINVAL; } } @@ -1170,14 +1141,12 @@ rte_sched_subport_tc_ov_config(struct rte_sched_port *port, struct rte_sched_subport *s; if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter subport id"); return -EINVAL; } @@ -1203,22 +1172,19 @@ rte_sched_subport_config(struct rte_sched_port *port, /* Check user parameters */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return 0; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport id"); ret = -EINVAL; goto out; } if (subport_profile_id >= port->n_max_subport_profiles) { - RTE_LOG(ERR, SCHED, "%s: " - "Number of subport profile exceeds the max limit\n", - __func__); + SCHED_LOG(ERR, + "Number of subport profile exceeds the max limit"); ret = -EINVAL; goto out; } @@ -1233,9 +1199,9 @@ rte_sched_subport_config(struct rte_sched_port *port, port->n_pipes_per_subport, port->rate); if (status != 0) { - RTE_LOG(NOTICE, SCHED, - "%s: Port scheduler params check failed (%d)\n", - __func__, status); + SCHED_LOG(NOTICE, + "Port scheduler params check failed (%d)", + status); ret = -EINVAL; goto out; } @@ -1249,8 +1215,7 @@ rte_sched_subport_config(struct rte_sched_port *port, s = rte_zmalloc_socket("subport_params", size0 + size1, RTE_CACHE_LINE_SIZE, port->socket); if (s == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Memory allocation fails\n", __func__); + SCHED_LOG(ERR, "Memory allocation fails"); ret = -ENOMEM; goto out; } @@ -1281,8 +1246,8 @@ rte_sched_subport_config(struct rte_sched_port *port, s->cman_enabled = true; status = rte_sched_cman_config(port, s, params, n_subports); if (status) { - RTE_LOG(NOTICE, SCHED, - "%s: CMAN configuration fails\n", __func__); + SCHED_LOG(NOTICE, + "CMAN configuration fails"); return status; } } else { @@ -1329,8 +1294,7 @@ rte_sched_subport_config(struct rte_sched_port *port, s->bmp = rte_bitmap_init(n_subport_pipe_queues, s->bmp_array, bmp_mem_size); if (s->bmp == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Subport bitmap init error\n", __func__); + SCHED_LOG(ERR, "Subport bitmap init error"); ret = -EINVAL; goto out; } @@ -1399,29 +1363,25 @@ rte_sched_pipe_config(struct rte_sched_port *port, deactivate = (pipe_profile < 0); if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter subport id"); ret = -EINVAL; goto out; } s = port->subports[subport_id]; if (pipe_id >= s->n_pipes_per_subport_enabled) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter pipe id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter pipe id"); ret = -EINVAL; goto out; } if (!deactivate && profile >= s->n_pipe_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter pipe profile\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter pipe profile"); ret = -EINVAL; goto out; } @@ -1446,9 +1406,9 @@ rte_sched_pipe_config(struct rte_sched_port *port, s->tc_ov = s->tc_ov_rate > subport_tc_be_rate; if (s->tc_ov != tc_be_ov) { - RTE_LOG(DEBUG, SCHED, - "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)\n", - subport_id, subport_tc_be_rate, s->tc_ov_rate); + SCHED_LOG(DEBUG, + "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)", + subport_id, subport_tc_be_rate, s->tc_ov_rate); } /* Reset the pipe */ @@ -1488,8 +1448,8 @@ rte_sched_pipe_config(struct rte_sched_port *port, s->tc_ov = s->tc_ov_rate > subport_tc_be_rate; if (s->tc_ov != tc_be_ov) { - RTE_LOG(DEBUG, SCHED, - "Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n", + SCHED_LOG(DEBUG, + "Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)", subport_id, subport_tc_be_rate, s->tc_ov_rate); } p->tc_ov_period_id = s->tc_ov_period_id; @@ -1517,15 +1477,13 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, /* Port */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } /* Subport id not exceeds the max limit */ if (subport_id > port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport id"); return -EINVAL; } @@ -1533,16 +1491,14 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, /* Pipe profiles exceeds the max limit */ if (s->n_pipe_profiles >= s->n_max_pipe_profiles) { - RTE_LOG(ERR, SCHED, - "%s: Number of pipe profiles exceeds the max limit\n", __func__); + SCHED_LOG(ERR, "Number of pipe profiles exceeds the max limit"); return -EINVAL; } /* Pipe params */ status = pipe_profile_check(params, port->rate, &s->qsize[0]); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: Pipe profile check failed(%d)\n", __func__, status); + SCHED_LOG(ERR, "Pipe profile check failed(%d)", status); return -EINVAL; } @@ -1552,8 +1508,7 @@ rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, /* Pipe profile should not exists */ for (i = 0; i < s->n_pipe_profiles; i++) if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) { - RTE_LOG(ERR, SCHED, - "%s: Pipe profile exists\n", __func__); + SCHED_LOG(ERR, "Pipe profile exists"); return -EINVAL; } @@ -1580,21 +1535,18 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port, /* Port */ if (port == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (params == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter profile\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter profile"); return -EINVAL; } if (subport_profile_id == NULL) { - RTE_LOG(ERR, SCHED, "%s: " - "Incorrect value for parameter subport_profile_id\n", - __func__); + SCHED_LOG(ERR, + "Incorrect value for parameter subport_profile_id"); return -EINVAL; } @@ -1602,16 +1554,14 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port, /* Subport profiles exceeds the max limit */ if (port->n_subport_profiles >= port->n_max_subport_profiles) { - RTE_LOG(ERR, SCHED, "%s: " - "Number of subport profiles exceeds the max limit\n", - __func__); + SCHED_LOG(ERR, + "Number of subport profiles exceeds the max limit"); return -EINVAL; } status = subport_profile_check(params, port->rate); if (status != 0) { - RTE_LOG(ERR, SCHED, - "%s: subport profile check failed(%d)\n", __func__, status); + SCHED_LOG(ERR, "subport profile check failed", status); return -EINVAL; } @@ -1621,8 +1571,7 @@ rte_sched_port_subport_profile_add(struct rte_sched_port *port, for (i = 0; i < port->n_subport_profiles; i++) if (memcmp(port->subport_profiles + i, dst, sizeof(*dst)) == 0) { - RTE_LOG(ERR, SCHED, - "%s: subport profile exists\n", __func__); + SCHED_LOG(ERR, "subport profile exists"); return -EINVAL; } @@ -1694,26 +1643,22 @@ rte_sched_subport_read_stats(struct rte_sched_port *port, /* Check user parameters */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (subport_id >= port->n_subports_per_port) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for subport id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for subport id"); return -EINVAL; } if (stats == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter stats\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter stats"); return -EINVAL; } if (tc_ov == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for tc_ov\n", __func__); + SCHED_LOG(ERR, "Incorrect value for tc_ov"); return -EINVAL; } @@ -1742,26 +1687,22 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, /* Check user parameters */ if (port == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter port\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter port"); return -EINVAL; } if (queue_id >= rte_sched_port_queues_per_port(port)) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for queue id\n", __func__); + SCHED_LOG(ERR, "Incorrect value for queue id"); return -EINVAL; } if (stats == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter stats\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter stats"); return -EINVAL; } if (qlen == NULL) { - RTE_LOG(ERR, SCHED, - "%s: Incorrect value for parameter qlen\n", __func__); + SCHED_LOG(ERR, "Incorrect value for parameter qlen"); return -EINVAL; } subport_qmask = port->n_pipes_per_subport_log2 + 4; @@ -3002,3 +2943,5 @@ rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint return count; } + +RTE_LOG_REGISTER_SUFFIX(sched_logtype, "sched", INFO); diff --git a/lib/sched/rte_sched_log.h b/lib/sched/rte_sched_log.h new file mode 100644 index 000000000000..cbf577faf2cb --- /dev/null +++ b/lib/sched/rte_sched_log.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + */ + +#include + +extern int sched_logtype; + +#define SCHED_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, sched_logtype, \ + "%s(): " fmt "\n", __func__, ##args) From patchwork Tue Feb 7 23:04: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: 123403 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 5C1AB41C34; Wed, 8 Feb 2023 00:07:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D80442DBF; Wed, 8 Feb 2023 00:05:30 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id A7482410D1 for ; Wed, 8 Feb 2023 00:05:24 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id d2so12909719pjd.5 for ; Tue, 07 Feb 2023 15:05:24 -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=/ig+6NW0tgcHV4HF37zqYNbmsNWy3JWoDvNbexM9/w8=; b=4FsH03HU7DsVatnlFn7vdzW6SAbQtPR3GntKjue1KI/pCAM0ZZzi29jEKI4nmJEsxk 1kiZpdGuwqyIP6cCL56yOmucaoP58w3JoTteH2F5tw4+3kQXWWxILLAkXAjZMo4JIo1y ZYwQIbvz6rabmngZU+7bmbUcTqSblc7p+hq6UPI0DfHKgYhjtM+Tq6PhQiz/q+nxzWos xzsjy42K0ufCxXC5qEbjUpuO4lenv8hObAK+P0vDpOvwOo+jCmnJpCaP9lV7ES1lDPUG UaN1VU0J2xtFeKj4RzcDIVbNLC3KzKT/PlBiK4JZMcG5zOeW4Bcgj95hxD7q7T6+tD5w dtoA== 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=/ig+6NW0tgcHV4HF37zqYNbmsNWy3JWoDvNbexM9/w8=; b=Heg+fkkLinf5Gy5fsTMWxwwcveW01fWPr9p826sA1MzI3Oxsr9grxA5U/9ulaFiKSs 4mFgCAaTRDnzm7Xztr47RSTuojy1YuwMb0CnIQvqmpRWi2rfGUJU3IQ35xJZNRhwLmgQ qVqBYmj2oVKKt95kifQrIghDzfnMX0B0F8mGP6i0lEHVGHtLDmZLK0qc6q6Os5wOg4bm WpOWGyye3GinmpeT+FDEmDMal6ZxSCgPQjzXX005+SYswvvE19Oezg+F0fPxqcyAMS8D rKiTDiZ0qQTFQEO76O+RYraUQ7lKbmnXaVKLZFYb0DEtYvB191kMxzNucf67Ml09VPfg uRwA== X-Gm-Message-State: AO0yUKV1gxe/F8GZm2ZLyT2vOqLgy1tdC9airBcyZg5RFsbGCrvFa89p o7+Ym84M3E4FHUUr6l/DH3KMP46K2Zldxak94j4= X-Google-Smtp-Source: AK7set8v+QFRja/ZmOeNs/+/vN3wrtEUJJLGVERbAvQqUywc74fkmlSaSM4J7p/6IB9JSQYGM3xZEg== X-Received: by 2002:a17:90b:1646:b0:230:c073:4d9e with SMTP id il6-20020a17090b164600b00230c0734d9emr5800638pjb.41.1675811122692; Tue, 07 Feb 2023 15:05:22 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:22 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [RFC v2 17/17] port: replace RTE_LOGTYPE_PORT with dynamic type Date: Tue, 7 Feb 2023 15:04:38 -0800 Message-Id: <20230207230438.1617331-18-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-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 Split up the single static RTE_LOGTYPE_PORT into seperate sub types for each component: port.ethdev, port.evendev, ... Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/port/rte_port_ethdev.c | 23 +++++---- lib/port/rte_port_eventdev.c | 23 +++++---- lib/port/rte_port_fd.c | 28 ++++++----- lib/port/rte_port_frag.c | 21 +++++---- lib/port/rte_port_kni.c | 22 +++++---- lib/port/rte_port_ras.c | 17 ++++--- lib/port/rte_port_ring.c | 22 +++++---- lib/port/rte_port_sched.c | 16 ++++--- lib/port/rte_port_source_sink.c | 82 +++++++++++++++++++-------------- lib/port/rte_port_sym_crypto.c | 22 +++++---- 12 files changed, 164 insertions(+), 115 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 212ccda0a6e8..7002e267be37 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -350,7 +350,6 @@ struct logtype { static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, - {RTE_LOGTYPE_PORT, "lib.port"}, {RTE_LOGTYPE_TABLE, "lib.table"}, {RTE_LOGTYPE_PIPELINE, "lib.pipeline"}, {RTE_LOGTYPE_CRYPTODEV, "lib.cryptodev"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index a1549b372767..ff714a703be7 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -39,7 +39,7 @@ extern "C" { /* was RTE_LOGTYPE_POWER */ /* was RTE_LOGTYPE_METER */ /* was RTE_LOGTYPE_SCHED */ -#define RTE_LOGTYPE_PORT 13 /**< Log related to port. */ + /* was RTE_LOGTYPE_PORT */ #define RTE_LOGTYPE_TABLE 14 /**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 15 /**< Log related to pipeline. */ /* was RTE_LOGTYPE_MBUF */ diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c index 0da7890261e9..614bdacb3cec 100644 --- a/lib/port/rte_port_ethdev.c +++ b/lib/port/rte_port_ethdev.c @@ -5,11 +5,16 @@ #include #include +#include #include #include #include "rte_port_ethdev.h" +RTE_LOG_REGISTER_SUFFIX(port_ethdev_logtype, "port.ethdev", INFO); +#define RTE_PORT_ETHDEV_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_ethdev_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port ETHDEV Reader */ @@ -43,7 +48,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "params is NULL"); return NULL; } @@ -51,7 +56,7 @@ rte_port_ethdev_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -78,7 +83,7 @@ static int rte_port_ethdev_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -142,7 +147,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -150,7 +155,7 @@ rte_port_ethdev_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -257,7 +262,7 @@ static int rte_port_ethdev_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -323,7 +328,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -331,7 +336,7 @@ rte_port_ethdev_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -470,7 +475,7 @@ static int rte_port_ethdev_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_ETHDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c index fd7dac9a5661..4d0838a004c9 100644 --- a/lib/port/rte_port_eventdev.c +++ b/lib/port/rte_port_eventdev.c @@ -5,11 +5,16 @@ #include #include +#include #include #include #include "rte_port_eventdev.h" +RTE_LOG_REGISTER_SUFFIX(port_eventdev_logtype, "port.eventdev", INFO); +#define RTE_PORT_EVENTDEV_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_eventdev_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port EVENTDEV Reader */ @@ -45,7 +50,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "params is NULL"); return NULL; } @@ -53,7 +58,7 @@ rte_port_eventdev_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -85,7 +90,7 @@ static int rte_port_eventdev_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -155,7 +160,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id) (conf->enq_burst_sz == 0) || (conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->enq_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -163,7 +168,7 @@ rte_port_eventdev_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -290,7 +295,7 @@ static int rte_port_eventdev_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -362,7 +367,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id) (conf->enq_burst_sz == 0) || (conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->enq_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -370,7 +375,7 @@ rte_port_eventdev_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -530,7 +535,7 @@ static int rte_port_eventdev_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_EVENTDEV_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c index 932ecd324e05..0c059a465b3a 100644 --- a/lib/port/rte_port_fd.c +++ b/lib/port/rte_port_fd.c @@ -10,6 +10,10 @@ #include "rte_port_fd.h" +RTE_LOG_REGISTER_SUFFIX(port_fd_logtype, "port.fd", INFO); +#define RTE_PORT_FD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_fd_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port FD Reader */ @@ -43,19 +47,19 @@ rte_port_fd_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "params is NULL"); return NULL; } if (conf->fd < 0) { - RTE_LOG(ERR, PORT, "%s: Invalid file descriptor\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid file descriptor"); return NULL; } if (conf->mtu == 0) { - RTE_LOG(ERR, PORT, "%s: Invalid MTU\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid MTU"); return NULL; } if (conf->mempool == NULL) { - RTE_LOG(ERR, PORT, "%s: Invalid mempool\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid mempool"); return NULL; } @@ -63,7 +67,7 @@ rte_port_fd_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_FD_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -109,7 +113,7 @@ static int rte_port_fd_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -171,7 +175,7 @@ rte_port_fd_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -179,7 +183,7 @@ rte_port_fd_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_FD_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -279,7 +283,7 @@ static int rte_port_fd_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -344,7 +348,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_FD_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -352,7 +356,7 @@ rte_port_fd_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_FD_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -464,7 +468,7 @@ static int rte_port_fd_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_FD_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c index e1f1892176c4..243ebf225770 100644 --- a/lib/port/rte_port_frag.c +++ b/lib/port/rte_port_frag.c @@ -7,6 +7,11 @@ #include "rte_port_frag.h" +RTE_LOG_REGISTER_SUFFIX(port_frag_logtype, "port.frag", INFO); +#define RTE_PORT_FRAG_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_frag_logtype, \ + "%s: " fmt "\n", __func__, ## args) + /* Max number of fragments per packet allowed */ #define RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80 @@ -62,25 +67,23 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter conf is NULL"); return NULL; } if (conf->ring == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter ring is NULL"); return NULL; } if (conf->mtu == 0) { - RTE_LOG(ERR, PORT, "%s: Parameter mtu is invalid\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter mtu is invalid"); return NULL; } if (conf->pool_direct == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter pool_direct is NULL\n", - __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter pool_direct is NULL"); return NULL; } if (conf->pool_indirect == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter pool_indirect is NULL\n", - __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter pool_indirect is NULL"); return NULL; } @@ -88,7 +91,7 @@ rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "port is NULL"); return NULL; } @@ -232,7 +235,7 @@ static int rte_port_ring_reader_frag_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__); + RTE_PORT_FRAG_LOG(ERR, "Parameter port is NULL"); return -1; } diff --git a/lib/port/rte_port_kni.c b/lib/port/rte_port_kni.c index 1c7a6cb200ea..ed2b5c3e4a31 100644 --- a/lib/port/rte_port_kni.c +++ b/lib/port/rte_port_kni.c @@ -9,6 +9,10 @@ #include "rte_port_kni.h" +RTE_LOG_REGISTER_SUFFIX(port_kni_logtype, "port.kni", INFO); +#define RTE_PORT_KNI_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_kni_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port KNI Reader */ @@ -41,7 +45,7 @@ rte_port_kni_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "params is NULL"); return NULL; } @@ -49,7 +53,7 @@ rte_port_kni_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -75,7 +79,7 @@ static int rte_port_kni_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -138,7 +142,7 @@ rte_port_kni_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -146,7 +150,7 @@ rte_port_kni_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -250,7 +254,7 @@ static int rte_port_kni_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -315,7 +319,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -323,7 +327,7 @@ rte_port_kni_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -460,7 +464,7 @@ static int rte_port_kni_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_KNI_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c index e5de57da42ea..3205b1abc360 100644 --- a/lib/port/rte_port_ras.c +++ b/lib/port/rte_port_ras.c @@ -21,6 +21,11 @@ #define RTE_PORT_RAS_N_ENTRIES (RTE_PORT_RAS_N_BUCKETS * RTE_PORT_RAS_N_ENTRIES_PER_BUCKET) #endif +RTE_LOG_REGISTER_SUFFIX(port_ras_logtype, "port.ras", INFO); +#define RTE_PORT_RAS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_ras_logtype, \ + "%s: " fmt "\n", __func__, ## args) + #ifdef RTE_PORT_STATS_COLLECT #define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val) \ @@ -69,16 +74,16 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Parameter conf is NULL"); return NULL; } if (conf->ring == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Parameter ring is NULL"); return NULL; } if ((conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - RTE_LOG(ERR, PORT, "%s: Parameter tx_burst_sz is invalid\n", + RTE_PORT_RAS_LOG(ERR, "Parameter tx_burst_sz is invalid\n", __func__); return NULL; } @@ -87,7 +92,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate socket\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Failed to allocate socket"); return NULL; } @@ -103,7 +108,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) socket_id); if (port->frag_tbl == NULL) { - RTE_LOG(ERR, PORT, "%s: rte_ip_frag_table_create failed\n", + RTE_PORT_RAS_LOG(ERR, "rte_ip_frag_table_create failed\n", __func__); rte_free(port); return NULL; @@ -282,7 +287,7 @@ rte_port_ring_writer_ras_free(void *port) port; if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__); + RTE_PORT_RAS_LOG(ERR, "Parameter port is NULL"); return -1; } diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c index 52b2d8e557f0..e493f63ab25e 100644 --- a/lib/port/rte_port_ring.c +++ b/lib/port/rte_port_ring.c @@ -10,6 +10,10 @@ #include "rte_port_ring.h" +RTE_LOG_REGISTER_SUFFIX(port_ring_logtype, "port.ring", INFO); +#define RTE_PORT_RING_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_ring_logtype, \ + "%s: " fmt "\n", __func__, ## args) /* * Port RING Reader */ @@ -46,7 +50,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id, (conf->ring == NULL) || (rte_ring_is_cons_single(conf->ring) && is_multi) || (!rte_ring_is_cons_single(conf->ring) && !is_multi)) { - RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + RTE_PORT_RING_LOG(ERR, "Invalid Parameters"); return NULL; } @@ -54,7 +58,7 @@ rte_port_ring_reader_create_internal(void *params, int socket_id, port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_RING_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -107,7 +111,7 @@ static int rte_port_ring_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_RING_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -174,7 +178,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id, (rte_ring_is_prod_single(conf->ring) && is_multi) || (!rte_ring_is_prod_single(conf->ring) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + RTE_PORT_RING_LOG(ERR, "Invalid Parameters"); return NULL; } @@ -182,7 +186,7 @@ rte_port_ring_writer_create_internal(void *params, int socket_id, port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_RING_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -370,7 +374,7 @@ rte_port_ring_writer_free(void *port) struct rte_port_ring_writer *p = port; if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_RING_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -443,7 +447,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id, (rte_ring_is_prod_single(conf->ring) && is_multi) || (!rte_ring_is_prod_single(conf->ring) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + RTE_PORT_RING_LOG(ERR, "Invalid Parameters"); return NULL; } @@ -451,7 +455,7 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id, port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_RING_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -703,7 +707,7 @@ rte_port_ring_writer_nodrop_free(void *port) port; if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_RING_LOG(ERR, "Port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c index 8a7d815ef323..dc590fd9c647 100644 --- a/lib/port/rte_port_sched.c +++ b/lib/port/rte_port_sched.c @@ -7,6 +7,10 @@ #include "rte_port_sched.h" +RTE_LOG_REGISTER_SUFFIX(port_sched_logtype, "port.sched", INFO); +#define RTE_PORT_SCHED_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_sched_logtype, \ + "%s: " fmt "\n", __func__, ##args) /* * Reader */ @@ -40,7 +44,7 @@ rte_port_sched_reader_create(void *params, int socket_id) /* Check input parameters */ if ((conf == NULL) || (conf->sched == NULL)) { - RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Invalid params"); return NULL; } @@ -48,7 +52,7 @@ rte_port_sched_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -74,7 +78,7 @@ static int rte_port_sched_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -139,7 +143,7 @@ rte_port_sched_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Invalid params"); return NULL; } @@ -147,7 +151,7 @@ rte_port_sched_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -247,7 +251,7 @@ static int rte_port_sched_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_SCHED_LOG(ERR, "port is NULL"); return -EINVAL; } diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c index 7d73adc1e79e..fbb453f22fae 100644 --- a/lib/port/rte_port_source_sink.c +++ b/lib/port/rte_port_source_sink.c @@ -15,6 +15,12 @@ #include "rte_port_source_sink.h" +RTE_LOG_REGISTER_SUFFIX(port_source_logtype, "port.source", INFO); + +#define RTE_PORT_SOURCE_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_source_logtype, \ + "%s: " fmt "\n", __func__, ##args) + /* * Port SOURCE */ @@ -49,9 +55,9 @@ struct rte_port_source { static int pcap_source_load(struct rte_port_source *port, - const char *file_name, - uint32_t n_bytes_per_pkt, - int socket_id) + const char *file_name, + uint32_t n_bytes_per_pkt, + int socket_id) { uint32_t n_pkts = 0; uint32_t i; @@ -64,8 +70,8 @@ pcap_source_load(struct rte_port_source *port, const uint8_t *pkt; uint8_t *buff = NULL; uint32_t pktmbuf_maxlen = (uint32_t) - (rte_pktmbuf_data_room_size(port->mempool) - - RTE_PKTMBUF_HEADROOM); + (rte_pktmbuf_data_room_size(port->mempool) - + RTE_PKTMBUF_HEADROOM); if (n_bytes_per_pkt == 0) max_len = pktmbuf_maxlen; @@ -75,8 +81,9 @@ pcap_source_load(struct rte_port_source *port, /* first time open, get packet number */ pcap_handle = pcap_open_offline(file_name, pcap_errbuf); if (pcap_handle == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "'%s' for reading\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file '%s' for reading", + file_name); goto error_exit; } @@ -86,31 +93,32 @@ pcap_source_load(struct rte_port_source *port, pcap_close(pcap_handle); port->pkt_len = rte_zmalloc_socket("PCAP", - (sizeof(*port->pkt_len) * n_pkts), 0, socket_id); + (sizeof(*port->pkt_len) * n_pkts), 0, socket_id); if (port->pkt_len == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } pkt_len_aligns = rte_malloc("PCAP", - (sizeof(*pkt_len_aligns) * n_pkts), 0); + (sizeof(*pkt_len_aligns) * n_pkts), 0); if (pkt_len_aligns == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } port->pkts = rte_zmalloc_socket("PCAP", - (sizeof(*port->pkts) * n_pkts), 0, socket_id); + (sizeof(*port->pkts) * n_pkts), 0, socket_id); if (port->pkts == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } /* open 2nd time, get pkt_len */ pcap_handle = pcap_open_offline(file_name, pcap_errbuf); if (pcap_handle == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "'%s' for reading\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file '%s' for reading", + file_name); goto error_exit; } @@ -126,9 +134,9 @@ pcap_source_load(struct rte_port_source *port, /* allocate a big trunk of data for pcap file load */ buff = rte_zmalloc_socket("PCAP", - total_buff_len, 0, socket_id); + total_buff_len, 0, socket_id); if (buff == NULL) { - RTE_LOG(ERR, PORT, "No enough memory\n"); + RTE_PORT_SOURCE_LOG(ERR, "Not enough memory"); goto error_exit; } @@ -137,8 +145,9 @@ pcap_source_load(struct rte_port_source *port, /* open file one last time to copy the pkt content */ pcap_handle = pcap_open_offline(file_name, pcap_errbuf); if (pcap_handle == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "'%s' for reading\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file '%s' for reading", + file_name); goto error_exit; } @@ -155,9 +164,9 @@ pcap_source_load(struct rte_port_source *port, rte_free(pkt_len_aligns); - RTE_LOG(INFO, PORT, "Successfully load pcap file " - "'%s' with %u pkts\n", - file_name, port->n_pkts); + RTE_PORT_SOURCE_LOG(INFO, + "Successfully load pcap file '%s' with %u pkts", + file_name, port->n_pkts); return 0; @@ -180,8 +189,8 @@ pcap_source_load(struct rte_port_source *port, int _ret = 0; \ \ if (file_name) { \ - RTE_LOG(ERR, PORT, "Source port field " \ - "\"file_name\" is not NULL.\n"); \ + RTE_PORT_SOURCE_LOG(ERR, "Source port field " \ + "\"file_name\" is not NULL."); \ _ret = -1; \ } \ \ @@ -199,7 +208,7 @@ rte_port_source_create(void *params, int socket_id) /* Check input arguments*/ if ((p == NULL) || (p->mempool == NULL)) { - RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__); + RTE_PORT_SOURCE_LOG(ERR, "Invalid params"); return NULL; } @@ -207,7 +216,7 @@ rte_port_source_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -332,15 +341,16 @@ pcap_sink_open(struct rte_port_sink *port, /** Open a dead pcap handler for opening dumper file */ tx_pcap = pcap_open_dead(DLT_EN10MB, 65535); if (tx_pcap == NULL) { - RTE_LOG(ERR, PORT, "Cannot open pcap dead handler\n"); + RTE_PORT_SOURCE_LOG(ERR, "Cannot open pcap dead handler"); return -1; } /* The dumper is created using the previous pcap_t reference */ pcap_dumper = pcap_dump_open(tx_pcap, file_name); if (pcap_dumper == NULL) { - RTE_LOG(ERR, PORT, "Failed to open pcap file " - "\"%s\" for writing\n", file_name); + RTE_PORT_SOURCE_LOG(ERR, + "Failed to open pcap file \"%s\" for writing", + file_name); return -1; } @@ -349,8 +359,9 @@ pcap_sink_open(struct rte_port_sink *port, port->pkt_index = 0; port->dump_finish = 0; - RTE_LOG(INFO, PORT, "Ready to dump packets to file \"%s\"\n", - file_name); + RTE_PORT_SOURCE_LOG(INFO, + "Ready to dump packets to file \"%s\"", + file_name); return 0; } @@ -402,8 +413,9 @@ pcap_sink_write_pkt(struct rte_port_sink *port, struct rte_mbuf *mbuf) if ((port->max_pkts != 0) && (port->pkt_index >= port->max_pkts)) { port->dump_finish = 1; - RTE_LOG(INFO, PORT, "Dumped %u packets to file\n", - port->pkt_index); + RTE_PORT_SOURCE_LOG(INFO, + "Dumped %u packets to file", + port->pkt_index); } } @@ -433,7 +445,7 @@ do { \ int _ret = 0; \ \ if (file_name) { \ - RTE_LOG(ERR, PORT, "Sink port field " \ + RTE_PORT_SOURCE_LOG(ERR, "Sink port field " \ "\"file_name\" is not NULL.\n"); \ _ret = -1; \ } \ @@ -459,7 +471,7 @@ rte_port_sink_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_SOURCE_LOG(ERR, "Failed to allocate port"); return NULL; } diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c index 295984d025cb..ee8573a3e1c4 100644 --- a/lib/port/rte_port_sym_crypto.c +++ b/lib/port/rte_port_sym_crypto.c @@ -8,6 +8,10 @@ #include "rte_port_sym_crypto.h" +RTE_LOG_REGISTER_SUFFIX(port_crypto_logtype, "port.crypto", INFO); +#define RTE_PORT_CRYPTO_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, port_crypto_logtype, \ + "%s: " fmt "\n", __func__, ##args) /* * Port Crypto Reader */ @@ -44,7 +48,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id) /* Check input parameters */ if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "params is NULL"); return NULL; } @@ -52,7 +56,7 @@ rte_port_sym_crypto_reader_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -100,7 +104,7 @@ static int rte_port_sym_crypto_reader_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "port is NULL"); return -EINVAL; } @@ -167,7 +171,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -175,7 +179,7 @@ rte_port_sym_crypto_writer_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -285,7 +289,7 @@ static int rte_port_sym_crypto_writer_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL"); return -EINVAL; } @@ -353,7 +357,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id) (conf->tx_burst_sz == 0) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || (!rte_is_power_of_2(conf->tx_burst_sz))) { - RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Invalid input parameters"); return NULL; } @@ -361,7 +365,7 @@ rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id) port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, socket_id); if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Failed to allocate port"); return NULL; } @@ -497,7 +501,7 @@ static int rte_port_sym_crypto_writer_nodrop_free(void *port) { if (port == NULL) { - RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); + RTE_PORT_CRYPTO_LOG(ERR, "Port is NULL"); return -EINVAL; }