29 #include <linux/kernel.h>
30 #include <linux/module.h>
32 #include <linux/slab.h>
35 #include <linux/sched.h>
37 #include <linux/netdevice.h>
39 #include <linux/if_arp.h>
44 #include <asm/div64.h>
103 iwlagn_iface_combinations_dualmode[] = {
104 { .num_different_channels = 1,
106 .beacon_int_infra_match =
true,
107 .limits = iwlagn_sta_ap_limits,
110 { .num_different_channels = 1,
112 .limits = iwlagn_2sta_limits,
118 iwlagn_iface_combinations_p2p[] = {
119 { .num_different_channels = 1,
121 .beacon_int_infra_match =
true,
122 .limits = iwlagn_p2p_sta_go_limits,
123 .n_limits =
ARRAY_SIZE(iwlagn_p2p_sta_go_limits),
125 { .num_different_channels = 1,
127 .limits = iwlagn_p2p_2sta_limits,
128 .n_limits =
ARRAY_SIZE(iwlagn_p2p_2sta_limits),
171 #ifndef CONFIG_IWLWIFI_EXPERIMENTAL_MFP
188 hw->
wiphy->iface_combinations = iwlagn_iface_combinations_p2p;
189 hw->
wiphy->n_iface_combinations =
192 hw->
wiphy->iface_combinations =
193 iwlagn_iface_combinations_dualmode;
194 hw->
wiphy->n_iface_combinations =
195 ARRAY_SIZE(iwlagn_iface_combinations_dualmode);
198 hw->
wiphy->max_remain_on_channel_duration = 500;
204 #ifdef CONFIG_PM_SLEEP
206 priv->
trans->ops->wowlan_suspend &&
207 device_can_wakeup(priv->
trans->dev)) {
213 hw->
wiphy->wowlan.flags |=
218 hw->
wiphy->wowlan.pattern_min_len =
220 hw->
wiphy->wowlan.pattern_max_len =
255 IWL_ERR(priv,
"Failed to register hw (error %d)\n", ret);
281 IWL_WARN(priv,
"Exit pending; will not bring the NIC up\n");
295 IWL_ERR(priv,
"Failed to run INIT ucode: %d\n", ret);
301 IWL_ERR(priv,
"Failed to start RT ucode: %d\n", ret);
315 IWL_ERR(priv,
"Unable to initialize device.\n");
328 ret = __iwl_up(priv);
369 iwl_trans_stop_hw(priv->
trans,
false);
374 static void iwlagn_mac_set_rekey_data(
struct ieee80211_hw *hw,
400 #ifdef CONFIG_PM_SLEEP
417 !iwl_is_associated_ctx(ctx)) {
422 ret = iwlagn_suspend(priv, wowlan);
426 iwl_trans_wowlan_suspend(priv->
trans);
465 spin_unlock_irqrestore(&priv->
trans->reg_lock, flags);
467 #ifdef CONFIG_IWLWIFI_DEBUGFS
472 if (!priv->wowlan_sram) {
478 if (priv->wowlan_sram)
480 priv->
trans, 0x800000,
521 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->
bitrate);
527 static void iwlagn_mac_update_tkip_key(
struct ieee80211_hw *hw,
547 bool is_default_wep_key =
false;
607 if (is_default_wep_key) {
624 if (is_default_wep_key)
641 static int iwlagn_mac_ampdu_action(
struct ieee80211_hw *hw,
651 IWL_DEBUG_HT(priv,
"A-MPDU action on addr %pM tid %d\n",
672 if (!priv->
trans->ops->txq_enable)
688 priv->
hw_params.use_rts_for_aggregation) {
692 sta_priv->
lq_sta.lq.general_params.flags &=
727 is_ap, sta, &sta_id);
729 IWL_ERR(priv,
"Unable to add station %pM (%d)\n",
740 static int iwlagn_mac_sta_remove(
struct ieee80211_hw *hw,
762 "Error removing station %pM\n", sta->
addr);
767 static int iwlagn_mac_sta_state(
struct ieee80211_hw *hw,
805 ret = iwlagn_mac_sta_add(hw, vif, sta);
815 priv->
stations[iwl_sta_id(sta)].used &=
820 ret = iwlagn_mac_sta_remove(hw, vif, sta);
823 ret = iwlagn_mac_sta_add(hw, vif, sta);
828 "Initializing rate scaling for station %pM\n",
839 "Initializing rate scaling for station %pM\n",
853 if (iwl_is_rfkill(priv))
862 static void iwlagn_mac_channel_switch(
struct ieee80211_hw *hw,
884 if (iwl_is_rfkill(priv))
892 if (!iwl_is_associated_ctx(ctx))
895 if (!priv->
lib->set_channel_switch)
905 ctx->
ht.enabled = conf_is_ht(conf);
909 ctx->
ht.is_40mhz =
false;
924 if (priv->
lib->set_channel_switch(priv, ch_switch)) {
950 static void iwlagn_configure_filter(
struct ieee80211_hw *hw,
951 unsigned int changed_flags,
952 unsigned int *total_flags,
956 __le32 filter_or = 0, filter_nand = 0;
959 #define CHK(test, flag) do { \
960 if (*total_flags & (test)) \
961 filter_or |= (flag); \
963 filter_nand |= (flag); \
967 changed_flags, *total_flags);
979 ctx->
staging.filter_flags &= ~filter_nand;
980 ctx->
staging.filter_flags |= filter_or;
1000 static void iwlagn_mac_flush(
struct ieee80211_hw *hw,
bool drop)
1008 IWL_DEBUG_TX(priv,
"Aborting flush due to device shutdown\n");
1011 if (iwl_is_rfkill(priv)) {
1023 IWL_ERR(priv,
"flush request fail\n");
1028 iwl_trans_wait_tx_queue_empty(priv->
trans);
1034 static int iwlagn_mac_remain_on_channel(
struct ieee80211_hw *hw,
1137 static int iwlagn_mac_cancel_remain_on_channel(
struct ieee80211_hw *hw)
1154 static void iwlagn_mac_rssi_callback(
struct ieee80211_hw *hw,
1162 if (priv->
cfg->bt_params &&
1163 priv->
cfg->bt_params->advanced_bt_coexist) {
1172 "ignoring RSSI callback\n");
1203 if (!iwl_is_ready_rf(priv)) {
1217 ctx->
qos_data.def_qos_parm.ac[
q].cw_min =
1219 ctx->
qos_data.def_qos_parm.ac[
q].cw_max =
1222 ctx->
qos_data.def_qos_parm.ac[
q].edca_txop =
1225 ctx->
qos_data.def_qos_parm.ac[
q].reserved1 = 0;
1233 static int iwlagn_mac_tx_last_beacon(
struct ieee80211_hw *hw)
1249 static int iwl_setup_interface(
struct iwl_priv *priv,
1266 err = iwl_set_mode(priv, ctx);
1273 if (priv->
cfg->bt_params && priv->
cfg->bt_params->advanced_bt_coexist &&
1295 static int iwlagn_mac_add_interface(
struct ieee80211_hw *hw,
1306 viftype, vif->
addr);
1314 if (!iwl_is_ready_rf(priv)) {
1315 IWL_WARN(priv,
"Try to add interface when device not ready\n");
1321 u32 possible_modes =
1326 if (tmp->
vif == vif) {
1341 if (!(possible_modes &
BIT(viftype)))
1371 err = iwl_setup_interface(priv, ctx);
1384 static void iwl_teardown_interface(
struct iwl_priv *priv,
1398 iwl_set_mode(priv, ctx);
1414 static void iwlagn_mac_remove_interface(
struct ieee80211_hw *hw,
1426 IWL_ERR(priv,
"ctx->vif = %p, vif = %p\n", ctx->
vif, vif);
1428 IWL_ERR(priv, "\tID = %
d:\tctx = %
p\tctx->vif = %
p\
n",
1429 tmp->
ctxid, tmp, tmp->vif);
1433 iwl_teardown_interface(priv, vif,
false);
1437 IWL_DEBUG_MAC80211(priv, "
leave\n");
1453 newtype = ieee80211_iftype_p2p(newtype, newp2p);
1457 ctx = iwl_rxon_ctx_from_vif(vif);
1469 if (!ctx->
vif || !iwl_is_ready_rf(priv)) {
1480 if (!(interface_modes &
BIT(newtype))) {
1503 iwl_teardown_interface(priv, vif,
true);
1504 vif->type = newviftype;
1506 err = iwl_setup_interface(priv, ctx);
1544 "SCAN request during internal scan - defer\n");
1570 static void iwl_sta_modify_ps_wake(
struct iwl_priv *priv,
int sta_id)
1575 .sta.sta_id = sta_id,
1581 static void iwlagn_mac_sta_notify(
struct ieee80211_hw *hw,
1603 sta_priv->
asleep =
false;
1604 sta_id = iwl_sta_id(sta);
1606 iwl_sta_modify_ps_wake(priv, sta_id);
1615 .tx = iwlagn_mac_tx,
1616 .start = iwlagn_mac_start,
1617 .stop = iwlagn_mac_stop,
1618 #ifdef CONFIG_PM_SLEEP
1619 .suspend = iwlagn_mac_suspend,
1620 .resume = iwlagn_mac_resume,
1621 .set_wakeup = iwlagn_mac_set_wakeup,
1623 .add_interface = iwlagn_mac_add_interface,
1624 .remove_interface = iwlagn_mac_remove_interface,
1625 .change_interface = iwlagn_mac_change_interface,
1627 .configure_filter = iwlagn_configure_filter,
1628 .set_key = iwlagn_mac_set_key,
1629 .update_tkip_key = iwlagn_mac_update_tkip_key,
1630 .set_rekey_data = iwlagn_mac_set_rekey_data,
1631 .conf_tx = iwlagn_mac_conf_tx,
1633 .ampdu_action = iwlagn_mac_ampdu_action,
1634 .hw_scan = iwlagn_mac_hw_scan,
1635 .sta_notify = iwlagn_mac_sta_notify,
1636 .sta_state = iwlagn_mac_sta_state,
1637 .channel_switch = iwlagn_mac_channel_switch,
1638 .flush = iwlagn_mac_flush,
1639 .tx_last_beacon = iwlagn_mac_tx_last_beacon,
1640 .remain_on_channel = iwlagn_mac_remain_on_channel,
1641 .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel,
1642 .rssi_callback = iwlagn_mac_rssi_callback,
1645 .set_tim = iwlagn_mac_set_tim,