xref: /linux/Documentation/admin-guide/perf/hisi-pcie-pmu.rst (revision fd7d598270724cc787982ea48bbe17ad383a8b7f)
1================================================
2HiSilicon PCIe Performance Monitoring Unit (PMU)
3================================================
4
5On Hip09, HiSilicon PCIe Performance Monitoring Unit (PMU) could monitor
6bandwidth, latency, bus utilization and buffer occupancy data of PCIe.
7
8Each PCIe Core has a PMU to monitor multi Root Ports of this PCIe Core and
9all Endpoints downstream these Root Ports.
10
11
12HiSilicon PCIe PMU driver
13=========================
14
15The PCIe PMU driver registers a perf PMU with the name of its sicl-id and PCIe
16Core id.::
17
18  /sys/bus/event_source/hisi_pcie<sicl>_core<core>
19
20PMU driver provides description of available events and filter options in sysfs,
21see /sys/bus/event_source/devices/hisi_pcie<sicl>_core<core>.
22
23The "format" directory describes all formats of the config (events) and config1
24(filter options) fields of the perf_event_attr structure. The "events" directory
25describes all documented events shown in perf list.
26
27The "identifier" sysfs file allows users to identify the version of the
28PMU hardware device.
29
30The "bus" sysfs file allows users to get the bus number of Root Ports
31monitored by PMU.
32
33Example usage of perf::
34
35  $# perf list
36  hisi_pcie0_core0/rx_mwr_latency/ [kernel PMU event]
37  hisi_pcie0_core0/rx_mwr_cnt/ [kernel PMU event]
38  ------------------------------------------
39
40  $# perf stat -e hisi_pcie0_core0/rx_mwr_latency/
41  $# perf stat -e hisi_pcie0_core0/rx_mwr_cnt/
42  $# perf stat -g -e hisi_pcie0_core0/rx_mwr_latency/ -e hisi_pcie0_core0/rx_mwr_cnt/
43
44The current driver does not support sampling. So "perf record" is unsupported.
45Also attach to a task is unsupported for PCIe PMU.
46
47Filter options
48--------------
49
501. Target filter
51
52   PMU could only monitor the performance of traffic downstream target Root
53   Ports or downstream target Endpoint. PCIe PMU driver support "port" and
54   "bdf" interfaces for users, and these two interfaces aren't supported at the
55   same time.
56
57   - port
58
59     "port" filter can be used in all PCIe PMU events, target Root Port can be
60     selected by configuring the 16-bits-bitmap "port". Multi ports can be
61     selected for AP-layer-events, and only one port can be selected for
62     TL/DL-layer-events.
63
64     For example, if target Root Port is 0000:00:00.0 (x8 lanes), bit0 of
65     bitmap should be set, port=0x1; if target Root Port is 0000:00:04.0 (x4
66     lanes), bit8 is set, port=0x100; if these two Root Ports are both
67     monitored, port=0x101.
68
69     Example usage of perf::
70
71       $# perf stat -e hisi_pcie0_core0/rx_mwr_latency,port=0x1/ sleep 5
72
73   - bdf
74
75     "bdf" filter can only be used in bandwidth events, target Endpoint is
76     selected by configuring BDF to "bdf". Counter only counts the bandwidth of
77     message requested by target Endpoint.
78
79     For example, "bdf=0x3900" means BDF of target Endpoint is 0000:39:00.0.
80
81     Example usage of perf::
82
83       $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,bdf=0x3900/ sleep 5
84
852. Trigger filter
86
87   Event statistics start when the first time TLP length is greater/smaller
88   than trigger condition. You can set the trigger condition by writing
89   "trig_len", and set the trigger mode by writing "trig_mode". This filter can
90   only be used in bandwidth events.
91
92   For example, "trig_len=4" means trigger condition is 2^4 DW, "trig_mode=0"
93   means statistics start when TLP length > trigger condition, "trig_mode=1"
94   means start when TLP length < condition.
95
96   Example usage of perf::
97
98     $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,trig_len=0x4,trig_mode=1/ sleep 5
99
1003. Threshold filter
101
102   Counter counts when TLP length within the specified range. You can set the
103   threshold by writing "thr_len", and set the threshold mode by writing
104   "thr_mode". This filter can only be used in bandwidth events.
105
106   For example, "thr_len=4" means threshold is 2^4 DW, "thr_mode=0" means
107   counter counts when TLP length >= threshold, and "thr_mode=1" means counts
108   when TLP length < threshold.
109
110   Example usage of perf::
111
112     $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,thr_len=0x4,thr_mode=1/ sleep 5
113
1144. TLP Length filter
115
116   When counting bandwidth, the data can be composed of certain parts of TLP
117   packets. You can specify it through "len_mode":
118
119   - 2'b00: Reserved (Do not use this since the behaviour is undefined)
120   - 2'b01: Bandwidth of TLP payloads
121   - 2'b10: Bandwidth of TLP headers
122   - 2'b11: Bandwidth of both TLP payloads and headers
123
124   For example, "len_mode=2" means only counting the bandwidth of TLP headers
125   and "len_mode=3" means the final bandwidth data is composed of both TLP
126   headers and payloads. Default value if not specified is 2'b11.
127
128   Example usage of perf::
129
130     $# perf stat -e hisi_pcie0_core0/rx_mrd_flux,len_mode=0x1/ sleep 5
131