hal_api.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above
  10. * copyright notice, this list of conditions and the following
  11. * disclaimer in the documentation and/or other materials provided
  12. * with the distribution.
  13. * * Neither the name of The Linux Foundation nor the names of its
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  21. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  24. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  26. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  27. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef _HAL_API_H_
  30. #define _HAL_API_H_
  31. #include "qdf_types.h"
  32. #include "qdf_util.h"
  33. #include "hal_internal.h"
  34. #include "rx_msdu_link.h"
  35. #include "rx_reo_queue.h"
  36. #include "rx_reo_queue_ext.h"
  37. #define MAX_UNWINDOWED_ADDRESS 0x80000
  38. #ifdef TARGET_TYPE_QCA6390
  39. #define WINDOW_ENABLE_BIT 0x40000000
  40. #else
  41. #define WINDOW_ENABLE_BIT 0x80000000
  42. #endif
  43. #define WINDOW_REG_ADDRESS 0x310C
  44. #define WINDOW_SHIFT 19
  45. #define WINDOW_VALUE_MASK 0x3F
  46. #define WINDOW_START MAX_UNWINDOWED_ADDRESS
  47. #define WINDOW_RANGE_MASK 0x7FFFF
  48. static inline void hal_select_window(struct hal_soc *hal_soc, uint32_t offset)
  49. {
  50. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  51. if (window != hal_soc->register_window) {
  52. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  53. WINDOW_ENABLE_BIT | window);
  54. hal_soc->register_window = window;
  55. }
  56. }
  57. /**
  58. * note1: WINDOW_RANGE_MASK = (1 << WINDOW_SHIFT) -1
  59. * note2: 1 << WINDOW_SHIFT = MAX_UNWINDOWED_ADDRESS
  60. * note3: WINDOW_VALUE_MASK = big enough that trying to write past that window
  61. * would be a bug
  62. */
  63. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  64. uint32_t value)
  65. {
  66. if (!hal_soc->use_register_windowing ||
  67. offset < MAX_UNWINDOWED_ADDRESS) {
  68. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  69. } else {
  70. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  71. hal_select_window(hal_soc, offset);
  72. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  73. (offset & WINDOW_RANGE_MASK), value);
  74. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  75. }
  76. }
  77. /**
  78. * hal_write_address_32_mb - write a value to a register
  79. *
  80. */
  81. static inline void hal_write_address_32_mb(struct hal_soc *hal_soc,
  82. void __iomem *addr, uint32_t value)
  83. {
  84. uint32_t offset;
  85. if (!hal_soc->use_register_windowing)
  86. return qdf_iowrite32(addr, value);
  87. offset = addr - hal_soc->dev_base_addr;
  88. hal_write32_mb(hal_soc, offset, value);
  89. }
  90. static inline uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  91. {
  92. uint32_t ret;
  93. if (!hal_soc->use_register_windowing ||
  94. offset < MAX_UNWINDOWED_ADDRESS) {
  95. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  96. }
  97. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  98. hal_select_window(hal_soc, offset);
  99. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  100. (offset & WINDOW_RANGE_MASK));
  101. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  102. return ret;
  103. }
  104. #include "hif_io32.h"
  105. /**
  106. * hal_attach - Initialize HAL layer
  107. * @hif_handle: Opaque HIF handle
  108. * @qdf_dev: QDF device
  109. *
  110. * Return: Opaque HAL SOC handle
  111. * NULL on failure (if given ring is not available)
  112. *
  113. * This function should be called as part of HIF initialization (for accessing
  114. * copy engines). DP layer will get hal_soc handle using hif_get_hal_handle()
  115. */
  116. extern void *hal_attach(void *hif_handle, qdf_device_t qdf_dev);
  117. /**
  118. * hal_detach - Detach HAL layer
  119. * @hal_soc: HAL SOC handle
  120. *
  121. * This function should be called as part of HIF detach
  122. *
  123. */
  124. extern void hal_detach(void *hal_soc);
  125. /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */
  126. enum hal_ring_type {
  127. REO_DST,
  128. REO_EXCEPTION,
  129. REO_REINJECT,
  130. REO_CMD,
  131. REO_STATUS,
  132. TCL_DATA,
  133. TCL_CMD,
  134. TCL_STATUS,
  135. CE_SRC,
  136. CE_DST,
  137. CE_DST_STATUS,
  138. WBM_IDLE_LINK,
  139. SW2WBM_RELEASE,
  140. WBM2SW_RELEASE,
  141. RXDMA_BUF,
  142. RXDMA_DST,
  143. RXDMA_MONITOR_BUF,
  144. RXDMA_MONITOR_STATUS,
  145. RXDMA_MONITOR_DST,
  146. RXDMA_MONITOR_DESC,
  147. DIR_BUF_RX_DMA_SRC,
  148. #ifdef WLAN_FEATURE_CIF_CFR
  149. WIFI_POS_SRC,
  150. #endif
  151. MAX_RING_TYPES
  152. };
  153. /* SRNG flags passed in hal_srng_params.flags */
  154. #define HAL_SRNG_MSI_SWAP 0x00000008
  155. #define HAL_SRNG_RING_PTR_SWAP 0x00000010
  156. #define HAL_SRNG_DATA_TLV_SWAP 0x00000020
  157. #define HAL_SRNG_LOW_THRES_INTR_ENABLE 0x00010000
  158. #define HAL_SRNG_MSI_INTR 0x00020000
  159. #define PN_SIZE_24 0
  160. #define PN_SIZE_48 1
  161. #define PN_SIZE_128 2
  162. /**
  163. * hal_srng_get_entrysize - Returns size of ring entry in bytes. Should be
  164. * used by callers for calculating the size of memory to be allocated before
  165. * calling hal_srng_setup to setup the ring
  166. *
  167. * @hal_soc: Opaque HAL SOC handle
  168. * @ring_type: one of the types from hal_ring_type
  169. *
  170. */
  171. extern uint32_t hal_srng_get_entrysize(void *hal_soc, int ring_type);
  172. /**
  173. * hal_srng_max_entries - Returns maximum possible number of ring entries
  174. * @hal_soc: Opaque HAL SOC handle
  175. * @ring_type: one of the types from hal_ring_type
  176. *
  177. * Return: Maximum number of entries for the given ring_type
  178. */
  179. uint32_t hal_srng_max_entries(void *hal_soc, int ring_type);
  180. /**
  181. * hal_srng_dump - Dump ring status
  182. * @srng: hal srng pointer
  183. */
  184. void hal_srng_dump(struct hal_srng *srng);
  185. /**
  186. * hal_srng_get_dir - Returns the direction of the ring
  187. * @hal_soc: Opaque HAL SOC handle
  188. * @ring_type: one of the types from hal_ring_type
  189. *
  190. * Return: Ring direction
  191. */
  192. enum hal_srng_dir hal_srng_get_dir(void *hal_soc, int ring_type);
  193. /* HAL memory information */
  194. struct hal_mem_info {
  195. /* dev base virutal addr */
  196. void *dev_base_addr;
  197. /* dev base physical addr */
  198. void *dev_base_paddr;
  199. /* Remote virtual pointer memory for HW/FW updates */
  200. void *shadow_rdptr_mem_vaddr;
  201. /* Remote physical pointer memory for HW/FW updates */
  202. void *shadow_rdptr_mem_paddr;
  203. /* Shared memory for ring pointer updates from host to FW */
  204. void *shadow_wrptr_mem_vaddr;
  205. /* Shared physical memory for ring pointer updates from host to FW */
  206. void *shadow_wrptr_mem_paddr;
  207. };
  208. /* SRNG parameters to be passed to hal_srng_setup */
  209. struct hal_srng_params {
  210. /* Physical base address of the ring */
  211. qdf_dma_addr_t ring_base_paddr;
  212. /* Virtual base address of the ring */
  213. void *ring_base_vaddr;
  214. /* Number of entries in ring */
  215. uint32_t num_entries;
  216. /* max transfer length */
  217. uint16_t max_buffer_length;
  218. /* MSI Address */
  219. qdf_dma_addr_t msi_addr;
  220. /* MSI data */
  221. uint32_t msi_data;
  222. /* Interrupt timer threshold – in micro seconds */
  223. uint32_t intr_timer_thres_us;
  224. /* Interrupt batch counter threshold – in number of ring entries */
  225. uint32_t intr_batch_cntr_thres_entries;
  226. /* Low threshold – in number of ring entries
  227. * (valid for src rings only)
  228. */
  229. uint32_t low_threshold;
  230. /* Misc flags */
  231. uint32_t flags;
  232. /* Unique ring id */
  233. uint8_t ring_id;
  234. /* Source or Destination ring */
  235. enum hal_srng_dir ring_dir;
  236. /* Size of ring entry */
  237. uint32_t entry_size;
  238. /* hw register base address */
  239. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  240. };
  241. /* hal_construct_shadow_config() - initialize the shadow registers for dp rings
  242. * @hal_soc: hal handle
  243. *
  244. * Return: QDF_STATUS_OK on success
  245. */
  246. extern QDF_STATUS hal_construct_shadow_config(void *hal_soc);
  247. /* hal_set_one_shadow_config() - add a config for the specified ring
  248. * @hal_soc: hal handle
  249. * @ring_type: ring type
  250. * @ring_num: ring num
  251. *
  252. * The ring type and ring num uniquely specify the ring. After this call,
  253. * the hp/tp will be added as the next entry int the shadow register
  254. * configuration table. The hal code will use the shadow register address
  255. * in place of the hp/tp address.
  256. *
  257. * This function is exposed, so that the CE module can skip configuring shadow
  258. * registers for unused ring and rings assigned to the firmware.
  259. *
  260. * Return: QDF_STATUS_OK on success
  261. */
  262. extern QDF_STATUS hal_set_one_shadow_config(void *hal_soc, int ring_type,
  263. int ring_num);
  264. /**
  265. * hal_get_shadow_config() - retrieve the config table
  266. * @hal_soc: hal handle
  267. * @shadow_config: will point to the table after
  268. * @num_shadow_registers_configured: will contain the number of valid entries
  269. */
  270. extern void hal_get_shadow_config(void *hal_soc,
  271. struct pld_shadow_reg_v2_cfg **shadow_config,
  272. int *num_shadow_registers_configured);
  273. /**
  274. * hal_srng_setup - Initialize HW SRNG ring.
  275. *
  276. * @hal_soc: Opaque HAL SOC handle
  277. * @ring_type: one of the types from hal_ring_type
  278. * @ring_num: Ring number if there are multiple rings of
  279. * same type (staring from 0)
  280. * @mac_id: valid MAC Id should be passed if ring type is one of lmac rings
  281. * @ring_params: SRNG ring params in hal_srng_params structure.
  282. * Callers are expected to allocate contiguous ring memory of size
  283. * 'num_entries * entry_size' bytes and pass the physical and virtual base
  284. * addresses through 'ring_base_paddr' and 'ring_base_vaddr' in hal_srng_params
  285. * structure. Ring base address should be 8 byte aligned and size of each ring
  286. * entry should be queried using the API hal_srng_get_entrysize
  287. *
  288. * Return: Opaque pointer to ring on success
  289. * NULL on failure (if given ring is not available)
  290. */
  291. extern void *hal_srng_setup(void *hal_soc, int ring_type, int ring_num,
  292. int mac_id, struct hal_srng_params *ring_params);
  293. /* Remapping ids of REO rings */
  294. #define REO_REMAP_TCL 0
  295. #define REO_REMAP_SW1 1
  296. #define REO_REMAP_SW2 2
  297. #define REO_REMAP_SW3 3
  298. #define REO_REMAP_SW4 4
  299. #define REO_REMAP_RELEASE 5
  300. #define REO_REMAP_FW 6
  301. #define REO_REMAP_UNUSED 7
  302. /*
  303. * currently this macro only works for IX0 since all the rings we are remapping
  304. * can be remapped from HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0
  305. */
  306. #define HAL_REO_REMAP_VAL(_ORIGINAL_DEST, _NEW_DEST) \
  307. HAL_REO_REMAP_VAL_(_ORIGINAL_DEST, _NEW_DEST)
  308. /* allow the destination macros to be expanded */
  309. #define HAL_REO_REMAP_VAL_(_ORIGINAL_DEST, _NEW_DEST) \
  310. (_NEW_DEST << \
  311. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0_DEST_RING_MAPPING_ ## \
  312. _ORIGINAL_DEST ## _SHFT))
  313. /**
  314. * hal_reo_remap_IX0 - Remap REO ring destination
  315. * @hal: HAL SOC handle
  316. * @remap_val: Remap value
  317. */
  318. extern void hal_reo_remap_IX0(struct hal_soc *hal, uint32_t remap_val);
  319. /**
  320. * hal_srng_set_hp_paddr() - Set physical address to dest SRNG head pointer
  321. * @sring: sring pointer
  322. * @paddr: physical address
  323. */
  324. extern void hal_srng_dst_set_hp_paddr(struct hal_srng *sring, uint64_t paddr);
  325. /**
  326. * hal_srng_dst_init_hp() - Initilaize head pointer with cached head pointer
  327. * @srng: sring pointer
  328. * @vaddr: virtual address
  329. */
  330. extern void hal_srng_dst_init_hp(struct hal_srng *srng, uint32_t *vaddr);
  331. /**
  332. * hal_srng_cleanup - Deinitialize HW SRNG ring.
  333. * @hal_soc: Opaque HAL SOC handle
  334. * @hal_srng: Opaque HAL SRNG pointer
  335. */
  336. extern void hal_srng_cleanup(void *hal_soc, void *hal_srng);
  337. static inline bool hal_srng_initialized(void *hal_ring)
  338. {
  339. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  340. return !!srng->initialized;
  341. }
  342. /**
  343. * hal_srng_access_start_unlocked - Start ring access (unlocked). Should use
  344. * hal_srng_access_start if locked access is required
  345. *
  346. * @hal_soc: Opaque HAL SOC handle
  347. * @hal_ring: Ring pointer (Source or Destination ring)
  348. *
  349. * Return: 0 on success; error on failire
  350. */
  351. static inline int hal_srng_access_start_unlocked(void *hal_soc, void *hal_ring)
  352. {
  353. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  354. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  355. srng->u.src_ring.cached_tp =
  356. *(volatile uint32_t *)(srng->u.src_ring.tp_addr);
  357. else
  358. srng->u.dst_ring.cached_hp =
  359. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  360. return 0;
  361. }
  362. /**
  363. * hal_srng_access_start - Start (locked) ring access
  364. *
  365. * @hal_soc: Opaque HAL SOC handle
  366. * @hal_ring: Ring pointer (Source or Destination ring)
  367. *
  368. * Return: 0 on success; error on failire
  369. */
  370. static inline int hal_srng_access_start(void *hal_soc, void *hal_ring)
  371. {
  372. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  373. SRNG_LOCK(&(srng->lock));
  374. return hal_srng_access_start_unlocked(hal_soc, hal_ring);
  375. }
  376. /**
  377. * hal_srng_dst_get_next - Get next entry from a destination ring and move
  378. * cached tail pointer
  379. *
  380. * @hal_soc: Opaque HAL SOC handle
  381. * @hal_ring: Destination ring pointer
  382. *
  383. * Return: Opaque pointer for next ring entry; NULL on failire
  384. */
  385. static inline void *hal_srng_dst_get_next(void *hal_soc, void *hal_ring)
  386. {
  387. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  388. uint32_t *desc;
  389. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp) {
  390. desc = &(srng->ring_base_vaddr[srng->u.dst_ring.tp]);
  391. /* TODO: Using % is expensive, but we have to do this since
  392. * size of some SRNG rings is not power of 2 (due to descriptor
  393. * sizes). Need to create separate API for rings used
  394. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  395. * SW2RXDMA and CE rings)
  396. */
  397. srng->u.dst_ring.tp = (srng->u.dst_ring.tp + srng->entry_size) %
  398. srng->ring_size;
  399. return (void *)desc;
  400. }
  401. return NULL;
  402. }
  403. /**
  404. * hal_srng_dst_get_next_hp - Get next entry from a destination ring and move
  405. * cached head pointer
  406. *
  407. * @hal_soc: Opaque HAL SOC handle
  408. * @hal_ring: Destination ring pointer
  409. *
  410. * Return: Opaque pointer for next ring entry; NULL on failire
  411. */
  412. static inline void *hal_srng_dst_get_next_hp(void *hal_soc, void *hal_ring)
  413. {
  414. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  415. uint32_t *desc;
  416. /* TODO: Using % is expensive, but we have to do this since
  417. * size of some SRNG rings is not power of 2 (due to descriptor
  418. * sizes). Need to create separate API for rings used
  419. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  420. * SW2RXDMA and CE rings)
  421. */
  422. uint32_t next_hp = (srng->u.dst_ring.cached_hp + srng->entry_size) %
  423. srng->ring_size;
  424. if (next_hp != srng->u.dst_ring.tp) {
  425. desc = &(srng->ring_base_vaddr[srng->u.dst_ring.cached_hp]);
  426. srng->u.dst_ring.cached_hp = next_hp;
  427. return (void *)desc;
  428. }
  429. return NULL;
  430. }
  431. /**
  432. * hal_srng_dst_peek - Get next entry from a ring without moving tail pointer.
  433. * hal_srng_dst_get_next should be called subsequently to move the tail pointer
  434. * TODO: See if we need an optimized version of get_next that doesn't check for
  435. * loop_cnt
  436. *
  437. * @hal_soc: Opaque HAL SOC handle
  438. * @hal_ring: Destination ring pointer
  439. *
  440. * Return: Opaque pointer for next ring entry; NULL on failire
  441. */
  442. static inline void *hal_srng_dst_peek(void *hal_soc, void *hal_ring)
  443. {
  444. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  445. if (srng->u.dst_ring.tp != srng->u.dst_ring.cached_hp)
  446. return (void *)(&(srng->ring_base_vaddr[srng->u.dst_ring.tp]));
  447. return NULL;
  448. }
  449. /**
  450. * hal_srng_dst_num_valid - Returns number of valid entries (to be processed
  451. * by SW) in destination ring
  452. *
  453. * @hal_soc: Opaque HAL SOC handle
  454. * @hal_ring: Destination ring pointer
  455. * @sync_hw_ptr: Sync cached head pointer with HW
  456. *
  457. */
  458. static inline uint32_t hal_srng_dst_num_valid(void *hal_soc, void *hal_ring,
  459. int sync_hw_ptr)
  460. {
  461. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  462. uint32 hp;
  463. uint32 tp = srng->u.dst_ring.tp;
  464. if (sync_hw_ptr) {
  465. hp = *(srng->u.dst_ring.hp_addr);
  466. srng->u.dst_ring.cached_hp = hp;
  467. } else {
  468. hp = srng->u.dst_ring.cached_hp;
  469. }
  470. if (hp >= tp)
  471. return (hp - tp) / srng->entry_size;
  472. else
  473. return (srng->ring_size - tp + hp) / srng->entry_size;
  474. }
  475. /**
  476. * hal_srng_src_reap_next - Reap next entry from a source ring and move reap
  477. * pointer. This can be used to release any buffers associated with completed
  478. * ring entries. Note that this should not be used for posting new descriptor
  479. * entries. Posting of new entries should be done only using
  480. * hal_srng_src_get_next_reaped when this function is used for reaping.
  481. *
  482. * @hal_soc: Opaque HAL SOC handle
  483. * @hal_ring: Source ring pointer
  484. *
  485. * Return: Opaque pointer for next ring entry; NULL on failire
  486. */
  487. static inline void *hal_srng_src_reap_next(void *hal_soc, void *hal_ring)
  488. {
  489. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  490. uint32_t *desc;
  491. /* TODO: Using % is expensive, but we have to do this since
  492. * size of some SRNG rings is not power of 2 (due to descriptor
  493. * sizes). Need to create separate API for rings used
  494. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  495. * SW2RXDMA and CE rings)
  496. */
  497. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  498. srng->ring_size;
  499. if (next_reap_hp != srng->u.src_ring.cached_tp) {
  500. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  501. srng->u.src_ring.reap_hp = next_reap_hp;
  502. return (void *)desc;
  503. }
  504. return NULL;
  505. }
  506. /**
  507. * hal_srng_src_get_next_reaped - Get next entry from a source ring that is
  508. * already reaped using hal_srng_src_reap_next, for posting new entries to
  509. * the ring
  510. *
  511. * @hal_soc: Opaque HAL SOC handle
  512. * @hal_ring: Source ring pointer
  513. *
  514. * Return: Opaque pointer for next (reaped) source ring entry; NULL on failire
  515. */
  516. static inline void *hal_srng_src_get_next_reaped(void *hal_soc, void *hal_ring)
  517. {
  518. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  519. uint32_t *desc;
  520. if (srng->u.src_ring.hp != srng->u.src_ring.reap_hp) {
  521. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  522. srng->u.src_ring.hp = (srng->u.src_ring.hp + srng->entry_size) %
  523. srng->ring_size;
  524. return (void *)desc;
  525. }
  526. return NULL;
  527. }
  528. /**
  529. * hal_srng_src_pending_reap_next - Reap next entry from a source ring and
  530. * move reap pointer. This API is used in detach path to release any buffers
  531. * associated with ring entries which are pending reap.
  532. *
  533. * @hal_soc: Opaque HAL SOC handle
  534. * @hal_ring: Source ring pointer
  535. *
  536. * Return: Opaque pointer for next ring entry; NULL on failire
  537. */
  538. static inline void *hal_srng_src_pending_reap_next(void *hal_soc, void *hal_ring)
  539. {
  540. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  541. uint32_t *desc;
  542. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  543. srng->ring_size;
  544. if (next_reap_hp != srng->u.src_ring.hp) {
  545. desc = &(srng->ring_base_vaddr[next_reap_hp]);
  546. srng->u.src_ring.reap_hp = next_reap_hp;
  547. return (void *)desc;
  548. }
  549. return NULL;
  550. }
  551. /**
  552. * hal_srng_src_done_val -
  553. *
  554. * @hal_soc: Opaque HAL SOC handle
  555. * @hal_ring: Source ring pointer
  556. *
  557. * Return: Opaque pointer for next ring entry; NULL on failire
  558. */
  559. static inline uint32_t hal_srng_src_done_val(void *hal_soc, void *hal_ring)
  560. {
  561. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  562. /* TODO: Using % is expensive, but we have to do this since
  563. * size of some SRNG rings is not power of 2 (due to descriptor
  564. * sizes). Need to create separate API for rings used
  565. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  566. * SW2RXDMA and CE rings)
  567. */
  568. uint32_t next_reap_hp = (srng->u.src_ring.reap_hp + srng->entry_size) %
  569. srng->ring_size;
  570. if (next_reap_hp == srng->u.src_ring.cached_tp)
  571. return 0;
  572. if (srng->u.src_ring.cached_tp > next_reap_hp)
  573. return (srng->u.src_ring.cached_tp - next_reap_hp) /
  574. srng->entry_size;
  575. else
  576. return ((srng->ring_size - next_reap_hp) +
  577. srng->u.src_ring.cached_tp) / srng->entry_size;
  578. }
  579. /**
  580. * hal_api_get_tphp - Get head and tail pointer location for any ring
  581. * @hal_soc: Opaque HAL SOC handle
  582. * @hal_ring: Source ring pointer
  583. * @tailp: Tail Pointer
  584. * @headp: Head Pointer
  585. *
  586. * Return: Update tail pointer and head pointer in arguments.
  587. */
  588. static inline void hal_api_get_tphp(void *hal_soc, void *hal_ring,
  589. uint32_t *tailp, uint32_t *headp)
  590. {
  591. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  592. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  593. *headp = srng->u.src_ring.hp / srng->entry_size;
  594. *tailp = *(srng->u.src_ring.tp_addr) / srng->entry_size;
  595. } else {
  596. *tailp = srng->u.dst_ring.tp / srng->entry_size;
  597. *headp = *(srng->u.dst_ring.hp_addr) / srng->entry_size;
  598. }
  599. }
  600. /**
  601. * hal_srng_src_get_next - Get next entry from a source ring and move cached tail pointer
  602. *
  603. * @hal_soc: Opaque HAL SOC handle
  604. * @hal_ring: Source ring pointer
  605. *
  606. * Return: Opaque pointer for next ring entry; NULL on failire
  607. */
  608. static inline void *hal_srng_src_get_next(void *hal_soc, void *hal_ring)
  609. {
  610. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  611. uint32_t *desc;
  612. /* TODO: Using % is expensive, but we have to do this since
  613. * size of some SRNG rings is not power of 2 (due to descriptor
  614. * sizes). Need to create separate API for rings used
  615. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  616. * SW2RXDMA and CE rings)
  617. */
  618. uint32_t next_hp = (srng->u.src_ring.hp + srng->entry_size) %
  619. srng->ring_size;
  620. if (next_hp != srng->u.src_ring.cached_tp) {
  621. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  622. srng->u.src_ring.hp = next_hp;
  623. /* TODO: Since reap function is not used by all rings, we can
  624. * remove the following update of reap_hp in this function
  625. * if we can ensure that only hal_srng_src_get_next_reaped
  626. * is used for the rings requiring reap functionality
  627. */
  628. srng->u.src_ring.reap_hp = next_hp;
  629. return (void *)desc;
  630. }
  631. return NULL;
  632. }
  633. /**
  634. * hal_srng_src_peek - Get next entry from a ring without moving head pointer.
  635. * hal_srng_src_get_next should be called subsequently to move the head pointer
  636. *
  637. * @hal_soc: Opaque HAL SOC handle
  638. * @hal_ring: Source ring pointer
  639. *
  640. * Return: Opaque pointer for next ring entry; NULL on failire
  641. */
  642. static inline void *hal_srng_src_peek(void *hal_soc, void *hal_ring)
  643. {
  644. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  645. uint32_t *desc;
  646. /* TODO: Using % is expensive, but we have to do this since
  647. * size of some SRNG rings is not power of 2 (due to descriptor
  648. * sizes). Need to create separate API for rings used
  649. * per-packet, with sizes power of 2 (TCL2SW, REO2SW,
  650. * SW2RXDMA and CE rings)
  651. */
  652. if (((srng->u.src_ring.hp + srng->entry_size) %
  653. srng->ring_size) != srng->u.src_ring.cached_tp) {
  654. desc = &(srng->ring_base_vaddr[srng->u.src_ring.hp]);
  655. return (void *)desc;
  656. }
  657. return NULL;
  658. }
  659. /**
  660. * hal_srng_src_num_avail - Returns number of available entries in src ring
  661. *
  662. * @hal_soc: Opaque HAL SOC handle
  663. * @hal_ring: Source ring pointer
  664. * @sync_hw_ptr: Sync cached tail pointer with HW
  665. *
  666. */
  667. static inline uint32_t hal_srng_src_num_avail(void *hal_soc,
  668. void *hal_ring, int sync_hw_ptr)
  669. {
  670. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  671. uint32 tp;
  672. uint32 hp = srng->u.src_ring.hp;
  673. if (sync_hw_ptr) {
  674. tp = *(srng->u.src_ring.tp_addr);
  675. srng->u.src_ring.cached_tp = tp;
  676. } else {
  677. tp = srng->u.src_ring.cached_tp;
  678. }
  679. if (tp > hp)
  680. return ((tp - hp) / srng->entry_size) - 1;
  681. else
  682. return ((srng->ring_size - hp + tp) / srng->entry_size) - 1;
  683. }
  684. /**
  685. * hal_srng_access_end_unlocked - End ring access (unlocked) - update cached
  686. * ring head/tail pointers to HW.
  687. * This should be used only if hal_srng_access_start_unlocked to start ring
  688. * access
  689. *
  690. * @hal_soc: Opaque HAL SOC handle
  691. * @hal_ring: Ring pointer (Source or Destination ring)
  692. *
  693. * Return: 0 on success; error on failire
  694. */
  695. static inline void hal_srng_access_end_unlocked(void *hal_soc, void *hal_ring)
  696. {
  697. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  698. /* TODO: See if we need a write memory barrier here */
  699. if (srng->flags & HAL_SRNG_LMAC_RING) {
  700. /* For LMAC rings, ring pointer updates are done through FW and
  701. * hence written to a shared memory location that is read by FW
  702. */
  703. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  704. *(srng->u.src_ring.hp_addr) = srng->u.src_ring.hp;
  705. } else {
  706. *(srng->u.dst_ring.tp_addr) = srng->u.dst_ring.tp;
  707. }
  708. } else {
  709. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  710. hal_write_address_32_mb(hal_soc,
  711. srng->u.src_ring.hp_addr,
  712. srng->u.src_ring.hp);
  713. else
  714. hal_write_address_32_mb(hal_soc,
  715. srng->u.dst_ring.tp_addr,
  716. srng->u.dst_ring.tp);
  717. }
  718. }
  719. /**
  720. * hal_srng_access_end - Unlock ring access and update cached ring head/tail
  721. * pointers to HW
  722. * This should be used only if hal_srng_access_start to start ring access
  723. *
  724. * @hal_soc: Opaque HAL SOC handle
  725. * @hal_ring: Ring pointer (Source or Destination ring)
  726. *
  727. * Return: 0 on success; error on failire
  728. */
  729. static inline void hal_srng_access_end(void *hal_soc, void *hal_ring)
  730. {
  731. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  732. hal_srng_access_end_unlocked(hal_soc, hal_ring);
  733. SRNG_UNLOCK(&(srng->lock));
  734. }
  735. /**
  736. * hal_srng_access_end_reap - Unlock ring access
  737. * This should be used only if hal_srng_access_start to start ring access
  738. * and should be used only while reaping SRC ring completions
  739. *
  740. * @hal_soc: Opaque HAL SOC handle
  741. * @hal_ring: Ring pointer (Source or Destination ring)
  742. *
  743. * Return: 0 on success; error on failire
  744. */
  745. static inline void hal_srng_access_end_reap(void *hal_soc, void *hal_ring)
  746. {
  747. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  748. SRNG_UNLOCK(&(srng->lock));
  749. }
  750. /* TODO: Check if the following definitions is available in HW headers */
  751. #define WBM_IDLE_DESC_LIST 1
  752. #define WBM_IDLE_SCATTER_BUF_SIZE 32704
  753. #define NUM_MPDUS_PER_LINK_DESC 6
  754. #define NUM_MSDUS_PER_LINK_DESC 7
  755. #define REO_QUEUE_DESC_ALIGN 128
  756. #define LINK_DESC_SIZE (NUM_OF_DWORDS_RX_MSDU_LINK << 2)
  757. #define LINK_DESC_ALIGN 128
  758. #define ADDRESS_MATCH_TAG_VAL 0x5
  759. /* Number of mpdu link pointers is 9 in case of TX_MPDU_QUEUE_HEAD and 14 in
  760. * of TX_MPDU_QUEUE_EXT. We are defining a common average count here
  761. */
  762. #define NUM_MPDU_LINKS_PER_QUEUE_DESC 12
  763. /* TODO: Check with HW team on the scatter buffer size supported. As per WBM
  764. * MLD, scatter_buffer_size in IDLE_LIST_CONTROL register is 9 bits and size
  765. * should be specified in 16 word units. But the number of bits defined for
  766. * this field in HW header files is 5.
  767. */
  768. #define WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE 8
  769. /**
  770. * hal_set_link_desc_addr - Setup link descriptor in a buffer_addr_info
  771. * HW structure
  772. *
  773. * @desc: Descriptor entry (from WBM_IDLE_LINK ring)
  774. * @cookie: SW cookie for the buffer/descriptor
  775. * @link_desc_paddr: Physical address of link descriptor entry
  776. *
  777. */
  778. static inline void hal_set_link_desc_addr(void *desc, uint32_t cookie,
  779. qdf_dma_addr_t link_desc_paddr)
  780. {
  781. uint32_t *buf_addr = (uint32_t *)desc;
  782. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_0, BUFFER_ADDR_31_0,
  783. link_desc_paddr & 0xffffffff);
  784. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_1, BUFFER_ADDR_39_32,
  785. (uint64_t)link_desc_paddr >> 32);
  786. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_1, RETURN_BUFFER_MANAGER,
  787. WBM_IDLE_DESC_LIST);
  788. HAL_DESC_SET_FIELD(buf_addr, BUFFER_ADDR_INFO_1, SW_BUFFER_COOKIE,
  789. cookie);
  790. }
  791. /**
  792. * hal_idle_list_scatter_buf_size - Get the size of each scatter buffer
  793. * in an idle list
  794. *
  795. * @hal_soc: Opaque HAL SOC handle
  796. *
  797. */
  798. static inline uint32_t hal_idle_list_scatter_buf_size(void *hal_soc)
  799. {
  800. return WBM_IDLE_SCATTER_BUF_SIZE;
  801. }
  802. /**
  803. * hal_get_link_desc_size - Get the size of each link descriptor
  804. *
  805. * @hal_soc: Opaque HAL SOC handle
  806. *
  807. */
  808. static inline uint32_t hal_get_link_desc_size(void *hal_soc)
  809. {
  810. return LINK_DESC_SIZE;
  811. }
  812. /**
  813. * hal_get_link_desc_align - Get the required start address alignment for
  814. * link descriptors
  815. *
  816. * @hal_soc: Opaque HAL SOC handle
  817. *
  818. */
  819. static inline uint32_t hal_get_link_desc_align(void *hal_soc)
  820. {
  821. return LINK_DESC_ALIGN;
  822. }
  823. /**
  824. * hal_num_mpdus_per_link_desc - Get number of mpdus each link desc can hold
  825. *
  826. * @hal_soc: Opaque HAL SOC handle
  827. *
  828. */
  829. static inline uint32_t hal_num_mpdus_per_link_desc(void *hal_soc)
  830. {
  831. return NUM_MPDUS_PER_LINK_DESC;
  832. }
  833. /**
  834. * hal_num_msdus_per_link_desc - Get number of msdus each link desc can hold
  835. *
  836. * @hal_soc: Opaque HAL SOC handle
  837. *
  838. */
  839. static inline uint32_t hal_num_msdus_per_link_desc(void *hal_soc)
  840. {
  841. return NUM_MSDUS_PER_LINK_DESC;
  842. }
  843. /**
  844. * hal_num_mpdu_links_per_queue_desc - Get number of mpdu links each queue
  845. * descriptor can hold
  846. *
  847. * @hal_soc: Opaque HAL SOC handle
  848. *
  849. */
  850. static inline uint32_t hal_num_mpdu_links_per_queue_desc(void *hal_soc)
  851. {
  852. return NUM_MPDU_LINKS_PER_QUEUE_DESC;
  853. }
  854. /**
  855. * hal_idle_list_scatter_buf_num_entries - Get the number of link desc entries
  856. * that the given buffer size
  857. *
  858. * @hal_soc: Opaque HAL SOC handle
  859. * @scatter_buf_size: Size of scatter buffer
  860. *
  861. */
  862. static inline uint32_t hal_idle_scatter_buf_num_entries(void *hal_soc,
  863. uint32_t scatter_buf_size)
  864. {
  865. return (scatter_buf_size - WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE) /
  866. hal_srng_get_entrysize(hal_soc, WBM_IDLE_LINK);
  867. }
  868. /**
  869. * hal_idle_list_num_scatter_bufs - Get the number of sctater buffer
  870. * each given buffer size
  871. *
  872. * @hal_soc: Opaque HAL SOC handle
  873. * @total_mem: size of memory to be scattered
  874. * @scatter_buf_size: Size of scatter buffer
  875. *
  876. */
  877. static inline uint32_t hal_idle_list_num_scatter_bufs(void *hal_soc,
  878. uint32_t total_mem, uint32_t scatter_buf_size)
  879. {
  880. uint8_t rem = (total_mem % (scatter_buf_size -
  881. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) ? 1 : 0;
  882. uint32_t num_scatter_bufs = (total_mem / (scatter_buf_size -
  883. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) + rem;
  884. return num_scatter_bufs;
  885. }
  886. /**
  887. * hal_idle_scatter_buf_setup - Setup scattered idle list using the buffer list
  888. * provided
  889. *
  890. * @hal_soc: Opaque HAL SOC handle
  891. * @idle_scatter_bufs_base_paddr: Array of physical base addresses
  892. * @idle_scatter_bufs_base_vaddr: Array of virtual base addresses
  893. * @num_scatter_bufs: Number of scatter buffers in the above lists
  894. * @scatter_buf_size: Size of each scatter buffer
  895. * @last_buf_end_offset: Offset to the last entry
  896. * @num_entries: Total entries of all scatter bufs
  897. *
  898. */
  899. extern void hal_setup_link_idle_list(void *hal_soc,
  900. qdf_dma_addr_t scatter_bufs_base_paddr[],
  901. void *scatter_bufs_base_vaddr[], uint32_t num_scatter_bufs,
  902. uint32_t scatter_buf_size, uint32_t last_buf_end_offset,
  903. uint32_t num_entries);
  904. /* REO parameters to be passed to hal_reo_setup */
  905. struct hal_reo_params {
  906. /** rx hash steering enabled or disabled */
  907. bool rx_hash_enabled;
  908. /** reo remap 1 register */
  909. uint32_t remap1;
  910. /** reo remap 2 register */
  911. uint32_t remap2;
  912. /** fragment destination ring */
  913. uint8_t frag_dst_ring;
  914. /** padding */
  915. uint8_t padding[3];
  916. };
  917. /**
  918. * hal_reo_setup - Initialize HW REO block
  919. *
  920. * @hal_soc: Opaque HAL SOC handle
  921. * @reo_params: parameters needed by HAL for REO config
  922. */
  923. extern void hal_reo_setup(void *hal_soc,
  924. struct hal_reo_params *reo_params);
  925. enum hal_pn_type {
  926. HAL_PN_NONE,
  927. HAL_PN_WPA,
  928. HAL_PN_WAPI_EVEN,
  929. HAL_PN_WAPI_UNEVEN,
  930. };
  931. #define HAL_RX_MAX_BA_WINDOW 256
  932. /**
  933. * hal_get_reo_qdesc_size - Get size of reo queue descriptor
  934. *
  935. * @hal_soc: Opaque HAL SOC handle
  936. * @ba_window_size: BlockAck window size
  937. *
  938. */
  939. static inline uint32_t hal_get_reo_qdesc_size(void *hal_soc,
  940. uint32_t ba_window_size)
  941. {
  942. if (ba_window_size <= 1)
  943. return sizeof(struct rx_reo_queue);
  944. if (ba_window_size <= 105)
  945. return sizeof(struct rx_reo_queue) +
  946. sizeof(struct rx_reo_queue_ext);
  947. if (ba_window_size <= 210)
  948. return sizeof(struct rx_reo_queue) +
  949. (2 * sizeof(struct rx_reo_queue_ext));
  950. return sizeof(struct rx_reo_queue) +
  951. (3 * sizeof(struct rx_reo_queue_ext));
  952. }
  953. /**
  954. * hal_get_reo_qdesc_align - Get start address alignment for reo
  955. * queue descriptors
  956. *
  957. * @hal_soc: Opaque HAL SOC handle
  958. *
  959. */
  960. static inline uint32_t hal_get_reo_qdesc_align(void *hal_soc)
  961. {
  962. return REO_QUEUE_DESC_ALIGN;
  963. }
  964. /**
  965. * hal_reo_qdesc_setup - Setup HW REO queue descriptor
  966. *
  967. * @hal_soc: Opaque HAL SOC handle
  968. * @ba_window_size: BlockAck window size
  969. * @start_seq: Starting sequence number
  970. * @hw_qdesc_vaddr: Virtual address of REO queue descriptor memory
  971. * @hw_qdesc_paddr: Physical address of REO queue descriptor memory
  972. * @pn_type: PN type (one of the types defined in 'enum hal_pn_type')
  973. *
  974. */
  975. extern void hal_reo_qdesc_setup(void *hal_soc, int tid, uint32_t ba_window_size,
  976. uint32_t start_seq, void *hw_qdesc_vaddr, qdf_dma_addr_t hw_qdesc_paddr,
  977. int pn_type);
  978. /**
  979. * hal_srng_get_hp_addr - Get head pointer physical address
  980. *
  981. * @hal_soc: Opaque HAL SOC handle
  982. * @hal_ring: Ring pointer (Source or Destination ring)
  983. *
  984. */
  985. static inline qdf_dma_addr_t hal_srng_get_hp_addr(void *hal_soc, void *hal_ring)
  986. {
  987. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  988. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  989. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  990. return hal->shadow_wrptr_mem_paddr +
  991. ((unsigned long)(srng->u.src_ring.hp_addr) -
  992. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  993. } else {
  994. return hal->shadow_rdptr_mem_paddr +
  995. ((unsigned long)(srng->u.dst_ring.hp_addr) -
  996. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  997. }
  998. }
  999. /**
  1000. * hal_srng_get_tp_addr - Get tail pointer physical address
  1001. *
  1002. * @hal_soc: Opaque HAL SOC handle
  1003. * @hal_ring: Ring pointer (Source or Destination ring)
  1004. *
  1005. */
  1006. static inline qdf_dma_addr_t hal_srng_get_tp_addr(void *hal_soc, void *hal_ring)
  1007. {
  1008. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  1009. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  1010. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  1011. return hal->shadow_rdptr_mem_paddr +
  1012. ((unsigned long)(srng->u.src_ring.tp_addr) -
  1013. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  1014. } else {
  1015. return hal->shadow_wrptr_mem_paddr +
  1016. ((unsigned long)(srng->u.dst_ring.tp_addr) -
  1017. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  1018. }
  1019. }
  1020. /**
  1021. * hal_get_srng_params - Retrieve SRNG parameters for a given ring from HAL
  1022. *
  1023. * @hal_soc: Opaque HAL SOC handle
  1024. * @hal_ring: Ring pointer (Source or Destination ring)
  1025. * @ring_params: SRNG parameters will be returned through this structure
  1026. */
  1027. extern void hal_get_srng_params(void *hal_soc, void *hal_ring,
  1028. struct hal_srng_params *ring_params);
  1029. /**
  1030. * hal_mem_info - Retrieve hal memory base address
  1031. *
  1032. * @hal_soc: Opaque HAL SOC handle
  1033. * @mem: pointer to structure to be updated with hal mem info
  1034. */
  1035. extern void hal_get_meminfo(void *hal_soc,struct hal_mem_info *mem );
  1036. #endif /* _HAL_APIH_ */