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 uniras_support : 1; 168 uint32_t reserved : 15; 169 } flags; 170 uint32_t all; 171 }; 172 173 union amd_sriov_reg_access_flags { 174 struct { 175 uint32_t vf_reg_access_ih : 1; 176 uint32_t vf_reg_access_mmhub : 1; 177 uint32_t vf_reg_access_gc : 1; 178 uint32_t vf_reg_access_l1_tlb_cntl : 1; 179 uint32_t vf_reg_access_sq_config : 1; 180 uint32_t reserved : 27; 181 } flags; 182 uint32_t all; 183 }; 184 185 union amd_sriov_ras_caps { 186 struct { 187 uint64_t block_umc : 1; 188 uint64_t block_sdma : 1; 189 uint64_t block_gfx : 1; 190 uint64_t block_mmhub : 1; 191 uint64_t block_athub : 1; 192 uint64_t block_pcie_bif : 1; 193 uint64_t block_hdp : 1; 194 uint64_t block_xgmi_wafl : 1; 195 uint64_t block_df : 1; 196 uint64_t block_smn : 1; 197 uint64_t block_sem : 1; 198 uint64_t block_mp0 : 1; 199 uint64_t block_mp1 : 1; 200 uint64_t block_fuse : 1; 201 uint64_t block_mca : 1; 202 uint64_t block_vcn : 1; 203 uint64_t block_jpeg : 1; 204 uint64_t block_ih : 1; 205 uint64_t block_mpio : 1; 206 uint64_t block_mmsch : 1; 207 uint64_t poison_propogation_mode : 1; 208 uint64_t uniras_supported : 1; 209 uint64_t reserved : 42; 210 } bits; 211 uint64_t all; 212 }; 213 214 struct amd_sriov_uniras_caps { 215 uint32_t ras_ext_ecc_type; 216 uint32_t ras_int_ecc_attributes; 217 uint64_t ras_en_block_mask; 218 }; 219 220 /* 221 * PF2VF RAS capability words (16 bytes, layout matches legacy fields): 222 * ras_ext_ecc_type and ras_int_ecc_attributes are aliases ras_en_caps, 223 * ras_en_block_mask aliases ras_telemetry_en_caps. 224 */ 225 union amd_sriov_msg_pf2vf_ras_caps { 226 /* ras caps for uniras enabled case */ 227 struct amd_sriov_uniras_caps uniras_caps; 228 /* ras caps for uniras disabled case*/ 229 struct { 230 union amd_sriov_ras_caps ras_en_caps; 231 union amd_sriov_ras_caps ras_telemetry_en_caps; 232 }; 233 }; 234 235 union amd_sriov_msg_os_info { 236 struct { 237 uint32_t windows : 1; 238 uint32_t reserved : 31; 239 } info; 240 uint32_t all; 241 }; 242 243 struct amd_sriov_msg_uuid_info { 244 union { 245 struct { 246 uint32_t did : 16; 247 uint32_t fcn : 8; 248 uint32_t asic_7 : 8; 249 }; 250 uint32_t time_low; 251 }; 252 253 struct { 254 uint32_t time_mid : 16; 255 uint32_t time_high : 12; 256 uint32_t version : 4; 257 }; 258 259 struct { 260 struct { 261 uint8_t clk_seq_hi : 6; 262 uint8_t variant : 2; 263 }; 264 union { 265 uint8_t clk_seq_low; 266 uint8_t asic_6; 267 }; 268 uint16_t asic_4; 269 }; 270 271 uint32_t asic_0; 272 }; 273 274 struct amd_sriov_msg_pf2vf_info_header { 275 /* the total structure size in byte */ 276 uint32_t size; 277 /* version of this structure, written by the HOST */ 278 uint32_t version; 279 /* reserved */ 280 uint32_t reserved[2]; 281 }; 282 283 #define AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE (59) 284 struct amd_sriov_msg_pf2vf_info { 285 /* header contains size and version */ 286 struct amd_sriov_msg_pf2vf_info_header header; 287 /* use private key from mailbox 2 to create checksum */ 288 uint32_t checksum; 289 /* The features flags of the HOST driver supports */ 290 union amd_sriov_msg_feature_flags feature_flags; 291 /* (max_width * max_height * fps) / (16 * 16) */ 292 uint32_t hevc_enc_max_mb_per_second; 293 /* (max_width * max_height) / (16 * 16) */ 294 uint32_t hevc_enc_max_mb_per_frame; 295 /* (max_width * max_height * fps) / (16 * 16) */ 296 uint32_t avc_enc_max_mb_per_second; 297 /* (max_width * max_height) / (16 * 16) */ 298 uint32_t avc_enc_max_mb_per_frame; 299 /* MEC FW position in BYTE from the start of VF visible frame buffer */ 300 uint64_t mecfw_offset; 301 /* MEC FW size in BYTE */ 302 uint32_t mecfw_size; 303 /* UVD FW position in BYTE from the start of VF visible frame buffer */ 304 uint64_t uvdfw_offset; 305 /* UVD FW size in BYTE */ 306 uint32_t uvdfw_size; 307 /* VCE FW position in BYTE from the start of VF visible frame buffer */ 308 uint64_t vcefw_offset; 309 /* VCE FW size in BYTE */ 310 uint32_t vcefw_size; 311 /* Bad pages block position in BYTE */ 312 uint32_t bp_block_offset_low; 313 uint32_t bp_block_offset_high; 314 /* Bad pages block size in BYTE */ 315 uint32_t bp_block_size; 316 /* frequency for VF to update the VF2PF area in msec, 0 = manual */ 317 uint32_t vf2pf_update_interval_ms; 318 /* identification in ROCm SMI */ 319 uint64_t uuid; 320 uint32_t pad; 321 /* flags to indicate which register access method VF should use */ 322 union amd_sriov_reg_access_flags reg_access_flags; 323 /* MM BW management */ 324 struct { 325 uint32_t decode_max_dimension_pixels; 326 uint32_t decode_max_frame_pixels; 327 uint32_t encode_max_dimension_pixels; 328 uint32_t encode_max_frame_pixels; 329 } mm_bw_management[AMD_SRIOV_MSG_RESERVE_VCN_INST]; 330 /* UUID info */ 331 struct amd_sriov_msg_uuid_info uuid_info; 332 /* PCIE atomic ops support flag */ 333 uint32_t pcie_atomic_ops_support_flags; 334 /* Portion of GPU memory occupied by VF. MAX value is 65535, but set to uint32_t to maintain alignment with reserved size */ 335 uint32_t gpu_capacity; 336 /* vf bdf on host pci tree for debug only */ 337 uint32_t bdf_on_host; 338 uint32_t more_bp; //Reserved for future use. 339 union amd_sriov_msg_pf2vf_ras_caps pf2vf_ras_caps; 340 /* PTL status response for guest */ 341 uint32_t ptl_enabled; // PTL enable status: 0=disabled, 1=enabled 342 uint32_t ptl_pref_format1; // Current preferred format 1 343 uint32_t ptl_pref_format2; // Current preferred format 2 344 /* unit ID assigned by host; vf_idx [0..254] maps to unitid [1..255] (0 = pf) */ 345 uint8_t unitid; 346 uint8_t padding[3]; //use the 3 bytes to align 347 348 /* reserved */ 349 uint32_t reserved[256 - AMD_SRIOV_MSG_PF2VF_INFO_FILLED_SIZE]; 350 } __packed; 351 352 struct amd_sriov_msg_vf2pf_info_header { 353 /* the total structure size in byte */ 354 uint32_t size; 355 /* version of this structure, written by the guest */ 356 uint32_t version; 357 /* reserved */ 358 uint32_t reserved[2]; 359 }; 360 361 #define AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE (73) 362 struct amd_sriov_msg_vf2pf_info { 363 /* header contains size and version */ 364 struct amd_sriov_msg_vf2pf_info_header header; 365 uint32_t checksum; 366 /* driver version */ 367 uint8_t driver_version[64]; 368 /* driver certification, 1=WHQL, 0=None */ 369 uint32_t driver_cert; 370 /* guest OS type and version */ 371 union amd_sriov_msg_os_info os_info; 372 /* guest fb information in the unit of MB */ 373 uint32_t fb_usage; 374 /* guest gfx engine usage percentage */ 375 uint32_t gfx_usage; 376 /* guest gfx engine health percentage */ 377 uint32_t gfx_health; 378 /* guest compute engine usage percentage */ 379 uint32_t compute_usage; 380 /* guest compute engine health percentage */ 381 uint32_t compute_health; 382 /* guest avc engine usage percentage. 0xffff means N/A */ 383 uint32_t avc_enc_usage; 384 /* guest avc engine health percentage. 0xffff means N/A */ 385 uint32_t avc_enc_health; 386 /* guest hevc engine usage percentage. 0xffff means N/A */ 387 uint32_t hevc_enc_usage; 388 /* guest hevc engine usage percentage. 0xffff means N/A */ 389 uint32_t hevc_enc_health; 390 /* combined encode/decode usage */ 391 uint32_t encode_usage; 392 uint32_t decode_usage; 393 /* Version of PF2VF that VF understands */ 394 uint32_t pf2vf_version_required; 395 /* additional FB usage */ 396 uint32_t fb_vis_usage; 397 uint32_t fb_vis_size; 398 uint32_t fb_size; 399 /* guest ucode data, each one is 1.25 Dword */ 400 struct { 401 uint8_t id; 402 uint32_t version; 403 } __packed ucode_info[AMD_SRIOV_MSG_RESERVE_UCODE]; 404 uint64_t dummy_page_addr; 405 /* FB allocated for guest MES to record UQ info */ 406 uint64_t mes_info_addr; 407 uint32_t mes_info_size; 408 /* reserved */ 409 uint32_t reserved[256 - AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE]; 410 } __packed; 411 412 /* mailbox message send from guest to host */ 413 enum amd_sriov_mailbox_request_message { 414 MB_REQ_MSG_REQ_GPU_INIT_ACCESS = 1, 415 MB_REQ_MSG_REL_GPU_INIT_ACCESS, 416 MB_REQ_MSG_REQ_GPU_FINI_ACCESS, 417 MB_REQ_MSG_REL_GPU_FINI_ACCESS, 418 MB_REQ_MSG_REQ_GPU_RESET_ACCESS, 419 MB_REQ_MSG_REQ_GPU_INIT_DATA, 420 MB_REQ_MSG_PSP_VF_CMD_RELAY, 421 422 MB_REQ_MSG_LOG_VF_ERROR = 200, 423 MB_REQ_MSG_READY_TO_RESET = 201, 424 MB_REQ_MSG_RAS_POISON = 202, 425 MB_REQ_RAS_ERROR_COUNT = 203, 426 MB_REQ_RAS_CPER_DUMP = 204, 427 MB_REQ_RAS_BAD_PAGES = 205, 428 MB_REQ_RAS_CHK_CRITI = 206, 429 MB_REQ_RAS_REMOTE_CMD = 207, 430 MB_REQ_MSG_PTL_UPDATE = 208, 431 }; 432 433 /* mailbox message send from host to guest */ 434 enum amd_sriov_mailbox_response_message { 435 MB_RES_MSG_CLR_MSG_BUF = 0, 436 MB_RES_MSG_READY_TO_ACCESS_GPU = 1, 437 MB_RES_MSG_FLR_NOTIFICATION = 2, 438 MB_RES_MSG_FLR_NOTIFICATION_COMPLETION = 3, 439 MB_RES_MSG_SUCCESS = 4, 440 MB_RES_MSG_FAIL = 5, 441 MB_RES_MSG_QUERY_ALIVE = 6, 442 MB_RES_MSG_GPU_INIT_DATA_READY = 7, 443 MB_RES_MSG_RAS_POISON_READY = 8, 444 MB_RES_MSG_PF_SOFT_FLR_NOTIFICATION = 9, 445 MB_RES_MSG_GPU_RMA = 10, 446 MB_RES_MSG_RAS_ERROR_COUNT_READY = 11, 447 MB_REQ_RAS_CPER_DUMP_READY = 14, 448 MB_RES_MSG_RAS_BAD_PAGES_READY = 15, 449 MB_RES_MSG_RAS_BAD_PAGES_NOTIFICATION = 16, 450 MB_RES_MSG_UNRECOV_ERR_NOTIFICATION = 17, 451 MB_RES_RAS_CHK_CRITI_READY = 18, 452 MB_RES_RAS_REMOTE_CMD_READY = 19, 453 MB_RES_MSG_PTL_UPDATE_READY = 20, 454 MB_RES_MSG_TEXT_MESSAGE = 255 455 }; 456 457 /* 458 * Generic response status codes for mailbox data fields. 459 * Used in msg_data[1..N] to indicate operation result. 460 */ 461 enum amd_sriov_response_status { 462 AMD_SRIOV_RESP_SUCCESS = 0, 463 AMD_SRIOV_RESP_FAIL = 1, 464 AMD_SRIOV_RESP_UNSUPPORTED = 2, 465 }; 466 467 /* 468 * PTL mailbox data format: 469 * Request: msg_data[1]=req_code, msg_data[2]=ptl_state, msg_data[3]=(fmt1<<16)|fmt2 470 * Response: msg_data[1]=(status<<16)|ptl_state, msg_data[2]=(fmt1<<16)|fmt2 471 */ 472 #define AMD_SRIOV_PTL_PACK_FORMATS(fmt1, fmt2) ((((fmt1) & 0xFFFF) << 16) | ((fmt2) & 0xFFFF)) 473 #define AMD_SRIOV_PTL_UNPACK_STATUS(dw) (((dw) >> 16) & 0xFFFF) 474 #define AMD_SRIOV_PTL_UNPACK_STATE(dw) ((dw) & 0xFFFF) 475 #define AMD_SRIOV_PTL_UNPACK_FMT1(dw) (((dw) >> 16) & 0xFFFF) 476 #define AMD_SRIOV_PTL_UNPACK_FMT2(dw) ((dw) & 0xFFFF) 477 478 enum amd_sriov_ras_telemetry_gpu_block { 479 RAS_TELEMETRY_GPU_BLOCK_UMC = 0, 480 RAS_TELEMETRY_GPU_BLOCK_SDMA = 1, 481 RAS_TELEMETRY_GPU_BLOCK_GFX = 2, 482 RAS_TELEMETRY_GPU_BLOCK_MMHUB = 3, 483 RAS_TELEMETRY_GPU_BLOCK_ATHUB = 4, 484 RAS_TELEMETRY_GPU_BLOCK_PCIE_BIF = 5, 485 RAS_TELEMETRY_GPU_BLOCK_HDP = 6, 486 RAS_TELEMETRY_GPU_BLOCK_XGMI_WAFL = 7, 487 RAS_TELEMETRY_GPU_BLOCK_DF = 8, 488 RAS_TELEMETRY_GPU_BLOCK_SMN = 9, 489 RAS_TELEMETRY_GPU_BLOCK_SEM = 10, 490 RAS_TELEMETRY_GPU_BLOCK_MP0 = 11, 491 RAS_TELEMETRY_GPU_BLOCK_MP1 = 12, 492 RAS_TELEMETRY_GPU_BLOCK_FUSE = 13, 493 RAS_TELEMETRY_GPU_BLOCK_MCA = 14, 494 RAS_TELEMETRY_GPU_BLOCK_VCN = 15, 495 RAS_TELEMETRY_GPU_BLOCK_JPEG = 16, 496 RAS_TELEMETRY_GPU_BLOCK_IH = 17, 497 RAS_TELEMETRY_GPU_BLOCK_MPIO = 18, 498 RAS_TELEMETRY_GPU_BLOCK_COUNT = 19, 499 }; 500 501 struct amd_sriov_ras_telemetry_header { 502 uint32_t checksum; 503 uint32_t used_size; 504 uint32_t reserved[2]; 505 }; 506 507 struct amd_sriov_ras_telemetry_error_count { 508 struct { 509 uint32_t ce_count; 510 uint32_t ue_count; 511 uint32_t de_count; 512 uint32_t ce_overflow_count; 513 uint32_t ue_overflow_count; 514 uint32_t de_overflow_count; 515 uint32_t reserved[6]; 516 } block[RAS_TELEMETRY_GPU_BLOCK_COUNT]; 517 }; 518 519 struct amd_sriov_ras_cper_dump { 520 uint32_t more; 521 uint64_t overflow_count; 522 uint64_t count; 523 uint64_t wptr; 524 uint32_t buf[]; 525 }; 526 527 struct amd_sriov_ras_chk_criti { 528 uint32_t hit; 529 }; 530 531 #define AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE 4096 532 #define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (4096 * 13) 533 struct amd_sriov_uniras_shared_mem { 534 uint8_t blocks_ecc_buf[AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE]; 535 uint8_t cmd_buf[AMD_SRIOV_UNIRAS_CMD_MAX_SIZE]; 536 }; 537 538 struct amdsriov_ras_telemetry { 539 union { 540 struct { 541 struct amd_sriov_ras_telemetry_header header; 542 543 union { 544 struct amd_sriov_ras_telemetry_error_count error_count; 545 struct amd_sriov_ras_cper_dump cper_dump; 546 struct amd_sriov_ras_chk_criti chk_criti; 547 } body; 548 }; 549 550 struct amd_sriov_uniras_shared_mem uniras_shared_mem; 551 }; 552 }; 553 554 /* version data stored in MAILBOX_MSGBUF_RCV_DW1 for future expansion */ 555 enum amd_sriov_gpu_init_data_version { 556 GPU_INIT_DATA_READY_V1 = 1, 557 }; 558 559 #pragma pack(pop) // Restore previous packing option 560 561 /* checksum function between host and guest */ 562 unsigned int amd_sriov_msg_checksum(void *obj, unsigned long obj_size, unsigned int key, 563 unsigned int checksum); 564 565 /* assertion at compile time */ 566 #ifdef __linux__ 567 #define stringification(s) _stringification(s) 568 #define _stringification(s) #s 569 570 _Static_assert( 571 sizeof(struct amd_sriov_msg_vf2pf_info) == AMD_SRIOV_MSG_SIZE_KB << 10, 572 "amd_sriov_msg_vf2pf_info must be " stringification(AMD_SRIOV_MSG_SIZE_KB) " KB"); 573 574 _Static_assert( 575 sizeof(struct amd_sriov_msg_pf2vf_info) == AMD_SRIOV_MSG_SIZE_KB << 10, 576 "amd_sriov_msg_pf2vf_info must be " stringification(AMD_SRIOV_MSG_SIZE_KB) " KB"); 577 578 _Static_assert(AMD_SRIOV_MSG_RESERVE_UCODE % 4 == 0, 579 "AMD_SRIOV_MSG_RESERVE_UCODE must be multiple of 4"); 580 581 _Static_assert(AMD_SRIOV_MSG_RESERVE_UCODE > AMD_SRIOV_UCODE_ID__MAX, 582 "AMD_SRIOV_MSG_RESERVE_UCODE must be bigger than AMD_SRIOV_UCODE_ID__MAX"); 583 584 _Static_assert( 585 sizeof(struct amdsriov_ras_telemetry) <= AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10, 586 "amdsriov_ras_telemetry must be " stringification(AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1) " KB"); 587 588 #undef _stringification 589 #undef stringification 590 #endif 591 592 #endif /* AMDGV_SRIOV_MSG__H_ */ 593