wlan_cfg.c 11 KB

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