xref: /wlan-dirver/qca-wifi-host-cmn/iot_sim/core/iot_sim_defs_i.h (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
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_ACTION 0x3
79 #define IOT_SIM_DEBUGFS_FILE_NUM 3
80 #define FRAME_TYPE_IS_BEACON(type, subtype) ((type) == 0 && (subtype) == 8)
81 #define FRAME_TYPE_IS_ACTION(type, subtype) ((type) == 0 && (subtype) == 13)
82 
83 enum iot_sim_action_cat_type {
84 	CAT_BA,
85 	CAT_SA_QUERY,
86 	IOT_SIM_MAX_CAT,
87 };
88 
89 /*
90  * struct iot_sim_debugfs - contains dentry pointer for opened
91  *			    iot sim files and directory
92  * @iot_sim_dir_de - dentry pointer to pdev specific folder
93  * @iot_sim_file_de - dentry pointer representing operation specific files
94  */
95 struct iot_sim_debugfs {
96 	struct dentry *iot_sim_dir_de;
97 	struct dentry *iot_sim_file_de[IOT_SIM_DEBUGFS_FILE_NUM];
98 };
99 
100 /*
101  * struct iot_sim_rule - represent user configured rules
102  * @len - Length of the content provided by user
103  * @offset - offset at which modification done in capture frame
104  * @frm_content - actual user data in hex
105  * @drop - frame marked for drop
106  * @delay_dur - duration of delay
107  */
108 struct iot_sim_rule {
109 	uint16_t len;
110 	uint16_t offset;
111 	uint8_t *frm_content;
112 	bool drop;
113 	uint16_t delay_dur;
114 	uint8_t rule_bitmap;
115 };
116 
117 /*
118  * struct iot_sim_rule_per_seq - rule structure per sequence iot sim files
119  *				 and directory
120  *
121  * @rule_per_type - 2d array of iot_sim_rule per type subtype
122  * @use_count - usage reference
123  */
124 struct iot_sim_rule_per_seq {
125 	struct iot_sim_rule *rule_per_type[N_FRAME_TYPE][N_FRAME_SUBTYPE];
126 	struct iot_sim_rule *rule_per_action_frm[IOT_SIM_MAX_CAT][MAX_ACTION];
127 	uint8_t use_count;
128 };
129 
130 /*
131  * struct iot_sim_rule_per_peer - peer specific structure for iot sim ops
132  *
133  * @addr - address of peer
134  * @iot_sim_lock - spinlock
135  * @rule_per_seq - array of iot_sim_rule_per_seq
136  * @list - list variable
137  */
138 struct iot_sim_rule_per_peer {
139 	struct qdf_mac_addr addr;
140 	qdf_spinlock_t iot_sim_lock;
141 	struct iot_sim_rule_per_seq *rule_per_seq[MAX_SEQ];
142 	qdf_list_t list;
143 };
144 
145 /**
146  * struct iot_sim_context - iot_sim pdev private object
147  * @pdev_obj:Reference to pdev global object
148  * @iot_sim_peer_list: peer list for peer specific rules
149  * @bcast_peer: broadcast peer entry for storing rules for all peers
150  */
151 struct iot_sim_context {
152 	struct wlan_objmgr_pdev *pdev_obj;
153 	/* IOT_SIM Peer list & Bcast Peer */
154 	struct iot_sim_rule_per_peer *iot_sim_peer_list, bcast_peer;
155 	struct iot_sim_debugfs iot_sim_dbgfs_ctx;
156 	void (*iot_sim_update_beacon_trigger)(mlme_pdev_ext_t *);
157 	qdf_nbuf_t bcn_buf;
158 };
159 
160 /* enum iot_sim_operations - iot sim operations
161  *
162  * @INVALID_OPERATION - invalid operation
163  * @CONTENT_CHANGE - Frame Content Change operation
164  * @DROP - Frame drop operation
165  * @DELAY - Frame delay operation
166  * @IOT_SIM_MAX_OPERATION - iot sim max operation
167  */
168 enum iot_sim_operations {
169 	CONTENT_CHANGE,
170 	DROP,
171 	DELAY,
172 	IOT_SIM_MAX_OPERATION
173 };
174 
175 /* enum iot_sim_subcmd - iot sim FW related subcommands
176  *
177  * @ADD_RULE - Add Rule
178  * @DEL_RULE - Delete Rule
179  * @ADD_RULE_ACTION - Add rule for action frame
180  * @DEL_RULE_ACTION - Del rule for action frame
181  * @IOT_SIM_MAX_SUBCMD - iot sim max subcmd
182  */
183 enum iot_sim_subcmd {
184 	ADD_RULE = 0,
185 	DEL_RULE,
186 	ADD_RULE_ACTION,
187 	DEL_RULE_ACTION,
188 	IOT_SIM_MAX_SUBCMD,
189 };
190 
191 #endif /* _IOT_SIM_DEFS_I_H_ */
192