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