From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DA7BD436D9; Wed, 13 Dec 2023 05:19:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7180F42E9E; Wed, 13 Dec 2023 05:19:26 +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 8E1D642E80 for ; Wed, 13 Dec 2023 05:19:24 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d32c5ce32eso18598115ad.0 for ; Tue, 12 Dec 2023 20:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1702441164; x=1703045964; 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=xF0by76o+9P0clNIMJD64Wc20vx8w96VOMEbOkX5L6ZjER7tvrR/wZgMGWGf1X9DR4 I8tpz1pUcCEy44CEg4vTp/MQ2ET3Gomvi2+cWutG86VmOK7OObz6bcb+yxA0SOAVq+Bw EHVy1zRsUVBbg2n+dJhuthE//K4yyi4gLZ3LsE3RM1l7BD5M7gp9lVKtrtcaeUhSPFXD xWYOmgG96aocdBl7D0c0OHlVHg+lYKnQpCAgyi4gDSZVu0nujCeI3GiHUsNlEhNIpM21 /S3kPCdB5zf4Vr9T06G5//+DPluRVYWIil9ygSmFM2oG7FFmDsmPmbrNDmHv2BldQp78 GsKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702441164; x=1703045964; 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=umnRj97t0SvqX5P1+b+tDG/TIBq020uoi/NDxx6gv/FgASwJT8P519G0PuYPXayBSH x//tW0N+FLgIIeyAKqBsW2Oum24m8JjVaTtFPVmZuObKkYz+7R3D+Ne0qPlQz+xj+YQj 2IqSbiloLDAy3+nNKpgFUFNvdROKkrKaHulgmDv6i26GNnslj1V4cqVRNn/ULgUqrwHJ /akf2pbpK5GJqjACp0rt4VIRK3N6lZPw45FVAlxnju8qJIrDuGMZQLUP8hSrDk3+C8Nz aHOvxefH2w7Po/HRXH2+qKY3t5YrlEIpG7j2KlPr5P78O+IzvCBMccU2qN7llVG0KO1J IzOw== X-Gm-Message-State: AOJu0Yw8Kz3RI1b5ZiVZN4qOBfZAau9NOAbPEUCl+apAo+zj3kMEpQXI i0goB9Fc8JBa7AOKtbDudHKS1BCeSHJiJR+oB6k= X-Google-Smtp-Source: AGHT+IHc9dnAlVfsa5kwRv8IEpPrz2MqPr/+8hEokA0lL6AirYQFbj3SNgC0rstyUpMmNRO/Xn9OZQ== X-Received: by 2002:a17:902:ce85:b0:1d0:910e:5036 with SMTP id f5-20020a170902ce8500b001d0910e5036mr8839594plg.7.1702441163813; Tue, 12 Dec 2023 20:19:23 -0800 (PST) Received: from hermes.lan (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id p12-20020a170902e74c00b001d077da4ac4sm9340888plf.212.2023.12.12.20.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 20:19:23 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2 02/25] log: add rte_log_dp() Date: Tue, 12 Dec 2023 20:16:29 -0800 Message-ID: <20231213041920.729403-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231213041920.729403-1-stephen@networkplumber.org> References: <20231213014408.612051-1-stephen@networkplumber.org> <20231213041920.729403-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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) \ -- 2.42.0