xref: /linux/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h (revision c06b6cde2a1c3bcbb561bd57bb6f34eae9030921)
1 /*
2  * Copyright (c) 2018-2021 Advanced Micro Devices, Inc. All rights reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef AMDGV_SRIOV_MSG__H_
24 #define AMDGV_SRIOV_MSG__H_
25 
26 #define AMD_SRIOV_MSG_SIZE_KB                           1
27 
28 /*
29  * layout v1
30  * 0           64KB        65KB        66KB           68KB                   132KB
31  * |   VBIOS   |   PF2VF   |   VF2PF   |   Bad Page   | RAS Telemetry Region | ...
32  * |   64KB    |   1KB     |   1KB     |   2KB        | 64KB                 | ...
33  */
34 
35 /*
36  * layout v2 (offsets are dynamically allocated and the offsets below are examples)
37  * 0           1KB         64KB        65KB        66KB           68KB                   132KB
38  * |  INITD_H  |   VBIOS   |   PF2VF   |   VF2PF   |   Bad Page   | RAS Telemetry Region | ...
39  * |   1KB     |   64KB    |   1KB     |   1KB     |   2KB        | 64KB                 | ...
40  *
41  * Note: PF2VF + VF2PF + Bad Page = DataExchange region (allocated contiguously)
42  */
43 
44 /* v1 layout sizes */
45 #define AMD_SRIOV_MSG_VBIOS_SIZE_KB_V1			64
46 #define AMD_SRIOV_MSG_PF2VF_SIZE_KB_V1			1
47 #define AMD_SRIOV_MSG_VF2PF_SIZE_KB_V1			1
48 #define AMD_SRIOV_MSG_BAD_PAGE_SIZE_KB_V1		2
49 #define AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1		64
50 #define AMD_SRIOV_MSG_DATAEXCHANGE_SIZE_KB_V1		\
51 	(AMD_SRIOV_MSG_PF2VF_SIZE_KB_V1 + AMD_SRIOV_MSG_VF2PF_SIZE_KB_V1 + \
52 	 AMD_SRIOV_MSG_BAD_PAGE_SIZE_KB_V1)
53 
54 /* v1 offsets */
55 #define AMD_SRIOV_MSG_VBIOS_OFFSET_V1			0
56 #define AMD_SRIOV_MSG_DATAEXCHANGE_OFFSET_KB_V1		AMD_SRIOV_MSG_VBIOS_SIZE_KB_V1
57 #define AMD_SRIOV_MSG_TMR_OFFSET_KB			2048
58 #define AMD_SRIOV_MSG_PF2VF_OFFSET_KB_V1		AMD_SRIOV_MSG_DATAEXCHANGE_OFFSET_KB_V1
59 #define AMD_SRIOV_MSG_VF2PF_OFFSET_KB_V1		\
60 	(AMD_SRIOV_MSG_PF2VF_OFFSET_KB_V1 + AMD_SRIOV_MSG_SIZE_KB)
61 #define AMD_SRIOV_MSG_BAD_PAGE_OFFSET_KB_V1		\
62 	(AMD_SRIOV_MSG_VF2PF_OFFSET_KB_V1 + AMD_SRIOV_MSG_SIZE_KB)
63 #define AMD_SRIOV_MSG_RAS_TELEMETRY_OFFSET_KB_V1	\
64 	(AMD_SRIOV_MSG_BAD_PAGE_OFFSET_KB_V1 + AMD_SRIOV_MSG_BAD_PAGE_SIZE_KB_V1)
65 #define AMD_SRIOV_MSG_INIT_DATA_TOT_SIZE_KB_V1		\
66 	(AMD_SRIOV_MSG_VBIOS_SIZE_KB_V1 + AMD_SRIOV_MSG_DATAEXCHANGE_SIZE_KB_V1 + \
67 	 AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1)
68 
69 enum amd_sriov_crit_region_version {
70 	GPU_CRIT_REGION_V1 = 1,
71 	GPU_CRIT_REGION_V2 = 2,
72 };
73 
74 /* v2 layout offset enum (in order of allocation) */
75 enum amd_sriov_msg_table_id_enum {
76 	AMD_SRIOV_MSG_IPD_TABLE_ID = 0,
77 	AMD_SRIOV_MSG_VBIOS_IMG_TABLE_ID,
78 	AMD_SRIOV_MSG_RAS_TELEMETRY_TABLE_ID,
79 	AMD_SRIOV_MSG_DATAEXCHANGE_TABLE_ID,
80 	AMD_SRIOV_MSG_BAD_PAGE_INFO_TABLE_ID,
81 	AMD_SRIOV_MSG_INITD_H_TABLE_ID,
82 	AMD_SRIOV_MSG_MAX_TABLE_ID,
83 };
84 
85 struct amd_sriov_msg_init_data_header {
86 	char     signature[4];  /* "INDA"  */
87 	uint32_t version;
88 	uint32_t checksum;
89 	uint32_t initdata_offset; /* 0 */
90 	uint32_t initdata_size_in_kb; /* 5MB */
91 	uint32_t valid_tables;
92 	uint32_t vbios_img_offset;
93 	uint32_t vbios_img_size_in_kb;
94 	uint32_t dataexchange_offset;
95 	uint32_t dataexchange_size_in_kb;
96 	uint32_t ras_tele_info_offset;
97 	uint32_t ras_tele_info_size_in_kb;
98 	uint32_t ip_discovery_offset;
99 	uint32_t ip_discovery_size_in_kb;
100 	uint32_t bad_page_info_offset;
101 	uint32_t bad_page_size_in_kb;
102 	uint32_t reserved[8];
103 };
104 
105 /*
106  * PF2VF history log:
107  * v1 defined in amdgim
108  * v2 current
109  *
110  * VF2PF history log:
111  * v1 defined in amdgim
112  * v2 defined in amdgim
113  * v3 current
114  */
115 #define AMD_SRIOV_MSG_FW_VRAM_PF2VF_VER 2
116 #define AMD_SRIOV_MSG_FW_VRAM_VF2PF_VER 3
117 
118 #define AMD_SRIOV_MSG_RESERVE_UCODE 24
119 
120 #define AMD_SRIOV_MSG_RESERVE_VCN_INST 4
121 
122 enum amd_sriov_ucode_engine_id {
123 	AMD_SRIOV_UCODE_ID_VCE = 0,
124 	AMD_SRIOV_UCODE_ID_UVD,
125 	AMD_SRIOV_UCODE_ID_MC,
126 	AMD_SRIOV_UCODE_ID_ME,
127 	AMD_SRIOV_UCODE_ID_PFP,
128 	AMD_SRIOV_UCODE_ID_CE,
129 	AMD_SRIOV_UCODE_ID_RLC,
130 	AMD_SRIOV_UCODE_ID_RLC_SRLC,
131 	AMD_SRIOV_UCODE_ID_RLC_SRLG,
132 	AMD_SRIOV_UCODE_ID_RLC_SRLS,
133 	AMD_SRIOV_UCODE_ID_MEC,
134 	AMD_SRIOV_UCODE_ID_MEC2,
135 	AMD_SRIOV_UCODE_ID_SOS,
136 	AMD_SRIOV_UCODE_ID_ASD,
137 	AMD_SRIOV_UCODE_ID_TA_RAS,
138 	AMD_SRIOV_UCODE_ID_TA_XGMI,
139 	AMD_SRIOV_UCODE_ID_SMC,
140 	AMD_SRIOV_UCODE_ID_SDMA,
141 	AMD_SRIOV_UCODE_ID_SDMA2,
142 	AMD_SRIOV_UCODE_ID_VCN,
143 	AMD_SRIOV_UCODE_ID_DMCU,
144 	AMD_SRIOV_UCODE_ID__MAX
145 };
146 
147 #pragma pack(push, 1) // PF2VF / VF2PF data areas are byte packed
148 
149 union amd_sriov_msg_feature_flags {
150 	struct {
151 		uint32_t error_log_collect	: 1;
152 		uint32_t host_load_ucodes	: 1;
153 		uint32_t host_flr_vramlost	: 1;
154 		uint32_t mm_bw_management	: 1;
155 		uint32_t pp_one_vf_mode		: 1;
156 		uint32_t reg_indirect_acc	: 1;
157 		uint32_t av1_support		: 1;
158 		uint32_t vcn_rb_decouple	: 1;
159 		uint32_t mes_info_dump_enable	: 1;
160 		uint32_t ras_caps		: 1;
161 		uint32_t ras_telemetry		: 1;
162 		uint32_t ras_cper		: 1;
163 		uint32_t xgmi_ta_ext_peer_link	: 1;
164 		uint32_t xgmi_connected_to_cpu  : 1;
165 		uint32_t ptl_support		: 1;
166 		uint32_t unitid_support		: 1;
167 		uint32_t reserved		: 16;
168 	} flags;
169 	uint32_t all;
170 };
171 
172 union amd_sriov_reg_access_flags {
173 	struct {
174 		uint32_t vf_reg_access_ih		: 1;
175 		uint32_t vf_reg_access_mmhub		: 1;
176 		uint32_t vf_reg_access_gc		: 1;
177 		uint32_t vf_reg_access_l1_tlb_cntl	: 1;
178 		uint32_t vf_reg_access_sq_config	: 1;
179 		uint32_t reserved			: 27;
180 	} flags;
181 	uint32_t all;
182 };
183 
184 union amd_sriov_ras_caps {
185 	struct {
186 		uint64_t block_umc			: 1;
187 		uint64_t block_sdma			: 1;
188 		uint64_t block_gfx			: 1;
189 		uint64_t block_mmhub			: 1;
190 		uint64_t block_athub			: 1;
191 		uint64_t block_pcie_bif			: 1;
192 		uint64_t block_hdp			: 1;
193 		uint64_t block_xgmi_wafl		: 1;
194 		uint64_t block_df			: 1;
195 		uint64_t block_smn			: 1;
196 		uint64_t block_sem			: 1;
197 		uint64_t block_mp0			: 1;
198 		uint64_t block_mp1			: 1;
199 		uint64_t block_fuse			: 1;
200 		uint64_t block_mca			: 1;
201 		uint64_t block_vcn			: 1;
202 		uint64_t block_jpeg			: 1;
203 		uint64_t block_ih			: 1;
204 		uint64_t block_mpio			: 1;
205 		uint64_t block_mmsch			: 1;
206 		uint64_t poison_propogation_mode	: 1;
207 		uint64_t uniras_supported		: 1;
208 		uint64_t reserved			: 42;
209 	} bits;
210 	uint64_t all;
211 };
212 
213 union amd_sriov_msg_os_info {
214 	struct {
215 		uint32_t windows  : 1;
216 		uint32_t reserved : 31;
217 	} info;
218 	uint32_t all;
219 };
220 
221 struct amd_sriov_msg_uuid_info {
222 	union {
223 		struct {
224 			uint32_t did	: 16;
225 			uint32_t fcn	: 8;
226 			uint32_t asic_7 : 8;
227 		};
228 		uint32_t time_low;
229 	};
230 
231 	struct {
232 		uint32_t time_mid  : 16;
233 		uint32_t time_high : 12;
234 		uint32_t version   : 4;
235 	};
236 
237 	struct {
238 		struct {
239 			uint8_t clk_seq_hi : 6;
240 			uint8_t variant    : 2;
241 		};
242 		union {
243 			uint8_t clk_seq_low;
244 			uint8_t asic_6;
245 		};
246 		uint16_t asic_4;
247 	};
248 
249 	uint32_t asic_0;
250 };
251 
252 struct amd_sriov_msg_pf2vf_info_header {
253 	/* the total structure size in byte */
254 	uint32_t size;
255 	/* version of this structure, written by the HOST */
256 	uint32_t version;
257 	/* reserved */
258 	uint32_t reserved[2];
259 };
260 
261 #define AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE (59)
262 struct amd_sriov_msg_pf2vf_info {
263 	/* header contains size and version */
264 	struct amd_sriov_msg_pf2vf_info_header header;
265 	/* use private key from mailbox 2 to create checksum */
266 	uint32_t checksum;
267 	/* The features flags of the HOST driver supports */
268 	union amd_sriov_msg_feature_flags feature_flags;
269 	/* (max_width * max_height * fps) / (16 * 16) */
270 	uint32_t hevc_enc_max_mb_per_second;
271 	/* (max_width * max_height) / (16 * 16) */
272 	uint32_t hevc_enc_max_mb_per_frame;
273 	/* (max_width * max_height * fps) / (16 * 16) */
274 	uint32_t avc_enc_max_mb_per_second;
275 	/* (max_width * max_height) / (16 * 16) */
276 	uint32_t avc_enc_max_mb_per_frame;
277 	/* MEC FW position in BYTE from the start of VF visible frame buffer */
278 	uint64_t mecfw_offset;
279 	/* MEC FW size in BYTE */
280 	uint32_t mecfw_size;
281 	/* UVD FW position in BYTE from the start of VF visible frame buffer */
282 	uint64_t uvdfw_offset;
283 	/* UVD FW size in BYTE */
284 	uint32_t uvdfw_size;
285 	/* VCE FW position in BYTE from the start of VF visible frame buffer */
286 	uint64_t vcefw_offset;
287 	/* VCE FW size in BYTE */
288 	uint32_t vcefw_size;
289 	/* Bad pages block position in BYTE */
290 	uint32_t bp_block_offset_low;
291 	uint32_t bp_block_offset_high;
292 	/* Bad pages block size in BYTE */
293 	uint32_t bp_block_size;
294 	/* frequency for VF to update the VF2PF area in msec, 0 = manual */
295 	uint32_t vf2pf_update_interval_ms;
296 	/* identification in ROCm SMI */
297 	uint64_t uuid;
298 	uint32_t pad;
299 	/* flags to indicate which register access method VF should use */
300 	union amd_sriov_reg_access_flags reg_access_flags;
301 	/* MM BW management */
302 	struct {
303 		uint32_t decode_max_dimension_pixels;
304 		uint32_t decode_max_frame_pixels;
305 		uint32_t encode_max_dimension_pixels;
306 		uint32_t encode_max_frame_pixels;
307 	} mm_bw_management[AMD_SRIOV_MSG_RESERVE_VCN_INST];
308 	/* UUID info */
309 	struct amd_sriov_msg_uuid_info uuid_info;
310 	/* PCIE atomic ops support flag */
311 	uint32_t pcie_atomic_ops_support_flags;
312 	/* Portion of GPU memory occupied by VF.  MAX value is 65535, but set to uint32_t to maintain alignment with reserved size */
313 	uint32_t gpu_capacity;
314 	/* vf bdf on host pci tree for debug only */
315 	uint32_t bdf_on_host;
316 	uint32_t more_bp;	//Reserved for future use.
317 	union amd_sriov_ras_caps ras_en_caps;
318 	union amd_sriov_ras_caps ras_telemetry_en_caps;
319 	/* PTL status response for guest */
320 	uint32_t ptl_enabled;        // PTL enable status: 0=disabled, 1=enabled
321 	uint32_t ptl_pref_format1;   // Current preferred format 1
322 	uint32_t ptl_pref_format2;   // Current preferred format 2
323 	/* unit ID assigned by host; vf_idx [0..254] maps to unitid [1..255] (0 = pf) */
324 	uint8_t unitid;
325 	uint8_t padding[3];  //use the 3 bytes to align
326 
327 	/* reserved */
328 	uint32_t reserved[256 - AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE];
329 } __packed;
330 
331 struct amd_sriov_msg_vf2pf_info_header {
332 	/* the total structure size in byte */
333 	uint32_t size;
334 	/* version of this structure, written by the guest */
335 	uint32_t version;
336 	/* reserved */
337 	uint32_t reserved[2];
338 };
339 
340 #define AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE (73)
341 struct amd_sriov_msg_vf2pf_info {
342 	/* header contains size and version */
343 	struct amd_sriov_msg_vf2pf_info_header header;
344 	uint32_t checksum;
345 	/* driver version */
346 	uint8_t driver_version[64];
347 	/* driver certification, 1=WHQL, 0=None */
348 	uint32_t driver_cert;
349 	/* guest OS type and version */
350 	union amd_sriov_msg_os_info os_info;
351 	/* guest fb information in the unit of MB */
352 	uint32_t fb_usage;
353 	/* guest gfx engine usage percentage */
354 	uint32_t gfx_usage;
355 	/* guest gfx engine health percentage */
356 	uint32_t gfx_health;
357 	/* guest compute engine usage percentage */
358 	uint32_t compute_usage;
359 	/* guest compute engine health percentage */
360 	uint32_t compute_health;
361 	/* guest avc engine usage percentage. 0xffff means N/A */
362 	uint32_t avc_enc_usage;
363 	/* guest avc engine health percentage. 0xffff means N/A */
364 	uint32_t avc_enc_health;
365 	/* guest hevc engine usage percentage. 0xffff means N/A */
366 	uint32_t hevc_enc_usage;
367 	/* guest hevc engine usage percentage. 0xffff means N/A */
368 	uint32_t hevc_enc_health;
369 	/* combined encode/decode usage */
370 	uint32_t encode_usage;
371 	uint32_t decode_usage;
372 	/* Version of PF2VF that VF understands */
373 	uint32_t pf2vf_version_required;
374 	/* additional FB usage */
375 	uint32_t fb_vis_usage;
376 	uint32_t fb_vis_size;
377 	uint32_t fb_size;
378 	/* guest ucode data, each one is 1.25 Dword */
379 	struct {
380 		uint8_t id;
381 		uint32_t version;
382 	} ucode_info[AMD_SRIOV_MSG_RESERVE_UCODE];
383 	uint64_t dummy_page_addr;
384 	/* FB allocated for guest MES to record UQ info */
385 	uint64_t mes_info_addr;
386 	uint32_t mes_info_size;
387 	/* reserved */
388 	uint32_t reserved[256 - AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE];
389 } __packed;
390 
391 /* mailbox message send from guest to host  */
392 enum amd_sriov_mailbox_request_message {
393 	MB_REQ_MSG_REQ_GPU_INIT_ACCESS = 1,
394 	MB_REQ_MSG_REL_GPU_INIT_ACCESS,
395 	MB_REQ_MSG_REQ_GPU_FINI_ACCESS,
396 	MB_REQ_MSG_REL_GPU_FINI_ACCESS,
397 	MB_REQ_MSG_REQ_GPU_RESET_ACCESS,
398 	MB_REQ_MSG_REQ_GPU_INIT_DATA,
399 	MB_REQ_MSG_PSP_VF_CMD_RELAY,
400 
401 	MB_REQ_MSG_LOG_VF_ERROR = 200,
402 	MB_REQ_MSG_READY_TO_RESET = 201,
403 	MB_REQ_MSG_RAS_POISON = 202,
404 	MB_REQ_RAS_ERROR_COUNT = 203,
405 	MB_REQ_RAS_CPER_DUMP = 204,
406 	MB_REQ_RAS_BAD_PAGES = 205,
407 };
408 
409 /* mailbox message send from host to guest  */
410 enum amd_sriov_mailbox_response_message {
411 	MB_RES_MSG_CLR_MSG_BUF			= 0,
412 	MB_RES_MSG_READY_TO_ACCESS_GPU		= 1,
413 	MB_RES_MSG_FLR_NOTIFICATION		= 2,
414 	MB_RES_MSG_FLR_NOTIFICATION_COMPLETION  = 3,
415 	MB_RES_MSG_SUCCESS			= 4,
416 	MB_RES_MSG_FAIL				= 5,
417 	MB_RES_MSG_QUERY_ALIVE			= 6,
418 	MB_RES_MSG_GPU_INIT_DATA_READY		= 7,
419 	MB_RES_MSG_RAS_POISON_READY		= 8,
420 	MB_RES_MSG_PF_SOFT_FLR_NOTIFICATION	= 9,
421 	MB_RES_MSG_GPU_RMA			= 10,
422 	MB_RES_MSG_RAS_ERROR_COUNT_READY	= 11,
423 	MB_REQ_RAS_CPER_DUMP_READY		= 14,
424 	MB_RES_MSG_RAS_BAD_PAGES_READY		= 15,
425 	MB_RES_MSG_RAS_BAD_PAGES_NOTIFICATION	= 16,
426 	MB_RES_MSG_UNRECOV_ERR_NOTIFICATION	= 17,
427 	MB_RES_MSG_TEXT_MESSAGE			= 255
428 };
429 
430 enum amd_sriov_ras_telemetry_gpu_block {
431 	RAS_TELEMETRY_GPU_BLOCK_UMC		= 0,
432 	RAS_TELEMETRY_GPU_BLOCK_SDMA		= 1,
433 	RAS_TELEMETRY_GPU_BLOCK_GFX		= 2,
434 	RAS_TELEMETRY_GPU_BLOCK_MMHUB		= 3,
435 	RAS_TELEMETRY_GPU_BLOCK_ATHUB		= 4,
436 	RAS_TELEMETRY_GPU_BLOCK_PCIE_BIF	= 5,
437 	RAS_TELEMETRY_GPU_BLOCK_HDP		= 6,
438 	RAS_TELEMETRY_GPU_BLOCK_XGMI_WAFL	= 7,
439 	RAS_TELEMETRY_GPU_BLOCK_DF		= 8,
440 	RAS_TELEMETRY_GPU_BLOCK_SMN		= 9,
441 	RAS_TELEMETRY_GPU_BLOCK_SEM		= 10,
442 	RAS_TELEMETRY_GPU_BLOCK_MP0		= 11,
443 	RAS_TELEMETRY_GPU_BLOCK_MP1		= 12,
444 	RAS_TELEMETRY_GPU_BLOCK_FUSE		= 13,
445 	RAS_TELEMETRY_GPU_BLOCK_MCA		= 14,
446 	RAS_TELEMETRY_GPU_BLOCK_VCN		= 15,
447 	RAS_TELEMETRY_GPU_BLOCK_JPEG		= 16,
448 	RAS_TELEMETRY_GPU_BLOCK_IH		= 17,
449 	RAS_TELEMETRY_GPU_BLOCK_MPIO		= 18,
450 	RAS_TELEMETRY_GPU_BLOCK_COUNT		= 19,
451 };
452 
453 struct amd_sriov_ras_telemetry_header {
454 	uint32_t checksum;
455 	uint32_t used_size;
456 	uint32_t reserved[2];
457 };
458 
459 struct amd_sriov_ras_telemetry_error_count {
460 	struct {
461 		uint32_t ce_count;
462 		uint32_t ue_count;
463 		uint32_t de_count;
464 		uint32_t ce_overflow_count;
465 		uint32_t ue_overflow_count;
466 		uint32_t de_overflow_count;
467 		uint32_t reserved[6];
468 	} block[RAS_TELEMETRY_GPU_BLOCK_COUNT];
469 };
470 
471 struct amd_sriov_ras_cper_dump {
472 	uint32_t more;
473 	uint64_t overflow_count;
474 	uint64_t count;
475 	uint64_t wptr;
476 	uint32_t buf[];
477 };
478 
479 struct amd_sriov_ras_chk_criti {
480 	uint32_t hit;
481 };
482 
483 union amd_sriov_ras_host_push {
484 	struct amd_sriov_ras_telemetry_error_count error_count;
485 	struct amd_sriov_ras_cper_dump cper_dump;
486 	struct amd_sriov_ras_chk_criti chk_criti;
487 };
488 
489 #define AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE 4096
490 #define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (4096 * 13)
491 struct amd_sriov_uniras_shared_mem {
492 	uint8_t blocks_ecc_buf[AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE];
493 	uint8_t cmd_buf[AMD_SRIOV_UNIRAS_CMD_MAX_SIZE];
494 };
495 
496 struct amdsriov_ras_telemetry {
497 	struct amd_sriov_ras_telemetry_header header;
498 	union amd_sriov_ras_host_push body;
499 	struct amd_sriov_uniras_shared_mem uniras_shared_mem;
500 };
501 
502 /* version data stored in MAILBOX_MSGBUF_RCV_DW1 for future expansion */
503 enum amd_sriov_gpu_init_data_version {
504 	GPU_INIT_DATA_READY_V1 = 1,
505 };
506 
507 #pragma pack(pop) // Restore previous packing option
508 
509 /* checksum function between host and guest */
510 unsigned int amd_sriov_msg_checksum(void *obj, unsigned long obj_size, unsigned int key,
511 				    unsigned int checksum);
512 
513 /* assertion at compile time */
514 #ifdef __linux__
515 #define stringification(s)  _stringification(s)
516 #define _stringification(s) #s
517 
518 _Static_assert(
519 	sizeof(struct amd_sriov_msg_vf2pf_info) == AMD_SRIOV_MSG_SIZE_KB << 10,
520 	"amd_sriov_msg_vf2pf_info must be " stringification(AMD_SRIOV_MSG_SIZE_KB) " KB");
521 
522 _Static_assert(
523 	sizeof(struct amd_sriov_msg_pf2vf_info) == AMD_SRIOV_MSG_SIZE_KB << 10,
524 	"amd_sriov_msg_pf2vf_info must be " stringification(AMD_SRIOV_MSG_SIZE_KB) " KB");
525 
526 _Static_assert(AMD_SRIOV_MSG_RESERVE_UCODE % 4 == 0,
527 	       "AMD_SRIOV_MSG_RESERVE_UCODE must be multiple of 4");
528 
529 _Static_assert(AMD_SRIOV_MSG_RESERVE_UCODE > AMD_SRIOV_UCODE_ID__MAX,
530 	       "AMD_SRIOV_MSG_RESERVE_UCODE must be bigger than AMD_SRIOV_UCODE_ID__MAX");
531 
532 _Static_assert(
533 	sizeof(struct amdsriov_ras_telemetry) <= AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10,
534 "amdsriov_ras_telemetry must be " stringification(AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1) " KB");
535 
536 #undef _stringification
537 #undef stringification
538 #endif
539 
540 #endif /* AMDGV_SRIOV_MSG__H_ */
541