aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/libertas/cmd.c')
-rw-r--r--drivers/net/wireless/libertas/cmd.c248
1 files changed, 103 insertions, 145 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 8da788e2ecf9..124e029f1bf4 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -25,13 +25,11 @@ static u16 commands_allowed_in_ps[] = {
25 * @param command the command ID 25 * @param command the command ID
26 * @return TRUE or FALSE 26 * @return TRUE or FALSE
27 */ 27 */
28static u8 is_command_allowed_in_ps(u16 command) 28static u8 is_command_allowed_in_ps(__le16 command)
29{ 29{
30 int count = sizeof(commands_allowed_in_ps)
31 / sizeof(commands_allowed_in_ps[0]);
32 int i; 30 int i;
33 31
34 for (i = 0; i < count; i++) { 32 for (i = 0; i < ARRAY_SIZE(commands_allowed_in_ps); i++) {
35 if (command == cpu_to_le16(commands_allowed_in_ps[i])) 33 if (command == cpu_to_le16(commands_allowed_in_ps[i]))
36 return 1; 34 return 1;
37 } 35 }
@@ -46,8 +44,7 @@ static int wlan_cmd_hw_spec(wlan_private * priv, struct cmd_ds_command *cmd)
46 lbs_deb_enter(LBS_DEB_CMD); 44 lbs_deb_enter(LBS_DEB_CMD);
47 45
48 cmd->command = cpu_to_le16(cmd_get_hw_spec); 46 cmd->command = cpu_to_le16(cmd_get_hw_spec);
49 cmd->size = 47 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN);
50 cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN);
51 memcpy(hwspec->permanentaddr, priv->adapter->current_addr, ETH_ALEN); 48 memcpy(hwspec->permanentaddr, priv->adapter->current_addr, ETH_ALEN);
52 49
53 lbs_deb_leave(LBS_DEB_CMD); 50 lbs_deb_leave(LBS_DEB_CMD);
@@ -59,18 +56,16 @@ static int wlan_cmd_802_11_ps_mode(wlan_private * priv,
59 u16 cmd_action) 56 u16 cmd_action)
60{ 57{
61 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode; 58 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode;
62 u16 action = cmd_action;
63 wlan_adapter *adapter = priv->adapter; 59 wlan_adapter *adapter = priv->adapter;
64 60
65 lbs_deb_enter(LBS_DEB_CMD); 61 lbs_deb_enter(LBS_DEB_CMD);
66 62
67 cmd->command = cpu_to_le16(cmd_802_11_ps_mode); 63 cmd->command = cpu_to_le16(cmd_802_11_ps_mode);
68 cmd->size = 64 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) +
69 cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) + 65 S_DS_GEN);
70 S_DS_GEN);
71 psm->action = cpu_to_le16(cmd_action); 66 psm->action = cpu_to_le16(cmd_action);
72 psm->multipledtim = 0; 67 psm->multipledtim = 0;
73 switch (action) { 68 switch (cmd_action) {
74 case cmd_subcmd_enter_ps: 69 case cmd_subcmd_enter_ps:
75 lbs_deb_cmd("PS command:" "SubCode- Enter PS\n"); 70 lbs_deb_cmd("PS command:" "SubCode- Enter PS\n");
76 lbs_deb_cmd("locallisteninterval = %d\n", 71 lbs_deb_cmd("locallisteninterval = %d\n",
@@ -114,8 +109,7 @@ static int wlan_cmd_802_11_inactivity_timeout(wlan_private * priv,
114 cmd->params.inactivity_timeout.action = cpu_to_le16(cmd_action); 109 cmd->params.inactivity_timeout.action = cpu_to_le16(cmd_action);
115 110
116 if (cmd_action) 111 if (cmd_action)
117 cmd->params.inactivity_timeout.timeout = 112 cmd->params.inactivity_timeout.timeout = cpu_to_le16(*timeout);
118 cpu_to_le16(*timeout);
119 else 113 else
120 cmd->params.inactivity_timeout.timeout = 0; 114 cmd->params.inactivity_timeout.timeout = 0;
121 115
@@ -131,9 +125,8 @@ static int wlan_cmd_802_11_sleep_params(wlan_private * priv,
131 125
132 lbs_deb_enter(LBS_DEB_CMD); 126 lbs_deb_enter(LBS_DEB_CMD);
133 127
134 cmd->size = 128 cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) +
135 cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) + 129 S_DS_GEN);
136 S_DS_GEN);
137 cmd->command = cpu_to_le16(cmd_802_11_sleep_params); 130 cmd->command = cpu_to_le16(cmd_802_11_sleep_params);
138 131
139 if (cmd_action == cmd_act_get) { 132 if (cmd_action == cmd_act_get) {
@@ -167,8 +160,7 @@ static int wlan_cmd_802_11_set_wep(wlan_private * priv,
167 lbs_deb_enter(LBS_DEB_CMD); 160 lbs_deb_enter(LBS_DEB_CMD);
168 161
169 cmd->command = cpu_to_le16(cmd_802_11_set_wep); 162 cmd->command = cpu_to_le16(cmd_802_11_set_wep);
170 cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_set_wep)) 163 cmd->size = cpu_to_le16(sizeof(*wep) + S_DS_GEN);
171 + S_DS_GEN);
172 164
173 if (cmd_act == cmd_act_add) { 165 if (cmd_act == cmd_act_add) {
174 int i; 166 int i;
@@ -182,11 +174,10 @@ static int wlan_cmd_802_11_set_wep(wlan_private * priv,
182 wep->action = cpu_to_le16(cmd_act_add); 174 wep->action = cpu_to_le16(cmd_act_add);
183 175
184 /* default tx key index */ 176 /* default tx key index */
185 wep->keyindex = cpu_to_le16((u16) 177 wep->keyindex = cpu_to_le16((u16)(assoc_req->wep_tx_keyidx &
186 (assoc_req->wep_tx_keyidx & 178 (u32)cmd_WEP_KEY_INDEX_MASK));
187 (u32)cmd_WEP_KEY_INDEX_MASK));
188 179
189 lbs_deb_cmd("Tx key Index: %u\n", wep->keyindex); 180 lbs_deb_cmd("Tx key Index: %u\n", le16_to_cpu(wep->keyindex));
190 181
191 /* Copy key types and material to host command structure */ 182 /* Copy key types and material to host command structure */
192 for (i = 0; i < 4; i++) { 183 for (i = 0; i < 4; i++) {
@@ -194,12 +185,14 @@ static int wlan_cmd_802_11_set_wep(wlan_private * priv,
194 185
195 switch (pkey->len) { 186 switch (pkey->len) {
196 case KEY_LEN_WEP_40: 187 case KEY_LEN_WEP_40:
197 wep->keytype[i] = cmd_type_wep_40_bit; 188 wep->keytype[i] =
189 cpu_to_le16(cmd_type_wep_40_bit);
198 memmove(&wep->keymaterial[i], pkey->key, 190 memmove(&wep->keymaterial[i], pkey->key,
199 pkey->len); 191 pkey->len);
200 break; 192 break;
201 case KEY_LEN_WEP_104: 193 case KEY_LEN_WEP_104:
202 wep->keytype[i] = cmd_type_wep_104_bit; 194 wep->keytype[i] =
195 cpu_to_le16(cmd_type_wep_104_bit);
203 memmove(&wep->keymaterial[i], pkey->key, 196 memmove(&wep->keymaterial[i], pkey->key,
204 pkey->len); 197 pkey->len);
205 break; 198 break;
@@ -218,9 +211,8 @@ static int wlan_cmd_802_11_set_wep(wlan_private * priv,
218 wep->action = cpu_to_le16(cmd_act_remove); 211 wep->action = cpu_to_le16(cmd_act_remove);
219 212
220 /* default tx key index */ 213 /* default tx key index */
221 wep->keyindex = cpu_to_le16((u16) 214 wep->keyindex = cpu_to_le16((u16)(adapter->wep_tx_keyidx &
222 (adapter->wep_tx_keyidx & 215 (u32)cmd_WEP_KEY_INDEX_MASK));
223 (u32)cmd_WEP_KEY_INDEX_MASK));
224 } 216 }
225 217
226 ret = 0; 218 ret = 0;
@@ -241,8 +233,7 @@ static int wlan_cmd_802_11_enable_rsn(wlan_private * priv,
241 lbs_deb_enter(LBS_DEB_CMD); 233 lbs_deb_enter(LBS_DEB_CMD);
242 234
243 cmd->command = cpu_to_le16(cmd_802_11_enable_rsn); 235 cmd->command = cpu_to_le16(cmd_802_11_enable_rsn);
244 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_enable_rsn) + 236 cmd->size = cpu_to_le16(sizeof(*penableRSN) + S_DS_GEN);
245 S_DS_GEN);
246 penableRSN->action = cpu_to_le16(cmd_action); 237 penableRSN->action = cpu_to_le16(cmd_action);
247 if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { 238 if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) {
248 penableRSN->enable = cpu_to_le16(cmd_enable_rsn); 239 penableRSN->enable = cpu_to_le16(cmd_enable_rsn);
@@ -353,8 +344,7 @@ static int wlan_cmd_802_11_get_stat(wlan_private * priv,
353{ 344{
354 cmd->command = cpu_to_le16(cmd_802_11_get_stat); 345 cmd->command = cpu_to_le16(cmd_802_11_get_stat);
355 cmd->size = 346 cmd->size =
356 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + 347 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + S_DS_GEN);
357 S_DS_GEN);
358 348
359 return 0; 349 return 0;
360} 350}
@@ -373,9 +363,7 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
373 lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); 363 lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid);
374 364
375 cmd->command = cpu_to_le16(cmd_802_11_snmp_mib); 365 cmd->command = cpu_to_le16(cmd_802_11_snmp_mib);
376 cmd->size = 366 cmd->size = cpu_to_le16(sizeof(*pSNMPMIB) + S_DS_GEN);
377 cpu_to_le16(sizeof(struct cmd_ds_802_11_snmp_mib) +
378 S_DS_GEN);
379 367
380 switch (cmd_oid) { 368 switch (cmd_oid) {
381 case OID_802_11_INFRASTRUCTURE_MODE: 369 case OID_802_11_INFRASTRUCTURE_MODE:
@@ -406,7 +394,7 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
406 pSNMPMIB->querytype = cmd_act_set; 394 pSNMPMIB->querytype = cmd_act_set;
407 pSNMPMIB->bufsize = sizeof(u16); 395 pSNMPMIB->bufsize = sizeof(u16);
408 ulTemp = *(u32 *)pdata_buf; 396 ulTemp = *(u32 *)pdata_buf;
409 *((unsigned short *)(pSNMPMIB->value)) = 397 *((__le16 *)(pSNMPMIB->value)) =
410 cpu_to_le16((u16) ulTemp); 398 cpu_to_le16((u16) ulTemp);
411 } 399 }
412 break; 400 break;
@@ -419,15 +407,12 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
419 pSNMPMIB->oid = cpu_to_le16((u16) fragthresh_i); 407 pSNMPMIB->oid = cpu_to_le16((u16) fragthresh_i);
420 408
421 if (cmd_action == cmd_act_get) { 409 if (cmd_action == cmd_act_get) {
422 pSNMPMIB->querytype = 410 pSNMPMIB->querytype = cpu_to_le16(cmd_act_get);
423 cpu_to_le16(cmd_act_get);
424 } else if (cmd_action == cmd_act_set) { 411 } else if (cmd_action == cmd_act_set) {
425 pSNMPMIB->querytype = 412 pSNMPMIB->querytype = cpu_to_le16(cmd_act_set);
426 cpu_to_le16(cmd_act_set); 413 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
427 pSNMPMIB->bufsize =
428 cpu_to_le16(sizeof(u16));
429 ulTemp = *((u32 *) pdata_buf); 414 ulTemp = *((u32 *) pdata_buf);
430 *((unsigned short *)(pSNMPMIB->value)) = 415 *((__le16 *)(pSNMPMIB->value)) =
431 cpu_to_le16((u16) ulTemp); 416 cpu_to_le16((u16) ulTemp);
432 417
433 } 418 }
@@ -442,16 +427,12 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
442 pSNMPMIB->oid = le16_to_cpu((u16) rtsthresh_i); 427 pSNMPMIB->oid = le16_to_cpu((u16) rtsthresh_i);
443 428
444 if (cmd_action == cmd_act_get) { 429 if (cmd_action == cmd_act_get) {
445 pSNMPMIB->querytype = 430 pSNMPMIB->querytype = cpu_to_le16(cmd_act_get);
446 cpu_to_le16(cmd_act_get);
447 } else if (cmd_action == cmd_act_set) { 431 } else if (cmd_action == cmd_act_set) {
448 pSNMPMIB->querytype = 432 pSNMPMIB->querytype = cpu_to_le16(cmd_act_set);
449 cpu_to_le16(cmd_act_set); 433 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
450 pSNMPMIB->bufsize = 434 ulTemp = *((u32 *)pdata_buf);
451 cpu_to_le16(sizeof(u16)); 435 *(__le16 *)(pSNMPMIB->value) =
452 ulTemp = *((u32 *)
453 pdata_buf);
454 *(unsigned short *)(pSNMPMIB->value) =
455 cpu_to_le16((u16) ulTemp); 436 cpu_to_le16((u16) ulTemp);
456 437
457 } 438 }
@@ -461,13 +442,11 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
461 pSNMPMIB->oid = cpu_to_le16((u16) short_retrylim_i); 442 pSNMPMIB->oid = cpu_to_le16((u16) short_retrylim_i);
462 443
463 if (cmd_action == cmd_act_get) { 444 if (cmd_action == cmd_act_get) {
464 pSNMPMIB->querytype = 445 pSNMPMIB->querytype = cpu_to_le16(cmd_act_get);
465 cpu_to_le16(cmd_act_get);
466 } else if (cmd_action == cmd_act_set) { 446 } else if (cmd_action == cmd_act_set) {
467 pSNMPMIB->querytype = 447 pSNMPMIB->querytype = cpu_to_le16(cmd_act_set);
468 cpu_to_le16(cmd_act_set);
469 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); 448 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
470 *((unsigned short *)(pSNMPMIB->value)) = 449 *((__le16 *)(pSNMPMIB->value)) =
471 cpu_to_le16((u16) adapter->txretrycount); 450 cpu_to_le16((u16) adapter->txretrycount);
472 } 451 }
473 452
@@ -478,12 +457,14 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
478 457
479 lbs_deb_cmd( 458 lbs_deb_cmd(
480 "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n", 459 "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n",
481 cmd->command, cmd->size, cmd->seqnum, cmd->result); 460 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size),
461 le16_to_cpu(cmd->seqnum), le16_to_cpu(cmd->result));
482 462
483 lbs_deb_cmd( 463 lbs_deb_cmd(
484 "SNMP_CMD: action=0x%x, oid=0x%x, oidsize=0x%x, value=0x%x\n", 464 "SNMP_CMD: action=0x%x, oid=0x%x, oidsize=0x%x, value=0x%x\n",
485 pSNMPMIB->querytype, pSNMPMIB->oid, pSNMPMIB->bufsize, 465 le16_to_cpu(pSNMPMIB->querytype), le16_to_cpu(pSNMPMIB->oid),
486 *(u16 *) pSNMPMIB->value); 466 le16_to_cpu(pSNMPMIB->bufsize),
467 le16_to_cpu(*(__le16 *) pSNMPMIB->value));
487 468
488 lbs_deb_leave(LBS_DEB_CMD); 469 lbs_deb_leave(LBS_DEB_CMD);
489 return 0; 470 return 0;
@@ -494,8 +475,7 @@ static int wlan_cmd_802_11_radio_control(wlan_private * priv,
494 int cmd_action) 475 int cmd_action)
495{ 476{
496 wlan_adapter *adapter = priv->adapter; 477 wlan_adapter *adapter = priv->adapter;
497 struct cmd_ds_802_11_radio_control *pradiocontrol = 478 struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio;
498 &cmd->params.radio;
499 479
500 lbs_deb_enter(LBS_DEB_CMD); 480 lbs_deb_enter(LBS_DEB_CMD);
501 481
@@ -540,13 +520,13 @@ static int wlan_cmd_802_11_rf_tx_power(wlan_private * priv,
540 lbs_deb_enter(LBS_DEB_CMD); 520 lbs_deb_enter(LBS_DEB_CMD);
541 521
542 cmd->size = 522 cmd->size =
543 cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + 523 cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + S_DS_GEN);
544 S_DS_GEN);
545 cmd->command = cpu_to_le16(cmd_802_11_rf_tx_power); 524 cmd->command = cpu_to_le16(cmd_802_11_rf_tx_power);
546 prtp->action = cmd_action; 525 prtp->action = cpu_to_le16(cmd_action);
547 526
548 lbs_deb_cmd("RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n", cmd->size, 527 lbs_deb_cmd("RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n",
549 cmd->command, prtp->action); 528 le16_to_cpu(cmd->size), le16_to_cpu(cmd->command),
529 le16_to_cpu(prtp->action));
550 530
551 switch (cmd_action) { 531 switch (cmd_action) {
552 case cmd_act_tx_power_opt_get: 532 case cmd_act_tx_power_opt_get:
@@ -556,14 +536,12 @@ static int wlan_cmd_802_11_rf_tx_power(wlan_private * priv,
556 536
557 case cmd_act_tx_power_opt_set_high: 537 case cmd_act_tx_power_opt_set_high:
558 prtp->action = cpu_to_le16(cmd_act_set); 538 prtp->action = cpu_to_le16(cmd_act_set);
559 prtp->currentlevel = 539 prtp->currentlevel = cpu_to_le16(cmd_act_tx_power_index_high);
560 cpu_to_le16(cmd_act_tx_power_index_high);
561 break; 540 break;
562 541
563 case cmd_act_tx_power_opt_set_mid: 542 case cmd_act_tx_power_opt_set_mid:
564 prtp->action = cpu_to_le16(cmd_act_set); 543 prtp->action = cpu_to_le16(cmd_act_set);
565 prtp->currentlevel = 544 prtp->currentlevel = cpu_to_le16(cmd_act_tx_power_index_mid);
566 cpu_to_le16(cmd_act_tx_power_index_mid);
567 break; 545 break;
568 546
569 case cmd_act_tx_power_opt_set_low: 547 case cmd_act_tx_power_opt_set_low:
@@ -583,15 +561,12 @@ static int wlan_cmd_802_11_rf_antenna(wlan_private * priv,
583 struct cmd_ds_802_11_rf_antenna *rant = &cmd->params.rant; 561 struct cmd_ds_802_11_rf_antenna *rant = &cmd->params.rant;
584 562
585 cmd->command = cpu_to_le16(cmd_802_11_rf_antenna); 563 cmd->command = cpu_to_le16(cmd_802_11_rf_antenna);
586 cmd->size = 564 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_antenna) +
587 cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_antenna) + 565 S_DS_GEN);
588 S_DS_GEN);
589 566
590 rant->action = cpu_to_le16(cmd_action); 567 rant->action = cpu_to_le16(cmd_action);
591 if ((cmd_action == cmd_act_set_rx) || 568 if ((cmd_action == cmd_act_set_rx) || (cmd_action == cmd_act_set_tx)) {
592 (cmd_action == cmd_act_set_tx)) { 569 rant->antennamode = cpu_to_le16((u16) (*(u32 *) pdata_buf));
593 rant->antennamode =
594 cpu_to_le16((u16) (*(u32 *) pdata_buf));
595 } 570 }
596 571
597 return 0; 572 return 0;
@@ -612,9 +587,9 @@ static int wlan_cmd_802_11_rate_adapt_rateset(wlan_private * priv,
612 587
613 lbs_deb_enter(LBS_DEB_CMD); 588 lbs_deb_enter(LBS_DEB_CMD);
614 589
615 rateadapt->action = cmd_action; 590 rateadapt->action = cpu_to_le16(cmd_action);
616 rateadapt->enablehwauto = adapter->enablehwauto; 591 rateadapt->enablehwauto = cpu_to_le16(adapter->enablehwauto);
617 rateadapt->bitmap = adapter->ratebitmap; 592 rateadapt->bitmap = cpu_to_le16(adapter->ratebitmap);
618 593
619 lbs_deb_leave(LBS_DEB_CMD); 594 lbs_deb_leave(LBS_DEB_CMD);
620 return 0; 595 return 0;
@@ -626,12 +601,10 @@ static int wlan_cmd_802_11_data_rate(wlan_private * priv,
626{ 601{
627 struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate; 602 struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate;
628 wlan_adapter *adapter = priv->adapter; 603 wlan_adapter *adapter = priv->adapter;
629 u16 action = cmd_action;
630 604
631 lbs_deb_enter(LBS_DEB_CMD); 605 lbs_deb_enter(LBS_DEB_CMD);
632 606
633 cmd->size = 607 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) +
634 cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) +
635 S_DS_GEN); 608 S_DS_GEN);
636 609
637 cmd->command = cpu_to_le16(cmd_802_11_data_rate); 610 cmd->command = cpu_to_le16(cmd_802_11_data_rate);
@@ -640,11 +613,11 @@ static int wlan_cmd_802_11_data_rate(wlan_private * priv,
640 613
641 pdatarate->action = cpu_to_le16(cmd_action); 614 pdatarate->action = cpu_to_le16(cmd_action);
642 615
643 if (action == cmd_act_set_tx_fix_rate) { 616 if (cmd_action == cmd_act_set_tx_fix_rate) {
644 pdatarate->datarate[0] = libertas_data_rate_to_index(adapter->datarate); 617 pdatarate->datarate[0] = libertas_data_rate_to_index(adapter->datarate);
645 lbs_deb_cmd("Setting FW for fixed rate 0x%02X\n", 618 lbs_deb_cmd("Setting FW for fixed rate 0x%02X\n",
646 adapter->datarate); 619 adapter->datarate);
647 } else if (action == cmd_act_set_tx_auto) { 620 } else if (cmd_action == cmd_act_set_tx_auto) {
648 lbs_deb_cmd("Setting FW for AUTO rate\n"); 621 lbs_deb_cmd("Setting FW for AUTO rate\n");
649 } 622 }
650 623
@@ -659,8 +632,7 @@ static int wlan_cmd_mac_multicast_adr(wlan_private * priv,
659 struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr; 632 struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr;
660 wlan_adapter *adapter = priv->adapter; 633 wlan_adapter *adapter = priv->adapter;
661 634
662 cmd->size = 635 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) +
663 cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) +
664 S_DS_GEN); 636 S_DS_GEN);
665 cmd->command = cpu_to_le16(cmd_mac_multicast_adr); 637 cmd->command = cpu_to_le16(cmd_mac_multicast_adr);
666 638
@@ -680,8 +652,8 @@ static int wlan_cmd_802_11_rf_channel(wlan_private * priv,
680 struct cmd_ds_802_11_rf_channel *rfchan = &cmd->params.rfchannel; 652 struct cmd_ds_802_11_rf_channel *rfchan = &cmd->params.rfchannel;
681 653
682 cmd->command = cpu_to_le16(cmd_802_11_rf_channel); 654 cmd->command = cpu_to_le16(cmd_802_11_rf_channel);
683 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_channel) 655 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_channel) +
684 + S_DS_GEN); 656 S_DS_GEN);
685 657
686 if (option == cmd_opt_802_11_rf_channel_set) { 658 if (option == cmd_opt_802_11_rf_channel_set) {
687 rfchan->currentchannel = cpu_to_le16(*((u16 *) pdata_buf)); 659 rfchan->currentchannel = cpu_to_le16(*((u16 *) pdata_buf));
@@ -698,9 +670,8 @@ static int wlan_cmd_802_11_rssi(wlan_private * priv,
698 wlan_adapter *adapter = priv->adapter; 670 wlan_adapter *adapter = priv->adapter;
699 671
700 cmd->command = cpu_to_le16(cmd_802_11_rssi); 672 cmd->command = cpu_to_le16(cmd_802_11_rssi);
701 cmd->size = 673 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rssi) + S_DS_GEN);
702 cpu_to_le16(sizeof(struct cmd_ds_802_11_rssi) + S_DS_GEN); 674 cmd->params.rssi.N = cpu_to_le16(priv->adapter->bcn_avg_factor);
703 cmd->params.rssi.N = priv->adapter->bcn_avg_factor;
704 675
705 /* reset Beacon SNR/NF/RSSI values */ 676 /* reset Beacon SNR/NF/RSSI values */
706 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = 0; 677 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = 0;
@@ -729,9 +700,8 @@ static int wlan_cmd_reg_access(wlan_private * priv,
729 struct cmd_ds_mac_reg_access *macreg; 700 struct cmd_ds_mac_reg_access *macreg;
730 701
731 cmdptr->size = 702 cmdptr->size =
732 cpu_to_le16(sizeof 703 cpu_to_le16(sizeof (struct cmd_ds_mac_reg_access)
733 (struct cmd_ds_mac_reg_access) 704 + S_DS_GEN);
734 + S_DS_GEN);
735 macreg = 705 macreg =
736 (struct cmd_ds_mac_reg_access *)&cmdptr->params. 706 (struct cmd_ds_mac_reg_access *)&cmdptr->params.
737 macreg; 707 macreg;
@@ -796,8 +766,7 @@ static int wlan_cmd_802_11_mac_address(wlan_private * priv,
796 wlan_adapter *adapter = priv->adapter; 766 wlan_adapter *adapter = priv->adapter;
797 767
798 cmd->command = cpu_to_le16(cmd_802_11_mac_address); 768 cmd->command = cpu_to_le16(cmd_802_11_mac_address);
799 cmd->size = 769 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) +
800 cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) +
801 S_DS_GEN); 770 S_DS_GEN);
802 cmd->result = 0; 771 cmd->result = 0;
803 772
@@ -821,9 +790,8 @@ static int wlan_cmd_802_11_eeprom_access(wlan_private * priv,
821 lbs_deb_enter(LBS_DEB_CMD); 790 lbs_deb_enter(LBS_DEB_CMD);
822 791
823 cmd->command = cpu_to_le16(cmd_802_11_eeprom_access); 792 cmd->command = cpu_to_le16(cmd_802_11_eeprom_access);
824 cmd->size = 793 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) +
825 cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) + 794 S_DS_GEN);
826 S_DS_GEN);
827 cmd->result = 0; 795 cmd->result = 0;
828 796
829 cmd->params.rdeeprom.action = cpu_to_le16(ea->action); 797 cmd->params.rdeeprom.action = cpu_to_le16(ea->action);
@@ -842,8 +810,7 @@ static int wlan_cmd_bt_access(wlan_private * priv,
842 lbs_deb_cmd("BT CMD(%d)\n", cmd_action); 810 lbs_deb_cmd("BT CMD(%d)\n", cmd_action);
843 811
844 cmd->command = cpu_to_le16(cmd_bt_access); 812 cmd->command = cpu_to_le16(cmd_bt_access);
845 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) 813 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + S_DS_GEN);
846 + S_DS_GEN);
847 cmd->result = 0; 814 cmd->result = 0;
848 bt_access->action = cpu_to_le16(cmd_action); 815 bt_access->action = cpu_to_le16(cmd_action);
849 816
@@ -880,8 +847,7 @@ static int wlan_cmd_fwt_access(wlan_private * priv,
880 lbs_deb_cmd("FWT CMD(%d)\n", cmd_action); 847 lbs_deb_cmd("FWT CMD(%d)\n", cmd_action);
881 848
882 cmd->command = cpu_to_le16(cmd_fwt_access); 849 cmd->command = cpu_to_le16(cmd_fwt_access);
883 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) 850 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + S_DS_GEN);
884 + S_DS_GEN);
885 cmd->result = 0; 851 cmd->result = 0;
886 852
887 if (pdata_buf) 853 if (pdata_buf)
@@ -902,8 +868,7 @@ static int wlan_cmd_mesh_access(wlan_private * priv,
902 lbs_deb_cmd("FWT CMD(%d)\n", cmd_action); 868 lbs_deb_cmd("FWT CMD(%d)\n", cmd_action);
903 869
904 cmd->command = cpu_to_le16(cmd_mesh_access); 870 cmd->command = cpu_to_le16(cmd_mesh_access);
905 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) 871 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) + S_DS_GEN);
906 + S_DS_GEN);
907 cmd->result = 0; 872 cmd->result = 0;
908 873
909 if (pdata_buf) 874 if (pdata_buf)
@@ -937,7 +902,7 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u
937 /* Exit_PS command needs to be queued in the header always. */ 902 /* Exit_PS command needs to be queued in the header always. */
938 if (cmdptr->command == cmd_802_11_ps_mode) { 903 if (cmdptr->command == cmd_802_11_ps_mode) {
939 struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode; 904 struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode;
940 if (psm->action == cmd_subcmd_exit_ps) { 905 if (psm->action == cpu_to_le16(cmd_subcmd_exit_ps)) {
941 if (adapter->psstate != PS_STATE_FULL_POWER) 906 if (adapter->psstate != PS_STATE_FULL_POWER)
942 addtail = 0; 907 addtail = 0;
943 } 908 }
@@ -955,7 +920,7 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u
955 920
956 lbs_deb_cmd("QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n", 921 lbs_deb_cmd("QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n",
957 cmdnode, 922 cmdnode,
958 ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); 923 le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command));
959 924
960done: 925done:
961 lbs_deb_leave(LBS_DEB_CMD); 926 lbs_deb_leave(LBS_DEB_CMD);
@@ -1009,7 +974,7 @@ static int DownloadcommandToStation(wlan_private * priv,
1009 adapter->cur_cmd_retcode = 0; 974 adapter->cur_cmd_retcode = 0;
1010 spin_unlock_irqrestore(&adapter->driver_lock, flags); 975 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1011 lbs_deb_cmd("DNLD_CMD:: Before download, size of cmd = %d\n", 976 lbs_deb_cmd("DNLD_CMD:: Before download, size of cmd = %d\n",
1012 cmdptr->size); 977 le16_to_cpu(cmdptr->size));
1013 978
1014 cmdsize = cmdptr->size; 979 cmdsize = cmdptr->size;
1015 980
@@ -1034,8 +999,7 @@ static int DownloadcommandToStation(wlan_private * priv,
1034 lbs_dbg_hex("DNLD_CMD: command", cmdnode->bufvirtualaddr, cmdsize); 999 lbs_dbg_hex("DNLD_CMD: command", cmdnode->bufvirtualaddr, cmdsize);
1035 1000
1036 /* Setup the timer after transmit command */ 1001 /* Setup the timer after transmit command */
1037 if (command == cmd_802_11_scan 1002 if (command == cmd_802_11_scan || command == cmd_802_11_authenticate
1038 || command == cmd_802_11_authenticate
1039 || command == cmd_802_11_associate) 1003 || command == cmd_802_11_associate)
1040 mod_timer(&adapter->command_timer, jiffies + (10*HZ)); 1004 mod_timer(&adapter->command_timer, jiffies + (10*HZ));
1041 else 1005 else
@@ -1056,12 +1020,11 @@ static int wlan_cmd_mac_control(wlan_private * priv,
1056 lbs_deb_enter(LBS_DEB_CMD); 1020 lbs_deb_enter(LBS_DEB_CMD);
1057 1021
1058 cmd->command = cpu_to_le16(cmd_mac_control); 1022 cmd->command = cpu_to_le16(cmd_mac_control);
1059 cmd->size = 1023 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN);
1060 cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN);
1061 mac->action = cpu_to_le16(priv->adapter->currentpacketfilter); 1024 mac->action = cpu_to_le16(priv->adapter->currentpacketfilter);
1062 1025
1063 lbs_deb_cmd("wlan_cmd_mac_control(): action=0x%X size=%d\n", 1026 lbs_deb_cmd("wlan_cmd_mac_control(): action=0x%X size=%d\n",
1064 mac->action, cmd->size); 1027 le16_to_cpu(mac->action), le16_to_cpu(cmd->size));
1065 1028
1066 lbs_deb_leave(LBS_DEB_CMD); 1029 lbs_deb_leave(LBS_DEB_CMD);
1067 return 0; 1030 return 0;
@@ -1193,7 +1156,7 @@ int libertas_prepare_and_send_command(wlan_private * priv,
1193 adapter->seqnum++; 1156 adapter->seqnum++;
1194 cmdptr->seqnum = cpu_to_le16(adapter->seqnum); 1157 cmdptr->seqnum = cpu_to_le16(adapter->seqnum);
1195 1158
1196 cmdptr->command = cmd_no; 1159 cmdptr->command = cpu_to_le16(cmd_no);
1197 cmdptr->result = 0; 1160 cmdptr->result = 0;
1198 1161
1199 switch (cmd_no) { 1162 switch (cmd_no) {
@@ -1329,9 +1292,8 @@ int libertas_prepare_and_send_command(wlan_private * priv,
1329 case cmd_802_11_get_afc: 1292 case cmd_802_11_get_afc:
1330 1293
1331 cmdptr->command = cpu_to_le16(cmd_no); 1294 cmdptr->command = cpu_to_le16(cmd_no);
1332 cmdptr->size = 1295 cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) +
1333 cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) + 1296 S_DS_GEN);
1334 S_DS_GEN);
1335 1297
1336 memmove(&cmdptr->params.afc, 1298 memmove(&cmdptr->params.afc,
1337 pdata_buf, sizeof(struct cmd_ds_802_11_afc)); 1299 pdata_buf, sizeof(struct cmd_ds_802_11_afc));
@@ -1410,17 +1372,14 @@ int libertas_prepare_and_send_command(wlan_private * priv,
1410 1372
1411 case cmd_get_tsf: 1373 case cmd_get_tsf:
1412 cmdptr->command = cpu_to_le16(cmd_get_tsf); 1374 cmdptr->command = cpu_to_le16(cmd_get_tsf);
1413 cmdptr->size = 1375 cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_get_tsf) +
1414 cpu_to_le16(sizeof(struct cmd_ds_get_tsf) 1376 S_DS_GEN);
1415 + S_DS_GEN);
1416 ret = 0; 1377 ret = 0;
1417 break; 1378 break;
1418 case cmd_802_11_tx_rate_query: 1379 case cmd_802_11_tx_rate_query:
1419 cmdptr->command = 1380 cmdptr->command = cpu_to_le16(cmd_802_11_tx_rate_query);
1420 cpu_to_le16(cmd_802_11_tx_rate_query); 1381 cmdptr->size = cpu_to_le16(sizeof(struct cmd_tx_rate_query) +
1421 cmdptr->size = 1382 S_DS_GEN);
1422 cpu_to_le16(sizeof(struct cmd_tx_rate_query) +
1423 S_DS_GEN);
1424 adapter->txrate = 0; 1383 adapter->txrate = 0;
1425 ret = 0; 1384 ret = 0;
1426 break; 1385 break;
@@ -1529,7 +1488,7 @@ done:
1529 */ 1488 */
1530int libertas_free_cmd_buffer(wlan_private * priv) 1489int libertas_free_cmd_buffer(wlan_private * priv)
1531{ 1490{
1532 u32 ulbufsize; 1491 u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */
1533 unsigned int i; 1492 unsigned int i;
1534 struct cmd_ctrl_node *tempcmd_array; 1493 struct cmd_ctrl_node *tempcmd_array;
1535 wlan_adapter *adapter = priv->adapter; 1494 wlan_adapter *adapter = priv->adapter;
@@ -1694,18 +1653,19 @@ int libertas_execute_next_command(wlan_private * priv)
1694 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 1653 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1695 1654
1696 if (is_command_allowed_in_ps(cmdptr->command)) { 1655 if (is_command_allowed_in_ps(cmdptr->command)) {
1697 if ((adapter->psstate == PS_STATE_SLEEP) 1656 if ((adapter->psstate == PS_STATE_SLEEP) ||
1698 || (adapter->psstate == PS_STATE_PRE_SLEEP) 1657 (adapter->psstate == PS_STATE_PRE_SLEEP)) {
1699 ) {
1700 lbs_deb_cmd( 1658 lbs_deb_cmd(
1701 "EXEC_NEXT_CMD: Cannot send cmd 0x%x in psstate %d\n", 1659 "EXEC_NEXT_CMD: Cannot send cmd 0x%x in psstate %d\n",
1702 cmdptr->command, adapter->psstate); 1660 le16_to_cpu(cmdptr->command),
1661 adapter->psstate);
1703 ret = -1; 1662 ret = -1;
1704 goto done; 1663 goto done;
1705 } 1664 }
1706 lbs_deb_cmd("EXEC_NEXT_CMD: OK to send command " 1665 lbs_deb_cmd("EXEC_NEXT_CMD: OK to send command "
1707 "0x%x in psstate %d\n", 1666 "0x%x in psstate %d\n",
1708 cmdptr->command, adapter->psstate); 1667 le16_to_cpu(cmdptr->command),
1668 adapter->psstate);
1709 } else if (adapter->psstate != PS_STATE_FULL_POWER) { 1669 } else if (adapter->psstate != PS_STATE_FULL_POWER) {
1710 /* 1670 /*
1711 * 1. Non-PS command: 1671 * 1. Non-PS command:
@@ -1755,9 +1715,8 @@ int libertas_execute_next_command(wlan_private * priv)
1755 goto done; 1715 goto done;
1756 } 1716 }
1757 1717
1758 if ((adapter->psstate == PS_STATE_SLEEP) 1718 if ((adapter->psstate == PS_STATE_SLEEP) ||
1759 || (adapter->psstate == PS_STATE_PRE_SLEEP) 1719 (adapter->psstate == PS_STATE_PRE_SLEEP)) {
1760 ) {
1761 lbs_deb_cmd( 1720 lbs_deb_cmd(
1762 "EXEC_NEXT_CMD: Ignore ExitPS cmd in sleep\n"); 1721 "EXEC_NEXT_CMD: Ignore ExitPS cmd in sleep\n");
1763 list_del((struct list_head *)cmdnode); 1722 list_del((struct list_head *)cmdnode);
@@ -1774,7 +1733,7 @@ int libertas_execute_next_command(wlan_private * priv)
1774 } 1733 }
1775 list_del((struct list_head *)cmdnode); 1734 list_del((struct list_head *)cmdnode);
1776 lbs_deb_cmd("EXEC_NEXT_CMD: Sending 0x%04X command\n", 1735 lbs_deb_cmd("EXEC_NEXT_CMD: Sending 0x%04X command\n",
1777 cmdptr->command); 1736 le16_to_cpu(cmdptr->command));
1778 DownloadcommandToStation(priv, cmdnode); 1737 DownloadcommandToStation(priv, cmdnode);
1779 } else { 1738 } else {
1780 /* 1739 /*
@@ -1784,11 +1743,11 @@ int libertas_execute_next_command(wlan_private * priv)
1784 if ((adapter->psmode != wlan802_11powermodecam) && 1743 if ((adapter->psmode != wlan802_11powermodecam) &&
1785 (adapter->psstate == PS_STATE_FULL_POWER) && 1744 (adapter->psstate == PS_STATE_FULL_POWER) &&
1786 (adapter->connect_status == libertas_connected)) { 1745 (adapter->connect_status == libertas_connected)) {
1787 if (adapter->secinfo.WPAenabled 1746 if (adapter->secinfo.WPAenabled ||
1788 || adapter->secinfo.WPA2enabled) { 1747 adapter->secinfo.WPA2enabled) {
1789 /* check for valid WPA group keys */ 1748 /* check for valid WPA group keys */
1790 if (adapter->wpa_mcast_key.len 1749 if (adapter->wpa_mcast_key.len ||
1791 || adapter->wpa_unicast_key.len) { 1750 adapter->wpa_unicast_key.len) {
1792 lbs_deb_cmd( 1751 lbs_deb_cmd(
1793 "EXEC_NEXT_CMD: WPA enabled and GTK_SET" 1752 "EXEC_NEXT_CMD: WPA enabled and GTK_SET"
1794 " go back to PS_SLEEP"); 1753 " go back to PS_SLEEP");
@@ -1824,8 +1783,7 @@ void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str)
1824 iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN; 1783 iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
1825 1784
1826 /* Send Event to upper layer */ 1785 /* Send Event to upper layer */
1827 lbs_deb_cmd("Event Indication string = %s\n", 1786 lbs_deb_cmd("Event Indication string = %s\n", (char *)buf);
1828 (char *)buf);
1829 lbs_deb_cmd("Event Indication String length = %d\n", iwrq.data.length); 1787 lbs_deb_cmd("Event Indication String length = %d\n", iwrq.data.length);
1830 1788
1831 lbs_deb_cmd("Sending wireless event IWEVCUSTOM for %s\n", str); 1789 lbs_deb_cmd("Sending wireless event IWEVCUSTOM for %s\n", str);
@@ -1901,13 +1859,13 @@ void libertas_ps_sleep(wlan_private * priv, int wait_option)
1901 */ 1859 */
1902void libertas_ps_wakeup(wlan_private * priv, int wait_option) 1860void libertas_ps_wakeup(wlan_private * priv, int wait_option)
1903{ 1861{
1904 enum WLAN_802_11_POWER_MODE Localpsmode; 1862 __le32 Localpsmode;
1905 1863
1906 lbs_deb_enter(LBS_DEB_CMD); 1864 lbs_deb_enter(LBS_DEB_CMD);
1907 1865
1908 Localpsmode = wlan802_11powermodecam; 1866 Localpsmode = cpu_to_le32(wlan802_11powermodecam);
1909 1867
1910 lbs_deb_cmd("Exit_PS: Localpsmode = %d\n", Localpsmode); 1868 lbs_deb_cmd("Exit_PS: Localpsmode = %d\n", wlan802_11powermodecam);
1911 1869
1912 libertas_prepare_and_send_command(priv, cmd_802_11_ps_mode, 1870 libertas_prepare_and_send_command(priv, cmd_802_11_ps_mode,
1913 cmd_subcmd_exit_ps, 1871 cmd_subcmd_exit_ps,