From patchwork Mon Nov 13 17:06:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 134173 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 0C6164331D; Mon, 13 Nov 2023 18:06:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AC9740A80; Mon, 13 Nov 2023 18:06:20 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id 3C54D4026C for ; Mon, 13 Nov 2023 18:06:17 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1cc938f9612so28595255ad.1 for ; Mon, 13 Nov 2023 09:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1699895176; x=1700499976; 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=O3lHp3Qtm1WSSZq+4sy/uPptKpSnWkMsyUR0UupaX6E=; b=wBS8Crl4fjJUZ7OT0D0K+RJOJoliIHvXGNcCcSgnR0baAVQaWhzPxzOs+hrr3Vj8bU RbgZycKEY0gSQZ70jL7M8wFNIfqeoKgiaX4tLsDK6iLvm9kt7qr+akxvbF4ezozI93p7 OOoPkgRl3Tv+7ipmKk0BGwaCJ7Zq1b2NK7/bU4/FIEsLOS4oaflLxfDm1q6bsfLGssTA ycWPjwzBWWeh0vwzBAvsM7r7DvaalgfsYOhh0BuZVmkFRrqXI/fBePz93kNI36IuF9Xf pvMm4m9clRc/UMcdtzo3Vd4NTsUoVAtP57Oqh7wq9cN4BMMMpgEZtOrvS591T5+k/I/J 5Pag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699895176; x=1700499976; 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=O3lHp3Qtm1WSSZq+4sy/uPptKpSnWkMsyUR0UupaX6E=; b=B9JLUKbIQMevwy0F7nBC0a7XeKTVD/13yfIrJjsAYXZFico/pswdKlXFMVItHvGPQH P0yT9QgH5HJV//FZRjXXpgCOlbKJM+LvQpehjhPb4Q32iYm153HflISQHmlaZET1PaJz FKyd1CPHc0ggG9b9NclTM5kRAQf2k2rh2mNc4ona+OabGrmtbWY+z9VxlRiihaXy8RPp WHBT2/bibcPWsxohXpP9NxxRi6cd45dgb35sdhHB45XPrDgqmtXTkMD/jmtYYDFLECkI vEiywIMKlKCZaYM576gE/MxO4p/5qdo02tP28ozOdiRe0F3OEdwBNXpRogYu7PjMV7Qz qxhg== X-Gm-Message-State: AOJu0YybPfnkfMWBj0xicYL3poBFBE+Vkd42iWoN0KrU0IpOntkUHXv+ qW7G60me1S003X//px5eCIAdswuNSZpmUJWnm5w= X-Google-Smtp-Source: AGHT+IHw7zTtQSgIZBlLVL5hXUGLCMngBylHtb83DCcO3q/qVqYMuJQWZTXOB7HtR14QJ5Le3PS9YA== X-Received: by 2002:a17:902:a582:b0:1cc:32be:b13 with SMTP id az2-20020a170902a58200b001cc32be0b13mr106697plb.64.1699895176107; Mon, 13 Nov 2023 09:06:16 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id l4-20020a170902eb0400b001c61901ed2esm4232051plb.219.2023.11.13.09.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 09:06:15 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , liang.j.ma@intel.com, Liang Ma , Peter Mccarthy , =?utf-8?q?Se=C3=A1n_Harte?= Subject: [PATCH v2 1/3] event/opdl: fix non-constant compile time assertion Date: Mon, 13 Nov 2023 09:06:03 -0800 Message-Id: <20231113170605.408281-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231113170605.408281-1-stephen@networkplumber.org> References: <20231111172153.57461-1-stephen@networkplumber.org> <20231113170605.408281-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 RTE_BUILD_BUG_ON() was being used with a non-constant value. The inline function rte_is_power_of_2() is not constant since inline expansion happens later in the compile process. Replace it with macro which will be constant. Fixes: 4236ce9bf5bf ("event/opdl: add OPDL ring infrastructure library") Cc: liang.j.ma@intel.com Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Tyler Retzlaff --- drivers/event/opdl/opdl_ring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/event/opdl/opdl_ring.c b/drivers/event/opdl/opdl_ring.c index 69392b56bbec..24e0bbe3222d 100644 --- a/drivers/event/opdl/opdl_ring.c +++ b/drivers/event/opdl/opdl_ring.c @@ -31,6 +31,9 @@ #define OPDL_OPA_MASK (0xFF) #define OPDL_OPA_OFFSET (0x38) +/* Equivalent to rte_is_power_of_2() but as macro. */ +#define IS_POWER_OF_2(x) (((x) & ((x) - 1)) == 0) + /* Types of dependency between stages */ enum dep_type { DEP_NONE = 0, /* no dependency */ @@ -910,7 +913,7 @@ opdl_ring_create(const char *name, uint32_t num_slots, uint32_t slot_size, RTE_CACHE_LINE_MASK) != 0); RTE_BUILD_BUG_ON((offsetof(struct opdl_ring, slots) & RTE_CACHE_LINE_MASK) != 0); - RTE_BUILD_BUG_ON(!rte_is_power_of_2(OPDL_DISCLAIMS_PER_LCORE)); + RTE_BUILD_BUG_ON(!IS_POWER_OF_2(OPDL_DISCLAIMS_PER_LCORE)); /* Parameter checking */ if (name == NULL) { From patchwork Mon Nov 13 17:06:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 134174 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 6515C4331D; Mon, 13 Nov 2023 18:06:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E5614026C; Mon, 13 Nov 2023 18:06:21 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id 56D4F4067B for ; Mon, 13 Nov 2023 18:06:18 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1cc1ee2d8dfso41702945ad.3 for ; Mon, 13 Nov 2023 09:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1699895177; x=1700499977; 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=Xfltq0FDtOzHtfnt35/mKLL5OageXwa8xNlYP8AehBI=; b=Nz9YNrYa8EXiezfzSOFOZokKImXrBH/njwijtw01aHjbFXlzFHyLlUGUVjnpal63M6 G0hV81yhB9xQ+B+uVjQB0QMxCQtB6kaBADM6MCkIjAPCJwjsbwhSNjHZKbAgrIWNSuHS 1KyrXp4CRJylN1kui5CavAZtxFUfH2CjZfPHx+YQZ+Fl++zRXPejV5Wr7u6guBp2dM9l yRdDgRleynD/b9BiOuyjegJRUK1+cdTVNfKOwY5gK6ipV8G++Y16saOnlcoPfZ13GRZ/ 3loVRO/4SbBCMHvcUmAi8bWEkSCH8AwpgK2TDUGzgelJmcWxfE/Nrsxq1UEUeoPU38sw t+aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699895177; x=1700499977; 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=Xfltq0FDtOzHtfnt35/mKLL5OageXwa8xNlYP8AehBI=; b=E0Q+09RnfzW29dJkXImYD3ub13vyoBaRxrW3pjzMNHeBMZzMxt6jS8qrXWwLu3UIHs y+6HGPacl3i/sgFt0B7/xUlZ0Apr9y17jUAlNWjjbhHqspxu6S0YJSm8ns8hO32RGpIV KyAOjg4zm/bi6f5A8GoYWXQn355F0nJ3pzrAqc1NgvbDf4iEUNg4J8qA47iPDJ+ULTcJ pVFkyn2uvdKIKliV4OzaaX0bRtbudug3RzvnSUlKsB/g0e7S3I/wEQxVlbx0emDgHUtx PlTEbB1XOqd2yMpbE4X1lKYsjG94TNrzTYq1P1f/jFdRn2fDdw7DemUrxyksFWQ8WS7E o5Ww== X-Gm-Message-State: AOJu0YzehMBi5ZwpWAhnQQ4kvG7fFFeoAdIDvjyeG2h7sBSo9CBRLE4D tF4a92umKlUH3He/i+AkNYBC/5/c0j8wwKL6hVo= X-Google-Smtp-Source: AGHT+IG0zMNkJprhj3y45r8npuncGBMZLjwVnZ0HwTa6TC99QmhMq7oLP4dlC4W0spf4XtqsBPTT/g== X-Received: by 2002:a17:902:e84f:b0:1cc:c243:1cb8 with SMTP id t15-20020a170902e84f00b001ccc2431cb8mr148929plg.43.1699895177185; Mon, 13 Nov 2023 09:06:17 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id l4-20020a170902eb0400b001c61901ed2esm4232051plb.219.2023.11.13.09.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 09:06:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , ivan.malov@oktetlabs.ru, Andrew Rybchenko , Ivan Malov Subject: [PATCH v2 2/3] net/sfc: fix non-constant expression inr RTE_BUILD_BUG_ON() Date: Mon, 13 Nov 2023 09:06:04 -0800 Message-Id: <20231113170605.408281-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231113170605.408281-1-stephen@networkplumber.org> References: <20231111172153.57461-1-stephen@networkplumber.org> <20231113170605.408281-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 macro RTE_MIN has some hidden assignments to provide type safety which means the statement can not be fully evaluted in first pass of compiler. Replace RTE_MIN() with equivalent macro. This will cause errors from checkpatch about multiple evaluations of same expression in macro but it is ok in this case. Fixes: 4f936666d790 ("net/sfc: support TSO for EF100 native datapath") Cc: ivan.malov@oktetlabs.ru Signed-off-by: Stephen Hemminger Acked-by: Tyler Retzlaff --- drivers/net/sfc/sfc_ef100_tx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_ef100_tx.c b/drivers/net/sfc/sfc_ef100_tx.c index 1b6374775f07..f4bcadc1e8e0 100644 --- a/drivers/net/sfc/sfc_ef100_tx.c +++ b/drivers/net/sfc/sfc_ef100_tx.c @@ -26,6 +26,10 @@ #include "sfc_ef100.h" #include "sfc_nic_dma_dp.h" +#ifndef MIN +/* not typesafe but is a constant */ +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif #define sfc_ef100_tx_err(_txq, ...) \ SFC_DP_LOG(SFC_KVARG_DATAPATH_EF100, ERR, &(_txq)->dp.dpq, __VA_ARGS__) @@ -563,8 +567,7 @@ sfc_ef100_tx_pkt_descs_max(const struct rte_mbuf *m) * (split into many Tx descriptors). */ RTE_BUILD_BUG_ON(SFC_EF100_TX_SEND_DESC_LEN_MAX < - RTE_MIN((unsigned int)EFX_MAC_PDU_MAX, - SFC_MBUF_SEG_LEN_MAX)); + MIN((unsigned int)EFX_MAC_PDU_MAX, SFC_MBUF_SEG_LEN_MAX)); } if (m->ol_flags & sfc_dp_mport_override) { From patchwork Mon Nov 13 17:06:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 134175 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 E34B24331D; Mon, 13 Nov 2023 18:06:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B50940DDA; Mon, 13 Nov 2023 18:06:22 +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 50A4040A7F for ; Mon, 13 Nov 2023 18:06:19 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1cc68c1fac2so41235165ad.0 for ; Mon, 13 Nov 2023 09:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1699895178; x=1700499978; 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=uxAfJ8vzwr1WQklSqEm+Tn8oVVCx3fo3M3Y1fw61Dbk=; b=oTBcDuzhKMfQ+zpnRFmbOpyFBqwDmhye+TW7gz1RjiKsvE4kRhmhZDbYImeud1gUeZ SuyP+xRn2S0d+b11VpiOlR0PFQE/U4zGL0SMPBwBXPQYJqdg3huP7/VAAHyIhKfYWHUJ aL8UnQ0slMBQ7+pU/UuX/Eb/RbT0S7pXyMBMXB4IKxIgleVMgy5k0wAYuWf3OvLl/Y/L hbFm2UbHoQ5nQkyxahlSl9fBZn4aGVO9pQzryyvgX8GJT31C1rjp+Hxn3WsLlqUQ7z/u UJoGod4kJ4df3+Qf8WU/RgvfsS7FAIIQFsMFwUIFg+Z7aL1+hF8BkwToT0AB8k54N+Ox 5Qpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699895178; x=1700499978; 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=uxAfJ8vzwr1WQklSqEm+Tn8oVVCx3fo3M3Y1fw61Dbk=; b=XEFLTB6LvvwKVt0mf1De956ib5qilVSXHzt9oFSe4cAfM5Ns6FW5RlGpomQOvHKTS5 0QVOAzB3nhv8RadkvWYGCnH4aHu+sIthWpuazNkWjhwWc2Ez0eIJvRiYD+nF5Z/WSx++ Ll9g+f3FyWMcMnqkhssDiuHGad2ZN1XsKO1slRhuH0a+2KRljPSA/ohwPipRWgGekKqT 7bFuj6gFw8lmYCTOjybbGOlE9cLKFdrRthBdugPytu0JUDMma1lb9XD1UgANfCZ9o11x yn4eWpR7pj2yM2kWMzCAes5RVb91NGb+hZMqkutQa+WW9uhOEsuIfdOO5FTgoOc3NUNe a3Lw== X-Gm-Message-State: AOJu0YxlYk0sVrJTKaWnoaxPfc6iYTxi1RE4WApWo4Vcsrhy/NsROgIl /HYERJv2To2VsLIaKbSWNDn3oDxz1Lq6jDRg2MU= X-Google-Smtp-Source: AGHT+IFSev4AIALLL5RjGSCN3tKRu0FNAqquV/Bm1UPyo1InUaV83jjm8OgAff4v7FydUo4Xpk1Nqw== X-Received: by 2002:a17:902:ab89:b0:1cc:5e1b:98b5 with SMTP id f9-20020a170902ab8900b001cc5e1b98b5mr116768plr.66.1699895178214; Mon, 13 Nov 2023 09:06:18 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id l4-20020a170902eb0400b001c61901ed2esm4232051plb.219.2023.11.13.09.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 09:06:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?utf-8?q?Morten_Br?= =?utf-8?q?=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH v2 3/3] eal: replace out of bounds VLA with static_assert Date: Mon, 13 Nov 2023 09:06:05 -0800 Message-Id: <20231113170605.408281-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231113170605.408281-1-stephen@networkplumber.org> References: <20231111172153.57461-1-stephen@networkplumber.org> <20231113170605.408281-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 Both Gcc, clang and MSVC have better way to do compile time assertions rather than using out of bounds array access. The old method would fail if -Wvla is enabled because compiler can't determine size in that code. Also, the use of new _Static_assert will catch broken code that is passing non-constant expression to RTE_BUILD_BUG_ON(). Signed-off-by: Stephen Hemminger Acked-by: Morten Brørup Acked-by: Tyler Retzlaff Acked-by: Bruce Richardson Reviewed-by: Morten Brørup --- lib/eal/include/rte_common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index c1ba32d00e47..bea7c0e57d5e 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -16,6 +16,7 @@ extern "C" { #endif +#include #include #include @@ -495,7 +496,7 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align) /** * Triggers an error at compilation time if the condition is true. */ -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#define RTE_BUILD_BUG_ON(condition) static_assert(!(condition), #condition) /*********** Cache line related macros ********/