hal_api.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HAL_API_H_
  19. #define _HAL_API_H_
  20. #include "qdf_types.h"
  21. #include "qdf_util.h"
  22. #include "hal_internal.h"
  23. #define MAX_UNWINDOWED_ADDRESS 0x80000
  24. #ifdef QCA_WIFI_QCA6390
  25. #define WINDOW_ENABLE_BIT 0x40000000
  26. #else
  27. #define WINDOW_ENABLE_BIT 0x80000000
  28. #endif
  29. #define WINDOW_REG_ADDRESS 0x310C
  30. #define WINDOW_SHIFT 19
  31. #define WINDOW_VALUE_MASK 0x3F
  32. #define WINDOW_START MAX_UNWINDOWED_ADDRESS
  33. #define WINDOW_RANGE_MASK 0x7FFFF
  34. static inline void hal_select_window(struct hal_soc *hal_soc, uint32_t offset)
  35. {
  36. uint32_t window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
  37. if (window != hal_soc->register_window) {
  38. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_REG_ADDRESS,
  39. WINDOW_ENABLE_BIT | window);
  40. hal_soc->register_window = window;
  41. }
  42. }
  43. /**
  44. * note1: WINDOW_RANGE_MASK = (1 << WINDOW_SHIFT) -1
  45. * note2: 1 << WINDOW_SHIFT = MAX_UNWINDOWED_ADDRESS
  46. * note3: WINDOW_VALUE_MASK = big enough that trying to write past that window
  47. * would be a bug
  48. */
  49. static inline void hal_write32_mb(struct hal_soc *hal_soc, uint32_t offset,
  50. uint32_t value)
  51. {
  52. if (!hal_soc->use_register_windowing ||
  53. offset < MAX_UNWINDOWED_ADDRESS) {
  54. qdf_iowrite32(hal_soc->dev_base_addr + offset, value);
  55. } else {
  56. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  57. hal_select_window(hal_soc, offset);
  58. qdf_iowrite32(hal_soc->dev_base_addr + WINDOW_START +
  59. (offset & WINDOW_RANGE_MASK), value);
  60. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  61. }
  62. }
  63. /**
  64. * hal_write_address_32_mb - write a value to a register
  65. *
  66. */
  67. static inline void hal_write_address_32_mb(struct hal_soc *hal_soc,
  68. void __iomem *addr, uint32_t value)
  69. {
  70. uint32_t offset;
  71. if (!hal_soc->use_register_windowing)
  72. return qdf_iowrite32(addr, value);
  73. offset = addr - hal_soc->dev_base_addr;
  74. hal_write32_mb(hal_soc, offset, value);
  75. }
  76. static inline uint32_t hal_read32_mb(struct hal_soc *hal_soc, uint32_t offset)
  77. {
  78. uint32_t ret;
  79. if (!hal_soc->use_register_windowing ||
  80. offset < MAX_UNWINDOWED_ADDRESS) {
  81. return qdf_ioread32(hal_soc->dev_base_addr + offset);
  82. }
  83. qdf_spin_lock_irqsave(&hal_soc->register_access_lock);
  84. hal_select_window(hal_soc, offset);
  85. ret = qdf_ioread32(hal_soc->dev_base_addr + WINDOW_START +
  86. (offset & WINDOW_RANGE_MASK));
  87. qdf_spin_unlock_irqrestore(&hal_soc->register_access_lock);
  88. return ret;
  89. }
  90. #include "hif_io32.h"
  91. /**
  92. * hal_attach - Initialize HAL layer
  93. * @hif_handle: Opaque HIF handle
  94. * @qdf_dev: QDF device
  95. *
  96. * Return: Opaque HAL SOC handle
  97. * NULL on failure (if given ring is not available)
  98. *
  99. * This function should be called as part of HIF initialization (for accessing
  100. * copy engines). DP layer will get hal_soc handle using hif_get_hal_handle()
  101. */
  102. extern void *hal_attach(void *hif_handle, qdf_device_t qdf_dev);
  103. /**
  104. * hal_detach - Detach HAL layer
  105. * @hal_soc: HAL SOC handle
  106. *
  107. * This function should be called as part of HIF detach
  108. *
  109. */
  110. extern void hal_detach(void *hal_soc);
  111. /* SRNG type to be passed in APIs hal_srng_get_entrysize and hal_srng_setup */
  112. enum hal_ring_type {
  113. REO_DST = 0,
  114. REO_EXCEPTION = 1,
  115. REO_REINJECT = 2,
  116. REO_CMD = 3,
  117. REO_STATUS = 4,
  118. TCL_DATA = 5,
  119. TCL_CMD = 6,
  120. TCL_STATUS = 7,
  121. CE_SRC = 8,
  122. CE_DST = 9,
  123. CE_DST_STATUS = 10,
  124. WBM_IDLE_LINK = 11,
  125. SW2WBM_RELEASE = 12,
  126. WBM2SW_RELEASE = 13,
  127. RXDMA_BUF = 14,
  128. RXDMA_DST = 15,
  129. RXDMA_MONITOR_BUF = 16,
  130. RXDMA_MONITOR_STATUS = 17,
  131. RXDMA_MONITOR_DST = 18,
  132. RXDMA_MONITOR_DESC = 19,
  133. DIR_BUF_RX_DMA_SRC = 20,
  134. #ifdef WLAN_FEATURE_CIF_CFR
  135. WIFI_POS_SRC,
  136. #endif
  137. MAX_RING_TYPES
  138. };
  139. #define HAL_SRNG_LMAC_RING 0x80000000
  140. /* SRNG flags passed in hal_srng_params.flags */
  141. #define HAL_SRNG_MSI_SWAP 0x00000008
  142. #define HAL_SRNG_RING_PTR_SWAP 0x00000010
  143. #define HAL_SRNG_DATA_TLV_SWAP 0x00000020
  144. #define HAL_SRNG_LOW_THRES_INTR_ENABLE 0x00010000
  145. #define HAL_SRNG_MSI_INTR 0x00020000
  146. #define PN_SIZE_24 0
  147. #define PN_SIZE_48 1
  148. #define PN_SIZE_128 2
  149. /**
  150. * hal_srng_get_entrysize - Returns size of ring entry in bytes. Should be
  151. * used by callers for calculating the size of memory to be allocated before
  152. * calling hal_srng_setup to setup the ring
  153. *
  154. * @hal_soc: Opaque HAL SOC handle
  155. * @ring_type: one of the types from hal_ring_type
  156. *
  157. */
  158. extern uint32_t hal_srng_get_entrysize(void *hal_soc, int ring_type);
  159. /**
  160. * hal_srng_max_entries - Returns maximum possible number of ring entries
  161. * @hal_soc: Opaque HAL SOC handle
  162. * @ring_type: one of the types from hal_ring_type
  163. *
  164. * Return: Maximum number of entries for the given ring_type
  165. */
  166. uint32_t hal_srng_max_entries(void *hal_soc, int ring_type);
  167. /**
  168. * hal_srng_dump - Dump ring status
  169. * @srng: hal srng pointer
  170. */
  171. void hal_srng_dump(struct hal_srng *srng);
  172. /**
  173. * hal_srng_get_dir - Returns the direction of the ring
  174. * @hal_soc: Opaque HAL SOC handle
  175. * @ring_type: one of the types from hal_ring_type
  176. *
  177. * Return: Ring direction
  178. */
  179. enum hal_srng_dir hal_srng_get_dir(void *hal_soc, int ring_type);
  180. /* HAL memory information */
  181. struct hal_mem_info {
  182. /* dev base virutal addr */
  183. void *dev_base_addr;
  184. /* dev base physical addr */
  185. void *dev_base_paddr;
  186. /* Remote virtual pointer memory for HW/FW updates */
  187. void *shadow_rdptr_mem_vaddr;
  188. /* Remote physical pointer memory for HW/FW updates */
  189. void *shadow_rdptr_mem_paddr;
  190. /* Shared memory for ring pointer updates from host to FW */
  191. void *shadow_wrptr_mem_vaddr;
  192. /* Shared physical memory for ring pointer updates from host to FW */
  193. void *shadow_wrptr_mem_paddr;
  194. };
  195. /* SRNG parameters to be passed to hal_srng_setup */
  196. struct hal_srng_params {
  197. /* Physical base address of the ring */
  198. qdf_dma_addr_t ring_base_paddr;
  199. /* Virtual base address of the ring */
  200. void *ring_base_vaddr;
  201. /* Number of entries in ring */
  202. uint32_t num_entries;
  203. /* max transfer length */
  204. uint16_t max_buffer_length;
  205. /* MSI Address */
  206. qdf_dma_addr_t msi_addr;
  207. /* MSI data */
  208. uint32_t msi_data;
  209. /* Interrupt timer threshold – in micro seconds */
  210. uint32_t intr_timer_thres_us;
  211. /* Interrupt batch counter threshold – in number of ring entries */
  212. uint32_t intr_batch_cntr_thres_entries;
  213. /* Low threshold – in number of ring entries
  214. * (valid for src rings only)
  215. */
  216. uint32_t low_threshold;
  217. /* Misc flags */
  218. uint32_t flags;
  219. /* Unique ring id */
  220. uint8_t ring_id;
  221. /* Source or Destination ring */
  222. enum hal_srng_dir ring_dir;
  223. /* Size of ring entry */
  224. uint32_t entry_size;
  225. /* hw register base address */
  226. void *hwreg_base[MAX_SRNG_REG_GROUPS];
  227. };
  228. /* hal_construct_shadow_config() - initialize the shadow registers for dp rings
  229. * @hal_soc: hal handle
  230. *
  231. * Return: QDF_STATUS_OK on success
  232. */
  233. extern QDF_STATUS hal_construct_shadow_config(void *hal_soc);
  234. /* hal_set_one_shadow_config() - add a config for the specified ring
  235. * @hal_soc: hal handle
  236. * @ring_type: ring type
  237. * @ring_num: ring num
  238. *
  239. * The ring type and ring num uniquely specify the ring. After this call,
  240. * the hp/tp will be added as the next entry int the shadow register
  241. * configuration table. The hal code will use the shadow register address
  242. * in place of the hp/tp address.
  243. *
  244. * This function is exposed, so that the CE module can skip configuring shadow
  245. * registers for unused ring and rings assigned to the firmware.
  246. *
  247. * Return: QDF_STATUS_OK on success
  248. */
  249. extern QDF_STATUS hal_set_one_shadow_config(void *hal_soc, int ring_type,
  250. int ring_num);
  251. /**
  252. * hal_get_shadow_config() - retrieve the config table
  253. * @hal_soc: hal handle
  254. * @shadow_config: will point to the table after
  255. * @num_shadow_registers_configured: will contain the number of valid entries
  256. */
  257. extern void hal_get_shadow_config(void *hal_soc,
  258. struct pld_shadow_reg_v2_cfg **shadow_config,
  259. int *num_shadow_registers_configured);
  260. /**
  261. * hal_srng_setup - Initialize HW SRNG ring.
  262. *
  263. * @hal_soc: Opaque HAL SOC handle
  264. * @ring_type: one of the types from hal_ring_type
  265. * @ring_num: Ring number if there are multiple rings of
  266. * same type (staring from 0)
  267. * @mac_id: valid MAC Id should be passed if ring type is one of lmac rings
  268. * @ring_params: SRNG ring params in hal_srng_params structure.
  269. * Callers are expected to allocate contiguous ring memory of size
  270. * 'num_entries * entry_size' bytes and pass the physical and virtual base
  271. * addresses through 'ring_base_paddr' and 'ring_base_vaddr' in hal_srng_params
  272. * structure. Ring base address should be 8 byte aligned and size of each ring
  273. * entry should be queried using the API hal_srng_get_entrysize
  274. *
  275. * Return: Opaque pointer to ring on success
  276. * NULL on failure (if given ring is not available)
  277. */
  278. extern void *hal_srng_setup(void *hal_soc, int ring_type, int ring_num,
  279. int mac_id, struct hal_srng_params *ring_params);
  280. /* Remapping ids of REO rings */
  281. #define REO_REMAP_TCL 0
  282. #define REO_REMAP_SW1 1
  283. #define REO_REMAP_SW2 2
  284. #define REO_REMAP_SW3 3
  285. #define REO_REMAP_SW4 4
  286. #define REO_REMAP_RELEASE 5
  287. #define REO_REMAP_FW 6
  288. #define REO_REMAP_UNUSED 7
  289. /*
  290. * currently this macro only works for IX0 since all the rings we are remapping
  291. * can be remapped from HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0
  292. */
  293. #define HAL_REO_REMAP_VAL(_ORIGINAL_DEST, _NEW_DEST) \
  294. HAL_REO_REMAP_VAL_(_ORIGINAL_DEST, _NEW_DEST)
  295. /* allow the destination macros to be expanded */
  296. #define HAL_REO_REMAP_VAL_(_ORIGINAL_DEST, _NEW_DEST) \
  297. (_NEW_DEST << \
  298. (HWIO_REO_R0_DESTINATION_RING_CTRL_IX_0_DEST_RING_MAPPING_ ## \
  299. _ORIGINAL_DEST ## _SHFT))
  300. /**
  301. * hal_reo_remap_IX0 - Remap REO ring destination
  302. * @hal: HAL SOC handle
  303. * @remap_val: Remap value
  304. */
  305. extern void hal_reo_remap_IX0(struct hal_soc *hal, uint32_t remap_val);
  306. /**
  307. * hal_srng_set_hp_paddr() - Set physical address to dest SRNG head pointer
  308. * @sring: sring pointer
  309. * @paddr: physical address
  310. */
  311. extern void hal_srng_dst_set_hp_paddr(struct hal_srng *sring, uint64_t paddr);
  312. /**
  313. * hal_srng_dst_init_hp() - Initilaize head pointer with cached head pointer
  314. * @srng: sring pointer
  315. * @vaddr: virtual address
  316. */
  317. extern void hal_srng_dst_init_hp(struct hal_srng *srng, uint32_t *vaddr);
  318. /**
  319. * hal_srng_cleanup - Deinitialize HW SRNG ring.
  320. * @hal_soc: Opaque HAL SOC handle
  321. * @hal_srng: Opaque HAL SRNG pointer
  322. */
  323. extern void hal_srng_cleanup(void *hal_soc, void *hal_srng);
  324. static inline bool hal_srng_initialized(void *hal_ring)
  325. {
  326. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  327. return !!srng->initialized;
  328. }
  329. /**
  330. * hal_srng_access_start_unlocked - Start ring access (unlocked). Should use
  331. * hal_srng_access_start if locked access is required
  332. *
  333. * @hal_soc: Opaque HAL SOC handle
  334. * @hal_ring: Ring pointer (Source or Destination ring)
  335. *
  336. * Return: 0 on success; error on failire
  337. */
  338. static inline int hal_srng_access_start_unlocked(void *hal_soc, void *hal_ring)
  339. {
  340. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  341. if (srng->ring_dir == HAL_SRNG_SRC_RING)
  342. srng->u.src_ring.cached_tp =
  343. *(volatile uint32_t *)(srng->u.src_ring.tp_addr);
  344. else
  345. srng->u.dst_ring.cached_hp =
  346. *(volatile uint32_t *)(srng->u.dst_ring.hp_addr);
  347. return 0;
  348. }
  349. /**
  350. * hal_srng_access_start - Start (locked) ring access
  351. *
  352. * @hal_soc: Opaque HAL SOC handle
  353. * @hal_ring: Ring pointer (Source or Destination ring)
  354. *
  355. * Return: 0 on success; error on failire
  356. */
  357. static inline int hal_srng_access_start(void *hal_soc, void *hal_ring)
  358. {
  359. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  360. if (qdf_unlikely(!hal_ring)) {
  361. qdf_print("Error: Invalid hal_ring\n");
  362. return -EINVAL;
  363. }
  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_t hp;
  454. uint32_t 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_t tp;
  663. uint32_t 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. if (qdf_unlikely(!hal_ring)) {
  724. qdf_print("Error: Invalid hal_ring\n");
  725. return;
  726. }
  727. hal_srng_access_end_unlocked(hal_soc, hal_ring);
  728. SRNG_UNLOCK(&(srng->lock));
  729. }
  730. /**
  731. * hal_srng_access_end_reap - Unlock ring access
  732. * This should be used only if hal_srng_access_start to start ring access
  733. * and should be used only while reaping SRC ring completions
  734. *
  735. * @hal_soc: Opaque HAL SOC handle
  736. * @hal_ring: Ring pointer (Source or Destination ring)
  737. *
  738. * Return: 0 on success; error on failire
  739. */
  740. static inline void hal_srng_access_end_reap(void *hal_soc, void *hal_ring)
  741. {
  742. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  743. SRNG_UNLOCK(&(srng->lock));
  744. }
  745. /* TODO: Check if the following definitions is available in HW headers */
  746. #define WBM_IDLE_SCATTER_BUF_SIZE 32704
  747. #define NUM_MPDUS_PER_LINK_DESC 6
  748. #define NUM_MSDUS_PER_LINK_DESC 7
  749. #define REO_QUEUE_DESC_ALIGN 128
  750. #define LINK_DESC_ALIGN 128
  751. #define ADDRESS_MATCH_TAG_VAL 0x5
  752. /* Number of mpdu link pointers is 9 in case of TX_MPDU_QUEUE_HEAD and 14 in
  753. * of TX_MPDU_QUEUE_EXT. We are defining a common average count here
  754. */
  755. #define NUM_MPDU_LINKS_PER_QUEUE_DESC 12
  756. /* TODO: Check with HW team on the scatter buffer size supported. As per WBM
  757. * MLD, scatter_buffer_size in IDLE_LIST_CONTROL register is 9 bits and size
  758. * should be specified in 16 word units. But the number of bits defined for
  759. * this field in HW header files is 5.
  760. */
  761. #define WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE 8
  762. /**
  763. * hal_idle_list_scatter_buf_size - Get the size of each scatter buffer
  764. * in an idle list
  765. *
  766. * @hal_soc: Opaque HAL SOC handle
  767. *
  768. */
  769. static inline uint32_t hal_idle_list_scatter_buf_size(void *hal_soc)
  770. {
  771. return WBM_IDLE_SCATTER_BUF_SIZE;
  772. }
  773. /**
  774. * hal_get_link_desc_size - Get the size of each link descriptor
  775. *
  776. * @hal_soc: Opaque HAL SOC handle
  777. *
  778. */
  779. static inline uint32_t hal_get_link_desc_size(struct hal_soc *hal_soc)
  780. {
  781. if (!hal_soc || !hal_soc->ops) {
  782. qdf_print("Error: Invalid ops\n");
  783. QDF_BUG(0);
  784. return -EINVAL;
  785. }
  786. if (!hal_soc->ops->hal_get_link_desc_size) {
  787. qdf_print("Error: Invalid function pointer\n");
  788. QDF_BUG(0);
  789. return -EINVAL;
  790. }
  791. return hal_soc->ops->hal_get_link_desc_size();
  792. }
  793. /**
  794. * hal_get_link_desc_align - Get the required start address alignment for
  795. * link descriptors
  796. *
  797. * @hal_soc: Opaque HAL SOC handle
  798. *
  799. */
  800. static inline uint32_t hal_get_link_desc_align(void *hal_soc)
  801. {
  802. return LINK_DESC_ALIGN;
  803. }
  804. /**
  805. * hal_num_mpdus_per_link_desc - Get number of mpdus each link desc can hold
  806. *
  807. * @hal_soc: Opaque HAL SOC handle
  808. *
  809. */
  810. static inline uint32_t hal_num_mpdus_per_link_desc(void *hal_soc)
  811. {
  812. return NUM_MPDUS_PER_LINK_DESC;
  813. }
  814. /**
  815. * hal_num_msdus_per_link_desc - Get number of msdus each link desc can hold
  816. *
  817. * @hal_soc: Opaque HAL SOC handle
  818. *
  819. */
  820. static inline uint32_t hal_num_msdus_per_link_desc(void *hal_soc)
  821. {
  822. return NUM_MSDUS_PER_LINK_DESC;
  823. }
  824. /**
  825. * hal_num_mpdu_links_per_queue_desc - Get number of mpdu links each queue
  826. * descriptor can hold
  827. *
  828. * @hal_soc: Opaque HAL SOC handle
  829. *
  830. */
  831. static inline uint32_t hal_num_mpdu_links_per_queue_desc(void *hal_soc)
  832. {
  833. return NUM_MPDU_LINKS_PER_QUEUE_DESC;
  834. }
  835. /**
  836. * hal_idle_list_scatter_buf_num_entries - Get the number of link desc entries
  837. * that the given buffer size
  838. *
  839. * @hal_soc: Opaque HAL SOC handle
  840. * @scatter_buf_size: Size of scatter buffer
  841. *
  842. */
  843. static inline uint32_t hal_idle_scatter_buf_num_entries(void *hal_soc,
  844. uint32_t scatter_buf_size)
  845. {
  846. return (scatter_buf_size - WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE) /
  847. hal_srng_get_entrysize(hal_soc, WBM_IDLE_LINK);
  848. }
  849. /**
  850. * hal_idle_list_num_scatter_bufs - Get the number of sctater buffer
  851. * each given buffer size
  852. *
  853. * @hal_soc: Opaque HAL SOC handle
  854. * @total_mem: size of memory to be scattered
  855. * @scatter_buf_size: Size of scatter buffer
  856. *
  857. */
  858. static inline uint32_t hal_idle_list_num_scatter_bufs(void *hal_soc,
  859. uint32_t total_mem, uint32_t scatter_buf_size)
  860. {
  861. uint8_t rem = (total_mem % (scatter_buf_size -
  862. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) ? 1 : 0;
  863. uint32_t num_scatter_bufs = (total_mem / (scatter_buf_size -
  864. WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE)) + rem;
  865. return num_scatter_bufs;
  866. }
  867. /* REO parameters to be passed to hal_reo_setup */
  868. struct hal_reo_params {
  869. /** rx hash steering enabled or disabled */
  870. bool rx_hash_enabled;
  871. /** reo remap 1 register */
  872. uint32_t remap1;
  873. /** reo remap 2 register */
  874. uint32_t remap2;
  875. /** fragment destination ring */
  876. uint8_t frag_dst_ring;
  877. /** padding */
  878. uint8_t padding[3];
  879. };
  880. enum hal_pn_type {
  881. HAL_PN_NONE,
  882. HAL_PN_WPA,
  883. HAL_PN_WAPI_EVEN,
  884. HAL_PN_WAPI_UNEVEN,
  885. };
  886. #define HAL_RX_MAX_BA_WINDOW 256
  887. /**
  888. * hal_get_reo_qdesc_align - Get start address alignment for reo
  889. * queue descriptors
  890. *
  891. * @hal_soc: Opaque HAL SOC handle
  892. *
  893. */
  894. static inline uint32_t hal_get_reo_qdesc_align(void *hal_soc)
  895. {
  896. return REO_QUEUE_DESC_ALIGN;
  897. }
  898. /**
  899. * hal_reo_qdesc_setup - Setup HW REO queue descriptor
  900. *
  901. * @hal_soc: Opaque HAL SOC handle
  902. * @ba_window_size: BlockAck window size
  903. * @start_seq: Starting sequence number
  904. * @hw_qdesc_vaddr: Virtual address of REO queue descriptor memory
  905. * @hw_qdesc_paddr: Physical address of REO queue descriptor memory
  906. * @pn_type: PN type (one of the types defined in 'enum hal_pn_type')
  907. *
  908. */
  909. extern void hal_reo_qdesc_setup(void *hal_soc, int tid, uint32_t ba_window_size,
  910. uint32_t start_seq, void *hw_qdesc_vaddr, qdf_dma_addr_t hw_qdesc_paddr,
  911. int pn_type);
  912. /**
  913. * hal_srng_get_hp_addr - Get head pointer physical address
  914. *
  915. * @hal_soc: Opaque HAL SOC handle
  916. * @hal_ring: Ring pointer (Source or Destination ring)
  917. *
  918. */
  919. static inline qdf_dma_addr_t hal_srng_get_hp_addr(void *hal_soc, void *hal_ring)
  920. {
  921. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  922. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  923. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  924. return hal->shadow_wrptr_mem_paddr +
  925. ((unsigned long)(srng->u.src_ring.hp_addr) -
  926. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  927. } else {
  928. return hal->shadow_rdptr_mem_paddr +
  929. ((unsigned long)(srng->u.dst_ring.hp_addr) -
  930. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  931. }
  932. }
  933. /**
  934. * hal_srng_get_tp_addr - Get tail pointer physical address
  935. *
  936. * @hal_soc: Opaque HAL SOC handle
  937. * @hal_ring: Ring pointer (Source or Destination ring)
  938. *
  939. */
  940. static inline qdf_dma_addr_t hal_srng_get_tp_addr(void *hal_soc, void *hal_ring)
  941. {
  942. struct hal_srng *srng = (struct hal_srng *)hal_ring;
  943. struct hal_soc *hal = (struct hal_soc *)hal_soc;
  944. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  945. return hal->shadow_rdptr_mem_paddr +
  946. ((unsigned long)(srng->u.src_ring.tp_addr) -
  947. (unsigned long)(hal->shadow_rdptr_mem_vaddr));
  948. } else {
  949. return hal->shadow_wrptr_mem_paddr +
  950. ((unsigned long)(srng->u.dst_ring.tp_addr) -
  951. (unsigned long)(hal->shadow_wrptr_mem_vaddr));
  952. }
  953. }
  954. /**
  955. * hal_get_srng_params - Retrieve SRNG parameters for a given ring from HAL
  956. *
  957. * @hal_soc: Opaque HAL SOC handle
  958. * @hal_ring: Ring pointer (Source or Destination ring)
  959. * @ring_params: SRNG parameters will be returned through this structure
  960. */
  961. extern void hal_get_srng_params(void *hal_soc, void *hal_ring,
  962. struct hal_srng_params *ring_params);
  963. /**
  964. * hal_mem_info - Retrieve hal memory base address
  965. *
  966. * @hal_soc: Opaque HAL SOC handle
  967. * @mem: pointer to structure to be updated with hal mem info
  968. */
  969. extern void hal_get_meminfo(void *hal_soc,struct hal_mem_info *mem );
  970. /**
  971. * hal_get_target_type - Return target type
  972. *
  973. * @hal_soc: Opaque HAL SOC handle
  974. */
  975. uint32_t hal_get_target_type(struct hal_soc *hal);
  976. /**
  977. * hal_get_ba_aging_timeout - Retrieve BA aging timeout
  978. *
  979. * @hal_soc: Opaque HAL SOC handle
  980. * @ac: Access category
  981. * @value: timeout duration in millisec
  982. */
  983. void hal_get_ba_aging_timeout(void *hal_soc, uint8_t ac,
  984. uint32_t *value);
  985. /**
  986. * hal_set_aging_timeout - Set BA aging timeout
  987. *
  988. * @hal_soc: Opaque HAL SOC handle
  989. * @ac: Access category in millisec
  990. * @value: timeout duration value
  991. */
  992. void hal_set_ba_aging_timeout(void *hal_soc, uint8_t ac,
  993. uint32_t value);
  994. /**
  995. * hal_srng_dst_hw_init - Private function to initialize SRNG
  996. * destination ring HW
  997. * @hal_soc: HAL SOC handle
  998. * @srng: SRNG ring pointer
  999. */
  1000. static inline void hal_srng_dst_hw_init(struct hal_soc *hal,
  1001. struct hal_srng *srng)
  1002. {
  1003. hal->ops->hal_srng_dst_hw_init(hal, srng);
  1004. }
  1005. /**
  1006. * hal_srng_src_hw_init - Private function to initialize SRNG
  1007. * source ring HW
  1008. * @hal_soc: HAL SOC handle
  1009. * @srng: SRNG ring pointer
  1010. */
  1011. static inline void hal_srng_src_hw_init(struct hal_soc *hal,
  1012. struct hal_srng *srng)
  1013. {
  1014. hal->ops->hal_srng_src_hw_init(hal, srng);
  1015. }
  1016. /**
  1017. * hal_reo_setup - Initialize HW REO block
  1018. *
  1019. * @hal_soc: Opaque HAL SOC handle
  1020. * @reo_params: parameters needed by HAL for REO config
  1021. */
  1022. static inline void hal_reo_setup(void *halsoc,
  1023. void *reoparams)
  1024. {
  1025. struct hal_soc *hal_soc = (struct hal_soc *)halsoc;
  1026. hal_soc->ops->hal_reo_setup(halsoc, reoparams);
  1027. }
  1028. /**
  1029. * hal_setup_link_idle_list - Setup scattered idle list using the
  1030. * buffer list provided
  1031. *
  1032. * @hal_soc: Opaque HAL SOC handle
  1033. * @scatter_bufs_base_paddr: Array of physical base addresses
  1034. * @scatter_bufs_base_vaddr: Array of virtual base addresses
  1035. * @num_scatter_bufs: Number of scatter buffers in the above lists
  1036. * @scatter_buf_size: Size of each scatter buffer
  1037. * @last_buf_end_offset: Offset to the last entry
  1038. * @num_entries: Total entries of all scatter bufs
  1039. *
  1040. */
  1041. static inline void hal_setup_link_idle_list(void *halsoc,
  1042. qdf_dma_addr_t scatter_bufs_base_paddr[],
  1043. void *scatter_bufs_base_vaddr[], uint32_t num_scatter_bufs,
  1044. uint32_t scatter_buf_size, uint32_t last_buf_end_offset,
  1045. uint32_t num_entries)
  1046. {
  1047. struct hal_soc *hal_soc = (struct hal_soc *)halsoc;
  1048. hal_soc->ops->hal_setup_link_idle_list(halsoc, scatter_bufs_base_paddr,
  1049. scatter_bufs_base_vaddr, num_scatter_bufs,
  1050. scatter_buf_size, last_buf_end_offset,
  1051. num_entries);
  1052. }
  1053. #endif /* _HAL_APIH_ */