blob: d5220d1f01e99ef2180a5504a63b464cd21572e6 [file] [log] [blame]
Saurabh Misra96998db2014-07-10 12:15:48 -07001/*
2 **************************************************************************
Cemil Coskun5f51db52018-05-07 17:15:37 -07003 * Copyright (c) 2014-2015, 2018 The Linux Foundation. All rights reserved.
Saurabh Misra96998db2014-07-10 12:15:48 -07004 * 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 */
29enum 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 Misra96998db2014-07-10 12:15:48 -070041#define NSS_LOG_COOKIE 0xFF785634
42
Saurabh Misra6d42da72015-03-05 14:57:01 -080043/*
Cemil Coskun5f51db52018-05-07 17:15:37 -070044 * 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 */
53struct 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 Misra6d42da72015-03-05 14:57:01 -080061 * nss_log_entry is shared between Host and NSS FW
62 */
Saurabh Misra96998db2014-07-10 12:15:48 -070063struct nss_log_entry {
Saurabh Misra6d42da72015-03-05 14:57:01 -080064 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 Misra96998db2014-07-10 12:15:48 -070069} __attribute__((aligned(NSS_CACHE_LINE_SIZE)));
70
Saurabh Misra6d42da72015-03-05 14:57:01 -080071/*
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 Misra96998db2014-07-10 12:15:48 -070077struct nss_log_descriptor {
Saurabh Misra6d42da72015-03-05 14:57:01 -080078 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 Misra96998db2014-07-10 12:15:48 -070082 struct nss_log_entry log_ring_buffer[0]; /* The actual log entry ring buffer */
83} __attribute__((aligned(NSS_CACHE_LINE_SIZE)));
84
Cemil Coskun5f51db52018-05-07 17:15:37 -070085struct nss_log_debug_memory_msg {
Saurabh Misra96998db2014-07-10 12:15:48 -070086 uint32_t version;
87 uint32_t nentry;
Saurabh Misra6d42da72015-03-05 14:57:01 -080088 uint32_t phy_addr;
Saurabh Misra96998db2014-07-10 12:15:48 -070089};
90
Cemil Coskun5f51db52018-05-07 17:15:37 -070091struct nss_log_debug_interface_msg {
Saurabh Misra96998db2014-07-10 12:15:48 -070092 struct nss_cmn_msg cm;
93 union {
Cemil Coskun5f51db52018-05-07 17:15:37 -070094 struct nss_log_debug_memory_msg addr;
Saurabh Misra96998db2014-07-10 12:15:48 -070095 } 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 Coskun5f51db52018-05-07 17:15:37 -0700106typedef void (*nss_log_msg_callback_t)(void *app_data, struct nss_log_debug_interface_msg *msg);
Saurabh Misra96998db2014-07-10 12:15:48 -0700107
108/*
109 * Exported by nss_init.c and used in nss_log.c
110 */
111extern int nss_ctl_logbuf;
112
Cemil Coskun5f51db52018-05-07 17:15:37 -0700113extern struct nss_log_ring_buffer_addr nss_rbe[NSS_MAX_CORES];
114
Saurabh Misra96998db2014-07-10 12:15:48 -0700115#endif /* __NSS_LOG_H */