[PATCH v1 25/32] net/ntnic: add SPI v3 support for FPGA

Stephen Hemminger stephen at networkplumber.org
Sat Feb 22 20:21:23 CET 2025


On Thu, 20 Feb 2025 23:03:49 +0100
Serhii Iliushyk <sil-plv at napatech.com> wrote:

> +/*
> + * Send Tx data using the SPIM module and receive any data using the SPIS module.
> + * The data are sent and received being wrapped into a SPI v3 container.
> + */
> +int nthw_spi_v3_transfer(nthw_spi_v3_t *p, uint16_t opcode, struct tx_rx_buf *tx_buf,
> +	struct tx_rx_buf *rx_buf)
> +{
> +	const uint16_t max_payload_rx_size = rx_buf->size;
> +	int result = 0;
> +
> +#pragma pack(push, 1)
> +	union {
> +		uint32_t raw;
> +
> +		struct {
> +			uint16_t opcode;
> +			uint16_t size;
> +		};
> +	} spi_tx_hdr;
> +
> +	union {
> +		uint32_t raw;
> +
> +		struct {
> +			uint16_t error_code;
> +			uint16_t size;
> +		};
> +	} spi_rx_hdr;
> +
> +#pragma pack(pop)

Use of pragma's is strongly discouraged. For packed data use __rte_packed_begin, __rte_packed_end.
Not sure why packing is needed here at all. The union will result in the same


More information about the dev mailing list