Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: wfx: place hif_tx_mib functions into a .c file

Until now, all functions from hif_tx_mib.h are declared "static inline".
However, they are not time critical. So, it does not make so much sense.

We prefer to place them in a .c file as for other hif functions.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200406111756.154086-9-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jérôme Pouiller and committed by
Greg Kroah-Hartman
9671f133 fac592d0

+443 -390
+1
drivers/staging/wfx/Makefile
··· 7 7 bh.o \ 8 8 hwio.o \ 9 9 fwio.o \ 10 + hif_tx_mib.o \ 10 11 hif_tx.o \ 11 12 hif_rx.o \ 12 13 queue.o \
+1
drivers/staging/wfx/data_tx.c
··· 6 6 * Copyright (c) 2010, ST-Ericsson 7 7 */ 8 8 #include <net/mac80211.h> 9 + #include <linux/etherdevice.h> 9 10 10 11 #include "data_tx.h" 11 12 #include "wfx.h"
+396
drivers/staging/wfx/hif_tx_mib.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Implementation of host-to-chip MIBs of WFxxx Split Mac (WSM) API. 4 + * 5 + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. 6 + * Copyright (c) 2010, ST-Ericsson 7 + * Copyright (C) 2010, ST-Ericsson SA 8 + */ 9 + 10 + #include <linux/etherdevice.h> 11 + 12 + #include "wfx.h" 13 + #include "hif_tx.h" 14 + #include "hif_tx_mib.h" 15 + #include "hif_api_mib.h" 16 + 17 + int hif_set_output_power(struct wfx_vif *wvif, int val) 18 + { 19 + struct hif_mib_current_tx_power_level arg = { 20 + .power_level = cpu_to_le32(val * 10), 21 + }; 22 + 23 + return hif_write_mib(wvif->wdev, wvif->id, 24 + HIF_MIB_ID_CURRENT_TX_POWER_LEVEL, 25 + &arg, sizeof(arg)); 26 + } 27 + 28 + int hif_set_beacon_wakeup_period(struct wfx_vif *wvif, 29 + unsigned int dtim_interval, 30 + unsigned int listen_interval) 31 + { 32 + struct hif_mib_beacon_wake_up_period val = { 33 + .wakeup_period_min = dtim_interval, 34 + .receive_dtim = 0, 35 + .wakeup_period_max = cpu_to_le16(listen_interval), 36 + }; 37 + 38 + if (dtim_interval > 0xFF || listen_interval > 0xFFFF) 39 + return -EINVAL; 40 + return hif_write_mib(wvif->wdev, wvif->id, 41 + HIF_MIB_ID_BEACON_WAKEUP_PERIOD, 42 + &val, sizeof(val)); 43 + } 44 + 45 + int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif, 46 + int rssi_thold, int rssi_hyst) 47 + { 48 + struct hif_mib_rcpi_rssi_threshold arg = { 49 + .rolling_average_count = 8, 50 + .detection = 1, 51 + }; 52 + 53 + if (!rssi_thold && !rssi_hyst) { 54 + arg.upperthresh = 1; 55 + arg.lowerthresh = 1; 56 + } else { 57 + arg.upper_threshold = rssi_thold + rssi_hyst; 58 + arg.upper_threshold = (arg.upper_threshold + 110) * 2; 59 + arg.lower_threshold = rssi_thold; 60 + arg.lower_threshold = (arg.lower_threshold + 110) * 2; 61 + } 62 + 63 + return hif_write_mib(wvif->wdev, wvif->id, 64 + HIF_MIB_ID_RCPI_RSSI_THRESHOLD, &arg, sizeof(arg)); 65 + } 66 + 67 + int hif_get_counters_table(struct wfx_dev *wdev, 68 + struct hif_mib_extended_count_table *arg) 69 + { 70 + if (wfx_api_older_than(wdev, 1, 3)) { 71 + // extended_count_table is wider than count_table 72 + memset(arg, 0xFF, sizeof(*arg)); 73 + return hif_read_mib(wdev, 0, HIF_MIB_ID_COUNTERS_TABLE, 74 + arg, sizeof(struct hif_mib_count_table)); 75 + } else { 76 + return hif_read_mib(wdev, 0, 77 + HIF_MIB_ID_EXTENDED_COUNTERS_TABLE, arg, 78 + sizeof(struct hif_mib_extended_count_table)); 79 + } 80 + } 81 + 82 + int hif_set_macaddr(struct wfx_vif *wvif, u8 *mac) 83 + { 84 + struct hif_mib_mac_address msg = { }; 85 + 86 + if (mac) 87 + ether_addr_copy(msg.mac_addr, mac); 88 + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_DOT11_MAC_ADDRESS, 89 + &msg, sizeof(msg)); 90 + } 91 + 92 + int hif_set_rx_filter(struct wfx_vif *wvif, 93 + bool filter_bssid, bool fwd_probe_req) 94 + { 95 + struct hif_mib_rx_filter val = { }; 96 + 97 + if (filter_bssid) 98 + val.bssid_filter = 1; 99 + if (fwd_probe_req) 100 + val.fwd_probe_req = 1; 101 + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_RX_FILTER, 102 + &val, sizeof(val)); 103 + } 104 + 105 + int hif_set_beacon_filter_table(struct wfx_vif *wvif, 106 + int tbl_len, struct hif_ie_table_entry *tbl) 107 + { 108 + int ret; 109 + struct hif_mib_bcn_filter_table *val; 110 + int buf_len = struct_size(val, ie_table, tbl_len); 111 + 112 + val = kzalloc(buf_len, GFP_KERNEL); 113 + if (!val) 114 + return -ENOMEM; 115 + val->num_of_info_elmts = cpu_to_le32(tbl_len); 116 + memcpy(val->ie_table, tbl, tbl_len * sizeof(*tbl)); 117 + ret = hif_write_mib(wvif->wdev, wvif->id, 118 + HIF_MIB_ID_BEACON_FILTER_TABLE, val, buf_len); 119 + kfree(val); 120 + return ret; 121 + } 122 + 123 + int hif_beacon_filter_control(struct wfx_vif *wvif, 124 + int enable, int beacon_count) 125 + { 126 + struct hif_mib_bcn_filter_enable arg = { 127 + .enable = cpu_to_le32(enable), 128 + .bcn_count = cpu_to_le32(beacon_count), 129 + }; 130 + return hif_write_mib(wvif->wdev, wvif->id, 131 + HIF_MIB_ID_BEACON_FILTER_ENABLE, 132 + &arg, sizeof(arg)); 133 + } 134 + 135 + int hif_set_operational_mode(struct wfx_dev *wdev, enum hif_op_power_mode mode) 136 + { 137 + struct hif_mib_gl_operational_power_mode val = { 138 + .power_mode = mode, 139 + .wup_ind_activation = 1, 140 + }; 141 + 142 + return hif_write_mib(wdev, -1, HIF_MIB_ID_GL_OPERATIONAL_POWER_MODE, 143 + &val, sizeof(val)); 144 + } 145 + 146 + int hif_set_template_frame(struct wfx_vif *wvif, struct sk_buff *skb, 147 + u8 frame_type, int init_rate) 148 + { 149 + struct hif_mib_template_frame *arg; 150 + 151 + skb_push(skb, 4); 152 + arg = (struct hif_mib_template_frame *)skb->data; 153 + skb_pull(skb, 4); 154 + arg->init_rate = init_rate; 155 + arg->frame_type = frame_type; 156 + arg->frame_length = cpu_to_le16(skb->len); 157 + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_TEMPLATE_FRAME, 158 + arg, sizeof(*arg)); 159 + } 160 + 161 + int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) 162 + { 163 + struct hif_mib_protected_mgmt_policy val = { }; 164 + 165 + WARN(required && !capable, "incoherent arguments"); 166 + if (capable) { 167 + val.pmf_enable = 1; 168 + val.host_enc_auth_frames = 1; 169 + } 170 + if (!required) 171 + val.unpmf_allowed = 1; 172 + return hif_write_mib(wvif->wdev, wvif->id, 173 + HIF_MIB_ID_PROTECTED_MGMT_POLICY, 174 + &val, sizeof(val)); 175 + } 176 + 177 + int hif_set_block_ack_policy(struct wfx_vif *wvif, 178 + u8 tx_tid_policy, u8 rx_tid_policy) 179 + { 180 + struct hif_mib_block_ack_policy val = { 181 + .block_ack_tx_tid_policy = tx_tid_policy, 182 + .block_ack_rx_tid_policy = rx_tid_policy, 183 + }; 184 + 185 + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_BLOCK_ACK_POLICY, 186 + &val, sizeof(val)); 187 + } 188 + 189 + int hif_set_association_mode(struct wfx_vif *wvif, 190 + struct ieee80211_bss_conf *info) 191 + { 192 + int basic_rates = wfx_rate_mask_to_hw(wvif->wdev, info->basic_rates); 193 + struct ieee80211_sta *sta = NULL; 194 + struct hif_mib_set_association_mode val = { 195 + .preambtype_use = 1, 196 + .mode = 1, 197 + .rateset = 1, 198 + .spacing = 1, 199 + .short_preamble = info->use_short_preamble, 200 + .basic_rate_set = cpu_to_le32(basic_rates) 201 + }; 202 + 203 + rcu_read_lock(); // protect sta 204 + if (info->bssid && !info->ibss_joined) 205 + sta = ieee80211_find_sta(wvif->vif, info->bssid); 206 + 207 + // FIXME: it is strange to not retrieve all information from bss_info 208 + if (sta && sta->ht_cap.ht_supported) { 209 + val.mpdu_start_spacing = sta->ht_cap.ampdu_density; 210 + if (!(info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)) 211 + val.greenfield = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); 212 + } 213 + rcu_read_unlock(); 214 + 215 + return hif_write_mib(wvif->wdev, wvif->id, 216 + HIF_MIB_ID_SET_ASSOCIATION_MODE, &val, sizeof(val)); 217 + } 218 + 219 + int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif, 220 + int policy_index, uint8_t *rates) 221 + { 222 + struct hif_mib_set_tx_rate_retry_policy *arg; 223 + size_t size = struct_size(arg, tx_rate_retry_policy, 1); 224 + int ret; 225 + 226 + arg = kzalloc(size, GFP_KERNEL); 227 + arg->num_tx_rate_policies = 1; 228 + arg->tx_rate_retry_policy[0].policy_index = policy_index; 229 + arg->tx_rate_retry_policy[0].short_retry_count = 255; 230 + arg->tx_rate_retry_policy[0].long_retry_count = 255; 231 + arg->tx_rate_retry_policy[0].first_rate_sel = 1; 232 + arg->tx_rate_retry_policy[0].terminate = 1; 233 + arg->tx_rate_retry_policy[0].count_init = 1; 234 + memcpy(&arg->tx_rate_retry_policy[0].rates, rates, 235 + sizeof(arg->tx_rate_retry_policy[0].rates)); 236 + ret = hif_write_mib(wvif->wdev, wvif->id, 237 + HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size); 238 + kfree(arg); 239 + return ret; 240 + } 241 + 242 + int hif_set_mac_addr_condition(struct wfx_vif *wvif, 243 + int idx, const u8 *mac_addr) 244 + { 245 + struct hif_mib_mac_addr_data_frame_condition val = { 246 + .condition_idx = idx, 247 + .address_type = HIF_MAC_ADDR_A1, 248 + }; 249 + 250 + ether_addr_copy(val.mac_address, mac_addr); 251 + return hif_write_mib(wvif->wdev, wvif->id, 252 + HIF_MIB_ID_MAC_ADDR_DATAFRAME_CONDITION, 253 + &val, sizeof(val)); 254 + } 255 + 256 + int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif, int idx, u8 allowed_frames) 257 + { 258 + struct hif_mib_uc_mc_bc_data_frame_condition val = { 259 + .condition_idx = idx, 260 + .allowed_frames = allowed_frames, 261 + }; 262 + 263 + return hif_write_mib(wvif->wdev, wvif->id, 264 + HIF_MIB_ID_UC_MC_BC_DATAFRAME_CONDITION, 265 + &val, sizeof(val)); 266 + } 267 + 268 + int hif_set_config_data_filter(struct wfx_vif *wvif, bool enable, int idx, 269 + int mac_filters, int frames_types_filters) 270 + { 271 + struct hif_mib_config_data_filter val = { 272 + .enable = enable, 273 + .filter_idx = idx, 274 + .mac_cond = mac_filters, 275 + .uc_mc_bc_cond = frames_types_filters, 276 + }; 277 + 278 + return hif_write_mib(wvif->wdev, wvif->id, 279 + HIF_MIB_ID_CONFIG_DATA_FILTER, &val, sizeof(val)); 280 + } 281 + 282 + int hif_set_data_filtering(struct wfx_vif *wvif, bool enable, bool invert) 283 + { 284 + struct hif_mib_set_data_filtering val = { 285 + .enable = enable, 286 + .invert_matching = invert, 287 + }; 288 + 289 + return hif_write_mib(wvif->wdev, wvif->id, 290 + HIF_MIB_ID_SET_DATA_FILTERING, &val, sizeof(val)); 291 + } 292 + 293 + int hif_keep_alive_period(struct wfx_vif *wvif, int period) 294 + { 295 + struct hif_mib_keep_alive_period arg = { 296 + .keep_alive_period = cpu_to_le16(period), 297 + }; 298 + 299 + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_KEEP_ALIVE_PERIOD, 300 + &arg, sizeof(arg)); 301 + }; 302 + 303 + int hif_set_arp_ipv4_filter(struct wfx_vif *wvif, int idx, __be32 *addr) 304 + { 305 + struct hif_mib_arp_ip_addr_table arg = { 306 + .condition_idx = idx, 307 + .arp_enable = HIF_ARP_NS_FILTERING_DISABLE, 308 + }; 309 + 310 + if (addr) { 311 + // Caution: type of addr is __be32 312 + memcpy(arg.ipv4_address, addr, sizeof(arg.ipv4_address)); 313 + arg.arp_enable = HIF_ARP_NS_FILTERING_ENABLE; 314 + } 315 + return hif_write_mib(wvif->wdev, wvif->id, 316 + HIF_MIB_ID_ARP_IP_ADDRESSES_TABLE, 317 + &arg, sizeof(arg)); 318 + } 319 + 320 + int hif_use_multi_tx_conf(struct wfx_dev *wdev, bool enable) 321 + { 322 + struct hif_mib_gl_set_multi_msg arg = { 323 + .enable_multi_tx_conf = enable, 324 + }; 325 + 326 + return hif_write_mib(wdev, -1, HIF_MIB_ID_GL_SET_MULTI_MSG, 327 + &arg, sizeof(arg)); 328 + } 329 + 330 + int hif_set_uapsd_info(struct wfx_vif *wvif, unsigned long val) 331 + { 332 + struct hif_mib_set_uapsd_information arg = { }; 333 + 334 + if (val & BIT(IEEE80211_AC_VO)) 335 + arg.trig_voice = 1; 336 + if (val & BIT(IEEE80211_AC_VI)) 337 + arg.trig_video = 1; 338 + if (val & BIT(IEEE80211_AC_BE)) 339 + arg.trig_be = 1; 340 + if (val & BIT(IEEE80211_AC_BK)) 341 + arg.trig_bckgrnd = 1; 342 + return hif_write_mib(wvif->wdev, wvif->id, 343 + HIF_MIB_ID_SET_UAPSD_INFORMATION, 344 + &arg, sizeof(arg)); 345 + } 346 + 347 + int hif_erp_use_protection(struct wfx_vif *wvif, bool enable) 348 + { 349 + struct hif_mib_non_erp_protection arg = { 350 + .use_cts_to_self = enable, 351 + }; 352 + 353 + return hif_write_mib(wvif->wdev, wvif->id, 354 + HIF_MIB_ID_NON_ERP_PROTECTION, &arg, sizeof(arg)); 355 + } 356 + 357 + int hif_slot_time(struct wfx_vif *wvif, int val) 358 + { 359 + struct hif_mib_slot_time arg = { 360 + .slot_time = cpu_to_le32(val), 361 + }; 362 + 363 + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SLOT_TIME, 364 + &arg, sizeof(arg)); 365 + } 366 + 367 + int hif_dual_cts_protection(struct wfx_vif *wvif, bool enable) 368 + { 369 + struct hif_mib_set_ht_protection arg = { 370 + .dual_cts_prot = enable, 371 + }; 372 + 373 + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SET_HT_PROTECTION, 374 + &arg, sizeof(arg)); 375 + } 376 + 377 + int hif_wep_default_key_id(struct wfx_vif *wvif, int val) 378 + { 379 + struct hif_mib_wep_default_key_id arg = { 380 + .wep_default_key_id = val, 381 + }; 382 + 383 + return hif_write_mib(wvif->wdev, wvif->id, 384 + HIF_MIB_ID_DOT11_WEP_DEFAULT_KEY_ID, 385 + &arg, sizeof(arg)); 386 + } 387 + 388 + int hif_rts_threshold(struct wfx_vif *wvif, int val) 389 + { 390 + struct hif_mib_dot11_rts_threshold arg = { 391 + .threshold = cpu_to_le32(val >= 0 ? val : 0xFFFF), 392 + }; 393 + 394 + return hif_write_mib(wvif->wdev, wvif->id, 395 + HIF_MIB_ID_DOT11_RTS_THRESHOLD, &arg, sizeof(arg)); 396 + }
+43 -390
drivers/staging/wfx/hif_tx_mib.h
··· 9 9 #ifndef WFX_HIF_TX_MIB_H 10 10 #define WFX_HIF_TX_MIB_H 11 11 12 - #include <linux/etherdevice.h> 13 - 14 - #include "wfx.h" 15 - #include "hif_tx.h" 16 12 #include "hif_api_mib.h" 17 13 18 - static inline int hif_set_output_power(struct wfx_vif *wvif, int val) 19 - { 20 - struct hif_mib_current_tx_power_level arg = { 21 - .power_level = cpu_to_le32(val * 10), 22 - }; 14 + struct wfx_vif; 15 + struct sk_buff; 23 16 24 - return hif_write_mib(wvif->wdev, wvif->id, 25 - HIF_MIB_ID_CURRENT_TX_POWER_LEVEL, 26 - &arg, sizeof(arg)); 27 - } 28 - 29 - static inline int hif_set_beacon_wakeup_period(struct wfx_vif *wvif, 30 - unsigned int dtim_interval, 31 - unsigned int listen_interval) 32 - { 33 - struct hif_mib_beacon_wake_up_period val = { 34 - .wakeup_period_min = dtim_interval, 35 - .receive_dtim = 0, 36 - .wakeup_period_max = cpu_to_le16(listen_interval), 37 - }; 38 - 39 - if (dtim_interval > 0xFF || listen_interval > 0xFFFF) 40 - return -EINVAL; 41 - return hif_write_mib(wvif->wdev, wvif->id, 42 - HIF_MIB_ID_BEACON_WAKEUP_PERIOD, 43 - &val, sizeof(val)); 44 - } 45 - 46 - static inline int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif, 47 - int rssi_thold, int rssi_hyst) 48 - { 49 - struct hif_mib_rcpi_rssi_threshold arg = { 50 - .rolling_average_count = 8, 51 - .detection = 1, 52 - }; 53 - 54 - if (!rssi_thold && !rssi_hyst) { 55 - arg.upperthresh = 1; 56 - arg.lowerthresh = 1; 57 - } else { 58 - arg.upper_threshold = rssi_thold + rssi_hyst; 59 - arg.upper_threshold = (arg.upper_threshold + 110) * 2; 60 - arg.lower_threshold = rssi_thold; 61 - arg.lower_threshold = (arg.lower_threshold + 110) * 2; 62 - } 63 - 64 - return hif_write_mib(wvif->wdev, wvif->id, 65 - HIF_MIB_ID_RCPI_RSSI_THRESHOLD, &arg, sizeof(arg)); 66 - } 67 - 68 - static inline int hif_get_counters_table(struct wfx_dev *wdev, 69 - struct hif_mib_extended_count_table *arg) 70 - { 71 - if (wfx_api_older_than(wdev, 1, 3)) { 72 - // extended_count_table is wider than count_table 73 - memset(arg, 0xFF, sizeof(*arg)); 74 - return hif_read_mib(wdev, 0, HIF_MIB_ID_COUNTERS_TABLE, 75 - arg, sizeof(struct hif_mib_count_table)); 76 - } else { 77 - return hif_read_mib(wdev, 0, 78 - HIF_MIB_ID_EXTENDED_COUNTERS_TABLE, arg, 79 - sizeof(struct hif_mib_extended_count_table)); 80 - } 81 - } 82 - 83 - static inline int hif_set_macaddr(struct wfx_vif *wvif, u8 *mac) 84 - { 85 - struct hif_mib_mac_address msg = { }; 86 - 87 - if (mac) 88 - ether_addr_copy(msg.mac_addr, mac); 89 - return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_DOT11_MAC_ADDRESS, 90 - &msg, sizeof(msg)); 91 - } 92 - 93 - static inline int hif_set_rx_filter(struct wfx_vif *wvif, bool filter_bssid, 94 - bool fwd_probe_req) 95 - { 96 - struct hif_mib_rx_filter val = { }; 97 - 98 - if (filter_bssid) 99 - val.bssid_filter = 1; 100 - if (fwd_probe_req) 101 - val.fwd_probe_req = 1; 102 - return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_RX_FILTER, 103 - &val, sizeof(val)); 104 - } 105 - 106 - static inline int hif_set_beacon_filter_table(struct wfx_vif *wvif, 107 - int tbl_len, 108 - struct hif_ie_table_entry *tbl) 109 - { 110 - int ret; 111 - struct hif_mib_bcn_filter_table *val; 112 - int buf_len = struct_size(val, ie_table, tbl_len); 113 - 114 - val = kzalloc(buf_len, GFP_KERNEL); 115 - if (!val) 116 - return -ENOMEM; 117 - val->num_of_info_elmts = cpu_to_le32(tbl_len); 118 - memcpy(val->ie_table, tbl, tbl_len * sizeof(*tbl)); 119 - ret = hif_write_mib(wvif->wdev, wvif->id, 120 - HIF_MIB_ID_BEACON_FILTER_TABLE, val, buf_len); 121 - kfree(val); 122 - return ret; 123 - } 124 - 125 - static inline int hif_beacon_filter_control(struct wfx_vif *wvif, 126 - int enable, int beacon_count) 127 - { 128 - struct hif_mib_bcn_filter_enable arg = { 129 - .enable = cpu_to_le32(enable), 130 - .bcn_count = cpu_to_le32(beacon_count), 131 - }; 132 - return hif_write_mib(wvif->wdev, wvif->id, 133 - HIF_MIB_ID_BEACON_FILTER_ENABLE, 134 - &arg, sizeof(arg)); 135 - } 136 - 137 - static inline int hif_set_operational_mode(struct wfx_dev *wdev, 138 - enum hif_op_power_mode mode) 139 - { 140 - struct hif_mib_gl_operational_power_mode val = { 141 - .power_mode = mode, 142 - .wup_ind_activation = 1, 143 - }; 144 - 145 - return hif_write_mib(wdev, -1, HIF_MIB_ID_GL_OPERATIONAL_POWER_MODE, 146 - &val, sizeof(val)); 147 - } 148 - 149 - static inline int hif_set_template_frame(struct wfx_vif *wvif, 150 - struct sk_buff *skb, 151 - u8 frame_type, int init_rate) 152 - { 153 - struct hif_mib_template_frame *arg; 154 - 155 - skb_push(skb, 4); 156 - arg = (struct hif_mib_template_frame *)skb->data; 157 - skb_pull(skb, 4); 158 - arg->init_rate = init_rate; 159 - arg->frame_type = frame_type; 160 - arg->frame_length = cpu_to_le16(skb->len); 161 - return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_TEMPLATE_FRAME, 162 - arg, sizeof(*arg)); 163 - } 164 - 165 - static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) 166 - { 167 - struct hif_mib_protected_mgmt_policy val = { }; 168 - 169 - WARN(required && !capable, "incoherent arguments"); 170 - if (capable) { 171 - val.pmf_enable = 1; 172 - val.host_enc_auth_frames = 1; 173 - } 174 - if (!required) 175 - val.unpmf_allowed = 1; 176 - return hif_write_mib(wvif->wdev, wvif->id, 177 - HIF_MIB_ID_PROTECTED_MGMT_POLICY, 178 - &val, sizeof(val)); 179 - } 180 - 181 - static inline int hif_set_block_ack_policy(struct wfx_vif *wvif, 182 - u8 tx_tid_policy, u8 rx_tid_policy) 183 - { 184 - struct hif_mib_block_ack_policy val = { 185 - .block_ack_tx_tid_policy = tx_tid_policy, 186 - .block_ack_rx_tid_policy = rx_tid_policy, 187 - }; 188 - 189 - return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_BLOCK_ACK_POLICY, 190 - &val, sizeof(val)); 191 - } 192 - 193 - static inline int hif_set_association_mode(struct wfx_vif *wvif, 194 - struct ieee80211_bss_conf *info) 195 - { 196 - int basic_rates = wfx_rate_mask_to_hw(wvif->wdev, info->basic_rates); 197 - struct ieee80211_sta *sta = NULL; 198 - struct hif_mib_set_association_mode val = { 199 - .preambtype_use = 1, 200 - .mode = 1, 201 - .rateset = 1, 202 - .spacing = 1, 203 - .short_preamble = info->use_short_preamble, 204 - .basic_rate_set = cpu_to_le32(basic_rates) 205 - }; 206 - 207 - rcu_read_lock(); // protect sta 208 - if (info->bssid && !info->ibss_joined) 209 - sta = ieee80211_find_sta(wvif->vif, info->bssid); 210 - 211 - // FIXME: it is strange to not retrieve all information from bss_info 212 - if (sta && sta->ht_cap.ht_supported) { 213 - val.mpdu_start_spacing = sta->ht_cap.ampdu_density; 214 - if (!(info->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)) 215 - val.greenfield = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD); 216 - } 217 - rcu_read_unlock(); 218 - 219 - return hif_write_mib(wvif->wdev, wvif->id, 220 - HIF_MIB_ID_SET_ASSOCIATION_MODE, &val, sizeof(val)); 221 - } 222 - 223 - static inline int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif, 224 - int policy_index, uint8_t *rates) 225 - { 226 - struct hif_mib_set_tx_rate_retry_policy *arg; 227 - size_t size = struct_size(arg, tx_rate_retry_policy, 1); 228 - int ret; 229 - 230 - arg = kzalloc(size, GFP_KERNEL); 231 - arg->num_tx_rate_policies = 1; 232 - arg->tx_rate_retry_policy[0].policy_index = policy_index; 233 - arg->tx_rate_retry_policy[0].short_retry_count = 255; 234 - arg->tx_rate_retry_policy[0].long_retry_count = 255; 235 - arg->tx_rate_retry_policy[0].first_rate_sel = 1; 236 - arg->tx_rate_retry_policy[0].terminate = 1; 237 - arg->tx_rate_retry_policy[0].count_init = 1; 238 - memcpy(&arg->tx_rate_retry_policy[0].rates, rates, 239 - sizeof(arg->tx_rate_retry_policy[0].rates)); 240 - ret = hif_write_mib(wvif->wdev, wvif->id, 241 - HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size); 242 - kfree(arg); 243 - return ret; 244 - } 245 - 246 - static inline int hif_set_mac_addr_condition(struct wfx_vif *wvif, 247 - int idx, const u8 *mac_addr) 248 - { 249 - struct hif_mib_mac_addr_data_frame_condition val = { 250 - .condition_idx = idx, 251 - .address_type = HIF_MAC_ADDR_A1, 252 - }; 253 - 254 - ether_addr_copy(val.mac_address, mac_addr); 255 - return hif_write_mib(wvif->wdev, wvif->id, 256 - HIF_MIB_ID_MAC_ADDR_DATAFRAME_CONDITION, 257 - &val, sizeof(val)); 258 - } 259 - 260 - static inline int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif, 261 - int idx, u8 allowed_frames) 262 - { 263 - struct hif_mib_uc_mc_bc_data_frame_condition val = { 264 - .condition_idx = idx, 265 - .allowed_frames = allowed_frames, 266 - }; 267 - 268 - return hif_write_mib(wvif->wdev, wvif->id, 269 - HIF_MIB_ID_UC_MC_BC_DATAFRAME_CONDITION, 270 - &val, sizeof(val)); 271 - } 272 - 273 - static inline int hif_set_config_data_filter(struct wfx_vif *wvif, bool enable, 274 - int idx, int mac_filters, 275 - int frames_types_filters) 276 - { 277 - struct hif_mib_config_data_filter val = { 278 - .enable = enable, 279 - .filter_idx = idx, 280 - .mac_cond = mac_filters, 281 - .uc_mc_bc_cond = frames_types_filters, 282 - }; 283 - 284 - return hif_write_mib(wvif->wdev, wvif->id, 285 - HIF_MIB_ID_CONFIG_DATA_FILTER, &val, sizeof(val)); 286 - } 287 - 288 - static inline int hif_set_data_filtering(struct wfx_vif *wvif, 289 - bool enable, bool invert) 290 - { 291 - struct hif_mib_set_data_filtering val = { 292 - .enable = enable, 293 - .invert_matching = invert, 294 - }; 295 - 296 - return hif_write_mib(wvif->wdev, wvif->id, 297 - HIF_MIB_ID_SET_DATA_FILTERING, &val, sizeof(val)); 298 - } 299 - 300 - static inline int hif_keep_alive_period(struct wfx_vif *wvif, int period) 301 - { 302 - struct hif_mib_keep_alive_period arg = { 303 - .keep_alive_period = cpu_to_le16(period), 304 - }; 305 - 306 - return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_KEEP_ALIVE_PERIOD, 307 - &arg, sizeof(arg)); 308 - }; 309 - 310 - static inline int hif_set_arp_ipv4_filter(struct wfx_vif *wvif, int idx, 311 - __be32 *addr) 312 - { 313 - struct hif_mib_arp_ip_addr_table arg = { 314 - .condition_idx = idx, 315 - .arp_enable = HIF_ARP_NS_FILTERING_DISABLE, 316 - }; 317 - 318 - if (addr) { 319 - // Caution: type of addr is __be32 320 - memcpy(arg.ipv4_address, addr, sizeof(arg.ipv4_address)); 321 - arg.arp_enable = HIF_ARP_NS_FILTERING_ENABLE; 322 - } 323 - return hif_write_mib(wvif->wdev, wvif->id, 324 - HIF_MIB_ID_ARP_IP_ADDRESSES_TABLE, 325 - &arg, sizeof(arg)); 326 - } 327 - 328 - static inline int hif_use_multi_tx_conf(struct wfx_dev *wdev, bool enable) 329 - { 330 - struct hif_mib_gl_set_multi_msg arg = { 331 - .enable_multi_tx_conf = enable, 332 - }; 333 - 334 - return hif_write_mib(wdev, -1, HIF_MIB_ID_GL_SET_MULTI_MSG, 335 - &arg, sizeof(arg)); 336 - } 337 - 338 - static inline int hif_set_uapsd_info(struct wfx_vif *wvif, unsigned long val) 339 - { 340 - struct hif_mib_set_uapsd_information arg = { }; 341 - 342 - if (val & BIT(IEEE80211_AC_VO)) 343 - arg.trig_voice = 1; 344 - if (val & BIT(IEEE80211_AC_VI)) 345 - arg.trig_video = 1; 346 - if (val & BIT(IEEE80211_AC_BE)) 347 - arg.trig_be = 1; 348 - if (val & BIT(IEEE80211_AC_BK)) 349 - arg.trig_bckgrnd = 1; 350 - return hif_write_mib(wvif->wdev, wvif->id, 351 - HIF_MIB_ID_SET_UAPSD_INFORMATION, 352 - &arg, sizeof(arg)); 353 - } 354 - 355 - static inline int hif_erp_use_protection(struct wfx_vif *wvif, bool enable) 356 - { 357 - struct hif_mib_non_erp_protection arg = { 358 - .use_cts_to_self = enable, 359 - }; 360 - 361 - return hif_write_mib(wvif->wdev, wvif->id, 362 - HIF_MIB_ID_NON_ERP_PROTECTION, &arg, sizeof(arg)); 363 - } 364 - 365 - static inline int hif_slot_time(struct wfx_vif *wvif, int val) 366 - { 367 - struct hif_mib_slot_time arg = { 368 - .slot_time = cpu_to_le32(val), 369 - }; 370 - 371 - return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SLOT_TIME, 372 - &arg, sizeof(arg)); 373 - } 374 - 375 - static inline int hif_dual_cts_protection(struct wfx_vif *wvif, bool enable) 376 - { 377 - struct hif_mib_set_ht_protection arg = { 378 - .dual_cts_prot = enable, 379 - }; 380 - 381 - return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SET_HT_PROTECTION, 382 - &arg, sizeof(arg)); 383 - } 384 - 385 - static inline int hif_wep_default_key_id(struct wfx_vif *wvif, int val) 386 - { 387 - struct hif_mib_wep_default_key_id arg = { 388 - .wep_default_key_id = val, 389 - }; 390 - 391 - return hif_write_mib(wvif->wdev, wvif->id, 392 - HIF_MIB_ID_DOT11_WEP_DEFAULT_KEY_ID, 393 - &arg, sizeof(arg)); 394 - } 395 - 396 - static inline int hif_rts_threshold(struct wfx_vif *wvif, int val) 397 - { 398 - struct hif_mib_dot11_rts_threshold arg = { 399 - .threshold = cpu_to_le32(val >= 0 ? val : 0xFFFF), 400 - }; 401 - 402 - return hif_write_mib(wvif->wdev, wvif->id, 403 - HIF_MIB_ID_DOT11_RTS_THRESHOLD, &arg, sizeof(arg)); 404 - } 17 + int hif_set_output_power(struct wfx_vif *wvif, int val); 18 + int hif_set_beacon_wakeup_period(struct wfx_vif *wvif, 19 + unsigned int dtim_interval, 20 + unsigned int listen_interval); 21 + int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif, 22 + int rssi_thold, int rssi_hyst); 23 + int hif_get_counters_table(struct wfx_dev *wdev, 24 + struct hif_mib_extended_count_table *arg); 25 + int hif_set_macaddr(struct wfx_vif *wvif, u8 *mac); 26 + int hif_set_rx_filter(struct wfx_vif *wvif, 27 + bool filter_bssid, bool fwd_probe_req); 28 + int hif_set_beacon_filter_table(struct wfx_vif *wvif, 29 + int tbl_len, struct hif_ie_table_entry *tbl); 30 + int hif_beacon_filter_control(struct wfx_vif *wvif, 31 + int enable, int beacon_count); 32 + int hif_set_operational_mode(struct wfx_dev *wdev, enum hif_op_power_mode mode); 33 + int hif_set_template_frame(struct wfx_vif *wvif, struct sk_buff *skb, 34 + u8 frame_type, int init_rate); 35 + int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required); 36 + int hif_set_block_ack_policy(struct wfx_vif *wvif, 37 + u8 tx_tid_policy, u8 rx_tid_policy); 38 + int hif_set_association_mode(struct wfx_vif *wvif, 39 + struct ieee80211_bss_conf *info); 40 + int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif, 41 + int policy_index, uint8_t *rates); 42 + int hif_set_mac_addr_condition(struct wfx_vif *wvif, 43 + int idx, const u8 *mac_addr); 44 + int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif, 45 + int idx, u8 allowed_frames); 46 + int hif_set_config_data_filter(struct wfx_vif *wvif, bool enable, int idx, 47 + int mac_filters, int frames_types_filters); 48 + int hif_set_data_filtering(struct wfx_vif *wvif, bool enable, bool invert); 49 + int hif_keep_alive_period(struct wfx_vif *wvif, int period); 50 + int hif_set_arp_ipv4_filter(struct wfx_vif *wvif, int idx, __be32 *addr); 51 + int hif_use_multi_tx_conf(struct wfx_dev *wdev, bool enable); 52 + int hif_set_uapsd_info(struct wfx_vif *wvif, unsigned long val); 53 + int hif_erp_use_protection(struct wfx_vif *wvif, bool enable); 54 + int hif_slot_time(struct wfx_vif *wvif, int val); 55 + int hif_dual_cts_protection(struct wfx_vif *wvif, bool enable); 56 + int hif_wep_default_key_id(struct wfx_vif *wvif, int val); 57 + int hif_rts_threshold(struct wfx_vif *wvif, int val); 405 58 406 59 #endif
+1
drivers/staging/wfx/key.c
··· 5 5 * Copyright (c) 2017-2019, Silicon Laboratories, Inc. 6 6 * Copyright (c) 2010, ST-Ericsson 7 7 */ 8 + #include <linux/etherdevice.h> 8 9 #include <net/mac80211.h> 9 10 10 11 #include "key.h"
+1
drivers/staging/wfx/sta.c
··· 5 5 * Copyright (c) 2017-2019, Silicon Laboratories, Inc. 6 6 * Copyright (c) 2010, ST-Ericsson 7 7 */ 8 + #include <linux/etherdevice.h> 8 9 #include <net/mac80211.h> 9 10 10 11 #include "sta.h"