[v6,17/30] drivers/vdpa: replace packed attributes
Checks
Commit Message
MSVC struct packing is not compatible with GCC. Replace macro
__rte_packed with __rte_packed_begin to push existing pack value
and set packing to 1-byte and macro __rte_packed_end to restore
the pack value prior to the push.
Macro __rte_packed_end is deliberately utilized to trigger a
MSVC compiler warning if no existing packing has been pushed allowing
easy identification of locations where the __rte_packed_begin is
missing.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/vdpa/ifc/base/ifcvf.h | 4 ++--
drivers/vdpa/mlx5/mlx5_vdpa.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
Comments
On Tue, Nov 26, 2024 at 04:52:28PM -0800, Andre Muezerie wrote:
> MSVC struct packing is not compatible with GCC. Replace macro
> __rte_packed with __rte_packed_begin to push existing pack value
> and set packing to 1-byte and macro __rte_packed_end to restore
> the pack value prior to the push.
>
> Macro __rte_packed_end is deliberately utilized to trigger a
> MSVC compiler warning if no existing packing has been pushed allowing
> easy identification of locations where the __rte_packed_begin is
> missing.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
Reviewed-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
@@ -115,11 +115,11 @@ struct ifcvf_pci_common_cfg {
u32 queue_used_hi;
};
-struct ifcvf_net_config {
+__rte_packed_begin struct ifcvf_net_config {
u8 mac[6];
u16 status;
u16 max_virtqueue_pairs;
-} __rte_packed;
+} __rte_packed_end;
struct ifcvf_pci_mem_resource {
u64 phys_addr; /**< Physical address, 0 if not resource. */
@@ -90,13 +90,13 @@ enum mlx5_vdpa_task_type {
};
/* Generic task information and size must be multiple of 4B. */
-struct __rte_aligned(4) mlx5_vdpa_task {
+__rte_packed_begin struct __rte_aligned(4) mlx5_vdpa_task {
struct mlx5_vdpa_priv *priv;
enum mlx5_vdpa_task_type type;
RTE_ATOMIC(uint32_t) *remaining_cnt;
RTE_ATOMIC(uint32_t) *err_cnt;
uint32_t idx;
-} __rte_packed;
+} __rte_packed_end;
/* Generic mlx5_vdpa_c_thread information. */
struct mlx5_vdpa_c_thread {