hal_be_tx.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. /*
  2. * Copyright (c) 2016-2021 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. #ifndef _HAL_BE_TX_H_
  19. #define _HAL_BE_TX_H_
  20. #include "hal_be_hw_headers.h"
  21. #include "hal_tx.h"
  22. /* Number of TX banks reserved i.e, will not be used by host driver. */
  23. /* MAX_TCL_BANK reserved for FW use */
  24. #define HAL_TX_NUM_RESERVED_BANKS 1
  25. enum hal_be_tx_ret_buf_manager {
  26. HAL_BE_WBM_SW0_BM_ID = 5,
  27. HAL_BE_WBM_SW1_BM_ID = 6,
  28. HAL_BE_WBM_SW2_BM_ID = 7,
  29. HAL_BE_WBM_SW3_BM_ID = 8,
  30. HAL_BE_WBM_SW4_BM_ID = 9,
  31. HAL_BE_WBM_SW5_BM_ID = 10,
  32. HAL_BE_WBM_SW6_BM_ID = 11,
  33. };
  34. enum hal_tx_mcast_ctrl {
  35. /* mcast traffic exceptioned to FW
  36. * valid only for AP VAP default for AP
  37. */
  38. HAL_TX_MCAST_CTRL_FW_EXCEPTION = 0,
  39. /* mcast traffic dropped in TCL*/
  40. HAL_TX_MCAST_CTRL_DROP,
  41. /* MEC notification are enabled
  42. * valid only for client VAP
  43. */
  44. HAL_TX_MCAST_CTRL_MEC_NOTIFY,
  45. /* no special routing for mcast
  46. * valid for client vap when index search is enabled
  47. */
  48. HAL_TX_MCAST_CTRL_NO_SPECIAL,
  49. };
  50. /**
  51. * enum hal_tx_vdev_mismatch_notify
  52. * @HAL_TX_VDEV_MISMATCH_TQM_NOTIFY: vdev mismatch exception routed to TQM
  53. * @HAL_TX_VDEV_MISMATCH_FW_NOTIFY: vdev mismatch exception routed to FW
  54. */
  55. enum hal_tx_vdev_mismatch_notify {
  56. HAL_TX_VDEV_MISMATCH_TQM_NOTIFY = 0,
  57. HAL_TX_VDEV_MISMATCH_FW_NOTIFY,
  58. };
  59. /*---------------------------------------------------------------------------
  60. * Structures
  61. * ---------------------------------------------------------------------------
  62. */
  63. /**
  64. * struct hal_tx_bank_config - SW config bank params
  65. * @epd: EPD indication flag
  66. * @encap_type: encapsulation type
  67. * @encrypt_type: encrypt type
  68. * @src_buffer_swap: big-endia switch for packet buffer
  69. * @link_meta_swap: big-endian switch for link metadata
  70. * @index_lookup_enable: Enabel index lookup
  71. * @addrx_en: Address-X search
  72. * @addry_en: Address-Y search
  73. * @mesh_enable:mesh enable flag
  74. * @vdev_id_check_en: vdev id check
  75. * @pmac_id: mac id
  76. * @mcast_pkt_ctrl: mulitcast packet control
  77. * @val: value representing bank config
  78. */
  79. union hal_tx_bank_config {
  80. struct {
  81. uint32_t epd:1,
  82. encap_type:2,
  83. encrypt_type:4,
  84. src_buffer_swap:1,
  85. link_meta_swap:1,
  86. index_lookup_enable:1,
  87. addrx_en:1,
  88. addry_en:1,
  89. mesh_enable:2,
  90. vdev_id_check_en:1,
  91. pmac_id:2,
  92. mcast_pkt_ctrl:2,
  93. dscp_tid_map_id:6,
  94. reserved:7;
  95. };
  96. uint32_t val;
  97. };
  98. /*---------------------------------------------------------------------------
  99. * Function declarations and documentation
  100. * ---------------------------------------------------------------------------
  101. */
  102. /*---------------------------------------------------------------------------
  103. * TCL Descriptor accessor APIs
  104. *---------------------------------------------------------------------------
  105. */
  106. /**
  107. * hal_tx_desc_set_buf_length - Set Data length in bytes in Tx Descriptor
  108. * @desc: Handle to Tx Descriptor
  109. * @data_length: MSDU length in case of direct descriptor.
  110. * Length of link extension descriptor in case of Link extension
  111. * descriptor.Includes the length of Metadata
  112. * Return: None
  113. */
  114. static inline void hal_tx_desc_set_buf_length(void *desc,
  115. uint16_t data_length)
  116. {
  117. HAL_SET_FLD(desc, TCL_DATA_CMD, DATA_LENGTH) |=
  118. HAL_TX_SM(TCL_DATA_CMD, DATA_LENGTH, data_length);
  119. }
  120. /**
  121. * hal_tx_desc_set_buf_offset - Sets Packet Offset field in Tx descriptor
  122. * @desc: Handle to Tx Descriptor
  123. * @offset: Packet offset from Metadata in case of direct buffer descriptor.
  124. *
  125. * Return: void
  126. */
  127. static inline void hal_tx_desc_set_buf_offset(void *desc,
  128. uint8_t offset)
  129. {
  130. HAL_SET_FLD(desc, TCL_DATA_CMD, PACKET_OFFSET) |=
  131. HAL_TX_SM(TCL_DATA_CMD, PACKET_OFFSET, offset);
  132. }
  133. /**
  134. * hal_tx_desc_set_l4_checksum_en - Set TCP/IP checksum enable flags
  135. * Tx Descriptor for MSDU_buffer type
  136. * @desc: Handle to Tx Descriptor
  137. * @en: UDP/TCP over ipv4/ipv6 checksum enable flags (5 bits)
  138. *
  139. * Return: void
  140. */
  141. static inline void hal_tx_desc_set_l4_checksum_en(void *desc,
  142. uint8_t en)
  143. {
  144. HAL_SET_FLD(desc, TCL_DATA_CMD, IPV4_CHECKSUM_EN) |=
  145. (HAL_TX_SM(TCL_DATA_CMD, UDP_OVER_IPV4_CHECKSUM_EN, en) |
  146. HAL_TX_SM(TCL_DATA_CMD, UDP_OVER_IPV6_CHECKSUM_EN, en) |
  147. HAL_TX_SM(TCL_DATA_CMD, TCP_OVER_IPV4_CHECKSUM_EN, en) |
  148. HAL_TX_SM(TCL_DATA_CMD, TCP_OVER_IPV6_CHECKSUM_EN, en));
  149. }
  150. /**
  151. * hal_tx_desc_set_l3_checksum_en - Set IPv4 checksum enable flag in
  152. * Tx Descriptor for MSDU_buffer type
  153. * @desc: Handle to Tx Descriptor
  154. * @checksum_en_flags: ipv4 checksum enable flags
  155. *
  156. * Return: void
  157. */
  158. static inline void hal_tx_desc_set_l3_checksum_en(void *desc,
  159. uint8_t en)
  160. {
  161. HAL_SET_FLD(desc, TCL_DATA_CMD, IPV4_CHECKSUM_EN) |=
  162. HAL_TX_SM(TCL_DATA_CMD, IPV4_CHECKSUM_EN, en);
  163. }
  164. /**
  165. * hal_tx_desc_set_fw_metadata- Sets the metadata that is part of TCL descriptor
  166. * @desc:Handle to Tx Descriptor
  167. * @metadata: Metadata to be sent to Firmware
  168. *
  169. * Return: void
  170. */
  171. static inline void hal_tx_desc_set_fw_metadata(void *desc,
  172. uint16_t metadata)
  173. {
  174. HAL_SET_FLD(desc, TCL_DATA_CMD, TCL_CMD_NUMBER) |=
  175. HAL_TX_SM(TCL_DATA_CMD, TCL_CMD_NUMBER, metadata);
  176. }
  177. /**
  178. * hal_tx_desc_set_to_fw - Set To_FW bit in Tx Descriptor.
  179. * @desc:Handle to Tx Descriptor
  180. * @to_fw: if set, Forward packet to FW along with classification result
  181. *
  182. * Return: void
  183. */
  184. static inline void hal_tx_desc_set_to_fw(void *desc, uint8_t to_fw)
  185. {
  186. HAL_SET_FLD(desc, TCL_DATA_CMD, TO_FW) |=
  187. HAL_TX_SM(TCL_DATA_CMD, TO_FW, to_fw);
  188. }
  189. /**
  190. * hal_tx_desc_set_hlos_tid - Set the TID value (override DSCP/PCP fields in
  191. * frame) to be used for Tx Frame
  192. * @desc: Handle to Tx Descriptor
  193. * @hlos_tid: HLOS TID
  194. *
  195. * Return: void
  196. */
  197. static inline void hal_tx_desc_set_hlos_tid(void *desc,
  198. uint8_t hlos_tid)
  199. {
  200. HAL_SET_FLD(desc, TCL_DATA_CMD, HLOS_TID) |=
  201. HAL_TX_SM(TCL_DATA_CMD, HLOS_TID, hlos_tid);
  202. HAL_SET_FLD(desc, TCL_DATA_CMD, HLOS_TID_OVERWRITE) |=
  203. HAL_TX_SM(TCL_DATA_CMD, HLOS_TID_OVERWRITE, 1);
  204. }
  205. /**
  206. * hal_tx_desc_sync - Commit the descriptor to Hardware
  207. * @hal_tx_des_cached: Cached descriptor that software maintains
  208. * @hw_desc: Hardware descriptor to be updated
  209. */
  210. static inline void hal_tx_desc_sync(void *hal_tx_desc_cached,
  211. void *hw_desc)
  212. {
  213. qdf_mem_copy(hw_desc, hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  214. }
  215. /**
  216. * hal_tx_desc_set_vdev_id - set vdev id to the descriptor to Hardware
  217. * @hal_tx_des_cached: Cached descriptor that software maintains
  218. * @vdev_id: vdev id
  219. */
  220. static inline void hal_tx_desc_set_vdev_id(void *desc, uint8_t vdev_id)
  221. {
  222. HAL_SET_FLD(desc, TCL_DATA_CMD, VDEV_ID) |=
  223. HAL_TX_SM(TCL_DATA_CMD, VDEV_ID, vdev_id);
  224. }
  225. /**
  226. * hal_tx_desc_set_bank_id - set bank id to the descriptor to Hardware
  227. * @hal_tx_des_cached: Cached descriptor that software maintains
  228. * @bank_id: bank id
  229. */
  230. static inline void hal_tx_desc_set_bank_id(void *desc, uint8_t bank_id)
  231. {
  232. HAL_SET_FLD(desc, TCL_DATA_CMD, BANK_ID) |=
  233. HAL_TX_SM(TCL_DATA_CMD, BANK_ID, bank_id);
  234. }
  235. /**
  236. * hal_tx_desc_set_tcl_cmd_type - set tcl command type to the descriptor
  237. * to Hardware
  238. * @hal_tx_des_cached: Cached descriptor that software maintains
  239. * @tcl_cmd_type: tcl command type
  240. */
  241. static inline void
  242. hal_tx_desc_set_tcl_cmd_type(void *desc, uint8_t tcl_cmd_type)
  243. {
  244. HAL_SET_FLD(desc, TCL_DATA_CMD, TCL_CMD_TYPE) |=
  245. HAL_TX_SM(TCL_DATA_CMD, TCL_CMD_TYPE, tcl_cmd_type);
  246. }
  247. /**
  248. * hal_tx_desc_set_lmac_id_be - set lmac id to the descriptor to Hardware
  249. * @hal_soc_hdl: hal soc handle
  250. * @hal_tx_des_cached: Cached descriptor that software maintains
  251. * @lmac_id: lmac id
  252. */
  253. static inline void
  254. hal_tx_desc_set_lmac_id_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  255. uint8_t lmac_id)
  256. {
  257. HAL_SET_FLD(desc, TCL_DATA_CMD, PMAC_ID) |=
  258. HAL_TX_SM(TCL_DATA_CMD, PMAC_ID, lmac_id);
  259. }
  260. /**
  261. * hal_tx_desc_set_search_index_be - set search index to the
  262. * descriptor to Hardware
  263. * @hal_soc_hdl: hal soc handle
  264. * @hal_tx_des_cached: Cached descriptor that software maintains
  265. * @search_index: search index
  266. */
  267. static inline void
  268. hal_tx_desc_set_search_index_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  269. uint32_t search_index)
  270. {
  271. HAL_SET_FLD(desc, TCL_DATA_CMD, SEARCH_INDEX) |=
  272. HAL_TX_SM(TCL_DATA_CMD, SEARCH_INDEX, search_index);
  273. }
  274. /**
  275. * hal_tx_desc_set_cache_set_num - set cache set num to the
  276. * descriptor to Hardware
  277. * @hal_soc_hdl: hal soc handle
  278. * @hal_tx_des_cached: Cached descriptor that software maintains
  279. * @cache_num: cache number
  280. */
  281. static inline void
  282. hal_tx_desc_set_cache_set_num(hal_soc_handle_t hal_soc_hdl, void *desc,
  283. uint8_t cache_num)
  284. {
  285. HAL_SET_FLD(desc, TCL_DATA_CMD, CACHE_SET_NUM) |=
  286. HAL_TX_SM(TCL_DATA_CMD, CACHE_SET_NUM, cache_num);
  287. }
  288. /*---------------------------------------------------------------------------
  289. * WBM Descriptor accessor APIs for Tx completions
  290. * ---------------------------------------------------------------------------
  291. */
  292. /**
  293. * hal_tx_get_wbm_sw0_bm_id() - Get the BM ID for first tx completion ring
  294. *
  295. * Return: BM ID for first tx completion ring
  296. */
  297. static inline uint32_t hal_tx_get_wbm_sw0_bm_id(void)
  298. {
  299. return HAL_BE_WBM_SW0_BM_ID;
  300. }
  301. /**
  302. * hal_tx_comp_get_desc_id() - Get TX descriptor id within comp descriptor
  303. * @hal_desc: completion ring descriptor pointer
  304. *
  305. * This function will tx descriptor id, cookie, within hardware completion
  306. * descriptor. For cases when cookie conversion is disabled, the sw_cookie
  307. * is present in the 2nd DWORD.
  308. *
  309. * Return: cookie
  310. */
  311. static inline uint32_t hal_tx_comp_get_desc_id(void *hal_desc)
  312. {
  313. uint32_t comp_desc =
  314. *(uint32_t *)(((uint8_t *)hal_desc) +
  315. BUFFER_ADDR_INFO_SW_BUFFER_COOKIE_OFFSET);
  316. /* Cookie is placed on 2nd word */
  317. return (comp_desc & BUFFER_ADDR_INFO_SW_BUFFER_COOKIE_MASK) >>
  318. BUFFER_ADDR_INFO_SW_BUFFER_COOKIE_LSB;
  319. }
  320. /**
  321. * hal_tx_comp_get_paddr() - Get paddr within comp descriptor
  322. * @hal_desc: completion ring descriptor pointer
  323. *
  324. * This function will get buffer physical address within hardware completion
  325. * descriptor
  326. *
  327. * Return: Buffer physical address
  328. */
  329. static inline qdf_dma_addr_t hal_tx_comp_get_paddr(void *hal_desc)
  330. {
  331. uint32_t paddr_lo;
  332. uint32_t paddr_hi;
  333. paddr_lo = *(uint32_t *)(((uint8_t *)hal_desc) +
  334. BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_OFFSET);
  335. paddr_hi = *(uint32_t *)(((uint8_t *)hal_desc) +
  336. BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_OFFSET);
  337. paddr_hi = (paddr_hi & BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_MASK) >>
  338. BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_LSB;
  339. return (qdf_dma_addr_t)(paddr_lo | (((uint64_t)paddr_hi) << 32));
  340. }
  341. #ifdef DP_HW_COOKIE_CONVERT_EXCEPTION
  342. /* HW set dowrd-2 bit30 to 1 if HW CC is done */
  343. #define HAL_WBM2SW_COMPLETION_RING_TX_CC_DONE_OFFSET 0x8
  344. #define HAL_WBM2SW_COMPLETION_RING_TX_CC_DONE_MASK 0x40000000
  345. #define HAL_WBM2SW_COMPLETION_RING_TX_CC_DONE_LSB 0x1E
  346. /**
  347. * hal_tx_comp_get_cookie_convert_done() - Get cookie conversion done flag
  348. * @hal_desc: completion ring descriptor pointer
  349. *
  350. * This function will get the bit value that indicate HW cookie
  351. * conversion done or not
  352. *
  353. * Return: 1 - HW cookie conversion done, 0 - not
  354. */
  355. static inline uint8_t hal_tx_comp_get_cookie_convert_done(void *hal_desc)
  356. {
  357. return HAL_TX_DESC_GET(hal_desc, HAL_WBM2SW_COMPLETION_RING_TX,
  358. CC_DONE);
  359. }
  360. #endif
  361. /**
  362. * hal_tx_comp_get_desc_va() - Get Desc virtual address within completion Desc
  363. * @hal_desc: completion ring descriptor pointer
  364. *
  365. * This function will get the TX Desc virtual address
  366. *
  367. * Return: TX desc virtual address
  368. */
  369. static inline uintptr_t hal_tx_comp_get_desc_va(void *hal_desc)
  370. {
  371. uint64_t va_from_desc;
  372. va_from_desc = HAL_TX_DESC_GET(hal_desc,
  373. WBM2SW_COMPLETION_RING_TX,
  374. BUFFER_VIRT_ADDR_31_0) |
  375. (((uint64_t)HAL_TX_DESC_GET(
  376. hal_desc,
  377. WBM2SW_COMPLETION_RING_TX,
  378. BUFFER_VIRT_ADDR_63_32)) << 32);
  379. return (uintptr_t)va_from_desc;
  380. }
  381. /*---------------------------------------------------------------------------
  382. * TX BANK register accessor APIs
  383. * ---------------------------------------------------------------------------
  384. */
  385. /**
  386. * hal_tx_get_num_tcl_banks() - Get number of banks for target
  387. *
  388. * Return: None
  389. */
  390. static inline uint8_t
  391. hal_tx_get_num_tcl_banks(hal_soc_handle_t hal_soc_hdl)
  392. {
  393. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  394. int hal_banks = 0;
  395. if (hal_soc->ops->hal_tx_get_num_tcl_banks) {
  396. hal_banks = hal_soc->ops->hal_tx_get_num_tcl_banks();
  397. hal_banks -= HAL_TX_NUM_RESERVED_BANKS;
  398. hal_banks = (hal_banks < 0) ? 0 : hal_banks;
  399. }
  400. return hal_banks;
  401. }
  402. /**
  403. * hal_tx_populate_bank_register() - populate the bank register with
  404. * the software configs.
  405. * @soc: HAL soc handle
  406. * @config: bank config
  407. * @bank_id: bank id to be configured
  408. *
  409. * Returns: None
  410. */
  411. #ifdef HWIO_TCL_R0_SW_CONFIG_BANK_n_MCAST_PACKET_CTRL_SHFT
  412. static inline void
  413. hal_tx_populate_bank_register(hal_soc_handle_t hal_soc_hdl,
  414. union hal_tx_bank_config *config,
  415. uint8_t bank_id)
  416. {
  417. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  418. uint32_t reg_addr, reg_val = 0;
  419. reg_addr = HWIO_TCL_R0_SW_CONFIG_BANK_n_ADDR(MAC_TCL_REG_REG_BASE,
  420. bank_id);
  421. reg_val |= (config->epd << HWIO_TCL_R0_SW_CONFIG_BANK_n_EPD_SHFT);
  422. reg_val |= (config->encap_type <<
  423. HWIO_TCL_R0_SW_CONFIG_BANK_n_ENCAP_TYPE_SHFT);
  424. reg_val |= (config->encrypt_type <<
  425. HWIO_TCL_R0_SW_CONFIG_BANK_n_ENCRYPT_TYPE_SHFT);
  426. reg_val |= (config->src_buffer_swap <<
  427. HWIO_TCL_R0_SW_CONFIG_BANK_n_SRC_BUFFER_SWAP_SHFT);
  428. reg_val |= (config->link_meta_swap <<
  429. HWIO_TCL_R0_SW_CONFIG_BANK_n_LINK_META_SWAP_SHFT);
  430. reg_val |= (config->index_lookup_enable <<
  431. HWIO_TCL_R0_SW_CONFIG_BANK_n_INDEX_LOOKUP_ENABLE_SHFT);
  432. reg_val |= (config->addrx_en <<
  433. HWIO_TCL_R0_SW_CONFIG_BANK_n_ADDRX_EN_SHFT);
  434. reg_val |= (config->addry_en <<
  435. HWIO_TCL_R0_SW_CONFIG_BANK_n_ADDRY_EN_SHFT);
  436. reg_val |= (config->mesh_enable <<
  437. HWIO_TCL_R0_SW_CONFIG_BANK_n_MESH_ENABLE_SHFT);
  438. reg_val |= (config->vdev_id_check_en <<
  439. HWIO_TCL_R0_SW_CONFIG_BANK_n_VDEV_ID_CHECK_EN_SHFT);
  440. reg_val |= (config->pmac_id <<
  441. HWIO_TCL_R0_SW_CONFIG_BANK_n_PMAC_ID_SHFT);
  442. reg_val |= (config->mcast_pkt_ctrl <<
  443. HWIO_TCL_R0_SW_CONFIG_BANK_n_MCAST_PACKET_CTRL_SHFT);
  444. HAL_REG_WRITE(hal_soc, reg_addr, reg_val);
  445. }
  446. #else
  447. static inline void
  448. hal_tx_populate_bank_register(hal_soc_handle_t hal_soc_hdl,
  449. union hal_tx_bank_config *config,
  450. uint8_t bank_id)
  451. {
  452. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  453. uint32_t reg_addr, reg_val = 0;
  454. reg_addr = HWIO_TCL_R0_SW_CONFIG_BANK_n_ADDR(MAC_TCL_REG_REG_BASE,
  455. bank_id);
  456. reg_val |= (config->epd << HWIO_TCL_R0_SW_CONFIG_BANK_n_EPD_SHFT);
  457. reg_val |= (config->encap_type <<
  458. HWIO_TCL_R0_SW_CONFIG_BANK_n_ENCAP_TYPE_SHFT);
  459. reg_val |= (config->encrypt_type <<
  460. HWIO_TCL_R0_SW_CONFIG_BANK_n_ENCRYPT_TYPE_SHFT);
  461. reg_val |= (config->src_buffer_swap <<
  462. HWIO_TCL_R0_SW_CONFIG_BANK_n_SRC_BUFFER_SWAP_SHFT);
  463. reg_val |= (config->link_meta_swap <<
  464. HWIO_TCL_R0_SW_CONFIG_BANK_n_LINK_META_SWAP_SHFT);
  465. reg_val |= (config->index_lookup_enable <<
  466. HWIO_TCL_R0_SW_CONFIG_BANK_n_INDEX_LOOKUP_ENABLE_SHFT);
  467. reg_val |= (config->addrx_en <<
  468. HWIO_TCL_R0_SW_CONFIG_BANK_n_ADDRX_EN_SHFT);
  469. reg_val |= (config->addry_en <<
  470. HWIO_TCL_R0_SW_CONFIG_BANK_n_ADDRY_EN_SHFT);
  471. reg_val |= (config->mesh_enable <<
  472. HWIO_TCL_R0_SW_CONFIG_BANK_n_MESH_ENABLE_SHFT);
  473. reg_val |= (config->vdev_id_check_en <<
  474. HWIO_TCL_R0_SW_CONFIG_BANK_n_VDEV_ID_CHECK_EN_SHFT);
  475. reg_val |= (config->pmac_id <<
  476. HWIO_TCL_R0_SW_CONFIG_BANK_n_PMAC_ID_SHFT);
  477. reg_val |= (config->mcast_pkt_ctrl <<
  478. HWIO_TCL_R0_SW_CONFIG_BANK_n_DSCP_TID_TABLE_NUM_SHFT);
  479. HAL_REG_WRITE(hal_soc, reg_addr, reg_val);
  480. }
  481. #endif
  482. #ifdef DP_TX_IMPLICIT_RBM_MAPPING
  483. #define RBM_MAPPING_BMSK HWIO_TCL_R0_RBM_MAPPING0_SW2TCL1_RING_BMSK
  484. #define RBM_MAPPING_SHFT HWIO_TCL_R0_RBM_MAPPING0_SW2TCL2_RING_SHFT
  485. #define RBM_PPE2TCL_OFFSET \
  486. (HWIO_TCL_R0_RBM_MAPPING0_PPE2TCL1_RING_SHFT >> 2)
  487. #define RBM_TCL_CMD_CREDIT_OFFSET \
  488. (HWIO_TCL_R0_RBM_MAPPING0_SW2TCL_CREDIT_RING_SHFT >> 2)
  489. /**
  490. * hal_tx_config_rbm_mapping_be() - Update return buffer manager ring id
  491. * @hal_soc: HAL SoC context
  492. * @hal_ring_hdl: Source ring pointer
  493. * @rbm_id: return buffer manager ring id
  494. *
  495. * Return: void
  496. */
  497. static inline void
  498. hal_tx_config_rbm_mapping_be(hal_soc_handle_t hal_soc_hdl,
  499. hal_ring_handle_t hal_ring_hdl,
  500. uint8_t rbm_id)
  501. {
  502. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  503. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  504. uint32_t reg_addr = 0;
  505. uint32_t reg_val = 0;
  506. uint32_t val = 0;
  507. uint8_t ring_num;
  508. enum hal_ring_type ring_type;
  509. ring_type = srng->ring_type;
  510. ring_num = hal_soc->hw_srng_table[ring_type].start_ring_id;
  511. ring_num = srng->ring_id - ring_num;
  512. reg_addr = HWIO_TCL_R0_RBM_MAPPING0_ADDR(MAC_TCL_REG_REG_BASE);
  513. if (ring_type == PPE2TCL)
  514. ring_num = ring_num + RBM_PPE2TCL_OFFSET;
  515. else if (ring_type == TCL_CMD_CREDIT)
  516. ring_num = ring_num + RBM_TCL_CMD_CREDIT_OFFSET;
  517. /* get current value stored in register address */
  518. val = HAL_REG_READ(hal_soc, reg_addr);
  519. /* mask out other stored value */
  520. val &= (~(RBM_MAPPING_BMSK << (RBM_MAPPING_SHFT * ring_num)));
  521. reg_val = val | ((RBM_MAPPING_BMSK & rbm_id) <<
  522. (RBM_MAPPING_SHFT * ring_num));
  523. /* write rbm mapped value to register address */
  524. HAL_REG_WRITE(hal_soc, reg_addr, reg_val);
  525. }
  526. #else
  527. static inline void
  528. hal_tx_config_rbm_mapping_be(hal_soc_handle_t hal_soc_hdl,
  529. hal_ring_handle_t hal_ring_hdl,
  530. uint8_t rbm_id)
  531. {
  532. }
  533. #endif
  534. /**
  535. * hal_tx_desc_set_buf_addr_be - Fill Buffer Address information in Tx Desc
  536. * @desc: Handle to Tx Descriptor
  537. * @paddr: Physical Address
  538. * @pool_id: Return Buffer Manager ID
  539. * @desc_id: Descriptor ID
  540. * @type: 0 - Address points to a MSDU buffer
  541. * 1 - Address points to MSDU extension descriptor
  542. *
  543. * Return: void
  544. */
  545. #ifdef DP_TX_IMPLICIT_RBM_MAPPING
  546. static inline void
  547. hal_tx_desc_set_buf_addr_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  548. dma_addr_t paddr, uint8_t rbm_id,
  549. uint32_t desc_id, uint8_t type)
  550. {
  551. /* Set buffer_addr_info.buffer_addr_31_0 */
  552. HAL_SET_FLD(desc, TCL_DATA_CMD,
  553. BUF_ADDR_INFO_BUFFER_ADDR_31_0) =
  554. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_31_0, paddr);
  555. /* Set buffer_addr_info.buffer_addr_39_32 */
  556. HAL_SET_FLD(desc, TCL_DATA_CMD,
  557. BUF_ADDR_INFO_BUFFER_ADDR_39_32) |=
  558. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_39_32,
  559. (((uint64_t)paddr) >> 32));
  560. /* Set buffer_addr_info.sw_buffer_cookie = desc_id */
  561. HAL_SET_FLD(desc, TCL_DATA_CMD,
  562. BUF_ADDR_INFO_SW_BUFFER_COOKIE) |=
  563. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_SW_BUFFER_COOKIE,
  564. desc_id);
  565. /* Set Buffer or Ext Descriptor Type */
  566. HAL_SET_FLD(desc, TCL_DATA_CMD,
  567. BUF_OR_EXT_DESC_TYPE) |=
  568. HAL_TX_SM(TCL_DATA_CMD, BUF_OR_EXT_DESC_TYPE, type);
  569. }
  570. #else
  571. static inline void
  572. hal_tx_desc_set_buf_addr_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  573. dma_addr_t paddr, uint8_t rbm_id,
  574. uint32_t desc_id, uint8_t type)
  575. {
  576. /* Set buffer_addr_info.buffer_addr_31_0 */
  577. HAL_SET_FLD(desc, TCL_DATA_CMD,
  578. BUF_ADDR_INFO_BUFFER_ADDR_31_0) =
  579. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_31_0, paddr);
  580. /* Set buffer_addr_info.buffer_addr_39_32 */
  581. HAL_SET_FLD(desc, TCL_DATA_CMD,
  582. BUF_ADDR_INFO_BUFFER_ADDR_39_32) |=
  583. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_39_32,
  584. (((uint64_t)paddr) >> 32));
  585. /* Set buffer_addr_info.return_buffer_manager = rbm id */
  586. HAL_SET_FLD(desc, TCL_DATA_CMD,
  587. BUF_ADDR_INFO_RETURN_BUFFER_MANAGER) |=
  588. HAL_TX_SM(TCL_DATA_CMD,
  589. BUF_ADDR_INFO_RETURN_BUFFER_MANAGER, rbm_id);
  590. /* Set buffer_addr_info.sw_buffer_cookie = desc_id */
  591. HAL_SET_FLD(desc, TCL_DATA_CMD,
  592. BUF_ADDR_INFO_SW_BUFFER_COOKIE) |=
  593. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_SW_BUFFER_COOKIE,
  594. desc_id);
  595. /* Set Buffer or Ext Descriptor Type */
  596. HAL_SET_FLD(desc, TCL_DATA_CMD,
  597. BUF_OR_EXT_DESC_TYPE) |=
  598. HAL_TX_SM(TCL_DATA_CMD, BUF_OR_EXT_DESC_TYPE, type);
  599. }
  600. #endif
  601. #ifdef HWIO_TCL_R0_VDEV_MCAST_PACKET_CTRL_MAP_n_VAL_SHFT
  602. #define HAL_TCL_VDEV_MCAST_PACKET_CTRL_REG_ID(vdev_id) (vdev_id >> 0x4)
  603. #define HAL_TCL_VDEV_MCAST_PACKET_CTRL_INDEX_IN_REG(vdev_id) (vdev_id & 0xF)
  604. #define HAL_TCL_VDEV_MCAST_PACKET_CTRL_MASK 0x3
  605. #define HAL_TCL_VDEV_MCAST_PACKET_CTRL_SHIFT 0x2
  606. /**
  607. * hal_tx_vdev_mcast_ctrl_set - set mcast_ctrl value
  608. * @hal_soc: HAL SoC context
  609. * @mcast_ctrl_val: mcast ctrl value for this VAP
  610. *
  611. * Return: void
  612. */
  613. static inline void
  614. hal_tx_vdev_mcast_ctrl_set(hal_soc_handle_t hal_soc_hdl,
  615. uint8_t vdev_id,
  616. uint8_t mcast_ctrl_val)
  617. {
  618. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  619. uint32_t reg_addr, reg_val = 0;
  620. uint32_t val;
  621. uint8_t reg_idx = HAL_TCL_VDEV_MCAST_PACKET_CTRL_REG_ID(vdev_id);
  622. uint8_t index_in_reg =
  623. HAL_TCL_VDEV_MCAST_PACKET_CTRL_INDEX_IN_REG(vdev_id);
  624. reg_addr =
  625. HWIO_TCL_R0_VDEV_MCAST_PACKET_CTRL_MAP_n_ADDR(MAC_TCL_REG_REG_BASE,
  626. reg_idx);
  627. val = HAL_REG_READ(hal_soc, reg_addr);
  628. /* mask out other stored value */
  629. val &= (~(HAL_TCL_VDEV_MCAST_PACKET_CTRL_MASK <<
  630. (HAL_TCL_VDEV_MCAST_PACKET_CTRL_SHIFT * index_in_reg)));
  631. reg_val = val |
  632. ((HAL_TCL_VDEV_MCAST_PACKET_CTRL_MASK & mcast_ctrl_val) <<
  633. (HAL_TCL_VDEV_MCAST_PACKET_CTRL_SHIFT * index_in_reg));
  634. HAL_REG_WRITE(hal_soc, reg_addr, reg_val);
  635. }
  636. #else
  637. static inline void
  638. hal_tx_vdev_mcast_ctrl_set(hal_soc_handle_t hal_soc_hdl,
  639. uint8_t vdev_id,
  640. uint8_t mcast_ctrl_val)
  641. {
  642. }
  643. #endif
  644. /**
  645. * hal_tx_vdev_mismatch_routing_set - set vdev mismatch exception routing
  646. * @hal_soc: HAL SoC context
  647. * @config: HAL_TX_VDEV_MISMATCH_TQM_NOTIFY - route via TQM
  648. * HAL_TX_VDEV_MISMATCH_FW_NOTIFY - route via FW
  649. *
  650. * Return: void
  651. */
  652. #ifdef HWIO_TCL_R0_CMN_CONFIG_VDEVID_MISMATCH_EXCEPTION_BMSK
  653. static inline void
  654. hal_tx_vdev_mismatch_routing_set(hal_soc_handle_t hal_soc_hdl,
  655. enum hal_tx_vdev_mismatch_notify config)
  656. {
  657. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  658. uint32_t reg_addr, reg_val = 0;
  659. uint32_t val = 0;
  660. reg_addr = HWIO_TCL_R0_CMN_CONFIG_ADDR(MAC_TCL_REG_REG_BASE);
  661. val = HAL_REG_READ(hal_soc, reg_addr);
  662. /* reset the corresponding bits in register */
  663. val &= (~(HWIO_TCL_R0_CMN_CONFIG_VDEVID_MISMATCH_EXCEPTION_BMSK));
  664. /* set config value */
  665. reg_val = val | (config <<
  666. HWIO_TCL_R0_CMN_CONFIG_VDEVID_MISMATCH_EXCEPTION_SHFT);
  667. HAL_REG_WRITE(hal_soc, reg_addr, reg_val);
  668. }
  669. #else
  670. static inline void
  671. hal_tx_vdev_mismatch_routing_set(hal_soc_handle_t hal_soc_hdl,
  672. enum hal_tx_vdev_mismatch_notify config)
  673. {
  674. }
  675. #endif
  676. #endif /* _HAL_BE_TX_H_ */