Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 1 | /* |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 3 | * |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 4 | * 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 |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 19 | /** |
| 20 | * DOC: Declare various struct, macros which are used privately in IPA |
| 21 | * component. |
| 22 | */ |
| 23 | |
| 24 | #ifndef _WLAN_IPA_PRIV_STRUCT_H_ |
| 25 | #define _WLAN_IPA_PRIV_STRUCT_H_ |
| 26 | |
| 27 | #ifdef IPA_OFFLOAD |
| 28 | |
| 29 | #ifdef CONFIG_IPA_WDI_UNIFIED_API |
| 30 | #include <qdf_ipa_wdi3.h> |
| 31 | #else |
| 32 | #include <qdf_ipa.h> |
| 33 | #endif |
| 34 | |
| 35 | #include <qdf_net_types.h> |
| 36 | #include <qdf_mc_timer.h> |
| 37 | #include <qdf_list.h> |
| 38 | #include <qdf_defer.h> |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 39 | #include "qdf_delayed_work.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 40 | #include <qdf_event.h> |
| 41 | #include "wlan_ipa_public_struct.h" |
| 42 | |
| 43 | #define WLAN_IPA_RX_INACTIVITY_MSEC_DELAY 1000 |
| 44 | #define WLAN_IPA_UC_WLAN_8023_HDR_SIZE 14 |
| 45 | |
| 46 | #define WLAN_IPA_UC_NUM_WDI_PIPE 2 |
| 47 | #define WLAN_IPA_UC_MAX_PENDING_EVENT 33 |
| 48 | |
| 49 | #define WLAN_IPA_UC_DEBUG_DUMMY_MEM_SIZE 32000 |
| 50 | #define WLAN_IPA_UC_RT_DEBUG_PERIOD 300 |
| 51 | #define WLAN_IPA_UC_RT_DEBUG_BUF_COUNT 30 |
| 52 | #define WLAN_IPA_UC_RT_DEBUG_FILL_INTERVAL 10000 |
| 53 | |
| 54 | #define WLAN_IPA_WLAN_HDR_DES_MAC_OFFSET 0 |
Chaoli Zhou | b11e18a | 2019-07-08 15:14:20 +0800 | [diff] [blame^] | 55 | #define WLAN_IPA_MAX_IFACE MAX_IPA_IFACE |
| 56 | #define WLAN_IPA_CLIENT_MAX_IFACE 3 |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 57 | #define WLAN_IPA_MAX_SYSBAM_PIPE 4 |
| 58 | #define WLAN_IPA_MAX_SESSION 5 |
| 59 | #define WLAN_IPA_MAX_STA_COUNT 41 |
| 60 | |
| 61 | #define WLAN_IPA_RX_PIPE WLAN_IPA_MAX_IFACE |
| 62 | #define WLAN_IPA_ENABLE_MASK BIT(0) |
| 63 | #define WLAN_IPA_PRE_FILTER_ENABLE_MASK BIT(1) |
| 64 | #define WLAN_IPA_IPV6_ENABLE_MASK BIT(2) |
| 65 | #define WLAN_IPA_RM_ENABLE_MASK BIT(3) |
| 66 | #define WLAN_IPA_CLK_SCALING_ENABLE_MASK BIT(4) |
| 67 | #define WLAN_IPA_UC_ENABLE_MASK BIT(5) |
| 68 | #define WLAN_IPA_UC_STA_ENABLE_MASK BIT(6) |
| 69 | #define WLAN_IPA_REAL_TIME_DEBUGGING BIT(8) |
| 70 | |
| 71 | #define WLAN_IPA_MAX_BANDWIDTH 800 |
| 72 | |
| 73 | #define WLAN_IPA_MAX_PENDING_EVENT_COUNT 20 |
| 74 | |
Tiger Yu | f5249d9 | 2018-09-20 17:37:54 +0800 | [diff] [blame] | 75 | #define IPA_WLAN_RX_SOFTIRQ_THRESH 32 |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * enum - IPA UC operation message |
| 79 | * |
| 80 | * @WLAN_IPA_UC_OPCODE_TX_SUSPEND: IPA WDI TX pipe suspend |
| 81 | * @WLAN_IPA_UC_OPCODE_TX_RESUME: IPA WDI TX pipe resume |
| 82 | * @WLAN_IPA_UC_OPCODE_RX_SUSPEND: IPA WDI RX pipe suspend |
| 83 | * @WLAN_IPA_UC_OPCODE_RX_RESUME: IPA WDI RX pipe resume |
| 84 | * @WLAN_IPA_UC_OPCODE_STATS: IPA UC stats |
| 85 | * @WLAN_IPA_UC_OPCODE_SHARING_STATS: IPA UC sharing stats |
| 86 | * @WLAN_IPA_UC_OPCODE_QUOTA_RSP: IPA UC quota response |
| 87 | * @WLAN_IPA_UC_OPCODE_QUOTA_IND: IPA UC quota indication |
| 88 | * @WLAN_IPA_UC_OPCODE_UC_READY: IPA UC ready indication |
| 89 | * @WLAN_IPA_UC_OPCODE_MAX: IPA UC max operation code |
| 90 | */ |
| 91 | enum wlan_ipa_uc_op_code { |
| 92 | WLAN_IPA_UC_OPCODE_TX_SUSPEND = 0, |
| 93 | WLAN_IPA_UC_OPCODE_TX_RESUME = 1, |
| 94 | WLAN_IPA_UC_OPCODE_RX_SUSPEND = 2, |
| 95 | WLAN_IPA_UC_OPCODE_RX_RESUME = 3, |
| 96 | WLAN_IPA_UC_OPCODE_STATS = 4, |
| 97 | #ifdef FEATURE_METERING |
| 98 | WLAN_IPA_UC_OPCODE_SHARING_STATS = 5, |
| 99 | WLAN_IPA_UC_OPCODE_QUOTA_RSP = 6, |
| 100 | WLAN_IPA_UC_OPCODE_QUOTA_IND = 7, |
| 101 | #endif |
| 102 | WLAN_IPA_UC_OPCODE_UC_READY = 8, |
| 103 | /* keep this last */ |
| 104 | WLAN_IPA_UC_OPCODE_MAX |
| 105 | }; |
| 106 | |
| 107 | /** |
| 108 | * enum - Reason codes for stat query |
| 109 | * |
| 110 | * @WLAN_IPA_UC_STAT_REASON_NONE: Initial value |
| 111 | * @WLAN_IPA_UC_STAT_REASON_DEBUG: For debug/info |
| 112 | * @WLAN_IPA_UC_STAT_REASON_BW_CAL: For bandwidth calibration |
| 113 | * @WLAN_IPA_UC_STAT_REASON_DUMP_INFO: For debug info dump |
| 114 | */ |
| 115 | enum { |
| 116 | WLAN_IPA_UC_STAT_REASON_NONE, |
| 117 | WLAN_IPA_UC_STAT_REASON_DEBUG, |
| 118 | WLAN_IPA_UC_STAT_REASON_BW_CAL |
| 119 | }; |
| 120 | |
| 121 | /** |
| 122 | * enum wlan_ipa_rm_state - IPA resource manager state |
| 123 | * @WLAN_IPA_RM_RELEASED: PROD pipe resource released |
| 124 | * @WLAN_IPA_RM_GRANT_PENDING: PROD pipe resource requested but not granted yet |
| 125 | * @WLAN_IPA_RM_GRANTED: PROD pipe resource granted |
| 126 | */ |
| 127 | enum wlan_ipa_rm_state { |
| 128 | WLAN_IPA_RM_RELEASED, |
| 129 | WLAN_IPA_RM_GRANT_PENDING, |
| 130 | WLAN_IPA_RM_GRANTED, |
| 131 | }; |
| 132 | |
| 133 | /** |
| 134 | * enum wlan_ipa_forward_type: Type of forward packet received from IPA |
| 135 | * @WLAN_IPA_FORWARD_PKT_NONE: No forward packet |
| 136 | * @WLAN_IPA_FORWARD_PKT_LOCAL_STACK: Packet forwarded to kernel network stack |
| 137 | * @WLAN_IPA_FORWARD_PKT_DISCARD: Discarded packet before sending to kernel |
| 138 | */ |
| 139 | enum wlan_ipa_forward_type { |
| 140 | WLAN_IPA_FORWARD_PKT_NONE = 0, |
| 141 | WLAN_IPA_FORWARD_PKT_LOCAL_STACK = 1, |
| 142 | WLAN_IPA_FORWARD_PKT_DISCARD = 2 |
| 143 | }; |
| 144 | |
| 145 | /** |
| 146 | * struct llc_snap_hdr - LLC snap header |
| 147 | * @dsap: Destination service access point |
| 148 | * @ssap: Source service access point |
| 149 | * @resv: Reserved for future use |
| 150 | * @eth_type: Ether type |
| 151 | */ |
| 152 | struct llc_snap_hdr { |
| 153 | uint8_t dsap; |
| 154 | uint8_t ssap; |
| 155 | uint8_t resv[4]; |
| 156 | qdf_be16_t eth_type; |
| 157 | } qdf_packed; |
| 158 | |
| 159 | /** |
| 160 | * struct wlan_ipa_tx_hdr - header type which IPA should handle to TX packet |
| 161 | * @eth: ether II header |
| 162 | * @llc_snap: LLC snap header |
| 163 | */ |
| 164 | struct wlan_ipa_tx_hdr { |
| 165 | qdf_ether_header_t eth; |
| 166 | struct llc_snap_hdr llc_snap; |
| 167 | } qdf_packed; |
| 168 | |
| 169 | /** |
| 170 | * struct frag_header - fragment header type registered to IPA hardware |
| 171 | * @length: fragment length |
| 172 | * @reserved1: Reserved not used |
| 173 | * @reserved2: Reserved not used |
| 174 | */ |
jiad | 42cc9fd | 2019-03-22 15:04:47 +0800 | [diff] [blame] | 175 | #if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) |
| 176 | struct frag_header { |
| 177 | uint8_t reserved[0]; |
| 178 | }; |
| 179 | #elif defined(QCA_WIFI_3_0) |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 180 | struct frag_header { |
| 181 | uint16_t length; |
| 182 | uint32_t reserved1; |
| 183 | uint32_t reserved2; |
| 184 | } qdf_packed; |
jiad | 80055eb | 2018-04-05 12:45:58 +0800 | [diff] [blame] | 185 | #else |
| 186 | struct frag_header { |
| 187 | uint32_t |
| 188 | length:16, |
| 189 | reserved16:16; |
| 190 | uint32_t reserved2; |
| 191 | } qdf_packed; |
| 192 | #endif |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 193 | |
| 194 | /** |
| 195 | * struct ipa_header - ipa header type registered to IPA hardware |
| 196 | * @vdev_id: vdev id |
| 197 | * @reserved: Reserved not used |
| 198 | */ |
jiad | 42cc9fd | 2019-03-22 15:04:47 +0800 | [diff] [blame] | 199 | |
| 200 | #if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390) |
| 201 | struct ipa_header { |
| 202 | uint8_t reserved[0]; |
| 203 | }; |
| 204 | #else |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 205 | struct ipa_header { |
| 206 | uint32_t |
| 207 | vdev_id:8, /* vdev_id field is LSB of IPA DESC */ |
| 208 | reserved:24; |
| 209 | } qdf_packed; |
jiad | 42cc9fd | 2019-03-22 15:04:47 +0800 | [diff] [blame] | 210 | #endif |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * struct wlan_ipa_uc_tx_hdr - full tx header registered to IPA hardware |
| 214 | * @frag_hd: fragment header |
| 215 | * @ipa_hd: ipa header |
| 216 | * @eth: ether II header |
| 217 | */ |
| 218 | struct wlan_ipa_uc_tx_hdr { |
| 219 | struct frag_header frag_hd; |
| 220 | struct ipa_header ipa_hd; |
| 221 | qdf_ether_header_t eth; |
| 222 | } qdf_packed; |
| 223 | |
| 224 | /** |
| 225 | * struct wlan_ipa_cld_hdr - IPA CLD Header |
| 226 | * @reserved: reserved fields |
| 227 | * @iface_id: interface ID |
| 228 | * @sta_id: Station ID |
| 229 | * |
| 230 | * Packed 32-bit structure |
| 231 | * +----------+----------+--------------+--------+ |
| 232 | * | Reserved | QCMAP ID | interface id | STA ID | |
| 233 | * +----------+----------+--------------+--------+ |
| 234 | */ |
| 235 | struct wlan_ipa_cld_hdr { |
| 236 | uint8_t reserved[2]; |
| 237 | uint8_t iface_id; |
| 238 | uint8_t sta_id; |
| 239 | } qdf_packed; |
| 240 | |
| 241 | /** |
| 242 | * struct wlan_ipa_rx_hdr - IPA RX header |
| 243 | * @cld_hdr: IPA CLD header |
| 244 | * @eth: ether II header |
| 245 | */ |
| 246 | struct wlan_ipa_rx_hdr { |
| 247 | struct wlan_ipa_cld_hdr cld_hdr; |
| 248 | qdf_ether_header_t eth; |
| 249 | } qdf_packed; |
| 250 | |
| 251 | /** |
| 252 | * struct wlan_ipa_pm_tx_cb - PM resume TX callback |
| 253 | * @exception: Exception packet |
| 254 | * @iface_context: Interface context |
| 255 | * @ipa_tx_desc: IPA TX descriptor |
| 256 | */ |
| 257 | struct wlan_ipa_pm_tx_cb { |
| 258 | bool exception; |
| 259 | struct wlan_ipa_iface_context *iface_context; |
| 260 | qdf_ipa_rx_data_t *ipa_tx_desc; |
| 261 | }; |
| 262 | |
| 263 | /** |
| 264 | * struct wlan_ipa_sys_pipe - IPA system pipe |
| 265 | * @conn_hdl: IPA system pipe connection handle |
| 266 | * @conn_hdl_valid: IPA system pipe valid flag |
| 267 | * @ipa_sys_params: IPA system pipe params |
| 268 | */ |
| 269 | struct wlan_ipa_sys_pipe { |
| 270 | uint32_t conn_hdl; |
| 271 | uint8_t conn_hdl_valid; |
| 272 | qdf_ipa_sys_connect_params_t ipa_sys_params; |
| 273 | }; |
| 274 | |
| 275 | /** |
| 276 | * struct wlan_ipa_iface_stats - IPA system pipe |
| 277 | * @num_tx: Number of TX packets |
| 278 | * @num_tx_drop: Number of TX packet drops |
| 279 | * @num_tx_err: Number of TX packet errors |
| 280 | * @num_tx_cac_drop: Number of TX packet drop due to CAC |
| 281 | * @num_rx_ipa_excep: Number of RX IPA exception packets |
| 282 | */ |
| 283 | struct wlan_ipa_iface_stats { |
| 284 | uint64_t num_tx; |
| 285 | uint64_t num_tx_drop; |
| 286 | uint64_t num_tx_err; |
| 287 | uint64_t num_tx_cac_drop; |
| 288 | uint64_t num_rx_ipa_excep; |
| 289 | }; |
| 290 | |
| 291 | /* IPA private context structure */ |
| 292 | struct wlan_ipa_priv; |
| 293 | |
| 294 | /** |
| 295 | * struct wlan_ipa_iface_context - IPA interface context |
| 296 | * @ipa_ctx: IPA private context |
| 297 | * @tl_context: TL context |
| 298 | * @cons_client: IPA consumer pipe |
| 299 | * @prod_client: IPA producer pipe |
| 300 | * @prod_client: IPA producer pipe |
| 301 | * @iface_id: IPA interface ID |
| 302 | * @dev: Net device structure |
| 303 | * @device_mode: Interface device mode |
| 304 | * @sta_id: Interface station ID |
| 305 | * @session_id: Session ID |
| 306 | * @interface_lock: Interface lock |
| 307 | * @ifa_address: Interface address |
| 308 | * @stats: Interface stats |
| 309 | */ |
| 310 | struct wlan_ipa_iface_context { |
| 311 | struct wlan_ipa_priv *ipa_ctx; |
| 312 | void *tl_context; |
| 313 | |
| 314 | qdf_ipa_client_type_t cons_client; |
| 315 | qdf_ipa_client_type_t prod_client; |
| 316 | |
| 317 | uint8_t iface_id; /* This iface ID */ |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 318 | qdf_netdev_t dev; |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 319 | enum QDF_OPMODE device_mode; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 320 | uint8_t sta_id; /* This iface station ID */ |
| 321 | uint8_t session_id; |
| 322 | qdf_spinlock_t interface_lock; |
| 323 | uint32_t ifa_address; |
| 324 | struct wlan_ipa_iface_stats stats; |
| 325 | }; |
| 326 | |
| 327 | /** |
| 328 | * struct wlan_ipa_stats - IPA system stats |
| 329 | * @event: WLAN IPA event record |
| 330 | * @num_send_msg: Number of sent IPA messages |
| 331 | * @num_rm_grant: Number of times IPA RM resource granted |
| 332 | * @num_rm_release: Number of times IPA RM resource released |
| 333 | * @num_rm_grant_imm: Number of immediate IPA RM granted |
| 334 | e @num_cons_perf_req: Number of CONS pipe perf request |
| 335 | * @num_prod_perf_req: Number of PROD pipe perf request |
| 336 | * @num_rx_drop: Number of RX packet drops |
| 337 | * @num_tx_desc_q_cnt: Number of TX descriptor queue count |
| 338 | * @num_tx_desc_err: Number of TX descriptor error |
| 339 | * @num_tx_comp_cnt: Number of TX qdf_event_t count |
| 340 | * @num_tx_queued: Number of TX queued |
| 341 | * @num_tx_dequeued: Number of TX dequeued |
| 342 | * @num_max_pm_queue: Number of packets in PM queue |
| 343 | * @num_rx_excep: Number of RX IPA exception packets |
| 344 | * @num_tx_fwd_ok: Number of TX forward packet success |
| 345 | * @num_tx_fwd_err: Number of TX forward packet failures |
| 346 | */ |
| 347 | struct wlan_ipa_stats { |
jiad | 629b217 | 2018-05-11 15:34:22 +0800 | [diff] [blame] | 348 | uint32_t event[QDF_IPA_WLAN_EVENT_MAX]; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 349 | uint64_t num_send_msg; |
| 350 | uint64_t num_free_msg; |
| 351 | uint64_t num_rm_grant; |
| 352 | uint64_t num_rm_release; |
| 353 | uint64_t num_rm_grant_imm; |
| 354 | uint64_t num_cons_perf_req; |
| 355 | uint64_t num_prod_perf_req; |
| 356 | uint64_t num_rx_drop; |
| 357 | uint64_t num_tx_desc_q_cnt; |
| 358 | uint64_t num_tx_desc_error; |
| 359 | uint64_t num_tx_comp_cnt; |
| 360 | uint64_t num_tx_queued; |
| 361 | uint64_t num_tx_dequeued; |
| 362 | uint64_t num_max_pm_queue; |
| 363 | uint64_t num_rx_excep; |
| 364 | uint64_t num_tx_fwd_ok; |
| 365 | uint64_t num_tx_fwd_err; |
| 366 | }; |
| 367 | |
| 368 | /** |
| 369 | * struct ipa_uc_stas_map - IPA UC assoc station map |
| 370 | * @is_reserved: STA reserved flag |
| 371 | * @sta_id: Station ID |
| 372 | * @mac_addr: Station mac address |
| 373 | */ |
| 374 | struct ipa_uc_stas_map { |
| 375 | bool is_reserved; |
| 376 | uint8_t sta_id; |
| 377 | struct qdf_mac_addr mac_addr; |
| 378 | }; |
| 379 | |
| 380 | /** |
| 381 | * struct op_msg_type - IPA operation message type |
| 382 | * @msg_t: Message type |
| 383 | * @rsvd: Reserved |
| 384 | * @op_code: IPA Operation type |
| 385 | * @len: IPA message length |
| 386 | * @rsvd_snd: Reserved |
| 387 | */ |
| 388 | struct op_msg_type { |
| 389 | uint8_t msg_t; |
| 390 | uint8_t rsvd; |
| 391 | uint16_t op_code; |
| 392 | uint16_t len; |
| 393 | uint16_t rsvd_snd; |
| 394 | }; |
| 395 | |
| 396 | /** |
| 397 | * struct ipa_uc_fw_stats - IPA FW stats |
| 398 | * @tx_comp_ring_size: TX completion ring size |
| 399 | * @txcomp_ring_dbell_addr: TX comp ring door bell address |
| 400 | * @txcomp_ring_dbell_ind_val: TX cop ring door bell indication |
| 401 | * @txcomp_ring_dbell_cached_val: TX cop ring cached value |
| 402 | * @txpkts_enqueued: TX packets enqueued |
| 403 | * @txpkts_completed: TX packets completed |
| 404 | * @tx_is_suspend: TX suspend flag |
| 405 | * @tx_reserved: Reserved for TX stat |
| 406 | * @rx_ind_ring_base: RX indication ring base addess |
| 407 | * @rx_ind_ring_size: RX indication ring size |
| 408 | * @rx_ind_ring_dbell_addr: RX indication ring doorbell address |
| 409 | * @rx_ind_ring_dbell_ind_val: RX indication ring doorbell indication |
| 410 | * @rx_ind_ring_dbell_ind_cached_val: RX indication ring doorbell cached value |
| 411 | * @rx_ind_ring_rdidx_addr: RX indication ring read index address |
| 412 | * @rx_ind_ring_rd_idx_cached_val: RX indication ring read index cached value |
| 413 | * @rx_refill_idx: RX ring refill index |
| 414 | * @rx_num_pkts_indicated: Number of RX packets indicated |
| 415 | * @rx_buf_refilled: Number of RX buffer refilled |
| 416 | * @rx_num_ind_drop_no_space: Number of RX indication drops due to no space |
| 417 | * @rx_num_ind_drop_no_buf: Number of RX indication drops due to no buffer |
| 418 | * @rx_is_suspend: RX suspend flag |
| 419 | * @rx_reserved: Reserved for RX stat |
| 420 | */ |
| 421 | struct ipa_uc_fw_stats { |
| 422 | uint32_t tx_comp_ring_base; |
| 423 | uint32_t tx_comp_ring_size; |
| 424 | uint32_t tx_comp_ring_dbell_addr; |
| 425 | uint32_t tx_comp_ring_dbell_ind_val; |
| 426 | uint32_t tx_comp_ring_dbell_cached_val; |
| 427 | uint32_t tx_pkts_enqueued; |
| 428 | uint32_t tx_pkts_completed; |
| 429 | uint32_t tx_is_suspend; |
| 430 | uint32_t tx_reserved; |
| 431 | uint32_t rx_ind_ring_base; |
| 432 | uint32_t rx_ind_ring_size; |
| 433 | uint32_t rx_ind_ring_dbell_addr; |
| 434 | uint32_t rx_ind_ring_dbell_ind_val; |
| 435 | uint32_t rx_ind_ring_dbell_ind_cached_val; |
| 436 | uint32_t rx_ind_ring_rdidx_addr; |
| 437 | uint32_t rx_ind_ring_rd_idx_cached_val; |
| 438 | uint32_t rx_refill_idx; |
| 439 | uint32_t rx_num_pkts_indicated; |
| 440 | uint32_t rx_buf_refilled; |
| 441 | uint32_t rx_num_ind_drop_no_space; |
| 442 | uint32_t rx_num_ind_drop_no_buf; |
| 443 | uint32_t rx_is_suspend; |
| 444 | uint32_t rx_reserved; |
| 445 | }; |
| 446 | |
| 447 | /** |
| 448 | * struct wlan_ipa_uc_pending_event - WLAN IPA UC pending event |
| 449 | * @node: Pending event list node |
| 450 | * @type: WLAN IPA event type |
| 451 | * @device_mode: Device mode |
| 452 | * @sta_id: Station ID |
| 453 | * @session_id: Session ID |
| 454 | * @mac_addr: Mac address |
| 455 | * @is_loading: Driver loading flag |
| 456 | */ |
| 457 | struct wlan_ipa_uc_pending_event { |
| 458 | qdf_list_node_t node; |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 459 | qdf_ipa_wlan_event type; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 460 | qdf_netdev_t net_dev; |
| 461 | uint8_t device_mode; |
| 462 | uint8_t sta_id; |
| 463 | uint8_t session_id; |
| 464 | uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; |
| 465 | bool is_loading; |
| 466 | }; |
| 467 | |
| 468 | /** |
| 469 | * struct uc_rm_work_struct |
| 470 | * @work: uC RM work |
| 471 | * @event: IPA RM event |
| 472 | */ |
| 473 | struct uc_rm_work_struct { |
| 474 | qdf_work_t work; |
| 475 | qdf_ipa_rm_event_t event; |
| 476 | }; |
| 477 | |
| 478 | /** |
| 479 | * struct uc_op_work_struct |
| 480 | * @work: uC OP work |
| 481 | * @msg: OP message |
| 482 | */ |
| 483 | struct uc_op_work_struct { |
| 484 | qdf_work_t work; |
| 485 | struct op_msg_type *msg; |
| 486 | }; |
| 487 | |
| 488 | /** |
| 489 | * struct uc_rt_debug_info |
| 490 | * @time: system time |
| 491 | * @ipa_excep_count: IPA exception packet count |
| 492 | * @rx_drop_count: IPA Rx drop packet count |
| 493 | * @net_sent_count: IPA Rx packet sent to network stack count |
| 494 | * @rx_discard_count: IPA Rx discard packet count |
| 495 | * @tx_fwd_ok_count: IPA Tx forward success packet count |
| 496 | * @tx_fwd_count: IPA Tx forward packet count |
| 497 | * @rx_destructor_call: IPA Rx packet destructor count |
| 498 | */ |
| 499 | struct uc_rt_debug_info { |
| 500 | uint64_t time; |
| 501 | uint64_t ipa_excep_count; |
| 502 | uint64_t rx_drop_count; |
| 503 | uint64_t net_sent_count; |
| 504 | uint64_t rx_discard_count; |
| 505 | uint64_t tx_fwd_ok_count; |
| 506 | uint64_t tx_fwd_count; |
| 507 | uint64_t rx_destructor_call; |
| 508 | }; |
| 509 | |
| 510 | #ifdef FEATURE_METERING |
| 511 | /** |
| 512 | * struct ipa_uc_sharing_stats - IPA UC sharing stats |
| 513 | * @ipv4_rx_packets: IPv4 RX packets |
| 514 | * @ipv4_rx_bytes: IPv4 RX bytes |
| 515 | * @ipv6_rx_packets: IPv6 RX packets |
| 516 | * @ipv6_rx_bytes: IPv6 RX bytes |
| 517 | * @ipv4_tx_packets: IPv4 TX packets |
| 518 | * @ipv4_tx_bytes: IPv4 TX bytes |
| 519 | * @ipv6_tx_packets: IPv4 TX packets |
| 520 | * @ipv6_tx_bytes: IPv6 TX bytes |
| 521 | */ |
| 522 | struct ipa_uc_sharing_stats { |
| 523 | uint64_t ipv4_rx_packets; |
| 524 | uint64_t ipv4_rx_bytes; |
| 525 | uint64_t ipv6_rx_packets; |
| 526 | uint64_t ipv6_rx_bytes; |
| 527 | uint64_t ipv4_tx_packets; |
| 528 | uint64_t ipv4_tx_bytes; |
| 529 | uint64_t ipv6_tx_packets; |
| 530 | uint64_t ipv6_tx_bytes; |
| 531 | }; |
| 532 | |
| 533 | /** |
| 534 | * struct ipa_uc_quota_rsp - IPA UC quota response |
| 535 | * @success: Success or fail flag |
| 536 | * @reserved[3]: Reserved |
| 537 | * @quota_lo: Quota limit low bytes |
| 538 | * @quota_hi: Quota limit high bytes |
| 539 | */ |
| 540 | struct ipa_uc_quota_rsp { |
| 541 | uint8_t success; |
| 542 | uint8_t reserved[3]; |
| 543 | uint32_t quota_lo; |
| 544 | uint32_t quota_hi; |
| 545 | }; |
| 546 | |
| 547 | /** |
| 548 | * struct ipa_uc_quota_ind |
| 549 | * @quota_bytes: Quota bytes to set |
| 550 | */ |
| 551 | struct ipa_uc_quota_ind { |
| 552 | uint64_t quota_bytes; |
| 553 | }; |
| 554 | #endif |
| 555 | |
| 556 | /** |
| 557 | * struct wlan_ipa_tx_desc |
| 558 | * @node: TX descriptor node |
| 559 | * @priv: pointer to priv list entry |
| 560 | * @id: Tx desc idex |
| 561 | * @ipa_tx_desc_ptr: pointer to IPA Tx descriptor |
| 562 | */ |
| 563 | struct wlan_ipa_tx_desc { |
| 564 | qdf_list_node_t node; |
| 565 | void *priv; |
| 566 | uint32_t id; |
| 567 | qdf_ipa_rx_data_t *ipa_tx_desc_ptr; |
| 568 | }; |
| 569 | |
Vevek Venkatesan | 78f7f09 | 2019-05-23 17:16:28 +0530 | [diff] [blame] | 570 | typedef QDF_STATUS (*wlan_ipa_softap_xmit)(qdf_nbuf_t nbuf, qdf_netdev_t dev); |
Vevek Venkatesan | 3b6be82 | 2019-05-28 18:19:15 +0530 | [diff] [blame] | 571 | typedef void (*wlan_ipa_send_to_nw)(qdf_nbuf_t nbuf, qdf_netdev_t dev); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 572 | |
| 573 | /* IPA private context structure definition */ |
| 574 | struct wlan_ipa_priv { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 575 | struct wlan_objmgr_pdev *pdev; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 576 | struct wlan_ipa_sys_pipe sys_pipe[WLAN_IPA_MAX_SYSBAM_PIPE]; |
| 577 | struct wlan_ipa_iface_context iface_context[WLAN_IPA_MAX_IFACE]; |
| 578 | uint8_t num_iface; |
| 579 | void *dp_soc; |
| 580 | void *dp_pdev; |
| 581 | struct wlan_ipa_config *config; |
| 582 | enum wlan_ipa_rm_state rm_state; |
| 583 | /* |
| 584 | * IPA driver can send RM notifications with IRQ disabled so using qdf |
| 585 | * APIs as it is taken care gracefully. Without this, kernel would throw |
| 586 | * an warning if spin_lock_bh is used while IRQ is disabled |
| 587 | */ |
| 588 | qdf_spinlock_t rm_lock; |
| 589 | struct uc_rm_work_struct uc_rm_work; |
| 590 | struct uc_op_work_struct uc_op_work[WLAN_IPA_UC_OPCODE_MAX]; |
| 591 | qdf_wake_lock_t wake_lock; |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 592 | struct qdf_delayed_work wake_lock_work; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 593 | bool wake_lock_released; |
| 594 | |
| 595 | qdf_atomic_t tx_ref_cnt; |
| 596 | qdf_nbuf_queue_t pm_queue_head; |
| 597 | qdf_work_t pm_work; |
| 598 | qdf_spinlock_t pm_lock; |
| 599 | bool suspended; |
| 600 | |
| 601 | qdf_spinlock_t q_lock; |
| 602 | |
Rakshith Suresh Patkar | 785b845 | 2019-03-18 13:36:02 +0530 | [diff] [blame] | 603 | qdf_spinlock_t pipes_down_lock; |
| 604 | bool pipes_down_in_progress; |
| 605 | |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 606 | qdf_list_node_t pend_desc_head; |
Sravan Kumar Kairam | 1f8f8b3 | 2018-07-06 16:05:24 +0530 | [diff] [blame] | 607 | struct wlan_ipa_tx_desc *tx_desc_pool; |
| 608 | qdf_list_t tx_desc_free_list; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 609 | |
| 610 | struct wlan_ipa_stats stats; |
| 611 | |
| 612 | uint32_t curr_prod_bw; |
| 613 | uint32_t curr_cons_bw; |
| 614 | |
| 615 | uint8_t activated_fw_pipe; |
| 616 | uint8_t sap_num_connected_sta; |
| 617 | uint8_t sta_connected; |
| 618 | uint32_t tx_pipe_handle; |
| 619 | uint32_t rx_pipe_handle; |
| 620 | bool resource_loading; |
| 621 | bool resource_unloading; |
| 622 | bool pending_cons_req; |
| 623 | struct ipa_uc_stas_map assoc_stas_map[WLAN_IPA_MAX_STA_COUNT]; |
| 624 | qdf_list_t pending_event; |
| 625 | qdf_mutex_t event_lock; |
| 626 | bool ipa_pipes_down; |
| 627 | uint32_t ipa_tx_packets_diff; |
| 628 | uint32_t ipa_rx_packets_diff; |
| 629 | uint32_t ipa_p_tx_packets; |
| 630 | uint32_t ipa_p_rx_packets; |
| 631 | uint32_t stat_req_reason; |
| 632 | uint64_t ipa_tx_forward; |
| 633 | uint64_t ipa_rx_discard; |
| 634 | uint64_t ipa_rx_net_send_count; |
| 635 | uint64_t ipa_rx_internal_drop_count; |
| 636 | uint64_t ipa_rx_destructor_count; |
| 637 | qdf_mc_timer_t rt_debug_timer; |
| 638 | struct uc_rt_debug_info rt_bug_buffer[WLAN_IPA_UC_RT_DEBUG_BUF_COUNT]; |
| 639 | unsigned int rt_buf_fill_index; |
| 640 | qdf_ipa_wdi_in_params_t cons_pipe_in; |
| 641 | qdf_ipa_wdi_in_params_t prod_pipe_in; |
| 642 | bool uc_loaded; |
| 643 | bool wdi_enabled; |
Sravan Kumar Kairam | c047d29 | 2018-11-19 18:43:15 +0530 | [diff] [blame] | 644 | bool over_gsi; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 645 | qdf_mc_timer_t rt_debug_fill_timer; |
| 646 | qdf_mutex_t rt_debug_lock; |
| 647 | qdf_mutex_t ipa_lock; |
| 648 | |
| 649 | uint8_t vdev_to_iface[WLAN_IPA_MAX_SESSION]; |
| 650 | bool vdev_offload_enabled[WLAN_IPA_MAX_SESSION]; |
| 651 | bool mcc_mode; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 652 | qdf_work_t mcc_work; |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 653 | bool ap_intrabss_fwd; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 654 | bool dfs_cac_block_tx; |
| 655 | #ifdef FEATURE_METERING |
| 656 | struct ipa_uc_sharing_stats ipa_sharing_stats; |
| 657 | struct ipa_uc_quota_rsp ipa_quota_rsp; |
| 658 | struct ipa_uc_quota_ind ipa_quota_ind; |
| 659 | qdf_event_t ipa_uc_sharing_stats_comp; |
| 660 | qdf_event_t ipa_uc_set_quota_comp; |
| 661 | #endif |
| 662 | |
| 663 | wlan_ipa_softap_xmit softap_xmit; |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 664 | wlan_ipa_send_to_nw send_to_nw; |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 665 | ipa_uc_offload_control_req ipa_tx_op; |
| 666 | |
| 667 | qdf_event_t ipa_resource_comp; |
| 668 | |
| 669 | uint32_t wdi_version; |
| 670 | bool is_smmu_enabled; /* IPA caps returned from ipa_wdi_init */ |
| 671 | }; |
| 672 | |
| 673 | #define WLAN_IPA_WLAN_FRAG_HEADER sizeof(struct frag_header) |
| 674 | #define WLAN_IPA_WLAN_IPA_HEADER sizeof(struct ipa_header) |
| 675 | #define WLAN_IPA_WLAN_CLD_HDR_LEN sizeof(struct wlan_ipa_cld_hdr) |
| 676 | #define WLAN_IPA_UC_WLAN_CLD_HDR_LEN 0 |
| 677 | #define WLAN_IPA_WLAN_TX_HDR_LEN sizeof(struct wlan_ipa_tx_hdr) |
| 678 | #define WLAN_IPA_UC_WLAN_TX_HDR_LEN sizeof(struct wlan_ipa_uc_tx_hdr) |
| 679 | #define WLAN_IPA_WLAN_RX_HDR_LEN sizeof(struct wlan_ipa_rx_hdr) |
| 680 | #define WLAN_IPA_UC_WLAN_HDR_DES_MAC_OFFSET \ |
| 681 | (WLAN_IPA_WLAN_FRAG_HEADER + WLAN_IPA_WLAN_IPA_HEADER) |
| 682 | |
| 683 | #define WLAN_IPA_GET_IFACE_ID(_data) \ |
| 684 | (((struct wlan_ipa_cld_hdr *) (_data))->iface_id) |
| 685 | |
| 686 | #define WLAN_IPA_LOG(LVL, fmt, args ...) \ |
| 687 | QDF_TRACE(QDF_MODULE_ID_IPA, LVL, \ |
| 688 | "%s:%d: "fmt, __func__, __LINE__, ## args) |
| 689 | |
| 690 | #define WLAN_IPA_IS_CONFIG_ENABLED(_ipa_cfg, _mask) \ |
| 691 | (((_ipa_cfg)->ipa_config & (_mask)) == (_mask)) |
| 692 | |
| 693 | #define BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) |
| 694 | |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 695 | #define IPA_RESOURCE_COMP_WAIT_TIME 100 |
| 696 | |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 697 | #ifdef FEATURE_METERING |
| 698 | #define IPA_UC_SHARING_STATES_WAIT_TIME 500 |
| 699 | #define IPA_UC_SET_QUOTA_WAIT_TIME 500 |
| 700 | #endif |
| 701 | |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 702 | /** |
| 703 | * wlan_ipa_wlan_event_to_str() - convert IPA WLAN event to string |
| 704 | * @event: IPA WLAN event to be converted to a string |
| 705 | * |
| 706 | * Return: ASCII string representing the IPA WLAN event |
| 707 | */ |
Yun Park | 84fbb27 | 2018-04-02 15:31:01 -0700 | [diff] [blame] | 708 | static inline char *wlan_ipa_wlan_event_to_str(qdf_ipa_wlan_event event) |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 709 | { |
| 710 | switch (event) { |
Yun Park | 84fbb27 | 2018-04-02 15:31:01 -0700 | [diff] [blame] | 711 | CASE_RETURN_STRING(QDF_IPA_CLIENT_CONNECT); |
| 712 | CASE_RETURN_STRING(QDF_IPA_CLIENT_DISCONNECT); |
| 713 | CASE_RETURN_STRING(QDF_IPA_AP_CONNECT); |
| 714 | CASE_RETURN_STRING(QDF_IPA_AP_DISCONNECT); |
| 715 | CASE_RETURN_STRING(QDF_IPA_STA_CONNECT); |
| 716 | CASE_RETURN_STRING(QDF_IPA_STA_DISCONNECT); |
| 717 | CASE_RETURN_STRING(QDF_IPA_CLIENT_CONNECT_EX); |
| 718 | CASE_RETURN_STRING(QDF_SWITCH_TO_SCC); |
| 719 | CASE_RETURN_STRING(QDF_SWITCH_TO_MCC); |
| 720 | CASE_RETURN_STRING(QDF_WDI_ENABLE); |
| 721 | CASE_RETURN_STRING(QDF_WDI_DISABLE); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 722 | default: |
| 723 | return "UNKNOWN"; |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | /** |
| 728 | * wlan_ipa_get_iface() - Get IPA interface |
| 729 | * @ipa_ctx: IPA context |
| 730 | * @mode: Interface device mode |
| 731 | * |
| 732 | * Return: IPA interface address |
| 733 | */ |
| 734 | struct wlan_ipa_iface_context |
| 735 | *wlan_ipa_get_iface(struct wlan_ipa_priv *ipa_ctx, uint8_t mode); |
| 736 | |
| 737 | #endif /* IPA_OFFLOAD */ |
| 738 | #endif /* _WLAN_IPA_PRIV_STRUCT_H_ */ |