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 AB41243E83; Tue, 16 Apr 2024 17:22:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C894340695; Tue, 16 Apr 2024 17:21:37 +0200 (CEST) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id 36EA84067B for ; Tue, 16 Apr 2024 17:21:33 +0200 (CEST) Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6ee0642f718so3297513b3a.0 for ; Tue, 16 Apr 2024 08:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713280892; x=1713885692; 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=xFZldrBvv+o0NLX2Xm+UCWEaTVh0OLbH05xGTJHlD4M=; b=YH6kuDAPNZLwB37zAOvIlHeNKJrVSXjAmEn5BmHWsKLeak6Qx0YBkLIeNqIzNvsJCi jFXzWw/UHCsRFCq0jO91WzZMb6SgFtviIhB1RPZYYUKMQ+LqyNEbMPICscTASYhzcLB3 +Yx15GRYIQ4MUOB+h3LJX6+aBPev4NJgmzYfZ6rCSp564C3fGRApTznExbmX+s6ePyPx /7Vvoa1xE1KxZG5ptkfcsEly/UTvSYp4aKNUt4W0Xqx9DKTBJnqYRgHLqZSUOkDGfDHl L8p+zC84G5ojQ//81EnMUmtaQmNgto3RCNTZ88NuTbXtf35hbA5VSwCwllMSIpPlodmw BrPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713280892; x=1713885692; 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=xFZldrBvv+o0NLX2Xm+UCWEaTVh0OLbH05xGTJHlD4M=; b=YLMuWu1mOAkE+tpVoKfbvjVpgTIW7DHGRBFcI1C+eAjfpz7wCL0//mJLW2mppm7tmY vbokOgpKV0i8O5Oq7A089jtN8jZLXMEaitWG/Nph1zz/rKord7e9CzfFkMhOGhp4AAF6 NvjLlbpoPuLiIQVGuEShQKmVBHKDjL96SGpgqSC7u5UbRhkO6qpjI4durASuL0d8mGN4 G2Rc5S+smLDW6waBzVqdH+HYEMwra9EbvM07JLgBfKl7/j36iCNFUgOSa0kVUefpYZ6m K7QGvzUKf1DElD77sQW9yNMnBYM6cKNWwxV3lrxmlBkLSki8/xN2IE3FscW+Fut2fldD tlJw== X-Gm-Message-State: AOJu0YzLErREeCRGtqz+vuCY3wFXsfTl7S9TeMKSiI+oZfs3C4sBm6/i DFo72vB7EqjYVhclf6XTlKE1LV8xs4JvQP90QnvYvHO+ExCvuMecX6RYBox8el6whdLQJOY1yZ0 S X-Google-Smtp-Source: AGHT+IERUeJkvIVFCx70AvXeDofc/4dmErq/+Uy//MGXbKt4jdjf+fsQbmUVS9Xcpas8YDjFG25myA== X-Received: by 2002:a17:902:b716:b0:1e2:a5db:30d1 with SMTP id d22-20020a170902b71600b001e2a5db30d1mr2573009pls.13.1713280892321; Tue, 16 Apr 2024 08:21:32 -0700 (PDT) Received: from hermes.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id l17-20020a170903245100b001e80154a400sm213348pls.126.2024.04.16.08.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:21:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Shepard Siegel , Ed Czeck , John Miller , Ajit Khaparde , Somnath Kotur , Jingjing Wu , Rosen Xu , Jiawen Wu , Harman Kalra , Jian Wang Subject: [PATCH 5/5] drivers/net: use RTE_DIM Date: Tue, 16 Apr 2024 08:19:31 -0700 Message-ID: <20240416152124.69590-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416152124.69590-1-stephen@networkplumber.org> References: <20240416152124.69590-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 Use RTE_DIM instead of computing directly with sizeof. Patch automatically generated via cocci/rte_dim.cocci. Code in base/ subdirectory manually excluded. Signed-off-by: Stephen Hemminger --- drivers/net/ark/ark_pktchkr.c | 2 +- drivers/net/ark/ark_pktgen.c | 2 +- drivers/net/bnxt/bnxt_hwrm.c | 12 ++++++------ drivers/net/e1000/em_rxtx.c | 3 +-- drivers/net/iavf/iavf_ipsec_crypto.c | 3 +-- drivers/net/igc/igc_ethdev.c | 3 +-- drivers/net/ipn3ke/ipn3ke_tm.c | 3 +-- drivers/net/ngbe/ngbe_ethdev.c | 6 ++---- drivers/net/octeontx/octeontx_stats.h | 3 +-- drivers/net/txgbe/txgbe_ethdev.c | 9 +++------ drivers/net/txgbe/txgbe_ethdev_vf.c | 3 +-- 11 files changed, 19 insertions(+), 30 deletions(-) diff --git a/drivers/net/ark/ark_pktchkr.c b/drivers/net/ark/ark_pktchkr.c index e1f336c73c..63c298fca8 100644 --- a/drivers/net/ark/ark_pktchkr.c +++ b/drivers/net/ark/ark_pktchkr.c @@ -320,7 +320,7 @@ options(const char *id) { unsigned int i; - for (i = 0; i < sizeof(toptions) / sizeof(struct OPTIONS); i++) { + for (i = 0; i < RTE_DIM(toptions); i++) { if (strcmp(id, toptions[i].opt) == 0) return &toptions[i]; } diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c index 69ff7072b2..98e692c3ad 100644 --- a/drivers/net/ark/ark_pktgen.c +++ b/drivers/net/ark/ark_pktgen.c @@ -297,7 +297,7 @@ options(const char *id) { unsigned int i; - for (i = 0; i < sizeof(toptions) / sizeof(struct OPTIONS); i++) { + for (i = 0; i < RTE_DIM(toptions); i++) { if (strcmp(id, toptions[i].opt) == 0) return &toptions[i]; } diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 6ea7089a3f..68d7382806 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -72,13 +72,13 @@ const char *media_type[] = { "Unknown", "Twisted Pair", "Direct Attached Copper", "Fiber" }; -#define MAX_MEDIA_TYPE (sizeof(media_type) / sizeof(const char *)) +#define MAX_MEDIA_TYPE RTE_DIM(media_type) const char *link_status_str[] = { "Down. No link or cable detected.", "Down. No link, but a cable has been detected.", "Up.", }; -#define MAX_LINK_STR (sizeof(link_status_str) / sizeof(const char *)) +#define MAX_LINK_STR RTE_DIM(link_status_str) const char *fec_mode[] = { "No active FEC", @@ -90,13 +90,13 @@ const char *fec_mode[] = { "FEC RS(272,257)" }; -#define MAX_FEC_MODE (sizeof(fec_mode) / sizeof(const char *)) +#define MAX_FEC_MODE RTE_DIM(fec_mode) const char *signal_mode[] = { "NRZ", "PAM4", "PAM4_112" }; -#define MAX_SIG_MODE (sizeof(signal_mode) / sizeof(const char *)) +#define MAX_SIG_MODE RTE_DIM(signal_mode) /* multi-purpose multi-key table container. * Add a unique entry for a new PHY attribs as per HW CAS. @@ -226,7 +226,7 @@ struct link_speeds2_tbl { }, }; -#define BNXT_SPEEDS2_TBL_SZ (sizeof(link_speeds2_tbl) / sizeof(*link_speeds2_tbl)) +#define BNXT_SPEEDS2_TBL_SZ RTE_DIM(link_speeds2_tbl) /* In hwrm_phy_qcfg reports trained up speeds in link_speed(offset:0x8[31:16]) */ struct link_speeds_tbl { @@ -269,7 +269,7 @@ struct link_speeds_tbl { }, }; -#define BNXT_SPEEDS_TBL_SZ (sizeof(link_speeds_tbl) / sizeof(*link_speeds_tbl)) +#define BNXT_SPEEDS_TBL_SZ RTE_DIM(link_speeds_tbl) static const char *bnxt_get_xcvr_type(uint32_t xcvr_identifier_type_tx_lpi_timer) { diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c index df5fbb7823..59d7793787 100644 --- a/drivers/net/e1000/em_rxtx.c +++ b/drivers/net/e1000/em_rxtx.c @@ -1666,8 +1666,7 @@ em_rctl_bsize(__rte_unused enum e1000_mac_type hwtyp, uint32_t *bufsz) * *************************************************************** */ - for (i = 0; i != sizeof(bufsz_to_rctl) / sizeof(bufsz_to_rctl[0]); - i++) { + for (i = 0; i != RTE_DIM(bufsz_to_rctl); i++) { if (rctl_bsize >= bufsz_to_rctl[i].bufsz) { *bufsz = bufsz_to_rctl[i].bufsz; return bufsz_to_rctl[i].rctl; diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c index 6fd45ff45f..d3ce666ef0 100644 --- a/drivers/net/iavf/iavf_ipsec_crypto.c +++ b/drivers/net/iavf/iavf_ipsec_crypto.c @@ -1483,8 +1483,7 @@ iavf_ipsec_crypto_capabilities_get(void *device) * crypto capabilities, except for last element of the array which is * the null termination */ - for (i = 0; i < ((sizeof(iavf_security_capabilities) / - sizeof(iavf_security_capabilities[0])) - 1); i++) { + for (i = 0; i < (RTE_DIM(iavf_security_capabilities) - 1); i++) { iavf_security_capabilities[i].crypto_capabilities = iavf_sctx->crypto_capabilities; } diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c index 87d7f7caa0..28682c42ae 100644 --- a/drivers/net/igc/igc_ethdev.c +++ b/drivers/net/igc/igc_ethdev.c @@ -188,8 +188,7 @@ static const struct rte_igc_xstats_name_off rte_igc_stats_strings[] = { offsetof(struct igc_hw_stats, icrxdmtc)}, }; -#define IGC_NB_XSTATS (sizeof(rte_igc_stats_strings) / \ - sizeof(rte_igc_stats_strings[0])) +#define IGC_NB_XSTATS RTE_DIM(rte_igc_stats_strings) static int eth_igc_configure(struct rte_eth_dev *dev); static int eth_igc_link_update(struct rte_eth_dev *dev, int wait_to_complete); diff --git a/drivers/net/ipn3ke/ipn3ke_tm.c b/drivers/net/ipn3ke/ipn3ke_tm.c index 0260227900..54687ce637 100644 --- a/drivers/net/ipn3ke/ipn3ke_tm.c +++ b/drivers/net/ipn3ke/ipn3ke_tm.c @@ -67,8 +67,7 @@ struct ipn3ke_tm_shaper_params_range_type ipn3ke_tm_shaper_params_rang[] = { {512, 1023, 15, 32768, 67108864, 134086656}, }; -#define IPN3KE_TM_SHAPER_RANGE_NUM (sizeof(ipn3ke_tm_shaper_params_rang) / \ - sizeof(struct ipn3ke_tm_shaper_params_range_type)) +#define IPN3KE_TM_SHAPER_RANGE_NUM RTE_DIM(ipn3ke_tm_shaper_params_rang) #define IPN3KE_TM_SHAPER_COMMITTED_RATE_MAX \ (ipn3ke_tm_shaper_params_rang[IPN3KE_TM_SHAPER_RANGE_NUM - 1].high) diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 4cd07a0030..f10b9647fa 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -238,8 +238,7 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_stats_strings[] = { HW_XSTAT_NAME(rx_xoff_packets, "rx_flow_control_xoff_packets"), }; -#define NGBE_NB_HW_STATS (sizeof(rte_ngbe_stats_strings) / \ - sizeof(rte_ngbe_stats_strings[0])) +#define NGBE_NB_HW_STATS RTE_DIM(rte_ngbe_stats_strings) /* Per-queue statistics */ #define QP_XSTAT(m) {#m, offsetof(struct ngbe_hw_stats, qp[0].m)} @@ -251,8 +250,7 @@ static const struct rte_ngbe_xstats_name_off rte_ngbe_qp_strings[] = { QP_XSTAT(rx_qp_mc_packets), }; -#define NGBE_NB_QP_STATS (sizeof(rte_ngbe_qp_strings) / \ - sizeof(rte_ngbe_qp_strings[0])) +#define NGBE_NB_QP_STATS RTE_DIM(rte_ngbe_qp_strings) static inline int32_t ngbe_pf_reset_hw(struct ngbe_hw *hw) diff --git a/drivers/net/octeontx/octeontx_stats.h b/drivers/net/octeontx/octeontx_stats.h index 73ef5e93bb..746205bb85 100644 --- a/drivers/net/octeontx/octeontx_stats.h +++ b/drivers/net/octeontx/octeontx_stats.h @@ -36,6 +36,5 @@ struct octeontx_xstats octeontx_bgx_xstats[] = { BGX_XSTAT(tx_pause_packets), }; -#define NUM_BGX_XSTAT \ - (sizeof(octeontx_bgx_xstats) / sizeof(struct octeontx_xstats)) +#define NUM_BGX_XSTAT RTE_DIM(octeontx_bgx_xstats) #endif /* __OCTEONTX_STATS_H__ */ diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index b75e8898e2..fbf261bd0b 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -269,8 +269,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = { HW_XSTAT_NAME(rx_xoff_packets, "rx_flow_control_xoff_packets"), }; -#define TXGBE_NB_HW_STATS (sizeof(rte_txgbe_stats_strings) / \ - sizeof(rte_txgbe_stats_strings[0])) +#define TXGBE_NB_HW_STATS RTE_DIM(rte_txgbe_stats_strings) /* Per-priority statistics */ #define UP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, up[0].m)} @@ -290,8 +289,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_up_strings[] = { UP_XSTAT(tx_up_xon2off_packets), }; -#define TXGBE_NB_UP_STATS (sizeof(rte_txgbe_up_strings) / \ - sizeof(rte_txgbe_up_strings[0])) +#define TXGBE_NB_UP_STATS RTE_DIM(rte_txgbe_up_strings) /* Per-queue statistics */ #define QP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, qp[0].m)} @@ -303,8 +301,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbe_qp_strings[] = { QP_XSTAT(rx_qp_mc_packets), }; -#define TXGBE_NB_QP_STATS (sizeof(rte_txgbe_qp_strings) / \ - sizeof(rte_txgbe_qp_strings[0])) +#define TXGBE_NB_QP_STATS RTE_DIM(rte_txgbe_qp_strings) static inline int txgbe_is_sfp(struct txgbe_hw *hw) diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c index f1341fbf7e..be96519b97 100644 --- a/drivers/net/txgbe/txgbe_ethdev_vf.c +++ b/drivers/net/txgbe/txgbe_ethdev_vf.c @@ -112,8 +112,7 @@ static const struct rte_txgbe_xstats_name_off rte_txgbevf_stats_strings[] = { offsetof(struct txgbevf_hw_stats, qp[7].vfmprc)} }; -#define TXGBEVF_NB_XSTATS (sizeof(rte_txgbevf_stats_strings) / \ - sizeof(rte_txgbevf_stats_strings[0])) +#define TXGBEVF_NB_XSTATS RTE_DIM(rte_txgbevf_stats_strings) /* * Negotiate mailbox API version with the PF. -- 2.43.0