hif.h 26 KB

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