hisi-pcie-pmu.rst 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ================================================
  2. HiSilicon PCIe Performance Monitoring Unit (PMU)
  3. ================================================
  4. On Hip09, HiSilicon PCIe Performance Monitoring Unit (PMU) could monitor
  5. bandwidth, latency, bus utilization and buffer occupancy data of PCIe.
  6. Each PCIe Core has a PMU to monitor multi Root Ports of this PCIe Core and
  7. all Endpoints downstream these Root Ports.
  8. HiSilicon PCIe PMU driver
  9. =========================
  10. The PCIe PMU driver registers a perf PMU with the name of its sicl-id and PCIe
  11. Core id.::
  12. /sys/bus/event_source/hisi_pcie<sicl>_core<core>
  13. PMU driver provides description of available events and filter options in sysfs,
  14. see /sys/bus/event_source/devices/hisi_pcie<sicl>_core<core>.
  15. The "format" directory describes all formats of the config (events) and config1
  16. (filter options) fields of the perf_event_attr structure. The "events" directory
  17. describes all documented events shown in perf list.
  18. The "identifier" sysfs file allows users to identify the version of the
  19. PMU hardware device.
  20. The "bus" sysfs file allows users to get the bus number of Root Ports
  21. monitored by PMU. Furthermore users can get the Root Ports range in
  22. [bdf_min, bdf_max] from "bdf_min" and "bdf_max" sysfs attributes
  23. respectively.
  24. Example usage of perf::
  25. $# perf list
  26. hisi_pcie0_core0/rx_mwr_latency/ [kernel PMU event]
  27. hisi_pcie0_core0/rx_mwr_cnt/ [kernel PMU event]
  28. ------------------------------------------
  29. $# perf stat -e hisi_pcie0_core0/rx_mwr_latency,port=0xffff/
  30. $# perf stat -e hisi_pcie0_core0/rx_mwr_cnt,port=0xffff/
  31. The related events usually used to calculate the bandwidth, latency or others.
  32. They need to start and end counting at the same time, therefore related events
  33. are best used in the same event group to get the expected value. There are two
  34. ways to know if they are related events:
  35. a) By event name, such as the latency events "xxx_latency, xxx_cnt" or
  36. bandwidth events "xxx_flux, xxx_time".
  37. b) By event type, such as "event=0xXXXX, event=0x1XXXX".
  38. Example usage of perf group::
  39. $# perf stat -e "{hisi_pcie0_core0/rx_mwr_latency,port=0xffff/,hisi_pcie0_core0/rx_mwr_cnt,port=0xffff/}"
  40. The current driver does not support sampling. So "perf record" is unsupported.
  41. Also attach to a task is unsupported for PCIe PMU.
  42. Filter options
  43. --------------
  44. 1. Target filter
  45. PMU could only monitor the performance of traffic downstream target Root
  46. Ports or downstream target Endpoint. PCIe PMU driver support "port" and
  47. "bdf" interfaces for users.
  48. Please notice that, one of these two interfaces must be set, and these two
  49. interfaces aren't supported at the same time. If they are both set, only
  50. "port" filter is valid.
  51. If "port" filter not being set or is set explicitly to zero (default), the
  52. "bdf" filter will be in effect, because "bdf=0" meaning 0000:000:00.0.
  53. - port
  54. "port" filter can be used in all PCIe PMU events, target Root Port can be
  55. selected by configuring the 16-bits-bitmap "port". Multi ports can be
  56. selected for AP-layer-events, and only one port can be selected for
  57. TL/DL-layer-events.
  58. For example, if target Root Port is 0000:00:00.0 (x8 lanes), bit0 of
  59. bitmap should be set, port=0x1; if target Root Port is 0000:00:04.0 (x4
  60. lanes), bit8 is set, port=0x100; if these two Root Ports are both
  61. monitored, port=0x101.
  62. Example usage of perf::
  63. $# perf stat -e hisi_pcie0_core0/rx_mwr_latency,port=0x1/ sleep 5
  64. - bdf
  65. "bdf" filter can only be used in bandwidth events, target Endpoint is
  66. selected by configuring BDF to "bdf". Counter only counts the bandwidth of
  67. message requested by target Endpoint.
  68. For example, "bdf=0x3900" means BDF of target Endpoint is 0000:39:00.0.
  69. Example usage of perf::
  70. $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,bdf=0x3900/ sleep 5
  71. 2. Trigger filter
  72. Event statistics start when the first time TLP length is greater/smaller
  73. than trigger condition. You can set the trigger condition by writing
  74. "trig_len", and set the trigger mode by writing "trig_mode". This filter can
  75. only be used in bandwidth events.
  76. For example, "trig_len=4" means trigger condition is 2^4 DW, "trig_mode=0"
  77. means statistics start when TLP length > trigger condition, "trig_mode=1"
  78. means start when TLP length < condition.
  79. Example usage of perf::
  80. $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,port=0xffff,trig_len=0x4,trig_mode=1/ sleep 5
  81. 3. Threshold filter
  82. Counter counts when TLP length within the specified range. You can set the
  83. threshold by writing "thr_len", and set the threshold mode by writing
  84. "thr_mode". This filter can only be used in bandwidth events.
  85. For example, "thr_len=4" means threshold is 2^4 DW, "thr_mode=0" means
  86. counter counts when TLP length >= threshold, and "thr_mode=1" means counts
  87. when TLP length < threshold.
  88. Example usage of perf::
  89. $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,port=0xffff,thr_len=0x4,thr_mode=1/ sleep 5
  90. 4. TLP Length filter
  91. When counting bandwidth, the data can be composed of certain parts of TLP
  92. packets. You can specify it through "len_mode":
  93. - 2'b00: Reserved (Do not use this since the behaviour is undefined)
  94. - 2'b01: Bandwidth of TLP payloads
  95. - 2'b10: Bandwidth of TLP headers
  96. - 2'b11: Bandwidth of both TLP payloads and headers
  97. For example, "len_mode=2" means only counting the bandwidth of TLP headers
  98. and "len_mode=3" means the final bandwidth data is composed of both TLP
  99. headers and payloads. Default value if not specified is 2'b11.
  100. Example usage of perf::
  101. $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,port=0xffff,len_mode=0x1/ sleep 5