From patchwork Wed Dec 13 01:42:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 135076 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 57E78436D8; Wed, 13 Dec 2023 02:44:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E7DE42E72; Wed, 13 Dec 2023 02:44:16 +0100 (CET) Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by mails.dpdk.org (Postfix) with ESMTP id AF9C940269 for ; Wed, 13 Dec 2023 02:44:13 +0100 (CET) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6d9f7af8918so3472631a34.0 for ; Tue, 12 Dec 2023 17:44:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1702431853; x=1703036653; darn=dpdk.org; 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=8zbmMtlxUZS8UjSI52yfEygDPKZxKBIUDdcN1Ph3NqA=; b=2K2qgW/+yg3qxWhRoRoLcfAnJjj1ugJZoDlrj/U1HB+VMKwJBNhChoyGtKIv6KaETv JlTattd1nbFA7fKFXCWLzJb/3Fm0GUtoJMBKivo7qiR1Tacwfd5Gmj1rJwAmq20hwrrU 8C3STPENOTBfk9LXGKLcrdUmaOoSdJzkbb7om97G6VPdZPGa007GHjg9Aj28b0gFlNgn c5K3Zp8QlKw+KY8bM62ayK775VY9EUpf6AQglR2a5RGjcAi4reSwRCal2e1FNmGAEdqa HqWSPaTE5C6kN0WGEm+l9twRUrer+0YR01RhD6m7O3xHS8ssf/BlRCNs+zC3xQf5g2ts KThA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702431853; x=1703036653; 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=8zbmMtlxUZS8UjSI52yfEygDPKZxKBIUDdcN1Ph3NqA=; b=MPhW9yJhVstWIiVEgy1iTM1GhpYZR5Rm9AsKpvPy9aQ8aXnPRfEgHXc2Yx1RNxwgSB xr0ai5D+ANpzyN34LY5a+eMZQKwA62CGMFBLQsx2AETwpaATq4qK+mB5nRSBX3ja8h2D s/zHSZOehclRmkg8Vu0H2nUvjlm6toiSrewGZNs97sD1GRsQX9LTnaBtcgtv4zwXk+qF thN/zf3Ds0DdfgMIZ7ic47KXAbeUijEohiJJDo++e68nmxjqkgIUfdY1aEhPniJWsD2D jbFROuLn5Jc+5y6DenVDxuQsWOiU6QLVPUv0AIat1XneMQq/lkKUXOuPDidKVxrqEbtc zYxw== X-Gm-Message-State: AOJu0Yw1I9/GciLUgB8e15p2rNF0+m5rkanAE5EhTyoew04/8r4IgmR9 RxZR22ORIOJkGpnHtT6/WExOK9elF2SDAhJBpdHcvA== X-Google-Smtp-Source: AGHT+IHm4iWiSp9lsQR/OBsWoIdqiAKJZpIFBuLtMeO+dKmW4QIm4+YGVDNOHxxNjxCvrX7RwPP1lg== X-Received: by 2002:a9d:4d94:0:b0:6d8:74e2:a3df with SMTP id u20-20020a9d4d94000000b006d874e2a3dfmr6492694otk.59.1702431852897; Tue, 12 Dec 2023 17:44:12 -0800 (PST) Received: from hermes.lan (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id f7-20020aa79d87000000b006ce5b4ade28sm8988375pfq.174.2023.12.12.17.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:44:12 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH 02/26] log: add rte_log_dp() Date: Tue, 12 Dec 2023 17:42:18 -0800 Message-ID: <20231213014408.612051-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231213014408.612051-1-stephen@networkplumber.org> References: <20231213014408.612051-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 Add a new macro for logging in datapath using a logtype. The existing macro RTE_LOG_DP() takes log type suffix (i.e. PMD) like RTE_LOG(). This macro allows using a dynamic type. Ideally, rte_log_dp() could be an always_inline function but GCC and Clang will not inline a function with variable number of arguments. Therefore it has to be a macro. Signed-off-by: Stephen Hemminger --- lib/log/rte_log.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/log/rte_log.h b/lib/log/rte_log.h index bbbb051c20e2..8eb2b38b1a9f 100644 --- a/lib/log/rte_log.h +++ b/lib/log/rte_log.h @@ -355,6 +355,29 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \ 0) +/** + * Generates a log message for data path. + * + * Similar to rte_log(), except that it gets optimized away + * if the RTE_LOG_DP_LEVEL configuration option is lower than the log + * level argument. + * + * @param level + * Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8). + * @param logtype + * The log type, for example, RTE_LOGTYPE_EAL. + * @param format + * The format string, as in printf(3), followed by the variable arguments + * required by the format. + * @param ap + * The va_list of the variable arguments required by the format. + */ +#define rte_log_dp(lev, t, ...) \ + do { \ + if (lev <= RTE_LOG_DP_LEVEL) \ + rte_log(lev, t, __VA_ARGS__); \ + } while(0) + #define RTE_LOG_REGISTER_IMPL(type, name, level) \ int type; \ RTE_INIT(__##type) \