Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
| 4 | * |
| 5 | * Portions of this file are derived from the ipw3945 project, as well |
| 6 | * as portions of the ieee80211 subsystem header files. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of version 2 of the GNU General Public License as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 | * more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 20 | * |
| 21 | * The full GNU General Public License is included in this distribution in the |
| 22 | * file called LICENSE. |
| 23 | * |
| 24 | * Contact Information: |
| 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | * |
| 28 | *****************************************************************************/ |
| 29 | |
| 30 | #include <net/mac80211.h> |
| 31 | #include <linux/etherdevice.h> |
| 32 | #include <linux/sched.h> |
| 33 | #include <linux/lockdep.h> |
Paul Gortmaker | ee40fa0 | 2011-05-27 16:14:23 -0400 | [diff] [blame] | 34 | #include <linux/export.h> |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 35 | |
| 36 | #include "iwl-dev.h" |
| 37 | #include "iwl-core.h" |
| 38 | #include "iwl-sta.h" |
| 39 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 40 | /* il->sta_lock must be held */ |
| 41 | static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 42 | { |
| 43 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 44 | if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 45 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 46 | "ACTIVATE a non DRIVER active station id %u addr %pM\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 47 | sta_id, il->stations[sta_id].sta.sta.addr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 48 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 49 | if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 50 | D_ASSOC( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 51 | "STA id %u addr %pM already present" |
| 52 | " in uCode (according to driver)\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 53 | sta_id, il->stations[sta_id].sta.sta.addr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 54 | } else { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 55 | il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 56 | D_ASSOC("Added STA id %u addr %pM to uCode\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 57 | sta_id, il->stations[sta_id].sta.sta.addr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 58 | } |
| 59 | } |
| 60 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 61 | static int il_process_add_sta_resp(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 62 | struct il_addsta_cmd *addsta, |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 63 | struct il_rx_pkt *pkt, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 64 | bool sync) |
| 65 | { |
| 66 | u8 sta_id = addsta->sta.sta_id; |
| 67 | unsigned long flags; |
| 68 | int ret = -EIO; |
| 69 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 70 | if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 71 | IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 72 | pkt->hdr.flags); |
| 73 | return ret; |
| 74 | } |
| 75 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 76 | D_INFO("Processing response for adding station %u\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 77 | sta_id); |
| 78 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 79 | spin_lock_irqsave(&il->sta_lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 80 | |
| 81 | switch (pkt->u.add_sta.status) { |
| 82 | case ADD_STA_SUCCESS_MSK: |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 83 | D_INFO("C_ADD_STA PASSED\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 84 | il_sta_ucode_activate(il, sta_id); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 85 | ret = 0; |
| 86 | break; |
Stanislaw Gruszka | 3b98c7f | 2011-08-26 16:29:35 +0200 | [diff] [blame] | 87 | case ADD_STA_NO_ROOM_IN_TBL: |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 88 | IL_ERR("Adding station %d failed, no room in table.\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 89 | sta_id); |
| 90 | break; |
| 91 | case ADD_STA_NO_BLOCK_ACK_RESOURCE: |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 92 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 93 | "Adding station %d failed, no block ack resource.\n", |
| 94 | sta_id); |
| 95 | break; |
| 96 | case ADD_STA_MODIFY_NON_EXIST_STA: |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 97 | IL_ERR("Attempting to modify non-existing station %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 98 | sta_id); |
| 99 | break; |
| 100 | default: |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 101 | D_ASSOC("Received C_ADD_STA:(0x%08X)\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 102 | pkt->u.add_sta.status); |
| 103 | break; |
| 104 | } |
| 105 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 106 | D_INFO("%s station id %u addr %pM\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 107 | il->stations[sta_id].sta.mode == |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 108 | STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 109 | sta_id, il->stations[sta_id].sta.sta.addr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 110 | |
| 111 | /* |
| 112 | * XXX: The MAC address in the command buffer is often changed from |
| 113 | * the original sent to the device. That is, the MAC address |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 114 | * written to the command buffer often is not the same MAC address |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 115 | * read from the command buffer when the command returns. This |
| 116 | * issue has not yet been resolved and this debugging is left to |
| 117 | * observe the problem. |
| 118 | */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 119 | D_INFO("%s station according to cmd buffer %pM\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 120 | il->stations[sta_id].sta.mode == |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 121 | STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", |
| 122 | addsta->sta.addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 123 | spin_unlock_irqrestore(&il->sta_lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 124 | |
| 125 | return ret; |
| 126 | } |
| 127 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 128 | static void il_add_sta_callback(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 129 | struct il_device_cmd *cmd, |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 130 | struct il_rx_pkt *pkt) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 131 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 132 | struct il_addsta_cmd *addsta = |
| 133 | (struct il_addsta_cmd *)cmd->cmd.payload; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 134 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 135 | il_process_add_sta_resp(il, addsta, pkt, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 136 | |
| 137 | } |
| 138 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 139 | int il_send_add_sta(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 140 | struct il_addsta_cmd *sta, u8 flags) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 141 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 142 | struct il_rx_pkt *pkt = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 143 | int ret = 0; |
| 144 | u8 data[sizeof(*sta)]; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 145 | struct il_host_cmd cmd = { |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 146 | .id = C_ADD_STA, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 147 | .flags = flags, |
| 148 | .data = data, |
| 149 | }; |
| 150 | u8 sta_id __maybe_unused = sta->sta.sta_id; |
| 151 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 152 | D_INFO("Adding sta %u (%pM) %ssynchronously\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 153 | sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); |
| 154 | |
| 155 | if (flags & CMD_ASYNC) |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 156 | cmd.callback = il_add_sta_callback; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 157 | else { |
| 158 | cmd.flags |= CMD_WANT_SKB; |
| 159 | might_sleep(); |
| 160 | } |
| 161 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 162 | cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); |
| 163 | ret = il_send_cmd(il, &cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 164 | |
| 165 | if (ret || (flags & CMD_ASYNC)) |
| 166 | return ret; |
| 167 | |
| 168 | if (ret == 0) { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 169 | pkt = (struct il_rx_pkt *)cmd.reply_page; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 170 | ret = il_process_add_sta_resp(il, sta, pkt, true); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 171 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 172 | il_free_pages(il, cmd.reply_page); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 173 | |
| 174 | return ret; |
| 175 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 176 | EXPORT_SYMBOL(il_send_add_sta); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 177 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 178 | static void il_set_ht_add_station(struct il_priv *il, u8 idx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 179 | struct ieee80211_sta *sta, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 180 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 181 | { |
| 182 | struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; |
| 183 | __le32 sta_flags; |
| 184 | u8 mimo_ps_mode; |
| 185 | |
| 186 | if (!sta || !sta_ht_inf->ht_supported) |
| 187 | goto done; |
| 188 | |
| 189 | mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 190 | D_ASSOC("spatial multiplexing power save mode: %s\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 191 | (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? |
| 192 | "static" : |
| 193 | (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? |
| 194 | "dynamic" : "disabled"); |
| 195 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 196 | sta_flags = il->stations[idx].sta.station_flags; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 197 | |
| 198 | sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); |
| 199 | |
| 200 | switch (mimo_ps_mode) { |
| 201 | case WLAN_HT_CAP_SM_PS_STATIC: |
| 202 | sta_flags |= STA_FLG_MIMO_DIS_MSK; |
| 203 | break; |
| 204 | case WLAN_HT_CAP_SM_PS_DYNAMIC: |
| 205 | sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK; |
| 206 | break; |
| 207 | case WLAN_HT_CAP_SM_PS_DISABLED: |
| 208 | break; |
| 209 | default: |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 210 | IL_WARN("Invalid MIMO PS mode %d\n", mimo_ps_mode); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 211 | break; |
| 212 | } |
| 213 | |
| 214 | sta_flags |= cpu_to_le32( |
| 215 | (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); |
| 216 | |
| 217 | sta_flags |= cpu_to_le32( |
| 218 | (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); |
| 219 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 220 | if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 221 | sta_flags |= STA_FLG_HT40_EN_MSK; |
| 222 | else |
| 223 | sta_flags &= ~STA_FLG_HT40_EN_MSK; |
| 224 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 225 | il->stations[idx].sta.station_flags = sta_flags; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 226 | done: |
| 227 | return; |
| 228 | } |
| 229 | |
| 230 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 231 | * il_prep_station - Prepare station information for addition |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 232 | * |
| 233 | * should be called with sta_lock held |
| 234 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 235 | u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 236 | const u8 *addr, bool is_ap, struct ieee80211_sta *sta) |
| 237 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 238 | struct il_station_entry *station; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 239 | int i; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 240 | u8 sta_id = IL_INVALID_STATION; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 241 | u16 rate; |
| 242 | |
| 243 | if (is_ap) |
| 244 | sta_id = ctx->ap_sta_id; |
| 245 | else if (is_broadcast_ether_addr(addr)) |
| 246 | sta_id = ctx->bcast_sta_id; |
| 247 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 248 | for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { |
| 249 | if (!compare_ether_addr(il->stations[i].sta.sta.addr, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 250 | addr)) { |
| 251 | sta_id = i; |
| 252 | break; |
| 253 | } |
| 254 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 255 | if (!il->stations[i].used && |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 256 | sta_id == IL_INVALID_STATION) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 257 | sta_id = i; |
| 258 | } |
| 259 | |
| 260 | /* |
| 261 | * These two conditions have the same outcome, but keep them |
| 262 | * separate |
| 263 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 264 | if (unlikely(sta_id == IL_INVALID_STATION)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 265 | return sta_id; |
| 266 | |
| 267 | /* |
| 268 | * uCode is not able to deal with multiple requests to add a |
| 269 | * station. Keep track if one is in progress so that we do not send |
| 270 | * another. |
| 271 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 272 | if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 273 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 274 | "STA %d already in process of being added.\n", |
| 275 | sta_id); |
| 276 | return sta_id; |
| 277 | } |
| 278 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 279 | if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && |
| 280 | (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && |
| 281 | !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 282 | D_ASSOC( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 283 | "STA %d (%pM) already added, not adding again.\n", |
| 284 | sta_id, addr); |
| 285 | return sta_id; |
| 286 | } |
| 287 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 288 | station = &il->stations[sta_id]; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 289 | station->used = IL_STA_DRIVER_ACTIVE; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 290 | D_ASSOC("Add STA to driver ID %d: %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 291 | sta_id, addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 292 | il->num_stations++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 293 | |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 294 | /* Set up the C_ADD_STA command to send to device */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 295 | memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 296 | memcpy(station->sta.sta.addr, addr, ETH_ALEN); |
| 297 | station->sta.mode = 0; |
| 298 | station->sta.sta.sta_id = sta_id; |
| 299 | station->sta.station_flags = ctx->station_flags; |
| 300 | station->ctxid = ctx->ctxid; |
| 301 | |
| 302 | if (sta) { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 303 | struct il_station_priv_common *sta_priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 304 | |
| 305 | sta_priv = (void *)sta->drv_priv; |
| 306 | sta_priv->ctx = ctx; |
| 307 | } |
| 308 | |
| 309 | /* |
| 310 | * OK to call unconditionally, since local stations (IBSS BSSID |
| 311 | * STA and broadcast STA) pass in a NULL sta, and mac80211 |
| 312 | * doesn't allow HT IBSS. |
| 313 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 314 | il_set_ht_add_station(il, sta_id, sta, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 315 | |
| 316 | /* 3945 only */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 317 | rate = (il->band == IEEE80211_BAND_5GHZ) ? |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 318 | RATE_6M_PLCP : RATE_1M_PLCP; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 319 | /* Turn on both antennas for the station... */ |
| 320 | station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); |
| 321 | |
| 322 | return sta_id; |
| 323 | |
| 324 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 325 | EXPORT_SYMBOL_GPL(il_prep_station); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 326 | |
| 327 | #define STA_WAIT_TIMEOUT (HZ/2) |
| 328 | |
| 329 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 330 | * il_add_station_common - |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 331 | */ |
| 332 | int |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 333 | il_add_station_common(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 334 | struct il_rxon_context *ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 335 | const u8 *addr, bool is_ap, |
| 336 | struct ieee80211_sta *sta, u8 *sta_id_r) |
| 337 | { |
| 338 | unsigned long flags_spin; |
| 339 | int ret = 0; |
| 340 | u8 sta_id; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 341 | struct il_addsta_cmd sta_cmd; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 342 | |
| 343 | *sta_id_r = 0; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 344 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
| 345 | sta_id = il_prep_station(il, ctx, addr, is_ap, sta); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 346 | if (sta_id == IL_INVALID_STATION) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 347 | IL_ERR("Unable to prepare station %pM for addition\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 348 | addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 349 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 350 | return -EINVAL; |
| 351 | } |
| 352 | |
| 353 | /* |
| 354 | * uCode is not able to deal with multiple requests to add a |
| 355 | * station. Keep track if one is in progress so that we do not send |
| 356 | * another. |
| 357 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 358 | if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 359 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 360 | "STA %d already in process of being added.\n", |
| 361 | sta_id); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 362 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 363 | return -EEXIST; |
| 364 | } |
| 365 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 366 | if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && |
| 367 | (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 368 | D_ASSOC( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 369 | "STA %d (%pM) already added, not adding again.\n", |
| 370 | sta_id, addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 371 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 372 | return -EEXIST; |
| 373 | } |
| 374 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 375 | il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; |
| 376 | memcpy(&sta_cmd, &il->stations[sta_id].sta, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 377 | sizeof(struct il_addsta_cmd)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 378 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 379 | |
| 380 | /* Add station to device's station table */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 381 | ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 382 | if (ret) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 383 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 384 | IL_ERR("Adding station %pM failed.\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 385 | il->stations[sta_id].sta.sta.addr); |
| 386 | il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; |
| 387 | il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; |
| 388 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 389 | } |
| 390 | *sta_id_r = sta_id; |
| 391 | return ret; |
| 392 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 393 | EXPORT_SYMBOL(il_add_station_common); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 394 | |
| 395 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 396 | * il_sta_ucode_deactivate - deactivate ucode status for a station |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 397 | * |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 398 | * il->sta_lock must be held |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 399 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 400 | static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 401 | { |
| 402 | /* Ucode must be active and driver must be non active */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 403 | if ((il->stations[sta_id].used & |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 404 | (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != |
| 405 | IL_STA_UCODE_ACTIVE) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 406 | IL_ERR("removed non active STA %u\n", sta_id); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 407 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 408 | il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 409 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 410 | memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 411 | D_ASSOC("Removed STA %u\n", sta_id); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 412 | } |
| 413 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 414 | static int il_send_remove_station(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 415 | const u8 *addr, int sta_id, |
| 416 | bool temporary) |
| 417 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 418 | struct il_rx_pkt *pkt; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 419 | int ret; |
| 420 | |
| 421 | unsigned long flags_spin; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 422 | struct il_rem_sta_cmd rm_sta_cmd; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 423 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 424 | struct il_host_cmd cmd = { |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 425 | .id = C_REM_STA, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 426 | .len = sizeof(struct il_rem_sta_cmd), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 427 | .flags = CMD_SYNC, |
| 428 | .data = &rm_sta_cmd, |
| 429 | }; |
| 430 | |
| 431 | memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd)); |
| 432 | rm_sta_cmd.num_sta = 1; |
| 433 | memcpy(&rm_sta_cmd.addr, addr, ETH_ALEN); |
| 434 | |
| 435 | cmd.flags |= CMD_WANT_SKB; |
| 436 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 437 | ret = il_send_cmd(il, &cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 438 | |
| 439 | if (ret) |
| 440 | return ret; |
| 441 | |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 442 | pkt = (struct il_rx_pkt *)cmd.reply_page; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 443 | if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 444 | IL_ERR("Bad return from C_REM_STA (0x%08X)\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 445 | pkt->hdr.flags); |
| 446 | ret = -EIO; |
| 447 | } |
| 448 | |
| 449 | if (!ret) { |
| 450 | switch (pkt->u.rem_sta.status) { |
| 451 | case REM_STA_SUCCESS_MSK: |
| 452 | if (!temporary) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 453 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
| 454 | il_sta_ucode_deactivate(il, sta_id); |
| 455 | spin_unlock_irqrestore(&il->sta_lock, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 456 | flags_spin); |
| 457 | } |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 458 | D_ASSOC("C_REM_STA PASSED\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 459 | break; |
| 460 | default: |
| 461 | ret = -EIO; |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 462 | IL_ERR("C_REM_STA failed\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 463 | break; |
| 464 | } |
| 465 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 466 | il_free_pages(il, cmd.reply_page); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 467 | |
| 468 | return ret; |
| 469 | } |
| 470 | |
| 471 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 472 | * il_remove_station - Remove driver's knowledge of station. |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 473 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 474 | int il_remove_station(struct il_priv *il, const u8 sta_id, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 475 | const u8 *addr) |
| 476 | { |
| 477 | unsigned long flags; |
| 478 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 479 | if (!il_is_ready(il)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 480 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 481 | "Unable to remove station %pM, device not ready.\n", |
| 482 | addr); |
| 483 | /* |
| 484 | * It is typical for stations to be removed when we are |
| 485 | * going down. Return success since device will be down |
| 486 | * soon anyway |
| 487 | */ |
| 488 | return 0; |
| 489 | } |
| 490 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 491 | D_ASSOC("Removing STA from driver:%d %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 492 | sta_id, addr); |
| 493 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 494 | if (WARN_ON(sta_id == IL_INVALID_STATION)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 495 | return -EINVAL; |
| 496 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 497 | spin_lock_irqsave(&il->sta_lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 498 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 499 | if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 500 | D_INFO("Removing %pM but non DRIVER active\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 501 | addr); |
| 502 | goto out_err; |
| 503 | } |
| 504 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 505 | if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 506 | D_INFO("Removing %pM but non UCODE active\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 507 | addr); |
| 508 | goto out_err; |
| 509 | } |
| 510 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 511 | if (il->stations[sta_id].used & IL_STA_LOCAL) { |
| 512 | kfree(il->stations[sta_id].lq); |
| 513 | il->stations[sta_id].lq = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 514 | } |
| 515 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 516 | il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 517 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 518 | il->num_stations--; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 519 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 520 | BUG_ON(il->num_stations < 0); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 521 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 522 | spin_unlock_irqrestore(&il->sta_lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 523 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 524 | return il_send_remove_station(il, addr, sta_id, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 525 | out_err: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 526 | spin_unlock_irqrestore(&il->sta_lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 527 | return -EINVAL; |
| 528 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 529 | EXPORT_SYMBOL_GPL(il_remove_station); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 530 | |
| 531 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 532 | * il_clear_ucode_stations - clear ucode station table bits |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 533 | * |
| 534 | * This function clears all the bits in the driver indicating |
| 535 | * which stations are active in the ucode. Call when something |
| 536 | * other than explicit station management would cause this in |
| 537 | * the ucode, e.g. unassociated RXON. |
| 538 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 539 | void il_clear_ucode_stations(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 540 | struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 541 | { |
| 542 | int i; |
| 543 | unsigned long flags_spin; |
| 544 | bool cleared = false; |
| 545 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 546 | D_INFO("Clearing ucode stations in driver\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 547 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 548 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
| 549 | for (i = 0; i < il->hw_params.max_stations; i++) { |
| 550 | if (ctx && ctx->ctxid != il->stations[i].ctxid) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 551 | continue; |
| 552 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 553 | if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 554 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 555 | "Clearing ucode active for station %d\n", i); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 556 | il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 557 | cleared = true; |
| 558 | } |
| 559 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 560 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 561 | |
| 562 | if (!cleared) |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 563 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 564 | "No active stations found to be cleared\n"); |
| 565 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 566 | EXPORT_SYMBOL(il_clear_ucode_stations); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 567 | |
| 568 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 569 | * il_restore_stations() - Restore driver known stations to device |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 570 | * |
| 571 | * All stations considered active by driver, but not present in ucode, is |
| 572 | * restored. |
| 573 | * |
| 574 | * Function sleeps. |
| 575 | */ |
| 576 | void |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 577 | il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 578 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 579 | struct il_addsta_cmd sta_cmd; |
| 580 | struct il_link_quality_cmd lq; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 581 | unsigned long flags_spin; |
| 582 | int i; |
| 583 | bool found = false; |
| 584 | int ret; |
| 585 | bool send_lq; |
| 586 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 587 | if (!il_is_ready(il)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 588 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 589 | "Not ready yet, not restoring any stations.\n"); |
| 590 | return; |
| 591 | } |
| 592 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 593 | D_ASSOC("Restoring all known stations ... start.\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 594 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
| 595 | for (i = 0; i < il->hw_params.max_stations; i++) { |
| 596 | if (ctx->ctxid != il->stations[i].ctxid) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 597 | continue; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 598 | if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && |
Stanislaw Gruszka | 232913b | 2011-08-26 10:45:16 +0200 | [diff] [blame] | 599 | !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 600 | D_ASSOC("Restoring sta %pM\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 601 | il->stations[i].sta.sta.addr); |
| 602 | il->stations[i].sta.mode = 0; |
| 603 | il->stations[i].used |= IL_STA_UCODE_INPROGRESS; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 604 | found = true; |
| 605 | } |
| 606 | } |
| 607 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 608 | for (i = 0; i < il->hw_params.max_stations; i++) { |
| 609 | if ((il->stations[i].used & IL_STA_UCODE_INPROGRESS)) { |
| 610 | memcpy(&sta_cmd, &il->stations[i].sta, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 611 | sizeof(struct il_addsta_cmd)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 612 | send_lq = false; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 613 | if (il->stations[i].lq) { |
| 614 | memcpy(&lq, il->stations[i].lq, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 615 | sizeof(struct il_link_quality_cmd)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 616 | send_lq = true; |
| 617 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 618 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
| 619 | ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 620 | if (ret) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 621 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 622 | IL_ERR("Adding station %pM failed.\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 623 | il->stations[i].sta.sta.addr); |
| 624 | il->stations[i].used &= |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 625 | ~IL_STA_DRIVER_ACTIVE; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 626 | il->stations[i].used &= |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 627 | ~IL_STA_UCODE_INPROGRESS; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 628 | spin_unlock_irqrestore(&il->sta_lock, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 629 | flags_spin); |
| 630 | } |
| 631 | /* |
| 632 | * Rate scaling has already been initialized, send |
| 633 | * current LQ command |
| 634 | */ |
| 635 | if (send_lq) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 636 | il_send_lq_cmd(il, ctx, &lq, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 637 | CMD_SYNC, true); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 638 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
| 639 | il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 640 | } |
| 641 | } |
| 642 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 643 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 644 | if (!found) |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 645 | D_INFO("Restoring all known stations" |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 646 | " .... no stations to be restored.\n"); |
| 647 | else |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 648 | D_INFO("Restoring all known stations" |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 649 | " .... complete.\n"); |
| 650 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 651 | EXPORT_SYMBOL(il_restore_stations); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 652 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 653 | int il_get_free_ucode_key_idx(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 654 | { |
| 655 | int i; |
| 656 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 657 | for (i = 0; i < il->sta_key_max_num; i++) |
| 658 | if (!test_and_set_bit(i, &il->ucode_key_table)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 659 | return i; |
| 660 | |
| 661 | return WEP_INVALID_OFFSET; |
| 662 | } |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 663 | EXPORT_SYMBOL(il_get_free_ucode_key_idx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 664 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 665 | void il_dealloc_bcast_stations(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 666 | { |
| 667 | unsigned long flags; |
| 668 | int i; |
| 669 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 670 | spin_lock_irqsave(&il->sta_lock, flags); |
| 671 | for (i = 0; i < il->hw_params.max_stations; i++) { |
| 672 | if (!(il->stations[i].used & IL_STA_BCAST)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 673 | continue; |
| 674 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 675 | il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; |
| 676 | il->num_stations--; |
| 677 | BUG_ON(il->num_stations < 0); |
| 678 | kfree(il->stations[i].lq); |
| 679 | il->stations[i].lq = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 680 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 681 | spin_unlock_irqrestore(&il->sta_lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 682 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 683 | EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 684 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 685 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 686 | static void il_dump_lq_cmd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 687 | struct il_link_quality_cmd *lq) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 688 | { |
| 689 | int i; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 690 | D_RATE("lq station id 0x%x\n", lq->sta_id); |
| 691 | D_RATE("lq ant 0x%X 0x%X\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 692 | lq->general_params.single_stream_ant_msk, |
| 693 | lq->general_params.dual_stream_ant_msk); |
| 694 | |
| 695 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 696 | D_RATE("lq idx %d 0x%X\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 697 | i, lq->rs_table[i].rate_n_flags); |
| 698 | } |
| 699 | #else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 700 | static inline void il_dump_lq_cmd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 701 | struct il_link_quality_cmd *lq) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 702 | { |
| 703 | } |
| 704 | #endif |
| 705 | |
| 706 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 707 | * il_is_lq_table_valid() - Test one aspect of LQ cmd for validity |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 708 | * |
| 709 | * It sometimes happens when a HT rate has been in use and we |
| 710 | * loose connectivity with AP then mac80211 will first tell us that the |
| 711 | * current channel is not HT anymore before removing the station. In such a |
| 712 | * scenario the RXON flags will be updated to indicate we are not |
| 713 | * communicating HT anymore, but the LQ command may still contain HT rates. |
| 714 | * Test for this to prevent driver from sending LQ command between the time |
| 715 | * RXON flags are updated and when LQ command is updated. |
| 716 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 717 | static bool il_is_lq_table_valid(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 718 | struct il_rxon_context *ctx, |
| 719 | struct il_link_quality_cmd *lq) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 720 | { |
| 721 | int i; |
| 722 | |
| 723 | if (ctx->ht.enabled) |
| 724 | return true; |
| 725 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 726 | D_INFO("Channel %u is not an HT channel\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 727 | ctx->active.channel); |
| 728 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { |
| 729 | if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & |
| 730 | RATE_MCS_HT_MSK) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 731 | D_INFO( |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 732 | "idx %d of LQ expects HT channel\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 733 | i); |
| 734 | return false; |
| 735 | } |
| 736 | } |
| 737 | return true; |
| 738 | } |
| 739 | |
| 740 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 741 | * il_send_lq_cmd() - Send link quality command |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 742 | * @init: This command is sent as part of station initialization right |
| 743 | * after station has been added. |
| 744 | * |
| 745 | * The link quality command is sent as the last step of station creation. |
| 746 | * This is the special case in which init is set and we call a callback in |
| 747 | * this case to clear the state indicating that station creation is in |
| 748 | * progress. |
| 749 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 750 | int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 751 | struct il_link_quality_cmd *lq, u8 flags, bool init) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 752 | { |
| 753 | int ret = 0; |
| 754 | unsigned long flags_spin; |
| 755 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 756 | struct il_host_cmd cmd = { |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 757 | .id = C_TX_LINK_QUALITY_CMD, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 758 | .len = sizeof(struct il_link_quality_cmd), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 759 | .flags = flags, |
| 760 | .data = lq, |
| 761 | }; |
| 762 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 763 | if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 764 | return -EINVAL; |
| 765 | |
| 766 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 767 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
| 768 | if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { |
| 769 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 770 | return -EINVAL; |
| 771 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 772 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 773 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 774 | il_dump_lq_cmd(il, lq); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 775 | BUG_ON(init && (cmd.flags & CMD_ASYNC)); |
| 776 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 777 | if (il_is_lq_table_valid(il, ctx, lq)) |
| 778 | ret = il_send_cmd(il, &cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 779 | else |
| 780 | ret = -EINVAL; |
| 781 | |
| 782 | if (cmd.flags & CMD_ASYNC) |
| 783 | return ret; |
| 784 | |
| 785 | if (init) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 786 | D_INFO("init LQ command complete," |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 787 | " clearing sta addition status for sta %d\n", |
| 788 | lq->sta_id); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 789 | spin_lock_irqsave(&il->sta_lock, flags_spin); |
| 790 | il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; |
| 791 | spin_unlock_irqrestore(&il->sta_lock, flags_spin); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 792 | } |
| 793 | return ret; |
| 794 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 795 | EXPORT_SYMBOL(il_send_lq_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 796 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 797 | int il_mac_sta_remove(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 798 | struct ieee80211_vif *vif, |
| 799 | struct ieee80211_sta *sta) |
| 800 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 801 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 802 | struct il_station_priv_common *sta_common = (void *)sta->drv_priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 803 | int ret; |
| 804 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 805 | D_INFO("received request to remove station %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 806 | sta->addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 807 | mutex_lock(&il->mutex); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 808 | D_INFO("proceeding to remove station %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 809 | sta->addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 810 | ret = il_remove_station(il, sta_common->sta_id, sta->addr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 811 | if (ret) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 812 | IL_ERR("Error removing station %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 813 | sta->addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 814 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 815 | return ret; |
| 816 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 817 | EXPORT_SYMBOL(il_mac_sta_remove); |