xref: /wlan-dirver/qca-wifi-host-cmn/iot_sim/core/iot_sim_defs_i.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _IOT_SIM_DEFS_I_H_
18 #define _IOT_SIM_DEFS_I_H_
19 
20 #include <wlan_objmgr_cmn.h>
21 #include <wlan_objmgr_global_obj.h>
22 #include <wlan_objmgr_pdev_obj.h>
23 #include <qdf_list.h>
24 #include <qdf_util.h>
25 #include <qdf_types.h>
26 #include <qdf_timer.h>
27 #include <wbuf.h>
28 #include <wlan_iot_sim_utils_api.h>
29 #include <wlan_iot_sim_public_structs.h>
30 
31 #define iot_sim_fatal(format, args...) \
32 	QDF_TRACE_FATAL(QDF_MODULE_ID_IOT_SIM, format, ## args)
33 #define iot_sim_err(format, args...) \
34 	QDF_TRACE_ERROR(QDF_MODULE_ID_IOT_SIM, format, ## args)
35 #define iot_sim_warn(format, args...) \
36 	QDF_TRACE_WARN(QDF_MODULE_ID_IOT_SIM, format, ## args)
37 #define iot_sim_info(format, args...) \
38 	QDF_TRACE_INFO(QDF_MODULE_ID_IOT_SIM, format, ## args)
39 #define iot_sim_debug(format, args...) \
40 	QDF_TRACE_DEBUG(QDF_MODULE_ID_IOT_SIM, format, ## args)
41 
42 #define iot_sim_fatal_nofl(format, args...) \
43 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
44 #define iot_sim_err_nofl(format, args...) \
45 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
46 #define iot_sim_warn_nofl(format, args...) \
47 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
48 #define iot_sim_info_nofl(format, args...) \
49 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
50 #define iot_sim_debug_nofl(format, args...) \
51 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
52 
53 #define iot_sim_fatal_rl(format, args...) \
54 	QDF_TRACE_FATAL_RL(QDF_MODULE_ID_IOT_SIM, format, ## args)
55 #define iot_sim_err_rl(format, args...) \
56 	QDF_TRACE_ERROR_RL(QDF_MODULE_ID_IOT_SIM, format, ## args)
57 #define iot_sim_warn_rl(format, args...) \
58 	QDF_TRACE_WARN_RL(QDF_MODULE_ID_IOT_SIM, format, ## args)
59 #define iot_sim_info_rl(format, args...) \
60 	QDF_TRACE_INFO_RL(QDF_MODULE_ID_IOT_SIM, format, ## args)
61 #define iot_sim_debug_rl(format, args...) \
62 	QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_IOT_SIM, format, ## args)
63 
64 #define iot_sim_fatal_rl_nofl(format, args...) \
65 	QDF_TRACE_FATAL_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
66 #define iot_sim_err_rl_nofl(format, args...) \
67 	QDF_TRACE_ERROR_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
68 #define iot_sim_warn_rl_nofl(format, args...) \
69 	QDF_TRACE_WARN_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
70 #define iot_sim_info_rl_nofl(format, args...) \
71 	QDF_TRACE_INFO_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
72 #define iot_sim_debug_rl_nofl(format, args...) \
73 	QDF_TRACE_DEBUG_RL_NO_FL(QDF_MODULE_ID_IOT_SIM, format, ## args)
74 
75 #define N_FRAME_TYPE 0x4
76 #define N_FRAME_SUBTYPE 0xF
77 #define MAX_SEQ 0x4
78 #define MAX_PEER_COUNT 0x2
79 #define MAX_ACTION 0x1B
80 #define RX_STATUS_SIZE 0x96
81 #define IOT_SIM_DEBUGFS_FILE_NUM 3
82 #define FRAME_TYPE_IS_BEACON(type, subtype) ((type) == 0 && (subtype) == 8)
83 #define FRAME_TYPE_IS_ACTION(type, subtype) ((type) == 0 && (subtype) == 13)
84 
85 enum iot_sim_action_cat_type {
86 	CAT_SPECTRUM,
87 	CAT_QOS,
88 	CAT_DLS,
89 	CAT_BA,
90 	CAT_RADIO,
91 	CAT_FAST_BSS_TRNST,
92 	CAT_HT,
93 	CAT_SA_QUERY,
94 	CAT_WNM,
95 	CAT_VHT,
96 	IOT_SIM_MAX_CAT,
97 };
98 
99 /*
100  * struct iot_sim_debugfs - contains dentry pointer for opened
101  *			    iot sim files and directory
102  * @iot_sim_dir_de - dentry pointer to pdev specific folder
103  * @iot_sim_file_de - dentry pointer representing operation specific files
104  */
105 struct iot_sim_debugfs {
106 	struct dentry *iot_sim_dir_de;
107 	struct dentry *iot_sim_file_de[IOT_SIM_DEBUGFS_FILE_NUM];
108 };
109 
110 /*
111  * struct iot_sim_rule - represent user configured rules
112  * @len - Length of the content provided by user
113  * @offset - offset at which modification done in capture frame
114  * @frm_content - actual user data in hex
115  * @drop - frame marked for drop
116  * @delay_dur - duration of delay
117  */
118 struct iot_sim_rule {
119 	uint16_t len;
120 	uint16_t offset;
121 	uint8_t *frm_content;
122 	bool drop;
123 	uint16_t delay_dur;
124 	uint8_t rule_bitmap;
125 	qdf_nbuf_t nbuf_list[2];
126 	struct wlan_objmgr_peer *peer;
127 	qdf_nbuf_t sec_buf;
128 	struct qdf_delayed_work *dwork;
129 	struct mgmt_rx_event_params *rx_param;
130 	qdf_spinlock_t iot_sim_delay_lock;
131 };
132 
133 /*
134  * struct iot_sim_rule_per_seq - rule structure per sequence iot sim files
135  *				 and directory
136  *
137  * @rule_per_type - 2d array of iot_sim_rule per type subtype
138  * @use_count - usage reference
139  */
140 struct iot_sim_rule_per_seq {
141 	struct iot_sim_rule *rule_per_type[N_FRAME_TYPE][N_FRAME_SUBTYPE];
142 	struct iot_sim_rule *rule_per_action_frm[IOT_SIM_MAX_CAT][MAX_ACTION];
143 	uint8_t use_count;
144 };
145 
146 /*
147  * struct iot_sim_rule_per_peer - peer specific structure for iot sim ops
148  *
149  * @addr - address of peer
150  * @iot_sim_lock - spinlock
151  * @rule_per_seq - array of iot_sim_rule_per_seq
152  * @list - list variable
153  */
154 struct iot_sim_rule_per_peer {
155 	qdf_list_node_t node;
156 	struct qdf_mac_addr addr;
157 	struct iot_sim_rule_per_seq *rule_per_seq[MAX_SEQ];
158 };
159 
160 /**
161  * struct iot_sim_context - iot_sim pdev private object
162  * @pdev_obj:Reference to pdev global object
163  * @iot_sim_peer_list: peer list for peer specific rules
164  * @bcast_peer: broadcast peer entry for storing rules for all peers
165  */
166 struct iot_sim_context {
167 	struct wlan_objmgr_pdev *pdev_obj;
168 	/* IOT_SIM Peer list & Bcast Peer */
169 	struct iot_sim_rule_per_peer *iot_sim_peer_list, bcast_peer;
170 	qdf_list_t peer_list;
171 	qdf_spinlock_t iot_sim_lock;
172 	struct iot_sim_debugfs iot_sim_dbgfs_ctx;
173 	void (*iot_sim_update_beacon_trigger)(mlme_pdev_ext_t *);
174 	qdf_nbuf_t bcn_buf;
175 };
176 
177 /* enum iot_sim_operations - iot sim operations
178  *
179  * @INVALID_OPERATION - invalid operation
180  * @CONTENT_CHANGE - Frame Content Change operation
181  * @DROP - Frame drop operation
182  * @DELAY - Frame delay operation
183  * @IOT_SIM_MAX_OPERATION - iot sim max operation
184  */
185 enum iot_sim_operations {
186 	CONTENT_CHANGE,
187 	DROP,
188 	DELAY,
189 	IOT_SIM_MAX_OPERATION
190 };
191 
192 /* enum iot_sim_subcmd - iot sim FW related subcommands
193  *
194  * @ADD_RULE - Add Rule
195  * @DEL_RULE - Delete Rule
196  * @ADD_RULE_ACTION - Add rule for action frame
197  * @DEL_RULE_ACTION - Del rule for action frame
198  * @IOT_SIM_MAX_SUBCMD - iot sim max subcmd
199  */
200 enum iot_sim_subcmd {
201 	ADD_RULE = 0,
202 	DEL_RULE,
203 	ADD_RULE_ACTION,
204 	DEL_RULE_ACTION,
205 	IOT_SIM_MAX_SUBCMD,
206 };
207 
208 struct iot_sim_cb_context {
209 	struct iot_sim_context *isc;
210 	struct iot_sim_rule *piot_sim_rule;
211 };
212 
213 #endif /* _IOT_SIM_DEFS_I_H_ */
214