summaryrefslogtreecommitdiffstats
path: root/src/occ_405/amec/amec_part.h
blob: b95909c85706c994aa02c91d97d0c679c627b534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ_405/amec/amec_part.h $                                */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2011,2015                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#ifndef _AMEC_PART_H
#define _AMEC_PART_H

/*----------------------------------------------------------------------------*/
/* Includes                                                                   */
/*----------------------------------------------------------------------------*/
#include <mode.h>
#include <sensor.h>
#include <occ_sys_config.h>
#include <amec_dps.h>

/*----------------------------------------------------------------------------*/
/* Constants                                                                  */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Globals                                                                    */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Defines                                                                    */
/*----------------------------------------------------------------------------*/

// Number of cores in system
#define AMEC_PART_NUM_CORES     (MAX_NUM_OCC * MAX_NUM_CORES)

// On a given OCC, only 12 partitions can be defined
#define AMEC_PART_MAX_PART      MAX_NUM_CORES

// Invalid core group ID
#define AMEC_PART_INVALID_ID    0xFF

/*----------------------------------------------------------------------------*/
/* Typedef / Enum                                                             */
/*----------------------------------------------------------------------------*/

typedef struct amec_part
{
    ///Flag to indicate if the core group should follow the system power policy
    BOOLEAN                     follow_sysmode;
    ///EnergyScale power savings policy
    OCC_INTERNAL_MODE           es_policy;
    ///Total number of cores in this core group.
    uint8_t                     ncores;
    ///List of cores group. Indices 0 to ncores-1 are valid. Valid values: 0 to
    ///AMEC_PART_NUM_CORES-1.
    uint8_t                     core_list[AMEC_PART_NUM_CORES];
    ///Partition ID
    uint8_t                     id;
    ///Valid bit (=1 in use, =0 not in use)
    uint8_t                     valid;
    ///Soft min frequency boundary sent by PHYP
    uint16_t                    soft_fmin;
    ///Soft max frequency boundary sent by PHYP
    uint16_t                    soft_fmax;
    ///Power saving state
    amec_dps_t                  dpsalg;
    ///slack utilization sensor
    sensor_t                    util2msslack;
} amec_part_t;

// Main structure that contains the partition configuration for PLPM work.
typedef struct amec_part_config
{
    ///Data structure holding core to partition mapping. The value
    ///AMEC_PART_INVALID_ID means that a core is not mapped to a partition. A
    ///value less than that means core is mapped to that partition index.
    uint16_t                    core2part[MAX_NUM_CORES];

    ///Data structure holding all active partitions (core groups)
    amec_part_t                 part_list[AMEC_PART_MAX_PART];
} amec_part_config_t;

/*----------------------------------------------------------------------------*/
/* Function Prototypes                                                        */
/*----------------------------------------------------------------------------*/

/**
 * Given a core, return a valid partition that owns it, or NULL.
 *  
 */
amec_part_t* amec_part_find_by_core(amec_part_config_t* i_config,
                                    const uint16_t i_core_index);

/**
 * This function adds a new core group and should only be called within the
 * AMEC ISR.
 *
 */
void amec_part_add(uint8_t i_id);

/**
 * Add a core group. 
 *  
 */
void amec_part_init(void);

/**
 * Update the parameter values depending on the DPS mode that 
 * has been selected (Favor Energy or Favor Performance). 
 *
 */
void amec_part_update_dps_parameter(amec_part_t* io_part);

/**
 * Update the internal performance settings for those cores that 
 * belong to the input partition. 
 *
 */
void amec_part_update_perf_settings(amec_part_t* io_part);

/**
 * Update the power mode on all core groups that are following 
 * the system mode. 
 *
 */
void AMEC_part_update_sysmode_policy(OCC_MODE i_occ_internal_mode);

/**
 * Overwrite the tunable parameters used by the DPS algorithms 
 * whenever the Master OCC sends them. 
 *
 */
void AMEC_part_overwrite_dps_parameters(void);

#endif //_AMEC_PART_H
OpenPOWER on IntegriCloud