dp_tx_desc.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*
  2. * Copyright (c) 2016-2017 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 DP_TX_DESC_H
  19. #define DP_TX_DESC_H
  20. #include "dp_types.h"
  21. #include "dp_tx.h"
  22. #include "dp_internal.h"
  23. /**
  24. * 21 bits cookie
  25. * 2 bits pool id 0 ~ 3,
  26. * 10 bits page id 0 ~ 1023
  27. * 5 bits offset id 0 ~ 31 (Desc size = 128, Num descs per page = 4096/128 = 32)
  28. */
  29. /* ???Ring ID needed??? */
  30. #define DP_TX_DESC_ID_POOL_MASK 0x018000
  31. #define DP_TX_DESC_ID_POOL_OS 15
  32. #define DP_TX_DESC_ID_PAGE_MASK 0x007FE0
  33. #define DP_TX_DESC_ID_PAGE_OS 5
  34. #define DP_TX_DESC_ID_OFFSET_MASK 0x00001F
  35. #define DP_TX_DESC_ID_OFFSET_OS 0
  36. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  37. #define TX_DESC_LOCK_CREATE(lock)
  38. #define TX_DESC_LOCK_DESTROY(lock)
  39. #define TX_DESC_LOCK_LOCK(lock)
  40. #define TX_DESC_LOCK_UNLOCK(lock)
  41. #else /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  42. #define TX_DESC_LOCK_CREATE(lock) qdf_spinlock_create(lock)
  43. #define TX_DESC_LOCK_DESTROY(lock) qdf_spinlock_destroy(lock)
  44. #define TX_DESC_LOCK_LOCK(lock) qdf_spin_lock_bh(lock)
  45. #define TX_DESC_LOCK_UNLOCK(lock) qdf_spin_unlock_bh(lock)
  46. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  47. #define MAX_POOL_BUFF_COUNT 10000
  48. QDF_STATUS dp_tx_desc_pool_alloc(struct dp_soc *soc, uint8_t pool_id,
  49. uint16_t num_elem);
  50. QDF_STATUS dp_tx_desc_pool_free(struct dp_soc *soc, uint8_t pool_id);
  51. QDF_STATUS dp_tx_ext_desc_pool_alloc(struct dp_soc *soc, uint8_t pool_id,
  52. uint16_t num_elem);
  53. QDF_STATUS dp_tx_ext_desc_pool_free(struct dp_soc *soc, uint8_t pool_id);
  54. QDF_STATUS dp_tx_tso_desc_pool_alloc(struct dp_soc *soc, uint8_t pool_id,
  55. uint16_t num_elem);
  56. void dp_tx_tso_desc_pool_free(struct dp_soc *soc, uint8_t pool_id);
  57. QDF_STATUS dp_tx_tso_num_seg_pool_alloc(struct dp_soc *soc, uint8_t pool_id,
  58. uint16_t num_elem);
  59. void dp_tx_tso_num_seg_pool_free(struct dp_soc *soc, uint8_t pool_id);
  60. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  61. void dp_tx_flow_control_init(struct dp_soc *);
  62. void dp_tx_flow_control_deinit(struct dp_soc *);
  63. QDF_STATUS dp_txrx_register_pause_cb(struct cdp_soc_t *soc,
  64. tx_pause_callback pause_cb);
  65. void dp_tx_clear_flow_pool_stats(struct dp_soc *soc);
  66. struct dp_tx_desc_pool_s *dp_tx_create_flow_pool(struct dp_soc *soc,
  67. uint8_t flow_pool_id, uint16_t flow_pool_size);
  68. QDF_STATUS dp_tx_flow_pool_map_handler(struct dp_pdev *pdev, uint8_t flow_id,
  69. uint8_t flow_type, uint8_t flow_pool_id, uint16_t flow_pool_size);
  70. void dp_tx_flow_pool_unmap_handler(struct dp_pdev *pdev, uint8_t flow_id,
  71. uint8_t flow_type, uint8_t flow_pool_id);
  72. /**
  73. * dp_tx_get_desc_flow_pool() - get descriptor from flow pool
  74. * @pool: flow pool
  75. *
  76. * Caller needs to take lock and do sanity checks.
  77. *
  78. * Return: tx descriptor
  79. */
  80. static inline
  81. struct dp_tx_desc_s *dp_tx_get_desc_flow_pool(struct dp_tx_desc_pool_s *pool)
  82. {
  83. struct dp_tx_desc_s *tx_desc = pool->freelist;
  84. pool->freelist = pool->freelist->next;
  85. pool->avail_desc--;
  86. return tx_desc;
  87. }
  88. /**
  89. * ol_tx_put_desc_flow_pool() - put descriptor to flow pool freelist
  90. * @pool: flow pool
  91. * @tx_desc: tx descriptor
  92. *
  93. * Caller needs to take lock and do sanity checks.
  94. *
  95. * Return: none
  96. */
  97. static inline
  98. void dp_tx_put_desc_flow_pool(struct dp_tx_desc_pool_s *pool,
  99. struct dp_tx_desc_s *tx_desc)
  100. {
  101. tx_desc->next = pool->freelist;
  102. pool->freelist = tx_desc;
  103. pool->avail_desc++;
  104. }
  105. /**
  106. * dp_tx_desc_alloc() - Allocate a Software Tx Descriptor from given pool
  107. *
  108. * @soc Handle to DP SoC structure
  109. * @pool_id
  110. *
  111. * Return:
  112. */
  113. static inline struct dp_tx_desc_s *
  114. dp_tx_desc_alloc(struct dp_soc *soc, uint8_t desc_pool_id)
  115. {
  116. struct dp_tx_desc_s *tx_desc = NULL;
  117. struct dp_tx_desc_pool_s *pool = &soc->tx_desc[desc_pool_id];
  118. if (pool) {
  119. qdf_spin_lock_bh(&pool->flow_pool_lock);
  120. if (pool->avail_desc) {
  121. tx_desc = dp_tx_get_desc_flow_pool(pool);
  122. tx_desc->pool_id = desc_pool_id;
  123. tx_desc->flags = DP_TX_DESC_FLAG_ALLOCATED;
  124. if (qdf_unlikely(pool->avail_desc < pool->stop_th)) {
  125. pool->status = FLOW_POOL_ACTIVE_PAUSED;
  126. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  127. /* pause network queues */
  128. soc->pause_cb(desc_pool_id,
  129. WLAN_STOP_ALL_NETIF_QUEUE,
  130. WLAN_DATA_FLOW_CONTROL);
  131. } else {
  132. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  133. }
  134. } else {
  135. pool->pkt_drop_no_desc++;
  136. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  137. }
  138. } else {
  139. soc->pool_stats.pkt_drop_no_pool++;
  140. }
  141. return tx_desc;
  142. }
  143. /**
  144. * dp_tx_desc_free() - Fee a tx descriptor and attach it to free list
  145. *
  146. * @soc Handle to DP SoC structure
  147. * @pool_id
  148. * @tx_desc
  149. *
  150. * Return: None
  151. */
  152. static inline void
  153. dp_tx_desc_free(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc,
  154. uint8_t desc_pool_id)
  155. {
  156. struct dp_tx_desc_pool_s *pool = &soc->tx_desc[desc_pool_id];
  157. qdf_spin_lock_bh(&pool->flow_pool_lock);
  158. dp_tx_put_desc_flow_pool(pool, tx_desc);
  159. switch (pool->status) {
  160. case FLOW_POOL_ACTIVE_PAUSED:
  161. if (pool->avail_desc > pool->start_th) {
  162. soc->pause_cb(pool->flow_pool_id,
  163. WLAN_WAKE_ALL_NETIF_QUEUE,
  164. WLAN_DATA_FLOW_CONTROL);
  165. pool->status = FLOW_POOL_ACTIVE_UNPAUSED;
  166. }
  167. break;
  168. case FLOW_POOL_INVALID:
  169. if (pool->avail_desc == pool->pool_size) {
  170. dp_tx_desc_pool_free(soc, desc_pool_id);
  171. pool->status = FLOW_POOL_INACTIVE;
  172. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  173. qdf_print("%s %d pool is freed!!\n",
  174. __func__, __LINE__);
  175. return;
  176. }
  177. break;
  178. case FLOW_POOL_ACTIVE_UNPAUSED:
  179. break;
  180. default:
  181. qdf_print("%s %d pool is INACTIVE State!!\n",
  182. __func__, __LINE__);
  183. break;
  184. };
  185. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  186. }
  187. #else /* QCA_LL_TX_FLOW_CONTROL_V2 */
  188. static inline void dp_tx_flow_control_init(struct dp_soc *handle)
  189. {
  190. }
  191. static inline void dp_tx_flow_control_deinit(struct dp_soc *handle)
  192. {
  193. }
  194. static inline QDF_STATUS dp_tx_flow_pool_map_handler(struct dp_pdev *pdev,
  195. uint8_t flow_id, uint8_t flow_type, uint8_t flow_pool_id,
  196. uint16_t flow_pool_size)
  197. {
  198. return QDF_STATUS_SUCCESS;
  199. }
  200. static inline void dp_tx_flow_pool_unmap_handler(struct dp_pdev *pdev,
  201. uint8_t flow_id, uint8_t flow_type, uint8_t flow_pool_id)
  202. {
  203. }
  204. /**
  205. * dp_tx_desc_alloc() - Allocate a Software Tx Descriptor from given pool
  206. *
  207. * @param soc Handle to DP SoC structure
  208. * @param pool_id
  209. *
  210. * Return:
  211. */
  212. static inline struct dp_tx_desc_s *dp_tx_desc_alloc(struct dp_soc *soc,
  213. uint8_t desc_pool_id)
  214. {
  215. struct dp_tx_desc_s *tx_desc = NULL;
  216. TX_DESC_LOCK_LOCK(&soc->tx_desc[desc_pool_id].lock);
  217. tx_desc = soc->tx_desc[desc_pool_id].freelist;
  218. /* Pool is exhausted */
  219. if (!tx_desc) {
  220. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  221. return NULL;
  222. }
  223. soc->tx_desc[desc_pool_id].freelist =
  224. soc->tx_desc[desc_pool_id].freelist->next;
  225. soc->tx_desc[desc_pool_id].num_allocated++;
  226. soc->tx_desc[desc_pool_id].num_free--;
  227. DP_STATS_INC(soc, tx.desc_in_use, 1);
  228. tx_desc->flags = DP_TX_DESC_FLAG_ALLOCATED;
  229. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  230. return tx_desc;
  231. }
  232. /**
  233. * dp_tx_desc_alloc_multiple() - Allocate batch of software Tx Descriptors
  234. * from given pool
  235. * @soc: Handle to DP SoC structure
  236. * @pool_id: pool id should pick up
  237. * @num_requested: number of required descriptor
  238. *
  239. * allocate multiple tx descriptor and make a link
  240. *
  241. * Return: h_desc first descriptor pointer
  242. */
  243. static inline struct dp_tx_desc_s *dp_tx_desc_alloc_multiple(
  244. struct dp_soc *soc, uint8_t desc_pool_id, uint8_t num_requested)
  245. {
  246. struct dp_tx_desc_s *c_desc = NULL, *h_desc = NULL;
  247. uint8_t count;
  248. TX_DESC_LOCK_LOCK(&soc->tx_desc[desc_pool_id].lock);
  249. if ((num_requested == 0) ||
  250. (soc->tx_desc[desc_pool_id].num_free < num_requested)) {
  251. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  252. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  253. "%s, No Free Desc: Available(%d) num_requested(%d)",
  254. __func__, soc->tx_desc[desc_pool_id].num_free,
  255. num_requested);
  256. return NULL;
  257. }
  258. h_desc = soc->tx_desc[desc_pool_id].freelist;
  259. /* h_desc should never be NULL since num_free > requested */
  260. qdf_assert_always(h_desc);
  261. c_desc = h_desc;
  262. for (count = 0; count < (num_requested - 1); count++) {
  263. c_desc->flags = DP_TX_DESC_FLAG_ALLOCATED;
  264. c_desc = c_desc->next;
  265. }
  266. soc->tx_desc[desc_pool_id].num_free -= count;
  267. soc->tx_desc[desc_pool_id].num_allocated += count;
  268. soc->tx_desc[desc_pool_id].freelist = c_desc->next;
  269. c_desc->next = NULL;
  270. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  271. return h_desc;
  272. }
  273. /**
  274. * dp_tx_desc_free() - Fee a tx descriptor and attach it to free list
  275. *
  276. * @soc Handle to DP SoC structure
  277. * @pool_id
  278. * @tx_desc
  279. */
  280. static inline void
  281. dp_tx_desc_free(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc,
  282. uint8_t desc_pool_id)
  283. {
  284. TX_DESC_LOCK_LOCK(&soc->tx_desc[desc_pool_id].lock);
  285. tx_desc->flags = 0;
  286. tx_desc->next = soc->tx_desc[desc_pool_id].freelist;
  287. soc->tx_desc[desc_pool_id].freelist = tx_desc;
  288. DP_STATS_DEC(soc, tx.desc_in_use, 1);
  289. soc->tx_desc[desc_pool_id].num_allocated--;
  290. soc->tx_desc[desc_pool_id].num_free++;
  291. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  292. }
  293. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  294. /**
  295. * dp_tx_desc_find() - find dp tx descriptor from cokie
  296. * @soc - handle for the device sending the data
  297. * @tx_desc_id - the ID of the descriptor in question
  298. * @return the descriptor object that has the specified ID
  299. *
  300. * Use a tx descriptor ID to find the corresponding descriptor object.
  301. *
  302. */
  303. static inline struct dp_tx_desc_s *dp_tx_desc_find(struct dp_soc *soc,
  304. uint8_t pool_id, uint16_t page_id, uint16_t offset)
  305. {
  306. struct dp_tx_desc_pool_s *tx_desc_pool = &((soc)->tx_desc[(pool_id)]);
  307. return tx_desc_pool->desc_pages.cacheable_pages[page_id] +
  308. tx_desc_pool->elem_size * offset;
  309. }
  310. /**
  311. * dp_tx_ext_desc_alloc() - Get tx extension descriptor from pool
  312. * @soc: handle for the device sending the data
  313. * @pool_id: target pool id
  314. *
  315. * Return: None
  316. */
  317. static inline
  318. struct dp_tx_ext_desc_elem_s *dp_tx_ext_desc_alloc(struct dp_soc *soc,
  319. uint8_t desc_pool_id)
  320. {
  321. struct dp_tx_ext_desc_elem_s *c_elem;
  322. qdf_spin_lock_bh(&soc->tx_ext_desc[desc_pool_id].lock);
  323. if (soc->tx_ext_desc[desc_pool_id].num_free <= 0) {
  324. qdf_spin_unlock_bh(&soc->tx_ext_desc[desc_pool_id].lock);
  325. return NULL;
  326. }
  327. c_elem = soc->tx_ext_desc[desc_pool_id].freelist;
  328. soc->tx_ext_desc[desc_pool_id].freelist =
  329. soc->tx_ext_desc[desc_pool_id].freelist->next;
  330. soc->tx_ext_desc[desc_pool_id].num_free--;
  331. qdf_spin_unlock_bh(&soc->tx_ext_desc[desc_pool_id].lock);
  332. return c_elem;
  333. }
  334. /**
  335. * dp_tx_ext_desc_free() - Release tx extension descriptor to the pool
  336. * @soc: handle for the device sending the data
  337. * @pool_id: target pool id
  338. * @elem: ext descriptor pointer should release
  339. *
  340. * Return: None
  341. */
  342. static inline void dp_tx_ext_desc_free(struct dp_soc *soc,
  343. struct dp_tx_ext_desc_elem_s *elem, uint8_t desc_pool_id)
  344. {
  345. qdf_spin_lock_bh(&soc->tx_ext_desc[desc_pool_id].lock);
  346. elem->next = soc->tx_ext_desc[desc_pool_id].freelist;
  347. soc->tx_ext_desc[desc_pool_id].freelist = elem;
  348. soc->tx_ext_desc[desc_pool_id].num_free++;
  349. qdf_spin_unlock_bh(&soc->tx_ext_desc[desc_pool_id].lock);
  350. return;
  351. }
  352. /**
  353. * dp_tx_ext_desc_free_multiple() - Fee multiple tx extension descriptor and
  354. * attach it to free list
  355. * @soc: Handle to DP SoC structure
  356. * @desc_pool_id: pool id should pick up
  357. * @elem: tx descriptor should be freed
  358. * @num_free: number of descriptors should be freed
  359. *
  360. * Return: none
  361. */
  362. static inline void dp_tx_ext_desc_free_multiple(struct dp_soc *soc,
  363. struct dp_tx_ext_desc_elem_s *elem, uint8_t desc_pool_id,
  364. uint8_t num_free)
  365. {
  366. struct dp_tx_ext_desc_elem_s *head, *tail, *c_elem;
  367. uint8_t freed = num_free;
  368. /* caller should always guarantee atleast list of num_free nodes */
  369. qdf_assert_always(head);
  370. head = elem;
  371. c_elem = head;
  372. tail = head;
  373. while (c_elem && freed) {
  374. tail = c_elem;
  375. c_elem = c_elem->next;
  376. freed--;
  377. }
  378. /* caller should always guarantee atleast list of num_free nodes */
  379. qdf_assert_always(tail);
  380. qdf_spin_lock_bh(&soc->tx_ext_desc[desc_pool_id].lock);
  381. tail->next = soc->tx_ext_desc[desc_pool_id].freelist;
  382. soc->tx_ext_desc[desc_pool_id].freelist = head;
  383. soc->tx_ext_desc[desc_pool_id].num_free += num_free;
  384. qdf_spin_unlock_bh(&soc->tx_ext_desc[desc_pool_id].lock);
  385. return;
  386. }
  387. #if defined(FEATURE_TSO)
  388. /**
  389. * dp_tx_tso_desc_alloc() - function to allocate a TSO segment
  390. * @soc: device soc instance
  391. * @pool_id: pool id should pick up tso descriptor
  392. *
  393. * Allocates a TSO segment element from the free list held in
  394. * the soc
  395. *
  396. * Return: tso_seg, tso segment memory pointer
  397. */
  398. static inline struct qdf_tso_seg_elem_t *dp_tx_tso_desc_alloc(
  399. struct dp_soc *soc, uint8_t pool_id)
  400. {
  401. struct qdf_tso_seg_elem_t *tso_seg = NULL;
  402. qdf_spin_lock_bh(&soc->tx_tso_desc[pool_id].lock);
  403. if (soc->tx_tso_desc[pool_id].freelist) {
  404. soc->tx_tso_desc[pool_id].num_free--;
  405. tso_seg = soc->tx_tso_desc[pool_id].freelist;
  406. soc->tx_tso_desc[pool_id].freelist =
  407. soc->tx_tso_desc[pool_id].freelist->next;
  408. }
  409. qdf_spin_unlock_bh(&soc->tx_tso_desc[pool_id].lock);
  410. return tso_seg;
  411. }
  412. /**
  413. * dp_tx_tso_desc_free() - function to free a TSO segment
  414. * @soc: device soc instance
  415. * @pool_id: pool id should pick up tso descriptor
  416. * @tso_seg: tso segment memory pointer
  417. *
  418. * Returns a TSO segment element to the free list held in the
  419. * HTT pdev
  420. *
  421. * Return: none
  422. */
  423. static inline void dp_tx_tso_desc_free(struct dp_soc *soc,
  424. uint8_t pool_id, struct qdf_tso_seg_elem_t *tso_seg)
  425. {
  426. qdf_spin_lock_bh(&soc->tx_tso_desc[pool_id].lock);
  427. tso_seg->next = soc->tx_tso_desc[pool_id].freelist;
  428. soc->tx_tso_desc[pool_id].freelist = tso_seg;
  429. soc->tx_tso_desc[pool_id].num_free++;
  430. qdf_spin_unlock_bh(&soc->tx_tso_desc[pool_id].lock);
  431. }
  432. static inline
  433. struct qdf_tso_num_seg_elem_t *dp_tso_num_seg_alloc(struct dp_soc *soc,
  434. uint8_t pool_id)
  435. {
  436. struct qdf_tso_num_seg_elem_t *tso_num_seg = NULL;
  437. qdf_spin_lock_bh(&soc->tx_tso_num_seg[pool_id].lock);
  438. if (soc->tx_tso_num_seg[pool_id].freelist) {
  439. soc->tx_tso_num_seg[pool_id].num_free--;
  440. tso_num_seg = soc->tx_tso_num_seg[pool_id].freelist;
  441. soc->tx_tso_num_seg[pool_id].freelist =
  442. soc->tx_tso_num_seg[pool_id].freelist->next;
  443. }
  444. qdf_spin_unlock_bh(&soc->tx_tso_num_seg[pool_id].lock);
  445. return tso_num_seg;
  446. }
  447. static inline
  448. void dp_tso_num_seg_free(struct dp_soc *soc,
  449. uint8_t pool_id, struct qdf_tso_num_seg_elem_t *tso_num_seg)
  450. {
  451. qdf_spin_lock_bh(&soc->tx_tso_num_seg[pool_id].lock);
  452. tso_num_seg->next = soc->tx_tso_num_seg[pool_id].freelist;
  453. soc->tx_tso_num_seg[pool_id].freelist = tso_num_seg;
  454. soc->tx_tso_num_seg[pool_id].num_free++;
  455. qdf_spin_unlock_bh(&soc->tx_tso_num_seg[pool_id].lock);
  456. }
  457. #endif
  458. /*
  459. * dp_tx_me_alloc_buf() Alloc descriptor from me pool
  460. * @pdev DP_PDEV handle for datapath
  461. *
  462. * Return:dp_tx_me_buf_t(buf)
  463. */
  464. static inline struct dp_tx_me_buf_t*
  465. dp_tx_me_alloc_buf(struct dp_pdev *pdev)
  466. {
  467. struct dp_tx_me_buf_t *buf = NULL;
  468. qdf_spin_lock_bh(&pdev->tx_mutex);
  469. if (pdev->me_buf.freelist) {
  470. buf = pdev->me_buf.freelist;
  471. pdev->me_buf.freelist = pdev->me_buf.freelist->next;
  472. pdev->me_buf.buf_in_use++;
  473. } else {
  474. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  475. "Error allocating memory in pool");
  476. qdf_spin_unlock_bh(&pdev->tx_mutex);
  477. return NULL;
  478. }
  479. qdf_spin_unlock_bh(&pdev->tx_mutex);
  480. return buf;
  481. }
  482. /*
  483. * dp_tx_me_free_buf() - Free me descriptor and add it to pool
  484. * @pdev: DP_PDEV handle for datapath
  485. * @buf : Allocated ME BUF
  486. *
  487. * Return:void
  488. */
  489. static inline void
  490. dp_tx_me_free_buf(struct dp_pdev *pdev, struct dp_tx_me_buf_t *buf)
  491. {
  492. qdf_spin_lock_bh(&pdev->tx_mutex);
  493. buf->next = pdev->me_buf.freelist;
  494. pdev->me_buf.freelist = buf;
  495. pdev->me_buf.buf_in_use--;
  496. qdf_spin_unlock_bh(&pdev->tx_mutex);
  497. }
  498. #endif /* DP_TX_DESC_H */