Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 3 | * Copyright (c) 2014-2015, 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 |
| 41 | #define NSS_CACHE_LINE_SIZE 32 |
| 42 | #define NSS_LOG_COOKIE 0xFF785634 |
| 43 | |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 44 | /* |
| 45 | * nss_log_entry is shared between Host and NSS FW |
| 46 | */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 47 | struct nss_log_entry { |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 48 | uint64_t sequence_num; /* Sequence number */ |
| 49 | uint32_t cookie; /* Magic for verification */ |
| 50 | uint32_t thread_num; /* thread-id */ |
| 51 | uint32_t timestamp; /* timestamp in ticks */ |
| 52 | char message[NSS_LOG_LINE_WIDTH]; /* actual debug message */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 53 | } __attribute__((aligned(NSS_CACHE_LINE_SIZE))); |
| 54 | |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 55 | /* |
| 56 | * The NSS log descripts holds ring-buffer along with other variables and |
| 57 | * it is shared between NSS FW and Host. |
| 58 | * |
| 59 | * NSS FW writes to ring buffer and current_entry but read by only Host. |
| 60 | */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 61 | struct nss_log_descriptor { |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 62 | uint32_t cookie; /* Magic for verification */ |
| 63 | uint32_t log_nentries; /* No.of log entries */ |
| 64 | uint32_t current_entry; /* pointer to current log entry */ |
| 65 | uint8_t pad[20]; /* pad to align ring buffer at cacheline boundary */ |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 66 | struct nss_log_entry log_ring_buffer[0]; /* The actual log entry ring buffer */ |
| 67 | } __attribute__((aligned(NSS_CACHE_LINE_SIZE))); |
| 68 | |
| 69 | struct nss_debug_log_memory_msg { |
| 70 | uint32_t version; |
| 71 | uint32_t nentry; |
Saurabh Misra | 6d42da7 | 2015-03-05 14:57:01 -0800 | [diff] [blame] | 72 | uint32_t phy_addr; |
Saurabh Misra | 96998db | 2014-07-10 12:15:48 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | struct nss_debug_interface_msg { |
| 76 | struct nss_cmn_msg cm; |
| 77 | union { |
| 78 | struct nss_debug_log_memory_msg addr; |
| 79 | } msg; |
| 80 | }; |
| 81 | |
| 82 | /** |
| 83 | * @brief Callback to receive debug interface messages |
| 84 | * |
| 85 | * @param app_data Application context of the message |
| 86 | * @param msg Message data |
| 87 | * |
| 88 | * @return void |
| 89 | */ |
| 90 | typedef void (*nss_log_msg_callback_t)(void *app_data, struct nss_debug_interface_msg *msg); |
| 91 | |
| 92 | /* |
| 93 | * Exported by nss_init.c and used in nss_log.c |
| 94 | */ |
| 95 | extern int nss_ctl_logbuf; |
| 96 | |
| 97 | #endif /* __NSS_LOG_H */ |