diff options
Diffstat (limited to 'drivers/net/wireless/libertas_tf/cmd.c')
-rw-r--r-- | drivers/net/wireless/libertas_tf/cmd.c | 203 |
1 files changed, 169 insertions, 34 deletions
diff --git a/drivers/net/wireless/libertas_tf/cmd.c b/drivers/net/wireless/libertas_tf/cmd.c index b620daf59ef7..8945afd6ce3e 100644 --- a/drivers/net/wireless/libertas_tf/cmd.c +++ b/drivers/net/wireless/libertas_tf/cmd.c | |||
@@ -7,6 +7,8 @@ | |||
7 | * the Free Software Foundation; either version 2 of the License, or (at | 7 | * the Free Software Foundation; either version 2 of the License, or (at |
8 | * your option) any later version. | 8 | * your option) any later version. |
9 | */ | 9 | */ |
10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
11 | |||
10 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
11 | 13 | ||
12 | #include "libertas_tf.h" | 14 | #include "libertas_tf.h" |
@@ -82,6 +84,8 @@ int lbtf_update_hw_spec(struct lbtf_private *priv) | |||
82 | int ret = -1; | 84 | int ret = -1; |
83 | u32 i; | 85 | u32 i; |
84 | 86 | ||
87 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
88 | |||
85 | memset(&cmd, 0, sizeof(cmd)); | 89 | memset(&cmd, 0, sizeof(cmd)); |
86 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 90 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
87 | memcpy(cmd.permanentaddr, priv->current_addr, ETH_ALEN); | 91 | memcpy(cmd.permanentaddr, priv->current_addr, ETH_ALEN); |
@@ -104,6 +108,8 @@ int lbtf_update_hw_spec(struct lbtf_private *priv) | |||
104 | priv->fwrelease >> 8 & 0xff, | 108 | priv->fwrelease >> 8 & 0xff, |
105 | priv->fwrelease & 0xff, | 109 | priv->fwrelease & 0xff, |
106 | priv->fwcapinfo); | 110 | priv->fwcapinfo); |
111 | lbtf_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n", | ||
112 | cmd.hwifversion, cmd.version); | ||
107 | 113 | ||
108 | /* Clamp region code to 8-bit since FW spec indicates that it should | 114 | /* Clamp region code to 8-bit since FW spec indicates that it should |
109 | * only ever be 8-bit, even though the field size is 16-bit. Some | 115 | * only ever be 8-bit, even though the field size is 16-bit. Some |
@@ -118,8 +124,10 @@ int lbtf_update_hw_spec(struct lbtf_private *priv) | |||
118 | } | 124 | } |
119 | 125 | ||
120 | /* if it's unidentified region code, use the default (USA) */ | 126 | /* if it's unidentified region code, use the default (USA) */ |
121 | if (i >= MRVDRV_MAX_REGION_CODE) | 127 | if (i >= MRVDRV_MAX_REGION_CODE) { |
122 | priv->regioncode = 0x10; | 128 | priv->regioncode = 0x10; |
129 | pr_info("unidentified region code; using the default (USA)\n"); | ||
130 | } | ||
123 | 131 | ||
124 | if (priv->current_addr[0] == 0xff) | 132 | if (priv->current_addr[0] == 0xff) |
125 | memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN); | 133 | memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN); |
@@ -128,6 +136,7 @@ int lbtf_update_hw_spec(struct lbtf_private *priv) | |||
128 | 136 | ||
129 | lbtf_geo_init(priv); | 137 | lbtf_geo_init(priv); |
130 | out: | 138 | out: |
139 | lbtf_deb_leave(LBTF_DEB_CMD); | ||
131 | return ret; | 140 | return ret; |
132 | } | 141 | } |
133 | 142 | ||
@@ -141,13 +150,18 @@ out: | |||
141 | */ | 150 | */ |
142 | int lbtf_set_channel(struct lbtf_private *priv, u8 channel) | 151 | int lbtf_set_channel(struct lbtf_private *priv, u8 channel) |
143 | { | 152 | { |
153 | int ret = 0; | ||
144 | struct cmd_ds_802_11_rf_channel cmd; | 154 | struct cmd_ds_802_11_rf_channel cmd; |
145 | 155 | ||
156 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
157 | |||
146 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 158 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
147 | cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_SET); | 159 | cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_SET); |
148 | cmd.channel = cpu_to_le16(channel); | 160 | cmd.channel = cpu_to_le16(channel); |
149 | 161 | ||
150 | return lbtf_cmd_with_response(priv, CMD_802_11_RF_CHANNEL, &cmd); | 162 | ret = lbtf_cmd_with_response(priv, CMD_802_11_RF_CHANNEL, &cmd); |
163 | lbtf_deb_leave_args(LBTF_DEB_CMD, "ret %d", ret); | ||
164 | return ret; | ||
151 | } | 165 | } |
152 | 166 | ||
153 | int lbtf_beacon_set(struct lbtf_private *priv, struct sk_buff *beacon) | 167 | int lbtf_beacon_set(struct lbtf_private *priv, struct sk_buff *beacon) |
@@ -155,20 +169,28 @@ int lbtf_beacon_set(struct lbtf_private *priv, struct sk_buff *beacon) | |||
155 | struct cmd_ds_802_11_beacon_set cmd; | 169 | struct cmd_ds_802_11_beacon_set cmd; |
156 | int size; | 170 | int size; |
157 | 171 | ||
158 | if (beacon->len > MRVL_MAX_BCN_SIZE) | 172 | lbtf_deb_enter(LBTF_DEB_CMD); |
173 | |||
174 | if (beacon->len > MRVL_MAX_BCN_SIZE) { | ||
175 | lbtf_deb_leave_args(LBTF_DEB_CMD, "ret %d", -1); | ||
159 | return -1; | 176 | return -1; |
177 | } | ||
160 | size = sizeof(cmd) - sizeof(cmd.beacon) + beacon->len; | 178 | size = sizeof(cmd) - sizeof(cmd.beacon) + beacon->len; |
161 | cmd.hdr.size = cpu_to_le16(size); | 179 | cmd.hdr.size = cpu_to_le16(size); |
162 | cmd.len = cpu_to_le16(beacon->len); | 180 | cmd.len = cpu_to_le16(beacon->len); |
163 | memcpy(cmd.beacon, (u8 *) beacon->data, beacon->len); | 181 | memcpy(cmd.beacon, (u8 *) beacon->data, beacon->len); |
164 | 182 | ||
165 | lbtf_cmd_async(priv, CMD_802_11_BEACON_SET, &cmd.hdr, size); | 183 | lbtf_cmd_async(priv, CMD_802_11_BEACON_SET, &cmd.hdr, size); |
184 | |||
185 | lbtf_deb_leave_args(LBTF_DEB_CMD, "ret %d", 0); | ||
166 | return 0; | 186 | return 0; |
167 | } | 187 | } |
168 | 188 | ||
169 | int lbtf_beacon_ctrl(struct lbtf_private *priv, bool beacon_enable, | 189 | int lbtf_beacon_ctrl(struct lbtf_private *priv, bool beacon_enable, |
170 | int beacon_int) { | 190 | int beacon_int) |
191 | { | ||
171 | struct cmd_ds_802_11_beacon_control cmd; | 192 | struct cmd_ds_802_11_beacon_control cmd; |
193 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
172 | 194 | ||
173 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 195 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
174 | cmd.action = cpu_to_le16(CMD_ACT_SET); | 196 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
@@ -176,6 +198,8 @@ int lbtf_beacon_ctrl(struct lbtf_private *priv, bool beacon_enable, | |||
176 | cmd.beacon_period = cpu_to_le16(beacon_int); | 198 | cmd.beacon_period = cpu_to_le16(beacon_int); |
177 | 199 | ||
178 | lbtf_cmd_async(priv, CMD_802_11_BEACON_CTRL, &cmd.hdr, sizeof(cmd)); | 200 | lbtf_cmd_async(priv, CMD_802_11_BEACON_CTRL, &cmd.hdr, sizeof(cmd)); |
201 | |||
202 | lbtf_deb_leave(LBTF_DEB_CMD); | ||
179 | return 0; | 203 | return 0; |
180 | } | 204 | } |
181 | 205 | ||
@@ -183,17 +207,28 @@ static void lbtf_queue_cmd(struct lbtf_private *priv, | |||
183 | struct cmd_ctrl_node *cmdnode) | 207 | struct cmd_ctrl_node *cmdnode) |
184 | { | 208 | { |
185 | unsigned long flags; | 209 | unsigned long flags; |
210 | lbtf_deb_enter(LBTF_DEB_HOST); | ||
186 | 211 | ||
187 | if (!cmdnode) | 212 | if (!cmdnode) { |
188 | return; | 213 | lbtf_deb_host("QUEUE_CMD: cmdnode is NULL\n"); |
214 | goto qcmd_done; | ||
215 | } | ||
189 | 216 | ||
190 | if (!cmdnode->cmdbuf->size) | 217 | if (!cmdnode->cmdbuf->size) { |
191 | return; | 218 | lbtf_deb_host("DNLD_CMD: cmd size is zero\n"); |
219 | goto qcmd_done; | ||
220 | } | ||
192 | 221 | ||
193 | cmdnode->result = 0; | 222 | cmdnode->result = 0; |
194 | spin_lock_irqsave(&priv->driver_lock, flags); | 223 | spin_lock_irqsave(&priv->driver_lock, flags); |
195 | list_add_tail(&cmdnode->list, &priv->cmdpendingq); | 224 | list_add_tail(&cmdnode->list, &priv->cmdpendingq); |
196 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 225 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
226 | |||
227 | lbtf_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n", | ||
228 | le16_to_cpu(cmdnode->cmdbuf->command)); | ||
229 | |||
230 | qcmd_done: | ||
231 | lbtf_deb_leave(LBTF_DEB_HOST); | ||
197 | } | 232 | } |
198 | 233 | ||
199 | static void lbtf_submit_command(struct lbtf_private *priv, | 234 | static void lbtf_submit_command(struct lbtf_private *priv, |
@@ -206,22 +241,33 @@ static void lbtf_submit_command(struct lbtf_private *priv, | |||
206 | int timeo = 5 * HZ; | 241 | int timeo = 5 * HZ; |
207 | int ret; | 242 | int ret; |
208 | 243 | ||
244 | lbtf_deb_enter(LBTF_DEB_HOST); | ||
245 | |||
209 | cmd = cmdnode->cmdbuf; | 246 | cmd = cmdnode->cmdbuf; |
210 | 247 | ||
211 | spin_lock_irqsave(&priv->driver_lock, flags); | 248 | spin_lock_irqsave(&priv->driver_lock, flags); |
212 | priv->cur_cmd = cmdnode; | 249 | priv->cur_cmd = cmdnode; |
213 | cmdsize = le16_to_cpu(cmd->size); | 250 | cmdsize = le16_to_cpu(cmd->size); |
214 | command = le16_to_cpu(cmd->command); | 251 | command = le16_to_cpu(cmd->command); |
252 | |||
253 | lbtf_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d\n", | ||
254 | command, le16_to_cpu(cmd->seqnum), cmdsize); | ||
255 | lbtf_deb_hex(LBTF_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize); | ||
256 | |||
215 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize); | 257 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize); |
216 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 258 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
217 | 259 | ||
218 | if (ret) | 260 | if (ret) { |
261 | pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret); | ||
219 | /* Let the timer kick in and retry, and potentially reset | 262 | /* Let the timer kick in and retry, and potentially reset |
220 | the whole thing if the condition persists */ | 263 | the whole thing if the condition persists */ |
221 | timeo = HZ; | 264 | timeo = HZ; |
265 | } | ||
222 | 266 | ||
223 | /* Setup the timer after transmit command */ | 267 | /* Setup the timer after transmit command */ |
224 | mod_timer(&priv->command_timer, jiffies + timeo); | 268 | mod_timer(&priv->command_timer, jiffies + timeo); |
269 | |||
270 | lbtf_deb_leave(LBTF_DEB_HOST); | ||
225 | } | 271 | } |
226 | 272 | ||
227 | /** | 273 | /** |
@@ -231,8 +277,10 @@ static void lbtf_submit_command(struct lbtf_private *priv, | |||
231 | static void __lbtf_cleanup_and_insert_cmd(struct lbtf_private *priv, | 277 | static void __lbtf_cleanup_and_insert_cmd(struct lbtf_private *priv, |
232 | struct cmd_ctrl_node *cmdnode) | 278 | struct cmd_ctrl_node *cmdnode) |
233 | { | 279 | { |
280 | lbtf_deb_enter(LBTF_DEB_HOST); | ||
281 | |||
234 | if (!cmdnode) | 282 | if (!cmdnode) |
235 | return; | 283 | goto cl_ins_out; |
236 | 284 | ||
237 | cmdnode->callback = NULL; | 285 | cmdnode->callback = NULL; |
238 | cmdnode->callback_arg = 0; | 286 | cmdnode->callback_arg = 0; |
@@ -240,6 +288,9 @@ static void __lbtf_cleanup_and_insert_cmd(struct lbtf_private *priv, | |||
240 | memset(cmdnode->cmdbuf, 0, LBS_CMD_BUFFER_SIZE); | 288 | memset(cmdnode->cmdbuf, 0, LBS_CMD_BUFFER_SIZE); |
241 | 289 | ||
242 | list_add_tail(&cmdnode->list, &priv->cmdfreeq); | 290 | list_add_tail(&cmdnode->list, &priv->cmdfreeq); |
291 | |||
292 | cl_ins_out: | ||
293 | lbtf_deb_leave(LBTF_DEB_HOST); | ||
243 | } | 294 | } |
244 | 295 | ||
245 | static void lbtf_cleanup_and_insert_cmd(struct lbtf_private *priv, | 296 | static void lbtf_cleanup_and_insert_cmd(struct lbtf_private *priv, |
@@ -268,29 +319,41 @@ int lbtf_cmd_set_mac_multicast_addr(struct lbtf_private *priv) | |||
268 | { | 319 | { |
269 | struct cmd_ds_mac_multicast_addr cmd; | 320 | struct cmd_ds_mac_multicast_addr cmd; |
270 | 321 | ||
322 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
323 | |||
271 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 324 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
272 | cmd.action = cpu_to_le16(CMD_ACT_SET); | 325 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
273 | 326 | ||
274 | cmd.nr_of_adrs = cpu_to_le16((u16) priv->nr_of_multicastmacaddr); | 327 | cmd.nr_of_adrs = cpu_to_le16((u16) priv->nr_of_multicastmacaddr); |
328 | |||
329 | lbtf_deb_cmd("MULTICAST_ADR: setting %d addresses\n", cmd.nr_of_adrs); | ||
330 | |||
275 | memcpy(cmd.maclist, priv->multicastlist, | 331 | memcpy(cmd.maclist, priv->multicastlist, |
276 | priv->nr_of_multicastmacaddr * ETH_ALEN); | 332 | priv->nr_of_multicastmacaddr * ETH_ALEN); |
277 | 333 | ||
278 | lbtf_cmd_async(priv, CMD_MAC_MULTICAST_ADR, &cmd.hdr, sizeof(cmd)); | 334 | lbtf_cmd_async(priv, CMD_MAC_MULTICAST_ADR, &cmd.hdr, sizeof(cmd)); |
335 | |||
336 | lbtf_deb_leave(LBTF_DEB_CMD); | ||
279 | return 0; | 337 | return 0; |
280 | } | 338 | } |
281 | 339 | ||
282 | void lbtf_set_mode(struct lbtf_private *priv, enum lbtf_mode mode) | 340 | void lbtf_set_mode(struct lbtf_private *priv, enum lbtf_mode mode) |
283 | { | 341 | { |
284 | struct cmd_ds_set_mode cmd; | 342 | struct cmd_ds_set_mode cmd; |
343 | lbtf_deb_enter(LBTF_DEB_WEXT); | ||
285 | 344 | ||
286 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 345 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
287 | cmd.mode = cpu_to_le16(mode); | 346 | cmd.mode = cpu_to_le16(mode); |
347 | lbtf_deb_wext("Switching to mode: 0x%x\n", mode); | ||
288 | lbtf_cmd_async(priv, CMD_802_11_SET_MODE, &cmd.hdr, sizeof(cmd)); | 348 | lbtf_cmd_async(priv, CMD_802_11_SET_MODE, &cmd.hdr, sizeof(cmd)); |
349 | |||
350 | lbtf_deb_leave(LBTF_DEB_WEXT); | ||
289 | } | 351 | } |
290 | 352 | ||
291 | void lbtf_set_bssid(struct lbtf_private *priv, bool activate, const u8 *bssid) | 353 | void lbtf_set_bssid(struct lbtf_private *priv, bool activate, const u8 *bssid) |
292 | { | 354 | { |
293 | struct cmd_ds_set_bssid cmd; | 355 | struct cmd_ds_set_bssid cmd; |
356 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
294 | 357 | ||
295 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 358 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
296 | cmd.activate = activate ? 1 : 0; | 359 | cmd.activate = activate ? 1 : 0; |
@@ -298,11 +361,13 @@ void lbtf_set_bssid(struct lbtf_private *priv, bool activate, const u8 *bssid) | |||
298 | memcpy(cmd.bssid, bssid, ETH_ALEN); | 361 | memcpy(cmd.bssid, bssid, ETH_ALEN); |
299 | 362 | ||
300 | lbtf_cmd_async(priv, CMD_802_11_SET_BSSID, &cmd.hdr, sizeof(cmd)); | 363 | lbtf_cmd_async(priv, CMD_802_11_SET_BSSID, &cmd.hdr, sizeof(cmd)); |
364 | lbtf_deb_leave(LBTF_DEB_CMD); | ||
301 | } | 365 | } |
302 | 366 | ||
303 | int lbtf_set_mac_address(struct lbtf_private *priv, uint8_t *mac_addr) | 367 | int lbtf_set_mac_address(struct lbtf_private *priv, uint8_t *mac_addr) |
304 | { | 368 | { |
305 | struct cmd_ds_802_11_mac_address cmd; | 369 | struct cmd_ds_802_11_mac_address cmd; |
370 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
306 | 371 | ||
307 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 372 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
308 | cmd.action = cpu_to_le16(CMD_ACT_SET); | 373 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
@@ -310,6 +375,7 @@ int lbtf_set_mac_address(struct lbtf_private *priv, uint8_t *mac_addr) | |||
310 | memcpy(cmd.macadd, mac_addr, ETH_ALEN); | 375 | memcpy(cmd.macadd, mac_addr, ETH_ALEN); |
311 | 376 | ||
312 | lbtf_cmd_async(priv, CMD_802_11_MAC_ADDRESS, &cmd.hdr, sizeof(cmd)); | 377 | lbtf_cmd_async(priv, CMD_802_11_MAC_ADDRESS, &cmd.hdr, sizeof(cmd)); |
378 | lbtf_deb_leave(LBTF_DEB_CMD); | ||
313 | return 0; | 379 | return 0; |
314 | } | 380 | } |
315 | 381 | ||
@@ -318,6 +384,8 @@ int lbtf_set_radio_control(struct lbtf_private *priv) | |||
318 | int ret = 0; | 384 | int ret = 0; |
319 | struct cmd_ds_802_11_radio_control cmd; | 385 | struct cmd_ds_802_11_radio_control cmd; |
320 | 386 | ||
387 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
388 | |||
321 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 389 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
322 | cmd.action = cpu_to_le16(CMD_ACT_SET); | 390 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
323 | 391 | ||
@@ -341,19 +409,28 @@ int lbtf_set_radio_control(struct lbtf_private *priv) | |||
341 | else | 409 | else |
342 | cmd.control &= cpu_to_le16(~TURN_ON_RF); | 410 | cmd.control &= cpu_to_le16(~TURN_ON_RF); |
343 | 411 | ||
412 | lbtf_deb_cmd("RADIO_SET: radio %d, preamble %d\n", priv->radioon, | ||
413 | priv->preamble); | ||
414 | |||
344 | ret = lbtf_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd); | 415 | ret = lbtf_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd); |
416 | |||
417 | lbtf_deb_leave_args(LBTF_DEB_CMD, "ret %d", ret); | ||
345 | return ret; | 418 | return ret; |
346 | } | 419 | } |
347 | 420 | ||
348 | void lbtf_set_mac_control(struct lbtf_private *priv) | 421 | void lbtf_set_mac_control(struct lbtf_private *priv) |
349 | { | 422 | { |
350 | struct cmd_ds_mac_control cmd; | 423 | struct cmd_ds_mac_control cmd; |
424 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
425 | |||
351 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | 426 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
352 | cmd.action = cpu_to_le16(priv->mac_control); | 427 | cmd.action = cpu_to_le16(priv->mac_control); |
353 | cmd.reserved = 0; | 428 | cmd.reserved = 0; |
354 | 429 | ||
355 | lbtf_cmd_async(priv, CMD_MAC_CONTROL, | 430 | lbtf_cmd_async(priv, CMD_MAC_CONTROL, |
356 | &cmd.hdr, sizeof(cmd)); | 431 | &cmd.hdr, sizeof(cmd)); |
432 | |||
433 | lbtf_deb_leave(LBTF_DEB_CMD); | ||
357 | } | 434 | } |
358 | 435 | ||
359 | /** | 436 | /** |
@@ -365,29 +442,43 @@ void lbtf_set_mac_control(struct lbtf_private *priv) | |||
365 | */ | 442 | */ |
366 | int lbtf_allocate_cmd_buffer(struct lbtf_private *priv) | 443 | int lbtf_allocate_cmd_buffer(struct lbtf_private *priv) |
367 | { | 444 | { |
445 | int ret = 0; | ||
368 | u32 bufsize; | 446 | u32 bufsize; |
369 | u32 i; | 447 | u32 i; |
370 | struct cmd_ctrl_node *cmdarray; | 448 | struct cmd_ctrl_node *cmdarray; |
371 | 449 | ||
450 | lbtf_deb_enter(LBTF_DEB_HOST); | ||
451 | |||
372 | /* Allocate and initialize the command array */ | 452 | /* Allocate and initialize the command array */ |
373 | bufsize = sizeof(struct cmd_ctrl_node) * LBS_NUM_CMD_BUFFERS; | 453 | bufsize = sizeof(struct cmd_ctrl_node) * LBS_NUM_CMD_BUFFERS; |
374 | cmdarray = kzalloc(bufsize, GFP_KERNEL); | 454 | cmdarray = kzalloc(bufsize, GFP_KERNEL); |
375 | if (!cmdarray) | 455 | if (!cmdarray) { |
376 | return -1; | 456 | lbtf_deb_host("ALLOC_CMD_BUF: tempcmd_array is NULL\n"); |
457 | ret = -1; | ||
458 | goto done; | ||
459 | } | ||
377 | priv->cmd_array = cmdarray; | 460 | priv->cmd_array = cmdarray; |
378 | 461 | ||
379 | /* Allocate and initialize each command buffer in the command array */ | 462 | /* Allocate and initialize each command buffer in the command array */ |
380 | for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) { | 463 | for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) { |
381 | cmdarray[i].cmdbuf = kzalloc(LBS_CMD_BUFFER_SIZE, GFP_KERNEL); | 464 | cmdarray[i].cmdbuf = kzalloc(LBS_CMD_BUFFER_SIZE, GFP_KERNEL); |
382 | if (!cmdarray[i].cmdbuf) | 465 | if (!cmdarray[i].cmdbuf) { |
383 | return -1; | 466 | lbtf_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n"); |
467 | ret = -1; | ||
468 | goto done; | ||
469 | } | ||
384 | } | 470 | } |
385 | 471 | ||
386 | for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) { | 472 | for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) { |
387 | init_waitqueue_head(&cmdarray[i].cmdwait_q); | 473 | init_waitqueue_head(&cmdarray[i].cmdwait_q); |
388 | lbtf_cleanup_and_insert_cmd(priv, &cmdarray[i]); | 474 | lbtf_cleanup_and_insert_cmd(priv, &cmdarray[i]); |
389 | } | 475 | } |
390 | return 0; | 476 | |
477 | ret = 0; | ||
478 | |||
479 | done: | ||
480 | lbtf_deb_leave_args(LBTF_DEB_HOST, "ret %d", ret); | ||
481 | return ret; | ||
391 | } | 482 | } |
392 | 483 | ||
393 | /** | 484 | /** |
@@ -402,9 +493,13 @@ int lbtf_free_cmd_buffer(struct lbtf_private *priv) | |||
402 | struct cmd_ctrl_node *cmdarray; | 493 | struct cmd_ctrl_node *cmdarray; |
403 | unsigned int i; | 494 | unsigned int i; |
404 | 495 | ||
496 | lbtf_deb_enter(LBTF_DEB_HOST); | ||
497 | |||
405 | /* need to check if cmd array is allocated or not */ | 498 | /* need to check if cmd array is allocated or not */ |
406 | if (priv->cmd_array == NULL) | 499 | if (priv->cmd_array == NULL) { |
407 | return 0; | 500 | lbtf_deb_host("FREE_CMD_BUF: cmd_array is NULL\n"); |
501 | goto done; | ||
502 | } | ||
408 | 503 | ||
409 | cmdarray = priv->cmd_array; | 504 | cmdarray = priv->cmd_array; |
410 | 505 | ||
@@ -418,6 +513,8 @@ int lbtf_free_cmd_buffer(struct lbtf_private *priv) | |||
418 | kfree(priv->cmd_array); | 513 | kfree(priv->cmd_array); |
419 | priv->cmd_array = NULL; | 514 | priv->cmd_array = NULL; |
420 | 515 | ||
516 | done: | ||
517 | lbtf_deb_leave(LBTF_DEB_HOST); | ||
421 | return 0; | 518 | return 0; |
422 | } | 519 | } |
423 | 520 | ||
@@ -433,6 +530,8 @@ static struct cmd_ctrl_node *lbtf_get_cmd_ctrl_node(struct lbtf_private *priv) | |||
433 | struct cmd_ctrl_node *tempnode; | 530 | struct cmd_ctrl_node *tempnode; |
434 | unsigned long flags; | 531 | unsigned long flags; |
435 | 532 | ||
533 | lbtf_deb_enter(LBTF_DEB_HOST); | ||
534 | |||
436 | if (!priv) | 535 | if (!priv) |
437 | return NULL; | 536 | return NULL; |
438 | 537 | ||
@@ -442,11 +541,14 @@ static struct cmd_ctrl_node *lbtf_get_cmd_ctrl_node(struct lbtf_private *priv) | |||
442 | tempnode = list_first_entry(&priv->cmdfreeq, | 541 | tempnode = list_first_entry(&priv->cmdfreeq, |
443 | struct cmd_ctrl_node, list); | 542 | struct cmd_ctrl_node, list); |
444 | list_del(&tempnode->list); | 543 | list_del(&tempnode->list); |
445 | } else | 544 | } else { |
545 | lbtf_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n"); | ||
446 | tempnode = NULL; | 546 | tempnode = NULL; |
547 | } | ||
447 | 548 | ||
448 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 549 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
449 | 550 | ||
551 | lbtf_deb_leave(LBTF_DEB_HOST); | ||
450 | return tempnode; | 552 | return tempnode; |
451 | } | 553 | } |
452 | 554 | ||
@@ -462,16 +564,20 @@ int lbtf_execute_next_command(struct lbtf_private *priv) | |||
462 | struct cmd_ctrl_node *cmdnode = NULL; | 564 | struct cmd_ctrl_node *cmdnode = NULL; |
463 | struct cmd_header *cmd; | 565 | struct cmd_header *cmd; |
464 | unsigned long flags; | 566 | unsigned long flags; |
567 | int ret = 0; | ||
465 | 568 | ||
466 | /* Debug group is LBS_DEB_THREAD and not LBS_DEB_HOST, because the | 569 | /* Debug group is lbtf_deb_THREAD and not lbtf_deb_HOST, because the |
467 | * only caller to us is lbtf_thread() and we get even when a | 570 | * only caller to us is lbtf_thread() and we get even when a |
468 | * data packet is received */ | 571 | * data packet is received */ |
572 | lbtf_deb_enter(LBTF_DEB_THREAD); | ||
469 | 573 | ||
470 | spin_lock_irqsave(&priv->driver_lock, flags); | 574 | spin_lock_irqsave(&priv->driver_lock, flags); |
471 | 575 | ||
472 | if (priv->cur_cmd) { | 576 | if (priv->cur_cmd) { |
577 | pr_alert("EXEC_NEXT_CMD: already processing command!\n"); | ||
473 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 578 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
474 | return -1; | 579 | ret = -1; |
580 | goto done; | ||
475 | } | 581 | } |
476 | 582 | ||
477 | if (!list_empty(&priv->cmdpendingq)) { | 583 | if (!list_empty(&priv->cmdpendingq)) { |
@@ -483,11 +589,17 @@ int lbtf_execute_next_command(struct lbtf_private *priv) | |||
483 | cmd = cmdnode->cmdbuf; | 589 | cmd = cmdnode->cmdbuf; |
484 | 590 | ||
485 | list_del(&cmdnode->list); | 591 | list_del(&cmdnode->list); |
592 | lbtf_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", | ||
593 | le16_to_cpu(cmd->command)); | ||
486 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 594 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
487 | lbtf_submit_command(priv, cmdnode); | 595 | lbtf_submit_command(priv, cmdnode); |
488 | } else | 596 | } else |
489 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 597 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
490 | return 0; | 598 | |
599 | ret = 0; | ||
600 | done: | ||
601 | lbtf_deb_leave(LBTF_DEB_THREAD); | ||
602 | return ret; | ||
491 | } | 603 | } |
492 | 604 | ||
493 | static struct cmd_ctrl_node *__lbtf_cmd_async(struct lbtf_private *priv, | 605 | static struct cmd_ctrl_node *__lbtf_cmd_async(struct lbtf_private *priv, |
@@ -498,14 +610,22 @@ static struct cmd_ctrl_node *__lbtf_cmd_async(struct lbtf_private *priv, | |||
498 | { | 610 | { |
499 | struct cmd_ctrl_node *cmdnode; | 611 | struct cmd_ctrl_node *cmdnode; |
500 | 612 | ||
501 | if (priv->surpriseremoved) | 613 | lbtf_deb_enter(LBTF_DEB_HOST); |
502 | return ERR_PTR(-ENOENT); | 614 | |
615 | if (priv->surpriseremoved) { | ||
616 | lbtf_deb_host("PREP_CMD: card removed\n"); | ||
617 | cmdnode = ERR_PTR(-ENOENT); | ||
618 | goto done; | ||
619 | } | ||
503 | 620 | ||
504 | cmdnode = lbtf_get_cmd_ctrl_node(priv); | 621 | cmdnode = lbtf_get_cmd_ctrl_node(priv); |
505 | if (cmdnode == NULL) { | 622 | if (cmdnode == NULL) { |
623 | lbtf_deb_host("PREP_CMD: cmdnode is NULL\n"); | ||
624 | |||
506 | /* Wake up main thread to execute next command */ | 625 | /* Wake up main thread to execute next command */ |
507 | queue_work(lbtf_wq, &priv->cmd_work); | 626 | queue_work(lbtf_wq, &priv->cmd_work); |
508 | return ERR_PTR(-ENOBUFS); | 627 | cmdnode = ERR_PTR(-ENOBUFS); |
628 | goto done; | ||
509 | } | 629 | } |
510 | 630 | ||
511 | cmdnode->callback = callback; | 631 | cmdnode->callback = callback; |
@@ -520,17 +640,24 @@ static struct cmd_ctrl_node *__lbtf_cmd_async(struct lbtf_private *priv, | |||
520 | cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); | 640 | cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); |
521 | cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum); | 641 | cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum); |
522 | cmdnode->cmdbuf->result = 0; | 642 | cmdnode->cmdbuf->result = 0; |
643 | |||
644 | lbtf_deb_host("PREP_CMD: command 0x%04x\n", command); | ||
645 | |||
523 | cmdnode->cmdwaitqwoken = 0; | 646 | cmdnode->cmdwaitqwoken = 0; |
524 | lbtf_queue_cmd(priv, cmdnode); | 647 | lbtf_queue_cmd(priv, cmdnode); |
525 | queue_work(lbtf_wq, &priv->cmd_work); | 648 | queue_work(lbtf_wq, &priv->cmd_work); |
526 | 649 | ||
650 | done: | ||
651 | lbtf_deb_leave_args(LBTF_DEB_HOST, "ret %p", cmdnode); | ||
527 | return cmdnode; | 652 | return cmdnode; |
528 | } | 653 | } |
529 | 654 | ||
530 | void lbtf_cmd_async(struct lbtf_private *priv, uint16_t command, | 655 | void lbtf_cmd_async(struct lbtf_private *priv, uint16_t command, |
531 | struct cmd_header *in_cmd, int in_cmd_size) | 656 | struct cmd_header *in_cmd, int in_cmd_size) |
532 | { | 657 | { |
658 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
533 | __lbtf_cmd_async(priv, command, in_cmd, in_cmd_size, NULL, 0); | 659 | __lbtf_cmd_async(priv, command, in_cmd, in_cmd_size, NULL, 0); |
660 | lbtf_deb_leave(LBTF_DEB_CMD); | ||
534 | } | 661 | } |
535 | 662 | ||
536 | int __lbtf_cmd(struct lbtf_private *priv, uint16_t command, | 663 | int __lbtf_cmd(struct lbtf_private *priv, uint16_t command, |
@@ -543,30 +670,35 @@ int __lbtf_cmd(struct lbtf_private *priv, uint16_t command, | |||
543 | unsigned long flags; | 670 | unsigned long flags; |
544 | int ret = 0; | 671 | int ret = 0; |
545 | 672 | ||
673 | lbtf_deb_enter(LBTF_DEB_HOST); | ||
674 | |||
546 | cmdnode = __lbtf_cmd_async(priv, command, in_cmd, in_cmd_size, | 675 | cmdnode = __lbtf_cmd_async(priv, command, in_cmd, in_cmd_size, |
547 | callback, callback_arg); | 676 | callback, callback_arg); |
548 | if (IS_ERR(cmdnode)) | 677 | if (IS_ERR(cmdnode)) { |
549 | return PTR_ERR(cmdnode); | 678 | ret = PTR_ERR(cmdnode); |
679 | goto done; | ||
680 | } | ||
550 | 681 | ||
551 | might_sleep(); | 682 | might_sleep(); |
552 | ret = wait_event_interruptible(cmdnode->cmdwait_q, | 683 | ret = wait_event_interruptible(cmdnode->cmdwait_q, |
553 | cmdnode->cmdwaitqwoken); | 684 | cmdnode->cmdwaitqwoken); |
554 | if (ret) { | 685 | if (ret) { |
555 | printk(KERN_DEBUG | 686 | pr_info("PREP_CMD: command 0x%04x interrupted by signal: %d\n", |
556 | "libertastf: command 0x%04x interrupted by signal", | 687 | command, ret); |
557 | command); | 688 | goto done; |
558 | return ret; | ||
559 | } | 689 | } |
560 | 690 | ||
561 | spin_lock_irqsave(&priv->driver_lock, flags); | 691 | spin_lock_irqsave(&priv->driver_lock, flags); |
562 | ret = cmdnode->result; | 692 | ret = cmdnode->result; |
563 | if (ret) | 693 | if (ret) |
564 | printk(KERN_DEBUG "libertastf: command 0x%04x failed: %d\n", | 694 | pr_info("PREP_CMD: command 0x%04x failed: %d\n", |
565 | command, ret); | 695 | command, ret); |
566 | 696 | ||
567 | __lbtf_cleanup_and_insert_cmd(priv, cmdnode); | 697 | __lbtf_cleanup_and_insert_cmd(priv, cmdnode); |
568 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 698 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
569 | 699 | ||
700 | done: | ||
701 | lbtf_deb_leave_args(LBTF_DEB_HOST, "ret %d", ret); | ||
570 | return ret; | 702 | return ret; |
571 | } | 703 | } |
572 | EXPORT_SYMBOL_GPL(__lbtf_cmd); | 704 | EXPORT_SYMBOL_GPL(__lbtf_cmd); |
@@ -587,6 +719,8 @@ int lbtf_process_rx_command(struct lbtf_private *priv) | |||
587 | unsigned long flags; | 719 | unsigned long flags; |
588 | uint16_t result; | 720 | uint16_t result; |
589 | 721 | ||
722 | lbtf_deb_enter(LBTF_DEB_CMD); | ||
723 | |||
590 | mutex_lock(&priv->lock); | 724 | mutex_lock(&priv->lock); |
591 | spin_lock_irqsave(&priv->driver_lock, flags); | 725 | spin_lock_irqsave(&priv->driver_lock, flags); |
592 | 726 | ||
@@ -602,7 +736,7 @@ int lbtf_process_rx_command(struct lbtf_private *priv) | |||
602 | result = le16_to_cpu(resp->result); | 736 | result = le16_to_cpu(resp->result); |
603 | 737 | ||
604 | if (net_ratelimit()) | 738 | if (net_ratelimit()) |
605 | printk(KERN_DEBUG "libertastf: cmd response 0x%04x, seq %d, size %d\n", | 739 | pr_info("libertastf: cmd response 0x%04x, seq %d, size %d\n", |
606 | respcmd, le16_to_cpu(resp->seqnum), | 740 | respcmd, le16_to_cpu(resp->seqnum), |
607 | le16_to_cpu(resp->size)); | 741 | le16_to_cpu(resp->size)); |
608 | 742 | ||
@@ -639,7 +773,7 @@ int lbtf_process_rx_command(struct lbtf_private *priv) | |||
639 | switch (respcmd) { | 773 | switch (respcmd) { |
640 | case CMD_RET(CMD_GET_HW_SPEC): | 774 | case CMD_RET(CMD_GET_HW_SPEC): |
641 | case CMD_RET(CMD_802_11_RESET): | 775 | case CMD_RET(CMD_802_11_RESET): |
642 | printk(KERN_DEBUG "libertastf: reset failed\n"); | 776 | pr_info("libertastf: reset failed\n"); |
643 | break; | 777 | break; |
644 | 778 | ||
645 | } | 779 | } |
@@ -666,5 +800,6 @@ int lbtf_process_rx_command(struct lbtf_private *priv) | |||
666 | 800 | ||
667 | done: | 801 | done: |
668 | mutex_unlock(&priv->lock); | 802 | mutex_unlock(&priv->lock); |
803 | lbtf_deb_leave_args(LBTF_DEB_CMD, "ret %d", ret); | ||
669 | return ret; | 804 | return ret; |
670 | } | 805 | } |