wlan_cfg.c 12 KB

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