pci.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM pci
  4. #if !defined(_TRACE_HW_EVENT_PCI_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_HW_EVENT_PCI_H
  6. #include <uapi/linux/pci_regs.h>
  7. #include <linux/tracepoint.h>
  8. #define PCI_HOTPLUG_EVENT \
  9. EM(PCI_HOTPLUG_LINK_UP, "LINK_UP") \
  10. EM(PCI_HOTPLUG_LINK_DOWN, "LINK_DOWN") \
  11. EM(PCI_HOTPLUG_CARD_PRESENT, "CARD_PRESENT") \
  12. EMe(PCI_HOTPLUG_CARD_NOT_PRESENT, "CARD_NOT_PRESENT")
  13. /* Enums require being exported to userspace, for user tool parsing */
  14. #undef EM
  15. #undef EMe
  16. #define EM(a, b) TRACE_DEFINE_ENUM(a);
  17. #define EMe(a, b) TRACE_DEFINE_ENUM(a);
  18. PCI_HOTPLUG_EVENT
  19. /*
  20. * Now redefine the EM() and EMe() macros to map the enums to the strings
  21. * that will be printed in the output.
  22. */
  23. #undef EM
  24. #undef EMe
  25. #define EM(a, b) {a, b},
  26. #define EMe(a, b) {a, b}
  27. /*
  28. * Note: For generic PCI hotplug events, we pass already-resolved strings
  29. * (port_name, slot) instead of driver-specific structures like 'struct
  30. * controller'. This is because different PCI hotplug drivers (pciehp, cpqphp,
  31. * ibmphp, shpchp) define their own versions of 'struct controller' with
  32. * different fields and helper functions. Using driver-specific structures would
  33. * make the tracepoint interface non-generic and cause compatibility issues
  34. * across different drivers.
  35. */
  36. TRACE_EVENT(pci_hp_event,
  37. TP_PROTO(const char *port_name,
  38. const char *slot,
  39. const int event),
  40. TP_ARGS(port_name, slot, event),
  41. TP_STRUCT__entry(
  42. __string( port_name, port_name )
  43. __string( slot, slot )
  44. __field( int, event )
  45. ),
  46. TP_fast_assign(
  47. __assign_str(port_name);
  48. __assign_str(slot);
  49. __entry->event = event;
  50. ),
  51. TP_printk("%s slot:%s, event:%s\n",
  52. __get_str(port_name),
  53. __get_str(slot),
  54. __print_symbolic(__entry->event, PCI_HOTPLUG_EVENT)
  55. )
  56. );
  57. #define PCI_EXP_LNKSTA_LINK_STATUS_MASK (PCI_EXP_LNKSTA_LBMS | \
  58. PCI_EXP_LNKSTA_LABS | \
  59. PCI_EXP_LNKSTA_LT | \
  60. PCI_EXP_LNKSTA_DLLLA)
  61. #define LNKSTA_FLAGS \
  62. { PCI_EXP_LNKSTA_LT, "LT"}, \
  63. { PCI_EXP_LNKSTA_DLLLA, "DLLLA"}, \
  64. { PCI_EXP_LNKSTA_LBMS, "LBMS"}, \
  65. { PCI_EXP_LNKSTA_LABS, "LABS"}
  66. TRACE_EVENT(pcie_link_event,
  67. TP_PROTO(struct pci_bus *bus,
  68. unsigned int reason,
  69. unsigned int width,
  70. unsigned int status
  71. ),
  72. TP_ARGS(bus, reason, width, status),
  73. TP_STRUCT__entry(
  74. __string( port_name, pci_name(bus->self))
  75. __field( unsigned int, type )
  76. __field( unsigned int, reason )
  77. __field( unsigned int, cur_bus_speed )
  78. __field( unsigned int, max_bus_speed )
  79. __field( unsigned int, width )
  80. __field( unsigned int, flit_mode )
  81. __field( unsigned int, link_status )
  82. ),
  83. TP_fast_assign(
  84. __assign_str(port_name);
  85. __entry->type = pci_pcie_type(bus->self);
  86. __entry->reason = reason;
  87. __entry->cur_bus_speed = bus->cur_bus_speed;
  88. __entry->max_bus_speed = bus->max_bus_speed;
  89. __entry->width = width;
  90. __entry->flit_mode = bus->flit_mode;
  91. __entry->link_status = status;
  92. ),
  93. TP_printk("%s type:%d, reason:%d, cur_bus_speed:%d, max_bus_speed:%d, width:%u, flit_mode:%u, status:%s\n",
  94. __get_str(port_name),
  95. __entry->type,
  96. __entry->reason,
  97. __entry->cur_bus_speed,
  98. __entry->max_bus_speed,
  99. __entry->width,
  100. __entry->flit_mode,
  101. __print_flags((unsigned long)__entry->link_status, "|",
  102. LNKSTA_FLAGS)
  103. )
  104. );
  105. #endif /* _TRACE_HW_EVENT_PCI_H */
  106. /* This part must be outside protection */
  107. #include <trace/define_trace.h>