Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Cemil Coskun | 5f51db5 | 2018-05-07 17:15:37 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2014-2015, 2018 The Linux Foundation. All rights reserved. |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all copies. |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 13 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | ************************************************************************** |
| 15 | */ |
| 16 | /* |
| 17 | * nss_log.h |
| 18 | * NSS FW debug log memory header file |
| 19 | */ |
| 20 | |
| 21 | #ifndef __NSS_LOG_H |
| 22 | #define __NSS_LOG_H |
| 23 | |
| 24 | #define NSS_DEBUG_LOG_VERSION 0x1 |
| 25 | |
| 26 | /** |
| 27 | * Dynamic Interface types |
| 28 | */ |
| 29 | enum nss_debug_interface_msg_type { |
| 30 | NSS_DEBUG_INTERFACE_TYPE_NONE = 0, |
| 31 | NSS_DEBUG_INTERFACE_TYPE_LOG_BUF_INIT = 1, |
| 32 | NSS_DEBUG_INTERFACE_TYPE_MAX, |
| 33 | }; |
| 34 | |
| 35 | /* |
| 36 | * The size of each log entry to be displayed. |
| 37 | */ |
| 38 | #define NSS_LOG_OUTPUT_LINE_SIZE 151 /* 5 + 12 + 132 + '\n' + '\0' (see below) */ |
| 39 | #define NSS_LOG_LINE_FORMAT "%3d: %010u: %s\n" |
| 40 | #define NSS_LOG_LINE_WIDTH 132 |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 41 | #define NSS_LOG_COOKIE 0xFF785634 |
| 42 | |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 43 | /* |
Cemil Coskun | 5f51db5 | 2018-05-07 17:15:37 -0700 | [diff] [blame^] | 44 | * Dump last N entry during the coredump. |
| 45 | * This number should be lower than the minimum size of the logbuf |
| 46 | * which 32 right now. |
| 47 | */ |
| 48 | #define NSS_LOG_COREDUMP_LINE_NUM 10 |
| 49 | |
| 50 | /* |
| 51 | * Saves the ring buffer address for logging per NSS core |
| 52 | */ |
| 53 | struct nss_log_ring_buffer_addr { |
| 54 | void *addr; /* Pointer to struct nss_log_descriptor */ |
| 55 | dma_addr_t dma_addr; /* DMA Handle */ |
| 56 | uint32_t nentries; /* Number of entries in the ring buffer */ |
| 57 | int ref_cnt; /* Reference count */ |
| 58 | }; |
| 59 | |
| 60 | /* |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 61 | * nss_log_entry is shared between Host and NSS FW |
| 62 | */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 63 | struct nss_log_entry { |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 64 | uint64_t sequence_num; /* Sequence number */ |
| 65 | uint32_t cookie; /* Magic for verification */ |
| 66 | uint32_t thread_num; /* thread-id */ |
| 67 | uint32_t timestamp; /* timestamp in ticks */ |
| 68 | char message[NSS_LOG_LINE_WIDTH]; /* actual debug message */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 69 | } __attribute__((aligned(NSS_CACHE_LINE_SIZE))); |
| 70 | |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 71 | /* |
| 72 | * The NSS log descripts holds ring-buffer along with other variables and |
| 73 | * it is shared between NSS FW and Host. |
| 74 | * |
| 75 | * NSS FW writes to ring buffer and current_entry but read by only Host. |
| 76 | */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 77 | struct nss_log_descriptor { |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 78 | uint32_t cookie; /* Magic for verification */ |
| 79 | uint32_t log_nentries; /* No.of log entries */ |
| 80 | uint32_t current_entry; /* pointer to current log entry */ |
| 81 | uint8_t pad[20]; /* pad to align ring buffer at cacheline boundary */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 82 | struct nss_log_entry log_ring_buffer[0]; /* The actual log entry ring buffer */ |
| 83 | } __attribute__((aligned(NSS_CACHE_LINE_SIZE))); |
| 84 | |
Cemil Coskun | 5f51db5 | 2018-05-07 17:15:37 -0700 | [diff] [blame^] | 85 | struct nss_log_debug_memory_msg { |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 86 | uint32_t version; |
| 87 | uint32_t nentry; |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 88 | uint32_t phy_addr; |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Cemil Coskun | 5f51db5 | 2018-05-07 17:15:37 -0700 | [diff] [blame^] | 91 | struct nss_log_debug_interface_msg { |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 92 | struct nss_cmn_msg cm; |
| 93 | union { |
Cemil Coskun | 5f51db5 | 2018-05-07 17:15:37 -0700 | [diff] [blame^] | 94 | struct nss_log_debug_memory_msg addr; |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 95 | } msg; |
| 96 | }; |
| 97 | |
| 98 | /** |
| 99 | * @brief Callback to receive debug interface messages |
| 100 | * |
| 101 | * @param app_data Application context of the message |
| 102 | * @param msg Message data |
| 103 | * |
| 104 | * @return void |
| 105 | */ |
Cemil Coskun | 5f51db5 | 2018-05-07 17:15:37 -0700 | [diff] [blame^] | 106 | typedef void (*nss_log_msg_callback_t)(void *app_data, struct nss_log_debug_interface_msg *msg); |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 107 | |
| 108 | /* |
| 109 | * Exported by nss_init.c and used in nss_log.c |
| 110 | */ |
| 111 | extern int nss_ctl_logbuf; |
| 112 | |
Cemil Coskun | 5f51db5 | 2018-05-07 17:15:37 -0700 | [diff] [blame^] | 113 | extern struct nss_log_ring_buffer_addr nss_rbe[NSS_MAX_CORES]; |
| 114 | |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 115 | #endif /* __NSS_LOG_H */ |