@@ -118,6 +118,11 @@ More functions are exposed through sysfs
118118 management information (current temperature, thresholds, threshold status,
119119 etc.).
120120
121+ Performance reporting
122+ performance counters are exposed through perf PMU APIs. Standard perf tool
123+ can be used to monitor all available perf events. Please see performance
124+ counter section below for more detailed information.
125+
121126
122127FIU - PORT
123128==========
@@ -378,6 +383,85 @@ The device nodes used for ioctl() or mmap() can be referenced through::
378383 /sys/class/fpga_region/<regionX>/<dfl-port.n>/dev
379384
380385
386+ Performance Counters
387+ ====================
388+ Performance reporting is one private feature implemented in FME. It could
389+ supports several independent, system-wide, device counter sets in hardware to
390+ monitor and count for performance events, including "basic", "cache", "fabric",
391+ "vtd" and "vtd_sip" counters. Users could use standard perf tool to monitor
392+ FPGA cache hit/miss rate, transaction number, interface clock counter of AFU
393+ and other FPGA performance events.
394+
395+ Different FPGA devices may have different counter sets, depending on hardware
396+ implementation. E.g., some discrete FPGA cards don't have any cache. User could
397+ use "perf list" to check which perf events are supported by target hardware.
398+
399+ In order to allow user to use standard perf API to access these performance
400+ counters, driver creates a perf PMU, and related sysfs interfaces in
401+ /sys/bus/event_source/devices/dfl_fme* to describe available perf events and
402+ configuration options.
403+
404+ The "format" directory describes the format of the config field of struct
405+ perf_event_attr. There are 3 bitfields for config: "evtype" defines which type
406+ the perf event belongs to; "event" is the identity of the event within its
407+ category; "portid" is introduced to decide counters set to monitor on FPGA
408+ overall data or a specific port.
409+
410+ The "events" directory describes the configuration templates for all available
411+ events which can be used with perf tool directly. For example, fab_mmio_read
412+ has the configuration "event=0x06,evtype=0x02,portid=0xff", which shows this
413+ event belongs to fabric type (0x02), the local event id is 0x06 and it is for
414+ overall monitoring (portid=0xff).
415+
416+ Example usage of perf::
417+
418+ $# perf list |grep dfl_fme
419+
420+ dfl_fme0/fab_mmio_read/ [Kernel PMU event]
421+ <...>
422+ dfl_fme0/fab_port_mmio_read,portid=?/ [Kernel PMU event]
423+ <...>
424+
425+ $# perf stat -a -e dfl_fme0/fab_mmio_read/ <command>
426+ or
427+ $# perf stat -a -e dfl_fme0/event=0x06,evtype=0x02,portid=0xff/ <command>
428+ or
429+ $# perf stat -a -e dfl_fme0/config=0xff2006/ <command>
430+
431+ Another example, fab_port_mmio_read monitors mmio read of a specific port. So
432+ its configuration template is "event=0x06,evtype=0x01,portid=?". The portid
433+ should be explicitly set.
434+
435+ Its usage of perf::
436+
437+ $# perf stat -a -e dfl_fme0/fab_port_mmio_read,portid=0x0/ <command>
438+ or
439+ $# perf stat -a -e dfl_fme0/event=0x06,evtype=0x02,portid=0x0/ <command>
440+ or
441+ $# perf stat -a -e dfl_fme0/config=0x2006/ <command>
442+
443+ Please note for fabric counters, overall perf events (fab_*) and port perf
444+ events (fab_port_*) actually share one set of counters in hardware, so it can't
445+ monitor both at the same time. If this set of counters is configured to monitor
446+ overall data, then per port perf data is not supported. See below example::
447+
448+ $# perf stat -e dfl_fme0/fab_mmio_read/,dfl_fme0/fab_port_mmio_write,\
449+ portid=0/ sleep 1
450+
451+ Performance counter stats for 'system wide':
452+
453+ 3 dfl_fme0/fab_mmio_read/
454+ <not supported> dfl_fme0/fab_port_mmio_write,portid=0x0/
455+
456+ 1.001750904 seconds time elapsed
457+
458+ The driver also provides a "cpumask" sysfs attribute, which contains only one
459+ CPU id used to access these perf events. Counting on multiple CPU is not allowed
460+ since they are system-wide counters on FPGA device.
461+
462+ The current driver does not support sampling. So "perf record" is unsupported.
463+
464+
381465Add new FIUs support
382466====================
383467It's possible that developers made some new function blocks (FIUs) under this
0 commit comments