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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/errl/errlmanager.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2015 */
/* [+] Google Inc. */
/* [+] 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 ERRLMANAGER_H
#define ERRLMANAGER_H
/**
* @file errlmanager.H
*
* @brief Error Log management for Host Boot environment.
*
*/
/*****************************************************************************/
// I n c l u d e s
/*****************************************************************************/
#include <config.h>
#include <util/singleton.H>
#include <errl/errlentry.H>
#include <errldisplay/errldisplay.H>
#include <sys/sync.h>
#include <kernel/timemgr.H>
#include <hbotcompid.H>
#include <hwas/common/hwasCallout.H>
#include <mbox/mbox_queues.H>
#include <mbox/mboxif.H>
#include <utility>
#include <list>
namespace ERRORLOG
{
/**
* @brief Global function to log an error
* Writes the log to PNOR where committed logs are kept.
* If there's not enough room, remove the latest log(s) to make
* enough room to commit this log.
* The error log will be automatically deleted after the
* commit. The input handle will be set to NULL.
* For Host Boot environment, there's no individual committer
* (i.e. committer = Host Boot), so no component ID of
* committer is specified.
* This function is global in order to workaround the singleton
* linker issue in HostBoot (linker can't find singleton outside of
* a module).
*
* @param[in,out] io_err Error log handle to be committed
* @param[in] i_comitterComp Component committing the error log
*
* @return None
*/
void errlCommit(errlHndl_t& io_err, compId_t i_committerComp );
/**
* @brief Global function to determine if INFO and Recovered errors
* should be skipped or forwarded
*
* @param[in] None
*
* @return iv_hiddenErrLogsEnable
*/
uint8_t getHiddenLogsEnable();
/**
* @brief Global enums used by static errlResourceReady function
*/
enum errlManagerNeeds
{
PNOR,
TARG,
MBOX,
IPMI,
ERRLDISP,
} ;
/*****************************************************************************/
// Forward class declarations
/*****************************************************************************/
class ErrlEntry;
class ErrlManager;
// Singleton - Use "theErrlManager::instance()" to access the singleton
typedef Singleton<ErrlManager> theErrlManager;
/**
* @brief Error log manager
* This class provides interfaces to perform some specific tasks
* on existing error objects such as committing a log, sending the
* log to the SP, etc..
*/
class ErrlManager
{
public:
/**
* @brief Commit an error log by sending it to the repository
* Writes the log to PNOR where committed logs are kept.
* If there's not enough room, remove the latest log(s) to make
* enough room to commit this log.
* The error log will be automatically deleted after the
* commit. The input handle will be set to NULL.
* For Host Boot environment, there's no individual committer
* (i.e. committer = Host Boot), so no component ID of
* committer is specified.
*
* @param[in,out] io_err Error log handle to be committed
*
* @return None
*/
void commitErrLog(errlHndl_t& io_err, compId_t i_committerComp );
/**
* @brief Returns a unique error log ID
*
* This routine generates a unique Error ID and assign it to
* the input error log. Mutates iv_currLogId.
*
* @return Unique generated error log ID
*/
uint32_t getUniqueErrId();
/**
* @brief Sets the HWAS ProcessCallout function pointer
*
* This is called by HWAS to inform errlmanager that HWAS is loaded and
* therefore it can call HWAS to process callout information in an errlog
*
* It is a static function because a module cannot call an interface on a
* singleton in another module
*/
static void setHwasProcessCalloutFn(HWAS::processCalloutFn i_fn);
/**
* @brief Sends msg to errlmanager telling what resources are ready
*
* This is called by resources that the ErrlManager needs, which start up
* AFTER ErrlManager starts.
*
* It is a static function because a module cannot call an interface on a
* singleton in another module
*/
static void errlResourceReady(errlManagerNeeds i_needs);
/**
* @brief Sends msg to errlmanager to ack sending of errl to BMC
*
* This is called by ipmi code once the SEL for the indicated errorlog
* has been successfully sent to the BMC
*
* It is a static function because a module cannot call an interface on a
* singleton in another module
*/
static void errlAckErrorlog(uint32_t i_eid);
/**
* @brief Returns the HWAS ProcessCallout function pointer
*
* This is called by ErrlEntry::commit to get the HWAS ProcessCallout
* function pointer, this is called to process callout information in an
* errlog, if NULL is returned then the function cannot be called (because
* the HWAS module is not loaded)
*
* @return HWAS::processCalloutFn function pointer
*/
HWAS::processCalloutFn getHwasProcessCalloutFn() const
{
return iv_hwasProcessCalloutFn;
}
/**
* @brief Determines if any non-informational logs have been committed
* during this boot.
*
* @return true - A non-informational log has been committed.
*/
static bool errlCommittedThisBoot();
/**
* @brief Value to determine what logs are to be skipped. Mirrors
* what is currently set in ATTR_HIDDEN_ERRLOGS_ENABLE
*/
static uint8_t iv_hiddenErrLogsEnable;
protected:
/**
* @brief Destructor
*
* Releases all resources owned by the handle. If the log has not
* been committed, it effectively aborts the log.
* All logs (committed or not) must be deleted to avoid a resource leak.
*
* @return None
*
*/
~ErrlManager();
/**
* @brief Default constructor
* Protected so only SingletonHolder can call
*/
ErrlManager();
private:
/**
* @enum ERRLOG_MSG_TYPE
*
* @brief Message types that recognized by the error log message queue
*/
enum ERRLOG_MSG_TYPE
{
ERRLOG_NEEDS_TO_BE_COMMITTED_TYPE = 0x00000030 | MBOX::FIRST_SECURE_MSG,
ERRLOG_SEND_TO_FSP_TYPE = 0x00000031 | MBOX::FIRST_SECURE_MSG,
ERRLOG_COMMITTED_ACK_RESPONSE_TYPE = 0x00000032 | MBOX::FIRST_UNSECURE_MSG,
ERRLOG_SHUTDOWN_TYPE = 0x00000033 | MBOX::FIRST_SECURE_MSG,
ERRLOG_ACCESS_PNOR_TYPE = 0x00000034 | MBOX::FIRST_SECURE_MSG,
ERRLOG_ACCESS_MBOX_TYPE = 0x00000035 | MBOX::FIRST_SECURE_MSG,
ERRLOG_ACCESS_TARG_TYPE = 0x00000036 | MBOX::FIRST_SECURE_MSG,
ERRLOG_ACCESS_ERRLDISP_TYPE = 0x00000037 | MBOX::FIRST_SECURE_MSG,
ERRLOG_ACCESS_IPMI_TYPE = 0x00000038 | MBOX::FIRST_SECURE_MSG,
};
/**
* @enum ERRORLOG_PLID_OFFSET
*
* Base ID of Hostboot PLIDs. The hostboot plid range is 0x90 to 0x93
* for each instance running on a multinode system.
*
* NOTE: Changes to this define (if '9' changes) will require changes to
* CpuManager::requestShutdown
*/
enum ERRORLOG_PLID_OFFSET
{
ERRLOG_PLID_BASE = 0x90000000,// Hostboot Base PLID Offset
ERRLOG_PLID_BASE_MASK = 0x9F000000,// mask of just the id
ERRLOG_PLID_NODE_SHIFT = 24, // shift to put node number 0x9#
ERRLOG_PLID_MASK = 0x00FFFFFF,// mask to find log number
ERRLOG_PLID_INITIAL = 0x00FF0000,// initial big id number
};
/**
* @brief Disabled copy constructor and assignment operator
*/
ErrlManager(const ErrlManager& i_right);
ErrlManager& operator=(const ErrlManager& i_right);
/**
* @brief Sends msg to errlmanager telling what resources are ready
*
* called by static errlResourceReady function.
*/
void sendResourcesMsg(errlManagerNeeds i_needs);
/**
* @brief Sends msg to errlmanager telling which errlog to ack
*
* called by static errlAckErrorlog function.
*/
void sendAckErrorlog(uint32_t i_eid);
/**
* @brief Access PNOR and get the address and size of the HBEL section in
* PNOR; sets the iv_pnorAddr, iv_maxErrlInPnor, iv_pnorOpenSlot variables;
* parsers the error logs in PNOR and determines the new iv_currLogId.
*
* @param[in/out] NONE
* @return NONE.
*/
void setupPnorInfo();
/**
* @brief Create and register the error log message queue
*
* @param[in/out] NONE
* @return NONE.
*/
void msgQueueInit ();
/**
* @brief Performs startup of the error log processing thread.
*
* @param[in/out]
* @return NONE
*/
static void * startup ( void* i_self );
/**
* @brief Message handler for process Hostboot error log message
* and send it to FSP.
*
* @param[in/out] NONE
* @return NONE
*
*/
void errlogMsgHndlr ();
/**
* @brief Send Host boot error log to error message queue for committing.
*
* @param[in,out] io_err Error log handle to be committed
* @param[in] i_committerComp Component id that committed the error
*
* @return NONE
*
*/
void sendErrlogToMessageQueue ( errlHndl_t& io_err, compId_t i_committerComp );
/**
* @brief Create a mailbox message with the error log and send it to Fsp.
*
* @param[in,out] io_err Error log handle to be committed
*
*/
void sendErrLogToFSP ( errlHndl_t& io_err );
/**
* @brief Create a mailbox message with the error log and send it to Fsp.
*
* @param[in,out] io_err Error log handle to be committed
* @return NONE
*
*/
void sendMboxMsg ( errlHndl_t& io_err );
/**
* @brief Save errlog entry in the memory
*
* @param[in,out] io_err Error log handle to be committed
* @return NULL
*
*/
void saveErrLogEntry( errlHndl_t& io_err );
/**
* @brief Shutdown error log manager
*
* @param[in,out] None
* @return NULL
*
*/
void errlogShutdown();
/**
* @brief Current log ID. As new error logs are created,
* this value will be used to assign the new error log its ID.
*/
uint32_t iv_currLogId;
/**
* @brief
* Pointer to the header that precedes the error log storage buffer
* in L3 RAM. This may go away when we adopt PNOR, or else become
* instance variables instead of a pointer pointing within the
* storage buffer.
*/
storage_header_t * iv_pStorage;
/**
* @brief Pointer to the HWAS processCallout function
*/
HWAS::processCalloutFn iv_hwasProcessCalloutFn;
/**
* @brief Message queue for error log
*/
msg_q_t iv_msgQ;
// functions relating to writing the errorlogs to PNOR
/**
* @brief flatten and save the error log into PNOR
*
* @param[in] error log handle
* @return true if saved in PNOR, false if not
*
*/
bool saveErrLogToPnor( errlHndl_t& io_err);
/**
* @brief find the flattened error log in PNOR and set it's ACK bit
*
* @param[in] i_errEid EID of the error log to look for
* @return true if we successfully set the ACK bit,
* false if we couldn't find that errlog in PNOR
*/
bool ackErrLogInPnor( uint32_t i_errEid );
/**
* @brief check the state of the PNOR 'slot'
*
* @param[in] i_position - index into PNOR to check
* @return true if slot is empty
* (first 32bits == EMPTY_ERRLOG_IN_PNOR)
*
*/
bool isSlotEmpty(uint32_t i_position);
/**
* @brief check the state of the PNOR 'slot'
* ONLY to be called on a slot that is NOT empty
*
* @param[in] i_position - index into PNOR to check
* @return true if errlog in this slot has been ACKed
* (ACK bit in word5 is 0x0)
*
*/
bool isSlotACKed(uint32_t i_position);
/**
* @brief increment the iv_PnorOpenSlot variable to the next
* available slot, handling wrap and checking that the
* slot is either EMPTY or has an ACKed error log.
*
* @return true if there was an open slot, false if PNOR is full
*
*/
bool incrementPnorOpenSlot();
/**
* @brief read the Eid from the flattened error log in PNOR;
* MUST point to a non-empty slot
*
* @param[in] i_position - index into PNOR to check
* @return eid for that error log
*
*/
uint32_t readEidFromFlattened(uint32_t i_position);
/**
* @brief read the Plid from the flattened error log in PNOR;
* MUST point to a non-empty slot
*
* @param[in] i_position - index into PNOR to check
* @return plid for that error log
*
*/
uint32_t readPlidFromFlattened(uint32_t i_position);
/**
* @brief set the ACK bit in the flattened error log in PNOR;
* MUST point to a non-empty slot
*
* @param[in] i_position - index into PNOR to check
* @return NONE
*
*/
void setACKInFlattened(uint32_t i_position);
#ifdef CONFIG_BMC_IPMI
/**
* @brief Create an ipmi message with the error log and send it to BMC
*
* @param[in,out] io_err Error log handle to be committed
*
*/
void sendErrLogToBmc(errlHndl_t &io_err);
#endif
/**
* @brief errorlog-into-PNOR variables
*/
char *iv_pnorAddr; // HBEL section in PNOR
uint32_t iv_maxErrlInPnor; // max number of errorlogs that will fit
uint32_t iv_pnorOpenSlot; // current open slot available for an errorlog
bool iv_isSpBaseServices; // do we need to send to FSP
bool iv_isMboxEnabled; // are we able to send to FSP
bool iv_isIpmiEnabled; // are we able to send to BMC via IPMI
bool iv_nonInfoCommitted; // Keeps track of any non-informational logs.
bool iv_isErrlDisplayEnabled; // are we able to use the errorDisplay
// Errl flags which represent processing needed by the errl
// represented as a bit field (8 bits)
// Note: When adding a new flag, add to the trace in errlogShutdown()
enum ERRLOG_FLAGS
{
PNOR_FLAG = 0x01,
MBOX_FLAG = 0x02,
ERRLDISP_FLAG = 0x04,
IPMI_FLAG = 0x08,
ALL_FLAGS = PNOR_FLAG | MBOX_FLAG
#ifdef CONFIG_BMC_IPMI
| IPMI_FLAG
#endif
#ifdef CONFIG_CONSOLE_OUTPUT_ERRORDISPLAY
| ERRLDISP_FLAG
#endif
};
// List of messages errl manager needs to handle
// The unint8_t is a bit field to indiciate what needs to be done
typedef std::pair<errlHndl_t, uint8_t> ErrlFlagPair_t;
typedef std::list<ErrlFlagPair_t> ErrlList_t;
typedef ErrlList_t::iterator ErrlListItr_t;
ErrlList_t iv_errlList;
/**
* @brief checks if the flag is set
*
* @param[in] i_pair - pair of errl and bitfield of flags
* @param[in] i_flag - specific flag
* @return True if specified flag is set
*
*/
static bool _isFlagSet(const ErrlFlagPair_t &i_pair,
const ERRLOG_FLAGS i_flag)
{
return (i_pair.second & i_flag);
}
/**
* @brief clears the flag, indicating complete
*
* @param[in/out] io_pair - pair of errl and bitfield of flags
* @param[in] i_flag - specific flag
* @return NA
*
*/
static void _clearFlag(ErrlFlagPair_t &io_pair,
const ERRLOG_FLAGS i_flag)
{
io_pair.second &= ~i_flag;
}
/**
* @brief Checks if all flags are cleared for a errlhndl.
* If so deletes and NULLs the errl and removes from errl list.
* It then updates the iterator accordingly, done in this function
* to properly handle when a list.erase() happens
*
* @param[in/out] io_it - iterator for the iv_errlList
* @return True if an erase occurred, otherwise false
*
*/
bool _updateErrlListIter(ErrlListItr_t & io_it);
/**
* @brief helper function to set the 'iv_skipShowingLog' flag of an error
* log. this needs to be called when we first get an errl object before we
* try to handle it. ie, when it's going to be committed, AND when it's
* been unflattened out of PNOR
*
* @param[in/out] io_err - errorlog that's being checked and updatd
*/
void setErrlSkipFlag(errlHndl_t io_err);
};
} // End namespace
#endif //ERRLMANAGER_H
|