diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/uapi/linux/mic_common.h | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/include/uapi/linux/mic_common.h b/include/uapi/linux/mic_common.h index 17e7d95e4f53..6eb40244e019 100644 --- a/include/uapi/linux/mic_common.h +++ b/include/uapi/linux/mic_common.h | |||
| @@ -23,12 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | #include <linux/virtio_ring.h> | 24 | #include <linux/virtio_ring.h> |
| 25 | 25 | ||
| 26 | #ifndef __KERNEL__ | 26 | #define __mic_align(a, x) (((a) + (x) - 1) & ~((x) - 1)) |
| 27 | #define ALIGN(a, x) (((a) + (x) - 1) & ~((x) - 1)) | ||
| 28 | #define __aligned(x) __attribute__ ((aligned(x))) | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #define mic_aligned_size(x) ALIGN(sizeof(x), 8) | ||
| 32 | 27 | ||
| 33 | /** | 28 | /** |
| 34 | * struct mic_device_desc: Virtio device information shared between the | 29 | * struct mic_device_desc: Virtio device information shared between the |
| @@ -48,8 +43,8 @@ struct mic_device_desc { | |||
| 48 | __u8 feature_len; | 43 | __u8 feature_len; |
| 49 | __u8 config_len; | 44 | __u8 config_len; |
| 50 | __u8 status; | 45 | __u8 status; |
| 51 | __u64 config[0]; | 46 | __le64 config[0]; |
| 52 | } __aligned(8); | 47 | } __attribute__ ((aligned(8))); |
| 53 | 48 | ||
| 54 | /** | 49 | /** |
| 55 | * struct mic_device_ctrl: Per virtio device information in the device page | 50 | * struct mic_device_ctrl: Per virtio device information in the device page |
| @@ -66,7 +61,7 @@ struct mic_device_desc { | |||
| 66 | * @h2c_vdev_db: The doorbell number to be used by host. Set by guest. | 61 | * @h2c_vdev_db: The doorbell number to be used by host. Set by guest. |
| 67 | */ | 62 | */ |
| 68 | struct mic_device_ctrl { | 63 | struct mic_device_ctrl { |
| 69 | __u64 vdev; | 64 | __le64 vdev; |
| 70 | __u8 config_change; | 65 | __u8 config_change; |
| 71 | __u8 vdev_reset; | 66 | __u8 vdev_reset; |
| 72 | __u8 guest_ack; | 67 | __u8 guest_ack; |
| @@ -74,7 +69,7 @@ struct mic_device_ctrl { | |||
| 74 | __u8 used_address_updated; | 69 | __u8 used_address_updated; |
| 75 | __s8 c2h_vdev_db; | 70 | __s8 c2h_vdev_db; |
| 76 | __s8 h2c_vdev_db; | 71 | __s8 h2c_vdev_db; |
| 77 | } __aligned(8); | 72 | } __attribute__ ((aligned(8))); |
| 78 | 73 | ||
| 79 | /** | 74 | /** |
| 80 | * struct mic_bootparam: Virtio device independent information in device page | 75 | * struct mic_bootparam: Virtio device independent information in device page |
| @@ -87,13 +82,13 @@ struct mic_device_ctrl { | |||
| 87 | * @shutdown_card: Set to 1 by the host when a card shutdown is initiated | 82 | * @shutdown_card: Set to 1 by the host when a card shutdown is initiated |
| 88 | */ | 83 | */ |
| 89 | struct mic_bootparam { | 84 | struct mic_bootparam { |
| 90 | __u32 magic; | 85 | __le32 magic; |
| 91 | __s8 c2h_shutdown_db; | 86 | __s8 c2h_shutdown_db; |
| 92 | __s8 h2c_shutdown_db; | 87 | __s8 h2c_shutdown_db; |
| 93 | __s8 h2c_config_db; | 88 | __s8 h2c_config_db; |
| 94 | __u8 shutdown_status; | 89 | __u8 shutdown_status; |
| 95 | __u8 shutdown_card; | 90 | __u8 shutdown_card; |
| 96 | } __aligned(8); | 91 | } __attribute__ ((aligned(8))); |
| 97 | 92 | ||
| 98 | /** | 93 | /** |
| 99 | * struct mic_device_page: High level representation of the device page | 94 | * struct mic_device_page: High level representation of the device page |
| @@ -116,10 +111,10 @@ struct mic_device_page { | |||
| 116 | * @num: The number of entries in the virtio_ring | 111 | * @num: The number of entries in the virtio_ring |
| 117 | */ | 112 | */ |
| 118 | struct mic_vqconfig { | 113 | struct mic_vqconfig { |
| 119 | __u64 address; | 114 | __le64 address; |
| 120 | __u64 used_address; | 115 | __le64 used_address; |
| 121 | __u16 num; | 116 | __le16 num; |
| 122 | } __aligned(8); | 117 | } __attribute__ ((aligned(8))); |
| 123 | 118 | ||
| 124 | /* | 119 | /* |
| 125 | * The alignment to use between consumer and producer parts of vring. | 120 | * The alignment to use between consumer and producer parts of vring. |
| @@ -154,7 +149,7 @@ struct mic_vqconfig { | |||
| 154 | */ | 149 | */ |
| 155 | struct _mic_vring_info { | 150 | struct _mic_vring_info { |
| 156 | __u16 avail_idx; | 151 | __u16 avail_idx; |
| 157 | int magic; | 152 | __le32 magic; |
| 158 | }; | 153 | }; |
| 159 | 154 | ||
| 160 | /** | 155 | /** |
| @@ -173,15 +168,13 @@ struct mic_vring { | |||
| 173 | int len; | 168 | int len; |
| 174 | }; | 169 | }; |
| 175 | 170 | ||
| 176 | #define mic_aligned_desc_size(d) ALIGN(mic_desc_size(d), 8) | 171 | #define mic_aligned_desc_size(d) __mic_align(mic_desc_size(d), 8) |
| 177 | 172 | ||
| 178 | #ifndef INTEL_MIC_CARD | 173 | #ifndef INTEL_MIC_CARD |
| 179 | static inline unsigned mic_desc_size(const struct mic_device_desc *desc) | 174 | static inline unsigned mic_desc_size(const struct mic_device_desc *desc) |
| 180 | { | 175 | { |
| 181 | return mic_aligned_size(*desc) | 176 | return sizeof(*desc) + desc->num_vq * sizeof(struct mic_vqconfig) |
| 182 | + desc->num_vq * mic_aligned_size(struct mic_vqconfig) | 177 | + desc->feature_len * 2 + desc->config_len; |
| 183 | + desc->feature_len * 2 | ||
| 184 | + desc->config_len; | ||
| 185 | } | 178 | } |
| 186 | 179 | ||
| 187 | static inline struct mic_vqconfig * | 180 | static inline struct mic_vqconfig * |
| @@ -201,8 +194,7 @@ static inline __u8 *mic_vq_configspace(const struct mic_device_desc *desc) | |||
| 201 | } | 194 | } |
| 202 | static inline unsigned mic_total_desc_size(struct mic_device_desc *desc) | 195 | static inline unsigned mic_total_desc_size(struct mic_device_desc *desc) |
| 203 | { | 196 | { |
| 204 | return mic_aligned_desc_size(desc) + | 197 | return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl); |
| 205 | mic_aligned_size(struct mic_device_ctrl); | ||
| 206 | } | 198 | } |
| 207 | #endif | 199 | #endif |
| 208 | 200 | ||
