hif.h 42 KB

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