intel/perf: add mdapi writes for register perf counters
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 28 Nov 2018 15:10:09 +0000 (15:10 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 23 Oct 2019 05:41:15 +0000 (05:41 +0000)
Those are not part of the OA reports.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/intel/perf/gen_perf_mdapi.h

index 9747198be956ef8bd4d390872793fe1fd679bd2b..c0e8d811c1df1c40abc30ad9f6c81170d0af5008 100644 (file)
@@ -134,6 +134,42 @@ int gen_perf_query_result_write_mdapi(void *data, uint32_t data_size,
                                       const struct gen_perf_query_result *result,
                                       uint64_t freq_start, uint64_t freq_end);
 
+static inline void gen_perf_query_mdapi_write_perfcntr(void *data, uint32_t data_size,
+                                                       const struct gen_device_info *devinfo,
+                                                       const uint64_t *begin_perf_cntrs,
+                                                       const uint64_t *end_perf_cntrs)
+{
+   /* Only bits 0:43 of the 64bit registers contains the value. */
+   const uint64_t mask = (1ull << 44) - 1;
+
+   switch (devinfo->gen) {
+   case 8: {
+      if (data_size < sizeof(struct gen8_mdapi_metrics))
+         return;
+      struct gen8_mdapi_metrics *mdapi_data = data;
+      mdapi_data->PerfCounter1 =
+         (end_perf_cntrs[0] & mask) - (begin_perf_cntrs[0] & mask);
+      mdapi_data->PerfCounter2 =
+         (end_perf_cntrs[1] & mask) - (begin_perf_cntrs[1] & mask);
+      break;
+   }
+   case 9:
+   case 10:
+   case 11: {
+      if (data_size < sizeof(struct gen9_mdapi_metrics))
+         return;
+      struct gen9_mdapi_metrics *mdapi_data = data;
+      mdapi_data->PerfCounter1 =
+         (end_perf_cntrs[0] & mask) - (begin_perf_cntrs[0] & mask);
+      mdapi_data->PerfCounter2 =
+         (end_perf_cntrs[1] & mask) - (begin_perf_cntrs[1] & mask);
+      break;
+   }
+   default:
+      break;
+   }
+}
+
 static inline void gen_perf_query_mdapi_write_marker(void *data, uint32_t data_size,
                                                      const struct gen_device_info *devinfo,
                                                      uint64_t value)