blob: 78208a754181bda970fb4dd6d6d737eb29bfc90a [file] [log] [blame]
Georgi Djakov11f1cec2019-01-16 18:10:56 +02001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2018, Linaro Ltd.
4 * Author: Georgi Djakov <georgi.djakov@linaro.org>
5 */
6
7#ifndef __LINUX_INTERCONNECT_PROVIDER_H
8#define __LINUX_INTERCONNECT_PROVIDER_H
9
10#include <linux/interconnect.h>
11
12#define icc_units_to_bps(bw) ((bw) * 1000ULL)
13
14struct icc_node;
15
16/**
17 * struct icc_provider - interconnect provider (controller) entity that might
18 * provide multiple interconnect controls
19 *
20 * @provider_list: list of the registered interconnect providers
21 * @nodes: internal list of the interconnect provider nodes
22 * @set: pointer to device specific set operation function
23 * @aggregate: pointer to device specific aggregate operation function
24 * @dev: the device this interconnect provider belongs to
25 * @users: count of active users
26 * @data: pointer to private data
27 */
28struct icc_provider {
29 struct list_head provider_list;
30 struct list_head nodes;
31 int (*set)(struct icc_node *src, struct icc_node *dst);
32 int (*aggregate)(struct icc_node *node, u32 avg_bw, u32 peak_bw,
33 u32 *agg_avg, u32 *agg_peak);
34 struct device *dev;
35 int users;
36 void *data;
37};
38
39/**
40 * struct icc_node - entity that is part of the interconnect topology
41 *
42 * @id: platform specific node id
43 * @name: node name used in debugfs
44 * @links: a list of targets pointing to where we can go next when traversing
45 * @num_links: number of links to other interconnect nodes
46 * @provider: points to the interconnect provider of this node
47 * @node_list: the list entry in the parent provider's "nodes" list
48 * @search_list: list used when walking the nodes graph
49 * @reverse: pointer to previous node when walking the nodes graph
50 * @is_traversed: flag that is used when walking the nodes graph
51 * @req_list: a list of QoS constraint requests associated with this node
52 * @avg_bw: aggregated value of average bandwidth requests from all consumers
53 * @peak_bw: aggregated value of peak bandwidth requests from all consumers
54 * @data: pointer to private data
55 */
56struct icc_node {
57 int id;
58 const char *name;
59 struct icc_node **links;
60 size_t num_links;
61
62 struct icc_provider *provider;
63 struct list_head node_list;
64 struct list_head search_list;
65 struct icc_node *reverse;
66 u8 is_traversed:1;
67 struct hlist_head req_list;
68 u32 avg_bw;
69 u32 peak_bw;
70 void *data;
71};
72
73#if IS_ENABLED(CONFIG_INTERCONNECT)
74
75struct icc_node *icc_node_create(int id);
76void icc_node_destroy(int id);
77int icc_link_create(struct icc_node *node, const int dst_id);
78int icc_link_destroy(struct icc_node *src, struct icc_node *dst);
79void icc_node_add(struct icc_node *node, struct icc_provider *provider);
80void icc_node_del(struct icc_node *node);
81int icc_provider_add(struct icc_provider *provider);
82int icc_provider_del(struct icc_provider *provider);
83
84#else
85
86static inline struct icc_node *icc_node_create(int id)
87{
88 return ERR_PTR(-ENOTSUPP);
89}
90
91void icc_node_destroy(int id)
92{
93}
94
95static inline int icc_link_create(struct icc_node *node, const int dst_id)
96{
97 return -ENOTSUPP;
98}
99
100int icc_link_destroy(struct icc_node *src, struct icc_node *dst)
101{
102 return -ENOTSUPP;
103}
104
105void icc_node_add(struct icc_node *node, struct icc_provider *provider)
106{
107}
108
109void icc_node_del(struct icc_node *node)
110{
111}
112
113static inline int icc_provider_add(struct icc_provider *provider)
114{
115 return -ENOTSUPP;
116}
117
118static inline int icc_provider_del(struct icc_provider *provider)
119{
120 return -ENOTSUPP;
121}
122
123#endif /* CONFIG_INTERCONNECT */
124
125#endif /* __LINUX_INTERCONNECT_PROVIDER_H */