hif.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /*
  2. * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef _HIF_H_
  27. #define _HIF_H_
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif /* __cplusplus */
  31. /* Header files */
  32. #include <qdf_status.h>
  33. #include "qdf_nbuf.h"
  34. #include "ol_if_athvar.h"
  35. #include <linux/platform_device.h>
  36. #ifdef HIF_PCI
  37. #include <linux/pci.h>
  38. #endif /* HIF_PCI */
  39. #ifdef HIF_USB
  40. #include <linux/usb.h>
  41. #endif /* HIF_USB */
  42. #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
  43. typedef struct htc_callbacks HTC_CALLBACKS;
  44. typedef void __iomem *A_target_id_t;
  45. typedef void *hif_handle_t;
  46. #define HIF_TYPE_AR6002 2
  47. #define HIF_TYPE_AR6003 3
  48. #define HIF_TYPE_AR6004 5
  49. #define HIF_TYPE_AR9888 6
  50. #define HIF_TYPE_AR6320 7
  51. #define HIF_TYPE_AR6320V2 8
  52. /* For attaching Peregrine 2.0 board host_reg_tbl only */
  53. #define HIF_TYPE_AR9888V2 9
  54. #define HIF_TYPE_ADRASTEA 10
  55. #define HIF_TYPE_AR900B 11
  56. #define HIF_TYPE_QCA9984 12
  57. #define HIF_TYPE_IPQ4019 13
  58. #define HIF_TYPE_QCA9888 14
  59. /* TARGET definition needs to be abstracted in fw common
  60. * header files, below is the placeholder till WIN codebase
  61. * moved to latest copy of fw common header files.
  62. */
  63. #ifdef CONFIG_WIN
  64. #if ENABLE_10_4_FW_HDR
  65. #define TARGET_TYPE_UNKNOWN 0
  66. #define TARGET_TYPE_AR6001 1
  67. #define TARGET_TYPE_AR6002 2
  68. #define TARGET_TYPE_AR6003 3
  69. #define TARGET_TYPE_AR6004 5
  70. #define TARGET_TYPE_AR6006 6
  71. #define TARGET_TYPE_AR9888 7
  72. #define TARGET_TYPE_AR6320 8
  73. #define TARGET_TYPE_AR900B 9
  74. #define TARGET_TYPE_QCA9984 10
  75. #define TARGET_TYPE_IPQ4019 11
  76. #define TARGET_TYPE_QCA9888 12
  77. /* For attach Peregrine 2.0 board target_reg_tbl only */
  78. #define TARGET_TYPE_AR9888V2 13
  79. /* For attach Rome1.0 target_reg_tbl only*/
  80. #define TARGET_TYPE_AR6320V1 14
  81. /* For Rome2.0/2.1 target_reg_tbl ID*/
  82. #define TARGET_TYPE_AR6320V2 15
  83. /* For Rome3.0 target_reg_tbl ID*/
  84. #define TARGET_TYPE_AR6320V3 16
  85. /* For Tufello1.0 target_reg_tbl ID*/
  86. #define TARGET_TYPE_QCA9377V1 17
  87. #endif /* ENABLE_10_4_FW_HDR */
  88. /* For Adrastea target */
  89. #define TARGET_TYPE_ADRASTEA 19
  90. #endif /* CONFIG_WIN */
  91. struct CE_state;
  92. #define CE_COUNT_MAX 12
  93. #ifdef CONFIG_SLUB_DEBUG_ON
  94. #define QCA_NAPI_BUDGET 64
  95. #define QCA_NAPI_DEF_SCALE 2
  96. #else /* PERF build */
  97. #define QCA_NAPI_BUDGET 64
  98. #define QCA_NAPI_DEF_SCALE 16
  99. #endif /* SLUB_DEBUG_ON */
  100. #define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
  101. /* NOTE: "napi->scale" can be changed,
  102. but this does not change the number of buckets */
  103. #define QCA_NAPI_NUM_BUCKETS (QCA_NAPI_BUDGET / QCA_NAPI_DEF_SCALE)
  104. struct qca_napi_stat {
  105. uint32_t napi_schedules;
  106. uint32_t napi_polls;
  107. uint32_t napi_completes;
  108. uint32_t napi_workdone;
  109. uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
  110. };
  111. /**
  112. * per NAPI instance data structure
  113. * This data structure holds stuff per NAPI instance.
  114. * Note that, in the current implementation, though scale is
  115. * an instance variable, it is set to the same value for all
  116. * instances.
  117. */
  118. struct qca_napi_info {
  119. struct net_device netdev; /* dummy net_dev */
  120. void *hif_ctx;
  121. struct napi_struct napi; /* one NAPI Instance per CE in phase I */
  122. uint8_t scale; /* currently same on all instances */
  123. uint8_t id;
  124. int irq;
  125. struct qca_napi_stat stats[NR_CPUS];
  126. };
  127. /**
  128. * struct qca_napi_cpu - an entry of the napi cpu table
  129. * @core_id: physical core id of the core
  130. * @cluster_id: cluster this core belongs to
  131. * @core_mask: mask to match all core of this cluster
  132. * @thread_mask: mask for this core within the cluster
  133. * @max_freq: maximum clock this core can be clocked at
  134. * same for all cpus of the same core.
  135. * @efficiency: a coefficient to mark relative efficiency
  136. * same for all cpus of the same core.
  137. * @napis: bitmap of napi instances on this core
  138. * cluster_nxt: chain to link cores within the same cluster
  139. *
  140. * This structure represents a single entry in the napi cpu
  141. * table. The table is part of struct qca_napi_data.
  142. * This table is initialized by the init function, called while
  143. * the first napi instance is being created, updated by hotplug
  144. * notifier and when cpu affinity decisions are made (by throughput
  145. * detection), and deleted when the last napi instance is removed.
  146. */
  147. enum qca_napi_tput_state {
  148. QCA_NAPI_TPUT_UNINITIALIZED,
  149. QCA_NAPI_TPUT_LO,
  150. QCA_NAPI_TPUT_HI
  151. };
  152. enum qca_napi_cpu_state {
  153. QCA_NAPI_CPU_UNINITIALIZED,
  154. QCA_NAPI_CPU_DOWN,
  155. QCA_NAPI_CPU_UP };
  156. struct qca_napi_cpu {
  157. enum qca_napi_cpu_state state;
  158. int core_id;
  159. int cluster_id;
  160. cpumask_t core_mask;
  161. cpumask_t thread_mask;
  162. unsigned int max_freq;
  163. unsigned long efficiency;
  164. uint32_t napis;
  165. int cluster_nxt; /* index, not pointer */
  166. };
  167. /**
  168. * NAPI data-structure common to all NAPI instances.
  169. *
  170. * A variable of this type will be stored in hif module context.
  171. */
  172. struct qca_napi_data {
  173. spinlock_t lock;
  174. uint32_t state;
  175. uint32_t ce_map; /* bitmap of created/registered NAPI
  176. instances, indexed by pipe_id,
  177. not used by clients (clients use an
  178. id returned by create) */
  179. struct qca_napi_info napis[CE_COUNT_MAX];
  180. struct qca_napi_cpu napi_cpu[NR_CPUS];
  181. int lilcl_head, bigcl_head;
  182. enum qca_napi_tput_state napi_mode;
  183. };
  184. /**
  185. * struct hif_config_info - Place Holder for hif confiruation
  186. * @enable_self_recovery: Self Recovery
  187. *
  188. * Structure for holding hif ini parameters.
  189. */
  190. struct hif_config_info {
  191. bool enable_self_recovery;
  192. #ifdef FEATURE_RUNTIME_PM
  193. bool enable_runtime_pm;
  194. u_int32_t runtime_pm_delay;
  195. #endif
  196. };
  197. /**
  198. * struct hif_target_info - Target Information
  199. * @target_version: Target Version
  200. * @target_type: Target Type
  201. * @target_revision: Target Revision
  202. * @soc_version: SOC Version
  203. *
  204. * Structure to hold target information.
  205. */
  206. struct hif_target_info {
  207. uint32_t target_version;
  208. uint32_t target_type;
  209. uint32_t target_revision;
  210. uint32_t soc_version;
  211. };
  212. struct hif_opaque_softc {
  213. };
  214. typedef enum {
  215. HIF_DEVICE_POWER_UP, /* HIF layer should power up interface
  216. * and/or module */
  217. HIF_DEVICE_POWER_DOWN, /* HIF layer should initiate bus-specific
  218. * measures to minimize power */
  219. HIF_DEVICE_POWER_CUT /* HIF layer should initiate bus-specific
  220. * AND/OR platform-specific measures
  221. * to completely power-off the module and
  222. * associated hardware (i.e. cut power
  223. * supplies) */
  224. } HIF_DEVICE_POWER_CHANGE_TYPE;
  225. /**
  226. * enum hif_enable_type: what triggered the enabling of hif
  227. *
  228. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  229. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  230. */
  231. enum hif_enable_type {
  232. HIF_ENABLE_TYPE_PROBE,
  233. HIF_ENABLE_TYPE_REINIT,
  234. HIF_ENABLE_TYPE_MAX
  235. };
  236. /**
  237. * enum hif_disable_type: what triggered the disabling of hif
  238. *
  239. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  240. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered
  241. * disable
  242. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  243. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  244. */
  245. enum hif_disable_type {
  246. HIF_DISABLE_TYPE_PROBE_ERROR,
  247. HIF_DISABLE_TYPE_REINIT_ERROR,
  248. HIF_DISABLE_TYPE_REMOVE,
  249. HIF_DISABLE_TYPE_SHUTDOWN,
  250. HIF_DISABLE_TYPE_MAX
  251. };
  252. /**
  253. * enum hif_device_config_opcode: configure mode
  254. *
  255. * @HIF_DEVICE_POWER_STATE: device power state
  256. * @HIF_DEVICE_GET_MBOX_BLOCK_SIZE: get mbox block size
  257. * @HIF_DEVICE_GET_MBOX_ADDR: get mbox block address
  258. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  259. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  260. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  261. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  262. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  263. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  264. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  265. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  266. * @HIF_BMI_DONE: bmi done
  267. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  268. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  269. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  270. */
  271. enum hif_device_config_opcode {
  272. HIF_DEVICE_POWER_STATE = 0,
  273. HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
  274. HIF_DEVICE_GET_MBOX_ADDR,
  275. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  276. HIF_DEVICE_GET_IRQ_PROC_MODE,
  277. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  278. HIF_DEVICE_POWER_STATE_CHANGE,
  279. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  280. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  281. HIF_DEVICE_GET_OS_DEVICE,
  282. HIF_DEVICE_DEBUG_BUS_STATE,
  283. HIF_BMI_DONE,
  284. HIF_DEVICE_SET_TARGET_TYPE,
  285. HIF_DEVICE_SET_HTC_CONTEXT,
  286. HIF_DEVICE_GET_HTC_CONTEXT,
  287. };
  288. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  289. typedef struct _HID_ACCESS_LOG {
  290. uint32_t seqnum;
  291. bool is_write;
  292. void *addr;
  293. uint32_t value;
  294. } HIF_ACCESS_LOG;
  295. #endif
  296. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  297. uint32_t value);
  298. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  299. #define HIF_MAX_DEVICES 1
  300. struct htc_callbacks {
  301. void *context; /* context to pass to the dsrhandler
  302. * note : rwCompletionHandler is provided
  303. * the context passed to hif_read_write */
  304. QDF_STATUS(*rwCompletionHandler)(void *rwContext, QDF_STATUS status);
  305. QDF_STATUS(*dsrHandler)(void *context);
  306. };
  307. /**
  308. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  309. * @context: Private data context
  310. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  311. * @is_recovery_in_progress: Query if driver state is recovery in progress
  312. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  313. * @is_driver_unloading: Query if driver is unloading.
  314. *
  315. * This Structure provides callback pointer for HIF to query hdd for driver
  316. * states.
  317. */
  318. struct hif_driver_state_callbacks {
  319. void *context;
  320. void (*set_recovery_in_progress)(void *context, uint8_t val);
  321. bool (*is_recovery_in_progress)(void *context);
  322. bool (*is_load_unload_in_progress)(void *context);
  323. bool (*is_driver_unloading)(void *context);
  324. };
  325. /* This API detaches the HTC layer from the HIF device */
  326. void hif_detach_htc(struct hif_opaque_softc *scn);
  327. /****************************************************************/
  328. /* BMI and Diag window abstraction */
  329. /****************************************************************/
  330. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  331. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  332. * handled atomically by
  333. * DiagRead/DiagWrite */
  334. /*
  335. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  336. * and only allowed to be called from a context that can block (sleep) */
  337. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *scn,
  338. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  339. uint8_t *pSendMessage, uint32_t Length,
  340. uint8_t *pResponseMessage,
  341. uint32_t *pResponseLength, uint32_t TimeoutMS);
  342. /*
  343. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  344. * synchronous and only allowed to be called from a context that
  345. * can block (sleep). They are not high performance APIs.
  346. *
  347. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  348. * Target register or memory word.
  349. *
  350. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  351. */
  352. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *scn, uint32_t address,
  353. uint32_t *data);
  354. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *scn, uint32_t address,
  355. uint8_t *data, int nbytes);
  356. void hif_dump_target_memory(struct hif_opaque_softc *scn, void *ramdump_base,
  357. uint32_t address, uint32_t size);
  358. /*
  359. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  360. * synchronous and only allowed to be called from a context that
  361. * can block (sleep).
  362. * They are not high performance APIs.
  363. *
  364. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  365. * Target register or memory word.
  366. *
  367. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  368. */
  369. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *scn, uint32_t address,
  370. uint32_t data);
  371. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *scn, uint32_t address,
  372. uint8_t *data, int nbytes);
  373. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  374. /*
  375. * Set the FASTPATH_mode_on flag in sc, for use by data path
  376. */
  377. #ifdef WLAN_FEATURE_FASTPATH
  378. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  379. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  380. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  381. int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  382. fastpath_msg_handler handler, void *context);
  383. #else
  384. static inline int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  385. fastpath_msg_handler handler,
  386. void *context)
  387. {
  388. return QDF_STATUS_E_FAILURE;
  389. }
  390. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  391. {
  392. return NULL;
  393. }
  394. #endif
  395. /*
  396. * Enable/disable CDC max performance workaround
  397. * For max-performace set this to 0
  398. * To allow SoC to enter sleep set this to 1
  399. */
  400. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  401. void hif_ipa_get_ce_resource(struct hif_opaque_softc *scn,
  402. qdf_dma_addr_t *ce_sr_base_paddr,
  403. uint32_t *ce_sr_ring_size,
  404. qdf_dma_addr_t *ce_reg_paddr);
  405. /**
  406. * @brief List of callbacks - filled in by HTC.
  407. */
  408. struct hif_msg_callbacks {
  409. void *Context;
  410. /**< context meaningful to HTC */
  411. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  412. uint32_t transferID,
  413. uint32_t toeplitz_hash_result);
  414. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  415. uint8_t pipeID);
  416. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  417. void (*fwEventHandler)(void *context, QDF_STATUS status);
  418. };
  419. enum hif_target_status {
  420. TARGET_STATUS_CONNECTED = 0, /* target connected */
  421. TARGET_STATUS_RESET, /* target got reset */
  422. TARGET_STATUS_EJECT, /* target got ejected */
  423. TARGET_STATUS_SUSPEND /*target got suspend */
  424. };
  425. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  426. (attr |= (v & 0x01) << 5)
  427. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  428. (attr |= (v & 0x03) << 6)
  429. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  430. (attr |= (v & 0x01) << 13)
  431. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  432. (attr |= (v & 0x01) << 14)
  433. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  434. (attr |= (v & 0x01) << 15)
  435. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  436. (attr |= (v & 0x0FFF) << 16)
  437. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  438. (attr |= (v & 0x01) << 30)
  439. struct hif_ul_pipe_info {
  440. unsigned int nentries;
  441. unsigned int nentries_mask;
  442. unsigned int sw_index;
  443. unsigned int write_index; /* cached copy */
  444. unsigned int hw_index; /* cached copy */
  445. void *base_addr_owner_space; /* Host address space */
  446. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  447. };
  448. struct hif_dl_pipe_info {
  449. unsigned int nentries;
  450. unsigned int nentries_mask;
  451. unsigned int sw_index;
  452. unsigned int write_index; /* cached copy */
  453. unsigned int hw_index; /* cached copy */
  454. void *base_addr_owner_space; /* Host address space */
  455. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  456. };
  457. struct hif_pipe_addl_info {
  458. uint32_t pci_mem;
  459. uint32_t ctrl_addr;
  460. struct hif_ul_pipe_info ul_pipe;
  461. struct hif_dl_pipe_info dl_pipe;
  462. };
  463. struct hif_bus_id;
  464. typedef struct hif_bus_id hif_bus_id;
  465. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  466. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  467. int opcode, void *config, uint32_t config_len);
  468. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  469. void hif_mask_interrupt_call(struct hif_opaque_softc *scn);
  470. void hif_post_init(struct hif_opaque_softc *scn, void *hHTC,
  471. struct hif_msg_callbacks *callbacks);
  472. QDF_STATUS hif_start(struct hif_opaque_softc *scn);
  473. void hif_stop(struct hif_opaque_softc *scn);
  474. void hif_flush_surprise_remove(struct hif_opaque_softc *scn);
  475. void hif_dump(struct hif_opaque_softc *scn, uint8_t CmdId, bool start);
  476. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  477. uint8_t cmd_id, bool start);
  478. QDF_STATUS hif_send_head(struct hif_opaque_softc *scn, uint8_t PipeID,
  479. uint32_t transferID, uint32_t nbytes,
  480. qdf_nbuf_t wbuf, uint32_t data_attr);
  481. void hif_send_complete_check(struct hif_opaque_softc *scn, uint8_t PipeID,
  482. int force);
  483. void hif_shut_down_device(struct hif_opaque_softc *scn);
  484. void hif_get_default_pipe(struct hif_opaque_softc *scn, uint8_t *ULPipe,
  485. uint8_t *DLPipe);
  486. int hif_map_service_to_pipe(struct hif_opaque_softc *scn, uint16_t svc_id,
  487. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  488. int *dl_is_polled);
  489. uint16_t
  490. hif_get_free_queue_number(struct hif_opaque_softc *scn, uint8_t PipeID);
  491. void *hif_get_targetdef(struct hif_opaque_softc *scn);
  492. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  493. void hif_set_target_sleep(struct hif_opaque_softc *scn, bool sleep_ok,
  494. bool wait_for_it);
  495. int hif_check_fw_reg(struct hif_opaque_softc *scn);
  496. #ifndef HIF_PCI
  497. static inline int hif_check_soc_status(struct hif_opaque_softc *scn)
  498. {
  499. return 0;
  500. }
  501. #else
  502. int hif_check_soc_status(struct hif_opaque_softc *scn);
  503. #endif
  504. void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
  505. const char **target_name);
  506. void hif_disable_isr(struct hif_opaque_softc *scn);
  507. void hif_reset_soc(struct hif_opaque_softc *scn);
  508. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  509. int htc_htt_tx_endpoint);
  510. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
  511. enum qdf_bus_type bus_type,
  512. struct hif_driver_state_callbacks *cbk);
  513. void hif_close(struct hif_opaque_softc *hif_ctx);
  514. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  515. void *bdev, const hif_bus_id *bid,
  516. enum qdf_bus_type bus_type,
  517. enum hif_enable_type type);
  518. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  519. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  520. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  521. #ifdef FEATURE_RUNTIME_PM
  522. struct hif_pm_runtime_lock;
  523. int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx);
  524. void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx);
  525. int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx);
  526. struct hif_pm_runtime_lock *hif_runtime_lock_init(const char *name);
  527. void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  528. struct hif_pm_runtime_lock *lock);
  529. int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  530. struct hif_pm_runtime_lock *lock);
  531. int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  532. struct hif_pm_runtime_lock *lock);
  533. int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  534. struct hif_pm_runtime_lock *lock, unsigned int delay);
  535. #else
  536. struct hif_pm_runtime_lock {
  537. const char *name;
  538. };
  539. static inline void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx)
  540. {}
  541. static inline int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx)
  542. { return 0; }
  543. static inline int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx)
  544. { return 0; }
  545. static inline struct hif_pm_runtime_lock *hif_runtime_lock_init(
  546. const char *name)
  547. { return NULL; }
  548. static inline void
  549. hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  550. struct hif_pm_runtime_lock *lock) {}
  551. static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  552. struct hif_pm_runtime_lock *lock)
  553. { return 0; }
  554. static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  555. struct hif_pm_runtime_lock *lock)
  556. { return 0; }
  557. static inline int
  558. hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  559. struct hif_pm_runtime_lock *lock, unsigned int delay)
  560. { return 0; }
  561. #endif
  562. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  563. bool is_packet_log_enabled);
  564. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  565. void hif_vote_link_down(struct hif_opaque_softc *);
  566. void hif_vote_link_up(struct hif_opaque_softc *);
  567. bool hif_can_suspend_link(struct hif_opaque_softc *);
  568. int hif_bus_resume(struct hif_opaque_softc *);
  569. int hif_bus_suspend(struct hif_opaque_softc *);
  570. int hif_bus_resume_noirq(struct hif_opaque_softc *);
  571. int hif_bus_suspend_noirq(struct hif_opaque_softc *);
  572. #ifdef FEATURE_RUNTIME_PM
  573. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  574. void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
  575. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  576. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  577. void hif_process_runtime_suspend_success(struct hif_opaque_softc *);
  578. void hif_process_runtime_suspend_failure(struct hif_opaque_softc *);
  579. void hif_process_runtime_resume_success(struct hif_opaque_softc *);
  580. #endif
  581. int hif_dump_registers(struct hif_opaque_softc *scn);
  582. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  583. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  584. void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
  585. const char **target_name);
  586. void hif_lro_flush_cb_register(struct hif_opaque_softc *scn,
  587. void (handler)(void *), void *data);
  588. void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn);
  589. bool hif_needs_bmi(struct hif_opaque_softc *scn);
  590. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  591. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  592. scn);
  593. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *scn);
  594. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  595. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  596. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  597. hif_target_status);
  598. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  599. struct hif_config_info *cfg);
  600. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  601. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  602. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  603. int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t
  604. transfer_id, u_int32_t len);
  605. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  606. uint32_t transfer_id, uint32_t download_len);
  607. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  608. void hif_ce_war_disable(void);
  609. void hif_ce_war_enable(void);
  610. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  611. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  612. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  613. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  614. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  615. uint32_t pipe_num);
  616. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  617. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  618. void hif_set_bundle_mode(struct hif_opaque_softc *scn, bool enabled,
  619. int rx_bundle_cnt);
  620. int hif_bus_reset_resume(struct hif_opaque_softc *scn);
  621. #ifdef WLAN_SUSPEND_RESUME_TEST
  622. typedef void (*hdd_fake_resume_callback)(uint32_t val);
  623. void hif_fake_apps_suspend(hdd_fake_resume_callback callback);
  624. #endif
  625. #ifdef __cplusplus
  626. }
  627. #endif
  628. #endif /* _HIF_H_ */