xref: /openbmc/linux/Documentation/admin-guide/perf/hns3-pmu.rst (revision dbeb56fe80e5574388ed9767788e8eb493589443)
139915b6bSGuangbin Huang======================================
239915b6bSGuangbin HuangHNS3 Performance Monitoring Unit (PMU)
339915b6bSGuangbin Huang======================================
439915b6bSGuangbin Huang
539915b6bSGuangbin HuangHNS3(HiSilicon network system 3) Performance Monitoring Unit (PMU) is an
639915b6bSGuangbin HuangEnd Point device to collect performance statistics of HiSilicon SoC NIC.
739915b6bSGuangbin HuangOn Hip09, each SICL(Super I/O cluster) has one PMU device.
839915b6bSGuangbin Huang
939915b6bSGuangbin HuangHNS3 PMU supports collection of performance statistics such as bandwidth,
1039915b6bSGuangbin Huanglatency, packet rate and interrupt rate.
1139915b6bSGuangbin Huang
1239915b6bSGuangbin HuangEach HNS3 PMU supports 8 hardware events.
1339915b6bSGuangbin Huang
1439915b6bSGuangbin HuangHNS3 PMU driver
1539915b6bSGuangbin Huang===============
1639915b6bSGuangbin Huang
1739915b6bSGuangbin HuangThe HNS3 PMU driver registers a perf PMU with the name of its sicl id.::
1839915b6bSGuangbin Huang
1939915b6bSGuangbin Huang  /sys/devices/hns3_pmu_sicl_<sicl_id>
2039915b6bSGuangbin Huang
2139915b6bSGuangbin HuangPMU driver provides description of available events, filter modes, format,
2239915b6bSGuangbin Huangidentifier and cpumask in sysfs.
2339915b6bSGuangbin Huang
2439915b6bSGuangbin HuangThe "events" directory describes the event code of all supported events
2539915b6bSGuangbin Huangshown in perf list.
2639915b6bSGuangbin Huang
2739915b6bSGuangbin HuangThe "filtermode" directory describes the supported filter modes of each
2839915b6bSGuangbin Huangevent.
2939915b6bSGuangbin Huang
3039915b6bSGuangbin HuangThe "format" directory describes all formats of the config (events) and
3139915b6bSGuangbin Huangconfig1 (filter options) fields of the perf_event_attr structure.
3239915b6bSGuangbin Huang
3339915b6bSGuangbin HuangThe "identifier" file shows version of PMU hardware device.
3439915b6bSGuangbin Huang
3539915b6bSGuangbin HuangThe "bdf_min" and "bdf_max" files show the supported bdf range of each
3639915b6bSGuangbin Huangpmu device.
3739915b6bSGuangbin Huang
3839915b6bSGuangbin HuangThe "hw_clk_freq" file shows the hardware clock frequency of each pmu
3939915b6bSGuangbin Huangdevice.
4039915b6bSGuangbin Huang
4139915b6bSGuangbin HuangExample usage of checking event code and subevent code::
4239915b6bSGuangbin Huang
4339915b6bSGuangbin Huang  $# cat /sys/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_time
4439915b6bSGuangbin Huang  config=0x00204
4539915b6bSGuangbin Huang  $# cat /sys/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_packet_num
4639915b6bSGuangbin Huang  config=0x10204
4739915b6bSGuangbin Huang
4839915b6bSGuangbin HuangEach performance statistic has a pair of events to get two values to
4939915b6bSGuangbin Huangcalculate real performance data in userspace.
5039915b6bSGuangbin Huang
5139915b6bSGuangbin HuangThe bits 0~15 of config (here 0x0204) are the true hardware event code. If
5239915b6bSGuangbin Huangtwo events have same value of bits 0~15 of config, that means they are
5339915b6bSGuangbin Huangevent pair. And the bit 16 of config indicates getting counter 0 or
5439915b6bSGuangbin Huangcounter 1 of hardware event.
5539915b6bSGuangbin Huang
56*dbeb56feSRandy DunlapAfter getting two values of event pair in userspace, the formula of
5739915b6bSGuangbin Huangcomputation to calculate real performance data is:::
5839915b6bSGuangbin Huang
5939915b6bSGuangbin Huang  counter 0 / counter 1
6039915b6bSGuangbin Huang
6139915b6bSGuangbin HuangExample usage of checking supported filter mode::
6239915b6bSGuangbin Huang
6339915b6bSGuangbin Huang  $# cat /sys/devices/hns3_pmu_sicl_0/filtermode/bw_ssu_rpu_byte_num
6439915b6bSGuangbin Huang  filter mode supported: global/port/port-tc/func/func-queue/
6539915b6bSGuangbin Huang
6639915b6bSGuangbin HuangExample usage of perf::
6739915b6bSGuangbin Huang
6839915b6bSGuangbin Huang  $# perf list
6939915b6bSGuangbin Huang  hns3_pmu_sicl_0/bw_ssu_rpu_byte_num/ [kernel PMU event]
7039915b6bSGuangbin Huang  hns3_pmu_sicl_0/bw_ssu_rpu_time/     [kernel PMU event]
7139915b6bSGuangbin Huang  ------------------------------------------
7239915b6bSGuangbin Huang
7339915b6bSGuangbin Huang  $# perf stat -g -e hns3_pmu_sicl_0/bw_ssu_rpu_byte_num,global=1/ -e hns3_pmu_sicl_0/bw_ssu_rpu_time,global=1/ -I 1000
7439915b6bSGuangbin Huang  or
7539915b6bSGuangbin Huang  $# perf stat -g -e hns3_pmu_sicl_0/config=0x00002,global=1/ -e hns3_pmu_sicl_0/config=0x10002,global=1/ -I 1000
7639915b6bSGuangbin Huang
7739915b6bSGuangbin Huang
7839915b6bSGuangbin HuangFilter modes
7939915b6bSGuangbin Huang--------------
8039915b6bSGuangbin Huang
8139915b6bSGuangbin Huang1. global mode
8239915b6bSGuangbin HuangPMU collect performance statistics for all HNS3 PCIe functions of IO DIE.
8339915b6bSGuangbin HuangSet the "global" filter option to 1 will enable this mode.
8439915b6bSGuangbin HuangExample usage of perf::
8539915b6bSGuangbin Huang
8639915b6bSGuangbin Huang  $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,global=1/ -I 1000
8739915b6bSGuangbin Huang
8839915b6bSGuangbin Huang2. port mode
8939915b6bSGuangbin HuangPMU collect performance statistic of one whole physical port. The port id
9039915b6bSGuangbin Huangis same as mac id. The "tc" filter option must be set to 0xF in this mode,
9139915b6bSGuangbin Huanghere tc stands for traffic class.
9239915b6bSGuangbin Huang
9339915b6bSGuangbin HuangExample usage of perf::
9439915b6bSGuangbin Huang
9539915b6bSGuangbin Huang  $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0xF/ -I 1000
9639915b6bSGuangbin Huang
9739915b6bSGuangbin Huang3. port-tc mode
9839915b6bSGuangbin HuangPMU collect performance statistic of one tc of physical port. The port id
9939915b6bSGuangbin Huangis same as mac id. The "tc" filter option must be set to 0 ~ 7 in this
10039915b6bSGuangbin Huangmode.
10139915b6bSGuangbin HuangExample usage of perf::
10239915b6bSGuangbin Huang
10339915b6bSGuangbin Huang  $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0/ -I 1000
10439915b6bSGuangbin Huang
10539915b6bSGuangbin Huang4. func mode
10639915b6bSGuangbin HuangPMU collect performance statistic of one PF/VF. The function id is BDF of
10739915b6bSGuangbin HuangPF/VF, its conversion formula::
10839915b6bSGuangbin Huang
10939915b6bSGuangbin Huang  func = (bus << 8) + (device << 3) + (function)
11039915b6bSGuangbin Huang
11139915b6bSGuangbin Huangfor example:
11239915b6bSGuangbin Huang  BDF         func
11339915b6bSGuangbin Huang  35:00.0    0x3500
11439915b6bSGuangbin Huang  35:00.1    0x3501
11539915b6bSGuangbin Huang  35:01.0    0x3508
11639915b6bSGuangbin Huang
11739915b6bSGuangbin HuangIn this mode, the "queue" filter option must be set to 0xFFFF.
11839915b6bSGuangbin HuangExample usage of perf::
11939915b6bSGuangbin Huang
12039915b6bSGuangbin Huang  $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0xFFFF/ -I 1000
12139915b6bSGuangbin Huang
12239915b6bSGuangbin Huang5. func-queue mode
12339915b6bSGuangbin HuangPMU collect performance statistic of one queue of PF/VF. The function id
12439915b6bSGuangbin Huangis BDF of PF/VF, the "queue" filter option must be set to the exact queue
12539915b6bSGuangbin Huangid of function.
12639915b6bSGuangbin HuangExample usage of perf::
12739915b6bSGuangbin Huang
12839915b6bSGuangbin Huang  $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0/ -I 1000
12939915b6bSGuangbin Huang
13039915b6bSGuangbin Huang6. func-intr mode
13139915b6bSGuangbin HuangPMU collect performance statistic of one interrupt of PF/VF. The function
13239915b6bSGuangbin Huangid is BDF of PF/VF, the "intr" filter option must be set to the exact
13339915b6bSGuangbin Huanginterrupt id of function.
13439915b6bSGuangbin HuangExample usage of perf::
13539915b6bSGuangbin Huang
13639915b6bSGuangbin Huang  $# perf stat -a -e hns3_pmu_sicl_0/config=0x00301,bdf=0x3500,intr=0/ -I 1000
137