37 static int iwl_sta_ucode_activate(
struct iwl_priv *
priv,
u8 sta_id)
42 IWL_ERR(priv,
"invalid sta_id %u", sta_id);
46 IWL_ERR(priv,
"ACTIVATE a non DRIVER active station id %u "
48 sta_id, priv->
stations[sta_id].sta.sta.addr);
52 "STA id %u addr %pM already present in uCode "
53 "(according to driver)\n",
54 sta_id, priv->
stations[sta_id].sta.sta.addr);
58 sta_id, priv->
stations[sta_id].sta.sta.addr);
63 static int iwl_process_add_sta_resp(
struct iwl_priv *priv,
68 u8 sta_id = addsta->
sta.sta_id;
72 IWL_ERR(priv,
"Bad return from REPLY_ADD_STA (0x%08X)\n",
77 IWL_DEBUG_INFO(priv,
"Processing response for adding station %u\n",
82 switch (add_sta_resp->
status) {
85 ret = iwl_sta_ucode_activate(priv, sta_id);
88 IWL_ERR(priv,
"Adding station %d failed, no room in table.\n",
92 IWL_ERR(priv,
"Adding station %d failed, no block ack "
93 "resource.\n", sta_id);
96 IWL_ERR(priv,
"Attempting to modify non-existing station %d\n",
108 sta_id, priv->
stations[sta_id].sta.sta.addr);
135 return iwl_process_add_sta_resp(priv, (
void *)cmd->
payload, pkt);
146 .len = {
sizeof(*sta), },
153 if (!(flags & CMD_ASYNC)) {
160 if (ret || (flags & CMD_ASYNC))
168 IWL_ERR(priv,
"%s - error in the CMD response %d", __func__,
178 if (!ctx->
ht.enabled || !ctx->
ht.is_40mhz)
181 #ifdef CONFIG_IWLWIFI_DEBUGFS
182 if (priv->disable_ht40)
202 static void iwl_sta_calc_ht_flags(
struct iwl_priv *priv,
227 "dynamic" :
"disabled");
229 switch (mimo_ps_mode) {
239 IWL_WARN(priv,
"Invalid MIMO PS mode %d\n", mimo_ps_mode);
256 u8 sta_id = iwl_sta_id(sta);
263 iwl_sta_calc_ht_flags(priv, sta, ctx, &flags, &mask);
266 priv->
stations[sta_id].sta.station_flags &= ~mask;
270 memset(&cmd, 0,
sizeof(cmd));
274 cmd.
sta.sta_id = sta_id;
285 iwl_sta_calc_ht_flags(priv, sta, ctx, &flags, &mask);
306 else if (is_broadcast_ether_addr(addr))
310 if (ether_addr_equal(priv->
stations[i].sta.sta.addr,
339 if ((priv->
stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
341 ether_addr_equal(priv->
stations[sta_id].sta.sta.addr, addr)) {
343 "adding again.\n", sta_id, addr);
356 station->
sta.mode = 0;
357 station->
sta.sta.sta_id = sta_id;
364 sta_priv = (
void *)sta->drv_priv;
373 iwl_set_ht_add_station(priv, sta_id, sta, ctx);
379 #define STA_WAIT_TIMEOUT (HZ/2)
385 const u8 *
addr,
bool is_ap,
396 IWL_ERR(priv,
"Unable to prepare station %pM for addition\n",
414 if ((priv->
stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
417 "adding again.\n", sta_id, addr);
431 IWL_ERR(priv,
"Adding station %pM failed.\n",
432 priv->
stations[sta_id].sta.sta.addr);
433 priv->
stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
434 priv->
stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
444 static void iwl_sta_ucode_deactivate(
struct iwl_priv *priv,
u8 sta_id)
452 IWL_ERR(priv,
"removed non active STA %u\n", sta_id);
460 static int iwl_send_remove_station(
struct iwl_priv *priv,
461 const u8 *
addr,
int sta_id,
472 .data = { &rm_sta_cmd, },
475 memset(&rm_sta_cmd, 0,
sizeof(rm_sta_cmd));
476 rm_sta_cmd.num_sta = 1;
488 IWL_ERR(priv,
"Bad return from REPLY_REMOVE_STA (0x%08X)\n",
495 switch (rem_sta_resp->
status) {
499 iwl_sta_ucode_deactivate(priv, sta_id);
506 IWL_ERR(priv,
"REPLY_REMOVE_STA failed\n");
523 if (!iwl_is_ready(priv)) {
525 "Unable to remove station %pM, device not ready.\n",
543 if (!(priv->
stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
562 sizeof(priv->
tid_data[sta_id][tid]));
564 priv->
stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
573 return iwl_send_remove_station(priv, addr, sta_id,
false);
584 if (!iwl_is_ready(priv)) {
586 "Unable to remove station %pM, device not ready.\n",
602 sizeof(priv->
tid_data[sta_id][tid]));
604 priv->
stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
623 memset(link_cmd, 0,
sizeof(*link_cmd));
629 else if (ctx && ctx->
vif && ctx->
vif->p2p)
637 rate_flags |= first_antenna(priv->
eeprom_data->valid_tx_ant) <<
639 rate_n_flags = iwl_hw_set_rate_n_flags(
iwl_rates[r].plcp, rate_flags);
641 link_cmd->
rs_table[i].rate_n_flags = rate_n_flags;
651 }
else if (num_of_ant(priv->
eeprom_data->valid_tx_ant) == 2) {
661 link_cmd->
sta_id = sta_id;
676 bool cleared =
false;
687 "Clearing ucode active for station %d\n", i);
688 priv->
stations[
i].used &= ~IWL_STA_UCODE_ACTIVE;
696 "No active stations found to be cleared\n");
716 if (!iwl_is_ready(priv)) {
718 "Not ready yet, not restoring any stations.\n");
727 if ((priv->
stations[i].used & IWL_STA_DRIVER_ACTIVE) &&
744 iwl_sta_fill_lq(priv, ctx, i, &lq);
754 IWL_ERR(priv,
"Adding station %pM failed.\n",
757 ~IWL_STA_DRIVER_ACTIVE;
759 ~IWL_STA_UCODE_INPROGRESS;
770 priv->
stations[
i].used &= ~IWL_STA_UCODE_INPROGRESS;
777 "no stations to be restored.\n");
813 #ifdef CONFIG_IWLWIFI_DEBUG
814 static void iwl_dump_lq_cmd(
struct iwl_priv *priv,
828 static inline void iwl_dump_lq_cmd(
struct iwl_priv *priv,
845 static bool is_lq_table_valid(
struct iwl_priv *priv,
860 "index %d of LQ expects HT channel\n",
900 iwl_dump_lq_cmd(priv, lq);
904 if (is_lq_table_valid(priv, ctx, lq))
914 "clearing sta addition status for sta %d\n",
932 IWL_ERR(priv,
"Unable to allocate memory for LQ cmd.\n");
936 iwl_sta_fill_lq(priv, ctx, sta_id, link_cmd);
948 const u8 *addr,
u8 *sta_id_r)
959 IWL_ERR(priv,
"Unable to add station %pM\n", addr);
971 link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id);
974 "Unable to initialize rate scaling for station %pM.\n",
981 IWL_ERR(priv,
"Link quality command failed (%d)\n", ret);
998 static int iwl_send_static_wepkey_cmd(
struct iwl_priv *priv,
1002 int i, not_empty = 0;
1009 .data = { wep_cmd, },
1015 memset(wep_cmd, 0, cmd_size +
1019 wep_cmd->
key[
i].key_index =
i;
1021 wep_cmd->
key[
i].key_offset =
i;
1039 if (not_empty || send_if_empty)
1050 return iwl_send_static_wepkey_cmd(priv, ctx,
false);
1065 if (iwl_is_rfkill(priv)) {
1067 "Not sending REPLY_WEPKEY command due to RFKILL.\n");
1071 ret = iwl_send_static_wepkey_cmd(priv, ctx, 1);
1072 IWL_DEBUG_WEP(priv,
"Remove default WEP key: idx=%d ret=%d\n",
1089 "Bad WEP key length %d\n", keyconf->
keylen);
1099 ret = iwl_send_static_wepkey_cmd(priv, ctx,
false);
1100 IWL_DEBUG_WEP(priv,
"Set default WEP key: len=%d idx=%d ret=%d\n",
1121 static u8 iwlagn_key_sta_id(
struct iwl_priv *priv,
1128 return iwl_sta_id(sta);
1136 return vif_priv->
ctx->ap_sta_id;
1141 static int iwlagn_send_sta_key(
struct iwl_priv *priv,
1143 u8 sta_id,
u32 tkip_iv32,
u16 *tkip_p1k,
1157 switch (keyconf->
cipher) {
1164 sta_cmd.key.tkip_rx_tsc_byte2 = tkip_iv32;
1165 for (i = 0; i < 5; i++)
1166 sta_cmd.key.tkip_rx_ttak[i] =
cpu_to_le16(tkip_p1k[i]);
1185 sta_cmd.key.key_offset = keyconf->
hw_key_idx;
1187 sta_cmd.key.key_flags = key_flags;
1199 u8 sta_id = iwlagn_key_sta_id(priv, vif, sta);
1210 iwlagn_send_sta_key(priv, keyconf, sta_id,
1220 u8 sta_id = iwlagn_key_sta_id(priv, ctx->
vif, sta);
1241 keyconf->
keyidx, sta_id);
1244 IWL_ERR(priv,
"offset %d not used in uCode key table.\n",
1254 sta_cmd.
key.key_flags = key_flags;
1270 u8 sta_id = iwlagn_key_sta_id(priv, ctx->
vif, sta);
1284 switch (keyconf->
cipher) {
1289 addr = ctx->
active.bssid_addr;
1294 ret = iwlagn_send_sta_key(priv, keyconf, sta_id,
1300 ret = iwlagn_send_sta_key(priv, keyconf, sta_id,
1313 IWL_DEBUG_WEP(priv,
"Set dynamic key: cipher=%x len=%d idx=%d sta=%pM ret=%d\n",
1336 IWL_ERR(priv,
"Unable to prepare broadcast station\n");
1346 link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id);
1349 "Unable to initialize rate scaling for bcast station.\n");
1372 link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id);
1374 IWL_ERR(priv,
"Unable to initialize rate scaling for bcast station.\n");
1382 IWL_DEBUG_INFO(priv,
"Bcast station rate scaling has not been initialized yet.\n");
1431 sta_id = iwl_sta_id(sta);
1436 priv->
stations[sta_id].sta.station_flags_msk = 0;
1438 priv->
stations[sta_id].sta.add_immediate_ba_tid = (
u8)tid;
1455 sta_id = iwl_sta_id(sta);
1457 IWL_ERR(priv,
"Invalid station for AGG tid %d\n", tid);
1462 priv->
stations[sta_id].sta.station_flags_msk = 0;
1464 priv->
stations[sta_id].sta.remove_immediate_ba_tid = (
u8)tid;
1480 .sta.sta_id = sta_id,