dp_be.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. /*
  2. * Copyright (c) 2021 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 <wlan_utility.h>
  19. #include <dp_internal.h>
  20. #include <dp_htt.h>
  21. #include "dp_be.h"
  22. #include "dp_be_tx.h"
  23. #include "dp_be_rx.h"
  24. #include <hal_be_api.h>
  25. #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
  26. static struct wlan_cfg_tcl_wbm_ring_num_map g_tcl_wbm_map_array[MAX_TCL_DATA_RINGS] = {
  27. {.tcl_ring_num = 0, .wbm_ring_num = 0, .wbm_rbm_id = HAL_BE_WBM_SW0_BM_ID, .for_ipa = 0},
  28. {1, 4, HAL_BE_WBM_SW4_BM_ID, 0},
  29. {2, 2, HAL_BE_WBM_SW2_BM_ID, 0},
  30. {3, 6, HAL_BE_WBM_SW5_BM_ID, 0},
  31. {4, 7, HAL_BE_WBM_SW6_BM_ID, 0}
  32. };
  33. #else
  34. static struct wlan_cfg_tcl_wbm_ring_num_map g_tcl_wbm_map_array[MAX_TCL_DATA_RINGS] = {
  35. {.tcl_ring_num = 0, .wbm_ring_num = 0, .wbm_rbm_id = HAL_BE_WBM_SW0_BM_ID, .for_ipa = 0},
  36. {1, 1, HAL_BE_WBM_SW1_BM_ID, 0},
  37. {2, 2, HAL_BE_WBM_SW2_BM_ID, 0},
  38. {3, 3, HAL_BE_WBM_SW3_BM_ID, 0},
  39. {4, 4, HAL_BE_WBM_SW4_BM_ID, 0}
  40. };
  41. #endif
  42. static void dp_soc_cfg_attach_be(struct dp_soc *soc)
  43. {
  44. soc->wlan_cfg_ctx->tcl_wbm_map_array = g_tcl_wbm_map_array;
  45. }
  46. qdf_size_t dp_get_context_size_be(enum dp_context_type context_type)
  47. {
  48. switch (context_type) {
  49. case DP_CONTEXT_TYPE_SOC:
  50. return sizeof(struct dp_soc_be);
  51. case DP_CONTEXT_TYPE_PDEV:
  52. return sizeof(struct dp_pdev_be);
  53. case DP_CONTEXT_TYPE_VDEV:
  54. return sizeof(struct dp_vdev_be);
  55. case DP_CONTEXT_TYPE_PEER:
  56. return sizeof(struct dp_peer_be);
  57. default:
  58. return 0;
  59. }
  60. }
  61. #ifdef DP_FEATURE_HW_COOKIE_CONVERSION
  62. #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
  63. /**
  64. * dp_cc_wbm_sw_en_cfg() - configure HW cookie conversion enablement
  65. per wbm2sw ring
  66. * @cc_cfg: HAL HW cookie conversion configuration structure pointer
  67. *
  68. * Return: None
  69. */
  70. static inline
  71. void dp_cc_wbm_sw_en_cfg(struct hal_hw_cc_config *cc_cfg)
  72. {
  73. cc_cfg->wbm2sw6_cc_en = 1;
  74. cc_cfg->wbm2sw5_cc_en = 1;
  75. cc_cfg->wbm2sw4_cc_en = 1;
  76. cc_cfg->wbm2sw3_cc_en = 1;
  77. cc_cfg->wbm2sw2_cc_en = 1;
  78. /* disable wbm2sw1 hw cc as it's for FW */
  79. cc_cfg->wbm2sw1_cc_en = 0;
  80. cc_cfg->wbm2sw0_cc_en = 1;
  81. cc_cfg->wbm2fw_cc_en = 0;
  82. }
  83. #else
  84. static inline
  85. void dp_cc_wbm_sw_en_cfg(struct hal_hw_cc_config *cc_cfg)
  86. {
  87. cc_cfg->wbm2sw6_cc_en = 1;
  88. cc_cfg->wbm2sw5_cc_en = 1;
  89. cc_cfg->wbm2sw4_cc_en = 1;
  90. cc_cfg->wbm2sw3_cc_en = 1;
  91. cc_cfg->wbm2sw2_cc_en = 1;
  92. cc_cfg->wbm2sw1_cc_en = 1;
  93. cc_cfg->wbm2sw0_cc_en = 1;
  94. cc_cfg->wbm2fw_cc_en = 0;
  95. }
  96. #endif
  97. /**
  98. * dp_cc_reg_cfg_init() - initialize and configure HW cookie
  99. conversion register
  100. * @soc: SOC handle
  101. * @cc_ctx: cookie conversion context pointer
  102. * @is_4k_align: page address 4k alignd
  103. *
  104. * Return: None
  105. */
  106. static void dp_cc_reg_cfg_init(struct dp_soc *soc,
  107. struct dp_hw_cookie_conversion_t *cc_ctx,
  108. bool is_4k_align)
  109. {
  110. struct hal_hw_cc_config cc_cfg = { 0 };
  111. if (!soc->wlan_cfg_ctx->hw_cc_enabled) {
  112. dp_info("INI skip HW CC register setting");
  113. return;
  114. }
  115. cc_cfg.lut_base_addr_31_0 = cc_ctx->cmem_base;
  116. cc_cfg.cc_global_en = true;
  117. cc_cfg.page_4k_align = is_4k_align;
  118. cc_cfg.cookie_offset_msb = DP_CC_DESC_ID_SPT_VA_OS_MSB;
  119. cc_cfg.cookie_page_msb = DP_CC_DESC_ID_PPT_PAGE_OS_MSB;
  120. /* 36th bit should be 1 then HW know this is CMEM address */
  121. cc_cfg.lut_base_addr_39_32 = 0x10;
  122. cc_cfg.error_path_cookie_conv_en = true;
  123. cc_cfg.release_path_cookie_conv_en = true;
  124. dp_cc_wbm_sw_en_cfg(&cc_cfg);
  125. hal_cookie_conversion_reg_cfg_be(soc->hal_soc, &cc_cfg);
  126. }
  127. /**
  128. * dp_hw_cc_cmem_write() - DP wrapper function for CMEM buffer writing
  129. * @hal_soc_hdl: HAL SOC handle
  130. * @offset: CMEM address
  131. * @value: value to write
  132. *
  133. * Return: None.
  134. */
  135. static inline void dp_hw_cc_cmem_write(hal_soc_handle_t hal_soc_hdl,
  136. uint32_t offset,
  137. uint32_t value)
  138. {
  139. hal_cmem_write(hal_soc_hdl, offset, value);
  140. }
  141. /**
  142. * dp_hw_cc_cmem_addr_init() - Check and initialize CMEM base address for
  143. HW cookie conversion
  144. * @soc: SOC handle
  145. * @cc_ctx: cookie conversion context pointer
  146. *
  147. * Return: 0 in case of success, else error value
  148. */
  149. static inline QDF_STATUS dp_hw_cc_cmem_addr_init(
  150. struct dp_soc *soc,
  151. struct dp_hw_cookie_conversion_t *cc_ctx)
  152. {
  153. dp_info("cmem base 0x%llx, size 0x%llx",
  154. soc->cmem_base, soc->cmem_size);
  155. /* get CMEM for cookie conversion */
  156. if (soc->cmem_size < DP_CC_PPT_MEM_SIZE) {
  157. dp_err("cmem_size %llu bytes < 4K", soc->cmem_size);
  158. return QDF_STATUS_E_RESOURCES;
  159. }
  160. cc_ctx->cmem_base = (uint32_t)(soc->cmem_base +
  161. DP_CC_MEM_OFFSET_IN_CMEM);
  162. return QDF_STATUS_SUCCESS;
  163. }
  164. #else
  165. static inline void dp_cc_reg_cfg_init(struct dp_soc *soc,
  166. struct dp_hw_cookie_conversion_t *cc_ctx,
  167. bool is_4k_align) {}
  168. static inline void dp_hw_cc_cmem_write(hal_soc_handle_t hal_soc_hdl,
  169. uint32_t offset,
  170. uint32_t value)
  171. { }
  172. static inline QDF_STATUS dp_hw_cc_cmem_addr_init(
  173. struct dp_soc *soc,
  174. struct dp_hw_cookie_conversion_t *cc_ctx)
  175. {
  176. return QDF_STATUS_SUCCESS;
  177. }
  178. #endif
  179. static QDF_STATUS dp_hw_cookie_conversion_attach(struct dp_soc_be *be_soc)
  180. {
  181. struct dp_soc *soc = DP_SOC_BE_GET_SOC(be_soc);
  182. struct dp_hw_cookie_conversion_t *cc_ctx = &be_soc->hw_cc_ctx;
  183. uint32_t max_tx_rx_desc_num, num_spt_pages, i = 0;
  184. struct dp_spt_page_desc *spt_desc;
  185. struct qdf_mem_dma_page_t *dma_page;
  186. QDF_STATUS qdf_status;
  187. if (soc->cdp_soc.ol_ops->get_con_mode &&
  188. soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_FTM_MODE)
  189. return QDF_STATUS_SUCCESS;
  190. qdf_status = dp_hw_cc_cmem_addr_init(soc, cc_ctx);
  191. if (!QDF_IS_STATUS_SUCCESS(qdf_status))
  192. return qdf_status;
  193. /* estimate how many SPT DDR pages needed */
  194. max_tx_rx_desc_num = WLAN_CFG_NUM_TX_DESC_MAX * MAX_TXDESC_POOLS +
  195. WLAN_CFG_RX_SW_DESC_NUM_SIZE_MAX * MAX_RXDESC_POOLS;
  196. num_spt_pages = max_tx_rx_desc_num / DP_CC_SPT_PAGE_MAX_ENTRIES;
  197. num_spt_pages = num_spt_pages <= DP_CC_PPT_MAX_ENTRIES ?
  198. num_spt_pages : DP_CC_PPT_MAX_ENTRIES;
  199. dp_info("num_spt_pages needed %d", num_spt_pages);
  200. dp_desc_multi_pages_mem_alloc(soc, DP_HW_CC_SPT_PAGE_TYPE,
  201. &cc_ctx->page_pool, qdf_page_size,
  202. num_spt_pages, 0, false);
  203. if (!cc_ctx->page_pool.dma_pages) {
  204. dp_err("spt ddr pages allocation failed");
  205. return QDF_STATUS_E_RESOURCES;
  206. }
  207. cc_ctx->page_desc_base = qdf_mem_malloc(
  208. num_spt_pages * sizeof(struct dp_spt_page_desc));
  209. if (!cc_ctx->page_desc_base) {
  210. dp_err("spt page descs allocation failed");
  211. goto fail_0;
  212. }
  213. /* initial page desc */
  214. spt_desc = cc_ctx->page_desc_base;
  215. dma_page = cc_ctx->page_pool.dma_pages;
  216. while (i < num_spt_pages) {
  217. /* check if page address 4K aligned */
  218. if (qdf_unlikely(dma_page[i].page_p_addr & 0xFFF)) {
  219. dp_err("non-4k aligned pages addr %pK",
  220. (void *)dma_page[i].page_p_addr);
  221. goto fail_1;
  222. }
  223. spt_desc[i].page_v_addr =
  224. dma_page[i].page_v_addr_start;
  225. spt_desc[i].page_p_addr =
  226. dma_page[i].page_p_addr;
  227. i++;
  228. }
  229. cc_ctx->total_page_num = num_spt_pages;
  230. qdf_spinlock_create(&cc_ctx->cc_lock);
  231. return QDF_STATUS_SUCCESS;
  232. fail_1:
  233. qdf_mem_free(cc_ctx->page_desc_base);
  234. fail_0:
  235. dp_desc_multi_pages_mem_free(soc, DP_HW_CC_SPT_PAGE_TYPE,
  236. &cc_ctx->page_pool, 0, false);
  237. return QDF_STATUS_E_FAILURE;
  238. }
  239. static QDF_STATUS dp_hw_cookie_conversion_detach(struct dp_soc_be *be_soc)
  240. {
  241. struct dp_soc *soc = DP_SOC_BE_GET_SOC(be_soc);
  242. struct dp_hw_cookie_conversion_t *cc_ctx = &be_soc->hw_cc_ctx;
  243. if (soc->cdp_soc.ol_ops->get_con_mode &&
  244. soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_FTM_MODE)
  245. return QDF_STATUS_SUCCESS;
  246. qdf_mem_free(cc_ctx->page_desc_base);
  247. dp_desc_multi_pages_mem_free(soc, DP_HW_CC_SPT_PAGE_TYPE,
  248. &cc_ctx->page_pool, 0, false);
  249. qdf_spinlock_destroy(&cc_ctx->cc_lock);
  250. return QDF_STATUS_SUCCESS;
  251. }
  252. static QDF_STATUS dp_hw_cookie_conversion_init(struct dp_soc_be *be_soc)
  253. {
  254. struct dp_soc *soc = DP_SOC_BE_GET_SOC(be_soc);
  255. struct dp_hw_cookie_conversion_t *cc_ctx = &be_soc->hw_cc_ctx;
  256. uint32_t i = 0;
  257. struct dp_spt_page_desc *spt_desc;
  258. if (soc->cdp_soc.ol_ops->get_con_mode &&
  259. soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_FTM_MODE)
  260. return QDF_STATUS_SUCCESS;
  261. if (!cc_ctx->total_page_num) {
  262. dp_err("total page num is 0");
  263. return QDF_STATUS_E_INVAL;
  264. }
  265. spt_desc = cc_ctx->page_desc_base;
  266. while (i < cc_ctx->total_page_num) {
  267. /* write page PA to CMEM */
  268. dp_hw_cc_cmem_write(soc->hal_soc,
  269. (cc_ctx->cmem_base +
  270. i * DP_CC_PPT_ENTRY_SIZE_4K_ALIGNED),
  271. (spt_desc[i].page_p_addr >>
  272. DP_CC_PPT_ENTRY_HW_APEND_BITS_4K_ALIGNED));
  273. spt_desc[i].ppt_index = i;
  274. spt_desc[i].avail_entry_index = 0;
  275. /* link page desc */
  276. if ((i + 1) != cc_ctx->total_page_num)
  277. spt_desc[i].next = &spt_desc[i + 1];
  278. else
  279. spt_desc[i].next = NULL;
  280. i++;
  281. }
  282. cc_ctx->page_desc_freelist = cc_ctx->page_desc_base;
  283. cc_ctx->free_page_num = cc_ctx->total_page_num;
  284. /* write WBM/REO cookie conversion CFG register */
  285. dp_cc_reg_cfg_init(soc, cc_ctx, true);
  286. return QDF_STATUS_SUCCESS;
  287. }
  288. static QDF_STATUS dp_hw_cookie_conversion_deinit(struct dp_soc_be *be_soc)
  289. {
  290. struct dp_soc *soc = DP_SOC_BE_GET_SOC(be_soc);
  291. struct dp_hw_cookie_conversion_t *cc_ctx = &be_soc->hw_cc_ctx;
  292. if (soc->cdp_soc.ol_ops->get_con_mode &&
  293. soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_FTM_MODE)
  294. return QDF_STATUS_SUCCESS;
  295. cc_ctx->page_desc_freelist = NULL;
  296. cc_ctx->free_page_num = 0;
  297. return QDF_STATUS_SUCCESS;
  298. }
  299. uint16_t dp_cc_spt_page_desc_alloc(struct dp_soc_be *be_soc,
  300. struct dp_spt_page_desc **list_head,
  301. struct dp_spt_page_desc **list_tail,
  302. uint16_t num_desc)
  303. {
  304. uint16_t num_pages, count;
  305. struct dp_hw_cookie_conversion_t *cc_ctx = &be_soc->hw_cc_ctx;
  306. num_pages = (num_desc / DP_CC_SPT_PAGE_MAX_ENTRIES) +
  307. (num_desc % DP_CC_SPT_PAGE_MAX_ENTRIES ? 1 : 0);
  308. if (num_pages > cc_ctx->free_page_num) {
  309. dp_err("fail: num_pages required %d > free_page_num %d",
  310. num_pages,
  311. cc_ctx->free_page_num);
  312. return 0;
  313. }
  314. qdf_spin_lock_bh(&cc_ctx->cc_lock);
  315. *list_head = *list_tail = cc_ctx->page_desc_freelist;
  316. for (count = 0; count < num_pages; count++) {
  317. if (qdf_unlikely(!cc_ctx->page_desc_freelist)) {
  318. cc_ctx->page_desc_freelist = *list_head;
  319. *list_head = *list_tail = NULL;
  320. qdf_spin_unlock_bh(&cc_ctx->cc_lock);
  321. return 0;
  322. }
  323. *list_tail = cc_ctx->page_desc_freelist;
  324. cc_ctx->page_desc_freelist = cc_ctx->page_desc_freelist->next;
  325. }
  326. (*list_tail)->next = NULL;
  327. cc_ctx->free_page_num -= count;
  328. qdf_spin_unlock_bh(&cc_ctx->cc_lock);
  329. return count;
  330. }
  331. void dp_cc_spt_page_desc_free(struct dp_soc_be *be_soc,
  332. struct dp_spt_page_desc **list_head,
  333. struct dp_spt_page_desc **list_tail,
  334. uint16_t page_nums)
  335. {
  336. struct dp_hw_cookie_conversion_t *cc_ctx = &be_soc->hw_cc_ctx;
  337. struct dp_spt_page_desc *temp_list = NULL;
  338. qdf_spin_lock_bh(&cc_ctx->cc_lock);
  339. temp_list = cc_ctx->page_desc_freelist;
  340. cc_ctx->page_desc_freelist = *list_head;
  341. (*list_tail)->next = temp_list;
  342. cc_ctx->free_page_num += page_nums;
  343. *list_tail = NULL;
  344. *list_head = NULL;
  345. qdf_spin_unlock_bh(&cc_ctx->cc_lock);
  346. }
  347. static QDF_STATUS dp_soc_attach_be(struct dp_soc *soc)
  348. {
  349. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  350. QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
  351. soc->wbm_sw0_bm_id = hal_tx_get_wbm_sw0_bm_id();
  352. qdf_status = dp_tx_init_bank_profiles(be_soc);
  353. /* cookie conversion */
  354. qdf_status = dp_hw_cookie_conversion_attach(be_soc);
  355. return qdf_status;
  356. }
  357. static QDF_STATUS dp_soc_detach_be(struct dp_soc *soc)
  358. {
  359. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  360. dp_tx_deinit_bank_profiles(be_soc);
  361. dp_hw_cookie_conversion_detach(be_soc);
  362. return QDF_STATUS_SUCCESS;
  363. }
  364. static QDF_STATUS dp_soc_init_be(struct dp_soc *soc)
  365. {
  366. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  367. QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
  368. qdf_status = dp_hw_cookie_conversion_init(be_soc);
  369. return qdf_status;
  370. }
  371. static QDF_STATUS dp_soc_deinit_be(struct dp_soc *soc)
  372. {
  373. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  374. dp_hw_cookie_conversion_deinit(be_soc);
  375. return QDF_STATUS_SUCCESS;
  376. }
  377. static QDF_STATUS dp_pdev_attach_be(struct dp_pdev *pdev)
  378. {
  379. return QDF_STATUS_SUCCESS;
  380. }
  381. static QDF_STATUS dp_pdev_detach_be(struct dp_pdev *pdev)
  382. {
  383. return QDF_STATUS_SUCCESS;
  384. }
  385. static QDF_STATUS dp_vdev_attach_be(struct dp_soc *soc, struct dp_vdev *vdev)
  386. {
  387. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  388. struct dp_vdev_be *be_vdev = dp_get_be_vdev_from_dp_vdev(vdev);
  389. be_vdev->bank_id = dp_tx_get_bank_profile(be_soc, be_vdev);
  390. /* Needs to be enabled after bring-up*/
  391. be_vdev->vdev_id_check_en = false;
  392. if (be_vdev->bank_id == DP_BE_INVALID_BANK_ID) {
  393. QDF_BUG(0);
  394. return QDF_STATUS_E_FAULT;
  395. }
  396. if (vdev->opmode == wlan_op_mode_sta)
  397. hal_tx_vdev_mcast_ctrl_set(soc->hal_soc, vdev->vdev_id,
  398. HAL_TX_MCAST_CTRL_MEC_NOTIFY);
  399. return QDF_STATUS_SUCCESS;
  400. }
  401. static QDF_STATUS dp_vdev_detach_be(struct dp_soc *soc, struct dp_vdev *vdev)
  402. {
  403. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  404. struct dp_vdev_be *be_vdev = dp_get_be_vdev_from_dp_vdev(vdev);
  405. dp_tx_put_bank_profile(be_soc, be_vdev);
  406. return QDF_STATUS_SUCCESS;
  407. }
  408. qdf_size_t dp_get_soc_context_size_be(void)
  409. {
  410. return sizeof(struct dp_soc_be);
  411. }
  412. /**
  413. * dp_rxdma_ring_sel_cfg_be() - Setup RXDMA ring config
  414. * @soc: Common DP soc handle
  415. *
  416. * Return: QDF_STATUS
  417. */
  418. static QDF_STATUS
  419. dp_rxdma_ring_sel_cfg_be(struct dp_soc *soc)
  420. {
  421. int i;
  422. int mac_id;
  423. struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
  424. struct dp_srng *rx_mac_srng;
  425. QDF_STATUS status = QDF_STATUS_SUCCESS;
  426. /*
  427. * In Beryllium chipset msdu_start, mpdu_end
  428. * and rx_attn are part of msdu_end/mpdu_start
  429. */
  430. htt_tlv_filter.msdu_start = 0;
  431. htt_tlv_filter.mpdu_end = 0;
  432. htt_tlv_filter.attention = 0;
  433. htt_tlv_filter.mpdu_start = 1;
  434. htt_tlv_filter.msdu_end = 1;
  435. htt_tlv_filter.packet = 1;
  436. htt_tlv_filter.packet_header = 1;
  437. htt_tlv_filter.ppdu_start = 0;
  438. htt_tlv_filter.ppdu_end = 0;
  439. htt_tlv_filter.ppdu_end_user_stats = 0;
  440. htt_tlv_filter.ppdu_end_user_stats_ext = 0;
  441. htt_tlv_filter.ppdu_end_status_done = 0;
  442. htt_tlv_filter.enable_fp = 1;
  443. htt_tlv_filter.enable_md = 0;
  444. htt_tlv_filter.enable_md = 0;
  445. htt_tlv_filter.enable_mo = 0;
  446. htt_tlv_filter.fp_mgmt_filter = 0;
  447. htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_BA_REQ;
  448. htt_tlv_filter.fp_data_filter = (FILTER_DATA_UCAST |
  449. FILTER_DATA_MCAST |
  450. FILTER_DATA_DATA);
  451. htt_tlv_filter.mo_mgmt_filter = 0;
  452. htt_tlv_filter.mo_ctrl_filter = 0;
  453. htt_tlv_filter.mo_data_filter = 0;
  454. htt_tlv_filter.md_data_filter = 0;
  455. htt_tlv_filter.offset_valid = true;
  456. /* Not subscribing to mpdu_end, msdu_start and rx_attn */
  457. htt_tlv_filter.rx_mpdu_end_offset = 0;
  458. htt_tlv_filter.rx_msdu_start_offset = 0;
  459. htt_tlv_filter.rx_attn_offset = 0;
  460. htt_tlv_filter.rx_packet_offset = soc->rx_pkt_tlv_size;
  461. htt_tlv_filter.rx_header_offset =
  462. hal_rx_pkt_tlv_offset_get(soc->hal_soc);
  463. htt_tlv_filter.rx_mpdu_start_offset =
  464. hal_rx_mpdu_start_offset_get(soc->hal_soc);
  465. htt_tlv_filter.rx_msdu_end_offset =
  466. hal_rx_msdu_end_offset_get(soc->hal_soc);
  467. dp_info("TLV subscription\n"
  468. "msdu_start %d, mpdu_end %d, attention %d"
  469. "mpdu_start %d, msdu_end %d, pkt_hdr %d, pkt %d\n"
  470. "TLV offsets\n"
  471. "msdu_start %d, mpdu_end %d, attention %d"
  472. "mpdu_start %d, msdu_end %d, pkt_hdr %d, pkt %d\n",
  473. htt_tlv_filter.msdu_start,
  474. htt_tlv_filter.mpdu_end,
  475. htt_tlv_filter.attention,
  476. htt_tlv_filter.mpdu_start,
  477. htt_tlv_filter.msdu_end,
  478. htt_tlv_filter.packet_header,
  479. htt_tlv_filter.packet,
  480. htt_tlv_filter.rx_msdu_start_offset,
  481. htt_tlv_filter.rx_mpdu_end_offset,
  482. htt_tlv_filter.rx_attn_offset,
  483. htt_tlv_filter.rx_mpdu_start_offset,
  484. htt_tlv_filter.rx_msdu_end_offset,
  485. htt_tlv_filter.rx_header_offset,
  486. htt_tlv_filter.rx_packet_offset);
  487. for (i = 0; i < MAX_PDEV_CNT; i++) {
  488. struct dp_pdev *pdev = soc->pdev_list[i];
  489. if (!pdev)
  490. continue;
  491. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  492. int mac_for_pdev =
  493. dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  494. /*
  495. * Obtain lmac id from pdev to access the LMAC ring
  496. * in soc context
  497. */
  498. int lmac_id =
  499. dp_get_lmac_id_for_pdev_id(soc, mac_id,
  500. pdev->pdev_id);
  501. rx_mac_srng = dp_get_rxdma_ring(pdev, lmac_id);
  502. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  503. rx_mac_srng->hal_srng,
  504. RXDMA_BUF, RX_DATA_BUFFER_SIZE,
  505. &htt_tlv_filter);
  506. }
  507. }
  508. return status;
  509. }
  510. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  511. /**
  512. * dp_service_near_full_srngs_be() - Main bottom half callback for the
  513. * near-full IRQs.
  514. * @soc: Datapath SoC handle
  515. * @int_ctx: Interrupt context
  516. * @dp_budget: Budget of the work that can be done in the bottom half
  517. *
  518. * Return: work done in the handler
  519. */
  520. static uint32_t
  521. dp_service_near_full_srngs_be(struct dp_soc *soc, struct dp_intr *int_ctx,
  522. uint32_t dp_budget)
  523. {
  524. int ring = 0;
  525. int budget = dp_budget;
  526. uint32_t work_done = 0;
  527. uint32_t remaining_quota = dp_budget;
  528. struct dp_intr_stats *intr_stats = &int_ctx->intr_stats;
  529. int tx_ring_near_full_mask = int_ctx->tx_ring_near_full_mask;
  530. int rx_near_full_grp_1_mask = int_ctx->rx_near_full_grp_1_mask;
  531. int rx_near_full_grp_2_mask = int_ctx->rx_near_full_grp_2_mask;
  532. int rx_near_full_mask = rx_near_full_grp_1_mask |
  533. rx_near_full_grp_2_mask;
  534. dp_verbose_debug("rx_ring_near_full 0x%x tx_ring_near_full 0x%x",
  535. rx_near_full_mask,
  536. tx_ring_near_full_mask);
  537. if (rx_near_full_mask) {
  538. for (ring = 0; ring < soc->num_reo_dest_rings; ring++) {
  539. if (!(rx_near_full_mask & (1 << ring)))
  540. continue;
  541. work_done = dp_rx_nf_process(int_ctx,
  542. soc->reo_dest_ring[ring].hal_srng,
  543. ring, remaining_quota);
  544. if (work_done) {
  545. intr_stats->num_rx_ring_near_full_masks[ring]++;
  546. dp_verbose_debug("rx NF mask 0x%x ring %d, work_done %d budget %d",
  547. rx_near_full_mask, ring,
  548. work_done,
  549. budget);
  550. budget -= work_done;
  551. if (budget <= 0)
  552. goto budget_done;
  553. remaining_quota = budget;
  554. }
  555. }
  556. }
  557. if (tx_ring_near_full_mask) {
  558. for (ring = 0; ring < MAX_TCL_DATA_RINGS; ring++) {
  559. if (!(tx_ring_near_full_mask & (1 << ring)))
  560. continue;
  561. work_done = dp_tx_comp_nf_handler(int_ctx, soc,
  562. soc->tx_comp_ring[ring].hal_srng,
  563. ring, remaining_quota);
  564. if (work_done) {
  565. intr_stats->num_tx_comp_ring_near_full_masks[ring]++;
  566. dp_verbose_debug("tx NF mask 0x%x ring %d, work_done %d budget %d",
  567. tx_ring_near_full_mask, ring,
  568. work_done, budget);
  569. budget -= work_done;
  570. if (budget <= 0)
  571. break;
  572. remaining_quota = budget;
  573. }
  574. }
  575. }
  576. intr_stats->num_near_full_masks++;
  577. budget_done:
  578. return dp_budget - budget;
  579. }
  580. /**
  581. * dp_srng_test_and_update_nf_params_be() - Check if the srng is in near full
  582. * state and set the reap_limit appropriately
  583. * as per the near full state
  584. * @soc: Datapath soc handle
  585. * @dp_srng: Datapath handle for SRNG
  586. * @max_reap_limit: [Output Buffer] Buffer to set the max reap limit as per
  587. * the srng near-full state
  588. *
  589. * Return: 1, if the srng is in near-full state
  590. * 0, if the srng is not in near-full state
  591. */
  592. static int
  593. dp_srng_test_and_update_nf_params_be(struct dp_soc *soc,
  594. struct dp_srng *dp_srng,
  595. int *max_reap_limit)
  596. {
  597. return _dp_srng_test_and_update_nf_params(soc, dp_srng, max_reap_limit);
  598. }
  599. /**
  600. * dp_init_near_full_arch_ops_be() - Initialize the arch ops handler for the
  601. * near full IRQ handling operations.
  602. * @arch_ops: arch ops handle
  603. *
  604. * Return: none
  605. */
  606. static inline void
  607. dp_init_near_full_arch_ops_be(struct dp_arch_ops *arch_ops)
  608. {
  609. arch_ops->dp_service_near_full_srngs = dp_service_near_full_srngs_be;
  610. arch_ops->dp_srng_test_and_update_nf_params =
  611. dp_srng_test_and_update_nf_params_be;
  612. }
  613. #else
  614. static inline void
  615. dp_init_near_full_arch_ops_be(struct dp_arch_ops *arch_ops)
  616. {
  617. }
  618. #endif
  619. #ifdef WLAN_SUPPORT_PPEDS
  620. static void dp_soc_ppe_srng_deinit(struct dp_soc *soc)
  621. {
  622. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  623. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  624. soc_cfg_ctx = soc->wlan_cfg_ctx;
  625. if (!wlan_cfg_get_dp_soc_is_ppe_enabled(soc_cfg_ctx))
  626. return;
  627. dp_srng_deinit(soc, &be_soc->ppe_release_ring, PPE_RELEASE, 0);
  628. wlan_minidump_remove(be_soc->ppe_release_ring.base_vaddr_unaligned,
  629. be_soc->ppe_release_ring.alloc_size,
  630. soc->ctrl_psoc,
  631. WLAN_MD_DP_SRNG_PPE_RELEASE,
  632. "ppe_release_ring");
  633. dp_srng_deinit(soc, &be_soc->ppe2tcl_ring, PPE2TCL, 0);
  634. wlan_minidump_remove(be_soc->ppe2tcl_ring.base_vaddr_unaligned,
  635. be_soc->ppe2tcl_ring.alloc_size,
  636. soc->ctrl_psoc,
  637. WLAN_MD_DP_SRNG_PPE2TCL,
  638. "ppe2tcl_ring");
  639. dp_srng_deinit(soc, &be_soc->reo2ppe_ring, REO2PPE, 0);
  640. wlan_minidump_remove(be_soc->reo2ppe_ring.base_vaddr_unaligned,
  641. be_soc->reo2ppe_ring.alloc_size,
  642. soc->ctrl_psoc,
  643. WLAN_MD_DP_SRNG_REO2PPE,
  644. "reo2ppe_ring");
  645. }
  646. static void dp_soc_ppe_srng_free(struct dp_soc *soc)
  647. {
  648. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  649. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  650. soc_cfg_ctx = soc->wlan_cfg_ctx;
  651. if (!wlan_cfg_get_dp_soc_is_ppe_enabled(soc_cfg_ctx))
  652. return;
  653. dp_srng_free(soc, &be_soc->ppe_release_ring);
  654. dp_srng_free(soc, &be_soc->ppe2tcl_ring);
  655. dp_srng_free(soc, &be_soc->reo2ppe_ring);
  656. }
  657. static QDF_STATUS dp_soc_ppe_srng_alloc(struct dp_soc *soc)
  658. {
  659. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  660. uint32_t entries;
  661. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  662. soc_cfg_ctx = soc->wlan_cfg_ctx;
  663. if (!wlan_cfg_get_dp_soc_is_ppe_enabled(soc_cfg_ctx))
  664. return QDF_STATUS_SUCCESS;
  665. entries = wlan_cfg_get_dp_soc_reo2ppe_ring_size(soc_cfg_ctx);
  666. if (dp_srng_alloc(soc, &be_soc->reo2ppe_ring, REO2PPE,
  667. entries, 0)) {
  668. dp_err("%pK: dp_srng_alloc failed for reo2ppe", soc);
  669. goto fail;
  670. }
  671. entries = wlan_cfg_get_dp_soc_ppe2tcl_ring_size(soc_cfg_ctx);
  672. if (dp_srng_alloc(soc, &be_soc->ppe2tcl_ring, PPE2TCL,
  673. entries, 0)) {
  674. dp_err("%pK: dp_srng_alloc failed for ppe2tcl_ring", soc);
  675. goto fail;
  676. }
  677. entries = wlan_cfg_get_dp_soc_ppe_release_ring_size(soc_cfg_ctx);
  678. if (dp_srng_alloc(soc, &be_soc->ppe_release_ring, PPE_RELEASE,
  679. entries, 0)) {
  680. dp_err("%pK: dp_srng_alloc failed for ppe_release_ring", soc);
  681. goto fail;
  682. }
  683. return QDF_STATUS_SUCCESS;
  684. fail:
  685. dp_soc_ppe_srng_free(soc);
  686. return QDF_STATUS_E_NOMEM;
  687. }
  688. static QDF_STATUS dp_soc_ppe_srng_init(struct dp_soc *soc)
  689. {
  690. struct dp_soc_be *be_soc = dp_get_be_soc_from_dp_soc(soc);
  691. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  692. soc_cfg_ctx = soc->wlan_cfg_ctx;
  693. if (!wlan_cfg_get_dp_soc_is_ppe_enabled(soc_cfg_ctx))
  694. return QDF_STATUS_SUCCESS;
  695. if (dp_srng_init(soc, &be_soc->reo2ppe_ring, REO2PPE, 0, 0)) {
  696. dp_err("%pK: dp_srng_init failed for reo2ppe", soc);
  697. goto fail;
  698. }
  699. wlan_minidump_log(be_soc->reo2ppe_ring.base_vaddr_unaligned,
  700. be_soc->reo2ppe_ring.alloc_size,
  701. soc->ctrl_psoc,
  702. WLAN_MD_DP_SRNG_REO2PPE,
  703. "reo2ppe_ring");
  704. if (dp_srng_init(soc, &be_soc->ppe2tcl_ring, PPE2TCL, 0, 0)) {
  705. dp_err("%pK: dp_srng_init failed for ppe2tcl_ring", soc);
  706. goto fail;
  707. }
  708. wlan_minidump_log(be_soc->ppe2tcl_ring.base_vaddr_unaligned,
  709. be_soc->ppe2tcl_ring.alloc_size,
  710. soc->ctrl_psoc,
  711. WLAN_MD_DP_SRNG_PPE2TCL,
  712. "ppe2tcl_ring");
  713. if (dp_srng_init(soc, &be_soc->ppe_release_ring, PPE_RELEASE, 0, 0)) {
  714. dp_err("%pK: dp_srng_init failed for ppe_release_ring", soc);
  715. goto fail;
  716. }
  717. wlan_minidump_log(be_soc->ppe_release_ring.base_vaddr_unaligned,
  718. be_soc->ppe_release_ring.alloc_size,
  719. soc->ctrl_psoc,
  720. WLAN_MD_DP_SRNG_PPE_RELEASE,
  721. "ppe_release_ring");
  722. return QDF_STATUS_SUCCESS;
  723. fail:
  724. dp_soc_ppe_srng_deinit(soc);
  725. return QDF_STATUS_E_NOMEM;
  726. }
  727. #else
  728. static void dp_soc_ppe_srng_deinit(struct dp_soc *soc)
  729. {
  730. }
  731. static void dp_soc_ppe_srng_free(struct dp_soc *soc)
  732. {
  733. }
  734. static QDF_STATUS dp_soc_ppe_srng_alloc(struct dp_soc *soc)
  735. {
  736. return QDF_STATUS_SUCCESS;
  737. }
  738. static QDF_STATUS dp_soc_ppe_srng_init(struct dp_soc *soc)
  739. {
  740. return QDF_STATUS_SUCCESS;
  741. }
  742. #endif
  743. static void dp_soc_srng_deinit_be(struct dp_soc *soc)
  744. {
  745. dp_soc_ppe_srng_deinit(soc);
  746. }
  747. static void dp_soc_srng_free_be(struct dp_soc *soc)
  748. {
  749. dp_soc_ppe_srng_free(soc);
  750. }
  751. static QDF_STATUS dp_soc_srng_alloc_be(struct dp_soc *soc)
  752. {
  753. return dp_soc_ppe_srng_alloc(soc);
  754. }
  755. static QDF_STATUS dp_soc_srng_init_be(struct dp_soc *soc)
  756. {
  757. return dp_soc_ppe_srng_init(soc);
  758. }
  759. void dp_initialize_arch_ops_be(struct dp_arch_ops *arch_ops)
  760. {
  761. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  762. arch_ops->tx_hw_enqueue = dp_tx_hw_enqueue_be;
  763. arch_ops->dp_rx_process = dp_rx_process_be;
  764. arch_ops->tx_comp_get_params_from_hal_desc =
  765. dp_tx_comp_get_params_from_hal_desc_be;
  766. arch_ops->dp_tx_desc_pool_init = dp_tx_desc_pool_init_be;
  767. arch_ops->dp_tx_desc_pool_deinit = dp_tx_desc_pool_deinit_be;
  768. arch_ops->dp_rx_desc_pool_init = dp_rx_desc_pool_init_be;
  769. arch_ops->dp_rx_desc_pool_deinit = dp_rx_desc_pool_deinit_be;
  770. arch_ops->dp_wbm_get_rx_desc_from_hal_desc =
  771. dp_wbm_get_rx_desc_from_hal_desc_be;
  772. #endif
  773. arch_ops->txrx_get_context_size = dp_get_context_size_be;
  774. arch_ops->dp_rx_desc_cookie_2_va =
  775. dp_rx_desc_cookie_2_va_be;
  776. arch_ops->txrx_soc_attach = dp_soc_attach_be;
  777. arch_ops->txrx_soc_detach = dp_soc_detach_be;
  778. arch_ops->txrx_soc_init = dp_soc_init_be;
  779. arch_ops->txrx_soc_deinit = dp_soc_deinit_be;
  780. arch_ops->txrx_soc_srng_alloc = dp_soc_srng_alloc_be;
  781. arch_ops->txrx_soc_srng_init = dp_soc_srng_init_be;
  782. arch_ops->txrx_soc_srng_deinit = dp_soc_srng_deinit_be;
  783. arch_ops->txrx_soc_srng_free = dp_soc_srng_free_be;
  784. arch_ops->txrx_pdev_attach = dp_pdev_attach_be;
  785. arch_ops->txrx_pdev_detach = dp_pdev_detach_be;
  786. arch_ops->txrx_vdev_attach = dp_vdev_attach_be;
  787. arch_ops->txrx_vdev_detach = dp_vdev_detach_be;
  788. arch_ops->dp_rxdma_ring_sel_cfg = dp_rxdma_ring_sel_cfg_be;
  789. arch_ops->soc_cfg_attach = dp_soc_cfg_attach_be;
  790. dp_init_near_full_arch_ops_be(arch_ops);
  791. }