blob: 2e3c230f9c3efd6f57bcb40236e071a8cf967152 [file] [log] [blame]
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08001/*
Houston Hoffmanebc68142016-01-18 15:38:27 -08002 * Copyright (c) 2013-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
28#ifndef _HIF_H_
29#define _HIF_H_
30
31#ifdef __cplusplus
32extern "C" {
33#endif /* __cplusplus */
34
35/* Header files */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053036#include <qdf_status.h>
37#include "qdf_nbuf.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080038#include "ol_if_athvar.h"
39#include <linux/platform_device.h>
40#ifdef HIF_PCI
41#include <linux/pci.h>
42#endif /* HIF_PCI */
43
44#define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
45
46typedef struct htc_callbacks HTC_CALLBACKS;
47typedef void __iomem *A_target_id_t;
Komal Seelam6ee55902016-04-11 17:11:07 +053048typedef void *hif_handle_t;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080049
50#define HIF_TYPE_AR6002 2
51#define HIF_TYPE_AR6003 3
52#define HIF_TYPE_AR6004 5
53#define HIF_TYPE_AR9888 6
54#define HIF_TYPE_AR6320 7
55#define HIF_TYPE_AR6320V2 8
56/* For attaching Peregrine 2.0 board host_reg_tbl only */
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070057#define HIF_TYPE_AR9888V2 9
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080058#define HIF_TYPE_ADRASTEA 10
Houston Hoffman56e0d702016-05-05 17:48:06 -070059#define HIF_TYPE_AR900B 11
60#define HIF_TYPE_QCA9984 12
61#define HIF_TYPE_IPQ4019 13
62#define HIF_TYPE_QCA9888 14
63
64
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080065
66#define TARGET_TYPE_UNKNOWN 0
67#define TARGET_TYPE_AR6001 1
68#define TARGET_TYPE_AR6002 2
69#define TARGET_TYPE_AR6003 3
70#define TARGET_TYPE_AR6004 5
71#define TARGET_TYPE_AR6006 6
72#define TARGET_TYPE_AR9888 7
73#define TARGET_TYPE_AR6320 8
74#define TARGET_TYPE_AR900B 9
Houston Hoffmanfb698ef2016-05-05 19:50:44 -070075#define TARGET_TYPE_QCA9984 10
76#define TARGET_TYPE_IPQ4019 11
77#define TARGET_TYPE_QCA9888 12
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080078/* For attach Peregrine 2.0 board target_reg_tbl only */
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070079#define TARGET_TYPE_AR9888V2 13
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080080/* For attach Rome1.0 target_reg_tbl only*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070081#define TARGET_TYPE_AR6320V1 14
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080082/* For Rome2.0/2.1 target_reg_tbl ID*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070083#define TARGET_TYPE_AR6320V2 15
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080084/* For Rome3.0 target_reg_tbl ID*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070085#define TARGET_TYPE_AR6320V3 16
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080086/* For Tufello1.0 target_reg_tbl ID*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070087#define TARGET_TYPE_QCA9377V1 17
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080088/* For Adrastea target */
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070089#define TARGET_TYPE_ADRASTEA 19
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080090
91struct CE_state;
Sanjay Devnani9ce15772015-11-12 14:08:57 -080092#define CE_COUNT_MAX 12
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080093
Prakash Manjunathappa82b89962016-05-05 18:54:23 -070094#ifdef CONFIG_SLUB_DEBUG_ON
95#define QCA_NAPI_BUDGET 64
96#define QCA_NAPI_DEF_SCALE 2
97#else /* PERF build */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080098#define QCA_NAPI_BUDGET 64
99#define QCA_NAPI_DEF_SCALE 16
Prakash Manjunathappa82b89962016-05-05 18:54:23 -0700100#endif /* SLUB_DEBUG_ON */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800101#define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
102
103/* NOTE: "napi->scale" can be changed,
104 but this does not change the number of buckets */
105#define QCA_NAPI_NUM_BUCKETS (QCA_NAPI_BUDGET / QCA_NAPI_DEF_SCALE)
106struct qca_napi_stat {
107 uint32_t napi_schedules;
108 uint32_t napi_polls;
109 uint32_t napi_completes;
110 uint32_t napi_workdone;
111 uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
112};
113
114/**
115 * per NAPI instance data structure
116 * This data structure holds stuff per NAPI instance.
117 * Note that, in the current implementation, though scale is
118 * an instance variable, it is set to the same value for all
119 * instances.
120 */
121struct qca_napi_info {
Houston Hoffmanc7d54292016-04-13 18:55:37 -0700122 struct net_device netdev; /* dummy net_dev */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800123 struct napi_struct napi; /* one NAPI Instance per CE in phase I */
124 uint8_t scale; /* currently same on all instances */
125 uint8_t id;
126 struct qca_napi_stat stats[NR_CPUS];
127};
128
129/**
130 * NAPI data-sructure common to all NAPI instances.
131 *
132 * A variable of this type will be stored in hif module context.
133 */
134
135struct qca_napi_data {
136 /* NOTE: make sure the mutex is inited only at the very beginning
137 once for the lifetime of the driver. For now, granularity of one
138 is OK, but we might want to have a better granularity later */
139 struct mutex mutex;
140 uint32_t state;
141 uint32_t ce_map; /* bitmap of created/registered NAPI
142 instances, indexed by pipe_id,
143 not used by clients (clients use an
144 id returned by create) */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800145 struct qca_napi_info napis[CE_COUNT_MAX];
146};
147
Komal Seelam91553ce2016-01-27 18:57:10 +0530148/**
Komal Seelama5911d32016-02-24 19:21:59 +0530149 * struct hif_config_info - Place Holder for hif confiruation
Komal Seelam91553ce2016-01-27 18:57:10 +0530150 * @enable_self_recovery: Self Recovery
Komal Seelam91553ce2016-01-27 18:57:10 +0530151 *
Komal Seelama5911d32016-02-24 19:21:59 +0530152 * Structure for holding hif ini parameters.
Komal Seelam91553ce2016-01-27 18:57:10 +0530153 */
154struct hif_config_info {
Komal Seelam91553ce2016-01-27 18:57:10 +0530155 bool enable_self_recovery;
Houston Hoffmanb21a0532016-03-14 21:12:12 -0700156#ifdef FEATURE_RUNTIME_PM
157 bool enable_runtime_pm;
158 u_int32_t runtime_pm_delay;
159#endif
Komal Seelam91553ce2016-01-27 18:57:10 +0530160};
161
162/**
163 * struct hif_target_info - Target Information
164 * @target_version: Target Version
165 * @target_type: Target Type
166 * @target_revision: Target Revision
167 * @soc_version: SOC Version
168 *
169 * Structure to hold target information.
170 */
171struct hif_target_info {
172 uint32_t target_version;
173 uint32_t target_type;
174 uint32_t target_revision;
175 uint32_t soc_version;
176};
177
Komal Seelam5584a7c2016-02-24 19:22:48 +0530178struct hif_opaque_softc {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800179};
180
181typedef enum {
182 HIF_DEVICE_POWER_UP, /* HIF layer should power up interface
183 * and/or module */
184 HIF_DEVICE_POWER_DOWN, /* HIF layer should initiate bus-specific
185 * measures to minimize power */
186 HIF_DEVICE_POWER_CUT /* HIF layer should initiate bus-specific
187 * AND/OR platform-specific measures
188 * to completely power-off the module and
189 * associated hardware (i.e. cut power
190 * supplies) */
191} HIF_DEVICE_POWER_CHANGE_TYPE;
192
193/**
194 * enum hif_enable_type: what triggered the enabling of hif
195 *
196 * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
197 * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
198 */
199enum hif_enable_type {
200 HIF_ENABLE_TYPE_PROBE,
201 HIF_ENABLE_TYPE_REINIT,
202 HIF_ENABLE_TYPE_MAX
203};
204
205/**
206 * enum hif_disable_type: what triggered the disabling of hif
207 *
208 * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
209 * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered
210 * disable
211 * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
212 * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
213 */
214enum hif_disable_type {
215 HIF_DISABLE_TYPE_PROBE_ERROR,
216 HIF_DISABLE_TYPE_REINIT_ERROR,
217 HIF_DISABLE_TYPE_REMOVE,
218 HIF_DISABLE_TYPE_SHUTDOWN,
219 HIF_DISABLE_TYPE_MAX
220};
Govind Singh4cc82132016-05-12 20:02:01 +0530221/**
222 * enum hif_device_config_opcode: configure mode
223 *
224 * @HIF_DEVICE_POWER_STATE: device power state
225 * @HIF_DEVICE_GET_MBOX_BLOCK_SIZE: get mbox block size
226 * @HIF_DEVICE_GET_MBOX_ADDR: get mbox block address
227 * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
228 * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
229 * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
230 * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
231 * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
232 * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
233 * @HIF_DEVICE_GET_OS_DEVICE: get OS device
234 * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
235 * @HIF_BMI_DONE: bmi done
236 * @HIF_DEVICE_SET_TARGET_TYPE: set target type
237 * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
238 * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
239 */
240enum hif_device_config_opcode {
241 HIF_DEVICE_POWER_STATE = 0,
242 HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
243 HIF_DEVICE_GET_MBOX_ADDR,
244 HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
245 HIF_DEVICE_GET_IRQ_PROC_MODE,
246 HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
247 HIF_DEVICE_POWER_STATE_CHANGE,
248 HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
249 HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
250 HIF_DEVICE_GET_OS_DEVICE,
251 HIF_DEVICE_DEBUG_BUS_STATE,
252 HIF_BMI_DONE,
253 HIF_DEVICE_SET_TARGET_TYPE,
254 HIF_DEVICE_SET_HTC_CONTEXT,
255 HIF_DEVICE_GET_HTC_CONTEXT,
256};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800257
258#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
259typedef struct _HID_ACCESS_LOG {
260 uint32_t seqnum;
261 bool is_write;
262 void *addr;
263 uint32_t value;
264} HIF_ACCESS_LOG;
265#endif
266
Houston Hoffman56e0d702016-05-05 17:48:06 -0700267void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
268 uint32_t value);
269uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
270
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800271#define HIF_MAX_DEVICES 1
272
273struct htc_callbacks {
274 void *context; /* context to pass to the dsrhandler
275 * note : rwCompletionHandler is provided
276 * the context passed to hif_read_write */
Govind Singh4cc82132016-05-12 20:02:01 +0530277 QDF_STATUS(*rwCompletionHandler)(void *rwContext, QDF_STATUS status);
278 QDF_STATUS(*dsrHandler)(void *context);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800279};
280
Komal Seelam75080122016-03-02 15:18:25 +0530281/**
282 * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
283 * @context: Private data context
284 * @set_recovery_in_progress: To Set Driver state for recovery in progress
285 * @is_recovery_in_progress: Query if driver state is recovery in progress
286 * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
287 * @is_driver_unloading: Query if driver is unloading.
288 *
289 * This Structure provides callback pointer for HIF to query hdd for driver
290 * states.
291 */
292struct hif_driver_state_callbacks {
Komal Seelambd7c51d2016-02-24 10:27:30 +0530293 void *context;
294 void (*set_recovery_in_progress)(void *context, uint8_t val);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530295 bool (*is_recovery_in_progress)(void *context);
296 bool (*is_load_unload_in_progress)(void *context);
297 bool (*is_driver_unloading)(void *context);
298};
299
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800300/* This API detaches the HTC layer from the HIF device */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530301void hif_detach_htc(struct hif_opaque_softc *scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800302
303/****************************************************************/
304/* BMI and Diag window abstraction */
305/****************************************************************/
306
307#define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
308
309#define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
310 * handled atomically by
311 * DiagRead/DiagWrite */
312
313/*
314 * API to handle HIF-specific BMI message exchanges, this API is synchronous
315 * and only allowed to be called from a context that can block (sleep) */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530316QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *scn,
317 qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
Komal Seelam2a5fa632016-02-15 10:33:44 +0530318 uint8_t *pSendMessage, uint32_t Length,
319 uint8_t *pResponseMessage,
320 uint32_t *pResponseLength, uint32_t TimeoutMS);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800321
322/*
323 * APIs to handle HIF specific diagnostic read accesses. These APIs are
324 * synchronous and only allowed to be called from a context that
325 * can block (sleep). They are not high performance APIs.
326 *
327 * hif_diag_read_access reads a 4 Byte aligned/length value from a
328 * Target register or memory word.
329 *
330 * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
331 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530332QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *scn, uint32_t address,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800333 uint32_t *data);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530334QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *scn, uint32_t address,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800335 uint8_t *data, int nbytes);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530336void hif_dump_target_memory(struct hif_opaque_softc *scn, void *ramdump_base,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800337 uint32_t address, uint32_t size);
338/*
339 * APIs to handle HIF specific diagnostic write accesses. These APIs are
340 * synchronous and only allowed to be called from a context that
341 * can block (sleep).
342 * They are not high performance APIs.
343 *
344 * hif_diag_write_access writes a 4 Byte aligned/length value to a
345 * Target register or memory word.
346 *
347 * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
348 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530349QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *scn, uint32_t address,
Komal Seelam5584a7c2016-02-24 19:22:48 +0530350 uint32_t data);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530351QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *scn, uint32_t address,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800352 uint8_t *data, int nbytes);
353
Manjunathappa Prakash4a9c3a82016-04-14 01:12:14 -0700354typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
355
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800356/*
357 * Set the FASTPATH_mode_on flag in sc, for use by data path
358 */
359#ifdef WLAN_FEATURE_FASTPATH
Komal Seelam5584a7c2016-02-24 19:22:48 +0530360void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
361bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
362void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int);
Houston Hoffman127467f2016-04-26 22:37:14 -0700363int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
364 fastpath_msg_handler handler, void *context);
Manjunathappa Prakash4a9c3a82016-04-14 01:12:14 -0700365#else
Houston Hoffman127467f2016-04-26 22:37:14 -0700366static inline int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
367 fastpath_msg_handler handler,
Manjunathappa Prakash4a9c3a82016-04-14 01:12:14 -0700368 void *context)
369{
370 return QDF_STATUS_E_FAILURE;
371}
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800372#endif
373
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800374/*
375 * Enable/disable CDC max performance workaround
376 * For max-performace set this to 0
377 * To allow SoC to enter sleep set this to 1
378 */
379#define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800380
Komal Seelam5584a7c2016-02-24 19:22:48 +0530381void hif_ipa_get_ce_resource(struct hif_opaque_softc *scn,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530382 qdf_dma_addr_t *ce_sr_base_paddr,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800383 uint32_t *ce_sr_ring_size,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530384 qdf_dma_addr_t *ce_reg_paddr);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800385
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800386/**
387 * @brief List of callbacks - filled in by HTC.
388 */
389struct hif_msg_callbacks {
390 void *Context;
391 /**< context meaningful to HTC */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530392 QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800393 uint32_t transferID,
394 uint32_t toeplitz_hash_result);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530395 QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800396 uint8_t pipeID);
397 void (*txResourceAvailHandler)(void *context, uint8_t pipe);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530398 void (*fwEventHandler)(void *context, QDF_STATUS status);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800399};
400
Komal Seelam6ee55902016-04-11 17:11:07 +0530401enum hif_target_status {
402 TARGET_STATUS_CONNECTED = 0, /* target connected */
403 TARGET_STATUS_RESET, /* target got reset */
404 TARGET_STATUS_EJECT, /* target got ejected */
405 TARGET_STATUS_SUSPEND /*target got suspend */
406};
407
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800408#define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
409 (attr |= (v & 0x01) << 5)
410#define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
411 (attr |= (v & 0x03) << 6)
412#define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
413 (attr |= (v & 0x01) << 13)
414#define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
415 (attr |= (v & 0x01) << 14)
416#define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
417 (attr |= (v & 0x01) << 15)
418#define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
419 (attr |= (v & 0x0FFF) << 16)
420#define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
421 (attr |= (v & 0x01) << 30)
422
Houston Hoffman85925072016-05-06 17:02:18 -0700423struct hif_ul_pipe_info {
424 unsigned int nentries;
425 unsigned int nentries_mask;
426 unsigned int sw_index;
427 unsigned int write_index; /* cached copy */
428 unsigned int hw_index; /* cached copy */
429 void *base_addr_owner_space; /* Host address space */
430 qdf_dma_addr_t base_addr_CE_space; /* CE address space */
431};
432
433struct hif_dl_pipe_info {
434 unsigned int nentries;
435 unsigned int nentries_mask;
436 unsigned int sw_index;
437 unsigned int write_index; /* cached copy */
438 unsigned int hw_index; /* cached copy */
439 void *base_addr_owner_space; /* Host address space */
440 qdf_dma_addr_t base_addr_CE_space; /* CE address space */
441};
442
443struct hif_pipe_addl_info {
444 uint32_t pci_mem;
445 uint32_t ctrl_addr;
446 struct hif_ul_pipe_info ul_pipe;
447 struct hif_dl_pipe_info dl_pipe;
448};
449
Houston Hoffmanf303f912016-03-14 21:11:42 -0700450struct hif_bus_id;
451typedef struct hif_bus_id hif_bus_id;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800452
Govind Singh4cc82132016-05-12 20:02:01 +0530453void hif_claim_device(struct hif_opaque_softc *hif_ctx);
454QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
455 int opcode, void *config, uint32_t config_len);
456void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
457void hif_mask_interrupt_call(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530458void hif_post_init(struct hif_opaque_softc *scn, void *hHTC,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800459 struct hif_msg_callbacks *callbacks);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530460QDF_STATUS hif_start(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530461void hif_stop(struct hif_opaque_softc *scn);
462void hif_flush_surprise_remove(struct hif_opaque_softc *scn);
463void hif_dump(struct hif_opaque_softc *scn, uint8_t CmdId, bool start);
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530464void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
465 uint8_t cmd_id, bool start);
466
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530467QDF_STATUS hif_send_head(struct hif_opaque_softc *scn, uint8_t PipeID,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800468 uint32_t transferID, uint32_t nbytes,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530469 qdf_nbuf_t wbuf, uint32_t data_attr);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530470void hif_send_complete_check(struct hif_opaque_softc *scn, uint8_t PipeID,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800471 int force);
Houston Hoffman56e0d702016-05-05 17:48:06 -0700472void hif_shut_down_device(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530473void hif_get_default_pipe(struct hif_opaque_softc *scn, uint8_t *ULPipe,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800474 uint8_t *DLPipe);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530475int hif_map_service_to_pipe(struct hif_opaque_softc *scn, uint16_t svc_id,
Sanjay Devnanic319c822015-11-06 16:44:28 -0800476 uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
477 int *dl_is_polled);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530478uint16_t
479hif_get_free_queue_number(struct hif_opaque_softc *scn, uint8_t PipeID);
480void *hif_get_targetdef(struct hif_opaque_softc *scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800481uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530482void hif_set_target_sleep(struct hif_opaque_softc *scn, bool sleep_ok,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800483 bool wait_for_it);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530484int hif_check_fw_reg(struct hif_opaque_softc *scn);
Yuanyuan Liua5f0a392016-05-09 11:39:48 -0700485#ifndef HIF_PCI
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700486static inline int hif_check_soc_status(struct hif_opaque_softc *scn)
487{
488 return 0;
489}
490#else
Komal Seelam5584a7c2016-02-24 19:22:48 +0530491int hif_check_soc_status(struct hif_opaque_softc *scn);
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700492#endif
Komal Seelam5584a7c2016-02-24 19:22:48 +0530493void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
494 const char **target_name);
495void hif_disable_isr(struct hif_opaque_softc *scn);
496void hif_reset_soc(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530497void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
Nirav Shahd7f91592016-04-21 14:18:43 +0530498 int htc_htt_tx_endpoint);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530499struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
500 enum qdf_bus_type bus_type,
Komal Seelam75080122016-03-02 15:18:25 +0530501 struct hif_driver_state_callbacks *cbk);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530502void hif_close(struct hif_opaque_softc *hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530503QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
Komal Seelam5584a7c2016-02-24 19:22:48 +0530504 void *bdev, const hif_bus_id *bid,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530505 enum qdf_bus_type bus_type,
Komal Seelam5584a7c2016-02-24 19:22:48 +0530506 enum hif_enable_type type);
507void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
Houston Hoffman9078a152015-11-02 16:15:02 -0800508
509#ifdef FEATURE_RUNTIME_PM
510struct hif_pm_runtime_lock;
Komal Seelam5584a7c2016-02-24 19:22:48 +0530511int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx);
512void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx);
513int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx);
Houston Hoffman9078a152015-11-02 16:15:02 -0800514struct hif_pm_runtime_lock *hif_runtime_lock_init(const char *name);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530515void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
Komal Seelam644263d2016-02-22 20:45:49 +0530516 struct hif_pm_runtime_lock *lock);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530517int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800518 struct hif_pm_runtime_lock *lock);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530519int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800520 struct hif_pm_runtime_lock *lock);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530521int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800522 struct hif_pm_runtime_lock *lock, unsigned int delay);
523#else
524struct hif_pm_runtime_lock {
525 const char *name;
526};
Houston Hoffmanf4607852015-12-17 17:14:40 -0800527
Komal Seelam5584a7c2016-02-24 19:22:48 +0530528static inline void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx)
Houston Hoffmanf4607852015-12-17 17:14:40 -0800529{}
530
Komal Seelam5584a7c2016-02-24 19:22:48 +0530531static inline int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx)
Houston Hoffman9078a152015-11-02 16:15:02 -0800532{ return 0; }
Komal Seelam5584a7c2016-02-24 19:22:48 +0530533static inline int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx)
Houston Hoffman9078a152015-11-02 16:15:02 -0800534{ return 0; }
535static inline struct hif_pm_runtime_lock *hif_runtime_lock_init(
536 const char *name)
537{ return NULL; }
Komal Seelamf8600682016-02-02 18:17:13 +0530538static inline void
Komal Seelam5584a7c2016-02-24 19:22:48 +0530539hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
Komal Seelam644263d2016-02-22 20:45:49 +0530540 struct hif_pm_runtime_lock *lock) {}
Houston Hoffman9078a152015-11-02 16:15:02 -0800541
Komal Seelam5584a7c2016-02-24 19:22:48 +0530542static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800543 struct hif_pm_runtime_lock *lock)
544{ return 0; }
Komal Seelam5584a7c2016-02-24 19:22:48 +0530545static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800546 struct hif_pm_runtime_lock *lock)
547{ return 0; }
Komal Seelam644263d2016-02-22 20:45:49 +0530548static inline int
Komal Seelam5584a7c2016-02-24 19:22:48 +0530549hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800550 struct hif_pm_runtime_lock *lock, unsigned int delay)
551{ return 0; }
552#endif
553
Houston Hoffmanfb7d6122016-03-14 21:11:46 -0700554void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
555 bool is_packet_log_enabled);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530556void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
Houston Hoffman78467a82016-01-05 20:08:56 -0800557
Komal Seelam5584a7c2016-02-24 19:22:48 +0530558void hif_vote_link_down(struct hif_opaque_softc *);
559void hif_vote_link_up(struct hif_opaque_softc *);
560bool hif_can_suspend_link(struct hif_opaque_softc *);
Houston Hoffman78467a82016-01-05 20:08:56 -0800561
Komal Seelam5584a7c2016-02-24 19:22:48 +0530562int hif_bus_resume(struct hif_opaque_softc *);
563int hif_bus_suspend(struct hif_opaque_softc *);
Houston Hoffman692cc052015-11-10 18:42:47 -0800564
565#ifdef FEATURE_RUNTIME_PM
Komal Seelam5584a7c2016-02-24 19:22:48 +0530566int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
567void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
568int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
569int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
570void hif_process_runtime_suspend_success(struct hif_opaque_softc *);
571void hif_process_runtime_suspend_failure(struct hif_opaque_softc *);
572void hif_process_runtime_resume_success(struct hif_opaque_softc *);
Houston Hoffman692cc052015-11-10 18:42:47 -0800573#endif
574
Komal Seelam5584a7c2016-02-24 19:22:48 +0530575int hif_dump_registers(struct hif_opaque_softc *scn);
576int ol_copy_ramdump(struct hif_opaque_softc *scn);
577void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
578void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
Komal Seelam91553ce2016-01-27 18:57:10 +0530579 const char **target_name);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530580void hif_lro_flush_cb_register(struct hif_opaque_softc *scn,
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530581 void (handler)(void *), void *data);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530582void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn);
Houston Hoffman26352592016-03-14 21:11:43 -0700583bool hif_needs_bmi(struct hif_opaque_softc *scn);
Houston Hoffman60a1eeb2016-03-14 21:11:44 -0700584enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530585struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
586 scn);
587struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *scn);
588struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
Komal Seelam6ee55902016-04-11 17:11:07 +0530589enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
590void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
591 hif_target_status);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530592void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
593 struct hif_config_info *cfg);
Houston Hoffman56e0d702016-05-05 17:48:06 -0700594void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
595qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
596 uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
597int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t
598 transfer_id, u_int32_t len);
Nirav Shahda0881a2016-05-16 10:45:16 +0530599int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
600 uint32_t transfer_id, uint32_t download_len);
Houston Hoffman56e0d702016-05-05 17:48:06 -0700601void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700602void hif_ce_war_disable(void);
603void hif_ce_war_enable(void);
Houston Hoffman85925072016-05-06 17:02:18 -0700604void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
605#ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
606struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
607 struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
608uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
609 uint32_t pipe_num);
610int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
611#endif
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700612
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800613#ifdef __cplusplus
614}
615#endif
616#endif /* _HIF_H_ */