xref: /wlan-driver/qca-wifi-host-cmn/qdf/inc/qdf_hang_event_notifier.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for any
6*5113495bSYour Name  * purpose with or without fee is hereby granted, provided that the above
7*5113495bSYour Name  * copyright notice and this permission notice appear in all copies.
8*5113495bSYour Name  *
9*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*5113495bSYour Name  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*5113495bSYour Name  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*5113495bSYour Name  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*5113495bSYour Name  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*5113495bSYour Name  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*5113495bSYour Name  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*5113495bSYour Name  */
17*5113495bSYour Name 
18*5113495bSYour Name  /**
19*5113495bSYour Name   * DOC: qdf_hang_event_notifier
20*5113495bSYour Name   * This file provides OS dependent QDF notifier call for hang event
21*5113495bSYour Name   */
22*5113495bSYour Name 
23*5113495bSYour Name #ifndef QDF_HANG_EVENT_NOTIFIER_H
24*5113495bSYour Name #define QDF_HANG_EVENT_NOTIFIER_H
25*5113495bSYour Name 
26*5113495bSYour Name #include <qdf_notifier.h>
27*5113495bSYour Name 
28*5113495bSYour Name #define QDF_HANG_EVENT_VERSION "1"
29*5113495bSYour Name /* Max hang event buffer size */
30*5113495bSYour Name #define QDF_HANG_EVENT_DATA_SIZE 390
31*5113495bSYour Name /* Max offset which host can write */
32*5113495bSYour Name #define QDF_WLAN_MAX_HOST_OFFSET 194
33*5113495bSYour Name /* Start of the Firmware Data offset */
34*5113495bSYour Name #define QDF_WLAN_HANG_FW_OFFSET 195
35*5113495bSYour Name 
36*5113495bSYour Name /**
37*5113495bSYour Name  * enum hang_event_tag - Hang event tag for various modules
38*5113495bSYour Name  * @HANG_EVT_TAG_CDS: CDS module hang event tag
39*5113495bSYour Name  * @HANG_EVT_TAG_OS_IF: OS interface module hang event tag
40*5113495bSYour Name  * @HANG_EVT_TAG_OS_IF_SCAN: scan module hang event tag
41*5113495bSYour Name  * @HANG_EVT_TAG_LEGACY_MAC: Legacy mac module hang event tag
42*5113495bSYour Name  * @HANG_EVT_TAG_WMI_EVT_HIST: WMI event history hang event tag
43*5113495bSYour Name  * @HANG_EVT_TAG_WMI_CMD_HIST: WMI command history hang event tag
44*5113495bSYour Name  * @HANG_EVT_TAG_HTC_CREDIT_HIST: HTC credit history hang event tag
45*5113495bSYour Name  * @HANG_EVT_TAG_DP_PEER_INFO: DP peer info hang event tag
46*5113495bSYour Name  * @HANG_EVT_TAG_CE_INFO: Copy Engine hang event tag
47*5113495bSYour Name  * @HANG_EVT_TAG_BUS_INFO: Bus hang event tag
48*5113495bSYour Name  */
49*5113495bSYour Name enum hang_event_tag {
50*5113495bSYour Name 	HANG_EVT_TAG_CDS,
51*5113495bSYour Name 	HANG_EVT_TAG_OS_IF,
52*5113495bSYour Name 	HANG_EVT_TAG_OS_IF_SCAN,
53*5113495bSYour Name 	HANG_EVT_TAG_LEGACY_MAC,
54*5113495bSYour Name 	HANG_EVT_TAG_WMI_EVT_HIST,
55*5113495bSYour Name 	HANG_EVT_TAG_WMI_CMD_HIST,
56*5113495bSYour Name 	HANG_EVT_TAG_HTC_CREDIT_HIST,
57*5113495bSYour Name 	HANG_EVT_TAG_DP_PEER_INFO,
58*5113495bSYour Name 	HANG_EVT_TAG_CE_INFO,
59*5113495bSYour Name 	HANG_EVT_TAG_BUS_INFO
60*5113495bSYour Name };
61*5113495bSYour Name 
62*5113495bSYour Name #define QDF_HANG_EVENT_TLV_HDR_SIZE   (sizeof(uint16_t))
63*5113495bSYour Name 
64*5113495bSYour Name #define QDF_HANG_EVT_SET_HDR(tlv_buf, tag, len) \
65*5113495bSYour Name 	(((uint16_t *)(tlv_buf))[0]) = (((tag) << 8) | ((len) & 0x000000FF))
66*5113495bSYour Name 
67*5113495bSYour Name #define QDF_HANG_GET_STRUCT_TLVLEN(tlv_struct) \
68*5113495bSYour Name 	((uint16_t)(sizeof(tlv_struct) - QDF_HANG_EVENT_TLV_HDR_SIZE))
69*5113495bSYour Name 
70*5113495bSYour Name /**
71*5113495bSYour Name  * struct qdf_notifer_data - Private data for notifier data
72*5113495bSYour Name  * @hang_data: Data filled by notifier
73*5113495bSYour Name  * @offset: Current offset of the hang data buffer
74*5113495bSYour Name  */
75*5113495bSYour Name struct qdf_notifer_data {
76*5113495bSYour Name 	uint8_t *hang_data;
77*5113495bSYour Name 	unsigned int offset;
78*5113495bSYour Name };
79*5113495bSYour Name 
80*5113495bSYour Name #ifdef WLAN_HANG_EVENT
81*5113495bSYour Name /**
82*5113495bSYour Name  * qdf_hang_event_register_notifier() - Hang data notifier register
83*5113495bSYour Name  * @nb: Notifier block
84*5113495bSYour Name  *
85*5113495bSYour Name  * This function registers notifier block for the hang data notifier chain
86*5113495bSYour Name  * the registered function will be invoked when the hang data notifier call
87*5113495bSYour Name  * is invoked.
88*5113495bSYour Name  *
89*5113495bSYour Name  * Return: QDF_STATUS
90*5113495bSYour Name  */
91*5113495bSYour Name QDF_STATUS qdf_hang_event_register_notifier(qdf_notif_block *nb);
92*5113495bSYour Name 
93*5113495bSYour Name /**
94*5113495bSYour Name  * qdf_hang_event_unregister_notifier() - Hang data notifier unregister
95*5113495bSYour Name  * @nb: Notifier block
96*5113495bSYour Name  *
97*5113495bSYour Name  * This function unregisters notifier block for the hang data notifier chain.
98*5113495bSYour Name  *
99*5113495bSYour Name  * Return: QDF_STATUS
100*5113495bSYour Name  */
101*5113495bSYour Name QDF_STATUS qdf_hang_event_unregister_notifier(qdf_notif_block *nb);
102*5113495bSYour Name 
103*5113495bSYour Name /**
104*5113495bSYour Name  * qdf_hang_event_notifier_call() - Hang data notifier register
105*5113495bSYour Name  * @v: state
106*5113495bSYour Name  * @data: Private data for this notifier chain
107*5113495bSYour Name  *
108*5113495bSYour Name  * This function when invoked will call the functions registered with this
109*5113495bSYour Name  * notifier chain.
110*5113495bSYour Name  *
111*5113495bSYour Name  * Return: QDF_STATUS
112*5113495bSYour Name  */
113*5113495bSYour Name QDF_STATUS qdf_hang_event_notifier_call(unsigned long v, void *data);
114*5113495bSYour Name #else
115*5113495bSYour Name static inline
qdf_hang_event_register_notifier(qdf_notif_block * nb)116*5113495bSYour Name QDF_STATUS qdf_hang_event_register_notifier(qdf_notif_block *nb)
117*5113495bSYour Name {
118*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
119*5113495bSYour Name }
120*5113495bSYour Name 
121*5113495bSYour Name static inline
qdf_hang_event_unregister_notifier(qdf_notif_block * nb)122*5113495bSYour Name QDF_STATUS qdf_hang_event_unregister_notifier(qdf_notif_block *nb)
123*5113495bSYour Name {
124*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
125*5113495bSYour Name }
126*5113495bSYour Name 
127*5113495bSYour Name static inline
qdf_hang_event_notifier_call(unsigned long v,void * data)128*5113495bSYour Name QDF_STATUS qdf_hang_event_notifier_call(unsigned long v, void *data)
129*5113495bSYour Name {
130*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
131*5113495bSYour Name }
132*5113495bSYour Name #endif
133*5113495bSYour Name #endif
134