|
7 | 7 | #define _CXL_EVENTS_H |
8 | 8 |
|
9 | 9 | #include <linux/tracepoint.h> |
| 10 | +#include <linux/pci.h> |
10 | 11 | #include <asm-generic/unaligned.h> |
11 | 12 |
|
12 | 13 | #include <cxl.h> |
13 | 14 | #include <cxlmem.h> |
| 15 | +#include "core.h" |
14 | 16 |
|
15 | 17 | #define CXL_RAS_UC_CACHE_DATA_PARITY BIT(0) |
16 | 18 | #define CXL_RAS_UC_CACHE_ADDR_PARITY BIT(1) |
@@ -600,6 +602,98 @@ TRACE_EVENT(cxl_memory_module, |
600 | 602 | ) |
601 | 603 | ); |
602 | 604 |
|
| 605 | +#define show_poison_trace_type(type) \ |
| 606 | + __print_symbolic(type, \ |
| 607 | + { CXL_POISON_TRACE_LIST, "List" }) |
| 608 | + |
| 609 | +#define __show_poison_source(source) \ |
| 610 | + __print_symbolic(source, \ |
| 611 | + { CXL_POISON_SOURCE_UNKNOWN, "Unknown" }, \ |
| 612 | + { CXL_POISON_SOURCE_EXTERNAL, "External" }, \ |
| 613 | + { CXL_POISON_SOURCE_INTERNAL, "Internal" }, \ |
| 614 | + { CXL_POISON_SOURCE_INJECTED, "Injected" }, \ |
| 615 | + { CXL_POISON_SOURCE_VENDOR, "Vendor" }) |
| 616 | + |
| 617 | +#define show_poison_source(source) \ |
| 618 | + (((source > CXL_POISON_SOURCE_INJECTED) && \ |
| 619 | + (source != CXL_POISON_SOURCE_VENDOR)) ? "Reserved" \ |
| 620 | + : __show_poison_source(source)) |
| 621 | + |
| 622 | +#define show_poison_flags(flags) \ |
| 623 | + __print_flags(flags, "|", \ |
| 624 | + { CXL_POISON_FLAG_MORE, "More" }, \ |
| 625 | + { CXL_POISON_FLAG_OVERFLOW, "Overflow" }, \ |
| 626 | + { CXL_POISON_FLAG_SCANNING, "Scanning" }) |
| 627 | + |
| 628 | +#define __cxl_poison_addr(record) \ |
| 629 | + (le64_to_cpu(record->address)) |
| 630 | +#define cxl_poison_record_dpa(record) \ |
| 631 | + (__cxl_poison_addr(record) & CXL_POISON_START_MASK) |
| 632 | +#define cxl_poison_record_source(record) \ |
| 633 | + (__cxl_poison_addr(record) & CXL_POISON_SOURCE_MASK) |
| 634 | +#define cxl_poison_record_dpa_length(record) \ |
| 635 | + (le32_to_cpu(record->length) * CXL_POISON_LEN_MULT) |
| 636 | +#define cxl_poison_overflow(flags, time) \ |
| 637 | + (flags & CXL_POISON_FLAG_OVERFLOW ? le64_to_cpu(time) : 0) |
| 638 | + |
| 639 | +TRACE_EVENT(cxl_poison, |
| 640 | + |
| 641 | + TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *region, |
| 642 | + const struct cxl_poison_record *record, u8 flags, |
| 643 | + __le64 overflow_ts, enum cxl_poison_trace_type trace_type), |
| 644 | + |
| 645 | + TP_ARGS(cxlmd, region, record, flags, overflow_ts, trace_type), |
| 646 | + |
| 647 | + TP_STRUCT__entry( |
| 648 | + __string(memdev, dev_name(&cxlmd->dev)) |
| 649 | + __string(host, dev_name(cxlmd->dev.parent)) |
| 650 | + __field(u64, serial) |
| 651 | + __field(u8, trace_type) |
| 652 | + __string(region, region) |
| 653 | + __field(u64, overflow_ts) |
| 654 | + __field(u64, dpa) |
| 655 | + __field(u32, dpa_length) |
| 656 | + __array(char, uuid, 16) |
| 657 | + __field(u8, source) |
| 658 | + __field(u8, flags) |
| 659 | + ), |
| 660 | + |
| 661 | + TP_fast_assign( |
| 662 | + __assign_str(memdev, dev_name(&cxlmd->dev)); |
| 663 | + __assign_str(host, dev_name(cxlmd->dev.parent)); |
| 664 | + __entry->serial = cxlmd->cxlds->serial; |
| 665 | + __entry->overflow_ts = cxl_poison_overflow(flags, overflow_ts); |
| 666 | + __entry->dpa = cxl_poison_record_dpa(record); |
| 667 | + __entry->dpa_length = cxl_poison_record_dpa_length(record); |
| 668 | + __entry->source = cxl_poison_record_source(record); |
| 669 | + __entry->trace_type = trace_type; |
| 670 | + __entry->flags = flags; |
| 671 | + if (region) { |
| 672 | + __assign_str(region, dev_name(®ion->dev)); |
| 673 | + memcpy(__entry->uuid, ®ion->params.uuid, 16); |
| 674 | + } else { |
| 675 | + __assign_str(region, ""); |
| 676 | + memset(__entry->uuid, 0, 16); |
| 677 | + } |
| 678 | + ), |
| 679 | + |
| 680 | + TP_printk("memdev=%s host=%s serial=%lld trace_type=%s region=%s " \ |
| 681 | + "region_uuid=%pU dpa=0x%llx dpa_length=0x%x source=%s " \ |
| 682 | + "flags=%s overflow_time=%llu", |
| 683 | + __get_str(memdev), |
| 684 | + __get_str(host), |
| 685 | + __entry->serial, |
| 686 | + show_poison_trace_type(__entry->trace_type), |
| 687 | + __get_str(region), |
| 688 | + __entry->uuid, |
| 689 | + __entry->dpa, |
| 690 | + __entry->dpa_length, |
| 691 | + show_poison_source(__entry->source), |
| 692 | + show_poison_flags(__entry->flags), |
| 693 | + __entry->overflow_ts |
| 694 | + ) |
| 695 | +); |
| 696 | + |
603 | 697 | #endif /* _CXL_EVENTS_H */ |
604 | 698 |
|
605 | 699 | #define TRACE_INCLUDE_FILE trace |
|
0 commit comments