1  /*
2   * Arm SCP/MCP Software
3   * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
4   *
5   * SPDX-License-Identifier: BSD-3-Clause
6   *
7   * Description:
8   *     Performance plugins handler.
9   *     Please refer to the architecture documentation for further details.
10   */
11  
12  #ifndef PERF_PLUGINS_HANDLER_H
13  #define PERF_PLUGINS_HANDLER_H
14  
15  /*!
16   * \addtogroup GroupSCMI_PERF SCMI Performance Domain Management Protocol
17   * @{
18   */
19  
20  #include <mod_scmi_perf.h>
21  
22  #include <fwk_element.h>
23  #include <fwk_id.h>
24  
25  int perf_plugins_handler_bind(void);
26  
27  int perf_plugins_handler_process_bind_request(
28      fwk_id_t source_id,
29      fwk_id_t target_id,
30      fwk_id_t api_id,
31      const void **api);
32  
33  /*!
34   * \brief FastChannel Performance Update data container
35   *
36   * \note This data structure is passed between the plugins handler and the SCMI
37   *      performance module. It contains:
38   *      - limits that SCMI-Perf provides to the plugins handler for its logic.
39   *      - adjusted limits that the plugins handler returns to SCMI-Perf ready
40   *          for the DVFS module.
41   *      These values come from the FastChannels and the plugins handler executes
42   *      its logic in order to aggregate them before they can be forwarded to the
43   *      DVFS module.
44   */
45  struct fc_perf_update {
46      /*! DVFS domain identifier */
47      fwk_id_t domain_id;
48  
49      /*! Performance level */
50      uint32_t level;
51  
52      /*! Performance limit max to the plugins handler */
53      uint32_t max_limit;
54      /*! Performance limit min to the plugins handler */
55      uint32_t min_limit;
56  
57      /*! Adjusted (by the plugins hanlder) performance limit max */
58      uint32_t adj_max_limit;
59      /*! Adjusted (by the plugins hanlder) performance limit min */
60      uint32_t adj_min_limit;
61  };
62  
63  /*!
64   * \brief FastChannel mirror
65   *
66   * \details Fastchannels addresses in memory are not necessarily contiguous,
67   *      thus copy them into a temporary area for easy handling. Also for the
68   *      purpose of managing performance requests, get_ are not required.
69   */
70  struct fast_channels_mirror {
71      uint32_t level;
72      struct mod_scmi_perf_fast_channel_limit limits;
73  };
74  
75  /*!
76   * \brief Performance Plugins Handler Update
77   *
78   * \details Call the update logic for the Plugins Handler. This logic will take
79   *      care of the aggregation of values for all the domains and all the
80   *      plugins.
81   *
82   * \param perf_dom_idx Performance domain index
83   * \param fc_update FastChannel data. The Plugins Handler expects to receive the
84   *      latest FastChannels values for the above particular performance domain
85   *      and runst its internal logic of storing and aggregating. This is an
86   *      input to the Plugins Handler.
87   */
88  void perf_plugins_handler_update(
89      unsigned int perf_dom_idx,
90      struct fc_perf_update *fc_update);
91  
92  /*!
93   * \brief Performance Plugins Handler Get
94   *
95   * \details Get the performance update for a performance domain. For a given
96   *      domain, the final aggregated values are provided in the fc_perf_update
97   *      container. It is meant to be called after all the updates have run.
98   *
99   * \param perf_dom_idx Performance domain index
100   * \param fc_update FastChannel data. The Plugins Handler expects to receive
101   *      the latest FastChannels values for the above particular performance
102   *      domain and runst its internal logic of storing and aggregating. This is
103   *      an input and an output to/from the Plugins Handler.
104   */
105  void perf_plugins_handler_get(
106      unsigned int perf_dom_idx,
107      struct fc_perf_update *fc_update);
108  
109  void perf_plugins_handler_report(struct perf_plugins_perf_report *data);
110  
111  fwk_id_t perf_plugins_get_dependency_id(unsigned int dom_idx);
112  
113  int perf_plugins_handler_init(const struct mod_scmi_perf_config *config);
114  
115  /*!
116   * @}
117   */
118  
119  #endif /* PERF_PLUGINS_HANDLER_H */
120