-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathsdr.c
More file actions
710 lines (609 loc) · 23.9 KB
/
sdr.c
File metadata and controls
710 lines (609 loc) · 23.9 KB
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
/*
* openMMC -- Open Source modular IPM Controller firmware
*
* Copyright (C) Vahan Petrosyan <vahan_petrosyan@desy.de>
* Copyright (C) Frederic Bompard (CPPM)
* Copyright (C) Paschalis Vichoudis (CERN)
* Copyright (C) Markus Joos <markus.joos@cern.ch>
* Copyright (C) Julian Mendez <julian.mendez@cern.ch>
* Copyright (C) 2015 Piotr Miedzik <P.Miedzik@gsi.de>
* Copyright (C) 2015-2016 Henrique Silva <henrique.silva@lnls.br>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
*/
/* FreeRTOS Includes */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/* Project Includes */
#include "sdr.h"
#include "port.h"
#include "sensors.h"
#include "ipmi.h"
#include "fpga_spi.h"
volatile uint8_t sdr_count = 0;
sensor_t *sdr_head = NULL;
sensor_t *sdr_tail = NULL;
static uint16_t reservationID;
static uint32_t sdr_change_count;
uint8_t compare_val(uint8_t val1, uint8_t val2, uint8_t comp, uint8_t sign)
{
if(sign == SIGNED) {
switch(comp) {
case UPPER_EQ:
return (((int8_t)val1) >= ((int8_t)val2));
case LOWER_EQ:
return (((int8_t)val1) <= ((int8_t)val2));
}
} else {
switch(comp){
case UPPER_EQ:
return ((val1) >= (val2));
case LOWER_EQ:
return ((val1) <= (val2));
}
}
return 0x00;
}
size_t sdr_get_size_by_type(SDR_TYPE type)
{
switch (type) {
case TYPE_01:
return sizeof(SDR_type_01h_t);
case TYPE_02:
return sizeof(SDR_type_02h_t);
case TYPE_12:
return sizeof(SDR_type_12h_t);
default:
return 0;
}
}
size_t sdr_get_size_by_entry(sensor_t * entry)
{
if (entry == NULL) {
return 0;
}
return sdr_get_size_by_type(entry->sdr_type);
}
void sensor_init( void )
{
/* This function must be provided by the board port */
amc_sdr_init();
#ifdef MODULE_RTM
rtm_sdr_init();
#endif
#ifdef MODULE_HOTSWAP
hotswap_init();
#else
#define vTaskHotSwap_Handle NULL
#endif
#ifdef MODULE_LM75
LM75_init();
#endif
#ifdef MODULE_MAX6642
MAX6642_init();
#endif
#if defined(MODULE_INA220_CURRENT) || defined(MODULE_INA220_VOLTAGE)
ina220_init();
#endif
#ifdef MODULE_STM32F3_ADC
STM32F3_ADC_init();
#endif
}
void sdr_init( void )
{
sdr_head = NULL;
sdr_tail = NULL;
/* Populate AMC SDR Device Locator Record */
sdr_head = sdr_insert_entry( TYPE_12, (void *) &SDR0, NULL, 0, 0 );
#ifdef MODULE_RTM
sdr_insert_entry( TYPE_12, (void *) &SDR_RTM_DEV_LOCATOR, NULL, 0, 0 );
#endif
}
sensor_t * sdr_insert_entry( SDR_TYPE type, void * sdr, TaskHandle_t *monitor_task, uint8_t diag_id, uint8_t chipid )
{
uint8_t sdr_len = sdr_get_size_by_type(type);
sensor_t * entry = pvPortMalloc( sizeof(sensor_t) );
memset( entry, 0, sizeof(sensor_t) );
entry->num = sdr_count;
entry->sdr_type = type;
entry->sdr = sdr;
entry->sdr_length = sdr_len;
entry->task_handle = monitor_task;
entry->diag_devID = diag_id;
entry->chipid = chipid;
entry->ownerID = ipmb_addr;
entry->entityinstance = 0x60 | ((ipmb_addr - 0x70) >> 1);
entry->readout_value = 0;
entry->state = SENSOR_STATE_LOW_NON_REC;
entry->event_scan = 0xC0; /* Start with sensor enabled */
/* Link the sdr list */
if (sdr_tail) {
sdr_tail->next = entry;
}
sdr_tail = entry;
entry->next = NULL;
sdr_count++;
sdr_change_count++;
return entry;
}
sensor_t * find_sensor_by_sdr( void * sdr )
{
sensor_t * cur;
for ( cur = sdr_head; cur != NULL; cur = cur->next ) {
if (cur->sdr == sdr) {
return cur;
}
}
return NULL;
}
sensor_t * find_sensor_by_id( uint8_t id )
{
sensor_t * cur;
for ( cur = sdr_head; cur != NULL; cur = cur->next ) {
if (cur->num == id) {
return cur;
}
}
return NULL;
}
void sdr_remove_entry( sensor_t * entry )
{
sensor_t * cur = sdr_head;
sensor_t * prev = NULL;
if (entry == sdr_head) {
sdr_pop();
}
while (cur != entry) {
prev = cur;
cur = cur->next;
if (cur == NULL) {
/* We reached the end of the list and didn't find the entry */
return;
}
}
/* Relink the table */
prev->next = cur->next;
sdr_count--;
sdr_change_count++;
/* Free the entry */
vPortFree(cur);
}
void sdr_pop( void )
{
sensor_t * new_head;
if ( sdr_head ) {
new_head = sdr_head->next;
vPortFree( sdr_head );
sdr_head = new_head;
}
}
void sensor_enable(sensor_t *sensor)
{
sensor->event_scan = 0xC0;
}
void sensor_disable(sensor_t *sensor)
{
sensor->event_scan = 0x00;
}
/******************************/
/* IPMI SDR Commands handlers */
/******************************/
IPMI_HANDLER(ipmi_se_get_sdr_info, NETFN_SE, IPMI_GET_DEVICE_SDR_INFO_CMD, ipmi_msg *req, ipmi_msg *rsp) {
int len = rsp->data_len = 0;
if (req->data_len == 0 || req->data[0] == 0) {
/* Return number of sensors only (minus the dev locator fields) */
#ifdef MODULE_RTM
rsp->data[len++] = sdr_count-3;
#else
rsp->data[len++] = sdr_count-2;
#endif
} else {
/* Return number of SDR entries */
rsp->data[len++] = sdr_count-1;
}
/* Static Sensor population and LUN 0 has sensors (LUN 1 also if RTM is present) */
#ifdef MODULE_RTM
rsp->data[len++] = (1 << 1) | (1 << 0);
#else
rsp->data[len++] = (1 << 0);
#endif
rsp->data_len = len;
rsp->completion_code = IPMI_CC_OK;
}
/**
* @brief Handler for "Set Event Receiver" command, as on IPMIv2 1.1
* section 29.1.
*
* Set (or reset) the address to which IPMI events
* will be sent. Also, disable sending events if command 0xFF is received.
*
* @param[in] req Incoming request to be handled and answered.
* @param[out] rsp Message with data, data length and completion code.
*
*/
uint8_t event_receiver_addr = 0x20;
uint8_t event_receiver_lun = 0x00;
IPMI_HANDLER(ipmi_se_set_event_receiver, NETFN_SE, IPMI_SET_EVENT_RECEIVER_CMD, ipmi_msg *req, ipmi_msg *rsp)
{
/* Update the event receiver address (even if its 0xFF,
the checking will be done in check_sensor_event function) */
event_receiver_addr = req->data[0];
event_receiver_lun = req->data[1];
rsp->completion_code = IPMI_CC_OK;
rsp->data_len = 0;
}
/**
* @brief Handler for "Get Event Receiver" command, as on IPMIv2 1.1
* section 29.1.
*
* Returns the previously set event receiver address and LUN
*
* @param[in] req Incoming request to be handled and answered.
* @param[out] rsp Message with data, data length and completion code.
*
* @return void
*/
IPMI_HANDLER(ipmi_se_get_event_receiver, NETFN_SE, IPMI_GET_EVENT_RECEIVER_CMD, ipmi_msg *req, ipmi_msg *rsp)
{
uint8_t len = 0;
rsp->data[len++] = event_receiver_addr;
rsp->data[len++] = event_receiver_lun;
rsp->completion_code = IPMI_CC_OK;
rsp->data_len = len;
}
IPMI_HANDLER(ipmi_se_get_sdr, NETFN_SE, IPMI_GET_DEVICE_SDR_CMD, ipmi_msg *req, ipmi_msg *rsp)
{
uint16_t recv_reserv_id = req->data[0] | (req->data[1] << 8);
uint16_t record_id = req->data[2] | (req->data[3] << 8);
uint8_t offset = req->data[4];
uint8_t size = req->data[5];
uint8_t len = rsp->data_len = 0;
rsp->completion_code = IPMI_CC_OK;
/* Reservation ID check */
if (reservationID != recv_reserv_id) {
rsp->data_len = 0;
rsp->completion_code = IPMI_CC_INV_DATA_FIELD_IN_REQ;
return;
}
sensor_t * cur_sensor = find_sensor_by_id( record_id );
if ( cur_sensor == NULL ) {
rsp->completion_code = IPMI_CC_REQ_DATA_NOT_PRESENT;
return;
}
if ( (record_id >= sdr_count) || ((size + offset) > cur_sensor->sdr_length)) {
rsp->completion_code = IPMI_CC_REQ_DATA_NOT_PRESENT;
return;
} else if (record_id == sdr_count - 1) {
rsp->data[len++] = 0xFF;
rsp->data[len++] = 0xFF;
} else {
rsp->data[len++] = (record_id + 1) & 0xFF; /* next record ID */
rsp->data[len++] = (record_id + 1) >> 8; /* next record ID */
}
uint8_t tmp_c, index;
uint8_t * pSDR = (uint8_t *) cur_sensor->sdr;
uint8_t sdr_type = pSDR[3];
for (uint8_t i = 0; i < size; i++) {
index = i + offset;
tmp_c = pSDR[index];
/* Return not-const data from SDR */
if (index == 0) {
tmp_c = record_id;
} else if (index == 5) {
tmp_c = ipmb_addr;
} else if ( sdr_type == TYPE_01 || sdr_type == TYPE_02 ) {
if (index == 9) {
tmp_c = cur_sensor->entityinstance;
}
if (index == 7) {
tmp_c = record_id;
}
} else if ( sdr_type == TYPE_11 || sdr_type == TYPE_12 ) {
if (index == 13) {
tmp_c = cur_sensor->entityinstance;
}
}
rsp->data[len++] = tmp_c;
}
rsp->data_len = len;
}
IPMI_HANDLER(ipmi_se_reserve_device_sdr, NETFN_SE, IPMI_RESERVE_DEVICE_SDR_REPOSITORY_CMD, ipmi_msg *req, ipmi_msg* rsp) {
int len = rsp->data_len;
reservationID++;
if (reservationID == 0) {
reservationID = 1;
}
rsp->data[len++] = reservationID & 0xff;
rsp->data[len++] = reservationID >> 8;
rsp->data_len = len;
rsp->completion_code = IPMI_CC_OK;
}
IPMI_HANDLER(ipmi_se_get_sensor_reading, NETFN_SE, IPMI_GET_SENSOR_READING_CMD, ipmi_msg *req, ipmi_msg* rsp) {
int sensor_number = req->data[0];
int len = rsp->data_len;
sensor_t * cur_sensor = find_sensor_by_id( sensor_number );
if (sensor_number > sdr_count) {
rsp->completion_code = IPMI_CC_PARAM_OUT_OF_RANGE;
rsp->data_len = 0;
return;
}
if (vTaskHotSwap_Handle != NULL && *(cur_sensor->task_handle) == vTaskHotSwap_Handle) {
rsp->data[len++] = 0x00;
rsp->data[len++] = cur_sensor->event_scan;
/* Current State Mask */
rsp->data[len++] = cur_sensor->readout_value;
} else {
rsp->data[len++] = cur_sensor->readout_value;
rsp->data[len++] = cur_sensor->event_scan;
/* Present threshold status ( [7:6] Reserved, return as 1b )*/
rsp->data[len] = 0xC0;
rsp->data[len] |= cur_sensor->state;
len++;
}
rsp->data[len++] = 0x00;
rsp->data_len = len;
rsp->completion_code = IPMI_CC_OK;
}
IPMI_HANDLER(ipmi_se_get_sensor_threshold, NETFN_SE, IPMI_GET_SENSOR_THRESHOLD_CMD, ipmi_msg *req, ipmi_msg* rsp) {
int sensor_number = req->data[0];
int len = rsp->data_len;
/* Check if the requested sensor exists */
if (sensor_number > sdr_count) {
rsp->completion_code = IPMI_CC_PARAM_OUT_OF_RANGE;
rsp->data_len = 0;
return;
}
sensor_t *cur_sensor = find_sensor_by_id( sensor_number );
/* Check if the selected sensor has a Full Sensor Record */
if ( cur_sensor->sdr_type != TYPE_01) {
rsp->completion_code = IPMI_CC_INV_DATA_FIELD_IN_REQ;
rsp->data_len = 0;
return;
}
SDR_type_01h_t *sdr = ( SDR_type_01h_t *) cur_sensor->sdr;
/* Returns readable threshold mask */
rsp->data[len++] = sdr->readable_threshold_mask;
/* Returns thresh values */
rsp->data[len++] = sdr->lower_noncritical_thr;
rsp->data[len++] = sdr->lower_critical_thr;
rsp->data[len++] = sdr->lower_nonrecover_thr;
rsp->data[len++] = sdr->upper_noncritical_thr;
rsp->data[len++] = sdr->upper_critical_thr;
rsp->data[len++] = sdr->upper_nonrecover_thr;
rsp->data_len = len;
rsp->completion_code = IPMI_CC_OK;
}
/* Sensor state checking function adapted from CERN MMCv2 implementation, credits in this file header */
void sensor_state_check( sensor_t *sensor )
{
if (sensor == NULL) return;
SDR_type_01h_t * sdr = (SDR_type_01h_t *) sensor->sdr;
if(sdr == NULL || sdr->hdr.rectype != TYPE_01) return;
/* Only check enabled sensors */
if (!(sensor->event_scan & 0xC0)) return;
if(compare_val(sensor->readout_value, sdr->lower_noncritical_thr, UPPER_EQ, sensor->signed_flag) && compare_val(sensor->readout_value, sdr->upper_noncritical_thr, LOWER_EQ, sensor->signed_flag)) {
sensor->state = SENSOR_STATE_NORMAL;
} else if(compare_val(sensor->readout_value, sdr->upper_noncritical_thr, UPPER_EQ, sensor->signed_flag) && compare_val(sensor->readout_value, sdr->upper_critical_thr, LOWER_EQ, sensor->signed_flag)) {
sensor->state = SENSOR_STATE_HIGH;
} else if(compare_val(sensor->readout_value, sdr->upper_critical_thr, UPPER_EQ, sensor->signed_flag) && compare_val(sensor->readout_value, sdr->upper_nonrecover_thr, LOWER_EQ, sensor->signed_flag)) {
sensor->state = SENSOR_STATE_HIGH_CRIT;
} else if(compare_val(sensor->readout_value, sdr->upper_nonrecover_thr, UPPER_EQ, sensor->signed_flag)) {
sensor->state = SENSOR_STATE_HIGH_NON_REC;
} else if(compare_val(sensor->readout_value, sdr->lower_noncritical_thr, LOWER_EQ, sensor->signed_flag) && compare_val(sensor->readout_value, sdr->lower_critical_thr, UPPER_EQ, sensor->signed_flag)) {
sensor->state = SENSOR_STATE_LOW;
} else if(compare_val(sensor->readout_value, sdr->lower_critical_thr, LOWER_EQ, sensor->signed_flag) && compare_val(sensor->readout_value, sdr->lower_nonrecover_thr, UPPER_EQ, sensor->signed_flag)) {
sensor->state = SENSOR_STATE_LOW_CRIT;
} else if(compare_val(sensor->readout_value, sdr->lower_nonrecover_thr, LOWER_EQ, sensor->signed_flag)) {
sensor->state = SENSOR_STATE_LOW_NON_REC;
}
}
/* Sensor alarm checking function adapted from CERN MMCv2 implementation, credits in this file header */
void check_sensor_event( sensor_t * sensor )
{
/** Should be rewritten to be compliant with RTM management !! */
/* Event message: [0] - Event Data 1
[7:6] 00b = unspecified byte 2
01b = trigger reading in byte 2
10b = OEM code in byte 2
11b = sensor-specific event extension code in byte 2
[5:4] 00b = unspecified byte 3
01b = trigger threshold value in byte 3
10b = OEM code in byte 3
11b = sensor-specific event extension code in byte 3
[3:0] Offset from Event/Reading Code for threshold event.
[1] - Event data 2 -> Reading that triggered the event
[2] - Event data 3 -> Threshold value that triggered the event
*/
uint8_t ev[3] = {0x0F, 0xFF, 0xFF};
uint8_t ev_type;
if (sensor == NULL) return;
SDR_type_01h_t * sdr = (SDR_type_01h_t *) sensor->sdr;
if(sdr == NULL || sdr->hdr.rectype != TYPE_01) return;
/* Only check enabled sensors */
if (!(sensor->event_scan & 0xC0)) return;
/* The 0x50 OR'ed in ev[0] indicates that the sensor read value and threshold
* that triggered the event will be present in bytes 1 and 2, respectively */
/** Compare threshold with the upper thresholds */
/** Upper non-critical threshold going-high */
if(sdr->assertion_event_mask & (1 << IPMI_THRESHOLD_UNC_GH)) {
if(!sensor->asserted_event.upper_non_critical_go_high && compare_val(sensor->readout_value, sdr->upper_noncritical_thr, UPPER_EQ, sensor->signed_flag)){
ev_type = ASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_UNC_GH;
ev[1] = sensor->readout_value;
ev[2] = sdr->upper_noncritical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.upper_non_critical_go_high = 1;
}
}
if(sdr->deassertion_event_mask & (1 << IPMI_THRESHOLD_UNC_GH)) {
if(sensor->asserted_event.upper_non_critical_go_high && compare_val(sensor->readout_value, (sdr->upper_noncritical_thr - sdr->neg_thr_hysteresis), LOWER_EQ, sensor->signed_flag)){
ev_type = DEASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_UNC_GH;
ev[1] = sensor->readout_value;
ev[2] = sdr->upper_noncritical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.upper_non_critical_go_high = 0;
}
}
/** Upper critical threshold going-high */
if(sdr->assertion_event_mask & (1 << IPMI_THRESHOLD_UC_GH)) {
if(!sensor->asserted_event.upper_critical_go_high && compare_val(sensor->readout_value, sdr->upper_critical_thr, UPPER_EQ, sensor->signed_flag)){
ev_type = ASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_UC_GH;
ev[1] = sensor->readout_value;
ev[2] = sdr->upper_critical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.upper_critical_go_high = 1;
}
}
if(sdr->deassertion_event_mask & (1 << IPMI_THRESHOLD_UC_GH)) {
if(sensor->asserted_event.upper_critical_go_high && compare_val(sensor->readout_value, (sdr->upper_critical_thr - sdr->neg_thr_hysteresis), LOWER_EQ, sensor->signed_flag)){
ev_type = DEASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_UC_GH;
ev[1] = sensor->readout_value;
ev[2] = sdr->upper_critical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.upper_critical_go_high = 0;
}
}
/** Upper non-recoverable threshold going-high */
if(sdr->assertion_event_mask & (1 << IPMI_THRESHOLD_UNR_GH)) {
if(!sensor->asserted_event.upper_non_recoverable_go_high && compare_val(sensor->readout_value, sdr->upper_nonrecover_thr, UPPER_EQ, sensor->signed_flag)){
ev_type = ASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_UNR_GH;
ev[1] = sensor->readout_value;
ev[2] = sdr->upper_nonrecover_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.upper_non_recoverable_go_high = 1;
}
}
if(sdr->deassertion_event_mask & (1 << IPMI_THRESHOLD_UNR_GH)) {
if(sensor->asserted_event.upper_non_recoverable_go_high && compare_val(sensor->readout_value, (sdr->upper_nonrecover_thr - sdr->neg_thr_hysteresis), LOWER_EQ, sensor->signed_flag)){
ev_type = DEASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_UNR_GH;
ev[1] = sensor->readout_value;
ev[2] = sdr->upper_nonrecover_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.upper_non_recoverable_go_high = 0;
}
}
/** Lower non-critical threshold going-high */
if(sdr->assertion_event_mask & (1 << IPMI_THRESHOLD_LNC_GL)) {
if(!sensor->asserted_event.lower_non_critical_go_low && compare_val(sensor->readout_value, sdr->lower_noncritical_thr, LOWER_EQ, sensor->signed_flag)){
ev_type = ASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_LNC_GL;
ev[1] = sensor->readout_value;
ev[2] = sdr->lower_noncritical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.lower_non_critical_go_low = 1;
}
}
if(sdr->deassertion_event_mask & (1 << IPMI_THRESHOLD_LNC_GL)) {
if(sensor->asserted_event.lower_non_critical_go_low && compare_val(sensor->readout_value, (sdr->lower_noncritical_thr + sdr->pos_thr_hysteresis), UPPER_EQ, sensor->signed_flag)){
ev_type = DEASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_LNC_GL;
ev[1] = sensor->readout_value;
ev[2] = sdr->lower_noncritical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.lower_non_critical_go_low = 0;
}
}
/** Lower critical threshold going-high */
if(sdr->assertion_event_mask & (1 << IPMI_THRESHOLD_LC_GL)) {
if(!sensor->asserted_event.lower_critical_go_low && compare_val(sensor->readout_value, sdr->lower_critical_thr, LOWER_EQ, sensor->signed_flag)){
ev_type = ASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_LC_GL;
ev[1] = sensor->readout_value;
ev[2] = sdr->lower_critical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.lower_critical_go_low = 1;
}
}
if(sdr->deassertion_event_mask & (1 << IPMI_THRESHOLD_LC_GL)) {
if(sensor->asserted_event.lower_critical_go_low && compare_val(sensor->readout_value, (sdr->lower_critical_thr + sdr->pos_thr_hysteresis), UPPER_EQ, sensor->signed_flag)){
ev_type = DEASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_LC_GL;
ev[1] = sensor->readout_value;
ev[2] = sdr->lower_critical_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.lower_critical_go_low = 0;
}
}
/** Lower non-recoverable threshold going-high */
if(sdr->assertion_event_mask & (1 << IPMI_THRESHOLD_LNR_GL)) {
if(!sensor->asserted_event.lower_non_recoverable_go_high && compare_val(sensor->readout_value, sdr->lower_nonrecover_thr, LOWER_EQ, sensor->signed_flag)){
ev_type = ASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_LNR_GL;
ev[1] = sensor->readout_value;
ev[2] = sdr->lower_nonrecover_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.lower_non_recoverable_go_high = 1;
}
}
if(sdr->deassertion_event_mask & (1 << IPMI_THRESHOLD_LNR_GL)) {
if(sensor->asserted_event.lower_non_recoverable_go_high && compare_val(sensor->readout_value, (sdr->lower_nonrecover_thr + sdr->pos_thr_hysteresis), UPPER_EQ, sensor->signed_flag)){
ev_type = DEASSERTION_EVENT;
ev[0] = 0x50 | IPMI_THRESHOLD_LNR_GL;
ev[1] = sensor->readout_value;
ev[2] = sdr->lower_nonrecover_thr;
ipmi_event_send(sensor, ev_type, ev, sizeof(ev));
sensor->asserted_event.lower_non_recoverable_go_high = 0;
}
}
}
/* Management Controller Device Locator Record 37.9 SDR Type 12h */
const SDR_type_12h_t SDR0 = {
.hdr.recID_LSB = 0x00,
.hdr.recID_MSB = 0x00,
.hdr.SDRversion = 0x51, /* IPMI protocol version */
.hdr.rectype = TYPE_12, /* record type: device locator record */
.hdr.reclength = sizeof(SDR_type_12h_t) - sizeof(SDR_entry_hdr_t),
/* record key bytes */
.slaveaddr = 0x00,
.chnum = 0x00,
.power_notification_global_init = 0x04,
.device_cap = 0x3b,
.reserved[0] = 0x00,
.reserved[1] = 0x00,
.reserved[2] = 0x00,
.entityID = 0xC1,
.entityinstance = 0x00,
.OEM = 0x00,
.IDtypelen = 0xc0 | STR_SIZE(STR(TARGET_BOARD_NAME)), /* 8 bit ASCII, number of bytes */
.IDstring = STR(TARGET_BOARD_NAME)
};
/* RTM Device Locator Record 37.9 SDR Type 12h */
const SDR_type_12h_t SDR_RTM_DEV_LOCATOR = {
.hdr.recID_LSB = 0x00,
.hdr.recID_MSB = 0x00,
.hdr.SDRversion = 0x51, /* IPMI protocol version */
.hdr.rectype = TYPE_12, /* record type: device locator record */
.hdr.reclength = sizeof(SDR_type_12h_t) - sizeof(SDR_entry_hdr_t),
/* record key bytes */
.slaveaddr = 0x00,
.chnum = 0x00,
.power_notification_global_init = 0x04,
.device_cap = 0x3b,
.reserved[0] = 0x00,
.reserved[1] = 0x00,
.reserved[2] = 0x00,
.entityID = 0xC0,
.entityinstance = 0x00,
.OEM = 0x00,
.IDtypelen = 0xc0 | (STR_SIZE(STR(TARGET_BOARD_NAME)) +4), /* 8 bit ASCII, number of bytes */
.IDstring = STR(TARGET_BOARD_NAME)"-RTM"
};