Skip to content

Commit 17d5739

Browse files
Yicong Yangwilldeacon
authored andcommitted
drivers/perf: hisi: Add TLP filter support
The PMU support to filter the TLP when counting the bandwidth with below options: - only count the TLP headers - only count the TLP payloads - count both TLP headers and payloads In the current driver it's default to count the TLP payloads only, which will have an implicity side effects that on the traffic only have header only TLPs, we'll get no data. Make this user configuration through "len_mode" parameter and make it default to count both TLP headers and payloads when user not specified. Also update the documentation for it. Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Yicong Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent c8dff67 commit 17d5739

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Documentation/admin-guide/perf/hisi-pcie-pmu.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,21 @@ Filter options
110110
Example usage of perf::
111111

112112
$# perf stat -e hisi_pcie0_core0/rx_mrd_flux,thr_len=0x4,thr_mode=1/ sleep 5
113+
114+
4. 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

drivers/perf/hisilicon/hisi_pcie_pmu.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@
4747
#define HISI_PCIE_EVENT_M GENMASK_ULL(15, 0)
4848
#define HISI_PCIE_THR_MODE_M GENMASK_ULL(27, 27)
4949
#define HISI_PCIE_THR_M GENMASK_ULL(31, 28)
50+
#define HISI_PCIE_LEN_M GENMASK_ULL(35, 34)
5051
#define HISI_PCIE_TARGET_M GENMASK_ULL(52, 36)
5152
#define HISI_PCIE_TRIG_MODE_M GENMASK_ULL(53, 53)
5253
#define HISI_PCIE_TRIG_M GENMASK_ULL(59, 56)
5354

55+
/* Default config of TLP length mode, will count both TLP headers and payloads */
56+
#define HISI_PCIE_LEN_M_DEFAULT 3ULL
57+
5458
#define HISI_PCIE_MAX_COUNTERS 8
5559
#define HISI_PCIE_REG_STEP 8
5660
#define HISI_PCIE_THR_MAX_VAL 10
@@ -91,6 +95,7 @@ HISI_PCIE_PMU_FILTER_ATTR(thr_len, config1, 3, 0);
9195
HISI_PCIE_PMU_FILTER_ATTR(thr_mode, config1, 4, 4);
9296
HISI_PCIE_PMU_FILTER_ATTR(trig_len, config1, 8, 5);
9397
HISI_PCIE_PMU_FILTER_ATTR(trig_mode, config1, 9, 9);
98+
HISI_PCIE_PMU_FILTER_ATTR(len_mode, config1, 11, 10);
9499
HISI_PCIE_PMU_FILTER_ATTR(port, config2, 15, 0);
95100
HISI_PCIE_PMU_FILTER_ATTR(bdf, config2, 31, 16);
96101

@@ -215,8 +220,8 @@ static void hisi_pcie_pmu_config_filter(struct perf_event *event)
215220
{
216221
struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
217222
struct hw_perf_event *hwc = &event->hw;
223+
u64 port, trig_len, thr_len, len_mode;
218224
u64 reg = HISI_PCIE_INIT_SET;
219-
u64 port, trig_len, thr_len;
220225

221226
/* Config HISI_PCIE_EVENT_CTRL according to event. */
222227
reg |= FIELD_PREP(HISI_PCIE_EVENT_M, hisi_pcie_get_real_event(event));
@@ -245,6 +250,12 @@ static void hisi_pcie_pmu_config_filter(struct perf_event *event)
245250
reg |= HISI_PCIE_THR_EN;
246251
}
247252

253+
len_mode = hisi_pcie_get_len_mode(event);
254+
if (len_mode)
255+
reg |= FIELD_PREP(HISI_PCIE_LEN_M, len_mode);
256+
else
257+
reg |= FIELD_PREP(HISI_PCIE_LEN_M, HISI_PCIE_LEN_M_DEFAULT);
258+
248259
hisi_pcie_pmu_writeq(pcie_pmu, HISI_PCIE_EVENT_CTRL, hwc->idx, reg);
249260
}
250261

@@ -711,6 +722,7 @@ static struct attribute *hisi_pcie_pmu_format_attr[] = {
711722
HISI_PCIE_PMU_FORMAT_ATTR(thr_mode, "config1:4"),
712723
HISI_PCIE_PMU_FORMAT_ATTR(trig_len, "config1:5-8"),
713724
HISI_PCIE_PMU_FORMAT_ATTR(trig_mode, "config1:9"),
725+
HISI_PCIE_PMU_FORMAT_ATTR(len_mode, "config1:10-11"),
714726
HISI_PCIE_PMU_FORMAT_ATTR(port, "config2:0-15"),
715727
HISI_PCIE_PMU_FORMAT_ATTR(bdf, "config2:16-31"),
716728
NULL

0 commit comments

Comments
 (0)