wlan_cfg.c 11 KB

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