[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] x86/MSI: use standard C types in structures/unions


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 21 Feb 2023 14:27:27 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w9qlElWTRRv0iSVXLMjPiy8BHJYHZmIhdJ27iGx102g=; b=QB/3zvvSEfER0utsLjwoTSNOk3tK8o7l84Ib1OsJeq6TcFgetvxzagDsUkisqlKB1gUjhVI3S2Vkvw7XB0K+OljTAyKG/lFe39xa4FvpOYKupQK0xKQ3uCPA9eS9B8slDUjrdhN5ddUPYSLgLUqaQeJHY8HXGq5vBPvFj0MkJGMjohdK53pFae6CI0a9BAgaLyWQlJyYxFoG7z/p1tVZ4FNFWsR+56nWZM6Hkjl88hgzf03KDjBrpU3JRJvBBunl6dk15ZZGAnhKgLjVRmnGkq3O6iQFSl8Fwqz57w7xytcQeCEGLJG4PE9T/91+TbS42vjz8wIt3aEBjPWlK0ivag==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B0THMarJaoI+GZ/hSfVadZ2h8b+vlXevNBWxh9J7D5EMhjHNMxm6OQQww6QZoK5DMgjEwMNOkautlncJRztrgnAPjSNimvlHVtnUiEg0U31RNT8JY605fkDGg5M5TS97ygjJVMyNP9QG5aWs/uwUTJEuu57gOBCvwE/EaHu0agO4xHnpOf392wKYFagriMPUpMWAEkd3qZ/DcFoEdMjl+vCPbI9UwCj6g6FFPaTXY6mh0zypszwfK96zQiSFgOdVh+69faRbQ+38f5Y/HaUR+bo+gYc8Ycua7JTJXE49Ku3ohQ4TMGJTkeE85fA91vLuLkz98Fu+ICiB8C98wZdpqw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 21 Feb 2023 13:27:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Consolidate this to use exclusively standard types, and change
indentation style to Xen's there at the same time (the file already had
a mix of styles).

While there
- switch boolean fields to use bool,
- drop the notion of big-endian bitfields being a thing on x86,
- drop the names for reserved fields,
- adjust the comment on "dest32".

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Make secondary adjustments ("While there ..." above).

--- a/xen/arch/x86/include/asm/msi.h
+++ b/xen/arch/x86/include/asm/msi.h
@@ -66,15 +66,15 @@ struct msi_info {
 };
 
 struct msi_msg {
-       union {
-               u64     address; /* message address */
-               struct {
-                       u32     address_lo; /* message address low 32 bits */
-                       u32     address_hi; /* message address high 32 bits */
-               };
-       };
-       u32     data;           /* 16 bits of msi message data */
-       u32     dest32;         /* used when Interrupt Remapping with EIM is 
enabled */
+    union {
+        uint64_t address; /* message address */
+        struct {
+            uint32_t address_lo; /* message address low 32 bits */
+            uint32_t address_hi; /* message address high 32 bits */
+        };
+    };
+    uint32_t data;        /* 16 bits of msi message data */
+    uint32_t dest32;      /* used when Interrupt Remapping is enabled */
 };
 
 struct irq_desc;
@@ -94,35 +94,35 @@ extern int pci_restore_msi_state(struct
 extern int pci_reset_msix_state(struct pci_dev *pdev);
 
 struct msi_desc {
-       struct msi_attrib {
-               __u8    type;           /* {0: unused, 5h:MSI, 11h:MSI-X} */
-               __u8    pos;            /* Location of the MSI capability */
-               __u8    maskbit : 1;    /* mask/pending bit supported ?   */
-               __u8    is_64   : 1;    /* Address size: 0=32bit 1=64bit  */
-               __u8    host_masked : 1;
-               __u8    guest_masked : 1;
-               __u16   entry_nr;       /* specific enabled entry         */
-       } msi_attrib;
-
-       bool irte_initialized;
-       uint8_t gvec;                   /* guest vector. valid when pi_desc 
isn't NULL */
-       const struct pi_desc *pi_desc;  /* pointer to posted descriptor */
-
-       struct list_head list;
-
-       union {
-               void __iomem *mask_base;/* va for the entry in mask table */
-               struct {
-                       unsigned int nvec;/* number of vectors            */
-                       unsigned int mpos;/* location of mask register    */
-               } msi;
-               unsigned int hpet_id;   /* HPET (dev is NULL)             */
-       };
-       struct pci_dev *dev;
-       int irq;
-       int remap_index;                /* index in interrupt remapping table */
+    struct msi_attrib {
+        uint8_t type;        /* {0: unused, 5h:MSI, 11h:MSI-X} */
+        uint8_t pos;         /* Location of the MSI capability */
+        bool maskbit      : 1; /* mask/pending bit supported ?   */
+        bool is_64        : 1; /* Address size: 0=32bit 1=64bit  */
+        bool host_masked  : 1;
+        bool guest_masked : 1;
+        uint16_t entry_nr;   /* specific enabled entry */
+    } msi_attrib;
+
+    bool irte_initialized;
+    uint8_t gvec;            /* guest vector. valid when pi_desc isn't NULL */
+    const struct pi_desc *pi_desc; /* pointer to posted descriptor */
+
+    struct list_head list;
+
+    union {
+        void __iomem *mask_base; /* va for the entry in mask table */
+        struct {
+            unsigned int nvec; /* number of vectors */
+            unsigned int mpos; /* location of mask register */
+        } msi;
+        unsigned int hpet_id; /* HPET (dev is NULL) */
+    };
+    struct pci_dev *dev;
+    int irq;
+    int remap_index;         /* index in interrupt remapping table */
 
-       struct msi_msg msg;             /* Last set MSI message */
+    struct msi_msg msg;      /* Last set MSI message */
 };
 
 /*
@@ -179,49 +179,27 @@ int msi_free_irq(struct msi_desc *entry)
  */
 
 struct __packed msg_data {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-       __u32   vector          :  8;
-       __u32   delivery_mode   :  3;   /* 000b: FIXED | 001b: lowest prior */
-       __u32   reserved_1      :  3;
-       __u32   level           :  1;   /* 0: deassert | 1: assert */
-       __u32   trigger         :  1;   /* 0: edge | 1: level */
-       __u32   reserved_2      : 16;
-#elif defined(__BIG_ENDIAN_BITFIELD)
-       __u32   reserved_2      : 16;
-       __u32   trigger         :  1;   /* 0: edge | 1: level */
-       __u32   level           :  1;   /* 0: deassert | 1: assert */
-       __u32   reserved_1      :  3;
-       __u32   delivery_mode   :  3;   /* 000b: FIXED | 001b: lowest prior */
-       __u32   vector          :  8;
-#else
-#error "Bitfield endianness not defined! Check your byteorder.h"
-#endif
+    uint32_t vector        :  8;
+    uint32_t delivery_mode :  3;    /* 000b: FIXED | 001b: lowest prior */
+    uint32_t               :  3;
+    bool level             :  1;    /* 0: deassert | 1: assert */
+    bool trigger           :  1;    /* 0: edge | 1: level */
+    uint32_t               : 16;
 };
 
 struct __packed msg_address {
-       union {
-               struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-                       __u32   reserved_1      :  2;
-                       __u32   dest_mode       :  1;   /*0:physic | 1:logic */
-                       __u32   redirection_hint:  1;   /*0: dedicated CPU
-                                                         1: lowest priority */
-                       __u32   reserved_2      :  4;
-                       __u32   dest_id         : 24;   /* Destination ID */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-                       __u32   dest_id         : 24;   /* Destination ID */
-                       __u32   reserved_2      :  4;
-                       __u32   redirection_hint:  1;   /*0: dedicated CPU
-                                                         1: lowest priority */
-                       __u32   dest_mode       :  1;   /*0:physic | 1:logic */
-                       __u32   reserved_1      :  2;
-#else
-#error "Bitfield endianness not defined! Check your byteorder.h"
-#endif
-               }u;
-                       __u32  value;
-       }lo_address;
-       __u32   hi_address;
+    union {
+        struct {
+            uint32_t              :  2;
+            bool dest_mode        :  1; /* 0:phys | 1:logic */
+            bool redirection_hint :  1; /* 0: dedicated CPU
+                                           1: lowest priority */
+            uint32_t              :  4;
+            uint32_t dest_id      : 24; /* Destination ID */
+        } u;
+        uint32_t value;
+    } lo_address;
+    uint32_t hi_address;
 };
 
 #define MAX_MSIX_TABLE_ENTRIES  (PCI_MSIX_FLAGS_QSIZE + 1)



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.