-
Notifications
You must be signed in to change notification settings - Fork 39
/
cmdh_fsp_cmds.c
executable file
·2308 lines (2048 loc) · 86.2 KB
/
cmdh_fsp_cmds.c
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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/occ_405/cmdh/cmdh_fsp_cmds.c $ */
/* */
/* OpenPOWER OnChipController Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] 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 */
#include "ssx.h"
#include "cmdh_service_codes.h"
#include "errl.h"
#include "trac.h"
#include "rtls.h"
#include "dcom.h"
#include "occ_common.h"
#include "state.h"
#include "cmdh_fsp_cmds.h"
#include "cmdh_dbug_cmd.h"
#include "proc_pstate.h"
#include "centaur_data.h"
#include <amec_data.h>
#include "amec_amester.h"
#include "amec_service_codes.h"
#include "amec_freq.h"
#include "amec_sys.h"
#include "sensor.h"
#include "sensor_query_list.h"
#include "chom.h"
#include "amec_master_smh.h"
#include <proc_data.h>
#include "homer.h"
#include <centaur_data.h>
#include <avsbus.h>
#include "wof.h"
#include "sensor_main_memory.h"
extern dimm_sensor_flags_t G_dimm_temp_expired_bitmap;
extern bool G_vrm_thermal_monitoring;
extern uint32_t G_first_proc_gpu_config;
extern bool G_vrm_vdd_temp_expired;
#include <gpe_export.h>
extern gpe_shared_data_t G_shared_gpe_data;
// This table contains tunable parameter information that can be exposed to
// customers (only Master OCC should access/control this table)
cmdh_tunable_param_table_t G_mst_tunable_parameter_table[CMDH_DEFAULT_TUNABLE_PARAM_NUM] =
{
{1, "Utilization threshold for increasing frequency", 3, 0, 980, 0, 1000},
{2, "Utilization threshold for decreasing frequency", 3, 0, 980, 0, 1000},
{3, "Number of samples for computing utilization statistics", 4, 0, 16, 1, 1024},
{4, "Step size for going up in frequency", 3, 0, 8, 1, 1000},
{5, "Step size for going down in frequency", 3, 0, 8, 1, 1000},
{6, "Delta percentage for determining active cores", 2, 0, 18, 0, 100 },
{7, "Utilization threshold to determine active cores with slack", 3, 0, 980, 0, 1000},
{8, "Enable/disable frequency delta between cores", 0, 0, 0, 0, 1 },
{9, "Maximum frequency delta between cores", 2, 0, 10, 10, 100 },
};
// The first two columns of this table are the default tunable parameter values
// and mutipliers.
cmdh_tunable_param_table_ext_t G_mst_tunable_parameter_table_ext[CMDH_DEFAULT_TUNABLE_PARAM_NUM] =
{
{980, 10, 9800},
{980, 10, 9800},
{16, 1, 16 },
{8, 1, 8 },
{8, 1, 8 },
{18, 100, 1800},
{980, 10, 980 },
{0, 1, 0 },
{10, 1, 10 },
};
// Flag to indicate that new tunable parameter values need to be written
// (=0: no new values available; =1: new values need to be written; =2: restore defaults)
uint8_t G_mst_tunable_parameter_overwrite = 0;
//Reverse association of channel to function.
uint8_t G_apss_ch_to_function[MAX_APSS_ADC_CHANNELS] = {0};
ERRL_RC cmdh_poll_v20 (cmdh_fsp_rsp_t * i_rsp_ptr);
// Function Specification
//
// Name: cmdh_tmgt_poll
//
// Description: Poll the OCC for OCC status, OCCs present
// system mode, error log ID, etc.
//
// End Function Specification
errlHndl_t cmdh_tmgt_poll (const cmdh_fsp_cmd_t * i_cmd_ptr,
cmdh_fsp_rsp_t * o_rsp_ptr)
{
errlHndl_t l_errlHndl = NULL;
cmdh_poll_query_t * l_poll_cmd = (cmdh_poll_query_t *) i_cmd_ptr;
ERRL_RC l_rc = ERRL_RC_INTERNAL_FAIL;
do
{
if (l_poll_cmd->version == CMDH_POLL_VERSION20)
{
l_rc = cmdh_poll_v20(o_rsp_ptr);
G_rsp_status = l_rc;
}
else
{
CMDH_TRAC_ERR("cmdh_tmgt_poll: Invalid version 0x%02X", l_poll_cmd->version);
l_rc = ERRL_RC_INVALID_DATA;
break;
}
} while(0);
if(l_rc)
{
// Build Error Response packet
cmdh_build_errl_rsp(i_cmd_ptr, o_rsp_ptr, l_rc, &l_errlHndl);
}
return l_errlHndl;
}
// Function Specification
//
// Name: cmdh_poll_v20
//
// Description: Used for version 0x20 poll calls from BMC/HTMGT.
//
// End Function Specification
ERRL_RC cmdh_poll_v20(cmdh_fsp_rsp_t * o_rsp_ptr)
{
ERRL_RC l_rc = ERRL_RC_INTERNAL_FAIL;
uint8_t k = 0, l_max_sensors = 0;
uint8_t l_err_hist_idx = 0, l_sens_list_idx = 0;
cmdh_poll_sensor_db_t l_sensorHeader;
// Set pointer to start of o_rsp_ptr
cmdh_poll_resp_v20_fixed_t * l_poll_rsp = (cmdh_poll_resp_v20_fixed_t *) o_rsp_ptr;
// Byte 1
l_poll_rsp->status.word = SMGR_validate_get_valid_states();
// Byte 2
l_poll_rsp->ext_status.word = 0;
//SET DVFS bits
for ( k = 0; k < MAX_NUM_CORES; k++ )
{
uint32_t l_freq_reason = g_amec->proc[0].core[k].f_reason;
if ( l_freq_reason & (AMEC_VOTING_REASON_PROC_THRM | AMEC_VOTING_REASON_VRHOT_THRM) )
{
l_poll_rsp->ext_status.dvfs_due_to_ot = 1;
}
if ( l_freq_reason & (AMEC_VOTING_REASON_PPB | AMEC_VOTING_REASON_PMAX | AMEC_VOTING_REASON_PWR) )
{
l_poll_rsp->ext_status.dvfs_due_to_pwr = 1;
}
}
//If memory is being throttled due to OverTemp or due to Failure to read sensors set mthrot_due_to_ot bit.
if (((g_amec->mem_throttle_reason == AMEC_MEM_VOTING_REASON_DIMM) ||
(g_amec->mem_throttle_reason == AMEC_MEM_VOTING_REASON_CENT)))
{
l_poll_rsp->ext_status.mthrot_due_to_ot = 1;
}
//If we are in oversubscription, set the N_power bit.
if( AMEC_INTF_GET_OVERSUBSCRIPTION() )
{
l_poll_rsp->ext_status.n_power = 1;
}
// TODO RTC 165947: Sync request bit set here
// Byte 3
l_poll_rsp->occ_pres_mask = G_sysConfigData.is_occ_present;
// Byte 4
l_poll_rsp->config_data = DATA_request_cnfgdata();
// Byte 5
l_poll_rsp->state = CURRENT_STATE();
// Byte 6
l_poll_rsp->mode = CURRENT_MODE();
// Byte 7
l_poll_rsp->ips_status.word = 0;
l_poll_rsp->ips_status.ips_enabled = G_ips_config_data.iv_ipsEnabled;
l_poll_rsp->ips_status.ips_active = AMEC_mst_get_ips_active_status();
// Byte 8:
l_poll_rsp->errl_id = getOldestErrlID();
// Byte 9 - 12:
l_poll_rsp->errl_address = getErrlOCIAddrByID(l_poll_rsp->errl_id);
// Byte 13 - 14:
l_poll_rsp->errl_length = getErrlLengthByID(l_poll_rsp->errl_id);
//If errl_id is not 0, then neither address or length should be zero.
//This should not happen, but if it does tmgt will create an error log that
//includes the data at the errl slot address given that can be used for debug.
//NOTE: One cause for a false errlog id is corruption of data in one errl slot
// due to writing data greater than the size of the previous slot. For
// example writing the CallHome errorlog (3kb) into a regular sized (2kb) slot.
// Make sure to verify the order of the memory allocation for the errl slots.
if ( (l_poll_rsp->errl_id != 0) &&
((l_poll_rsp->errl_address == 0) || (l_poll_rsp->errl_length == 0)))
{
TRAC_ERR("An error ID has been sent via poll but the address or size is 0. "
"ErrlId:0x%X, sz:0x%X, address:0x%X.",
l_poll_rsp->errl_id, l_poll_rsp->errl_length, l_poll_rsp->errl_address);
}
// Byte 15: reserved.
// Byte 16: GPU Configuration
l_poll_rsp->gpu_presence = (uint8_t)G_first_proc_gpu_config;
// Byte 17 - 32 (16 bytes): OCC level
memcpy( (void *) l_poll_rsp->occ_level, (void *) &G_occ_buildname[0], 16);
// Byte 33 - 38:
char l_sensor_ec[6] = "SENSOR";
memcpy( (void *) l_poll_rsp->sensor_ec, (void *) &l_sensor_ec[0], (size_t) sizeof(l_sensor_ec));
// Byte 39:
l_poll_rsp->sensor_dblock_count = 0;
// Byte 40:
l_poll_rsp->sensor_dblock_version = 0x01; //Currently only 0x01 is supported.
//l_rsp_index is used as an index into o_rsp_ptr
uint16_t l_rsp_index = CMDH_POLL_RESP_LEN_V20;
////////////////////
// TEMP sensors:
// Generate datablock header for temp sensors and sensor data.
// Set up the header
memset((void*) &l_sensorHeader, 0, (size_t)sizeof(cmdh_poll_sensor_db_t));
memcpy ((void *) &(l_sensorHeader.eyecatcher[0]), SENSOR_TEMP, 4);
l_sensorHeader.format = 0x02;
l_sensorHeader.length = sizeof(cmdh_poll_temp_sensor_t);
l_sensorHeader.count = 0;
//Initialize to max number of possible temperature sensors.
l_max_sensors = MAX_NUM_CORES + MAX_NUM_MEM_CONTROLLERS + (MAX_NUM_MEM_CONTROLLERS * NUM_DIMMS_PER_CENTAUR) + (MAX_NUM_GPU_PER_DOMAIN * 2);
l_max_sensors++; // +1 for VRM
cmdh_poll_temp_sensor_t l_tempSensorList[l_max_sensors];
memset(l_tempSensorList, 0x00, sizeof(l_tempSensorList));
// Add the core temperatures
for (k=0; k<MAX_NUM_CORES; k++)
{
if(CORE_PRESENT(k))
{
l_tempSensorList[l_sensorHeader.count].id = G_amec_sensor_list[TEMPPROCTHRMC0 + k]->ipmi_sid;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_PROC;
l_tempSensorList[l_sensorHeader.count].value = (G_amec_sensor_list[TEMPPROCTHRMC0 + k]->sample) & 0xFF;
l_sensorHeader.count++;
}
}
// Add the DIMM and centaur temperatures
uint8_t l_cent, l_port, l_dimm = 0;
if(G_sysConfigData.mem_type == MEM_TYPE_NIMBUS)
{
for (l_port=0; l_port < NUM_DIMM_PORTS; l_port++)
{
for(l_dimm=0; l_dimm < NUM_DIMMS_PER_CENTAUR; l_dimm++)
{
if (g_amec->proc[0].memctl[l_port].centaur.dimm_temps[l_dimm].temp_sid != 0)
{
l_tempSensorList[l_sensorHeader.count].id = g_amec->proc[0].memctl[l_port].centaur.dimm_temps[l_dimm].temp_sid;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_DIMM;
//If a dimm timed out long enough, we should return 0xFFFF for that sensor.
if (G_dimm_temp_expired_bitmap.bytes[l_port] & (DIMM_SENSOR0 >> l_dimm))
{
l_tempSensorList[l_sensorHeader.count].value = 0xFF;
}
else
{
l_tempSensorList[l_sensorHeader.count].value = (g_amec->proc[0].memctl[l_port].centaur.dimm_temps[l_dimm].cur_temp) & 0xFF;
}
l_sensorHeader.count++;
}
}
}
}
else if (G_sysConfigData.mem_type == MEM_TYPE_CUMULUS)
{
for (l_cent=0; l_cent < MAX_NUM_MEM_CONTROLLERS; l_cent++)
{
if (CENTAUR_PRESENT(l_cent))
{
//Add entry for centaurs.
l_tempSensorList[l_sensorHeader.count].id = g_amec->proc[0].memctl[l_cent].centaur.temp_sid;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_CENTAUR;
if (G_cent_timeout_logged_bitmap & (CENTAUR0_PRESENT_MASK >> l_cent))
{
l_tempSensorList[l_sensorHeader.count].value = 0xFF;
}
else
{
l_tempSensorList[l_sensorHeader.count].value = (g_amec->proc[0].memctl[l_cent].centaur.centaur_hottest.cur_temp) & 0xFF;
}
l_sensorHeader.count++;
//Add entries for present dimms associated with current centaur l_cent.
for(l_dimm=0; l_dimm < NUM_DIMMS_PER_CENTAUR; l_dimm++)
{
if (g_amec->proc[0].memctl[l_cent].centaur.dimm_temps[l_dimm].temp_sid != 0)
{
l_tempSensorList[l_sensorHeader.count].id = g_amec->proc[0].memctl[l_cent].centaur.dimm_temps[l_dimm].temp_sid;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_DIMM;
//If a dimm timed out long enough, we should return 0xFFFF for that sensor.
if (G_dimm_temp_expired_bitmap.bytes[l_cent] & (DIMM_SENSOR0 >> l_dimm))
{
l_tempSensorList[l_sensorHeader.count].value = 0xFF;
}
else
{
l_tempSensorList[l_sensorHeader.count].value = (g_amec->proc[0].memctl[l_cent].centaur.dimm_temps[l_dimm].cur_temp & 0xFF);
}
l_sensorHeader.count++;
}
}
}
}
}
if (G_vrm_thermal_monitoring)
{
// Add VRFAN
const sensor_t *vrfan = getSensorByGsid(VRMPROCOT);
if (vrfan != NULL)
{
l_tempSensorList[l_sensorHeader.count].id = 0;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_VRM_OT_STATUS;
l_tempSensorList[l_sensorHeader.count].value = vrfan->sample & 0xFF;
l_sensorHeader.count++;
}
}
if (G_avsbus_vdd_monitoring)
{
// Add Vdd temp
const sensor_t *tempvdd = getSensorByGsid(TEMPVDD);
if (tempvdd != NULL)
{
l_tempSensorList[l_sensorHeader.count].id = AMECSENSOR_PTR(TEMPVDD)->ipmi_sid;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_VRM_VDD;
if (G_vrm_vdd_temp_expired)
{
l_tempSensorList[l_sensorHeader.count].value = 0xFF;
}
else
{
l_tempSensorList[l_sensorHeader.count].value = tempvdd->sample & 0xFF;
}
l_sensorHeader.count++;
}
}
// Add GPU temperatures
for (k=0; k<MAX_NUM_GPU_PER_DOMAIN; k++)
{
if(GPU_PRESENT(k))
{
// GPU core temperature
l_tempSensorList[l_sensorHeader.count].id = G_amec_sensor_list[TEMPGPU0 + k]->ipmi_sid;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_GPU;
if(g_amec->gpu[k].status.coreTempFailure)
{
// failed to read core temperature return 0xFF
l_tempSensorList[l_sensorHeader.count].value = 0xFF;
}
else if(g_amec->gpu[k].status.coreTempNotAvailable)
{
// core temperature not available return 0
l_tempSensorList[l_sensorHeader.count].value = 0;
}
else
{
// have a good core temperature return the reading
l_tempSensorList[l_sensorHeader.count].value = (G_amec_sensor_list[TEMPGPU0 + k]->sample) & 0xFF;
}
l_sensorHeader.count++;
// GPU memory temperature
l_tempSensorList[l_sensorHeader.count].id = G_amec_sensor_list[TEMPGPU0MEM + k]->ipmi_sid;
l_tempSensorList[l_sensorHeader.count].fru_type = DATA_FRU_GPU_MEM;
if(g_amec->gpu[k].status.memTempFailure)
{
// failed to read memory temperature return 0xFF
l_tempSensorList[l_sensorHeader.count].value = 0xFF;
}
else if(g_amec->gpu[k].status.memTempNotAvailable)
{
// memory temperature not available return 0
l_tempSensorList[l_sensorHeader.count].value = 0;
}
else
{
// have a good memory temperature return the reading
l_tempSensorList[l_sensorHeader.count].value = (G_amec_sensor_list[TEMPGPU0MEM + k]->sample) & 0xFF;
}
l_sensorHeader.count++;
}
}
// Copy header first.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)&l_sensorHeader, sizeof(l_sensorHeader));
// Increment index into response buffer.
l_rsp_index += sizeof(l_sensorHeader);
l_poll_rsp->sensor_dblock_count +=1;
// Write data to resp buffer if any.
if (l_sensorHeader.count)
{
uint8_t l_sensordataSz = l_sensorHeader.count * l_sensorHeader.length;
// Copy sensor data into response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)l_tempSensorList, l_sensordataSz);
// Increment index into response buffer.
l_rsp_index += l_sensordataSz;
}
///////////////////
// FREQ Sensors:
// Generate datablock header for freq sensors and sensor data.
memset((void*) &l_sensorHeader, 0, (size_t)sizeof(cmdh_poll_sensor_db_t));
memcpy ((void *) &(l_sensorHeader.eyecatcher[0]), SENSOR_FREQ, 4);
l_sensorHeader.format = 0x02;
l_sensorHeader.length = sizeof(cmdh_poll_freq_sensor_t);
l_sensorHeader.count = 0;
cmdh_poll_freq_sensor_t l_freqSensorList[MAX_NUM_CORES];
for (k=0; k<MAX_NUM_CORES; k++)
{
if(CORE_PRESENT(k))
{
l_freqSensorList[l_sensorHeader.count].id = G_amec_sensor_list[FREQAC0 + k]->ipmi_sid;
l_freqSensorList[l_sensorHeader.count].value = G_amec_sensor_list[FREQAC0 + k]->sample;
l_sensorHeader.count++;
}
}
// Copy header to response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)&l_sensorHeader, sizeof(l_sensorHeader));
//Increment index into response buffer.
l_rsp_index += sizeof(l_sensorHeader);
l_poll_rsp->sensor_dblock_count +=1;
// Write data to outbuffer if any.
if (l_sensorHeader.count)
{
uint8_t l_sensordataSz = l_sensorHeader.count * l_sensorHeader.length;
// Copy sensor data into response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)l_freqSensorList, l_sensordataSz);
// Increment index into response buffer.
l_rsp_index += l_sensordataSz;
}
/////////////////////
// POWR Sensors:
// Generate datablock header for power sensors and sensor data.
// If APSS is present return format version 0x02 by MASTER ONLY.
// If no APSS present return format version 0xA0 by all OCCs.
if ( (G_occ_role == OCC_MASTER) && (G_pwr_reading_type == PWR_READING_TYPE_APSS) )
{
memset((void*) &l_sensorHeader, 0, (size_t)sizeof(cmdh_poll_sensor_db_t));
memcpy ((void *) &(l_sensorHeader.eyecatcher[0]), SENSOR_POWR, 4);
l_sensorHeader.format = 0x02;
l_sensorHeader.length = sizeof(cmdh_poll_power_sensor_t);
l_sensorHeader.count = 0;
// Generate sensor list.
cmdh_poll_power_sensor_t l_pwrSensorList[MAX_APSS_ADC_CHANNELS];
for (k = 0; k < MAX_APSS_ADC_CHANNELS; k++)
{
if ((G_apss_ch_to_function[k] != ADC_12V_SENSE) &&
(G_apss_ch_to_function[k] != ADC_GND_REMOTE_SENSE) &&
(G_apss_ch_to_function[k] != ADC_12V_STANDBY_CURRENT))
{
l_pwrSensorList[l_sensorHeader.count].id = G_amec_sensor_list[PWRAPSSCH0 + k]->ipmi_sid;
l_pwrSensorList[l_sensorHeader.count].function_id = G_apss_ch_to_function[k];
l_pwrSensorList[l_sensorHeader.count].apss_channel = k;
l_pwrSensorList[l_sensorHeader.count].reserved = 0;
l_pwrSensorList[l_sensorHeader.count].current = G_amec_sensor_list[PWRAPSSCH0 + k]->sample;
l_pwrSensorList[l_sensorHeader.count].accumul = G_amec_sensor_list[PWRAPSSCH0 + k]->accumulator;
l_pwrSensorList[l_sensorHeader.count].update_tag = G_amec_sensor_list[PWRAPSSCH0 + k]->update_tag;
l_sensorHeader.count++;
}
}
// Copy header to response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)&l_sensorHeader, sizeof(l_sensorHeader));
// Increment index into response buffer.
l_rsp_index += sizeof(l_sensorHeader);
l_poll_rsp->sensor_dblock_count +=1;
// Write data to resp buffer if any.
if (l_sensorHeader.count)
{
uint16_t l_sensordataSz = l_sensorHeader.count * l_sensorHeader.length;
// Copy sensor data into response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)l_pwrSensorList, l_sensordataSz);
// Increment index into response buffer.
l_rsp_index += l_sensordataSz;
}
}
else if (G_pwr_reading_type != PWR_READING_TYPE_APSS)
{
memset((void*) &l_sensorHeader, 0, (size_t)sizeof(cmdh_poll_sensor_db_t));
memcpy ((void *) &(l_sensorHeader.eyecatcher[0]), SENSOR_POWR, 4);
l_sensorHeader.format = 0xA0;
l_sensorHeader.length = sizeof(cmdh_poll_power_no_apss_sensor_t);
l_sensorHeader.count = 1;
cmdh_poll_power_no_apss_sensor_t l_pwrData;
memset((void*) &l_pwrData, 0, (size_t)sizeof(cmdh_poll_power_no_apss_sensor_t));
// if there is a non-APSS chip for system power fill in system power else return 0's
if(G_pwr_reading_type != PWR_READING_TYPE_NONE)
{
l_pwrData.sys_pwr_id = G_amec_sensor_list[PWRSYS]->ipmi_sid;
l_pwrData.sys_pwr_update_time = G_mics_per_tick; // system power is read every tick
l_pwrData.sys_pwr_current = G_amec_sensor_list[PWRSYS]->sample;
l_pwrData.sys_pwr_update_tag = G_amec_sensor_list[PWRSYS]->update_tag;
l_pwrData.sys_pwr_accumul = G_amec_sensor_list[PWRSYS]->accumulator;
}
// Proc power is from AVS bus, return readings if reading Vdd and Vdn else return 0's
if( (G_avsbus_vdd_monitoring) && (G_avsbus_vdn_monitoring) )
{
// when no APSS present proc readings are updated based on AVS timing use PWRVDD/N timing (2 ticks)
l_pwrData.proc_pwr_update_time = G_mics_per_tick * 2;
l_pwrData.proc_pwr_current = G_amec_sensor_list[PWRPROC]->sample;
l_pwrData.proc_pwr_update_tag = G_amec_sensor_list[PWRPROC]->update_tag;
l_pwrData.proc_pwr_accumul = G_amec_sensor_list[PWRPROC]->accumulator;
l_pwrData.vdd_pwr_current = G_amec_sensor_list[PWRVDD]->sample;
l_pwrData.vdd_pwr_update_tag = G_amec_sensor_list[PWRVDD]->update_tag;
l_pwrData.vdd_pwr_accumul = G_amec_sensor_list[PWRVDD]->accumulator;
l_pwrData.vdn_pwr_current = G_amec_sensor_list[PWRVDN]->sample;
l_pwrData.vdn_pwr_update_tag = G_amec_sensor_list[PWRVDN]->update_tag;
l_pwrData.vdn_pwr_accumul = G_amec_sensor_list[PWRVDN]->accumulator;
}
// Copy header to response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]),
(void *)&l_sensorHeader, sizeof(l_sensorHeader));
// Increment index into response buffer.
l_rsp_index += sizeof(l_sensorHeader);
// Copy sensor data into response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]),
(void *)&(l_pwrData), sizeof(cmdh_poll_power_no_apss_sensor_t));
// Increment index into response buffer.
l_rsp_index += sizeof(cmdh_poll_power_no_apss_sensor_t);
l_poll_rsp->sensor_dblock_count +=1;
}
////////////////////////
// POWER CAPS:
// Generate datablock header for power caps. RETURNED by MASTER ONLY.
if (G_occ_role == OCC_MASTER)
{
memset((void*) &l_sensorHeader, 0, (size_t)sizeof(cmdh_poll_sensor_db_t));
memcpy ((void *) &(l_sensorHeader.eyecatcher[0]), SENSOR_CAPS, 4);
l_sensorHeader.format = 0x03;
l_sensorHeader.length = sizeof(cmdh_poll_pcaps_sensor_t);
l_sensorHeader.count = 1;
cmdh_poll_pcaps_sensor_t l_pcapData;
memset((void*) &l_pcapData, 0, (size_t)sizeof(cmdh_poll_pcaps_sensor_t));
// Return 0's for power cap section if there is no system power reading
// OCC can't support power capping without knowing the system power
if(G_pwr_reading_type != PWR_READING_TYPE_NONE)
{
l_pcapData.current = g_amec->pcap.active_node_pcap;
l_pcapData.system = G_amec_sensor_list[PWRSYS]->sample;
l_pcapData.n = G_sysConfigData.pcap.oversub_pcap;
l_pcapData.max = G_sysConfigData.pcap.max_pcap;
l_pcapData.hard_min = G_sysConfigData.pcap.hard_min_pcap;
l_pcapData.soft_min = G_sysConfigData.pcap.soft_min_pcap;
l_pcapData.user = G_sysConfigData.pcap.current_pcap;
l_pcapData.source = G_sysConfigData.pcap.source;
}
// Copy header to response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]),
(void *)&l_sensorHeader, sizeof(l_sensorHeader));
// Increment index into response buffer.
l_rsp_index += sizeof(l_sensorHeader);
// Copy sensor data into response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]),
(void *)&(l_pcapData), sizeof(cmdh_poll_pcaps_sensor_t));
// Increment index into response buffer.
l_rsp_index += sizeof(cmdh_poll_pcaps_sensor_t);
l_poll_rsp->sensor_dblock_count +=1;
}
///////////////////
// EXTN Sensors:
// Generate datablock header for freq sensors and sensor data.
memset((void*) &l_sensorHeader, 0, (size_t)sizeof(cmdh_poll_sensor_db_t));
memcpy ((void *) &(l_sensorHeader.eyecatcher[0]), SENSOR_EXTN, 4);
l_sensorHeader.format = 0x01;
l_sensorHeader.length = sizeof(cmdh_poll_extn_sensor_t);
l_sensorHeader.count = 0;
cmdh_poll_extn_sensor_t l_extnSensorList[MAX_EXTN_SENSORS] = {{0}};
l_extnSensorList[l_sensorHeader.count].name = EXTN_NAME_FMIN;
uint16_t freq = G_sysConfigData.sys_mode_freq.table[OCC_MODE_MIN_FREQUENCY];
l_extnSensorList[l_sensorHeader.count].data[0] = proc_freq2pstate(freq);
l_extnSensorList[l_sensorHeader.count].data[1] = CONVERT_UINT16_UINT8_HIGH(freq);
l_extnSensorList[l_sensorHeader.count].data[2] = CONVERT_UINT16_UINT8_LOW(freq);
l_sensorHeader.count++;
l_extnSensorList[l_sensorHeader.count].name = EXTN_NAME_FNOM;
freq = G_sysConfigData.sys_mode_freq.table[OCC_MODE_NOMINAL];
l_extnSensorList[l_sensorHeader.count].data[0] = proc_freq2pstate(freq);
l_extnSensorList[l_sensorHeader.count].data[1] = CONVERT_UINT16_UINT8_HIGH(freq);
l_extnSensorList[l_sensorHeader.count].data[2] = CONVERT_UINT16_UINT8_LOW(freq);
l_sensorHeader.count++;
l_extnSensorList[l_sensorHeader.count].name = EXTN_NAME_FTURBO;
freq = G_sysConfigData.sys_mode_freq.table[OCC_MODE_TURBO];
if (freq > 0)
{
l_extnSensorList[l_sensorHeader.count].data[0] = proc_freq2pstate(freq);
l_extnSensorList[l_sensorHeader.count].data[1] = CONVERT_UINT16_UINT8_HIGH(freq);
l_extnSensorList[l_sensorHeader.count].data[2] = CONVERT_UINT16_UINT8_LOW(freq);
}
l_sensorHeader.count++;
l_extnSensorList[l_sensorHeader.count].name = EXTN_NAME_FUTURBO;
freq = G_sysConfigData.sys_mode_freq.table[OCC_MODE_UTURBO];
if (freq > 0)
{
l_extnSensorList[l_sensorHeader.count].data[0] = proc_freq2pstate(freq);
l_extnSensorList[l_sensorHeader.count].data[1] = CONVERT_UINT16_UINT8_HIGH(freq);
l_extnSensorList[l_sensorHeader.count].data[2] = CONVERT_UINT16_UINT8_LOW(freq);
}
l_sensorHeader.count++;
// add any non-0 error history counts
for(l_err_hist_idx=0; l_err_hist_idx < ERR_HISTORY_SIZE; l_err_hist_idx++)
{
if(G_error_history[l_err_hist_idx])
{
if(l_sens_list_idx == 0)
{
// first one to add fill in name
l_extnSensorList[l_sensorHeader.count].name = EXTN_NAME_ERRHIST;
l_extnSensorList[l_sensorHeader.count].data[l_sens_list_idx] = l_err_hist_idx;
l_sens_list_idx++;
l_extnSensorList[l_sensorHeader.count].data[l_sens_list_idx] = G_error_history[l_err_hist_idx];
l_sens_list_idx++;
}
else if(l_sens_list_idx < 5) // room in current extended error history sensor?
{
l_extnSensorList[l_sensorHeader.count].data[l_sens_list_idx] = l_err_hist_idx;
l_sens_list_idx++;
l_extnSensorList[l_sensorHeader.count].data[l_sens_list_idx] = G_error_history[l_err_hist_idx];
l_sens_list_idx++;
}
else // no room start another extended error history sensor
{
l_sensorHeader.count++;
l_extnSensorList[l_sensorHeader.count].name = EXTN_NAME_ERRHIST;
l_sens_list_idx = 0;
l_extnSensorList[l_sensorHeader.count].data[l_sens_list_idx] = l_err_hist_idx;
l_sens_list_idx++;
l_extnSensorList[l_sensorHeader.count].data[l_sens_list_idx] = G_error_history[l_err_hist_idx];
l_sens_list_idx++;
}
}
}
if(l_sens_list_idx)
{
l_sensorHeader.count++;
}
// Copy header to response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)&l_sensorHeader, sizeof(l_sensorHeader));
//Increment index into response buffer.
l_rsp_index += sizeof(l_sensorHeader);
l_poll_rsp->sensor_dblock_count +=1;
// Write data to outbuffer if any.
if (l_sensorHeader.count)
{
uint8_t l_sensordataSz = l_sensorHeader.count * l_sensorHeader.length;
// Copy sensor data into response buffer.
memcpy ((void *) &(o_rsp_ptr->data[l_rsp_index]), (void *)l_extnSensorList, l_sensordataSz);
// Increment index into response buffer.
l_rsp_index += l_sensordataSz;
}
l_poll_rsp->data_length[0] = CONVERT_UINT16_UINT8_HIGH(l_rsp_index);
l_poll_rsp->data_length[1] = CONVERT_UINT16_UINT8_LOW(l_rsp_index);
l_rc = ERRL_RC_SUCCESS;
// Response status is returned (must be written to rsp buffer last)
return l_rc;
}
// Function Specification
//
// Name: cmdh_reset_prep_t
//
// Description: Process reset prep command
//
// End Function Specification
errlHndl_t cmdh_reset_prep (const cmdh_fsp_cmd_t * i_cmd_ptr,
cmdh_fsp_rsp_t * o_rsp_ptr)
{
errlHndl_t l_errlHndl = NULL;
cmdh_reset_prep_t * l_cmd_ptr = (cmdh_reset_prep_t *) i_cmd_ptr;
ERRL_RC l_rc = ERRL_RC_SUCCESS;
bool l_ffdc = FALSE;
G_rsp_status = ERRL_RC_SUCCESS;
o_rsp_ptr->data_length[0] = 0;
o_rsp_ptr->data_length[1] = 0;
do
{
// Command Length Check - make sure we at least have a version number
if( CMDH_DATALEN_FIELD_UINT16(i_cmd_ptr) < CMDH_RESET_PREP_MIN_DATALEN)
{
l_rc = ERRL_RC_INVALID_CMD_LEN;
break;
}
// Version Number Check
if(l_cmd_ptr->version != CMDH_RESET_PREP_VERSION)
{
l_rc = ERRL_RC_INVALID_DATA;
break;
}
TRAC_IMP("cmdh_reset_prep: Prep for reset command received! reason[0x%.2X]",
l_cmd_ptr->reason);
// Command Handling
switch( l_cmd_ptr->reason )
{
case CMDH_PREP_NONFAILURE:
// No FFDC Error Log Needed
l_rc = ERRL_RC_SUCCESS;
break;
case CMDH_PREP_FAILON_THISOCC:
l_ffdc = TRUE;
l_rc = ERRL_RC_SUCCESS;
break;
case CMDH_PREP_FAILON_OTHEROCC:
// If OCC is master, we may want to generate FFDC log
if (G_occ_role == OCC_MASTER)
{
l_ffdc = TRUE;
}
l_rc = ERRL_RC_SUCCESS;
break;
case CMDH_PREP_FAILON_OTHERNODE:
// No FFDC Error Log Needed
l_rc = ERRL_RC_SUCCESS;
break;
case CMDH_PREP_POWER_OFF:
// System powering off, stop DCOM and other tasks that still run in standby
rtl_stop_task(TASK_ID_DCOM_WAIT_4_MSTR);
rtl_stop_task(TASK_ID_DCOM_RX_INBX);
rtl_stop_task(TASK_ID_DCOM_TX_INBX);
rtl_stop_task(TASK_ID_DCOM_RX_OUTBX);
rtl_stop_task(TASK_ID_DCOM_TX_OUTBX);
rtl_stop_task(TASK_ID_DCOM_PARSE_FW_MSG);
rtl_stop_task(TASK_ID_MISC_405_CHECKS);
rtl_stop_task(TASK_ID_POKE_WDT);
l_rc = ERRL_RC_SUCCESS;
break;
default:
l_rc = ERRL_RC_INVALID_DATA;
break;
}
// Generate FFDC error log if required
if (TRUE == l_ffdc)
{
/* @
* @errortype
* @moduleid DATA_GET_RESET_PREP_ERRL
* @reasoncode PREP_FOR_RESET
* @userdata1 reset reason
* @userdata2 0
* @userdata4 0
* @devdesc Generate error log for ResetPrep command
*/
l_errlHndl = createErrl(
DATA_GET_RESET_PREP_ERRL, //modId
PREP_FOR_RESET, //reasoncode
OCC_NO_EXTENDED_RC, //Extended reason code
ERRL_SEV_INFORMATIONAL, //Severity
NULL, //Trace Buf
CMDH_RESET_PREP_TRACE_SIZE, //Trace Size
l_cmd_ptr->reason, //userdata1
0 //userdata2
);
// commit error log
if (l_errlHndl != NULL)
{
commitErrl(&l_errlHndl);
}
}
if (G_sysConfigData.system_type.kvm && isSafeStateRequested() &&
(l_cmd_ptr->reason != CMDH_PREP_POWER_OFF))
{
// Notify dcom thread to update opal table
ssx_semaphore_post(&G_dcomThreadWakeupSem);
}
if (CURRENT_STATE() != OCC_STATE_STANDBY)
{
// Put OCC in stand-by state
l_errlHndl = SMGR_set_state(OCC_STATE_STANDBY);
}
if(l_errlHndl)
{
// Commit error log for the failed transition
commitErrl(&l_errlHndl);
TRAC_ERR("cmdh_reset_prep: Failed to transition to stand-by state!");
l_rc = ERRL_RC_INTERNAL_FAIL;
}
else
{
// Prevent the OCC from going back to the original state it was
// prior to the reset prep command
if (G_occ_role == OCC_MASTER)
{
G_occ_external_req_state = OCC_STATE_STANDBY;
}
}
} while(0);
G_rsp_status = l_rc;
if(ERRL_RC_SUCCESS != l_rc)
{
// Build Error Response packet
cmdh_build_errl_rsp(i_cmd_ptr, o_rsp_ptr, l_rc, &l_errlHndl);
}
return l_errlHndl;
}
// Function Specification
//
// Name: cmdh_clear_elog
//
// Description: Clear elog and free up entry
//
// End Function Specification
errlHndl_t cmdh_clear_elog (const cmdh_fsp_cmd_t * i_cmd_ptr,
cmdh_fsp_rsp_t * o_rsp_ptr)
{
cmdh_clear_elog_query_t *l_cmd_ptr = (cmdh_clear_elog_query_t *) i_cmd_ptr;
uint8_t l_SlotNum = ERRL_INVALID_SLOT;
errlHndl_t l_err = INVALID_ERR_HNDL;
errlHndl_t l_oci_address = INVALID_ERR_HNDL;
o_rsp_ptr->data_length[0] = 0;
o_rsp_ptr->data_length[1] = 0;
// Get Errl Array index
l_SlotNum = getErrSlotNumByErrId(l_cmd_ptr->elog_id);
// Get ERRL address
l_oci_address = (errlHndl_t)getErrSlotOCIAddr(l_SlotNum);
if ((l_oci_address != NULL) &&
(l_oci_address != INVALID_ERR_HNDL))
{
// clear only one Errl by ID
l_err = deleteErrl(&l_oci_address);
}
if (l_err == NULL)
{
G_rsp_status = ERRL_RC_SUCCESS;
}
else
{
/// Build Error Response packet
cmdh_build_errl_rsp(i_cmd_ptr, o_rsp_ptr, ERRL_RC_INVALID_DATA, &l_err);
}
return l_err;
}
// Function Specification
//
// Name: cmdh_dbug_get_trace
//
// Description: Process get trace command
//
// End Function Specification
void cmdh_dbug_get_trace (const cmdh_fsp_cmd_t * i_cmd_ptr,
cmdh_fsp_rsp_t * o_rsp_ptr)
{
UINT l_rc = 0;
UINT l_trace_buffer_size = CMDH_FSP_RSP_SIZE-CMDH_DBUG_FSP_RESP_LEN-8; // tmgt reserved 8 bytes
UINT16 l_trace_size = 0;
cmdh_dbug_get_trace_query_t *l_get_trace_query_ptr = (cmdh_dbug_get_trace_query_t*) i_cmd_ptr;
cmdh_dbug_get_trace_resp_t *l_get_trace_resp_ptr = (cmdh_dbug_get_trace_resp_t*) o_rsp_ptr;
if (memcmp((char *)l_get_trace_query_ptr->comp, "GP", 2) == 0)
{
// Return a GPE0/GPE1 trace buffer
if (l_get_trace_query_ptr->comp[2] == '0')
{
if (G_shared_gpe_data.gpe0_tb_ptr != 0)
{
l_trace_size = G_shared_gpe_data.gpe0_tb_sz;
memcpy(l_get_trace_resp_ptr->data, (uint8_t*)G_shared_gpe_data.gpe0_tb_ptr, (size_t)l_trace_size);
}
}
else if (l_get_trace_query_ptr->comp[2] == '1')
{
if (G_shared_gpe_data.gpe0_tb_ptr != 0)
{
l_trace_size = G_shared_gpe_data.gpe1_tb_sz;
memcpy(l_get_trace_resp_ptr->data, (uint8_t*)G_shared_gpe_data.gpe1_tb_ptr, (size_t)l_trace_size);
}
}
else l_rc = 255;
}
else
{
// Return a 405 trace buffer
const trace_descriptor_array_t* l_trace_ptr = TRAC_get_td((char *)l_get_trace_query_ptr->comp);
l_rc = TRAC_get_buffer_partial(l_trace_ptr, l_get_trace_resp_ptr->data,&l_trace_buffer_size);
l_trace_size = l_trace_buffer_size;
}
if(l_rc==0)
{
G_rsp_status = ERRL_RC_SUCCESS;
o_rsp_ptr->data_length[0] = CONVERT_UINT16_UINT8_HIGH(l_trace_size);
o_rsp_ptr->data_length[1] = CONVERT_UINT16_UINT8_LOW(l_trace_size);
}
else
{
G_rsp_status = ERRL_RC_INTERNAL_FAIL;
o_rsp_ptr->data_length[0] = 0;
o_rsp_ptr->data_length[1] = 0;
}
}
// Function Specification
//
// Name: cmdh_dbug_get_ame_sensor
//
// Description: Process get sensor data command
//
// End Function Specification
void cmdh_dbug_get_ame_sensor (const cmdh_fsp_cmd_t * i_cmd_ptr,
cmdh_fsp_rsp_t * o_rsp_ptr)
{
uint8_t l_rc = ERRL_RC_SUCCESS;
uint16_t l_type = 0;
uint16_t l_location = 0;
uint16_t i = 0;
uint16_t l_resp_data_length = 0;
uint16_t l_num_of_sensors = CMDH_DBUG_MAX_NUM_SENSORS;