blob: b6db21d98fbc2b99b55f4db0d69051e477f730d4 [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
Govind Singh051a8c42016-05-10 12:23:41 +053064/* TARGET definition needs to be abstracted in fw common
65 * header files, below is the placeholder till WIN codebase
66 * moved to latest copy of fw common header files.
67 */
68#ifdef CONFIG_WIN
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080069#define TARGET_TYPE_UNKNOWN 0
70#define TARGET_TYPE_AR6001 1
71#define TARGET_TYPE_AR6002 2
72#define TARGET_TYPE_AR6003 3
73#define TARGET_TYPE_AR6004 5
74#define TARGET_TYPE_AR6006 6
75#define TARGET_TYPE_AR9888 7
76#define TARGET_TYPE_AR6320 8
77#define TARGET_TYPE_AR900B 9
Houston Hoffmanfb698ef2016-05-05 19:50:44 -070078#define TARGET_TYPE_QCA9984 10
79#define TARGET_TYPE_IPQ4019 11
80#define TARGET_TYPE_QCA9888 12
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080081/* For attach Peregrine 2.0 board target_reg_tbl only */
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070082#define TARGET_TYPE_AR9888V2 13
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080083/* For attach Rome1.0 target_reg_tbl only*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070084#define TARGET_TYPE_AR6320V1 14
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080085/* For Rome2.0/2.1 target_reg_tbl ID*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070086#define TARGET_TYPE_AR6320V2 15
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080087/* For Rome3.0 target_reg_tbl ID*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070088#define TARGET_TYPE_AR6320V3 16
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080089/* For Tufello1.0 target_reg_tbl ID*/
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070090#define TARGET_TYPE_QCA9377V1 17
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080091/* For Adrastea target */
Houston Hoffmanc3c6bc12016-05-06 17:08:39 -070092#define TARGET_TYPE_ADRASTEA 19
Govind Singh051a8c42016-05-10 12:23:41 +053093#endif
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080094
95struct CE_state;
Sanjay Devnani9ce15772015-11-12 14:08:57 -080096#define CE_COUNT_MAX 12
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080097
Prakash Manjunathappa82b89962016-05-05 18:54:23 -070098#ifdef CONFIG_SLUB_DEBUG_ON
99#define QCA_NAPI_BUDGET 64
100#define QCA_NAPI_DEF_SCALE 2
101#else /* PERF build */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800102#define QCA_NAPI_BUDGET 64
103#define QCA_NAPI_DEF_SCALE 16
Prakash Manjunathappa82b89962016-05-05 18:54:23 -0700104#endif /* SLUB_DEBUG_ON */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800105#define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
106
107/* NOTE: "napi->scale" can be changed,
108 but this does not change the number of buckets */
109#define QCA_NAPI_NUM_BUCKETS (QCA_NAPI_BUDGET / QCA_NAPI_DEF_SCALE)
110struct qca_napi_stat {
111 uint32_t napi_schedules;
112 uint32_t napi_polls;
113 uint32_t napi_completes;
114 uint32_t napi_workdone;
115 uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
116};
117
118/**
119 * per NAPI instance data structure
120 * This data structure holds stuff per NAPI instance.
121 * Note that, in the current implementation, though scale is
122 * an instance variable, it is set to the same value for all
123 * instances.
124 */
125struct qca_napi_info {
Houston Hoffmanc7d54292016-04-13 18:55:37 -0700126 struct net_device netdev; /* dummy net_dev */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800127 struct napi_struct napi; /* one NAPI Instance per CE in phase I */
128 uint8_t scale; /* currently same on all instances */
129 uint8_t id;
130 struct qca_napi_stat stats[NR_CPUS];
131};
132
133/**
134 * NAPI data-sructure common to all NAPI instances.
135 *
136 * A variable of this type will be stored in hif module context.
137 */
138
139struct qca_napi_data {
140 /* NOTE: make sure the mutex is inited only at the very beginning
141 once for the lifetime of the driver. For now, granularity of one
142 is OK, but we might want to have a better granularity later */
143 struct mutex mutex;
144 uint32_t state;
145 uint32_t ce_map; /* bitmap of created/registered NAPI
146 instances, indexed by pipe_id,
147 not used by clients (clients use an
148 id returned by create) */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800149 struct qca_napi_info napis[CE_COUNT_MAX];
150};
151
Komal Seelam91553ce2016-01-27 18:57:10 +0530152/**
Komal Seelama5911d32016-02-24 19:21:59 +0530153 * struct hif_config_info - Place Holder for hif confiruation
Komal Seelam91553ce2016-01-27 18:57:10 +0530154 * @enable_self_recovery: Self Recovery
Komal Seelam91553ce2016-01-27 18:57:10 +0530155 *
Komal Seelama5911d32016-02-24 19:21:59 +0530156 * Structure for holding hif ini parameters.
Komal Seelam91553ce2016-01-27 18:57:10 +0530157 */
158struct hif_config_info {
Komal Seelam91553ce2016-01-27 18:57:10 +0530159 bool enable_self_recovery;
Houston Hoffmanb21a0532016-03-14 21:12:12 -0700160#ifdef FEATURE_RUNTIME_PM
161 bool enable_runtime_pm;
162 u_int32_t runtime_pm_delay;
163#endif
Komal Seelam91553ce2016-01-27 18:57:10 +0530164};
165
166/**
167 * struct hif_target_info - Target Information
168 * @target_version: Target Version
169 * @target_type: Target Type
170 * @target_revision: Target Revision
171 * @soc_version: SOC Version
172 *
173 * Structure to hold target information.
174 */
175struct hif_target_info {
176 uint32_t target_version;
177 uint32_t target_type;
178 uint32_t target_revision;
179 uint32_t soc_version;
180};
181
Komal Seelam5584a7c2016-02-24 19:22:48 +0530182struct hif_opaque_softc {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800183};
184
185typedef enum {
186 HIF_DEVICE_POWER_UP, /* HIF layer should power up interface
187 * and/or module */
188 HIF_DEVICE_POWER_DOWN, /* HIF layer should initiate bus-specific
189 * measures to minimize power */
190 HIF_DEVICE_POWER_CUT /* HIF layer should initiate bus-specific
191 * AND/OR platform-specific measures
192 * to completely power-off the module and
193 * associated hardware (i.e. cut power
194 * supplies) */
195} HIF_DEVICE_POWER_CHANGE_TYPE;
196
197/**
198 * enum hif_enable_type: what triggered the enabling of hif
199 *
200 * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
201 * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
202 */
203enum hif_enable_type {
204 HIF_ENABLE_TYPE_PROBE,
205 HIF_ENABLE_TYPE_REINIT,
206 HIF_ENABLE_TYPE_MAX
207};
208
209/**
210 * enum hif_disable_type: what triggered the disabling of hif
211 *
212 * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
213 * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered
214 * disable
215 * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
216 * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
217 */
218enum hif_disable_type {
219 HIF_DISABLE_TYPE_PROBE_ERROR,
220 HIF_DISABLE_TYPE_REINIT_ERROR,
221 HIF_DISABLE_TYPE_REMOVE,
222 HIF_DISABLE_TYPE_SHUTDOWN,
223 HIF_DISABLE_TYPE_MAX
224};
Govind Singh4cc82132016-05-12 20:02:01 +0530225/**
226 * enum hif_device_config_opcode: configure mode
227 *
228 * @HIF_DEVICE_POWER_STATE: device power state
229 * @HIF_DEVICE_GET_MBOX_BLOCK_SIZE: get mbox block size
230 * @HIF_DEVICE_GET_MBOX_ADDR: get mbox block address
231 * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
232 * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
233 * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
234 * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
235 * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
236 * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
237 * @HIF_DEVICE_GET_OS_DEVICE: get OS device
238 * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
239 * @HIF_BMI_DONE: bmi done
240 * @HIF_DEVICE_SET_TARGET_TYPE: set target type
241 * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
242 * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
243 */
244enum hif_device_config_opcode {
245 HIF_DEVICE_POWER_STATE = 0,
246 HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
247 HIF_DEVICE_GET_MBOX_ADDR,
248 HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
249 HIF_DEVICE_GET_IRQ_PROC_MODE,
250 HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
251 HIF_DEVICE_POWER_STATE_CHANGE,
252 HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
253 HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
254 HIF_DEVICE_GET_OS_DEVICE,
255 HIF_DEVICE_DEBUG_BUS_STATE,
256 HIF_BMI_DONE,
257 HIF_DEVICE_SET_TARGET_TYPE,
258 HIF_DEVICE_SET_HTC_CONTEXT,
259 HIF_DEVICE_GET_HTC_CONTEXT,
260};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800261
262#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
263typedef struct _HID_ACCESS_LOG {
264 uint32_t seqnum;
265 bool is_write;
266 void *addr;
267 uint32_t value;
268} HIF_ACCESS_LOG;
269#endif
270
Houston Hoffman56e0d702016-05-05 17:48:06 -0700271void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
272 uint32_t value);
273uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
274
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800275#define HIF_MAX_DEVICES 1
276
277struct htc_callbacks {
278 void *context; /* context to pass to the dsrhandler
279 * note : rwCompletionHandler is provided
280 * the context passed to hif_read_write */
Govind Singh4cc82132016-05-12 20:02:01 +0530281 QDF_STATUS(*rwCompletionHandler)(void *rwContext, QDF_STATUS status);
282 QDF_STATUS(*dsrHandler)(void *context);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800283};
284
Komal Seelam75080122016-03-02 15:18:25 +0530285/**
286 * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
287 * @context: Private data context
288 * @set_recovery_in_progress: To Set Driver state for recovery in progress
289 * @is_recovery_in_progress: Query if driver state is recovery in progress
290 * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
291 * @is_driver_unloading: Query if driver is unloading.
292 *
293 * This Structure provides callback pointer for HIF to query hdd for driver
294 * states.
295 */
296struct hif_driver_state_callbacks {
Komal Seelambd7c51d2016-02-24 10:27:30 +0530297 void *context;
298 void (*set_recovery_in_progress)(void *context, uint8_t val);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530299 bool (*is_recovery_in_progress)(void *context);
300 bool (*is_load_unload_in_progress)(void *context);
301 bool (*is_driver_unloading)(void *context);
302};
303
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800304/* This API detaches the HTC layer from the HIF device */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530305void hif_detach_htc(struct hif_opaque_softc *scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800306
307/****************************************************************/
308/* BMI and Diag window abstraction */
309/****************************************************************/
310
311#define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
312
313#define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
314 * handled atomically by
315 * DiagRead/DiagWrite */
316
317/*
318 * API to handle HIF-specific BMI message exchanges, this API is synchronous
319 * and only allowed to be called from a context that can block (sleep) */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530320QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *scn,
321 qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
Komal Seelam2a5fa632016-02-15 10:33:44 +0530322 uint8_t *pSendMessage, uint32_t Length,
323 uint8_t *pResponseMessage,
324 uint32_t *pResponseLength, uint32_t TimeoutMS);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800325
326/*
327 * APIs to handle HIF specific diagnostic read accesses. These APIs are
328 * synchronous and only allowed to be called from a context that
329 * can block (sleep). They are not high performance APIs.
330 *
331 * hif_diag_read_access reads a 4 Byte aligned/length value from a
332 * Target register or memory word.
333 *
334 * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
335 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530336QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *scn, uint32_t address,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800337 uint32_t *data);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530338QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *scn, uint32_t address,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800339 uint8_t *data, int nbytes);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530340void hif_dump_target_memory(struct hif_opaque_softc *scn, void *ramdump_base,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800341 uint32_t address, uint32_t size);
342/*
343 * APIs to handle HIF specific diagnostic write accesses. These APIs are
344 * synchronous and only allowed to be called from a context that
345 * can block (sleep).
346 * They are not high performance APIs.
347 *
348 * hif_diag_write_access writes a 4 Byte aligned/length value to a
349 * Target register or memory word.
350 *
351 * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
352 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530353QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *scn, uint32_t address,
Komal Seelam5584a7c2016-02-24 19:22:48 +0530354 uint32_t data);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530355QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *scn, uint32_t address,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800356 uint8_t *data, int nbytes);
357
Manjunathappa Prakash4a9c3a82016-04-14 01:12:14 -0700358typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
359
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800360/*
361 * Set the FASTPATH_mode_on flag in sc, for use by data path
362 */
363#ifdef WLAN_FEATURE_FASTPATH
Komal Seelam5584a7c2016-02-24 19:22:48 +0530364void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
365bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
366void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int);
Houston Hoffman127467f2016-04-26 22:37:14 -0700367int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
368 fastpath_msg_handler handler, void *context);
Manjunathappa Prakash4a9c3a82016-04-14 01:12:14 -0700369#else
Houston Hoffman127467f2016-04-26 22:37:14 -0700370static inline int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
371 fastpath_msg_handler handler,
Manjunathappa Prakash4a9c3a82016-04-14 01:12:14 -0700372 void *context)
373{
374 return QDF_STATUS_E_FAILURE;
375}
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800376#endif
377
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800378/*
379 * Enable/disable CDC max performance workaround
380 * For max-performace set this to 0
381 * To allow SoC to enter sleep set this to 1
382 */
383#define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800384
Komal Seelam5584a7c2016-02-24 19:22:48 +0530385void hif_ipa_get_ce_resource(struct hif_opaque_softc *scn,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530386 qdf_dma_addr_t *ce_sr_base_paddr,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800387 uint32_t *ce_sr_ring_size,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530388 qdf_dma_addr_t *ce_reg_paddr);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800389
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800390/**
391 * @brief List of callbacks - filled in by HTC.
392 */
393struct hif_msg_callbacks {
394 void *Context;
395 /**< context meaningful to HTC */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530396 QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800397 uint32_t transferID,
398 uint32_t toeplitz_hash_result);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530399 QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800400 uint8_t pipeID);
401 void (*txResourceAvailHandler)(void *context, uint8_t pipe);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530402 void (*fwEventHandler)(void *context, QDF_STATUS status);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800403};
404
Komal Seelam6ee55902016-04-11 17:11:07 +0530405enum hif_target_status {
406 TARGET_STATUS_CONNECTED = 0, /* target connected */
407 TARGET_STATUS_RESET, /* target got reset */
408 TARGET_STATUS_EJECT, /* target got ejected */
409 TARGET_STATUS_SUSPEND /*target got suspend */
410};
411
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800412#define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
413 (attr |= (v & 0x01) << 5)
414#define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
415 (attr |= (v & 0x03) << 6)
416#define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
417 (attr |= (v & 0x01) << 13)
418#define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
419 (attr |= (v & 0x01) << 14)
420#define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
421 (attr |= (v & 0x01) << 15)
422#define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
423 (attr |= (v & 0x0FFF) << 16)
424#define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
425 (attr |= (v & 0x01) << 30)
426
Houston Hoffman85925072016-05-06 17:02:18 -0700427struct hif_ul_pipe_info {
428 unsigned int nentries;
429 unsigned int nentries_mask;
430 unsigned int sw_index;
431 unsigned int write_index; /* cached copy */
432 unsigned int hw_index; /* cached copy */
433 void *base_addr_owner_space; /* Host address space */
434 qdf_dma_addr_t base_addr_CE_space; /* CE address space */
435};
436
437struct hif_dl_pipe_info {
438 unsigned int nentries;
439 unsigned int nentries_mask;
440 unsigned int sw_index;
441 unsigned int write_index; /* cached copy */
442 unsigned int hw_index; /* cached copy */
443 void *base_addr_owner_space; /* Host address space */
444 qdf_dma_addr_t base_addr_CE_space; /* CE address space */
445};
446
447struct hif_pipe_addl_info {
448 uint32_t pci_mem;
449 uint32_t ctrl_addr;
450 struct hif_ul_pipe_info ul_pipe;
451 struct hif_dl_pipe_info dl_pipe;
452};
453
Houston Hoffmanf303f912016-03-14 21:11:42 -0700454struct hif_bus_id;
455typedef struct hif_bus_id hif_bus_id;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800456
Govind Singh4cc82132016-05-12 20:02:01 +0530457void hif_claim_device(struct hif_opaque_softc *hif_ctx);
458QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
459 int opcode, void *config, uint32_t config_len);
460void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
461void hif_mask_interrupt_call(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530462void hif_post_init(struct hif_opaque_softc *scn, void *hHTC,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800463 struct hif_msg_callbacks *callbacks);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530464QDF_STATUS hif_start(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530465void hif_stop(struct hif_opaque_softc *scn);
466void hif_flush_surprise_remove(struct hif_opaque_softc *scn);
467void hif_dump(struct hif_opaque_softc *scn, uint8_t CmdId, bool start);
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530468void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
469 uint8_t cmd_id, bool start);
470
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530471QDF_STATUS hif_send_head(struct hif_opaque_softc *scn, uint8_t PipeID,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800472 uint32_t transferID, uint32_t nbytes,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530473 qdf_nbuf_t wbuf, uint32_t data_attr);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530474void hif_send_complete_check(struct hif_opaque_softc *scn, uint8_t PipeID,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800475 int force);
Houston Hoffman56e0d702016-05-05 17:48:06 -0700476void hif_shut_down_device(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530477void hif_get_default_pipe(struct hif_opaque_softc *scn, uint8_t *ULPipe,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800478 uint8_t *DLPipe);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530479int hif_map_service_to_pipe(struct hif_opaque_softc *scn, uint16_t svc_id,
Sanjay Devnanic319c822015-11-06 16:44:28 -0800480 uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
481 int *dl_is_polled);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530482uint16_t
483hif_get_free_queue_number(struct hif_opaque_softc *scn, uint8_t PipeID);
484void *hif_get_targetdef(struct hif_opaque_softc *scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800485uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530486void hif_set_target_sleep(struct hif_opaque_softc *scn, bool sleep_ok,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800487 bool wait_for_it);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530488int hif_check_fw_reg(struct hif_opaque_softc *scn);
Yuanyuan Liua5f0a392016-05-09 11:39:48 -0700489#ifndef HIF_PCI
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700490static inline int hif_check_soc_status(struct hif_opaque_softc *scn)
491{
492 return 0;
493}
494#else
Komal Seelam5584a7c2016-02-24 19:22:48 +0530495int hif_check_soc_status(struct hif_opaque_softc *scn);
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700496#endif
Komal Seelam5584a7c2016-02-24 19:22:48 +0530497void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
498 const char **target_name);
499void hif_disable_isr(struct hif_opaque_softc *scn);
500void hif_reset_soc(struct hif_opaque_softc *scn);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530501void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
Nirav Shahd7f91592016-04-21 14:18:43 +0530502 int htc_htt_tx_endpoint);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530503struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
504 enum qdf_bus_type bus_type,
Komal Seelam75080122016-03-02 15:18:25 +0530505 struct hif_driver_state_callbacks *cbk);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530506void hif_close(struct hif_opaque_softc *hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530507QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
Komal Seelam5584a7c2016-02-24 19:22:48 +0530508 void *bdev, const hif_bus_id *bid,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530509 enum qdf_bus_type bus_type,
Komal Seelam5584a7c2016-02-24 19:22:48 +0530510 enum hif_enable_type type);
511void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
Nirav Shahb70bd732016-05-25 14:31:51 +0530512void hif_display_stats(struct hif_opaque_softc *hif_ctx);
513void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
Houston Hoffman9078a152015-11-02 16:15:02 -0800514#ifdef FEATURE_RUNTIME_PM
515struct hif_pm_runtime_lock;
Komal Seelam5584a7c2016-02-24 19:22:48 +0530516int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx);
517void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx);
518int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx);
Houston Hoffman9078a152015-11-02 16:15:02 -0800519struct hif_pm_runtime_lock *hif_runtime_lock_init(const char *name);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530520void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
Komal Seelam644263d2016-02-22 20:45:49 +0530521 struct hif_pm_runtime_lock *lock);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530522int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800523 struct hif_pm_runtime_lock *lock);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530524int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800525 struct hif_pm_runtime_lock *lock);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530526int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800527 struct hif_pm_runtime_lock *lock, unsigned int delay);
528#else
529struct hif_pm_runtime_lock {
530 const char *name;
531};
Houston Hoffmanf4607852015-12-17 17:14:40 -0800532
Komal Seelam5584a7c2016-02-24 19:22:48 +0530533static inline void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx)
Houston Hoffmanf4607852015-12-17 17:14:40 -0800534{}
535
Komal Seelam5584a7c2016-02-24 19:22:48 +0530536static inline int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx)
Houston Hoffman9078a152015-11-02 16:15:02 -0800537{ return 0; }
Komal Seelam5584a7c2016-02-24 19:22:48 +0530538static inline int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx)
Houston Hoffman9078a152015-11-02 16:15:02 -0800539{ return 0; }
540static inline struct hif_pm_runtime_lock *hif_runtime_lock_init(
541 const char *name)
542{ return NULL; }
Komal Seelamf8600682016-02-02 18:17:13 +0530543static inline void
Komal Seelam5584a7c2016-02-24 19:22:48 +0530544hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
Komal Seelam644263d2016-02-22 20:45:49 +0530545 struct hif_pm_runtime_lock *lock) {}
Houston Hoffman9078a152015-11-02 16:15:02 -0800546
Komal Seelam5584a7c2016-02-24 19:22:48 +0530547static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800548 struct hif_pm_runtime_lock *lock)
549{ return 0; }
Komal Seelam5584a7c2016-02-24 19:22:48 +0530550static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800551 struct hif_pm_runtime_lock *lock)
552{ return 0; }
Komal Seelam644263d2016-02-22 20:45:49 +0530553static inline int
Komal Seelam5584a7c2016-02-24 19:22:48 +0530554hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
Houston Hoffman9078a152015-11-02 16:15:02 -0800555 struct hif_pm_runtime_lock *lock, unsigned int delay)
556{ return 0; }
557#endif
558
Houston Hoffmanfb7d6122016-03-14 21:11:46 -0700559void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
560 bool is_packet_log_enabled);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530561void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
Houston Hoffman78467a82016-01-05 20:08:56 -0800562
Komal Seelam5584a7c2016-02-24 19:22:48 +0530563void hif_vote_link_down(struct hif_opaque_softc *);
564void hif_vote_link_up(struct hif_opaque_softc *);
565bool hif_can_suspend_link(struct hif_opaque_softc *);
Houston Hoffman78467a82016-01-05 20:08:56 -0800566
Komal Seelam5584a7c2016-02-24 19:22:48 +0530567int hif_bus_resume(struct hif_opaque_softc *);
568int hif_bus_suspend(struct hif_opaque_softc *);
Houston Hoffman692cc052015-11-10 18:42:47 -0800569
570#ifdef FEATURE_RUNTIME_PM
Komal Seelam5584a7c2016-02-24 19:22:48 +0530571int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
572void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
573int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
574int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
575void hif_process_runtime_suspend_success(struct hif_opaque_softc *);
576void hif_process_runtime_suspend_failure(struct hif_opaque_softc *);
577void hif_process_runtime_resume_success(struct hif_opaque_softc *);
Houston Hoffman692cc052015-11-10 18:42:47 -0800578#endif
579
Komal Seelam5584a7c2016-02-24 19:22:48 +0530580int hif_dump_registers(struct hif_opaque_softc *scn);
581int ol_copy_ramdump(struct hif_opaque_softc *scn);
582void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
583void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
Komal Seelam91553ce2016-01-27 18:57:10 +0530584 const char **target_name);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530585void hif_lro_flush_cb_register(struct hif_opaque_softc *scn,
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530586 void (handler)(void *), void *data);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530587void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn);
Houston Hoffman26352592016-03-14 21:11:43 -0700588bool hif_needs_bmi(struct hif_opaque_softc *scn);
Houston Hoffman60a1eeb2016-03-14 21:11:44 -0700589enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530590struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
591 scn);
592struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *scn);
593struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
Komal Seelam6ee55902016-04-11 17:11:07 +0530594enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
595void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
596 hif_target_status);
Komal Seelam5584a7c2016-02-24 19:22:48 +0530597void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
598 struct hif_config_info *cfg);
Houston Hoffman56e0d702016-05-05 17:48:06 -0700599void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
600qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
601 uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
602int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t
603 transfer_id, u_int32_t len);
Nirav Shahda0881a2016-05-16 10:45:16 +0530604int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
605 uint32_t transfer_id, uint32_t download_len);
Houston Hoffman56e0d702016-05-05 17:48:06 -0700606void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700607void hif_ce_war_disable(void);
608void hif_ce_war_enable(void);
Houston Hoffman85925072016-05-06 17:02:18 -0700609void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
610#ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
611struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
612 struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
613uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
614 uint32_t pipe_num);
615int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
616#endif
Houston Hoffmanfb698ef2016-05-05 19:50:44 -0700617
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800618#ifdef __cplusplus
619}
620#endif
621#endif /* _HIF_H_ */