wlan_cfg.c 11 KB

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