summaryrefslogtreecommitdiffstats
path: root/src/occ_405/cmdh/cmdh_fsp_cmds.h
blob: 4405b1df11de7996ae8e1d4a17a201b2c717eaeb (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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ_405/cmdh/cmdh_fsp_cmds.h $                            */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2011,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 _CMDH_FSP_CMDS_H
#define _CMDH_FSP_CMDS_H

#include "ssx.h"
#include "cmdh_service_codes.h"
#include "errl.h"
#include "trac.h"
#include "rtls.h"
#include "occ_common.h"
#include "state.h"
#include "cmdh_fsp.h"
#include "cmdh_fsp_cmds_datacnfg.h"
#include "sensor.h"
#include "apss.h"

// Enum of the various commands that may be sent to OCC
typedef enum
{
    CMDH_POLL                   = 0x00,
    CMDH_CLEARERRL              = 0x12,
    CMDH_SETMODESTATE           = 0x20,
    CMDH_SETCONFIGDATA          = 0x21,
    CMDH_SET_USER_PCAP          = 0x22,
    CMDH_RESET_PREP             = 0x25,
    CMDH_SNAPSHOT_SYNC          = 0x26,
    CMDH_GET_SNAPSHOT_BUFFER    = 0x35,
    CMDH_DEBUGPT                = 0x40,
    CMDH_AME_PASS_THROUGH       = 0x41,
    CMDH_GET_FIELD_DEBUG_DATA   = 0x42,
    CMDH_MFG_TEST_CMD           = 0x53,
    CMDH_TUNABLE_PARMS          = 0x60,
    CMDH_CLEAR_SENSOR_DATA      = 0xD0,
    CMDH_SET_PCAP_INBAND        = 0xD1,
    CMDH_WRITE_PSR              = 0xD2,
    CMDH_SELECT_SENSOR_GROUPS   = 0xD3,
} eCmdhCommands;

#define SENSOR_TEMP "TEMP"
#define SENSOR_FREQ "FREQ"
#define SENSOR_POWR "POWR"
#define SENSOR_CAPS "CAPS"
#define SENSOR_EXTN "EXTN"
#define EXTN_NAME_FMIN    0x464D494E // "FMIN"
#define EXTN_NAME_FNOM    0x464E4F4D // "FNOM"
#define EXTN_NAME_FTURBO  0x46540000 // "FT"
#define EXTN_NAME_FUTURBO 0x46555400 // "FUT"
#define EXTN_NAME_CLIP    0x434C4950 // "CLIP"
#define EXTN_NAME_WOFC    0x574F4643 // "WOFC"
#define EXTN_NAME_ERRHIST 0x45525248 // "ERRH"

#define MAX_EXTN_SENSORS 32
//---------------------------------------------------------
// Poll Command
//---------------------------------------------------------

// Length of Poll Response
#define CMDH_POLL_RESP_LEN_V20 40 // version 0x20 has at least 40 bytes.
// Poll Version 0x20
#define CMDH_POLL_VERSION20  0x20

// Struct used to parse Poll Cmd
typedef struct __attribute__ ((packed)) cmdh_poll_query
{
    // Standard TMGT
    struct    cmdh_fsp_cmd_header;
    // Poll Version
    uint8_t   version;
}cmdh_poll_query_t;

// Response packet used for Poll Cmd
typedef struct __attribute__ ((packed)) cmdh_poll_resp_v20
{
    // Standard TMGT/HTMGT
    struct    cmdh_fsp_rsp_header;
    // BYTE  1: Status
    union
    {
        struct
        {
            uint8_t master_occ     : 1;   // 1 => master, 0 => slave
            uint8_t fir_master     : 1;   // 1 => fir master.
            uint8_t _reserved_5    : 1;
            uint8_t _reserved_4    : 1;
            uint8_t simics         : 1;   // 1 => running in SIMICS environment
            uint8_t _reserved_2    : 1;
            uint8_t obs_ready      : 1;   // 1 => OCC received all data to support obs state.
            uint8_t active_ready   : 1;   // 1 => OCC received all data to support active state.
        };
        uint8_t word;
    } status;
    // BYTE  2: Extended Status
    union
    {
        struct
        {
            uint8_t dvfs_due_to_ot     : 1;   // 1 => OCC clipped max Pstate due to a processor over temp.
            uint8_t dvfs_due_to_pwr    : 1;   // 1 => OCC clipped max Psate due to reaching pcap limit.
            uint8_t mthrot_due_to_ot   : 1;   // 1 => OCC throttled memory due to an over temp.
            uint8_t n_power            : 1;   // 1 => Server running without redundant power.
            uint8_t dvfs_due_to_vdd_ot : 1;   // 1 => OCC clipped max Pstate due to VRM Vdd over temp.
            uint8_t _reserved_2        : 1;
            uint8_t _reserved_1        : 1;
            uint8_t _reserved_0        : 1;
        };
        uint8_t word;
    } ext_status;
    // BYTE  3: OCCs Present
    uint8_t   occ_pres_mask;
    // BYTE  4: Config Data Requested
    uint8_t   config_data;
    // BYTE  5: Current OCC State
    uint8_t   state;
    // BYTE  6: Current OCC Mode
    uint8_t   mode;
    // BYTE  7: Current Idle Power Saver Status
    union
    {
        struct
        {
            uint8_t _reserved_7     : 1;
            uint8_t _reserved_6     : 1;
            uint8_t _reserved_5     : 1;
            uint8_t _reserved_4     : 1;
            uint8_t _reserved_3     : 1;
            uint8_t _reserved_2     : 1;
            uint8_t ips_active      : 1;
            uint8_t ips_enabled     : 1;
        };
        uint8_t word;
    } ips_status;
    // BYTE  8: Error Log ID
    uint8_t   errl_id;
    // BYTES  9 - 12: Error Log Start Address
    uint32_t  errl_address;
    // BYTES 13 - 14: Error Log Length
    uint16_t  errl_length;
    // BYTE 15: Reserved
    uint8_t   _reserved_15;
    // BYTE 16: GPU Configuration
    uint8_t   gpu_presence;
    // BYTES 17 - 32 (16 bytes): OCC Code Level - ASCII string of OCC build level currently running.
    uint8_t   occ_level[16];
    // BYTES 33 - 38 (6 bytes):  ASCII eye catcher "SENSOR"
    uint8_t   sensor_ec[6];
    // BYTE  39: Number of sensor data blocks
    uint8_t   sensor_dblock_count;
    // BYTE  40: Sensor Data Block Header Version
    uint8_t   sensor_dblock_version;
    // No need to include the 2 bytes for checksum since they get added prior to sending
    // data back to tmgt.
}cmdh_poll_resp_v20_fixed_t;

typedef struct __attribute__ ((packed)) cmdh_poll_sensor_datablock
{
    uint8_t eyecatcher[4];
    uint8_t reserved;
    uint8_t format;
    uint8_t length;
    uint8_t count;
} cmdh_poll_sensor_db_t;

typedef struct __attribute__ ((packed)) cmdh_poll_temp_sensor
{
    uint32_t id;     // Sensor id.
    uint8_t  fru_type;
    uint8_t  value;  // current temperature sensor reading in degrees C
} cmdh_poll_temp_sensor_t;

typedef struct __attribute__ ((packed)) cmdh_poll_freq_sensor
{
    uint32_t id;     // Id to represent the frequency.
    uint16_t value;  // current frequency in MHZ
} cmdh_poll_freq_sensor_t;

// Only available from master occ.
typedef struct __attribute__ ((packed)) cmdh_poll_powr_sensor
{
    uint32_t id;            // Sensor id - to represent the power.
    uint8_t  function_id;   // Identify what the reading is for (ADC_CHANNEL_ID in xml file)
    uint8_t  apss_channel;  // APSS channel that the power was read from
    uint16_t reserved;
    uint32_t update_tag;    // Count of number of 250us samples represented by accumulator.
    uint64_t accumul;       // Accumulation of 250us power readings
    uint16_t current;       // Most recent 250us reading in watts.
} cmdh_poll_power_sensor_t;

typedef struct __attribute__ ((packed)) cmdh_poll_powr_no_apss_sensor
{
    uint32_t sys_pwr_id;            // Sensor id - to represent total system power.
    uint16_t sys_pwr_update_time;   // Time in us that system power is read
    uint16_t sys_pwr_current;       // Most recent system power reading in watts
    uint32_t sys_pwr_update_tag;    // Count of number of samples represented by sys pwr accumulator
    uint64_t sys_pwr_accumul;       // Accumulation of system power readings
    uint32_t reserved;
    uint16_t proc_pwr_update_time;  // Time in us that processor power is updated
    uint16_t proc_pwr_current;      // Most recent processor power reading in watts
    uint32_t proc_pwr_update_tag;   // Count of number of samples represented by proc accumulator
    uint64_t proc_pwr_accumul;      // Accumulation of processor power readings
    uint16_t vdd_pwr_current;       // Most recent processor Vdd power reading in watts
    uint32_t vdd_pwr_update_tag;    // Count of number of samples represented by Vdd accumulator
    uint64_t vdd_pwr_accumul;       // Accumulation of processor Vdd power readings
    uint16_t vdn_pwr_current;       // Most recent processor Vdn power reading in watts
    uint32_t vdn_pwr_update_tag;    // Count of number of samples represented by Vdn accumulator
    uint64_t vdn_pwr_accumul;       // Accumulation of processor Vdn power readings
} cmdh_poll_power_no_apss_sensor_t;

// Only available from master occ.
typedef struct __attribute__ ((packed)) cmdh_poll_caps_sensor
{
    uint16_t current;   // Current power cap in 1W units.
    uint16_t system;    // Current system power in 1W units.
    uint16_t n;         // Oversubscription; output pcap limit when theres no redundant power.
    uint16_t max;       // Maximum power cap in 1W units.
    uint16_t hard_min;  // Minimum hard power cap in 1W units.
    uint16_t soft_min;  // Minimum soft power cap in 1W units.
    uint16_t user;      // Power cap set by user in 1W units.
    uint8_t  source;    // User Power Limit Source
} cmdh_poll_pcaps_sensor_t;

typedef struct __attribute__ ((packed)) cmdh_poll_extn_sensor
{
    uint32_t name;          // Sensor name or id
    uint8_t  flags;         // Flags indicating any special processing
    uint8_t  reserved;
    uint8_t  data[6];       // Data associated with sensor
} cmdh_poll_extn_sensor_t;

//---------------------------------------------------------
// Query FW Level Command
//---------------------------------------------------------

// Response packet used for Query Firmware Level Cmd
#define CMDH_FW_QUERY_RESP_LEN 16
typedef struct __attribute__ ((packed)) cmdh_fw_resp
{
    // Standard TMGT
    struct    cmdh_fsp_rsp_header;
    // Firmware Level (4 bytes)
    uint8_t   fw_level[CMDH_FW_QUERY_RESP_LEN];
    // Checksum
    uint8_t   checksum[2];
}cmdh_fw_resp_t;

extern uint8_t G_apss_ch_to_function[MAX_APSS_ADC_CHANNELS];
//---------------------------------------------------------
// Set Mode And State Command
//---------------------------------------------------------

// Query packet used by the FSP for setting the TPMF state, version 0.
struct smgr_setmodestate_v0_query
{
    // Standard TMGT
    struct    cmdh_fsp_cmd_header;
    // Version
    uint8_t       version;
    // New state from OCC_STATE_*
    uint8_t       occ_state;
    // New mode from OCC_MODE_*
    uint8_t       occ_mode;
} __attribute__ ((__packed__));

typedef struct smgr_setmodestate_v0_query smgr_setmodestate_v0_query_t;

#define SMGR_SETMODESTATE_CMD_LEN    3

// Complete Response packet for a set mode / state command
#define SMGR_SETMODESTATE_RESP_LEN   0
typedef cmdh_fsp_rsp_t smgr_setmodestate_resp_t;

// Set-mode-state TMGT command version
#define SMGR_SMS_CMD_VERSION         0

//---------------------------------------------------------
// Clear Elog Command
//---------------------------------------------------------

// Used by TMGT to clear elog data state, version 0.
typedef struct __attribute__ ((packed))
{
    struct    cmdh_fsp_cmd_header;
    uint8_t   elog_id;
}cmdh_clear_elog_query_t;

//---------------------------------------------------------
// Get Elog Command
//---------------------------------------------------------

// Used by TMGT to response occ elog data, version 0.
typedef struct __attribute__ ((packed))
{
    struct    cmdh_fsp_rsp_header;
    uint32_t  oci_address;
    uint8_t   elog_id;
}cmdh_get_elog_resp_t;

#define CMDH_GET_ELOG_RESP_LEN 5

//---------------------------------------------------------
// Reset Prep
//---------------------------------------------------------

// Minimum Data Length for Reset Prep Command
#define CMDH_RESET_PREP_MIN_DATALEN 1

// Version 0
#define CMDH_RESET_PREP_VERSION 0

// Reason
typedef enum
{
    // Non-failure. Code update, external user request (i.e. to load
    // new pState table). No FFDC error logs should be generated.
    CMDH_PREP_NONFAILURE       = 0x00,
    // Failure detected on this OCC. FFDC error log should be generated.
    CMDH_PREP_FAILON_THISOCC   = 0x01,
    // Failure detected on a different OCC within same node.
    // FFDC log is optional, if this OCC is master OCC it may want to
    // generate FFDC log.
    CMDH_PREP_FAILON_OTHEROCC  = 0x02,
    // Failure detected on a different OCC in different node. No
    // FFDC error log should be generated. Current assumption is that an
    // OCC in a different node should never be reason for an OCC failure.
    CMDH_PREP_FAILON_OTHERNODE = 0x03,
    // System is powering off, stop RTL tasks
    CMDH_PREP_POWER_OFF = 0xFF,
} eCmdhResetPrepReason;

#define CMDH_RESET_PREP_TRACE_SIZE 3072

// Struct used to parse Reset Prep Command
typedef struct __attribute__ ((packed)) cmdh_reset_prep
{
    // Standard TMGT
    struct    cmdh_fsp_cmd_header;
    // Poll Version
    uint8_t   version;
    // Reason
    uint8_t   reason;
}cmdh_reset_prep_t;

//---------------------------------------------------------
// Debug Command
//---------------------------------------------------------

///Max string length of trace component name
#define OCC_TRACE_NAME_SIZE     4

// Enum of the various Debug commands that may be sent to OCC
// over the TMGT<->OCC interface.
typedef enum
{
    DBUG_DUMP_WOF_DATA      = 0x01,
    // free = 0x02
    DBUG_GET_TRACE          = 0x03,
    DBUG_CLEAR_TRACE        = 0x04,
    DBUG_ALLOW_TRACE        = 0x05,
    DBUG_SET_PEXE_EVENT     = 0x06,
    DBUG_GET_AME_SENSOR     = 0x07,
    DBUG_DUMP_GPU_TIMINGS   = 0x08,
    DBUG_PEEK               = 0x09,
    DBUG_POKE               = 0x0A,
    DBUG_DUMP_THEMAL        = 0x0B,
    DBUG_DUMP_POWER         = 0x0C,
    DBUG_DUMP_RAW_AD        = 0x0D,
    DBUG_DVFS_SLEW          = 0x0E,
    DBUG_MEM_PWR_CTL        = 0x0F,
    DBUG_PERFCOUNT          = 0x10,
    DBUG_TEST_INTF          = 0x11,
    // free = 0x12
    // free = 0x13
    DBUG_INJECT_ERRL        = 0x14,
    // free = 0x15
    // free = 0x16
    DBUG_GPIO_READ          = 0x17,
    DBUG_FSP_ATTN           = 0x18,
    DBUG_CALCULATE_MAX_DIFF = 0x19,
    DBUG_FORCE_ELOG         = 0x1A,
    DBUG_SWITCH_PHASE       = 0x1B,
    DBUG_INJECT_ERR         = 0x1C,
    DBUG_VERIFY_V_F         = 0x1D,
    DBUG_DUMP_PPM_DATA      = 0x1E,
    // free = 0x1F
    DBUG_FLUSH_DCACHE       = 0x20,
    DBUG_INVALIDATE_DCACHE  = 0x21,
    DBUG_CENTAUR_SENSOR_CACHE = 0x22,
    DBUG_DUMP_PROC_DATA     = 0x23,
    DBUG_GEN_CHOM_LOG       = 0x24,
    DBUG_DUMP_APSS_DATA     = 0x25,
    DBUG_DUMP_AME_SENSOR    = 0x26,
    DBUG_CLEAR_AME_SENSOR   = 0x27,
    DBUG_WOF_CONTROL        = 0x28
} DBUG_CMD;

// Used by OCC tool to get trace, version 0.
typedef struct __attribute__ ((packed))
{
    struct    cmdh_fsp_cmd_header;
    int8_t    sub_cmd;
    int16_t   size_request;
    int8_t    comp[OCC_TRACE_NAME_SIZE];
}cmdh_dbug_get_trace_query_t;

// Used by OCC to response "get trace" cmd, version 0.
typedef struct __attribute__ ((packed))
{
    struct    cmdh_fsp_rsp_header;
    uint8_t   data[0];
}cmdh_dbug_get_trace_resp_t;

#define CMDH_DBUG_GET_TRACE_RESP_LEN 6  // size_request(2) and occ_comp_sram_offset(4)

// Used by occtool to get AME sensor data
typedef struct __attribute__ ((packed))
{
    struct     cmdh_fsp_cmd_header;
    uint8_t    sub_cmd;
    uint16_t   type;
    uint16_t   location;
}cmdh_dbug_get_sensor_query_t;

typedef struct cmdh_dbug_sensor_list
{
    char        name[MAX_SENSOR_NAME_SZ];
    uint16_t    gsid;
    uint16_t    sample;
    uint16_t    sample_min;
    uint16_t    sample_max;
    uint32_t    ipmi_sid;
}cmdh_dbug_sensor_list_t;

// Max number of sensors that can be returned with cmdh_dbug_get_ame_sensor command
#define CMDH_DBUG_MAX_NUM_SENSORS  50
// Size of standard response header (5 bytes) plus checksum (2 bytes)
#define CMDH_DBUG_FSP_RESP_LEN     7

// Used by OCC firmware to respond "cmdh_dbug_get_ame_sensor" debug command
typedef struct __attribute__ ((packed))
{
    struct                  cmdh_fsp_rsp_header;
    uint16_t                num_sensors;
    cmdh_dbug_sensor_list_t sensor[CMDH_DBUG_MAX_NUM_SENSORS];
    uint8_t                 filler;
    uint16_t                checksum;
}cmdh_dbug_get_sensor_resp_t;

// Size of trace data for a trace buffer
#define CMDH_FIELD_TRACE_DATA_SIZE  1024
// Max number of sensors for field debug data
#define CMDH_FIELD_MAX_NUM_SENSORS  50

// Used by OCC to response "GET_FIELD_DEBUG_DATA" cmd
typedef struct __attribute__ ((packed))
{
    struct                  cmdh_fsp_rsp_header;
    // OCC node
    uint8_t                 occ_node;
    // OCC id
    uint8_t                 occ_id;
    // OCC role
    uint8_t                 occ_role;
    // ERR trace
    char                    trace_err[CMDH_FIELD_TRACE_DATA_SIZE];
    // INF trace
    char                    trace_inf[CMDH_FIELD_TRACE_DATA_SIZE];
    // Number of Sensors
    uint16_t                num_sensors;
    // Sensors list
    cmdh_dbug_sensor_list_t sensor[CMDH_FIELD_MAX_NUM_SENSORS];
    // Checksum
    uint8_t   checksum[2];
}cmdh_get_field_debug_data_resp_t;

// Used by TMGT to get field debug data
typedef struct __attribute__ ((packed))
{
    struct     cmdh_fsp_cmd_header;
    uint8_t    version;
}cmdh_get_field_debug_data_query_t;

// Used by OCC to debug on real hardware
typedef struct __attribute__ ((packed))
{
    struct    cmdh_fsp_cmd_header;
    uint8_t   sub_cmd;
    uint8_t   type;
    uint16_t  size;
    uint32_t  oci_address;
}cmdh_dbug_peek_t;

typedef struct __attribute__ ((packed))
{
    uint8_t     func;
    uint16_t    raw;
    uint16_t    calculated;
    uint32_t    ipmi_sid;
    uint32_t    offset;
    uint32_t    gain;
}cmdh_dbug_apss_data_t;

// Used to get the APSS raw values
typedef struct __attribute__ ((packed))
{
    struct                  cmdh_fsp_rsp_header;
    cmdh_dbug_apss_data_t   ApssCh[MAX_APSS_ADC_CHANNELS];
    uint8_t                 checksum[2];
} cmdh_dbug_apss_data_resp_t;

// DBUG_DUMP_AME_SENSOR command struct
typedef struct __attribute__ ((packed))
{
    struct   cmdh_fsp_cmd_header;  // Standard command header
    uint8_t  sub_cmd;              // Debug sub-command
    uint16_t gsid;                 // Global Sensor ID
} cmdh_dbug_dump_ame_sensor_cmd_t;

// DBUG_DUMP_AME_SENSOR response struct
typedef struct __attribute__ ((packed))
{
    struct        cmdh_fsp_rsp_header;               // Standard response header
    sensor_info_t sensor_info;                       // Static sensor fields
    sensor_t      sensor;                            // Dynamic sensor fields
    uint8_t       checksum[CMDH_FSP_CHECKSUM_SIZE];  // Checksum
} cmdh_dbug_dump_ame_sensor_rsp_t;

// DBUG_CLEAR_AME_SENSOR command struct
typedef struct __attribute__ ((packed))
{
    struct   cmdh_fsp_cmd_header;  // Standard command header
    uint8_t  sub_cmd;              // Debug sub-command
    uint16_t gsid;                 // Global Sensor ID
    uint16_t clear_type;           // Fields to clear (AMEC_SENSOR_CLEAR_TYPE)
} cmdh_dbug_clear_ame_sensor_cmd_t;

// DBUG_CLEAR_AME_SENSOR response struct
typedef struct __attribute__ ((packed))
{
    struct   cmdh_fsp_rsp_header;               // Standard response header
    sensor_t sensor;                            // Dynamic sensor fields
    uint8_t  checksum[CMDH_FSP_CHECKSUM_SIZE];  // Checksum
} cmdh_dbug_clear_ame_sensor_rsp_t;

// DBUG_WOF_CONTROL command struct
typedef struct __attribute__ ((packed))
{
    struct      cmdh_fsp_cmd_header;    // Standard command header
    uint8_t     sub_cmd;                // Debug sub-command
    uint8_t     action;                 // CLEAR(0) or SET(1)
    uint32_t    wof_rc;                 // Bit to set
} cmdh_dbug_wof_control_cmd_t;

// DBUG_WOF_CONTROL response struct
typedef struct __attribute__ ((packed))
{
    struct      cmdh_fsp_rsp_header;
    uint32_t    wof_disabled;
    uint8_t     checksum[CMDH_FSP_CHECKSUM_SIZE];
} cmdh_dbug_wof_control_rsp_t;

// DBUG_ALLOW_TRACE command struct
typedef struct __attribute__ ((packed))
{
    struct      cmdh_fsp_cmd_header;
    uint8_t     sub_cmd;
    uint8_t     action;
    uint16_t    trace_flags;
}cmdh_dbug_allow_trace_cmd_t;

// DBUG_ALLOW_TRACE response struct
typedef struct __attribute__ ((packed))
{
    struct      cmdh_fsp_rsp_header;
    uint16_t    trace_flags;
    uint8_t     checksum[CMDH_FSP_CHECKSUM_SIZE];
}cmdh_dbug_allow_trace_rsp_t;

//---------------------------------------------------------
// Tunable Parameter Command
//---------------------------------------------------------

// Default number of tunable parameters available
// NOTE: update this value if any new tunable parameter is added into the table
#define CMDH_DEFAULT_TUNABLE_PARAM_NUM   10
// Max size for string containing the tunable parameter name
#define CMDH_TUNABLE_PARAM_NAME_MAX_SIZE 60

typedef struct cmdh_tunable_param_table
{
    uint8_t             id;
    char                name[CMDH_TUNABLE_PARAM_NAME_MAX_SIZE];
    uint8_t             unit_type;
    uint16_t            flag;
    uint16_t            value;
    uint16_t            min;
    uint16_t            max;
}cmdh_tunable_param_table_t;

typedef struct cmdh_tunable_param_table_ext
{
    // Default value for this parameter
    uint16_t            def_value;
    // Multiplier to convert the input value to correct internal resolution
    uint16_t            multiplier;
    // Adjusted value for this parameter (adjusted for internal resolution)
    uint16_t            adj_value;
}cmdh_tunable_param_table_ext_t;

extern uint8_t G_mst_tunable_parameter_overwrite;
extern cmdh_tunable_param_table_ext_t G_mst_tunable_parameter_table_ext[CMDH_DEFAULT_TUNABLE_PARAM_NUM];
extern cmdh_tunable_param_table_t G_mst_tunable_parameter_table[CMDH_DEFAULT_TUNABLE_PARAM_NUM];

#define CMDH_SET_USER_PCAP_DATALEN 2

//---------------------------------------------------------
// Clear Sensor Data Command
//---------------------------------------------------------

typedef struct __attribute__ ((packed))
{
    uint8_t                 sensor_owner_id;
    uint8_t                 reserved[3];
}cmdh_clear_sensor_cmd_data_t;

typedef struct __attribute__ ((packed))
{
    uint8_t                 sensor_owner_id;
    uint8_t                 reserved[3];
}cmdh_clear_sensor_rsp_data_t;

//---------------------------------------------------------
// Set Power Cap In-band Command
//---------------------------------------------------------

typedef struct __attribute__ ((packed))
{
    uint8_t                power_cap[2];
}cmdh_set_inband_pcap_cmd_data_t;

typedef struct __attribute__ ((packed))
{
    uint8_t                power_cap[2];
}cmdh_set_inband_pcap_rsp_data_t;

//---------------------------------------------------------
// Write Power Shifting Ratio Command
//---------------------------------------------------------

typedef struct __attribute__ ((packed))
{
    uint8_t                 psr;
}cmdh_write_psr_cmd_data_t;

typedef struct __attribute__ ((packed))
{
    uint8_t                 psr;
}cmdh_write_psr_rsp_data_t;

//---------------------------------------------------------
// Select Sensor Groups Command
//---------------------------------------------------------

typedef struct __attribute__ ((packed))
{
    uint8_t                sensor_groups[2];
}cmdh_select_sensor_groups_cmd_data_t;

typedef struct __attribute__ ((packed))
{
    uint8_t                sensor_groups[2];
}cmdh_select_sensor_groups_rsp_data_t;


errlHndl_t cmdh_tmgt_setmodestate(const cmdh_fsp_cmd_t * i_cmd_ptr,
                                        cmdh_fsp_rsp_t * i_rsp_ptr);

void cmdh_dbug_cmd (const cmdh_fsp_cmd_t * i_cmd_ptr,
                          cmdh_fsp_rsp_t * i_rsp_ptr);

errlHndl_t cmdh_tmgt_poll (const cmdh_fsp_cmd_t * i_cmd_ptr,
                                 cmdh_fsp_rsp_t * i_rsp_ptr);

errlHndl_t cmdh_clear_elog (const cmdh_fsp_cmd_t * i_cmd_ptr,
                                  cmdh_fsp_rsp_t * i_rsp_ptr);

errlHndl_t cmdh_amec_pass_through(const cmdh_fsp_cmd_t * i_cmd_ptr,
                                        cmdh_fsp_rsp_t * i_rsp_ptr);

errlHndl_t cmdh_reset_prep(const cmdh_fsp_cmd_t * i_cmd_ptr,
                                 cmdh_fsp_rsp_t * i_rsp_ptr);

errlHndl_t cmdh_tmgt_get_field_debug_data(const cmdh_fsp_cmd_t * i_cmd_ptr,
                                                cmdh_fsp_rsp_t * i_rsp_ptr);

errlHndl_t cmdh_set_user_pcap(const cmdh_fsp_cmd_t * i_cmd_ptr,
                                    cmdh_fsp_rsp_t * o_rsp_ptr);


//------------------------------------------------------------------------------------
// Commands supported via in-band interface must have additional inputs/output/return
// Any out of band commands that are to be supported in-band should change to this
// common format to allow calling by either i.e. AMESTER pass thru is supported on both
//------------------------------------------------------------------------------------
uint8_t cmdh_clear_sensor_data(const uint16_t  i_cmd_data_length,
                                    const uint8_t*  i_cmd_data_ptr,
                                    const uint16_t  i_max_rsp_data_length,
                                          uint16_t* o_rsp_data_length,
                                          uint8_t*  o_rsp_data_ptr);

uint8_t cmdh_set_pcap_inband(const uint16_t  i_cmd_data_length,
                                  const uint8_t*  i_cmd_data_ptr,
                                  const uint16_t  i_max_rsp_data_length,
                                        uint16_t* o_rsp_data_length,
                                        uint8_t*  o_rsp_data_ptr);

uint8_t cmdh_write_psr(const uint16_t  i_cmd_data_length,
                            const uint8_t*  i_cmd_data_ptr,
                            const uint16_t  i_max_rsp_data_length,
                                  uint16_t* o_rsp_data_length,
                                  uint8_t*  o_rsp_data_ptr);

uint8_t cmdh_select_sensor_groups(const uint16_t  i_cmd_data_length,
                                       const uint8_t*  i_cmd_data_ptr,
                                       const uint16_t  i_max_rsp_data_length,
                                             uint16_t* o_rsp_data_length,
                                             uint8_t*  o_rsp_data_ptr);

#endif

OpenPOWER on IntegriCloud