hal_api.h 33 KB

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