wlan_cfg.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /*
  2. * Copyright (c) 2016 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 "wlan_cfg.h"
  26. /*
  27. * FIX THIS -
  28. * For now, all these configuration parameters are hardcoded.
  29. * Many of these should actually be coming from dts file/ini file
  30. */
  31. #define WLAN_CFG_INT_NUM_CONTEXTS 4
  32. #define RXDMA_BUF_RING_SIZE 2048
  33. #define RXDMA_MONITOR_BUF_RING_SIZE 2048
  34. #define RXDMA_MONITOR_DEST_RING_SIZE 2048
  35. #define RXDMA_MONITOR_STATUS_RING_SIZE 2048
  36. #define WLAN_CFG_NUM_TX_DESC 1024
  37. #define WLAN_CFG_NUM_TX_EXT_DESC 1024
  38. #define WLAN_CFG_NUM_TX_DESC_POOL 3
  39. #define WLAN_CFG_NUM_TXEXT_DESC_POOL 3
  40. #define WLAN_CFG_TX_RING_MASK_0 0x1
  41. #define WLAN_CFG_TX_RING_MASK_1 0x2
  42. #define WLAN_CFG_TX_RING_MASK_2 0x4
  43. #define WLAN_CFG_TX_RING_MASK_3 0x0
  44. #define WLAN_CFG_RX_RING_MASK_0 0x1
  45. #define WLAN_CFG_RX_RING_MASK_1 0x2
  46. #define WLAN_CFG_RX_RING_MASK_2 0x4
  47. #define WLAN_CFG_RX_RING_MASK_3 0x8
  48. #define WLAN_CFG_RX_MON_RING_MASK_0 0x1
  49. #define WLAN_CFG_RX_MON_RING_MASK_1 0x2
  50. #define WLAN_CFG_RX_MON_RING_MASK_2 0x4
  51. #define WLAN_CFG_RX_MON_RING_MASK_3 0x0
  52. #define WLAN_CFG_DP_TX_NUM_POOLS 3
  53. /* Change this to a lower value to enforce scattered idle list mode */
  54. #define WLAN_CFG_MAX_ALLOC_SIZE (32 << 20)
  55. # define WLAN_CFG_MAX_CLIENTS 32
  56. #define WLAN_CFG_PER_PDEV_TX_RING 1
  57. #define WLAN_CFG_NUM_TCL_DATA_RINGS 3
  58. #define WLAN_CFG_PER_PDEV_RX_RING 1
  59. #define WLAN_CFG_NUM_REO_DEST_RING 4
  60. #define WLAN_CFG_HTT_PKT_TYPE 2
  61. #define WLAN_CFG_MAX_PEER_ID 16
  62. static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  63. WLAN_CFG_TX_RING_MASK_0,
  64. WLAN_CFG_TX_RING_MASK_1,
  65. WLAN_CFG_TX_RING_MASK_2,
  66. WLAN_CFG_TX_RING_MASK_3};
  67. static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  68. WLAN_CFG_RX_RING_MASK_0,
  69. WLAN_CFG_RX_RING_MASK_1,
  70. WLAN_CFG_RX_RING_MASK_2,
  71. WLAN_CFG_RX_RING_MASK_3};
  72. static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
  73. WLAN_CFG_RX_MON_RING_MASK_0,
  74. WLAN_CFG_RX_MON_RING_MASK_1,
  75. WLAN_CFG_RX_MON_RING_MASK_2,
  76. WLAN_CFG_RX_MON_RING_MASK_3};
  77. /**
  78. * struct wlan_cfg_dp_soc_ctxt - Configuration parameters for SoC (core TxRx)
  79. * @num_int_ctxts - Number of NAPI/Interrupt contexts to be registered for DP
  80. * @max_clients - Maximum number of peers/stations supported by device
  81. * @max_alloc_size - Maximum allocation size for any dynamic memory
  82. * allocation request for this device
  83. * @per_pdev_tx_ring - 0 - TCL ring is not mapped per radio
  84. * 1 - Each TCL ring is mapped to one radio/pdev
  85. * @num_tcl_data_rings - Number of TCL Data rings supported by device
  86. * @per_pdev_rx_ring - 0 - REO ring is not mapped per radio
  87. * 1 - Each REO ring is mapped to one radio/pdev
  88. * @num_tx_desc_pool - Number of Tx Descriptor pools
  89. * @num_tx_ext_desc_pool - Number of Tx MSDU extension Descriptor pools
  90. * @num_tx_desc - Number of Tx Descriptors per pool
  91. * @num_tx_ext_desc - Number of Tx MSDU extension Descriptors per pool
  92. * @max_peer_id - Maximum value of peer id that FW can assign for a client
  93. * @htt_packet_type - Default 802.11 encapsulation type for any VAP created
  94. * @int_tx_ring_mask - Bitmap of Tx interrupts mapped to each NAPI/Intr context
  95. * @int_rx_ring_mask - Bitmap of Rx interrupts mapped to each NAPI/Intr context
  96. * @int_rx_mon_ring_mask - Bitmap of Rx monitor ring interrupts mapped to each
  97. * NAPI/Intr context
  98. * @int_ce_ring_mask - Bitmap of CE interrupts mapped to each NAPI/Intr context
  99. *
  100. */
  101. struct wlan_cfg_dp_soc_ctxt {
  102. int num_int_ctxts;
  103. int max_clients;
  104. int max_alloc_size;
  105. int per_pdev_tx_ring;
  106. int num_tcl_data_rings;
  107. int per_pdev_rx_ring;
  108. int num_reo_dest_rings;
  109. int num_tx_desc_pool;
  110. int num_tx_ext_desc_pool;
  111. int num_tx_desc;
  112. int num_tx_ext_desc;
  113. int max_peer_id;
  114. int htt_packet_type;
  115. int int_tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
  116. int int_rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
  117. int int_rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
  118. int int_ce_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
  119. };
  120. /**
  121. * struct wlan_cfg_dp_pdev_ctxt - Configuration parameters for pdev (radio)
  122. * @rx_dma_buf_ring_size - Size of RxDMA buffer ring
  123. * @dma_mon_buf_ring_size - Size of RxDMA Monitor buffer ring
  124. * @dma_mon_dest_ring_size - Size of RxDMA Monitor Destination ring
  125. * @dma_mon_status_ring_size - Size of RxDMA Monitor Status ring
  126. */
  127. struct wlan_cfg_dp_pdev_ctxt {
  128. int rx_dma_buf_ring_size;
  129. int dma_mon_buf_ring_size;
  130. int dma_mon_dest_ring_size;
  131. int dma_mon_status_ring_size;
  132. };
  133. /**
  134. * wlan_cfg_soc_attach() - Allocate and prepare SoC configuration
  135. *
  136. * Return: wlan_cfg_ctx - Handle to Configuration context
  137. */
  138. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_soc_attach(void)
  139. {
  140. int i = 0;
  141. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx =
  142. qdf_mem_malloc(sizeof(struct wlan_cfg_dp_soc_ctxt));
  143. if (wlan_cfg_ctx == NULL)
  144. return NULL;
  145. wlan_cfg_ctx->num_int_ctxts = WLAN_CFG_INT_NUM_CONTEXTS;
  146. wlan_cfg_ctx->max_clients = WLAN_CFG_MAX_CLIENTS;
  147. wlan_cfg_ctx->max_alloc_size = WLAN_CFG_MAX_ALLOC_SIZE;
  148. wlan_cfg_ctx->per_pdev_tx_ring = WLAN_CFG_PER_PDEV_TX_RING;
  149. wlan_cfg_ctx->num_tcl_data_rings = WLAN_CFG_NUM_TCL_DATA_RINGS;
  150. wlan_cfg_ctx->per_pdev_rx_ring = WLAN_CFG_PER_PDEV_RX_RING;
  151. wlan_cfg_ctx->num_reo_dest_rings = WLAN_CFG_NUM_REO_DEST_RING;
  152. wlan_cfg_ctx->num_tx_desc_pool = WLAN_CFG_NUM_TX_DESC_POOL;
  153. wlan_cfg_ctx->num_tx_ext_desc_pool = WLAN_CFG_NUM_TXEXT_DESC_POOL;
  154. wlan_cfg_ctx->num_tx_desc = WLAN_CFG_NUM_TX_DESC;
  155. wlan_cfg_ctx->num_tx_ext_desc = WLAN_CFG_NUM_TX_EXT_DESC;
  156. wlan_cfg_ctx->max_peer_id = WLAN_CFG_MAX_PEER_ID;
  157. wlan_cfg_ctx->htt_packet_type = WLAN_CFG_HTT_PKT_TYPE;
  158. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  159. wlan_cfg_ctx->int_tx_ring_mask[i] = tx_ring_mask[i];
  160. wlan_cfg_ctx->int_rx_ring_mask[i] = rx_ring_mask[i];
  161. wlan_cfg_ctx->int_rx_mon_ring_mask[i] = rx_mon_ring_mask[i];
  162. }
  163. return wlan_cfg_ctx;
  164. }
  165. void wlan_cfg_soc_detach(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx)
  166. {
  167. qdf_mem_free(wlan_cfg_ctx);
  168. }
  169. struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_pdev_attach(void)
  170. {
  171. struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx =
  172. qdf_mem_malloc(sizeof(struct wlan_cfg_dp_pdev_ctxt));
  173. if (wlan_cfg_ctx == NULL)
  174. return NULL;
  175. wlan_cfg_ctx->rx_dma_buf_ring_size = RXDMA_BUF_RING_SIZE;
  176. wlan_cfg_ctx->dma_mon_buf_ring_size = RXDMA_MONITOR_BUF_RING_SIZE;
  177. wlan_cfg_ctx->dma_mon_dest_ring_size = RXDMA_MONITOR_DEST_RING_SIZE;
  178. wlan_cfg_ctx->dma_mon_status_ring_size = RXDMA_MONITOR_STATUS_RING_SIZE;
  179. return wlan_cfg_ctx;
  180. }
  181. void wlan_cfg_pdev_detach(struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx)
  182. {
  183. qdf_mem_free(wlan_cfg_ctx);
  184. }
  185. void wlan_cfg_set_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg, int num)
  186. {
  187. cfg->num_int_ctxts = num;
  188. }
  189. void wlan_cfg_set_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  190. int context, int mask)
  191. {
  192. cfg->int_tx_ring_mask[context] = mask;
  193. }
  194. void wlan_cfg_set_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  195. int context, int mask)
  196. {
  197. cfg->int_rx_ring_mask[context] = mask;
  198. }
  199. void wlan_cfg_set_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  200. int context, int mask)
  201. {
  202. cfg->int_rx_mon_ring_mask[context] = mask;
  203. }
  204. void wlan_cfg_set_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
  205. int context, int mask)
  206. {
  207. cfg->int_ce_ring_mask[context] = mask;
  208. }
  209. void wlan_cfg_set_rxbuf_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context,
  210. int mask)
  211. {
  212. cfg->int_rx_ring_mask[context] = mask;
  213. }
  214. int wlan_cfg_get_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg)
  215. {
  216. return cfg->num_int_ctxts;
  217. }
  218. int wlan_cfg_get_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  219. {
  220. return cfg->int_tx_ring_mask[context];
  221. }
  222. int wlan_cfg_get_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  223. {
  224. return cfg->int_rx_ring_mask[context];
  225. }
  226. int wlan_cfg_get_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  227. {
  228. return cfg->int_rx_mon_ring_mask[context];
  229. }
  230. int wlan_cfg_get_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
  231. {
  232. return cfg->int_ce_ring_mask[context];
  233. }
  234. uint32_t wlan_cfg_get_max_clients(struct wlan_cfg_dp_soc_ctxt *cfg)
  235. {
  236. return cfg->max_clients;
  237. }
  238. uint32_t wlan_cfg_max_alloc_size(struct wlan_cfg_dp_soc_ctxt *cfg)
  239. {
  240. return cfg->max_alloc_size;
  241. }
  242. int wlan_cfg_per_pdev_tx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  243. {
  244. return cfg->per_pdev_tx_ring;
  245. }
  246. int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
  247. {
  248. return cfg->num_tcl_data_rings;
  249. }
  250. int wlan_cfg_per_pdev_rx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
  251. {
  252. return cfg->per_pdev_rx_ring;
  253. }
  254. int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
  255. {
  256. return cfg->num_reo_dest_rings;
  257. }
  258. int wlan_cfg_pkt_type(struct wlan_cfg_dp_soc_ctxt *cfg)
  259. {
  260. return cfg->htt_packet_type; /*htt_pkt_type_ethernet*/
  261. }
  262. int wlan_cfg_get_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
  263. {
  264. return cfg->num_tx_desc_pool;
  265. }
  266. int wlan_cfg_get_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
  267. {
  268. return cfg->num_tx_ext_desc_pool;
  269. }
  270. int wlan_cfg_get_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
  271. {
  272. return cfg->num_tx_desc;
  273. }
  274. int wlan_cfg_get_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
  275. {
  276. return cfg->num_tx_ext_desc;
  277. }
  278. uint32_t wlan_cfg_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg)
  279. {
  280. /* TODO: This should be calculated based on target capabilities */
  281. return cfg->max_peer_id;
  282. }
  283. int wlan_cfg_get_dma_mon_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  284. {
  285. return cfg->dma_mon_buf_ring_size;
  286. }
  287. int wlan_cfg_get_dma_mon_dest_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  288. {
  289. return cfg->dma_mon_dest_ring_size;
  290. }
  291. int wlan_cfg_get_dma_mon_stat_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  292. {
  293. return cfg->dma_mon_status_ring_size;
  294. }
  295. int wlan_cfg_get_rx_dma_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
  296. {
  297. return cfg->rx_dma_buf_ring_size;
  298. }