summaryrefslogtreecommitdiffstats
path: root/src/usr/htmgt/htmgt_cfgdata.H
blob: d26e556ca4bf007104bb5666fea9b43354f64eeb (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/htmgt/htmgt_cfgdata.H $                               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,2018                        */
/* [+] 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 HTMGT_CFGDATA_H
#define HTMGT_CFGDATA_H

#include <targeting/common/target.H>
#include "htmgt_occ.H"

#define MAX_GPUS 3

namespace HTMGT
{
    const uint8_t  OCC_PROC_QUAD_DEFAULT_WEIGHT = 10;  //Default 1.0 weight.
    const uint8_t  OCC_PROC_DEFAULT_DVFS_TEMP = 0x55;//default from DEF file PM
    const uint8_t  OCC_PROC_DEFAULT_ERR_TEMP  = 0x5F;
    const uint8_t  OCC_PROC_DEFAULT_TIMEOUT   = 0x05;
    const uint8_t  OCC_DIMM_DEFAULT_DVFS_TEMP = 0x45;//default from DEF file PM
    const uint8_t  OCC_DIMM_DEFAULT_ERR_TEMP  = 0x56;
    const uint8_t  OCC_DIMM_DEFAULT_TIMEOUT   = 0x1E;
    const uint8_t  OCC_NOT_DEFINED   = 0xFF;

    /** OCC configuration data message formats */
    enum occCfgDataFormat
    {
        OCC_CFGDATA_NO_REQUEST     = 0x00,  // no request for config data
        OCC_CFGDATA_FREQ_POINT     = 0x02,  // Frequency Operating Points
        OCC_CFGDATA_OCC_ROLE       = 0x03,  // OCC Role
        OCC_CFGDATA_APSS_CONFIG    = 0x04,  // APSS Config
        OCC_CFGDATA_MEM_CONFIG     = 0x05,  // Memory Configuration
        OCC_CFGDATA_PCAP_CONFIG    = 0x07,  // PCAP Config
        OCC_CFGDATA_SYS_CONFIG     = 0x0F,  // System Configuration
        OCC_CFGDATA_MEM_THROTTLE   = 0x12,  // Memory Throttle Settings
        OCC_CFGDATA_TCT_CONFIG     = 0x13,  // Thermal Control Treshold
        OCC_CFGDATA_AVSBUS_CONFIG  = 0x14,  // AVSBus Config
        OCC_CFGDATA_GPU_CONFIG     = 0x15,  // GPU Config

        OCC_CFGDATA_FORMAT_END,             // Marker to indicate last entry
        OCC_CFGDATA_CLEAR_ALL      = 0xFF,  // Clear All Active Config Data
    };


    enum  // constants
    {
        //KVM or OPAL mode + single node
        OCC_CFGDATA_OPENPOWER_OPALVM  = 0x81,
        //PowerVM mode + single node
        OCC_CFGDATA_NON_REDUNDANT_PS  = 0x02,
        OCC_CFGDATA_OPENPOWER_POWERVM = 0x01,

        //Mask, report throttling only when max frequency lowered below nominal
        OCC_REPORT_THROTTLE_BELOW_NOMINAL = 0x08,   //Bit 3
        //else, OCC report throttling when max frequency lowered below turbo

        CFGDATA_CORES = 24,

        CFGDATA_FRU_TYPE_PROC       = 0x00,
        CFGDATA_FRU_TYPE_MEMBUF     = 0x01,
        CFGDATA_FRU_TYPE_DIMM       = 0x02,
        CFGDATA_FRU_TYPE_VRM        = 0x03,
        CFGDATA_FRU_TYPE_GPU_CORE   = 0x04,
        CFGDATA_FRU_TYPE_GPU_MEMORY = 0x05,
        CFGDATA_FRU_TYPE_VRM_VDD    = 0x06,
        CFDATA_DVFS_NOT_DEFINED = 0xFF,
    };

    enum // WOF disabled reasons
    {
        WOF_MISSING_ULTRA_TURBO     = 0x0000,
        WOF_SYSTEM_DISABLED         = 0x0001,
        WOF_RESET_COUNT_REACHED     = 0x0002,
        WOF_UNSUPPORTED_FREQ        = 0x0003,
    };

    enum cfgTargets
    {
        TARGET_ALL    = 0x00,
        TARGET_MASTER = 0x01,
    };

    enum cfgSupStates
    {
        CFGSTATE_ALL     = 0x00,
        CFGSTATE_STANDBY = 0x01,
        CFGSTATE_SBYOBS  = 0x02
    };

    const uint32_t TO_20SEC = 20;

    struct occCfgDataTable_t
    {
        occCfgDataFormat    format;
        cfgTargets          targets;
        uint16_t            timeout; // in seconds
        cfgSupStates        supportedStates;

        bool operator==(const occCfgDataFormat& i_format) const
        {
            return (i_format == format);
        }
    };

    const occCfgDataTable_t occCfgDataTable[] =
    {
        { OCC_CFGDATA_SYS_CONFIG,     TARGET_ALL,    TO_20SEC, CFGSTATE_ALL },
        { OCC_CFGDATA_APSS_CONFIG,    TARGET_ALL,    TO_20SEC, CFGSTATE_ALL },
        { OCC_CFGDATA_OCC_ROLE,       TARGET_ALL,  TO_20SEC,CFGSTATE_STANDBY },
        { OCC_CFGDATA_FREQ_POINT,     TARGET_MASTER,TO_20SEC, CFGSTATE_SBYOBS },
        { OCC_CFGDATA_MEM_CONFIG,     TARGET_ALL,    TO_20SEC, CFGSTATE_ALL },
        { OCC_CFGDATA_PCAP_CONFIG,    TARGET_MASTER, TO_20SEC, CFGSTATE_ALL },
        { OCC_CFGDATA_MEM_THROTTLE,   TARGET_ALL,    TO_20SEC, CFGSTATE_ALL },
        { OCC_CFGDATA_TCT_CONFIG,     TARGET_ALL,    TO_20SEC, CFGSTATE_ALL },
        { OCC_CFGDATA_AVSBUS_CONFIG,  TARGET_ALL,    TO_20SEC, CFGSTATE_ALL },
        // GPU config packet MUST be sent after APSS config
        { OCC_CFGDATA_GPU_CONFIG,     TARGET_ALL,    TO_20SEC, CFGSTATE_ALL },
    };
    const size_t OCC_CONFIG_TABLE_SIZE = sizeof(occCfgDataTable) /
        sizeof(occCfgDataTable_t);

    /**
     * @brief Send config format data to all OCCs
     *
     * @param[in]  config format to send.  Default is to send
     *             all config formats.
     */
    void sendOccConfigData(const occCfgDataFormat i_requestedFormat =
                           OCC_CFGDATA_CLEAR_ALL);

    /**
     * Fills in the Memory Config Configuration Data message buffer,
     * including the format and version numbers.
     *
     * @param[in] i_occ - the OCC to gather data for
     * @param[out] o_data - preallocated buffer to fill in
     * @param[out] o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getMemConfigMessageData(const TARGETING::TargetHandle_t i_occ,
                                 uint8_t* o_data, uint64_t & o_size);


    /**
     * Fills in the Memory Throttle Configuration Data message buffer,
     * including the format and version numbers.
     *
     * @param[in] i_occ - the OCC to gather data for
     * @param[in] i_occ_instance - OCC instance number
     * @param[in] o_data - preallocated buffer to fill in
     * @param[out] o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getMemThrottleMessageData(const TARGETING::TargetHandle_t i_occ,
                                   const uint8_t i_occ_instance,
                                   uint8_t* o_data, uint64_t & o_size);


    /**
     * Fills in the OCC Role Configuration Data message buffer.
     *
     * @param[in] i_master - if this is for the OCC master
     * @param[in] i_firMaster - if this is for the OCC FIR master
     * @param[out] o_data - preallocated buffer to fill in
     * @param[out] o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getOCCRoleMessageData(bool i_master, bool i_firMaster,
                               uint8_t* o_data, uint64_t & o_size);


    /**
     * Return the maximum power cap for the system.
     *
     * Value is read from the MRW based on the Current Power Supply
     * Redundancy Policy sensor in the BMC
     *
     * @param[in]  i_sys - pointer to system target
     * @param[out] o_is_redundant - true if power supplies should be redundant
     * @returns  maximum power cap in watts
     */
    uint16_t getMaxPowerCap(TARGETING::Target *i_sys, bool & o_is_redundant);


    /**
     * Fills in the Power Cap Configuration Data message buffer.
     *
     * @param[out] o_data - preallocated buffer to fill in
     * @param[out] o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getPowerCapMessageData(uint8_t* o_data, uint64_t & o_size);


    /**
     * Fills in the System Config Configuration Data message buffer.
     *
     * @param[in]  i_occ  - the OCC target
     * @param[out] o_data - preallocated buffer to fill in
     * @param[out] o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getSystemConfigMessageData(const TARGETING::TargetHandle_t i_occ,
                                    uint8_t* o_data, uint64_t & o_size);


    /**
     * Fills in the Thermal Control Thresholds Configuration
     * Data message buffer.
     *
     * @param[out] o_data - preallocated buffer to fill in
     * @param[out] o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getThermalControlMessageData(uint8_t* o_data, uint64_t & o_size);


    /**
     * Fills in the AVSBus Configuration Data message buffer
     *
     * @param[in]   i_occ - the OCC target
     * @param[out]  o_data - preallocated buffer to fill in
     * @param[out]  o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getAVSBusConfigMessageData(const TARGETING::TargetHandle_t i_occ,
                                    uint8_t* o_data, uint64_t & o_size);

    /**
     * Fills in the GPU Configuration Data message buffer
     *
     * @param[in]   i_occ - the OCC target
     * @param[out]  o_data - preallocated buffer to fill in
     * @param[out]  o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getGPUConfigMessageData(const TARGETING::TargetHandle_t i_occ,
                                 uint8_t * o_data,
                                 uint64_t & o_size);

    /**
     * Fill in the Frequency Point Configuration Data
     * message buffer.
     *
     * @param[out] o_data - preallocated buffer to fill in
     * @param[out] o_size - set to the message size
     * @pre o_data is large enough.
     */
    void getFrequencyPointMessageData(uint8_t* o_data,
                                      uint64_t & o_size);

    /**
     * Generate the APSS configuration message
     * @param[out] The APSS cfg message
     * @param[in/out] In: Byte size of the o_data area. Out: Byte size of
     *                the occ cmd message
     */
    void getApssMessageData(uint8_t* o_data,
                            uint64_t & o_size);

    /**
     * Determine if WOF is supported and return applicable frequencies
     * @param[out] nominal Nominal frequency in MHz
     * @param[out] turbo   Turbo frequency in MHz (0 = no support)
     * @param[out] ultra   Ultra Turbo frequency in MHz (0 = no support)
     * @return             TRUE if WOF is supported, else FALSE
     */
    bool check_wof_support(uint16_t & nominal,
                           uint16_t & turbo,
                           uint16_t & ultra);

    /**
     * Fill specified buffer with requested config format data
     * @param[in]  i_occ     OCC object that data is requested
     * @param[in]  i_format  config format being requested
     * @param[out] o_cfgDataLength   Length of data being returned
     * @param[in/out] o_cfgDataPtr   Buffer containing config data
     */
    void readConfigData(Occ * i_occ,
                        const uint8_t i_format,
                        uint16_t & o_cfgDataLength,
                        uint8_t *o_cfgDataPtr);
};
#endif
OpenPOWER on IntegriCloud