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