xref: /openbmc/linux/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h (revision 34d6f206a88c2651d216bd3487ac956a40b2ba8e)
11721bc1bSBokun Zhang /*
2c649287aSBokun Zhang  * Copyright (c) 2018-2021 Advanced Micro Devices, Inc. All rights reserved.
31721bc1bSBokun Zhang  *
4c649287aSBokun Zhang  * Permission is hereby granted, free of charge, to any person obtaining a copy
5c649287aSBokun Zhang  * of this software and associated documentation files (the "Software"), to deal
6c649287aSBokun Zhang  * in the Software without restriction, including without limitation the rights
7c649287aSBokun Zhang  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8c649287aSBokun Zhang  * copies of the Software, and to permit persons to whom the Software is
9c649287aSBokun Zhang  * furnished to do so, subject to the following conditions:
101721bc1bSBokun Zhang  *
111721bc1bSBokun Zhang  * The above copyright notice and this permission notice shall be included in
121721bc1bSBokun Zhang  * all copies or substantial portions of the Software.
131721bc1bSBokun Zhang  *
141721bc1bSBokun Zhang  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151721bc1bSBokun Zhang  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c649287aSBokun Zhang  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17c649287aSBokun Zhang  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18c649287aSBokun Zhang  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19c649287aSBokun Zhang  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20c649287aSBokun Zhang  * THE SOFTWARE.
211721bc1bSBokun Zhang  */
221721bc1bSBokun Zhang 
231721bc1bSBokun Zhang #ifndef AMDGV_SRIOV_MSG__H_
241721bc1bSBokun Zhang #define AMDGV_SRIOV_MSG__H_
251721bc1bSBokun Zhang 
261721bc1bSBokun Zhang /* unit in kilobytes */
271721bc1bSBokun Zhang #define AMD_SRIOV_MSG_VBIOS_OFFSET	     0
281721bc1bSBokun Zhang #define AMD_SRIOV_MSG_VBIOS_SIZE_KB	     64
291721bc1bSBokun Zhang #define AMD_SRIOV_MSG_DATAEXCHANGE_OFFSET_KB AMD_SRIOV_MSG_VBIOS_SIZE_KB
301721bc1bSBokun Zhang #define AMD_SRIOV_MSG_DATAEXCHANGE_SIZE_KB   4
311721bc1bSBokun Zhang 
321721bc1bSBokun Zhang /*
331721bc1bSBokun Zhang  * layout
341721bc1bSBokun Zhang  * 0           64KB        65KB        66KB
351721bc1bSBokun Zhang  * |   VBIOS   |   PF2VF   |   VF2PF   |   Bad Page   | ...
361721bc1bSBokun Zhang  * |   64KB    |   1KB     |   1KB     |
371721bc1bSBokun Zhang  */
381721bc1bSBokun Zhang #define AMD_SRIOV_MSG_SIZE_KB                   1
391721bc1bSBokun Zhang #define AMD_SRIOV_MSG_PF2VF_OFFSET_KB           AMD_SRIOV_MSG_DATAEXCHANGE_OFFSET_KB
401721bc1bSBokun Zhang #define AMD_SRIOV_MSG_VF2PF_OFFSET_KB           (AMD_SRIOV_MSG_PF2VF_OFFSET_KB + AMD_SRIOV_MSG_SIZE_KB)
411721bc1bSBokun Zhang #define AMD_SRIOV_MSG_BAD_PAGE_OFFSET_KB        (AMD_SRIOV_MSG_VF2PF_OFFSET_KB + AMD_SRIOV_MSG_SIZE_KB)
421721bc1bSBokun Zhang 
431721bc1bSBokun Zhang /*
441721bc1bSBokun Zhang  * PF2VF history log:
451721bc1bSBokun Zhang  * v1 defined in amdgim
461721bc1bSBokun Zhang  * v2 current
471721bc1bSBokun Zhang  *
481721bc1bSBokun Zhang  * VF2PF history log:
491721bc1bSBokun Zhang  * v1 defined in amdgim
501721bc1bSBokun Zhang  * v2 defined in amdgim
511721bc1bSBokun Zhang  * v3 current
521721bc1bSBokun Zhang  */
531721bc1bSBokun Zhang #define AMD_SRIOV_MSG_FW_VRAM_PF2VF_VER 2
541721bc1bSBokun Zhang #define AMD_SRIOV_MSG_FW_VRAM_VF2PF_VER 3
551721bc1bSBokun Zhang 
561721bc1bSBokun Zhang #define AMD_SRIOV_MSG_RESERVE_UCODE 24
571721bc1bSBokun Zhang 
58ed9d2053SBokun Zhang #define AMD_SRIOV_MSG_RESERVE_VCN_INST 4
59ed9d2053SBokun Zhang 
601721bc1bSBokun Zhang enum amd_sriov_ucode_engine_id {
611721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_VCE = 0,
621721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_UVD,
631721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_MC,
641721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_ME,
651721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_PFP,
661721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_CE,
671721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_RLC,
681721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_RLC_SRLC,
691721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_RLC_SRLG,
701721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_RLC_SRLS,
711721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_MEC,
721721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_MEC2,
731721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_SOS,
741721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_ASD,
751721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_TA_RAS,
761721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_TA_XGMI,
771721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_SMC,
781721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_SDMA,
791721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_SDMA2,
801721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_VCN,
811721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID_DMCU,
821721bc1bSBokun Zhang 	AMD_SRIOV_UCODE_ID__MAX
831721bc1bSBokun Zhang };
841721bc1bSBokun Zhang 
851721bc1bSBokun Zhang #pragma pack(push, 1) // PF2VF / VF2PF data areas are byte packed
861721bc1bSBokun Zhang 
871721bc1bSBokun Zhang union amd_sriov_msg_feature_flags {
881721bc1bSBokun Zhang 	struct {
891721bc1bSBokun Zhang 		uint32_t error_log_collect : 1;
901721bc1bSBokun Zhang 		uint32_t host_load_ucodes  : 1;
911721bc1bSBokun Zhang 		uint32_t host_flr_vramlost : 1;
921721bc1bSBokun Zhang 		uint32_t mm_bw_management  : 1;
931721bc1bSBokun Zhang 		uint32_t pp_one_vf_mode	   : 1;
944d675e1eSRohit Khaire 		uint32_t reg_indirect_acc  : 1;
95dcaf5000SJane Jian 		uint32_t av1_support       : 1;
96dcaf5000SJane Jian 		uint32_t reserved	   : 25;
974d675e1eSRohit Khaire 	} flags;
984d675e1eSRohit Khaire 	uint32_t all;
994d675e1eSRohit Khaire };
1004d675e1eSRohit Khaire 
1014d675e1eSRohit Khaire union amd_sriov_reg_access_flags {
1024d675e1eSRohit Khaire 	struct {
103ed9d2053SBokun Zhang 		uint32_t vf_reg_access_ih 	 : 1;
104ed9d2053SBokun Zhang 		uint32_t vf_reg_access_mmhub : 1;
105ed9d2053SBokun Zhang 		uint32_t vf_reg_access_gc 	 : 1;
1064d675e1eSRohit Khaire 		uint32_t reserved	         : 29;
1071721bc1bSBokun Zhang 	} flags;
1081721bc1bSBokun Zhang 	uint32_t all;
1091721bc1bSBokun Zhang };
1101721bc1bSBokun Zhang 
1111721bc1bSBokun Zhang union amd_sriov_msg_os_info {
1121721bc1bSBokun Zhang 	struct {
1131721bc1bSBokun Zhang 		uint32_t windows  : 1;
1141721bc1bSBokun Zhang 		uint32_t reserved : 31;
1151721bc1bSBokun Zhang 	} info;
1161721bc1bSBokun Zhang 	uint32_t all;
1171721bc1bSBokun Zhang };
1181721bc1bSBokun Zhang 
119ed9d2053SBokun Zhang struct amd_sriov_msg_uuid_info {
120ed9d2053SBokun Zhang 	union {
121ed9d2053SBokun Zhang 		struct {
122ed9d2053SBokun Zhang 			uint32_t did	: 16;
123ed9d2053SBokun Zhang 			uint32_t fcn	: 8;
124ed9d2053SBokun Zhang 			uint32_t asic_7 : 8;
125ed9d2053SBokun Zhang 		};
126ed9d2053SBokun Zhang 		uint32_t time_low;
127ed9d2053SBokun Zhang 	};
128ed9d2053SBokun Zhang 
129ed9d2053SBokun Zhang 	struct {
130ed9d2053SBokun Zhang 		uint32_t time_mid  : 16;
131ed9d2053SBokun Zhang 		uint32_t time_high : 12;
132ed9d2053SBokun Zhang 		uint32_t version   : 4;
133ed9d2053SBokun Zhang 	};
134ed9d2053SBokun Zhang 
135ed9d2053SBokun Zhang 	struct {
136ed9d2053SBokun Zhang 		struct {
137ed9d2053SBokun Zhang 			uint8_t clk_seq_hi : 6;
138ed9d2053SBokun Zhang 			uint8_t variant    : 2;
139ed9d2053SBokun Zhang 		};
140ed9d2053SBokun Zhang 		union {
141ed9d2053SBokun Zhang 			uint8_t clk_seq_low;
142ed9d2053SBokun Zhang 			uint8_t asic_6;
143ed9d2053SBokun Zhang 		};
144ed9d2053SBokun Zhang 		uint16_t asic_4;
145ed9d2053SBokun Zhang 	};
146ed9d2053SBokun Zhang 
147ed9d2053SBokun Zhang 	uint32_t asic_0;
148ed9d2053SBokun Zhang };
149ed9d2053SBokun Zhang 
1501721bc1bSBokun Zhang struct amd_sriov_msg_pf2vf_info_header {
1511721bc1bSBokun Zhang 	/* the total structure size in byte */
1521721bc1bSBokun Zhang 	uint32_t size;
1531721bc1bSBokun Zhang 	/* version of this structure, written by the HOST */
1541721bc1bSBokun Zhang 	uint32_t version;
1551721bc1bSBokun Zhang 	/* reserved */
1561721bc1bSBokun Zhang 	uint32_t reserved[2];
1571721bc1bSBokun Zhang };
1581721bc1bSBokun Zhang 
159e15c9d06SBokun Zhang #define AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE (48)
1601721bc1bSBokun Zhang struct amd_sriov_msg_pf2vf_info {
1611721bc1bSBokun Zhang 	/* header contains size and version */
1621721bc1bSBokun Zhang 	struct amd_sriov_msg_pf2vf_info_header header;
1631721bc1bSBokun Zhang 	/* use private key from mailbox 2 to create checksum */
1641721bc1bSBokun Zhang 	uint32_t checksum;
1651721bc1bSBokun Zhang 	/* The features flags of the HOST driver supports */
1661721bc1bSBokun Zhang 	union amd_sriov_msg_feature_flags feature_flags;
1671721bc1bSBokun Zhang 	/* (max_width * max_height * fps) / (16 * 16) */
1681721bc1bSBokun Zhang 	uint32_t hevc_enc_max_mb_per_second;
1691721bc1bSBokun Zhang 	/* (max_width * max_height) / (16 * 16) */
1701721bc1bSBokun Zhang 	uint32_t hevc_enc_max_mb_per_frame;
1711721bc1bSBokun Zhang 	/* (max_width * max_height * fps) / (16 * 16) */
1721721bc1bSBokun Zhang 	uint32_t avc_enc_max_mb_per_second;
1731721bc1bSBokun Zhang 	/* (max_width * max_height) / (16 * 16) */
1741721bc1bSBokun Zhang 	uint32_t avc_enc_max_mb_per_frame;
1751721bc1bSBokun Zhang 	/* MEC FW position in BYTE from the start of VF visible frame buffer */
1761721bc1bSBokun Zhang 	uint64_t mecfw_offset;
1771721bc1bSBokun Zhang 	/* MEC FW size in BYTE */
1781721bc1bSBokun Zhang 	uint32_t mecfw_size;
1791721bc1bSBokun Zhang 	/* UVD FW position in BYTE from the start of VF visible frame buffer */
1801721bc1bSBokun Zhang 	uint64_t uvdfw_offset;
1811721bc1bSBokun Zhang 	/* UVD FW size in BYTE */
1821721bc1bSBokun Zhang 	uint32_t uvdfw_size;
1831721bc1bSBokun Zhang 	/* VCE FW position in BYTE from the start of VF visible frame buffer */
1841721bc1bSBokun Zhang 	uint64_t vcefw_offset;
1851721bc1bSBokun Zhang 	/* VCE FW size in BYTE */
1861721bc1bSBokun Zhang 	uint32_t vcefw_size;
1871721bc1bSBokun Zhang 	/* Bad pages block position in BYTE */
1881721bc1bSBokun Zhang 	uint32_t bp_block_offset_low;
1891721bc1bSBokun Zhang 	uint32_t bp_block_offset_high;
1901721bc1bSBokun Zhang 	/* Bad pages block size in BYTE */
1911721bc1bSBokun Zhang 	uint32_t bp_block_size;
1921721bc1bSBokun Zhang 	/* frequency for VF to update the VF2PF area in msec, 0 = manual */
1931721bc1bSBokun Zhang 	uint32_t vf2pf_update_interval_ms;
1941721bc1bSBokun Zhang 	/* identification in ROCm SMI */
1951721bc1bSBokun Zhang 	uint64_t uuid;
1961721bc1bSBokun Zhang 	uint32_t fcn_idx;
197ed9d2053SBokun Zhang 	/* flags to indicate which register access method VF should use */
1984d675e1eSRohit Khaire 	union amd_sriov_reg_access_flags reg_access_flags;
199ed9d2053SBokun Zhang 	/* MM BW management */
200ed9d2053SBokun Zhang 	struct {
201ed9d2053SBokun Zhang 		uint32_t decode_max_dimension_pixels;
202ed9d2053SBokun Zhang 		uint32_t decode_max_frame_pixels;
203ed9d2053SBokun Zhang 		uint32_t encode_max_dimension_pixels;
204ed9d2053SBokun Zhang 		uint32_t encode_max_frame_pixels;
205ed9d2053SBokun Zhang 	} mm_bw_management[AMD_SRIOV_MSG_RESERVE_VCN_INST];
206ed9d2053SBokun Zhang 	/* UUID info */
207ed9d2053SBokun Zhang 	struct amd_sriov_msg_uuid_info uuid_info;
208e15c9d06SBokun Zhang 	/* PCIE atomic ops support flag */
209e15c9d06SBokun Zhang 	uint32_t pcie_atomic_ops_support_flags;
2101721bc1bSBokun Zhang 	/* reserved */
211e15c9d06SBokun Zhang 	uint32_t reserved[256 - AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE];
212*8e7760edSWangYuli } __packed;
2131721bc1bSBokun Zhang 
2141721bc1bSBokun Zhang struct amd_sriov_msg_vf2pf_info_header {
2151721bc1bSBokun Zhang 	/* the total structure size in byte */
2161721bc1bSBokun Zhang 	uint32_t size;
2171721bc1bSBokun Zhang 	/* version of this structure, written by the guest */
2181721bc1bSBokun Zhang 	uint32_t version;
2191721bc1bSBokun Zhang 	/* reserved */
2201721bc1bSBokun Zhang 	uint32_t reserved[2];
2211721bc1bSBokun Zhang };
2221721bc1bSBokun Zhang 
223e15c9d06SBokun Zhang #define AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE (70)
2241721bc1bSBokun Zhang struct amd_sriov_msg_vf2pf_info {
2251721bc1bSBokun Zhang 	/* header contains size and version */
2261721bc1bSBokun Zhang 	struct amd_sriov_msg_vf2pf_info_header header;
2271721bc1bSBokun Zhang 	uint32_t checksum;
2281721bc1bSBokun Zhang 	/* driver version */
2291721bc1bSBokun Zhang 	uint8_t driver_version[64];
2301721bc1bSBokun Zhang 	/* driver certification, 1=WHQL, 0=None */
2311721bc1bSBokun Zhang 	uint32_t driver_cert;
2321721bc1bSBokun Zhang 	/* guest OS type and version */
2331721bc1bSBokun Zhang 	union amd_sriov_msg_os_info os_info;
2341721bc1bSBokun Zhang 	/* guest fb information in the unit of MB */
2351721bc1bSBokun Zhang 	uint32_t fb_usage;
2361721bc1bSBokun Zhang 	/* guest gfx engine usage percentage */
2371721bc1bSBokun Zhang 	uint32_t gfx_usage;
2381721bc1bSBokun Zhang 	/* guest gfx engine health percentage */
2391721bc1bSBokun Zhang 	uint32_t gfx_health;
2401721bc1bSBokun Zhang 	/* guest compute engine usage percentage */
2411721bc1bSBokun Zhang 	uint32_t compute_usage;
2421721bc1bSBokun Zhang 	/* guest compute engine health percentage */
2431721bc1bSBokun Zhang 	uint32_t compute_health;
2441721bc1bSBokun Zhang 	/* guest avc engine usage percentage. 0xffff means N/A */
2451721bc1bSBokun Zhang 	uint32_t avc_enc_usage;
2461721bc1bSBokun Zhang 	/* guest avc engine health percentage. 0xffff means N/A */
2471721bc1bSBokun Zhang 	uint32_t avc_enc_health;
2481721bc1bSBokun Zhang 	/* guest hevc engine usage percentage. 0xffff means N/A */
2491721bc1bSBokun Zhang 	uint32_t hevc_enc_usage;
2501721bc1bSBokun Zhang 	/* guest hevc engine usage percentage. 0xffff means N/A */
2511721bc1bSBokun Zhang 	uint32_t hevc_enc_health;
2521721bc1bSBokun Zhang 	/* combined encode/decode usage */
2531721bc1bSBokun Zhang 	uint32_t encode_usage;
2541721bc1bSBokun Zhang 	uint32_t decode_usage;
2551721bc1bSBokun Zhang 	/* Version of PF2VF that VF understands */
2561721bc1bSBokun Zhang 	uint32_t pf2vf_version_required;
2571721bc1bSBokun Zhang 	/* additional FB usage */
2581721bc1bSBokun Zhang 	uint32_t fb_vis_usage;
2591721bc1bSBokun Zhang 	uint32_t fb_vis_size;
2601721bc1bSBokun Zhang 	uint32_t fb_size;
2611721bc1bSBokun Zhang 	/* guest ucode data, each one is 1.25 Dword */
2621721bc1bSBokun Zhang 	struct {
2631721bc1bSBokun Zhang 		uint8_t id;
2641721bc1bSBokun Zhang 		uint32_t version;
2651721bc1bSBokun Zhang 	} ucode_info[AMD_SRIOV_MSG_RESERVE_UCODE];
266e77f0f5cSJingwen Chen 	uint64_t dummy_page_addr;
2671721bc1bSBokun Zhang 
2681721bc1bSBokun Zhang 	/* reserved */
269e15c9d06SBokun Zhang 	uint32_t reserved[256 - AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE];
270*8e7760edSWangYuli } __packed;
2711721bc1bSBokun Zhang 
2721721bc1bSBokun Zhang /* mailbox message send from guest to host  */
2731721bc1bSBokun Zhang enum amd_sriov_mailbox_request_message {
2741721bc1bSBokun Zhang 	MB_REQ_MSG_REQ_GPU_INIT_ACCESS = 1,
2751721bc1bSBokun Zhang 	MB_REQ_MSG_REL_GPU_INIT_ACCESS,
2761721bc1bSBokun Zhang 	MB_REQ_MSG_REQ_GPU_FINI_ACCESS,
2771721bc1bSBokun Zhang 	MB_REQ_MSG_REL_GPU_FINI_ACCESS,
2781721bc1bSBokun Zhang 	MB_REQ_MSG_REQ_GPU_RESET_ACCESS,
2791721bc1bSBokun Zhang 	MB_REQ_MSG_REQ_GPU_INIT_DATA,
2801721bc1bSBokun Zhang 
2811721bc1bSBokun Zhang 	MB_REQ_MSG_LOG_VF_ERROR = 200,
2821721bc1bSBokun Zhang };
2831721bc1bSBokun Zhang 
2841721bc1bSBokun Zhang /* mailbox message send from host to guest  */
2851721bc1bSBokun Zhang enum amd_sriov_mailbox_response_message {
2861721bc1bSBokun Zhang 	MB_RES_MSG_CLR_MSG_BUF = 0,
2871721bc1bSBokun Zhang 	MB_RES_MSG_READY_TO_ACCESS_GPU = 1,
2881721bc1bSBokun Zhang 	MB_RES_MSG_FLR_NOTIFICATION,
2891721bc1bSBokun Zhang 	MB_RES_MSG_FLR_NOTIFICATION_COMPLETION,
2901721bc1bSBokun Zhang 	MB_RES_MSG_SUCCESS,
2911721bc1bSBokun Zhang 	MB_RES_MSG_FAIL,
2921721bc1bSBokun Zhang 	MB_RES_MSG_QUERY_ALIVE,
2931721bc1bSBokun Zhang 	MB_RES_MSG_GPU_INIT_DATA_READY,
2941721bc1bSBokun Zhang 
2951721bc1bSBokun Zhang 	MB_RES_MSG_TEXT_MESSAGE = 255
2961721bc1bSBokun Zhang };
2971721bc1bSBokun Zhang 
2981721bc1bSBokun Zhang /* version data stored in MAILBOX_MSGBUF_RCV_DW1 for future expansion */
2991721bc1bSBokun Zhang enum amd_sriov_gpu_init_data_version {
3001721bc1bSBokun Zhang 	GPU_INIT_DATA_READY_V1 = 1,
3011721bc1bSBokun Zhang };
3021721bc1bSBokun Zhang 
3031721bc1bSBokun Zhang #pragma pack(pop) // Restore previous packing option
3041721bc1bSBokun Zhang 
3051721bc1bSBokun Zhang /* checksum function between host and guest */
306451913e9SBokun Zhang unsigned int amd_sriov_msg_checksum(void *obj, unsigned long obj_size, unsigned int key,
3071721bc1bSBokun Zhang 				    unsigned int checksum);
3081721bc1bSBokun Zhang 
3091721bc1bSBokun Zhang /* assertion at compile time */
3101721bc1bSBokun Zhang #ifdef __linux__
3111721bc1bSBokun Zhang #define stringification(s)  _stringification(s)
3121721bc1bSBokun Zhang #define _stringification(s) #s
3131721bc1bSBokun Zhang 
3141721bc1bSBokun Zhang _Static_assert(
3151721bc1bSBokun Zhang 	sizeof(struct amd_sriov_msg_vf2pf_info) == AMD_SRIOV_MSG_SIZE_KB << 10,
3161721bc1bSBokun Zhang 	"amd_sriov_msg_vf2pf_info must be " stringification(AMD_SRIOV_MSG_SIZE_KB) " KB");
3171721bc1bSBokun Zhang 
3181721bc1bSBokun Zhang _Static_assert(
3191721bc1bSBokun Zhang 	sizeof(struct amd_sriov_msg_pf2vf_info) == AMD_SRIOV_MSG_SIZE_KB << 10,
3201721bc1bSBokun Zhang 	"amd_sriov_msg_pf2vf_info must be " stringification(AMD_SRIOV_MSG_SIZE_KB) " KB");
3211721bc1bSBokun Zhang 
322451913e9SBokun Zhang _Static_assert(AMD_SRIOV_MSG_RESERVE_UCODE % 4 == 0,
3231721bc1bSBokun Zhang 	       "AMD_SRIOV_MSG_RESERVE_UCODE must be multiple of 4");
3241721bc1bSBokun Zhang 
325451913e9SBokun Zhang _Static_assert(AMD_SRIOV_MSG_RESERVE_UCODE > AMD_SRIOV_UCODE_ID__MAX,
3261721bc1bSBokun Zhang 	       "AMD_SRIOV_MSG_RESERVE_UCODE must be bigger than AMD_SRIOV_UCODE_ID__MAX");
3271721bc1bSBokun Zhang 
3281721bc1bSBokun Zhang #undef _stringification
3291721bc1bSBokun Zhang #undef stringification
3301721bc1bSBokun Zhang #endif
3311721bc1bSBokun Zhang 
3321721bc1bSBokun Zhang #endif /* AMDGV_SRIOV_MSG__H_ */
333