Skip to content

Commit bd26631

Browse files
multics69rafaeljw
authored andcommitted
PM: EM: Add em.yaml and autogen files
Add a generic netlink spec in YAML format and autogenerate boilerplate code using ynl-regen.sh to introduce a generic netlink for the energy model. It allows a userspace program to read the performance domain and its energy model. It notifies the userspace program when a performance domain is created or deleted or its energy model is updated through a multicast interface. Specifically, it supports two commands: - EM_CMD_GET_PDS: Get the list of information for all performance domains. - EM_CMD_GET_PD_TABLE: Get the energy model table of a performance domain. Also, it supports three notification events: - EM_CMD_PD_CREATED: When a performance domain is created. - EM_CMD_PD_DELETED: When a performance domain is deleted. - EM_CMD_PD_UPDATED: When the energy model table of a performance domain is updated. Finally, update MAINTAINERS to include new files. Signed-off-by: Changwoo Min <changwoo@igalia.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/20251020220914.320832-4-changwoo@igalia.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent ee50b8b commit bd26631

5 files changed

Lines changed: 249 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2+
3+
name: em
4+
5+
doc: |
6+
Energy model netlink interface to notify its changes.
7+
8+
protocol: genetlink
9+
10+
uapi-header: linux/energy_model.h
11+
12+
attribute-sets:
13+
-
14+
name: pds
15+
attributes:
16+
-
17+
name: pd
18+
type: nest
19+
nested-attributes: pd
20+
multi-attr: true
21+
-
22+
name: pd
23+
attributes:
24+
-
25+
name: pad
26+
type: pad
27+
-
28+
name: pd-id
29+
type: u32
30+
-
31+
name: flags
32+
type: u64
33+
-
34+
name: cpus
35+
type: string
36+
-
37+
name: pd-table
38+
attributes:
39+
-
40+
name: pd-id
41+
type: u32
42+
-
43+
name: ps
44+
type: nest
45+
nested-attributes: ps
46+
multi-attr: true
47+
-
48+
name: ps
49+
attributes:
50+
-
51+
name: pad
52+
type: pad
53+
-
54+
name: performance
55+
type: u64
56+
-
57+
name: frequency
58+
type: u64
59+
-
60+
name: power
61+
type: u64
62+
-
63+
name: cost
64+
type: u64
65+
-
66+
name: flags
67+
type: u64
68+
69+
operations:
70+
list:
71+
-
72+
name: get-pds
73+
attribute-set: pds
74+
doc: Get the list of information for all performance domains.
75+
do:
76+
reply:
77+
attributes:
78+
- pd
79+
-
80+
name: get-pd-table
81+
attribute-set: pd-table
82+
doc: Get the energy model table of a performance domain.
83+
do:
84+
request:
85+
attributes:
86+
- pd-id
87+
reply:
88+
attributes:
89+
- pd-id
90+
- ps
91+
-
92+
name: pd-created
93+
doc: A performance domain is created.
94+
notify: get-pd-table
95+
mcgrp: event
96+
-
97+
name: pd-updated
98+
doc: A performance domain is updated.
99+
notify: get-pd-table
100+
mcgrp: event
101+
-
102+
name: pd-deleted
103+
doc: A performance domain is deleted.
104+
attribute-set: pd-table
105+
event:
106+
attributes:
107+
- pd-id
108+
mcgrp: event
109+
110+
mcast-groups:
111+
list:
112+
-
113+
name: event

MAINTAINERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9181,6 +9181,9 @@ S: Maintained
91819181
F: kernel/power/energy_model.c
91829182
F: include/linux/energy_model.h
91839183
F: Documentation/power/energy-model.rst
9184+
F: Documentation/netlink/specs/em.yaml
9185+
F: include/uapi/linux/energy_model.h
9186+
F: kernel/power/em_netlink_autogen.*
91849187

91859188
EPAPR HYPERVISOR BYTE CHANNEL DEVICE DRIVER
91869189
M: Laurentiu Tudor <laurentiu.tudor@nxp.com>

include/uapi/linux/energy_model.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2+
/* Do not edit directly, auto-generated from: */
3+
/* Documentation/netlink/specs/em.yaml */
4+
/* YNL-GEN uapi header */
5+
6+
#ifndef _UAPI_LINUX_ENERGY_MODEL_H
7+
#define _UAPI_LINUX_ENERGY_MODEL_H
8+
9+
#define EM_FAMILY_NAME "em"
10+
#define EM_FAMILY_VERSION 1
11+
12+
enum {
13+
EM_A_PDS_PD = 1,
14+
15+
__EM_A_PDS_MAX,
16+
EM_A_PDS_MAX = (__EM_A_PDS_MAX - 1)
17+
};
18+
19+
enum {
20+
EM_A_PD_PAD = 1,
21+
EM_A_PD_PD_ID,
22+
EM_A_PD_FLAGS,
23+
EM_A_PD_CPUS,
24+
25+
__EM_A_PD_MAX,
26+
EM_A_PD_MAX = (__EM_A_PD_MAX - 1)
27+
};
28+
29+
enum {
30+
EM_A_PD_TABLE_PD_ID = 1,
31+
EM_A_PD_TABLE_PS,
32+
33+
__EM_A_PD_TABLE_MAX,
34+
EM_A_PD_TABLE_MAX = (__EM_A_PD_TABLE_MAX - 1)
35+
};
36+
37+
enum {
38+
EM_A_PS_PAD = 1,
39+
EM_A_PS_PERFORMANCE,
40+
EM_A_PS_FREQUENCY,
41+
EM_A_PS_POWER,
42+
EM_A_PS_COST,
43+
EM_A_PS_FLAGS,
44+
45+
__EM_A_PS_MAX,
46+
EM_A_PS_MAX = (__EM_A_PS_MAX - 1)
47+
};
48+
49+
enum {
50+
EM_CMD_GET_PDS = 1,
51+
EM_CMD_GET_PD_TABLE,
52+
EM_CMD_PD_CREATED,
53+
EM_CMD_PD_UPDATED,
54+
EM_CMD_PD_DELETED,
55+
56+
__EM_CMD_MAX,
57+
EM_CMD_MAX = (__EM_CMD_MAX - 1)
58+
};
59+
60+
#define EM_MCGRP_EVENT "event"
61+
62+
#endif /* _UAPI_LINUX_ENERGY_MODEL_H */

kernel/power/em_netlink_autogen.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2+
/* Do not edit directly, auto-generated from: */
3+
/* Documentation/netlink/specs/em.yaml */
4+
/* YNL-GEN kernel source */
5+
6+
#include <net/netlink.h>
7+
#include <net/genetlink.h>
8+
9+
#include "em_netlink_autogen.h"
10+
11+
#include <uapi/linux/energy_model.h>
12+
13+
/* EM_CMD_GET_PD_TABLE - do */
14+
static const struct nla_policy em_get_pd_table_nl_policy[EM_A_PD_TABLE_PD_ID + 1] = {
15+
[EM_A_PD_TABLE_PD_ID] = { .type = NLA_U32, },
16+
};
17+
18+
/* Ops table for em */
19+
static const struct genl_split_ops em_nl_ops[] = {
20+
{
21+
.cmd = EM_CMD_GET_PDS,
22+
.doit = em_nl_get_pds_doit,
23+
.flags = GENL_CMD_CAP_DO,
24+
},
25+
{
26+
.cmd = EM_CMD_GET_PD_TABLE,
27+
.doit = em_nl_get_pd_table_doit,
28+
.policy = em_get_pd_table_nl_policy,
29+
.maxattr = EM_A_PD_TABLE_PD_ID,
30+
.flags = GENL_CMD_CAP_DO,
31+
},
32+
};
33+
34+
static const struct genl_multicast_group em_nl_mcgrps[] = {
35+
[EM_NLGRP_EVENT] = { "event", },
36+
};
37+
38+
struct genl_family em_nl_family __ro_after_init = {
39+
.name = EM_FAMILY_NAME,
40+
.version = EM_FAMILY_VERSION,
41+
.netnsok = true,
42+
.parallel_ops = true,
43+
.module = THIS_MODULE,
44+
.split_ops = em_nl_ops,
45+
.n_split_ops = ARRAY_SIZE(em_nl_ops),
46+
.mcgrps = em_nl_mcgrps,
47+
.n_mcgrps = ARRAY_SIZE(em_nl_mcgrps),
48+
};

kernel/power/em_netlink_autogen.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2+
/* Do not edit directly, auto-generated from: */
3+
/* Documentation/netlink/specs/em.yaml */
4+
/* YNL-GEN kernel header */
5+
6+
#ifndef _LINUX_EM_GEN_H
7+
#define _LINUX_EM_GEN_H
8+
9+
#include <net/netlink.h>
10+
#include <net/genetlink.h>
11+
12+
#include <uapi/linux/energy_model.h>
13+
14+
int em_nl_get_pds_doit(struct sk_buff *skb, struct genl_info *info);
15+
int em_nl_get_pd_table_doit(struct sk_buff *skb, struct genl_info *info);
16+
17+
enum {
18+
EM_NLGRP_EVENT,
19+
};
20+
21+
extern struct genl_family em_nl_family;
22+
23+
#endif /* _LINUX_EM_GEN_H */

0 commit comments

Comments
 (0)