hal_be_tx.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _HAL_BE_TX_H_
  20. #define _HAL_BE_TX_H_
  21. #include "hal_be_hw_headers.h"
  22. #include "hal_tx.h"
  23. /* Number of TX banks reserved i.e, will not be used by host driver. */
  24. /* MAX_TCL_BANK reserved for FW use */
  25. #define HAL_TX_NUM_RESERVED_BANKS 1
  26. /*
  27. * Number of Priority to TID mapping
  28. */
  29. #define HAL_BE_TX_MAP0_PRI2TID_MAX 10
  30. #define HAL_BE_TX_MAP1_PRI2TID_MAX 6
  31. enum hal_be_tx_ret_buf_manager {
  32. HAL_BE_WBM_SW0_BM_ID = 5,
  33. HAL_BE_WBM_SW1_BM_ID = 6,
  34. HAL_BE_WBM_SW2_BM_ID = 7,
  35. HAL_BE_WBM_SW3_BM_ID = 8,
  36. HAL_BE_WBM_SW4_BM_ID = 9,
  37. HAL_BE_WBM_SW5_BM_ID = 10,
  38. HAL_BE_WBM_SW6_BM_ID = 11,
  39. };
  40. enum hal_tx_mcast_ctrl {
  41. /* mcast traffic exceptioned to FW
  42. * valid only for AP VAP default for AP
  43. */
  44. HAL_TX_MCAST_CTRL_FW_EXCEPTION = 0,
  45. /* mcast traffic dropped in TCL*/
  46. HAL_TX_MCAST_CTRL_DROP,
  47. /* MEC notification are enabled
  48. * valid only for client VAP
  49. */
  50. HAL_TX_MCAST_CTRL_MEC_NOTIFY,
  51. /* no special routing for mcast
  52. * valid for client vap when index search is enabled
  53. */
  54. HAL_TX_MCAST_CTRL_NO_SPECIAL,
  55. };
  56. /* enum hal_tx_notify_frame_type - TX notify frame type
  57. * @NO_TX_NOTIFY: Not a notify frame
  58. * @TX_HARD_NOTIFY: Hard notify TX frame
  59. * @TX_SOFT_NOTIFY_E: Soft Notify Tx frame
  60. * @TX_SEMI_HARD_NOTIFY_E: Semi Hard notify TX frame
  61. */
  62. enum hal_tx_notify_frame_type {
  63. NO_TX_NOTIFY = 0,
  64. TX_HARD_NOTIFY = 1,
  65. TX_SOFT_NOTIFY_E = 2,
  66. TX_SEMI_HARD_NOTIFY_E = 3
  67. };
  68. /*---------------------------------------------------------------------------
  69. * Structures
  70. * ---------------------------------------------------------------------------
  71. */
  72. /**
  73. * struct hal_tx_bank_config - SW config bank params
  74. * @epd: EPD indication flag
  75. * @encap_type: encapsulation type
  76. * @encrypt_type: encrypt type
  77. * @src_buffer_swap: big-endia switch for packet buffer
  78. * @link_meta_swap: big-endian switch for link metadata
  79. * @index_lookup_enable: Enable index lookup
  80. * @addrx_en: Address-X search
  81. * @addry_en: Address-Y search
  82. * @mesh_enable:mesh enable flag
  83. * @vdev_id_check_en: vdev id check
  84. * @pmac_id: mac id
  85. * @mcast_pkt_ctrl: mulitcast packet control
  86. * @val: value representing bank config
  87. */
  88. union hal_tx_bank_config {
  89. struct {
  90. uint32_t epd:1,
  91. encap_type:2,
  92. encrypt_type:4,
  93. src_buffer_swap:1,
  94. link_meta_swap:1,
  95. index_lookup_enable:1,
  96. addrx_en:1,
  97. addry_en:1,
  98. mesh_enable:2,
  99. vdev_id_check_en:1,
  100. pmac_id:2,
  101. mcast_pkt_ctrl:2,
  102. dscp_tid_map_id:6,
  103. reserved:7;
  104. };
  105. uint32_t val;
  106. };
  107. /**
  108. * struct hal_tx_cmn_config_ppe - SW config exception related parameters
  109. * @drop_prec_err - Exception drop_prec errors.
  110. * @fake_mac_hdr - Exception fake mac header.
  111. * @cpu_code_inv - Exception cpu code invalid.
  112. * @data_buff_err - Exception buffer length/offset erorors.
  113. * @l3_l4_err - Exception m3_l4 checksum errors
  114. * @data_offset_max - Maximum data offset allowed.
  115. * @data_len_max - Maximum data length allowed.
  116. */
  117. union hal_tx_cmn_config_ppe {
  118. struct {
  119. uint32_t drop_prec_err:1,
  120. fake_mac_hdr:1,
  121. cpu_code_inv:1,
  122. data_buff_err:1,
  123. l3_l4_err:1,
  124. data_offset_max:12,
  125. data_len_max:14;
  126. };
  127. uint32_t val;
  128. };
  129. /**
  130. * hal_tx_ppe_vp_config - SW config PPE VP table
  131. * @vp_num - Virtual port number
  132. * @pmac_id - Lmac ID
  133. * @bank_id: Bank ID corresponding to this I/F.
  134. * @vdev_id: VDEV ID of the I/F.
  135. * @search_idx_reg_num: Register number of this SI.
  136. * @use_ppe_int_pri: Use the PPE INT_PRI to TID table
  137. * @to_fw: Use FW
  138. * @drop_prec_enable: Enable precedence drop.
  139. */
  140. union hal_tx_ppe_vp_config {
  141. struct {
  142. uint32_t vp_num:8,
  143. pmac_id:2,
  144. bank_id:6,
  145. vdev_id:8,
  146. search_idx_reg_num:3,
  147. use_ppe_int_pri:1,
  148. to_fw:1,
  149. drop_prec_enable:1;
  150. };
  151. uint32_t val;
  152. };
  153. /**
  154. * hal_tx_cmn_ppe_idx_map_config: Use ppe index mapping table
  155. * @search_idx: Search index
  156. * @cache_set: Cache set number
  157. */
  158. union hal_tx_ppe_idx_map_config {
  159. struct {
  160. uint32_t search_idx:20,
  161. cache_set:4;
  162. };
  163. uint32_t val;
  164. };
  165. /**
  166. * hal_tx_ppe_pri2tid_map0_config : Configure ppe INT_PRI to tid map
  167. * @int_pri0: INT_PRI_0
  168. * @int_pri1: INT_PRI_1
  169. * @int_pri2: INT_PRI_2
  170. * @int_pri3: INT_PRI_3
  171. * @int_pri4: INT_PRI_4
  172. * @int_pri5: INT_PRI_5
  173. * @int_pri6: INT_PRI_6
  174. * @int_pri7: INT_PRI_7
  175. * @int_pri8: INT_PRI_8
  176. * @int_pri9: INT_PRI_9
  177. */
  178. union hal_tx_ppe_pri2tid_map0_config {
  179. struct {
  180. uint32_t int_pri0:3,
  181. int_pri1:3,
  182. int_pri2:3,
  183. int_pri3:3,
  184. int_pri4:3,
  185. int_pri5:3,
  186. int_pri6:3,
  187. int_pri7:3,
  188. int_pri8:3,
  189. int_pri9:3;
  190. };
  191. uint32_t val;
  192. };
  193. /**
  194. * hal_tx_ppe_pri2tid_map1_config : Configure ppe INT_PRI to tid map
  195. * @int_pri0: INT_PRI_10
  196. * @int_pri1: INT_PRI_11
  197. * @int_pri2: INT_PRI_12
  198. * @int_pri3: INT_PRI_13
  199. * @int_pri4: INT_PRI_14
  200. * @int_pri5: INT_PRI_15
  201. */
  202. union hal_tx_ppe_pri2tid_map1_config {
  203. struct {
  204. uint32_t int_pri10:3,
  205. int_pri11:3,
  206. int_pri12:3,
  207. int_pri13:3,
  208. int_pri14:3,
  209. int_pri15:3;
  210. };
  211. uint32_t val;
  212. };
  213. /*---------------------------------------------------------------------------
  214. * Function declarations and documentation
  215. * ---------------------------------------------------------------------------
  216. */
  217. /*---------------------------------------------------------------------------
  218. * TCL Descriptor accessor APIs
  219. *---------------------------------------------------------------------------
  220. */
  221. /**
  222. * hal_tx_desc_set_tx_notify_frame - Set TX notify_frame field in Tx desc
  223. * @desc: Handle to Tx Descriptor
  224. * @val: Value to be set
  225. *
  226. * Return: None
  227. */
  228. static inline void hal_tx_desc_set_tx_notify_frame(void *desc,
  229. uint8_t val)
  230. {
  231. HAL_SET_FLD(desc, TCL_DATA_CMD, TX_NOTIFY_FRAME) |=
  232. HAL_TX_SM(TCL_DATA_CMD, TX_NOTIFY_FRAME, val);
  233. }
  234. /**
  235. * hal_tx_desc_set_flow_override_enable - Set flow_override_enable field
  236. * @desc: Handle to Tx Descriptor
  237. * @val: Value to be set
  238. *
  239. * Return: None
  240. */
  241. static inline void hal_tx_desc_set_flow_override_enable(void *desc,
  242. uint8_t val)
  243. {
  244. HAL_SET_FLD(desc, TCL_DATA_CMD, FLOW_OVERRIDE_ENABLE) |=
  245. HAL_TX_SM(TCL_DATA_CMD, FLOW_OVERRIDE_ENABLE, val);
  246. }
  247. /**
  248. * hal_tx_desc_set_flow_override - Set flow_override field in TX desc
  249. * @desc: Handle to Tx Descriptor
  250. * @val: Value to be set
  251. *
  252. * Return: None
  253. */
  254. static inline void hal_tx_desc_set_flow_override(void *desc,
  255. uint8_t val)
  256. {
  257. HAL_SET_FLD(desc, TCL_DATA_CMD, FLOW_OVERRIDE) |=
  258. HAL_TX_SM(TCL_DATA_CMD, FLOW_OVERRIDE, val);
  259. }
  260. /**
  261. * hal_tx_desc_set_who_classify_info_sel - Set who_classify_info_sel field
  262. * @desc: Handle to Tx Descriptor
  263. * @val: Value to be set
  264. *
  265. * Return: None
  266. */
  267. static inline void hal_tx_desc_set_who_classify_info_sel(void *desc,
  268. uint8_t val)
  269. {
  270. HAL_SET_FLD(desc, TCL_DATA_CMD, WHO_CLASSIFY_INFO_SEL) |=
  271. HAL_TX_SM(TCL_DATA_CMD, WHO_CLASSIFY_INFO_SEL, val);
  272. }
  273. /**
  274. * hal_tx_desc_set_buf_length - Set Data length in bytes in Tx Descriptor
  275. * @desc: Handle to Tx Descriptor
  276. * @data_length: MSDU length in case of direct descriptor.
  277. * Length of link extension descriptor in case of Link extension
  278. * descriptor.Includes the length of Metadata
  279. * Return: None
  280. */
  281. static inline void hal_tx_desc_set_buf_length(void *desc,
  282. uint16_t data_length)
  283. {
  284. HAL_SET_FLD(desc, TCL_DATA_CMD, DATA_LENGTH) |=
  285. HAL_TX_SM(TCL_DATA_CMD, DATA_LENGTH, data_length);
  286. }
  287. /**
  288. * hal_tx_desc_set_buf_offset - Sets Packet Offset field in Tx descriptor
  289. * @desc: Handle to Tx Descriptor
  290. * @offset: Packet offset from Metadata in case of direct buffer descriptor.
  291. *
  292. * Return: void
  293. */
  294. static inline void hal_tx_desc_set_buf_offset(void *desc,
  295. uint8_t offset)
  296. {
  297. HAL_SET_FLD(desc, TCL_DATA_CMD, PACKET_OFFSET) |=
  298. HAL_TX_SM(TCL_DATA_CMD, PACKET_OFFSET, offset);
  299. }
  300. /**
  301. * hal_tx_desc_set_l4_checksum_en - Set TCP/IP checksum enable flags
  302. * Tx Descriptor for MSDU_buffer type
  303. * @desc: Handle to Tx Descriptor
  304. * @en: UDP/TCP over ipv4/ipv6 checksum enable flags (5 bits)
  305. *
  306. * Return: void
  307. */
  308. static inline void hal_tx_desc_set_l4_checksum_en(void *desc,
  309. uint8_t en)
  310. {
  311. HAL_SET_FLD(desc, TCL_DATA_CMD, IPV4_CHECKSUM_EN) |=
  312. (HAL_TX_SM(TCL_DATA_CMD, UDP_OVER_IPV4_CHECKSUM_EN, en) |
  313. HAL_TX_SM(TCL_DATA_CMD, UDP_OVER_IPV6_CHECKSUM_EN, en) |
  314. HAL_TX_SM(TCL_DATA_CMD, TCP_OVER_IPV4_CHECKSUM_EN, en) |
  315. HAL_TX_SM(TCL_DATA_CMD, TCP_OVER_IPV6_CHECKSUM_EN, en));
  316. }
  317. /**
  318. * hal_tx_desc_set_l3_checksum_en - Set IPv4 checksum enable flag in
  319. * Tx Descriptor for MSDU_buffer type
  320. * @desc: Handle to Tx Descriptor
  321. * @checksum_en_flags: ipv4 checksum enable flags
  322. *
  323. * Return: void
  324. */
  325. static inline void hal_tx_desc_set_l3_checksum_en(void *desc,
  326. uint8_t en)
  327. {
  328. HAL_SET_FLD(desc, TCL_DATA_CMD, IPV4_CHECKSUM_EN) |=
  329. HAL_TX_SM(TCL_DATA_CMD, IPV4_CHECKSUM_EN, en);
  330. }
  331. /**
  332. * hal_tx_desc_set_fw_metadata- Sets the metadata that is part of TCL descriptor
  333. * @desc:Handle to Tx Descriptor
  334. * @metadata: Metadata to be sent to Firmware
  335. *
  336. * Return: void
  337. */
  338. static inline void hal_tx_desc_set_fw_metadata(void *desc,
  339. uint16_t metadata)
  340. {
  341. HAL_SET_FLD(desc, TCL_DATA_CMD, TCL_CMD_NUMBER) |=
  342. HAL_TX_SM(TCL_DATA_CMD, TCL_CMD_NUMBER, metadata);
  343. }
  344. /**
  345. * hal_tx_desc_set_to_fw - Set To_FW bit in Tx Descriptor.
  346. * @desc:Handle to Tx Descriptor
  347. * @to_fw: if set, Forward packet to FW along with classification result
  348. *
  349. * Return: void
  350. */
  351. static inline void hal_tx_desc_set_to_fw(void *desc, uint8_t to_fw)
  352. {
  353. HAL_SET_FLD(desc, TCL_DATA_CMD, TO_FW) |=
  354. HAL_TX_SM(TCL_DATA_CMD, TO_FW, to_fw);
  355. }
  356. /**
  357. * hal_tx_desc_set_hlos_tid - Set the TID value (override DSCP/PCP fields in
  358. * frame) to be used for Tx Frame
  359. * @desc: Handle to Tx Descriptor
  360. * @hlos_tid: HLOS TID
  361. *
  362. * Return: void
  363. */
  364. static inline void hal_tx_desc_set_hlos_tid(void *desc,
  365. uint8_t hlos_tid)
  366. {
  367. HAL_SET_FLD(desc, TCL_DATA_CMD, HLOS_TID) |=
  368. HAL_TX_SM(TCL_DATA_CMD, HLOS_TID, hlos_tid);
  369. HAL_SET_FLD(desc, TCL_DATA_CMD, HLOS_TID_OVERWRITE) |=
  370. HAL_TX_SM(TCL_DATA_CMD, HLOS_TID_OVERWRITE, 1);
  371. }
  372. /**
  373. * hal_tx_desc_sync - Commit the descriptor to Hardware
  374. * @hal_tx_des_cached: Cached descriptor that software maintains
  375. * @hw_desc: Hardware descriptor to be updated
  376. */
  377. static inline void hal_tx_desc_sync(void *hal_tx_desc_cached,
  378. void *hw_desc, uint8_t num_bytes)
  379. {
  380. qdf_mem_copy(hw_desc, hal_tx_desc_cached, num_bytes);
  381. }
  382. /**
  383. * hal_tx_desc_set_vdev_id - set vdev id to the descriptor to Hardware
  384. * @hal_tx_des_cached: Cached descriptor that software maintains
  385. * @vdev_id: vdev id
  386. */
  387. static inline void hal_tx_desc_set_vdev_id(void *desc, uint8_t vdev_id)
  388. {
  389. HAL_SET_FLD(desc, TCL_DATA_CMD, VDEV_ID) |=
  390. HAL_TX_SM(TCL_DATA_CMD, VDEV_ID, vdev_id);
  391. }
  392. /**
  393. * hal_tx_desc_set_bank_id - set bank id to the descriptor to Hardware
  394. * @hal_tx_des_cached: Cached descriptor that software maintains
  395. * @bank_id: bank id
  396. */
  397. static inline void hal_tx_desc_set_bank_id(void *desc, uint8_t bank_id)
  398. {
  399. HAL_SET_FLD(desc, TCL_DATA_CMD, BANK_ID) |=
  400. HAL_TX_SM(TCL_DATA_CMD, BANK_ID, bank_id);
  401. }
  402. /**
  403. * hal_tx_desc_set_tcl_cmd_type - set tcl command type to the descriptor
  404. * to Hardware
  405. * @hal_tx_des_cached: Cached descriptor that software maintains
  406. * @tcl_cmd_type: tcl command type
  407. */
  408. static inline void
  409. hal_tx_desc_set_tcl_cmd_type(void *desc, uint8_t tcl_cmd_type)
  410. {
  411. HAL_SET_FLD(desc, TCL_DATA_CMD, TCL_CMD_TYPE) |=
  412. HAL_TX_SM(TCL_DATA_CMD, TCL_CMD_TYPE, tcl_cmd_type);
  413. }
  414. /**
  415. * hal_tx_desc_set_lmac_id_be - set lmac id to the descriptor to Hardware
  416. * @hal_soc_hdl: hal soc handle
  417. * @hal_tx_des_cached: Cached descriptor that software maintains
  418. * @lmac_id: lmac id
  419. */
  420. static inline void
  421. hal_tx_desc_set_lmac_id_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  422. uint8_t lmac_id)
  423. {
  424. HAL_SET_FLD(desc, TCL_DATA_CMD, PMAC_ID) |=
  425. HAL_TX_SM(TCL_DATA_CMD, PMAC_ID, lmac_id);
  426. }
  427. /**
  428. * hal_tx_desc_set_search_index_be - set search index to the
  429. * descriptor to Hardware
  430. * @hal_soc_hdl: hal soc handle
  431. * @hal_tx_des_cached: Cached descriptor that software maintains
  432. * @search_index: search index
  433. */
  434. static inline void
  435. hal_tx_desc_set_search_index_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  436. uint32_t search_index)
  437. {
  438. HAL_SET_FLD(desc, TCL_DATA_CMD, SEARCH_INDEX) |=
  439. HAL_TX_SM(TCL_DATA_CMD, SEARCH_INDEX, search_index);
  440. }
  441. /**
  442. * hal_tx_desc_set_cache_set_num - set cache set num to the
  443. * descriptor to Hardware
  444. * @hal_soc_hdl: hal soc handle
  445. * @hal_tx_des_cached: Cached descriptor that software maintains
  446. * @cache_num: cache number
  447. */
  448. static inline void
  449. hal_tx_desc_set_cache_set_num(hal_soc_handle_t hal_soc_hdl, void *desc,
  450. uint8_t cache_num)
  451. {
  452. HAL_SET_FLD(desc, TCL_DATA_CMD, CACHE_SET_NUM) |=
  453. HAL_TX_SM(TCL_DATA_CMD, CACHE_SET_NUM, cache_num);
  454. }
  455. /**
  456. * hal_tx_desc_set_lookup_override_num - set lookup override num
  457. * to the descriptor to Hardware
  458. * @hal_soc_hdl: hal soc handle
  459. * @hal_tx_des_cached: Cached descriptor that software maintains
  460. * @cache_num: set numbernumber
  461. */
  462. static inline void
  463. hal_tx_desc_set_index_lookup_override(hal_soc_handle_t hal_soc_hdl,
  464. void *desc, uint8_t num)
  465. {
  466. HAL_SET_FLD(desc, TCL_DATA_CMD, INDEX_LOOKUP_OVERRIDE) |=
  467. HAL_TX_SM(TCL_DATA_CMD, INDEX_LOOKUP_OVERRIDE, num);
  468. }
  469. /*---------------------------------------------------------------------------
  470. * WBM Descriptor accessor APIs for Tx completions
  471. * ---------------------------------------------------------------------------
  472. */
  473. /**
  474. * hal_tx_get_wbm_sw0_bm_id() - Get the BM ID for first tx completion ring
  475. *
  476. * Return: BM ID for first tx completion ring
  477. */
  478. static inline uint32_t hal_tx_get_wbm_sw0_bm_id(void)
  479. {
  480. return HAL_BE_WBM_SW0_BM_ID;
  481. }
  482. /**
  483. * hal_tx_comp_get_desc_id() - Get TX descriptor id within comp descriptor
  484. * @hal_desc: completion ring descriptor pointer
  485. *
  486. * This function will tx descriptor id, cookie, within hardware completion
  487. * descriptor. For cases when cookie conversion is disabled, the sw_cookie
  488. * is present in the 2nd DWORD.
  489. *
  490. * Return: cookie
  491. */
  492. static inline uint32_t hal_tx_comp_get_desc_id(void *hal_desc)
  493. {
  494. uint32_t comp_desc =
  495. *(uint32_t *)(((uint8_t *)hal_desc) +
  496. BUFFER_ADDR_INFO_SW_BUFFER_COOKIE_OFFSET);
  497. /* Cookie is placed on 2nd word */
  498. return (comp_desc & BUFFER_ADDR_INFO_SW_BUFFER_COOKIE_MASK) >>
  499. BUFFER_ADDR_INFO_SW_BUFFER_COOKIE_LSB;
  500. }
  501. /**
  502. * hal_tx_comp_get_paddr() - Get paddr within comp descriptor
  503. * @hal_desc: completion ring descriptor pointer
  504. *
  505. * This function will get buffer physical address within hardware completion
  506. * descriptor
  507. *
  508. * Return: Buffer physical address
  509. */
  510. static inline qdf_dma_addr_t hal_tx_comp_get_paddr(void *hal_desc)
  511. {
  512. uint32_t paddr_lo;
  513. uint32_t paddr_hi;
  514. paddr_lo = *(uint32_t *)(((uint8_t *)hal_desc) +
  515. BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_OFFSET);
  516. paddr_hi = *(uint32_t *)(((uint8_t *)hal_desc) +
  517. BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_OFFSET);
  518. paddr_hi = (paddr_hi & BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_MASK) >>
  519. BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_LSB;
  520. return (qdf_dma_addr_t)(paddr_lo | (((uint64_t)paddr_hi) << 32));
  521. }
  522. #ifdef DP_HW_COOKIE_CONVERT_EXCEPTION
  523. /* HW set dowrd-2 bit30 to 1 if HW CC is done */
  524. #define HAL_WBM2SW_COMPLETION_RING_TX_CC_DONE_OFFSET 0x8
  525. #define HAL_WBM2SW_COMPLETION_RING_TX_CC_DONE_MASK 0x40000000
  526. #define HAL_WBM2SW_COMPLETION_RING_TX_CC_DONE_LSB 0x1E
  527. /**
  528. * hal_tx_comp_get_cookie_convert_done() - Get cookie conversion done flag
  529. * @hal_desc: completion ring descriptor pointer
  530. *
  531. * This function will get the bit value that indicate HW cookie
  532. * conversion done or not
  533. *
  534. * Return: 1 - HW cookie conversion done, 0 - not
  535. */
  536. static inline uint8_t hal_tx_comp_get_cookie_convert_done(void *hal_desc)
  537. {
  538. return HAL_TX_DESC_GET(hal_desc, HAL_WBM2SW_COMPLETION_RING_TX,
  539. CC_DONE);
  540. }
  541. #endif
  542. /**
  543. * hal_tx_comp_set_desc_va_63_32() - Set bit 32~63 value for 64 bit VA
  544. * @hal_desc: completion ring descriptor pointer
  545. * @val: value to be set
  546. *
  547. * Return: None
  548. */
  549. static inline void hal_tx_comp_set_desc_va_63_32(void *hal_desc, uint32_t val)
  550. {
  551. HAL_SET_FLD(hal_desc,
  552. WBM2SW_COMPLETION_RING_TX,
  553. BUFFER_VIRT_ADDR_63_32) = val;
  554. }
  555. /**
  556. * hal_tx_comp_get_desc_va() - Get Desc virtual address within completion Desc
  557. * @hal_desc: completion ring descriptor pointer
  558. *
  559. * This function will get the TX Desc virtual address
  560. *
  561. * Return: TX desc virtual address
  562. */
  563. static inline uint64_t hal_tx_comp_get_desc_va(void *hal_desc)
  564. {
  565. uint64_t va_from_desc;
  566. va_from_desc = HAL_TX_DESC_GET(hal_desc,
  567. WBM2SW_COMPLETION_RING_TX,
  568. BUFFER_VIRT_ADDR_31_0) |
  569. (((uint64_t)HAL_TX_DESC_GET(
  570. hal_desc,
  571. WBM2SW_COMPLETION_RING_TX,
  572. BUFFER_VIRT_ADDR_63_32)) << 32);
  573. return va_from_desc;
  574. }
  575. /*---------------------------------------------------------------------------
  576. * TX BANK register accessor APIs
  577. * ---------------------------------------------------------------------------
  578. */
  579. /**
  580. * hal_tx_get_num_tcl_banks() - Get number of banks for target
  581. *
  582. * Return: None
  583. */
  584. static inline uint8_t
  585. hal_tx_get_num_tcl_banks(hal_soc_handle_t hal_soc_hdl)
  586. {
  587. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  588. int hal_banks = 0;
  589. if (hal_soc->ops->hal_tx_get_num_tcl_banks) {
  590. hal_banks = hal_soc->ops->hal_tx_get_num_tcl_banks();
  591. hal_banks -= HAL_TX_NUM_RESERVED_BANKS;
  592. hal_banks = (hal_banks < 0) ? 0 : hal_banks;
  593. }
  594. return hal_banks;
  595. }
  596. /**
  597. * hal_tx_populate_bank_register() - populate the bank register with
  598. * the software configs.
  599. * @soc: HAL soc handle
  600. * @config: bank config
  601. * @bank_id: bank id to be configured
  602. *
  603. * Returns: None
  604. */
  605. static inline void
  606. hal_tx_populate_bank_register(hal_soc_handle_t hal_soc_hdl,
  607. union hal_tx_bank_config *config,
  608. uint8_t bank_id)
  609. {
  610. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  611. hal_soc->ops->hal_tx_populate_bank_register(hal_soc_hdl, config,
  612. bank_id);
  613. }
  614. #ifdef DP_TX_IMPLICIT_RBM_MAPPING
  615. #define RBM_MAPPING_BMSK HWIO_TCL_R0_RBM_MAPPING0_SW2TCL1_RING_BMSK
  616. #define RBM_MAPPING_SHFT HWIO_TCL_R0_RBM_MAPPING0_SW2TCL2_RING_SHFT
  617. #define RBM_PPE2TCL_OFFSET \
  618. (HWIO_TCL_R0_RBM_MAPPING0_PPE2TCL1_RING_SHFT >> 2)
  619. #define RBM_TCL_CMD_CREDIT_OFFSET \
  620. (HWIO_TCL_R0_RBM_MAPPING0_SW2TCL_CREDIT_RING_SHFT >> 2)
  621. /**
  622. * hal_tx_config_rbm_mapping_be() - Update return buffer manager ring id
  623. * @hal_soc: HAL SoC context
  624. * @hal_ring_hdl: Source ring pointer
  625. * @rbm_id: return buffer manager ring id
  626. *
  627. * Return: void
  628. */
  629. static inline void
  630. hal_tx_config_rbm_mapping_be(hal_soc_handle_t hal_soc_hdl,
  631. hal_ring_handle_t hal_ring_hdl,
  632. uint8_t rbm_id)
  633. {
  634. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  635. hal_soc->ops->hal_tx_config_rbm_mapping_be(hal_soc_hdl, hal_ring_hdl,
  636. rbm_id);
  637. }
  638. #else
  639. static inline void
  640. hal_tx_config_rbm_mapping_be(hal_soc_handle_t hal_soc_hdl,
  641. hal_ring_handle_t hal_ring_hdl,
  642. uint8_t rbm_id)
  643. {
  644. }
  645. #endif
  646. /**
  647. * hal_tx_desc_set_buf_addr_be - Fill Buffer Address information in Tx Desc
  648. * @desc: Handle to Tx Descriptor
  649. * @paddr: Physical Address
  650. * @pool_id: Return Buffer Manager ID
  651. * @desc_id: Descriptor ID
  652. * @type: 0 - Address points to a MSDU buffer
  653. * 1 - Address points to MSDU extension descriptor
  654. *
  655. * Return: void
  656. */
  657. #ifdef DP_TX_IMPLICIT_RBM_MAPPING
  658. static inline void
  659. hal_tx_desc_set_buf_addr_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  660. dma_addr_t paddr, uint8_t rbm_id,
  661. uint32_t desc_id, uint8_t type)
  662. {
  663. /* Set buffer_addr_info.buffer_addr_31_0 */
  664. HAL_SET_FLD(desc, TCL_DATA_CMD,
  665. BUF_ADDR_INFO_BUFFER_ADDR_31_0) =
  666. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_31_0, paddr);
  667. /* Set buffer_addr_info.buffer_addr_39_32 */
  668. HAL_SET_FLD(desc, TCL_DATA_CMD,
  669. BUF_ADDR_INFO_BUFFER_ADDR_39_32) |=
  670. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_39_32,
  671. (((uint64_t)paddr) >> 32));
  672. /* Set buffer_addr_info.sw_buffer_cookie = desc_id */
  673. HAL_SET_FLD(desc, TCL_DATA_CMD,
  674. BUF_ADDR_INFO_SW_BUFFER_COOKIE) |=
  675. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_SW_BUFFER_COOKIE,
  676. desc_id);
  677. /* Set Buffer or Ext Descriptor Type */
  678. HAL_SET_FLD(desc, TCL_DATA_CMD,
  679. BUF_OR_EXT_DESC_TYPE) |=
  680. HAL_TX_SM(TCL_DATA_CMD, BUF_OR_EXT_DESC_TYPE, type);
  681. }
  682. #else
  683. static inline void
  684. hal_tx_desc_set_buf_addr_be(hal_soc_handle_t hal_soc_hdl, void *desc,
  685. dma_addr_t paddr, uint8_t rbm_id,
  686. uint32_t desc_id, uint8_t type)
  687. {
  688. /* Set buffer_addr_info.buffer_addr_31_0 */
  689. HAL_SET_FLD(desc, TCL_DATA_CMD,
  690. BUF_ADDR_INFO_BUFFER_ADDR_31_0) =
  691. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_31_0, paddr);
  692. /* Set buffer_addr_info.buffer_addr_39_32 */
  693. HAL_SET_FLD(desc, TCL_DATA_CMD,
  694. BUF_ADDR_INFO_BUFFER_ADDR_39_32) |=
  695. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_BUFFER_ADDR_39_32,
  696. (((uint64_t)paddr) >> 32));
  697. /* Set buffer_addr_info.return_buffer_manager = rbm id */
  698. HAL_SET_FLD(desc, TCL_DATA_CMD,
  699. BUF_ADDR_INFO_RETURN_BUFFER_MANAGER) |=
  700. HAL_TX_SM(TCL_DATA_CMD,
  701. BUF_ADDR_INFO_RETURN_BUFFER_MANAGER, rbm_id);
  702. /* Set buffer_addr_info.sw_buffer_cookie = desc_id */
  703. HAL_SET_FLD(desc, TCL_DATA_CMD,
  704. BUF_ADDR_INFO_SW_BUFFER_COOKIE) |=
  705. HAL_TX_SM(TCL_DATA_CMD, BUF_ADDR_INFO_SW_BUFFER_COOKIE,
  706. desc_id);
  707. /* Set Buffer or Ext Descriptor Type */
  708. HAL_SET_FLD(desc, TCL_DATA_CMD,
  709. BUF_OR_EXT_DESC_TYPE) |=
  710. HAL_TX_SM(TCL_DATA_CMD, BUF_OR_EXT_DESC_TYPE, type);
  711. }
  712. #endif
  713. /**
  714. * hal_tx_vdev_mismatch_routing_set - set vdev mismatch exception routing
  715. * @hal_soc: HAL SoC context
  716. * @config: HAL_TX_VDEV_MISMATCH_TQM_NOTIFY - route via TQM
  717. * HAL_TX_VDEV_MISMATCH_FW_NOTIFY - route via FW
  718. *
  719. * Return: void
  720. */
  721. #ifdef HWIO_TCL_R0_CMN_CONFIG_VDEVID_MISMATCH_EXCEPTION_BMSK
  722. static inline void
  723. hal_tx_vdev_mismatch_routing_set(hal_soc_handle_t hal_soc_hdl,
  724. enum hal_tx_vdev_mismatch_notify config)
  725. {
  726. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  727. hal_soc->ops->hal_tx_vdev_mismatch_routing_set(hal_soc_hdl, config);
  728. }
  729. #else
  730. static inline void
  731. hal_tx_vdev_mismatch_routing_set(hal_soc_handle_t hal_soc_hdl,
  732. enum hal_tx_vdev_mismatch_notify config)
  733. {
  734. }
  735. #endif
  736. /**
  737. * hal_tx_mcast_mlo_reinject_routing_set - set MLO multicast reinject routing
  738. * @hal_soc: HAL SoC context
  739. * @config: HAL_TX_MCAST_MLO_REINJECT_FW_NOTIFY - route via FW
  740. * HAL_TX_MCAST_MLO_REINJECT_TQM_NOTIFY - route via TQM
  741. *
  742. * Return: void
  743. */
  744. #if defined(HWIO_TCL_R0_CMN_CONFIG_MCAST_CMN_PN_SN_MLO_REINJECT_ENABLE_BMSK) && \
  745. defined(WLAN_MCAST_MLO)
  746. static inline void
  747. hal_tx_mcast_mlo_reinject_routing_set(
  748. hal_soc_handle_t hal_soc_hdl,
  749. enum hal_tx_mcast_mlo_reinject_notify config)
  750. {
  751. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  752. hal_soc->ops->hal_tx_mcast_mlo_reinject_routing_set(hal_soc_hdl,
  753. config);
  754. }
  755. #else
  756. static inline void
  757. hal_tx_mcast_mlo_reinject_routing_set(
  758. hal_soc_handle_t hal_soc_hdl,
  759. enum hal_tx_mcast_mlo_reinject_notify config)
  760. {
  761. }
  762. #endif
  763. /*
  764. * hal_reo_config_reo2ppe_dest_info() - Configure reo2ppe dest info
  765. * @hal_soc_hdl: HAL SoC Context
  766. *
  767. * Return: None.
  768. */
  769. static inline
  770. void hal_reo_config_reo2ppe_dest_info(hal_soc_handle_t hal_soc_hdl)
  771. {
  772. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  773. if (hal_soc->ops->hal_reo_config_reo2ppe_dest_info)
  774. hal_soc->ops->hal_reo_config_reo2ppe_dest_info(hal_soc_hdl);
  775. }
  776. /*
  777. * hal_tx_get_num_ppe_vp_tbl_entries() - Get the total number of VP table
  778. * @hal_soc: HAL SoC Context
  779. *
  780. * Return: Total number of entries.
  781. */
  782. static inline
  783. uint32_t hal_tx_get_num_ppe_vp_tbl_entries(hal_soc_handle_t hal_soc_hdl)
  784. {
  785. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  786. return hal_soc->ops->hal_tx_get_num_ppe_vp_tbl_entries(hal_soc_hdl);
  787. }
  788. /**
  789. * hal_tx_set_ppe_cmn_cfg()- Set the PPE common config
  790. * @hal_soc: HAL SoC context
  791. * @cmn_cfg: HAL PPE VP common config
  792. *
  793. * Return: void
  794. */
  795. static inline void
  796. hal_tx_set_ppe_cmn_cfg(hal_soc_handle_t hal_soc_hdl,
  797. union hal_tx_cmn_config_ppe *cmn_cfg)
  798. {
  799. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  800. hal_soc->ops->hal_tx_set_ppe_cmn_cfg(hal_soc_hdl, cmn_cfg);
  801. }
  802. /**
  803. * hal_tx_populate_ppe_vp_entry - Populate ppe VP entry
  804. * @hal_soc: HAL SoC context
  805. * @vp_cfg: HAL PPE VP config
  806. * @ppe_vp_idx: PPE VP index
  807. *
  808. * Return: void
  809. */
  810. static inline void
  811. hal_tx_populate_ppe_vp_entry(hal_soc_handle_t hal_soc_hdl,
  812. union hal_tx_ppe_vp_config *vp_cfg,
  813. int ppe_vp_idx)
  814. {
  815. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  816. hal_soc->ops->hal_tx_set_ppe_vp_entry(hal_soc_hdl, vp_cfg, ppe_vp_idx);
  817. }
  818. /**
  819. * hal_ppeds_cfg_ast_override_map_reg - Set ppe index mapping table value
  820. * @hal_soc: HAL SoC context
  821. * @reg_idx: index into the table
  822. * @overide_map: HAL PPE INDEX MAPPING config
  823. *
  824. * Return: void
  825. */
  826. static inline void
  827. hal_ppeds_cfg_ast_override_map_reg(hal_soc_handle_t hal_soc_hdl,
  828. uint8_t reg_idx, union hal_tx_ppe_idx_map_config *overide_map)
  829. {
  830. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  831. if (hal_soc->ops->hal_ppeds_cfg_ast_override_map_reg)
  832. hal_soc->ops->hal_ppeds_cfg_ast_override_map_reg(hal_soc_hdl,
  833. reg_idx,
  834. overide_map);
  835. }
  836. /**
  837. * hal_tx_set_int_pri2id - Set the prit2tid table.
  838. * @hal_soc: HAL SoC context
  839. * @pri2tid: Reference to SW INT_PRI to TID table
  840. *
  841. * Return: void
  842. */
  843. static inline void
  844. hal_tx_set_int_pri2tid(hal_soc_handle_t hal_soc_hdl,
  845. uint32_t val, uint8_t map_no)
  846. {
  847. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  848. hal_soc->ops->hal_tx_set_ppe_pri2tid(hal_soc_hdl, val, map_no);
  849. }
  850. /**
  851. * hal_tx_update_int_pri2id - Populate the prit2tid table.
  852. * @hal_soc: HAL SoC context
  853. * @pri: INT_PRI value
  854. * @tid: Wi-Fi TID
  855. *
  856. * Return: void
  857. */
  858. static inline void
  859. hal_tx_update_int_pri2tid(hal_soc_handle_t hal_soc_hdl,
  860. uint8_t pri, uint8_t tid)
  861. {
  862. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  863. hal_soc->ops->hal_tx_update_ppe_pri2tid(hal_soc_hdl, pri, tid);
  864. }
  865. /**
  866. * hal_tx_dump_ppe_vp_entry - Dump the PPE VP entry
  867. * @hal_soc_hdl: HAL SoC context
  868. *
  869. * Return: void
  870. */
  871. static inline void
  872. hal_tx_dump_ppe_vp_entry(hal_soc_handle_t hal_soc_hdl)
  873. {
  874. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  875. hal_soc->ops->hal_tx_dump_ppe_vp_entry(hal_soc_hdl);
  876. }
  877. /**
  878. * hal_tx_enable_pri2tid_map- Enable the priority to tid mapping
  879. * @hal_soc_hdl: HAL SoC context
  880. * @val: True/False value
  881. *
  882. * Return: void
  883. */
  884. static inline void
  885. hal_tx_enable_pri2tid_map(hal_soc_handle_t hal_soc_hdl, bool val,
  886. uint8_t ppe_vp_idx)
  887. {
  888. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  889. hal_soc->ops->hal_tx_enable_pri2tid_map(hal_soc_hdl, val,
  890. ppe_vp_idx);
  891. }
  892. #ifdef HWIO_TCL_R0_VDEV_MCAST_PACKET_CTRL_MAP_n_VAL_SHFT
  893. static inline void
  894. hal_tx_vdev_mcast_ctrl_set(hal_soc_handle_t hal_soc_hdl,
  895. uint8_t vdev_id, uint8_t mcast_ctrl_val)
  896. {
  897. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  898. hal_soc->ops->hal_tx_vdev_mcast_ctrl_set(hal_soc_hdl, vdev_id,
  899. mcast_ctrl_val);
  900. }
  901. #else
  902. static inline void
  903. hal_tx_vdev_mcast_ctrl_set(hal_soc_handle_t hal_soc_hdl,
  904. uint8_t vdev_id, uint8_t mcast_ctrl_val)
  905. {
  906. }
  907. #endif
  908. #endif /* _HAL_BE_TX_H_ */