blob: 624874a5d7107817458246cf30a598f48565c8cd [file] [log] [blame]
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08001/*
Houston Hoffmancceec342015-11-11 11:37:20 -08002 * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080028#include "targcfg.h"
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053029#include "qdf_lock.h"
30#include "qdf_status.h"
31#include "qdf_status.h"
32#include <qdf_atomic.h> /* qdf_atomic_read */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080033#include <targaddrs.h>
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080034#include "hif_io32.h"
35#include <hif.h>
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080036#include "regtable.h"
37#define ATH_MODULE_NAME hif
38#include <a_debug.h>
39#include "hif_main.h"
40#include "hif_hw_version.h"
Poddar, Siddarthe41943f2016-04-27 15:33:48 +053041#if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080042#include "ce_api.h"
43#include "ce_tasklet.h"
Poddar, Siddarthe41943f2016-04-27 15:33:48 +053044#include "platform_icnss.h"
45#endif
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053046#include "qdf_trace.h"
47#include "qdf_status.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080048#ifdef CONFIG_CNSS
49#include <net/cnss.h>
50#endif
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080051#include "hif_debug.h"
52#include "mp_dev.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080053
Komal Seelam5584a7c2016-02-24 19:22:48 +053054void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t cmd_id, bool start)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080055{
Poddar, Siddarthe41943f2016-04-27 15:33:48 +053056 hif_trigger_dump(hif_ctx, cmd_id, start);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080057}
58
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080059/**
60 * hif_get_target_id(): hif_get_target_id
61 *
62 * Return the virtual memory base address to the caller
63 *
Komal Seelam644263d2016-02-22 20:45:49 +053064 * @scn: hif_softc
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080065 *
66 * Return: A_target_id_t
67 */
Komal Seelam644263d2016-02-22 20:45:49 +053068A_target_id_t hif_get_target_id(struct hif_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080069{
70 return scn->mem;
71}
72
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080073/**
74 * hif_get_targetdef(): hif_get_targetdef
75 * @scn: scn
76 *
77 * Return: void *
78 */
Komal Seelam5584a7c2016-02-24 19:22:48 +053079void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080080{
Komal Seelam644263d2016-02-22 20:45:49 +053081 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
82
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080083 return scn->targetdef;
84}
85
86/**
87 * hif_vote_link_down(): unvote for link up
88 *
89 * Call hif_vote_link_down to release a previous request made using
90 * hif_vote_link_up. A hif_vote_link_down call should only be made
91 * after a corresponding hif_vote_link_up, otherwise you could be
92 * negating a vote from another source. When no votes are present
93 * hif will not guarantee the linkstate after hif_bus_suspend.
94 *
95 * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread
96 * and initialization deinitialization sequencences.
97 *
98 * Return: n/a
99 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530100void hif_vote_link_down(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800101{
Komal Seelam644263d2016-02-22 20:45:49 +0530102 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530103 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800104
105 scn->linkstate_vote--;
106 if (scn->linkstate_vote == 0)
Houston Hoffmancceec342015-11-11 11:37:20 -0800107 hif_bus_prevent_linkdown(scn, false);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800108}
109
110/**
111 * hif_vote_link_up(): vote to prevent bus from suspending
112 *
113 * Makes hif guarantee that fw can message the host normally
114 * durring suspend.
115 *
116 * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread
117 * and initialization deinitialization sequencences.
118 *
119 * Return: n/a
120 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530121void hif_vote_link_up(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800122{
Komal Seelam644263d2016-02-22 20:45:49 +0530123 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530124 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800125
126 scn->linkstate_vote++;
127 if (scn->linkstate_vote == 1)
Houston Hoffmancceec342015-11-11 11:37:20 -0800128 hif_bus_prevent_linkdown(scn, true);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800129}
130
131/**
132 * hif_can_suspend_link(): query if hif is permitted to suspend the link
133 *
134 * Hif will ensure that the link won't be suspended if the upperlayers
135 * don't want it to.
136 *
137 * SYNCHRONIZATION: MC thread is stopped before bus suspend thus
138 * we don't need extra locking to ensure votes dont change while
139 * we are in the process of suspending or resuming.
140 *
141 * Return: false if hif will guarantee link up durring suspend.
142 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530143bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800144{
Komal Seelam644263d2016-02-22 20:45:49 +0530145 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530146 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800147
148 return scn->linkstate_vote == 0;
149}
150
Houston Hoffman4f529982016-05-05 16:11:04 -0700151#ifndef CONFIG_WIN
152#define QCA9984_HOST_INTEREST_ADDRESS -1
153#define QCA9888_HOST_INTEREST_ADDRESS -1
154#define IPQ4019_HOST_INTEREST_ADDRESS -1
155#endif
156
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800157/**
158 * hif_hia_item_address(): hif_hia_item_address
159 * @target_type: target_type
160 * @item_offset: item_offset
161 *
162 * Return: n/a
163 */
164uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset)
165{
166 switch (target_type) {
167 case TARGET_TYPE_AR6002:
168 return AR6002_HOST_INTEREST_ADDRESS + item_offset;
169 case TARGET_TYPE_AR6003:
170 return AR6003_HOST_INTEREST_ADDRESS + item_offset;
171 case TARGET_TYPE_AR6004:
172 return AR6004_HOST_INTEREST_ADDRESS + item_offset;
173 case TARGET_TYPE_AR6006:
174 return AR6006_HOST_INTEREST_ADDRESS + item_offset;
175 case TARGET_TYPE_AR9888:
176 return AR9888_HOST_INTEREST_ADDRESS + item_offset;
177 case TARGET_TYPE_AR6320:
178 case TARGET_TYPE_AR6320V2:
179 return AR6320_HOST_INTEREST_ADDRESS + item_offset;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800180 case TARGET_TYPE_ADRASTEA:
181 /* ADRASTEA doesn't have a host interest address */
182 ASSERT(0);
183 return 0;
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700184 case TARGET_TYPE_AR900B:
185 return AR900B_HOST_INTEREST_ADDRESS + item_offset;
186 case TARGET_TYPE_QCA9984:
187 return QCA9984_HOST_INTEREST_ADDRESS + item_offset;
188 case TARGET_TYPE_QCA9888:
189 return QCA9888_HOST_INTEREST_ADDRESS + item_offset;
190 case TARGET_TYPE_IPQ4019:
191 return IPQ4019_HOST_INTEREST_ADDRESS + item_offset;
192
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800193 default:
194 ASSERT(0);
195 return 0;
196 }
197}
198
199/**
200 * hif_max_num_receives_reached() - check max receive is reached
Komal Seelambd7c51d2016-02-24 10:27:30 +0530201 * @scn: HIF Context
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800202 * @count: unsigned int.
203 *
204 * Output check status as bool
205 *
206 * Return: bool
207 */
Komal Seelambd7c51d2016-02-24 10:27:30 +0530208bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800209{
Houston Hoffman75ef5a52016-04-14 17:15:49 -0700210 if (QDF_IS_EPPING_ENABLED(hif_get_conparam(scn)))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800211 return count > 120;
212 else
213 return count > MAX_NUM_OF_RECEIVES;
214}
215
216/**
217 * init_buffer_count() - initial buffer count
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530218 * @maxSize: qdf_size_t
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800219 *
220 * routine to modify the initial buffer count to be allocated on an os
221 * platform basis. Platform owner will need to modify this as needed
222 *
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530223 * Return: qdf_size_t
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800224 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530225qdf_size_t init_buffer_count(qdf_size_t maxSize)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800226{
227 return maxSize;
228}
229
230/**
Nirav Shahd7f91592016-04-21 14:18:43 +0530231 * hif_save_htc_htt_config_endpoint() - save htt_tx_endpoint
232 * @hif_ctx: hif context
233 * @htc_htt_tx_endpoint: htt_tx_endpoint
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800234 *
235 * Return: void
236 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530237void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
Nirav Shahd7f91592016-04-21 14:18:43 +0530238 int htc_htt_tx_endpoint)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800239{
Komal Seelam644263d2016-02-22 20:45:49 +0530240 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800241
242 if (!scn) {
243 HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!",
244 __func__);
245 return;
246 }
247
Nirav Shahd7f91592016-04-21 14:18:43 +0530248 scn->htc_htt_tx_endpoint = htc_htt_tx_endpoint;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800249}
250
Houston Hoffmanec93ab02016-05-03 20:09:55 -0700251static const struct qwlan_hw qwlan_hw_list[] = {
252 {
253 .id = AR6320_REV1_VERSION,
254 .subid = 0,
255 .name = "QCA6174_REV1",
256 },
257 {
258 .id = AR6320_REV1_1_VERSION,
259 .subid = 0x1,
260 .name = "QCA6174_REV1_1",
261 },
262 {
263 .id = AR6320_REV1_3_VERSION,
264 .subid = 0x2,
265 .name = "QCA6174_REV1_3",
266 },
267 {
268 .id = AR6320_REV2_1_VERSION,
269 .subid = 0x4,
270 .name = "QCA6174_REV2_1",
271 },
272 {
273 .id = AR6320_REV2_1_VERSION,
274 .subid = 0x5,
275 .name = "QCA6174_REV2_2",
276 },
277 {
278 .id = AR6320_REV3_VERSION,
279 .subid = 0x6,
280 .name = "QCA6174_REV2.3",
281 },
282 {
283 .id = AR6320_REV3_VERSION,
284 .subid = 0x8,
285 .name = "QCA6174_REV3",
286 },
287 {
288 .id = AR6320_REV3_VERSION,
289 .subid = 0x9,
290 .name = "QCA6174_REV3_1",
291 },
292 {
293 .id = AR6320_REV3_2_VERSION,
294 .subid = 0xA,
295 .name = "AR6320_REV3_2_VERSION",
296 }
297};
298
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800299/**
300 * hif_get_hw_name(): get a human readable name for the hardware
Komal Seelam91553ce2016-01-27 18:57:10 +0530301 * @info: Target Info
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800302 *
Komal Seelam91553ce2016-01-27 18:57:10 +0530303 * Return: human readable name for the underlying wifi hardware.
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800304 */
Komal Seelam91553ce2016-01-27 18:57:10 +0530305static const char *hif_get_hw_name(struct hif_target_info *info)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800306{
307 int i;
Komal Seelam91553ce2016-01-27 18:57:10 +0530308
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800309 for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) {
Komal Seelam91553ce2016-01-27 18:57:10 +0530310 if (info->target_version == qwlan_hw_list[i].id &&
311 info->target_revision == qwlan_hw_list[i].subid) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800312 return qwlan_hw_list[i].name;
313 }
314 }
315
316 return "Unknown Device";
317}
318
319/**
320 * hif_get_hw_info(): hif_get_hw_info
321 * @scn: scn
322 * @version: version
323 * @revision: revision
324 *
325 * Return: n/a
326 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530327void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800328 const char **target_name)
329{
Komal Seelam91553ce2016-01-27 18:57:10 +0530330 struct hif_target_info *info = hif_get_target_info_handle(scn);
331 *version = info->target_version;
332 *revision = info->target_revision;
333 *target_name = hif_get_hw_name(info);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800334}
335
336/**
337 * hif_open(): hif_open
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530338 * @qdf_ctx: QDF Context
Komal Seelambd7c51d2016-02-24 10:27:30 +0530339 * @mode: Driver Mode
340 * @bus_type: Bus Type
341 * @cbk: CDS Callbacks
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800342 *
Komal Seelambd7c51d2016-02-24 10:27:30 +0530343 * API to open HIF Context
344 *
345 * Return: HIF Opaque Pointer
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800346 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530347struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
348 enum qdf_bus_type bus_type,
Komal Seelam75080122016-03-02 15:18:25 +0530349 struct hif_driver_state_callbacks *cbk)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800350{
Komal Seelam644263d2016-02-22 20:45:49 +0530351 struct hif_softc *scn;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530352 QDF_STATUS status = QDF_STATUS_SUCCESS;
Houston Hoffman162164c2016-03-14 21:12:10 -0700353 int bus_context_size = hif_bus_get_context_size(bus_type);
354
355 if (bus_context_size == 0) {
356 HIF_ERROR("%s: context size 0 not allowed", __func__);
357 return NULL;
358 }
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800359
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530360 scn = (struct hif_softc *)qdf_mem_malloc(bus_context_size);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530361 if (!scn) {
362 HIF_ERROR("%s: cannot alloc memory for HIF context of size:%d",
363 __func__, bus_context_size);
364 return GET_HIF_OPAQUE_HDL(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800365 }
366
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530367 qdf_mem_zero(scn, bus_context_size);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530368
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530369 scn->qdf_dev = qdf_ctx;
Komal Seelambd7c51d2016-02-24 10:27:30 +0530370 scn->hif_con_param = mode;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530371 qdf_atomic_init(&scn->active_tasklet_cnt);
372 qdf_atomic_init(&scn->link_suspended);
373 qdf_atomic_init(&scn->tasklet_from_intr);
Komal Seelam75080122016-03-02 15:18:25 +0530374 qdf_mem_copy(&scn->callbacks, cbk, sizeof(struct hif_driver_state_callbacks));
Houston Hoffman3db96a42016-05-05 19:54:39 -0700375 scn->bus_type = bus_type;
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800376 status = hif_bus_open(scn, bus_type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530377 if (status != QDF_STATUS_SUCCESS) {
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800378 HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d",
379 __func__, status, bus_type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530380 qdf_mem_free(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530381 scn = NULL;
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800382 }
383
Komal Seelambd7c51d2016-02-24 10:27:30 +0530384 return GET_HIF_OPAQUE_HDL(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800385}
386
387/**
388 * hif_close(): hif_close
389 * @hif_ctx: hif_ctx
390 *
391 * Return: n/a
392 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530393void hif_close(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800394{
Komal Seelam644263d2016-02-22 20:45:49 +0530395 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800396
397 if (scn == NULL) {
Komal Seelam5584a7c2016-02-24 19:22:48 +0530398 HIF_ERROR("%s: hif_opaque_softc is NULL", __func__);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800399 return;
400 }
401
402 if (scn->athdiag_procfs_inited) {
403 athdiag_procfs_remove();
404 scn->athdiag_procfs_inited = false;
405 }
406
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800407 hif_bus_close(scn);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530408 qdf_mem_free(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800409}
410
411/**
412 * hif_enable(): hif_enable
413 * @hif_ctx: hif_ctx
414 * @dev: dev
415 * @bdev: bus dev
416 * @bid: bus ID
417 * @bus_type: bus type
418 * @type: enable type
419 *
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530420 * Return: QDF_STATUS
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800421 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530422QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800423 void *bdev, const hif_bus_id *bid,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530424 enum qdf_bus_type bus_type,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800425 enum hif_enable_type type)
426{
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530427 QDF_STATUS status;
Komal Seelam644263d2016-02-22 20:45:49 +0530428 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800429
430 if (scn == NULL) {
431 HIF_ERROR("%s: hif_ctx = NULL", __func__);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530432 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800433 }
434
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800435 status = hif_enable_bus(scn, dev, bdev, bid, type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530436 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800437 HIF_ERROR("%s: hif_enable_bus error = %d",
438 __func__, status);
439 return status;
440 }
441
442 if (ADRASTEA_BU)
Komal Seelamf8600682016-02-02 18:17:13 +0530443 hif_vote_link_up(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800444
Houston Hoffman108da402016-03-14 21:11:24 -0700445 if (hif_bus_configure(scn)) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800446 HIF_ERROR("%s: Target probe failed.", __func__);
Vishwajith Upendra3f78aa62016-02-09 17:53:02 +0530447 hif_disable_bus(scn);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530448 status = QDF_STATUS_E_FAILURE;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800449 return status;
450 }
Houston Hoffman108da402016-03-14 21:11:24 -0700451
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800452 /*
453 * Flag to avoid potential unallocated memory access from MSI
454 * interrupt handler which could get scheduled as soon as MSI
455 * is enabled, i.e to take care of the race due to the order
456 * in where MSI is enabled before the memory, that will be
457 * in interrupt handlers, is allocated.
458 */
459
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800460 scn->hif_init_done = true;
461
462 HIF_TRACE("%s: X OK", __func__);
463
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530464 return QDF_STATUS_SUCCESS;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800465}
466
Komal Seelam5584a7c2016-02-24 19:22:48 +0530467void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800468{
Komal Seelam644263d2016-02-22 20:45:49 +0530469 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800470
471 if (!scn)
472 return;
473
474 hif_nointrs(scn);
475 if (scn->hif_init_done == false)
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530476 hif_shutdown_device(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800477 else
Komal Seelam644263d2016-02-22 20:45:49 +0530478 hif_stop(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800479
480 if (ADRASTEA_BU)
Komal Seelamf8600682016-02-02 18:17:13 +0530481 hif_vote_link_down(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800482
Vishwajith Upendra3f78aa62016-02-09 17:53:02 +0530483 hif_disable_bus(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800484
Komal Seelambd7c51d2016-02-24 10:27:30 +0530485 hif_wlan_disable(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800486
487 scn->notice_send = false;
488
489 HIF_INFO("%s: X", __func__);
490}
491
Nirav Shahb70bd732016-05-25 14:31:51 +0530492void hif_display_stats(struct hif_opaque_softc *hif_ctx)
493{
494 hif_display_bus_stats(hif_ctx);
495}
496
497void hif_clear_stats(struct hif_opaque_softc *hif_ctx)
498{
499 hif_clear_bus_stats(hif_ctx);
500}
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800501
502/**
Govind Singh2443fb32016-01-13 17:44:48 +0530503 * hif_crash_shutdown_dump_bus_register() - dump bus registers
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800504 * @hif_ctx: hif_ctx
505 *
506 * Return: n/a
507 */
508#if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \
Houston Hoffmanbc693492016-03-14 21:11:41 -0700509&& defined(DEBUG)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800510
Govind Singh2443fb32016-01-13 17:44:48 +0530511static void hif_crash_shutdown_dump_bus_register(void *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800512{
Komal Seelam5584a7c2016-02-24 19:22:48 +0530513 struct hif_opaque_softc *scn = hif_ctx;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800514
Govind Singh2443fb32016-01-13 17:44:48 +0530515 if (hif_check_soc_status(scn))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800516 return;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800517
Govind Singh2443fb32016-01-13 17:44:48 +0530518 if (hif_dump_registers(scn))
519 HIF_ERROR("Failed to dump bus registers!");
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800520}
521
522/**
523 * hif_crash_shutdown(): hif_crash_shutdown
524 *
525 * This function is called by the platform driver to dump CE registers
526 *
527 * @hif_ctx: hif_ctx
528 *
529 * Return: n/a
530 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530531void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800532{
Komal Seelam644263d2016-02-22 20:45:49 +0530533 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800534
Houston Hoffmanbc693492016-03-14 21:11:41 -0700535 if (!hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800536 return;
537
Houston Hoffmanbc693492016-03-14 21:11:41 -0700538 if (scn->bus_type == QDF_BUS_TYPE_SNOC) {
539 HIF_INFO_MED("%s: RAM dump disabled for bustype %d",
540 __func__, scn->bus_type);
541 return;
542 }
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800543
Komal Seelam6ee55902016-04-11 17:11:07 +0530544 if (TARGET_STATUS_RESET == scn->target_status) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800545 HIF_INFO_MED("%s: Target is already asserted, ignore!",
546 __func__);
547 return;
548 }
549
Komal Seelambd7c51d2016-02-24 10:27:30 +0530550 if (hif_is_load_or_unload_in_progress(scn)) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800551 HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__);
552 return;
553 }
554
Govind Singh2443fb32016-01-13 17:44:48 +0530555 hif_crash_shutdown_dump_bus_register(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800556
Komal Seelam644263d2016-02-22 20:45:49 +0530557 if (ol_copy_ramdump(hif_ctx))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800558 goto out;
559
560 HIF_INFO_MED("%s: RAM dump collecting completed!", __func__);
561
562out:
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800563 return;
564}
565#else
Komal Seelam5584a7c2016-02-24 19:22:48 +0530566void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800567{
568 HIF_INFO_MED("%s: Collecting target RAM dump disabled",
569 __func__);
570 return;
571}
572#endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */
573
574#ifdef QCA_WIFI_3_0
575/**
576 * hif_check_fw_reg(): hif_check_fw_reg
577 * @scn: scn
578 * @state:
579 *
580 * Return: int
581 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530582int hif_check_fw_reg(struct hif_opaque_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800583{
584 return 0;
585}
586#endif
587
588#ifdef IPA_OFFLOAD
589/**
590 * hif_read_phy_mem_base(): hif_read_phy_mem_base
591 * @scn: scn
592 * @phy_mem_base: physical mem base
593 *
594 * Return: n/a
595 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530596void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *phy_mem_base)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800597{
598 *phy_mem_base = scn->mem_pa;
599}
600#endif /* IPA_OFFLOAD */
601
602/**
603 * hif_get_device_type(): hif_get_device_type
604 * @device_id: device_id
605 * @revision_id: revision_id
606 * @hif_type: returned hif_type
607 * @target_type: returned target_type
608 *
609 * Return: int
610 */
611int hif_get_device_type(uint32_t device_id,
612 uint32_t revision_id,
613 uint32_t *hif_type, uint32_t *target_type)
614{
615 int ret = 0;
616
617 switch (device_id) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800618 case ADRASTEA_DEVICE_ID:
619 case ADRASTEA_DEVICE_ID_P2_E12:
620
621 *hif_type = HIF_TYPE_ADRASTEA;
622 *target_type = TARGET_TYPE_ADRASTEA;
623 break;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800624
625 case AR9888_DEVICE_ID:
626 *hif_type = HIF_TYPE_AR9888;
627 *target_type = TARGET_TYPE_AR9888;
628 break;
629
630 case AR6320_DEVICE_ID:
631 switch (revision_id) {
632 case AR6320_FW_1_1:
633 case AR6320_FW_1_3:
634 *hif_type = HIF_TYPE_AR6320;
635 *target_type = TARGET_TYPE_AR6320;
636 break;
637
638 case AR6320_FW_2_0:
639 case AR6320_FW_3_0:
640 case AR6320_FW_3_2:
641 *hif_type = HIF_TYPE_AR6320V2;
642 *target_type = TARGET_TYPE_AR6320V2;
643 break;
644
645 default:
646 HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x",
647 __func__, device_id, revision_id);
648 ret = -ENODEV;
649 goto end;
650 }
651 break;
652
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700653 case AR9887_DEVICE_ID:
654 *hif_type = HIF_TYPE_AR9888;
655 *target_type = TARGET_TYPE_AR9888;
Houston Hoffmanc50572b2016-06-08 19:49:46 -0700656 HIF_INFO(" *********** AR9887 **************");
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700657 break;
658
659 case QCA9984_DEVICE_ID:
660 *hif_type = HIF_TYPE_QCA9984;
661 *target_type = TARGET_TYPE_QCA9984;
Houston Hoffmanc50572b2016-06-08 19:49:46 -0700662 HIF_INFO(" *********** QCA9984 *************");
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700663 break;
664
665 case QCA9888_DEVICE_ID:
666 *hif_type = HIF_TYPE_QCA9888;
667 *target_type = TARGET_TYPE_QCA9888;
Houston Hoffmanc50572b2016-06-08 19:49:46 -0700668 HIF_INFO(" *********** QCA9888 *************");
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700669 break;
670
671 case AR900B_DEVICE_ID:
672 *hif_type = HIF_TYPE_AR900B;
673 *target_type = TARGET_TYPE_AR900B;
Houston Hoffmanc50572b2016-06-08 19:49:46 -0700674 HIF_INFO(" *********** AR900B *************");
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700675 break;
676
Houston Hoffman3db96a42016-05-05 19:54:39 -0700677 case IPQ4019_DEVICE_ID:
678 *hif_type = HIF_TYPE_IPQ4019;
679 *target_type = TARGET_TYPE_IPQ4019;
Houston Hoffmanc50572b2016-06-08 19:49:46 -0700680 HIF_INFO(" *********** IPQ4019 *************");
Houston Hoffman3db96a42016-05-05 19:54:39 -0700681 break;
682
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800683 default:
684 HIF_ERROR("%s: Unsupported device ID!", __func__);
685 ret = -ENODEV;
686 break;
687 }
688end:
689 return ret;
690}
Komal Seelam91553ce2016-01-27 18:57:10 +0530691
692/**
Houston Hoffman26352592016-03-14 21:11:43 -0700693 * hif_needs_bmi() - return true if the soc needs bmi through the driver
694 * @hif_ctx: hif context
695 *
696 * Return: true if the soc needs driver bmi otherwise false
697 */
698bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
699{
700 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
701 return hif_sc->bus_type != QDF_BUS_TYPE_SNOC;
702}
703
704/**
Houston Hoffman60a1eeb2016-03-14 21:11:44 -0700705 * hif_get_bus_type() - return the bus type
706 *
707 * Return: enum qdf_bus_type
708 */
709enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl)
710{
711 struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
712 return scn->bus_type;
713}
714
715/**
Komal Seelam91553ce2016-01-27 18:57:10 +0530716 * Target info and ini parameters are global to the driver
717 * Hence these structures are exposed to all the modules in
718 * the driver and they don't need to maintains multiple copies
719 * of the same info, instead get the handle from hif and
720 * modify them in hif
721 */
722
723/**
724 * hif_get_ini_handle() - API to get hif_config_param handle
Komal Seelam644263d2016-02-22 20:45:49 +0530725 * @hif_ctx: HIF Context
Komal Seelam91553ce2016-01-27 18:57:10 +0530726 *
727 * Return: pointer to hif_config_info
728 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530729struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx)
Komal Seelam91553ce2016-01-27 18:57:10 +0530730{
Komal Seelam644263d2016-02-22 20:45:49 +0530731 struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx);
732
733 return &sc->hif_config;
Komal Seelam91553ce2016-01-27 18:57:10 +0530734}
735
736/**
737 * hif_get_target_info_handle() - API to get hif_target_info handle
Komal Seelam644263d2016-02-22 20:45:49 +0530738 * @hif_ctx: HIF context
Komal Seelam91553ce2016-01-27 18:57:10 +0530739 *
740 * Return: Pointer to hif_target_info
741 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530742struct hif_target_info *hif_get_target_info_handle(
743 struct hif_opaque_softc *hif_ctx)
Komal Seelam91553ce2016-01-27 18:57:10 +0530744{
Komal Seelam644263d2016-02-22 20:45:49 +0530745 struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx);
746
747 return &sc->target_info;
748
Komal Seelam91553ce2016-01-27 18:57:10 +0530749}
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530750
751#if defined(FEATURE_LRO)
752/**
753 * hif_lro_flush_cb_register - API to register for LRO Flush Callback
754 * @scn: HIF Context
755 * @handler: Function pointer to be called by HIF
756 * @data: Private data to be used by the module registering to HIF
757 *
758 * Return: void
759 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530760void hif_lro_flush_cb_register(struct hif_opaque_softc *scn,
761 void (handler)(void *), void *data)
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530762{
763 ce_lro_flush_cb_register(scn, handler, data);
764}
765
766/**
767 * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks
768 * @scn: HIF Context
769 *
770 * Return: void
771 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530772void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn)
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530773{
774 ce_lro_flush_cb_deregister(scn);
775}
776#endif
Komal Seelam644263d2016-02-22 20:45:49 +0530777
778/**
779 * hif_get_target_status - API to get target status
780 * @hif_ctx: HIF Context
781 *
Komal Seelam6ee55902016-04-11 17:11:07 +0530782 * Return: enum hif_target_status
Komal Seelam644263d2016-02-22 20:45:49 +0530783 */
Komal Seelam6ee55902016-04-11 17:11:07 +0530784enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx)
Komal Seelam644263d2016-02-22 20:45:49 +0530785{
786 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
787
788 return scn->target_status;
789}
790
791/**
Komal Seelama5911d32016-02-24 19:21:59 +0530792 * hif_set_target_status() - API to set target status
Komal Seelam644263d2016-02-22 20:45:49 +0530793 * @hif_ctx: HIF Context
794 * @status: Target Status
795 *
796 * Return: void
797 */
Komal Seelam6ee55902016-04-11 17:11:07 +0530798void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
799 hif_target_status status)
Komal Seelam644263d2016-02-22 20:45:49 +0530800{
801 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
802
803 scn->target_status = status;
804}
Komal Seelama5911d32016-02-24 19:21:59 +0530805
806/**
807 * hif_init_ini_config() - API to initialize HIF configuration parameters
808 * @hif_ctx: HIF Context
809 * @cfg: HIF Configuration
810 *
811 * Return: void
812 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530813void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
814 struct hif_config_info *cfg)
Komal Seelama5911d32016-02-24 19:21:59 +0530815{
816 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
817
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530818 qdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info));
Komal Seelama5911d32016-02-24 19:21:59 +0530819}
Komal Seelambd7c51d2016-02-24 10:27:30 +0530820
821/**
822 * hif_get_conparam() - API to get driver mode in HIF
823 * @scn: HIF Context
824 *
825 * Return: driver mode of operation
826 */
827uint32_t hif_get_conparam(struct hif_softc *scn)
828{
829 if (!scn)
830 return 0;
831
832 return scn->hif_con_param;
833}
834
835/**
836 * hif_get_callbacks_handle() - API to get callbacks Handle
837 * @scn: HIF Context
838 *
839 * Return: pointer to HIF Callbacks
840 */
Komal Seelam75080122016-03-02 15:18:25 +0530841struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn)
Komal Seelambd7c51d2016-02-24 10:27:30 +0530842{
843 return &scn->callbacks;
844}
845
846/**
847 * hif_is_driver_unloading() - API to query upper layers if driver is unloading
848 * @scn: HIF Context
849 *
850 * Return: True/False
851 */
852bool hif_is_driver_unloading(struct hif_softc *scn)
853{
Komal Seelam75080122016-03-02 15:18:25 +0530854 struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530855
856 if (cbk && cbk->is_driver_unloading)
857 return cbk->is_driver_unloading(cbk->context);
858
859 return false;
860}
861
862/**
863 * hif_is_load_or_unload_in_progress() - API to query upper layers if
864 * load/unload in progress
865 * @scn: HIF Context
866 *
867 * Return: True/False
868 */
869bool hif_is_load_or_unload_in_progress(struct hif_softc *scn)
870{
Komal Seelam75080122016-03-02 15:18:25 +0530871 struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530872
873 if (cbk && cbk->is_load_unload_in_progress)
874 return cbk->is_load_unload_in_progress(cbk->context);
875
876 return false;
877}
878
879/**
880 * hif_is_recovery_in_progress() - API to query upper layers if recovery in
881 * progress
882 * @scn: HIF Context
883 *
884 * Return: True/False
885 */
886bool hif_is_recovery_in_progress(struct hif_softc *scn)
887{
Komal Seelam75080122016-03-02 15:18:25 +0530888 struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530889
890 if (cbk && cbk->is_recovery_in_progress)
891 return cbk->is_recovery_in_progress(cbk->context);
892
893 return false;
894}
Houston Hoffman56e0d702016-05-05 17:48:06 -0700895
896/**
897 * hif_batch_send() - API to access hif specific function
898 * ce_batch_send.
899 * @osc: HIF Context
900 * @msdu : list of msdus to be sent
901 * @transfer_id : transfer id
902 * @len : donwloaded length
903 *
904 * Return: list of msds not sent
905 */
906qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
907 uint32_t transfer_id, u_int32_t len, uint32_t sendhead)
908{
909 void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE);
910 return ce_batch_send((struct CE_handle *)ce_tx_hdl, msdu, transfer_id,
911 len, sendhead);
912}
913
914/**
915 * hif_update_tx_ring() - API to access hif specific function
916 * ce_update_tx_ring.
917 * @osc: HIF Context
918 * @num_htt_cmpls : number of htt compl received.
919 *
920 * Return: void
921 */
922void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls)
923{
924 void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE);
925 ce_update_tx_ring(ce_tx_hdl, num_htt_cmpls);
926}
927
928
929/**
930 * hif_send_single() - API to access hif specific function
931 * ce_send_single.
932 * @osc: HIF Context
933 * @msdu : msdu to be sent
934 * @transfer_id: transfer id
935 * @len : downloaded length
936 *
937 * Return: msdu sent status
938 */
939int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t
940 transfer_id, u_int32_t len)
941{
942 void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE);
943 return ce_send_single((struct CE_handle *)ce_tx_hdl, msdu, transfer_id,
944 len);
945}
946
947/**
948 * hif_send_fast() - API to access hif specific function
949 * ce_send_fast.
950 * @osc: HIF Context
951 * @msdu : array of msdus to be sent
952 * @num_msdus : number of msdus in an array
953 * @transfer_id: transfer id
Nirav Shahda0881a2016-05-16 10:45:16 +0530954 * @download_len: download length
Houston Hoffman56e0d702016-05-05 17:48:06 -0700955 *
956 * Return: No. of packets that could be sent
957 */
Nirav Shahda0881a2016-05-16 10:45:16 +0530958int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
959 uint32_t transfer_id, uint32_t download_len)
Houston Hoffman56e0d702016-05-05 17:48:06 -0700960{
961 void *ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_TX_CE);
Nirav Shahda0881a2016-05-16 10:45:16 +0530962 return ce_send_fast((struct CE_handle *)ce_tx_hdl, nbuf,
963 transfer_id, download_len);
Houston Hoffman56e0d702016-05-05 17:48:06 -0700964}
965
966/**
967 * hif_reg_write() - API to access hif specific function
968 * hif_write32_mb.
969 * @hif_ctx : HIF Context
970 * @offset : offset on which value has to be written
971 * @value : value to be written
972 *
973 * Return: None
974 */
975void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
976 uint32_t value)
977{
978 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
979 hif_write32_mb(scn->mem + offset, value);
980
981}
982
983/**
984 * hif_reg_read() - API to access hif specific function
985 * hif_read32_mb.
986 * @hif_ctx : HIF Context
987 * @offset : offset from which value has to be read
988 *
989 * Return: Read value
990 */
991uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset)
992{
993
994 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
995 return hif_read32_mb(scn->mem + offset);
996}