Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Pratik Gandhi | 034cb7c | 2017-11-10 16:46:06 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 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 | */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 27 | #include "targcfg.h" |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 28 | #include "qdf_lock.h" |
| 29 | #include "qdf_status.h" |
| 30 | #include "qdf_status.h" |
| 31 | #include <qdf_atomic.h> /* qdf_atomic_read */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 32 | #include <targaddrs.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 33 | #include "hif_io32.h" |
| 34 | #include <hif.h> |
Pratik Gandhi | 034cb7c | 2017-11-10 16:46:06 +0530 | [diff] [blame] | 35 | #include <target_type.h> |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 36 | #include "regtable.h" |
| 37 | #define ATH_MODULE_NAME hif |
| 38 | #include <a_debug.h> |
| 39 | #include "hif_main.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 40 | #include "ce_api.h" |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 41 | #include "qdf_trace.h" |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 42 | #include "pld_common.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 43 | #include "hif_debug.h" |
| 44 | #include "ce_internal.h" |
| 45 | #include "ce_reg.h" |
| 46 | #include "ce_assignment.h" |
| 47 | #include "ce_tasklet.h" |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 48 | #ifndef CONFIG_WIN |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 49 | #include "qwlan_version.h" |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 50 | #endif |
Pratik Gandhi | dc82a77 | 2018-01-30 18:57:05 +0530 | [diff] [blame] | 51 | #include "qdf_module.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 52 | |
| 53 | #define CE_POLL_TIMEOUT 10 /* ms */ |
| 54 | |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 55 | #define AGC_DUMP 1 |
| 56 | #define CHANINFO_DUMP 2 |
| 57 | #define BB_WATCHDOG_DUMP 3 |
| 58 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 59 | #define PCIE_ACCESS_DUMP 4 |
| 60 | #endif |
| 61 | #include "mp_dev.h" |
| 62 | |
Houston Hoffman | 5141f9d | 2017-01-05 10:49:17 -0800 | [diff] [blame] | 63 | #if (defined(QCA_WIFI_QCA8074) || defined(QCA_WIFI_QCA6290)) && \ |
| 64 | !defined(QCA_WIFI_SUPPORT_SRNG) |
| 65 | #define QCA_WIFI_SUPPORT_SRNG |
| 66 | #endif |
| 67 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 68 | /* Forward references */ |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 69 | QDF_STATUS hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 70 | |
| 71 | /* |
| 72 | * Fix EV118783, poll to check whether a BMI response comes |
| 73 | * other than waiting for the interruption which may be lost. |
| 74 | */ |
| 75 | /* #define BMI_RSP_POLLING */ |
| 76 | #define BMI_RSP_TO_MILLISEC 1000 |
| 77 | |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 78 | #ifdef CONFIG_BYPASS_QMI |
| 79 | #define BYPASS_QMI 1 |
| 80 | #else |
| 81 | #define BYPASS_QMI 0 |
| 82 | #endif |
| 83 | |
Houston Hoffman | abd0077 | 2016-05-06 17:02:48 -0700 | [diff] [blame] | 84 | #ifdef CONFIG_WIN |
Pratik Gandhi | 424c62e | 2016-08-23 19:47:09 +0530 | [diff] [blame] | 85 | #if ENABLE_10_4_FW_HDR |
Houston Hoffman | abd0077 | 2016-05-06 17:02:48 -0700 | [diff] [blame] | 86 | #define WDI_IPA_SERVICE_GROUP 5 |
| 87 | #define WDI_IPA_TX_SVC MAKE_SERVICE_ID(WDI_IPA_SERVICE_GROUP, 0) |
| 88 | #define HTT_DATA2_MSG_SVC MAKE_SERVICE_ID(HTT_SERVICE_GROUP, 1) |
| 89 | #define HTT_DATA3_MSG_SVC MAKE_SERVICE_ID(HTT_SERVICE_GROUP, 2) |
Pratik Gandhi | 424c62e | 2016-08-23 19:47:09 +0530 | [diff] [blame] | 90 | #endif /* ENABLE_10_4_FW_HDR */ |
Houston Hoffman | abd0077 | 2016-05-06 17:02:48 -0700 | [diff] [blame] | 91 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 92 | |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 93 | QDF_STATUS hif_post_recv_buffers(struct hif_softc *scn); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 94 | static void hif_config_rri_on_ddr(struct hif_softc *scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 95 | |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 96 | /** |
| 97 | * hif_target_access_log_dump() - dump access log |
| 98 | * |
| 99 | * dump access log |
| 100 | * |
| 101 | * Return: n/a |
| 102 | */ |
| 103 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 104 | static void hif_target_access_log_dump(void) |
| 105 | { |
| 106 | hif_target_dump_access_log(); |
| 107 | } |
| 108 | #endif |
| 109 | |
| 110 | |
| 111 | void hif_trigger_dump(struct hif_opaque_softc *hif_ctx, |
| 112 | uint8_t cmd_id, bool start) |
| 113 | { |
| 114 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 115 | |
| 116 | switch (cmd_id) { |
| 117 | case AGC_DUMP: |
| 118 | if (start) |
| 119 | priv_start_agc(scn); |
| 120 | else |
| 121 | priv_dump_agc(scn); |
| 122 | break; |
| 123 | case CHANINFO_DUMP: |
| 124 | if (start) |
| 125 | priv_start_cap_chaninfo(scn); |
| 126 | else |
| 127 | priv_dump_chaninfo(scn); |
| 128 | break; |
| 129 | case BB_WATCHDOG_DUMP: |
| 130 | priv_dump_bbwatchdog(scn); |
| 131 | break; |
| 132 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 133 | case PCIE_ACCESS_DUMP: |
| 134 | hif_target_access_log_dump(); |
| 135 | break; |
| 136 | #endif |
| 137 | default: |
| 138 | HIF_ERROR("%s: Invalid htc dump command", __func__); |
| 139 | break; |
| 140 | } |
| 141 | } |
| 142 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 143 | static void ce_poll_timeout(void *arg) |
| 144 | { |
| 145 | struct CE_state *CE_state = (struct CE_state *)arg; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 146 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 147 | if (CE_state->timer_inited) { |
| 148 | ce_per_engine_service(CE_state->scn, CE_state->id); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 149 | qdf_timer_mod(&CE_state->poll_timer, CE_POLL_TIMEOUT); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
| 153 | static unsigned int roundup_pwr2(unsigned int n) |
| 154 | { |
| 155 | int i; |
| 156 | unsigned int test_pwr2; |
| 157 | |
| 158 | if (!(n & (n - 1))) |
| 159 | return n; /* already a power of 2 */ |
| 160 | |
| 161 | test_pwr2 = 4; |
| 162 | for (i = 0; i < 29; i++) { |
| 163 | if (test_pwr2 > n) |
| 164 | return test_pwr2; |
| 165 | test_pwr2 = test_pwr2 << 1; |
| 166 | } |
| 167 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 168 | QDF_ASSERT(0); /* n too large */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 169 | return 0; |
| 170 | } |
| 171 | |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 172 | #define ADRASTEA_SRC_WR_INDEX_OFFSET 0x3C |
| 173 | #define ADRASTEA_DST_WR_INDEX_OFFSET 0x40 |
| 174 | |
| 175 | static struct shadow_reg_cfg target_shadow_reg_cfg_map[] = { |
| 176 | { 0, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 177 | { 3, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 178 | { 4, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 179 | { 5, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 180 | { 7, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 181 | { 1, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 182 | { 2, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 183 | { 7, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 184 | { 8, ADRASTEA_DST_WR_INDEX_OFFSET}, |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 185 | #ifdef QCA_WIFI_3_0_ADRASTEA |
| 186 | { 9, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 187 | { 10, ADRASTEA_DST_WR_INDEX_OFFSET}, |
Nirav Shah | 75cc5c8 | 2016-05-25 10:52:38 +0530 | [diff] [blame] | 188 | { 11, ADRASTEA_DST_WR_INDEX_OFFSET}, |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 189 | #endif |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 190 | }; |
| 191 | |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 192 | #ifdef WLAN_FEATURE_EPPING |
Vishwajith Upendra | 70efc75 | 2016-04-18 11:23:49 -0700 | [diff] [blame] | 193 | static struct shadow_reg_cfg target_shadow_reg_cfg_epping[] = { |
| 194 | { 0, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 195 | { 3, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 196 | { 4, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 197 | { 7, ADRASTEA_SRC_WR_INDEX_OFFSET}, |
| 198 | { 1, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 199 | { 2, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 200 | { 5, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 201 | { 7, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 202 | { 8, ADRASTEA_DST_WR_INDEX_OFFSET}, |
| 203 | }; |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 204 | #endif |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 205 | |
| 206 | /* CE_PCI TABLE */ |
| 207 | /* |
| 208 | * NOTE: the table below is out of date, though still a useful reference. |
| 209 | * Refer to target_service_to_ce_map and hif_map_service_to_pipe for the actual |
| 210 | * mapping of HTC services to HIF pipes. |
| 211 | */ |
| 212 | /* |
| 213 | * This authoritative table defines Copy Engine configuration and the mapping |
| 214 | * of services/endpoints to CEs. A subset of this information is passed to |
| 215 | * the Target during startup as a prerequisite to entering BMI phase. |
| 216 | * See: |
| 217 | * target_service_to_ce_map - Target-side mapping |
| 218 | * hif_map_service_to_pipe - Host-side mapping |
| 219 | * target_ce_config - Target-side configuration |
| 220 | * host_ce_config - Host-side configuration |
| 221 | ============================================================================ |
| 222 | Purpose | Service / Endpoint | CE | Dire | Xfer | Xfer |
| 223 | | | | ctio | Size | Frequency |
| 224 | | | | n | | |
| 225 | ============================================================================ |
| 226 | tx | HTT_DATA (downlink) | CE 0 | h->t | medium - | very frequent |
| 227 | descriptor | | | | O(100B) | and regular |
| 228 | download | | | | | |
| 229 | ---------------------------------------------------------------------------- |
| 230 | rx | HTT_DATA (uplink) | CE 1 | t->h | small - | frequent and |
| 231 | indication | | | | O(10B) | regular |
| 232 | upload | | | | | |
| 233 | ---------------------------------------------------------------------------- |
| 234 | MSDU | DATA_BK (uplink) | CE 2 | t->h | large - | rare |
| 235 | upload | | | | O(1000B) | (frequent |
| 236 | e.g. noise | | | | | during IP1.0 |
| 237 | packets | | | | | testing) |
| 238 | ---------------------------------------------------------------------------- |
| 239 | MSDU | DATA_BK (downlink) | CE 3 | h->t | large - | very rare |
| 240 | download | | | | O(1000B) | (frequent |
| 241 | e.g. | | | | | during IP1.0 |
| 242 | misdirecte | | | | | testing) |
| 243 | d EAPOL | | | | | |
| 244 | packets | | | | | |
| 245 | ---------------------------------------------------------------------------- |
| 246 | n/a | DATA_BE, DATA_VI | CE 2 | t->h | | never(?) |
| 247 | | DATA_VO (uplink) | | | | |
| 248 | ---------------------------------------------------------------------------- |
| 249 | n/a | DATA_BE, DATA_VI | CE 3 | h->t | | never(?) |
| 250 | | DATA_VO (downlink) | | | | |
| 251 | ---------------------------------------------------------------------------- |
| 252 | WMI events | WMI_CONTROL (uplink) | CE 4 | t->h | medium - | infrequent |
| 253 | | | | | O(100B) | |
| 254 | ---------------------------------------------------------------------------- |
| 255 | WMI | WMI_CONTROL | CE 5 | h->t | medium - | infrequent |
| 256 | messages | (downlink) | | | O(100B) | |
| 257 | | | | | | |
| 258 | ---------------------------------------------------------------------------- |
| 259 | n/a | HTC_CTRL_RSVD, | CE 1 | t->h | | never(?) |
| 260 | | HTC_RAW_STREAMS | | | | |
| 261 | | (uplink) | | | | |
| 262 | ---------------------------------------------------------------------------- |
| 263 | n/a | HTC_CTRL_RSVD, | CE 0 | h->t | | never(?) |
| 264 | | HTC_RAW_STREAMS | | | | |
| 265 | | (downlink) | | | | |
| 266 | ---------------------------------------------------------------------------- |
| 267 | diag | none (raw CE) | CE 7 | t<>h | 4 | Diag Window |
| 268 | | | | | | infrequent |
| 269 | ============================================================================ |
| 270 | */ |
| 271 | |
| 272 | /* |
| 273 | * Map from service/endpoint to Copy Engine. |
| 274 | * This table is derived from the CE_PCI TABLE, above. |
| 275 | * It is passed to the Target at startup for use by firmware. |
| 276 | */ |
| 277 | static struct service_to_pipe target_service_to_ce_map_wlan[] = { |
| 278 | { |
| 279 | WMI_DATA_VO_SVC, |
| 280 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 281 | 3, |
| 282 | }, |
| 283 | { |
| 284 | WMI_DATA_VO_SVC, |
| 285 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 286 | 2, |
| 287 | }, |
| 288 | { |
| 289 | WMI_DATA_BK_SVC, |
| 290 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 291 | 3, |
| 292 | }, |
| 293 | { |
| 294 | WMI_DATA_BK_SVC, |
| 295 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 296 | 2, |
| 297 | }, |
| 298 | { |
| 299 | WMI_DATA_BE_SVC, |
| 300 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 301 | 3, |
| 302 | }, |
| 303 | { |
| 304 | WMI_DATA_BE_SVC, |
| 305 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 306 | 2, |
| 307 | }, |
| 308 | { |
| 309 | WMI_DATA_VI_SVC, |
| 310 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 311 | 3, |
| 312 | }, |
| 313 | { |
| 314 | WMI_DATA_VI_SVC, |
| 315 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 316 | 2, |
| 317 | }, |
| 318 | { |
| 319 | WMI_CONTROL_SVC, |
| 320 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 321 | 3, |
| 322 | }, |
| 323 | { |
| 324 | WMI_CONTROL_SVC, |
| 325 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 326 | 2, |
| 327 | }, |
| 328 | { |
| 329 | HTC_CTRL_RSVD_SVC, |
| 330 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 331 | 0, /* could be moved to 3 (share with WMI) */ |
| 332 | }, |
| 333 | { |
| 334 | HTC_CTRL_RSVD_SVC, |
| 335 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 336 | 2, |
| 337 | }, |
| 338 | { |
| 339 | HTC_RAW_STREAMS_SVC, /* not currently used */ |
| 340 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 341 | 0, |
| 342 | }, |
| 343 | { |
| 344 | HTC_RAW_STREAMS_SVC, /* not currently used */ |
| 345 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 346 | 2, |
| 347 | }, |
| 348 | { |
| 349 | HTT_DATA_MSG_SVC, |
| 350 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 351 | 4, |
| 352 | }, |
| 353 | { |
| 354 | HTT_DATA_MSG_SVC, |
| 355 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 356 | 1, |
| 357 | }, |
| 358 | { |
| 359 | WDI_IPA_TX_SVC, |
| 360 | PIPEDIR_OUT, /* in = DL = target -> host */ |
| 361 | 5, |
| 362 | }, |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 363 | #if defined(QCA_WIFI_3_0_ADRASTEA) |
| 364 | { |
| 365 | HTT_DATA2_MSG_SVC, |
| 366 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 367 | 9, |
| 368 | }, |
| 369 | { |
| 370 | HTT_DATA3_MSG_SVC, |
| 371 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 372 | 10, |
| 373 | }, |
Nirav Shah | 75cc5c8 | 2016-05-25 10:52:38 +0530 | [diff] [blame] | 374 | { |
| 375 | PACKET_LOG_SVC, |
| 376 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 377 | 11, |
| 378 | }, |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 379 | #endif |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 380 | /* (Additions here) */ |
| 381 | |
| 382 | { /* Must be last */ |
| 383 | 0, |
| 384 | 0, |
| 385 | 0, |
| 386 | }, |
| 387 | }; |
| 388 | |
Houston Hoffman | 88c896f | 2016-12-14 09:56:35 -0800 | [diff] [blame] | 389 | /* PIPEDIR_OUT = HOST to Target */ |
| 390 | /* PIPEDIR_IN = TARGET to HOST */ |
Balamurugan Mahalingam | 20802b2 | 2017-05-02 19:11:38 +0530 | [diff] [blame] | 391 | static struct service_to_pipe target_service_to_ce_map_qca8074[] = { |
| 392 | { WMI_DATA_VO_SVC, PIPEDIR_OUT, 3, }, |
| 393 | { WMI_DATA_VO_SVC, PIPEDIR_IN, 2, }, |
| 394 | { WMI_DATA_BK_SVC, PIPEDIR_OUT, 3, }, |
| 395 | { WMI_DATA_BK_SVC, PIPEDIR_IN, 2, }, |
| 396 | { WMI_DATA_BE_SVC, PIPEDIR_OUT, 3, }, |
| 397 | { WMI_DATA_BE_SVC, PIPEDIR_IN, 2, }, |
| 398 | { WMI_DATA_VI_SVC, PIPEDIR_OUT, 3, }, |
| 399 | { WMI_DATA_VI_SVC, PIPEDIR_IN, 2, }, |
| 400 | { WMI_CONTROL_SVC, PIPEDIR_OUT, 3, }, |
| 401 | { WMI_CONTROL_SVC, PIPEDIR_IN, 2, }, |
| 402 | { WMI_CONTROL_SVC_WMAC1, PIPEDIR_OUT, 7}, |
| 403 | { WMI_CONTROL_SVC_WMAC1, PIPEDIR_IN, 2}, |
| 404 | { HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0, }, |
| 405 | { HTC_CTRL_RSVD_SVC, PIPEDIR_IN, 1, }, |
| 406 | { HTC_RAW_STREAMS_SVC, PIPEDIR_OUT, 0}, |
| 407 | { HTC_RAW_STREAMS_SVC, PIPEDIR_IN, 1 }, |
| 408 | { HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4, }, |
| 409 | { HTT_DATA_MSG_SVC, PIPEDIR_IN, 1, }, |
Balamurugan Mahalingam | dcb5226 | 2017-08-16 19:16:45 +0530 | [diff] [blame] | 410 | { PACKET_LOG_SVC, PIPEDIR_IN, 5, }, |
Balamurugan Mahalingam | 20802b2 | 2017-05-02 19:11:38 +0530 | [diff] [blame] | 411 | /* (Additions here) */ |
| 412 | { 0, 0, 0, }, |
| 413 | }; |
| 414 | |
Nandha Kishore Easwaran | 51f80b8 | 2018-02-21 12:04:34 +0530 | [diff] [blame] | 415 | #ifdef CONFIG_WIN |
Houston Hoffman | 88c896f | 2016-12-14 09:56:35 -0800 | [diff] [blame] | 416 | static struct service_to_pipe target_service_to_ce_map_qca6290[] = { |
| 417 | { WMI_DATA_VO_SVC, PIPEDIR_OUT, 3, }, |
| 418 | { WMI_DATA_VO_SVC, PIPEDIR_IN , 2, }, |
| 419 | { WMI_DATA_BK_SVC, PIPEDIR_OUT, 3, }, |
| 420 | { WMI_DATA_BK_SVC, PIPEDIR_IN , 2, }, |
| 421 | { WMI_DATA_BE_SVC, PIPEDIR_OUT, 3, }, |
| 422 | { WMI_DATA_BE_SVC, PIPEDIR_IN , 2, }, |
| 423 | { WMI_DATA_VI_SVC, PIPEDIR_OUT, 3, }, |
| 424 | { WMI_DATA_VI_SVC, PIPEDIR_IN , 2, }, |
| 425 | { WMI_CONTROL_SVC, PIPEDIR_OUT, 3, }, |
| 426 | { WMI_CONTROL_SVC, PIPEDIR_IN , 2, }, |
| 427 | { HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0, }, |
| 428 | { HTC_CTRL_RSVD_SVC, PIPEDIR_IN , 2, }, |
| 429 | { HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4, }, |
| 430 | { HTT_DATA_MSG_SVC, PIPEDIR_IN , 1, }, |
Nandha Kishore Easwaran | 51f80b8 | 2018-02-21 12:04:34 +0530 | [diff] [blame] | 431 | { WMI_CONTROL_SVC_WMAC1, PIPEDIR_OUT, 7}, |
| 432 | { WMI_CONTROL_SVC_WMAC1, PIPEDIR_IN, 2}, |
Houston Hoffman | 88c896f | 2016-12-14 09:56:35 -0800 | [diff] [blame] | 433 | /* (Additions here) */ |
| 434 | { 0, 0, 0, }, |
| 435 | }; |
Nandha Kishore Easwaran | 51f80b8 | 2018-02-21 12:04:34 +0530 | [diff] [blame] | 436 | #else |
| 437 | static struct service_to_pipe target_service_to_ce_map_qca6290[] = { |
| 438 | { WMI_DATA_VO_SVC, PIPEDIR_OUT, 3, }, |
| 439 | { WMI_DATA_VO_SVC, PIPEDIR_IN, 2, }, |
| 440 | { WMI_DATA_BK_SVC, PIPEDIR_OUT, 3, }, |
| 441 | { WMI_DATA_BK_SVC, PIPEDIR_IN, 2, }, |
| 442 | { WMI_DATA_BE_SVC, PIPEDIR_OUT, 3, }, |
| 443 | { WMI_DATA_BE_SVC, PIPEDIR_IN, 2, }, |
| 444 | { WMI_DATA_VI_SVC, PIPEDIR_OUT, 3, }, |
| 445 | { WMI_DATA_VI_SVC, PIPEDIR_IN, 2, }, |
| 446 | { WMI_CONTROL_SVC, PIPEDIR_OUT, 3, }, |
| 447 | { WMI_CONTROL_SVC, PIPEDIR_IN, 2, }, |
| 448 | { HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0, }, |
| 449 | { HTC_CTRL_RSVD_SVC, PIPEDIR_IN, 2, }, |
| 450 | { HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4, }, |
| 451 | { HTT_DATA_MSG_SVC, PIPEDIR_IN, 1, }, |
| 452 | /* (Additions here) */ |
| 453 | { 0, 0, 0, }, |
| 454 | }; |
| 455 | #endif |
Houston Hoffman | 88c896f | 2016-12-14 09:56:35 -0800 | [diff] [blame] | 456 | |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 457 | static struct service_to_pipe target_service_to_ce_map_ar900b[] = { |
| 458 | { |
| 459 | WMI_DATA_VO_SVC, |
| 460 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 461 | 3, |
| 462 | }, |
| 463 | { |
| 464 | WMI_DATA_VO_SVC, |
| 465 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 466 | 2, |
| 467 | }, |
| 468 | { |
| 469 | WMI_DATA_BK_SVC, |
| 470 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 471 | 3, |
| 472 | }, |
| 473 | { |
| 474 | WMI_DATA_BK_SVC, |
| 475 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 476 | 2, |
| 477 | }, |
| 478 | { |
| 479 | WMI_DATA_BE_SVC, |
| 480 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 481 | 3, |
| 482 | }, |
| 483 | { |
| 484 | WMI_DATA_BE_SVC, |
| 485 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 486 | 2, |
| 487 | }, |
| 488 | { |
| 489 | WMI_DATA_VI_SVC, |
| 490 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 491 | 3, |
| 492 | }, |
| 493 | { |
| 494 | WMI_DATA_VI_SVC, |
| 495 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 496 | 2, |
| 497 | }, |
| 498 | { |
| 499 | WMI_CONTROL_SVC, |
| 500 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 501 | 3, |
| 502 | }, |
| 503 | { |
| 504 | WMI_CONTROL_SVC, |
| 505 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 506 | 2, |
| 507 | }, |
| 508 | { |
| 509 | HTC_CTRL_RSVD_SVC, |
| 510 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 511 | 0, /* could be moved to 3 (share with WMI) */ |
| 512 | }, |
| 513 | { |
| 514 | HTC_CTRL_RSVD_SVC, |
| 515 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 516 | 1, |
| 517 | }, |
| 518 | { |
| 519 | HTC_RAW_STREAMS_SVC, /* not currently used */ |
| 520 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 521 | 0, |
| 522 | }, |
| 523 | { |
| 524 | HTC_RAW_STREAMS_SVC, /* not currently used */ |
| 525 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 526 | 1, |
| 527 | }, |
| 528 | { |
| 529 | HTT_DATA_MSG_SVC, |
| 530 | PIPEDIR_OUT, /* out = UL = host -> target */ |
| 531 | 4, |
| 532 | }, |
| 533 | #if WLAN_FEATURE_FASTPATH |
| 534 | { |
| 535 | HTT_DATA_MSG_SVC, |
| 536 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 537 | 5, |
| 538 | }, |
| 539 | #else /* WLAN_FEATURE_FASTPATH */ |
| 540 | { |
| 541 | HTT_DATA_MSG_SVC, |
| 542 | PIPEDIR_IN, /* in = DL = target -> host */ |
| 543 | 1, |
| 544 | }, |
| 545 | #endif /* WLAN_FEATURE_FASTPATH */ |
| 546 | |
| 547 | /* (Additions here) */ |
| 548 | |
| 549 | { /* Must be last */ |
| 550 | 0, |
| 551 | 0, |
| 552 | 0, |
| 553 | }, |
| 554 | }; |
| 555 | |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 556 | static struct shadow_reg_cfg *target_shadow_reg_cfg = target_shadow_reg_cfg_map; |
| 557 | static int shadow_cfg_sz = sizeof(target_shadow_reg_cfg_map); |
| 558 | |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 559 | #ifdef WLAN_FEATURE_EPPING |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 560 | static struct service_to_pipe target_service_to_ce_map_wlan_epping[] = { |
| 561 | {WMI_DATA_VO_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */ |
| 562 | {WMI_DATA_VO_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */ |
| 563 | {WMI_DATA_BK_SVC, PIPEDIR_OUT, 4,}, /* out = UL = host -> target */ |
| 564 | {WMI_DATA_BK_SVC, PIPEDIR_IN, 1,}, /* in = DL = target -> host */ |
| 565 | {WMI_DATA_BE_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */ |
| 566 | {WMI_DATA_BE_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */ |
| 567 | {WMI_DATA_VI_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */ |
| 568 | {WMI_DATA_VI_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */ |
| 569 | {WMI_CONTROL_SVC, PIPEDIR_OUT, 3,}, /* out = UL = host -> target */ |
| 570 | {WMI_CONTROL_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */ |
| 571 | {HTC_CTRL_RSVD_SVC, PIPEDIR_OUT, 0,}, /* out = UL = host -> target */ |
| 572 | {HTC_CTRL_RSVD_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */ |
| 573 | {HTC_RAW_STREAMS_SVC, PIPEDIR_OUT, 0,}, /* out = UL = host -> target */ |
| 574 | {HTC_RAW_STREAMS_SVC, PIPEDIR_IN, 2,}, /* in = DL = target -> host */ |
| 575 | {HTT_DATA_MSG_SVC, PIPEDIR_OUT, 4,}, /* out = UL = host -> target */ |
| 576 | {HTT_DATA_MSG_SVC, PIPEDIR_IN, 1,}, /* in = DL = target -> host */ |
| 577 | {0, 0, 0,}, /* Must be last */ |
| 578 | }; |
| 579 | |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 580 | void hif_select_epping_service_to_pipe_map(struct service_to_pipe |
| 581 | **tgt_svc_map_to_use, |
| 582 | uint32_t *sz_tgt_svc_map_to_use) |
| 583 | { |
| 584 | *tgt_svc_map_to_use = target_service_to_ce_map_wlan_epping; |
| 585 | *sz_tgt_svc_map_to_use = |
| 586 | sizeof(target_service_to_ce_map_wlan_epping); |
| 587 | } |
| 588 | #endif |
| 589 | |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 590 | static void hif_select_service_to_pipe_map(struct hif_softc *scn, |
| 591 | struct service_to_pipe **tgt_svc_map_to_use, |
| 592 | uint32_t *sz_tgt_svc_map_to_use) |
| 593 | { |
| 594 | uint32_t mode = hif_get_conparam(scn); |
| 595 | struct hif_target_info *tgt_info = &scn->target_info; |
| 596 | |
| 597 | if (QDF_IS_EPPING_ENABLED(mode)) { |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 598 | hif_select_epping_service_to_pipe_map(tgt_svc_map_to_use, |
| 599 | sz_tgt_svc_map_to_use); |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 600 | } else { |
| 601 | switch (tgt_info->target_type) { |
| 602 | default: |
| 603 | *tgt_svc_map_to_use = target_service_to_ce_map_wlan; |
| 604 | *sz_tgt_svc_map_to_use = |
| 605 | sizeof(target_service_to_ce_map_wlan); |
| 606 | break; |
| 607 | case TARGET_TYPE_AR900B: |
| 608 | case TARGET_TYPE_QCA9984: |
| 609 | case TARGET_TYPE_IPQ4019: |
| 610 | case TARGET_TYPE_QCA9888: |
| 611 | case TARGET_TYPE_AR9888: |
| 612 | case TARGET_TYPE_AR9888V2: |
| 613 | *tgt_svc_map_to_use = target_service_to_ce_map_ar900b; |
| 614 | *sz_tgt_svc_map_to_use = |
| 615 | sizeof(target_service_to_ce_map_ar900b); |
| 616 | break; |
| 617 | case TARGET_TYPE_QCA6290: |
| 618 | *tgt_svc_map_to_use = target_service_to_ce_map_qca6290; |
| 619 | *sz_tgt_svc_map_to_use = |
| 620 | sizeof(target_service_to_ce_map_qca6290); |
| 621 | break; |
Balamurugan Mahalingam | 20802b2 | 2017-05-02 19:11:38 +0530 | [diff] [blame] | 622 | case TARGET_TYPE_QCA8074: |
| 623 | *tgt_svc_map_to_use = target_service_to_ce_map_qca8074; |
| 624 | *sz_tgt_svc_map_to_use = |
| 625 | sizeof(target_service_to_ce_map_qca8074); |
| 626 | break; |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | } |
| 630 | |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 631 | /** |
| 632 | * ce_mark_datapath() - marks the ce_state->htt_rx_data accordingly |
| 633 | * @ce_state : pointer to the state context of the CE |
| 634 | * |
| 635 | * Description: |
| 636 | * Sets htt_rx_data attribute of the state structure if the |
| 637 | * CE serves one of the HTT DATA services. |
| 638 | * |
| 639 | * Return: |
| 640 | * false (attribute set to false) |
| 641 | * true (attribute set to true); |
| 642 | */ |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 643 | static bool ce_mark_datapath(struct CE_state *ce_state) |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 644 | { |
| 645 | struct service_to_pipe *svc_map; |
Kiran Venkatappa | c068709 | 2017-04-13 16:45:03 +0530 | [diff] [blame] | 646 | uint32_t map_sz, map_len; |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 647 | int i; |
| 648 | bool rc = false; |
| 649 | |
| 650 | if (ce_state != NULL) { |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 651 | hif_select_service_to_pipe_map(ce_state->scn, &svc_map, |
| 652 | &map_sz); |
Houston Hoffman | 55fcf5a | 2016-09-27 23:21:51 -0700 | [diff] [blame] | 653 | |
Kiran Venkatappa | c068709 | 2017-04-13 16:45:03 +0530 | [diff] [blame] | 654 | map_len = map_sz / sizeof(struct service_to_pipe); |
| 655 | for (i = 0; i < map_len; i++) { |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 656 | if ((svc_map[i].pipenum == ce_state->id) && |
| 657 | ((svc_map[i].service_id == HTT_DATA_MSG_SVC) || |
| 658 | (svc_map[i].service_id == HTT_DATA2_MSG_SVC) || |
| 659 | (svc_map[i].service_id == HTT_DATA3_MSG_SVC))) { |
| 660 | /* HTT CEs are unidirectional */ |
| 661 | if (svc_map[i].pipedir == PIPEDIR_IN) |
| 662 | ce_state->htt_rx_data = true; |
| 663 | else |
| 664 | ce_state->htt_tx_data = true; |
| 665 | rc = true; |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | return rc; |
| 670 | } |
| 671 | |
Houston Hoffman | 4780817 | 2016-05-06 10:04:21 -0700 | [diff] [blame] | 672 | /** |
| 673 | * ce_ring_test_initial_indexes() - tests the initial ce ring indexes |
| 674 | * @ce_id: ce in question |
| 675 | * @ring: ring state being examined |
| 676 | * @type: "src_ring" or "dest_ring" string for identifying the ring |
| 677 | * |
| 678 | * Warns on non-zero index values. |
| 679 | * Causes a kernel panic if the ring is not empty durring initialization. |
| 680 | */ |
| 681 | static void ce_ring_test_initial_indexes(int ce_id, struct CE_ring_state *ring, |
| 682 | char *type) |
| 683 | { |
| 684 | if (ring->write_index != 0 || ring->sw_index != 0) |
| 685 | HIF_ERROR("ce %d, %s, initial sw_index = %d, initial write_index =%d", |
| 686 | ce_id, type, ring->sw_index, ring->write_index); |
| 687 | if (ring->write_index != ring->sw_index) |
| 688 | QDF_BUG(0); |
| 689 | } |
| 690 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 691 | /** |
| 692 | * ce_srng_based() - Does this target use srng |
| 693 | * @ce_state : pointer to the state context of the CE |
| 694 | * |
| 695 | * Description: |
| 696 | * returns true if the target is SRNG based |
| 697 | * |
| 698 | * Return: |
| 699 | * false (attribute set to false) |
| 700 | * true (attribute set to true); |
| 701 | */ |
| 702 | bool ce_srng_based(struct hif_softc *scn) |
| 703 | { |
| 704 | struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn); |
| 705 | struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl); |
| 706 | |
| 707 | switch (tgt_info->target_type) { |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 708 | case TARGET_TYPE_QCA8074: |
Houston Hoffman | 31b25ec | 2016-09-19 13:12:30 -0700 | [diff] [blame] | 709 | case TARGET_TYPE_QCA6290: |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 710 | return true; |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 711 | default: |
| 712 | return false; |
| 713 | } |
| 714 | return false; |
| 715 | } |
Pratik Gandhi | dc82a77 | 2018-01-30 18:57:05 +0530 | [diff] [blame] | 716 | qdf_export_symbol(ce_srng_based); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 717 | |
Houston Hoffman | 5141f9d | 2017-01-05 10:49:17 -0800 | [diff] [blame] | 718 | #ifdef QCA_WIFI_SUPPORT_SRNG |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 719 | static struct ce_ops *ce_services_attach(struct hif_softc *scn) |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 720 | { |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 721 | if (ce_srng_based(scn)) |
| 722 | return ce_services_srng(); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 723 | |
| 724 | return ce_services_legacy(); |
| 725 | } |
Houston Hoffman | 5141f9d | 2017-01-05 10:49:17 -0800 | [diff] [blame] | 726 | |
Houston Hoffman | 5141f9d | 2017-01-05 10:49:17 -0800 | [diff] [blame] | 727 | |
Venkata Sharath Chandra Manchala | 837d323 | 2017-01-18 15:11:56 -0800 | [diff] [blame] | 728 | #else /* QCA_LITHIUM */ |
| 729 | static struct ce_ops *ce_services_attach(struct hif_softc *scn) |
| 730 | { |
| 731 | return ce_services_legacy(); |
| 732 | } |
| 733 | #endif /* QCA_LITHIUM */ |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 734 | |
Houston Hoffman | 403c2df | 2017-01-27 12:51:15 -0800 | [diff] [blame] | 735 | static void hif_prepare_hal_shadow_register_cfg(struct hif_softc *scn, |
Houston Hoffman | 10fedfc | 2017-01-23 15:23:09 -0800 | [diff] [blame] | 736 | struct pld_shadow_reg_v2_cfg **shadow_config, |
| 737 | int *num_shadow_registers_configured) { |
| 738 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 739 | |
| 740 | return hif_state->ce_services->ce_prepare_shadow_register_v2_cfg( |
| 741 | scn, shadow_config, num_shadow_registers_configured); |
| 742 | } |
| 743 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 744 | static inline uint32_t ce_get_desc_size(struct hif_softc *scn, |
| 745 | uint8_t ring_type) |
| 746 | { |
| 747 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 748 | |
| 749 | return hif_state->ce_services->ce_get_desc_size(ring_type); |
| 750 | } |
| 751 | |
| 752 | |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 753 | static struct CE_ring_state *ce_alloc_ring_state(struct CE_state *CE_state, |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 754 | uint8_t ring_type, uint32_t nentries) |
| 755 | { |
| 756 | uint32_t ce_nbytes; |
| 757 | char *ptr; |
| 758 | qdf_dma_addr_t base_addr; |
| 759 | struct CE_ring_state *ce_ring; |
| 760 | uint32_t desc_size; |
| 761 | struct hif_softc *scn = CE_state->scn; |
| 762 | |
| 763 | ce_nbytes = sizeof(struct CE_ring_state) |
| 764 | + (nentries * sizeof(void *)); |
| 765 | ptr = qdf_mem_malloc(ce_nbytes); |
| 766 | if (!ptr) |
| 767 | return NULL; |
| 768 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 769 | ce_ring = (struct CE_ring_state *)ptr; |
| 770 | ptr += sizeof(struct CE_ring_state); |
| 771 | ce_ring->nentries = nentries; |
| 772 | ce_ring->nentries_mask = nentries - 1; |
| 773 | |
| 774 | ce_ring->low_water_mark_nentries = 0; |
| 775 | ce_ring->high_water_mark_nentries = nentries; |
| 776 | ce_ring->per_transfer_context = (void **)ptr; |
| 777 | |
| 778 | desc_size = ce_get_desc_size(scn, ring_type); |
| 779 | |
| 780 | /* Legacy platforms that do not support cache |
| 781 | * coherent DMA are unsupported |
| 782 | */ |
| 783 | ce_ring->base_addr_owner_space_unaligned = |
| 784 | qdf_mem_alloc_consistent(scn->qdf_dev, |
| 785 | scn->qdf_dev->dev, |
| 786 | (nentries * |
| 787 | desc_size + |
| 788 | CE_DESC_RING_ALIGN), |
| 789 | &base_addr); |
| 790 | if (ce_ring->base_addr_owner_space_unaligned |
| 791 | == NULL) { |
| 792 | HIF_ERROR("%s: ring has no DMA mem", |
| 793 | __func__); |
| 794 | qdf_mem_free(ptr); |
| 795 | return NULL; |
| 796 | } |
| 797 | ce_ring->base_addr_CE_space_unaligned = base_addr; |
| 798 | |
| 799 | /* Correctly initialize memory to 0 to |
| 800 | * prevent garbage data crashing system |
| 801 | * when download firmware |
| 802 | */ |
| 803 | qdf_mem_zero(ce_ring->base_addr_owner_space_unaligned, |
| 804 | nentries * desc_size + |
| 805 | CE_DESC_RING_ALIGN); |
| 806 | |
| 807 | if (ce_ring->base_addr_CE_space_unaligned & (CE_DESC_RING_ALIGN - 1)) { |
| 808 | |
| 809 | ce_ring->base_addr_CE_space = |
| 810 | (ce_ring->base_addr_CE_space_unaligned + |
| 811 | CE_DESC_RING_ALIGN - 1) & ~(CE_DESC_RING_ALIGN - 1); |
| 812 | |
| 813 | ce_ring->base_addr_owner_space = (void *) |
| 814 | (((size_t) ce_ring->base_addr_owner_space_unaligned + |
| 815 | CE_DESC_RING_ALIGN - 1) & ~(CE_DESC_RING_ALIGN - 1)); |
| 816 | } else { |
| 817 | ce_ring->base_addr_CE_space = |
| 818 | ce_ring->base_addr_CE_space_unaligned; |
| 819 | ce_ring->base_addr_owner_space = |
| 820 | ce_ring->base_addr_owner_space_unaligned; |
| 821 | } |
| 822 | |
| 823 | return ce_ring; |
| 824 | } |
| 825 | |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 826 | static int ce_ring_setup(struct hif_softc *scn, uint8_t ring_type, |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 827 | uint32_t ce_id, struct CE_ring_state *ring, |
| 828 | struct CE_attr *attr) |
| 829 | { |
| 830 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 831 | |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 832 | return hif_state->ce_services->ce_ring_setup(scn, ring_type, ce_id, |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 833 | ring, attr); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 834 | } |
| 835 | |
Houston Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 836 | int hif_ce_bus_early_suspend(struct hif_softc *scn) |
| 837 | { |
| 838 | uint8_t ul_pipe, dl_pipe; |
| 839 | int ce_id, status, ul_is_polled, dl_is_polled; |
| 840 | struct CE_state *ce_state; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 841 | |
Houston Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 842 | status = hif_map_service_to_pipe(&scn->osc, WMI_CONTROL_SVC, |
| 843 | &ul_pipe, &dl_pipe, |
| 844 | &ul_is_polled, &dl_is_polled); |
| 845 | if (status) { |
| 846 | HIF_ERROR("%s: pipe_mapping failure", __func__); |
| 847 | return status; |
| 848 | } |
| 849 | |
| 850 | for (ce_id = 0; ce_id < scn->ce_count; ce_id++) { |
| 851 | if (ce_id == ul_pipe) |
| 852 | continue; |
| 853 | if (ce_id == dl_pipe) |
| 854 | continue; |
| 855 | |
| 856 | ce_state = scn->ce_id_to_state[ce_id]; |
| 857 | qdf_spin_lock_bh(&ce_state->ce_index_lock); |
| 858 | if (ce_state->state == CE_RUNNING) |
| 859 | ce_state->state = CE_PAUSED; |
| 860 | qdf_spin_unlock_bh(&ce_state->ce_index_lock); |
| 861 | } |
| 862 | |
| 863 | return status; |
| 864 | } |
| 865 | |
| 866 | int hif_ce_bus_late_resume(struct hif_softc *scn) |
| 867 | { |
| 868 | int ce_id; |
| 869 | struct CE_state *ce_state; |
| 870 | int write_index; |
| 871 | bool index_updated; |
| 872 | |
| 873 | for (ce_id = 0; ce_id < scn->ce_count; ce_id++) { |
| 874 | ce_state = scn->ce_id_to_state[ce_id]; |
| 875 | qdf_spin_lock_bh(&ce_state->ce_index_lock); |
| 876 | if (ce_state->state == CE_PENDING) { |
| 877 | write_index = ce_state->src_ring->write_index; |
| 878 | CE_SRC_RING_WRITE_IDX_SET(scn, ce_state->ctrl_addr, |
| 879 | write_index); |
| 880 | ce_state->state = CE_RUNNING; |
| 881 | index_updated = true; |
| 882 | } else { |
| 883 | index_updated = false; |
| 884 | } |
| 885 | |
| 886 | if (ce_state->state == CE_PAUSED) |
| 887 | ce_state->state = CE_RUNNING; |
| 888 | qdf_spin_unlock_bh(&ce_state->ce_index_lock); |
| 889 | |
| 890 | if (index_updated) |
| 891 | hif_record_ce_desc_event(scn, ce_id, |
| 892 | RESUME_WRITE_INDEX_UPDATE, |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 893 | NULL, NULL, write_index, 0); |
Houston Hoffman | cbcd839 | 2017-02-08 17:43:13 -0800 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | return 0; |
| 897 | } |
| 898 | |
Houston Hoffman | b12ccb7 | 2017-03-01 20:02:28 -0800 | [diff] [blame] | 899 | /** |
| 900 | * ce_oom_recovery() - try to recover rx ce from oom condition |
| 901 | * @context: CE_state of the CE with oom rx ring |
| 902 | * |
| 903 | * the executing work Will continue to be rescheduled untill |
| 904 | * at least 1 descriptor is successfully posted to the rx ring. |
| 905 | * |
| 906 | * return: none |
| 907 | */ |
| 908 | static void ce_oom_recovery(void *context) |
| 909 | { |
| 910 | struct CE_state *ce_state = context; |
| 911 | struct hif_softc *scn = ce_state->scn; |
| 912 | struct HIF_CE_state *ce_softc = HIF_GET_CE_STATE(scn); |
| 913 | struct HIF_CE_pipe_info *pipe_info = |
| 914 | &ce_softc->pipe_info[ce_state->id]; |
| 915 | |
| 916 | hif_post_recv_buffers_for_pipe(pipe_info); |
| 917 | } |
| 918 | |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 919 | #if HIF_CE_DEBUG_DATA_BUF |
| 920 | /** |
| 921 | * alloc_mem_ce_debug_hist_data() - Allocate mem for the data pointed by |
| 922 | * the CE descriptors. |
| 923 | * Allocate HIF_CE_HISTORY_MAX records by CE_DEBUG_MAX_DATA_BUF_SIZE |
| 924 | * @scn: hif scn handle |
| 925 | * ce_id: Copy Engine Id |
| 926 | * |
| 927 | * Return: QDF_STATUS |
| 928 | */ |
| 929 | QDF_STATUS alloc_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id) |
| 930 | { |
| 931 | struct hif_ce_desc_event *event = NULL; |
| 932 | struct hif_ce_desc_event *hist_ev = NULL; |
| 933 | uint32_t index = 0; |
| 934 | |
| 935 | hist_ev = |
| 936 | (struct hif_ce_desc_event *)scn->hif_ce_desc_hist.hist_ev[ce_id]; |
| 937 | |
| 938 | if (!hist_ev) |
| 939 | return QDF_STATUS_E_NOMEM; |
| 940 | |
| 941 | for (index = 0; index < HIF_CE_HISTORY_MAX; index++) { |
| 942 | event = &hist_ev[index]; |
| 943 | event->data = |
| 944 | (uint8_t *)qdf_mem_malloc(CE_DEBUG_MAX_DATA_BUF_SIZE); |
| 945 | if (event->data == NULL) |
| 946 | return QDF_STATUS_E_NOMEM; |
| 947 | } |
| 948 | return QDF_STATUS_SUCCESS; |
| 949 | } |
| 950 | |
| 951 | /** |
| 952 | * free_mem_ce_debug_hist_data() - Free mem of the data pointed by |
| 953 | * the CE descriptors. |
| 954 | * @scn: hif scn handle |
| 955 | * ce_id: Copy Engine Id |
| 956 | * |
| 957 | * Return: |
| 958 | */ |
| 959 | void free_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id) |
| 960 | { |
| 961 | struct hif_ce_desc_event *event = NULL; |
| 962 | struct hif_ce_desc_event *hist_ev = NULL; |
| 963 | uint32_t index = 0; |
| 964 | |
| 965 | hist_ev = |
| 966 | (struct hif_ce_desc_event *)scn->hif_ce_desc_hist.hist_ev[ce_id]; |
| 967 | |
| 968 | if (!hist_ev) |
| 969 | return; |
| 970 | |
| 971 | for (index = 0; index < HIF_CE_HISTORY_MAX; index++) { |
| 972 | event = &hist_ev[index]; |
| 973 | if (event->data != NULL) |
| 974 | qdf_mem_free(event->data); |
| 975 | event->data = NULL; |
| 976 | event = NULL; |
| 977 | } |
| 978 | } |
| 979 | #endif /* HIF_CE_DEBUG_DATA_BUF */ |
| 980 | |
| 981 | /* |
| 982 | * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked |
| 983 | * for defined here |
| 984 | */ |
| 985 | #if HIF_CE_DEBUG_DATA_BUF |
| 986 | /** |
| 987 | * alloc_mem_ce_debug_history() - Allocate mem for the CE descriptors storing |
| 988 | * @scn: hif scn handle |
| 989 | * ce_id: Copy Engine Id |
| 990 | * |
| 991 | * Return: QDF_STATUS |
| 992 | */ |
| 993 | static inline QDF_STATUS alloc_mem_ce_debug_history(struct hif_softc *scn, |
| 994 | unsigned int CE_id) |
| 995 | { |
| 996 | scn->hif_ce_desc_hist.hist_ev[CE_id] = (struct hif_ce_desc_event *) |
| 997 | qdf_mem_malloc(HIF_CE_HISTORY_MAX * sizeof(struct hif_ce_desc_event)); |
| 998 | |
| 999 | if (scn->hif_ce_desc_hist.hist_ev[CE_id] == NULL) { |
| 1000 | scn->hif_ce_desc_hist.enable[CE_id] = 0; |
| 1001 | return QDF_STATUS_E_NOMEM; |
| 1002 | } else { |
| 1003 | scn->hif_ce_desc_hist.enable[CE_id] = 1; |
| 1004 | return QDF_STATUS_SUCCESS; |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | /** |
| 1009 | * free_mem_ce_debug_history() - Free mem allocated for the CE descriptors |
| 1010 | * storing. |
| 1011 | * @scn: hif scn handle |
| 1012 | * ce_id: Copy Engine Id |
| 1013 | * |
| 1014 | * Return: |
| 1015 | */ |
| 1016 | static inline void free_mem_ce_debug_history(struct hif_softc *scn, |
| 1017 | unsigned int CE_id) |
| 1018 | { |
| 1019 | struct ce_desc_hist *ce_hist = &scn->hif_ce_desc_hist; |
| 1020 | struct hif_ce_desc_event *hist_ev = |
| 1021 | (struct hif_ce_desc_event *)ce_hist->hist_ev[CE_id]; |
| 1022 | |
| 1023 | if (!hist_ev) |
| 1024 | return; |
| 1025 | |
| 1026 | #if HIF_CE_DEBUG_DATA_BUF |
| 1027 | if (ce_hist->data_enable[CE_id] == 1) { |
| 1028 | ce_hist->data_enable[CE_id] = 0; |
| 1029 | free_mem_ce_debug_hist_data(scn, CE_id); |
| 1030 | } |
| 1031 | #endif |
| 1032 | ce_hist->enable[CE_id] = 0; |
| 1033 | qdf_mem_free(ce_hist->hist_ev[CE_id]); |
| 1034 | ce_hist->hist_ev[CE_id] = NULL; |
| 1035 | } |
| 1036 | |
| 1037 | /** |
| 1038 | * reset_ce_debug_history() - reset the index and ce id used for dumping the |
| 1039 | * CE records on the console using sysfs. |
| 1040 | * @scn: hif scn handle |
| 1041 | * |
| 1042 | * Return: |
| 1043 | */ |
| 1044 | static inline void reset_ce_debug_history(struct hif_softc *scn) |
| 1045 | { |
| 1046 | struct ce_desc_hist *ce_hist = &scn->hif_ce_desc_hist; |
| 1047 | /* Initialise the CE debug history sysfs interface inputs ce_id and |
| 1048 | * index. Disable data storing |
| 1049 | */ |
| 1050 | ce_hist->hist_index = 0; |
| 1051 | ce_hist->hist_id = 0; |
| 1052 | } |
| 1053 | #else /*Note: #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || HIF_CE_DEBUG_DATA_BUF */ |
| 1054 | static inline QDF_STATUS alloc_mem_ce_debug_history(struct hif_softc *scn, |
| 1055 | unsigned int CE_id) |
| 1056 | { |
| 1057 | return QDF_STATUS_SUCCESS; |
| 1058 | } |
| 1059 | |
| 1060 | static inline void free_mem_ce_debug_history(struct hif_softc *scn, |
| 1061 | unsigned int CE_id) |
| 1062 | { |
| 1063 | } |
| 1064 | |
| 1065 | static inline void reset_ce_debug_history(struct hif_softc *scn) |
| 1066 | { |
| 1067 | } |
| 1068 | #endif /*Note: defined(HIF_CONFIG_SLUB_DEBUG_ON) || HIF_CE_DEBUG_DATA_BUF */ |
| 1069 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1070 | /* |
| 1071 | * Initialize a Copy Engine based on caller-supplied attributes. |
| 1072 | * This may be called once to initialize both source and destination |
| 1073 | * rings or it may be called twice for separate source and destination |
| 1074 | * initialization. It may be that only one side or the other is |
| 1075 | * initialized by software/firmware. |
Houston Hoffman | 233e909 | 2015-09-02 13:37:21 -0700 | [diff] [blame] | 1076 | * |
| 1077 | * This should be called durring the initialization sequence before |
| 1078 | * interupts are enabled, so we don't have to worry about thread safety. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1079 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1080 | struct CE_handle *ce_init(struct hif_softc *scn, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1081 | unsigned int CE_id, struct CE_attr *attr) |
| 1082 | { |
| 1083 | struct CE_state *CE_state; |
| 1084 | uint32_t ctrl_addr; |
| 1085 | unsigned int nentries; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1086 | bool malloc_CE_state = false; |
| 1087 | bool malloc_src_ring = false; |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 1088 | int status; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1089 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1090 | QDF_ASSERT(CE_id < scn->ce_count); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1091 | ctrl_addr = CE_BASE_ADDRESS(CE_id); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1092 | CE_state = scn->ce_id_to_state[CE_id]; |
| 1093 | |
| 1094 | if (!CE_state) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1095 | CE_state = |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1096 | (struct CE_state *)qdf_mem_malloc(sizeof(*CE_state)); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1097 | if (!CE_state) { |
| 1098 | HIF_ERROR("%s: CE_state has no mem", __func__); |
| 1099 | return NULL; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1100 | } |
Houston Hoffman | 233e909 | 2015-09-02 13:37:21 -0700 | [diff] [blame] | 1101 | malloc_CE_state = true; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1102 | qdf_spinlock_create(&CE_state->ce_index_lock); |
Houston Hoffman | 233e909 | 2015-09-02 13:37:21 -0700 | [diff] [blame] | 1103 | |
| 1104 | CE_state->id = CE_id; |
| 1105 | CE_state->ctrl_addr = ctrl_addr; |
| 1106 | CE_state->state = CE_RUNNING; |
| 1107 | CE_state->attr_flags = attr->flags; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1108 | } |
| 1109 | CE_state->scn = scn; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1110 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1111 | qdf_atomic_init(&CE_state->rx_pending); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1112 | if (attr == NULL) { |
| 1113 | /* Already initialized; caller wants the handle */ |
| 1114 | return (struct CE_handle *)CE_state; |
| 1115 | } |
| 1116 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1117 | if (CE_state->src_sz_max) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1118 | QDF_ASSERT(CE_state->src_sz_max == attr->src_sz_max); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1119 | else |
| 1120 | CE_state->src_sz_max = attr->src_sz_max; |
| 1121 | |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 1122 | ce_init_ce_desc_event_log(scn, CE_id, |
| 1123 | attr->src_nentries + attr->dest_nentries); |
Houston Hoffman | 68e837e | 2015-12-04 12:57:24 -0800 | [diff] [blame] | 1124 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1125 | /* source ring setup */ |
| 1126 | nentries = attr->src_nentries; |
| 1127 | if (nentries) { |
| 1128 | struct CE_ring_state *src_ring; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1129 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1130 | nentries = roundup_pwr2(nentries); |
| 1131 | if (CE_state->src_ring) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1132 | QDF_ASSERT(CE_state->src_ring->nentries == nentries); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1133 | } else { |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1134 | src_ring = CE_state->src_ring = |
| 1135 | ce_alloc_ring_state(CE_state, |
| 1136 | CE_RING_SRC, |
| 1137 | nentries); |
| 1138 | if (!src_ring) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1139 | /* cannot allocate src ring. If the |
| 1140 | * CE_state is allocated locally free |
| 1141 | * CE_State and return error. |
| 1142 | */ |
| 1143 | HIF_ERROR("%s: src ring has no mem", __func__); |
| 1144 | if (malloc_CE_state) { |
| 1145 | /* allocated CE_state locally */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1146 | qdf_mem_free(CE_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1147 | malloc_CE_state = false; |
| 1148 | } |
| 1149 | return NULL; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1150 | } |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1151 | /* we can allocate src ring. Mark that the src ring is |
| 1152 | * allocated locally |
| 1153 | */ |
| 1154 | malloc_src_ring = true; |
| 1155 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1156 | /* |
| 1157 | * Also allocate a shadow src ring in |
| 1158 | * regular mem to use for faster access. |
| 1159 | */ |
| 1160 | src_ring->shadow_base_unaligned = |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1161 | qdf_mem_malloc(nentries * |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1162 | sizeof(struct CE_src_desc) + |
| 1163 | CE_DESC_RING_ALIGN); |
| 1164 | if (src_ring->shadow_base_unaligned == NULL) { |
| 1165 | HIF_ERROR("%s: src ring no shadow_base mem", |
| 1166 | __func__); |
| 1167 | goto error_no_dma_mem; |
| 1168 | } |
| 1169 | src_ring->shadow_base = (struct CE_src_desc *) |
| 1170 | (((size_t) src_ring->shadow_base_unaligned + |
| 1171 | CE_DESC_RING_ALIGN - 1) & |
| 1172 | ~(CE_DESC_RING_ALIGN - 1)); |
| 1173 | |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 1174 | status = ce_ring_setup(scn, CE_RING_SRC, CE_id, |
| 1175 | src_ring, attr); |
| 1176 | if (status < 0) |
Houston Hoffman | 4411ad4 | 2016-03-14 21:12:04 -0700 | [diff] [blame] | 1177 | goto error_target_access; |
Houston Hoffman | f789c66 | 2016-04-12 15:39:04 -0700 | [diff] [blame] | 1178 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1179 | ce_ring_test_initial_indexes(CE_id, src_ring, |
| 1180 | "src_ring"); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | /* destination ring setup */ |
| 1185 | nentries = attr->dest_nentries; |
| 1186 | if (nentries) { |
| 1187 | struct CE_ring_state *dest_ring; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1188 | |
| 1189 | nentries = roundup_pwr2(nentries); |
| 1190 | if (CE_state->dest_ring) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1191 | QDF_ASSERT(CE_state->dest_ring->nentries == nentries); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1192 | } else { |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1193 | dest_ring = CE_state->dest_ring = |
| 1194 | ce_alloc_ring_state(CE_state, |
| 1195 | CE_RING_DEST, |
| 1196 | nentries); |
| 1197 | if (!dest_ring) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1198 | /* cannot allocate dst ring. If the CE_state |
| 1199 | * or src ring is allocated locally free |
| 1200 | * CE_State and src ring and return error. |
| 1201 | */ |
| 1202 | HIF_ERROR("%s: dest ring has no mem", |
| 1203 | __func__); |
Poddar, Siddarth | 55d6da0 | 2017-03-31 18:42:54 +0530 | [diff] [blame] | 1204 | goto error_no_dma_mem; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1205 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1206 | |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 1207 | status = ce_ring_setup(scn, CE_RING_DEST, CE_id, |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1208 | dest_ring, attr); |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 1209 | if (status < 0) |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1210 | goto error_target_access; |
Houston Hoffman | 4780817 | 2016-05-06 10:04:21 -0700 | [diff] [blame] | 1211 | |
| 1212 | ce_ring_test_initial_indexes(CE_id, dest_ring, |
| 1213 | "dest_ring"); |
| 1214 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1215 | /* For srng based target, init status ring here */ |
| 1216 | if (ce_srng_based(CE_state->scn)) { |
| 1217 | CE_state->status_ring = |
| 1218 | ce_alloc_ring_state(CE_state, |
| 1219 | CE_RING_STATUS, |
| 1220 | nentries); |
| 1221 | if (CE_state->status_ring == NULL) { |
| 1222 | /*Allocation failed. Cleanup*/ |
| 1223 | qdf_mem_free(CE_state->dest_ring); |
| 1224 | if (malloc_src_ring) { |
| 1225 | qdf_mem_free |
| 1226 | (CE_state->src_ring); |
| 1227 | CE_state->src_ring = NULL; |
| 1228 | malloc_src_ring = false; |
| 1229 | } |
| 1230 | if (malloc_CE_state) { |
| 1231 | /* allocated CE_state locally */ |
| 1232 | scn->ce_id_to_state[CE_id] = |
| 1233 | NULL; |
| 1234 | qdf_mem_free(CE_state); |
| 1235 | malloc_CE_state = false; |
| 1236 | } |
Houston Hoffman | 4411ad4 | 2016-03-14 21:12:04 -0700 | [diff] [blame] | 1237 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1238 | return NULL; |
| 1239 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1240 | |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 1241 | status = ce_ring_setup(scn, CE_RING_STATUS, |
| 1242 | CE_id, CE_state->status_ring, |
| 1243 | attr); |
| 1244 | if (status < 0) |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1245 | goto error_target_access; |
| 1246 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1247 | } |
Houston Hoffman | 31b25ec | 2016-09-19 13:12:30 -0700 | [diff] [blame] | 1248 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1249 | /* epping */ |
| 1250 | /* poll timer */ |
Balamurugan Mahalingam | 3ab3633 | 2018-01-29 19:15:02 +0530 | [diff] [blame] | 1251 | if ((CE_state->attr_flags & CE_ATTR_ENABLE_POLL) || |
| 1252 | scn->polled_mode_on) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1253 | qdf_timer_init(scn->qdf_dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1254 | &CE_state->poll_timer, |
| 1255 | ce_poll_timeout, |
| 1256 | CE_state, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1257 | QDF_TIMER_TYPE_SW); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1258 | CE_state->timer_inited = true; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1259 | qdf_timer_mod(&CE_state->poll_timer, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1260 | CE_POLL_TIMEOUT); |
| 1261 | } |
| 1262 | } |
| 1263 | } |
| 1264 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1265 | if (!ce_srng_based(scn)) { |
| 1266 | /* Enable CE error interrupts */ |
| 1267 | if (Q_TARGET_ACCESS_BEGIN(scn) < 0) |
| 1268 | goto error_target_access; |
| 1269 | CE_ERROR_INTR_ENABLE(scn, ctrl_addr); |
| 1270 | if (Q_TARGET_ACCESS_END(scn) < 0) |
| 1271 | goto error_target_access; |
| 1272 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1273 | |
Houston Hoffman | b12ccb7 | 2017-03-01 20:02:28 -0800 | [diff] [blame] | 1274 | qdf_create_work(scn->qdf_dev, &CE_state->oom_allocation_work, |
| 1275 | ce_oom_recovery, CE_state); |
| 1276 | |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 1277 | /* update the htt_data attribute */ |
| 1278 | ce_mark_datapath(CE_state); |
Houston Hoffman | b01db18 | 2017-03-13 14:38:09 -0700 | [diff] [blame] | 1279 | scn->ce_id_to_state[CE_id] = CE_state; |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 1280 | |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 1281 | alloc_mem_ce_debug_history(scn, CE_id); |
| 1282 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1283 | return (struct CE_handle *)CE_state; |
| 1284 | |
Houston Hoffman | 4411ad4 | 2016-03-14 21:12:04 -0700 | [diff] [blame] | 1285 | error_target_access: |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1286 | error_no_dma_mem: |
| 1287 | ce_fini((struct CE_handle *)CE_state); |
| 1288 | return NULL; |
| 1289 | } |
| 1290 | |
| 1291 | #ifdef WLAN_FEATURE_FASTPATH |
| 1292 | /** |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1293 | * hif_enable_fastpath() Update that we have enabled fastpath mode |
| 1294 | * @hif_ctx: HIF context |
| 1295 | * |
| 1296 | * For use in data path |
| 1297 | * |
| 1298 | * Retrun: void |
| 1299 | */ |
| 1300 | void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx) |
| 1301 | { |
| 1302 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1303 | |
Houston Hoffman | d63cd74 | 2016-12-05 11:59:56 -0800 | [diff] [blame] | 1304 | if (ce_srng_based(scn)) { |
| 1305 | HIF_INFO("%s, srng rings do not support fastpath", __func__); |
| 1306 | return; |
| 1307 | } |
Srinivas Girigowda | 6e0cfd9 | 2017-03-09 15:49:59 -0800 | [diff] [blame] | 1308 | HIF_DBG("%s, Enabling fastpath mode", __func__); |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1309 | scn->fastpath_mode_on = true; |
| 1310 | } |
| 1311 | |
Balamurugan Mahalingam | 3ab3633 | 2018-01-29 19:15:02 +0530 | [diff] [blame] | 1312 | void hif_enable_polled_mode(struct hif_opaque_softc *hif_ctx) |
| 1313 | { |
| 1314 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1315 | HIF_DBG("%s, Enabling polled mode", __func__); |
| 1316 | |
| 1317 | scn->polled_mode_on = true; |
| 1318 | } |
| 1319 | |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1320 | /** |
| 1321 | * hif_is_fastpath_mode_enabled - API to query if fasthpath mode is enabled |
| 1322 | * @hif_ctx: HIF Context |
| 1323 | * |
| 1324 | * For use in data path to skip HTC |
| 1325 | * |
| 1326 | * Return: bool |
| 1327 | */ |
| 1328 | bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx) |
| 1329 | { |
| 1330 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1331 | |
| 1332 | return scn->fastpath_mode_on; |
| 1333 | } |
| 1334 | |
Balamurugan Mahalingam | 3ab3633 | 2018-01-29 19:15:02 +0530 | [diff] [blame] | 1335 | bool hif_is_polled_mode_enabled(struct hif_opaque_softc *hif_ctx) |
| 1336 | { |
| 1337 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1338 | |
| 1339 | return scn->polled_mode_on; |
| 1340 | } |
| 1341 | |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1342 | /** |
| 1343 | * hif_get_ce_handle - API to get CE handle for FastPath mode |
| 1344 | * @hif_ctx: HIF Context |
| 1345 | * @id: CopyEngine Id |
| 1346 | * |
| 1347 | * API to return CE handle for fastpath mode |
| 1348 | * |
| 1349 | * Return: void |
| 1350 | */ |
| 1351 | void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int id) |
| 1352 | { |
| 1353 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 1354 | |
| 1355 | return scn->ce_id_to_state[id]; |
| 1356 | } |
| 1357 | |
| 1358 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1359 | * ce_h2t_tx_ce_cleanup() Place holder function for H2T CE cleanup. |
| 1360 | * No processing is required inside this function. |
| 1361 | * @ce_hdl: Cope engine handle |
| 1362 | * Using an assert, this function makes sure that, |
| 1363 | * the TX CE has been processed completely. |
Houston Hoffman | 9a831ef | 2015-09-03 14:42:40 -0700 | [diff] [blame] | 1364 | * |
| 1365 | * This is called while dismantling CE structures. No other thread |
| 1366 | * should be using these structures while dismantling is occuring |
| 1367 | * therfore no locking is needed. |
| 1368 | * |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1369 | * Return: none |
| 1370 | */ |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1371 | void ce_h2t_tx_ce_cleanup(struct CE_handle *ce_hdl) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1372 | { |
| 1373 | struct CE_state *ce_state = (struct CE_state *)ce_hdl; |
| 1374 | struct CE_ring_state *src_ring = ce_state->src_ring; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1375 | struct hif_softc *sc = ce_state->scn; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1376 | uint32_t sw_index, write_index; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1377 | |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 1378 | if (hif_is_nss_wifi_enabled(sc)) |
| 1379 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1380 | |
Houston Hoffman | c7d5429 | 2016-04-13 18:55:37 -0700 | [diff] [blame] | 1381 | if (sc->fastpath_mode_on && ce_state->htt_tx_data) { |
Srinivas Girigowda | 6e0cfd9 | 2017-03-09 15:49:59 -0800 | [diff] [blame] | 1382 | HIF_DBG("%s %d Fastpath mode ON, Cleaning up HTT Tx CE", |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 1383 | __func__, __LINE__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1384 | sw_index = src_ring->sw_index; |
| 1385 | write_index = src_ring->sw_index; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1386 | |
| 1387 | /* At this point Tx CE should be clean */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1388 | qdf_assert_always(sw_index == write_index); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1389 | } |
| 1390 | } |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1391 | |
| 1392 | /** |
| 1393 | * ce_t2h_msg_ce_cleanup() - Cleanup buffers on the t2h datapath msg queue. |
| 1394 | * @ce_hdl: Handle to CE |
| 1395 | * |
| 1396 | * These buffers are never allocated on the fly, but |
| 1397 | * are allocated only once during HIF start and freed |
| 1398 | * only once during HIF stop. |
| 1399 | * NOTE: |
| 1400 | * The assumption here is there is no in-flight DMA in progress |
| 1401 | * currently, so that buffers can be freed up safely. |
| 1402 | * |
| 1403 | * Return: NONE |
| 1404 | */ |
| 1405 | void ce_t2h_msg_ce_cleanup(struct CE_handle *ce_hdl) |
| 1406 | { |
| 1407 | struct CE_state *ce_state = (struct CE_state *)ce_hdl; |
| 1408 | struct CE_ring_state *dst_ring = ce_state->dest_ring; |
| 1409 | qdf_nbuf_t nbuf; |
| 1410 | int i; |
| 1411 | |
Houston Hoffman | 7fe51b1 | 2016-11-14 18:01:05 -0800 | [diff] [blame] | 1412 | if (ce_state->scn->fastpath_mode_on == false) |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1413 | return; |
Houston Hoffman | 7fe51b1 | 2016-11-14 18:01:05 -0800 | [diff] [blame] | 1414 | |
| 1415 | if (!ce_state->htt_rx_data) |
| 1416 | return; |
| 1417 | |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1418 | /* |
| 1419 | * when fastpath_mode is on and for datapath CEs. Unlike other CE's, |
| 1420 | * this CE is completely full: does not leave one blank space, to |
| 1421 | * distinguish between empty queue & full queue. So free all the |
| 1422 | * entries. |
| 1423 | */ |
| 1424 | for (i = 0; i < dst_ring->nentries; i++) { |
| 1425 | nbuf = dst_ring->per_transfer_context[i]; |
| 1426 | |
| 1427 | /* |
| 1428 | * The reasons for doing this check are: |
| 1429 | * 1) Protect against calling cleanup before allocating buffers |
| 1430 | * 2) In a corner case, FASTPATH_mode_on may be set, but we |
| 1431 | * could have a partially filled ring, because of a memory |
| 1432 | * allocation failure in the middle of allocating ring. |
| 1433 | * This check accounts for that case, checking |
| 1434 | * fastpath_mode_on flag or started flag would not have |
| 1435 | * covered that case. This is not in performance path, |
| 1436 | * so OK to do this. |
| 1437 | */ |
Houston Hoffman | 1c72830 | 2017-03-10 16:58:49 -0800 | [diff] [blame] | 1438 | if (nbuf) { |
| 1439 | qdf_nbuf_unmap_single(ce_state->scn->qdf_dev, nbuf, |
| 1440 | QDF_DMA_FROM_DEVICE); |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1441 | qdf_nbuf_free(nbuf); |
Houston Hoffman | 1c72830 | 2017-03-10 16:58:49 -0800 | [diff] [blame] | 1442 | } |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1443 | } |
| 1444 | } |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1445 | |
| 1446 | /** |
| 1447 | * hif_update_fastpath_recv_bufs_cnt() - Increments the Rx buf count by 1 |
| 1448 | * @scn: HIF handle |
| 1449 | * |
| 1450 | * Datapath Rx CEs are special case, where we reuse all the message buffers. |
| 1451 | * Hence we have to post all the entries in the pipe, even, in the beginning |
| 1452 | * unlike for other CE pipes where one less than dest_nentries are filled in |
| 1453 | * the beginning. |
| 1454 | * |
| 1455 | * Return: None |
| 1456 | */ |
| 1457 | static void hif_update_fastpath_recv_bufs_cnt(struct hif_softc *scn) |
| 1458 | { |
| 1459 | int pipe_num; |
| 1460 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 1461 | |
| 1462 | if (scn->fastpath_mode_on == false) |
| 1463 | return; |
| 1464 | |
| 1465 | for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) { |
| 1466 | struct HIF_CE_pipe_info *pipe_info = |
| 1467 | &hif_state->pipe_info[pipe_num]; |
| 1468 | struct CE_state *ce_state = |
| 1469 | scn->ce_id_to_state[pipe_info->pipe_num]; |
| 1470 | |
| 1471 | if (ce_state->htt_rx_data) |
| 1472 | atomic_inc(&pipe_info->recv_bufs_needed); |
| 1473 | } |
| 1474 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1475 | #else |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1476 | static inline void hif_update_fastpath_recv_bufs_cnt(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1477 | { |
| 1478 | } |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1479 | |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1480 | static inline bool ce_is_fastpath_enabled(struct hif_softc *scn) |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1481 | { |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 1482 | return false; |
| 1483 | } |
| 1484 | |
| 1485 | static inline bool ce_is_fastpath_handler_registered(struct CE_state *ce_state) |
| 1486 | { |
| 1487 | return false; |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1488 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1489 | #endif /* WLAN_FEATURE_FASTPATH */ |
| 1490 | |
| 1491 | void ce_fini(struct CE_handle *copyeng) |
| 1492 | { |
| 1493 | struct CE_state *CE_state = (struct CE_state *)copyeng; |
| 1494 | unsigned int CE_id = CE_state->id; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1495 | struct hif_softc *scn = CE_state->scn; |
Kiran Venkatappa | ae1a370 | 2017-12-29 21:08:10 +0530 | [diff] [blame] | 1496 | uint32_t desc_size; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1497 | |
Balamurugan Mahalingam | f6d3035 | 2018-01-31 16:17:24 +0530 | [diff] [blame] | 1498 | bool inited = CE_state->timer_inited; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1499 | CE_state->state = CE_UNUSED; |
| 1500 | scn->ce_id_to_state[CE_id] = NULL; |
Balamurugan Mahalingam | f6d3035 | 2018-01-31 16:17:24 +0530 | [diff] [blame] | 1501 | /* Set the flag to false first to stop processing in ce_poll_timeout */ |
| 1502 | CE_state->timer_inited = false; |
Dhanashri Atre | 991ee4d | 2017-05-03 19:03:10 -0700 | [diff] [blame] | 1503 | qdf_lro_deinit(CE_state->lro_data); |
| 1504 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1505 | if (CE_state->src_ring) { |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1506 | /* Cleanup the datapath Tx ring */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1507 | ce_h2t_tx_ce_cleanup(copyeng); |
| 1508 | |
Kiran Venkatappa | ae1a370 | 2017-12-29 21:08:10 +0530 | [diff] [blame] | 1509 | desc_size = ce_get_desc_size(scn, CE_RING_SRC); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1510 | if (CE_state->src_ring->shadow_base_unaligned) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1511 | qdf_mem_free(CE_state->src_ring->shadow_base_unaligned); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1512 | if (CE_state->src_ring->base_addr_owner_space_unaligned) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1513 | qdf_mem_free_consistent(scn->qdf_dev, |
| 1514 | scn->qdf_dev->dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1515 | (CE_state->src_ring->nentries * |
Kiran Venkatappa | ae1a370 | 2017-12-29 21:08:10 +0530 | [diff] [blame] | 1516 | desc_size + |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1517 | CE_DESC_RING_ALIGN), |
| 1518 | CE_state->src_ring-> |
| 1519 | base_addr_owner_space_unaligned, |
| 1520 | CE_state->src_ring-> |
| 1521 | base_addr_CE_space, 0); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1522 | qdf_mem_free(CE_state->src_ring); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1523 | } |
| 1524 | if (CE_state->dest_ring) { |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 1525 | /* Cleanup the datapath Rx ring */ |
| 1526 | ce_t2h_msg_ce_cleanup(copyeng); |
| 1527 | |
Kiran Venkatappa | ae1a370 | 2017-12-29 21:08:10 +0530 | [diff] [blame] | 1528 | desc_size = ce_get_desc_size(scn, CE_RING_DEST); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1529 | if (CE_state->dest_ring->base_addr_owner_space_unaligned) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1530 | qdf_mem_free_consistent(scn->qdf_dev, |
| 1531 | scn->qdf_dev->dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1532 | (CE_state->dest_ring->nentries * |
Kiran Venkatappa | ae1a370 | 2017-12-29 21:08:10 +0530 | [diff] [blame] | 1533 | desc_size + |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1534 | CE_DESC_RING_ALIGN), |
| 1535 | CE_state->dest_ring-> |
| 1536 | base_addr_owner_space_unaligned, |
| 1537 | CE_state->dest_ring-> |
| 1538 | base_addr_CE_space, 0); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1539 | qdf_mem_free(CE_state->dest_ring); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1540 | |
| 1541 | /* epping */ |
Balamurugan Mahalingam | f6d3035 | 2018-01-31 16:17:24 +0530 | [diff] [blame] | 1542 | if (inited) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1543 | qdf_timer_free(&CE_state->poll_timer); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1544 | } |
| 1545 | } |
Houston Hoffman | 31b25ec | 2016-09-19 13:12:30 -0700 | [diff] [blame] | 1546 | if ((ce_srng_based(CE_state->scn)) && (CE_state->status_ring)) { |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1547 | /* Cleanup the datapath Tx ring */ |
| 1548 | ce_h2t_tx_ce_cleanup(copyeng); |
| 1549 | |
| 1550 | if (CE_state->status_ring->shadow_base_unaligned) |
| 1551 | qdf_mem_free( |
| 1552 | CE_state->status_ring->shadow_base_unaligned); |
| 1553 | |
Kiran Venkatappa | ae1a370 | 2017-12-29 21:08:10 +0530 | [diff] [blame] | 1554 | desc_size = ce_get_desc_size(scn, CE_RING_STATUS); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1555 | if (CE_state->status_ring->base_addr_owner_space_unaligned) |
| 1556 | qdf_mem_free_consistent(scn->qdf_dev, |
| 1557 | scn->qdf_dev->dev, |
| 1558 | (CE_state->status_ring->nentries * |
Kiran Venkatappa | ae1a370 | 2017-12-29 21:08:10 +0530 | [diff] [blame] | 1559 | desc_size + |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 1560 | CE_DESC_RING_ALIGN), |
| 1561 | CE_state->status_ring-> |
| 1562 | base_addr_owner_space_unaligned, |
| 1563 | CE_state->status_ring-> |
| 1564 | base_addr_CE_space, 0); |
| 1565 | qdf_mem_free(CE_state->status_ring); |
| 1566 | } |
Houston Hoffman | 03f4657 | 2016-12-12 12:53:56 -0800 | [diff] [blame] | 1567 | |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 1568 | free_mem_ce_debug_history(scn, CE_id); |
| 1569 | reset_ce_debug_history(scn); |
| 1570 | ce_deinit_ce_desc_event_log(scn, CE_id); |
| 1571 | |
Houston Hoffman | 03f4657 | 2016-12-12 12:53:56 -0800 | [diff] [blame] | 1572 | qdf_spinlock_destroy(&CE_state->ce_index_lock); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1573 | qdf_mem_free(CE_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1574 | } |
| 1575 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 1576 | void hif_detach_htc(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1577 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 1578 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1579 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1580 | qdf_mem_zero(&hif_state->msg_callbacks_pending, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1581 | sizeof(hif_state->msg_callbacks_pending)); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1582 | qdf_mem_zero(&hif_state->msg_callbacks_current, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1583 | sizeof(hif_state->msg_callbacks_current)); |
| 1584 | } |
| 1585 | |
| 1586 | /* Send the first nbytes bytes of the buffer */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1587 | QDF_STATUS |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 1588 | hif_send_head(struct hif_opaque_softc *hif_ctx, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1589 | uint8_t pipe, unsigned int transfer_id, unsigned int nbytes, |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1590 | qdf_nbuf_t nbuf, unsigned int data_attr) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1591 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1592 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 1593 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1594 | struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]); |
| 1595 | struct CE_handle *ce_hdl = pipe_info->ce_hdl; |
| 1596 | int bytes = nbytes, nfrags = 0; |
| 1597 | struct ce_sendlist sendlist; |
| 1598 | int status, i = 0; |
| 1599 | unsigned int mux_id = 0; |
| 1600 | |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1601 | QDF_ASSERT(nbytes <= qdf_nbuf_len(nbuf)); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1602 | |
| 1603 | transfer_id = |
| 1604 | (mux_id & MUX_ID_MASK) | |
| 1605 | (transfer_id & TRANSACTION_ID_MASK); |
| 1606 | data_attr &= DESC_DATA_FLAG_MASK; |
| 1607 | /* |
| 1608 | * The common case involves sending multiple fragments within a |
| 1609 | * single download (the tx descriptor and the tx frame header). |
| 1610 | * So, optimize for the case of multiple fragments by not even |
| 1611 | * checking whether it's necessary to use a sendlist. |
| 1612 | * The overhead of using a sendlist for a single buffer download |
| 1613 | * is not a big deal, since it happens rarely (for WMI messages). |
| 1614 | */ |
| 1615 | ce_sendlist_init(&sendlist); |
| 1616 | do { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1617 | qdf_dma_addr_t frag_paddr; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1618 | int frag_bytes; |
| 1619 | |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1620 | frag_paddr = qdf_nbuf_get_frag_paddr(nbuf, nfrags); |
| 1621 | frag_bytes = qdf_nbuf_get_frag_len(nbuf, nfrags); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1622 | /* |
| 1623 | * Clear the packet offset for all but the first CE desc. |
| 1624 | */ |
| 1625 | if (i++ > 0) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1626 | data_attr &= ~QDF_CE_TX_PKT_OFFSET_BIT_M; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1627 | |
| 1628 | status = ce_sendlist_buf_add(&sendlist, frag_paddr, |
| 1629 | frag_bytes > |
| 1630 | bytes ? bytes : frag_bytes, |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1631 | qdf_nbuf_get_frag_is_wordstream |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1632 | (nbuf, |
| 1633 | nfrags) ? 0 : |
| 1634 | CE_SEND_FLAG_SWAP_DISABLE, |
| 1635 | data_attr); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1636 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1637 | HIF_ERROR("%s: error, frag_num %d larger than limit", |
| 1638 | __func__, nfrags); |
| 1639 | return status; |
| 1640 | } |
| 1641 | bytes -= frag_bytes; |
| 1642 | nfrags++; |
| 1643 | } while (bytes > 0); |
| 1644 | |
| 1645 | /* Make sure we have resources to handle this request */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1646 | qdf_spin_lock_bh(&pipe_info->completion_freeq_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1647 | if (pipe_info->num_sends_allowed < nfrags) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1648 | qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1649 | ce_pkt_error_count_incr(hif_state, HIF_PIPE_NO_RESOURCE); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1650 | return QDF_STATUS_E_RESOURCES; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1651 | } |
| 1652 | pipe_info->num_sends_allowed -= nfrags; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1653 | qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1654 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1655 | if (qdf_unlikely(ce_hdl == NULL)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1656 | HIF_ERROR("%s: error CE handle is null", __func__); |
| 1657 | return A_ERROR; |
| 1658 | } |
| 1659 | |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1660 | QDF_NBUF_UPDATE_TX_PKT_COUNT(nbuf, QDF_NBUF_TX_PKT_HIF); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1661 | DPTRACE(qdf_dp_trace(nbuf, QDF_DP_TRACE_HIF_PACKET_PTR_RECORD, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1662 | QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(nbuf), |
| 1663 | sizeof(qdf_nbuf_data(nbuf)), QDF_TX)); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1664 | status = ce_sendlist_send(ce_hdl, nbuf, &sendlist, transfer_id); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1665 | QDF_ASSERT(status == QDF_STATUS_SUCCESS); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1666 | |
| 1667 | return status; |
| 1668 | } |
| 1669 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 1670 | void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t pipe, |
| 1671 | int force) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1672 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1673 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 1674 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1675 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1676 | if (!force) { |
| 1677 | int resources; |
| 1678 | /* |
| 1679 | * Decide whether to actually poll for completions, or just |
| 1680 | * wait for a later chance. If there seem to be plenty of |
| 1681 | * resources left, then just wait, since checking involves |
| 1682 | * reading a CE register, which is a relatively expensive |
| 1683 | * operation. |
| 1684 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1685 | resources = hif_get_free_queue_number(hif_ctx, pipe); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1686 | /* |
| 1687 | * If at least 50% of the total resources are still available, |
| 1688 | * don't bother checking again yet. |
| 1689 | */ |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1690 | if (resources > (hif_state->host_ce_config[pipe].src_nentries >> |
| 1691 | 1)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1692 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1693 | } |
Houston Hoffman | 56e0d70 | 2016-05-05 17:48:06 -0700 | [diff] [blame] | 1694 | #if ATH_11AC_TXCOMPACT |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1695 | ce_per_engine_servicereap(scn, pipe); |
| 1696 | #else |
| 1697 | ce_per_engine_service(scn, pipe); |
| 1698 | #endif |
| 1699 | } |
| 1700 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 1701 | uint16_t |
| 1702 | hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t pipe) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1703 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 1704 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1705 | struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]); |
| 1706 | uint16_t rv; |
| 1707 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1708 | qdf_spin_lock_bh(&pipe_info->completion_freeq_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1709 | rv = pipe_info->num_sends_allowed; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1710 | qdf_spin_unlock_bh(&pipe_info->completion_freeq_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1711 | return rv; |
| 1712 | } |
| 1713 | |
| 1714 | /* Called by lower (CE) layer when a send to Target completes. */ |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 1715 | static void |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1716 | hif_pci_ce_send_done(struct CE_handle *copyeng, void *ce_context, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1717 | void *transfer_context, qdf_dma_addr_t CE_data, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1718 | unsigned int nbytes, unsigned int transfer_id, |
| 1719 | unsigned int sw_index, unsigned int hw_index, |
| 1720 | unsigned int toeplitz_hash_result) |
| 1721 | { |
| 1722 | struct HIF_CE_pipe_info *pipe_info = |
| 1723 | (struct HIF_CE_pipe_info *)ce_context; |
| 1724 | struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1725 | struct hif_softc *scn = HIF_GET_SOFTC(hif_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1726 | unsigned int sw_idx = sw_index, hw_idx = hw_index; |
Houston Hoffman | 8511851 | 2015-09-28 14:17:11 -0700 | [diff] [blame] | 1727 | struct hif_msg_callbacks *msg_callbacks = |
Venkateswara Swamy Bandaru | 26f6f1e | 2016-10-03 19:35:57 +0530 | [diff] [blame] | 1728 | &pipe_info->pipe_callbacks; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1729 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1730 | do { |
| 1731 | /* |
Houston Hoffman | 8511851 | 2015-09-28 14:17:11 -0700 | [diff] [blame] | 1732 | * The upper layer callback will be triggered |
| 1733 | * when last fragment is complteted. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1734 | */ |
Houston Hoffman | 8511851 | 2015-09-28 14:17:11 -0700 | [diff] [blame] | 1735 | if (transfer_context != CE_SENDLIST_ITEM_CTXT) { |
Houston Hoffman | 1c72830 | 2017-03-10 16:58:49 -0800 | [diff] [blame] | 1736 | if (scn->target_status == TARGET_STATUS_RESET) { |
| 1737 | |
| 1738 | qdf_nbuf_unmap_single(scn->qdf_dev, |
| 1739 | transfer_context, |
| 1740 | QDF_DMA_TO_DEVICE); |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1741 | qdf_nbuf_free(transfer_context); |
Houston Hoffman | 1c72830 | 2017-03-10 16:58:49 -0800 | [diff] [blame] | 1742 | } else |
Houston Hoffman | 49794a3 | 2015-12-21 12:14:56 -0800 | [diff] [blame] | 1743 | msg_callbacks->txCompletionHandler( |
Houston Hoffman | 8511851 | 2015-09-28 14:17:11 -0700 | [diff] [blame] | 1744 | msg_callbacks->Context, |
| 1745 | transfer_context, transfer_id, |
| 1746 | toeplitz_hash_result); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1747 | } |
| 1748 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1749 | qdf_spin_lock(&pipe_info->completion_freeq_lock); |
Houston Hoffman | 8511851 | 2015-09-28 14:17:11 -0700 | [diff] [blame] | 1750 | pipe_info->num_sends_allowed++; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1751 | qdf_spin_unlock(&pipe_info->completion_freeq_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1752 | } while (ce_completed_send_next(copyeng, |
| 1753 | &ce_context, &transfer_context, |
| 1754 | &CE_data, &nbytes, &transfer_id, |
| 1755 | &sw_idx, &hw_idx, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1756 | &toeplitz_hash_result) == QDF_STATUS_SUCCESS); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1757 | } |
| 1758 | |
Houston Hoffman | 910c626 | 2015-09-28 12:56:25 -0700 | [diff] [blame] | 1759 | /** |
| 1760 | * hif_ce_do_recv(): send message from copy engine to upper layers |
| 1761 | * @msg_callbacks: structure containing callback and callback context |
| 1762 | * @netbuff: skb containing message |
| 1763 | * @nbytes: number of bytes in the message |
| 1764 | * @pipe_info: used for the pipe_number info |
| 1765 | * |
| 1766 | * Checks the packet length, configures the lenght in the netbuff, |
| 1767 | * and calls the upper layer callback. |
| 1768 | * |
| 1769 | * return: None |
| 1770 | */ |
| 1771 | static inline void hif_ce_do_recv(struct hif_msg_callbacks *msg_callbacks, |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1772 | qdf_nbuf_t netbuf, int nbytes, |
Houston Hoffman | 910c626 | 2015-09-28 12:56:25 -0700 | [diff] [blame] | 1773 | struct HIF_CE_pipe_info *pipe_info) { |
| 1774 | if (nbytes <= pipe_info->buf_sz) { |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1775 | qdf_nbuf_set_pktlen(netbuf, nbytes); |
Houston Hoffman | 910c626 | 2015-09-28 12:56:25 -0700 | [diff] [blame] | 1776 | msg_callbacks-> |
| 1777 | rxCompletionHandler(msg_callbacks->Context, |
| 1778 | netbuf, pipe_info->pipe_num); |
| 1779 | } else { |
Jeff Johnson | b945021 | 2017-09-18 10:12:38 -0700 | [diff] [blame] | 1780 | HIF_ERROR("%s: Invalid Rx msg buf:%pK nbytes:%d", |
Houston Hoffman | 910c626 | 2015-09-28 12:56:25 -0700 | [diff] [blame] | 1781 | __func__, netbuf, nbytes); |
Houston Hoffman | 1c72830 | 2017-03-10 16:58:49 -0800 | [diff] [blame] | 1782 | |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1783 | qdf_nbuf_free(netbuf); |
Houston Hoffman | 910c626 | 2015-09-28 12:56:25 -0700 | [diff] [blame] | 1784 | } |
| 1785 | } |
| 1786 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1787 | /* Called by lower (CE) layer when data is received from the Target. */ |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 1788 | static void |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1789 | hif_pci_ce_recv_data(struct CE_handle *copyeng, void *ce_context, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1790 | void *transfer_context, qdf_dma_addr_t CE_data, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1791 | unsigned int nbytes, unsigned int transfer_id, |
| 1792 | unsigned int flags) |
| 1793 | { |
| 1794 | struct HIF_CE_pipe_info *pipe_info = |
| 1795 | (struct HIF_CE_pipe_info *)ce_context; |
| 1796 | struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state; |
Houston Hoffman | 18c7fc5 | 2015-09-02 11:44:42 -0700 | [diff] [blame] | 1797 | struct CE_state *ce_state = (struct CE_state *) copyeng; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1798 | struct hif_softc *scn = HIF_GET_SOFTC(hif_state); |
Houston Hoffman | e02e12d | 2016-03-14 21:11:36 -0700 | [diff] [blame] | 1799 | #ifdef HIF_PCI |
| 1800 | struct hif_pci_softc *hif_pci_sc = HIF_GET_PCI_SOFTC(hif_state); |
| 1801 | #endif |
Houston Hoffman | 910c626 | 2015-09-28 12:56:25 -0700 | [diff] [blame] | 1802 | struct hif_msg_callbacks *msg_callbacks = |
Venkateswara Swamy Bandaru | 26f6f1e | 2016-10-03 19:35:57 +0530 | [diff] [blame] | 1803 | &pipe_info->pipe_callbacks; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1804 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1805 | do { |
Houston Hoffman | e02e12d | 2016-03-14 21:11:36 -0700 | [diff] [blame] | 1806 | #ifdef HIF_PCI |
| 1807 | hif_pm_runtime_mark_last_busy(hif_pci_sc->dev); |
| 1808 | #endif |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1809 | qdf_nbuf_unmap_single(scn->qdf_dev, |
| 1810 | (qdf_nbuf_t) transfer_context, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1811 | QDF_DMA_FROM_DEVICE); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1812 | |
Houston Hoffman | 910c626 | 2015-09-28 12:56:25 -0700 | [diff] [blame] | 1813 | atomic_inc(&pipe_info->recv_bufs_needed); |
| 1814 | hif_post_recv_buffers_for_pipe(pipe_info); |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 1815 | if (scn->target_status == TARGET_STATUS_RESET) |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 1816 | qdf_nbuf_free(transfer_context); |
Houston Hoffman | 49794a3 | 2015-12-21 12:14:56 -0800 | [diff] [blame] | 1817 | else |
| 1818 | hif_ce_do_recv(msg_callbacks, transfer_context, |
Houston Hoffman | 9c0f80a | 2015-09-28 18:36:36 -0700 | [diff] [blame] | 1819 | nbytes, pipe_info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1820 | |
| 1821 | /* Set up force_break flag if num of receices reaches |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1822 | * MAX_NUM_OF_RECEIVES |
| 1823 | */ |
Houston Hoffman | 5bf441a | 2015-09-02 11:52:10 -0700 | [diff] [blame] | 1824 | ce_state->receive_count++; |
Houston Hoffman | 0565272 | 2016-04-29 16:58:59 -0700 | [diff] [blame] | 1825 | if (qdf_unlikely(hif_ce_service_should_yield(scn, ce_state))) { |
Houston Hoffman | 18c7fc5 | 2015-09-02 11:44:42 -0700 | [diff] [blame] | 1826 | ce_state->force_break = 1; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1827 | break; |
| 1828 | } |
| 1829 | } while (ce_completed_recv_next(copyeng, &ce_context, &transfer_context, |
| 1830 | &CE_data, &nbytes, &transfer_id, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1831 | &flags) == QDF_STATUS_SUCCESS); |
Houston Hoffman | f460785 | 2015-12-17 17:14:40 -0800 | [diff] [blame] | 1832 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1833 | } |
| 1834 | |
| 1835 | /* TBDXXX: Set CE High Watermark; invoke txResourceAvailHandler in response */ |
| 1836 | |
| 1837 | void |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 1838 | hif_post_init(struct hif_opaque_softc *hif_ctx, void *unused, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1839 | struct hif_msg_callbacks *callbacks) |
| 1840 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 1841 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1842 | |
| 1843 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 1844 | spin_lock_init(&pcie_access_log_lock); |
| 1845 | #endif |
| 1846 | /* Save callbacks for later installation */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1847 | qdf_mem_copy(&hif_state->msg_callbacks_pending, callbacks, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1848 | sizeof(hif_state->msg_callbacks_pending)); |
| 1849 | |
| 1850 | } |
| 1851 | |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 1852 | static int hif_completion_thread_startup(struct HIF_CE_state *hif_state) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1853 | { |
| 1854 | struct CE_handle *ce_diag = hif_state->ce_diag; |
| 1855 | int pipe_num; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1856 | struct hif_softc *scn = HIF_GET_SOFTC(hif_state); |
Houston Hoffman | 9c12f7f | 2015-09-28 16:52:14 -0700 | [diff] [blame] | 1857 | struct hif_msg_callbacks *hif_msg_callbacks = |
| 1858 | &hif_state->msg_callbacks_current; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1859 | |
| 1860 | /* daemonize("hif_compl_thread"); */ |
| 1861 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1862 | if (scn->ce_count == 0) { |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 1863 | HIF_ERROR("%s: Invalid ce_count", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1864 | return -EINVAL; |
| 1865 | } |
Houston Hoffman | 9c12f7f | 2015-09-28 16:52:14 -0700 | [diff] [blame] | 1866 | |
| 1867 | if (!hif_msg_callbacks || |
| 1868 | !hif_msg_callbacks->rxCompletionHandler || |
| 1869 | !hif_msg_callbacks->txCompletionHandler) { |
| 1870 | HIF_ERROR("%s: no completion handler registered", __func__); |
| 1871 | return -EFAULT; |
| 1872 | } |
| 1873 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1874 | A_TARGET_ACCESS_LIKELY(scn); |
| 1875 | for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) { |
| 1876 | struct CE_attr attr; |
| 1877 | struct HIF_CE_pipe_info *pipe_info; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1878 | |
| 1879 | pipe_info = &hif_state->pipe_info[pipe_num]; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 1880 | if (pipe_info->ce_hdl == ce_diag) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1881 | continue; /* Handle Diagnostic CE specially */ |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 1882 | attr = hif_state->host_ce_config[pipe_num]; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1883 | if (attr.src_nentries) { |
| 1884 | /* pipe used to send to target */ |
Jeff Johnson | b945021 | 2017-09-18 10:12:38 -0700 | [diff] [blame] | 1885 | HIF_DBG("%s: pipe_num:%d pipe_info:0x%pK", |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1886 | __func__, pipe_num, pipe_info); |
| 1887 | ce_send_cb_register(pipe_info->ce_hdl, |
| 1888 | hif_pci_ce_send_done, pipe_info, |
| 1889 | attr.flags & CE_ATTR_DISABLE_INTR); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1890 | pipe_info->num_sends_allowed = attr.src_nentries - 1; |
| 1891 | } |
| 1892 | if (attr.dest_nentries) { |
| 1893 | /* pipe used to receive from target */ |
| 1894 | ce_recv_cb_register(pipe_info->ce_hdl, |
| 1895 | hif_pci_ce_recv_data, pipe_info, |
| 1896 | attr.flags & CE_ATTR_DISABLE_INTR); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1897 | } |
Houston Hoffman | 6666df7 | 2015-11-30 16:48:35 -0800 | [diff] [blame] | 1898 | |
| 1899 | if (attr.src_nentries) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1900 | qdf_spinlock_create(&pipe_info->completion_freeq_lock); |
Venkateswara Swamy Bandaru | 26f6f1e | 2016-10-03 19:35:57 +0530 | [diff] [blame] | 1901 | |
| 1902 | qdf_mem_copy(&pipe_info->pipe_callbacks, hif_msg_callbacks, |
| 1903 | sizeof(pipe_info->pipe_callbacks)); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1904 | } |
Houston Hoffman | 6666df7 | 2015-11-30 16:48:35 -0800 | [diff] [blame] | 1905 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1906 | A_TARGET_ACCESS_UNLIKELY(scn); |
| 1907 | return 0; |
| 1908 | } |
| 1909 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1910 | /* |
| 1911 | * Install pending msg callbacks. |
| 1912 | * |
| 1913 | * TBDXXX: This hack is needed because upper layers install msg callbacks |
| 1914 | * for use with HTC before BMI is done; yet this HIF implementation |
| 1915 | * needs to continue to use BMI msg callbacks. Really, upper layers |
| 1916 | * should not register HTC callbacks until AFTER BMI phase. |
| 1917 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1918 | static void hif_msg_callbacks_install(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1919 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 1920 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1921 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 1922 | qdf_mem_copy(&hif_state->msg_callbacks_current, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1923 | &hif_state->msg_callbacks_pending, |
| 1924 | sizeof(hif_state->msg_callbacks_pending)); |
| 1925 | } |
| 1926 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 1927 | void hif_get_default_pipe(struct hif_opaque_softc *hif_hdl, uint8_t *ULPipe, |
| 1928 | uint8_t *DLPipe) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1929 | { |
| 1930 | int ul_is_polled, dl_is_polled; |
| 1931 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1932 | (void)hif_map_service_to_pipe(hif_hdl, HTC_CTRL_RSVD_SVC, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1933 | ULPipe, DLPipe, &ul_is_polled, &dl_is_polled); |
| 1934 | } |
| 1935 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1936 | /** |
| 1937 | * hif_dump_pipe_debug_count() - Log error count |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1938 | * @scn: hif_softc pointer. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1939 | * |
| 1940 | * Output the pipe error counts of each pipe to log file |
| 1941 | * |
| 1942 | * Return: N/A |
| 1943 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 1944 | void hif_dump_pipe_debug_count(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1945 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 1946 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1947 | int pipe_num; |
| 1948 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1949 | if (hif_state == NULL) { |
| 1950 | HIF_ERROR("%s hif_state is NULL", __func__); |
| 1951 | return; |
| 1952 | } |
| 1953 | for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) { |
| 1954 | struct HIF_CE_pipe_info *pipe_info; |
| 1955 | |
| 1956 | pipe_info = &hif_state->pipe_info[pipe_num]; |
| 1957 | |
| 1958 | if (pipe_info->nbuf_alloc_err_count > 0 || |
| 1959 | pipe_info->nbuf_dma_err_count > 0 || |
| 1960 | pipe_info->nbuf_ce_enqueue_err_count) |
| 1961 | HIF_ERROR( |
| 1962 | "%s: pipe_id = %d, recv_bufs_needed = %d, nbuf_alloc_err_count = %u, nbuf_dma_err_count = %u, nbuf_ce_enqueue_err_count = %u", |
| 1963 | __func__, pipe_info->pipe_num, |
| 1964 | atomic_read(&pipe_info->recv_bufs_needed), |
| 1965 | pipe_info->nbuf_alloc_err_count, |
| 1966 | pipe_info->nbuf_dma_err_count, |
| 1967 | pipe_info->nbuf_ce_enqueue_err_count); |
| 1968 | } |
| 1969 | } |
| 1970 | |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 1971 | static void hif_post_recv_buffers_failure(struct HIF_CE_pipe_info *pipe_info, |
| 1972 | void *nbuf, uint32_t *error_cnt, |
| 1973 | enum hif_ce_event_type failure_type, |
| 1974 | const char *failure_type_string) |
| 1975 | { |
| 1976 | int bufs_needed_tmp = atomic_inc_return(&pipe_info->recv_bufs_needed); |
| 1977 | struct CE_state *CE_state = (struct CE_state *)pipe_info->ce_hdl; |
| 1978 | struct hif_softc *scn = HIF_GET_SOFTC(pipe_info->HIF_CE_state); |
| 1979 | int ce_id = CE_state->id; |
| 1980 | uint32_t error_cnt_tmp; |
| 1981 | |
| 1982 | qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock); |
| 1983 | error_cnt_tmp = ++(*error_cnt); |
| 1984 | qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock); |
Himanshu Agarwal | 38cea4a | 2017-03-30 19:02:52 +0530 | [diff] [blame] | 1985 | HIF_DBG("%s: pipe_num %d, needed %d, err_cnt = %u, fail_type = %s", |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 1986 | __func__, pipe_info->pipe_num, bufs_needed_tmp, error_cnt_tmp, |
| 1987 | failure_type_string); |
| 1988 | hif_record_ce_desc_event(scn, ce_id, failure_type, |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 1989 | NULL, nbuf, bufs_needed_tmp, 0); |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 1990 | /* if we fail to allocate the last buffer for an rx pipe, |
| 1991 | * there is no trigger to refill the ce and we will |
| 1992 | * eventually crash |
| 1993 | */ |
Himanshu Agarwal | bedeed9 | 2017-03-21 14:05:10 +0530 | [diff] [blame] | 1994 | if (bufs_needed_tmp == CE_state->dest_ring->nentries - 1) |
Houston Hoffman | b12ccb7 | 2017-03-01 20:02:28 -0800 | [diff] [blame] | 1995 | qdf_sched_work(scn->qdf_dev, &CE_state->oom_allocation_work); |
Himanshu Agarwal | bedeed9 | 2017-03-21 14:05:10 +0530 | [diff] [blame] | 1996 | |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 1997 | } |
| 1998 | |
| 1999 | |
Houston Hoffman | b12ccb7 | 2017-03-01 20:02:28 -0800 | [diff] [blame] | 2000 | |
| 2001 | |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2002 | QDF_STATUS hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2003 | { |
| 2004 | struct CE_handle *ce_hdl; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2005 | qdf_size_t buf_sz; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2006 | struct hif_softc *scn = HIF_GET_SOFTC(pipe_info->HIF_CE_state); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2007 | QDF_STATUS status; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2008 | uint32_t bufs_posted = 0; |
| 2009 | |
| 2010 | buf_sz = pipe_info->buf_sz; |
| 2011 | if (buf_sz == 0) { |
| 2012 | /* Unused Copy Engine */ |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2013 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | ce_hdl = pipe_info->ce_hdl; |
| 2017 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2018 | qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2019 | while (atomic_read(&pipe_info->recv_bufs_needed) > 0) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2020 | qdf_dma_addr_t CE_data; /* CE space buffer address */ |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2021 | qdf_nbuf_t nbuf; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2022 | |
| 2023 | atomic_dec(&pipe_info->recv_bufs_needed); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2024 | qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2025 | |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2026 | nbuf = qdf_nbuf_alloc(scn->qdf_dev, buf_sz, 0, 4, false); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2027 | if (!nbuf) { |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 2028 | hif_post_recv_buffers_failure(pipe_info, nbuf, |
| 2029 | &pipe_info->nbuf_alloc_err_count, |
| 2030 | HIF_RX_NBUF_ALLOC_FAILURE, |
| 2031 | "HIF_RX_NBUF_ALLOC_FAILURE"); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2032 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2033 | } |
| 2034 | |
| 2035 | /* |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2036 | * qdf_nbuf_peek_header(nbuf, &data, &unused); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2037 | * CE_data = dma_map_single(dev, data, buf_sz, ); |
| 2038 | * DMA_FROM_DEVICE); |
| 2039 | */ |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2040 | status = qdf_nbuf_map_single(scn->qdf_dev, nbuf, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2041 | QDF_DMA_FROM_DEVICE); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2042 | |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2043 | if (qdf_unlikely(status != QDF_STATUS_SUCCESS)) { |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 2044 | hif_post_recv_buffers_failure(pipe_info, nbuf, |
| 2045 | &pipe_info->nbuf_dma_err_count, |
| 2046 | HIF_RX_NBUF_MAP_FAILURE, |
| 2047 | "HIF_RX_NBUF_MAP_FAILURE"); |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2048 | qdf_nbuf_free(nbuf); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2049 | return status; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2050 | } |
| 2051 | |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2052 | CE_data = qdf_nbuf_get_frag_paddr(nbuf, 0); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2053 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2054 | qdf_mem_dma_sync_single_for_device(scn->qdf_dev, CE_data, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2055 | buf_sz, DMA_FROM_DEVICE); |
| 2056 | status = ce_recv_buf_enqueue(ce_hdl, (void *)nbuf, CE_data); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2057 | if (qdf_unlikely(status != QDF_STATUS_SUCCESS)) { |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 2058 | hif_post_recv_buffers_failure(pipe_info, nbuf, |
| 2059 | &pipe_info->nbuf_ce_enqueue_err_count, |
| 2060 | HIF_RX_NBUF_ENQUEUE_FAILURE, |
| 2061 | "HIF_RX_NBUF_ENQUEUE_FAILURE"); |
| 2062 | |
Govind Singh | 4fcafd4 | 2016-08-08 12:37:31 +0530 | [diff] [blame] | 2063 | qdf_nbuf_unmap_single(scn->qdf_dev, nbuf, |
| 2064 | QDF_DMA_FROM_DEVICE); |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2065 | qdf_nbuf_free(nbuf); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2066 | return status; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2067 | } |
| 2068 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2069 | qdf_spin_lock_bh(&pipe_info->recv_bufs_needed_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2070 | bufs_posted++; |
| 2071 | } |
| 2072 | pipe_info->nbuf_alloc_err_count = |
Houston Hoffman | 5693683 | 2016-03-16 12:16:24 -0700 | [diff] [blame] | 2073 | (pipe_info->nbuf_alloc_err_count > bufs_posted) ? |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2074 | pipe_info->nbuf_alloc_err_count - bufs_posted : 0; |
| 2075 | pipe_info->nbuf_dma_err_count = |
Houston Hoffman | 5693683 | 2016-03-16 12:16:24 -0700 | [diff] [blame] | 2076 | (pipe_info->nbuf_dma_err_count > bufs_posted) ? |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2077 | pipe_info->nbuf_dma_err_count - bufs_posted : 0; |
| 2078 | pipe_info->nbuf_ce_enqueue_err_count = |
Houston Hoffman | 5693683 | 2016-03-16 12:16:24 -0700 | [diff] [blame] | 2079 | (pipe_info->nbuf_ce_enqueue_err_count > bufs_posted) ? |
Houston Hoffman | c0c00a2 | 2017-02-24 17:37:46 -0800 | [diff] [blame] | 2080 | pipe_info->nbuf_ce_enqueue_err_count - bufs_posted : 0; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2081 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2082 | qdf_spin_unlock_bh(&pipe_info->recv_bufs_needed_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2083 | |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2084 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2085 | } |
| 2086 | |
| 2087 | /* |
| 2088 | * Try to post all desired receive buffers for all pipes. |
Govind Singh | caa850e | 2017-04-20 16:41:36 +0530 | [diff] [blame] | 2089 | * Returns 0 for non fastpath rx copy engine as |
| 2090 | * oom_allocation_work will be scheduled to recover any |
| 2091 | * failures, non-zero if unable to completely replenish |
| 2092 | * receive buffers for fastpath rx Copy engine. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2093 | */ |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2094 | QDF_STATUS hif_post_recv_buffers(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2095 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 2096 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2097 | int pipe_num; |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2098 | struct CE_state *ce_state; |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2099 | QDF_STATUS qdf_status; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2100 | |
| 2101 | A_TARGET_ACCESS_LIKELY(scn); |
| 2102 | for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) { |
| 2103 | struct HIF_CE_pipe_info *pipe_info; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2104 | |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2105 | ce_state = scn->ce_id_to_state[pipe_num]; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2106 | pipe_info = &hif_state->pipe_info[pipe_num]; |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2107 | |
| 2108 | if (hif_is_nss_wifi_enabled(scn) && |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2109 | ce_state && (ce_state->htt_rx_data)) |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2110 | continue; |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2111 | |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2112 | qdf_status = hif_post_recv_buffers_for_pipe(pipe_info); |
| 2113 | if (!QDF_IS_STATUS_SUCCESS(qdf_status) && |
Govind Singh | caa850e | 2017-04-20 16:41:36 +0530 | [diff] [blame] | 2114 | ce_state->htt_rx_data && |
| 2115 | scn->fastpath_mode_on) { |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2116 | A_TARGET_ACCESS_UNLIKELY(scn); |
| 2117 | return qdf_status; |
Govind Singh | caa850e | 2017-04-20 16:41:36 +0530 | [diff] [blame] | 2118 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2119 | } |
| 2120 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2121 | A_TARGET_ACCESS_UNLIKELY(scn); |
| 2122 | |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2123 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2124 | } |
| 2125 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2126 | QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2127 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2128 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 2129 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2130 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2131 | |
Manjunathappa Prakash | 4a9c3a8 | 2016-04-14 01:12:14 -0700 | [diff] [blame] | 2132 | hif_update_fastpath_recv_bufs_cnt(scn); |
| 2133 | |
Houston Hoffman | 9c12f7f | 2015-09-28 16:52:14 -0700 | [diff] [blame] | 2134 | hif_msg_callbacks_install(scn); |
| 2135 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2136 | if (hif_completion_thread_startup(hif_state)) |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2137 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2138 | |
Houston Hoffman | 271951f | 2016-11-12 15:24:27 -0800 | [diff] [blame] | 2139 | /* enable buffer cleanup */ |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2140 | hif_state->started = true; |
| 2141 | |
Houston Hoffman | 271951f | 2016-11-12 15:24:27 -0800 | [diff] [blame] | 2142 | /* Post buffers once to start things off. */ |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2143 | qdf_status = hif_post_recv_buffers(scn); |
| 2144 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Houston Hoffman | 271951f | 2016-11-12 15:24:27 -0800 | [diff] [blame] | 2145 | /* cleanup is done in hif_ce_disable */ |
| 2146 | HIF_ERROR("%s:failed to post buffers", __func__); |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2147 | return qdf_status; |
Houston Hoffman | 271951f | 2016-11-12 15:24:27 -0800 | [diff] [blame] | 2148 | } |
| 2149 | |
Nachiket Kukade | e5738b5 | 2017-09-07 17:16:12 +0530 | [diff] [blame] | 2150 | return qdf_status; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2151 | } |
| 2152 | |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 2153 | static void hif_recv_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2154 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2155 | struct hif_softc *scn; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2156 | struct CE_handle *ce_hdl; |
| 2157 | uint32_t buf_sz; |
| 2158 | struct HIF_CE_state *hif_state; |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2159 | qdf_nbuf_t netbuf; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2160 | qdf_dma_addr_t CE_data; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2161 | void *per_CE_context; |
| 2162 | |
| 2163 | buf_sz = pipe_info->buf_sz; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2164 | /* Unused Copy Engine */ |
| 2165 | if (buf_sz == 0) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2166 | return; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2167 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2168 | |
| 2169 | hif_state = pipe_info->HIF_CE_state; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2170 | if (!hif_state->started) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2171 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2172 | |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 2173 | scn = HIF_GET_SOFTC(hif_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2174 | ce_hdl = pipe_info->ce_hdl; |
| 2175 | |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2176 | if (scn->qdf_dev == NULL) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2177 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2178 | while (ce_revoke_recv_next |
| 2179 | (ce_hdl, &per_CE_context, (void **)&netbuf, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2180 | &CE_data) == QDF_STATUS_SUCCESS) { |
Govind Singh | caa850e | 2017-04-20 16:41:36 +0530 | [diff] [blame] | 2181 | if (netbuf) { |
| 2182 | qdf_nbuf_unmap_single(scn->qdf_dev, netbuf, |
| 2183 | QDF_DMA_FROM_DEVICE); |
| 2184 | qdf_nbuf_free(netbuf); |
| 2185 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2186 | } |
| 2187 | } |
| 2188 | |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 2189 | static void hif_send_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2190 | { |
| 2191 | struct CE_handle *ce_hdl; |
| 2192 | struct HIF_CE_state *hif_state; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2193 | struct hif_softc *scn; |
Vishwajith Upendra | 70f8b6e | 2016-03-01 16:28:23 +0530 | [diff] [blame] | 2194 | qdf_nbuf_t netbuf; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2195 | void *per_CE_context; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2196 | qdf_dma_addr_t CE_data; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2197 | unsigned int nbytes; |
| 2198 | unsigned int id; |
| 2199 | uint32_t buf_sz; |
| 2200 | uint32_t toeplitz_hash_result; |
| 2201 | |
| 2202 | buf_sz = pipe_info->buf_sz; |
| 2203 | if (buf_sz == 0) { |
| 2204 | /* Unused Copy Engine */ |
| 2205 | return; |
| 2206 | } |
| 2207 | |
| 2208 | hif_state = pipe_info->HIF_CE_state; |
| 2209 | if (!hif_state->started) { |
| 2210 | return; |
| 2211 | } |
| 2212 | |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 2213 | scn = HIF_GET_SOFTC(hif_state); |
| 2214 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2215 | ce_hdl = pipe_info->ce_hdl; |
| 2216 | |
| 2217 | while (ce_cancel_send_next |
| 2218 | (ce_hdl, &per_CE_context, |
| 2219 | (void **)&netbuf, &CE_data, &nbytes, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2220 | &id, &toeplitz_hash_result) == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2221 | if (netbuf != CE_SENDLIST_ITEM_CTXT) { |
| 2222 | /* |
| 2223 | * Packets enqueued by htt_h2t_ver_req_msg() and |
| 2224 | * htt_h2t_rx_ring_cfg_msg_ll() have already been |
| 2225 | * freed in htt_htc_misc_pkt_pool_free() in |
| 2226 | * wlantl_close(), so do not free them here again |
Houston Hoffman | 29573d9 | 2015-10-20 17:49:44 -0700 | [diff] [blame] | 2227 | * by checking whether it's the endpoint |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2228 | * which they are queued in. |
| 2229 | */ |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 2230 | if (id == scn->htc_htt_tx_endpoint) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2231 | return; |
Nirav Shah | d7f9159 | 2016-04-21 14:18:43 +0530 | [diff] [blame] | 2232 | /* Indicate the completion to higher |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2233 | * layer to free the buffer |
| 2234 | */ |
| 2235 | if (pipe_info->pipe_callbacks.txCompletionHandler) |
Venkateswara Swamy Bandaru | 26f6f1e | 2016-10-03 19:35:57 +0530 | [diff] [blame] | 2236 | pipe_info->pipe_callbacks. |
| 2237 | txCompletionHandler(pipe_info-> |
| 2238 | pipe_callbacks.Context, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2239 | netbuf, id, toeplitz_hash_result); |
| 2240 | } |
| 2241 | } |
| 2242 | } |
| 2243 | |
| 2244 | /* |
| 2245 | * Cleanup residual buffers for device shutdown: |
| 2246 | * buffers that were enqueued for receive |
| 2247 | * buffers that were to be sent |
| 2248 | * Note: Buffers that had completed but which were |
| 2249 | * not yet processed are on a completion queue. They |
| 2250 | * are handled when the completion thread shuts down. |
| 2251 | */ |
Jeff Johnson | 6950fdb | 2016-10-07 13:00:59 -0700 | [diff] [blame] | 2252 | static void hif_buffer_cleanup(struct HIF_CE_state *hif_state) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2253 | { |
| 2254 | int pipe_num; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2255 | struct hif_softc *scn = HIF_GET_SOFTC(hif_state); |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2256 | struct CE_state *ce_state; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2257 | |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 2258 | for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2259 | struct HIF_CE_pipe_info *pipe_info; |
| 2260 | |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2261 | ce_state = scn->ce_id_to_state[pipe_num]; |
| 2262 | if (hif_is_nss_wifi_enabled(scn) && ce_state && |
| 2263 | ((ce_state->htt_tx_data) || |
| 2264 | (ce_state->htt_rx_data))) { |
| 2265 | continue; |
| 2266 | } |
| 2267 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2268 | pipe_info = &hif_state->pipe_info[pipe_num]; |
| 2269 | hif_recv_buffer_cleanup_on_pipe(pipe_info); |
| 2270 | hif_send_buffer_cleanup_on_pipe(pipe_info); |
| 2271 | } |
| 2272 | } |
| 2273 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 2274 | void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2275 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2276 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 2277 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2278 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2279 | hif_buffer_cleanup(hif_state); |
| 2280 | } |
| 2281 | |
Houston Hoffman | b12ccb7 | 2017-03-01 20:02:28 -0800 | [diff] [blame] | 2282 | static void hif_destroy_oom_work(struct hif_softc *scn) |
| 2283 | { |
| 2284 | struct CE_state *ce_state; |
| 2285 | int ce_id; |
| 2286 | |
| 2287 | for (ce_id = 0; ce_id < scn->ce_count; ce_id++) { |
| 2288 | ce_state = scn->ce_id_to_state[ce_id]; |
| 2289 | if (ce_state) |
| 2290 | qdf_destroy_work(scn->qdf_dev, |
| 2291 | &ce_state->oom_allocation_work); |
| 2292 | } |
| 2293 | } |
| 2294 | |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 2295 | void hif_ce_stop(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2296 | { |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 2297 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2298 | int pipe_num; |
| 2299 | |
Houston Hoffman | a69581e | 2016-11-14 18:03:19 -0800 | [diff] [blame] | 2300 | /* |
| 2301 | * before cleaning up any memory, ensure irq & |
| 2302 | * bottom half contexts will not be re-entered |
| 2303 | */ |
Houston Hoffman | 7622cd3 | 2017-04-06 14:17:49 -0700 | [diff] [blame] | 2304 | hif_disable_isr(&scn->osc); |
Houston Hoffman | b12ccb7 | 2017-03-01 20:02:28 -0800 | [diff] [blame] | 2305 | hif_destroy_oom_work(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2306 | scn->hif_init_done = false; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2307 | |
| 2308 | /* |
| 2309 | * At this point, asynchronous threads are stopped, |
| 2310 | * The Target should not DMA nor interrupt, Host code may |
| 2311 | * not initiate anything more. So we just need to clean |
| 2312 | * up Host-side state. |
| 2313 | */ |
| 2314 | |
| 2315 | if (scn->athdiag_procfs_inited) { |
| 2316 | athdiag_procfs_remove(); |
| 2317 | scn->athdiag_procfs_inited = false; |
| 2318 | } |
| 2319 | |
| 2320 | hif_buffer_cleanup(hif_state); |
| 2321 | |
| 2322 | for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) { |
| 2323 | struct HIF_CE_pipe_info *pipe_info; |
Poddar, Siddarth | 725e9f5 | 2017-07-19 15:18:28 +0530 | [diff] [blame] | 2324 | struct CE_attr attr; |
| 2325 | struct CE_handle *ce_diag = hif_state->ce_diag; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2326 | |
| 2327 | pipe_info = &hif_state->pipe_info[pipe_num]; |
| 2328 | if (pipe_info->ce_hdl) { |
Poddar, Siddarth | 725e9f5 | 2017-07-19 15:18:28 +0530 | [diff] [blame] | 2329 | if (pipe_info->ce_hdl != ce_diag) { |
| 2330 | attr = hif_state->host_ce_config[pipe_num]; |
| 2331 | if (attr.src_nentries) |
| 2332 | qdf_spinlock_destroy(&pipe_info-> |
| 2333 | completion_freeq_lock); |
| 2334 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2335 | ce_fini(pipe_info->ce_hdl); |
| 2336 | pipe_info->ce_hdl = NULL; |
| 2337 | pipe_info->buf_sz = 0; |
Poddar, Siddarth | 725e9f5 | 2017-07-19 15:18:28 +0530 | [diff] [blame] | 2338 | qdf_spinlock_destroy(&pipe_info->recv_bufs_needed_lock); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2339 | } |
| 2340 | } |
| 2341 | |
| 2342 | if (hif_state->sleep_timer_init) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2343 | qdf_timer_stop(&hif_state->sleep_timer); |
| 2344 | qdf_timer_free(&hif_state->sleep_timer); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2345 | hif_state->sleep_timer_init = false; |
| 2346 | } |
| 2347 | |
| 2348 | hif_state->started = false; |
| 2349 | } |
| 2350 | |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 2351 | |
Houston Hoffman | 854e67f | 2016-03-14 21:11:39 -0700 | [diff] [blame] | 2352 | /** |
| 2353 | * hif_get_target_ce_config() - get copy engine configuration |
| 2354 | * @target_ce_config_ret: basic copy engine configuration |
| 2355 | * @target_ce_config_sz_ret: size of the basic configuration in bytes |
| 2356 | * @target_service_to_ce_map_ret: service mapping for the copy engines |
| 2357 | * @target_service_to_ce_map_sz_ret: size of the mapping in bytes |
| 2358 | * @target_shadow_reg_cfg_ret: shadow register configuration |
| 2359 | * @shadow_cfg_sz_ret: size of the shadow register configuration in bytes |
| 2360 | * |
| 2361 | * providing accessor to these values outside of this file. |
| 2362 | * currently these are stored in static pointers to const sections. |
| 2363 | * there are multiple configurations that are selected from at compile time. |
| 2364 | * Runtime selection would need to consider mode, target type and bus type. |
| 2365 | * |
| 2366 | * Return: return by parameter. |
| 2367 | */ |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2368 | void hif_get_target_ce_config(struct hif_softc *scn, |
| 2369 | struct CE_pipe_config **target_ce_config_ret, |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 2370 | uint32_t *target_ce_config_sz_ret, |
Houston Hoffman | 854e67f | 2016-03-14 21:11:39 -0700 | [diff] [blame] | 2371 | struct service_to_pipe **target_service_to_ce_map_ret, |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 2372 | uint32_t *target_service_to_ce_map_sz_ret, |
Houston Hoffman | 854e67f | 2016-03-14 21:11:39 -0700 | [diff] [blame] | 2373 | struct shadow_reg_cfg **target_shadow_reg_cfg_ret, |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 2374 | uint32_t *shadow_cfg_sz_ret) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2375 | { |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2376 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 2377 | |
| 2378 | *target_ce_config_ret = hif_state->target_ce_config; |
| 2379 | *target_ce_config_sz_ret = hif_state->target_ce_config_sz; |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 2380 | |
| 2381 | hif_select_service_to_pipe_map(scn, target_service_to_ce_map_ret, |
| 2382 | target_service_to_ce_map_sz_ret); |
Houston Hoffman | 854e67f | 2016-03-14 21:11:39 -0700 | [diff] [blame] | 2383 | |
| 2384 | if (target_shadow_reg_cfg_ret) |
| 2385 | *target_shadow_reg_cfg_ret = target_shadow_reg_cfg; |
| 2386 | |
| 2387 | if (shadow_cfg_sz_ret) |
| 2388 | *shadow_cfg_sz_ret = shadow_cfg_sz; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2389 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2390 | |
Houston Hoffman | f60a348 | 2017-01-31 10:45:07 -0800 | [diff] [blame] | 2391 | #ifdef CONFIG_SHADOW_V2 |
Houston Hoffman | 403c2df | 2017-01-27 12:51:15 -0800 | [diff] [blame] | 2392 | static void hif_print_hal_shadow_register_cfg(struct pld_wlan_enable_cfg *cfg) |
Houston Hoffman | 5141f9d | 2017-01-05 10:49:17 -0800 | [diff] [blame] | 2393 | { |
| 2394 | int i; |
| 2395 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 2396 | "%s: num_config %d\n", __func__, cfg->num_shadow_reg_v2_cfg); |
| 2397 | |
| 2398 | for (i = 0; i < cfg->num_shadow_reg_v2_cfg; i++) { |
| 2399 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO, |
| 2400 | "%s: i %d, val %x\n", __func__, i, |
| 2401 | cfg->shadow_reg_v2_cfg[i].addr); |
| 2402 | } |
| 2403 | } |
| 2404 | |
Houston Hoffman | f60a348 | 2017-01-31 10:45:07 -0800 | [diff] [blame] | 2405 | #else |
| 2406 | static void hif_print_hal_shadow_register_cfg(struct pld_wlan_enable_cfg *cfg) |
| 2407 | { |
| 2408 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 2409 | "%s: CONFIG_SHADOW_V2 not defined\n", __func__); |
| 2410 | } |
| 2411 | #endif |
| 2412 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2413 | /** |
| 2414 | * hif_wlan_enable(): call the platform driver to enable wlan |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 2415 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2416 | * |
| 2417 | * This function passes the con_mode and CE configuration to |
| 2418 | * platform driver to enable wlan. |
| 2419 | * |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2420 | * Return: linux error code |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2421 | */ |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2422 | int hif_wlan_enable(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2423 | { |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 2424 | struct pld_wlan_enable_cfg cfg; |
| 2425 | enum pld_driver_mode mode; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 2426 | uint32_t con_mode = hif_get_conparam(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2427 | |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2428 | hif_get_target_ce_config(scn, |
| 2429 | (struct CE_pipe_config **)&cfg.ce_tgt_cfg, |
Houston Hoffman | 854e67f | 2016-03-14 21:11:39 -0700 | [diff] [blame] | 2430 | &cfg.num_ce_tgt_cfg, |
| 2431 | (struct service_to_pipe **)&cfg.ce_svc_cfg, |
| 2432 | &cfg.num_ce_svc_pipe_cfg, |
| 2433 | (struct shadow_reg_cfg **)&cfg.shadow_reg_cfg, |
| 2434 | &cfg.num_shadow_reg_cfg); |
| 2435 | |
| 2436 | /* translate from structure size to array size */ |
| 2437 | cfg.num_ce_tgt_cfg /= sizeof(struct CE_pipe_config); |
| 2438 | cfg.num_ce_svc_pipe_cfg /= sizeof(struct service_to_pipe); |
| 2439 | cfg.num_shadow_reg_cfg /= sizeof(struct shadow_reg_cfg); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2440 | |
Houston Hoffman | 5141f9d | 2017-01-05 10:49:17 -0800 | [diff] [blame] | 2441 | hif_prepare_hal_shadow_register_cfg(scn, &cfg.shadow_reg_v2_cfg, |
| 2442 | &cfg.num_shadow_reg_v2_cfg); |
| 2443 | |
| 2444 | hif_print_hal_shadow_register_cfg(&cfg); |
| 2445 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2446 | if (QDF_GLOBAL_FTM_MODE == con_mode) |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 2447 | mode = PLD_FTM; |
Balamurugan Mahalingam | 1666dd3 | 2017-09-14 15:19:42 +0530 | [diff] [blame] | 2448 | else if (QDF_GLOBAL_COLDBOOT_CALIB_MODE == con_mode) |
| 2449 | mode = PLD_COLDBOOT_CALIBRATION; |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 2450 | else if (QDF_IS_EPPING_ENABLED(con_mode)) |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 2451 | mode = PLD_EPPING; |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 2452 | else |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 2453 | mode = PLD_MISSION; |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 2454 | |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 2455 | if (BYPASS_QMI) |
| 2456 | return 0; |
| 2457 | else |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 2458 | return pld_wlan_enable(scn->qdf_dev->dev, &cfg, |
| 2459 | mode, QWLAN_VERSIONSTR); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2460 | } |
| 2461 | |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 2462 | #ifdef WLAN_FEATURE_EPPING |
| 2463 | |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 2464 | #define CE_EPPING_USES_IRQ true |
| 2465 | |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 2466 | void hif_ce_prepare_epping_config(struct HIF_CE_state *hif_state) |
| 2467 | { |
| 2468 | if (CE_EPPING_USES_IRQ) |
| 2469 | hif_state->host_ce_config = host_ce_config_wlan_epping_irq; |
| 2470 | else |
| 2471 | hif_state->host_ce_config = host_ce_config_wlan_epping_poll; |
| 2472 | hif_state->target_ce_config = target_ce_config_wlan_epping; |
| 2473 | hif_state->target_ce_config_sz = sizeof(target_ce_config_wlan_epping); |
| 2474 | target_shadow_reg_cfg = target_shadow_reg_cfg_epping; |
| 2475 | shadow_cfg_sz = sizeof(target_shadow_reg_cfg_epping); |
| 2476 | } |
| 2477 | #endif |
| 2478 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2479 | /** |
| 2480 | * hif_ce_prepare_config() - load the correct static tables. |
| 2481 | * @scn: hif context |
| 2482 | * |
| 2483 | * Epping uses different static attribute tables than mission mode. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2484 | */ |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2485 | void hif_ce_prepare_config(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2486 | { |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 2487 | uint32_t mode = hif_get_conparam(scn); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2488 | struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn); |
| 2489 | struct hif_target_info *tgt_info = hif_get_target_info_handle(hif_hdl); |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2490 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2491 | |
Houston Hoffman | 10fedfc | 2017-01-23 15:23:09 -0800 | [diff] [blame] | 2492 | hif_state->ce_services = ce_services_attach(scn); |
| 2493 | |
Houston Hoffman | 710af5a | 2016-11-22 21:59:03 -0800 | [diff] [blame] | 2494 | scn->ce_count = HOST_CE_COUNT; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2495 | /* if epping is enabled we need to use the epping configuration. */ |
Houston Hoffman | 75ef5a5 | 2016-04-14 17:15:49 -0700 | [diff] [blame] | 2496 | if (QDF_IS_EPPING_ENABLED(mode)) { |
Nirav Shah | 0d0cce8 | 2018-01-17 17:00:31 +0530 | [diff] [blame^] | 2497 | hif_ce_prepare_epping_config(hif_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2498 | } |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2499 | |
| 2500 | switch (tgt_info->target_type) { |
| 2501 | default: |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2502 | hif_state->host_ce_config = host_ce_config_wlan; |
| 2503 | hif_state->target_ce_config = target_ce_config_wlan; |
| 2504 | hif_state->target_ce_config_sz = sizeof(target_ce_config_wlan); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2505 | break; |
| 2506 | case TARGET_TYPE_AR900B: |
| 2507 | case TARGET_TYPE_QCA9984: |
| 2508 | case TARGET_TYPE_IPQ4019: |
| 2509 | case TARGET_TYPE_QCA9888: |
Venkateswara Swamy Bandaru | 5432c1b | 2016-10-12 19:00:40 +0530 | [diff] [blame] | 2510 | if (hif_is_attribute_set(scn, HIF_LOWDESC_CE_NO_PKTLOG_CFG)) { |
| 2511 | hif_state->host_ce_config = |
| 2512 | host_lowdesc_ce_cfg_wlan_ar900b_nopktlog; |
| 2513 | } else if (hif_is_attribute_set(scn, HIF_LOWDESC_CE_CFG)) { |
| 2514 | hif_state->host_ce_config = |
| 2515 | host_lowdesc_ce_cfg_wlan_ar900b; |
| 2516 | } else { |
| 2517 | hif_state->host_ce_config = host_ce_config_wlan_ar900b; |
| 2518 | } |
| 2519 | |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2520 | hif_state->target_ce_config = target_ce_config_wlan_ar900b; |
| 2521 | hif_state->target_ce_config_sz = |
| 2522 | sizeof(target_ce_config_wlan_ar900b); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2523 | |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2524 | break; |
| 2525 | |
| 2526 | case TARGET_TYPE_AR9888: |
| 2527 | case TARGET_TYPE_AR9888V2: |
Venkateswara Swamy Bandaru | 5432c1b | 2016-10-12 19:00:40 +0530 | [diff] [blame] | 2528 | if (hif_is_attribute_set(scn, HIF_LOWDESC_CE_CFG)) { |
| 2529 | hif_state->host_ce_config = host_lowdesc_ce_cfg_wlan_ar9888; |
| 2530 | } else { |
| 2531 | hif_state->host_ce_config = host_ce_config_wlan_ar9888; |
| 2532 | } |
| 2533 | |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2534 | hif_state->target_ce_config = target_ce_config_wlan_ar9888; |
| 2535 | hif_state->target_ce_config_sz = |
| 2536 | sizeof(target_ce_config_wlan_ar9888); |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2537 | |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2538 | break; |
Houston Hoffman | 31b25ec | 2016-09-19 13:12:30 -0700 | [diff] [blame] | 2539 | |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 2540 | case TARGET_TYPE_QCA8074: |
Karunakar Dasineni | f61cb07 | 2016-09-29 11:50:45 -0700 | [diff] [blame] | 2541 | if (scn->bus_type == QDF_BUS_TYPE_PCI) { |
| 2542 | hif_state->host_ce_config = |
| 2543 | host_ce_config_wlan_qca8074_pci; |
| 2544 | hif_state->target_ce_config = |
| 2545 | target_ce_config_wlan_qca8074_pci; |
| 2546 | hif_state->target_ce_config_sz = |
| 2547 | sizeof(target_ce_config_wlan_qca8074_pci); |
| 2548 | } else { |
| 2549 | hif_state->host_ce_config = host_ce_config_wlan_qca8074; |
| 2550 | hif_state->target_ce_config = |
| 2551 | target_ce_config_wlan_qca8074; |
| 2552 | hif_state->target_ce_config_sz = |
| 2553 | sizeof(target_ce_config_wlan_qca8074); |
| 2554 | } |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 2555 | break; |
Houston Hoffman | 31b25ec | 2016-09-19 13:12:30 -0700 | [diff] [blame] | 2556 | case TARGET_TYPE_QCA6290: |
| 2557 | hif_state->host_ce_config = host_ce_config_wlan_qca6290; |
| 2558 | hif_state->target_ce_config = target_ce_config_wlan_qca6290; |
| 2559 | hif_state->target_ce_config_sz = |
| 2560 | sizeof(target_ce_config_wlan_qca6290); |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 2561 | |
Houston Hoffman | 710af5a | 2016-11-22 21:59:03 -0800 | [diff] [blame] | 2562 | scn->ce_count = QCA_6290_CE_COUNT; |
Houston Hoffman | 31b25ec | 2016-09-19 13:12:30 -0700 | [diff] [blame] | 2563 | break; |
Houston Hoffman | fb698ef | 2016-05-05 19:50:44 -0700 | [diff] [blame] | 2564 | } |
Yun park | c80eea7 | 2017-10-06 15:33:36 -0700 | [diff] [blame] | 2565 | QDF_BUG(scn->ce_count <= CE_COUNT_MAX); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2566 | } |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2567 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2568 | /** |
| 2569 | * hif_ce_open() - do ce specific allocations |
| 2570 | * @hif_sc: pointer to hif context |
| 2571 | * |
| 2572 | * return: 0 for success or QDF_STATUS_E_NOMEM |
| 2573 | */ |
| 2574 | QDF_STATUS hif_ce_open(struct hif_softc *hif_sc) |
| 2575 | { |
| 2576 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2577 | |
Venkateswara Swamy Bandaru | 9fd9af0 | 2016-09-20 20:27:31 +0530 | [diff] [blame] | 2578 | qdf_spinlock_create(&hif_state->irq_reg_lock); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2579 | qdf_spinlock_create(&hif_state->keep_awake_lock); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2580 | return QDF_STATUS_SUCCESS; |
| 2581 | } |
| 2582 | |
| 2583 | /** |
| 2584 | * hif_ce_close() - do ce specific free |
| 2585 | * @hif_sc: pointer to hif context |
| 2586 | */ |
| 2587 | void hif_ce_close(struct hif_softc *hif_sc) |
| 2588 | { |
Venkateswara Swamy Bandaru | 9fd9af0 | 2016-09-20 20:27:31 +0530 | [diff] [blame] | 2589 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc); |
| 2590 | |
| 2591 | qdf_spinlock_destroy(&hif_state->irq_reg_lock); |
Poddar, Siddarth | 725e9f5 | 2017-07-19 15:18:28 +0530 | [diff] [blame] | 2592 | qdf_spinlock_destroy(&hif_state->keep_awake_lock); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2593 | } |
| 2594 | |
| 2595 | /** |
| 2596 | * hif_unconfig_ce() - ensure resources from hif_config_ce are freed |
| 2597 | * @hif_sc: hif context |
| 2598 | * |
| 2599 | * uses state variables to support cleaning up when hif_config_ce fails. |
| 2600 | */ |
| 2601 | void hif_unconfig_ce(struct hif_softc *hif_sc) |
| 2602 | { |
| 2603 | int pipe_num; |
| 2604 | struct HIF_CE_pipe_info *pipe_info; |
| 2605 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_sc); |
| 2606 | |
| 2607 | for (pipe_num = 0; pipe_num < hif_sc->ce_count; pipe_num++) { |
| 2608 | pipe_info = &hif_state->pipe_info[pipe_num]; |
| 2609 | if (pipe_info->ce_hdl) { |
| 2610 | ce_unregister_irq(hif_state, (1 << pipe_num)); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2611 | ce_fini(pipe_info->ce_hdl); |
| 2612 | pipe_info->ce_hdl = NULL; |
| 2613 | pipe_info->buf_sz = 0; |
Houston Hoffman | 03f4657 | 2016-12-12 12:53:56 -0800 | [diff] [blame] | 2614 | qdf_spinlock_destroy(&pipe_info->recv_bufs_needed_lock); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2615 | } |
| 2616 | } |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2617 | if (hif_sc->athdiag_procfs_inited) { |
| 2618 | athdiag_procfs_remove(); |
| 2619 | hif_sc->athdiag_procfs_inited = false; |
| 2620 | } |
| 2621 | } |
| 2622 | |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 2623 | #ifdef CONFIG_BYPASS_QMI |
| 2624 | #define FW_SHARED_MEM (2 * 1024 * 1024) |
| 2625 | |
| 2626 | /** |
| 2627 | * hif_post_static_buf_to_target() - post static buffer to WLAN FW |
| 2628 | * @scn: pointer to HIF structure |
| 2629 | * |
| 2630 | * WLAN FW needs 2MB memory from DDR when QMI is disabled. |
| 2631 | * |
| 2632 | * Return: void |
| 2633 | */ |
| 2634 | static void hif_post_static_buf_to_target(struct hif_softc *scn) |
| 2635 | { |
Hardik Kantilal Patel | c5dc5f2 | 2016-04-21 14:11:33 -0700 | [diff] [blame] | 2636 | void *target_va; |
| 2637 | phys_addr_t target_pa; |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 2638 | |
Hardik Kantilal Patel | c5dc5f2 | 2016-04-21 14:11:33 -0700 | [diff] [blame] | 2639 | target_va = qdf_mem_alloc_consistent(scn->qdf_dev, scn->qdf_dev->dev, |
| 2640 | FW_SHARED_MEM, &target_pa); |
| 2641 | if (NULL == target_va) { |
| 2642 | HIF_TRACE("Memory allocation failed could not post target buf"); |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 2643 | return; |
| 2644 | } |
Hardik Kantilal Patel | c5dc5f2 | 2016-04-21 14:11:33 -0700 | [diff] [blame] | 2645 | hif_write32_mb(scn->mem + BYPASS_QMI_TEMP_REGISTER, target_pa); |
| 2646 | HIF_TRACE("target va %pK target pa %pa", target_va, &target_pa); |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 2647 | } |
| 2648 | #else |
| 2649 | static inline void hif_post_static_buf_to_target(struct hif_softc *scn) |
| 2650 | { |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 2651 | } |
| 2652 | #endif |
| 2653 | |
Houston Hoffman | 579c02f | 2017-08-02 01:57:38 -0700 | [diff] [blame] | 2654 | static int hif_srng_sleep_state_adjust(struct hif_softc *scn, bool sleep_ok, |
| 2655 | bool wait_for_it) |
| 2656 | { |
| 2657 | /* todo */ |
| 2658 | return 0; |
| 2659 | } |
| 2660 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2661 | /** |
| 2662 | * hif_config_ce() - configure copy engines |
| 2663 | * @scn: hif context |
| 2664 | * |
| 2665 | * Prepares fw, copy engine hardware and host sw according |
| 2666 | * to the attributes selected by hif_ce_prepare_config. |
| 2667 | * |
| 2668 | * also calls athdiag_procfs_init |
| 2669 | * |
| 2670 | * return: 0 for success nonzero for failure. |
| 2671 | */ |
| 2672 | int hif_config_ce(struct hif_softc *scn) |
| 2673 | { |
| 2674 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 2675 | struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn); |
| 2676 | struct HIF_CE_pipe_info *pipe_info; |
| 2677 | int pipe_num; |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2678 | struct CE_state *ce_state; |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 2679 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2680 | #ifdef ADRASTEA_SHADOW_REGISTERS |
| 2681 | int i; |
| 2682 | #endif |
| 2683 | QDF_STATUS rv = QDF_STATUS_SUCCESS; |
| 2684 | |
| 2685 | scn->notice_send = true; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2686 | |
Yuanyuan Liu | a7a282f | 2016-04-15 12:55:04 -0700 | [diff] [blame] | 2687 | hif_post_static_buf_to_target(scn); |
| 2688 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2689 | hif_state->fw_indicator_address = FW_INDICATOR_ADDRESS; |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2690 | |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 2691 | hif_config_rri_on_ddr(scn); |
| 2692 | |
Houston Hoffman | 579c02f | 2017-08-02 01:57:38 -0700 | [diff] [blame] | 2693 | if (ce_srng_based(scn)) |
| 2694 | scn->bus_ops.hif_target_sleep_state_adjust = |
| 2695 | &hif_srng_sleep_state_adjust; |
| 2696 | |
c_cgodav | fda96ad | 2017-09-07 16:16:00 +0530 | [diff] [blame] | 2697 | /* Initialise the CE debug history sysfs interface inputs ce_id and |
| 2698 | * index. Disable data storing |
| 2699 | */ |
| 2700 | reset_ce_debug_history(scn); |
| 2701 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2702 | for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) { |
| 2703 | struct CE_attr *attr; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2704 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2705 | pipe_info = &hif_state->pipe_info[pipe_num]; |
| 2706 | pipe_info->pipe_num = pipe_num; |
| 2707 | pipe_info->HIF_CE_state = hif_state; |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 2708 | attr = &hif_state->host_ce_config[pipe_num]; |
Karunakar Dasineni | f61cb07 | 2016-09-29 11:50:45 -0700 | [diff] [blame] | 2709 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2710 | pipe_info->ce_hdl = ce_init(scn, pipe_num, attr); |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2711 | ce_state = scn->ce_id_to_state[pipe_num]; |
Houston Hoffman | 03f4657 | 2016-12-12 12:53:56 -0800 | [diff] [blame] | 2712 | qdf_spinlock_create(&pipe_info->recv_bufs_needed_lock); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2713 | QDF_ASSERT(pipe_info->ce_hdl != NULL); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2714 | if (pipe_info->ce_hdl == NULL) { |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2715 | rv = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2716 | A_TARGET_ACCESS_UNLIKELY(scn); |
| 2717 | goto err; |
| 2718 | } |
| 2719 | |
Dhanashri Atre | 991ee4d | 2017-05-03 19:03:10 -0700 | [diff] [blame] | 2720 | ce_state->lro_data = qdf_lro_init(); |
| 2721 | |
Kiran Venkatappa | e17e3b6 | 2017-02-10 16:31:49 +0530 | [diff] [blame] | 2722 | if (attr->flags & CE_ATTR_DIAG) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2723 | /* Reserve the ultimate CE for |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2724 | * Diagnostic Window support |
| 2725 | */ |
Houston Hoffman | c1d9a41 | 2016-03-30 21:07:57 -0700 | [diff] [blame] | 2726 | hif_state->ce_diag = pipe_info->ce_hdl; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2727 | continue; |
| 2728 | } |
| 2729 | |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 2730 | if (hif_is_nss_wifi_enabled(scn) && ce_state && |
| 2731 | (ce_state->htt_rx_data)) |
| 2732 | continue; |
| 2733 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2734 | pipe_info->buf_sz = (qdf_size_t) (attr->src_sz_max); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2735 | if (attr->dest_nentries > 0) { |
| 2736 | atomic_set(&pipe_info->recv_bufs_needed, |
| 2737 | init_buffer_count(attr->dest_nentries - 1)); |
Kiran Venkatappa | f41ef2e | 2016-09-05 10:59:58 +0530 | [diff] [blame] | 2738 | /*SRNG based CE has one entry less */ |
| 2739 | if (ce_srng_based(scn)) |
| 2740 | atomic_dec(&pipe_info->recv_bufs_needed); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2741 | } else { |
| 2742 | atomic_set(&pipe_info->recv_bufs_needed, 0); |
| 2743 | } |
| 2744 | ce_tasklet_init(hif_state, (1 << pipe_num)); |
| 2745 | ce_register_irq(hif_state, (1 << pipe_num)); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2746 | } |
| 2747 | |
| 2748 | if (athdiag_procfs_init(scn) != 0) { |
| 2749 | A_TARGET_ACCESS_UNLIKELY(scn); |
| 2750 | goto err; |
| 2751 | } |
| 2752 | scn->athdiag_procfs_inited = true; |
| 2753 | |
Srinivas Girigowda | 6e0cfd9 | 2017-03-09 15:49:59 -0800 | [diff] [blame] | 2754 | HIF_DBG("%s: ce_init done", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2755 | |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2756 | init_tasklet_workers(hif_hdl); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2757 | |
Srinivas Girigowda | 6e0cfd9 | 2017-03-09 15:49:59 -0800 | [diff] [blame] | 2758 | HIF_DBG("%s: X, ret = %d", __func__, rv); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2759 | |
| 2760 | #ifdef ADRASTEA_SHADOW_REGISTERS |
Srinivas Girigowda | 6e0cfd9 | 2017-03-09 15:49:59 -0800 | [diff] [blame] | 2761 | HIF_DBG("%s, Using Shadow Registers instead of CE Registers", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2762 | for (i = 0; i < NUM_SHADOW_REGISTERS; i++) { |
Srinivas Girigowda | 6e0cfd9 | 2017-03-09 15:49:59 -0800 | [diff] [blame] | 2763 | HIF_DBG("%s Shadow Register%d is mapped to address %x", |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2764 | __func__, i, |
| 2765 | (A_TARGET_READ(scn, (SHADOW_ADDRESS(i))) << 2)); |
| 2766 | } |
| 2767 | #endif |
| 2768 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2769 | return rv != QDF_STATUS_SUCCESS; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2770 | |
| 2771 | err: |
| 2772 | /* Failure, so clean up */ |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 2773 | hif_unconfig_ce(scn); |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 2774 | HIF_TRACE("%s: X, ret = %d", __func__, rv); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2775 | return QDF_STATUS_SUCCESS != QDF_STATUS_E_FAILURE; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2776 | } |
| 2777 | |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2778 | #ifdef WLAN_FEATURE_FASTPATH |
| 2779 | /** |
| 2780 | * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler |
| 2781 | * @handler: Callback funtcion |
| 2782 | * @context: handle for callback function |
| 2783 | * |
| 2784 | * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE |
| 2785 | */ |
Houston Hoffman | 127467f | 2016-04-26 22:37:14 -0700 | [diff] [blame] | 2786 | int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx, |
| 2787 | fastpath_msg_handler handler, |
| 2788 | void *context) |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2789 | { |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2790 | struct CE_state *ce_state; |
Houston Hoffman | 127467f | 2016-04-26 22:37:14 -0700 | [diff] [blame] | 2791 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2792 | int i; |
| 2793 | |
Himanshu Agarwal | 2a92459 | 2016-06-30 18:04:14 +0530 | [diff] [blame] | 2794 | if (!scn) { |
| 2795 | HIF_ERROR("%s: scn is NULL", __func__); |
| 2796 | QDF_ASSERT(0); |
| 2797 | return QDF_STATUS_E_FAILURE; |
| 2798 | } |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2799 | |
| 2800 | if (!scn->fastpath_mode_on) { |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 2801 | HIF_WARN("%s: Fastpath mode disabled", __func__); |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2802 | return QDF_STATUS_E_FAILURE; |
| 2803 | } |
| 2804 | |
Houston Hoffman | d6f946c | 2016-04-06 15:16:00 -0700 | [diff] [blame] | 2805 | for (i = 0; i < scn->ce_count; i++) { |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2806 | ce_state = scn->ce_id_to_state[i]; |
| 2807 | if (ce_state->htt_rx_data) { |
| 2808 | ce_state->fastpath_handler = handler; |
| 2809 | ce_state->context = context; |
| 2810 | } |
| 2811 | } |
| 2812 | |
| 2813 | return QDF_STATUS_SUCCESS; |
| 2814 | } |
Pratik Gandhi | dc82a77 | 2018-01-30 18:57:05 +0530 | [diff] [blame] | 2815 | qdf_export_symbol(hif_ce_fastpath_cb_register); |
Manjunathappa Prakash | 7399f14 | 2016-04-13 23:38:16 -0700 | [diff] [blame] | 2816 | #endif |
| 2817 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2818 | #ifdef IPA_OFFLOAD |
Leo Chang | d85f78d | 2015-11-13 10:55:34 -0800 | [diff] [blame] | 2819 | /** |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 2820 | * hif_ce_ipa_get_ce_resource() - get uc resource on hif |
Leo Chang | d85f78d | 2015-11-13 10:55:34 -0800 | [diff] [blame] | 2821 | * @scn: bus context |
| 2822 | * @ce_sr_base_paddr: copyengine source ring base physical address |
| 2823 | * @ce_sr_ring_size: copyengine source ring size |
| 2824 | * @ce_reg_paddr: copyengine register physical address |
| 2825 | * |
| 2826 | * IPA micro controller data path offload feature enabled, |
| 2827 | * HIF should release copy engine related resource information to IPA UC |
| 2828 | * IPA UC will access hardware resource with released information |
| 2829 | * |
| 2830 | * Return: None |
| 2831 | */ |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 2832 | void hif_ce_ipa_get_ce_resource(struct hif_softc *scn, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2833 | qdf_dma_addr_t *ce_sr_base_paddr, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2834 | uint32_t *ce_sr_ring_size, |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2835 | qdf_dma_addr_t *ce_reg_paddr) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2836 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 2837 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2838 | struct HIF_CE_pipe_info *pipe_info = |
| 2839 | &(hif_state->pipe_info[HIF_PCI_IPA_UC_ASSIGNED_CE]); |
| 2840 | struct CE_handle *ce_hdl = pipe_info->ce_hdl; |
| 2841 | |
| 2842 | ce_ipa_get_resource(ce_hdl, ce_sr_base_paddr, ce_sr_ring_size, |
| 2843 | ce_reg_paddr); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2844 | } |
| 2845 | #endif /* IPA_OFFLOAD */ |
| 2846 | |
| 2847 | |
| 2848 | #ifdef ADRASTEA_SHADOW_REGISTERS |
| 2849 | |
| 2850 | /* |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 2851 | * Current shadow register config |
| 2852 | * |
| 2853 | * ----------------------------------------------------------- |
| 2854 | * Shadow Register | CE | src/dst write index |
| 2855 | * ----------------------------------------------------------- |
| 2856 | * 0 | 0 | src |
| 2857 | * 1 No Config - Doesn't point to anything |
| 2858 | * 2 No Config - Doesn't point to anything |
| 2859 | * 3 | 3 | src |
| 2860 | * 4 | 4 | src |
| 2861 | * 5 | 5 | src |
| 2862 | * 6 No Config - Doesn't point to anything |
| 2863 | * 7 | 7 | src |
| 2864 | * 8 No Config - Doesn't point to anything |
| 2865 | * 9 No Config - Doesn't point to anything |
| 2866 | * 10 No Config - Doesn't point to anything |
| 2867 | * 11 No Config - Doesn't point to anything |
| 2868 | * ----------------------------------------------------------- |
| 2869 | * 12 No Config - Doesn't point to anything |
| 2870 | * 13 | 1 | dst |
| 2871 | * 14 | 2 | dst |
| 2872 | * 15 No Config - Doesn't point to anything |
| 2873 | * 16 No Config - Doesn't point to anything |
| 2874 | * 17 No Config - Doesn't point to anything |
| 2875 | * 18 No Config - Doesn't point to anything |
| 2876 | * 19 | 7 | dst |
| 2877 | * 20 | 8 | dst |
| 2878 | * 21 No Config - Doesn't point to anything |
| 2879 | * 22 No Config - Doesn't point to anything |
| 2880 | * 23 No Config - Doesn't point to anything |
| 2881 | * ----------------------------------------------------------- |
| 2882 | * |
| 2883 | * |
| 2884 | * ToDo - Move shadow register config to following in the future |
| 2885 | * This helps free up a block of shadow registers towards the end. |
| 2886 | * Can be used for other purposes |
| 2887 | * |
| 2888 | * ----------------------------------------------------------- |
| 2889 | * Shadow Register | CE | src/dst write index |
| 2890 | * ----------------------------------------------------------- |
| 2891 | * 0 | 0 | src |
| 2892 | * 1 | 3 | src |
| 2893 | * 2 | 4 | src |
| 2894 | * 3 | 5 | src |
| 2895 | * 4 | 7 | src |
| 2896 | * ----------------------------------------------------------- |
| 2897 | * 5 | 1 | dst |
| 2898 | * 6 | 2 | dst |
| 2899 | * 7 | 7 | dst |
| 2900 | * 8 | 8 | dst |
| 2901 | * ----------------------------------------------------------- |
| 2902 | * 9 No Config - Doesn't point to anything |
| 2903 | * 12 No Config - Doesn't point to anything |
| 2904 | * 13 No Config - Doesn't point to anything |
| 2905 | * 14 No Config - Doesn't point to anything |
| 2906 | * 15 No Config - Doesn't point to anything |
| 2907 | * 16 No Config - Doesn't point to anything |
| 2908 | * 17 No Config - Doesn't point to anything |
| 2909 | * 18 No Config - Doesn't point to anything |
| 2910 | * 19 No Config - Doesn't point to anything |
| 2911 | * 20 No Config - Doesn't point to anything |
| 2912 | * 21 No Config - Doesn't point to anything |
| 2913 | * 22 No Config - Doesn't point to anything |
| 2914 | * 23 No Config - Doesn't point to anything |
| 2915 | * ----------------------------------------------------------- |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2916 | */ |
| 2917 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2918 | u32 shadow_sr_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2919 | { |
| 2920 | u32 addr = 0; |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 2921 | u32 ce = COPY_ENGINE_ID(ctrl_addr); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2922 | |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 2923 | switch (ce) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2924 | case 0: |
| 2925 | addr = SHADOW_VALUE0; |
| 2926 | break; |
| 2927 | case 3: |
| 2928 | addr = SHADOW_VALUE3; |
| 2929 | break; |
| 2930 | case 4: |
| 2931 | addr = SHADOW_VALUE4; |
| 2932 | break; |
| 2933 | case 5: |
| 2934 | addr = SHADOW_VALUE5; |
| 2935 | break; |
| 2936 | case 7: |
| 2937 | addr = SHADOW_VALUE7; |
| 2938 | break; |
| 2939 | default: |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 2940 | HIF_ERROR("invalid CE ctrl_addr (CE=%d)", ce); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2941 | QDF_ASSERT(0); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2942 | } |
| 2943 | return addr; |
| 2944 | |
| 2945 | } |
| 2946 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 2947 | u32 shadow_dst_wr_ind_addr(struct hif_softc *scn, u32 ctrl_addr) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2948 | { |
| 2949 | u32 addr = 0; |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 2950 | u32 ce = COPY_ENGINE_ID(ctrl_addr); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2951 | |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 2952 | switch (ce) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2953 | case 1: |
| 2954 | addr = SHADOW_VALUE13; |
| 2955 | break; |
| 2956 | case 2: |
| 2957 | addr = SHADOW_VALUE14; |
| 2958 | break; |
Vishwajith Upendra | 70efc75 | 2016-04-18 11:23:49 -0700 | [diff] [blame] | 2959 | case 5: |
| 2960 | addr = SHADOW_VALUE17; |
| 2961 | break; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2962 | case 7: |
| 2963 | addr = SHADOW_VALUE19; |
| 2964 | break; |
| 2965 | case 8: |
| 2966 | addr = SHADOW_VALUE20; |
| 2967 | break; |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 2968 | case 9: |
| 2969 | addr = SHADOW_VALUE21; |
| 2970 | break; |
| 2971 | case 10: |
| 2972 | addr = SHADOW_VALUE22; |
| 2973 | break; |
Nirav Shah | 75cc5c8 | 2016-05-25 10:52:38 +0530 | [diff] [blame] | 2974 | case 11: |
| 2975 | addr = SHADOW_VALUE23; |
| 2976 | break; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2977 | default: |
Houston Hoffman | e633044 | 2016-02-26 12:19:11 -0800 | [diff] [blame] | 2978 | HIF_ERROR("invalid CE ctrl_addr (CE=%d)", ce); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 2979 | QDF_ASSERT(0); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 2980 | } |
| 2981 | |
| 2982 | return addr; |
| 2983 | |
| 2984 | } |
| 2985 | #endif |
| 2986 | |
Dhanashri Atre | 65b674f | 2015-10-30 15:12:03 -0700 | [diff] [blame] | 2987 | #if defined(FEATURE_LRO) |
Manjunathappa Prakash | 2146da3 | 2016-10-13 14:47:47 -0700 | [diff] [blame] | 2988 | void *hif_ce_get_lro_ctx(struct hif_opaque_softc *hif_hdl, int ctx_id) |
| 2989 | { |
| 2990 | struct CE_state *ce_state; |
| 2991 | struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl); |
| 2992 | |
Manjunathappa Prakash | 2146da3 | 2016-10-13 14:47:47 -0700 | [diff] [blame] | 2993 | ce_state = scn->ce_id_to_state[ctx_id]; |
| 2994 | |
| 2995 | return ce_state->lro_data; |
| 2996 | } |
Dhanashri Atre | 65b674f | 2015-10-30 15:12:03 -0700 | [diff] [blame] | 2997 | #endif |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 2998 | |
| 2999 | /** |
| 3000 | * hif_map_service_to_pipe() - returns the ce ids pertaining to |
| 3001 | * this service |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3002 | * @scn: hif_softc pointer. |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3003 | * @svc_id: Service ID for which the mapping is needed. |
| 3004 | * @ul_pipe: address of the container in which ul pipe is returned. |
| 3005 | * @dl_pipe: address of the container in which dl pipe is returned. |
| 3006 | * @ul_is_polled: address of the container in which a bool |
| 3007 | * indicating if the UL CE for this service |
| 3008 | * is polled is returned. |
| 3009 | * @dl_is_polled: address of the container in which a bool |
| 3010 | * indicating if the DL CE for this service |
| 3011 | * is polled is returned. |
| 3012 | * |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3013 | * Return: Indicates whether the service has been found in the table. |
| 3014 | * Upon return, ul_is_polled is updated only if ul_pipe is updated. |
| 3015 | * There will be warning logs if either leg has not been updated |
| 3016 | * because it missed the entry in the table (but this is not an err). |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3017 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 3018 | int hif_map_service_to_pipe(struct hif_opaque_softc *hif_hdl, uint16_t svc_id, |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3019 | uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled, |
| 3020 | int *dl_is_polled) |
| 3021 | { |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3022 | int status = QDF_STATUS_E_INVAL; |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3023 | unsigned int i; |
| 3024 | struct service_to_pipe element; |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3025 | struct service_to_pipe *tgt_svc_map_to_use; |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 3026 | uint32_t sz_tgt_svc_map_to_use; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 3027 | struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl); |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 3028 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3029 | bool dl_updated = false; |
| 3030 | bool ul_updated = false; |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3031 | |
Houston Hoffman | 748e1a6 | 2017-03-30 17:20:42 -0700 | [diff] [blame] | 3032 | hif_select_service_to_pipe_map(scn, &tgt_svc_map_to_use, |
| 3033 | &sz_tgt_svc_map_to_use); |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3034 | |
| 3035 | *dl_is_polled = 0; /* polling for received messages not supported */ |
| 3036 | |
| 3037 | for (i = 0; i < (sz_tgt_svc_map_to_use/sizeof(element)); i++) { |
| 3038 | |
| 3039 | memcpy(&element, &tgt_svc_map_to_use[i], sizeof(element)); |
| 3040 | if (element.service_id == svc_id) { |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3041 | if (element.pipedir == PIPEDIR_OUT) { |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3042 | *ul_pipe = element.pipenum; |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3043 | *ul_is_polled = |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 3044 | (hif_state->host_ce_config[*ul_pipe].flags & |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3045 | CE_ATTR_DISABLE_INTR) != 0; |
| 3046 | ul_updated = true; |
| 3047 | } else if (element.pipedir == PIPEDIR_IN) { |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3048 | *dl_pipe = element.pipenum; |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3049 | dl_updated = true; |
| 3050 | } |
| 3051 | status = QDF_STATUS_SUCCESS; |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3052 | } |
| 3053 | } |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3054 | if (ul_updated == false) |
Poddar, Siddarth | f53a9b0 | 2017-03-14 20:30:17 +0530 | [diff] [blame] | 3055 | HIF_INFO("%s: ul pipe is NOT updated for service %d", |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3056 | __func__, svc_id); |
| 3057 | if (dl_updated == false) |
Poddar, Siddarth | f53a9b0 | 2017-03-14 20:30:17 +0530 | [diff] [blame] | 3058 | HIF_INFO("%s: dl pipe is NOT updated for service %d", |
Manjunathappa Prakash | 32afe37 | 2016-04-29 11:12:41 -0700 | [diff] [blame] | 3059 | __func__, svc_id); |
Sanjay Devnani | c319c82 | 2015-11-06 16:44:28 -0800 | [diff] [blame] | 3060 | |
| 3061 | return status; |
| 3062 | } |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3063 | |
| 3064 | #ifdef SHADOW_REG_DEBUG |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3065 | inline uint32_t DEBUG_CE_SRC_RING_READ_IDX_GET(struct hif_softc *scn, |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3066 | uint32_t CE_ctrl_addr) |
| 3067 | { |
| 3068 | uint32_t read_from_hw, srri_from_ddr = 0; |
| 3069 | |
| 3070 | read_from_hw = A_TARGET_READ(scn, CE_ctrl_addr + CURRENT_SRRI_ADDRESS); |
| 3071 | |
| 3072 | srri_from_ddr = SRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr)); |
| 3073 | |
| 3074 | if (read_from_hw != srri_from_ddr) { |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 3075 | HIF_ERROR("%s: error: read from ddr = %d actual read from register = %d, CE_MISC_INT_STATUS_GET = 0x%x", |
| 3076 | __func__, srri_from_ddr, read_from_hw, |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3077 | CE_MISC_INT_STATUS_GET(scn, CE_ctrl_addr)); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3078 | QDF_ASSERT(0); |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3079 | } |
| 3080 | return srri_from_ddr; |
| 3081 | } |
| 3082 | |
| 3083 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3084 | inline uint32_t DEBUG_CE_DEST_RING_READ_IDX_GET(struct hif_softc *scn, |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3085 | uint32_t CE_ctrl_addr) |
| 3086 | { |
| 3087 | uint32_t read_from_hw, drri_from_ddr = 0; |
| 3088 | |
| 3089 | read_from_hw = A_TARGET_READ(scn, CE_ctrl_addr + CURRENT_DRRI_ADDRESS); |
| 3090 | |
| 3091 | drri_from_ddr = DRRI_FROM_DDR_ADDR(VADDR_FOR_CE(scn, CE_ctrl_addr)); |
| 3092 | |
| 3093 | if (read_from_hw != drri_from_ddr) { |
Houston Hoffman | c50572b | 2016-06-08 19:49:46 -0700 | [diff] [blame] | 3094 | HIF_ERROR("error: read from ddr = %d actual read from register = %d, CE_MISC_INT_STATUS_GET = 0x%x", |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3095 | drri_from_ddr, read_from_hw, |
| 3096 | CE_MISC_INT_STATUS_GET(scn, CE_ctrl_addr)); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3097 | QDF_ASSERT(0); |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3098 | } |
| 3099 | return drri_from_ddr; |
| 3100 | } |
| 3101 | |
| 3102 | #endif |
| 3103 | |
Houston Hoffman | 3d0cda8 | 2015-12-03 13:25:05 -0800 | [diff] [blame] | 3104 | #ifdef ADRASTEA_RRI_ON_DDR |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3105 | /** |
| 3106 | * hif_get_src_ring_read_index(): Called to get the SRRI |
| 3107 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3108 | * @scn: hif_softc pointer |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3109 | * @CE_ctrl_addr: base address of the CE whose RRI is to be read |
| 3110 | * |
| 3111 | * This function returns the SRRI to the caller. For CEs that |
| 3112 | * dont have interrupts enabled, we look at the DDR based SRRI |
| 3113 | * |
| 3114 | * Return: SRRI |
| 3115 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3116 | inline unsigned int hif_get_src_ring_read_index(struct hif_softc *scn, |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3117 | uint32_t CE_ctrl_addr) |
| 3118 | { |
| 3119 | struct CE_attr attr; |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 3120 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3121 | |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 3122 | attr = hif_state->host_ce_config[COPY_ENGINE_ID(CE_ctrl_addr)]; |
Govind Singh | bc679dc | 2017-06-08 12:33:59 +0530 | [diff] [blame] | 3123 | if (attr.flags & CE_ATTR_DISABLE_INTR) { |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3124 | return CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr); |
Govind Singh | bc679dc | 2017-06-08 12:33:59 +0530 | [diff] [blame] | 3125 | } else { |
| 3126 | if (TARGET_REGISTER_ACCESS_ALLOWED(scn)) |
| 3127 | return A_TARGET_READ(scn, |
| 3128 | (CE_ctrl_addr) + CURRENT_SRRI_ADDRESS); |
| 3129 | else |
| 3130 | return CE_SRC_RING_READ_IDX_GET_FROM_DDR(scn, |
| 3131 | CE_ctrl_addr); |
| 3132 | } |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3133 | } |
| 3134 | |
| 3135 | /** |
| 3136 | * hif_get_dst_ring_read_index(): Called to get the DRRI |
| 3137 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3138 | * @scn: hif_softc pointer |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3139 | * @CE_ctrl_addr: base address of the CE whose RRI is to be read |
| 3140 | * |
| 3141 | * This function returns the DRRI to the caller. For CEs that |
| 3142 | * dont have interrupts enabled, we look at the DDR based DRRI |
| 3143 | * |
| 3144 | * Return: DRRI |
| 3145 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3146 | inline unsigned int hif_get_dst_ring_read_index(struct hif_softc *scn, |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3147 | uint32_t CE_ctrl_addr) |
| 3148 | { |
| 3149 | struct CE_attr attr; |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 3150 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3151 | |
Venkateswara Swamy Bandaru | 13164aa | 2016-09-20 20:24:54 +0530 | [diff] [blame] | 3152 | attr = hif_state->host_ce_config[COPY_ENGINE_ID(CE_ctrl_addr)]; |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3153 | |
Govind Singh | bc679dc | 2017-06-08 12:33:59 +0530 | [diff] [blame] | 3154 | if (attr.flags & CE_ATTR_DISABLE_INTR) { |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3155 | return CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn, CE_ctrl_addr); |
Govind Singh | bc679dc | 2017-06-08 12:33:59 +0530 | [diff] [blame] | 3156 | } else { |
| 3157 | if (TARGET_REGISTER_ACCESS_ALLOWED(scn)) |
| 3158 | return A_TARGET_READ(scn, |
| 3159 | (CE_ctrl_addr) + CURRENT_DRRI_ADDRESS); |
| 3160 | else |
| 3161 | return CE_DEST_RING_READ_IDX_GET_FROM_DDR(scn, |
| 3162 | CE_ctrl_addr); |
| 3163 | } |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3164 | } |
| 3165 | |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3166 | /** |
| 3167 | * hif_config_rri_on_ddr(): Configure the RRI on DDR mechanism |
| 3168 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3169 | * @scn: hif_softc pointer |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3170 | * |
| 3171 | * This function allocates non cached memory on ddr and sends |
| 3172 | * the physical address of this memory to the CE hardware. The |
| 3173 | * hardware updates the RRI on this particular location. |
| 3174 | * |
| 3175 | * Return: None |
| 3176 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3177 | static inline void hif_config_rri_on_ddr(struct hif_softc *scn) |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3178 | { |
| 3179 | unsigned int i; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3180 | qdf_dma_addr_t paddr_rri_on_ddr; |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3181 | uint32_t high_paddr, low_paddr; |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 3182 | |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3183 | scn->vaddr_rri_on_ddr = |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3184 | (uint32_t *)qdf_mem_alloc_consistent(scn->qdf_dev, |
| 3185 | scn->qdf_dev->dev, (CE_COUNT*sizeof(uint32_t)), |
| 3186 | &paddr_rri_on_ddr); |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3187 | |
Arunk Khandavalli | e14e8e9 | 2017-04-03 21:40:26 +0530 | [diff] [blame] | 3188 | scn->paddr_rri_on_ddr = paddr_rri_on_ddr; |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3189 | low_paddr = BITS0_TO_31(paddr_rri_on_ddr); |
| 3190 | high_paddr = BITS32_TO_35(paddr_rri_on_ddr); |
| 3191 | |
Srinivas Girigowda | 6e0cfd9 | 2017-03-09 15:49:59 -0800 | [diff] [blame] | 3192 | HIF_DBG("%s using srri and drri from DDR", __func__); |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3193 | |
| 3194 | WRITE_CE_DDR_ADDRESS_FOR_RRI_LOW(scn, low_paddr); |
| 3195 | WRITE_CE_DDR_ADDRESS_FOR_RRI_HIGH(scn, high_paddr); |
| 3196 | |
| 3197 | for (i = 0; i < CE_COUNT; i++) |
| 3198 | CE_IDX_UPD_EN_SET(scn, CE_BASE_ADDRESS(i)); |
| 3199 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3200 | qdf_mem_zero(scn->vaddr_rri_on_ddr, CE_COUNT*sizeof(uint32_t)); |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3201 | |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3202 | } |
| 3203 | #else |
| 3204 | |
| 3205 | /** |
| 3206 | * hif_config_rri_on_ddr(): Configure the RRI on DDR mechanism |
| 3207 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3208 | * @scn: hif_softc pointer |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3209 | * |
| 3210 | * This is a dummy implementation for platforms that don't |
| 3211 | * support this functionality. |
| 3212 | * |
| 3213 | * Return: None |
| 3214 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3215 | static inline void hif_config_rri_on_ddr(struct hif_softc *scn) |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3216 | { |
Sanjay Devnani | b925d7e | 2015-11-12 14:43:58 -0800 | [diff] [blame] | 3217 | } |
| 3218 | #endif |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3219 | |
| 3220 | /** |
| 3221 | * hif_dump_ce_registers() - dump ce registers |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 3222 | * @scn: hif_opaque_softc pointer. |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3223 | * |
| 3224 | * Output the copy engine registers |
| 3225 | * |
| 3226 | * Return: 0 for success or error code |
| 3227 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3228 | int hif_dump_ce_registers(struct hif_softc *scn) |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3229 | { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 3230 | struct hif_opaque_softc *hif_hdl = GET_HIF_OPAQUE_HDL(scn); |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3231 | uint32_t ce_reg_address = CE0_BASE_ADDRESS; |
Houston Hoffman | 6296c3e | 2016-07-12 18:43:32 -0700 | [diff] [blame] | 3232 | uint32_t ce_reg_values[CE_USEFUL_SIZE >> 2]; |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3233 | uint32_t ce_reg_word_size = CE_USEFUL_SIZE >> 2; |
| 3234 | uint16_t i; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3235 | QDF_STATUS status; |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3236 | |
Houston Hoffman | d6f946c | 2016-04-06 15:16:00 -0700 | [diff] [blame] | 3237 | for (i = 0; i < scn->ce_count; i++, ce_reg_address += CE_OFFSET) { |
| 3238 | if (scn->ce_id_to_state[i] == NULL) { |
| 3239 | HIF_DBG("CE%d not used.", i); |
| 3240 | continue; |
| 3241 | } |
| 3242 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 3243 | status = hif_diag_read_mem(hif_hdl, ce_reg_address, |
Houston Hoffman | 6296c3e | 2016-07-12 18:43:32 -0700 | [diff] [blame] | 3244 | (uint8_t *) &ce_reg_values[0], |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3245 | ce_reg_word_size * sizeof(uint32_t)); |
| 3246 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3247 | if (status != QDF_STATUS_SUCCESS) { |
Manikandan Mohan | afd6e88 | 2017-04-07 17:46:41 -0700 | [diff] [blame] | 3248 | HIF_ERROR("Dumping CE register failed!"); |
| 3249 | return -EACCES; |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3250 | } |
Venkateswara Swamy Bandaru | 772377c | 2016-10-03 14:17:28 +0530 | [diff] [blame] | 3251 | HIF_ERROR("CE%d=>\n", i); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 3252 | qdf_trace_hex_dump(QDF_MODULE_ID_HIF, QDF_TRACE_LEVEL_DEBUG, |
Houston Hoffman | 6296c3e | 2016-07-12 18:43:32 -0700 | [diff] [blame] | 3253 | (uint8_t *) &ce_reg_values[0], |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3254 | ce_reg_word_size * sizeof(uint32_t)); |
Venkateswara Swamy Bandaru | 772377c | 2016-10-03 14:17:28 +0530 | [diff] [blame] | 3255 | qdf_print("ADDR:[0x%08X], SR_WR_INDEX:%d\n", (ce_reg_address |
| 3256 | + SR_WR_INDEX_ADDRESS), |
| 3257 | ce_reg_values[SR_WR_INDEX_ADDRESS/4]); |
| 3258 | qdf_print("ADDR:[0x%08X], CURRENT_SRRI:%d\n", (ce_reg_address |
| 3259 | + CURRENT_SRRI_ADDRESS), |
| 3260 | ce_reg_values[CURRENT_SRRI_ADDRESS/4]); |
| 3261 | qdf_print("ADDR:[0x%08X], DST_WR_INDEX:%d\n", (ce_reg_address |
| 3262 | + DST_WR_INDEX_ADDRESS), |
| 3263 | ce_reg_values[DST_WR_INDEX_ADDRESS/4]); |
| 3264 | qdf_print("ADDR:[0x%08X], CURRENT_DRRI:%d\n", (ce_reg_address |
| 3265 | + CURRENT_DRRI_ADDRESS), |
| 3266 | ce_reg_values[CURRENT_DRRI_ADDRESS/4]); |
| 3267 | qdf_print("---\n"); |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3268 | } |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 3269 | return 0; |
| 3270 | } |
Pratik Gandhi | dc82a77 | 2018-01-30 18:57:05 +0530 | [diff] [blame] | 3271 | qdf_export_symbol(hif_dump_ce_registers); |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 3272 | #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT |
| 3273 | struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc, |
| 3274 | struct hif_pipe_addl_info *hif_info, uint32_t pipe) |
| 3275 | { |
| 3276 | struct hif_softc *scn = HIF_GET_SOFTC(osc); |
| 3277 | struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn); |
| 3278 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(osc); |
| 3279 | struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]); |
| 3280 | struct CE_handle *ce_hdl = pipe_info->ce_hdl; |
| 3281 | struct CE_state *ce_state = (struct CE_state *)ce_hdl; |
| 3282 | struct CE_ring_state *src_ring = ce_state->src_ring; |
| 3283 | struct CE_ring_state *dest_ring = ce_state->dest_ring; |
| 3284 | |
| 3285 | if (src_ring) { |
| 3286 | hif_info->ul_pipe.nentries = src_ring->nentries; |
| 3287 | hif_info->ul_pipe.nentries_mask = src_ring->nentries_mask; |
| 3288 | hif_info->ul_pipe.sw_index = src_ring->sw_index; |
| 3289 | hif_info->ul_pipe.write_index = src_ring->write_index; |
| 3290 | hif_info->ul_pipe.hw_index = src_ring->hw_index; |
| 3291 | hif_info->ul_pipe.base_addr_CE_space = |
| 3292 | src_ring->base_addr_CE_space; |
| 3293 | hif_info->ul_pipe.base_addr_owner_space = |
| 3294 | src_ring->base_addr_owner_space; |
| 3295 | } |
| 3296 | |
| 3297 | |
| 3298 | if (dest_ring) { |
| 3299 | hif_info->dl_pipe.nentries = dest_ring->nentries; |
| 3300 | hif_info->dl_pipe.nentries_mask = dest_ring->nentries_mask; |
| 3301 | hif_info->dl_pipe.sw_index = dest_ring->sw_index; |
| 3302 | hif_info->dl_pipe.write_index = dest_ring->write_index; |
| 3303 | hif_info->dl_pipe.hw_index = dest_ring->hw_index; |
| 3304 | hif_info->dl_pipe.base_addr_CE_space = |
| 3305 | dest_ring->base_addr_CE_space; |
| 3306 | hif_info->dl_pipe.base_addr_owner_space = |
| 3307 | dest_ring->base_addr_owner_space; |
| 3308 | } |
| 3309 | |
| 3310 | hif_info->pci_mem = pci_resource_start(sc->pdev, 0); |
| 3311 | hif_info->ctrl_addr = ce_state->ctrl_addr; |
| 3312 | |
| 3313 | return hif_info; |
| 3314 | } |
Pratik Gandhi | dc82a77 | 2018-01-30 18:57:05 +0530 | [diff] [blame] | 3315 | qdf_export_symbol(hif_get_addl_pipe_info); |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 3316 | |
| 3317 | uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc, uint32_t mode) |
| 3318 | { |
| 3319 | struct hif_softc *scn = HIF_GET_SOFTC(osc); |
| 3320 | |
| 3321 | scn->nss_wifi_ol_mode = mode; |
| 3322 | return 0; |
| 3323 | } |
Pratik Gandhi | dc82a77 | 2018-01-30 18:57:05 +0530 | [diff] [blame] | 3324 | qdf_export_symbol(hif_set_nss_wifiol_mode); |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 3325 | #endif |
| 3326 | |
Venkateswara Swamy Bandaru | 5432c1b | 2016-10-12 19:00:40 +0530 | [diff] [blame] | 3327 | void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib) |
| 3328 | { |
| 3329 | struct hif_softc *scn = HIF_GET_SOFTC(osc); |
| 3330 | scn->hif_attribute = hif_attrib; |
| 3331 | } |
| 3332 | |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 3333 | |
| 3334 | /* disable interrupts (only applicable for legacy copy engine currently */ |
Houston Hoffman | 8592507 | 2016-05-06 17:02:18 -0700 | [diff] [blame] | 3335 | void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num) |
| 3336 | { |
| 3337 | struct hif_softc *scn = HIF_GET_SOFTC(osc); |
| 3338 | struct CE_state *CE_state = scn->ce_id_to_state[pipe_num]; |
| 3339 | uint32_t ctrl_addr = CE_state->ctrl_addr; |
| 3340 | |
| 3341 | Q_TARGET_ACCESS_BEGIN(scn); |
| 3342 | CE_COPY_COMPLETE_INTR_DISABLE(scn, ctrl_addr); |
| 3343 | Q_TARGET_ACCESS_END(scn); |
| 3344 | } |
Pratik Gandhi | dc82a77 | 2018-01-30 18:57:05 +0530 | [diff] [blame] | 3345 | qdf_export_symbol(hif_disable_interrupt); |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3346 | |
| 3347 | /** |
| 3348 | * hif_fw_event_handler() - hif fw event handler |
| 3349 | * @hif_state: pointer to hif ce state structure |
| 3350 | * |
| 3351 | * Process fw events and raise HTC callback to process fw events. |
| 3352 | * |
| 3353 | * Return: none |
| 3354 | */ |
| 3355 | static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state) |
| 3356 | { |
| 3357 | struct hif_msg_callbacks *msg_callbacks = |
| 3358 | &hif_state->msg_callbacks_current; |
| 3359 | |
| 3360 | if (!msg_callbacks->fwEventHandler) |
| 3361 | return; |
| 3362 | |
| 3363 | msg_callbacks->fwEventHandler(msg_callbacks->Context, |
| 3364 | QDF_STATUS_E_FAILURE); |
| 3365 | } |
| 3366 | |
| 3367 | #ifndef QCA_WIFI_3_0 |
| 3368 | /** |
| 3369 | * hif_fw_interrupt_handler() - FW interrupt handler |
| 3370 | * @irq: irq number |
| 3371 | * @arg: the user pointer |
| 3372 | * |
| 3373 | * Called from the PCI interrupt handler when a |
| 3374 | * firmware-generated interrupt to the Host. |
| 3375 | * |
Yun Park | 3fb3644 | 2017-08-17 17:37:53 -0700 | [diff] [blame] | 3376 | * only registered for legacy ce devices |
| 3377 | * |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3378 | * Return: status of handled irq |
| 3379 | */ |
| 3380 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 3381 | { |
| 3382 | struct hif_softc *scn = arg; |
| 3383 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
| 3384 | uint32_t fw_indicator_address, fw_indicator; |
| 3385 | |
| 3386 | if (Q_TARGET_ACCESS_BEGIN(scn) < 0) |
| 3387 | return ATH_ISR_NOSCHED; |
| 3388 | |
| 3389 | fw_indicator_address = hif_state->fw_indicator_address; |
| 3390 | /* For sudden unplug this will return ~0 */ |
| 3391 | fw_indicator = A_TARGET_READ(scn, fw_indicator_address); |
| 3392 | |
| 3393 | if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) { |
| 3394 | /* ACK: clear Target-side pending event */ |
| 3395 | A_TARGET_WRITE(scn, fw_indicator_address, |
| 3396 | fw_indicator & ~FW_IND_EVENT_PENDING); |
| 3397 | if (Q_TARGET_ACCESS_END(scn) < 0) |
| 3398 | return ATH_ISR_SCHED; |
| 3399 | |
| 3400 | if (hif_state->started) { |
| 3401 | hif_fw_event_handler(hif_state); |
| 3402 | } else { |
| 3403 | /* |
| 3404 | * Probable Target failure before we're prepared |
| 3405 | * to handle it. Generally unexpected. |
| 3406 | */ |
| 3407 | AR_DEBUG_PRINTF(ATH_DEBUG_ERR, |
| 3408 | ("%s: Early firmware event indicated\n", |
| 3409 | __func__)); |
| 3410 | } |
| 3411 | } else { |
| 3412 | if (Q_TARGET_ACCESS_END(scn) < 0) |
| 3413 | return ATH_ISR_SCHED; |
| 3414 | } |
| 3415 | |
| 3416 | return ATH_ISR_SCHED; |
| 3417 | } |
| 3418 | #else |
| 3419 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 3420 | { |
| 3421 | return ATH_ISR_SCHED; |
| 3422 | } |
| 3423 | #endif /* #ifdef QCA_WIFI_3_0 */ |
| 3424 | |
| 3425 | |
| 3426 | /** |
| 3427 | * hif_wlan_disable(): call the platform driver to disable wlan |
| 3428 | * @scn: HIF Context |
| 3429 | * |
| 3430 | * This function passes the con_mode to platform driver to disable |
| 3431 | * wlan. |
| 3432 | * |
| 3433 | * Return: void |
| 3434 | */ |
| 3435 | void hif_wlan_disable(struct hif_softc *scn) |
| 3436 | { |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 3437 | enum pld_driver_mode mode; |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3438 | uint32_t con_mode = hif_get_conparam(scn); |
| 3439 | |
Vinay Adella | 2a6bd8a | 2018-02-07 20:07:37 +0530 | [diff] [blame] | 3440 | if (scn->target_status == TARGET_STATUS_RESET) |
| 3441 | return; |
| 3442 | |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3443 | if (QDF_GLOBAL_FTM_MODE == con_mode) |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 3444 | mode = PLD_FTM; |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3445 | else if (QDF_IS_EPPING_ENABLED(con_mode)) |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 3446 | mode = PLD_EPPING; |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3447 | else |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 3448 | mode = PLD_MISSION; |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3449 | |
Yuanyuan Liu | fd594c2 | 2016-04-25 13:59:19 -0700 | [diff] [blame] | 3450 | pld_wlan_disable(scn->qdf_dev->dev, mode); |
Poddar, Siddarth | e41943f | 2016-04-27 15:33:48 +0530 | [diff] [blame] | 3451 | } |
Dustin Brown | 6bdbda5 | 2016-09-27 15:52:30 -0700 | [diff] [blame] | 3452 | |
Dustin Brown | 6834d32 | 2017-03-20 15:02:48 -0700 | [diff] [blame] | 3453 | int hif_get_wake_ce_id(struct hif_softc *scn, uint8_t *ce_id) |
| 3454 | { |
| 3455 | QDF_STATUS status; |
| 3456 | uint8_t ul_pipe, dl_pipe; |
| 3457 | int ul_is_polled, dl_is_polled; |
| 3458 | |
| 3459 | /* DL pipe for HTC_CTRL_RSVD_SVC should map to the wake CE */ |
| 3460 | status = hif_map_service_to_pipe(GET_HIF_OPAQUE_HDL(scn), |
| 3461 | HTC_CTRL_RSVD_SVC, |
| 3462 | &ul_pipe, &dl_pipe, |
| 3463 | &ul_is_polled, &dl_is_polled); |
| 3464 | if (status) { |
| 3465 | HIF_ERROR("%s: failed to map pipe: %d", __func__, status); |
| 3466 | return qdf_status_to_os_return(status); |
| 3467 | } |
| 3468 | |
| 3469 | *ce_id = dl_pipe; |
| 3470 | |
| 3471 | return 0; |
| 3472 | } |