wlan_cfg.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. /*
  2. * Copyright (c) 2016-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. #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_HOST2RXDMA_MON_RING_MASK_0 0x1
  52. #define WLAN_CFG_HOST2RXDMA_MON_RING_MASK_1 0x2
  53. #define WLAN_CFG_HOST2RXDMA_MON_RING_MASK_2 0x4
  54. #define WLAN_CFG_RXDMA2HOST_MON_RING_MASK_0 0x1
  55. #define WLAN_CFG_RXDMA2HOST_MON_RING_MASK_1 0x2
  56. #define WLAN_CFG_RXDMA2HOST_MON_RING_MASK_2 0x4
  57. #define WLAN_CFG_RX_ERR_RING_MASK_0 0x1
  58. #define WLAN_CFG_RX_ERR_RING_MASK_1 0x0
  59. #define WLAN_CFG_RX_ERR_RING_MASK_2 0x0
  60. #define WLAN_CFG_RX_ERR_RING_MASK_3 0x0
  61. #define WLAN_CFG_RX_WBM_REL_RING_MASK_0 0x1
  62. #define WLAN_CFG_RX_WBM_REL_RING_MASK_1 0x0
  63. #define WLAN_CFG_RX_WBM_REL_RING_MASK_2 0x0
  64. #define WLAN_CFG_RX_WBM_REL_RING_MASK_3 0x0
  65. #define WLAN_CFG_REO_STATUS_RING_MASK_0 0x1
  66. #define WLAN_CFG_REO_STATUS_RING_MASK_1 0x0
  67. #define WLAN_CFG_REO_STATUS_RING_MASK_2 0x0
  68. #define WLAN_CFG_REO_STATUS_RING_MASK_3 0x0
  69. #define WLAN_CFG_RXDMA2HOST_RING_MASK_0 0x1
  70. #define WLAN_CFG_RXDMA2HOST_RING_MASK_1 0x2
  71. #define WLAN_CFG_RXDMA2HOST_RING_MASK_2 0x4
  72. #define WLAN_CFG_RXDMA2HOST_RING_MASK_3 0x0
  73. #define WLAN_CFG_HOST2RXDMA_RING_MASK_0 0x1
  74. #define WLAN_CFG_HOST2RXDMA_RING_MASK_1 0x2
  75. #define WLAN_CFG_HOST2RXDMA_RING_MASK_2 0x4
  76. #define WLAN_CFG_HOST2RXDMA_RING_MASK_3 0x0
  77. #ifdef CONFIG_MCL
  78. static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  79. 0,
  80. WLAN_CFG_TX_RING_MASK_0,
  81. 0,
  82. 0,
  83. 0,
  84. 0,
  85. 0};
  86. #ifndef IPA_OFFLOAD
  87. static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  88. 0,
  89. 0,
  90. WLAN_CFG_RX_RING_MASK_0,
  91. 0,
  92. WLAN_CFG_RX_RING_MASK_1,
  93. WLAN_CFG_RX_RING_MASK_2,
  94. WLAN_CFG_RX_RING_MASK_3};
  95. #else
  96. static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  97. 0,
  98. 0,
  99. WLAN_CFG_RX_RING_MASK_0,
  100. 0,
  101. WLAN_CFG_RX_RING_MASK_1,
  102. WLAN_CFG_RX_RING_MASK_2,
  103. 0};
  104. #endif
  105. static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  106. 0,
  107. 0,
  108. 0,
  109. WLAN_CFG_RX_MON_RING_MASK_0,
  110. WLAN_CFG_RX_MON_RING_MASK_1,
  111. WLAN_CFG_RX_MON_RING_MASK_2,
  112. WLAN_CFG_RX_MON_RING_MASK_3};
  113. static const int host2rxdma_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  114. WLAN_CFG_HOST2RXDMA_RING_MASK_0,
  115. 0,
  116. 0,
  117. 0,
  118. 0,
  119. 0,
  120. 0};
  121. static const int rxdma2host_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  122. WLAN_CFG_RXDMA2HOST_RING_MASK_0,
  123. WLAN_CFG_RXDMA2HOST_RING_MASK_1,
  124. WLAN_CFG_RXDMA2HOST_RING_MASK_2,
  125. WLAN_CFG_RXDMA2HOST_RING_MASK_3,
  126. 0,
  127. 0,
  128. 0};
  129. static const int host2rxdma_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  130. 0,
  131. 0,
  132. 0,
  133. WLAN_CFG_HOST2RXDMA_MON_RING_MASK_0,
  134. WLAN_CFG_HOST2RXDMA_MON_RING_MASK_1,
  135. WLAN_CFG_HOST2RXDMA_MON_RING_MASK_2};
  136. static const int rxdma2host_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  137. 0,
  138. 0,
  139. 0,
  140. WLAN_CFG_RXDMA2HOST_MON_RING_MASK_0,
  141. WLAN_CFG_RXDMA2HOST_MON_RING_MASK_1,
  142. WLAN_CFG_RXDMA2HOST_MON_RING_MASK_2};
  143. #else
  144. static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  145. WLAN_CFG_TX_RING_MASK_0,
  146. WLAN_CFG_TX_RING_MASK_1,
  147. WLAN_CFG_TX_RING_MASK_2,
  148. WLAN_CFG_TX_RING_MASK_3};
  149. static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  150. 0,
  151. 0,
  152. 0,
  153. 0,
  154. 0,
  155. 0,
  156. 0,
  157. WLAN_CFG_RX_RING_MASK_0,
  158. WLAN_CFG_RX_RING_MASK_1,
  159. WLAN_CFG_RX_RING_MASK_2,
  160. WLAN_CFG_RX_RING_MASK_3};
  161. static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  162. 0,
  163. 0,
  164. 0,
  165. 0,
  166. WLAN_CFG_RX_MON_RING_MASK_0,
  167. WLAN_CFG_RX_MON_RING_MASK_1,
  168. WLAN_CFG_RX_MON_RING_MASK_2};
  169. static const int host2rxdma_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  170. WLAN_CFG_HOST2RXDMA_RING_MASK_0,
  171. WLAN_CFG_HOST2RXDMA_RING_MASK_1,
  172. WLAN_CFG_HOST2RXDMA_RING_MASK_2,
  173. WLAN_CFG_HOST2RXDMA_RING_MASK_3};
  174. static const int rxdma2host_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  175. WLAN_CFG_RXDMA2HOST_RING_MASK_0,
  176. WLAN_CFG_RXDMA2HOST_RING_MASK_1,
  177. WLAN_CFG_RXDMA2HOST_RING_MASK_2,
  178. WLAN_CFG_RXDMA2HOST_RING_MASK_3};
  179. static const int host2rxdma_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  180. 0,
  181. 0,
  182. 0,
  183. 0,
  184. WLAN_CFG_HOST2RXDMA_MON_RING_MASK_0,
  185. WLAN_CFG_HOST2RXDMA_MON_RING_MASK_1,
  186. WLAN_CFG_HOST2RXDMA_MON_RING_MASK_2};
  187. static const int rxdma2host_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  188. 0,
  189. 0,
  190. 0,
  191. 0,
  192. WLAN_CFG_RXDMA2HOST_MON_RING_MASK_0,
  193. WLAN_CFG_RXDMA2HOST_MON_RING_MASK_1,
  194. WLAN_CFG_RXDMA2HOST_MON_RING_MASK_2};
  195. #endif
  196. static const int rx_err_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  197. WLAN_CFG_RX_ERR_RING_MASK_0,
  198. WLAN_CFG_RX_ERR_RING_MASK_1,
  199. WLAN_CFG_RX_ERR_RING_MASK_2,
  200. WLAN_CFG_RX_ERR_RING_MASK_3};
  201. static const int rx_wbm_rel_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  202. WLAN_CFG_RX_WBM_REL_RING_MASK_0,
  203. WLAN_CFG_RX_WBM_REL_RING_MASK_1,
  204. WLAN_CFG_RX_WBM_REL_RING_MASK_2,
  205. WLAN_CFG_RX_WBM_REL_RING_MASK_3};
  206. static const int reo_status_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  207. WLAN_CFG_REO_STATUS_RING_MASK_0,
  208. WLAN_CFG_REO_STATUS_RING_MASK_1,
  209. WLAN_CFG_REO_STATUS_RING_MASK_2,
  210. WLAN_CFG_REO_STATUS_RING_MASK_3};
  211. /**
  212. * wlan_cfg_soc_attach() - Allocate and prepare SoC configuration
  213. * @psoc - Object manager psoc
  214. * Return: wlan_cfg_ctx - Handle to Configuration context
  215. */
  216. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_soc_attach(void *psoc)
  217. {
  218. int i = 0;
  219. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx =
  220. qdf_mem_malloc(sizeof(struct wlan_cfg_dp_soc_ctxt));
  221. if (wlan_cfg_ctx == NULL)
  222. return NULL;
  223. wlan_cfg_ctx->rxdma1_enable = WLAN_CFG_RXDMA1_ENABLE;
  224. wlan_cfg_ctx->num_int_ctxts = WLAN_CFG_INT_NUM_CONTEXTS;
  225. wlan_cfg_ctx->max_clients = cfg_get(psoc, CFG_DP_MAX_CLIENTS);
  226. wlan_cfg_ctx->max_alloc_size = cfg_get(psoc, CFG_DP_MAX_ALLOC_SIZE);
  227. wlan_cfg_ctx->per_pdev_tx_ring = cfg_get(psoc, CFG_DP_PDEV_TX_RING);
  228. wlan_cfg_ctx->num_tcl_data_rings = cfg_get(psoc, CFG_DP_TCL_DATA_RINGS);
  229. wlan_cfg_ctx->per_pdev_rx_ring = cfg_get(psoc, CFG_DP_PDEV_RX_RING);
  230. wlan_cfg_ctx->per_pdev_lmac_ring = cfg_get(psoc, CFG_DP_PDEV_LMAC_RING);
  231. wlan_cfg_ctx->num_reo_dest_rings = cfg_get(psoc, CFG_DP_REO_DEST_RINGS);
  232. wlan_cfg_ctx->num_tx_desc_pool = MAX_TXDESC_POOLS;
  233. wlan_cfg_ctx->num_tx_ext_desc_pool = cfg_get(psoc,
  234. CFG_DP_TX_EXT_DESC_POOLS);
  235. wlan_cfg_ctx->num_tx_desc = cfg_get(psoc, CFG_DP_TX_DESC);
  236. wlan_cfg_ctx->min_tx_desc = WLAN_CFG_NUM_TX_DESC_MIN;
  237. wlan_cfg_ctx->num_tx_ext_desc = cfg_get(psoc, CFG_DP_TX_EXT_DESC);
  238. wlan_cfg_ctx->htt_packet_type = cfg_get(psoc, CFG_DP_HTT_PACKET_TYPE);
  239. wlan_cfg_ctx->max_peer_id = cfg_get(psoc, CFG_DP_MAX_PEER_ID);
  240. wlan_cfg_ctx->tx_ring_size = cfg_get(psoc, CFG_DP_TX_RING_SIZE);
  241. wlan_cfg_ctx->tx_comp_ring_size = cfg_get(psoc,
  242. CFG_DP_TX_COMPL_RING_SIZE);
  243. wlan_cfg_ctx->tx_comp_ring_size_nss =
  244. cfg_get(psoc, CFG_DP_NSS_COMP_RING_SIZE);
  245. wlan_cfg_ctx->int_batch_threshold_tx =
  246. cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_TX);
  247. wlan_cfg_ctx->int_timer_threshold_tx =
  248. cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_TX);
  249. wlan_cfg_ctx->int_batch_threshold_rx =
  250. cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_RX);
  251. wlan_cfg_ctx->int_timer_threshold_rx =
  252. cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_RX);
  253. wlan_cfg_ctx->int_batch_threshold_other =
  254. cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_OTHER);
  255. wlan_cfg_ctx->int_timer_threshold_other =
  256. cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_OTHER);
  257. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  258. wlan_cfg_ctx->int_tx_ring_mask[i] = tx_ring_mask[i];
  259. wlan_cfg_ctx->int_rx_ring_mask[i] = rx_ring_mask[i];
  260. wlan_cfg_ctx->int_rx_mon_ring_mask[i] = rx_mon_ring_mask[i];
  261. wlan_cfg_ctx->int_rx_err_ring_mask[i] = rx_err_ring_mask[i];
  262. wlan_cfg_ctx->int_rx_wbm_rel_ring_mask[i] =
  263. rx_wbm_rel_ring_mask[i];
  264. wlan_cfg_ctx->int_reo_status_ring_mask[i] =
  265. reo_status_ring_mask[i];
  266. wlan_cfg_ctx->int_rxdma2host_ring_mask[i] =
  267. rxdma2host_ring_mask[i];
  268. wlan_cfg_ctx->int_host2rxdma_ring_mask[i] =
  269. host2rxdma_ring_mask[i];
  270. wlan_cfg_ctx->int_host2rxdma_mon_ring_mask[i] =
  271. host2rxdma_mon_ring_mask[i];
  272. wlan_cfg_ctx->int_rxdma2host_mon_ring_mask[i] =
  273. rxdma2host_mon_ring_mask[i];
  274. }
  275. /* This is default mapping and can be overridden by HW config
  276. * received from FW */
  277. wlan_cfg_set_hw_macid(wlan_cfg_ctx, 0, 1);
  278. if (MAX_PDEV_CNT > 1)
  279. wlan_cfg_set_hw_macid(wlan_cfg_ctx, 1, 3);
  280. if (MAX_PDEV_CNT > 2)
  281. wlan_cfg_set_hw_macid(wlan_cfg_ctx, 2, 2);
  282. wlan_cfg_ctx->base_hw_macid = cfg_get(psoc, CFG_DP_BASE_HW_MAC_ID);
  283. wlan_cfg_ctx->rx_hash = cfg_get(psoc, CFG_DP_RX_HASH);
  284. wlan_cfg_ctx->tso_enabled = cfg_get(psoc, CFG_DP_TSO);
  285. wlan_cfg_ctx->lro_enabled = cfg_get(psoc, CFG_DP_LRO);
  286. wlan_cfg_ctx->sg_enabled = cfg_get(psoc, CFG_DP_SG);
  287. wlan_cfg_ctx->gro_enabled = cfg_get(psoc, CFG_DP_GRO);
  288. wlan_cfg_ctx->ol_tx_csum_enabled = cfg_get(psoc, CFG_DP_OL_TX_CSUM);
  289. wlan_cfg_ctx->ol_rx_csum_enabled = cfg_get(psoc, CFG_DP_OL_RX_CSUM);
  290. wlan_cfg_ctx->rawmode_enabled = cfg_get(psoc, CFG_DP_RAWMODE);
  291. wlan_cfg_ctx->peer_flow_ctrl_enabled =
  292. cfg_get(psoc, CFG_DP_PEER_FLOW_CTRL);
  293. wlan_cfg_ctx->napi_enabled = cfg_get(psoc, CFG_DP_NAPI);
  294. /*Enable checksum offload by default*/
  295. wlan_cfg_ctx->tcp_udp_checksumoffload =
  296. cfg_get(psoc, CFG_DP_TCP_UDP_CKSUM_OFFLOAD);
  297. wlan_cfg_ctx->per_pkt_trace = cfg_get(psoc, CFG_DP_PER_PKT_LOGGING);
  298. wlan_cfg_ctx->defrag_timeout_check =
  299. cfg_get(psoc, CFG_DP_DEFRAG_TIMEOUT_CHECK);
  300. wlan_cfg_ctx->rx_defrag_min_timeout =
  301. cfg_get(psoc, CFG_DP_RX_DEFRAG_TIMEOUT);
  302. wlan_cfg_ctx->wbm_release_ring = cfg_get(psoc,
  303. CFG_DP_WBM_RELEASE_RING);
  304. wlan_cfg_ctx->tcl_cmd_ring = cfg_get(psoc,
  305. CFG_DP_TCL_CMD_RING);
  306. wlan_cfg_ctx->tcl_status_ring = cfg_get(psoc,
  307. CFG_DP_TCL_STATUS_RING);
  308. wlan_cfg_ctx->reo_reinject_ring = cfg_get(psoc,
  309. CFG_DP_REO_REINJECT_RING);
  310. wlan_cfg_ctx->rx_release_ring = cfg_get(psoc,
  311. CFG_DP_RX_RELEASE_RING);
  312. wlan_cfg_ctx->reo_exception_ring = cfg_get(psoc,
  313. CFG_DP_REO_EXCEPTION_RING);
  314. wlan_cfg_ctx->reo_cmd_ring = cfg_get(psoc,
  315. CFG_DP_REO_CMD_RING);
  316. wlan_cfg_ctx->reo_status_ring = cfg_get(psoc,
  317. CFG_DP_REO_STATUS_RING);
  318. wlan_cfg_ctx->rxdma_refill_ring = cfg_get(psoc,
  319. CFG_DP_RXDMA_REFILL_RING);
  320. wlan_cfg_ctx->rxdma_err_dst_ring = cfg_get(psoc,
  321. CFG_DP_RXDMA_ERR_DST_RING);
  322. wlan_cfg_ctx->enable_data_stall_detection =
  323. cfg_get(psoc, CFG_DP_ENABLE_DATA_STALL_DETECTION);
  324. wlan_cfg_ctx->tx_flow_start_queue_offset =
  325. cfg_get(psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET);
  326. wlan_cfg_ctx->tx_flow_stop_queue_threshold =
  327. cfg_get(psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH);
  328. wlan_cfg_ctx->disable_intra_bss_fwd =
  329. cfg_get(psoc, CFG_DP_AP_STA_SECURITY_SEPERATION);
  330. return wlan_cfg_ctx;
  331. }
  332. void wlan_cfg_soc_detach(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx)
  333. {
  334. qdf_mem_free(wlan_cfg_ctx);
  335. }
  336. struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_pdev_attach(void *psoc)
  337. {
  338. struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx =
  339. qdf_mem_malloc(sizeof(struct wlan_cfg_dp_pdev_ctxt));
  340. if (wlan_cfg_ctx == NULL)
  341. return NULL;
  342. wlan_cfg_ctx->rx_dma_buf_ring_size = cfg_get(psoc,
  343. CFG_DP_RXDMA_BUF_RING);
  344. wlan_cfg_ctx->dma_mon_buf_ring_size = cfg_get(psoc,
  345. CFG_DP_RXDMA_MONITOR_BUF_RING);
  346. wlan_cfg_ctx->dma_mon_dest_ring_size = cfg_get(psoc,
  347. CFG_DP_RXDMA_MONITOR_DST_RING);
  348. wlan_cfg_ctx->dma_mon_status_ring_size = cfg_get(psoc,
  349. CFG_DP_RXDMA_MONITOR_STATUS_RING);
  350. wlan_cfg_ctx->rxdma_monitor_desc_ring = cfg_get(psoc,
  351. CFG_DP_RXDMA_MONITOR_DESC_RING);
  352. wlan_cfg_ctx->num_mac_rings = NUM_RXDMA_RINGS_PER_PDEV;
  353. return wlan_cfg_ctx;
  354. }
  355. void wlan_cfg_pdev_detach(struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx)
  356. {
  357. qdf_mem_free(wlan_cfg_ctx);
  358. }
  359. void wlan_cfg_set_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg, int num)
  360. {
  361. cfg->num_int_ctxts = num;
  362. }
  363. void wlan_cfg_set_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg, uint32_t val)
  364. {
  365. cfg->max_peer_id = val;
  366. }
  367. void wlan_cfg_set_max_ast_idx(struct wlan_cfg_dp_soc_ctxt *cfg, uint32_t val)
  368. {
  369. cfg->max_ast_idx = val;
  370. }
  371. int wlan_cfg_get_max_ast_idx(struct wlan_cfg_dp_soc_ctxt *cfg)
  372. {
  373. return cfg->max_ast_idx;
  374. }
  375. void wlan_cfg_set_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  376. int context, int mask)
  377. {
  378. cfg->int_tx_ring_mask[context] = mask;
  379. }
  380. void wlan_cfg_set_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  381. int context, int mask)
  382. {
  383. cfg->int_rx_ring_mask[context] = mask;
  384. }
  385. void wlan_cfg_set_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  386. int context, int mask)
  387. {
  388. cfg->int_rx_mon_ring_mask[context] = mask;
  389. }
  390. int wlan_cfg_get_host2rxdma_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  391. int context)
  392. {
  393. return cfg->int_host2rxdma_mon_ring_mask[context];
  394. }
  395. void wlan_cfg_set_host2rxdma_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  396. int context, int mask)
  397. {
  398. cfg->int_host2rxdma_mon_ring_mask[context] = mask;
  399. }
  400. int wlan_cfg_get_rxdma2host_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  401. int context)
  402. {
  403. return cfg->int_rxdma2host_mon_ring_mask[context];
  404. }
  405. void wlan_cfg_set_rxdma2host_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  406. int context, int mask)
  407. {
  408. cfg->int_rxdma2host_mon_ring_mask[context] = mask;
  409. }
  410. void wlan_cfg_set_rxdma2host_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  411. int context, int mask)
  412. {
  413. cfg->int_rxdma2host_ring_mask[context] = mask;
  414. }
  415. int wlan_cfg_get_rxdma2host_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  416. int context)
  417. {
  418. return cfg->int_rxdma2host_ring_mask[context];
  419. }
  420. void wlan_cfg_set_host2rxdma_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  421. int context, int mask)
  422. {
  423. cfg->int_host2rxdma_ring_mask[context] = mask;
  424. }
  425. int wlan_cfg_get_host2rxdma_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  426. int context)
  427. {
  428. return cfg->int_host2rxdma_ring_mask[context];
  429. }
  430. void wlan_cfg_set_hw_macid(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx,
  431. int hw_macid)
  432. {
  433. qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
  434. cfg->hw_macid[pdev_idx] = hw_macid;
  435. }
  436. int wlan_cfg_get_hw_macid(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx)
  437. {
  438. qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
  439. return cfg->hw_macid[pdev_idx];
  440. }
  441. int wlan_cfg_get_hw_mac_idx(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx)
  442. {
  443. qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
  444. return cfg->hw_macid[pdev_idx] - cfg->base_hw_macid;
  445. }
  446. void wlan_cfg_set_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  447. int context, int mask)
  448. {
  449. cfg->int_ce_ring_mask[context] = mask;
  450. }
  451. void wlan_cfg_set_rxbuf_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context,
  452. int mask)
  453. {
  454. cfg->int_rx_ring_mask[context] = mask;
  455. }
  456. int wlan_cfg_set_rx_err_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  457. int context, int mask)
  458. {
  459. return cfg->int_rx_err_ring_mask[context] = mask;
  460. }
  461. int wlan_cfg_set_rx_wbm_rel_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  462. int context, int mask)
  463. {
  464. return cfg->int_rx_wbm_rel_ring_mask[context] = mask;
  465. }
  466. int wlan_cfg_set_reo_status_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  467. int context, int mask)
  468. {
  469. return cfg->int_reo_status_ring_mask[context] = mask;
  470. }
  471. int wlan_cfg_get_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg)
  472. {
  473. return cfg->num_int_ctxts;
  474. }
  475. int wlan_cfg_get_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  476. {
  477. return cfg->int_tx_ring_mask[context];
  478. }
  479. int wlan_cfg_get_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  480. {
  481. return cfg->int_rx_ring_mask[context];
  482. }
  483. int wlan_cfg_get_rx_err_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  484. int context)
  485. {
  486. return cfg->int_rx_err_ring_mask[context];
  487. }
  488. int wlan_cfg_get_rx_wbm_rel_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  489. int context)
  490. {
  491. return cfg->int_rx_wbm_rel_ring_mask[context];
  492. }
  493. int wlan_cfg_get_reo_status_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  494. int context)
  495. {
  496. return cfg->int_reo_status_ring_mask[context];
  497. }
  498. int wlan_cfg_get_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  499. {
  500. return cfg->int_rx_mon_ring_mask[context];
  501. }
  502. int wlan_cfg_get_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  503. {
  504. return cfg->int_ce_ring_mask[context];
  505. }
  506. uint32_t wlan_cfg_get_max_clients(struct wlan_cfg_dp_soc_ctxt *cfg)
  507. {
  508. return cfg->max_clients;
  509. }
  510. uint32_t wlan_cfg_max_alloc_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  511. {
  512. return cfg->max_alloc_size;
  513. }
  514. int wlan_cfg_per_pdev_tx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  515. {
  516. return cfg->per_pdev_tx_ring;
  517. }
  518. int wlan_cfg_per_pdev_lmac_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  519. {
  520. return cfg->per_pdev_lmac_ring;
  521. }
  522. int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
  523. {
  524. return cfg->num_tcl_data_rings;
  525. }
  526. int wlan_cfg_tx_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  527. {
  528. return cfg->tx_ring_size;
  529. }
  530. int wlan_cfg_tx_comp_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  531. {
  532. return cfg->tx_comp_ring_size;
  533. }
  534. int wlan_cfg_per_pdev_rx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  535. {
  536. return cfg->per_pdev_rx_ring;
  537. }
  538. int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
  539. {
  540. return cfg->num_reo_dest_rings;
  541. }
  542. int wlan_cfg_pkt_type(struct wlan_cfg_dp_soc_ctxt *cfg)
  543. {
  544. return cfg->htt_packet_type; /*htt_pkt_type_ethernet*/
  545. }
  546. int wlan_cfg_get_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
  547. {
  548. return cfg->num_tx_desc_pool;
  549. }
  550. void wlan_cfg_set_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg, int num_pool)
  551. {
  552. cfg->num_tx_desc_pool = num_pool;
  553. }
  554. int wlan_cfg_get_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
  555. {
  556. return cfg->num_tx_ext_desc_pool;
  557. }
  558. void wlan_cfg_set_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg, int num_pool)
  559. {
  560. cfg->num_tx_ext_desc_pool = num_pool;
  561. }
  562. int wlan_cfg_get_reo_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  563. {
  564. return cfg->reo_dst_ring_size;
  565. }
  566. void wlan_cfg_set_reo_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg,
  567. int reo_dst_ring_size)
  568. {
  569. cfg->reo_dst_ring_size = reo_dst_ring_size;
  570. }
  571. void wlan_cfg_set_raw_mode_war(struct wlan_cfg_dp_soc_ctxt *cfg,
  572. bool raw_mode_war)
  573. {
  574. cfg->raw_mode_war = raw_mode_war;
  575. }
  576. bool wlan_cfg_get_raw_mode_war(struct wlan_cfg_dp_soc_ctxt *cfg)
  577. {
  578. return cfg->raw_mode_war;
  579. }
  580. int wlan_cfg_get_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
  581. {
  582. return cfg->num_tx_desc;
  583. }
  584. void wlan_cfg_set_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg, int num_desc)
  585. {
  586. cfg->num_tx_desc = num_desc;
  587. }
  588. int wlan_cfg_get_min_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
  589. {
  590. return cfg->min_tx_desc;
  591. }
  592. int wlan_cfg_get_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
  593. {
  594. return cfg->num_tx_ext_desc;
  595. }
  596. void wlan_cfg_set_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg, int num_ext_desc)
  597. {
  598. cfg->num_tx_ext_desc = num_ext_desc;
  599. }
  600. uint32_t wlan_cfg_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg)
  601. {
  602. /* TODO: This should be calculated based on target capabilities */
  603. return cfg->max_peer_id;
  604. }
  605. int wlan_cfg_get_dma_mon_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  606. {
  607. return cfg->dma_mon_buf_ring_size;
  608. }
  609. int wlan_cfg_get_dma_mon_dest_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  610. {
  611. return cfg->dma_mon_dest_ring_size;
  612. }
  613. int wlan_cfg_get_dma_mon_stat_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  614. {
  615. return cfg->dma_mon_status_ring_size;
  616. }
  617. int
  618. wlan_cfg_get_dma_mon_desc_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  619. {
  620. return cfg->rxdma_monitor_desc_ring;
  621. }
  622. int wlan_cfg_get_rx_dma_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  623. {
  624. return cfg->rx_dma_buf_ring_size;
  625. }
  626. int wlan_cfg_get_num_mac_rings(struct wlan_cfg_dp_pdev_ctxt *cfg)
  627. {
  628. return cfg->num_mac_rings;
  629. }
  630. bool wlan_cfg_is_gro_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
  631. {
  632. return cfg->gro_enabled;
  633. }
  634. bool wlan_cfg_is_lro_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
  635. {
  636. return cfg->lro_enabled;
  637. }
  638. bool wlan_cfg_is_ipa_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
  639. {
  640. return cfg->ipa_enabled;
  641. }
  642. void wlan_cfg_set_rx_hash(struct wlan_cfg_dp_soc_ctxt *cfg, bool val)
  643. {
  644. cfg->rx_hash = val;
  645. }
  646. bool wlan_cfg_is_rx_hash_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
  647. {
  648. return cfg->rx_hash;
  649. }
  650. int wlan_cfg_get_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg)
  651. {
  652. return cfg->nss_enabled;
  653. }
  654. void wlan_cfg_set_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg, int nss_enabled)
  655. {
  656. cfg->nss_enabled = nss_enabled;
  657. }
  658. int wlan_cfg_get_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg)
  659. {
  660. return cfg->nss_cfg;
  661. }
  662. void wlan_cfg_set_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg, int nss_cfg)
  663. {
  664. cfg->nss_cfg = nss_cfg;
  665. if (cfg->nss_cfg)
  666. cfg->tx_comp_ring_size = cfg->tx_comp_ring_size_nss;
  667. }
  668. int wlan_cfg_get_int_batch_threshold_tx(struct wlan_cfg_dp_soc_ctxt *cfg)
  669. {
  670. return cfg->int_batch_threshold_tx;
  671. }
  672. int wlan_cfg_get_int_timer_threshold_tx(struct wlan_cfg_dp_soc_ctxt *cfg)
  673. {
  674. return cfg->int_timer_threshold_tx;
  675. }
  676. int wlan_cfg_get_int_batch_threshold_rx(struct wlan_cfg_dp_soc_ctxt *cfg)
  677. {
  678. return cfg->int_batch_threshold_rx;
  679. }
  680. int wlan_cfg_get_int_timer_threshold_rx(struct wlan_cfg_dp_soc_ctxt *cfg)
  681. {
  682. return cfg->int_timer_threshold_rx;
  683. }
  684. int wlan_cfg_get_int_batch_threshold_other(struct wlan_cfg_dp_soc_ctxt *cfg)
  685. {
  686. return cfg->int_batch_threshold_other;
  687. }
  688. int wlan_cfg_get_int_timer_threshold_other(struct wlan_cfg_dp_soc_ctxt *cfg)
  689. {
  690. return cfg->int_timer_threshold_other;
  691. }
  692. int wlan_cfg_get_int_timer_threshold_mon(struct wlan_cfg_dp_soc_ctxt *cfg)
  693. {
  694. return cfg->int_timer_threshold_mon;
  695. }
  696. int wlan_cfg_get_checksum_offload(struct wlan_cfg_dp_soc_ctxt *cfg)
  697. {
  698. return cfg->tcp_udp_checksumoffload;
  699. }
  700. int wlan_cfg_get_rx_defrag_min_timeout(struct wlan_cfg_dp_soc_ctxt *cfg)
  701. {
  702. return cfg->rx_defrag_min_timeout;
  703. }
  704. int wlan_cfg_get_defrag_timeout_check(struct wlan_cfg_dp_soc_ctxt *cfg)
  705. {
  706. return cfg->defrag_timeout_check;
  707. }
  708. int
  709. wlan_cfg_get_dp_soc_wbm_release_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  710. {
  711. return cfg->wbm_release_ring;
  712. }
  713. int
  714. wlan_cfg_get_dp_soc_tcl_cmd_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  715. {
  716. return cfg->tcl_cmd_ring;
  717. }
  718. int
  719. wlan_cfg_get_dp_soc_tcl_status_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  720. {
  721. return cfg->tcl_status_ring;
  722. }
  723. int
  724. wlan_cfg_get_dp_soc_reo_reinject_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  725. {
  726. return cfg->reo_reinject_ring;
  727. }
  728. int
  729. wlan_cfg_get_dp_soc_rx_release_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  730. {
  731. return cfg->rx_release_ring;
  732. }
  733. int
  734. wlan_cfg_get_dp_soc_reo_exception_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  735. {
  736. return cfg->reo_exception_ring;
  737. }
  738. int
  739. wlan_cfg_get_dp_soc_reo_cmd_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  740. {
  741. return cfg->reo_cmd_ring;
  742. }
  743. int
  744. wlan_cfg_get_dp_soc_reo_status_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  745. {
  746. return cfg->reo_status_ring;
  747. }
  748. int
  749. wlan_cfg_get_dp_soc_rxdma_refill_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  750. {
  751. return cfg->rxdma_refill_ring;
  752. }
  753. int
  754. wlan_cfg_get_dp_soc_rxdma_err_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  755. {
  756. return cfg->rxdma_err_dst_ring;
  757. }
  758. bool
  759. wlan_cfg_get_dp_caps(struct wlan_cfg_dp_soc_ctxt *cfg,
  760. enum cdp_capabilities dp_caps)
  761. {
  762. switch (dp_caps) {
  763. case CDP_CFG_DP_TSO:
  764. return cfg->tso_enabled;
  765. case CDP_CFG_DP_LRO:
  766. return cfg->lro_enabled;
  767. case CDP_CFG_DP_SG:
  768. return cfg->sg_enabled;
  769. case CDP_CFG_DP_GRO:
  770. return cfg->gro_enabled;
  771. case CDP_CFG_DP_OL_TX_CSUM:
  772. return cfg->ol_tx_csum_enabled;
  773. case CDP_CFG_DP_OL_RX_CSUM:
  774. return cfg->ol_rx_csum_enabled;
  775. case CDP_CFG_DP_RAWMODE:
  776. return cfg->rawmode_enabled;
  777. case CDP_CFG_DP_PEER_FLOW_CTRL:
  778. return cfg->peer_flow_ctrl_enabled;
  779. default:
  780. return false;
  781. }
  782. }
  783. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  784. /**
  785. * wlan_cfg_get_tx_flow_stop_queue_th() - Get flow control stop threshold
  786. * @cfg: config context
  787. *
  788. * Return: stop threshold
  789. */
  790. int wlan_cfg_get_tx_flow_stop_queue_th(struct wlan_cfg_dp_soc_ctxt *cfg)
  791. {
  792. return cfg->tx_flow_stop_queue_threshold;
  793. }
  794. /**
  795. * wlan_cfg_get_tx_flow_start_queue_offset() - Get flow control start offset
  796. * for TX to resume
  797. * @cfg: config context
  798. *
  799. * Return: stop threshold
  800. */
  801. int wlan_cfg_get_tx_flow_start_queue_offset(struct wlan_cfg_dp_soc_ctxt *cfg)
  802. {
  803. return cfg->tx_flow_start_queue_offset;
  804. }
  805. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */