dp_tx_flow_control.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /*
  2. * Copyright (c) 2015-2019 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. #include <cds_api.h>
  19. /* OS abstraction libraries */
  20. #include <qdf_nbuf.h> /* qdf_nbuf_t, etc. */
  21. #include <qdf_atomic.h> /* qdf_atomic_read, etc. */
  22. #include <qdf_util.h> /* qdf_unlikely */
  23. #include "dp_types.h"
  24. #include "dp_tx_desc.h"
  25. #include <cdp_txrx_handle.h>
  26. #include "dp_internal.h"
  27. #define INVALID_FLOW_ID 0xFF
  28. #define MAX_INVALID_BIN 3
  29. #ifdef QCA_AC_BASED_FLOW_CONTROL
  30. /**
  31. * dp_tx_initialize_threshold() - Threshold of flow Pool initialization
  32. * @pool: flow_pool
  33. * @stop_threshold: stop threshold of certian AC
  34. * @start_threshold: start threshold of certian AC
  35. * @flow_pool_size: flow pool size
  36. *
  37. * Return: none
  38. */
  39. static inline void
  40. dp_tx_initialize_threshold(struct dp_tx_desc_pool_s *pool,
  41. uint32_t start_threshold,
  42. uint32_t stop_threshold,
  43. uint16_t flow_pool_size)
  44. {
  45. /* BE_BK threshold is same as previous threahold */
  46. pool->start_th[DP_TH_BE_BK] = (start_threshold
  47. * flow_pool_size) / 100;
  48. pool->stop_th[DP_TH_BE_BK] = (stop_threshold
  49. * flow_pool_size) / 100;
  50. /* Update VI threshold based on BE_BK threashold */
  51. pool->start_th[DP_TH_VI] = (pool->start_th[DP_TH_BE_BK]
  52. * FL_TH_VI_PERCENTAGE) / 100;
  53. pool->stop_th[DP_TH_VI] = (pool->stop_th[DP_TH_BE_BK]
  54. * FL_TH_VI_PERCENTAGE) / 100;
  55. /* Update VO threshold based on BE_BK threashold */
  56. pool->start_th[DP_TH_VO] = (pool->start_th[DP_TH_BE_BK]
  57. * FL_TH_VO_PERCENTAGE) / 100;
  58. pool->stop_th[DP_TH_VO] = (pool->stop_th[DP_TH_BE_BK]
  59. * FL_TH_VO_PERCENTAGE) / 100;
  60. /* Update High Priority threshold based on BE_BK threashold */
  61. pool->start_th[DP_TH_HI] = (pool->start_th[DP_TH_BE_BK]
  62. * FL_TH_HI_PERCENTAGE) / 100;
  63. pool->stop_th[DP_TH_HI] = (pool->stop_th[DP_TH_BE_BK]
  64. * FL_TH_HI_PERCENTAGE) / 100;
  65. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  66. "%s: tx flow control threshold is set, pool size is %d",
  67. __func__, flow_pool_size);
  68. }
  69. /**
  70. * dp_tx_flow_pool_reattach() - Reattach flow_pool
  71. * @pool: flow_pool
  72. *
  73. * Return: none
  74. */
  75. static inline void
  76. dp_tx_flow_pool_reattach(struct dp_tx_desc_pool_s *pool)
  77. {
  78. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  79. "%s: flow pool already allocated, attached %d times",
  80. __func__, pool->pool_create_cnt);
  81. if (pool->avail_desc > pool->start_th[DP_TH_BE_BK])
  82. pool->status = FLOW_POOL_ACTIVE_UNPAUSED;
  83. if (pool->avail_desc <= pool->start_th[DP_TH_BE_BK] &&
  84. pool->avail_desc > pool->start_th[DP_TH_VI])
  85. pool->status = FLOW_POOL_BE_BK_PAUSED;
  86. else if (pool->avail_desc <= pool->start_th[DP_TH_VI] &&
  87. pool->avail_desc > pool->start_th[DP_TH_VO])
  88. pool->status = FLOW_POOL_VI_PAUSED;
  89. else if (pool->avail_desc <= pool->start_th[DP_TH_VO] &&
  90. pool->avail_desc > pool->start_th[DP_TH_HI])
  91. pool->status = FLOW_POOL_VO_PAUSED;
  92. else
  93. pool->status = FLOW_POOL_ACTIVE_PAUSED;
  94. pool->pool_create_cnt++;
  95. }
  96. /**
  97. * dp_tx_flow_pool_dump_threshold() - Dump threshold of the flow_pool
  98. * @pool: flow_pool
  99. *
  100. * Return: none
  101. */
  102. static inline void
  103. dp_tx_flow_pool_dump_threshold(struct dp_tx_desc_pool_s *pool)
  104. {
  105. int i;
  106. for (i = 0; i < FL_TH_MAX; i++) {
  107. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  108. "Level %d :: Start threshold %d :: Stop threshold %d",
  109. i, pool->start_th[i], pool->stop_th[i]);
  110. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  111. "Level %d :: Maximun pause time %lu ms",
  112. i, pool->max_pause_time[i]);
  113. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  114. "Level %d :: Latest pause timestamp %lu",
  115. i, pool->latest_pause_time[i]);
  116. }
  117. }
  118. #else
  119. static inline void
  120. dp_tx_initialize_threshold(struct dp_tx_desc_pool_s *pool,
  121. uint32_t start_threshold,
  122. uint32_t stop_threshold,
  123. uint16_t flow_pool_size)
  124. {
  125. /* INI is in percentage so divide by 100 */
  126. pool->start_th = (start_threshold * flow_pool_size) / 100;
  127. pool->stop_th = (stop_threshold * flow_pool_size) / 100;
  128. }
  129. static inline void
  130. dp_tx_flow_pool_reattach(struct dp_tx_desc_pool_s *pool)
  131. {
  132. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  133. "%s: flow pool already allocated, attached %d times",
  134. __func__, pool->pool_create_cnt);
  135. if (pool->avail_desc > pool->start_th)
  136. pool->status = FLOW_POOL_ACTIVE_UNPAUSED;
  137. else
  138. pool->status = FLOW_POOL_ACTIVE_PAUSED;
  139. pool->pool_create_cnt++;
  140. }
  141. static inline void
  142. dp_tx_flow_pool_dump_threshold(struct dp_tx_desc_pool_s *pool)
  143. {
  144. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  145. "Start threshold %d :: Stop threshold %d",
  146. pool->start_th, pool->stop_th);
  147. }
  148. #endif
  149. /**
  150. * dp_tx_dump_flow_pool_info() - dump global_pool and flow_pool info
  151. *
  152. * @ctx: Handle to struct dp_soc.
  153. *
  154. * Return: none
  155. */
  156. void dp_tx_dump_flow_pool_info(struct cdp_soc_t *soc_hdl)
  157. {
  158. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  159. struct dp_txrx_pool_stats *pool_stats = &soc->pool_stats;
  160. struct dp_tx_desc_pool_s *pool = NULL;
  161. struct dp_tx_desc_pool_s tmp_pool;
  162. int i;
  163. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  164. "No of pool map received %d", pool_stats->pool_map_count);
  165. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  166. "No of pool unmap received %d", pool_stats->pool_unmap_count);
  167. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  168. "Pkt dropped due to unavailablity of pool %d",
  169. pool_stats->pkt_drop_no_pool);
  170. /*
  171. * Nested spin lock.
  172. * Always take in below order.
  173. * flow_pool_array_lock -> flow_pool_lock
  174. */
  175. qdf_spin_lock_bh(&soc->flow_pool_array_lock);
  176. for (i = 0; i < MAX_TXDESC_POOLS; i++) {
  177. pool = &soc->tx_desc[i];
  178. if (pool->status > FLOW_POOL_INVALID)
  179. continue;
  180. qdf_spin_lock_bh(&pool->flow_pool_lock);
  181. qdf_mem_copy(&tmp_pool, pool, sizeof(tmp_pool));
  182. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  183. qdf_spin_unlock_bh(&soc->flow_pool_array_lock);
  184. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, "\n");
  185. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  186. "Flow_pool_id %d :: status %d",
  187. tmp_pool.flow_pool_id, tmp_pool.status);
  188. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  189. "Total %d :: Available %d",
  190. tmp_pool.pool_size, tmp_pool.avail_desc);
  191. dp_tx_flow_pool_dump_threshold(&tmp_pool);
  192. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  193. "Member flow_id %d :: flow_type %d",
  194. tmp_pool.flow_pool_id, tmp_pool.flow_type);
  195. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  196. "Pkt dropped due to unavailablity of descriptors %d",
  197. tmp_pool.pkt_drop_no_desc);
  198. qdf_spin_lock_bh(&soc->flow_pool_array_lock);
  199. }
  200. qdf_spin_unlock_bh(&soc->flow_pool_array_lock);
  201. }
  202. /**
  203. * dp_tx_clear_flow_pool_stats() - clear flow pool statistics
  204. *
  205. * @soc: Handle to struct dp_soc.
  206. *
  207. * Return: None
  208. */
  209. void dp_tx_clear_flow_pool_stats(struct dp_soc *soc)
  210. {
  211. if (!soc) {
  212. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  213. "%s: soc is null", __func__);
  214. return;
  215. }
  216. qdf_mem_zero(&soc->pool_stats, sizeof(soc->pool_stats));
  217. }
  218. /**
  219. * dp_tx_create_flow_pool() - create flow pool
  220. * @soc: Handle to struct dp_soc
  221. * @flow_pool_id: flow pool id
  222. * @flow_pool_size: flow pool size
  223. *
  224. * Return: flow_pool pointer / NULL for error
  225. */
  226. struct dp_tx_desc_pool_s *dp_tx_create_flow_pool(struct dp_soc *soc,
  227. uint8_t flow_pool_id, uint16_t flow_pool_size)
  228. {
  229. struct dp_tx_desc_pool_s *pool;
  230. uint32_t stop_threshold;
  231. uint32_t start_threshold;
  232. if (flow_pool_id >= MAX_TXDESC_POOLS) {
  233. dp_err("invalid flow_pool_id %d", flow_pool_id);
  234. return NULL;
  235. }
  236. pool = &soc->tx_desc[flow_pool_id];
  237. qdf_spin_lock_bh(&pool->flow_pool_lock);
  238. if ((pool->status != FLOW_POOL_INACTIVE) || pool->pool_create_cnt) {
  239. dp_tx_flow_pool_reattach(pool);
  240. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  241. dp_err("cannot alloc desc, status=%d, create_cnt=%d",
  242. pool->status, pool->pool_create_cnt);
  243. return pool;
  244. }
  245. if (dp_tx_desc_pool_alloc(soc, flow_pool_id, flow_pool_size)) {
  246. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  247. return NULL;
  248. }
  249. stop_threshold = wlan_cfg_get_tx_flow_stop_queue_th(soc->wlan_cfg_ctx);
  250. start_threshold = stop_threshold +
  251. wlan_cfg_get_tx_flow_start_queue_offset(soc->wlan_cfg_ctx);
  252. pool->flow_pool_id = flow_pool_id;
  253. pool->pool_size = flow_pool_size;
  254. pool->avail_desc = flow_pool_size;
  255. pool->status = FLOW_POOL_ACTIVE_UNPAUSED;
  256. dp_tx_initialize_threshold(pool, start_threshold, stop_threshold,
  257. flow_pool_size);
  258. pool->pool_create_cnt++;
  259. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  260. return pool;
  261. }
  262. /**
  263. * dp_tx_delete_flow_pool() - delete flow pool
  264. * @soc: Handle to struct dp_soc
  265. * @pool: flow pool pointer
  266. * @force: free pool forcefully
  267. *
  268. * Delete flow_pool if all tx descriptors are available.
  269. * Otherwise put it in FLOW_POOL_INVALID state.
  270. * If force is set then pull all available descriptors to
  271. * global pool.
  272. *
  273. * Return: 0 for success or error
  274. */
  275. int dp_tx_delete_flow_pool(struct dp_soc *soc, struct dp_tx_desc_pool_s *pool,
  276. bool force)
  277. {
  278. if (!soc || !pool) {
  279. dp_err("pool or soc is NULL");
  280. QDF_ASSERT(0);
  281. return ENOMEM;
  282. }
  283. dp_info("pool create_cnt=%d, avail_desc=%d, size=%d, status=%d",
  284. pool->pool_create_cnt, pool->avail_desc,
  285. pool->pool_size, pool->status);
  286. qdf_spin_lock_bh(&pool->flow_pool_lock);
  287. if (!pool->pool_create_cnt) {
  288. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  289. dp_err("flow pool either not created or alread deleted");
  290. return -ENOENT;
  291. }
  292. pool->pool_create_cnt--;
  293. if (pool->pool_create_cnt) {
  294. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  295. dp_err("pool is still attached, pending detach %d",
  296. pool->pool_create_cnt);
  297. return -EAGAIN;
  298. }
  299. if (pool->avail_desc < pool->pool_size) {
  300. pool->status = FLOW_POOL_INVALID;
  301. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  302. dp_err("avail desc less than pool size");
  303. return -EAGAIN;
  304. }
  305. /* We have all the descriptors for the pool, we can delete the pool */
  306. dp_tx_desc_pool_free(soc, pool->flow_pool_id);
  307. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  308. return 0;
  309. }
  310. /**
  311. * dp_tx_flow_pool_vdev_map() - Map flow_pool with vdev
  312. * @pdev: Handle to struct dp_pdev
  313. * @pool: flow_pool
  314. * @vdev_id: flow_id /vdev_id
  315. *
  316. * Return: none
  317. */
  318. static void dp_tx_flow_pool_vdev_map(struct dp_pdev *pdev,
  319. struct dp_tx_desc_pool_s *pool, uint8_t vdev_id)
  320. {
  321. struct dp_vdev *vdev;
  322. struct dp_soc *soc = pdev->soc;
  323. vdev = dp_get_vdev_from_soc_vdev_id_wifi3(soc, vdev_id);
  324. if (!vdev) {
  325. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  326. "%s: invalid vdev_id %d",
  327. __func__, vdev_id);
  328. return;
  329. }
  330. vdev->pool = pool;
  331. qdf_spin_lock_bh(&pool->flow_pool_lock);
  332. pool->pool_owner_ctx = soc;
  333. pool->flow_pool_id = vdev_id;
  334. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  335. }
  336. /**
  337. * dp_tx_flow_pool_vdev_unmap() - Unmap flow_pool from vdev
  338. * @pdev: Handle to struct dp_pdev
  339. * @pool: flow_pool
  340. * @vdev_id: flow_id /vdev_id
  341. *
  342. * Return: none
  343. */
  344. static void dp_tx_flow_pool_vdev_unmap(struct dp_pdev *pdev,
  345. struct dp_tx_desc_pool_s *pool, uint8_t vdev_id)
  346. {
  347. struct dp_vdev *vdev;
  348. struct dp_soc *soc = pdev->soc;
  349. vdev = dp_get_vdev_from_soc_vdev_id_wifi3(soc, vdev_id);
  350. if (!vdev) {
  351. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  352. "%s: invalid vdev_id %d",
  353. __func__, vdev_id);
  354. return;
  355. }
  356. vdev->pool = NULL;
  357. }
  358. /**
  359. * dp_tx_flow_pool_map_handler() - Map flow_id with pool of descriptors
  360. * @pdev: Handle to struct dp_pdev
  361. * @flow_id: flow id
  362. * @flow_type: flow type
  363. * @flow_pool_id: pool id
  364. * @flow_pool_size: pool size
  365. *
  366. * Process below target to host message
  367. * HTT_T2H_MSG_TYPE_FLOW_POOL_MAP
  368. *
  369. * Return: none
  370. */
  371. QDF_STATUS dp_tx_flow_pool_map_handler(struct dp_pdev *pdev, uint8_t flow_id,
  372. uint8_t flow_type, uint8_t flow_pool_id, uint16_t flow_pool_size)
  373. {
  374. struct dp_soc *soc = pdev->soc;
  375. struct dp_tx_desc_pool_s *pool;
  376. enum htt_flow_type type = flow_type;
  377. dp_info("flow_id %d flow_type %d flow_pool_id %d flow_pool_size %d",
  378. flow_id, flow_type, flow_pool_id, flow_pool_size);
  379. if (qdf_unlikely(!soc)) {
  380. dp_err("soc is NULL");
  381. return QDF_STATUS_E_FAULT;
  382. }
  383. soc->pool_stats.pool_map_count++;
  384. pool = dp_tx_create_flow_pool(soc, flow_pool_id,
  385. flow_pool_size);
  386. if (!pool) {
  387. dp_err("creation of flow_pool %d size %d failed",
  388. flow_pool_id, flow_pool_size);
  389. return QDF_STATUS_E_RESOURCES;
  390. }
  391. switch (type) {
  392. case FLOW_TYPE_VDEV:
  393. dp_tx_flow_pool_vdev_map(pdev, pool, flow_id);
  394. break;
  395. default:
  396. dp_err("flow type %d not supported", type);
  397. break;
  398. }
  399. return QDF_STATUS_SUCCESS;
  400. }
  401. /**
  402. * dp_tx_flow_pool_unmap_handler() - Unmap flow_id from pool of descriptors
  403. * @pdev: Handle to struct dp_pdev
  404. * @flow_id: flow id
  405. * @flow_type: flow type
  406. * @flow_pool_id: pool id
  407. *
  408. * Process below target to host message
  409. * HTT_T2H_MSG_TYPE_FLOW_POOL_UNMAP
  410. *
  411. * Return: none
  412. */
  413. void dp_tx_flow_pool_unmap_handler(struct dp_pdev *pdev, uint8_t flow_id,
  414. uint8_t flow_type, uint8_t flow_pool_id)
  415. {
  416. struct dp_soc *soc = pdev->soc;
  417. struct dp_tx_desc_pool_s *pool;
  418. enum htt_flow_type type = flow_type;
  419. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  420. "%s: flow_id %d flow_type %d flow_pool_id %d",
  421. __func__, flow_id, flow_type, flow_pool_id);
  422. if (qdf_unlikely(!pdev)) {
  423. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  424. "%s: pdev is NULL", __func__);
  425. return;
  426. }
  427. soc->pool_stats.pool_unmap_count++;
  428. pool = &soc->tx_desc[flow_pool_id];
  429. if (!pool) {
  430. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  431. "%s: flow_pool not available flow_pool_id %d",
  432. __func__, type);
  433. return;
  434. }
  435. switch (type) {
  436. case FLOW_TYPE_VDEV:
  437. dp_tx_flow_pool_vdev_unmap(pdev, pool, flow_id);
  438. break;
  439. default:
  440. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  441. "%s: flow type %d not supported !!!",
  442. __func__, type);
  443. return;
  444. }
  445. /* only delete if all descriptors are available */
  446. dp_tx_delete_flow_pool(soc, pool, false);
  447. }
  448. /**
  449. * dp_tx_flow_control_init() - Initialize tx flow control
  450. * @tx_desc_pool: Handle to flow_pool
  451. *
  452. * Return: none
  453. */
  454. void dp_tx_flow_control_init(struct dp_soc *soc)
  455. {
  456. qdf_spinlock_create(&soc->flow_pool_array_lock);
  457. }
  458. /**
  459. * dp_tx_desc_pool_dealloc() - De-allocate tx desc pool
  460. * @tx_desc_pool: Handle to flow_pool
  461. *
  462. * Return: none
  463. */
  464. static inline void dp_tx_desc_pool_dealloc(struct dp_soc *soc)
  465. {
  466. struct dp_tx_desc_pool_s *tx_desc_pool;
  467. int i;
  468. for (i = 0; i < MAX_TXDESC_POOLS; i++) {
  469. tx_desc_pool = &((soc)->tx_desc[i]);
  470. if (!tx_desc_pool->desc_pages.num_pages)
  471. continue;
  472. if (dp_tx_desc_pool_free(soc, i) != QDF_STATUS_SUCCESS)
  473. dp_err("Tx Desc Pool:%d Free failed", i);
  474. }
  475. }
  476. /**
  477. * dp_tx_flow_control_deinit() - Deregister fw based tx flow control
  478. * @tx_desc_pool: Handle to flow_pool
  479. *
  480. * Return: none
  481. */
  482. void dp_tx_flow_control_deinit(struct dp_soc *soc)
  483. {
  484. dp_tx_desc_pool_dealloc(soc);
  485. qdf_spinlock_destroy(&soc->flow_pool_array_lock);
  486. }
  487. /**
  488. * dp_txrx_register_pause_cb() - Register pause callback
  489. * @ctx: Handle to struct dp_soc
  490. * @pause_cb: Tx pause_cb
  491. *
  492. * Return: none
  493. */
  494. QDF_STATUS dp_txrx_register_pause_cb(struct cdp_soc_t *handle,
  495. tx_pause_callback pause_cb)
  496. {
  497. struct dp_soc *soc = (struct dp_soc *)handle;
  498. if (!soc || !pause_cb) {
  499. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  500. FL("soc or pause_cb is NULL"));
  501. return QDF_STATUS_E_INVAL;
  502. }
  503. soc->pause_cb = pause_cb;
  504. return QDF_STATUS_SUCCESS;
  505. }
  506. QDF_STATUS dp_tx_flow_pool_map(struct cdp_soc_t *handle, uint8_t pdev_id,
  507. uint8_t vdev_id)
  508. {
  509. struct dp_soc *soc = cdp_soc_t_to_dp_soc(handle);
  510. struct dp_pdev *pdev =
  511. dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
  512. int tx_ring_size = wlan_cfg_tx_ring_size(soc->wlan_cfg_ctx);
  513. if (!pdev) {
  514. dp_err("pdev is NULL");
  515. return QDF_STATUS_E_INVAL;
  516. }
  517. return dp_tx_flow_pool_map_handler(pdev, vdev_id, FLOW_TYPE_VDEV,
  518. vdev_id, tx_ring_size);
  519. }
  520. void dp_tx_flow_pool_unmap(struct cdp_soc_t *handle, uint8_t pdev_id,
  521. uint8_t vdev_id)
  522. {
  523. struct dp_soc *soc = cdp_soc_t_to_dp_soc(handle);
  524. struct dp_pdev *pdev =
  525. dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
  526. if (!pdev) {
  527. dp_err("pdev is NULL");
  528. return;
  529. }
  530. return dp_tx_flow_pool_unmap_handler(pdev, vdev_id,
  531. FLOW_TYPE_VDEV, vdev_id);
  532. }