cam.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright(c) 2019-2020 Realtek Corporation
  3. */
  4. #ifndef __RTW89_CAM_H__
  5. #define __RTW89_CAM_H__
  6. #include "core.h"
  7. #define RTW89_SEC_CAM_LEN 20
  8. #define RTW89_BSSID_MATCH_ALL GENMASK(5, 0)
  9. #define RTW89_BSSID_MATCH_5_BYTES GENMASK(4, 0)
  10. static inline void FWCMD_SET_ADDR_IDX(void *cmd, u32 value)
  11. {
  12. le32p_replace_bits((__le32 *)(cmd) + 1, value, GENMASK(7, 0));
  13. }
  14. static inline void FWCMD_SET_ADDR_OFFSET(void *cmd, u32 value)
  15. {
  16. le32p_replace_bits((__le32 *)(cmd) + 1, value, GENMASK(15, 8));
  17. }
  18. static inline void FWCMD_SET_ADDR_LEN(void *cmd, u32 value)
  19. {
  20. le32p_replace_bits((__le32 *)(cmd) + 1, value, GENMASK(23, 16));
  21. }
  22. static inline void FWCMD_SET_ADDR_VALID(void *cmd, u32 value)
  23. {
  24. le32p_replace_bits((__le32 *)(cmd) + 2, value, BIT(0));
  25. }
  26. static inline void FWCMD_SET_ADDR_NET_TYPE(void *cmd, u32 value)
  27. {
  28. le32p_replace_bits((__le32 *)(cmd) + 2, value, GENMASK(2, 1));
  29. }
  30. static inline void FWCMD_SET_ADDR_BCN_HIT_COND(void *cmd, u32 value)
  31. {
  32. le32p_replace_bits((__le32 *)(cmd) + 2, value, GENMASK(4, 3));
  33. }
  34. static inline void FWCMD_SET_ADDR_HIT_RULE(void *cmd, u32 value)
  35. {
  36. le32p_replace_bits((__le32 *)(cmd) + 2, value, GENMASK(6, 5));
  37. }
  38. static inline void FWCMD_SET_ADDR_BB_SEL(void *cmd, u32 value)
  39. {
  40. le32p_replace_bits((__le32 *)(cmd) + 2, value, BIT(7));
  41. }
  42. static inline void FWCMD_SET_ADDR_ADDR_MASK(void *cmd, u32 value)
  43. {
  44. le32p_replace_bits((__le32 *)(cmd) + 2, value, GENMASK(13, 8));
  45. }
  46. static inline void FWCMD_SET_ADDR_MASK_SEL(void *cmd, u32 value)
  47. {
  48. le32p_replace_bits((__le32 *)(cmd) + 2, value, GENMASK(15, 14));
  49. }
  50. static inline void FWCMD_SET_ADDR_SMA_HASH(void *cmd, u32 value)
  51. {
  52. le32p_replace_bits((__le32 *)(cmd) + 2, value, GENMASK(23, 16));
  53. }
  54. static inline void FWCMD_SET_ADDR_TMA_HASH(void *cmd, u32 value)
  55. {
  56. le32p_replace_bits((__le32 *)(cmd) + 2, value, GENMASK(31, 24));
  57. }
  58. static inline void FWCMD_SET_ADDR_BSSID_CAM_IDX(void *cmd, u32 value)
  59. {
  60. le32p_replace_bits((__le32 *)(cmd) + 3, value, GENMASK(5, 0));
  61. }
  62. static inline void FWCMD_SET_ADDR_SMA0(void *cmd, u32 value)
  63. {
  64. le32p_replace_bits((__le32 *)(cmd) + 4, value, GENMASK(7, 0));
  65. }
  66. static inline void FWCMD_SET_ADDR_SMA1(void *cmd, u32 value)
  67. {
  68. le32p_replace_bits((__le32 *)(cmd) + 4, value, GENMASK(15, 8));
  69. }
  70. static inline void FWCMD_SET_ADDR_SMA2(void *cmd, u32 value)
  71. {
  72. le32p_replace_bits((__le32 *)(cmd) + 4, value, GENMASK(23, 16));
  73. }
  74. static inline void FWCMD_SET_ADDR_SMA3(void *cmd, u32 value)
  75. {
  76. le32p_replace_bits((__le32 *)(cmd) + 4, value, GENMASK(31, 24));
  77. }
  78. static inline void FWCMD_SET_ADDR_SMA4(void *cmd, u32 value)
  79. {
  80. le32p_replace_bits((__le32 *)(cmd) + 5, value, GENMASK(7, 0));
  81. }
  82. static inline void FWCMD_SET_ADDR_SMA5(void *cmd, u32 value)
  83. {
  84. le32p_replace_bits((__le32 *)(cmd) + 5, value, GENMASK(15, 8));
  85. }
  86. static inline void FWCMD_SET_ADDR_TMA0(void *cmd, u32 value)
  87. {
  88. le32p_replace_bits((__le32 *)(cmd) + 5, value, GENMASK(23, 16));
  89. }
  90. static inline void FWCMD_SET_ADDR_TMA1(void *cmd, u32 value)
  91. {
  92. le32p_replace_bits((__le32 *)(cmd) + 5, value, GENMASK(31, 24));
  93. }
  94. static inline void FWCMD_SET_ADDR_TMA2(void *cmd, u32 value)
  95. {
  96. le32p_replace_bits((__le32 *)(cmd) + 6, value, GENMASK(7, 0));
  97. }
  98. static inline void FWCMD_SET_ADDR_TMA3(void *cmd, u32 value)
  99. {
  100. le32p_replace_bits((__le32 *)(cmd) + 6, value, GENMASK(15, 8));
  101. }
  102. static inline void FWCMD_SET_ADDR_TMA4(void *cmd, u32 value)
  103. {
  104. le32p_replace_bits((__le32 *)(cmd) + 6, value, GENMASK(23, 16));
  105. }
  106. static inline void FWCMD_SET_ADDR_TMA5(void *cmd, u32 value)
  107. {
  108. le32p_replace_bits((__le32 *)(cmd) + 6, value, GENMASK(31, 24));
  109. }
  110. static inline void FWCMD_SET_ADDR_MACID(void *cmd, u32 value)
  111. {
  112. le32p_replace_bits((__le32 *)(cmd) + 8, value, GENMASK(7, 0));
  113. }
  114. static inline void FWCMD_SET_ADDR_PORT_INT(void *cmd, u32 value)
  115. {
  116. le32p_replace_bits((__le32 *)(cmd) + 8, value, GENMASK(10, 8));
  117. }
  118. static inline void FWCMD_SET_ADDR_TSF_SYNC(void *cmd, u32 value)
  119. {
  120. le32p_replace_bits((__le32 *)(cmd) + 8, value, GENMASK(13, 11));
  121. }
  122. static inline void FWCMD_SET_ADDR_TF_TRS(void *cmd, u32 value)
  123. {
  124. le32p_replace_bits((__le32 *)(cmd) + 8, value, BIT(14));
  125. }
  126. static inline void FWCMD_SET_ADDR_LSIG_TXOP(void *cmd, u32 value)
  127. {
  128. le32p_replace_bits((__le32 *)(cmd) + 8, value, BIT(15));
  129. }
  130. static inline void FWCMD_SET_ADDR_TGT_IND(void *cmd, u32 value)
  131. {
  132. le32p_replace_bits((__le32 *)(cmd) + 8, value, GENMASK(26, 24));
  133. }
  134. static inline void FWCMD_SET_ADDR_FRM_TGT_IND(void *cmd, u32 value)
  135. {
  136. le32p_replace_bits((__le32 *)(cmd) + 8, value, GENMASK(29, 27));
  137. }
  138. static inline void FWCMD_SET_ADDR_AID12(void *cmd, u32 value)
  139. {
  140. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(11, 0));
  141. }
  142. static inline void FWCMD_SET_ADDR_AID12_0(void *cmd, u32 value)
  143. {
  144. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(7, 0));
  145. }
  146. static inline void FWCMD_SET_ADDR_AID12_1(void *cmd, u32 value)
  147. {
  148. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(11, 8));
  149. }
  150. static inline void FWCMD_SET_ADDR_WOL_PATTERN(void *cmd, u32 value)
  151. {
  152. le32p_replace_bits((__le32 *)(cmd) + 9, value, BIT(12));
  153. }
  154. static inline void FWCMD_SET_ADDR_WOL_UC(void *cmd, u32 value)
  155. {
  156. le32p_replace_bits((__le32 *)(cmd) + 9, value, BIT(13));
  157. }
  158. static inline void FWCMD_SET_ADDR_WOL_MAGIC(void *cmd, u32 value)
  159. {
  160. le32p_replace_bits((__le32 *)(cmd) + 9, value, BIT(14));
  161. }
  162. static inline void FWCMD_SET_ADDR_WAPI(void *cmd, u32 value)
  163. {
  164. le32p_replace_bits((__le32 *)(cmd) + 9, value, BIT(15));
  165. }
  166. static inline void FWCMD_SET_ADDR_SEC_ENT_MODE(void *cmd, u32 value)
  167. {
  168. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(17, 16));
  169. }
  170. static inline void FWCMD_SET_ADDR_SEC_ENT0_KEYID(void *cmd, u32 value)
  171. {
  172. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(19, 18));
  173. }
  174. static inline void FWCMD_SET_ADDR_SEC_ENT1_KEYID(void *cmd, u32 value)
  175. {
  176. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(21, 20));
  177. }
  178. static inline void FWCMD_SET_ADDR_SEC_ENT2_KEYID(void *cmd, u32 value)
  179. {
  180. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(23, 22));
  181. }
  182. static inline void FWCMD_SET_ADDR_SEC_ENT3_KEYID(void *cmd, u32 value)
  183. {
  184. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(25, 24));
  185. }
  186. static inline void FWCMD_SET_ADDR_SEC_ENT4_KEYID(void *cmd, u32 value)
  187. {
  188. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(27, 26));
  189. }
  190. static inline void FWCMD_SET_ADDR_SEC_ENT5_KEYID(void *cmd, u32 value)
  191. {
  192. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(29, 28));
  193. }
  194. static inline void FWCMD_SET_ADDR_SEC_ENT6_KEYID(void *cmd, u32 value)
  195. {
  196. le32p_replace_bits((__le32 *)(cmd) + 9, value, GENMASK(31, 30));
  197. }
  198. static inline void FWCMD_SET_ADDR_SEC_ENT_VALID(void *cmd, u32 value)
  199. {
  200. le32p_replace_bits((__le32 *)(cmd) + 10, value, GENMASK(7, 0));
  201. }
  202. static inline void FWCMD_SET_ADDR_SEC_ENT0(void *cmd, u32 value)
  203. {
  204. le32p_replace_bits((__le32 *)(cmd) + 10, value, GENMASK(15, 8));
  205. }
  206. static inline void FWCMD_SET_ADDR_SEC_ENT1(void *cmd, u32 value)
  207. {
  208. le32p_replace_bits((__le32 *)(cmd) + 10, value, GENMASK(23, 16));
  209. }
  210. static inline void FWCMD_SET_ADDR_SEC_ENT2(void *cmd, u32 value)
  211. {
  212. le32p_replace_bits((__le32 *)(cmd) + 10, value, GENMASK(31, 24));
  213. }
  214. static inline void FWCMD_SET_ADDR_SEC_ENT3(void *cmd, u32 value)
  215. {
  216. le32p_replace_bits((__le32 *)(cmd) + 11, value, GENMASK(7, 0));
  217. }
  218. static inline void FWCMD_SET_ADDR_SEC_ENT4(void *cmd, u32 value)
  219. {
  220. le32p_replace_bits((__le32 *)(cmd) + 11, value, GENMASK(15, 8));
  221. }
  222. static inline void FWCMD_SET_ADDR_SEC_ENT5(void *cmd, u32 value)
  223. {
  224. le32p_replace_bits((__le32 *)(cmd) + 11, value, GENMASK(23, 16));
  225. }
  226. static inline void FWCMD_SET_ADDR_SEC_ENT6(void *cmd, u32 value)
  227. {
  228. le32p_replace_bits((__le32 *)(cmd) + 11, value, GENMASK(31, 24));
  229. }
  230. static inline void FWCMD_SET_ADDR_BSSID_IDX(void *cmd, u32 value)
  231. {
  232. le32p_replace_bits((__le32 *)(cmd) + 12, value, GENMASK(7, 0));
  233. }
  234. static inline void FWCMD_SET_ADDR_BSSID_OFFSET(void *cmd, u32 value)
  235. {
  236. le32p_replace_bits((__le32 *)(cmd) + 12, value, GENMASK(15, 8));
  237. }
  238. static inline void FWCMD_SET_ADDR_BSSID_LEN(void *cmd, u32 value)
  239. {
  240. le32p_replace_bits((__le32 *)(cmd) + 12, value, GENMASK(23, 16));
  241. }
  242. static inline void FWCMD_SET_ADDR_BSSID_VALID(void *cmd, u32 value)
  243. {
  244. le32p_replace_bits((__le32 *)(cmd) + 13, value, BIT(0));
  245. }
  246. static inline void FWCMD_SET_ADDR_BSSID_BB_SEL(void *cmd, u32 value)
  247. {
  248. le32p_replace_bits((__le32 *)(cmd) + 13, value, BIT(1));
  249. }
  250. static inline void FWCMD_SET_ADDR_BSSID_MASK(void *cmd, u32 value)
  251. {
  252. le32p_replace_bits((__le32 *)(cmd) + 13, value, GENMASK(7, 2));
  253. }
  254. static inline void FWCMD_SET_ADDR_BSSID_BSS_COLOR(void *cmd, u32 value)
  255. {
  256. le32p_replace_bits((__le32 *)(cmd) + 13, value, GENMASK(13, 8));
  257. }
  258. static inline void FWCMD_SET_ADDR_BSSID_BSSID0(void *cmd, u32 value)
  259. {
  260. le32p_replace_bits((__le32 *)(cmd) + 13, value, GENMASK(23, 16));
  261. }
  262. static inline void FWCMD_SET_ADDR_BSSID_BSSID1(void *cmd, u32 value)
  263. {
  264. le32p_replace_bits((__le32 *)(cmd) + 13, value, GENMASK(31, 24));
  265. }
  266. static inline void FWCMD_SET_ADDR_BSSID_BSSID2(void *cmd, u32 value)
  267. {
  268. le32p_replace_bits((__le32 *)(cmd) + 14, value, GENMASK(7, 0));
  269. }
  270. static inline void FWCMD_SET_ADDR_BSSID_BSSID3(void *cmd, u32 value)
  271. {
  272. le32p_replace_bits((__le32 *)(cmd) + 14, value, GENMASK(15, 8));
  273. }
  274. static inline void FWCMD_SET_ADDR_BSSID_BSSID4(void *cmd, u32 value)
  275. {
  276. le32p_replace_bits((__le32 *)(cmd) + 14, value, GENMASK(23, 16));
  277. }
  278. static inline void FWCMD_SET_ADDR_BSSID_BSSID5(void *cmd, u32 value)
  279. {
  280. le32p_replace_bits((__le32 *)(cmd) + 14, value, GENMASK(31, 24));
  281. }
  282. int rtw89_cam_init(struct rtw89_dev *rtwdev, struct rtw89_vif *vif);
  283. void rtw89_cam_deinit(struct rtw89_dev *rtwdev, struct rtw89_vif *vif);
  284. int rtw89_cam_init_addr_cam(struct rtw89_dev *rtwdev,
  285. struct rtw89_addr_cam_entry *addr_cam,
  286. const struct rtw89_bssid_cam_entry *bssid_cam);
  287. void rtw89_cam_deinit_addr_cam(struct rtw89_dev *rtwdev,
  288. struct rtw89_addr_cam_entry *addr_cam);
  289. int rtw89_cam_init_bssid_cam(struct rtw89_dev *rtwdev,
  290. struct rtw89_vif *rtwvif,
  291. struct rtw89_bssid_cam_entry *bssid_cam,
  292. const u8 *bssid);
  293. void rtw89_cam_deinit_bssid_cam(struct rtw89_dev *rtwdev,
  294. struct rtw89_bssid_cam_entry *bssid_cam);
  295. void rtw89_cam_fill_addr_cam_info(struct rtw89_dev *rtwdev,
  296. struct rtw89_vif *vif,
  297. struct rtw89_sta *rtwsta,
  298. const u8 *scan_mac_addr, u8 *cmd);
  299. void rtw89_cam_fill_dctl_sec_cam_info_v1(struct rtw89_dev *rtwdev,
  300. struct rtw89_vif *rtwvif,
  301. struct rtw89_sta *rtwsta,
  302. u8 *cmd);
  303. int rtw89_cam_fill_bssid_cam_info(struct rtw89_dev *rtwdev,
  304. struct rtw89_vif *rtwvif,
  305. struct rtw89_sta *rtwsta, u8 *cmd);
  306. int rtw89_cam_sec_key_add(struct rtw89_dev *rtwdev,
  307. struct ieee80211_vif *vif,
  308. struct ieee80211_sta *sta,
  309. struct ieee80211_key_conf *key);
  310. int rtw89_cam_sec_key_del(struct rtw89_dev *rtwdev,
  311. struct ieee80211_vif *vif,
  312. struct ieee80211_sta *sta,
  313. struct ieee80211_key_conf *key,
  314. bool inform_fw);
  315. void rtw89_cam_bssid_changed(struct rtw89_dev *rtwdev,
  316. struct rtw89_vif *rtwvif);
  317. void rtw89_cam_reset_keys(struct rtw89_dev *rtwdev);
  318. #endif