1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM pci 4 5 #if !defined(_TRACE_HW_EVENT_PCI_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_HW_EVENT_PCI_H 7 8 #include <linux/tracepoint.h> 9 10 #define PCI_HOTPLUG_EVENT \ 11 EM(PCI_HOTPLUG_LINK_UP, "LINK_UP") \ 12 EM(PCI_HOTPLUG_LINK_DOWN, "LINK_DOWN") \ 13 EM(PCI_HOTPLUG_CARD_PRESENT, "CARD_PRESENT") \ 14 EMe(PCI_HOTPLUG_CARD_NOT_PRESENT, "CARD_NOT_PRESENT") 15 16 /* Enums require being exported to userspace, for user tool parsing */ 17 #undef EM 18 #undef EMe 19 #define EM(a, b) TRACE_DEFINE_ENUM(a); 20 #define EMe(a, b) TRACE_DEFINE_ENUM(a); 21 22 PCI_HOTPLUG_EVENT 23 24 /* 25 * Now redefine the EM() and EMe() macros to map the enums to the strings 26 * that will be printed in the output. 27 */ 28 #undef EM 29 #undef EMe 30 #define EM(a, b) {a, b}, 31 #define EMe(a, b) {a, b} 32 33 /* 34 * Note: For generic PCI hotplug events, we pass already-resolved strings 35 * (port_name, slot) instead of driver-specific structures like 'struct 36 * controller'. This is because different PCI hotplug drivers (pciehp, cpqphp, 37 * ibmphp, shpchp) define their own versions of 'struct controller' with 38 * different fields and helper functions. Using driver-specific structures would 39 * make the tracepoint interface non-generic and cause compatibility issues 40 * across different drivers. 41 */ 42 TRACE_EVENT(pci_hp_event, 43 44 TP_PROTO(const char *port_name, 45 const char *slot, 46 const int event), 47 48 TP_ARGS(port_name, slot, event), 49 50 TP_STRUCT__entry( 51 __string( port_name, port_name ) 52 __string( slot, slot ) 53 __field( int, event ) 54 ), 55 56 TP_fast_assign( 57 __assign_str(port_name); 58 __assign_str(slot); 59 __entry->event = event; 60 ), 61 62 TP_printk("%s slot:%s, event:%s\n", 63 __get_str(port_name), 64 __get_str(slot), 65 __print_symbolic(__entry->event, PCI_HOTPLUG_EVENT) 66 ) 67 ); 68 69 #endif /* _TRACE_HW_EVENT_PCI_H */ 70 71 /* This part must be outside protection */ 72 #include <trace/define_trace.h> 73