1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ 3 #undef TRACE_SYSTEM 4 #define TRACE_SYSTEM cxl 5 6 #if !defined(_CXL_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ) 7 #define _CXL_EVENTS_H 8 9 #include <linux/tracepoint.h> 10 #include <linux/pci.h> 11 #include <asm-generic/unaligned.h> 12 13 #include <cxl.h> 14 #include <cxlmem.h> 15 #include "core.h" 16 17 #define CXL_RAS_UC_CACHE_DATA_PARITY BIT(0) 18 #define CXL_RAS_UC_CACHE_ADDR_PARITY BIT(1) 19 #define CXL_RAS_UC_CACHE_BE_PARITY BIT(2) 20 #define CXL_RAS_UC_CACHE_DATA_ECC BIT(3) 21 #define CXL_RAS_UC_MEM_DATA_PARITY BIT(4) 22 #define CXL_RAS_UC_MEM_ADDR_PARITY BIT(5) 23 #define CXL_RAS_UC_MEM_BE_PARITY BIT(6) 24 #define CXL_RAS_UC_MEM_DATA_ECC BIT(7) 25 #define CXL_RAS_UC_REINIT_THRESH BIT(8) 26 #define CXL_RAS_UC_RSVD_ENCODE BIT(9) 27 #define CXL_RAS_UC_POISON BIT(10) 28 #define CXL_RAS_UC_RECV_OVERFLOW BIT(11) 29 #define CXL_RAS_UC_INTERNAL_ERR BIT(14) 30 #define CXL_RAS_UC_IDE_TX_ERR BIT(15) 31 #define CXL_RAS_UC_IDE_RX_ERR BIT(16) 32 33 #define show_uc_errs(status) __print_flags(status, " | ", \ 34 { CXL_RAS_UC_CACHE_DATA_PARITY, "Cache Data Parity Error" }, \ 35 { CXL_RAS_UC_CACHE_ADDR_PARITY, "Cache Address Parity Error" }, \ 36 { CXL_RAS_UC_CACHE_BE_PARITY, "Cache Byte Enable Parity Error" }, \ 37 { CXL_RAS_UC_CACHE_DATA_ECC, "Cache Data ECC Error" }, \ 38 { CXL_RAS_UC_MEM_DATA_PARITY, "Memory Data Parity Error" }, \ 39 { CXL_RAS_UC_MEM_ADDR_PARITY, "Memory Address Parity Error" }, \ 40 { CXL_RAS_UC_MEM_BE_PARITY, "Memory Byte Enable Parity Error" }, \ 41 { CXL_RAS_UC_MEM_DATA_ECC, "Memory Data ECC Error" }, \ 42 { CXL_RAS_UC_REINIT_THRESH, "REINIT Threshold Hit" }, \ 43 { CXL_RAS_UC_RSVD_ENCODE, "Received Unrecognized Encoding" }, \ 44 { CXL_RAS_UC_POISON, "Received Poison From Peer" }, \ 45 { CXL_RAS_UC_RECV_OVERFLOW, "Receiver Overflow" }, \ 46 { CXL_RAS_UC_INTERNAL_ERR, "Component Specific Error" }, \ 47 { CXL_RAS_UC_IDE_TX_ERR, "IDE Tx Error" }, \ 48 { CXL_RAS_UC_IDE_RX_ERR, "IDE Rx Error" } \ 49 ) 50 51 TRACE_EVENT(cxl_aer_uncorrectable_error, 52 TP_PROTO(const struct cxl_memdev *cxlmd, u32 status, u32 fe, u32 *hl), 53 TP_ARGS(cxlmd, status, fe, hl), 54 TP_STRUCT__entry( 55 __string(memdev, dev_name(&cxlmd->dev)) 56 __string(host, dev_name(cxlmd->dev.parent)) 57 __field(u64, serial) 58 __field(u32, status) 59 __field(u32, first_error) 60 __array(u32, header_log, CXL_HEADERLOG_SIZE_U32) 61 ), 62 TP_fast_assign( 63 __assign_str(memdev, dev_name(&cxlmd->dev)); 64 __assign_str(host, dev_name(cxlmd->dev.parent)); 65 __entry->serial = cxlmd->cxlds->serial; 66 __entry->status = status; 67 __entry->first_error = fe; 68 /* 69 * Embed the 512B headerlog data for user app retrieval and 70 * parsing, but no need to print this in the trace buffer. 71 */ 72 memcpy(__entry->header_log, hl, CXL_HEADERLOG_SIZE); 73 ), 74 TP_printk("memdev=%s host=%s serial=%lld: status: '%s' first_error: '%s'", 75 __get_str(memdev), __get_str(host), __entry->serial, 76 show_uc_errs(__entry->status), 77 show_uc_errs(__entry->first_error) 78 ) 79 ); 80 81 #define CXL_RAS_CE_CACHE_DATA_ECC BIT(0) 82 #define CXL_RAS_CE_MEM_DATA_ECC BIT(1) 83 #define CXL_RAS_CE_CRC_THRESH BIT(2) 84 #define CLX_RAS_CE_RETRY_THRESH BIT(3) 85 #define CXL_RAS_CE_CACHE_POISON BIT(4) 86 #define CXL_RAS_CE_MEM_POISON BIT(5) 87 #define CXL_RAS_CE_PHYS_LAYER_ERR BIT(6) 88 89 #define show_ce_errs(status) __print_flags(status, " | ", \ 90 { CXL_RAS_CE_CACHE_DATA_ECC, "Cache Data ECC Error" }, \ 91 { CXL_RAS_CE_MEM_DATA_ECC, "Memory Data ECC Error" }, \ 92 { CXL_RAS_CE_CRC_THRESH, "CRC Threshold Hit" }, \ 93 { CLX_RAS_CE_RETRY_THRESH, "Retry Threshold" }, \ 94 { CXL_RAS_CE_CACHE_POISON, "Received Cache Poison From Peer" }, \ 95 { CXL_RAS_CE_MEM_POISON, "Received Memory Poison From Peer" }, \ 96 { CXL_RAS_CE_PHYS_LAYER_ERR, "Received Error From Physical Layer" } \ 97 ) 98 99 TRACE_EVENT(cxl_aer_correctable_error, 100 TP_PROTO(const struct cxl_memdev *cxlmd, u32 status), 101 TP_ARGS(cxlmd, status), 102 TP_STRUCT__entry( 103 __string(memdev, dev_name(&cxlmd->dev)) 104 __string(host, dev_name(cxlmd->dev.parent)) 105 __field(u64, serial) 106 __field(u32, status) 107 ), 108 TP_fast_assign( 109 __assign_str(memdev, dev_name(&cxlmd->dev)); 110 __assign_str(host, dev_name(cxlmd->dev.parent)); 111 __entry->serial = cxlmd->cxlds->serial; 112 __entry->status = status; 113 ), 114 TP_printk("memdev=%s host=%s serial=%lld: status: '%s'", 115 __get_str(memdev), __get_str(host), __entry->serial, 116 show_ce_errs(__entry->status) 117 ) 118 ); 119 120 #define cxl_event_log_type_str(type) \ 121 __print_symbolic(type, \ 122 { CXL_EVENT_TYPE_INFO, "Informational" }, \ 123 { CXL_EVENT_TYPE_WARN, "Warning" }, \ 124 { CXL_EVENT_TYPE_FAIL, "Failure" }, \ 125 { CXL_EVENT_TYPE_FATAL, "Fatal" }) 126 127 TRACE_EVENT(cxl_overflow, 128 129 TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type log, 130 struct cxl_get_event_payload *payload), 131 132 TP_ARGS(cxlmd, log, payload), 133 134 TP_STRUCT__entry( 135 __string(memdev, dev_name(&cxlmd->dev)) 136 __string(host, dev_name(cxlmd->dev.parent)) 137 __field(int, log) 138 __field(u64, serial) 139 __field(u64, first_ts) 140 __field(u64, last_ts) 141 __field(u16, count) 142 ), 143 144 TP_fast_assign( 145 __assign_str(memdev, dev_name(&cxlmd->dev)); 146 __assign_str(host, dev_name(cxlmd->dev.parent)); 147 __entry->serial = cxlmd->cxlds->serial; 148 __entry->log = log; 149 __entry->count = le16_to_cpu(payload->overflow_err_count); 150 __entry->first_ts = le64_to_cpu(payload->first_overflow_timestamp); 151 __entry->last_ts = le64_to_cpu(payload->last_overflow_timestamp); 152 ), 153 154 TP_printk("memdev=%s host=%s serial=%lld: log=%s : %u records from %llu to %llu", 155 __get_str(memdev), __get_str(host), __entry->serial, 156 cxl_event_log_type_str(__entry->log), __entry->count, 157 __entry->first_ts, __entry->last_ts) 158 159 ); 160 161 /* 162 * Common Event Record Format 163 * CXL 3.0 section 8.2.9.2.1; Table 8-42 164 */ 165 #define CXL_EVENT_RECORD_FLAG_PERMANENT BIT(2) 166 #define CXL_EVENT_RECORD_FLAG_MAINT_NEEDED BIT(3) 167 #define CXL_EVENT_RECORD_FLAG_PERF_DEGRADED BIT(4) 168 #define CXL_EVENT_RECORD_FLAG_HW_REPLACE BIT(5) 169 #define show_hdr_flags(flags) __print_flags(flags, " | ", \ 170 { CXL_EVENT_RECORD_FLAG_PERMANENT, "PERMANENT_CONDITION" }, \ 171 { CXL_EVENT_RECORD_FLAG_MAINT_NEEDED, "MAINTENANCE_NEEDED" }, \ 172 { CXL_EVENT_RECORD_FLAG_PERF_DEGRADED, "PERFORMANCE_DEGRADED" }, \ 173 { CXL_EVENT_RECORD_FLAG_HW_REPLACE, "HARDWARE_REPLACEMENT_NEEDED" } \ 174 ) 175 176 /* 177 * Define macros for the common header of each CXL event. 178 * 179 * Tracepoints using these macros must do 3 things: 180 * 181 * 1) Add CXL_EVT_TP_entry to TP_STRUCT__entry 182 * 2) Use CXL_EVT_TP_fast_assign within TP_fast_assign; 183 * pass the dev, log, and CXL event header 184 * 3) Use CXL_EVT_TP_printk() instead of TP_printk() 185 * 186 * See the generic_event tracepoint as an example. 187 */ 188 #define CXL_EVT_TP_entry \ 189 __string(memdev, dev_name(&cxlmd->dev)) \ 190 __string(host, dev_name(cxlmd->dev.parent)) \ 191 __field(int, log) \ 192 __field_struct(uuid_t, hdr_uuid) \ 193 __field(u64, serial) \ 194 __field(u32, hdr_flags) \ 195 __field(u16, hdr_handle) \ 196 __field(u16, hdr_related_handle) \ 197 __field(u64, hdr_timestamp) \ 198 __field(u8, hdr_length) \ 199 __field(u8, hdr_maint_op_class) 200 201 #define CXL_EVT_TP_fast_assign(cxlmd, l, hdr) \ 202 __assign_str(memdev, dev_name(&(cxlmd)->dev)); \ 203 __assign_str(host, dev_name((cxlmd)->dev.parent)); \ 204 __entry->log = (l); \ 205 __entry->serial = (cxlmd)->cxlds->serial; \ 206 memcpy(&__entry->hdr_uuid, &(hdr).id, sizeof(uuid_t)); \ 207 __entry->hdr_length = (hdr).length; \ 208 __entry->hdr_flags = get_unaligned_le24((hdr).flags); \ 209 __entry->hdr_handle = le16_to_cpu((hdr).handle); \ 210 __entry->hdr_related_handle = le16_to_cpu((hdr).related_handle); \ 211 __entry->hdr_timestamp = le64_to_cpu((hdr).timestamp); \ 212 __entry->hdr_maint_op_class = (hdr).maint_op_class 213 214 #define CXL_EVT_TP_printk(fmt, ...) \ 215 TP_printk("memdev=%s host=%s serial=%lld log=%s : time=%llu uuid=%pUb " \ 216 "len=%d flags='%s' handle=%x related_handle=%x " \ 217 "maint_op_class=%u : " fmt, \ 218 __get_str(memdev), __get_str(host), __entry->serial, \ 219 cxl_event_log_type_str(__entry->log), \ 220 __entry->hdr_timestamp, &__entry->hdr_uuid, __entry->hdr_length,\ 221 show_hdr_flags(__entry->hdr_flags), __entry->hdr_handle, \ 222 __entry->hdr_related_handle, __entry->hdr_maint_op_class, \ 223 ##__VA_ARGS__) 224 225 TRACE_EVENT(cxl_generic_event, 226 227 TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type log, 228 struct cxl_event_record_raw *rec), 229 230 TP_ARGS(cxlmd, log, rec), 231 232 TP_STRUCT__entry( 233 CXL_EVT_TP_entry 234 __array(u8, data, CXL_EVENT_RECORD_DATA_LENGTH) 235 ), 236 237 TP_fast_assign( 238 CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); 239 memcpy(__entry->data, &rec->data, CXL_EVENT_RECORD_DATA_LENGTH); 240 ), 241 242 CXL_EVT_TP_printk("%s", 243 __print_hex(__entry->data, CXL_EVENT_RECORD_DATA_LENGTH)) 244 ); 245 246 /* 247 * Physical Address field masks 248 * 249 * General Media Event Record 250 * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 251 * 252 * DRAM Event Record 253 * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 254 */ 255 #define CXL_DPA_FLAGS_MASK GENMASK(1, 0) 256 #define CXL_DPA_MASK GENMASK_ULL(63, 6) 257 258 #define CXL_DPA_VOLATILE BIT(0) 259 #define CXL_DPA_NOT_REPAIRABLE BIT(1) 260 #define show_dpa_flags(flags) __print_flags(flags, "|", \ 261 { CXL_DPA_VOLATILE, "VOLATILE" }, \ 262 { CXL_DPA_NOT_REPAIRABLE, "NOT_REPAIRABLE" } \ 263 ) 264 265 /* 266 * General Media Event Record - GMER 267 * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 268 */ 269 #define CXL_GMER_EVT_DESC_UNCORECTABLE_EVENT BIT(0) 270 #define CXL_GMER_EVT_DESC_THRESHOLD_EVENT BIT(1) 271 #define CXL_GMER_EVT_DESC_POISON_LIST_OVERFLOW BIT(2) 272 #define show_event_desc_flags(flags) __print_flags(flags, "|", \ 273 { CXL_GMER_EVT_DESC_UNCORECTABLE_EVENT, "UNCORRECTABLE_EVENT" }, \ 274 { CXL_GMER_EVT_DESC_THRESHOLD_EVENT, "THRESHOLD_EVENT" }, \ 275 { CXL_GMER_EVT_DESC_POISON_LIST_OVERFLOW, "POISON_LIST_OVERFLOW" } \ 276 ) 277 278 #define CXL_GMER_MEM_EVT_TYPE_ECC_ERROR 0x00 279 #define CXL_GMER_MEM_EVT_TYPE_INV_ADDR 0x01 280 #define CXL_GMER_MEM_EVT_TYPE_DATA_PATH_ERROR 0x02 281 #define show_gmer_mem_event_type(type) __print_symbolic(type, \ 282 { CXL_GMER_MEM_EVT_TYPE_ECC_ERROR, "ECC Error" }, \ 283 { CXL_GMER_MEM_EVT_TYPE_INV_ADDR, "Invalid Address" }, \ 284 { CXL_GMER_MEM_EVT_TYPE_DATA_PATH_ERROR, "Data Path Error" } \ 285 ) 286 287 #define CXL_GMER_TRANS_UNKNOWN 0x00 288 #define CXL_GMER_TRANS_HOST_READ 0x01 289 #define CXL_GMER_TRANS_HOST_WRITE 0x02 290 #define CXL_GMER_TRANS_HOST_SCAN_MEDIA 0x03 291 #define CXL_GMER_TRANS_HOST_INJECT_POISON 0x04 292 #define CXL_GMER_TRANS_INTERNAL_MEDIA_SCRUB 0x05 293 #define CXL_GMER_TRANS_INTERNAL_MEDIA_MANAGEMENT 0x06 294 #define show_trans_type(type) __print_symbolic(type, \ 295 { CXL_GMER_TRANS_UNKNOWN, "Unknown" }, \ 296 { CXL_GMER_TRANS_HOST_READ, "Host Read" }, \ 297 { CXL_GMER_TRANS_HOST_WRITE, "Host Write" }, \ 298 { CXL_GMER_TRANS_HOST_SCAN_MEDIA, "Host Scan Media" }, \ 299 { CXL_GMER_TRANS_HOST_INJECT_POISON, "Host Inject Poison" }, \ 300 { CXL_GMER_TRANS_INTERNAL_MEDIA_SCRUB, "Internal Media Scrub" }, \ 301 { CXL_GMER_TRANS_INTERNAL_MEDIA_MANAGEMENT, "Internal Media Management" } \ 302 ) 303 304 #define CXL_GMER_VALID_CHANNEL BIT(0) 305 #define CXL_GMER_VALID_RANK BIT(1) 306 #define CXL_GMER_VALID_DEVICE BIT(2) 307 #define CXL_GMER_VALID_COMPONENT BIT(3) 308 #define show_valid_flags(flags) __print_flags(flags, "|", \ 309 { CXL_GMER_VALID_CHANNEL, "CHANNEL" }, \ 310 { CXL_GMER_VALID_RANK, "RANK" }, \ 311 { CXL_GMER_VALID_DEVICE, "DEVICE" }, \ 312 { CXL_GMER_VALID_COMPONENT, "COMPONENT" } \ 313 ) 314 315 TRACE_EVENT(cxl_general_media, 316 317 TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type log, 318 struct cxl_event_gen_media *rec), 319 320 TP_ARGS(cxlmd, log, rec), 321 322 TP_STRUCT__entry( 323 CXL_EVT_TP_entry 324 /* General Media */ 325 __field(u64, dpa) 326 __field(u8, descriptor) 327 __field(u8, type) 328 __field(u8, transaction_type) 329 __field(u8, channel) 330 __field(u32, device) 331 __array(u8, comp_id, CXL_EVENT_GEN_MED_COMP_ID_SIZE) 332 __field(u16, validity_flags) 333 /* Following are out of order to pack trace record */ 334 __field(u8, rank) 335 __field(u8, dpa_flags) 336 ), 337 338 TP_fast_assign( 339 CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); 340 341 /* General Media */ 342 __entry->dpa = le64_to_cpu(rec->phys_addr); 343 __entry->dpa_flags = __entry->dpa & CXL_DPA_FLAGS_MASK; 344 /* Mask after flags have been parsed */ 345 __entry->dpa &= CXL_DPA_MASK; 346 __entry->descriptor = rec->descriptor; 347 __entry->type = rec->type; 348 __entry->transaction_type = rec->transaction_type; 349 __entry->channel = rec->channel; 350 __entry->rank = rec->rank; 351 __entry->device = get_unaligned_le24(rec->device); 352 memcpy(__entry->comp_id, &rec->component_id, 353 CXL_EVENT_GEN_MED_COMP_ID_SIZE); 354 __entry->validity_flags = get_unaligned_le16(&rec->validity_flags); 355 ), 356 357 CXL_EVT_TP_printk("dpa=%llx dpa_flags='%s' " \ 358 "descriptor='%s' type='%s' transaction_type='%s' channel=%u rank=%u " \ 359 "device=%x comp_id=%s validity_flags='%s'", 360 __entry->dpa, show_dpa_flags(__entry->dpa_flags), 361 show_event_desc_flags(__entry->descriptor), 362 show_gmer_mem_event_type(__entry->type), 363 show_trans_type(__entry->transaction_type), 364 __entry->channel, __entry->rank, __entry->device, 365 __print_hex(__entry->comp_id, CXL_EVENT_GEN_MED_COMP_ID_SIZE), 366 show_valid_flags(__entry->validity_flags) 367 ) 368 ); 369 370 /* 371 * DRAM Event Record - DER 372 * 373 * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 374 */ 375 /* 376 * DRAM Event Record defines many fields the same as the General Media Event 377 * Record. Reuse those definitions as appropriate. 378 */ 379 #define CXL_DER_MEM_EVT_TYPE_ECC_ERROR 0x00 380 #define CXL_DER_MEM_EVT_TYPE_SCRUB_MEDIA_ECC_ERROR 0x01 381 #define CXL_DER_MEM_EVT_TYPE_INV_ADDR 0x02 382 #define CXL_DER_MEM_EVT_TYPE_DATA_PATH_ERROR 0x03 383 #define show_dram_mem_event_type(type) __print_symbolic(type, \ 384 { CXL_DER_MEM_EVT_TYPE_ECC_ERROR, "ECC Error" }, \ 385 { CXL_DER_MEM_EVT_TYPE_SCRUB_MEDIA_ECC_ERROR, "Scrub Media ECC Error" }, \ 386 { CXL_DER_MEM_EVT_TYPE_INV_ADDR, "Invalid Address" }, \ 387 { CXL_DER_MEM_EVT_TYPE_DATA_PATH_ERROR, "Data Path Error" } \ 388 ) 389 390 #define CXL_DER_VALID_CHANNEL BIT(0) 391 #define CXL_DER_VALID_RANK BIT(1) 392 #define CXL_DER_VALID_NIBBLE BIT(2) 393 #define CXL_DER_VALID_BANK_GROUP BIT(3) 394 #define CXL_DER_VALID_BANK BIT(4) 395 #define CXL_DER_VALID_ROW BIT(5) 396 #define CXL_DER_VALID_COLUMN BIT(6) 397 #define CXL_DER_VALID_CORRECTION_MASK BIT(7) 398 #define show_dram_valid_flags(flags) __print_flags(flags, "|", \ 399 { CXL_DER_VALID_CHANNEL, "CHANNEL" }, \ 400 { CXL_DER_VALID_RANK, "RANK" }, \ 401 { CXL_DER_VALID_NIBBLE, "NIBBLE" }, \ 402 { CXL_DER_VALID_BANK_GROUP, "BANK GROUP" }, \ 403 { CXL_DER_VALID_BANK, "BANK" }, \ 404 { CXL_DER_VALID_ROW, "ROW" }, \ 405 { CXL_DER_VALID_COLUMN, "COLUMN" }, \ 406 { CXL_DER_VALID_CORRECTION_MASK, "CORRECTION MASK" } \ 407 ) 408 409 TRACE_EVENT(cxl_dram, 410 411 TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type log, 412 struct cxl_event_dram *rec), 413 414 TP_ARGS(cxlmd, log, rec), 415 416 TP_STRUCT__entry( 417 CXL_EVT_TP_entry 418 /* DRAM */ 419 __field(u64, dpa) 420 __field(u8, descriptor) 421 __field(u8, type) 422 __field(u8, transaction_type) 423 __field(u8, channel) 424 __field(u16, validity_flags) 425 __field(u16, column) /* Out of order to pack trace record */ 426 __field(u32, nibble_mask) 427 __field(u32, row) 428 __array(u8, cor_mask, CXL_EVENT_DER_CORRECTION_MASK_SIZE) 429 __field(u8, rank) /* Out of order to pack trace record */ 430 __field(u8, bank_group) /* Out of order to pack trace record */ 431 __field(u8, bank) /* Out of order to pack trace record */ 432 __field(u8, dpa_flags) /* Out of order to pack trace record */ 433 ), 434 435 TP_fast_assign( 436 CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); 437 438 /* DRAM */ 439 __entry->dpa = le64_to_cpu(rec->phys_addr); 440 __entry->dpa_flags = __entry->dpa & CXL_DPA_FLAGS_MASK; 441 __entry->dpa &= CXL_DPA_MASK; 442 __entry->descriptor = rec->descriptor; 443 __entry->type = rec->type; 444 __entry->transaction_type = rec->transaction_type; 445 __entry->validity_flags = get_unaligned_le16(rec->validity_flags); 446 __entry->channel = rec->channel; 447 __entry->rank = rec->rank; 448 __entry->nibble_mask = get_unaligned_le24(rec->nibble_mask); 449 __entry->bank_group = rec->bank_group; 450 __entry->bank = rec->bank; 451 __entry->row = get_unaligned_le24(rec->row); 452 __entry->column = get_unaligned_le16(rec->column); 453 memcpy(__entry->cor_mask, &rec->correction_mask, 454 CXL_EVENT_DER_CORRECTION_MASK_SIZE); 455 ), 456 457 CXL_EVT_TP_printk("dpa=%llx dpa_flags='%s' descriptor='%s' type='%s' " \ 458 "transaction_type='%s' channel=%u rank=%u nibble_mask=%x " \ 459 "bank_group=%u bank=%u row=%u column=%u cor_mask=%s " \ 460 "validity_flags='%s'", 461 __entry->dpa, show_dpa_flags(__entry->dpa_flags), 462 show_event_desc_flags(__entry->descriptor), 463 show_dram_mem_event_type(__entry->type), 464 show_trans_type(__entry->transaction_type), 465 __entry->channel, __entry->rank, __entry->nibble_mask, 466 __entry->bank_group, __entry->bank, 467 __entry->row, __entry->column, 468 __print_hex(__entry->cor_mask, CXL_EVENT_DER_CORRECTION_MASK_SIZE), 469 show_dram_valid_flags(__entry->validity_flags) 470 ) 471 ); 472 473 /* 474 * Memory Module Event Record - MMER 475 * 476 * CXL res 3.0 section 8.2.9.2.1.3; Table 8-45 477 */ 478 #define CXL_MMER_HEALTH_STATUS_CHANGE 0x00 479 #define CXL_MMER_MEDIA_STATUS_CHANGE 0x01 480 #define CXL_MMER_LIFE_USED_CHANGE 0x02 481 #define CXL_MMER_TEMP_CHANGE 0x03 482 #define CXL_MMER_DATA_PATH_ERROR 0x04 483 #define CXL_MMER_LSA_ERROR 0x05 484 #define show_dev_evt_type(type) __print_symbolic(type, \ 485 { CXL_MMER_HEALTH_STATUS_CHANGE, "Health Status Change" }, \ 486 { CXL_MMER_MEDIA_STATUS_CHANGE, "Media Status Change" }, \ 487 { CXL_MMER_LIFE_USED_CHANGE, "Life Used Change" }, \ 488 { CXL_MMER_TEMP_CHANGE, "Temperature Change" }, \ 489 { CXL_MMER_DATA_PATH_ERROR, "Data Path Error" }, \ 490 { CXL_MMER_LSA_ERROR, "LSA Error" } \ 491 ) 492 493 /* 494 * Device Health Information - DHI 495 * 496 * CXL res 3.0 section 8.2.9.8.3.1; Table 8-100 497 */ 498 #define CXL_DHI_HS_MAINTENANCE_NEEDED BIT(0) 499 #define CXL_DHI_HS_PERFORMANCE_DEGRADED BIT(1) 500 #define CXL_DHI_HS_HW_REPLACEMENT_NEEDED BIT(2) 501 #define show_health_status_flags(flags) __print_flags(flags, "|", \ 502 { CXL_DHI_HS_MAINTENANCE_NEEDED, "MAINTENANCE_NEEDED" }, \ 503 { CXL_DHI_HS_PERFORMANCE_DEGRADED, "PERFORMANCE_DEGRADED" }, \ 504 { CXL_DHI_HS_HW_REPLACEMENT_NEEDED, "REPLACEMENT_NEEDED" } \ 505 ) 506 507 #define CXL_DHI_MS_NORMAL 0x00 508 #define CXL_DHI_MS_NOT_READY 0x01 509 #define CXL_DHI_MS_WRITE_PERSISTENCY_LOST 0x02 510 #define CXL_DHI_MS_ALL_DATA_LOST 0x03 511 #define CXL_DHI_MS_WRITE_PERSISTENCY_LOSS_EVENT_POWER_LOSS 0x04 512 #define CXL_DHI_MS_WRITE_PERSISTENCY_LOSS_EVENT_SHUTDOWN 0x05 513 #define CXL_DHI_MS_WRITE_PERSISTENCY_LOSS_IMMINENT 0x06 514 #define CXL_DHI_MS_WRITE_ALL_DATA_LOSS_EVENT_POWER_LOSS 0x07 515 #define CXL_DHI_MS_WRITE_ALL_DATA_LOSS_EVENT_SHUTDOWN 0x08 516 #define CXL_DHI_MS_WRITE_ALL_DATA_LOSS_IMMINENT 0x09 517 #define show_media_status(ms) __print_symbolic(ms, \ 518 { CXL_DHI_MS_NORMAL, \ 519 "Normal" }, \ 520 { CXL_DHI_MS_NOT_READY, \ 521 "Not Ready" }, \ 522 { CXL_DHI_MS_WRITE_PERSISTENCY_LOST, \ 523 "Write Persistency Lost" }, \ 524 { CXL_DHI_MS_ALL_DATA_LOST, \ 525 "All Data Lost" }, \ 526 { CXL_DHI_MS_WRITE_PERSISTENCY_LOSS_EVENT_POWER_LOSS, \ 527 "Write Persistency Loss in the Event of Power Loss" }, \ 528 { CXL_DHI_MS_WRITE_PERSISTENCY_LOSS_EVENT_SHUTDOWN, \ 529 "Write Persistency Loss in Event of Shutdown" }, \ 530 { CXL_DHI_MS_WRITE_PERSISTENCY_LOSS_IMMINENT, \ 531 "Write Persistency Loss Imminent" }, \ 532 { CXL_DHI_MS_WRITE_ALL_DATA_LOSS_EVENT_POWER_LOSS, \ 533 "All Data Loss in Event of Power Loss" }, \ 534 { CXL_DHI_MS_WRITE_ALL_DATA_LOSS_EVENT_SHUTDOWN, \ 535 "All Data loss in the Event of Shutdown" }, \ 536 { CXL_DHI_MS_WRITE_ALL_DATA_LOSS_IMMINENT, \ 537 "All Data Loss Imminent" } \ 538 ) 539 540 #define CXL_DHI_AS_NORMAL 0x0 541 #define CXL_DHI_AS_WARNING 0x1 542 #define CXL_DHI_AS_CRITICAL 0x2 543 #define show_two_bit_status(as) __print_symbolic(as, \ 544 { CXL_DHI_AS_NORMAL, "Normal" }, \ 545 { CXL_DHI_AS_WARNING, "Warning" }, \ 546 { CXL_DHI_AS_CRITICAL, "Critical" } \ 547 ) 548 #define show_one_bit_status(as) __print_symbolic(as, \ 549 { CXL_DHI_AS_NORMAL, "Normal" }, \ 550 { CXL_DHI_AS_WARNING, "Warning" } \ 551 ) 552 553 #define CXL_DHI_AS_LIFE_USED(as) (as & 0x3) 554 #define CXL_DHI_AS_DEV_TEMP(as) ((as & 0xC) >> 2) 555 #define CXL_DHI_AS_COR_VOL_ERR_CNT(as) ((as & 0x10) >> 4) 556 #define CXL_DHI_AS_COR_PER_ERR_CNT(as) ((as & 0x20) >> 5) 557 558 TRACE_EVENT(cxl_memory_module, 559 560 TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type log, 561 struct cxl_event_mem_module *rec), 562 563 TP_ARGS(cxlmd, log, rec), 564 565 TP_STRUCT__entry( 566 CXL_EVT_TP_entry 567 568 /* Memory Module Event */ 569 __field(u8, event_type) 570 571 /* Device Health Info */ 572 __field(u8, health_status) 573 __field(u8, media_status) 574 __field(u8, life_used) 575 __field(u32, dirty_shutdown_cnt) 576 __field(u32, cor_vol_err_cnt) 577 __field(u32, cor_per_err_cnt) 578 __field(s16, device_temp) 579 __field(u8, add_status) 580 ), 581 582 TP_fast_assign( 583 CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); 584 585 /* Memory Module Event */ 586 __entry->event_type = rec->event_type; 587 588 /* Device Health Info */ 589 __entry->health_status = rec->info.health_status; 590 __entry->media_status = rec->info.media_status; 591 __entry->life_used = rec->info.life_used; 592 __entry->dirty_shutdown_cnt = get_unaligned_le32(rec->info.dirty_shutdown_cnt); 593 __entry->cor_vol_err_cnt = get_unaligned_le32(rec->info.cor_vol_err_cnt); 594 __entry->cor_per_err_cnt = get_unaligned_le32(rec->info.cor_per_err_cnt); 595 __entry->device_temp = get_unaligned_le16(rec->info.device_temp); 596 __entry->add_status = rec->info.add_status; 597 ), 598 599 CXL_EVT_TP_printk("event_type='%s' health_status='%s' media_status='%s' " \ 600 "as_life_used=%s as_dev_temp=%s as_cor_vol_err_cnt=%s " \ 601 "as_cor_per_err_cnt=%s life_used=%u device_temp=%d " \ 602 "dirty_shutdown_cnt=%u cor_vol_err_cnt=%u cor_per_err_cnt=%u", 603 show_dev_evt_type(__entry->event_type), 604 show_health_status_flags(__entry->health_status), 605 show_media_status(__entry->media_status), 606 show_two_bit_status(CXL_DHI_AS_LIFE_USED(__entry->add_status)), 607 show_two_bit_status(CXL_DHI_AS_DEV_TEMP(__entry->add_status)), 608 show_one_bit_status(CXL_DHI_AS_COR_VOL_ERR_CNT(__entry->add_status)), 609 show_one_bit_status(CXL_DHI_AS_COR_PER_ERR_CNT(__entry->add_status)), 610 __entry->life_used, __entry->device_temp, 611 __entry->dirty_shutdown_cnt, __entry->cor_vol_err_cnt, 612 __entry->cor_per_err_cnt 613 ) 614 ); 615 616 #define show_poison_trace_type(type) \ 617 __print_symbolic(type, \ 618 { CXL_POISON_TRACE_LIST, "List" }, \ 619 { CXL_POISON_TRACE_INJECT, "Inject" }, \ 620 { CXL_POISON_TRACE_CLEAR, "Clear" }) 621 622 #define __show_poison_source(source) \ 623 __print_symbolic(source, \ 624 { CXL_POISON_SOURCE_UNKNOWN, "Unknown" }, \ 625 { CXL_POISON_SOURCE_EXTERNAL, "External" }, \ 626 { CXL_POISON_SOURCE_INTERNAL, "Internal" }, \ 627 { CXL_POISON_SOURCE_INJECTED, "Injected" }, \ 628 { CXL_POISON_SOURCE_VENDOR, "Vendor" }) 629 630 #define show_poison_source(source) \ 631 (((source > CXL_POISON_SOURCE_INJECTED) && \ 632 (source != CXL_POISON_SOURCE_VENDOR)) ? "Reserved" \ 633 : __show_poison_source(source)) 634 635 #define show_poison_flags(flags) \ 636 __print_flags(flags, "|", \ 637 { CXL_POISON_FLAG_MORE, "More" }, \ 638 { CXL_POISON_FLAG_OVERFLOW, "Overflow" }, \ 639 { CXL_POISON_FLAG_SCANNING, "Scanning" }) 640 641 #define __cxl_poison_addr(record) \ 642 (le64_to_cpu(record->address)) 643 #define cxl_poison_record_dpa(record) \ 644 (__cxl_poison_addr(record) & CXL_POISON_START_MASK) 645 #define cxl_poison_record_source(record) \ 646 (__cxl_poison_addr(record) & CXL_POISON_SOURCE_MASK) 647 #define cxl_poison_record_dpa_length(record) \ 648 (le32_to_cpu(record->length) * CXL_POISON_LEN_MULT) 649 #define cxl_poison_overflow(flags, time) \ 650 (flags & CXL_POISON_FLAG_OVERFLOW ? le64_to_cpu(time) : 0) 651 652 u64 cxl_trace_hpa(struct cxl_region *cxlr, struct cxl_memdev *memdev, u64 dpa); 653 654 TRACE_EVENT(cxl_poison, 655 656 TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *cxlr, 657 const struct cxl_poison_record *record, u8 flags, 658 __le64 overflow_ts, enum cxl_poison_trace_type trace_type), 659 660 TP_ARGS(cxlmd, cxlr, record, flags, overflow_ts, trace_type), 661 662 TP_STRUCT__entry( 663 __string(memdev, dev_name(&cxlmd->dev)) 664 __string(host, dev_name(cxlmd->dev.parent)) 665 __field(u64, serial) 666 __field(u8, trace_type) 667 __string(region, cxlr ? dev_name(&cxlr->dev) : "") 668 __field(u64, overflow_ts) 669 __field(u64, hpa) 670 __field(u64, dpa) 671 __field(u32, dpa_length) 672 __array(char, uuid, 16) 673 __field(u8, source) 674 __field(u8, flags) 675 ), 676 677 TP_fast_assign( 678 __assign_str(memdev, dev_name(&cxlmd->dev)); 679 __assign_str(host, dev_name(cxlmd->dev.parent)); 680 __entry->serial = cxlmd->cxlds->serial; 681 __entry->overflow_ts = cxl_poison_overflow(flags, overflow_ts); 682 __entry->dpa = cxl_poison_record_dpa(record); 683 __entry->dpa_length = cxl_poison_record_dpa_length(record); 684 __entry->source = cxl_poison_record_source(record); 685 __entry->trace_type = trace_type; 686 __entry->flags = flags; 687 if (cxlr) { 688 __assign_str(region, dev_name(&cxlr->dev)); 689 memcpy(__entry->uuid, &cxlr->params.uuid, 16); 690 __entry->hpa = cxl_trace_hpa(cxlr, cxlmd, 691 __entry->dpa); 692 } else { 693 __assign_str(region, ""); 694 memset(__entry->uuid, 0, 16); 695 __entry->hpa = ULLONG_MAX; 696 } 697 ), 698 699 TP_printk("memdev=%s host=%s serial=%lld trace_type=%s region=%s " \ 700 "region_uuid=%pU hpa=0x%llx dpa=0x%llx dpa_length=0x%x " \ 701 "source=%s flags=%s overflow_time=%llu", 702 __get_str(memdev), 703 __get_str(host), 704 __entry->serial, 705 show_poison_trace_type(__entry->trace_type), 706 __get_str(region), 707 __entry->uuid, 708 __entry->hpa, 709 __entry->dpa, 710 __entry->dpa_length, 711 show_poison_source(__entry->source), 712 show_poison_flags(__entry->flags), 713 __entry->overflow_ts 714 ) 715 ); 716 717 #endif /* _CXL_EVENTS_H */ 718 719 #define TRACE_INCLUDE_FILE trace 720 #include <trace/define_trace.h> 721