hif.h 27 KB

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