hal_api.h 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694
  1. /*
  2. * Copyright (c) 2016-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 _HAL_API_H_
  19. #define _HAL_API_H_
  20. #include "qdf_types.h"
  21. #include "qdf_util.h"
  22. #include "qdf_atomic.h"
  23. #include "hal_internal.h"
  24. #define MAX_UNWINDOWED_ADDRESS 0x80000
  25. #if defined(QCA_WIFI_QCA6390) || defined(QCA_WIFI_QCA6490)
  26. #define WINDOW_ENABLE_BIT 0x40000000
  27. #else
  28. #define WINDOW_ENABLE_BIT 0x80000000
  29. #endif
  30. #define WINDOW_REG_ADDRESS 0x310C
  31. #define WINDOW_SHIFT 19
  32. #define WINDOW_VALUE_MASK 0x3F
  33. #define WINDOW_START MAX_UNWINDOWED_ADDRESS
  34. #define WINDOW_RANGE_MASK 0x7FFFF
  35. /*
  36. * BAR + 4K is always accessible, any access outside this
  37. * space requires force wake procedure.
  38. * OFFSET = 4K - 32 bytes = 0x4063
  39. */
  40. #define MAPPED_REF_OFF 0x4063
  41. #define FORCE_WAKE_DELAY_TIMEOUT 50
  42. #define FORCE_WAKE_DELAY_MS 5
  43. /**
  44. * hal_ring_desc - opaque handle for DP ring descriptor
  45. */
  46. struct hal_ring_desc;
  47. typedef struct hal_ring_desc *hal_ring_desc_t;
  48. /**
  49. * hal_link_desc - opaque handle for DP link descriptor
  50. */
  51. struct hal_link_desc;
  52. typedef struct hal_link_desc *hal_link_desc_t;
  53. /**
  54. * hal_rxdma_desc - opaque handle for DP rxdma dst ring descriptor
  55. */
  56. struct hal_rxdma_desc;
  57. typedef struct hal_rxdma_desc *hal_rxdma_desc_t;
  58. #ifdef ENABLE_VERBOSE_DEBUG
  59. static inline void
  60. hal_set_verbose_debug(bool flag)
  61. {
  62. is_hal_verbose_debug_enabled = flag;
  63. }
  64. #endif
  65. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490)
  66. static inline int hal_force_wake_request(struct hal_soc *soc)
  67. {
  68. return 0;
  69. }
  70. static inline int hal_force_wake_release(struct hal_soc *soc)
  71. {
  72. return 0;
  73. }
  74. #else
  75. static inline int hal_force_wake_request(struct hal_soc *soc)
  76. {
  77. uint32_t timeout = 0;
  78. int ret;
  79. ret = pld_force_wake_request(soc->qdf_dev->dev);
  80. if (ret) {
  81. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  82. "%s: Request send failed %d\n", __func__, ret);
  83. return -EINVAL;
  84. }
  85. while (!pld_is_device_awake(soc->qdf_dev->dev) &&
  86. timeout <= FORCE_WAKE_DELAY_TIMEOUT) {
  87. mdelay(FORCE_WAKE_DELAY_MS);
  88. timeout += FORCE_WAKE_DELAY_MS;
  89. }
  90. if (pld_is_device_awake(soc->qdf_dev->dev) == true)
  91. return 0;
  92. else
  93. return -ETIMEDOUT;
  94. }
  95. static inline int hal_force_wake_release(struct hal_soc *soc)
  96. {
  97. return pld_force_wake_release(soc->qdf_dev->dev);
  98. }
  99. #endif
  100. #ifdef PCIE_REG_WINDOW_LOCAL_NO_CACHE
  101. static inline void hal_select_window(struct hal_soc *hal_soc, uint32_t offset)
  102. {
  103. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  104. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  105. WINDOW_ENABLE_BIT | window);
  106. hal_soc->register_window = window;
  107. }
  108. #else
  109. static inline void hal_select_window(struct hal_soc *hal_soc, uint32_t offset)
  110. {
  111. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  112. if (window != hal_soc->register_window) {
  113. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  114. WINDOW_ENABLE_BIT | window);
  115. hal_soc->register_window = window;
  116. }
  117. }
  118. #endif
  119. /**
  120. * note1: WINDOW_RANGE_MASK = (1 << WINDOW_SHIFT) -1
  121. * note2: 1 << WINDOW_SHIFT = MAX_UNWINDOWED_ADDRESS
  122. * note3: WINDOW_VALUE_MASK = big enough that trying to write past that window
  123. * would be a bug
  124. */
  125. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490)
  126. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  127. uint32_t value)
  128. {
  129. if (!hal_soc->use_register_windowing ||
  130. offset < MAX_UNWINDOWED_ADDRESS) {
  131. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  132. } else {
  133. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  134. hal_select_window(hal_soc, offset);
  135. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  136. (offset & WINDOW_RANGE_MASK), value);
  137. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  138. }
  139. }
  140. #else
  141. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  142. uint32_t value)
  143. {
  144. int ret;
  145. if (offset > MAPPED_REF_OFF) {
  146. ret = hal_force_wake_request(hal_soc);
  147. if (ret) {
  148. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  149. "%s: Wake up request failed %d\n",
  150. __func__, ret);
  151. QDF_BUG(0);
  152. return;
  153. }
  154. }
  155. if (!hal_soc->use_register_windowing ||
  156. offset < MAX_UNWINDOWED_ADDRESS) {
  157. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  158. } else {
  159. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  160. hal_select_window(hal_soc, offset);
  161. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  162. (offset & WINDOW_RANGE_MASK), value);
  163. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  164. }
  165. if ((offset > MAPPED_REF_OFF) &&
  166. hal_force_wake_release(hal_soc))
  167. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  168. "%s: Wake up release failed\n", __func__);
  169. }
  170. #endif
  171. /**
  172. * hal_write_address_32_mb - write a value to a register
  173. *
  174. */
  175. static inline void hal_write_address_32_mb(struct hal_soc *hal_soc,
  176. void __iomem *addr, uint32_t value)
  177. {
  178. uint32_t offset;
  179. if (!hal_soc->use_register_windowing)
  180. return qdf_iowrite32(addr, value);
  181. offset = addr - hal_soc->dev_base_addr;
  182. hal_write32_mb(hal_soc, offset, value);
  183. }
  184. #if !defined(QCA_WIFI_QCA6390) && !defined(QCA_WIFI_QCA6490)
  185. static inline uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  186. {
  187. uint32_t ret;
  188. if (!hal_soc->use_register_windowing ||
  189. offset < MAX_UNWINDOWED_ADDRESS) {
  190. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  191. }
  192. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  193. hal_select_window(hal_soc, offset);
  194. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  195. (offset & WINDOW_RANGE_MASK));
  196. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  197. return ret;
  198. }
  199. /**
  200. * hal_read_address_32_mb() - Read 32-bit value from the register
  201. * @soc: soc handle
  202. * @addr: register address to read
  203. *
  204. * Return: 32-bit value
  205. */
  206. static inline uint32_t hal_read_address_32_mb(struct hal_soc *soc,
  207. void __iomem *addr)
  208. {
  209. uint32_t offset;
  210. uint32_t ret;
  211. if (!soc->use_register_windowing)
  212. return qdf_ioread32(addr);
  213. offset = addr - soc->dev_base_addr;
  214. ret = hal_read32_mb(soc, offset);
  215. return ret;
  216. }
  217. #else
  218. static inline uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  219. {
  220. uint32_t ret;
  221. if ((offset > MAPPED_REF_OFF) &&
  222. hal_force_wake_request(hal_soc)) {
  223. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  224. "%s: Wake up request failed\n", __func__);
  225. return -EINVAL;
  226. }
  227. if (!hal_soc->use_register_windowing ||
  228. offset < MAX_UNWINDOWED_ADDRESS) {
  229. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  230. }
  231. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  232. hal_select_window(hal_soc, offset);
  233. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  234. (offset & WINDOW_RANGE_MASK));
  235. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  236. if ((offset > MAPPED_REF_OFF) &&
  237. hal_force_wake_release(hal_soc))
  238. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  239. "%s: Wake up release failed\n", __func__);
  240. return ret;
  241. }
  242. static inline uint32_t hal_read_address_32_mb(struct hal_soc *soc,
  243. void __iomem *addr)
  244. {
  245. uint32_t offset;
  246. uint32_t ret;
  247. if (!soc->use_register_windowing)
  248. return qdf_ioread32(addr);
  249. offset = addr - soc->dev_base_addr;
  250. ret = hal_read32_mb(soc, offset);
  251. return ret;
  252. }
  253. #endif
  254. #include "hif_io32.h"
  255. /**
  256. * hal_attach - Initialize HAL layer
  257. * @hif_handle: Opaque HIF handle
  258. * @qdf_dev: QDF device
  259. *
  260. * Return: Opaque HAL SOC handle
  261. * NULL on failure (if given ring is not available)
  262. *
  263. * This function should be called as part of HIF initialization (for accessing
  264. * copy engines). DP layer will get hal_soc handle using hif_get_hal_handle()
  265. */
  266. void *hal_attach(struct hif_opaque_softc *hif_handle, qdf_device_t qdf_dev);
  267. /**
  268. * hal_detach - Detach HAL layer
  269. * @hal_soc: HAL SOC handle
  270. *
  271. * This function should be called as part of HIF detach
  272. *
  273. */
  274. extern void hal_detach(void *hal_soc);
  275. /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */
  276. enum hal_ring_type {
  277. REO_DST = 0,
  278. REO_EXCEPTION = 1,
  279. REO_REINJECT = 2,
  280. REO_CMD = 3,
  281. REO_STATUS = 4,
  282. TCL_DATA = 5,
  283. TCL_CMD = 6,
  284. TCL_STATUS = 7,
  285. CE_SRC = 8,
  286. CE_DST = 9,
  287. CE_DST_STATUS = 10,
  288. WBM_IDLE_LINK = 11,
  289. SW2WBM_RELEASE = 12,
  290. WBM2SW_RELEASE = 13,
  291. RXDMA_BUF = 14,
  292. RXDMA_DST = 15,
  293. RXDMA_MONITOR_BUF = 16,
  294. RXDMA_MONITOR_STATUS = 17,
  295. RXDMA_MONITOR_DST = 18,
  296. RXDMA_MONITOR_DESC = 19,
  297. DIR_BUF_RX_DMA_SRC = 20,
  298. #ifdef WLAN_FEATURE_CIF_CFR
  299. WIFI_POS_SRC,
  300. #endif
  301. MAX_RING_TYPES
  302. };
  303. #define HAL_SRNG_LMAC_RING 0x80000000
  304. /* SRNG flags passed in hal_srng_params.flags */
  305. #define HAL_SRNG_MSI_SWAP 0x00000008
  306. #define HAL_SRNG_RING_PTR_SWAP 0x00000010
  307. #define HAL_SRNG_DATA_TLV_SWAP 0x00000020
  308. #define HAL_SRNG_LOW_THRES_INTR_ENABLE 0x00010000
  309. #define HAL_SRNG_MSI_INTR 0x00020000
  310. #define HAL_SRNG_CACHED_DESC 0x00040000
  311. #define PN_SIZE_24 0
  312. #define PN_SIZE_48 1
  313. #define PN_SIZE_128 2
  314. /**
  315. * hal_srng_get_entrysize - Returns size of ring entry in bytes. Should be
  316. * used by callers for calculating the size of memory to be allocated before
  317. * calling hal_srng_setup to setup the ring
  318. *
  319. * @hal_soc: Opaque HAL SOC handle
  320. * @ring_type: one of the types from hal_ring_type
  321. *
  322. */
  323. extern uint32_t hal_srng_get_entrysize(void *hal_soc, int ring_type);
  324. /**
  325. * hal_srng_max_entries - Returns maximum possible number of ring entries
  326. * @hal_soc: Opaque HAL SOC handle
  327. * @ring_type: one of the types from hal_ring_type
  328. *
  329. * Return: Maximum number of entries for the given ring_type
  330. */
  331. uint32_t hal_srng_max_entries(void *hal_soc, int ring_type);
  332. /**
  333. * hal_srng_dump - Dump ring status
  334. * @srng: hal srng pointer
  335. */
  336. void hal_srng_dump(struct hal_srng *srng);
  337. /**
  338. * hal_srng_get_dir - Returns the direction of the ring
  339. * @hal_soc: Opaque HAL SOC handle
  340. * @ring_type: one of the types from hal_ring_type
  341. *
  342. * Return: Ring direction
  343. */
  344. enum hal_srng_dir hal_srng_get_dir(void *hal_soc, int ring_type);
  345. /* HAL memory information */
  346. struct hal_mem_info {
  347. /* dev base virutal addr */
  348. void *dev_base_addr;
  349. /* dev base physical addr */
  350. void *dev_base_paddr;
  351. /* Remote virtual pointer memory for HW/FW updates */
  352. void *shadow_rdptr_mem_vaddr;
  353. /* Remote physical pointer memory for HW/FW updates */
  354. void *shadow_rdptr_mem_paddr;
  355. /* Shared memory for ring pointer updates from host to FW */
  356. void *shadow_wrptr_mem_vaddr;
  357. /* Shared physical memory for ring pointer updates from host to FW */
  358. void *shadow_wrptr_mem_paddr;
  359. };
  360. /* SRNG parameters to be passed to hal_srng_setup */
  361. struct hal_srng_params {
  362. /* Physical base address of the ring */
  363. qdf_dma_addr_t ring_base_paddr;
  364. /* Virtual base address of the ring */
  365. void *ring_base_vaddr;
  366. /* Number of entries in ring */
  367. uint32_t num_entries;
  368. /* max transfer length */
  369. uint16_t max_buffer_length;
  370. /* MSI Address */
  371. qdf_dma_addr_t msi_addr;
  372. /* MSI data */
  373. uint32_t msi_data;
  374. /* Interrupt timer threshold – in micro seconds */
  375. uint32_t intr_timer_thres_us;
  376. /* Interrupt batch counter threshold – in number of ring entries */
  377. uint32_t intr_batch_cntr_thres_entries;
  378. /* Low threshold – in number of ring entries
  379. * (valid for src rings only)
  380. */
  381. uint32_t low_threshold;
  382. /* Misc flags */
  383. uint32_t flags;
  384. /* Unique ring id */
  385. uint8_t ring_id;
  386. /* Source or Destination ring */
  387. enum hal_srng_dir ring_dir;
  388. /* Size of ring entry */
  389. uint32_t entry_size;
  390. /* hw register base address */
  391. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  392. };
  393. /* hal_construct_shadow_config() - initialize the shadow registers for dp rings
  394. * @hal_soc: hal handle
  395. *
  396. * Return: QDF_STATUS_OK on success
  397. */
  398. extern QDF_STATUS hal_construct_shadow_config(void *hal_soc);
  399. /* hal_set_one_shadow_config() - add a config for the specified ring
  400. * @hal_soc: hal handle
  401. * @ring_type: ring type
  402. * @ring_num: ring num
  403. *
  404. * The ring type and ring num uniquely specify the ring. After this call,
  405. * the hp/tp will be added as the next entry int the shadow register
  406. * configuration table. The hal code will use the shadow register address
  407. * in place of the hp/tp address.
  408. *
  409. * This function is exposed, so that the CE module can skip configuring shadow
  410. * registers for unused ring and rings assigned to the firmware.
  411. *
  412. * Return: QDF_STATUS_OK on success
  413. */
  414. extern QDF_STATUS hal_set_one_shadow_config(void *hal_soc, int ring_type,
  415. int ring_num);
  416. /**
  417. * hal_get_shadow_config() - retrieve the config table
  418. * @hal_soc: hal handle
  419. * @shadow_config: will point to the table after
  420. * @num_shadow_registers_configured: will contain the number of valid entries
  421. */
  422. extern void hal_get_shadow_config(void *hal_soc,
  423. struct pld_shadow_reg_v2_cfg **shadow_config,
  424. int *num_shadow_registers_configured);
  425. /**
  426. * hal_srng_setup - Initialize HW SRNG ring.
  427. *
  428. * @hal_soc: Opaque HAL SOC handle
  429. * @ring_type: one of the types from hal_ring_type
  430. * @ring_num: Ring number if there are multiple rings of
  431. * same type (staring from 0)
  432. * @mac_id: valid MAC Id should be passed if ring type is one of lmac rings
  433. * @ring_params: SRNG ring params in hal_srng_params structure.
  434. * Callers are expected to allocate contiguous ring memory of size
  435. * 'num_entries * entry_size' bytes and pass the physical and virtual base
  436. * addresses through 'ring_base_paddr' and 'ring_base_vaddr' in hal_srng_params
  437. * structure. Ring base address should be 8 byte aligned and size of each ring
  438. * entry should be queried using the API hal_srng_get_entrysize
  439. *
  440. * Return: Opaque pointer to ring on success
  441. * NULL on failure (if given ring is not available)
  442. */
  443. extern void *hal_srng_setup(void *hal_soc, int ring_type, int ring_num,
  444. int mac_id, struct hal_srng_params *ring_params);
  445. /* Remapping ids of REO rings */
  446. #define REO_REMAP_TCL 0
  447. #define REO_REMAP_SW1 1
  448. #define REO_REMAP_SW2 2
  449. #define REO_REMAP_SW3 3
  450. #define REO_REMAP_SW4 4
  451. #define REO_REMAP_RELEASE 5
  452. #define REO_REMAP_FW 6
  453. #define REO_REMAP_UNUSED 7
  454. /*
  455. * currently this macro only works for IX0 since all the rings we are remapping
  456. * can be remapped from HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0
  457. */
  458. #define HAL_REO_REMAP_VAL(_ORIGINAL_DEST, _NEW_DEST) \
  459. HAL_REO_REMAP_VAL_(_ORIGINAL_DEST, _NEW_DEST)
  460. /* allow the destination macros to be expanded */
  461. #define HAL_REO_REMAP_VAL_(_ORIGINAL_DEST, _NEW_DEST) \
  462. (_NEW_DEST << \
  463. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0_DEST_RING_MAPPING_ ## \
  464. _ORIGINAL_DEST ## _SHFT))
  465. /**
  466. * hal_reo_read_write_ctrl_ix - Read or write REO_DESTINATION_RING_CTRL_IX
  467. * @hal_soc_hdl: HAL SOC handle
  468. * @read: boolean value to indicate if read or write
  469. * @ix0: pointer to store IX0 reg value
  470. * @ix1: pointer to store IX1 reg value
  471. * @ix2: pointer to store IX2 reg value
  472. * @ix3: pointer to store IX3 reg value
  473. */
  474. void hal_reo_read_write_ctrl_ix(hal_soc_handle_t hal_soc_hdl, bool read,
  475. uint32_t *ix0, uint32_t *ix1,
  476. uint32_t *ix2, uint32_t *ix3);
  477. /**
  478. * hal_srng_set_hp_paddr() - Set physical address to dest SRNG head pointer
  479. * @sring: sring pointer
  480. * @paddr: physical address
  481. */
  482. extern void hal_srng_dst_set_hp_paddr(struct hal_srng *sring, uint64_t paddr);
  483. /**
  484. * hal_srng_dst_init_hp() - Initilaize head pointer with cached head pointer
  485. * @srng: sring pointer
  486. * @vaddr: virtual address
  487. */
  488. extern void hal_srng_dst_init_hp(struct hal_srng *srng, uint32_t *vaddr);
  489. /**
  490. * hal_srng_cleanup - Deinitialize HW SRNG ring.
  491. * @hal_soc: Opaque HAL SOC handle
  492. * @hal_srng: Opaque HAL SRNG pointer
  493. */
  494. void hal_srng_cleanup(void *hal_soc, hal_ring_handle_t hal_ring_hdl);
  495. static inline bool hal_srng_initialized(hal_ring_handle_t hal_ring_hdl)
  496. {
  497. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  498. return !!srng->initialized;
  499. }
  500. /**
  501. * hal_srng_dst_peek - Check if there are any entries in the ring (peek)
  502. * @hal_soc: Opaque HAL SOC handle
  503. * @hal_ring_hdl: Destination ring pointer
  504. *
  505. * Caller takes responsibility for any locking needs.
  506. *
  507. * Return: Opaque pointer for next ring entry; NULL on failire
  508. */
  509. static inline
  510. void *hal_srng_dst_peek(hal_soc_handle_t hal_soc_hdl,
  511. hal_ring_handle_t hal_ring_hdl)
  512. {
  513. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  514. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp)
  515. return (void *)(&srng->ring_base_vaddr[srng->u.dst_ring.tp]);
  516. return NULL;
  517. }
  518. /**
  519. * hal_srng_access_start_unlocked - Start ring access (unlocked). Should use
  520. * hal_srng_access_start if locked access is required
  521. *
  522. * @hal_soc: Opaque HAL SOC handle
  523. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  524. *
  525. * Return: 0 on success; error on failire
  526. */
  527. static inline int
  528. hal_srng_access_start_unlocked(hal_soc_handle_t hal_soc_hdl,
  529. hal_ring_handle_t hal_ring_hdl)
  530. {
  531. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  532. struct hal_soc *soc = (struct hal_soc *)hal_soc_hdl;
  533. uint32_t *desc;
  534. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  535. srng->u.src_ring.cached_tp =
  536. *(volatile uint32_t *)(srng->u.src_ring.tp_addr);
  537. else {
  538. srng->u.dst_ring.cached_hp =
  539. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  540. if (srng->flags & HAL_SRNG_CACHED_DESC) {
  541. desc = hal_srng_dst_peek(hal_soc_hdl, hal_ring_hdl);
  542. if (qdf_likely(desc)) {
  543. qdf_mem_dma_cache_sync(soc->qdf_dev,
  544. qdf_mem_virt_to_phys
  545. (desc),
  546. QDF_DMA_FROM_DEVICE,
  547. (srng->entry_size *
  548. sizeof(uint32_t)));
  549. qdf_prefetch(desc);
  550. }
  551. }
  552. }
  553. return 0;
  554. }
  555. /**
  556. * hal_srng_access_start - Start (locked) ring access
  557. *
  558. * @hal_soc: Opaque HAL SOC handle
  559. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  560. *
  561. * Return: 0 on success; error on failire
  562. */
  563. static inline int hal_srng_access_start(hal_soc_handle_t hal_soc_hdl,
  564. hal_ring_handle_t hal_ring_hdl)
  565. {
  566. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  567. if (qdf_unlikely(!hal_ring_hdl)) {
  568. qdf_print("Error: Invalid hal_ring\n");
  569. return -EINVAL;
  570. }
  571. SRNG_LOCK(&(srng->lock));
  572. return hal_srng_access_start_unlocked(hal_soc_hdl, hal_ring_hdl);
  573. }
  574. /**
  575. * hal_srng_dst_get_next - Get next entry from a destination ring and move
  576. * cached tail pointer
  577. *
  578. * @hal_soc: Opaque HAL SOC handle
  579. * @hal_ring_hdl: Destination ring pointer
  580. *
  581. * Return: Opaque pointer for next ring entry; NULL on failire
  582. */
  583. static inline
  584. void *hal_srng_dst_get_next(void *hal_soc,
  585. hal_ring_handle_t hal_ring_hdl)
  586. {
  587. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  588. struct hal_soc *soc = (struct hal_soc *)hal_soc;
  589. uint32_t *desc;
  590. uint32_t *desc_next;
  591. uint32_t tp;
  592. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp) {
  593. desc = &(srng->ring_base_vaddr[srng->u.dst_ring.tp]);
  594. /* TODO: Using % is expensive, but we have to do this since
  595. * size of some SRNG rings is not power of 2 (due to descriptor
  596. * sizes). Need to create separate API for rings used
  597. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  598. * SW2RXDMA and CE rings)
  599. */
  600. srng->u.dst_ring.tp = (srng->u.dst_ring.tp + srng->entry_size) %
  601. srng->ring_size;
  602. if (srng->flags & HAL_SRNG_CACHED_DESC) {
  603. tp = srng->u.dst_ring.tp;
  604. desc_next = &srng->ring_base_vaddr[tp];
  605. qdf_mem_dma_cache_sync(soc->qdf_dev,
  606. qdf_mem_virt_to_phys(desc_next),
  607. QDF_DMA_FROM_DEVICE,
  608. (srng->entry_size *
  609. sizeof(uint32_t)));
  610. qdf_prefetch(desc_next);
  611. }
  612. return (void *)desc;
  613. }
  614. return NULL;
  615. }
  616. /**
  617. * hal_srng_dst_get_next_hp - Get next entry from a destination ring and move
  618. * cached head pointer
  619. *
  620. * @hal_soc: Opaque HAL SOC handle
  621. * @hal_ring_hdl: Destination ring pointer
  622. *
  623. * Return: Opaque pointer for next ring entry; NULL on failire
  624. */
  625. static inline void *
  626. hal_srng_dst_get_next_hp(hal_soc_handle_t hal_soc_hdl,
  627. hal_ring_handle_t hal_ring_hdl)
  628. {
  629. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  630. uint32_t *desc;
  631. /* TODO: Using % is expensive, but we have to do this since
  632. * size of some SRNG rings is not power of 2 (due to descriptor
  633. * sizes). Need to create separate API for rings used
  634. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  635. * SW2RXDMA and CE rings)
  636. */
  637. uint32_t next_hp = (srng->u.dst_ring.cached_hp + srng->entry_size) %
  638. srng->ring_size;
  639. if (next_hp != srng->u.dst_ring.tp) {
  640. desc = &(srng->ring_base_vaddr[srng->u.dst_ring.cached_hp]);
  641. srng->u.dst_ring.cached_hp = next_hp;
  642. return (void *)desc;
  643. }
  644. return NULL;
  645. }
  646. /**
  647. * hal_srng_dst_peek_sync - Check if there are any entries in the ring (peek)
  648. * @hal_soc: Opaque HAL SOC handle
  649. * @hal_ring_hdl: Destination ring pointer
  650. *
  651. * Sync cached head pointer with HW.
  652. * Caller takes responsibility for any locking needs.
  653. *
  654. * Return: Opaque pointer for next ring entry; NULL on failire
  655. */
  656. static inline
  657. void *hal_srng_dst_peek_sync(hal_soc_handle_t hal_soc_hdl,
  658. hal_ring_handle_t hal_ring_hdl)
  659. {
  660. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  661. srng->u.dst_ring.cached_hp =
  662. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  663. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp)
  664. return (void *)(&(srng->ring_base_vaddr[srng->u.dst_ring.tp]));
  665. return NULL;
  666. }
  667. /**
  668. * hal_srng_dst_peek_sync_locked - Peek for any entries in the ring
  669. * @hal_soc: Opaque HAL SOC handle
  670. * @hal_ring_hdl: Destination ring pointer
  671. *
  672. * Sync cached head pointer with HW.
  673. * This function takes up SRNG_LOCK. Should not be called with SRNG lock held.
  674. *
  675. * Return: Opaque pointer for next ring entry; NULL on failire
  676. */
  677. static inline
  678. void *hal_srng_dst_peek_sync_locked(hal_soc_handle_t hal_soc_hdl,
  679. hal_ring_handle_t hal_ring_hdl)
  680. {
  681. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  682. void *ring_desc_ptr = NULL;
  683. if (qdf_unlikely(!hal_ring_hdl)) {
  684. qdf_print("Error: Invalid hal_ring\n");
  685. return NULL;
  686. }
  687. SRNG_LOCK(&srng->lock);
  688. ring_desc_ptr = hal_srng_dst_peek_sync(hal_soc_hdl, hal_ring_hdl);
  689. SRNG_UNLOCK(&srng->lock);
  690. return ring_desc_ptr;
  691. }
  692. /**
  693. * hal_srng_dst_num_valid - Returns number of valid entries (to be processed
  694. * by SW) in destination ring
  695. *
  696. * @hal_soc: Opaque HAL SOC handle
  697. * @hal_ring_hdl: Destination ring pointer
  698. * @sync_hw_ptr: Sync cached head pointer with HW
  699. *
  700. */
  701. static inline
  702. uint32_t hal_srng_dst_num_valid(void *hal_soc,
  703. hal_ring_handle_t hal_ring_hdl,
  704. int sync_hw_ptr)
  705. {
  706. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  707. uint32_t hp;
  708. uint32_t tp = srng->u.dst_ring.tp;
  709. if (sync_hw_ptr) {
  710. hp = *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  711. srng->u.dst_ring.cached_hp = hp;
  712. } else {
  713. hp = srng->u.dst_ring.cached_hp;
  714. }
  715. if (hp >= tp)
  716. return (hp - tp) / srng->entry_size;
  717. else
  718. return (srng->ring_size - tp + hp) / srng->entry_size;
  719. }
  720. /**
  721. * hal_srng_dst_num_valid_locked - Returns num valid entries to be processed
  722. *
  723. * @hal_soc: Opaque HAL SOC handle
  724. * @hal_ring_hdl: Destination ring pointer
  725. * @sync_hw_ptr: Sync cached head pointer with HW
  726. *
  727. * Returns number of valid entries to be processed by the host driver. The
  728. * function takes up SRNG lock.
  729. *
  730. * Return: Number of valid destination entries
  731. */
  732. static inline uint32_t
  733. hal_srng_dst_num_valid_locked(hal_soc_handle_t hal_soc,
  734. hal_ring_handle_t hal_ring_hdl,
  735. int sync_hw_ptr)
  736. {
  737. uint32_t num_valid;
  738. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  739. SRNG_LOCK(&srng->lock);
  740. num_valid = hal_srng_dst_num_valid(hal_soc, hal_ring_hdl, sync_hw_ptr);
  741. SRNG_UNLOCK(&srng->lock);
  742. return num_valid;
  743. }
  744. /**
  745. * hal_srng_src_reap_next - Reap next entry from a source ring and move reap
  746. * pointer. This can be used to release any buffers associated with completed
  747. * ring entries. Note that this should not be used for posting new descriptor
  748. * entries. Posting of new entries should be done only using
  749. * hal_srng_src_get_next_reaped when this function is used for reaping.
  750. *
  751. * @hal_soc: Opaque HAL SOC handle
  752. * @hal_ring_hdl: Source ring pointer
  753. *
  754. * Return: Opaque pointer for next ring entry; NULL on failire
  755. */
  756. static inline void *
  757. hal_srng_src_reap_next(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  758. {
  759. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  760. uint32_t *desc;
  761. /* TODO: Using % is expensive, but we have to do this since
  762. * size of some SRNG rings is not power of 2 (due to descriptor
  763. * sizes). Need to create separate API for rings used
  764. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  765. * SW2RXDMA and CE rings)
  766. */
  767. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  768. srng->ring_size;
  769. if (next_reap_hp != srng->u.src_ring.cached_tp) {
  770. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  771. srng->u.src_ring.reap_hp = next_reap_hp;
  772. return (void *)desc;
  773. }
  774. return NULL;
  775. }
  776. /**
  777. * hal_srng_src_get_next_reaped - Get next entry from a source ring that is
  778. * already reaped using hal_srng_src_reap_next, for posting new entries to
  779. * the ring
  780. *
  781. * @hal_soc: Opaque HAL SOC handle
  782. * @hal_ring_hdl: Source ring pointer
  783. *
  784. * Return: Opaque pointer for next (reaped) source ring entry; NULL on failire
  785. */
  786. static inline void *
  787. hal_srng_src_get_next_reaped(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  788. {
  789. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  790. uint32_t *desc;
  791. if (srng->u.src_ring.hp != srng->u.src_ring.reap_hp) {
  792. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  793. srng->u.src_ring.hp = (srng->u.src_ring.hp + srng->entry_size) %
  794. srng->ring_size;
  795. return (void *)desc;
  796. }
  797. return NULL;
  798. }
  799. /**
  800. * hal_srng_src_pending_reap_next - Reap next entry from a source ring and
  801. * move reap pointer. This API is used in detach path to release any buffers
  802. * associated with ring entries which are pending reap.
  803. *
  804. * @hal_soc: Opaque HAL SOC handle
  805. * @hal_ring_hdl: Source ring pointer
  806. *
  807. * Return: Opaque pointer for next ring entry; NULL on failire
  808. */
  809. static inline void *
  810. hal_srng_src_pending_reap_next(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  811. {
  812. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  813. uint32_t *desc;
  814. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  815. srng->ring_size;
  816. if (next_reap_hp != srng->u.src_ring.hp) {
  817. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  818. srng->u.src_ring.reap_hp = next_reap_hp;
  819. return (void *)desc;
  820. }
  821. return NULL;
  822. }
  823. /**
  824. * hal_srng_src_done_val -
  825. *
  826. * @hal_soc: Opaque HAL SOC handle
  827. * @hal_ring_hdl: Source ring pointer
  828. *
  829. * Return: Opaque pointer for next ring entry; NULL on failire
  830. */
  831. static inline uint32_t
  832. hal_srng_src_done_val(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  833. {
  834. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  835. /* TODO: Using % is expensive, but we have to do this since
  836. * size of some SRNG rings is not power of 2 (due to descriptor
  837. * sizes). Need to create separate API for rings used
  838. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  839. * SW2RXDMA and CE rings)
  840. */
  841. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  842. srng->ring_size;
  843. if (next_reap_hp == srng->u.src_ring.cached_tp)
  844. return 0;
  845. if (srng->u.src_ring.cached_tp > next_reap_hp)
  846. return (srng->u.src_ring.cached_tp - next_reap_hp) /
  847. srng->entry_size;
  848. else
  849. return ((srng->ring_size - next_reap_hp) +
  850. srng->u.src_ring.cached_tp) / srng->entry_size;
  851. }
  852. /**
  853. * hal_get_entrysize_from_srng() - Retrieve ring entry size
  854. * @hal_ring_hdl: Source ring pointer
  855. *
  856. * Return: uint8_t
  857. */
  858. static inline
  859. uint8_t hal_get_entrysize_from_srng(hal_ring_handle_t hal_ring_hdl)
  860. {
  861. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  862. return srng->entry_size;
  863. }
  864. /**
  865. * hal_get_sw_hptp - Get SW head and tail pointer location for any ring
  866. * @hal_soc: Opaque HAL SOC handle
  867. * @hal_ring_hdl: Source ring pointer
  868. * @tailp: Tail Pointer
  869. * @headp: Head Pointer
  870. *
  871. * Return: Update tail pointer and head pointer in arguments.
  872. */
  873. static inline
  874. void hal_get_sw_hptp(void *hal_soc, hal_ring_handle_t hal_ring_hdl,
  875. uint32_t *tailp, uint32_t *headp)
  876. {
  877. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  878. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  879. *headp = srng->u.src_ring.hp;
  880. *tailp = *srng->u.src_ring.tp_addr;
  881. } else {
  882. *tailp = srng->u.dst_ring.tp;
  883. *headp = *srng->u.dst_ring.hp_addr;
  884. }
  885. }
  886. /**
  887. * hal_srng_src_get_next - Get next entry from a source ring and move cached tail pointer
  888. *
  889. * @hal_soc: Opaque HAL SOC handle
  890. * @hal_ring_hdl: Source ring pointer
  891. *
  892. * Return: Opaque pointer for next ring entry; NULL on failire
  893. */
  894. static inline
  895. void *hal_srng_src_get_next(void *hal_soc,
  896. hal_ring_handle_t hal_ring_hdl)
  897. {
  898. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  899. uint32_t *desc;
  900. /* TODO: Using % is expensive, but we have to do this since
  901. * size of some SRNG rings is not power of 2 (due to descriptor
  902. * sizes). Need to create separate API for rings used
  903. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  904. * SW2RXDMA and CE rings)
  905. */
  906. uint32_t next_hp = (srng->u.src_ring.hp + srng->entry_size) %
  907. srng->ring_size;
  908. if (next_hp != srng->u.src_ring.cached_tp) {
  909. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  910. srng->u.src_ring.hp = next_hp;
  911. /* TODO: Since reap function is not used by all rings, we can
  912. * remove the following update of reap_hp in this function
  913. * if we can ensure that only hal_srng_src_get_next_reaped
  914. * is used for the rings requiring reap functionality
  915. */
  916. srng->u.src_ring.reap_hp = next_hp;
  917. return (void *)desc;
  918. }
  919. return NULL;
  920. }
  921. /**
  922. * hal_srng_src_peek - Get next entry from a ring without moving head pointer.
  923. * hal_srng_src_get_next should be called subsequently to move the head pointer
  924. *
  925. * @hal_soc: Opaque HAL SOC handle
  926. * @hal_ring_hdl: Source ring pointer
  927. *
  928. * Return: Opaque pointer for next ring entry; NULL on failire
  929. */
  930. static inline
  931. void *hal_srng_src_peek(hal_soc_handle_t hal_soc_hdl,
  932. hal_ring_handle_t hal_ring_hdl)
  933. {
  934. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  935. uint32_t *desc;
  936. /* TODO: Using % is expensive, but we have to do this since
  937. * size of some SRNG rings is not power of 2 (due to descriptor
  938. * sizes). Need to create separate API for rings used
  939. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  940. * SW2RXDMA and CE rings)
  941. */
  942. if (((srng->u.src_ring.hp + srng->entry_size) %
  943. srng->ring_size) != srng->u.src_ring.cached_tp) {
  944. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  945. return (void *)desc;
  946. }
  947. return NULL;
  948. }
  949. /**
  950. * hal_srng_src_num_avail - Returns number of available entries in src ring
  951. *
  952. * @hal_soc: Opaque HAL SOC handle
  953. * @hal_ring_hdl: Source ring pointer
  954. * @sync_hw_ptr: Sync cached tail pointer with HW
  955. *
  956. */
  957. static inline uint32_t
  958. hal_srng_src_num_avail(void *hal_soc,
  959. hal_ring_handle_t hal_ring_hdl, int sync_hw_ptr)
  960. {
  961. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  962. uint32_t tp;
  963. uint32_t hp = srng->u.src_ring.hp;
  964. if (sync_hw_ptr) {
  965. tp = *(srng->u.src_ring.tp_addr);
  966. srng->u.src_ring.cached_tp = tp;
  967. } else {
  968. tp = srng->u.src_ring.cached_tp;
  969. }
  970. if (tp > hp)
  971. return ((tp - hp) / srng->entry_size) - 1;
  972. else
  973. return ((srng->ring_size - hp + tp) / srng->entry_size) - 1;
  974. }
  975. /**
  976. * hal_srng_access_end_unlocked - End ring access (unlocked) - update cached
  977. * ring head/tail pointers to HW.
  978. * This should be used only if hal_srng_access_start_unlocked to start ring
  979. * access
  980. *
  981. * @hal_soc: Opaque HAL SOC handle
  982. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  983. *
  984. * Return: 0 on success; error on failire
  985. */
  986. static inline void
  987. hal_srng_access_end_unlocked(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  988. {
  989. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  990. /* TODO: See if we need a write memory barrier here */
  991. if (srng->flags & HAL_SRNG_LMAC_RING) {
  992. /* For LMAC rings, ring pointer updates are done through FW and
  993. * hence written to a shared memory location that is read by FW
  994. */
  995. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  996. *(srng->u.src_ring.hp_addr) = srng->u.src_ring.hp;
  997. } else {
  998. *(srng->u.dst_ring.tp_addr) = srng->u.dst_ring.tp;
  999. }
  1000. } else {
  1001. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  1002. hal_write_address_32_mb(hal_soc,
  1003. srng->u.src_ring.hp_addr,
  1004. srng->u.src_ring.hp);
  1005. else
  1006. hal_write_address_32_mb(hal_soc,
  1007. srng->u.dst_ring.tp_addr,
  1008. srng->u.dst_ring.tp);
  1009. }
  1010. }
  1011. /**
  1012. * hal_srng_access_end - Unlock ring access and update cached ring head/tail
  1013. * pointers to HW
  1014. * This should be used only if hal_srng_access_start to start ring access
  1015. *
  1016. * @hal_soc: Opaque HAL SOC handle
  1017. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1018. *
  1019. * Return: 0 on success; error on failire
  1020. */
  1021. static inline void
  1022. hal_srng_access_end(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1023. {
  1024. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1025. if (qdf_unlikely(!hal_ring_hdl)) {
  1026. qdf_print("Error: Invalid hal_ring\n");
  1027. return;
  1028. }
  1029. hal_srng_access_end_unlocked(hal_soc, hal_ring_hdl);
  1030. SRNG_UNLOCK(&(srng->lock));
  1031. }
  1032. /**
  1033. * hal_srng_access_end_reap - Unlock ring access
  1034. * This should be used only if hal_srng_access_start to start ring access
  1035. * and should be used only while reaping SRC ring completions
  1036. *
  1037. * @hal_soc: Opaque HAL SOC handle
  1038. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1039. *
  1040. * Return: 0 on success; error on failire
  1041. */
  1042. static inline void
  1043. hal_srng_access_end_reap(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1044. {
  1045. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1046. SRNG_UNLOCK(&(srng->lock));
  1047. }
  1048. /* TODO: Check if the following definitions is available in HW headers */
  1049. #define WBM_IDLE_SCATTER_BUF_SIZE 32704
  1050. #define NUM_MPDUS_PER_LINK_DESC 6
  1051. #define NUM_MSDUS_PER_LINK_DESC 7
  1052. #define REO_QUEUE_DESC_ALIGN 128
  1053. #define LINK_DESC_ALIGN 128
  1054. #define ADDRESS_MATCH_TAG_VAL 0x5
  1055. /* Number of mpdu link pointers is 9 in case of TX_MPDU_QUEUE_HEAD and 14 in
  1056. * of TX_MPDU_QUEUE_EXT. We are defining a common average count here
  1057. */
  1058. #define NUM_MPDU_LINKS_PER_QUEUE_DESC 12
  1059. /* TODO: Check with HW team on the scatter buffer size supported. As per WBM
  1060. * MLD, scatter_buffer_size in IDLE_LIST_CONTROL register is 9 bits and size
  1061. * should be specified in 16 word units. But the number of bits defined for
  1062. * this field in HW header files is 5.
  1063. */
  1064. #define WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE 8
  1065. /**
  1066. * hal_idle_list_scatter_buf_size - Get the size of each scatter buffer
  1067. * in an idle list
  1068. *
  1069. * @hal_soc: Opaque HAL SOC handle
  1070. *
  1071. */
  1072. static inline
  1073. uint32_t hal_idle_list_scatter_buf_size(hal_soc_handle_t hal_soc_hdl)
  1074. {
  1075. return WBM_IDLE_SCATTER_BUF_SIZE;
  1076. }
  1077. /**
  1078. * hal_get_link_desc_size - Get the size of each link descriptor
  1079. *
  1080. * @hal_soc: Opaque HAL SOC handle
  1081. *
  1082. */
  1083. static inline uint32_t hal_get_link_desc_size(hal_soc_handle_t hal_soc_hdl)
  1084. {
  1085. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1086. if (!hal_soc || !hal_soc->ops) {
  1087. qdf_print("Error: Invalid ops\n");
  1088. QDF_BUG(0);
  1089. return -EINVAL;
  1090. }
  1091. if (!hal_soc->ops->hal_get_link_desc_size) {
  1092. qdf_print("Error: Invalid function pointer\n");
  1093. QDF_BUG(0);
  1094. return -EINVAL;
  1095. }
  1096. return hal_soc->ops->hal_get_link_desc_size();
  1097. }
  1098. /**
  1099. * hal_get_link_desc_align - Get the required start address alignment for
  1100. * link descriptors
  1101. *
  1102. * @hal_soc: Opaque HAL SOC handle
  1103. *
  1104. */
  1105. static inline
  1106. uint32_t hal_get_link_desc_align(hal_soc_handle_t hal_soc_hdl)
  1107. {
  1108. return LINK_DESC_ALIGN;
  1109. }
  1110. /**
  1111. * hal_num_mpdus_per_link_desc - Get number of mpdus each link desc can hold
  1112. *
  1113. * @hal_soc: Opaque HAL SOC handle
  1114. *
  1115. */
  1116. static inline
  1117. uint32_t hal_num_mpdus_per_link_desc(hal_soc_handle_t hal_soc_hdl)
  1118. {
  1119. return NUM_MPDUS_PER_LINK_DESC;
  1120. }
  1121. /**
  1122. * hal_num_msdus_per_link_desc - Get number of msdus each link desc can hold
  1123. *
  1124. * @hal_soc: Opaque HAL SOC handle
  1125. *
  1126. */
  1127. static inline
  1128. uint32_t hal_num_msdus_per_link_desc(hal_soc_handle_t hal_soc_hdl)
  1129. {
  1130. return NUM_MSDUS_PER_LINK_DESC;
  1131. }
  1132. /**
  1133. * hal_num_mpdu_links_per_queue_desc - Get number of mpdu links each queue
  1134. * descriptor can hold
  1135. *
  1136. * @hal_soc: Opaque HAL SOC handle
  1137. *
  1138. */
  1139. static inline
  1140. uint32_t hal_num_mpdu_links_per_queue_desc(hal_soc_handle_t hal_soc_hdl)
  1141. {
  1142. return NUM_MPDU_LINKS_PER_QUEUE_DESC;
  1143. }
  1144. /**
  1145. * hal_idle_list_scatter_buf_num_entries - Get the number of link desc entries
  1146. * that the given buffer size
  1147. *
  1148. * @hal_soc: Opaque HAL SOC handle
  1149. * @scatter_buf_size: Size of scatter buffer
  1150. *
  1151. */
  1152. static inline
  1153. uint32_t hal_idle_scatter_buf_num_entries(hal_soc_handle_t hal_soc_hdl,
  1154. uint32_t scatter_buf_size)
  1155. {
  1156. return (scatter_buf_size - WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE) /
  1157. hal_srng_get_entrysize(hal_soc_hdl, WBM_IDLE_LINK);
  1158. }
  1159. /**
  1160. * hal_idle_list_num_scatter_bufs - Get the number of sctater buffer
  1161. * each given buffer size
  1162. *
  1163. * @hal_soc: Opaque HAL SOC handle
  1164. * @total_mem: size of memory to be scattered
  1165. * @scatter_buf_size: Size of scatter buffer
  1166. *
  1167. */
  1168. static inline
  1169. uint32_t hal_idle_list_num_scatter_bufs(hal_soc_handle_t hal_soc_hdl,
  1170. uint32_t total_mem,
  1171. uint32_t scatter_buf_size)
  1172. {
  1173. uint8_t rem = (total_mem % (scatter_buf_size -
  1174. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) ? 1 : 0;
  1175. uint32_t num_scatter_bufs = (total_mem / (scatter_buf_size -
  1176. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) + rem;
  1177. return num_scatter_bufs;
  1178. }
  1179. enum hal_pn_type {
  1180. HAL_PN_NONE,
  1181. HAL_PN_WPA,
  1182. HAL_PN_WAPI_EVEN,
  1183. HAL_PN_WAPI_UNEVEN,
  1184. };
  1185. #define HAL_RX_MAX_BA_WINDOW 256
  1186. /**
  1187. * hal_get_reo_qdesc_align - Get start address alignment for reo
  1188. * queue descriptors
  1189. *
  1190. * @hal_soc: Opaque HAL SOC handle
  1191. *
  1192. */
  1193. static inline
  1194. uint32_t hal_get_reo_qdesc_align(hal_soc_handle_t hal_soc_hdl)
  1195. {
  1196. return REO_QUEUE_DESC_ALIGN;
  1197. }
  1198. /**
  1199. * hal_reo_qdesc_setup - Setup HW REO queue descriptor
  1200. *
  1201. * @hal_soc: Opaque HAL SOC handle
  1202. * @ba_window_size: BlockAck window size
  1203. * @start_seq: Starting sequence number
  1204. * @hw_qdesc_vaddr: Virtual address of REO queue descriptor memory
  1205. * @hw_qdesc_paddr: Physical address of REO queue descriptor memory
  1206. * @pn_type: PN type (one of the types defined in 'enum hal_pn_type')
  1207. *
  1208. */
  1209. void hal_reo_qdesc_setup(hal_soc_handle_t hal_soc_hdl,
  1210. int tid, uint32_t ba_window_size,
  1211. uint32_t start_seq, void *hw_qdesc_vaddr,
  1212. qdf_dma_addr_t hw_qdesc_paddr,
  1213. int pn_type);
  1214. /**
  1215. * hal_srng_get_hp_addr - Get head pointer physical address
  1216. *
  1217. * @hal_soc: Opaque HAL SOC handle
  1218. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1219. *
  1220. */
  1221. static inline qdf_dma_addr_t
  1222. hal_srng_get_hp_addr(void *hal_soc,
  1223. hal_ring_handle_t hal_ring_hdl)
  1224. {
  1225. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1226. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  1227. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1228. return hal->shadow_wrptr_mem_paddr +
  1229. ((unsigned long)(srng->u.src_ring.hp_addr) -
  1230. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  1231. } else {
  1232. return hal->shadow_rdptr_mem_paddr +
  1233. ((unsigned long)(srng->u.dst_ring.hp_addr) -
  1234. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  1235. }
  1236. }
  1237. /**
  1238. * hal_srng_get_tp_addr - Get tail pointer physical address
  1239. *
  1240. * @hal_soc: Opaque HAL SOC handle
  1241. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1242. *
  1243. */
  1244. static inline qdf_dma_addr_t
  1245. hal_srng_get_tp_addr(void *hal_soc, hal_ring_handle_t hal_ring_hdl)
  1246. {
  1247. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1248. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  1249. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1250. return hal->shadow_rdptr_mem_paddr +
  1251. ((unsigned long)(srng->u.src_ring.tp_addr) -
  1252. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  1253. } else {
  1254. return hal->shadow_wrptr_mem_paddr +
  1255. ((unsigned long)(srng->u.dst_ring.tp_addr) -
  1256. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  1257. }
  1258. }
  1259. /**
  1260. * hal_srng_get_num_entries - Get total entries in the HAL Srng
  1261. *
  1262. * @hal_soc: Opaque HAL SOC handle
  1263. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1264. *
  1265. * Return: total number of entries in hal ring
  1266. */
  1267. static inline
  1268. uint32_t hal_srng_get_num_entries(hal_soc_handle_t hal_soc_hdl,
  1269. hal_ring_handle_t hal_ring_hdl)
  1270. {
  1271. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1272. return srng->num_entries;
  1273. }
  1274. /**
  1275. * hal_get_srng_params - Retrieve SRNG parameters for a given ring from HAL
  1276. *
  1277. * @hal_soc: Opaque HAL SOC handle
  1278. * @hal_ring_hdl: Ring pointer (Source or Destination ring)
  1279. * @ring_params: SRNG parameters will be returned through this structure
  1280. */
  1281. void hal_get_srng_params(hal_soc_handle_t hal_soc_hdl,
  1282. hal_ring_handle_t hal_ring_hdl,
  1283. struct hal_srng_params *ring_params);
  1284. /**
  1285. * hal_mem_info - Retrieve hal memory base address
  1286. *
  1287. * @hal_soc: Opaque HAL SOC handle
  1288. * @mem: pointer to structure to be updated with hal mem info
  1289. */
  1290. void hal_get_meminfo(hal_soc_handle_t hal_soc_hdl, struct hal_mem_info *mem);
  1291. /**
  1292. * hal_get_target_type - Return target type
  1293. *
  1294. * @hal_soc: Opaque HAL SOC handle
  1295. */
  1296. uint32_t hal_get_target_type(hal_soc_handle_t hal_soc_hdl);
  1297. /**
  1298. * hal_get_ba_aging_timeout - Retrieve BA aging timeout
  1299. *
  1300. * @hal_soc: Opaque HAL SOC handle
  1301. * @ac: Access category
  1302. * @value: timeout duration in millisec
  1303. */
  1304. void hal_get_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  1305. uint32_t *value);
  1306. /**
  1307. * hal_set_aging_timeout - Set BA aging timeout
  1308. *
  1309. * @hal_soc: Opaque HAL SOC handle
  1310. * @ac: Access category in millisec
  1311. * @value: timeout duration value
  1312. */
  1313. void hal_set_ba_aging_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t ac,
  1314. uint32_t value);
  1315. /**
  1316. * hal_srng_dst_hw_init - Private function to initialize SRNG
  1317. * destination ring HW
  1318. * @hal_soc: HAL SOC handle
  1319. * @srng: SRNG ring pointer
  1320. */
  1321. static inline void hal_srng_dst_hw_init(struct hal_soc *hal,
  1322. struct hal_srng *srng)
  1323. {
  1324. hal->ops->hal_srng_dst_hw_init(hal, srng);
  1325. }
  1326. /**
  1327. * hal_srng_src_hw_init - Private function to initialize SRNG
  1328. * source ring HW
  1329. * @hal_soc: HAL SOC handle
  1330. * @srng: SRNG ring pointer
  1331. */
  1332. static inline void hal_srng_src_hw_init(struct hal_soc *hal,
  1333. struct hal_srng *srng)
  1334. {
  1335. hal->ops->hal_srng_src_hw_init(hal, srng);
  1336. }
  1337. /**
  1338. * hal_get_hw_hptp() - Get HW head and tail pointer value for any ring
  1339. * @hal_soc: Opaque HAL SOC handle
  1340. * @hal_ring_hdl: Source ring pointer
  1341. * @headp: Head Pointer
  1342. * @tailp: Tail Pointer
  1343. * @ring_type: Ring
  1344. *
  1345. * Return: Update tail pointer and head pointer in arguments.
  1346. */
  1347. static inline
  1348. void hal_get_hw_hptp(hal_soc_handle_t hal_soc_hdl,
  1349. hal_ring_handle_t hal_ring_hdl,
  1350. uint32_t *headp, uint32_t *tailp,
  1351. uint8_t ring_type)
  1352. {
  1353. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1354. hal_soc->ops->hal_get_hw_hptp(hal_soc, hal_ring_hdl,
  1355. headp, tailp, ring_type);
  1356. }
  1357. /**
  1358. * hal_reo_setup - Initialize HW REO block
  1359. *
  1360. * @hal_soc: Opaque HAL SOC handle
  1361. * @reo_params: parameters needed by HAL for REO config
  1362. */
  1363. static inline void hal_reo_setup(hal_soc_handle_t hal_soc_hdl,
  1364. void *reoparams)
  1365. {
  1366. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1367. hal_soc->ops->hal_reo_setup(hal_soc, reoparams);
  1368. }
  1369. /**
  1370. * hal_setup_link_idle_list - Setup scattered idle list using the
  1371. * buffer list provided
  1372. *
  1373. * @hal_soc: Opaque HAL SOC handle
  1374. * @scatter_bufs_base_paddr: Array of physical base addresses
  1375. * @scatter_bufs_base_vaddr: Array of virtual base addresses
  1376. * @num_scatter_bufs: Number of scatter buffers in the above lists
  1377. * @scatter_buf_size: Size of each scatter buffer
  1378. * @last_buf_end_offset: Offset to the last entry
  1379. * @num_entries: Total entries of all scatter bufs
  1380. *
  1381. */
  1382. static inline
  1383. void hal_setup_link_idle_list(hal_soc_handle_t hal_soc_hdl,
  1384. qdf_dma_addr_t scatter_bufs_base_paddr[],
  1385. void *scatter_bufs_base_vaddr[],
  1386. uint32_t num_scatter_bufs,
  1387. uint32_t scatter_buf_size,
  1388. uint32_t last_buf_end_offset,
  1389. uint32_t num_entries)
  1390. {
  1391. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1392. hal_soc->ops->hal_setup_link_idle_list(hal_soc, scatter_bufs_base_paddr,
  1393. scatter_bufs_base_vaddr, num_scatter_bufs,
  1394. scatter_buf_size, last_buf_end_offset,
  1395. num_entries);
  1396. }
  1397. /**
  1398. * hal_srng_dump_ring_desc() - Dump ring descriptor info
  1399. *
  1400. * @hal_soc: Opaque HAL SOC handle
  1401. * @hal_ring_hdl: Source ring pointer
  1402. * @ring_desc: Opaque ring descriptor handle
  1403. */
  1404. static inline void hal_srng_dump_ring_desc(hal_soc_handle_t hal_soc_hdl,
  1405. hal_ring_handle_t hal_ring_hdl,
  1406. hal_ring_desc_t ring_desc)
  1407. {
  1408. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1409. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  1410. ring_desc, (srng->entry_size << 2));
  1411. }
  1412. /**
  1413. * hal_srng_dump_ring() - Dump last 128 descs of the ring
  1414. *
  1415. * @hal_soc: Opaque HAL SOC handle
  1416. * @hal_ring_hdl: Source ring pointer
  1417. */
  1418. static inline void hal_srng_dump_ring(hal_soc_handle_t hal_soc_hdl,
  1419. hal_ring_handle_t hal_ring_hdl)
  1420. {
  1421. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1422. uint32_t *desc;
  1423. uint32_t tp, i;
  1424. tp = srng->u.dst_ring.tp;
  1425. for (i = 0; i < 128; i++) {
  1426. if (!tp)
  1427. tp = srng->ring_size;
  1428. desc = &srng->ring_base_vaddr[tp - srng->entry_size];
  1429. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP,
  1430. QDF_TRACE_LEVEL_DEBUG,
  1431. desc, (srng->entry_size << 2));
  1432. tp -= srng->entry_size;
  1433. }
  1434. }
  1435. /*
  1436. * hal_rxdma_desc_to_hal_ring_desc - API to convert rxdma ring desc
  1437. * to opaque dp_ring desc type
  1438. * @ring_desc - rxdma ring desc
  1439. *
  1440. * Return: hal_rxdma_desc_t type
  1441. */
  1442. static inline
  1443. hal_ring_desc_t hal_rxdma_desc_to_hal_ring_desc(hal_rxdma_desc_t ring_desc)
  1444. {
  1445. return (hal_ring_desc_t)ring_desc;
  1446. }
  1447. /**
  1448. * hal_srng_set_event() - Set hal_srng event
  1449. * @hal_ring_hdl: Source ring pointer
  1450. * @event: SRNG ring event
  1451. *
  1452. * Return: None
  1453. */
  1454. static inline void hal_srng_set_event(hal_ring_handle_t hal_ring_hdl, int event)
  1455. {
  1456. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1457. qdf_atomic_set_bit(event, &srng->srng_event);
  1458. }
  1459. /**
  1460. * hal_srng_clear_event() - Clear hal_srng event
  1461. * @hal_ring_hdl: Source ring pointer
  1462. * @event: SRNG ring event
  1463. *
  1464. * Return: None
  1465. */
  1466. static inline
  1467. void hal_srng_clear_event(hal_ring_handle_t hal_ring_hdl, int event)
  1468. {
  1469. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1470. qdf_atomic_clear_bit(event, &srng->srng_event);
  1471. }
  1472. /**
  1473. * hal_srng_get_clear_event() - Clear srng event and return old value
  1474. * @hal_ring_hdl: Source ring pointer
  1475. * @event: SRNG ring event
  1476. *
  1477. * Return: Return old event value
  1478. */
  1479. static inline
  1480. int hal_srng_get_clear_event(hal_ring_handle_t hal_ring_hdl, int event)
  1481. {
  1482. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1483. return qdf_atomic_test_and_clear_bit(event, &srng->srng_event);
  1484. }
  1485. /**
  1486. * hal_srng_set_flush_last_ts() - Record last flush time stamp
  1487. * @hal_ring_hdl: Source ring pointer
  1488. *
  1489. * Return: None
  1490. */
  1491. static inline void hal_srng_set_flush_last_ts(hal_ring_handle_t hal_ring_hdl)
  1492. {
  1493. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1494. srng->last_flush_ts = qdf_get_log_timestamp();
  1495. }
  1496. /**
  1497. * hal_srng_inc_flush_cnt() - Increment flush counter
  1498. * @hal_ring_hdl: Source ring pointer
  1499. *
  1500. * Return: None
  1501. */
  1502. static inline void hal_srng_inc_flush_cnt(hal_ring_handle_t hal_ring_hdl)
  1503. {
  1504. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  1505. srng->flush_count++;
  1506. }
  1507. #endif /* _HAL_APIH_ */