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