aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2012-07-13 23:09:31 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-07-17 15:11:33 -0400
commit006606c0bb387ed8d97bd9915b0b64efd7f84d0d (patch)
tree5e18e8c3b9419e7d8ce242f0b948714af5d56561 /drivers
parent1f45b39ececbdfb13a7bf4d2f644d2e89a8b415f (diff)
mwifiex: remove unnecessary code in data rate configuration
1) Remove unnecessary wrapper functions. 2) Currently we don't have command to set Tx data rate, so mwifiex_rate_ioctl_set_rate_value() function and related code can be removed. 3) "ds_rate" filled by mwifiex_ret_tx_rate_cfg() is never used. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c4
-rw-r--r--drivers/net/wireless/mwifiex/cfp.c31
-rw-r--r--drivers/net/wireless/mwifiex/decl.h9
-rw-r--r--drivers/net/wireless/mwifiex/ioctl.h6
-rw-r--r--drivers/net/wireless/mwifiex/main.h5
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmdresp.c39
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c124
7 files changed, 17 insertions, 201 deletions
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 7276a3449e17..691487406241 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -615,7 +615,7 @@ static int
615mwifiex_dump_station_info(struct mwifiex_private *priv, 615mwifiex_dump_station_info(struct mwifiex_private *priv,
616 struct station_info *sinfo) 616 struct station_info *sinfo)
617{ 617{
618 struct mwifiex_rate_cfg rate; 618 u32 rate;
619 619
620 sinfo->filled = STATION_INFO_RX_BYTES | STATION_INFO_TX_BYTES | 620 sinfo->filled = STATION_INFO_RX_BYTES | STATION_INFO_TX_BYTES |
621 STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS | 621 STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS |
@@ -661,7 +661,7 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
661 sinfo->tx_packets = priv->stats.tx_packets; 661 sinfo->tx_packets = priv->stats.tx_packets;
662 sinfo->signal = priv->bcn_rssi_avg; 662 sinfo->signal = priv->bcn_rssi_avg;
663 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */ 663 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
664 sinfo->txrate.legacy = rate.rate * 5; 664 sinfo->txrate.legacy = rate * 5;
665 665
666 if (priv->bss_mode == NL80211_IFTYPE_STATION) { 666 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
667 sinfo->filled |= STATION_INFO_BSS_PARAM; 667 sinfo->filled |= STATION_INFO_BSS_PARAM;
diff --git a/drivers/net/wireless/mwifiex/cfp.c b/drivers/net/wireless/mwifiex/cfp.c
index 560871b0e236..f69300f93f42 100644
--- a/drivers/net/wireless/mwifiex/cfp.c
+++ b/drivers/net/wireless/mwifiex/cfp.c
@@ -167,23 +167,6 @@ u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv, u8 index,
167} 167}
168 168
169/* 169/*
170 * This function maps a data rate value into corresponding index in supported
171 * rates table.
172 */
173u8 mwifiex_data_rate_to_index(u32 rate)
174{
175 u16 *ptr;
176
177 if (rate) {
178 ptr = memchr(mwifiex_data_rates, rate,
179 sizeof(mwifiex_data_rates));
180 if (ptr)
181 return (u8) (ptr - mwifiex_data_rates);
182 }
183 return 0;
184}
185
186/*
187 * This function returns the current active data rates. 170 * This function returns the current active data rates.
188 * 171 *
189 * The result may vary depending upon connection status. 172 * The result may vary depending upon connection status.
@@ -277,20 +260,6 @@ mwifiex_is_rate_auto(struct mwifiex_private *priv)
277} 260}
278 261
279/* 262/*
280 * This function converts rate bitmap into rate index.
281 */
282int mwifiex_get_rate_index(u16 *rate_bitmap, int size)
283{
284 int i;
285
286 for (i = 0; i < size * 8; i++)
287 if (rate_bitmap[i / 16] & (1 << (i % 16)))
288 return i;
289
290 return 0;
291}
292
293/*
294 * This function gets the supported data rates. 263 * This function gets the supported data rates.
295 * 264 *
296 * The function works in both Ad-Hoc and infra mode by printing the 265 * The function works in both Ad-Hoc and infra mode by printing the
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h
index f918f66e5e27..070ef25f5186 100644
--- a/drivers/net/wireless/mwifiex/decl.h
+++ b/drivers/net/wireless/mwifiex/decl.h
@@ -41,16 +41,7 @@
41#define MWIFIEX_AMPDU_DEF_RXWINSIZE 16 41#define MWIFIEX_AMPDU_DEF_RXWINSIZE 16
42#define MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT 0xffff 42#define MWIFIEX_DEFAULT_BLOCK_ACK_TIMEOUT 0xffff
43 43
44#define MWIFIEX_RATE_INDEX_HRDSSS0 0
45#define MWIFIEX_RATE_INDEX_HRDSSS3 3
46#define MWIFIEX_RATE_INDEX_OFDM0 4
47#define MWIFIEX_RATE_INDEX_OFDM7 11
48#define MWIFIEX_RATE_INDEX_MCS0 12
49
50#define MWIFIEX_RATE_BITMAP_OFDM0 16
51#define MWIFIEX_RATE_BITMAP_OFDM7 23
52#define MWIFIEX_RATE_BITMAP_MCS0 32 44#define MWIFIEX_RATE_BITMAP_MCS0 32
53#define MWIFIEX_RATE_BITMAP_MCS127 159
54 45
55#define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024) 46#define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024)
56#define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024) 47#define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024)
diff --git a/drivers/net/wireless/mwifiex/ioctl.h b/drivers/net/wireless/mwifiex/ioctl.h
index e121294cc1ac..50191539bb32 100644
--- a/drivers/net/wireless/mwifiex/ioctl.h
+++ b/drivers/net/wireless/mwifiex/ioctl.h
@@ -225,12 +225,6 @@ struct mwifiex_ds_encrypt_key {
225 u8 wapi_rxpn[WAPI_RXPN_LEN]; 225 u8 wapi_rxpn[WAPI_RXPN_LEN];
226}; 226};
227 227
228struct mwifiex_rate_cfg {
229 u32 action;
230 u32 is_rate_auto;
231 u32 rate;
232};
233
234struct mwifiex_power_cfg { 228struct mwifiex_power_cfg {
235 u32 is_power_auto; 229 u32 is_power_auto;
236 u32 power_level; 230 u32 power_level;
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index b710649ccf15..34705f5e46e1 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -824,9 +824,7 @@ int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
824u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, 824u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
825 u8 *rates); 825 u8 *rates);
826u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates); 826u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
827u8 mwifiex_data_rate_to_index(u32 rate);
828u8 mwifiex_is_rate_auto(struct mwifiex_private *priv); 827u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
829int mwifiex_get_rate_index(u16 *rateBitmap, int size);
830extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE]; 828extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
831void mwifiex_save_curr_bcn(struct mwifiex_private *priv); 829void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
832void mwifiex_free_curr_bcn(struct mwifiex_private *priv); 830void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
@@ -945,8 +943,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
945int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type); 943int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
946int mwifiex_enable_hs(struct mwifiex_adapter *adapter); 944int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
947int mwifiex_disable_auto_ds(struct mwifiex_private *priv); 945int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
948int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, 946int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
949 struct mwifiex_rate_cfg *rate);
950int mwifiex_request_scan(struct mwifiex_private *priv, 947int mwifiex_request_scan(struct mwifiex_private *priv,
951 struct cfg80211_ssid *req_ssid); 948 struct cfg80211_ssid *req_ssid);
952int mwifiex_scan_networks(struct mwifiex_private *priv, 949int mwifiex_scan_networks(struct mwifiex_private *priv,
diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c
index 43ede5e58851..e0178c0829d7 100644
--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c
@@ -267,12 +267,10 @@ static int mwifiex_ret_get_log(struct mwifiex_private *priv,
267 * 267 *
268 * Based on the new rate bitmaps, the function re-evaluates if 268 * Based on the new rate bitmaps, the function re-evaluates if
269 * auto data rate has been activated. If not, it sends another 269 * auto data rate has been activated. If not, it sends another
270 * query to the firmware to get the current Tx data rate and updates 270 * query to the firmware to get the current Tx data rate.
271 * the driver value.
272 */ 271 */
273static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, 272static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
274 struct host_cmd_ds_command *resp, 273 struct host_cmd_ds_command *resp)
275 struct mwifiex_rate_cfg *ds_rate)
276{ 274{
277 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; 275 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
278 struct mwifiex_rate_scope *rate_scope; 276 struct mwifiex_rate_scope *rate_scope;
@@ -280,7 +278,6 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
280 u16 tlv, tlv_buf_len; 278 u16 tlv, tlv_buf_len;
281 u8 *tlv_buf; 279 u8 *tlv_buf;
282 u32 i; 280 u32 i;
283 int ret = 0;
284 281
285 tlv_buf = (u8 *) ((u8 *) rate_cfg) + 282 tlv_buf = (u8 *) ((u8 *) rate_cfg) +
286 sizeof(struct host_cmd_ds_tx_rate_cfg); 283 sizeof(struct host_cmd_ds_tx_rate_cfg);
@@ -318,33 +315,11 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
318 if (priv->is_data_rate_auto) 315 if (priv->is_data_rate_auto)
319 priv->data_rate = 0; 316 priv->data_rate = 0;
320 else 317 else
321 ret = mwifiex_send_cmd_async(priv, 318 return mwifiex_send_cmd_async(priv,
322 HostCmd_CMD_802_11_TX_RATE_QUERY, 319 HostCmd_CMD_802_11_TX_RATE_QUERY,
323 HostCmd_ACT_GEN_GET, 0, NULL); 320 HostCmd_ACT_GEN_GET, 0, NULL);
324
325 if (!ds_rate)
326 return ret;
327
328 if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
329 if (priv->is_data_rate_auto) {
330 ds_rate->is_rate_auto = 1;
331 return ret;
332 }
333 ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates,
334 sizeof(priv->bitmap_rates));
335
336 if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 &&
337 ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7)
338 ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 -
339 MWIFIEX_RATE_INDEX_OFDM0);
340
341 if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 &&
342 ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127)
343 ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 -
344 MWIFIEX_RATE_INDEX_MCS0);
345 }
346 321
347 return ret; 322 return 0;
348} 323}
349 324
350/* 325/*
@@ -856,7 +831,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
856 ret = mwifiex_ret_mac_multicast_adr(priv, resp); 831 ret = mwifiex_ret_mac_multicast_adr(priv, resp);
857 break; 832 break;
858 case HostCmd_CMD_TX_RATE_CFG: 833 case HostCmd_CMD_TX_RATE_CFG:
859 ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf); 834 ret = mwifiex_ret_tx_rate_cfg(priv, resp);
860 break; 835 break;
861 case HostCmd_CMD_802_11_SCAN: 836 case HostCmd_CMD_802_11_SCAN:
862 ret = mwifiex_ret_802_11_scan(priv, resp); 837 ret = mwifiex_ret_802_11_scan(priv, resp);
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index 6dff01650242..fb2136089a22 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -497,134 +497,24 @@ int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
497EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds); 497EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
498 498
499/* 499/*
500 * IOCTL request handler to get rate.
501 *
502 * This function prepares the correct firmware command and
503 * issues it to get the current rate if it is connected,
504 * otherwise, the function returns the lowest supported rate
505 * for the band.
506 */
507static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
508 struct mwifiex_rate_cfg *rate_cfg)
509{
510 rate_cfg->is_rate_auto = priv->is_data_rate_auto;
511 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
512 HostCmd_ACT_GEN_GET, 0, NULL);
513}
514
515/*
516 * IOCTL request handler to set rate.
517 *
518 * This function prepares the correct firmware command and
519 * issues it to set the current rate.
520 *
521 * The function also performs validation checking on the supplied value.
522 */
523static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
524 struct mwifiex_rate_cfg *rate_cfg)
525{
526 u8 rates[MWIFIEX_SUPPORTED_RATES];
527 u8 *rate;
528 int rate_index, ret;
529 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
530 u32 i;
531 struct mwifiex_adapter *adapter = priv->adapter;
532
533 if (rate_cfg->is_rate_auto) {
534 memset(bitmap_rates, 0, sizeof(bitmap_rates));
535 /* Support all HR/DSSS rates */
536 bitmap_rates[0] = 0x000F;
537 /* Support all OFDM rates */
538 bitmap_rates[1] = 0x00FF;
539 /* Support all HT-MCSs rate */
540 for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++)
541 bitmap_rates[i + 2] = 0xFFFF;
542 bitmap_rates[9] = 0x3FFF;
543 } else {
544 memset(rates, 0, sizeof(rates));
545 mwifiex_get_active_data_rates(priv, rates);
546 rate = rates;
547 for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) {
548 dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n",
549 rate[i], rate_cfg->rate);
550 if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f))
551 break;
552 }
553 if ((i == MWIFIEX_SUPPORTED_RATES) || !rate[i]) {
554 dev_err(adapter->dev, "fixed data rate %#x is out "
555 "of range\n", rate_cfg->rate);
556 return -1;
557 }
558 memset(bitmap_rates, 0, sizeof(bitmap_rates));
559
560 rate_index = mwifiex_data_rate_to_index(rate_cfg->rate);
561
562 /* Only allow b/g rates to be set */
563 if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 &&
564 rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) {
565 bitmap_rates[0] = 1 << rate_index;
566 } else {
567 rate_index -= 1; /* There is a 0x00 in the table */
568 if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 &&
569 rate_index <= MWIFIEX_RATE_INDEX_OFDM7)
570 bitmap_rates[1] = 1 << (rate_index -
571 MWIFIEX_RATE_INDEX_OFDM0);
572 }
573 }
574
575 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
576 HostCmd_ACT_GEN_SET, 0, bitmap_rates);
577
578 return ret;
579}
580
581/*
582 * IOCTL request handler to set/get rate.
583 *
584 * This function can be used to set/get either the rate value or the
585 * rate index.
586 */
587static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
588 struct mwifiex_rate_cfg *rate_cfg)
589{
590 int status;
591
592 if (!rate_cfg)
593 return -1;
594
595 if (rate_cfg->action == HostCmd_ACT_GEN_GET)
596 status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg);
597 else
598 status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg);
599
600 return status;
601}
602
603/*
604 * Sends IOCTL request to get the data rate. 500 * Sends IOCTL request to get the data rate.
605 * 501 *
606 * This function allocates the IOCTL request buffer, fills it 502 * This function allocates the IOCTL request buffer, fills it
607 * with requisite parameters and calls the IOCTL handler. 503 * with requisite parameters and calls the IOCTL handler.
608 */ 504 */
609int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, 505int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate)
610 struct mwifiex_rate_cfg *rate)
611{ 506{
612 int ret; 507 int ret;
613 508
614 memset(rate, 0, sizeof(struct mwifiex_rate_cfg)); 509 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
615 rate->action = HostCmd_ACT_GEN_GET; 510 HostCmd_ACT_GEN_GET, 0, NULL);
616 ret = mwifiex_rate_ioctl_cfg(priv, rate);
617 511
618 if (!ret) { 512 if (!ret) {
619 if (rate->is_rate_auto) 513 if (priv->is_data_rate_auto)
620 rate->rate = mwifiex_index_to_data_rate(priv, 514 *rate = mwifiex_index_to_data_rate(priv, priv->tx_rate,
621 priv->tx_rate, 515 priv->tx_htinfo);
622 priv->tx_htinfo
623 );
624 else 516 else
625 rate->rate = priv->data_rate; 517 *rate = priv->data_rate;
626 } else {
627 ret = -1;
628 } 518 }
629 519
630 return ret; 520 return ret;