hal_api.h 33 KB

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