hif.h 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. /*
  2. * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HIF_H_
  19. #define _HIF_H_
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif /* __cplusplus */
  23. /* Header files */
  24. #include <qdf_status.h>
  25. #include "qdf_nbuf.h"
  26. #include "qdf_lro.h"
  27. #include "ol_if_athvar.h"
  28. #include <linux/platform_device.h>
  29. #ifdef HIF_PCI
  30. #include <linux/pci.h>
  31. #endif /* HIF_PCI */
  32. #ifdef HIF_USB
  33. #include <linux/usb.h>
  34. #endif /* HIF_USB */
  35. #ifdef IPA_OFFLOAD
  36. #include <linux/ipa.h>
  37. #endif
  38. #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
  39. typedef void __iomem *A_target_id_t;
  40. typedef void *hif_handle_t;
  41. #define HIF_TYPE_AR6002 2
  42. #define HIF_TYPE_AR6003 3
  43. #define HIF_TYPE_AR6004 5
  44. #define HIF_TYPE_AR9888 6
  45. #define HIF_TYPE_AR6320 7
  46. #define HIF_TYPE_AR6320V2 8
  47. /* For attaching Peregrine 2.0 board host_reg_tbl only */
  48. #define HIF_TYPE_AR9888V2 9
  49. #define HIF_TYPE_ADRASTEA 10
  50. #define HIF_TYPE_AR900B 11
  51. #define HIF_TYPE_QCA9984 12
  52. #define HIF_TYPE_IPQ4019 13
  53. #define HIF_TYPE_QCA9888 14
  54. #define HIF_TYPE_QCA8074 15
  55. #define HIF_TYPE_QCA6290 16
  56. #define HIF_TYPE_QCN7605 17
  57. #define HIF_TYPE_QCA6390 18
  58. #define HIF_TYPE_QCA8074V2 19
  59. #define HIF_TYPE_QCA6018 20
  60. #ifdef IPA_OFFLOAD
  61. #define DMA_COHERENT_MASK_IPA_VER_3_AND_ABOVE 37
  62. #define DMA_COHERENT_MASK_BELOW_IPA_VER_3 32
  63. #endif
  64. /* enum hif_ic_irq - enum defining integrated chip irq numbers
  65. * defining irq nubers that can be used by external modules like datapath
  66. */
  67. enum hif_ic_irq {
  68. host2wbm_desc_feed = 16,
  69. host2reo_re_injection,
  70. host2reo_command,
  71. host2rxdma_monitor_ring3,
  72. host2rxdma_monitor_ring2,
  73. host2rxdma_monitor_ring1,
  74. reo2host_exception,
  75. wbm2host_rx_release,
  76. reo2host_status,
  77. reo2host_destination_ring4,
  78. reo2host_destination_ring3,
  79. reo2host_destination_ring2,
  80. reo2host_destination_ring1,
  81. rxdma2host_monitor_destination_mac3,
  82. rxdma2host_monitor_destination_mac2,
  83. rxdma2host_monitor_destination_mac1,
  84. ppdu_end_interrupts_mac3,
  85. ppdu_end_interrupts_mac2,
  86. ppdu_end_interrupts_mac1,
  87. rxdma2host_monitor_status_ring_mac3,
  88. rxdma2host_monitor_status_ring_mac2,
  89. rxdma2host_monitor_status_ring_mac1,
  90. host2rxdma_host_buf_ring_mac3,
  91. host2rxdma_host_buf_ring_mac2,
  92. host2rxdma_host_buf_ring_mac1,
  93. rxdma2host_destination_ring_mac3,
  94. rxdma2host_destination_ring_mac2,
  95. rxdma2host_destination_ring_mac1,
  96. host2tcl_input_ring4,
  97. host2tcl_input_ring3,
  98. host2tcl_input_ring2,
  99. host2tcl_input_ring1,
  100. wbm2host_tx_completions_ring3,
  101. wbm2host_tx_completions_ring2,
  102. wbm2host_tx_completions_ring1,
  103. tcl2host_status_ring,
  104. };
  105. struct CE_state;
  106. #define CE_COUNT_MAX 12
  107. #define HIF_MAX_GRP_IRQ 16
  108. #ifdef CONFIG_WIN
  109. #define HIF_MAX_GROUP 12
  110. #else
  111. #define HIF_MAX_GROUP 8
  112. #endif
  113. #ifdef CONFIG_SLUB_DEBUG_ON
  114. #ifndef CONFIG_WIN
  115. #define HIF_CONFIG_SLUB_DEBUG_ON
  116. #endif
  117. #endif
  118. #ifndef NAPI_YIELD_BUDGET_BASED
  119. #ifdef HIF_CONFIG_SLUB_DEBUG_ON
  120. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 1
  121. #else
  122. #ifndef QCA_NAPI_DEF_SCALE_BIN_SHIFT
  123. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 4
  124. #endif
  125. #endif /* SLUB_DEBUG_ON */
  126. #else /* NAPI_YIELD_BUDGET_BASED */
  127. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 2
  128. #endif /* NAPI_YIELD_BUDGET_BASED */
  129. #define QCA_NAPI_BUDGET 64
  130. #define QCA_NAPI_DEF_SCALE \
  131. (1 << QCA_NAPI_DEF_SCALE_BIN_SHIFT)
  132. #define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
  133. /* NOTE: "napi->scale" can be changed,
  134. * but this does not change the number of buckets
  135. */
  136. #define QCA_NAPI_NUM_BUCKETS 4
  137. /**
  138. * qca_napi_stat - stats structure for execution contexts
  139. * @napi_schedules - number of times the schedule function is called
  140. * @napi_polls - number of times the execution context runs
  141. * @napi_completes - number of times that the generating interrupt is reenabled
  142. * @napi_workdone - cumulative of all work done reported by handler
  143. * @cpu_corrected - incremented when execution context runs on a different core
  144. * than the one that its irq is affined to.
  145. * @napi_budget_uses - histogram of work done per execution run
  146. * @time_limit_reache - count of yields due to time limit threshholds
  147. * @rxpkt_thresh_reached - count of yields due to a work limit
  148. * @poll_time_buckets - histogram of poll times for the napi
  149. *
  150. */
  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 cpu_corrected;
  157. uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
  158. uint32_t time_limit_reached;
  159. uint32_t rxpkt_thresh_reached;
  160. unsigned long long napi_max_poll_time;
  161. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  162. uint32_t poll_time_buckets[QCA_NAPI_NUM_BUCKETS];
  163. #endif
  164. };
  165. /**
  166. * per NAPI instance data structure
  167. * This data structure holds stuff per NAPI instance.
  168. * Note that, in the current implementation, though scale is
  169. * an instance variable, it is set to the same value for all
  170. * instances.
  171. */
  172. struct qca_napi_info {
  173. struct net_device netdev; /* dummy net_dev */
  174. void *hif_ctx;
  175. struct napi_struct napi;
  176. uint8_t scale; /* currently same on all instances */
  177. uint8_t id;
  178. uint8_t cpu;
  179. int irq;
  180. cpumask_t cpumask;
  181. struct qca_napi_stat stats[NR_CPUS];
  182. #ifdef RECEIVE_OFFLOAD
  183. /* will only be present for data rx CE's */
  184. void (*offld_flush_cb)(void *);
  185. struct napi_struct rx_thread_napi;
  186. struct net_device rx_thread_netdev;
  187. #endif /* RECEIVE_OFFLOAD */
  188. qdf_lro_ctx_t lro_ctx;
  189. };
  190. enum qca_napi_tput_state {
  191. QCA_NAPI_TPUT_UNINITIALIZED,
  192. QCA_NAPI_TPUT_LO,
  193. QCA_NAPI_TPUT_HI
  194. };
  195. enum qca_napi_cpu_state {
  196. QCA_NAPI_CPU_UNINITIALIZED,
  197. QCA_NAPI_CPU_DOWN,
  198. QCA_NAPI_CPU_UP };
  199. /**
  200. * struct qca_napi_cpu - an entry of the napi cpu table
  201. * @core_id: physical core id of the core
  202. * @cluster_id: cluster this core belongs to
  203. * @core_mask: mask to match all core of this cluster
  204. * @thread_mask: mask for this core within the cluster
  205. * @max_freq: maximum clock this core can be clocked at
  206. * same for all cpus of the same core.
  207. * @napis: bitmap of napi instances on this core
  208. * @execs: bitmap of execution contexts on this core
  209. * cluster_nxt: chain to link cores within the same cluster
  210. *
  211. * This structure represents a single entry in the napi cpu
  212. * table. The table is part of struct qca_napi_data.
  213. * This table is initialized by the init function, called while
  214. * the first napi instance is being created, updated by hotplug
  215. * notifier and when cpu affinity decisions are made (by throughput
  216. * detection), and deleted when the last napi instance is removed.
  217. */
  218. struct qca_napi_cpu {
  219. enum qca_napi_cpu_state state;
  220. int core_id;
  221. int cluster_id;
  222. cpumask_t core_mask;
  223. cpumask_t thread_mask;
  224. unsigned int max_freq;
  225. uint32_t napis;
  226. uint32_t execs;
  227. int cluster_nxt; /* index, not pointer */
  228. };
  229. /**
  230. * struct qca_napi_data - collection of napi data for a single hif context
  231. * @hif_softc: pointer to the hif context
  232. * @lock: spinlock used in the event state machine
  233. * @state: state variable used in the napi stat machine
  234. * @ce_map: bit map indicating which ce's have napis running
  235. * @exec_map: bit map of instanciated exec contexts
  236. * @user_cpu_affin_map: CPU affinity map from INI config.
  237. * @napi_cpu: cpu info for irq affinty
  238. * @lilcl_head:
  239. * @bigcl_head:
  240. * @napi_mode: irq affinity & clock voting mode
  241. * @cpuhp_handler: CPU hotplug event registration handle
  242. */
  243. struct qca_napi_data {
  244. struct hif_softc *hif_softc;
  245. qdf_spinlock_t lock;
  246. uint32_t state;
  247. /* bitmap of created/registered NAPI instances, indexed by pipe_id,
  248. * not used by clients (clients use an id returned by create)
  249. */
  250. uint32_t ce_map;
  251. uint32_t exec_map;
  252. uint32_t user_cpu_affin_mask;
  253. struct qca_napi_info *napis[CE_COUNT_MAX];
  254. struct qca_napi_cpu napi_cpu[NR_CPUS];
  255. int lilcl_head, bigcl_head;
  256. enum qca_napi_tput_state napi_mode;
  257. struct qdf_cpuhp_handler *cpuhp_handler;
  258. uint8_t flags;
  259. };
  260. /**
  261. * struct hif_config_info - Place Holder for HIF configuration
  262. * @enable_self_recovery: Self Recovery
  263. * @enable_runtime_pm: Enable Runtime PM
  264. * @runtime_pm_delay: Runtime PM Delay
  265. * @rx_softirq_max_yield_duration_ns: Max Yield time duration for RX Softirq
  266. *
  267. * Structure for holding HIF ini parameters.
  268. */
  269. struct hif_config_info {
  270. bool enable_self_recovery;
  271. #ifdef FEATURE_RUNTIME_PM
  272. bool enable_runtime_pm;
  273. u_int32_t runtime_pm_delay;
  274. #endif
  275. uint64_t rx_softirq_max_yield_duration_ns;
  276. };
  277. /**
  278. * struct hif_target_info - Target Information
  279. * @target_version: Target Version
  280. * @target_type: Target Type
  281. * @target_revision: Target Revision
  282. * @soc_version: SOC Version
  283. * @hw_name: pointer to hardware name
  284. *
  285. * Structure to hold target information.
  286. */
  287. struct hif_target_info {
  288. uint32_t target_version;
  289. uint32_t target_type;
  290. uint32_t target_revision;
  291. uint32_t soc_version;
  292. char *hw_name;
  293. };
  294. struct hif_opaque_softc {
  295. };
  296. /**
  297. * enum hif_event_type - Type of DP events to be recorded
  298. * @HIF_EVENT_IRQ_TRIGGER: IRQ trigger event
  299. * @HIF_EVENT_BH_SCHED: NAPI POLL scheduled event
  300. * @HIF_EVENT_SRNG_ACCESS_START: hal ring access start event
  301. * @HIF_EVENT_SRNG_ACCESS_END: hal ring access end event
  302. */
  303. enum hif_event_type {
  304. HIF_EVENT_IRQ_TRIGGER,
  305. HIF_EVENT_BH_SCHED,
  306. HIF_EVENT_SRNG_ACCESS_START,
  307. HIF_EVENT_SRNG_ACCESS_END,
  308. };
  309. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  310. /* HIF_EVENT_HIST_MAX should always be power of 2 */
  311. #define HIF_EVENT_HIST_MAX 512
  312. #define HIF_NUM_INT_CONTEXTS 7
  313. #define HIF_EVENT_HIST_DISABLE_MASK 0
  314. /**
  315. * struct hif_event_record - an entry of the DP event history
  316. * @hal_ring_id: ring id for which event is recorded
  317. * @hp: head pointer of the ring (may not be applicable for all events)
  318. * @tp: tail pointer of the ring (may not be applicable for all events)
  319. * @cpu_id: cpu id on which the event occurred
  320. * @timestamp: timestamp when event occurred
  321. * @type: type of the event
  322. *
  323. * This structure represents the information stored for every datapath
  324. * event which is logged in the history.
  325. */
  326. struct hif_event_record {
  327. uint8_t hal_ring_id;
  328. uint32_t hp;
  329. uint32_t tp;
  330. int cpu_id;
  331. uint64_t timestamp;
  332. enum hif_event_type type;
  333. };
  334. /**
  335. * struct hif_event_history - history for one interrupt group
  336. * @index: index to store new event
  337. * @event: event entry
  338. *
  339. * This structure represents the datapath history for one
  340. * interrupt group.
  341. */
  342. struct hif_event_history {
  343. qdf_atomic_t index;
  344. struct hif_event_record event[HIF_EVENT_HIST_MAX];
  345. };
  346. /**
  347. * hif_hist_record_event() - Record one datapath event in history
  348. * @hif_ctx: HIF opaque context
  349. * @event: DP event entry
  350. * @intr_grp_id: interrupt group ID registered with hif
  351. *
  352. * Return: None
  353. */
  354. void hif_hist_record_event(struct hif_opaque_softc *hif_ctx,
  355. struct hif_event_record *event,
  356. uint8_t intr_grp_id);
  357. /**
  358. * hif_record_event() - Wrapper function to form and record DP event
  359. * @hif_ctx: HIF opaque context
  360. * @intr_grp_id: interrupt group ID registered with hif
  361. * @hal_ring_id: ring id for which event is recorded
  362. * @hp: head pointer index of the srng
  363. * @tp: tail pointer index of the srng
  364. * @type: type of the event to be logged in history
  365. *
  366. * Return: None
  367. */
  368. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  369. uint8_t intr_grp_id,
  370. uint8_t hal_ring_id,
  371. uint32_t hp,
  372. uint32_t tp,
  373. enum hif_event_type type)
  374. {
  375. struct hif_event_record event;
  376. event.hal_ring_id = hal_ring_id;
  377. event.hp = hp;
  378. event.tp = tp;
  379. event.type = type;
  380. return hif_hist_record_event(hif_ctx, &event,
  381. intr_grp_id);
  382. }
  383. #else
  384. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  385. uint8_t intr_grp_id,
  386. uint8_t hal_ring_id,
  387. uint32_t hp,
  388. uint32_t tp,
  389. enum hif_event_type type)
  390. {
  391. }
  392. #endif /* WLAN_FEATURE_DP_EVENT_HISTORY */
  393. /**
  394. * enum HIF_DEVICE_POWER_CHANGE_TYPE: Device Power change type
  395. *
  396. * @HIF_DEVICE_POWER_UP: HIF layer should power up interface and/or module
  397. * @HIF_DEVICE_POWER_DOWN: HIF layer should initiate bus-specific measures to
  398. * minimize power
  399. * @HIF_DEVICE_POWER_CUT: HIF layer should initiate bus-specific AND/OR
  400. * platform-specific measures to completely power-off
  401. * the module and associated hardware (i.e. cut power
  402. * supplies)
  403. */
  404. enum HIF_DEVICE_POWER_CHANGE_TYPE {
  405. HIF_DEVICE_POWER_UP,
  406. HIF_DEVICE_POWER_DOWN,
  407. HIF_DEVICE_POWER_CUT
  408. };
  409. /**
  410. * enum hif_enable_type: what triggered the enabling of hif
  411. *
  412. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  413. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  414. */
  415. enum hif_enable_type {
  416. HIF_ENABLE_TYPE_PROBE,
  417. HIF_ENABLE_TYPE_REINIT,
  418. HIF_ENABLE_TYPE_MAX
  419. };
  420. /**
  421. * enum hif_disable_type: what triggered the disabling of hif
  422. *
  423. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  424. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered disable
  425. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  426. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  427. */
  428. enum hif_disable_type {
  429. HIF_DISABLE_TYPE_PROBE_ERROR,
  430. HIF_DISABLE_TYPE_REINIT_ERROR,
  431. HIF_DISABLE_TYPE_REMOVE,
  432. HIF_DISABLE_TYPE_SHUTDOWN,
  433. HIF_DISABLE_TYPE_MAX
  434. };
  435. /**
  436. * enum hif_device_config_opcode: configure mode
  437. *
  438. * @HIF_DEVICE_POWER_STATE: device power state
  439. * @HIF_DEVICE_GET_MBOX_BLOCK_SIZE: get mbox block size
  440. * @HIF_DEVICE_GET_MBOX_ADDR: get mbox block address
  441. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  442. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  443. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  444. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  445. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  446. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  447. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  448. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  449. * @HIF_BMI_DONE: bmi done
  450. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  451. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  452. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  453. */
  454. enum hif_device_config_opcode {
  455. HIF_DEVICE_POWER_STATE = 0,
  456. HIF_DEVICE_GET_BLOCK_SIZE,
  457. HIF_DEVICE_GET_FIFO_ADDR,
  458. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  459. HIF_DEVICE_GET_IRQ_PROC_MODE,
  460. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  461. HIF_DEVICE_POWER_STATE_CHANGE,
  462. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  463. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  464. HIF_DEVICE_GET_OS_DEVICE,
  465. HIF_DEVICE_DEBUG_BUS_STATE,
  466. HIF_BMI_DONE,
  467. HIF_DEVICE_SET_TARGET_TYPE,
  468. HIF_DEVICE_SET_HTC_CONTEXT,
  469. HIF_DEVICE_GET_HTC_CONTEXT,
  470. };
  471. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  472. struct HID_ACCESS_LOG {
  473. uint32_t seqnum;
  474. bool is_write;
  475. void *addr;
  476. uint32_t value;
  477. };
  478. #endif
  479. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  480. uint32_t value);
  481. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  482. #define HIF_MAX_DEVICES 1
  483. /**
  484. * struct htc_callbacks - Structure for HTC Callbacks methods
  485. * @context: context to pass to the dsrhandler
  486. * note : rwCompletionHandler is provided the context
  487. * passed to hif_read_write
  488. * @rwCompletionHandler: Read / write completion handler
  489. * @dsrHandler: DSR Handler
  490. */
  491. struct htc_callbacks {
  492. void *context;
  493. QDF_STATUS(*rw_compl_handler)(void *rw_ctx, QDF_STATUS status);
  494. QDF_STATUS(*dsr_handler)(void *context);
  495. };
  496. /**
  497. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  498. * @context: Private data context
  499. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  500. * @is_recovery_in_progress: Query if driver state is recovery in progress
  501. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  502. * @is_driver_unloading: Query if driver is unloading.
  503. *
  504. * This Structure provides callback pointer for HIF to query hdd for driver
  505. * states.
  506. */
  507. struct hif_driver_state_callbacks {
  508. void *context;
  509. void (*set_recovery_in_progress)(void *context, uint8_t val);
  510. bool (*is_recovery_in_progress)(void *context);
  511. bool (*is_load_unload_in_progress)(void *context);
  512. bool (*is_driver_unloading)(void *context);
  513. bool (*is_target_ready)(void *context);
  514. };
  515. /* This API detaches the HTC layer from the HIF device */
  516. void hif_detach_htc(struct hif_opaque_softc *hif_ctx);
  517. /****************************************************************/
  518. /* BMI and Diag window abstraction */
  519. /****************************************************************/
  520. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  521. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  522. * handled atomically by
  523. * DiagRead/DiagWrite
  524. */
  525. #ifdef WLAN_FEATURE_BMI
  526. /*
  527. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  528. * and only allowed to be called from a context that can block (sleep)
  529. */
  530. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx,
  531. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  532. uint8_t *pSendMessage, uint32_t Length,
  533. uint8_t *pResponseMessage,
  534. uint32_t *pResponseLength, uint32_t TimeoutMS);
  535. void hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx);
  536. bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx);
  537. #else /* WLAN_FEATURE_BMI */
  538. static inline void
  539. hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx)
  540. {
  541. }
  542. static inline bool
  543. hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
  544. {
  545. return false;
  546. }
  547. #endif /* WLAN_FEATURE_BMI */
  548. /*
  549. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  550. * synchronous and only allowed to be called from a context that
  551. * can block (sleep). They are not high performance APIs.
  552. *
  553. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  554. * Target register or memory word.
  555. *
  556. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  557. */
  558. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *hif_ctx,
  559. uint32_t address, uint32_t *data);
  560. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *hif_ctx, uint32_t address,
  561. uint8_t *data, int nbytes);
  562. void hif_dump_target_memory(struct hif_opaque_softc *hif_ctx,
  563. void *ramdump_base, uint32_t address, uint32_t size);
  564. /*
  565. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  566. * synchronous and only allowed to be called from a context that
  567. * can block (sleep).
  568. * They are not high performance APIs.
  569. *
  570. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  571. * Target register or memory word.
  572. *
  573. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  574. */
  575. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *hif_ctx,
  576. uint32_t address, uint32_t data);
  577. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
  578. uint32_t address, uint8_t *data, int nbytes);
  579. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  580. void hif_enable_polled_mode(struct hif_opaque_softc *hif_ctx);
  581. bool hif_is_polled_mode_enabled(struct hif_opaque_softc *hif_ctx);
  582. /*
  583. * Set the FASTPATH_mode_on flag in sc, for use by data path
  584. */
  585. #ifdef WLAN_FEATURE_FASTPATH
  586. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  587. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  588. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  589. int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  590. fastpath_msg_handler handler, void *context);
  591. #else
  592. static inline int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  593. fastpath_msg_handler handler,
  594. void *context)
  595. {
  596. return QDF_STATUS_E_FAILURE;
  597. }
  598. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  599. {
  600. return NULL;
  601. }
  602. #endif
  603. /*
  604. * Enable/disable CDC max performance workaround
  605. * For max-performace set this to 0
  606. * To allow SoC to enter sleep set this to 1
  607. */
  608. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  609. void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_ctx,
  610. qdf_shared_mem_t **ce_sr,
  611. uint32_t *ce_sr_ring_size,
  612. qdf_dma_addr_t *ce_reg_paddr);
  613. /**
  614. * @brief List of callbacks - filled in by HTC.
  615. */
  616. struct hif_msg_callbacks {
  617. void *Context;
  618. /**< context meaningful to HTC */
  619. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  620. uint32_t transferID,
  621. uint32_t toeplitz_hash_result);
  622. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  623. uint8_t pipeID);
  624. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  625. void (*fwEventHandler)(void *context, QDF_STATUS status);
  626. };
  627. enum hif_target_status {
  628. TARGET_STATUS_CONNECTED = 0, /* target connected */
  629. TARGET_STATUS_RESET, /* target got reset */
  630. TARGET_STATUS_EJECT, /* target got ejected */
  631. TARGET_STATUS_SUSPEND /*target got suspend */
  632. };
  633. /**
  634. * enum hif_attribute_flags: configure hif
  635. *
  636. * @HIF_LOWDESC_CE_CFG: Configure HIF with Low descriptor CE
  637. * @HIF_LOWDESC_CE_NO_PKTLOG_CFG: Configure HIF with Low descriptor
  638. * + No pktlog CE
  639. */
  640. enum hif_attribute_flags {
  641. HIF_LOWDESC_CE_CFG = 1,
  642. HIF_LOWDESC_CE_NO_PKTLOG_CFG
  643. };
  644. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  645. (attr |= (v & 0x01) << 5)
  646. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  647. (attr |= (v & 0x03) << 6)
  648. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  649. (attr |= (v & 0x01) << 13)
  650. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  651. (attr |= (v & 0x01) << 14)
  652. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  653. (attr |= (v & 0x01) << 15)
  654. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  655. (attr |= (v & 0x0FFF) << 16)
  656. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  657. (attr |= (v & 0x01) << 30)
  658. struct hif_ul_pipe_info {
  659. unsigned int nentries;
  660. unsigned int nentries_mask;
  661. unsigned int sw_index;
  662. unsigned int write_index; /* cached copy */
  663. unsigned int hw_index; /* cached copy */
  664. void *base_addr_owner_space; /* Host address space */
  665. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  666. };
  667. struct hif_dl_pipe_info {
  668. unsigned int nentries;
  669. unsigned int nentries_mask;
  670. unsigned int sw_index;
  671. unsigned int write_index; /* cached copy */
  672. unsigned int hw_index; /* cached copy */
  673. void *base_addr_owner_space; /* Host address space */
  674. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  675. };
  676. struct hif_pipe_addl_info {
  677. uint32_t pci_mem;
  678. uint32_t ctrl_addr;
  679. struct hif_ul_pipe_info ul_pipe;
  680. struct hif_dl_pipe_info dl_pipe;
  681. };
  682. #ifdef CONFIG_SLUB_DEBUG_ON
  683. #define MSG_FLUSH_NUM 16
  684. #else /* PERF build */
  685. #define MSG_FLUSH_NUM 32
  686. #endif /* SLUB_DEBUG_ON */
  687. struct hif_bus_id;
  688. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  689. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  690. int opcode, void *config, uint32_t config_len);
  691. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  692. void hif_mask_interrupt_call(struct hif_opaque_softc *hif_ctx);
  693. void hif_post_init(struct hif_opaque_softc *hif_ctx, void *hHTC,
  694. struct hif_msg_callbacks *callbacks);
  695. QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx);
  696. void hif_stop(struct hif_opaque_softc *hif_ctx);
  697. void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx);
  698. void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t CmdId, bool start);
  699. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  700. uint8_t cmd_id, bool start);
  701. QDF_STATUS hif_send_head(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  702. uint32_t transferID, uint32_t nbytes,
  703. qdf_nbuf_t wbuf, uint32_t data_attr);
  704. void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  705. int force);
  706. void hif_shut_down_device(struct hif_opaque_softc *hif_ctx);
  707. void hif_get_default_pipe(struct hif_opaque_softc *hif_ctx, uint8_t *ULPipe,
  708. uint8_t *DLPipe);
  709. int hif_map_service_to_pipe(struct hif_opaque_softc *hif_ctx, uint16_t svc_id,
  710. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  711. int *dl_is_polled);
  712. uint16_t
  713. hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  714. void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx);
  715. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  716. void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx, bool sleep_ok,
  717. bool wait_for_it);
  718. int hif_check_fw_reg(struct hif_opaque_softc *hif_ctx);
  719. #ifndef HIF_PCI
  720. static inline int hif_check_soc_status(struct hif_opaque_softc *hif_ctx)
  721. {
  722. return 0;
  723. }
  724. #else
  725. int hif_check_soc_status(struct hif_opaque_softc *hif_ctx);
  726. #endif
  727. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  728. u32 *revision, const char **target_name);
  729. #ifdef RECEIVE_OFFLOAD
  730. /**
  731. * hif_offld_flush_cb_register() - Register the offld flush callback
  732. * @scn: HIF opaque context
  733. * @offld_flush_handler: Flush callback is either ol_flush, incase of rx_thread
  734. * Or GRO/LRO flush when RxThread is not enabled. Called
  735. * with corresponding context for flush.
  736. * Return: None
  737. */
  738. void hif_offld_flush_cb_register(struct hif_opaque_softc *scn,
  739. void (offld_flush_handler)(void *ol_ctx));
  740. /**
  741. * hif_offld_flush_cb_deregister() - deRegister the offld flush callback
  742. * @scn: HIF opaque context
  743. *
  744. * Return: None
  745. */
  746. void hif_offld_flush_cb_deregister(struct hif_opaque_softc *scn);
  747. #endif
  748. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  749. /**
  750. * hif_exec_should_yield() - Check if hif napi context should yield
  751. * @hif_ctx - HIF opaque context
  752. * @grp_id - grp_id of the napi for which check needs to be done
  753. *
  754. * The function uses grp_id to look for NAPI and checks if NAPI needs to
  755. * yield. HIF_EXT_GROUP_MAX_YIELD_DURATION_NS is the duration used for
  756. * yield decision.
  757. *
  758. * Return: true if NAPI needs to yield, else false
  759. */
  760. bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx, uint grp_id);
  761. #else
  762. static inline bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx,
  763. uint grp_id)
  764. {
  765. return false;
  766. }
  767. #endif
  768. void hif_disable_isr(struct hif_opaque_softc *hif_ctx);
  769. void hif_reset_soc(struct hif_opaque_softc *hif_ctx);
  770. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  771. int htc_htt_tx_endpoint);
  772. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
  773. enum qdf_bus_type bus_type,
  774. struct hif_driver_state_callbacks *cbk);
  775. void hif_close(struct hif_opaque_softc *hif_ctx);
  776. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  777. void *bdev, const struct hif_bus_id *bid,
  778. enum qdf_bus_type bus_type,
  779. enum hif_enable_type type);
  780. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  781. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  782. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  783. #ifdef FEATURE_RUNTIME_PM
  784. struct hif_pm_runtime_lock;
  785. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  786. int hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx);
  787. int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx);
  788. void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx);
  789. int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx);
  790. void hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx);
  791. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name);
  792. void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  793. struct hif_pm_runtime_lock *lock);
  794. int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  795. struct hif_pm_runtime_lock *lock);
  796. int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  797. struct hif_pm_runtime_lock *lock);
  798. int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  799. struct hif_pm_runtime_lock *lock, unsigned int delay);
  800. #else
  801. struct hif_pm_runtime_lock {
  802. const char *name;
  803. };
  804. static inline void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx) {}
  805. static inline int
  806. hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx)
  807. { return 0; }
  808. static inline void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx)
  809. {}
  810. static inline int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx)
  811. { return 0; }
  812. static inline int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx)
  813. { return 0; }
  814. static inline void
  815. hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx) {};
  816. static inline int hif_runtime_lock_init(qdf_runtime_lock_t *lock,
  817. const char *name)
  818. { return 0; }
  819. static inline void
  820. hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  821. struct hif_pm_runtime_lock *lock) {}
  822. static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  823. struct hif_pm_runtime_lock *lock)
  824. { return 0; }
  825. static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  826. struct hif_pm_runtime_lock *lock)
  827. { return 0; }
  828. static inline int
  829. hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  830. struct hif_pm_runtime_lock *lock, unsigned int delay)
  831. { return 0; }
  832. #endif
  833. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  834. bool is_packet_log_enabled);
  835. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  836. void hif_vote_link_down(struct hif_opaque_softc *hif_ctx);
  837. void hif_vote_link_up(struct hif_opaque_softc *hif_ctx);
  838. bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx);
  839. #ifdef IPA_OFFLOAD
  840. /**
  841. * hif_get_ipa_hw_type() - get IPA hw type
  842. *
  843. * This API return the IPA hw type.
  844. *
  845. * Return: IPA hw type
  846. */
  847. static inline
  848. enum ipa_hw_type hif_get_ipa_hw_type(void)
  849. {
  850. return ipa_get_hw_type();
  851. }
  852. /**
  853. * hif_get_ipa_present() - get IPA hw status
  854. *
  855. * This API return the IPA hw status.
  856. *
  857. * Return: true if IPA is present or false otherwise
  858. */
  859. static inline
  860. bool hif_get_ipa_present(void)
  861. {
  862. if (ipa_uc_reg_rdyCB(NULL) != -EPERM)
  863. return true;
  864. else
  865. return false;
  866. }
  867. #endif
  868. int hif_bus_resume(struct hif_opaque_softc *hif_ctx);
  869. /**
  870. * hif_bus_ealry_suspend() - stop non wmi tx traffic
  871. * @context: hif context
  872. */
  873. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  874. /**
  875. * hif_bus_late_resume() - resume non wmi traffic
  876. * @context: hif context
  877. */
  878. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  879. int hif_bus_suspend(struct hif_opaque_softc *hif_ctx);
  880. int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx);
  881. int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx);
  882. /**
  883. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  884. * @hif_ctx: an opaque HIF handle to use
  885. *
  886. * As opposed to the standard hif_irq_enable, this function always applies to
  887. * the APPS side kernel interrupt handling.
  888. *
  889. * Return: errno
  890. */
  891. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  892. /**
  893. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  894. * @hif_ctx: an opaque HIF handle to use
  895. *
  896. * As opposed to the standard hif_irq_disable, this function always applies to
  897. * the APPS side kernel interrupt handling.
  898. *
  899. * Return: errno
  900. */
  901. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  902. /**
  903. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  904. * @hif_ctx: an opaque HIF handle to use
  905. *
  906. * As opposed to the standard hif_irq_enable, this function always applies to
  907. * the APPS side kernel interrupt handling.
  908. *
  909. * Return: errno
  910. */
  911. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  912. /**
  913. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  914. * @hif_ctx: an opaque HIF handle to use
  915. *
  916. * As opposed to the standard hif_irq_disable, this function always applies to
  917. * the APPS side kernel interrupt handling.
  918. *
  919. * Return: errno
  920. */
  921. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  922. #ifdef FEATURE_RUNTIME_PM
  923. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  924. void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
  925. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  926. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  927. void hif_process_runtime_suspend_success(struct hif_opaque_softc *hif_ctx);
  928. void hif_process_runtime_suspend_failure(struct hif_opaque_softc *hif_ctx);
  929. void hif_process_runtime_resume_success(struct hif_opaque_softc *hif_ctx);
  930. #endif
  931. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  932. int hif_dump_registers(struct hif_opaque_softc *scn);
  933. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  934. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  935. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  936. u32 *revision, const char **target_name);
  937. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  938. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  939. scn);
  940. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx);
  941. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  942. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  943. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  944. hif_target_status);
  945. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  946. struct hif_config_info *cfg);
  947. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  948. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  949. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  950. int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t
  951. transfer_id, u_int32_t len);
  952. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  953. uint32_t transfer_id, uint32_t download_len);
  954. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  955. void hif_ce_war_disable(void);
  956. void hif_ce_war_enable(void);
  957. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  958. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  959. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  960. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  961. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  962. uint32_t pipe_num);
  963. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  964. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  965. void hif_set_bundle_mode(struct hif_opaque_softc *hif_ctx, bool enabled,
  966. int rx_bundle_cnt);
  967. int hif_bus_reset_resume(struct hif_opaque_softc *hif_ctx);
  968. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  969. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  970. enum hif_exec_type {
  971. HIF_EXEC_NAPI_TYPE,
  972. HIF_EXEC_TASKLET_TYPE,
  973. };
  974. typedef uint32_t (*ext_intr_handler)(void *, uint32_t);
  975. /**
  976. * hif_get_int_ctx_irq_num() - retrieve an irq num for an interrupt context id
  977. * @softc: hif opaque context owning the exec context
  978. * @id: the id of the interrupt context
  979. *
  980. * Return: IRQ number of the first (zero'th) IRQ within the interrupt context ID
  981. * 'id' registered with the OS
  982. */
  983. int32_t hif_get_int_ctx_irq_num(struct hif_opaque_softc *softc,
  984. uint8_t id);
  985. uint32_t hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  986. uint32_t hif_register_ext_group(struct hif_opaque_softc *hif_ctx,
  987. uint32_t numirq, uint32_t irq[], ext_intr_handler handler,
  988. void *cb_ctx, const char *context_name,
  989. enum hif_exec_type type, uint32_t scale);
  990. void hif_deregister_exec_group(struct hif_opaque_softc *hif_ctx,
  991. const char *context_name);
  992. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  993. u_int8_t pipeid,
  994. struct hif_msg_callbacks *callbacks);
  995. /**
  996. * hif_print_napi_stats() - Display HIF NAPI stats
  997. * @hif_ctx - HIF opaque context
  998. *
  999. * Return: None
  1000. */
  1001. void hif_print_napi_stats(struct hif_opaque_softc *hif_ctx);
  1002. /* hif_clear_napi_stats() - function clears the stats of the
  1003. * latency when called.
  1004. * @hif_ctx - the HIF context to assign the callback to
  1005. *
  1006. * Return: None
  1007. */
  1008. void hif_clear_napi_stats(struct hif_opaque_softc *hif_ctx);
  1009. #ifdef __cplusplus
  1010. }
  1011. #endif
  1012. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  1013. /**
  1014. * hif_set_initial_wakeup_cb() - set the initial wakeup event handler function
  1015. * @hif_ctx - the HIF context to assign the callback to
  1016. * @callback - the callback to assign
  1017. * @priv - the private data to pass to the callback when invoked
  1018. *
  1019. * Return: None
  1020. */
  1021. void hif_set_initial_wakeup_cb(struct hif_opaque_softc *hif_ctx,
  1022. void (*callback)(void *),
  1023. void *priv);
  1024. /*
  1025. * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked
  1026. * for defined here
  1027. */
  1028. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  1029. ssize_t hif_dump_desc_trace_buf(struct device *dev,
  1030. struct device_attribute *attr, char *buf);
  1031. ssize_t hif_input_desc_trace_buf_index(struct hif_softc *scn,
  1032. const char *buf, size_t size);
  1033. ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
  1034. const char *buf, size_t size);
  1035. ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
  1036. ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
  1037. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  1038. /**
  1039. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  1040. * @hif: hif context
  1041. * @ce_service_max_yield_time: CE service max yield time to set
  1042. *
  1043. * This API storess CE service max yield time in hif context based
  1044. * on ini value.
  1045. *
  1046. * Return: void
  1047. */
  1048. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  1049. uint32_t ce_service_max_yield_time);
  1050. /**
  1051. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  1052. * @hif: hif context
  1053. *
  1054. * This API returns CE service max yield time.
  1055. *
  1056. * Return: CE service max yield time
  1057. */
  1058. unsigned long long
  1059. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  1060. /**
  1061. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  1062. * @hif: hif context
  1063. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  1064. *
  1065. * This API stores CE service max rx ind flush in hif context based
  1066. * on ini value.
  1067. *
  1068. * Return: void
  1069. */
  1070. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  1071. uint8_t ce_service_max_rx_ind_flush);
  1072. #ifdef OL_ATH_SMART_LOGGING
  1073. /*
  1074. * hif_log_ce_dump() - Copy all the CE DEST ring to buf
  1075. * @scn : HIF handler
  1076. * @buf_cur: Current pointer in ring buffer
  1077. * @buf_init:Start of the ring buffer
  1078. * @buf_sz: Size of the ring buffer
  1079. * @ce: Copy Engine id
  1080. * @skb_sz: Max size of the SKB buffer to be copied
  1081. *
  1082. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  1083. * and buffers pointed by them in to the given buf
  1084. *
  1085. * Return: Current pointer in ring buffer
  1086. */
  1087. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  1088. uint8_t *buf_init, uint32_t buf_sz,
  1089. uint32_t ce, uint32_t skb_sz);
  1090. #endif /* OL_ATH_SMART_LOGGING */
  1091. #endif /* _HIF_H_ */