1 /* 2 * Copyright (c) 2020-2021, 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 #define IOT_SIM_DBG_FILE_PERM (QDF_FILE_USR_READ | \ 86 QDF_FILE_USR_WRITE | \ 87 QDF_FILE_GRP_READ | \ 88 QDF_FILE_OTH_READ) 89 90 enum iot_sim_action_cat_type { 91 CAT_SPECTRUM, 92 CAT_QOS, 93 CAT_DLS, 94 CAT_BA, 95 CAT_RADIO, 96 CAT_FAST_BSS_TRNST, 97 CAT_HT, 98 CAT_SA_QUERY, 99 CAT_WNM, 100 CAT_VHT, 101 IOT_SIM_MAX_CAT, 102 }; 103 104 /* 105 * struct iot_sim_debugfs - contains dentry pointer for opened 106 * iot sim files and directory 107 * @iot_sim_dir_de - dentry pointer to pdev specific folder 108 * @iot_sim_file_de - dentry pointer representing operation specific files 109 */ 110 struct iot_sim_debugfs { 111 struct dentry *iot_sim_dir_de; 112 struct dentry *iot_sim_file_de[IOT_SIM_DEBUGFS_FILE_NUM]; 113 }; 114 115 /* 116 * struct iot_sim_rule - represent user configured rules 117 * @len - Length of the content provided by user 118 * @offset - offset at which modification done in capture frame 119 * @frm_content - actual user data in hex 120 * @drop - frame marked for drop 121 * @delay_dur - duration of delay 122 */ 123 struct iot_sim_rule { 124 uint16_t len; 125 uint16_t offset; 126 uint8_t *frm_content; 127 bool drop; 128 uint16_t delay_dur; 129 uint8_t rule_bitmap; 130 qdf_nbuf_t nbuf_list[2]; 131 struct wlan_objmgr_peer *peer; 132 qdf_nbuf_t sec_buf; 133 struct qdf_delayed_work *dwork; 134 struct mgmt_rx_event_params *rx_param; 135 qdf_spinlock_t iot_sim_delay_lock; 136 }; 137 138 /* 139 * struct iot_sim_rule_per_seq - rule structure per sequence iot sim files 140 * and directory 141 * 142 * @rule_per_type - 2d array of iot_sim_rule per type subtype 143 * @use_count - usage reference 144 */ 145 struct iot_sim_rule_per_seq { 146 struct iot_sim_rule *rule_per_type[N_FRAME_TYPE][N_FRAME_SUBTYPE]; 147 struct iot_sim_rule *rule_per_action_frm[IOT_SIM_MAX_CAT][MAX_ACTION]; 148 uint8_t use_count; 149 }; 150 151 /* 152 * struct iot_sim_rule_per_peer - peer specific structure for iot sim ops 153 * 154 * @addr - address of peer 155 * @iot_sim_lock - spinlock 156 * @rule_per_seq - array of iot_sim_rule_per_seq 157 * @list - list variable 158 */ 159 struct iot_sim_rule_per_peer { 160 qdf_list_node_t node; 161 struct qdf_mac_addr addr; 162 struct iot_sim_rule_per_seq *rule_per_seq[MAX_SEQ]; 163 }; 164 165 /** 166 * struct iot_sim_context - iot_sim pdev private object 167 * @pdev_obj:Reference to pdev global object 168 * @iot_sim_peer_list: peer list for peer specific rules 169 * @bcast_peer: broadcast peer entry for storing rules for all peers 170 */ 171 struct iot_sim_context { 172 struct wlan_objmgr_pdev *pdev_obj; 173 /* IOT_SIM Peer list & Bcast Peer */ 174 struct iot_sim_rule_per_peer *iot_sim_peer_list, bcast_peer; 175 qdf_list_t peer_list; 176 qdf_spinlock_t iot_sim_lock; 177 struct iot_sim_debugfs iot_sim_dbgfs_ctx; 178 void (*iot_sim_update_beacon_trigger)(mlme_pdev_ext_t *); 179 qdf_nbuf_t bcn_buf; 180 }; 181 182 /* enum iot_sim_operations - iot sim operations 183 * 184 * @INVALID_OPERATION - invalid operation 185 * @CONTENT_CHANGE - Frame Content Change operation 186 * @DROP - Frame drop operation 187 * @DELAY - Frame delay operation 188 * @IOT_SIM_MAX_OPERATION - iot sim max operation 189 */ 190 enum iot_sim_operations { 191 CONTENT_CHANGE, 192 DROP, 193 DELAY, 194 IOT_SIM_MAX_OPERATION 195 }; 196 197 /* enum iot_sim_subcmd - iot sim FW related subcommands 198 * 199 * @ADD_RULE - Add Rule 200 * @DEL_RULE - Delete Rule 201 * @ADD_RULE_ACTION - Add rule for action frame 202 * @DEL_RULE_ACTION - Del rule for action frame 203 * @IOT_SIM_MAX_SUBCMD - iot sim max subcmd 204 */ 205 enum iot_sim_subcmd { 206 ADD_RULE = 0, 207 DEL_RULE, 208 ADD_RULE_ACTION, 209 DEL_RULE_ACTION, 210 IOT_SIM_MAX_SUBCMD, 211 }; 212 213 struct iot_sim_cb_context { 214 struct iot_sim_context *isc; 215 struct iot_sim_rule *piot_sim_rule; 216 }; 217 218 #endif /* _IOT_SIM_DEFS_I_H_ */ 219