blob: fd463c5afb38d259e3e66cbea8d5478d20b8038b [file] [log] [blame]
Saurabh Misra96998db2014-07-10 12:15:48 -07001/*
2 **************************************************************************
Saurabh Misra6d42da72015-03-05 14:57:01 -08003 * Copyright (c) 2014-2015, 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
41#define NSS_CACHE_LINE_SIZE 32
42#define NSS_LOG_COOKIE 0xFF785634
43
Saurabh Misra6d42da72015-03-05 14:57:01 -080044/*
45 * nss_log_entry is shared between Host and NSS FW
46 */
Saurabh Misra96998db2014-07-10 12:15:48 -070047struct nss_log_entry {
Saurabh Misra6d42da72015-03-05 14:57:01 -080048 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 Misra96998db2014-07-10 12:15:48 -070053} __attribute__((aligned(NSS_CACHE_LINE_SIZE)));
54
Saurabh Misra6d42da72015-03-05 14:57:01 -080055/*
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 Misra96998db2014-07-10 12:15:48 -070061struct nss_log_descriptor {
Saurabh Misra6d42da72015-03-05 14:57:01 -080062 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 Misra96998db2014-07-10 12:15:48 -070066 struct nss_log_entry log_ring_buffer[0]; /* The actual log entry ring buffer */
67} __attribute__((aligned(NSS_CACHE_LINE_SIZE)));
68
69struct nss_debug_log_memory_msg {
70 uint32_t version;
71 uint32_t nentry;
Saurabh Misra6d42da72015-03-05 14:57:01 -080072 uint32_t phy_addr;
Saurabh Misra96998db2014-07-10 12:15:48 -070073};
74
75struct 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 */
90typedef 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 */
95extern int nss_ctl_logbuf;
96
97#endif /* __NSS_LOG_H */