qdf_mem.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268
  1. /*
  2. * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: qdf_mem
  21. * QCA driver framework (QDF) memory management APIs
  22. */
  23. #if !defined(__QDF_MEMORY_H)
  24. #define __QDF_MEMORY_H
  25. /* Include Files */
  26. #include <qdf_types.h>
  27. #include <i_qdf_mem.h>
  28. #include <i_qdf_trace.h>
  29. #include <qdf_atomic.h>
  30. #define QDF_CACHE_LINE_SZ __qdf_cache_line_sz
  31. /**
  32. * qdf_align() - align to the given size.
  33. * @a: input that needs to be aligned.
  34. * @align_size: boundary on which 'a' has to be alinged.
  35. *
  36. * Return: aligned value.
  37. */
  38. #define qdf_align(a, align_size) __qdf_align(a, align_size)
  39. #define qdf_page_size __page_size
  40. /**
  41. * struct qdf_mem_dma_page_t - Allocated dmaable page
  42. * @page_v_addr_start: Page start virtual address
  43. * @page_v_addr_end: Page end virtual address
  44. * @page_p_addr: Page start physical address
  45. */
  46. struct qdf_mem_dma_page_t {
  47. char *page_v_addr_start;
  48. char *page_v_addr_end;
  49. qdf_dma_addr_t page_p_addr;
  50. };
  51. /**
  52. * struct qdf_mem_multi_page_t - multiple page allocation information storage
  53. * @num_element_per_page: Number of element in single page
  54. * @num_pages: Number of allocation needed pages
  55. * @dma_pages: page information storage in case of coherent memory
  56. * @cacheable_pages: page information storage in case of cacheable memory
  57. * @is_mem_prealloc: flag for multiple pages pre-alloc or not
  58. */
  59. struct qdf_mem_multi_page_t {
  60. uint16_t num_element_per_page;
  61. uint16_t num_pages;
  62. struct qdf_mem_dma_page_t *dma_pages;
  63. void **cacheable_pages;
  64. qdf_size_t page_size;
  65. #ifdef DP_MEM_PRE_ALLOC
  66. uint8_t is_mem_prealloc;
  67. #endif
  68. };
  69. /* Preprocessor definitions and constants */
  70. typedef __qdf_mempool_t qdf_mempool_t;
  71. /**
  72. * qdf_mem_init() - Initialize QDF memory module
  73. *
  74. * Return: None
  75. *
  76. */
  77. void qdf_mem_init(void);
  78. /**
  79. * qdf_mem_exit() - Exit QDF memory module
  80. *
  81. * Return: None
  82. *
  83. */
  84. void qdf_mem_exit(void);
  85. #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI
  86. #define qdf_untracked_mem_malloc(size) \
  87. __qdf_untracked_mem_malloc(size, __func__, __LINE__)
  88. #define qdf_untracked_mem_free(ptr) \
  89. __qdf_untracked_mem_free(ptr)
  90. #endif
  91. #define QDF_MEM_FUNC_NAME_SIZE 48
  92. #ifdef MEMORY_DEBUG
  93. /**
  94. * qdf_mem_debug_config_get() - Get the user configuration of mem_debug_disabled
  95. *
  96. * Return: value of mem_debug_disabled qdf module argument
  97. */
  98. bool qdf_mem_debug_config_get(void);
  99. #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI
  100. /**
  101. * qdf_mem_debug_disabled_set() - Set mem_debug_disabled
  102. * @str_value: value of the module param
  103. *
  104. * This function will set qdf module param mem_debug_disabled
  105. *
  106. * Return: QDF_STATUS_SUCCESS on Success
  107. */
  108. QDF_STATUS qdf_mem_debug_disabled_config_set(const char *str_value);
  109. #endif
  110. /**
  111. * qdf_mem_malloc_atomic_debug() - debug version of QDF memory allocation API
  112. * @size: Number of bytes of memory to allocate.
  113. * @func: Function name of the call site
  114. * @line: Line number of the call site
  115. * @caller: Address of the caller function
  116. *
  117. * This function will dynamicallly allocate the specified number of bytes of
  118. * memory and add it to the qdf tracking list to check for memory leaks and
  119. * corruptions
  120. *
  121. * Return: A valid memory location on success, or NULL on failure
  122. */
  123. void *qdf_mem_malloc_atomic_debug(size_t size, const char *func,
  124. uint32_t line, void *caller);
  125. /**
  126. * qdf_mem_malloc_atomic_debug_fl() - allocation QDF memory atomically
  127. * @size: Number of bytes of memory to allocate.
  128. *
  129. * This function will dynamicallly allocate the specified number of bytes of
  130. * memory.
  131. *
  132. * Return:
  133. * Upon successful allocate, returns a non-NULL pointer to the allocated
  134. * memory. If this function is unable to allocate the amount of memory
  135. * specified (for any reason) it returns NULL.
  136. */
  137. void *qdf_mem_malloc_atomic_debug_fl(qdf_size_t size, const char *func,
  138. uint32_t line);
  139. /**
  140. * qdf_mem_malloc_debug() - debug version of QDF memory allocation API
  141. * @size: Number of bytes of memory to allocate.
  142. * @func: Function name of the call site
  143. * @line: Line number of the call site
  144. * @caller: Address of the caller function
  145. * @flag: GFP flag
  146. *
  147. * This function will dynamicallly allocate the specified number of bytes of
  148. * memory and add it to the qdf tracking list to check for memory leaks and
  149. * corruptions
  150. *
  151. * Return: A valid memory location on success, or NULL on failure
  152. */
  153. void *qdf_mem_malloc_debug(size_t size, const char *func, uint32_t line,
  154. void *caller, uint32_t flag);
  155. #define qdf_mem_malloc(size) \
  156. qdf_mem_malloc_debug(size, __func__, __LINE__, QDF_RET_IP, 0)
  157. #define qdf_mem_malloc_fl(size, func, line) \
  158. qdf_mem_malloc_debug(size, func, line, QDF_RET_IP, 0)
  159. #define qdf_mem_malloc_atomic(size) \
  160. qdf_mem_malloc_atomic_debug(size, __func__, __LINE__, QDF_RET_IP)
  161. /**
  162. * qdf_mem_free_debug() - debug version of qdf_mem_free
  163. * @ptr: Pointer to the starting address of the memory to be freed.
  164. *
  165. * This function will free the memory pointed to by 'ptr'. It also checks for
  166. * memory corruption, underrun, overrun, double free, domain mismatch, etc.
  167. *
  168. * Return: none
  169. */
  170. void qdf_mem_free_debug(void *ptr, const char *file, uint32_t line);
  171. #define qdf_mem_free(ptr) \
  172. qdf_mem_free_debug(ptr, __func__, __LINE__)
  173. void qdf_mem_multi_pages_alloc_debug(qdf_device_t osdev,
  174. struct qdf_mem_multi_page_t *pages,
  175. size_t element_size, uint32_t element_num,
  176. qdf_dma_context_t memctxt, bool cacheable,
  177. const char *func, uint32_t line,
  178. void *caller);
  179. #define qdf_mem_multi_pages_alloc(osdev, pages, element_size, element_num,\
  180. memctxt, cacheable) \
  181. qdf_mem_multi_pages_alloc_debug(osdev, pages, element_size, \
  182. element_num, memctxt, cacheable, \
  183. __func__, __LINE__, QDF_RET_IP)
  184. void qdf_mem_multi_pages_free_debug(qdf_device_t osdev,
  185. struct qdf_mem_multi_page_t *pages,
  186. qdf_dma_context_t memctxt, bool cacheable,
  187. const char *func, uint32_t line);
  188. #define qdf_mem_multi_pages_free(osdev, pages, memctxt, cacheable) \
  189. qdf_mem_multi_pages_free_debug(osdev, pages, memctxt, cacheable, \
  190. __func__, __LINE__)
  191. /**
  192. * qdf_mem_check_for_leaks() - Assert that the current memory domain is empty
  193. *
  194. * Call this to ensure there are no active memory allocations being tracked
  195. * against the current debug domain. For example, one should call this function
  196. * immediately before a call to qdf_debug_domain_set() as a memory leak
  197. * detection mechanism.
  198. *
  199. * e.g.
  200. * qdf_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE);
  201. *
  202. * ...
  203. *
  204. * // memory is allocated and freed
  205. *
  206. * ...
  207. *
  208. * // before transitioning back to inactive state,
  209. * // make sure all active memory has been freed
  210. * qdf_mem_check_for_leaks();
  211. * qdf_debug_domain_set(QDF_DEBUG_DOMAIN_INIT);
  212. *
  213. * ...
  214. *
  215. * // also, before program exit, make sure init time memory is freed
  216. * qdf_mem_check_for_leaks();
  217. * exit();
  218. *
  219. * Return: None
  220. */
  221. void qdf_mem_check_for_leaks(void);
  222. /**
  223. * qdf_mem_alloc_consistent_debug() - allocates consistent qdf memory
  224. * @osdev: OS device handle
  225. * @dev: Pointer to device handle
  226. * @size: Size to be allocated
  227. * @paddr: Physical address
  228. * @func: Function name of the call site
  229. * @line: line numbe rof the call site
  230. * @caller: Address of the caller function
  231. *
  232. * Return: pointer of allocated memory or null if memory alloc fails
  233. */
  234. void *qdf_mem_alloc_consistent_debug(qdf_device_t osdev, void *dev,
  235. qdf_size_t size, qdf_dma_addr_t *paddr,
  236. const char *func, uint32_t line,
  237. void *caller);
  238. #define qdf_mem_alloc_consistent(osdev, dev, size, paddr) \
  239. qdf_mem_alloc_consistent_debug(osdev, dev, size, paddr, \
  240. __func__, __LINE__, QDF_RET_IP)
  241. /**
  242. * qdf_mem_free_consistent_debug() - free consistent qdf memory
  243. * @osdev: OS device handle
  244. * @size: Size to be allocated
  245. * @vaddr: virtual address
  246. * @paddr: Physical address
  247. * @memctx: Pointer to DMA context
  248. * @func: Function name of the call site
  249. * @line: line numbe rof the call site
  250. *
  251. * Return: none
  252. */
  253. void qdf_mem_free_consistent_debug(qdf_device_t osdev, void *dev,
  254. qdf_size_t size, void *vaddr,
  255. qdf_dma_addr_t paddr,
  256. qdf_dma_context_t memctx,
  257. const char *func, uint32_t line);
  258. #define qdf_mem_free_consistent(osdev, dev, size, vaddr, paddr, memctx) \
  259. qdf_mem_free_consistent_debug(osdev, dev, size, vaddr, paddr, memctx, \
  260. __func__, __LINE__)
  261. #else
  262. static inline bool qdf_mem_debug_config_get(void)
  263. {
  264. return false;
  265. }
  266. static inline
  267. QDF_STATUS qdf_mem_debug_disabled_config_set(const char *str_value)
  268. {
  269. return QDF_STATUS_SUCCESS;
  270. }
  271. /**
  272. * qdf_mem_malloc() - allocation QDF memory
  273. * @size: Number of bytes of memory to allocate.
  274. *
  275. * This function will dynamicallly allocate the specified number of bytes of
  276. * memory.
  277. *
  278. * Return:
  279. * Upon successful allocate, returns a non-NULL pointer to the allocated
  280. * memory. If this function is unable to allocate the amount of memory
  281. * specified (for any reason) it returns NULL.
  282. */
  283. #define qdf_mem_malloc(size) \
  284. __qdf_mem_malloc(size, __func__, __LINE__)
  285. #define qdf_mem_malloc_fl(size, func, line) \
  286. __qdf_mem_malloc(size, func, line)
  287. /**
  288. * qdf_mem_malloc_atomic() - allocation QDF memory atomically
  289. * @size: Number of bytes of memory to allocate.
  290. *
  291. * This function will dynamicallly allocate the specified number of bytes of
  292. * memory.
  293. *
  294. * Return:
  295. * Upon successful allocate, returns a non-NULL pointer to the allocated
  296. * memory. If this function is unable to allocate the amount of memory
  297. * specified (for any reason) it returns NULL.
  298. */
  299. #define qdf_mem_malloc_atomic(size) \
  300. qdf_mem_malloc_atomic_fl(size, __func__, __LINE__)
  301. void *qdf_mem_malloc_atomic_fl(qdf_size_t size,
  302. const char *func,
  303. uint32_t line);
  304. #define qdf_mem_free(ptr) \
  305. __qdf_mem_free(ptr)
  306. static inline void qdf_mem_check_for_leaks(void) { }
  307. #define qdf_mem_alloc_consistent(osdev, dev, size, paddr) \
  308. __qdf_mem_alloc_consistent(osdev, dev, size, paddr, __func__, __LINE__)
  309. #define qdf_mem_free_consistent(osdev, dev, size, vaddr, paddr, memctx) \
  310. __qdf_mem_free_consistent(osdev, dev, size, vaddr, paddr, memctx)
  311. void qdf_mem_multi_pages_alloc(qdf_device_t osdev,
  312. struct qdf_mem_multi_page_t *pages,
  313. size_t element_size, uint32_t element_num,
  314. qdf_dma_context_t memctxt, bool cacheable);
  315. void qdf_mem_multi_pages_free(qdf_device_t osdev,
  316. struct qdf_mem_multi_page_t *pages,
  317. qdf_dma_context_t memctxt, bool cacheable);
  318. #endif /* MEMORY_DEBUG */
  319. /**
  320. * qdf_mem_malloc_flags: Get mem allocation flags
  321. *
  322. * Return the flag to be use for memory allocation
  323. * based on the context
  324. *
  325. * Returns: Based on the context, returns the GFP flag
  326. * for memory alloaction
  327. */
  328. int qdf_mem_malloc_flags(void);
  329. /**
  330. * qdf_prealloc_disabled_config_get() - Get the user configuration of
  331. * prealloc_disabled
  332. *
  333. * Return: value of prealloc_disabled qdf module argument
  334. */
  335. bool qdf_prealloc_disabled_config_get(void);
  336. #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI
  337. /**
  338. * qdf_prealloc_disabled_config_set() - Set prealloc_disabled
  339. * @str_value: value of the module param
  340. *
  341. * This function will set qdf module param prealloc_disabled
  342. *
  343. * Return: QDF_STATUS_SUCCESS on Success
  344. */
  345. QDF_STATUS qdf_prealloc_disabled_config_set(const char *str_value);
  346. #endif
  347. /**
  348. * qdf_mem_multi_pages_zero() - zero out each page memory
  349. * @pages: Multi page information storage
  350. * @cacheable: Coherent memory or cacheable memory
  351. *
  352. * This function will zero out each page memory
  353. *
  354. * Return: None
  355. */
  356. void qdf_mem_multi_pages_zero(struct qdf_mem_multi_page_t *pages,
  357. bool cacheable);
  358. /**
  359. * qdf_aligned_malloc() - allocates aligned QDF memory.
  360. * @size: Size to be allocated
  361. * @vaddr_unaligned: Unaligned virtual address.
  362. * @paddr_unaligned: Unaligned physical address.
  363. * @paddr_aligned: Aligned physical address.
  364. * @align: Base address alignment.
  365. * @func: Function name of the call site.
  366. * @line: Line number of the call site.
  367. *
  368. * This function will dynamically allocate the specified number of bytes of
  369. * memory. Checks if the allocated base address is aligned with base_align.
  370. * If not, it frees the allocated memory, adds base_align to alloc size and
  371. * re-allocates the memory.
  372. *
  373. * Return:
  374. * Upon successful allocate, returns an aligned base address of the allocated
  375. * memory. If this function is unable to allocate the amount of memory
  376. * specified (for any reason) it returns NULL.
  377. */
  378. #define qdf_aligned_malloc(size, vaddr_unaligned, paddr_unaligned, \
  379. paddr_aligned, align) \
  380. qdf_aligned_malloc_fl(size, vaddr_unaligned, paddr_unaligned, \
  381. paddr_aligned, align, __func__, __LINE__)
  382. void *qdf_aligned_malloc_fl(uint32_t *size, void **vaddr_unaligned,
  383. qdf_dma_addr_t *paddr_unaligned,
  384. qdf_dma_addr_t *paddr_aligned,
  385. uint32_t align,
  386. const char *func, uint32_t line);
  387. /**
  388. * qdf_aligned_mem_alloc_consistent() - allocates consistent qdf memory
  389. * @osdev: OS device handle
  390. * @size: Size to be allocated
  391. * @vaddr_unaligned: Unaligned virtual address.
  392. * @paddr_unaligned: Unaligned physical address.
  393. * @paddr_aligned: Aligned physical address.
  394. * @align: Base address alignment.
  395. * @func: Function name of the call site.
  396. * @line: Line number of the call site.
  397. *
  398. * Return: pointer of allocated memory or null if memory alloc fails.
  399. */
  400. #define qdf_aligned_mem_alloc_consistent(osdev, size, vaddr_unaligned, \
  401. paddr_unaligned, paddr_aligned, \
  402. align) \
  403. qdf_aligned_mem_alloc_consistent_fl(osdev, size, vaddr_unaligned, \
  404. paddr_unaligned, paddr_aligned, \
  405. align, __func__, __LINE__)
  406. void *qdf_aligned_mem_alloc_consistent_fl(qdf_device_t osdev, uint32_t *size,
  407. void **vaddr_unaligned,
  408. qdf_dma_addr_t *paddr_unaligned,
  409. qdf_dma_addr_t *paddr_aligned,
  410. uint32_t align, const char *func,
  411. uint32_t line);
  412. #define qdf_mem_virt_to_phys(vaddr) virt_to_phys(vaddr)
  413. void qdf_mem_set_io(void *ptr, uint32_t num_bytes, uint32_t value);
  414. void qdf_mem_copy_toio(void *dst_addr, const void *src_addr,
  415. uint32_t num_bytes);
  416. /**
  417. * qdf_mem_set() - set (fill) memory with a specified byte value.
  418. * @ptr: Pointer to memory that will be set
  419. * @num_bytes: Number of bytes to be set
  420. * @value: Byte set in memory
  421. *
  422. * WARNING: parameter @num_bytes and @value are swapped comparing with
  423. * standard C function "memset", please ensure correct usage of this function!
  424. *
  425. * Return: None
  426. */
  427. void qdf_mem_set(void *ptr, uint32_t num_bytes, uint32_t value);
  428. /**
  429. * qdf_mem_zero() - zero out memory
  430. * @ptr: pointer to memory that will be set to zero
  431. * @num_bytes: number of bytes zero
  432. *
  433. * This function sets the memory location to all zeros, essentially clearing
  434. * the memory.
  435. *
  436. * Return: None
  437. */
  438. static inline void qdf_mem_zero(void *ptr, uint32_t num_bytes)
  439. {
  440. qdf_mem_set(ptr, num_bytes, 0);
  441. }
  442. /**
  443. * qdf_mem_copy() - copy memory
  444. * @dst_addr: Pointer to destination memory location (to copy to)
  445. * @src_addr: Pointer to source memory location (to copy from)
  446. * @num_bytes: Number of bytes to copy.
  447. *
  448. * Copy host memory from one location to another, similar to memcpy in
  449. * standard C. Note this function does not specifically handle overlapping
  450. * source and destination memory locations. Calling this function with
  451. * overlapping source and destination memory locations will result in
  452. * unpredictable results. Use qdf_mem_move() if the memory locations
  453. * for the source and destination are overlapping (or could be overlapping!)
  454. *
  455. * Return: none
  456. */
  457. void qdf_mem_copy(void *dst_addr, const void *src_addr, uint32_t num_bytes);
  458. /**
  459. * qdf_mem_move() - move memory
  460. * @dst_addr: pointer to destination memory location (to move to)
  461. * @src_addr: pointer to source memory location (to move from)
  462. * @num_bytes: number of bytes to move.
  463. *
  464. * Move host memory from one location to another, similar to memmove in
  465. * standard C. Note this function *does* handle overlapping
  466. * source and destination memory locations.
  467. * Return: None
  468. */
  469. void qdf_mem_move(void *dst_addr, const void *src_addr, uint32_t num_bytes);
  470. /**
  471. * qdf_mem_cmp() - memory compare
  472. * @left: pointer to one location in memory to compare
  473. * @right: pointer to second location in memory to compare
  474. * @size: the number of bytes to compare
  475. *
  476. * Function to compare two pieces of memory, similar to memcmp function
  477. * in standard C.
  478. *
  479. * Return:
  480. * 0 -- equal
  481. * < 0 -- *memory1 is less than *memory2
  482. * > 0 -- *memory1 is bigger than *memory2
  483. */
  484. int qdf_mem_cmp(const void *left, const void *right, size_t size);
  485. void qdf_ether_addr_copy(void *dst_addr, const void *src_addr);
  486. /**
  487. * qdf_mem_map_nbytes_single - Map memory for DMA
  488. * @osdev: pomter OS device context
  489. * @buf: pointer to memory to be dma mapped
  490. * @dir: DMA map direction
  491. * @nbytes: number of bytes to be mapped.
  492. * @phy_addr: ponter to recive physical address.
  493. *
  494. * Return: success/failure
  495. */
  496. static inline uint32_t qdf_mem_map_nbytes_single(qdf_device_t osdev, void *buf,
  497. qdf_dma_dir_t dir, int nbytes,
  498. qdf_dma_addr_t *phy_addr)
  499. {
  500. #if defined(HIF_PCI) || defined(HIF_IPCI)
  501. return __qdf_mem_map_nbytes_single(osdev, buf, dir, nbytes, phy_addr);
  502. #else
  503. return 0;
  504. #endif
  505. }
  506. static inline void qdf_mem_dma_cache_sync(qdf_device_t osdev,
  507. qdf_dma_addr_t buf,
  508. qdf_dma_dir_t dir,
  509. int nbytes)
  510. {
  511. __qdf_mem_dma_cache_sync(osdev, buf, dir, nbytes);
  512. }
  513. /**
  514. * qdf_mem_unmap_nbytes_single() - un_map memory for DMA
  515. * @osdev: pomter OS device context
  516. * @phy_addr: physical address of memory to be dma unmapped
  517. * @dir: DMA unmap direction
  518. * @nbytes: number of bytes to be unmapped.
  519. *
  520. * Return: none
  521. */
  522. static inline void qdf_mem_unmap_nbytes_single(qdf_device_t osdev,
  523. qdf_dma_addr_t phy_addr,
  524. qdf_dma_dir_t dir,
  525. int nbytes)
  526. {
  527. #if defined(HIF_PCI) || defined(HIF_IPCI)
  528. __qdf_mem_unmap_nbytes_single(osdev, phy_addr, dir, nbytes);
  529. #endif
  530. }
  531. /**
  532. * qdf_mempool_init - Create and initialize memory pool
  533. * @osdev: platform device object
  534. * @pool_addr: address of the pool created
  535. * @elem_cnt: no. of elements in pool
  536. * @elem_size: size of each pool element in bytes
  537. * @flags: flags
  538. * Return: Handle to memory pool or NULL if allocation failed
  539. */
  540. static inline int qdf_mempool_init(qdf_device_t osdev,
  541. qdf_mempool_t *pool_addr, int elem_cnt,
  542. size_t elem_size, uint32_t flags)
  543. {
  544. return __qdf_mempool_init(osdev, pool_addr, elem_cnt, elem_size,
  545. flags);
  546. }
  547. /**
  548. * qdf_mempool_destroy - Destroy memory pool
  549. * @osdev: platform device object
  550. * @Handle: to memory pool
  551. * Return: none
  552. */
  553. static inline void qdf_mempool_destroy(qdf_device_t osdev, qdf_mempool_t pool)
  554. {
  555. __qdf_mempool_destroy(osdev, pool);
  556. }
  557. /**
  558. * qdf_mempool_alloc - Allocate an element memory pool
  559. * @osdev: platform device object
  560. * @Handle: to memory pool
  561. * Return: Pointer to the allocated element or NULL if the pool is empty
  562. */
  563. static inline void *qdf_mempool_alloc(qdf_device_t osdev, qdf_mempool_t pool)
  564. {
  565. return (void *)__qdf_mempool_alloc(osdev, pool);
  566. }
  567. /**
  568. * qdf_mempool_free - Free a memory pool element
  569. * @osdev: Platform device object
  570. * @pool: Handle to memory pool
  571. * @buf: Element to be freed
  572. * Return: none
  573. */
  574. static inline void qdf_mempool_free(qdf_device_t osdev, qdf_mempool_t pool,
  575. void *buf)
  576. {
  577. __qdf_mempool_free(osdev, pool, buf);
  578. }
  579. void qdf_mem_dma_sync_single_for_device(qdf_device_t osdev,
  580. qdf_dma_addr_t bus_addr,
  581. qdf_size_t size,
  582. __dma_data_direction direction);
  583. void qdf_mem_dma_sync_single_for_cpu(qdf_device_t osdev,
  584. qdf_dma_addr_t bus_addr,
  585. qdf_size_t size,
  586. __dma_data_direction direction);
  587. int qdf_mem_multi_page_link(qdf_device_t osdev,
  588. struct qdf_mem_multi_page_t *pages,
  589. uint32_t elem_size, uint32_t elem_count, uint8_t cacheable);
  590. /**
  591. * qdf_mem_kmalloc_inc() - increment kmalloc allocated bytes count
  592. * @size: number of bytes to increment by
  593. *
  594. * Return: None
  595. */
  596. void qdf_mem_kmalloc_inc(qdf_size_t size);
  597. /**
  598. * qdf_mem_kmalloc_dec() - decrement kmalloc allocated bytes count
  599. * @size: number of bytes to decrement by
  600. *
  601. * Return: None
  602. */
  603. void qdf_mem_kmalloc_dec(qdf_size_t size);
  604. #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
  605. /**
  606. * qdf_mem_skb_inc() - increment total skb allocation size
  607. * @size: size to be added
  608. *
  609. * Return: none
  610. */
  611. void qdf_mem_skb_inc(qdf_size_t size);
  612. /**
  613. * qdf_mem_skb_dec() - decrement total skb allocation size
  614. * @size: size to be decremented
  615. *
  616. * Return: none
  617. */
  618. void qdf_mem_skb_dec(qdf_size_t size);
  619. /**
  620. * qdf_mem_skb_total_inc() - increment total skb allocation size
  621. * in host driver in both debug and perf builds
  622. * @size: size to be added
  623. *
  624. * Return: none
  625. */
  626. void qdf_mem_skb_total_inc(qdf_size_t size);
  627. /**
  628. * qdf_mem_skb_total_dec() - decrement total skb allocation size
  629. * in the host driver in debug and perf flavors
  630. * @size: size to be decremented
  631. *
  632. * Return: none
  633. */
  634. void qdf_mem_skb_total_dec(qdf_size_t size);
  635. /**
  636. * qdf_mem_dp_tx_skb_inc() - Increment Tx skb allocation size
  637. * @size: size to be added
  638. *
  639. * Return: none
  640. */
  641. void qdf_mem_dp_tx_skb_inc(qdf_size_t size);
  642. /**
  643. * qdf_mem_dp_tx_skb_dec() - Decrement Tx skb allocation size
  644. * @size: size to be decreased
  645. *
  646. * Return: none
  647. */
  648. void qdf_mem_dp_tx_skb_dec(qdf_size_t size);
  649. /**
  650. * qdf_mem_dp_rx_skb_inc() - Increment Rx skb allocation size
  651. * @size: size to be added
  652. *
  653. * Return: none
  654. */
  655. void qdf_mem_dp_rx_skb_inc(qdf_size_t size);
  656. /**
  657. * qdf_mem_dp_rx_skb_dec() - Decrement Rx skb allocation size
  658. * @size: size to be decreased
  659. *
  660. * Return: none
  661. */
  662. void qdf_mem_dp_rx_skb_dec(qdf_size_t size);
  663. /**
  664. * qdf_mem_dp_tx_skb_cnt_inc() - Increment Tx buffer count
  665. *
  666. * Return: none
  667. */
  668. void qdf_mem_dp_tx_skb_cnt_inc(void);
  669. /**
  670. * qdf_mem_dp_tx_skb_cnt_dec() - Decrement Tx buffer count
  671. *
  672. * Return: none
  673. */
  674. void qdf_mem_dp_tx_skb_cnt_dec(void);
  675. /**
  676. * qdf_mem_dp_rx_skb_cnt_inc() - Increment Rx buffer count
  677. *
  678. * Return: none
  679. */
  680. void qdf_mem_dp_rx_skb_cnt_inc(void);
  681. /**
  682. * qdf_mem_dp_rx_skb_cnt_dec() - Decrement Rx buffer count
  683. *
  684. * Return: none
  685. */
  686. void qdf_mem_dp_rx_skb_cnt_dec(void);
  687. #else
  688. static inline void qdf_mem_skb_inc(qdf_size_t size)
  689. {
  690. }
  691. static inline void qdf_mem_skb_dec(qdf_size_t size)
  692. {
  693. }
  694. static inline void qdf_mem_skb_total_inc(qdf_size_t size)
  695. {
  696. }
  697. static inline void qdf_mem_skb_total_dec(qdf_size_t size)
  698. {
  699. }
  700. static inline void qdf_mem_dp_tx_skb_inc(qdf_size_t size)
  701. {
  702. }
  703. static inline void qdf_mem_dp_tx_skb_dec(qdf_size_t size)
  704. {
  705. }
  706. static inline void qdf_mem_dp_rx_skb_inc(qdf_size_t size)
  707. {
  708. }
  709. static inline void qdf_mem_dp_rx_skb_dec(qdf_size_t size)
  710. {
  711. }
  712. static inline void qdf_mem_dp_tx_skb_cnt_inc(void)
  713. {
  714. }
  715. static inline void qdf_mem_dp_tx_skb_cnt_dec(void)
  716. {
  717. }
  718. static inline void qdf_mem_dp_rx_skb_cnt_inc(void)
  719. {
  720. }
  721. static inline void qdf_mem_dp_rx_skb_cnt_dec(void)
  722. {
  723. }
  724. #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
  725. /**
  726. * qdf_mem_map_table_alloc() - Allocate shared memory info structure
  727. * @num: number of required storage
  728. *
  729. * Allocate mapping table for DMA memory allocation. This is needed for
  730. * IPA-WLAN buffer sharing when SMMU Stage1 Translation is enabled.
  731. *
  732. * Return: shared memory info storage table pointer
  733. */
  734. static inline qdf_mem_info_t *qdf_mem_map_table_alloc(uint32_t num)
  735. {
  736. qdf_mem_info_t *mem_info_arr;
  737. mem_info_arr = qdf_mem_malloc(num * sizeof(mem_info_arr[0]));
  738. return mem_info_arr;
  739. }
  740. #ifdef ENHANCED_OS_ABSTRACTION
  741. /**
  742. * qdf_update_mem_map_table() - Update DMA memory map info
  743. * @osdev: Parent device instance
  744. * @mem_info: Pointer to shared memory information
  745. * @dma_addr: dma address
  746. * @mem_size: memory size allocated
  747. *
  748. * Store DMA shared memory information
  749. *
  750. * Return: none
  751. */
  752. void qdf_update_mem_map_table(qdf_device_t osdev,
  753. qdf_mem_info_t *mem_info,
  754. qdf_dma_addr_t dma_addr,
  755. uint32_t mem_size);
  756. /**
  757. * qdf_mem_paddr_from_dmaaddr() - get actual physical address from dma address
  758. * @osdev: Parent device instance
  759. * @dma_addr: DMA/IOVA address
  760. *
  761. * Get actual physical address from dma_addr based on SMMU enablement status.
  762. * IF SMMU Stage 1 tranlation is enabled, DMA APIs return IO virtual address
  763. * (IOVA) otherwise returns physical address. So get SMMU physical address
  764. * mapping from IOVA.
  765. *
  766. * Return: dmaable physical address
  767. */
  768. qdf_dma_addr_t qdf_mem_paddr_from_dmaaddr(qdf_device_t osdev,
  769. qdf_dma_addr_t dma_addr);
  770. #else
  771. static inline
  772. void qdf_update_mem_map_table(qdf_device_t osdev,
  773. qdf_mem_info_t *mem_info,
  774. qdf_dma_addr_t dma_addr,
  775. uint32_t mem_size)
  776. {
  777. if (!mem_info) {
  778. qdf_nofl_err("%s: NULL mem_info", __func__);
  779. return;
  780. }
  781. __qdf_update_mem_map_table(osdev, mem_info, dma_addr, mem_size);
  782. }
  783. static inline
  784. qdf_dma_addr_t qdf_mem_paddr_from_dmaaddr(qdf_device_t osdev,
  785. qdf_dma_addr_t dma_addr)
  786. {
  787. return __qdf_mem_paddr_from_dmaaddr(osdev, dma_addr);
  788. }
  789. #endif
  790. /**
  791. * qdf_mem_smmu_s1_enabled() - Return SMMU stage 1 translation enable status
  792. * @osdev parent device instance
  793. *
  794. * Return: true if smmu s1 enabled, false if smmu s1 is bypassed
  795. */
  796. static inline bool qdf_mem_smmu_s1_enabled(qdf_device_t osdev)
  797. {
  798. return __qdf_mem_smmu_s1_enabled(osdev);
  799. }
  800. /**
  801. * qdf_mem_dma_get_sgtable() - Returns DMA memory scatter gather table
  802. * @dev: device instace
  803. * @sgt: scatter gather table pointer
  804. * @cpu_addr: HLOS virtual address
  805. * @dma_addr: dma address
  806. * @size: allocated memory size
  807. *
  808. * Return: physical address
  809. */
  810. static inline int
  811. qdf_mem_dma_get_sgtable(struct device *dev, void *sgt, void *cpu_addr,
  812. qdf_dma_addr_t dma_addr, size_t size)
  813. {
  814. return __qdf_os_mem_dma_get_sgtable(dev, sgt, cpu_addr, dma_addr, size);
  815. }
  816. /**
  817. * qdf_mem_free_sgtable() - Free a previously allocated sg table
  818. * @sgt: the mapped sg table header
  819. *
  820. * Return: None
  821. */
  822. static inline void
  823. qdf_mem_free_sgtable(struct sg_table *sgt)
  824. {
  825. __qdf_os_mem_free_sgtable(sgt);
  826. }
  827. /**
  828. * qdf_dma_get_sgtable_dma_addr() - Assigns DMA address to scatterlist elements
  829. * @sgt: scatter gather table pointer
  830. *
  831. * Return: None
  832. */
  833. static inline void
  834. qdf_dma_get_sgtable_dma_addr(struct sg_table *sgt)
  835. {
  836. __qdf_dma_get_sgtable_dma_addr(sgt);
  837. }
  838. /**
  839. * qdf_mem_get_dma_addr() - Return dma address based on SMMU translation status.
  840. * @osdev: Parent device instance
  841. * @mem_info: Pointer to allocated memory information
  842. *
  843. * Get dma address based on SMMU enablement status. If SMMU Stage 1
  844. * tranlation is enabled, DMA APIs return IO virtual address otherwise
  845. * returns physical address.
  846. *
  847. * Return: dma address
  848. */
  849. static inline qdf_dma_addr_t qdf_mem_get_dma_addr(qdf_device_t osdev,
  850. qdf_mem_info_t *mem_info)
  851. {
  852. return __qdf_mem_get_dma_addr(osdev, mem_info);
  853. }
  854. /**
  855. * qdf_mem_get_dma_addr_ptr() - Return DMA address pointer from mem info struct
  856. * @osdev: Parent device instance
  857. * @mem_info: Pointer to allocated memory information
  858. *
  859. * Based on smmu stage 1 translation enablement, return corresponding dma
  860. * address storage pointer.
  861. *
  862. * Return: dma address storage pointer
  863. */
  864. static inline qdf_dma_addr_t *qdf_mem_get_dma_addr_ptr(qdf_device_t osdev,
  865. qdf_mem_info_t *mem_info)
  866. {
  867. return __qdf_mem_get_dma_addr_ptr(osdev, mem_info);
  868. }
  869. /**
  870. * qdf_mem_get_dma_size() - Return DMA memory size
  871. * @osdev: parent device instance
  872. * @mem_info: Pointer to allocated memory information
  873. *
  874. * Return: DMA memory size
  875. */
  876. static inline uint32_t
  877. qdf_mem_get_dma_size(qdf_device_t osdev,
  878. qdf_mem_info_t *mem_info)
  879. {
  880. return __qdf_mem_get_dma_size(osdev, mem_info);
  881. }
  882. /**
  883. * qdf_mem_set_dma_size() - Set DMA memory size
  884. * @osdev: parent device instance
  885. * @mem_info: Pointer to allocated memory information
  886. * @mem_size: memory size allocated
  887. *
  888. * Return: none
  889. */
  890. static inline void
  891. qdf_mem_set_dma_size(qdf_device_t osdev,
  892. qdf_mem_info_t *mem_info,
  893. uint32_t mem_size)
  894. {
  895. __qdf_mem_set_dma_size(osdev, mem_info, mem_size);
  896. }
  897. /**
  898. * qdf_mem_get_dma_size() - Return DMA physical address
  899. * @osdev: parent device instance
  900. * @mem_info: Pointer to allocated memory information
  901. *
  902. * Return: DMA physical address
  903. */
  904. static inline qdf_dma_addr_t
  905. qdf_mem_get_dma_pa(qdf_device_t osdev,
  906. qdf_mem_info_t *mem_info)
  907. {
  908. return __qdf_mem_get_dma_pa(osdev, mem_info);
  909. }
  910. /**
  911. * qdf_mem_set_dma_size() - Set DMA physical address
  912. * @osdev: parent device instance
  913. * @mem_info: Pointer to allocated memory information
  914. * @dma_pa: DMA phsical address
  915. *
  916. * Return: none
  917. */
  918. static inline void
  919. qdf_mem_set_dma_pa(qdf_device_t osdev,
  920. qdf_mem_info_t *mem_info,
  921. qdf_dma_addr_t dma_pa)
  922. {
  923. __qdf_mem_set_dma_pa(osdev, mem_info, dma_pa);
  924. }
  925. /**
  926. * qdf_mem_shared_mem_alloc() - Allocate DMA memory for shared resource
  927. * @osdev: parent device instance
  928. * @mem_info: Pointer to allocated memory information
  929. * @size: size to be allocated
  930. *
  931. * Allocate DMA memory which will be shared with external kernel module. This
  932. * information is needed for SMMU mapping.
  933. *
  934. * Return: 0 success
  935. */
  936. qdf_shared_mem_t *qdf_mem_shared_mem_alloc(qdf_device_t osdev, uint32_t size);
  937. /**
  938. * qdf_mem_shared_mem_free() - Free shared memory
  939. * @osdev: parent device instance
  940. * @shared_mem: shared memory information storage
  941. *
  942. * Free DMA shared memory resource
  943. *
  944. * Return: None
  945. */
  946. static inline void qdf_mem_shared_mem_free(qdf_device_t osdev,
  947. qdf_shared_mem_t *shared_mem)
  948. {
  949. if (!shared_mem) {
  950. qdf_nofl_err("%s: NULL shared mem struct passed",
  951. __func__);
  952. return;
  953. }
  954. if (shared_mem->vaddr) {
  955. qdf_mem_free_consistent(osdev, osdev->dev,
  956. qdf_mem_get_dma_size(osdev,
  957. &shared_mem->mem_info),
  958. shared_mem->vaddr,
  959. qdf_mem_get_dma_addr(osdev,
  960. &shared_mem->mem_info),
  961. qdf_get_dma_mem_context(shared_mem,
  962. memctx));
  963. }
  964. qdf_mem_free_sgtable(&shared_mem->sgtable);
  965. qdf_mem_free(shared_mem);
  966. }
  967. /**
  968. * qdf_dma_mem_stats_read() - Return the DMA memory allocated in
  969. * host driver
  970. *
  971. * Return: Total DMA memory allocated
  972. */
  973. int32_t qdf_dma_mem_stats_read(void);
  974. /**
  975. * qdf_heap_mem_stats_read() - Return the heap memory allocated
  976. * in host driver
  977. *
  978. * Return: Total heap memory allocated
  979. */
  980. int32_t qdf_heap_mem_stats_read(void);
  981. /**
  982. * qdf_skb_mem_stats_read() - Return the SKB memory allocated in
  983. * host driver
  984. *
  985. * Return: Total SKB memory allocated
  986. */
  987. int32_t qdf_skb_mem_stats_read(void);
  988. /**
  989. * qdf_skb_total_mem_stats_read() - Return the SKB memory allocated
  990. * in the host driver tracked in both debug and perf builds
  991. *
  992. * Return: Total SKB memory allocated
  993. */
  994. int32_t qdf_skb_total_mem_stats_read(void);
  995. /**
  996. * qdf_skb_max_mem_stats_read() - Return the max SKB memory
  997. * allocated in host driver. This is the high watermark for the
  998. * total SKB allocated in the host driver
  999. *
  1000. * Return: None
  1001. */
  1002. int32_t qdf_skb_max_mem_stats_read(void);
  1003. /**
  1004. * qdf_mem_tx_desc_cnt_read() - Return the outstanding Tx descs
  1005. * which are waiting on Tx completions
  1006. *
  1007. * Return: Outstanding Tx desc count
  1008. */
  1009. int32_t qdf_mem_tx_desc_cnt_read(void);
  1010. /**
  1011. * qdf_mem_tx_desc_max_read() - Return the max outstanding Tx
  1012. * descs which are waiting on Tx completions. This is the high
  1013. * watermark for the pending desc count
  1014. *
  1015. * Return: Max outstanding Tx desc count
  1016. */
  1017. int32_t qdf_mem_tx_desc_max_read(void);
  1018. /**
  1019. * qdf_mem_stats_init() - Initialize the qdf memstats fields on
  1020. * creating the sysfs node
  1021. *
  1022. * Return: None
  1023. */
  1024. void qdf_mem_stats_init(void);
  1025. /**
  1026. * qdf_dp_tx_skb_mem_stats_read() - Return the SKB memory
  1027. * allocated for Tx data path
  1028. *
  1029. * Return: Tx SKB memory allocated
  1030. */
  1031. int32_t qdf_dp_tx_skb_mem_stats_read(void);
  1032. /**
  1033. * qdf_dp_rx_skb_mem_stats_read() - Return the SKB memory
  1034. * allocated for Rx data path
  1035. *
  1036. * Return: Rx SKB memory allocated
  1037. */
  1038. int32_t qdf_dp_rx_skb_mem_stats_read(void);
  1039. /**
  1040. * qdf_dp_tx_skb_max_mem_stats_read() - Return the high
  1041. * watermark for the SKB memory allocated for Tx data path
  1042. *
  1043. * Return: Max Tx SKB memory allocated
  1044. */
  1045. int32_t qdf_dp_tx_skb_max_mem_stats_read(void);
  1046. /**
  1047. * qdf_dp_rx_skb_max_mem_stats_read() - Return the high
  1048. * watermark for the SKB memory allocated for Rx data path
  1049. *
  1050. * Return: Max Rx SKB memory allocated
  1051. */
  1052. int32_t qdf_dp_rx_skb_max_mem_stats_read(void);
  1053. /**
  1054. * qdf_mem_dp_tx_skb_cnt_read() - Return number of buffers
  1055. * allocated in the Tx data path by the host driver or
  1056. * buffers coming from the n/w stack
  1057. *
  1058. * Return: Number of DP Tx buffers allocated
  1059. */
  1060. int32_t qdf_mem_dp_tx_skb_cnt_read(void);
  1061. /**
  1062. * qdf_mem_dp_tx_skb_max_cnt_read() - Return max number of
  1063. * buffers allocated in the Tx data path
  1064. *
  1065. * Return: Max number of DP Tx buffers allocated
  1066. */
  1067. int32_t qdf_mem_dp_tx_skb_max_cnt_read(void);
  1068. /**
  1069. * qdf_mem_dp_rx_skb_cnt_read() - Return number of buffers
  1070. * allocated in the Rx data path
  1071. *
  1072. * Return: Number of DP Rx buffers allocated
  1073. */
  1074. int32_t qdf_mem_dp_rx_skb_cnt_read(void);
  1075. /**
  1076. * qdf_mem_dp_rx_skb_max_cnt_read() - Return max number of
  1077. * buffers allocated in the Rx data path
  1078. *
  1079. * Return: Max number of DP Rx buffers allocated
  1080. */
  1081. int32_t qdf_mem_dp_rx_skb_max_cnt_read(void);
  1082. /**
  1083. * qdf_mem_tx_desc_cnt_update() - Update the pending tx desc
  1084. * count and the high watermark for pending tx desc count
  1085. *
  1086. * @pending_tx_descs: outstanding Tx desc count
  1087. * @tx_descs_max: high watermark for outstanding Tx desc count
  1088. *
  1089. * Return: None
  1090. */
  1091. void qdf_mem_tx_desc_cnt_update(qdf_atomic_t pending_tx_descs,
  1092. int32_t tx_descs_max);
  1093. /**
  1094. * qdf_mem_vfree() - Free the virtual memory pointed to by ptr
  1095. * @ptr: Pointer to the starting address of the memory to
  1096. * be freed.
  1097. *
  1098. * Return: None
  1099. */
  1100. #define qdf_mem_vfree(ptr) __qdf_mem_vfree(ptr)
  1101. /**
  1102. * qdf_mem_valloc() - Allocate virtual memory for the given
  1103. * size
  1104. * @size: Number of bytes of memory to be allocated
  1105. *
  1106. * Return: Pointer to the starting address of the allocated virtual memory
  1107. */
  1108. #define qdf_mem_valloc(size) __qdf_mem_valloc(size, __func__, __LINE__)
  1109. #if IS_ENABLED(CONFIG_ARM_SMMU) && defined(ENABLE_SMMU_S1_TRANSLATION)
  1110. /*
  1111. * typedef qdf_iommu_domain_t: Platform indepedent iommu domain
  1112. * abstraction
  1113. */
  1114. typedef __qdf_iommu_domain_t qdf_iommu_domain_t;
  1115. /**
  1116. * qdf_iommu_domain_get_attr() - API to get iommu domain attributes
  1117. * @domain: iommu domain
  1118. * @attr: iommu attribute
  1119. * @data: data pointer
  1120. *
  1121. * Return: 0 on success, else errno
  1122. */
  1123. int
  1124. qdf_iommu_domain_get_attr(qdf_iommu_domain_t *domain,
  1125. enum qdf_iommu_attr attr, void *data);
  1126. #endif
  1127. #endif /* __QDF_MEMORY_H */