hal_be_tx.h 20 KB

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