FD.io VPP  v21.06
Vector Packet Processing
power_license.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/vnet.h>
17 #include <perfmon/perfmon.h>
18 #include <perfmon/intel/core.h>
19 
20 static u8 *
21 format_power_licensing (u8 *s, va_list *args)
22 {
23  perfmon_node_stats_t *ns = va_arg (*args, perfmon_node_stats_t *);
24  int row = va_arg (*args, int);
25 
26  switch (row)
27  {
28  case 0:
29  s = format (s, "%.2f", (ns->value[1] / (f64) ns->value[0]) * 100);
30  break;
31  case 1:
32  s = format (s, "%.2f", (ns->value[2] / (f64) ns->value[0]) * 100);
33  break;
34  case 2:
35  s = format (s, "%.2f", (ns->value[3] / (f64) ns->value[0]) * 100);
36  break;
37  case 3:
38  s = format (s, "%.2f", (ns->value[4] / (f64) ns->value[0]) * 100);
39  break;
40  }
41  return s;
42 }
43 
44 PERFMON_REGISTER_BUNDLE (power_licensing) = {
45  .name = "power-licensing",
46  .description = "Thread power licensing",
47  .source = "intel-core",
49  .events[0] = INTEL_CORE_E_CPU_CLK_UNHALTED_THREAD_P,
50  .events[1] = INTEL_CORE_E_CORE_POWER_LVL0_TURBO_LICENSE,
51  .events[2] = INTEL_CORE_E_CORE_POWER_LVL1_TURBO_LICENSE,
52  .events[3] = INTEL_CORE_E_CORE_POWER_LVL2_TURBO_LICENSE,
53  .events[4] = INTEL_CORE_E_CORE_POWER_THROTTLE,
54  .n_events = 5,
55  .format_fn = format_power_licensing,
56  .column_headers = PERFMON_STRINGS ("LVL0", "LVL1", "LVL2", "Throttle"),
57 };
unsigned char u8
Definition: types.h:56
double f64
Definition: types.h:142
description fragment has unexpected format
Definition: map.api:433
#define PERFMON_STRINGS(...)
Definition: perfmon.h:195
u64 value[PERF_MAX_EVENTS]
Definition: perfmon.h:138
static u8 * format_power_licensing(u8 *s, va_list *args)
Definition: power_license.c:21
PERFMON_REGISTER_BUNDLE(power_licensing)