aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2008-09-10 12:49:00 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-15 16:48:20 -0400
commit39fcf7a315e098430e878a5c0c4d39561c93ebf6 (patch)
treee616eb6085e4c99c8920edbd6ebbec65627b7445 /drivers/net/wireless/libertas
parent500c064d3a5f9c8aa604ef63a1346ab70eed443a (diff)
libertas: convert SNMP_MIB to a direct command
And support setting both long and short retries independently. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas')
-rw-r--r--drivers/net/wireless/libertas/assoc.c6
-rw-r--r--drivers/net/wireless/libertas/cmd.c180
-rw-r--r--drivers/net/wireless/libertas/cmd.h4
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c46
-rw-r--r--drivers/net/wireless/libertas/defs.h27
-rw-r--r--drivers/net/wireless/libertas/dev.h3
-rw-r--r--drivers/net/wireless/libertas/host.h24
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h5
-rw-r--r--drivers/net/wireless/libertas/wext.c141
9 files changed, 172 insertions, 264 deletions
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 4ddf44b2758b..92be60415d04 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -823,11 +823,7 @@ static int assoc_helper_mode(struct lbs_private *priv,
823 } 823 }
824 824
825 priv->mode = assoc_req->mode; 825 priv->mode = assoc_req->mode;
826 ret = lbs_prepare_and_send_command(priv, 826 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_BSS_TYPE, assoc_req->mode);
827 CMD_802_11_SNMP_MIB,
828 0, CMD_OPTION_WAITFORRSP,
829 OID_802_11_INFRASTRUCTURE_MODE,
830 /* Shoot me now */ (void *) (size_t) assoc_req->mode);
831 827
832done: 828done:
833 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 829 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index b57625a38021..aee19fa844e4 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -480,124 +480,103 @@ int lbs_cmd_802_11_key_material(struct lbs_private *priv, uint16_t cmd_action,
480 return ret; 480 return ret;
481} 481}
482 482
483static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv, 483/**
484 struct cmd_ds_command *cmd, 484 * @brief Set an SNMP MIB value
485 int cmd_action, 485 *
486 int cmd_oid, void *pdata_buf) 486 * @param priv A pointer to struct lbs_private structure
487 * @param oid The OID to set in the firmware
488 * @param val Value to set the OID to
489 *
490 * @return 0 on success, error on failure
491 */
492int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val)
487{ 493{
488 struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib; 494 struct cmd_ds_802_11_snmp_mib cmd;
489 u8 ucTemp; 495 int ret;
490 496
491 lbs_deb_enter(LBS_DEB_CMD); 497 lbs_deb_enter(LBS_DEB_CMD);
492 498
493 lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); 499 memset(&cmd, 0, sizeof (cmd));
494 500 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
495 cmd->command = cpu_to_le16(CMD_802_11_SNMP_MIB); 501 cmd.action = cpu_to_le16(CMD_ACT_SET);
496 cmd->size = cpu_to_le16(sizeof(*pSNMPMIB) + S_DS_GEN); 502 cmd.oid = cpu_to_le16((u16) oid);
497
498 switch (cmd_oid) {
499 case OID_802_11_INFRASTRUCTURE_MODE:
500 {
501 u8 mode = (u8) (size_t) pdata_buf;
502 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
503 pSNMPMIB->oid = cpu_to_le16((u16) DESIRED_BSSTYPE_I);
504 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u8));
505 if (mode == IW_MODE_ADHOC) {
506 ucTemp = SNMP_MIB_VALUE_ADHOC;
507 } else {
508 /* Infra and Auto modes */
509 ucTemp = SNMP_MIB_VALUE_INFRA;
510 }
511
512 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8));
513 503
504 switch (oid) {
505 case SNMP_MIB_OID_BSS_TYPE:
506 cmd.bufsize = cpu_to_le16(sizeof(u8));
507 cmd.value[0] = (val == IW_MODE_ADHOC) ? 2 : 1;
508 break;
509 case SNMP_MIB_OID_11D_ENABLE:
510 case SNMP_MIB_OID_FRAG_THRESHOLD:
511 case SNMP_MIB_OID_RTS_THRESHOLD:
512 case SNMP_MIB_OID_SHORT_RETRY_LIMIT:
513 case SNMP_MIB_OID_LONG_RETRY_LIMIT:
514 cmd.bufsize = cpu_to_le16(sizeof(u16));
515 *((__le16 *)(&cmd.value)) = cpu_to_le16(val);
514 break; 516 break;
517 default:
518 lbs_deb_cmd("SNMP_CMD: (set) unhandled OID 0x%x\n", oid);
519 ret = -EINVAL;
520 goto out;
515 } 521 }
516 522
517 case OID_802_11D_ENABLE: 523 lbs_deb_cmd("SNMP_CMD: (set) oid 0x%x, oid size 0x%x, value 0x%x\n",
518 { 524 le16_to_cpu(cmd.oid), le16_to_cpu(cmd.bufsize), val);
519 u32 ulTemp;
520
521 pSNMPMIB->oid = cpu_to_le16((u16) DOT11D_I);
522
523 if (cmd_action == CMD_ACT_SET) {
524 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
525 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
526 ulTemp = *(u32 *)pdata_buf;
527 *((__le16 *)(pSNMPMIB->value)) =
528 cpu_to_le16((u16) ulTemp);
529 }
530 break;
531 }
532
533 case OID_802_11_FRAGMENTATION_THRESHOLD:
534 {
535 u32 ulTemp;
536
537 pSNMPMIB->oid = cpu_to_le16((u16) FRAGTHRESH_I);
538 525
539 if (cmd_action == CMD_ACT_GET) { 526 ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd);
540 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
541 } else if (cmd_action == CMD_ACT_SET) {
542 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
543 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
544 ulTemp = *((u32 *) pdata_buf);
545 *((__le16 *)(pSNMPMIB->value)) =
546 cpu_to_le16((u16) ulTemp);
547 527
548 } 528out:
549 529 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
550 break; 530 return ret;
551 } 531}
552 532
553 case OID_802_11_RTS_THRESHOLD: 533/**
554 { 534 * @brief Get an SNMP MIB value
535 *
536 * @param priv A pointer to struct lbs_private structure
537 * @param oid The OID to retrieve from the firmware
538 * @param out_val Location for the returned value
539 *
540 * @return 0 on success, error on failure
541 */
542int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val)
543{
544 struct cmd_ds_802_11_snmp_mib cmd;
545 int ret;
555 546
556 u32 ulTemp; 547 lbs_deb_enter(LBS_DEB_CMD);
557 pSNMPMIB->oid = cpu_to_le16(RTSTHRESH_I);
558 548
559 if (cmd_action == CMD_ACT_GET) { 549 memset(&cmd, 0, sizeof (cmd));
560 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET); 550 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
561 } else if (cmd_action == CMD_ACT_SET) { 551 cmd.action = cpu_to_le16(CMD_ACT_GET);
562 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); 552 cmd.oid = cpu_to_le16(oid);
563 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
564 ulTemp = *((u32 *)pdata_buf);
565 *(__le16 *)(pSNMPMIB->value) =
566 cpu_to_le16((u16) ulTemp);
567 553
568 } 554 ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd);
569 break; 555 if (ret)
570 } 556 goto out;
571 case OID_802_11_TX_RETRYCOUNT:
572 pSNMPMIB->oid = cpu_to_le16((u16) SHORT_RETRYLIM_I);
573
574 if (cmd_action == CMD_ACT_GET) {
575 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
576 } else if (cmd_action == CMD_ACT_SET) {
577 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
578 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
579 *((__le16 *)(pSNMPMIB->value)) =
580 cpu_to_le16((u16) priv->txretrycount);
581 }
582 557
558 switch (le16_to_cpu(cmd.bufsize)) {
559 case sizeof(u8):
560 if (oid == SNMP_MIB_OID_BSS_TYPE) {
561 if (cmd.value[0] == 2)
562 *out_val = IW_MODE_ADHOC;
563 else
564 *out_val = IW_MODE_INFRA;
565 } else
566 *out_val = cmd.value[0];
567 break;
568 case sizeof(u16):
569 *out_val = le16_to_cpu(*((__le16 *)(&cmd.value)));
583 break; 570 break;
584 default: 571 default:
572 lbs_deb_cmd("SNMP_CMD: (get) unhandled OID 0x%x size %d\n",
573 oid, le16_to_cpu(cmd.bufsize));
585 break; 574 break;
586 } 575 }
587 576
588 lbs_deb_cmd( 577out:
589 "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n", 578 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
590 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size), 579 return ret;
591 le16_to_cpu(cmd->seqnum), le16_to_cpu(cmd->result));
592
593 lbs_deb_cmd(
594 "SNMP_CMD: action 0x%x, oid 0x%x, oidsize 0x%x, value 0x%x\n",
595 le16_to_cpu(pSNMPMIB->querytype), le16_to_cpu(pSNMPMIB->oid),
596 le16_to_cpu(pSNMPMIB->bufsize),
597 le16_to_cpu(*(__le16 *) pSNMPMIB->value));
598
599 lbs_deb_leave(LBS_DEB_CMD);
600 return 0;
601} 580}
602 581
603/** 582/**
@@ -1409,11 +1388,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1409 ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf); 1388 ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf);
1410 break; 1389 break;
1411 1390
1412 case CMD_802_11_SNMP_MIB:
1413 ret = lbs_cmd_802_11_snmp_mib(priv, cmdptr,
1414 cmd_action, cmd_oid, pdata_buf);
1415 break;
1416
1417 case CMD_MAC_REG_ACCESS: 1391 case CMD_MAC_REG_ACCESS:
1418 case CMD_BBP_REG_ACCESS: 1392 case CMD_BBP_REG_ACCESS:
1419 case CMD_RF_REG_ACCESS: 1393 case CMD_RF_REG_ACCESS:
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index 336a181d857a..d002160f597d 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -73,4 +73,8 @@ int lbs_set_tx_power(struct lbs_private *priv, s16 dbm);
73 73
74int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on); 74int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on);
75 75
76int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val);
77
78int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val);
79
76#endif /* _LBS_CMD_H */ 80#endif /* _LBS_CMD_H */
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index f305b049b586..bcf2a9756fb6 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -146,48 +146,6 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
146 return ret; 146 return ret;
147} 147}
148 148
149static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv,
150 struct cmd_ds_command *resp)
151{
152 struct cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
153 u16 oid = le16_to_cpu(smib->oid);
154 u16 querytype = le16_to_cpu(smib->querytype);
155
156 lbs_deb_enter(LBS_DEB_CMD);
157
158 lbs_deb_cmd("SNMP_RESP: oid 0x%x, querytype 0x%x\n", oid,
159 querytype);
160 lbs_deb_cmd("SNMP_RESP: Buf size %d\n", le16_to_cpu(smib->bufsize));
161
162 if (querytype == CMD_ACT_GET) {
163 switch (oid) {
164 case FRAGTHRESH_I:
165 priv->fragthsd =
166 le16_to_cpu(*((__le16 *)(smib->value)));
167 lbs_deb_cmd("SNMP_RESP: frag threshold %u\n",
168 priv->fragthsd);
169 break;
170 case RTSTHRESH_I:
171 priv->rtsthsd =
172 le16_to_cpu(*((__le16 *)(smib->value)));
173 lbs_deb_cmd("SNMP_RESP: rts threshold %u\n",
174 priv->rtsthsd);
175 break;
176 case SHORT_RETRYLIM_I:
177 priv->txretrycount =
178 le16_to_cpu(*((__le16 *)(smib->value)));
179 lbs_deb_cmd("SNMP_RESP: tx retry count %u\n",
180 priv->rtsthsd);
181 break;
182 default:
183 break;
184 }
185 }
186
187 lbs_deb_enter(LBS_DEB_CMD);
188 return 0;
189}
190
191static int lbs_ret_802_11_rssi(struct lbs_private *priv, 149static int lbs_ret_802_11_rssi(struct lbs_private *priv,
192 struct cmd_ds_command *resp) 150 struct cmd_ds_command *resp)
193{ 151{
@@ -258,10 +216,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
258 ret = lbs_ret_80211_associate(priv, resp); 216 ret = lbs_ret_80211_associate(priv, resp);
259 break; 217 break;
260 218
261 case CMD_RET(CMD_802_11_SNMP_MIB):
262 ret = lbs_ret_802_11_snmp_mib(priv, resp);
263 break;
264
265 case CMD_RET(CMD_802_11_SET_AFC): 219 case CMD_RET(CMD_802_11_SET_AFC):
266 case CMD_RET(CMD_802_11_GET_AFC): 220 case CMD_RET(CMD_802_11_GET_AFC):
267 spin_lock_irqsave(&priv->driver_lock, flags); 221 spin_lock_irqsave(&priv->driver_lock, flags);
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index c89d7a1041a8..58d11a35e61b 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -352,27 +352,6 @@ enum mv_ms_type {
352 MVMS_EVENT 352 MVMS_EVENT
353}; 353};
354 354
355/** SNMP_MIB_INDEX_e */
356enum SNMP_MIB_INDEX_e {
357 DESIRED_BSSTYPE_I = 0,
358 OP_RATESET_I,
359 BCNPERIOD_I,
360 DTIMPERIOD_I,
361 ASSOCRSP_TIMEOUT_I,
362 RTSTHRESH_I,
363 SHORT_RETRYLIM_I,
364 LONG_RETRYLIM_I,
365 FRAGTHRESH_I,
366 DOT11D_I,
367 DOT11H_I,
368 MANUFID_I,
369 PRODID_I,
370 MANUF_OUI_I,
371 MANUF_NAME_I,
372 MANUF_PRODNAME_I,
373 MANUF_PRODVER_I,
374};
375
376/** KEY_TYPE_ID */ 355/** KEY_TYPE_ID */
377enum KEY_TYPE_ID { 356enum KEY_TYPE_ID {
378 KEY_TYPE_ID_WEP = 0, 357 KEY_TYPE_ID_WEP = 0,
@@ -387,12 +366,6 @@ enum KEY_INFO_WPA {
387 KEY_INFO_WPA_ENABLED = 0x04 366 KEY_INFO_WPA_ENABLED = 0x04
388}; 367};
389 368
390/** SNMP_MIB_VALUE_e */
391enum SNMP_MIB_VALUE_e {
392 SNMP_MIB_VALUE_INFRA = 1,
393 SNMP_MIB_VALUE_ADHOC
394};
395
396/* Default values for fwt commands. */ 369/* Default values for fwt commands. */
397#define FWT_DEFAULT_METRIC 0 370#define FWT_DEFAULT_METRIC 0
398#define FWT_DEFAULT_DIR 1 371#define FWT_DEFAULT_DIR 1
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index fd59e1816460..acb889e25900 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -240,9 +240,6 @@ struct lbs_private {
240 uint16_t enablehwauto; 240 uint16_t enablehwauto;
241 uint16_t ratebitmap; 241 uint16_t ratebitmap;
242 242
243 u32 fragthsd;
244 u32 rtsthsd;
245
246 u8 txretrycount; 243 u8 txretrycount;
247 244
248 /** Tx-related variables (for single packet tx) */ 245 /** Tx-related variables (for single packet tx) */
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h
index a916bb9bd5da..5004d7679c02 100644
--- a/drivers/net/wireless/libertas/host.h
+++ b/drivers/net/wireless/libertas/host.h
@@ -9,17 +9,6 @@
9#define DEFAULT_AD_HOC_CHANNEL 6 9#define DEFAULT_AD_HOC_CHANNEL 6
10#define DEFAULT_AD_HOC_CHANNEL_A 36 10#define DEFAULT_AD_HOC_CHANNEL_A 36
11 11
12/** IEEE 802.11 oids */
13#define OID_802_11_SSID 0x00008002
14#define OID_802_11_INFRASTRUCTURE_MODE 0x00008008
15#define OID_802_11_FRAGMENTATION_THRESHOLD 0x00008009
16#define OID_802_11_RTS_THRESHOLD 0x0000800A
17#define OID_802_11_TX_ANTENNA_SELECTED 0x0000800D
18#define OID_802_11_SUPPORTED_RATES 0x0000800E
19#define OID_802_11_STATISTICS 0x00008012
20#define OID_802_11_TX_RETRYCOUNT 0x0000801D
21#define OID_802_11D_ENABLE 0x00008020
22
23#define CMD_OPTION_WAITFORRSP 0x0002 12#define CMD_OPTION_WAITFORRSP 0x0002
24 13
25/** Host command IDs */ 14/** Host command IDs */
@@ -191,6 +180,19 @@
191#define CMD_WAKE_METHOD_COMMAND_INT 0x0001 180#define CMD_WAKE_METHOD_COMMAND_INT 0x0001
192#define CMD_WAKE_METHOD_GPIO 0x0002 181#define CMD_WAKE_METHOD_GPIO 0x0002
193 182
183/* Object IDs for CMD_802_11_SNMP_MIB */
184#define SNMP_MIB_OID_BSS_TYPE 0x0000
185#define SNMP_MIB_OID_OP_RATE_SET 0x0001
186#define SNMP_MIB_OID_BEACON_PERIOD 0x0002 /* Reserved on v9+ */
187#define SNMP_MIB_OID_DTIM_PERIOD 0x0003 /* Reserved on v9+ */
188#define SNMP_MIB_OID_ASSOC_TIMEOUT 0x0004 /* Reserved on v9+ */
189#define SNMP_MIB_OID_RTS_THRESHOLD 0x0005
190#define SNMP_MIB_OID_SHORT_RETRY_LIMIT 0x0006
191#define SNMP_MIB_OID_LONG_RETRY_LIMIT 0x0007
192#define SNMP_MIB_OID_FRAG_THRESHOLD 0x0008
193#define SNMP_MIB_OID_11D_ENABLE 0x0009
194#define SNMP_MIB_OID_11H_ENABLE 0x000A
195
194/* Define action or option for CMD_BT_ACCESS */ 196/* Define action or option for CMD_BT_ACCESS */
195enum cmd_bt_access_opts { 197enum cmd_bt_access_opts {
196 /* The bt commands start at 5 instead of 1 because the old dft commands 198 /* The bt commands start at 5 instead of 1 because the old dft commands
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index f2f92e237c4a..d9f9a12a739e 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -297,7 +297,9 @@ struct cmd_ds_802_11_get_stat {
297}; 297};
298 298
299struct cmd_ds_802_11_snmp_mib { 299struct cmd_ds_802_11_snmp_mib {
300 __le16 querytype; 300 struct cmd_header hdr;
301
302 __le16 action;
301 __le16 oid; 303 __le16 oid;
302 __le16 bufsize; 304 __le16 bufsize;
303 u8 value[128]; 305 u8 value[128];
@@ -716,7 +718,6 @@ struct cmd_ds_command {
716 struct cmd_ds_802_11_authenticate auth; 718 struct cmd_ds_802_11_authenticate auth;
717 struct cmd_ds_802_11_get_stat gstat; 719 struct cmd_ds_802_11_get_stat gstat;
718 struct cmd_ds_802_3_get_stat gstat_8023; 720 struct cmd_ds_802_3_get_stat gstat_8023;
719 struct cmd_ds_802_11_snmp_mib smib;
720 struct cmd_ds_802_11_rf_antenna rant; 721 struct cmd_ds_802_11_rf_antenna rant;
721 struct cmd_ds_802_11_monitor_mode monitor; 722 struct cmd_ds_802_11_monitor_mode monitor;
722 struct cmd_ds_802_11_rssi rssi; 723 struct cmd_ds_802_11_rssi rssi;
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index e8cadad2c863..d86fcf0a5ad5 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -266,21 +266,17 @@ static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
266{ 266{
267 int ret = 0; 267 int ret = 0;
268 struct lbs_private *priv = dev->priv; 268 struct lbs_private *priv = dev->priv;
269 u32 rthr = vwrq->value; 269 u32 val = vwrq->value;
270 270
271 lbs_deb_enter(LBS_DEB_WEXT); 271 lbs_deb_enter(LBS_DEB_WEXT);
272 272
273 if (vwrq->disabled) { 273 if (vwrq->disabled)
274 priv->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE; 274 val = MRVDRV_RTS_MAX_VALUE;
275 } else { 275
276 if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE) 276 if (val < MRVDRV_RTS_MIN_VALUE || val > MRVDRV_RTS_MAX_VALUE)
277 return -EINVAL; 277 return -EINVAL;
278 priv->rtsthsd = rthr;
279 }
280 278
281 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 279 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, (u16) val);
282 CMD_ACT_SET, CMD_OPTION_WAITFORRSP,
283 OID_802_11_RTS_THRESHOLD, &rthr);
284 280
285 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 281 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
286 return ret; 282 return ret;
@@ -289,21 +285,19 @@ static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
289static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info, 285static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
290 struct iw_param *vwrq, char *extra) 286 struct iw_param *vwrq, char *extra)
291{ 287{
292 int ret = 0;
293 struct lbs_private *priv = dev->priv; 288 struct lbs_private *priv = dev->priv;
289 int ret = 0;
290 u16 val = 0;
294 291
295 lbs_deb_enter(LBS_DEB_WEXT); 292 lbs_deb_enter(LBS_DEB_WEXT);
296 293
297 priv->rtsthsd = 0; 294 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
298 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
299 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
300 OID_802_11_RTS_THRESHOLD, NULL);
301 if (ret) 295 if (ret)
302 goto out; 296 goto out;
303 297
304 vwrq->value = priv->rtsthsd; 298 vwrq->value = val;
305 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE) 299 vwrq->disabled = ((val < MRVDRV_RTS_MIN_VALUE)
306 || (vwrq->value > MRVDRV_RTS_MAX_VALUE)); 300 || (val > MRVDRV_RTS_MAX_VALUE));
307 vwrq->fixed = 1; 301 vwrq->fixed = 1;
308 302
309out: 303out:
@@ -314,24 +308,19 @@ out:
314static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info, 308static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
315 struct iw_param *vwrq, char *extra) 309 struct iw_param *vwrq, char *extra)
316{ 310{
317 int ret = 0;
318 u32 fthr = vwrq->value;
319 struct lbs_private *priv = dev->priv; 311 struct lbs_private *priv = dev->priv;
312 int ret = 0;
313 u32 val = vwrq->value;
320 314
321 lbs_deb_enter(LBS_DEB_WEXT); 315 lbs_deb_enter(LBS_DEB_WEXT);
322 316
323 if (vwrq->disabled) { 317 if (vwrq->disabled)
324 priv->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE; 318 val = MRVDRV_FRAG_MAX_VALUE;
325 } else { 319
326 if (fthr < MRVDRV_FRAG_MIN_VALUE 320 if (val < MRVDRV_FRAG_MIN_VALUE || val > MRVDRV_FRAG_MAX_VALUE)
327 || fthr > MRVDRV_FRAG_MAX_VALUE) 321 return -EINVAL;
328 return -EINVAL;
329 priv->fragthsd = fthr;
330 }
331 322
332 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 323 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, (u16) val);
333 CMD_ACT_SET, CMD_OPTION_WAITFORRSP,
334 OID_802_11_FRAGMENTATION_THRESHOLD, &fthr);
335 324
336 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 325 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
337 return ret; 326 return ret;
@@ -340,22 +329,19 @@ static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
340static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info, 329static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
341 struct iw_param *vwrq, char *extra) 330 struct iw_param *vwrq, char *extra)
342{ 331{
343 int ret = 0;
344 struct lbs_private *priv = dev->priv; 332 struct lbs_private *priv = dev->priv;
333 int ret = 0;
334 u16 val = 0;
345 335
346 lbs_deb_enter(LBS_DEB_WEXT); 336 lbs_deb_enter(LBS_DEB_WEXT);
347 337
348 priv->fragthsd = 0; 338 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
349 ret = lbs_prepare_and_send_command(priv,
350 CMD_802_11_SNMP_MIB,
351 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
352 OID_802_11_FRAGMENTATION_THRESHOLD, NULL);
353 if (ret) 339 if (ret)
354 goto out; 340 goto out;
355 341
356 vwrq->value = priv->fragthsd; 342 vwrq->value = val;
357 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE) 343 vwrq->disabled = ((val < MRVDRV_FRAG_MIN_VALUE)
358 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE)); 344 || (val > MRVDRV_FRAG_MAX_VALUE));
359 vwrq->fixed = 1; 345 vwrq->fixed = 1;
360 346
361out: 347out:
@@ -382,7 +368,7 @@ static int mesh_wlan_get_mode(struct net_device *dev,
382{ 368{
383 lbs_deb_enter(LBS_DEB_WEXT); 369 lbs_deb_enter(LBS_DEB_WEXT);
384 370
385 *uwrq = IW_MODE_REPEAT ; 371 *uwrq = IW_MODE_REPEAT;
386 372
387 lbs_deb_leave(LBS_DEB_WEXT); 373 lbs_deb_leave(LBS_DEB_WEXT);
388 return 0; 374 return 0;
@@ -425,31 +411,44 @@ out:
425static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info, 411static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
426 struct iw_param *vwrq, char *extra) 412 struct iw_param *vwrq, char *extra)
427{ 413{
428 int ret = 0;
429 struct lbs_private *priv = dev->priv; 414 struct lbs_private *priv = dev->priv;
415 int ret = 0;
416 u16 slimit = 0, llimit = 0;
430 417
431 lbs_deb_enter(LBS_DEB_WEXT); 418 lbs_deb_enter(LBS_DEB_WEXT);
432 419
433 if (vwrq->flags == IW_RETRY_LIMIT) { 420 if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
434 /* The MAC has a 4-bit Total_Tx_Count register 421 return -EOPNOTSUPP;
435 Total_Tx_Count = 1 + Tx_Retry_Count */ 422
423 /* The MAC has a 4-bit Total_Tx_Count register
424 Total_Tx_Count = 1 + Tx_Retry_Count */
436#define TX_RETRY_MIN 0 425#define TX_RETRY_MIN 0
437#define TX_RETRY_MAX 14 426#define TX_RETRY_MAX 14
438 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX) 427 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
439 return -EINVAL; 428 return -EINVAL;
440 429
441 /* Adding 1 to convert retry count to try count */ 430 /* Add 1 to convert retry count to try count */
442 priv->txretrycount = vwrq->value + 1; 431 if (vwrq->flags & IW_RETRY_SHORT)
432 slimit = (u16) (vwrq->value + 1);
433 else if (vwrq->flags & IW_RETRY_LONG)
434 llimit = (u16) (vwrq->value + 1);
435 else
436 slimit = llimit = (u16) (vwrq->value + 1); /* set both */
443 437
444 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 438 if (llimit) {
445 CMD_ACT_SET, 439 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT,
446 CMD_OPTION_WAITFORRSP, 440 llimit);
447 OID_802_11_TX_RETRYCOUNT, NULL); 441 if (ret)
442 goto out;
443 }
448 444
445 if (slimit) {
446 /* txretrycount follows the short retry limit */
447 priv->txretrycount = slimit;
448 ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT,
449 slimit);
449 if (ret) 450 if (ret)
450 goto out; 451 goto out;
451 } else {
452 return -EOPNOTSUPP;
453 } 452 }
454 453
455out: 454out:
@@ -462,22 +461,30 @@ static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
462{ 461{
463 struct lbs_private *priv = dev->priv; 462 struct lbs_private *priv = dev->priv;
464 int ret = 0; 463 int ret = 0;
464 u16 val = 0;
465 465
466 lbs_deb_enter(LBS_DEB_WEXT); 466 lbs_deb_enter(LBS_DEB_WEXT);
467 467
468 priv->txretrycount = 0;
469 ret = lbs_prepare_and_send_command(priv,
470 CMD_802_11_SNMP_MIB,
471 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
472 OID_802_11_TX_RETRYCOUNT, NULL);
473 if (ret)
474 goto out;
475
476 vwrq->disabled = 0; 468 vwrq->disabled = 0;
477 if (!vwrq->flags) { 469
478 vwrq->flags = IW_RETRY_LIMIT; 470 if (vwrq->flags & IW_RETRY_LONG) {
471 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_LONG_RETRY_LIMIT, &val);
472 if (ret)
473 goto out;
474
475 /* Subtract 1 to convert try count to retry count */
476 vwrq->value = val - 1;
477 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
478 } else {
479 ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_SHORT_RETRY_LIMIT, &val);
480 if (ret)
481 goto out;
482
483 /* txretry count follows the short retry limit */
484 priv->txretrycount = val;
479 /* Subtract 1 to convert try count to retry count */ 485 /* Subtract 1 to convert try count to retry count */
480 vwrq->value = priv->txretrycount - 1; 486 vwrq->value = val - 1;
487 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
481 } 488 }
482 489
483out: 490out: