wlan_cfg.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #if defined(CONFIG_HL_SUPPORT)
  19. #include "wlan_tgt_def_config_hl.h"
  20. #else
  21. #include "wlan_tgt_def_config.h"
  22. #endif
  23. #include "qdf_trace.h"
  24. #include "qdf_mem.h"
  25. #include <cdp_txrx_ops.h>
  26. #include "wlan_cfg.h"
  27. #include "cfg_ucfg_api.h"
  28. /*
  29. * FIX THIS -
  30. * For now, all these configuration parameters are hardcoded.
  31. * Many of these should actually be coming from dts file/ini file
  32. */
  33. /*
  34. * The max allowed size for tx comp ring is 8191.
  35. * This is limitted by h/w ring max size.
  36. * As this is not a power of 2 it does not work with nss offload so the
  37. * nearest available size which is power of 2 is 4096 chosen for nss
  38. */
  39. #define WLAN_CFG_TX_RING_MASK_0 0x1
  40. #define WLAN_CFG_TX_RING_MASK_1 0x2
  41. #define WLAN_CFG_TX_RING_MASK_2 0x4
  42. #define WLAN_CFG_TX_RING_MASK_3 0x0
  43. #define WLAN_CFG_RX_RING_MASK_0 0x1
  44. #define WLAN_CFG_RX_RING_MASK_1 0x2
  45. #define WLAN_CFG_RX_RING_MASK_2 0x4
  46. #define WLAN_CFG_RX_RING_MASK_3 0x8
  47. #define WLAN_CFG_RX_MON_RING_MASK_0 0x1
  48. #define WLAN_CFG_RX_MON_RING_MASK_1 0x2
  49. #define WLAN_CFG_RX_MON_RING_MASK_2 0x4
  50. #define WLAN_CFG_RX_MON_RING_MASK_3 0x0
  51. #define WLAN_CFG_RX_ERR_RING_MASK_0 0x1
  52. #define WLAN_CFG_RX_ERR_RING_MASK_1 0x0
  53. #define WLAN_CFG_RX_ERR_RING_MASK_2 0x0
  54. #define WLAN_CFG_RX_ERR_RING_MASK_3 0x0
  55. #define WLAN_CFG_RX_WBM_REL_RING_MASK_0 0x1
  56. #define WLAN_CFG_RX_WBM_REL_RING_MASK_1 0x0
  57. #define WLAN_CFG_RX_WBM_REL_RING_MASK_2 0x0
  58. #define WLAN_CFG_RX_WBM_REL_RING_MASK_3 0x0
  59. #define WLAN_CFG_REO_STATUS_RING_MASK_0 0x1
  60. #define WLAN_CFG_REO_STATUS_RING_MASK_1 0x0
  61. #define WLAN_CFG_REO_STATUS_RING_MASK_2 0x0
  62. #define WLAN_CFG_REO_STATUS_RING_MASK_3 0x0
  63. #define WLAN_CFG_RXDMA2HOST_RING_MASK_0 0x1
  64. #define WLAN_CFG_RXDMA2HOST_RING_MASK_1 0x2
  65. #define WLAN_CFG_RXDMA2HOST_RING_MASK_2 0x4
  66. #define WLAN_CFG_RXDMA2HOST_RING_MASK_3 0x0
  67. #define WLAN_CFG_HOST2RXDMA_RING_MASK_0 0x1
  68. #define WLAN_CFG_HOST2RXDMA_RING_MASK_1 0x2
  69. #define WLAN_CFG_HOST2RXDMA_RING_MASK_2 0x4
  70. #define WLAN_CFG_HOST2RXDMA_RING_MASK_3 0x0
  71. #ifdef CONFIG_MCL
  72. static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  73. 0,
  74. WLAN_CFG_TX_RING_MASK_0,
  75. 0,
  76. 0,
  77. 0,
  78. 0,
  79. 0};
  80. #ifndef IPA_OFFLOAD
  81. static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  82. 0,
  83. 0,
  84. WLAN_CFG_RX_RING_MASK_0,
  85. 0,
  86. WLAN_CFG_RX_RING_MASK_1,
  87. WLAN_CFG_RX_RING_MASK_2,
  88. WLAN_CFG_RX_RING_MASK_3};
  89. #else
  90. static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  91. 0,
  92. 0,
  93. WLAN_CFG_RX_RING_MASK_0,
  94. 0,
  95. WLAN_CFG_RX_RING_MASK_1,
  96. WLAN_CFG_RX_RING_MASK_2,
  97. 0};
  98. #endif
  99. static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  100. 0,
  101. 0,
  102. 0,
  103. WLAN_CFG_RX_MON_RING_MASK_0,
  104. WLAN_CFG_RX_MON_RING_MASK_1,
  105. WLAN_CFG_RX_MON_RING_MASK_2,
  106. WLAN_CFG_RX_MON_RING_MASK_3};
  107. static const int host2rxdma_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  108. WLAN_CFG_HOST2RXDMA_RING_MASK_0,
  109. 0,
  110. 0,
  111. 0,
  112. 0,
  113. 0,
  114. 0};
  115. #else
  116. static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  117. WLAN_CFG_TX_RING_MASK_0,
  118. WLAN_CFG_TX_RING_MASK_1,
  119. WLAN_CFG_TX_RING_MASK_2,
  120. WLAN_CFG_TX_RING_MASK_3};
  121. static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  122. WLAN_CFG_RX_RING_MASK_0,
  123. WLAN_CFG_RX_RING_MASK_1,
  124. WLAN_CFG_RX_RING_MASK_2,
  125. WLAN_CFG_RX_RING_MASK_3};
  126. static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  127. 0,
  128. 0,
  129. 0,
  130. 0,
  131. WLAN_CFG_RX_MON_RING_MASK_0,
  132. WLAN_CFG_RX_MON_RING_MASK_1,
  133. WLAN_CFG_RX_MON_RING_MASK_2};
  134. static const int host2rxdma_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  135. WLAN_CFG_HOST2RXDMA_RING_MASK_0,
  136. WLAN_CFG_HOST2RXDMA_RING_MASK_1,
  137. WLAN_CFG_HOST2RXDMA_RING_MASK_2,
  138. WLAN_CFG_HOST2RXDMA_RING_MASK_3};
  139. #endif
  140. static const int rx_err_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  141. WLAN_CFG_RX_ERR_RING_MASK_0,
  142. WLAN_CFG_RX_ERR_RING_MASK_1,
  143. WLAN_CFG_RX_ERR_RING_MASK_2,
  144. WLAN_CFG_RX_ERR_RING_MASK_3};
  145. static const int rx_wbm_rel_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  146. WLAN_CFG_RX_WBM_REL_RING_MASK_0,
  147. WLAN_CFG_RX_WBM_REL_RING_MASK_1,
  148. WLAN_CFG_RX_WBM_REL_RING_MASK_2,
  149. WLAN_CFG_RX_WBM_REL_RING_MASK_3};
  150. static const int reo_status_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  151. WLAN_CFG_REO_STATUS_RING_MASK_0,
  152. WLAN_CFG_REO_STATUS_RING_MASK_1,
  153. WLAN_CFG_REO_STATUS_RING_MASK_2,
  154. WLAN_CFG_REO_STATUS_RING_MASK_3};
  155. static const int rxdma2host_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  156. WLAN_CFG_RXDMA2HOST_RING_MASK_0,
  157. WLAN_CFG_RXDMA2HOST_RING_MASK_1,
  158. WLAN_CFG_RXDMA2HOST_RING_MASK_2,
  159. WLAN_CFG_RXDMA2HOST_RING_MASK_3};
  160. /**
  161. * struct wlan_cfg_dp_pdev_ctxt - Configuration parameters for pdev (radio)
  162. * @rx_dma_buf_ring_size - Size of RxDMA buffer ring
  163. * @dma_mon_buf_ring_size - Size of RxDMA Monitor buffer ring
  164. * @dma_mon_dest_ring_size - Size of RxDMA Monitor Destination ring
  165. * @dma_mon_status_ring_size - Size of RxDMA Monitor Status ring
  166. * @rxdma_monitor_desc_ring - rxdma monitor desc ring size
  167. */
  168. struct wlan_cfg_dp_pdev_ctxt {
  169. int rx_dma_buf_ring_size;
  170. int dma_mon_buf_ring_size;
  171. int dma_mon_dest_ring_size;
  172. int dma_mon_status_ring_size;
  173. int rxdma_monitor_desc_ring;
  174. int num_mac_rings;
  175. int nss_enabled;
  176. };
  177. /**
  178. * wlan_cfg_soc_attach() - Allocate and prepare SoC configuration
  179. * @psoc - Object manager psoc
  180. * Return: wlan_cfg_ctx - Handle to Configuration context
  181. */
  182. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_soc_attach(void *psoc)
  183. {
  184. int i = 0;
  185. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx =
  186. qdf_mem_malloc(sizeof(struct wlan_cfg_dp_soc_ctxt));
  187. if (wlan_cfg_ctx == NULL)
  188. return NULL;
  189. wlan_cfg_ctx->num_int_ctxts = WLAN_CFG_INT_NUM_CONTEXTS;
  190. wlan_cfg_ctx->max_clients = cfg_get(psoc, CFG_DP_MAX_CLIENTS);
  191. wlan_cfg_ctx->max_alloc_size = cfg_get(psoc, CFG_DP_MAX_ALLOC_SIZE);
  192. wlan_cfg_ctx->per_pdev_tx_ring = cfg_get(psoc, CFG_DP_PDEV_TX_RING);
  193. wlan_cfg_ctx->num_tcl_data_rings = cfg_get(psoc, CFG_DP_TCL_DATA_RINGS);
  194. wlan_cfg_ctx->per_pdev_rx_ring = cfg_get(psoc, CFG_DP_PDEV_RX_RING);
  195. wlan_cfg_ctx->per_pdev_lmac_ring = cfg_get(psoc, CFG_DP_PDEV_LMAC_RING);
  196. wlan_cfg_ctx->num_reo_dest_rings = cfg_get(psoc, CFG_DP_REO_DEST_RINGS);
  197. wlan_cfg_ctx->num_tx_desc_pool = MAX_TXDESC_POOLS;
  198. wlan_cfg_ctx->num_tx_ext_desc_pool = cfg_get(psoc,
  199. CFG_DP_TX_EXT_DESC_POOLS);
  200. wlan_cfg_ctx->num_tx_desc = cfg_get(psoc, CFG_DP_TX_DESC);
  201. wlan_cfg_ctx->num_tx_ext_desc = cfg_get(psoc, CFG_DP_TX_EXT_DESC);
  202. wlan_cfg_ctx->htt_packet_type = cfg_get(psoc, CFG_DP_HTT_PACKET_TYPE);
  203. wlan_cfg_ctx->max_peer_id = cfg_get(psoc, CFG_DP_MAX_PEER_ID);
  204. wlan_cfg_ctx->tx_ring_size = cfg_get(psoc, CFG_DP_TX_RING_SIZE);
  205. wlan_cfg_ctx->tx_comp_ring_size = cfg_get(psoc,
  206. CFG_DP_TX_COMPL_RING_SIZE);
  207. wlan_cfg_ctx->tx_comp_ring_size_nss =
  208. cfg_get(psoc, CFG_DP_NSS_COMP_RING_SIZE);
  209. wlan_cfg_ctx->int_batch_threshold_tx =
  210. cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_TX);
  211. wlan_cfg_ctx->int_timer_threshold_tx =
  212. cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_TX);
  213. wlan_cfg_ctx->int_batch_threshold_rx =
  214. cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_RX);
  215. wlan_cfg_ctx->int_timer_threshold_rx =
  216. cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_RX);
  217. wlan_cfg_ctx->int_batch_threshold_other =
  218. cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_OTHER);
  219. wlan_cfg_ctx->int_timer_threshold_other =
  220. cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_OTHER);
  221. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  222. wlan_cfg_ctx->int_tx_ring_mask[i] = tx_ring_mask[i];
  223. wlan_cfg_ctx->int_rx_ring_mask[i] = rx_ring_mask[i];
  224. wlan_cfg_ctx->int_rx_mon_ring_mask[i] = rx_mon_ring_mask[i];
  225. wlan_cfg_ctx->int_rx_err_ring_mask[i] = rx_err_ring_mask[i];
  226. wlan_cfg_ctx->int_rx_wbm_rel_ring_mask[i] =
  227. rx_wbm_rel_ring_mask[i];
  228. wlan_cfg_ctx->int_reo_status_ring_mask[i] =
  229. reo_status_ring_mask[i];
  230. wlan_cfg_ctx->int_rxdma2host_ring_mask[i] =
  231. rxdma2host_ring_mask[i];
  232. wlan_cfg_ctx->int_host2rxdma_ring_mask[i] =
  233. host2rxdma_ring_mask[i];
  234. }
  235. /* This is default mapping and can be overridden by HW config
  236. * received from FW */
  237. wlan_cfg_set_hw_macid(wlan_cfg_ctx, 0, 1);
  238. if (MAX_PDEV_CNT > 1)
  239. wlan_cfg_set_hw_macid(wlan_cfg_ctx, 1, 3);
  240. if (MAX_PDEV_CNT > 2)
  241. wlan_cfg_set_hw_macid(wlan_cfg_ctx, 2, 2);
  242. wlan_cfg_ctx->base_hw_macid = cfg_get(psoc, CFG_DP_BASE_HW_MAC_ID);
  243. wlan_cfg_ctx->rx_hash = cfg_get(psoc, CFG_DP_RX_HASH);
  244. wlan_cfg_ctx->tso_enabled = cfg_get(psoc, CFG_DP_TSO);
  245. wlan_cfg_ctx->lro_enabled = cfg_get(psoc, CFG_DP_LRO);
  246. wlan_cfg_ctx->sg_enabled = cfg_get(psoc, CFG_DP_SG);
  247. wlan_cfg_ctx->gro_enabled = cfg_get(psoc, CFG_DP_GRO);
  248. wlan_cfg_ctx->ol_tx_csum_enabled = cfg_get(psoc, CFG_DP_OL_TX_CSUM);
  249. wlan_cfg_ctx->ol_rx_csum_enabled = cfg_get(psoc, CFG_DP_OL_RX_CSUM);
  250. wlan_cfg_ctx->rawmode_enabled = cfg_get(psoc, CFG_DP_RAWMODE);
  251. wlan_cfg_ctx->peer_flow_ctrl_enabled =
  252. cfg_get(psoc, CFG_DP_PEER_FLOW_CTRL);
  253. wlan_cfg_ctx->napi_enabled = cfg_get(psoc, CFG_DP_NAPI);
  254. /*Enable checksum offload by default*/
  255. wlan_cfg_ctx->tcp_udp_checksumoffload =
  256. cfg_get(psoc, CFG_DP_TCP_UDP_CKSUM_OFFLOAD);
  257. wlan_cfg_ctx->defrag_timeout_check =
  258. cfg_get(psoc, CFG_DP_DEFRAG_TIMEOUT_CHECK);
  259. wlan_cfg_ctx->rx_defrag_min_timeout =
  260. cfg_get(psoc, CFG_DP_RX_DEFRAG_TIMEOUT);
  261. wlan_cfg_ctx->wbm_release_ring = cfg_get(psoc,
  262. CFG_DP_WBM_RELEASE_RING);
  263. wlan_cfg_ctx->tcl_cmd_ring = cfg_get(psoc,
  264. CFG_DP_TCL_CMD_RING);
  265. wlan_cfg_ctx->tcl_status_ring = cfg_get(psoc,
  266. CFG_DP_TCL_STATUS_RING);
  267. wlan_cfg_ctx->reo_reinject_ring = cfg_get(psoc,
  268. CFG_DP_REO_REINJECT_RING);
  269. wlan_cfg_ctx->rx_release_ring = cfg_get(psoc,
  270. CFG_DP_RX_RELEASE_RING);
  271. wlan_cfg_ctx->reo_exception_ring = cfg_get(psoc,
  272. CFG_DP_REO_EXCEPTION_RING);
  273. wlan_cfg_ctx->reo_cmd_ring = cfg_get(psoc,
  274. CFG_DP_REO_CMD_RING);
  275. wlan_cfg_ctx->reo_status_ring = cfg_get(psoc,
  276. CFG_DP_REO_STATUS_RING);
  277. wlan_cfg_ctx->rxdma_refill_ring = cfg_get(psoc,
  278. CFG_DP_RXDMA_REFILL_RING);
  279. wlan_cfg_ctx->rxdma_err_dst_ring = cfg_get(psoc,
  280. CFG_DP_RXDMA_ERR_DST_RING);
  281. return wlan_cfg_ctx;
  282. }
  283. void wlan_cfg_soc_detach(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx)
  284. {
  285. qdf_mem_free(wlan_cfg_ctx);
  286. }
  287. struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_pdev_attach(void *psoc)
  288. {
  289. struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx =
  290. qdf_mem_malloc(sizeof(struct wlan_cfg_dp_pdev_ctxt));
  291. if (wlan_cfg_ctx == NULL)
  292. return NULL;
  293. wlan_cfg_ctx->rx_dma_buf_ring_size = cfg_get(psoc,
  294. CFG_DP_RXDMA_BUF_RING);
  295. wlan_cfg_ctx->dma_mon_buf_ring_size = cfg_get(psoc,
  296. CFG_DP_RXDMA_MONITOR_BUF_RING);
  297. wlan_cfg_ctx->dma_mon_dest_ring_size = cfg_get(psoc,
  298. CFG_DP_RXDMA_MONITOR_DST_RING);
  299. wlan_cfg_ctx->dma_mon_status_ring_size = cfg_get(psoc,
  300. CFG_DP_RXDMA_MONITOR_STATUS_RING);
  301. wlan_cfg_ctx->rxdma_monitor_desc_ring = cfg_get(psoc,
  302. CFG_DP_RXDMA_MONITOR_DESC_RING);
  303. wlan_cfg_ctx->num_mac_rings = NUM_RXDMA_RINGS_PER_PDEV;
  304. return wlan_cfg_ctx;
  305. }
  306. void wlan_cfg_pdev_detach(struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx)
  307. {
  308. qdf_mem_free(wlan_cfg_ctx);
  309. }
  310. void wlan_cfg_set_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg, int num)
  311. {
  312. cfg->num_int_ctxts = num;
  313. }
  314. void wlan_cfg_set_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg, uint32_t val)
  315. {
  316. cfg->max_peer_id = val;;
  317. }
  318. void wlan_cfg_set_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  319. int context, int mask)
  320. {
  321. cfg->int_tx_ring_mask[context] = mask;
  322. }
  323. void wlan_cfg_set_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  324. int context, int mask)
  325. {
  326. cfg->int_rx_ring_mask[context] = mask;
  327. }
  328. void wlan_cfg_set_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  329. int context, int mask)
  330. {
  331. cfg->int_rx_mon_ring_mask[context] = mask;
  332. }
  333. void wlan_cfg_set_rxdma2host_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  334. int context, int mask)
  335. {
  336. cfg->int_rxdma2host_ring_mask[context] = mask;
  337. }
  338. int wlan_cfg_get_rxdma2host_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  339. int context)
  340. {
  341. return cfg->int_rxdma2host_ring_mask[context];
  342. }
  343. void wlan_cfg_set_host2rxdma_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  344. int context, int mask)
  345. {
  346. cfg->int_host2rxdma_ring_mask[context] = mask;
  347. }
  348. int wlan_cfg_get_host2rxdma_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  349. int context)
  350. {
  351. return cfg->int_host2rxdma_ring_mask[context];
  352. }
  353. void wlan_cfg_set_hw_macid(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx,
  354. int hw_macid)
  355. {
  356. qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
  357. cfg->hw_macid[pdev_idx] = hw_macid;
  358. }
  359. int wlan_cfg_get_hw_macid(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx)
  360. {
  361. qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
  362. return cfg->hw_macid[pdev_idx];
  363. }
  364. int wlan_cfg_get_hw_mac_idx(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx)
  365. {
  366. qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
  367. return cfg->hw_macid[pdev_idx] - cfg->base_hw_macid;
  368. }
  369. void wlan_cfg_set_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  370. int context, int mask)
  371. {
  372. cfg->int_ce_ring_mask[context] = mask;
  373. }
  374. void wlan_cfg_set_rxbuf_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context,
  375. int mask)
  376. {
  377. cfg->int_rx_ring_mask[context] = mask;
  378. }
  379. int wlan_cfg_set_rx_err_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  380. int context, int mask)
  381. {
  382. return cfg->int_rx_err_ring_mask[context] = mask;
  383. }
  384. int wlan_cfg_set_rx_wbm_rel_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  385. int context, int mask)
  386. {
  387. return cfg->int_rx_wbm_rel_ring_mask[context] = mask;
  388. }
  389. int wlan_cfg_set_reo_status_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  390. int context, int mask)
  391. {
  392. return cfg->int_reo_status_ring_mask[context] = mask;
  393. }
  394. int wlan_cfg_get_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg)
  395. {
  396. return cfg->num_int_ctxts;
  397. }
  398. int wlan_cfg_get_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  399. {
  400. return cfg->int_tx_ring_mask[context];
  401. }
  402. int wlan_cfg_get_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  403. {
  404. return cfg->int_rx_ring_mask[context];
  405. }
  406. int wlan_cfg_get_rx_err_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  407. int context)
  408. {
  409. return cfg->int_rx_err_ring_mask[context];
  410. }
  411. int wlan_cfg_get_rx_wbm_rel_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  412. int context)
  413. {
  414. return cfg->int_rx_wbm_rel_ring_mask[context];
  415. }
  416. int wlan_cfg_get_reo_status_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  417. int context)
  418. {
  419. return cfg->int_reo_status_ring_mask[context];
  420. }
  421. int wlan_cfg_get_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  422. {
  423. return cfg->int_rx_mon_ring_mask[context];
  424. }
  425. int wlan_cfg_get_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  426. {
  427. return cfg->int_ce_ring_mask[context];
  428. }
  429. uint32_t wlan_cfg_get_max_clients(struct wlan_cfg_dp_soc_ctxt *cfg)
  430. {
  431. return cfg->max_clients;
  432. }
  433. uint32_t wlan_cfg_max_alloc_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  434. {
  435. return cfg->max_alloc_size;
  436. }
  437. int wlan_cfg_per_pdev_tx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  438. {
  439. return cfg->per_pdev_tx_ring;
  440. }
  441. int wlan_cfg_per_pdev_lmac_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  442. {
  443. return cfg->per_pdev_lmac_ring;
  444. }
  445. int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
  446. {
  447. return cfg->num_tcl_data_rings;
  448. }
  449. int wlan_cfg_tx_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  450. {
  451. return cfg->tx_ring_size;
  452. }
  453. int wlan_cfg_tx_comp_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  454. {
  455. return cfg->tx_comp_ring_size;
  456. }
  457. int wlan_cfg_per_pdev_rx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  458. {
  459. return cfg->per_pdev_rx_ring;
  460. }
  461. int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
  462. {
  463. return cfg->num_reo_dest_rings;
  464. }
  465. int wlan_cfg_pkt_type(struct wlan_cfg_dp_soc_ctxt *cfg)
  466. {
  467. return cfg->htt_packet_type; /*htt_pkt_type_ethernet*/
  468. }
  469. int wlan_cfg_get_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
  470. {
  471. return cfg->num_tx_desc_pool;
  472. }
  473. void wlan_cfg_set_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg, int num_pool)
  474. {
  475. cfg->num_tx_desc_pool = num_pool;
  476. }
  477. int wlan_cfg_get_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
  478. {
  479. return cfg->num_tx_ext_desc_pool;
  480. }
  481. void wlan_cfg_set_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg, int num_pool)
  482. {
  483. cfg->num_tx_ext_desc_pool = num_pool;
  484. }
  485. int wlan_cfg_get_reo_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  486. {
  487. return cfg->reo_dst_ring_size;
  488. }
  489. void wlan_cfg_set_reo_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg,
  490. int reo_dst_ring_size)
  491. {
  492. cfg->reo_dst_ring_size = reo_dst_ring_size;
  493. }
  494. void wlan_cfg_set_raw_mode_war(struct wlan_cfg_dp_soc_ctxt *cfg,
  495. bool raw_mode_war)
  496. {
  497. cfg->raw_mode_war = raw_mode_war;
  498. }
  499. bool wlan_cfg_get_raw_mode_war(struct wlan_cfg_dp_soc_ctxt *cfg)
  500. {
  501. return cfg->raw_mode_war;
  502. }
  503. int wlan_cfg_get_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
  504. {
  505. return cfg->num_tx_desc;
  506. }
  507. void wlan_cfg_set_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg, int num_desc)
  508. {
  509. cfg->num_tx_desc = num_desc;
  510. }
  511. int wlan_cfg_get_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
  512. {
  513. return cfg->num_tx_ext_desc;
  514. }
  515. void wlan_cfg_set_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg, int num_ext_desc)
  516. {
  517. cfg->num_tx_ext_desc = num_ext_desc;
  518. }
  519. uint32_t wlan_cfg_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg)
  520. {
  521. /* TODO: This should be calculated based on target capabilities */
  522. return cfg->max_peer_id;
  523. }
  524. int wlan_cfg_get_dma_mon_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  525. {
  526. return cfg->dma_mon_buf_ring_size;
  527. }
  528. int wlan_cfg_get_dma_mon_dest_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  529. {
  530. return cfg->dma_mon_dest_ring_size;
  531. }
  532. int wlan_cfg_get_dma_mon_stat_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  533. {
  534. return cfg->dma_mon_status_ring_size;
  535. }
  536. int
  537. wlan_cfg_get_dma_mon_desc_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  538. {
  539. return cfg->rxdma_monitor_desc_ring;
  540. }
  541. int wlan_cfg_get_rx_dma_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  542. {
  543. return cfg->rx_dma_buf_ring_size;
  544. }
  545. int wlan_cfg_get_num_mac_rings(struct wlan_cfg_dp_pdev_ctxt *cfg)
  546. {
  547. return cfg->num_mac_rings;
  548. }
  549. bool wlan_cfg_is_lro_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
  550. {
  551. return cfg->lro_enabled;
  552. }
  553. void wlan_cfg_set_rx_hash(struct wlan_cfg_dp_soc_ctxt *cfg, bool val)
  554. {
  555. cfg->rx_hash = val;
  556. }
  557. bool wlan_cfg_is_rx_hash_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
  558. {
  559. return cfg->rx_hash;
  560. }
  561. int wlan_cfg_get_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg)
  562. {
  563. return cfg->nss_enabled;
  564. }
  565. void wlan_cfg_set_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg, int nss_enabled)
  566. {
  567. cfg->nss_enabled = nss_enabled;
  568. }
  569. int wlan_cfg_get_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg)
  570. {
  571. return cfg->nss_cfg;
  572. }
  573. void wlan_cfg_set_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg, int nss_cfg)
  574. {
  575. cfg->nss_cfg = nss_cfg;
  576. if (cfg->nss_cfg)
  577. cfg->tx_comp_ring_size = cfg->tx_comp_ring_size_nss;
  578. }
  579. int wlan_cfg_get_int_batch_threshold_tx(struct wlan_cfg_dp_soc_ctxt *cfg)
  580. {
  581. return cfg->int_batch_threshold_tx;
  582. }
  583. int wlan_cfg_get_int_timer_threshold_tx(struct wlan_cfg_dp_soc_ctxt *cfg)
  584. {
  585. return cfg->int_timer_threshold_tx;
  586. }
  587. int wlan_cfg_get_int_batch_threshold_rx(struct wlan_cfg_dp_soc_ctxt *cfg)
  588. {
  589. return cfg->int_batch_threshold_rx;
  590. }
  591. int wlan_cfg_get_int_timer_threshold_rx(struct wlan_cfg_dp_soc_ctxt *cfg)
  592. {
  593. return cfg->int_timer_threshold_rx;
  594. }
  595. int wlan_cfg_get_int_batch_threshold_other(struct wlan_cfg_dp_soc_ctxt *cfg)
  596. {
  597. return cfg->int_batch_threshold_other;
  598. }
  599. int wlan_cfg_get_int_timer_threshold_other(struct wlan_cfg_dp_soc_ctxt *cfg)
  600. {
  601. return cfg->int_timer_threshold_other;
  602. }
  603. int wlan_cfg_get_checksum_offload(struct wlan_cfg_dp_soc_ctxt *cfg)
  604. {
  605. return cfg->tcp_udp_checksumoffload;
  606. }
  607. int wlan_cfg_get_rx_defrag_min_timeout(struct wlan_cfg_dp_soc_ctxt *cfg)
  608. {
  609. return cfg->rx_defrag_min_timeout;
  610. }
  611. int wlan_cfg_get_defrag_timeout_check(struct wlan_cfg_dp_soc_ctxt *cfg)
  612. {
  613. return cfg->defrag_timeout_check;
  614. }
  615. int
  616. wlan_cfg_get_dp_soc_wbm_release_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  617. {
  618. return cfg->wbm_release_ring;
  619. }
  620. int
  621. wlan_cfg_get_dp_soc_tcl_cmd_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  622. {
  623. return cfg->tcl_cmd_ring;
  624. }
  625. int
  626. wlan_cfg_get_dp_soc_tcl_status_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  627. {
  628. return cfg->tcl_status_ring;
  629. }
  630. int
  631. wlan_cfg_get_dp_soc_reo_reinject_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  632. {
  633. return cfg->reo_reinject_ring;
  634. }
  635. int
  636. wlan_cfg_get_dp_soc_rx_release_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  637. {
  638. return cfg->rx_release_ring;
  639. }
  640. int
  641. wlan_cfg_get_dp_soc_reo_exception_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  642. {
  643. return cfg->reo_exception_ring;
  644. }
  645. int
  646. wlan_cfg_get_dp_soc_reo_cmd_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  647. {
  648. return cfg->reo_cmd_ring;
  649. }
  650. int
  651. wlan_cfg_get_dp_soc_reo_status_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  652. {
  653. return cfg->reo_status_ring;
  654. }
  655. int
  656. wlan_cfg_get_dp_soc_rxdma_refill_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  657. {
  658. return cfg->rxdma_refill_ring;
  659. }
  660. int
  661. wlan_cfg_get_dp_soc_rxdma_err_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  662. {
  663. return cfg->rxdma_err_dst_ring;
  664. }
  665. bool
  666. wlan_cfg_get_dp_caps(struct wlan_cfg_dp_soc_ctxt *cfg,
  667. enum cdp_capabilities dp_caps)
  668. {
  669. switch (dp_caps) {
  670. case CDP_CFG_DP_TSO:
  671. return cfg->tso_enabled;
  672. case CDP_CFG_DP_LRO:
  673. return cfg->lro_enabled;
  674. case CDP_CFG_DP_SG:
  675. return cfg->sg_enabled;
  676. case CDP_CFG_DP_GRO:
  677. return cfg->gro_enabled;
  678. case CDP_CFG_DP_OL_TX_CSUM:
  679. return cfg->ol_tx_csum_enabled;
  680. case CDP_CFG_DP_OL_RX_CSUM:
  681. return cfg->ol_rx_csum_enabled;
  682. case CDP_CFG_DP_RAWMODE:
  683. return cfg->rawmode_enabled;
  684. case CDP_CFG_DP_PEER_FLOW_CTRL:
  685. return cfg->peer_flow_ctrl_enabled;
  686. default:
  687. return false;
  688. }
  689. }
  690. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  691. /**
  692. * wlan_cfg_get_tx_flow_stop_queue_th() - Get flow control stop threshold
  693. * @cfg: config context
  694. *
  695. * Return: stop threshold
  696. */
  697. int wlan_cfg_get_tx_flow_stop_queue_th(struct wlan_cfg_dp_soc_ctxt *cfg)
  698. {
  699. return cfg->tx_flow_stop_queue_threshold;
  700. }
  701. /**
  702. * wlan_cfg_get_tx_flow_start_queue_offset() - Get flow control start offset
  703. * for TX to resume
  704. * @cfg: config context
  705. *
  706. * Return: stop threshold
  707. */
  708. int wlan_cfg_get_tx_flow_start_queue_offset(struct wlan_cfg_dp_soc_ctxt *cfg)
  709. {
  710. return cfg->tx_flow_start_queue_offset;
  711. }
  712. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */