14a20bc3eSDan Williams // SPDX-License-Identifier: GPL-2.0 24a20bc3eSDan Williams /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ 34a20bc3eSDan Williams #undef TRACE_SYSTEM 44a20bc3eSDan Williams #define TRACE_SYSTEM cxl 54a20bc3eSDan Williams 64a20bc3eSDan Williams #if !defined(_CXL_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ) 74a20bc3eSDan Williams #define _CXL_EVENTS_H 84a20bc3eSDan Williams 94a20bc3eSDan Williams #include <linux/tracepoint.h> 106ebe28f9SIra Weiny #include <asm-generic/unaligned.h> 116ebe28f9SIra Weiny 126ebe28f9SIra Weiny #include <cxl.h> 136ebe28f9SIra Weiny #include <cxlmem.h> 144a20bc3eSDan Williams 154a20bc3eSDan Williams #define CXL_RAS_UC_CACHE_DATA_PARITY BIT(0) 164a20bc3eSDan Williams #define CXL_RAS_UC_CACHE_ADDR_PARITY BIT(1) 174a20bc3eSDan Williams #define CXL_RAS_UC_CACHE_BE_PARITY BIT(2) 184a20bc3eSDan Williams #define CXL_RAS_UC_CACHE_DATA_ECC BIT(3) 194a20bc3eSDan Williams #define CXL_RAS_UC_MEM_DATA_PARITY BIT(4) 204a20bc3eSDan Williams #define CXL_RAS_UC_MEM_ADDR_PARITY BIT(5) 214a20bc3eSDan Williams #define CXL_RAS_UC_MEM_BE_PARITY BIT(6) 224a20bc3eSDan Williams #define CXL_RAS_UC_MEM_DATA_ECC BIT(7) 234a20bc3eSDan Williams #define CXL_RAS_UC_REINIT_THRESH BIT(8) 244a20bc3eSDan Williams #define CXL_RAS_UC_RSVD_ENCODE BIT(9) 254a20bc3eSDan Williams #define CXL_RAS_UC_POISON BIT(10) 264a20bc3eSDan Williams #define CXL_RAS_UC_RECV_OVERFLOW BIT(11) 274a20bc3eSDan Williams #define CXL_RAS_UC_INTERNAL_ERR BIT(14) 284a20bc3eSDan Williams #define CXL_RAS_UC_IDE_TX_ERR BIT(15) 294a20bc3eSDan Williams #define CXL_RAS_UC_IDE_RX_ERR BIT(16) 304a20bc3eSDan Williams 314a20bc3eSDan Williams #define show_uc_errs(status) __print_flags(status, " | ", \ 324a20bc3eSDan Williams { CXL_RAS_UC_CACHE_DATA_PARITY, "Cache Data Parity Error" }, \ 334a20bc3eSDan Williams { CXL_RAS_UC_CACHE_ADDR_PARITY, "Cache Address Parity Error" }, \ 344a20bc3eSDan Williams { CXL_RAS_UC_CACHE_BE_PARITY, "Cache Byte Enable Parity Error" }, \ 354a20bc3eSDan Williams { CXL_RAS_UC_CACHE_DATA_ECC, "Cache Data ECC Error" }, \ 364a20bc3eSDan Williams { CXL_RAS_UC_MEM_DATA_PARITY, "Memory Data Parity Error" }, \ 374a20bc3eSDan Williams { CXL_RAS_UC_MEM_ADDR_PARITY, "Memory Address Parity Error" }, \ 384a20bc3eSDan Williams { CXL_RAS_UC_MEM_BE_PARITY, "Memory Byte Enable Parity Error" }, \ 394a20bc3eSDan Williams { CXL_RAS_UC_MEM_DATA_ECC, "Memory Data ECC Error" }, \ 404a20bc3eSDan Williams { CXL_RAS_UC_REINIT_THRESH, "REINIT Threshold Hit" }, \ 414a20bc3eSDan Williams { CXL_RAS_UC_RSVD_ENCODE, "Received Unrecognized Encoding" }, \ 424a20bc3eSDan Williams { CXL_RAS_UC_POISON, "Received Poison From Peer" }, \ 434a20bc3eSDan Williams { CXL_RAS_UC_RECV_OVERFLOW, "Receiver Overflow" }, \ 444a20bc3eSDan Williams { CXL_RAS_UC_INTERNAL_ERR, "Component Specific Error" }, \ 454a20bc3eSDan Williams { CXL_RAS_UC_IDE_TX_ERR, "IDE Tx Error" }, \ 464a20bc3eSDan Williams { CXL_RAS_UC_IDE_RX_ERR, "IDE Rx Error" } \ 474a20bc3eSDan Williams ) 484a20bc3eSDan Williams 494a20bc3eSDan Williams TRACE_EVENT(cxl_aer_uncorrectable_error, 504a20bc3eSDan Williams TP_PROTO(const struct device *dev, u32 status, u32 fe, u32 *hl), 514a20bc3eSDan Williams TP_ARGS(dev, status, fe, hl), 524a20bc3eSDan Williams TP_STRUCT__entry( 534a20bc3eSDan Williams __string(dev_name, dev_name(dev)) 544a20bc3eSDan Williams __field(u32, status) 554a20bc3eSDan Williams __field(u32, first_error) 564a20bc3eSDan Williams __array(u32, header_log, CXL_HEADERLOG_SIZE_U32) 574a20bc3eSDan Williams ), 584a20bc3eSDan Williams TP_fast_assign( 594a20bc3eSDan Williams __assign_str(dev_name, dev_name(dev)); 604a20bc3eSDan Williams __entry->status = status; 614a20bc3eSDan Williams __entry->first_error = fe; 624a20bc3eSDan Williams /* 634a20bc3eSDan Williams * Embed the 512B headerlog data for user app retrieval and 644a20bc3eSDan Williams * parsing, but no need to print this in the trace buffer. 654a20bc3eSDan Williams */ 664a20bc3eSDan Williams memcpy(__entry->header_log, hl, CXL_HEADERLOG_SIZE); 674a20bc3eSDan Williams ), 684a20bc3eSDan Williams TP_printk("%s: status: '%s' first_error: '%s'", 694a20bc3eSDan Williams __get_str(dev_name), 704a20bc3eSDan Williams show_uc_errs(__entry->status), 714a20bc3eSDan Williams show_uc_errs(__entry->first_error) 724a20bc3eSDan Williams ) 734a20bc3eSDan Williams ); 744a20bc3eSDan Williams 754a20bc3eSDan Williams #define CXL_RAS_CE_CACHE_DATA_ECC BIT(0) 764a20bc3eSDan Williams #define CXL_RAS_CE_MEM_DATA_ECC BIT(1) 774a20bc3eSDan Williams #define CXL_RAS_CE_CRC_THRESH BIT(2) 784a20bc3eSDan Williams #define CLX_RAS_CE_RETRY_THRESH BIT(3) 794a20bc3eSDan Williams #define CXL_RAS_CE_CACHE_POISON BIT(4) 804a20bc3eSDan Williams #define CXL_RAS_CE_MEM_POISON BIT(5) 814a20bc3eSDan Williams #define CXL_RAS_CE_PHYS_LAYER_ERR BIT(6) 824a20bc3eSDan Williams 834a20bc3eSDan Williams #define show_ce_errs(status) __print_flags(status, " | ", \ 844a20bc3eSDan Williams { CXL_RAS_CE_CACHE_DATA_ECC, "Cache Data ECC Error" }, \ 854a20bc3eSDan Williams { CXL_RAS_CE_MEM_DATA_ECC, "Memory Data ECC Error" }, \ 864a20bc3eSDan Williams { CXL_RAS_CE_CRC_THRESH, "CRC Threshold Hit" }, \ 874a20bc3eSDan Williams { CLX_RAS_CE_RETRY_THRESH, "Retry Threshold" }, \ 884a20bc3eSDan Williams { CXL_RAS_CE_CACHE_POISON, "Received Cache Poison From Peer" }, \ 894a20bc3eSDan Williams { CXL_RAS_CE_MEM_POISON, "Received Memory Poison From Peer" }, \ 904a20bc3eSDan Williams { CXL_RAS_CE_PHYS_LAYER_ERR, "Received Error From Physical Layer" } \ 914a20bc3eSDan Williams ) 924a20bc3eSDan Williams 934a20bc3eSDan Williams TRACE_EVENT(cxl_aer_correctable_error, 944a20bc3eSDan Williams TP_PROTO(const struct device *dev, u32 status), 954a20bc3eSDan Williams TP_ARGS(dev, status), 964a20bc3eSDan Williams TP_STRUCT__entry( 974a20bc3eSDan Williams __string(dev_name, dev_name(dev)) 984a20bc3eSDan Williams __field(u32, status) 994a20bc3eSDan Williams ), 1004a20bc3eSDan Williams TP_fast_assign( 1014a20bc3eSDan Williams __assign_str(dev_name, dev_name(dev)); 1024a20bc3eSDan Williams __entry->status = status; 1034a20bc3eSDan Williams ), 1044a20bc3eSDan Williams TP_printk("%s: status: '%s'", 1054a20bc3eSDan Williams __get_str(dev_name), show_ce_errs(__entry->status) 1064a20bc3eSDan Williams ) 1074a20bc3eSDan Williams ); 1084a20bc3eSDan Williams 1096ebe28f9SIra Weiny #define cxl_event_log_type_str(type) \ 1106ebe28f9SIra Weiny __print_symbolic(type, \ 1116ebe28f9SIra Weiny { CXL_EVENT_TYPE_INFO, "Informational" }, \ 1126ebe28f9SIra Weiny { CXL_EVENT_TYPE_WARN, "Warning" }, \ 1136ebe28f9SIra Weiny { CXL_EVENT_TYPE_FAIL, "Failure" }, \ 1146ebe28f9SIra Weiny { CXL_EVENT_TYPE_FATAL, "Fatal" }) 1156ebe28f9SIra Weiny 1166ebe28f9SIra Weiny TRACE_EVENT(cxl_overflow, 1176ebe28f9SIra Weiny 1186ebe28f9SIra Weiny TP_PROTO(const struct device *dev, enum cxl_event_log_type log, 1196ebe28f9SIra Weiny struct cxl_get_event_payload *payload), 1206ebe28f9SIra Weiny 1216ebe28f9SIra Weiny TP_ARGS(dev, log, payload), 1226ebe28f9SIra Weiny 1236ebe28f9SIra Weiny TP_STRUCT__entry( 1246ebe28f9SIra Weiny __string(dev_name, dev_name(dev)) 1256ebe28f9SIra Weiny __field(int, log) 1266ebe28f9SIra Weiny __field(u64, first_ts) 1276ebe28f9SIra Weiny __field(u64, last_ts) 1286ebe28f9SIra Weiny __field(u16, count) 1296ebe28f9SIra Weiny ), 1306ebe28f9SIra Weiny 1316ebe28f9SIra Weiny TP_fast_assign( 1326ebe28f9SIra Weiny __assign_str(dev_name, dev_name(dev)); 1336ebe28f9SIra Weiny __entry->log = log; 1346ebe28f9SIra Weiny __entry->count = le16_to_cpu(payload->overflow_err_count); 1356ebe28f9SIra Weiny __entry->first_ts = le64_to_cpu(payload->first_overflow_timestamp); 1366ebe28f9SIra Weiny __entry->last_ts = le64_to_cpu(payload->last_overflow_timestamp); 1376ebe28f9SIra Weiny ), 1386ebe28f9SIra Weiny 1396ebe28f9SIra Weiny TP_printk("%s: log=%s : %u records from %llu to %llu", 1406ebe28f9SIra Weiny __get_str(dev_name), cxl_event_log_type_str(__entry->log), 1416ebe28f9SIra Weiny __entry->count, __entry->first_ts, __entry->last_ts) 1426ebe28f9SIra Weiny 1436ebe28f9SIra Weiny ); 1446ebe28f9SIra Weiny 1456ebe28f9SIra Weiny /* 1466ebe28f9SIra Weiny * Common Event Record Format 1476ebe28f9SIra Weiny * CXL 3.0 section 8.2.9.2.1; Table 8-42 1486ebe28f9SIra Weiny */ 1496ebe28f9SIra Weiny #define CXL_EVENT_RECORD_FLAG_PERMANENT BIT(2) 1506ebe28f9SIra Weiny #define CXL_EVENT_RECORD_FLAG_MAINT_NEEDED BIT(3) 1516ebe28f9SIra Weiny #define CXL_EVENT_RECORD_FLAG_PERF_DEGRADED BIT(4) 1526ebe28f9SIra Weiny #define CXL_EVENT_RECORD_FLAG_HW_REPLACE BIT(5) 1536ebe28f9SIra Weiny #define show_hdr_flags(flags) __print_flags(flags, " | ", \ 1546ebe28f9SIra Weiny { CXL_EVENT_RECORD_FLAG_PERMANENT, "PERMANENT_CONDITION" }, \ 1556ebe28f9SIra Weiny { CXL_EVENT_RECORD_FLAG_MAINT_NEEDED, "MAINTENANCE_NEEDED" }, \ 1566ebe28f9SIra Weiny { CXL_EVENT_RECORD_FLAG_PERF_DEGRADED, "PERFORMANCE_DEGRADED" }, \ 1576ebe28f9SIra Weiny { CXL_EVENT_RECORD_FLAG_HW_REPLACE, "HARDWARE_REPLACEMENT_NEEDED" } \ 1586ebe28f9SIra Weiny ) 1596ebe28f9SIra Weiny 1606ebe28f9SIra Weiny /* 1616ebe28f9SIra Weiny * Define macros for the common header of each CXL event. 1626ebe28f9SIra Weiny * 1636ebe28f9SIra Weiny * Tracepoints using these macros must do 3 things: 1646ebe28f9SIra Weiny * 1656ebe28f9SIra Weiny * 1) Add CXL_EVT_TP_entry to TP_STRUCT__entry 1666ebe28f9SIra Weiny * 2) Use CXL_EVT_TP_fast_assign within TP_fast_assign; 1676ebe28f9SIra Weiny * pass the dev, log, and CXL event header 1686ebe28f9SIra Weiny * 3) Use CXL_EVT_TP_printk() instead of TP_printk() 1696ebe28f9SIra Weiny * 1706ebe28f9SIra Weiny * See the generic_event tracepoint as an example. 1716ebe28f9SIra Weiny */ 1726ebe28f9SIra Weiny #define CXL_EVT_TP_entry \ 1736ebe28f9SIra Weiny __string(dev_name, dev_name(dev)) \ 1746ebe28f9SIra Weiny __field(int, log) \ 1756ebe28f9SIra Weiny __field_struct(uuid_t, hdr_uuid) \ 1766ebe28f9SIra Weiny __field(u32, hdr_flags) \ 1776ebe28f9SIra Weiny __field(u16, hdr_handle) \ 1786ebe28f9SIra Weiny __field(u16, hdr_related_handle) \ 1796ebe28f9SIra Weiny __field(u64, hdr_timestamp) \ 1806ebe28f9SIra Weiny __field(u8, hdr_length) \ 1816ebe28f9SIra Weiny __field(u8, hdr_maint_op_class) 1826ebe28f9SIra Weiny 1836ebe28f9SIra Weiny #define CXL_EVT_TP_fast_assign(dev, l, hdr) \ 1846ebe28f9SIra Weiny __assign_str(dev_name, dev_name(dev)); \ 1856ebe28f9SIra Weiny __entry->log = (l); \ 1866ebe28f9SIra Weiny memcpy(&__entry->hdr_uuid, &(hdr).id, sizeof(uuid_t)); \ 1876ebe28f9SIra Weiny __entry->hdr_length = (hdr).length; \ 1886ebe28f9SIra Weiny __entry->hdr_flags = get_unaligned_le24((hdr).flags); \ 1896ebe28f9SIra Weiny __entry->hdr_handle = le16_to_cpu((hdr).handle); \ 1906ebe28f9SIra Weiny __entry->hdr_related_handle = le16_to_cpu((hdr).related_handle); \ 1916ebe28f9SIra Weiny __entry->hdr_timestamp = le64_to_cpu((hdr).timestamp); \ 1926ebe28f9SIra Weiny __entry->hdr_maint_op_class = (hdr).maint_op_class 1936ebe28f9SIra Weiny 1946ebe28f9SIra Weiny #define CXL_EVT_TP_printk(fmt, ...) \ 1956ebe28f9SIra Weiny TP_printk("%s log=%s : time=%llu uuid=%pUb len=%d flags='%s' " \ 1966ebe28f9SIra Weiny "handle=%x related_handle=%x maint_op_class=%u" \ 1976ebe28f9SIra Weiny " : " fmt, \ 1986ebe28f9SIra Weiny __get_str(dev_name), cxl_event_log_type_str(__entry->log), \ 1996ebe28f9SIra Weiny __entry->hdr_timestamp, &__entry->hdr_uuid, __entry->hdr_length,\ 2006ebe28f9SIra Weiny show_hdr_flags(__entry->hdr_flags), __entry->hdr_handle, \ 2016ebe28f9SIra Weiny __entry->hdr_related_handle, __entry->hdr_maint_op_class, \ 2026ebe28f9SIra Weiny ##__VA_ARGS__) 2036ebe28f9SIra Weiny 2046ebe28f9SIra Weiny TRACE_EVENT(cxl_generic_event, 2056ebe28f9SIra Weiny 2066ebe28f9SIra Weiny TP_PROTO(const struct device *dev, enum cxl_event_log_type log, 2076ebe28f9SIra Weiny struct cxl_event_record_raw *rec), 2086ebe28f9SIra Weiny 2096ebe28f9SIra Weiny TP_ARGS(dev, log, rec), 2106ebe28f9SIra Weiny 2116ebe28f9SIra Weiny TP_STRUCT__entry( 2126ebe28f9SIra Weiny CXL_EVT_TP_entry 2136ebe28f9SIra Weiny __array(u8, data, CXL_EVENT_RECORD_DATA_LENGTH) 2146ebe28f9SIra Weiny ), 2156ebe28f9SIra Weiny 2166ebe28f9SIra Weiny TP_fast_assign( 2176ebe28f9SIra Weiny CXL_EVT_TP_fast_assign(dev, log, rec->hdr); 2186ebe28f9SIra Weiny memcpy(__entry->data, &rec->data, CXL_EVENT_RECORD_DATA_LENGTH); 2196ebe28f9SIra Weiny ), 2206ebe28f9SIra Weiny 2216ebe28f9SIra Weiny CXL_EVT_TP_printk("%s", 2226ebe28f9SIra Weiny __print_hex(__entry->data, CXL_EVENT_RECORD_DATA_LENGTH)) 2236ebe28f9SIra Weiny ); 2246ebe28f9SIra Weiny 225d54a531aSIra Weiny /* 226d54a531aSIra Weiny * Physical Address field masks 227d54a531aSIra Weiny * 228d54a531aSIra Weiny * General Media Event Record 229d54a531aSIra Weiny * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 230d54a531aSIra Weiny * 231d54a531aSIra Weiny * DRAM Event Record 232d54a531aSIra Weiny * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 233d54a531aSIra Weiny */ 234d54a531aSIra Weiny #define CXL_DPA_FLAGS_MASK 0x3F 235d54a531aSIra Weiny #define CXL_DPA_MASK (~CXL_DPA_FLAGS_MASK) 236d54a531aSIra Weiny 237d54a531aSIra Weiny #define CXL_DPA_VOLATILE BIT(0) 238d54a531aSIra Weiny #define CXL_DPA_NOT_REPAIRABLE BIT(1) 239d54a531aSIra Weiny #define show_dpa_flags(flags) __print_flags(flags, "|", \ 240d54a531aSIra Weiny { CXL_DPA_VOLATILE, "VOLATILE" }, \ 241d54a531aSIra Weiny { CXL_DPA_NOT_REPAIRABLE, "NOT_REPAIRABLE" } \ 242d54a531aSIra Weiny ) 243d54a531aSIra Weiny 244d54a531aSIra Weiny /* 245d54a531aSIra Weiny * General Media Event Record - GMER 246d54a531aSIra Weiny * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 247d54a531aSIra Weiny */ 248d54a531aSIra Weiny #define CXL_GMER_EVT_DESC_UNCORECTABLE_EVENT BIT(0) 249d54a531aSIra Weiny #define CXL_GMER_EVT_DESC_THRESHOLD_EVENT BIT(1) 250d54a531aSIra Weiny #define CXL_GMER_EVT_DESC_POISON_LIST_OVERFLOW BIT(2) 251d54a531aSIra Weiny #define show_event_desc_flags(flags) __print_flags(flags, "|", \ 252d54a531aSIra Weiny { CXL_GMER_EVT_DESC_UNCORECTABLE_EVENT, "UNCORRECTABLE_EVENT" }, \ 253d54a531aSIra Weiny { CXL_GMER_EVT_DESC_THRESHOLD_EVENT, "THRESHOLD_EVENT" }, \ 254d54a531aSIra Weiny { CXL_GMER_EVT_DESC_POISON_LIST_OVERFLOW, "POISON_LIST_OVERFLOW" } \ 255d54a531aSIra Weiny ) 256d54a531aSIra Weiny 257d54a531aSIra Weiny #define CXL_GMER_MEM_EVT_TYPE_ECC_ERROR 0x00 258d54a531aSIra Weiny #define CXL_GMER_MEM_EVT_TYPE_INV_ADDR 0x01 259d54a531aSIra Weiny #define CXL_GMER_MEM_EVT_TYPE_DATA_PATH_ERROR 0x02 260d54a531aSIra Weiny #define show_mem_event_type(type) __print_symbolic(type, \ 261d54a531aSIra Weiny { CXL_GMER_MEM_EVT_TYPE_ECC_ERROR, "ECC Error" }, \ 262d54a531aSIra Weiny { CXL_GMER_MEM_EVT_TYPE_INV_ADDR, "Invalid Address" }, \ 263d54a531aSIra Weiny { CXL_GMER_MEM_EVT_TYPE_DATA_PATH_ERROR, "Data Path Error" } \ 264d54a531aSIra Weiny ) 265d54a531aSIra Weiny 266d54a531aSIra Weiny #define CXL_GMER_TRANS_UNKNOWN 0x00 267d54a531aSIra Weiny #define CXL_GMER_TRANS_HOST_READ 0x01 268d54a531aSIra Weiny #define CXL_GMER_TRANS_HOST_WRITE 0x02 269d54a531aSIra Weiny #define CXL_GMER_TRANS_HOST_SCAN_MEDIA 0x03 270d54a531aSIra Weiny #define CXL_GMER_TRANS_HOST_INJECT_POISON 0x04 271d54a531aSIra Weiny #define CXL_GMER_TRANS_INTERNAL_MEDIA_SCRUB 0x05 272d54a531aSIra Weiny #define CXL_GMER_TRANS_INTERNAL_MEDIA_MANAGEMENT 0x06 273d54a531aSIra Weiny #define show_trans_type(type) __print_symbolic(type, \ 274d54a531aSIra Weiny { CXL_GMER_TRANS_UNKNOWN, "Unknown" }, \ 275d54a531aSIra Weiny { CXL_GMER_TRANS_HOST_READ, "Host Read" }, \ 276d54a531aSIra Weiny { CXL_GMER_TRANS_HOST_WRITE, "Host Write" }, \ 277d54a531aSIra Weiny { CXL_GMER_TRANS_HOST_SCAN_MEDIA, "Host Scan Media" }, \ 278d54a531aSIra Weiny { CXL_GMER_TRANS_HOST_INJECT_POISON, "Host Inject Poison" }, \ 279d54a531aSIra Weiny { CXL_GMER_TRANS_INTERNAL_MEDIA_SCRUB, "Internal Media Scrub" }, \ 280d54a531aSIra Weiny { CXL_GMER_TRANS_INTERNAL_MEDIA_MANAGEMENT, "Internal Media Management" } \ 281d54a531aSIra Weiny ) 282d54a531aSIra Weiny 283d54a531aSIra Weiny #define CXL_GMER_VALID_CHANNEL BIT(0) 284d54a531aSIra Weiny #define CXL_GMER_VALID_RANK BIT(1) 285d54a531aSIra Weiny #define CXL_GMER_VALID_DEVICE BIT(2) 286d54a531aSIra Weiny #define CXL_GMER_VALID_COMPONENT BIT(3) 287d54a531aSIra Weiny #define show_valid_flags(flags) __print_flags(flags, "|", \ 288d54a531aSIra Weiny { CXL_GMER_VALID_CHANNEL, "CHANNEL" }, \ 289d54a531aSIra Weiny { CXL_GMER_VALID_RANK, "RANK" }, \ 290d54a531aSIra Weiny { CXL_GMER_VALID_DEVICE, "DEVICE" }, \ 291d54a531aSIra Weiny { CXL_GMER_VALID_COMPONENT, "COMPONENT" } \ 292d54a531aSIra Weiny ) 293d54a531aSIra Weiny 294d54a531aSIra Weiny TRACE_EVENT(cxl_general_media, 295d54a531aSIra Weiny 296d54a531aSIra Weiny TP_PROTO(const struct device *dev, enum cxl_event_log_type log, 297d54a531aSIra Weiny struct cxl_event_gen_media *rec), 298d54a531aSIra Weiny 299d54a531aSIra Weiny TP_ARGS(dev, log, rec), 300d54a531aSIra Weiny 301d54a531aSIra Weiny TP_STRUCT__entry( 302d54a531aSIra Weiny CXL_EVT_TP_entry 303d54a531aSIra Weiny /* General Media */ 304d54a531aSIra Weiny __field(u64, dpa) 305d54a531aSIra Weiny __field(u8, descriptor) 306d54a531aSIra Weiny __field(u8, type) 307d54a531aSIra Weiny __field(u8, transaction_type) 308d54a531aSIra Weiny __field(u8, channel) 309d54a531aSIra Weiny __field(u32, device) 310d54a531aSIra Weiny __array(u8, comp_id, CXL_EVENT_GEN_MED_COMP_ID_SIZE) 311d54a531aSIra Weiny __field(u16, validity_flags) 312d54a531aSIra Weiny /* Following are out of order to pack trace record */ 313d54a531aSIra Weiny __field(u8, rank) 314d54a531aSIra Weiny __field(u8, dpa_flags) 315d54a531aSIra Weiny ), 316d54a531aSIra Weiny 317d54a531aSIra Weiny TP_fast_assign( 318d54a531aSIra Weiny CXL_EVT_TP_fast_assign(dev, log, rec->hdr); 319d54a531aSIra Weiny 320d54a531aSIra Weiny /* General Media */ 321d54a531aSIra Weiny __entry->dpa = le64_to_cpu(rec->phys_addr); 322d54a531aSIra Weiny __entry->dpa_flags = __entry->dpa & CXL_DPA_FLAGS_MASK; 323d54a531aSIra Weiny /* Mask after flags have been parsed */ 324d54a531aSIra Weiny __entry->dpa &= CXL_DPA_MASK; 325d54a531aSIra Weiny __entry->descriptor = rec->descriptor; 326d54a531aSIra Weiny __entry->type = rec->type; 327d54a531aSIra Weiny __entry->transaction_type = rec->transaction_type; 328d54a531aSIra Weiny __entry->channel = rec->channel; 329d54a531aSIra Weiny __entry->rank = rec->rank; 330d54a531aSIra Weiny __entry->device = get_unaligned_le24(rec->device); 331d54a531aSIra Weiny memcpy(__entry->comp_id, &rec->component_id, 332d54a531aSIra Weiny CXL_EVENT_GEN_MED_COMP_ID_SIZE); 333d54a531aSIra Weiny __entry->validity_flags = get_unaligned_le16(&rec->validity_flags); 334d54a531aSIra Weiny ), 335d54a531aSIra Weiny 336d54a531aSIra Weiny CXL_EVT_TP_printk("dpa=%llx dpa_flags='%s' " \ 337d54a531aSIra Weiny "descriptor='%s' type='%s' transaction_type='%s' channel=%u rank=%u " \ 338d54a531aSIra Weiny "device=%x comp_id=%s validity_flags='%s'", 339d54a531aSIra Weiny __entry->dpa, show_dpa_flags(__entry->dpa_flags), 340d54a531aSIra Weiny show_event_desc_flags(__entry->descriptor), 341d54a531aSIra Weiny show_mem_event_type(__entry->type), 342d54a531aSIra Weiny show_trans_type(__entry->transaction_type), 343d54a531aSIra Weiny __entry->channel, __entry->rank, __entry->device, 344d54a531aSIra Weiny __print_hex(__entry->comp_id, CXL_EVENT_GEN_MED_COMP_ID_SIZE), 345d54a531aSIra Weiny show_valid_flags(__entry->validity_flags) 346d54a531aSIra Weiny ) 347d54a531aSIra Weiny ); 348d54a531aSIra Weiny 349*2d6c1e6dSIra Weiny /* 350*2d6c1e6dSIra Weiny * DRAM Event Record - DER 351*2d6c1e6dSIra Weiny * 352*2d6c1e6dSIra Weiny * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 353*2d6c1e6dSIra Weiny */ 354*2d6c1e6dSIra Weiny /* 355*2d6c1e6dSIra Weiny * DRAM Event Record defines many fields the same as the General Media Event 356*2d6c1e6dSIra Weiny * Record. Reuse those definitions as appropriate. 357*2d6c1e6dSIra Weiny */ 358*2d6c1e6dSIra Weiny #define CXL_DER_VALID_CHANNEL BIT(0) 359*2d6c1e6dSIra Weiny #define CXL_DER_VALID_RANK BIT(1) 360*2d6c1e6dSIra Weiny #define CXL_DER_VALID_NIBBLE BIT(2) 361*2d6c1e6dSIra Weiny #define CXL_DER_VALID_BANK_GROUP BIT(3) 362*2d6c1e6dSIra Weiny #define CXL_DER_VALID_BANK BIT(4) 363*2d6c1e6dSIra Weiny #define CXL_DER_VALID_ROW BIT(5) 364*2d6c1e6dSIra Weiny #define CXL_DER_VALID_COLUMN BIT(6) 365*2d6c1e6dSIra Weiny #define CXL_DER_VALID_CORRECTION_MASK BIT(7) 366*2d6c1e6dSIra Weiny #define show_dram_valid_flags(flags) __print_flags(flags, "|", \ 367*2d6c1e6dSIra Weiny { CXL_DER_VALID_CHANNEL, "CHANNEL" }, \ 368*2d6c1e6dSIra Weiny { CXL_DER_VALID_RANK, "RANK" }, \ 369*2d6c1e6dSIra Weiny { CXL_DER_VALID_NIBBLE, "NIBBLE" }, \ 370*2d6c1e6dSIra Weiny { CXL_DER_VALID_BANK_GROUP, "BANK GROUP" }, \ 371*2d6c1e6dSIra Weiny { CXL_DER_VALID_BANK, "BANK" }, \ 372*2d6c1e6dSIra Weiny { CXL_DER_VALID_ROW, "ROW" }, \ 373*2d6c1e6dSIra Weiny { CXL_DER_VALID_COLUMN, "COLUMN" }, \ 374*2d6c1e6dSIra Weiny { CXL_DER_VALID_CORRECTION_MASK, "CORRECTION MASK" } \ 375*2d6c1e6dSIra Weiny ) 376*2d6c1e6dSIra Weiny 377*2d6c1e6dSIra Weiny TRACE_EVENT(cxl_dram, 378*2d6c1e6dSIra Weiny 379*2d6c1e6dSIra Weiny TP_PROTO(const struct device *dev, enum cxl_event_log_type log, 380*2d6c1e6dSIra Weiny struct cxl_event_dram *rec), 381*2d6c1e6dSIra Weiny 382*2d6c1e6dSIra Weiny TP_ARGS(dev, log, rec), 383*2d6c1e6dSIra Weiny 384*2d6c1e6dSIra Weiny TP_STRUCT__entry( 385*2d6c1e6dSIra Weiny CXL_EVT_TP_entry 386*2d6c1e6dSIra Weiny /* DRAM */ 387*2d6c1e6dSIra Weiny __field(u64, dpa) 388*2d6c1e6dSIra Weiny __field(u8, descriptor) 389*2d6c1e6dSIra Weiny __field(u8, type) 390*2d6c1e6dSIra Weiny __field(u8, transaction_type) 391*2d6c1e6dSIra Weiny __field(u8, channel) 392*2d6c1e6dSIra Weiny __field(u16, validity_flags) 393*2d6c1e6dSIra Weiny __field(u16, column) /* Out of order to pack trace record */ 394*2d6c1e6dSIra Weiny __field(u32, nibble_mask) 395*2d6c1e6dSIra Weiny __field(u32, row) 396*2d6c1e6dSIra Weiny __array(u8, cor_mask, CXL_EVENT_DER_CORRECTION_MASK_SIZE) 397*2d6c1e6dSIra Weiny __field(u8, rank) /* Out of order to pack trace record */ 398*2d6c1e6dSIra Weiny __field(u8, bank_group) /* Out of order to pack trace record */ 399*2d6c1e6dSIra Weiny __field(u8, bank) /* Out of order to pack trace record */ 400*2d6c1e6dSIra Weiny __field(u8, dpa_flags) /* Out of order to pack trace record */ 401*2d6c1e6dSIra Weiny ), 402*2d6c1e6dSIra Weiny 403*2d6c1e6dSIra Weiny TP_fast_assign( 404*2d6c1e6dSIra Weiny CXL_EVT_TP_fast_assign(dev, log, rec->hdr); 405*2d6c1e6dSIra Weiny 406*2d6c1e6dSIra Weiny /* DRAM */ 407*2d6c1e6dSIra Weiny __entry->dpa = le64_to_cpu(rec->phys_addr); 408*2d6c1e6dSIra Weiny __entry->dpa_flags = __entry->dpa & CXL_DPA_FLAGS_MASK; 409*2d6c1e6dSIra Weiny __entry->dpa &= CXL_DPA_MASK; 410*2d6c1e6dSIra Weiny __entry->descriptor = rec->descriptor; 411*2d6c1e6dSIra Weiny __entry->type = rec->type; 412*2d6c1e6dSIra Weiny __entry->transaction_type = rec->transaction_type; 413*2d6c1e6dSIra Weiny __entry->validity_flags = get_unaligned_le16(rec->validity_flags); 414*2d6c1e6dSIra Weiny __entry->channel = rec->channel; 415*2d6c1e6dSIra Weiny __entry->rank = rec->rank; 416*2d6c1e6dSIra Weiny __entry->nibble_mask = get_unaligned_le24(rec->nibble_mask); 417*2d6c1e6dSIra Weiny __entry->bank_group = rec->bank_group; 418*2d6c1e6dSIra Weiny __entry->bank = rec->bank; 419*2d6c1e6dSIra Weiny __entry->row = get_unaligned_le24(rec->row); 420*2d6c1e6dSIra Weiny __entry->column = get_unaligned_le16(rec->column); 421*2d6c1e6dSIra Weiny memcpy(__entry->cor_mask, &rec->correction_mask, 422*2d6c1e6dSIra Weiny CXL_EVENT_DER_CORRECTION_MASK_SIZE); 423*2d6c1e6dSIra Weiny ), 424*2d6c1e6dSIra Weiny 425*2d6c1e6dSIra Weiny CXL_EVT_TP_printk("dpa=%llx dpa_flags='%s' descriptor='%s' type='%s' " \ 426*2d6c1e6dSIra Weiny "transaction_type='%s' channel=%u rank=%u nibble_mask=%x " \ 427*2d6c1e6dSIra Weiny "bank_group=%u bank=%u row=%u column=%u cor_mask=%s " \ 428*2d6c1e6dSIra Weiny "validity_flags='%s'", 429*2d6c1e6dSIra Weiny __entry->dpa, show_dpa_flags(__entry->dpa_flags), 430*2d6c1e6dSIra Weiny show_event_desc_flags(__entry->descriptor), 431*2d6c1e6dSIra Weiny show_mem_event_type(__entry->type), 432*2d6c1e6dSIra Weiny show_trans_type(__entry->transaction_type), 433*2d6c1e6dSIra Weiny __entry->channel, __entry->rank, __entry->nibble_mask, 434*2d6c1e6dSIra Weiny __entry->bank_group, __entry->bank, 435*2d6c1e6dSIra Weiny __entry->row, __entry->column, 436*2d6c1e6dSIra Weiny __print_hex(__entry->cor_mask, CXL_EVENT_DER_CORRECTION_MASK_SIZE), 437*2d6c1e6dSIra Weiny show_dram_valid_flags(__entry->validity_flags) 438*2d6c1e6dSIra Weiny ) 439*2d6c1e6dSIra Weiny ); 440*2d6c1e6dSIra Weiny 4414a20bc3eSDan Williams #endif /* _CXL_EVENTS_H */ 4424a20bc3eSDan Williams 4434a20bc3eSDan Williams #define TRACE_INCLUDE_FILE trace 4444a20bc3eSDan Williams #include <trace/define_trace.h> 445