From: Oleksandr Kolomeiets <okl-plv@napatech.com>
To: dev@dpdk.org
Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com,
stephen@networkplumber.org, thomas@monjalon.net
Subject: [PATCH v2 03/26] net/ntnic: replace pragma pack with DPDK defined macros
Date: Mon, 5 May 2025 09:12:43 +0200 [thread overview]
Message-ID: <20250505071309.586015-4-okl-plv@napatech.com> (raw)
In-Reply-To: <20250505071309.586015-1-okl-plv@napatech.com>
The macros __rte_packed_begin and __rte_packed_end are used instead
of #pragma pack(1) when structure or union memory should be minimized.
Signed-off-by: Oleksandr Kolomeiets <okl-plv@napatech.com>
---
drivers/net/ntnic/include/hw_mod_flm_v25.h | 14 ++++++--------
drivers/net/ntnic/nthw/core/nthw_spi_v3.c | 15 +++++++--------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ntnic/include/hw_mod_flm_v25.h b/drivers/net/ntnic/include/hw_mod_flm_v25.h
index 12135a652c..132a585802 100644
--- a/drivers/net/ntnic/include/hw_mod_flm_v25.h
+++ b/drivers/net/ntnic/include/hw_mod_flm_v25.h
@@ -226,8 +226,7 @@ struct flm_v25_scrub_s {
uint8_t inf;
};
-#pragma pack(1)
-struct flm_v25_lrn_data_s {
+struct __rte_packed_begin flm_v25_lrn_data_s {
uint32_t sw9; /* 31:0 (32) */
uint32_t sw8; /* 63:32 (32) */
uint32_t qw4[4];/* 191:64 (128) */
@@ -267,9 +266,9 @@ struct flm_v25_lrn_data_s {
uint64_t nofi : 1; /* 716:716 (1) */
uint64_t pad : 50; /* 766:717 (50) */
uint64_t eor : 1; /* 767:767 (1) */
-};
+} __rte_packed_end;
-struct flm_v25_inf_data_s {
+struct __rte_packed_begin flm_v25_inf_data_s {
uint64_t bytes;
uint64_t packets;
uint64_t ts;
@@ -277,9 +276,9 @@ struct flm_v25_inf_data_s {
uint64_t cause : 3;
uint64_t pad : 60;
uint64_t eor : 1;
-};
+} __rte_packed_end;
-struct flm_v25_sta_data_s {
+struct __rte_packed_begin flm_v25_sta_data_s {
uint32_t id;
uint64_t lds : 1;
uint64_t lfs : 1;
@@ -292,8 +291,7 @@ struct flm_v25_sta_data_s {
uint64_t pis : 1;
uint64_t pad : 54;
uint64_t eor : 1;
-};
-#pragma pack()
+} __rte_packed_end;
struct hw_mod_flm_v25_s {
struct flm_v25_control_s *control;
diff --git a/drivers/net/ntnic/nthw/core/nthw_spi_v3.c b/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
index 0b611462a0..6ef739279a 100644
--- a/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
+++ b/drivers/net/ntnic/nthw/core/nthw_spi_v3.c
@@ -171,26 +171,23 @@ int nthw_spi_v3_transfer(nthw_spi_v3_t *p, uint16_t opcode, struct tx_rx_buf *tx
const uint16_t max_payload_rx_size = rx_buf->size;
int result = 0;
-#pragma pack(push, 1)
- union {
+ union __rte_packed_begin {
uint32_t raw;
struct {
uint16_t opcode;
uint16_t size;
};
- } spi_tx_hdr;
+ } __rte_packed_end spi_tx_hdr;
- union {
+ union __rte_packed_begin {
uint32_t raw;
struct {
uint16_t error_code;
uint16_t size;
};
- } spi_rx_hdr;
-
-#pragma pack(pop)
+ } __rte_packed_end spi_rx_hdr;
#ifdef SPI_V3_DEBUG_PRINT
NT_LOG_DBG(DBG, NTHW, "Started");
@@ -294,7 +291,9 @@ int nthw_spi_v3_transfer(nthw_spi_v3_t *p, uint16_t opcode, struct tx_rx_buf *tx
if (result != 0)
return result;
- result = nthw_spis_read_rx_fifo(p->mp_spis_mod, &spi_rx_hdr.raw);
+ typeof(spi_rx_hdr.raw) raw;
+ result = nthw_spis_read_rx_fifo(p->mp_spis_mod, &raw);
+ spi_rx_hdr.raw = raw;
if (result != 0) {
NT_LOG(WRN, NTHW, "nthw_spis_read_rx_fifo failed");
--
2.47.1
next prev parent reply other threads:[~2025-05-05 7:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 7:12 [PATCH v2 00/26] net/ntnic: fixes and improvements Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 01/26] net/ntnic: remove usage of the variable-length arrays Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 02/26] net/ntnic: handle string truncations when using strlcpy Oleksandr Kolomeiets
2025-05-05 7:12 ` Oleksandr Kolomeiets [this message]
2025-05-05 7:12 ` [PATCH v2 04/26] net/ntnic: remove extra memset Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 05/26] net/ntnic: include all queues into statistics Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 06/26] net/ntnic: avoid misleading variable names Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 07/26] net/ntnic: apply packing to the structure Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 08/26] net/ntnic: correct misspelled variable names Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 09/26] net/ntnic: improve logging format specifiers Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 10/26] net/ntnic: remove usless expressions Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 11/26] net/ntnic: remove unused code Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 12/26] net/ntnic: remove usless part of conditional expression Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 13/26] net/ntnic: add error logging for hsh Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 14/26] net/ntnic: add explicitly specificator Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 15/26] net/ntnic: add handle memory allocation failures Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 16/26] net/ntnic: remove redundant initialization Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 17/26] net/ntnic: enhance null checks and assertions Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 18/26] net/ntnic: add return value check Oleksandr Kolomeiets
2025-05-05 7:12 ` [PATCH v2 19/26] net/ntnic: remove redundant assignments and branching Oleksandr Kolomeiets
2025-05-05 7:13 ` [PATCH v2 20/26] net/ntnic: rework array usage Oleksandr Kolomeiets
2025-05-05 7:13 ` [PATCH v2 21/26] net/ntnic: avoid divide by zero Oleksandr Kolomeiets
2025-05-05 7:13 ` [PATCH v2 22/26] net/ntnic: remove unnecessary void cast Oleksandr Kolomeiets
2025-05-05 7:13 ` [PATCH v2 23/26] net/ntnic: remove unnecessary memset Oleksandr Kolomeiets
2025-05-05 7:13 ` [PATCH v2 24/26] net/ntnic: add null verification Oleksandr Kolomeiets
2025-05-05 7:13 ` [PATCH v2 25/26] net/ntnic: avoid possible deadlock Oleksandr Kolomeiets
2025-05-05 7:13 ` [PATCH v2 26/26] net/ntnic: fix operation with rte ring queue Oleksandr Kolomeiets
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250505071309.586015-4-okl-plv@napatech.com \
--to=okl-plv@napatech.com \
--cc=ckm@napatech.com \
--cc=dev@dpdk.org \
--cc=mko-plv@napatech.com \
--cc=sil-plv@napatech.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).