aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/scan.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-08-02 11:40:45 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:49:48 -0400
commit8c5127657549d055ac9d709cdea73902a6ef392c (patch)
tree33e72a0b55165d51652a002ab6929857f0e2facc /drivers/net/wireless/libertas/scan.c
parente52414728b930f0adcbc38c6498dd03b3568fe99 (diff)
[PATCH] libertas: simplify and clean up data rate handling
Remove unused/duplicated fields and consolidate static data rate arrays, for example the libertas_supported_rates[] and datarates[] arrays in the bss_descriptor structure, and the libertas_supported_rates field in the wlan_adapter structure. Introduce libertas_fw_index_to_data_rate and libertas_data_rate_to_fw_index functions and use them everywhere firmware requires a rate index rather than a rate array. The firmware requires the 4 basic rates to have the MSB set, but most other stuff doesn't, like WEXT and mesh ioctls. Therefore, only set the MSB on basic rates when pushing rate arrays to firmware instead of doing a ton of (rate & 0x7f) everywhere. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/scan.c')
-rw-r--r--drivers/net/wireless/libertas/scan.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 2cac47fc4cd9..790e9888ea2b 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -17,6 +17,7 @@
17#include "decl.h" 17#include "decl.h"
18#include "dev.h" 18#include "dev.h"
19#include "scan.h" 19#include "scan.h"
20#include "join.h"
20 21
21//! Approximate amount of data needed to pass a scan result back to iwlist 22//! Approximate amount of data needed to pass a scan result back to iwlist
22#define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \ 23#define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \
@@ -904,22 +905,14 @@ static int libertas_process_bss(struct bss_descriptor * bss,
904 struct ieeetypes_dsparamset *pDS; 905 struct ieeetypes_dsparamset *pDS;
905 struct ieeetypes_cfparamset *pCF; 906 struct ieeetypes_cfparamset *pCF;
906 struct ieeetypes_ibssparamset *pibss; 907 struct ieeetypes_ibssparamset *pibss;
907 u8 *pos, *end;
908 u8 *pRate;
909 u8 bytestocopy;
910 u8 ratesize;
911 u16 beaconsize;
912 u8 founddatarateie;
913 int ret;
914
915 struct ieeetypes_countryinfoset *pcountryinfo; 908 struct ieeetypes_countryinfoset *pcountryinfo;
909 u8 *pos, *end, *p;
910 u8 n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0;
911 u16 beaconsize = 0;
912 int ret;
916 913
917 lbs_deb_enter(LBS_DEB_ASSOC); 914 lbs_deb_enter(LBS_DEB_ASSOC);
918 915
919 founddatarateie = 0;
920 ratesize = 0;
921 beaconsize = 0;
922
923 if (*bytesleft >= sizeof(beaconsize)) { 916 if (*bytesleft >= sizeof(beaconsize)) {
924 /* Extract & convert beacon size from the command buffer */ 917 /* Extract & convert beacon size from the command buffer */
925 beaconsize = le16_to_cpup((void *)*pbeaconinfo); 918 beaconsize = le16_to_cpup((void *)*pbeaconinfo);
@@ -1005,11 +998,9 @@ static int libertas_process_bss(struct bss_descriptor * bss,
1005 break; 998 break;
1006 999
1007 case MFIE_TYPE_RATES: 1000 case MFIE_TYPE_RATES:
1008 memcpy(bss->datarates, elem->data, elem->len); 1001 n_basic_rates = min_t(u8, MAX_RATES, elem->len);
1009 memmove(bss->libertas_supported_rates, elem->data, 1002 memcpy(bss->rates, elem->data, n_basic_rates);
1010 elem->len); 1003 got_basic_rates = 1;
1011 ratesize = elem->len;
1012 founddatarateie = 1;
1013 break; 1004 break;
1014 1005
1015 case MFIE_TYPE_FH_SET: 1006 case MFIE_TYPE_FH_SET:
@@ -1070,22 +1061,15 @@ static int libertas_process_bss(struct bss_descriptor * bss,
1070 * already found. Data rate IE should come before 1061 * already found. Data rate IE should come before
1071 * extended supported rate IE 1062 * extended supported rate IE
1072 */ 1063 */
1073 if (!founddatarateie) 1064 if (!got_basic_rates)
1074 break; 1065 break;
1075 1066
1076 if ((elem->len + ratesize) > WLAN_SUPPORTED_RATES) { 1067 n_ex_rates = elem->len;
1077 bytestocopy = 1068 if (n_basic_rates + n_ex_rates > MAX_RATES)
1078 (WLAN_SUPPORTED_RATES - ratesize); 1069 n_ex_rates = MAX_RATES - n_basic_rates;
1079 } else {
1080 bytestocopy = elem->len;
1081 }
1082 1070
1083 pRate = (u8 *) bss->datarates; 1071 p = bss->rates + n_basic_rates;
1084 pRate += ratesize; 1072 memcpy(p, elem->data, n_ex_rates);
1085 memmove(pRate, elem->data, bytestocopy);
1086 pRate = (u8 *) bss->libertas_supported_rates;
1087 pRate += ratesize;
1088 memmove(pRate, elem->data, bytestocopy);
1089 break; 1073 break;
1090 1074
1091 case MFIE_TYPE_GENERIC: 1075 case MFIE_TYPE_GENERIC:
@@ -1123,6 +1107,7 @@ static int libertas_process_bss(struct bss_descriptor * bss,
1123 1107
1124 /* Timestamp */ 1108 /* Timestamp */
1125 bss->last_scanned = jiffies; 1109 bss->last_scanned = jiffies;
1110 libertas_unset_basic_rate_flags(bss->rates, sizeof(bss->rates));
1126 1111
1127 ret = 0; 1112 ret = 0;
1128 1113
@@ -1530,12 +1515,9 @@ static inline char *libertas_translate_scan(wlan_private *priv,
1530 iwe.u.bitrate.disabled = 0; 1515 iwe.u.bitrate.disabled = 0;
1531 iwe.u.bitrate.value = 0; 1516 iwe.u.bitrate.value = 0;
1532 1517
1533 for (j = 0; j < sizeof(bss->libertas_supported_rates); j++) { 1518 for (j = 0; bss->rates[j] && (j < sizeof(bss->rates)); j++) {
1534 u8 rate = bss->libertas_supported_rates[j]; 1519 /* Bit rate given in 500 kb/s units */
1535 if (rate == 0) 1520 iwe.u.bitrate.value = bss->rates[j] * 500000;
1536 break; /* no more rates */
1537 /* Bit rate given in 500 kb/s units (+ 0x80) */
1538 iwe.u.bitrate.value = (rate & 0x7f) * 500000;
1539 current_val = iwe_stream_add_value(start, current_val, 1521 current_val = iwe_stream_add_value(start, current_val,
1540 stop, &iwe, IW_EV_PARAM_LEN); 1522 stop, &iwe, IW_EV_PARAM_LEN);
1541 } 1523 }