22 #include <linux/module.h>
30 #include <linux/slab.h>
47 wl->
if_ops->enable_irq(wl);
52 wl->
if_ops->disable_irq(wl);
55 static int wl1251_power_off(
struct wl1251 *wl)
57 return wl->
if_ops->power(wl,
false);
60 static int wl1251_power_on(
struct wl1251 *wl)
62 return wl->
if_ops->power(wl,
true);
65 static int wl1251_fetch_firmware(
struct wl1251 *wl)
79 wl1251_error(
"firmware size is not multiple of 32 bits: %zu",
89 wl1251_error(
"could not allocate memory for the firmware");
104 static int wl1251_fetch_nvs(
struct wl1251 *wl)
107 struct device *dev = wiphy_dev(wl->
hw->wiphy);
118 wl1251_error(
"nvs size is not multiple of 32 bits: %zu",
128 wl1251_error(
"could not allocate memory for the nvs file");
141 static void wl1251_fw_wakeup(
struct wl1251 *wl)
153 static int wl1251_chip_wakeup(
struct wl1251 *wl)
157 ret = wl1251_power_on(wl);
173 wl1251_fw_wakeup(wl);
199 ret = wl1251_fetch_firmware(wl);
206 ret = wl1251_fetch_nvs(wl);
215 #define WL1251_IRQ_LOOP_COUNT 10
248 "RX: FW and host in sync");
264 "RX: FW and host out of sync: %d",
309 "WL1251_ACX_INTR_INIT_COMPLETE");
341 if (is_zero_ether_addr(wl->
bssid))
383 spin_unlock_irqrestore(&wl->
wl_lock, flags);
398 wl1251_error(
"cannot start because not in off state: %d",
404 ret = wl1251_chip_wakeup(wl);
430 wl1251_power_off(wl);
468 wl1251_power_off(wl);
492 static int wl1251_op_add_interface(
struct ieee80211_hw *hw,
526 SET_IEEE80211_PERM_ADDR(wl->
hw, wl->
mac_addr);
537 static void wl1251_op_remove_interface(
struct ieee80211_hw *hw,
548 static int wl1251_build_qos_null_data(
struct wl1251 *wl)
552 memset(&
template, 0,
sizeof(
template));
659 #define WL1251_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \
662 FIF_BCN_PRBRESP_PROMISC | \
667 static void wl1251_op_configure_filter(
struct ieee80211_hw *hw,
668 unsigned int changed,
669 unsigned int *total,
u64 multicast)
728 static int wl1251_set_key_type(
struct wl1251 *wl,
734 switch (mac80211_key->
cipher) {
737 if (is_broadcast_ether_addr(addr))
745 if (is_broadcast_ether_addr(addr))
753 if (is_broadcast_ether_addr(addr))
778 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
782 wl_cmd = kzalloc(
sizeof(*wl_cmd),
GFP_KERNEL);
788 addr = sta ? sta->
addr : bcast_addr;
796 if (is_zero_ether_addr(addr)) {
820 ret = wl1251_set_key_type(wl, wl_cmd, cmd, key, addr);
882 ssid = req->
ssids[0].ssid;
883 ssid_len = req->
ssids[0].ssid_len;
956 static void wl1251_op_bss_info_changed(
struct ieee80211_hw *hw,
996 ret = wl1251_build_qos_null_data(wl);
1009 if (bss_conf->
assoc) {
1062 beacon = ieee80211_beacon_get(hw, vif);
1070 dev_kfree_skb(beacon);
1077 dev_kfree_skb(beacon);
1101 .hw_value_short = 0x1, },
1104 .hw_value_short = 0x2,
1108 .hw_value_short = 0x4,
1112 .hw_value_short = 0x20,
1116 .hw_value_short = 0x8, },
1119 .hw_value_short = 0x10, },
1122 .hw_value_short = 0x40, },
1125 .hw_value_short = 0x80, },
1128 .hw_value_short = 0x200, },
1131 .hw_value_short = 0x400, },
1134 .hw_value_short = 0x800, },
1137 .hw_value_short = 0x1000, },
1142 { .hw_value = 1, .center_freq = 2412},
1143 { .hw_value = 2, .center_freq = 2417},
1144 { .hw_value = 3, .center_freq = 2422},
1145 { .hw_value = 4, .center_freq = 2427},
1146 { .hw_value = 5, .center_freq = 2432},
1147 { .hw_value = 6, .center_freq = 2437},
1148 { .hw_value = 7, .center_freq = 2442},
1149 { .hw_value = 8, .center_freq = 2447},
1150 { .hw_value = 9, .center_freq = 2452},
1151 { .hw_value = 10, .center_freq = 2457},
1152 { .hw_value = 11, .center_freq = 2462},
1153 { .hw_value = 12, .center_freq = 2467},
1154 { .hw_value = 13, .center_freq = 2472},
1187 wl1251_tx_get_queue(queue), ps_scheme,
1219 .channels = wl1251_channels,
1221 .bitrates = wl1251_rates,
1226 .start = wl1251_op_start,
1227 .stop = wl1251_op_stop,
1228 .add_interface = wl1251_op_add_interface,
1229 .remove_interface = wl1251_op_remove_interface,
1230 .config = wl1251_op_config,
1231 .configure_filter = wl1251_op_configure_filter,
1233 .set_key = wl1251_op_set_key,
1234 .hw_scan = wl1251_op_hw_scan,
1235 .bss_info_changed = wl1251_op_bss_info_changed,
1236 .set_rts_threshold = wl1251_op_set_rts_threshold,
1237 .conf_tx = wl1251_op_conf_tx,
1238 .get_survey = wl1251_op_get_survey,
1264 static int wl1251_read_eeprom(
struct wl1251 *wl,
off_t offset,
1265 u8 *data,
size_t len)
1272 for (i = 0; i < len; i++) {
1273 ret = wl1251_read_eeprom_byte(wl, offset + i, &data[i]);
1281 static int wl1251_read_eeprom_mac(
struct wl1251 *wl)
1288 ret = wl1251_read_eeprom(wl, 0x1c, mac,
sizeof(mac));
1296 wl->
mac_addr[i] = mac[ETH_ALEN - i - 1];
1301 static int wl1251_register_hw(
struct wl1251 *wl)
1308 SET_IEEE80211_PERM_ADDR(wl->
hw, wl->
mac_addr);
1312 wl1251_error(
"unable to register mac80211 hw: %d", ret);
1333 wl->
hw->channel_change_time = 10000;
1341 wl->
hw->wiphy->max_scan_ssids = 1;
1347 wl1251_read_eeprom_mac(wl);
1349 ret = wl1251_register_hw(wl);
1368 static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
1377 memset(wl, 0,
sizeof(*wl));
1383 skb_queue_head_init(&wl->
tx_queue);
1429 wl1251_error(
"could not allocate memory for rx descriptor");