1*39915b6bSGuangbin Huang====================================== 2*39915b6bSGuangbin HuangHNS3 Performance Monitoring Unit (PMU) 3*39915b6bSGuangbin Huang====================================== 4*39915b6bSGuangbin Huang 5*39915b6bSGuangbin HuangHNS3(HiSilicon network system 3) Performance Monitoring Unit (PMU) is an 6*39915b6bSGuangbin HuangEnd Point device to collect performance statistics of HiSilicon SoC NIC. 7*39915b6bSGuangbin HuangOn Hip09, each SICL(Super I/O cluster) has one PMU device. 8*39915b6bSGuangbin Huang 9*39915b6bSGuangbin HuangHNS3 PMU supports collection of performance statistics such as bandwidth, 10*39915b6bSGuangbin Huanglatency, packet rate and interrupt rate. 11*39915b6bSGuangbin Huang 12*39915b6bSGuangbin HuangEach HNS3 PMU supports 8 hardware events. 13*39915b6bSGuangbin Huang 14*39915b6bSGuangbin HuangHNS3 PMU driver 15*39915b6bSGuangbin Huang=============== 16*39915b6bSGuangbin Huang 17*39915b6bSGuangbin HuangThe HNS3 PMU driver registers a perf PMU with the name of its sicl id.:: 18*39915b6bSGuangbin Huang 19*39915b6bSGuangbin Huang /sys/devices/hns3_pmu_sicl_<sicl_id> 20*39915b6bSGuangbin Huang 21*39915b6bSGuangbin HuangPMU driver provides description of available events, filter modes, format, 22*39915b6bSGuangbin Huangidentifier and cpumask in sysfs. 23*39915b6bSGuangbin Huang 24*39915b6bSGuangbin HuangThe "events" directory describes the event code of all supported events 25*39915b6bSGuangbin Huangshown in perf list. 26*39915b6bSGuangbin Huang 27*39915b6bSGuangbin HuangThe "filtermode" directory describes the supported filter modes of each 28*39915b6bSGuangbin Huangevent. 29*39915b6bSGuangbin Huang 30*39915b6bSGuangbin HuangThe "format" directory describes all formats of the config (events) and 31*39915b6bSGuangbin Huangconfig1 (filter options) fields of the perf_event_attr structure. 32*39915b6bSGuangbin Huang 33*39915b6bSGuangbin HuangThe "identifier" file shows version of PMU hardware device. 34*39915b6bSGuangbin Huang 35*39915b6bSGuangbin HuangThe "bdf_min" and "bdf_max" files show the supported bdf range of each 36*39915b6bSGuangbin Huangpmu device. 37*39915b6bSGuangbin Huang 38*39915b6bSGuangbin HuangThe "hw_clk_freq" file shows the hardware clock frequency of each pmu 39*39915b6bSGuangbin Huangdevice. 40*39915b6bSGuangbin Huang 41*39915b6bSGuangbin HuangExample usage of checking event code and subevent code:: 42*39915b6bSGuangbin Huang 43*39915b6bSGuangbin Huang $# cat /sys/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_time 44*39915b6bSGuangbin Huang config=0x00204 45*39915b6bSGuangbin Huang $# cat /sys/devices/hns3_pmu_sicl_0/events/dly_tx_normal_to_mac_packet_num 46*39915b6bSGuangbin Huang config=0x10204 47*39915b6bSGuangbin Huang 48*39915b6bSGuangbin HuangEach performance statistic has a pair of events to get two values to 49*39915b6bSGuangbin Huangcalculate real performance data in userspace. 50*39915b6bSGuangbin Huang 51*39915b6bSGuangbin HuangThe bits 0~15 of config (here 0x0204) are the true hardware event code. If 52*39915b6bSGuangbin Huangtwo events have same value of bits 0~15 of config, that means they are 53*39915b6bSGuangbin Huangevent pair. And the bit 16 of config indicates getting counter 0 or 54*39915b6bSGuangbin Huangcounter 1 of hardware event. 55*39915b6bSGuangbin Huang 56*39915b6bSGuangbin HuangAfter getting two values of event pair in usersapce, the formula of 57*39915b6bSGuangbin Huangcomputation to calculate real performance data is::: 58*39915b6bSGuangbin Huang 59*39915b6bSGuangbin Huang counter 0 / counter 1 60*39915b6bSGuangbin Huang 61*39915b6bSGuangbin HuangExample usage of checking supported filter mode:: 62*39915b6bSGuangbin Huang 63*39915b6bSGuangbin Huang $# cat /sys/devices/hns3_pmu_sicl_0/filtermode/bw_ssu_rpu_byte_num 64*39915b6bSGuangbin Huang filter mode supported: global/port/port-tc/func/func-queue/ 65*39915b6bSGuangbin Huang 66*39915b6bSGuangbin HuangExample usage of perf:: 67*39915b6bSGuangbin Huang 68*39915b6bSGuangbin Huang $# perf list 69*39915b6bSGuangbin Huang hns3_pmu_sicl_0/bw_ssu_rpu_byte_num/ [kernel PMU event] 70*39915b6bSGuangbin Huang hns3_pmu_sicl_0/bw_ssu_rpu_time/ [kernel PMU event] 71*39915b6bSGuangbin Huang ------------------------------------------ 72*39915b6bSGuangbin Huang 73*39915b6bSGuangbin 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 74*39915b6bSGuangbin Huang or 75*39915b6bSGuangbin Huang $# perf stat -g -e hns3_pmu_sicl_0/config=0x00002,global=1/ -e hns3_pmu_sicl_0/config=0x10002,global=1/ -I 1000 76*39915b6bSGuangbin Huang 77*39915b6bSGuangbin Huang 78*39915b6bSGuangbin HuangFilter modes 79*39915b6bSGuangbin Huang-------------- 80*39915b6bSGuangbin Huang 81*39915b6bSGuangbin Huang1. global mode 82*39915b6bSGuangbin HuangPMU collect performance statistics for all HNS3 PCIe functions of IO DIE. 83*39915b6bSGuangbin HuangSet the "global" filter option to 1 will enable this mode. 84*39915b6bSGuangbin HuangExample usage of perf:: 85*39915b6bSGuangbin Huang 86*39915b6bSGuangbin Huang $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,global=1/ -I 1000 87*39915b6bSGuangbin Huang 88*39915b6bSGuangbin Huang2. port mode 89*39915b6bSGuangbin HuangPMU collect performance statistic of one whole physical port. The port id 90*39915b6bSGuangbin Huangis same as mac id. The "tc" filter option must be set to 0xF in this mode, 91*39915b6bSGuangbin Huanghere tc stands for traffic class. 92*39915b6bSGuangbin Huang 93*39915b6bSGuangbin HuangExample usage of perf:: 94*39915b6bSGuangbin Huang 95*39915b6bSGuangbin Huang $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0xF/ -I 1000 96*39915b6bSGuangbin Huang 97*39915b6bSGuangbin Huang3. port-tc mode 98*39915b6bSGuangbin HuangPMU collect performance statistic of one tc of physical port. The port id 99*39915b6bSGuangbin Huangis same as mac id. The "tc" filter option must be set to 0 ~ 7 in this 100*39915b6bSGuangbin Huangmode. 101*39915b6bSGuangbin HuangExample usage of perf:: 102*39915b6bSGuangbin Huang 103*39915b6bSGuangbin Huang $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,port=0,tc=0/ -I 1000 104*39915b6bSGuangbin Huang 105*39915b6bSGuangbin Huang4. func mode 106*39915b6bSGuangbin HuangPMU collect performance statistic of one PF/VF. The function id is BDF of 107*39915b6bSGuangbin HuangPF/VF, its conversion formula:: 108*39915b6bSGuangbin Huang 109*39915b6bSGuangbin Huang func = (bus << 8) + (device << 3) + (function) 110*39915b6bSGuangbin Huang 111*39915b6bSGuangbin Huangfor example: 112*39915b6bSGuangbin Huang BDF func 113*39915b6bSGuangbin Huang 35:00.0 0x3500 114*39915b6bSGuangbin Huang 35:00.1 0x3501 115*39915b6bSGuangbin Huang 35:01.0 0x3508 116*39915b6bSGuangbin Huang 117*39915b6bSGuangbin HuangIn this mode, the "queue" filter option must be set to 0xFFFF. 118*39915b6bSGuangbin HuangExample usage of perf:: 119*39915b6bSGuangbin Huang 120*39915b6bSGuangbin Huang $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0xFFFF/ -I 1000 121*39915b6bSGuangbin Huang 122*39915b6bSGuangbin Huang5. func-queue mode 123*39915b6bSGuangbin HuangPMU collect performance statistic of one queue of PF/VF. The function id 124*39915b6bSGuangbin Huangis BDF of PF/VF, the "queue" filter option must be set to the exact queue 125*39915b6bSGuangbin Huangid of function. 126*39915b6bSGuangbin HuangExample usage of perf:: 127*39915b6bSGuangbin Huang 128*39915b6bSGuangbin Huang $# perf stat -a -e hns3_pmu_sicl_0/config=0x1020F,bdf=0x3500,queue=0/ -I 1000 129*39915b6bSGuangbin Huang 130*39915b6bSGuangbin Huang6. func-intr mode 131*39915b6bSGuangbin HuangPMU collect performance statistic of one interrupt of PF/VF. The function 132*39915b6bSGuangbin Huangid is BDF of PF/VF, the "intr" filter option must be set to the exact 133*39915b6bSGuangbin Huanginterrupt id of function. 134*39915b6bSGuangbin HuangExample usage of perf:: 135*39915b6bSGuangbin Huang 136*39915b6bSGuangbin Huang $# perf stat -a -e hns3_pmu_sicl_0/config=0x00301,bdf=0x3500,intr=0/ -I 1000 137