blob: 227bb129868390c58af7c0bf4489666b757454d1 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001/*
2<:copyright-BRCM:2016:DUAL/GPL:standard
3
4 Broadcom Proprietary and Confidential.(c) 2016 Broadcom
5 All Rights Reserved
6
7Unless you and Broadcom execute a separate written software license
8agreement governing use of this software, this software is licensed
9to you under the terms of the GNU General Public License version 2
10(the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
11with the following added to such license:
12
13 As a special exception, the copyright holders of this software give
14 you permission to link this software with independent modules, and
15 to copy and distribute the resulting executable under terms of your
16 choice, provided that you also meet, for each linked independent
17 module, the terms and conditions of the license of that module.
18 An independent module is a module which is not derived from this
19 software. The special exception does not apply to any modifications
20 of the software.
21
22Not withstanding the above, under no circumstances may you combine
23this software in any way with any other Broadcom software provided
24under a license other than the GPL, without Broadcom's express prior
25written consent.
26
27:>
28 */
29
30#ifndef __BCM_DEV_LOG_TASK_H_
31#define __BCM_DEV_LOG_TASK_H_
32
33/* Because we cast from dev_log_id to pointer type in bcm_dev_log.c, we want it to be the same size as a pointer size (e.g: "typedef uint32_t dev_log_id" won't work
34 * on 64bit platform). */
35typedef unsigned long dev_log_id;
36
37#define DEV_LOG_INVALID_ID (dev_log_id)UINT_MAX
38
39#ifdef ENABLE_LOG
40
41/* Uncomment the following line to enable info prints for dev_log debugging */
42/* #define DEV_LOG_DEBUG */
43
44#include <bcmos_system.h>
45
46/********************************************/
47/* */
48/* Log macros */
49/* */
50/********************************************/
51
52/********************************************/
53/* */
54/* Defines/Typedefs */
55/* */
56/********************************************/
57
58#define STRINGIFY(x) #x
59#define STRINGIFY_EXPAND(str) STRINGIFY(str)
60
61#ifdef __KERNEL__
62#define DEV_LOG_PRINTF printk
63#define DEV_LOG_VPRINTF vprintk
64#else
65#define DEV_LOG_PRINTF bcmos_printf
66#define DEV_LOG_VPRINTF bcmos_vprintf
67#endif
68
69#ifdef DEV_LOG_DEBUG
70#define DEV_LOG_INFO_PRINTF(fmt, args...) DEV_LOG_PRINTF("(%s:" STRINGIFY_EXPAND(__LINE__) ") " fmt, __FUNCTION__, ##args)
71#else
72static inline void dev_log_info_printf_ignore(const char *fmt, ...) { }
73#define DEV_LOG_INFO_PRINTF(fmt, args...) dev_log_info_printf_ignore(fmt, ##args)
74#endif
75#define DEV_LOG_ERROR_PRINTF(fmt, args...) DEV_LOG_PRINTF("(%s:" STRINGIFY_EXPAND(__LINE__) ") " fmt, __FUNCTION__, ##args)
76
77/* IMPORTANT! when modifying DEV_LOG_MAX_ARGS,
78 * don't forget to add/remove _BCM_LOG_ARGS... macros in order to force number of arguments in compile time
79 */
80#define DEV_LOG_MAX_ARGS 36
81/* String bigger than this size will be cut */
82#define MAX_DEV_LOG_ID_NAME 32 /* Maximum size of log_id name */
83#define DEV_LOG_MAX_IDS 512
84#define DEV_LOG_MAX_FILES 2
85#define MAX_DEV_LOG_STRING_SIZE 256 /* Note that this size includes header. */
86#define MAX_DEV_LOG_HEADER_SIZE (7 + 16 + 20) /* (time=16, ID=20, delimiters=7) */
87#define MAX_DEV_LOG_STRING_NET_SIZE (MAX_DEV_LOG_STRING_SIZE - MAX_DEV_LOG_HEADER_SIZE)
88#define DEV_LOG_INVALID_INDEX UINT_MAX
89#define DEV_LOG_DROP_REPORT_RATE_US 1000000 /* 1 second */
90#define DEV_LOG_DROP_REPORT_DROP_THRESHOLD 1000
91#define DEV_LOG_ENDIAN BCMOS_ENDIAN_LITTLE
92
93/* If the log message pool utilization is >= this percentage, do not print messages (only save them).
94 * (note that error/fatal messages will not objey this rule). */
95#define DEV_LOG_SKIP_PRINT_THRESHOLD_PERCENT 50
96
97/* If the log message pool utilization is >= this percentage, drop all messages that aren't 'error' or 'fatal' level. */
98#define DEV_LOG_ERROR_ONLY_THRESHOLD_PERCENT 75
99
100/* Log level enum */
101typedef enum
102{
103 DEV_LOG_LEVEL_NO_LOG = 0,
104 DEV_LOG_LEVEL_FATAL,
105 DEV_LOG_LEVEL_ERROR,
106 DEV_LOG_LEVEL_WARNING,
107 DEV_LOG_LEVEL_INFO,
108 DEV_LOG_LEVEL_DEBUG,
109
110 DEV_LOG_LEVEL_NUM_OF
111} bcm_dev_log_level;
112
113/* Log type enum */
114typedef enum
115{
116 /* Bit[0] - Print Enable, Bit[1] - Save Enable */
117 DEV_LOG_ID_TYPE_NONE = 0, /* NO SAVE, NO PRINT*/
118 DEV_LOG_ID_TYPE_PRINT = 1,
119 DEV_LOG_ID_TYPE_SAVE = 1 << 1,
120 DEV_LOG_ID_TYPE_BOTH = DEV_LOG_ID_TYPE_PRINT | DEV_LOG_ID_TYPE_SAVE, /* SAVE & PRINT */
121} bcm_dev_log_id_type;
122
123typedef enum
124{
125 BCM_DEV_LOG_FLAG_NONE = 0,
126
127 /* Even if logger is disabled, BCM_LOG() calls are redirected to bcmos_printf(). */
128 BCM_DEV_LOG_FLAG_DISABLED_WITH_PRINTF = 1 << 0,
129
130 /* When bcm_dev_log_destroy() is called, do not wait for outstanding log messages to be drained. Discard the
131 * messages and destroy the task immediately. */
132 BCM_DEV_LOG_FLAG_DESTROY_IMMEDIATELY = 1 << 1,
133} bcm_dev_log_flags;
134
135typedef enum
136{
137 BCM_DEV_LOG_FILE_FLAG_NONE = 0,
138 BCM_DEV_LOG_FILE_FLAG_VALID = 1, /**< file is valid */
139 BCM_DEV_LOG_FILE_FLAG_WRAP_AROUND = 1 << 1, /**< new messages will override old */
140 BCM_DEV_LOG_FILE_FLAG_STOP_WHEN_FULL = 1 << 2, /**< stop logging if the file is full */
141 BCM_DEV_LOG_FILE_FLAG_CLEAR_AFTER_READ = 1 << 4, /**< auto-clear log when it is fully read */
142} bcm_dev_log_file_flags;
143
144typedef enum
145{
146 BCM_DEV_LOG_STYLE_NORMAL,
147 BCM_DEV_LOG_STYLE_BOLD,
148 BCM_DEV_LOG_STYLE_UNDERLINE,
149 BCM_DEV_LOG_STYLE_BLINK,
150 BCM_DEV_LOG_STYLE_REVERSE_VIDEO,
151} bcm_dev_log_style;
152
153/********************************************/
154/* */
155/* Callbacks functions */
156/* */
157/********************************************/
158
159/* Default logger ID */
160extern dev_log_id def_log_id;
161
162/* Log file type */
163typedef enum
164{
165 BCM_DEV_LOG_FILE_MEMORY, /**< Memory file */
166#ifdef BCM_OS_POSIX
167 BCM_DEV_LOG_FILE_REGULAR, /**< Regular file */
168#endif
169#ifdef DEV_LOG_SYSLOG
170 BCM_DEV_LOG_FILE_SYSLOG, /**< syslog "file" */
171#endif
172 BCM_DEV_LOG_FILE_UDEF /**< User-defined file */
173} bcm_dev_log_file_type;
174
175typedef struct bcm_dev_log_file_parm bcm_dev_log_file_parm;
176typedef struct bcm_dev_log_file bcm_dev_log_file;
177
178/****************************************************************************************/
179/* OPEN CALLBACK: open memory/file */
180/* file_parm - file parameters */
181/* file - file */
182/****************************************************************************************/
183typedef bcmos_errno (*bcm_dev_log_file_open_cb)(const bcm_dev_log_file_parm *file_parm, bcm_dev_log_file *file);
184
185/****************************************************************************************/
186/* CLOSE CALLBACK: close memory/file */
187/* file - file handle */
188/****************************************************************************************/
189typedef bcmos_errno (*bcm_dev_log_file_close_cb)(bcm_dev_log_file *file);
190
191/****************************************************************************************/
192/* REWIND CALLBACK: clears memory/file */
193/* file - file handle */
194/****************************************************************************************/
195typedef bcmos_errno (*bcm_dev_log_file_rewind_cb)(bcm_dev_log_file *file);
196
197/****************************************************************************************/
198/* READ_CALLBACK: read form memory/file */
199/* offset - the offset in bytes to read from, output */
200/* buf - Where to put the result */
201/* length - Buffer length */
202/* This function should return the number of bytes actually read from file or 0 if EOF */
203/****************************************************************************************/
204typedef int (*bcm_dev_log_file_read_cb)(bcm_dev_log_file *file, uint32_t *offset, void *buf, uint32_t length);
205
206/****************************************************************************************/
207/* WRITE_CALLBACK: write form memory/file */
208/* buf - The buffer that should be written */
209/* length - The number of bytes to write */
210/* This function should return the number of bytes actually written to file or 0 if EOF */
211/****************************************************************************************/
212typedef int (*bcm_dev_log_file_write_cb)(bcm_dev_log_file *file, const void *buf, uint32_t length);
213
214/* File almost full indication callback prototype */
215typedef bcmos_errno (*F_dev_log_file_almost_full)(long priv);
216
217/* File parameters */
218struct bcm_dev_log_file_parm
219{
220 bcm_dev_log_file_type type;
221 /* File-access callbacks can be NULL for memory files, in this case start_addr */
222 /* should be a valid memory address, all read/writes options will be */
223 /* performed directly to this memory */
224 void *start_addr;
225 uint32_t size;
226 bcm_dev_log_file_open_cb open_cb;
227 bcm_dev_log_file_close_cb close_cb;
228 bcm_dev_log_file_write_cb write_cb;
229 bcm_dev_log_file_read_cb read_cb;
230 bcm_dev_log_file_rewind_cb rewind_cb;
231 bcm_dev_log_file_flags flags;
232 void *udef_parms;
233};
234
235#define FILE_MAGIC_STR_SIZE 16
236#define FILE_MAGIC_STR "@LOGFILE MAGIC@" /* length should be FILE_MAGIC_STR_SIZE (including '\0') */
237
238/* File almost full indication control info */
239typedef struct dev_log_almost_full_info
240{
241 F_dev_log_file_almost_full send_ind_cb;
242 uint32_t threshold;
243 bcmos_bool ind_sent;
244 long priv;
245} dev_log_almost_full_info;
246
247/* Memory file header */
248typedef struct dev_log_mem_file_header
249{
250 uint32_t file_wrap_cnt;
251 uint32_t write_offset;
252 uint32_t data_size;
253 uint32_t num_msgs;
254 char file_magic[FILE_MAGIC_STR_SIZE];
255 char msg_buffer[0];
256} dev_log_mem_file_header;
257
258struct bcm_dev_log_file
259{
260 bcm_dev_log_file_parm file_parm;
261 dev_log_almost_full_info almost_full;
262 bcmos_bool is_full;
263 union
264 {
265 /* Memory file */
266 struct
267 {
268 bcmos_mutex mutex; /* Mutex to lock file access while printing it */
269 dev_log_mem_file_header file_header;
270 } mem_file;
271
272#ifdef BCM_OS_POSIX
273 FILE *reg_file_handle;
274#endif
275
276 /* User-defined file handle */
277 unsigned long udef_handle;
278 } u;
279};
280
281/*******************************************************************************************************/
282/* Get time callback should return an integer representing time. If NULL time prints will be disabled. */
283/*******************************************************************************************************/
284typedef uint32_t (*bcm_dev_log_get_time_cb)(void);
285
286/********************************************************************************************************/
287/* Time to string callback receives timestamp (us) and should convert into time_str */
288/* time_str_size is the maximum number of bytes to be copied. In the end function should update the */
289/* number bytes actually written */
290/* If NULL time will printed as an unsigned integer. */
291/********************************************************************************************************/
292typedef int (*bcm_dev_log_time_to_str_cb)(uint32_t time, char *time_str, int time_str_size);
293typedef int (*bcm_dev_log_print_cb)(void *arg, const char *fmt, ...);
294
295/********************************************/
296/* */
297/* Structs */
298/* */
299/********************************************/
300
301typedef struct
302{
303 bcm_dev_log_get_time_cb get_time_cb;
304 bcm_dev_log_time_to_str_cb time_to_str_cb;
305 bcm_dev_log_print_cb print_cb;
306 void *print_cb_arg;
307 bcm_dev_log_file_parm log_file[DEV_LOG_MAX_FILES];
308} bcm_dev_log_parm;
309
310#ifdef TRIGGER_LOGGER_FEATURE
311typedef struct
312{
313 uint32_t threshold; /* every threshold messages, print one */
314 uint32_t counter; /* current index - runs from 0 to threshold, periodically */
315} dev_log_id_throttle;
316
317typedef struct
318{
319 uint32_t start_threshold; /* start printing when threshold is reached */
320 uint32_t stop_threshold; /* stop printing when threshold is reached, starting counting from start, if 0, do no stop */
321 uint32_t counter; /* current index - runs : first - from 0 to start_threshold
322 second - from start_threshold to stop_threshold */
323 int32_t repeat_threshold;/* the trigger period, how many times the trigger is set, -1 = always */
324 int32_t repeat; /* current repeat counter */
325} dev_log_id_trigger;
326#endif
327typedef struct
328{
329 char name[MAX_DEV_LOG_ID_NAME];
330 bcm_dev_log_id_type log_type;
331 bcm_dev_log_id_type default_log_type;
332 bcm_dev_log_level log_level_print;
333 bcm_dev_log_level log_level_save;
334 bcm_dev_log_level default_log_level;
335 bcm_dev_log_style style;
336 uint32_t lost_msg_cnt;
337 uint32_t print_skipped_count; /* see DEV_LOG_SKIP_PRINT_THRESHOLD_PERCENT */
338 uint32_t counters[DEV_LOG_LEVEL_NUM_OF];
339#ifdef TRIGGER_LOGGER_FEATURE
340 bcm_dev_log_level throttle_log_level;
341 dev_log_id_throttle throttle;
342 bcm_dev_log_level trigger_log_level;
343 dev_log_id_trigger trigger;
344#endif
345} dev_log_id_parm;
346
347/********************************************/
348/* */
349/* Functions prototypes */
350/* */
351/********************************************/
352
353/** Tear down the dev_log, freeing all OS resources. */
354void bcm_dev_log_destroy(void);
355
356/* This function creates default logger that supports logging on the screen and
357 * into 0 or more memory files.
358 */
359bcmos_errno bcm_dev_log_init_default_logger(void **start_addresses,
360 uint32_t *sizes,
361 bcm_dev_log_file_flags *flags,
362 uint32_t num_files,
363 uint32_t stack_size,
364 bcmos_task_priority priority,
365 uint32_t pool_size);
366
367/* This function is more flexible comparing with bcm_dev_log_init_default_logger().
368 * It creates logger that supports logging on the screen and into 0 or more
369 * memory, regular and user-defined files.
370 */
371bcmos_errno bcm_dev_log_init_default_logger_ext(
372 bcm_dev_log_parm *dev_log_parm,
373 uint32_t num_files,
374 uint32_t stack_size,
375 bcmos_task_priority priority,
376 uint32_t pool_size);
377
378/************************************************************************/
379/* */
380/* Name: bcm_dev_log_id_register */
381/* */
382/* Abstract: Add new ID to dev_log and return it to user */
383/* */
384/* Arguments: */
385/* xi_name - ID name */
386/* xi_default_log_level - ID default log level */
387/* xi_default_log_type - ID default log type */
388/* */
389/* Return Value: */
390/* new ID */
391/* */
392/************************************************************************/
393dev_log_id bcm_dev_log_id_register(const char *xi_name,
394 bcm_dev_log_level xi_default_log_level,
395 bcm_dev_log_id_type xi_default_log_type);
396
397/********************************************************************************************/
398/* */
399/* Name: bcm_dev_log_id_set_type */
400/* */
401/* Abstract: Set current log type for an ID */
402/* */
403/* Arguments: */
404/* - xi_id - The ID in the Dev log (what we got form bcm_dev_log_id_register) */
405/* - xi_log_type - New log type */
406/* */
407/* Return Value: */
408/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
409/* */
410/********************************************************************************************/
411bcmos_errno bcm_dev_log_id_set_type(dev_log_id xi_id, bcm_dev_log_id_type xi_log_type);
412
413/********************************************************************************************/
414/* */
415/* Name: bcm_dev_log_id_set_level */
416/* */
417/* Abstract: Set current log level for an ID */
418/* */
419/* Arguments: */
420/* - xi_id - The ID in the Dev log (what we got form bcm_dev_log_id_register) */
421/* - xi_log_level - New log level */
422/* */
423/* Return Value: */
424/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
425/* */
426/********************************************************************************************/
427bcmos_errno bcm_dev_log_id_set_level(dev_log_id xi_id, bcm_dev_log_level xi_log_level_print, bcm_dev_log_level xi_log_level_save);
428
429/********************************************************************************************/
430/* */
431/* Name: bcm_dev_log_id_set_to_default */
432/* */
433/* Abstract: Set log_type and log_level to default (creation) values for an ID */
434/* */
435/* Arguments: */
436/* - xi_id - The ID in the Dev log (what we got form bcm_dev_log_id_register) */
437/* */
438/* Return Value: */
439/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
440/* */
441/********************************************************************************************/
442bcmos_errno bcm_dev_log_id_set_levels_and_type_to_default(dev_log_id xi_id);
443
444/********************************************************************************************/
445/* */
446/* Name: bcm_dev_log_level_set_style */
447/* */
448/* Abstract: Set log style per level */
449/* */
450/* Arguments: */
451/* - xi_level - Log level */
452/* - xi_style - The style of the log, NORMAL, BOLD, UNDERLINE, BLINK, REVERSE_VIDEO */
453/* */
454/* Return Value: */
455/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
456/* */
457/********************************************************************************************/
458void bcm_dev_log_level_set_style(bcm_dev_log_level level, bcm_dev_log_style xi_style);
459
460/********************************************************************************************/
461/* */
462/* Name: bcm_dev_log_id_set_style */
463/* */
464/* Abstract: Set log style per log id */
465/* */
466/* Arguments: */
467/* - xi_id - The ID in the Dev log (what we got form bcm_dev_log_id_register) */
468/* - xi_style - The style of the log, NORMAL, BOLD, UNDERLINE, BLINK, REVERSE_VIDEO */
469/* */
470/* Return Value: */
471/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
472/* */
473/********************************************************************************************/
474bcmos_errno bcm_dev_log_id_set_style(dev_log_id xi_id, bcm_dev_log_style xi_style);
475
476/************************************************************************************************/
477/* */
478/* Name: bcm_dev_log_id_clear_counters */
479/* */
480/* Abstract: Clear counter for an ID */
481/* */
482/* Arguments: */
483/* - xi_id - The ID in the Dev log (what we got form bcm_dev_log_id_register) */
484/* */
485/* Return Value: */
486/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
487/* */
488/************************************************************************************************/
489bcmos_errno bcm_dev_log_id_clear_counters(dev_log_id xi_id);
490
491/********************************************************************************************/
492/* */
493/* Name: bcm_dev_log_id_get */
494/* */
495/* Abstract: Get the ID status (type, level, counters ...) */
496/* */
497/* Arguments: */
498/* - xi_id - The ID in the Dev log (what we got form bcm_dev_log_id_register) */
499/* - xo_id_status - Returned status structure */
500/* */
501/* Return Value: */
502/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
503/* */
504/********************************************************************************************/
505bcmos_errno bcm_dev_log_id_get(dev_log_id xi_id, dev_log_id_parm *xo_id_status);
506
507/********************************************************************************************/
508/* */
509/* Name: bcm_dev_log_id_set */
510/* */
511/* Abstract: set the ID status (type, level, style ...) */
512/* */
513/* Arguments: */
514/* - xi_id - The ID in the Dev log (what we got form bcm_dev_log_id_register) */
515/* - xi_parms - structure to set */
516/* */
517/* Return Value: */
518/* bcmos_errno - Success code (BCM_ERR_OK) or Error code (see bcmos_errno.h) */
519/* */
520/********************************************************************************************/
521bcmos_errno bcm_dev_log_id_set(dev_log_id xi_id, dev_log_id_parm *xi_parms);
522
523/********************************************************************************/
524/* */
525/* Name: bcm_dev_log_id_get_by_index */
526/* */
527/* Abstract: Return ID for index, if no such index return (DEV_LOG_INVALID_ID) */
528/* */
529/* Arguments: */
530/* xi_index - The index of the ID in the global array. */
531/* */
532/* Return Value: */
533/* uint32_t - The ID (DEV_LOG_INVALID_ID if index is not valid) */
534/* */
535/********************************************************************************/
536dev_log_id bcm_dev_log_id_get_by_index(uint32_t xi_index);
537
538/********************************************************************************/
539/* */
540/* Name: bcm_dev_log_get_index_by_id */
541/* */
542/* Abstract: Return ID for index, if no such index return (DEV_LOG_INVALID_ID) */
543/* */
544/* Arguments: */
545/* xi_id - Log id. */
546/* */
547/* Return Value: */
548/* uint32_t - The index ID (DEV_LOG_INVALID_INDEX if id is not valid) */
549/* */
550/********************************************************************************/
551uint32_t bcm_dev_log_get_index_by_id(dev_log_id xi_id);
552
553/********************************************************************************/
554/* */
555/* Name: bcm_dev_log_id_get_by_name */
556/* */
557/* Abstract: Return ID index for name */
558/* */
559/* Arguments: */
560/* xi__name - The name of the ID */
561/* */
562/* Return Value: */
563/* int32_t - The ID index (-1 if name is not valid) */
564/* */
565/********************************************************************************/
566dev_log_id bcm_dev_log_id_get_by_name(const char* xi_name);
567
568uint32_t bcm_dev_log_get_num_of_entries(void);
569
570bcmos_bool bcm_dev_log_get_control(void);
571void bcm_dev_log_set_control(bcmos_bool control);
572
573bcm_dev_log_file_flags bcm_dev_log_get_file_flags(uint32_t file_id);
574void bcm_dev_log_set_file_flags(uint32_t file_id, bcm_dev_log_file_flags flags);
575
576bcm_dev_log_flags bcm_dev_log_get_flags(void);
577void bcm_dev_log_set_flags(bcm_dev_log_flags flags);
578
579void bcm_dev_log_set_print_cb(bcm_dev_log_print_cb cb);
580void bcm_dev_log_set_get_time_cb(bcm_dev_log_get_time_cb cb);
581void bcm_dev_log_set_time_to_str_cb(bcm_dev_log_time_to_str_cb cb);
582
583/* File index to file handle */
584bcm_dev_log_file *bcm_dev_log_file_get(uint32_t file_index);
585
586/* Get number of messages stored in the file */
587uint32_t bcm_dev_log_get_num_of_messages(bcm_dev_log_file *file);
588
589/* Get file info: max data size, used bytes */
590bcmos_errno bcm_dev_log_get_file_info(bcm_dev_log_file *file, uint32_t *file_size, uint32_t *used_bytes);
591
592/* Read from file.
593 * \param[in] file File to read from
594 * \param[in,out] offset offset to read from. 0=read from the start
595 * \param[in,out] buf buffer to read records to
596 * \param[in] buf_len buf size
597 * \returns - number of bytes read >= 0 or bcmos_errno < 0
598 * 0 = no more records to read
599 * BCM_ERR_OVERFLOW - buffer is too short for log record
600 */
601int bcm_dev_log_file_read(bcm_dev_log_file *file, uint32_t *offset, char *buf, uint32_t buf_len);
602
603/* Clear file
604 * \param[in] file File handle
605 * \returns bcmos_errno error code
606 */
607bcmos_errno bcm_dev_log_file_clear(bcm_dev_log_file *file);
608
609/* Attach file to memory buffer.
610 * The file data can be read using bcm_dev_log_file_read or bcm_dev_log_file_read_cut
611 * \param[in] buf buffer to be interpreted as memory file
612 * \param[in] buf_len buf size
613 * \param[out] file File handle.
614 * file_handle has to be destroyed using bcm_dev_log_file_detach() when no longer needed.
615 * \returns bcmos_errno error code
616 */
617bcmos_errno bcm_dev_log_file_attach(void *buf, uint32_t buf_len, bcm_dev_log_file *file);
618
619/* Detach file handle from memory buffer.
620 * Following this call, the file handle becomes invalid
621 * \param[in] file File handle.
622 * \returns bcmos_errno error code
623 */
624bcmos_errno bcm_dev_log_file_detach(bcm_dev_log_file *file);
625
626/* Register indication to be sent when file utilization crosses threshold */
627bcmos_errno bcm_dev_log_almost_full_ind_register(bcm_dev_log_file *file, uint32_t used_bytes_threshold,
628 F_dev_log_file_almost_full send_ind_cb, long ind_cb_priv);
629
630void dev_log_get_log_name_table(char *buffer, uint32_t buf_len);
631
632void bcm_dev_log_drop_report(void);
633
634/** Helper function to determine if a given log level qualifies as an error. */
635static inline bcmos_bool bcm_dev_log_level_is_error(bcm_dev_log_level log_level)
636{
637 return log_level == DEV_LOG_LEVEL_FATAL || log_level == DEV_LOG_LEVEL_ERROR;
638}
639
640/** Returns the percentage (0 - 100) of the msg pool that is currently in use. */
641uint8_t bcm_dev_log_pool_occupancy_percent_get(void);
642
643#ifdef TRIGGER_LOGGER_FEATURE
644bcmos_errno bcm_dev_log_set_throttle(dev_log_id xi_id, bcm_dev_log_level xi_log_level, uint32_t xi_throttle);
645
646bcmos_errno bcm_dev_log_set_trigger(dev_log_id xi_id, bcm_dev_log_level xi_log_level, uint32_t xi_start, uint32_t xi_stop, int32_t xi_repeat);
647#endif /* TRIGGER_LOGGER_FEATURE */
648
649#endif /* ENABLE_LOG */
650
651#endif /* __BCM_DEV_LOG_TASK_H_ */