hal_rh_tx.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 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_RH_TX_H_
  20. #define _HAL_RH_TX_H_
  21. /*---------------------------------------------------------------------------
  22. * Function declarations and documentation
  23. * ---------------------------------------------------------------------------
  24. */
  25. /*---------------------------------------------------------------------------
  26. * TCL Descriptor accessor APIs
  27. * ---------------------------------------------------------------------------
  28. */
  29. /**
  30. * hal_tx_desc_set_buf_addr - Fill Buffer Address information in Tx Descriptor
  31. * @hal_soc_hdl: HAL SOC handle
  32. * @desc: Handle to Tx Descriptor
  33. * @paddr: Physical Address
  34. * @pool_id: Return Buffer Manager ID
  35. * @desc_id: Descriptor ID
  36. * @type: 0 - Address points to a MSDU buffer
  37. * 1 - Address points to MSDU extension descriptor
  38. *
  39. * Return: void
  40. */
  41. static inline
  42. void hal_tx_desc_set_buf_addr(hal_soc_handle_t hal_soc_hdl, void *desc,
  43. dma_addr_t paddr,
  44. uint8_t pool_id, uint32_t desc_id,
  45. uint8_t type)
  46. {
  47. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  48. hal_soc->ops->hal_tx_desc_set_buf_addr(desc, paddr, pool_id,
  49. desc_id, type);
  50. }
  51. /**
  52. * hal_tx_desc_set_lmac_id - Set the lmac_id value
  53. * @hal_soc_hdl: HAL SOC handle
  54. * @desc: Handle to Tx Descriptor
  55. * @lmac_id: mac Id to ast matching
  56. * b00 – mac 0
  57. * b01 – mac 1
  58. * b10 – mac 2
  59. * b11 – all macs (legacy HK way)
  60. *
  61. * Return: void
  62. */
  63. static inline void hal_tx_desc_set_lmac_id(hal_soc_handle_t hal_soc_hdl,
  64. void *desc, uint8_t lmac_id)
  65. {
  66. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  67. hal_soc->ops->hal_tx_desc_set_lmac_id(desc, lmac_id);
  68. }
  69. /**
  70. * hal_tx_desc_set_search_type - Set the search type value
  71. * @hal_soc_hdl: HAL SOC handle
  72. * @desc: Handle to Tx Descriptor
  73. * @search_type: search type
  74. * 0 – Normal search
  75. * 1 – Index based address search
  76. * 2 – Index based flow search
  77. *
  78. * Return: void
  79. */
  80. static inline void hal_tx_desc_set_search_type(hal_soc_handle_t hal_soc_hdl,
  81. void *desc,
  82. uint8_t search_type)
  83. {
  84. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  85. hal_soc->ops->hal_tx_desc_set_search_type(desc, search_type);
  86. }
  87. /**
  88. * hal_tx_desc_set_search_index - Set the search index value
  89. * @hal_soc_hdl: HAL SOC handle
  90. * @desc: Handle to Tx Descriptor
  91. * @search_index: The index that will be used for index based address or
  92. * flow search. The field is valid when 'search_type' is
  93. * 1 0r 2
  94. *
  95. * Return: void
  96. */
  97. static inline void hal_tx_desc_set_search_index(hal_soc_handle_t hal_soc_hdl,
  98. void *desc,
  99. uint32_t search_index)
  100. {
  101. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  102. hal_soc->ops->hal_tx_desc_set_search_index(desc, search_index);
  103. }
  104. /**
  105. * hal_tx_desc_set_cache_set_num - Set the cache-set-num value
  106. * @hal_soc_hdl: HAL SOC handle
  107. * @desc: Handle to Tx Descriptor
  108. * @cache_num: Cache set number that should be used to cache the index
  109. * based search results, for address and flow search.
  110. * This value should be equal to LSB four bits of the hash value
  111. * of match data, in case of search index points to an entry
  112. * which may be used in content based search also. The value can
  113. * be anything when the entry pointed by search index will not be
  114. * used for content based search.
  115. *
  116. * Return: void
  117. */
  118. static inline void hal_tx_desc_set_cache_set_num(hal_soc_handle_t hal_soc_hdl,
  119. void *desc,
  120. uint8_t cache_num)
  121. {
  122. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  123. hal_soc->ops->hal_tx_desc_set_cache_set_num(desc, cache_num);
  124. }
  125. /**
  126. * hal_tx_desc_set_buf_length - Set Data length in bytes in Tx Descriptor
  127. * @desc: Handle to Tx Descriptor
  128. * @data_length: MSDU length in case of direct descriptor.
  129. * Length of link extension descriptor in case of Link extension
  130. * descriptor.Includes the length of Metadata
  131. * Return: None
  132. */
  133. static inline void hal_tx_desc_set_buf_length(void *desc,
  134. uint16_t data_length)
  135. {
  136. HAL_SET_FLD(desc, TCL_DATA_CMD_3, DATA_LENGTH) |=
  137. HAL_TX_SM(TCL_DATA_CMD_3, DATA_LENGTH, data_length);
  138. }
  139. /**
  140. * hal_tx_desc_set_buf_offset - Sets Packet Offset field in Tx descriptor
  141. * @desc: Handle to Tx Descriptor
  142. * @offset: Packet offset from Metadata in case of direct buffer descriptor.
  143. *
  144. * Return: void
  145. */
  146. static inline void hal_tx_desc_set_buf_offset(void *desc,
  147. uint8_t offset)
  148. {
  149. HAL_SET_FLD(desc, TCL_DATA_CMD_3, PACKET_OFFSET) |=
  150. HAL_TX_SM(TCL_DATA_CMD_3, PACKET_OFFSET, offset);
  151. }
  152. /**
  153. * hal_tx_desc_set_encap_type - Set encapsulation type in Tx Descriptor
  154. * @desc: Handle to Tx Descriptor
  155. * @encap_type: Encapsulation that HW will perform
  156. *
  157. * Return: void
  158. *
  159. */
  160. static inline void hal_tx_desc_set_encap_type(void *desc,
  161. enum hal_tx_encap_type encap_type)
  162. {
  163. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ENCAP_TYPE) |=
  164. HAL_TX_SM(TCL_DATA_CMD_2, ENCAP_TYPE, encap_type);
  165. }
  166. /**
  167. * hal_tx_desc_set_encrypt_type - Sets the Encrypt Type in Tx Descriptor
  168. * @desc: Handle to Tx Descriptor
  169. * @type: Encrypt Type
  170. *
  171. * Return: void
  172. */
  173. static inline void hal_tx_desc_set_encrypt_type(void *desc,
  174. enum hal_tx_encrypt_type type)
  175. {
  176. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ENCRYPT_TYPE) |=
  177. HAL_TX_SM(TCL_DATA_CMD_2, ENCRYPT_TYPE, type);
  178. }
  179. /**
  180. * hal_tx_desc_set_addr_search_flags - Enable AddrX and AddrY search flags
  181. * @desc: Handle to Tx Descriptor
  182. * @flags: Bit 0 - AddrY search enable, Bit 1 - AddrX search enable
  183. *
  184. * Return: void
  185. */
  186. static inline void hal_tx_desc_set_addr_search_flags(void *desc,
  187. uint8_t flags)
  188. {
  189. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ADDRX_EN) |=
  190. HAL_TX_SM(TCL_DATA_CMD_2, ADDRX_EN, (flags & 0x1));
  191. HAL_SET_FLD(desc, TCL_DATA_CMD_2, ADDRY_EN) |=
  192. HAL_TX_SM(TCL_DATA_CMD_2, ADDRY_EN, (flags >> 1));
  193. }
  194. /**
  195. * hal_tx_desc_set_l4_checksum_en - Set TCP/IP checksum enable flags
  196. * Tx Descriptor for MSDU_buffer type
  197. * @desc: Handle to Tx Descriptor
  198. * @en: UDP/TCP over ipv4/ipv6 checksum enable flags (5 bits)
  199. *
  200. * Return: void
  201. */
  202. static inline void hal_tx_desc_set_l4_checksum_en(void *desc,
  203. uint8_t en)
  204. {
  205. HAL_SET_FLD(desc, TCL_DATA_CMD_3, IPV4_CHECKSUM_EN) |=
  206. (HAL_TX_SM(TCL_DATA_CMD_3, UDP_OVER_IPV4_CHECKSUM_EN, en) |
  207. HAL_TX_SM(TCL_DATA_CMD_3, UDP_OVER_IPV6_CHECKSUM_EN, en) |
  208. HAL_TX_SM(TCL_DATA_CMD_3, TCP_OVER_IPV4_CHECKSUM_EN, en) |
  209. HAL_TX_SM(TCL_DATA_CMD_3, TCP_OVER_IPV6_CHECKSUM_EN, en));
  210. }
  211. /**
  212. * hal_tx_desc_set_l3_checksum_en - Set IPv4 checksum enable flag in
  213. * Tx Descriptor for MSDU_buffer type
  214. * @desc: Handle to Tx Descriptor
  215. * @en: ipv4 checksum enable flags
  216. *
  217. * Return: void
  218. */
  219. static inline void hal_tx_desc_set_l3_checksum_en(void *desc,
  220. uint8_t en)
  221. {
  222. HAL_SET_FLD(desc, TCL_DATA_CMD_3, IPV4_CHECKSUM_EN) |=
  223. HAL_TX_SM(TCL_DATA_CMD_3, IPV4_CHECKSUM_EN, en);
  224. }
  225. /**
  226. * hal_tx_desc_set_fw_metadata- Sets the metadata that is part of TCL descriptor
  227. * @desc:Handle to Tx Descriptor
  228. * @metadata: Metadata to be sent to Firmware
  229. *
  230. * Return: void
  231. */
  232. static inline void hal_tx_desc_set_fw_metadata(void *desc,
  233. uint16_t metadata)
  234. {
  235. HAL_SET_FLD(desc, TCL_DATA_CMD_2, TCL_CMD_NUMBER) |=
  236. HAL_TX_SM(TCL_DATA_CMD_2, TCL_CMD_NUMBER, metadata);
  237. }
  238. /**
  239. * hal_tx_desc_set_to_fw - Set To_FW bit in Tx Descriptor.
  240. * @desc:Handle to Tx Descriptor
  241. * @to_fw: if set, Forward packet to FW along with classification result
  242. *
  243. * Return: void
  244. */
  245. static inline void hal_tx_desc_set_to_fw(void *desc, uint8_t to_fw)
  246. {
  247. HAL_SET_FLD(desc, TCL_DATA_CMD_3, TO_FW) |=
  248. HAL_TX_SM(TCL_DATA_CMD_3, TO_FW, to_fw);
  249. }
  250. /**
  251. * hal_tx_desc_set_mesh_en - Set mesh_enable flag in Tx descriptor
  252. * @hal_soc_hdl: hal soc handle
  253. * @desc: Handle to Tx Descriptor
  254. * @en: For raw WiFi frames, this indicates transmission to a mesh STA,
  255. * enabling the interpretation of the 'Mesh Control Present' bit
  256. * (bit 8) of QoS Control (otherwise this bit is ignored),
  257. * For native WiFi frames, this indicates that a 'Mesh Control' field
  258. * is present between the header and the LLC.
  259. *
  260. * Return: void
  261. */
  262. static inline void hal_tx_desc_set_mesh_en(hal_soc_handle_t hal_soc_hdl,
  263. void *desc, uint8_t en)
  264. {
  265. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  266. hal_soc->ops->hal_tx_desc_set_mesh_en(desc, en);
  267. }
  268. /**
  269. * hal_tx_desc_set_hlos_tid - Set the TID value (override DSCP/PCP fields in
  270. * frame) to be used for Tx Frame
  271. * @desc: Handle to Tx Descriptor
  272. * @hlos_tid: HLOS TID
  273. *
  274. * Return: void
  275. */
  276. static inline void hal_tx_desc_set_hlos_tid(void *desc,
  277. uint8_t hlos_tid)
  278. {
  279. HAL_SET_FLD(desc, TCL_DATA_CMD_4, HLOS_TID) |=
  280. HAL_TX_SM(TCL_DATA_CMD_4, HLOS_TID, hlos_tid);
  281. HAL_SET_FLD(desc, TCL_DATA_CMD_4, HLOS_TID_OVERWRITE) |=
  282. HAL_TX_SM(TCL_DATA_CMD_4, HLOS_TID_OVERWRITE, 1);
  283. }
  284. /**
  285. * hal_tx_desc_clear - Clear the HW descriptor entry
  286. * @hw_desc: Hardware descriptor to be cleared
  287. *
  288. * Return: void
  289. */
  290. static inline void hal_tx_desc_clear(void *hw_desc)
  291. {
  292. qdf_mem_set(hw_desc + sizeof(struct tlv_32_hdr),
  293. HAL_TX_DESC_LEN_BYTES, 0);
  294. }
  295. /**
  296. * hal_tx_desc_sync - Commit the descriptor to Hardware
  297. * @hal_tx_desc_cached: Cached descriptor that software maintains
  298. * @hw_desc: Hardware descriptor to be updated
  299. */
  300. static inline void hal_tx_desc_sync(void *hal_tx_desc_cached,
  301. void *hw_desc)
  302. {
  303. qdf_mem_copy((hw_desc + sizeof(struct tlv_32_hdr)),
  304. hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  305. }
  306. #endif /* _HAL_RH_TX_H_ */