2007-02-10 14:25:27 +00:00
|
|
|
/**
|
|
|
|
* Functions implementing wlan scan IOCTL and firmware command APIs
|
|
|
|
*
|
|
|
|
* IOCTL handlers as well as command preperation and response routines
|
|
|
|
* for sending scan commands to the firmware.
|
|
|
|
*/
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2008-09-24 22:13:14 +00:00
|
|
|
#include <linux/types.h>
|
2009-07-28 07:59:47 +00:00
|
|
|
#include <linux/kernel.h>
|
2007-05-25 20:15:56 +00:00
|
|
|
#include <linux/etherdevice.h>
|
2008-10-30 21:09:54 +00:00
|
|
|
#include <linux/if_arp.h>
|
2007-09-07 01:45:36 +00:00
|
|
|
#include <asm/unaligned.h>
|
2008-09-24 22:13:14 +00:00
|
|
|
#include <net/lib80211.h>
|
|
|
|
|
2007-02-10 14:25:27 +00:00
|
|
|
#include "host.h"
|
|
|
|
#include "dev.h"
|
|
|
|
#include "scan.h"
|
2009-10-22 13:30:48 +00:00
|
|
|
#include "assoc.h"
|
2009-10-22 13:30:58 +00:00
|
|
|
#include "wext.h"
|
2008-03-03 11:18:03 +00:00
|
|
|
#include "cmd.h"
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
//! Approximate amount of data needed to pass a scan result back to iwlist
|
|
|
|
#define MAX_SCAN_CELL_SIZE (IW_EV_ADDR_LEN \
|
2009-10-22 13:30:47 +00:00
|
|
|
+ IEEE80211_MAX_SSID_LEN \
|
2007-02-10 14:25:27 +00:00
|
|
|
+ IW_EV_UINT_LEN \
|
|
|
|
+ IW_EV_FREQ_LEN \
|
|
|
|
+ IW_EV_QUAL_LEN \
|
2009-10-22 13:30:47 +00:00
|
|
|
+ IEEE80211_MAX_SSID_LEN \
|
2007-02-10 14:25:27 +00:00
|
|
|
+ IW_EV_PARAM_LEN \
|
|
|
|
+ 40) /* 40 for WPAIE */
|
|
|
|
|
|
|
|
//! Memory needed to store a max sized channel List TLV for a firmware scan
|
2009-05-23 00:03:09 +00:00
|
|
|
#define CHAN_TLV_MAX_SIZE (sizeof(struct mrvl_ie_header) \
|
2007-02-10 14:25:27 +00:00
|
|
|
+ (MRVDRV_MAX_CHANNELS_PER_SCAN \
|
|
|
|
* sizeof(struct chanscanparamset)))
|
|
|
|
|
|
|
|
//! Memory needed to store a max number/size SSID TLV for a firmware scan
|
2009-05-23 00:03:09 +00:00
|
|
|
#define SSID_TLV_MAX_SIZE (1 * sizeof(struct mrvl_ie_ssid_param_set))
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-03 11:18:03 +00:00
|
|
|
//! Maximum memory needed for a cmd_ds_802_11_scan with all TLVs at max
|
|
|
|
#define MAX_SCAN_CFG_ALLOC (sizeof(struct cmd_ds_802_11_scan) \
|
|
|
|
+ CHAN_TLV_MAX_SIZE + SSID_TLV_MAX_SIZE)
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
//! The maximum number of channels the firmware can scan per command
|
|
|
|
#define MRVDRV_MAX_CHANNELS_PER_SCAN 14
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Number of channels to scan per firmware scan command issuance.
|
|
|
|
*
|
|
|
|
* Number restricted to prevent hitting the limit on the amount of scan data
|
|
|
|
* returned in a single firmware scan command.
|
|
|
|
*/
|
|
|
|
#define MRVDRV_CHANNELS_PER_SCAN_CMD 4
|
|
|
|
|
|
|
|
//! Scan time specified in the channel TLV for each channel for passive scans
|
|
|
|
#define MRVDRV_PASSIVE_SCAN_CHAN_TIME 100
|
|
|
|
|
|
|
|
//! Scan time specified in the channel TLV for each channel for active scans
|
|
|
|
#define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
|
|
|
|
|
2008-03-03 11:18:03 +00:00
|
|
|
static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
|
|
|
|
struct cmd_header *resp);
|
2007-10-09 12:15:19 +00:00
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Misc helper functions */
|
|
|
|
/* */
|
|
|
|
/*********************************************************************/
|
|
|
|
|
2008-01-28 16:27:03 +00:00
|
|
|
/**
|
|
|
|
* @brief Unsets the MSB on basic rates
|
|
|
|
*
|
|
|
|
* Scan through an array and unset the MSB for basic data rates.
|
|
|
|
*
|
|
|
|
* @param rates buffer of data rates
|
|
|
|
* @param len size of buffer
|
|
|
|
*/
|
|
|
|
static void lbs_unset_basic_rate_flags(u8 *rates, size_t len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
rates[i] &= 0x7f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-03 11:18:59 +00:00
|
|
|
static inline void clear_bss_descriptor(struct bss_descriptor *bss)
|
2007-05-25 20:15:56 +00:00
|
|
|
{
|
|
|
|
/* Don't blow away ->list, just BSS data */
|
|
|
|
memset(bss, 0, offsetof(struct bss_descriptor, list));
|
|
|
|
}
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/**
|
|
|
|
* @brief Compare two SSIDs
|
|
|
|
*
|
|
|
|
* @param ssid1 A pointer to ssid to compare
|
|
|
|
* @param ssid2 A pointer to ssid to compare
|
|
|
|
*
|
|
|
|
* @return 0: ssid is same, otherwise is different
|
|
|
|
*/
|
2008-03-03 11:18:59 +00:00
|
|
|
int lbs_ssid_cmp(uint8_t *ssid1, uint8_t ssid1_len, uint8_t *ssid2,
|
|
|
|
uint8_t ssid2_len)
|
2007-12-07 15:52:10 +00:00
|
|
|
{
|
|
|
|
if (ssid1_len != ssid2_len)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return memcmp(ssid1, ssid2, ssid1_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int is_same_network(struct bss_descriptor *src,
|
|
|
|
struct bss_descriptor *dst)
|
|
|
|
{
|
|
|
|
/* A network is only a duplicate if the channel, BSSID, and ESSID
|
|
|
|
* all match. We treat all <hidden> with the same BSSID and channel
|
|
|
|
* as one network */
|
|
|
|
return ((src->ssid_len == dst->ssid_len) &&
|
|
|
|
(src->channel == dst->channel) &&
|
|
|
|
!compare_ether_addr(src->bssid, dst->bssid) &&
|
|
|
|
!memcmp(src->ssid, dst->ssid, src->ssid_len));
|
|
|
|
}
|
|
|
|
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
|
2009-10-22 13:30:48 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Region channel support */
|
|
|
|
/* */
|
|
|
|
/*********************************************************************/
|
|
|
|
|
|
|
|
#define LBS_TX_PWR_DEFAULT 20 /*100mW */
|
|
|
|
#define LBS_TX_PWR_US_DEFAULT 20 /*100mW */
|
|
|
|
#define LBS_TX_PWR_JP_DEFAULT 16 /*50mW */
|
|
|
|
#define LBS_TX_PWR_FR_DEFAULT 20 /*100mW */
|
|
|
|
#define LBS_TX_PWR_EMEA_DEFAULT 20 /*100mW */
|
|
|
|
|
|
|
|
/* Format { channel, frequency (MHz), maxtxpower } */
|
|
|
|
/* band: 'B/G', region: USA FCC/Canada IC */
|
|
|
|
static struct chan_freq_power channel_freq_power_US_BG[] = {
|
|
|
|
{1, 2412, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{2, 2417, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{3, 2422, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{4, 2427, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{5, 2432, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{6, 2437, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{7, 2442, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{8, 2447, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{9, 2452, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{10, 2457, LBS_TX_PWR_US_DEFAULT},
|
|
|
|
{11, 2462, LBS_TX_PWR_US_DEFAULT}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* band: 'B/G', region: Europe ETSI */
|
|
|
|
static struct chan_freq_power channel_freq_power_EU_BG[] = {
|
|
|
|
{1, 2412, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{2, 2417, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{3, 2422, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{4, 2427, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{5, 2432, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{6, 2437, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{7, 2442, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{8, 2447, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{9, 2452, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{10, 2457, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{11, 2462, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{12, 2467, LBS_TX_PWR_EMEA_DEFAULT},
|
|
|
|
{13, 2472, LBS_TX_PWR_EMEA_DEFAULT}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* band: 'B/G', region: Spain */
|
|
|
|
static struct chan_freq_power channel_freq_power_SPN_BG[] = {
|
|
|
|
{10, 2457, LBS_TX_PWR_DEFAULT},
|
|
|
|
{11, 2462, LBS_TX_PWR_DEFAULT}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* band: 'B/G', region: France */
|
|
|
|
static struct chan_freq_power channel_freq_power_FR_BG[] = {
|
|
|
|
{10, 2457, LBS_TX_PWR_FR_DEFAULT},
|
|
|
|
{11, 2462, LBS_TX_PWR_FR_DEFAULT},
|
|
|
|
{12, 2467, LBS_TX_PWR_FR_DEFAULT},
|
|
|
|
{13, 2472, LBS_TX_PWR_FR_DEFAULT}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* band: 'B/G', region: Japan */
|
|
|
|
static struct chan_freq_power channel_freq_power_JPN_BG[] = {
|
|
|
|
{1, 2412, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{2, 2417, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{3, 2422, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{4, 2427, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{5, 2432, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{6, 2437, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{7, 2442, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{8, 2447, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{9, 2452, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{10, 2457, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{11, 2462, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{12, 2467, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{13, 2472, LBS_TX_PWR_JP_DEFAULT},
|
|
|
|
{14, 2484, LBS_TX_PWR_JP_DEFAULT}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the structure for channel, frequency and power
|
|
|
|
*/
|
|
|
|
struct region_cfp_table {
|
|
|
|
u8 region;
|
|
|
|
struct chan_freq_power *cfp_BG;
|
|
|
|
int cfp_no_BG;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the structure for the mapping between region and CFP
|
|
|
|
*/
|
|
|
|
static struct region_cfp_table region_cfp_table[] = {
|
|
|
|
{0x10, /*US FCC */
|
|
|
|
channel_freq_power_US_BG,
|
|
|
|
ARRAY_SIZE(channel_freq_power_US_BG),
|
|
|
|
}
|
|
|
|
,
|
|
|
|
{0x20, /*CANADA IC */
|
|
|
|
channel_freq_power_US_BG,
|
|
|
|
ARRAY_SIZE(channel_freq_power_US_BG),
|
|
|
|
}
|
|
|
|
,
|
|
|
|
{0x30, /*EU*/ channel_freq_power_EU_BG,
|
|
|
|
ARRAY_SIZE(channel_freq_power_EU_BG),
|
|
|
|
}
|
|
|
|
,
|
|
|
|
{0x31, /*SPAIN*/ channel_freq_power_SPN_BG,
|
|
|
|
ARRAY_SIZE(channel_freq_power_SPN_BG),
|
|
|
|
}
|
|
|
|
,
|
|
|
|
{0x32, /*FRANCE*/ channel_freq_power_FR_BG,
|
|
|
|
ARRAY_SIZE(channel_freq_power_FR_BG),
|
|
|
|
}
|
|
|
|
,
|
|
|
|
{0x40, /*JAPAN*/ channel_freq_power_JPN_BG,
|
|
|
|
ARRAY_SIZE(channel_freq_power_JPN_BG),
|
|
|
|
}
|
|
|
|
,
|
|
|
|
/*Add new region here */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function finds the CFP in
|
|
|
|
* region_cfp_table based on region and band parameter.
|
|
|
|
*
|
|
|
|
* @param region The region code
|
|
|
|
* @param band The band
|
|
|
|
* @param cfp_no A pointer to CFP number
|
|
|
|
* @return A pointer to CFP
|
|
|
|
*/
|
|
|
|
static struct chan_freq_power *lbs_get_region_cfp_table(u8 region, int *cfp_no)
|
|
|
|
{
|
|
|
|
int i, end;
|
|
|
|
|
|
|
|
lbs_deb_enter(LBS_DEB_MAIN);
|
|
|
|
|
|
|
|
end = ARRAY_SIZE(region_cfp_table);
|
|
|
|
|
|
|
|
for (i = 0; i < end ; i++) {
|
|
|
|
lbs_deb_main("region_cfp_table[i].region=%d\n",
|
|
|
|
region_cfp_table[i].region);
|
|
|
|
if (region_cfp_table[i].region == region) {
|
|
|
|
*cfp_no = region_cfp_table[i].cfp_no_BG;
|
|
|
|
lbs_deb_leave(LBS_DEB_MAIN);
|
|
|
|
return region_cfp_table[i].cfp_BG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lbs_deb_leave_args(LBS_DEB_MAIN, "ret NULL");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
struct chan_freq_power *cfp;
|
|
|
|
int cfp_no;
|
|
|
|
|
|
|
|
lbs_deb_enter(LBS_DEB_MAIN);
|
|
|
|
|
|
|
|
memset(priv->region_channel, 0, sizeof(priv->region_channel));
|
|
|
|
|
|
|
|
cfp = lbs_get_region_cfp_table(region, &cfp_no);
|
|
|
|
if (cfp != NULL) {
|
|
|
|
priv->region_channel[i].nrcfp = cfp_no;
|
|
|
|
priv->region_channel[i].CFP = cfp;
|
|
|
|
} else {
|
|
|
|
lbs_deb_main("wrong region code %#x in band B/G\n",
|
|
|
|
region);
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
priv->region_channel[i].valid = 1;
|
|
|
|
priv->region_channel[i].region = region;
|
|
|
|
priv->region_channel[i].band = band;
|
|
|
|
i++;
|
|
|
|
out:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Main scanning support */
|
|
|
|
/* */
|
|
|
|
/*********************************************************************/
|
|
|
|
|
2007-02-10 14:25:27 +00:00
|
|
|
/**
|
|
|
|
* @brief Create a channel list for the driver to scan based on region info
|
|
|
|
*
|
2007-11-15 23:05:47 +00:00
|
|
|
* Only used from lbs_scan_setup_scan_config()
|
2007-10-09 12:15:19 +00:00
|
|
|
*
|
2007-02-10 14:25:27 +00:00
|
|
|
* Use the driver region/band information to construct a comprehensive list
|
|
|
|
* of channels to scan. This routine is used for any scan that is not
|
|
|
|
* provided a specific channel list to scan.
|
|
|
|
*
|
2007-11-23 14:43:44 +00:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2007-02-10 14:25:27 +00:00
|
|
|
* @param scanchanlist Output parameter: resulting channel list to scan
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2007-12-07 15:52:10 +00:00
|
|
|
static int lbs_scan_create_channel_list(struct lbs_private *priv,
|
2008-03-05 06:05:32 +00:00
|
|
|
struct chanscanparamset *scanchanlist)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
|
|
|
struct region_channel *scanregion;
|
|
|
|
struct chan_freq_power *cfp;
|
|
|
|
int rgnidx;
|
|
|
|
int chanidx;
|
|
|
|
int nextchan;
|
2008-03-03 11:18:59 +00:00
|
|
|
uint8_t scantype;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
chanidx = 0;
|
|
|
|
|
|
|
|
/* Set the default scan type to the user specified type, will later
|
|
|
|
* be changed to passive on a per channel basis if restricted by
|
|
|
|
* regulatory requirements (11d or 11h)
|
|
|
|
*/
|
2007-08-02 17:12:27 +00:00
|
|
|
scantype = CMD_SCAN_TYPE_ACTIVE;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-08 20:04:36 +00:00
|
|
|
for (rgnidx = 0; rgnidx < ARRAY_SIZE(priv->region_channel); rgnidx++) {
|
2009-10-22 13:30:45 +00:00
|
|
|
if (!priv->region_channel[rgnidx].valid)
|
|
|
|
continue;
|
|
|
|
scanregion = &priv->region_channel[rgnidx];
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-03 11:18:59 +00:00
|
|
|
for (nextchan = 0; nextchan < scanregion->nrcfp; nextchan++, chanidx++) {
|
|
|
|
struct chanscanparamset *chan = &scanchanlist[chanidx];
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
cfp = scanregion->CFP + nextchan;
|
|
|
|
|
2008-03-03 11:18:59 +00:00
|
|
|
if (scanregion->band == BAND_B || scanregion->band == BAND_G)
|
|
|
|
chan->radiotype = CMD_SCAN_RADIO_TYPE_BG;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-08-02 15:31:18 +00:00
|
|
|
if (scantype == CMD_SCAN_TYPE_PASSIVE) {
|
2008-03-03 11:18:59 +00:00
|
|
|
chan->maxscantime = cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME);
|
|
|
|
chan->chanscanmode.passivescan = 1;
|
2007-02-10 14:25:27 +00:00
|
|
|
} else {
|
2008-03-03 11:18:59 +00:00
|
|
|
chan->maxscantime = cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME);
|
|
|
|
chan->chanscanmode.passivescan = 0;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2008-03-03 11:18:59 +00:00
|
|
|
chan->channumber = cfp->channel;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-07 15:52:10 +00:00
|
|
|
return chanidx;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/*
|
|
|
|
* Add SSID TLV of the form:
|
|
|
|
*
|
|
|
|
* TLV-ID SSID 00 00
|
|
|
|
* length 06 00
|
|
|
|
* ssid 4d 4e 54 45 53 54
|
|
|
|
*/
|
2008-03-05 06:05:32 +00:00
|
|
|
static int lbs_scan_add_ssid_tlv(struct lbs_private *priv, u8 *tlv)
|
2007-08-02 17:19:04 +00:00
|
|
|
{
|
2009-05-23 00:03:09 +00:00
|
|
|
struct mrvl_ie_ssid_param_set *ssid_tlv = (void *)tlv;
|
2008-03-03 11:18:59 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
ssid_tlv->header.type = cpu_to_le16(TLV_TYPE_SSID);
|
2008-03-05 06:05:32 +00:00
|
|
|
ssid_tlv->header.len = cpu_to_le16(priv->scan_ssid_len);
|
|
|
|
memcpy(ssid_tlv->ssid, priv->scan_ssid, priv->scan_ssid_len);
|
|
|
|
return sizeof(ssid_tlv->header) + priv->scan_ssid_len;
|
2007-08-02 17:19:04 +00:00
|
|
|
}
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/*
|
|
|
|
* Add CHANLIST TLV of the form
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
2007-12-07 15:52:10 +00:00
|
|
|
* TLV-ID CHANLIST 01 01
|
|
|
|
* length 5b 00
|
|
|
|
* channel 1 00 01 00 00 00 64 00
|
|
|
|
* radio type 00
|
|
|
|
* channel 01
|
|
|
|
* scan type 00
|
|
|
|
* min scan time 00 00
|
|
|
|
* max scan time 64 00
|
|
|
|
* channel 2 00 02 00 00 00 64 00
|
|
|
|
* channel 3 00 03 00 00 00 64 00
|
|
|
|
* channel 4 00 04 00 00 00 64 00
|
|
|
|
* channel 5 00 05 00 00 00 64 00
|
|
|
|
* channel 6 00 06 00 00 00 64 00
|
|
|
|
* channel 7 00 07 00 00 00 64 00
|
|
|
|
* channel 8 00 08 00 00 00 64 00
|
|
|
|
* channel 9 00 09 00 00 00 64 00
|
|
|
|
* channel 10 00 0a 00 00 00 64 00
|
|
|
|
* channel 11 00 0b 00 00 00 64 00
|
|
|
|
* channel 12 00 0c 00 00 00 64 00
|
|
|
|
* channel 13 00 0d 00 00 00 64 00
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
|
|
|
*/
|
2008-03-03 11:18:59 +00:00
|
|
|
static int lbs_scan_add_chanlist_tlv(uint8_t *tlv,
|
|
|
|
struct chanscanparamset *chan_list,
|
|
|
|
int chan_count)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
2008-03-03 11:18:59 +00:00
|
|
|
size_t size = sizeof(struct chanscanparamset) *chan_count;
|
2009-05-23 00:03:09 +00:00
|
|
|
struct mrvl_ie_chanlist_param_set *chan_tlv = (void *)tlv;
|
2007-12-07 15:52:10 +00:00
|
|
|
|
|
|
|
chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
|
|
|
|
memcpy(chan_tlv->chanscanparam, chan_list, size);
|
|
|
|
chan_tlv->header.len = cpu_to_le16(size);
|
|
|
|
return sizeof(chan_tlv->header) + size;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/*
|
|
|
|
* Add RATES TLV of the form
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
2007-12-07 15:52:10 +00:00
|
|
|
* TLV-ID RATES 01 00
|
|
|
|
* length 0e 00
|
|
|
|
* rates 82 84 8b 96 0c 12 18 24 30 48 60 6c
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
2007-12-07 15:52:10 +00:00
|
|
|
* The rates are in lbs_bg_rates[], but for the 802.11b
|
|
|
|
* rates the high bit isn't set.
|
2007-02-10 14:25:27 +00:00
|
|
|
*/
|
2008-03-03 11:18:59 +00:00
|
|
|
static int lbs_scan_add_rates_tlv(uint8_t *tlv)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
2007-12-07 15:52:10 +00:00
|
|
|
int i;
|
2009-05-23 00:03:09 +00:00
|
|
|
struct mrvl_ie_rates_param_set *rate_tlv = (void *)tlv;
|
2007-12-07 15:52:10 +00:00
|
|
|
|
|
|
|
rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES);
|
|
|
|
tlv += sizeof(rate_tlv->header);
|
|
|
|
for (i = 0; i < MAX_RATES; i++) {
|
|
|
|
*tlv = lbs_bg_rates[i];
|
|
|
|
if (*tlv == 0)
|
|
|
|
break;
|
|
|
|
/* This code makes sure that the 802.11b rates (1 MBit/s, 2
|
|
|
|
MBit/s, 5.5 MBit/s and 11 MBit/s get's the high bit set.
|
|
|
|
Note that the values are MBit/s * 2, to mark them as
|
|
|
|
basic rates so that the firmware likes it better */
|
|
|
|
if (*tlv == 0x02 || *tlv == 0x04 ||
|
|
|
|
*tlv == 0x0b || *tlv == 0x16)
|
|
|
|
*tlv |= 0x80;
|
|
|
|
tlv++;
|
2007-08-02 17:19:04 +00:00
|
|
|
}
|
2007-12-07 15:52:10 +00:00
|
|
|
rate_tlv->header.len = cpu_to_le16(i);
|
|
|
|
return sizeof(rate_tlv->header) + i;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
/*
|
2007-12-07 15:52:10 +00:00
|
|
|
* Generate the CMD_802_11_SCAN command with the proper tlv
|
|
|
|
* for a bunch of channels.
|
|
|
|
*/
|
2008-03-03 11:18:03 +00:00
|
|
|
static int lbs_do_scan(struct lbs_private *priv, uint8_t bsstype,
|
2008-03-05 06:05:32 +00:00
|
|
|
struct chanscanparamset *chan_list, int chan_count)
|
2007-05-25 20:25:21 +00:00
|
|
|
{
|
2007-12-07 15:52:10 +00:00
|
|
|
int ret = -ENOMEM;
|
2008-03-03 11:18:03 +00:00
|
|
|
struct cmd_ds_802_11_scan *scan_cmd;
|
|
|
|
uint8_t *tlv; /* pointer into our current, growing TLV storage area */
|
2007-05-25 20:25:21 +00:00
|
|
|
|
2008-03-03 11:18:03 +00:00
|
|
|
lbs_deb_enter_args(LBS_DEB_SCAN, "bsstype %d, chanlist[].chan %d, chan_count %d",
|
2008-04-29 08:07:56 +00:00
|
|
|
bsstype, chan_list ? chan_list[0].channumber : -1,
|
|
|
|
chan_count);
|
2007-10-09 12:15:19 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/* create the fixed part for scan command */
|
|
|
|
scan_cmd = kzalloc(MAX_SCAN_CFG_ALLOC, GFP_KERNEL);
|
|
|
|
if (scan_cmd == NULL)
|
2007-10-09 12:15:19 +00:00
|
|
|
goto out;
|
2008-03-03 11:18:03 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
tlv = scan_cmd->tlvbuffer;
|
2008-03-05 06:05:32 +00:00
|
|
|
/* TODO: do we need to scan for a specific BSSID?
|
|
|
|
memcpy(scan_cmd->bssid, priv->scan_bssid, ETH_ALEN); */
|
2007-12-07 15:52:10 +00:00
|
|
|
scan_cmd->bsstype = bsstype;
|
|
|
|
|
|
|
|
/* add TLVs */
|
2008-03-05 06:05:32 +00:00
|
|
|
if (priv->scan_ssid_len)
|
|
|
|
tlv += lbs_scan_add_ssid_tlv(priv, tlv);
|
2007-12-07 15:52:10 +00:00
|
|
|
if (chan_list && chan_count)
|
|
|
|
tlv += lbs_scan_add_chanlist_tlv(tlv, chan_list, chan_count);
|
|
|
|
tlv += lbs_scan_add_rates_tlv(tlv);
|
|
|
|
|
|
|
|
/* This is the final data we are about to send */
|
2008-03-03 11:18:03 +00:00
|
|
|
scan_cmd->hdr.size = cpu_to_le16(tlv - (uint8_t *)scan_cmd);
|
|
|
|
lbs_deb_hex(LBS_DEB_SCAN, "SCAN_CMD", (void *)scan_cmd,
|
|
|
|
sizeof(*scan_cmd));
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_hex(LBS_DEB_SCAN, "SCAN_TLV", scan_cmd->tlvbuffer,
|
2008-03-03 11:18:03 +00:00
|
|
|
tlv - scan_cmd->tlvbuffer);
|
|
|
|
|
|
|
|
ret = __lbs_cmd(priv, CMD_802_11_SCAN, &scan_cmd->hdr,
|
|
|
|
le16_to_cpu(scan_cmd->hdr.size),
|
|
|
|
lbs_ret_80211_scan, 0);
|
2007-12-07 15:52:10 +00:00
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
out:
|
2007-12-07 15:52:10 +00:00
|
|
|
kfree(scan_cmd);
|
|
|
|
lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
|
|
|
|
return ret;
|
2007-05-25 20:25:21 +00:00
|
|
|
}
|
|
|
|
|
2007-02-10 14:25:27 +00:00
|
|
|
/**
|
|
|
|
* @brief Internal function used to start a scan based on an input config
|
|
|
|
*
|
|
|
|
* Use the input user scan configuration information when provided in
|
|
|
|
* order to send the appropriate scan commands to firmware to populate or
|
|
|
|
* update the internal driver scan table
|
|
|
|
*
|
2007-11-23 14:43:44 +00:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2008-03-05 06:05:32 +00:00
|
|
|
* @param full_scan Do a full-scan (blocking)
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
|
|
|
* @return 0 or < 0 if error
|
|
|
|
*/
|
2008-04-02 14:27:42 +00:00
|
|
|
int lbs_scan_networks(struct lbs_private *priv, int full_scan)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
2007-12-07 15:52:10 +00:00
|
|
|
int ret = -ENOMEM;
|
|
|
|
struct chanscanparamset *chan_list;
|
|
|
|
struct chanscanparamset *curr_chans;
|
|
|
|
int chan_count;
|
2008-03-03 11:18:59 +00:00
|
|
|
uint8_t bsstype = CMD_BSS_TYPE_ANY;
|
2007-12-07 15:52:10 +00:00
|
|
|
int numchannels = MRVDRV_CHANNELS_PER_SCAN_CMD;
|
|
|
|
union iwreq_data wrqu;
|
2007-05-30 14:12:55 +00:00
|
|
|
#ifdef CONFIG_LIBERTAS_DEBUG
|
2007-12-07 15:52:10 +00:00
|
|
|
struct bss_descriptor *iter;
|
2007-05-30 14:12:55 +00:00
|
|
|
int i = 0;
|
2008-10-01 00:59:05 +00:00
|
|
|
DECLARE_SSID_BUF(ssid);
|
2007-05-30 14:12:55 +00:00
|
|
|
#endif
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-03 11:18:59 +00:00
|
|
|
lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan);
|
2007-08-02 17:19:04 +00:00
|
|
|
|
|
|
|
/* Cancel any partial outstanding partial scans if this scan
|
|
|
|
* is a full scan.
|
|
|
|
*/
|
|
|
|
if (full_scan && delayed_work_pending(&priv->scan_work))
|
|
|
|
cancel_delayed_work(&priv->scan_work);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
/* User-specified bsstype or channel list
|
|
|
|
TODO: this can be implemented if some user-space application
|
|
|
|
need the feature. Formerly, it was accessible from debugfs,
|
|
|
|
but then nowhere used.
|
2007-12-07 15:52:10 +00:00
|
|
|
if (user_cfg) {
|
|
|
|
if (user_cfg->bsstype)
|
2008-03-05 06:05:32 +00:00
|
|
|
bsstype = user_cfg->bsstype;
|
|
|
|
} */
|
|
|
|
|
|
|
|
lbs_deb_scan("numchannels %d, bsstype %d\n", numchannels, bsstype);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/* Create list of channels to scan */
|
|
|
|
chan_list = kzalloc(sizeof(struct chanscanparamset) *
|
2008-03-03 11:18:59 +00:00
|
|
|
LBS_IOCTL_USER_SCAN_CHAN_MAX, GFP_KERNEL);
|
2007-12-07 15:52:10 +00:00
|
|
|
if (!chan_list) {
|
|
|
|
lbs_pr_alert("SCAN: chan_list empty\n");
|
2007-02-10 14:25:27 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/* We want to scan all channels */
|
2008-03-05 06:05:32 +00:00
|
|
|
chan_count = lbs_scan_create_channel_list(priv, chan_list);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
netif_stop_queue(priv->dev);
|
2009-12-18 10:36:49 +00:00
|
|
|
if (priv->mesh_dev)
|
2007-12-12 05:41:51 +00:00
|
|
|
netif_stop_queue(priv->mesh_dev);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/* Prepare to continue an interrupted scan */
|
2008-01-28 16:28:05 +00:00
|
|
|
lbs_deb_scan("chan_count %d, scan_channel %d\n",
|
|
|
|
chan_count, priv->scan_channel);
|
2007-12-07 15:52:10 +00:00
|
|
|
curr_chans = chan_list;
|
|
|
|
/* advance channel list by already-scanned-channels */
|
2008-01-28 16:28:05 +00:00
|
|
|
if (priv->scan_channel > 0) {
|
|
|
|
curr_chans += priv->scan_channel;
|
|
|
|
chan_count -= priv->scan_channel;
|
2007-12-07 15:52:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Send scan command(s)
|
|
|
|
* numchannels contains the number of channels we should maximally scan
|
|
|
|
* chan_count is the total number of channels to scan
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (chan_count) {
|
|
|
|
int to_scan = min(numchannels, chan_count);
|
|
|
|
lbs_deb_scan("scanning %d of %d channels\n",
|
2008-03-03 11:18:59 +00:00
|
|
|
to_scan, chan_count);
|
2007-12-07 15:52:10 +00:00
|
|
|
ret = lbs_do_scan(priv, bsstype, curr_chans,
|
2008-03-05 06:05:32 +00:00
|
|
|
to_scan);
|
2007-12-07 15:52:10 +00:00
|
|
|
if (ret) {
|
|
|
|
lbs_pr_err("SCAN_CMD failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
curr_chans += to_scan;
|
|
|
|
chan_count -= to_scan;
|
|
|
|
|
|
|
|
/* somehow schedule the next part of the scan */
|
2008-03-03 11:18:59 +00:00
|
|
|
if (chan_count && !full_scan &&
|
2007-12-08 20:04:36 +00:00
|
|
|
!priv->surpriseremoved) {
|
2007-12-07 15:52:10 +00:00
|
|
|
/* -1 marks just that we're currently scanning */
|
2008-01-28 16:28:05 +00:00
|
|
|
if (priv->scan_channel < 0)
|
|
|
|
priv->scan_channel = to_scan;
|
2007-12-07 15:52:10 +00:00
|
|
|
else
|
2008-01-28 16:28:05 +00:00
|
|
|
priv->scan_channel += to_scan;
|
2007-12-07 15:52:10 +00:00
|
|
|
cancel_delayed_work(&priv->scan_work);
|
|
|
|
queue_delayed_work(priv->work_thread, &priv->scan_work,
|
2008-03-03 11:18:59 +00:00
|
|
|
msecs_to_jiffies(300));
|
2007-12-07 15:52:10 +00:00
|
|
|
/* skip over GIWSCAN event */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
memset(&wrqu, 0, sizeof(union iwreq_data));
|
|
|
|
wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-30 14:12:55 +00:00
|
|
|
#ifdef CONFIG_LIBERTAS_DEBUG
|
|
|
|
/* Dump the scan table */
|
2007-12-08 20:04:36 +00:00
|
|
|
mutex_lock(&priv->lock);
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("scan table:\n");
|
2007-12-08 20:04:36 +00:00
|
|
|
list_for_each_entry(iter, &priv->network_list, list)
|
2008-10-27 22:59:26 +00:00
|
|
|
lbs_deb_scan("%02d: BSSID %pM, RSSI %d, SSID '%s'\n",
|
|
|
|
i++, iter->bssid, iter->rssi,
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, iter->ssid, iter->ssid_len));
|
2007-12-08 20:04:36 +00:00
|
|
|
mutex_unlock(&priv->lock);
|
2007-05-30 14:12:55 +00:00
|
|
|
#endif
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
out2:
|
2008-01-28 16:28:05 +00:00
|
|
|
priv->scan_channel = 0;
|
2007-12-07 15:52:10 +00:00
|
|
|
|
|
|
|
out:
|
2009-12-18 10:36:49 +00:00
|
|
|
if (priv->connect_status == LBS_CONNECTED && !priv->tx_pending_len)
|
|
|
|
netif_wake_queue(priv->dev);
|
|
|
|
|
2009-12-30 20:25:08 +00:00
|
|
|
if (priv->mesh_dev && lbs_mesh_connected(priv) &&
|
2009-12-18 10:36:49 +00:00
|
|
|
!priv->tx_pending_len)
|
|
|
|
netif_wake_queue(priv->mesh_dev);
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
kfree(chan_list);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 15:27:16 +00:00
|
|
|
lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
|
2007-02-10 14:25:27 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
void lbs_scan_worker(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct lbs_private *priv =
|
|
|
|
container_of(work, struct lbs_private, scan_work.work);
|
|
|
|
|
|
|
|
lbs_deb_enter(LBS_DEB_SCAN);
|
|
|
|
lbs_scan_networks(priv, 0);
|
|
|
|
lbs_deb_leave(LBS_DEB_SCAN);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Result interpretation */
|
|
|
|
/* */
|
|
|
|
/*********************************************************************/
|
|
|
|
|
2007-02-10 14:25:27 +00:00
|
|
|
/**
|
|
|
|
* @brief Interpret a BSS scan response returned from the firmware
|
|
|
|
*
|
|
|
|
* Parse the various fixed fields and IEs passed back for a a BSS probe
|
2007-12-07 15:52:10 +00:00
|
|
|
* response or beacon from the scan command. Record information as needed
|
|
|
|
* in the scan table struct bss_descriptor for that entry.
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
2007-05-25 20:15:56 +00:00
|
|
|
* @param bss Output parameter: Pointer to the BSS Entry
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
|
|
|
* @return 0 or -1
|
|
|
|
*/
|
2007-11-15 23:05:47 +00:00
|
|
|
static int lbs_process_bss(struct bss_descriptor *bss,
|
2008-03-03 11:18:59 +00:00
|
|
|
uint8_t **pbeaconinfo, int *bytesleft)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
2009-05-23 00:01:21 +00:00
|
|
|
struct ieee_ie_fh_param_set *fh;
|
|
|
|
struct ieee_ie_ds_param_set *ds;
|
|
|
|
struct ieee_ie_cf_param_set *cf;
|
|
|
|
struct ieee_ie_ibss_param_set *ibss;
|
2008-10-01 00:59:05 +00:00
|
|
|
DECLARE_SSID_BUF(ssid);
|
2008-03-03 11:18:59 +00:00
|
|
|
uint8_t *pos, *end, *p;
|
|
|
|
uint8_t n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0;
|
|
|
|
uint16_t beaconsize = 0;
|
2007-08-02 15:40:45 +00:00
|
|
|
int ret;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
lbs_deb_enter(LBS_DEB_SCAN);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
if (*bytesleft >= sizeof(beaconsize)) {
|
|
|
|
/* Extract & convert beacon size from the command buffer */
|
2008-04-29 08:03:36 +00:00
|
|
|
beaconsize = get_unaligned_le16(*pbeaconinfo);
|
2007-02-10 14:25:27 +00:00
|
|
|
*bytesleft -= sizeof(beaconsize);
|
|
|
|
*pbeaconinfo += sizeof(beaconsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (beaconsize == 0 || beaconsize > *bytesleft) {
|
|
|
|
*pbeaconinfo += *bytesleft;
|
|
|
|
*bytesleft = 0;
|
2007-10-09 12:15:19 +00:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the current working beacon pointer for this BSS iteration */
|
2007-08-02 14:48:02 +00:00
|
|
|
pos = *pbeaconinfo;
|
|
|
|
end = pos + beaconsize;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/* Advance the return beacon pointer past the current beacon */
|
|
|
|
*pbeaconinfo += beaconsize;
|
|
|
|
*bytesleft -= beaconsize;
|
|
|
|
|
2007-08-02 14:48:02 +00:00
|
|
|
memcpy(bss->bssid, pos, ETH_ALEN);
|
2008-10-27 22:59:26 +00:00
|
|
|
lbs_deb_scan("process_bss: BSSID %pM\n", bss->bssid);
|
2007-08-02 14:48:02 +00:00
|
|
|
pos += ETH_ALEN;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-08-02 14:48:02 +00:00
|
|
|
if ((end - pos) < 12) {
|
2007-05-25 20:15:56 +00:00
|
|
|
lbs_deb_scan("process_bss: Not enough bytes left\n");
|
2007-10-09 12:15:19 +00:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* next 4 fields are RSSI, time stamp, beacon interval,
|
|
|
|
* and capability information
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* RSSI is 1 byte long */
|
2007-08-02 14:48:02 +00:00
|
|
|
bss->rssi = *pos;
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("process_bss: RSSI %d\n", *pos);
|
2007-08-02 14:48:02 +00:00
|
|
|
pos++;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/* time stamp is 8 bytes long */
|
2007-08-02 14:48:02 +00:00
|
|
|
pos += 8;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/* beacon interval is 2 bytes long */
|
2008-07-09 06:29:58 +00:00
|
|
|
bss->beaconperiod = get_unaligned_le16(pos);
|
2007-08-02 14:48:02 +00:00
|
|
|
pos += 2;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/* capability information is 2 bytes long */
|
2008-07-09 06:29:58 +00:00
|
|
|
bss->capability = get_unaligned_le16(pos);
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("process_bss: capabilities 0x%04x\n", bss->capability);
|
2007-08-02 14:48:02 +00:00
|
|
|
pos += 2;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-08-02 14:43:44 +00:00
|
|
|
if (bss->capability & WLAN_CAPABILITY_PRIVACY)
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("process_bss: WEP enabled\n");
|
2007-08-02 14:43:44 +00:00
|
|
|
if (bss->capability & WLAN_CAPABILITY_IBSS)
|
|
|
|
bss->mode = IW_MODE_ADHOC;
|
|
|
|
else
|
|
|
|
bss->mode = IW_MODE_INFRA;
|
|
|
|
|
2007-02-10 14:25:27 +00:00
|
|
|
/* rest of the current buffer are IE's */
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("process_bss: IE len %zd\n", end - pos);
|
2007-08-02 15:53:06 +00:00
|
|
|
lbs_deb_hex(LBS_DEB_SCAN, "process_bss: IE info", pos, end - pos);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/* process variable IE */
|
2007-08-02 14:48:02 +00:00
|
|
|
while (pos <= end - 2) {
|
2008-10-30 21:09:54 +00:00
|
|
|
if (pos + pos[1] > end) {
|
2007-05-25 20:15:56 +00:00
|
|
|
lbs_deb_scan("process_bss: error in processing IE, "
|
2008-03-03 11:18:59 +00:00
|
|
|
"bytes left < IE length\n");
|
2007-08-02 14:48:02 +00:00
|
|
|
break;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
switch (pos[0]) {
|
|
|
|
case WLAN_EID_SSID:
|
|
|
|
bss->ssid_len = min_t(int, IEEE80211_MAX_SSID_LEN, pos[1]);
|
|
|
|
memcpy(bss->ssid, pos + 2, bss->ssid_len);
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got SSID IE: '%s', len %u\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, bss->ssid, bss->ssid_len),
|
2007-05-29 03:54:55 +00:00
|
|
|
bss->ssid_len);
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_SUPP_RATES:
|
|
|
|
n_basic_rates = min_t(uint8_t, MAX_RATES, pos[1]);
|
|
|
|
memcpy(bss->rates, pos + 2, n_basic_rates);
|
2007-08-02 15:40:45 +00:00
|
|
|
got_basic_rates = 1;
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got RATES IE\n");
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_FH_PARAMS:
|
2009-05-23 00:01:21 +00:00
|
|
|
fh = (struct ieee_ie_fh_param_set *) pos;
|
|
|
|
memcpy(&bss->phy.fh, fh, sizeof(*fh));
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got FH IE\n");
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_DS_PARAMS:
|
2009-05-23 00:01:21 +00:00
|
|
|
ds = (struct ieee_ie_ds_param_set *) pos;
|
|
|
|
bss->channel = ds->channel;
|
|
|
|
memcpy(&bss->phy.ds, ds, sizeof(*ds));
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got DS IE, channel %d\n", bss->channel);
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_CF_PARAMS:
|
2009-05-23 00:01:21 +00:00
|
|
|
cf = (struct ieee_ie_cf_param_set *) pos;
|
|
|
|
memcpy(&bss->ss.cf, cf, sizeof(*cf));
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got CF IE\n");
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_IBSS_PARAMS:
|
2009-05-23 00:01:21 +00:00
|
|
|
ibss = (struct ieee_ie_ibss_param_set *) pos;
|
|
|
|
bss->atimwindow = ibss->atimwindow;
|
|
|
|
memcpy(&bss->ss.ibss, ibss, sizeof(*ibss));
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got IBSS IE\n");
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_EXT_SUPP_RATES:
|
2007-08-02 14:48:02 +00:00
|
|
|
/* only process extended supported rate if data rate is
|
|
|
|
* already found. Data rate IE should come before
|
2007-02-10 14:25:27 +00:00
|
|
|
* extended supported rate IE
|
|
|
|
*/
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got RATESEX IE\n");
|
|
|
|
if (!got_basic_rates) {
|
|
|
|
lbs_deb_scan("... but ignoring it\n");
|
2007-08-02 14:48:02 +00:00
|
|
|
break;
|
2007-12-07 15:52:10 +00:00
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
n_ex_rates = pos[1];
|
2007-08-02 15:40:45 +00:00
|
|
|
if (n_basic_rates + n_ex_rates > MAX_RATES)
|
|
|
|
n_ex_rates = MAX_RATES - n_basic_rates;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-08-02 15:40:45 +00:00
|
|
|
p = bss->rates + n_basic_rates;
|
2008-10-30 21:09:54 +00:00
|
|
|
memcpy(p, pos + 2, n_ex_rates);
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
2007-08-02 14:48:02 +00:00
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_GENERIC:
|
|
|
|
if (pos[1] >= 4 &&
|
|
|
|
pos[2] == 0x00 && pos[3] == 0x50 &&
|
|
|
|
pos[4] == 0xf2 && pos[5] == 0x01) {
|
|
|
|
bss->wpa_ie_len = min(pos[1] + 2, MAX_WPA_IE_LEN);
|
|
|
|
memcpy(bss->wpa_ie, pos, bss->wpa_ie_len);
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got WPA IE\n");
|
2008-10-30 21:09:54 +00:00
|
|
|
lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie,
|
|
|
|
bss->wpa_ie_len);
|
|
|
|
} else if (pos[1] >= MARVELL_MESH_IE_LENGTH &&
|
|
|
|
pos[2] == 0x00 && pos[3] == 0x50 &&
|
2009-02-03 16:15:57 +00:00
|
|
|
pos[4] == 0x43 && pos[5] == 0x04) {
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got mesh IE\n");
|
2007-08-02 14:51:27 +00:00
|
|
|
bss->mesh = 1;
|
2007-12-07 15:52:10 +00:00
|
|
|
} else {
|
2008-03-03 11:18:59 +00:00
|
|
|
lbs_deb_scan("got generic IE: %02x:%02x:%02x:%02x, len %d\n",
|
2008-10-30 21:09:54 +00:00
|
|
|
pos[2], pos[3],
|
|
|
|
pos[4], pos[5],
|
|
|
|
pos[1]);
|
2007-08-02 14:48:02 +00:00
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
2007-08-02 14:48:02 +00:00
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
case WLAN_EID_RSN:
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got RSN IE\n");
|
2008-10-30 21:09:54 +00:00
|
|
|
bss->rsn_ie_len = min(pos[1] + 2, MAX_WPA_IE_LEN);
|
|
|
|
memcpy(bss->rsn_ie, pos, bss->rsn_ie_len);
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_hex(LBS_DEB_SCAN, "process_bss: RSN_IE",
|
2008-10-30 21:09:54 +00:00
|
|
|
bss->rsn_ie, bss->rsn_ie_len);
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-02 14:48:02 +00:00
|
|
|
default:
|
2007-12-07 15:52:10 +00:00
|
|
|
lbs_deb_scan("got IE 0x%04x, len %d\n",
|
2008-10-30 21:09:54 +00:00
|
|
|
pos[0], pos[1]);
|
2007-02-10 14:25:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-10-30 21:09:54 +00:00
|
|
|
pos += pos[1] + 2;
|
2007-08-02 14:48:02 +00:00
|
|
|
}
|
2007-05-25 20:15:56 +00:00
|
|
|
|
|
|
|
/* Timestamp */
|
|
|
|
bss->last_scanned = jiffies;
|
2007-11-15 23:05:47 +00:00
|
|
|
lbs_unset_basic_rate_flags(bss->rates, sizeof(bss->rates));
|
2007-05-25 20:15:56 +00:00
|
|
|
|
2007-05-25 15:27:16 +00:00
|
|
|
ret = 0;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 15:27:16 +00:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
|
|
|
|
return ret;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Send a scan command for all available channels filtered on a spec
|
|
|
|
*
|
2007-10-09 12:15:19 +00:00
|
|
|
* Used in association code and from debugfs
|
|
|
|
*
|
2007-11-23 14:43:44 +00:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2007-10-09 12:15:19 +00:00
|
|
|
* @param ssid A pointer to the SSID to scan for
|
|
|
|
* @param ssid_len Length of the SSID
|
2007-02-10 14:25:27 +00:00
|
|
|
*
|
|
|
|
* @return 0-success, otherwise fail
|
|
|
|
*/
|
2008-03-03 11:18:59 +00:00
|
|
|
int lbs_send_specific_ssid_scan(struct lbs_private *priv, uint8_t *ssid,
|
2008-03-05 06:05:32 +00:00
|
|
|
uint8_t ssid_len)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
2008-10-01 00:59:05 +00:00
|
|
|
DECLARE_SSID_BUF(ssid_buf);
|
2007-05-25 20:25:21 +00:00
|
|
|
int ret = 0;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s'\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid_buf, ssid, ssid_len));
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-29 03:54:55 +00:00
|
|
|
if (!ssid_len)
|
2007-05-25 20:25:21 +00:00
|
|
|
goto out;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
memcpy(priv->scan_ssid, ssid, ssid_len);
|
|
|
|
priv->scan_ssid_len = ssid_len;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
lbs_scan_networks(priv, 1);
|
2007-12-08 20:04:36 +00:00
|
|
|
if (priv->surpriseremoved) {
|
2007-10-09 12:15:19 +00:00
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:25:21 +00:00
|
|
|
out:
|
2007-10-09 12:15:19 +00:00
|
|
|
lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
|
2007-05-25 20:25:21 +00:00
|
|
|
return ret;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Support for Wireless Extensions */
|
|
|
|
/* */
|
|
|
|
/*********************************************************************/
|
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
|
2007-08-02 17:14:56 +00:00
|
|
|
#define MAX_CUSTOM_LEN 64
|
|
|
|
|
2007-11-23 14:43:44 +00:00
|
|
|
static inline char *lbs_translate_scan(struct lbs_private *priv,
|
2008-06-17 01:50:49 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
char *start, char *stop,
|
|
|
|
struct bss_descriptor *bss)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
|
|
|
struct chan_freq_power *cfp;
|
|
|
|
char *current_val; /* For rates */
|
|
|
|
struct iw_event iwe; /* Temporary buffer */
|
|
|
|
int j;
|
2008-03-03 11:18:59 +00:00
|
|
|
#define PERFECT_RSSI ((uint8_t)50)
|
|
|
|
#define WORST_RSSI ((uint8_t)0)
|
|
|
|
#define RSSI_DIFF ((uint8_t)(PERFECT_RSSI - WORST_RSSI))
|
|
|
|
uint8_t rssi;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
lbs_deb_enter(LBS_DEB_SCAN);
|
|
|
|
|
2007-12-08 20:04:36 +00:00
|
|
|
cfp = lbs_find_cfp_by_band_and_channel(priv, 0, bss->channel);
|
2007-05-25 20:15:56 +00:00
|
|
|
if (!cfp) {
|
|
|
|
lbs_deb_scan("Invalid channel number %d\n", bss->channel);
|
2007-10-09 12:15:19 +00:00
|
|
|
start = NULL;
|
|
|
|
goto out;
|
2007-05-25 04:33:28 +00:00
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/* First entry *MUST* be the BSSID */
|
2007-05-25 20:15:56 +00:00
|
|
|
iwe.cmd = SIOCGIWAP;
|
|
|
|
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
|
|
|
|
memcpy(iwe.u.ap_addr.sa_data, &bss->bssid, ETH_ALEN);
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
|
2007-05-25 20:15:56 +00:00
|
|
|
|
|
|
|
/* SSID */
|
|
|
|
iwe.cmd = SIOCGIWESSID;
|
|
|
|
iwe.u.data.flags = 1;
|
2009-10-22 13:30:47 +00:00
|
|
|
iwe.u.data.length = min((uint32_t) bss->ssid_len, (uint32_t) IEEE80211_MAX_SSID_LEN);
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, bss->ssid);
|
2007-05-25 20:15:56 +00:00
|
|
|
|
|
|
|
/* Mode */
|
|
|
|
iwe.cmd = SIOCGIWMODE;
|
|
|
|
iwe.u.mode = bss->mode;
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN);
|
2007-05-25 20:15:56 +00:00
|
|
|
|
|
|
|
/* Frequency */
|
|
|
|
iwe.cmd = SIOCGIWFREQ;
|
|
|
|
iwe.u.freq.m = (long)cfp->freq * 100000;
|
|
|
|
iwe.u.freq.e = 1;
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN);
|
2007-05-25 20:15:56 +00:00
|
|
|
|
|
|
|
/* Add quality statistics */
|
|
|
|
iwe.cmd = IWEVQUAL;
|
|
|
|
iwe.u.qual.updated = IW_QUAL_ALL_UPDATED;
|
|
|
|
iwe.u.qual.level = SCAN_RSSI(bss->rssi);
|
|
|
|
|
|
|
|
rssi = iwe.u.qual.level - MRVDRV_NF_DEFAULT_SCAN_VALUE;
|
|
|
|
iwe.u.qual.qual =
|
2008-03-03 11:18:59 +00:00
|
|
|
(100 * RSSI_DIFF * RSSI_DIFF - (PERFECT_RSSI - rssi) *
|
|
|
|
(15 * (RSSI_DIFF) + 62 * (PERFECT_RSSI - rssi))) /
|
|
|
|
(RSSI_DIFF * RSSI_DIFF);
|
2007-05-25 20:15:56 +00:00
|
|
|
if (iwe.u.qual.qual > 100)
|
|
|
|
iwe.u.qual.qual = 100;
|
|
|
|
|
2007-12-08 20:04:36 +00:00
|
|
|
if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
|
2007-05-25 20:15:56 +00:00
|
|
|
iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
|
|
|
|
} else {
|
2008-03-03 11:18:59 +00:00
|
|
|
iwe.u.qual.noise = CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
|
2007-05-25 20:15:56 +00:00
|
|
|
}
|
2007-05-26 02:18:47 +00:00
|
|
|
|
|
|
|
/* Locally created ad-hoc BSSs won't have beacons if this is the
|
|
|
|
* only station in the adhoc network; so get signal strength
|
|
|
|
* from receive statistics.
|
|
|
|
*/
|
2008-03-03 11:18:59 +00:00
|
|
|
if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate
|
2007-12-08 20:04:36 +00:00
|
|
|
&& !lbs_ssid_cmp(priv->curbssparams.ssid,
|
2008-03-03 11:18:59 +00:00
|
|
|
priv->curbssparams.ssid_len,
|
|
|
|
bss->ssid, bss->ssid_len)) {
|
2007-05-26 02:18:47 +00:00
|
|
|
int snr, nf;
|
2007-12-08 20:04:36 +00:00
|
|
|
snr = priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
|
|
|
|
nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
|
2007-05-26 02:18:47 +00:00
|
|
|
iwe.u.qual.level = CAL_RSSI(snr, nf);
|
2007-05-25 20:15:56 +00:00
|
|
|
}
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
/* Add encryption capability */
|
|
|
|
iwe.cmd = SIOCGIWENCODE;
|
2007-08-02 14:43:44 +00:00
|
|
|
if (bss->capability & WLAN_CAPABILITY_PRIVACY) {
|
2007-05-25 20:15:56 +00:00
|
|
|
iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
|
|
|
|
} else {
|
|
|
|
iwe.u.data.flags = IW_ENCODE_DISABLED;
|
|
|
|
}
|
|
|
|
iwe.u.data.length = 0;
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, bss->ssid);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-06-17 01:50:49 +00:00
|
|
|
current_val = start + iwe_stream_lcp_len(info);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
iwe.cmd = SIOCGIWRATE;
|
|
|
|
iwe.u.bitrate.fixed = 0;
|
|
|
|
iwe.u.bitrate.disabled = 0;
|
|
|
|
iwe.u.bitrate.value = 0;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2009-07-28 07:59:47 +00:00
|
|
|
for (j = 0; j < ARRAY_SIZE(bss->rates) && bss->rates[j]; j++) {
|
2007-08-02 15:40:45 +00:00
|
|
|
/* Bit rate given in 500 kb/s units */
|
|
|
|
iwe.u.bitrate.value = bss->rates[j] * 500000;
|
2008-06-17 01:50:49 +00:00
|
|
|
current_val = iwe_stream_add_value(info, start, current_val,
|
|
|
|
stop, &iwe, IW_EV_PARAM_LEN);
|
2007-05-25 20:15:56 +00:00
|
|
|
}
|
2008-03-03 11:18:59 +00:00
|
|
|
if ((bss->mode == IW_MODE_ADHOC) && priv->adhoccreate
|
2007-12-08 20:04:36 +00:00
|
|
|
&& !lbs_ssid_cmp(priv->curbssparams.ssid,
|
2008-03-03 11:18:59 +00:00
|
|
|
priv->curbssparams.ssid_len,
|
|
|
|
bss->ssid, bss->ssid_len)) {
|
2007-05-25 20:15:56 +00:00
|
|
|
iwe.u.bitrate.value = 22 * 500000;
|
2008-06-17 01:50:49 +00:00
|
|
|
current_val = iwe_stream_add_value(info, start, current_val,
|
2008-03-03 11:18:59 +00:00
|
|
|
stop, &iwe, IW_EV_PARAM_LEN);
|
2007-05-25 20:15:56 +00:00
|
|
|
}
|
|
|
|
/* Check if we added any event */
|
2008-06-17 01:50:49 +00:00
|
|
|
if ((current_val - start) > iwe_stream_lcp_len(info))
|
2007-05-25 20:15:56 +00:00
|
|
|
start = current_val;
|
|
|
|
|
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
|
|
|
if (bss->wpa_ie_len) {
|
|
|
|
char buf[MAX_WPA_IE_LEN];
|
|
|
|
memcpy(buf, bss->wpa_ie, bss->wpa_ie_len);
|
|
|
|
iwe.cmd = IWEVGENIE;
|
|
|
|
iwe.u.data.length = bss->wpa_ie_len;
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, buf);
|
2007-05-25 20:15:56 +00:00
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
|
|
|
if (bss->rsn_ie_len) {
|
|
|
|
char buf[MAX_WPA_IE_LEN];
|
|
|
|
memcpy(buf, bss->rsn_ie, bss->rsn_ie_len);
|
|
|
|
iwe.cmd = IWEVGENIE;
|
|
|
|
iwe.u.data.length = bss->rsn_ie_len;
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, buf);
|
2007-05-25 20:15:56 +00:00
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-08-02 17:14:56 +00:00
|
|
|
if (bss->mesh) {
|
|
|
|
char custom[MAX_CUSTOM_LEN];
|
|
|
|
char *p = custom;
|
|
|
|
|
|
|
|
iwe.cmd = IWEVCUSTOM;
|
2008-03-03 11:18:59 +00:00
|
|
|
p += snprintf(p, MAX_CUSTOM_LEN, "mesh-type: olpc");
|
2007-08-02 17:14:56 +00:00
|
|
|
iwe.u.data.length = p - custom;
|
|
|
|
if (iwe.u.data.length)
|
2008-06-17 01:50:49 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop,
|
|
|
|
&iwe, custom);
|
2007-08-02 17:14:56 +00:00
|
|
|
}
|
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
out:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_SCAN, "start %p", start);
|
2007-05-25 20:15:56 +00:00
|
|
|
return start;
|
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Handle Scan Network ioctl
|
|
|
|
*
|
|
|
|
* @param dev A pointer to net_device structure
|
|
|
|
* @param info A pointer to iw_request_info structure
|
|
|
|
* @param vwrq A pointer to iw_param structure
|
|
|
|
* @param extra A pointer to extra data buf
|
|
|
|
*
|
|
|
|
* @return 0 --success, otherwise fail
|
|
|
|
*/
|
|
|
|
int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
|
2008-03-05 06:05:32 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
2007-12-07 15:52:10 +00:00
|
|
|
{
|
2008-10-01 00:59:05 +00:00
|
|
|
DECLARE_SSID_BUF(ssid);
|
2009-02-20 00:32:39 +00:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2008-03-05 06:05:32 +00:00
|
|
|
int ret = 0;
|
2007-12-07 15:52:10 +00:00
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
lbs_deb_enter(LBS_DEB_WEXT);
|
2007-12-07 15:52:10 +00:00
|
|
|
|
2008-08-21 21:51:07 +00:00
|
|
|
if (!priv->radio_on) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
if (!netif_running(dev)) {
|
|
|
|
ret = -ENETDOWN;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-12-07 15:52:10 +00:00
|
|
|
|
|
|
|
/* mac80211 does this:
|
|
|
|
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
2008-03-05 06:05:32 +00:00
|
|
|
if (sdata->type != IEEE80211_IF_TYPE_xxx) {
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
*/
|
2007-12-07 15:52:10 +00:00
|
|
|
|
|
|
|
if (wrqu->data.length == sizeof(struct iw_scan_req) &&
|
|
|
|
wrqu->data.flags & IW_SCAN_THIS_ESSID) {
|
2008-03-05 06:05:32 +00:00
|
|
|
struct iw_scan_req *req = (struct iw_scan_req *)extra;
|
|
|
|
priv->scan_ssid_len = req->essid_len;
|
|
|
|
memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len);
|
|
|
|
lbs_deb_wext("set_scan, essid '%s'\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, priv->scan_ssid, priv->scan_ssid_len));
|
2008-03-05 06:05:32 +00:00
|
|
|
} else {
|
|
|
|
priv->scan_ssid_len = 0;
|
2007-12-07 15:52:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!delayed_work_pending(&priv->scan_work))
|
|
|
|
queue_delayed_work(priv->work_thread, &priv->scan_work,
|
2008-03-03 11:18:59 +00:00
|
|
|
msecs_to_jiffies(50));
|
2007-12-07 15:52:10 +00:00
|
|
|
/* set marker that currently a scan is taking place */
|
2008-01-28 16:28:05 +00:00
|
|
|
priv->scan_channel = -1;
|
2007-12-07 15:52:10 +00:00
|
|
|
|
2007-12-08 20:04:36 +00:00
|
|
|
if (priv->surpriseremoved)
|
2008-03-05 06:05:32 +00:00
|
|
|
ret = -EIO;
|
2007-12-07 15:52:10 +00:00
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
out:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
|
|
|
|
return ret;
|
2007-12-07 15:52:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
/**
|
2007-10-09 12:15:19 +00:00
|
|
|
* @brief Handle Retrieve scan table ioctl
|
2007-05-25 20:15:56 +00:00
|
|
|
*
|
|
|
|
* @param dev A pointer to net_device structure
|
|
|
|
* @param info A pointer to iw_request_info structure
|
|
|
|
* @param dwrq A pointer to iw_point structure
|
|
|
|
* @param extra A pointer to extra data buf
|
|
|
|
*
|
|
|
|
* @return 0 --success, otherwise fail
|
|
|
|
*/
|
2007-11-15 23:05:47 +00:00
|
|
|
int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
|
2008-03-03 11:18:59 +00:00
|
|
|
struct iw_point *dwrq, char *extra)
|
2007-05-25 20:15:56 +00:00
|
|
|
{
|
|
|
|
#define SCAN_ITEM_SIZE 128
|
2009-02-20 00:32:39 +00:00
|
|
|
struct lbs_private *priv = dev->ml_priv;
|
2007-05-25 20:15:56 +00:00
|
|
|
int err = 0;
|
|
|
|
char *ev = extra;
|
|
|
|
char *stop = ev + dwrq->length;
|
2008-03-03 11:18:59 +00:00
|
|
|
struct bss_descriptor *iter_bss;
|
|
|
|
struct bss_descriptor *safe;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-05 06:05:32 +00:00
|
|
|
lbs_deb_enter(LBS_DEB_WEXT);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-07 15:52:10 +00:00
|
|
|
/* iwlist should wait until the current scan is finished */
|
2008-01-28 16:28:05 +00:00
|
|
|
if (priv->scan_channel)
|
2007-12-07 15:52:10 +00:00
|
|
|
return -EAGAIN;
|
|
|
|
|
2007-05-26 02:18:47 +00:00
|
|
|
/* Update RSSI if current BSS is a locally created ad-hoc BSS */
|
2009-10-09 02:38:45 +00:00
|
|
|
if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate) {
|
|
|
|
err = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
|
|
|
|
CMD_OPTION_WAITFORRSP, 0, NULL);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
}
|
2007-05-26 02:18:47 +00:00
|
|
|
|
2007-12-08 20:04:36 +00:00
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) {
|
2008-03-03 11:18:59 +00:00
|
|
|
char *next_ev;
|
2007-05-25 20:15:56 +00:00
|
|
|
unsigned long stale_time;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
if (stop - ev < SCAN_ITEM_SIZE) {
|
|
|
|
err = -E2BIG;
|
|
|
|
break;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-08-02 14:51:27 +00:00
|
|
|
/* For mesh device, list only mesh networks */
|
|
|
|
if (dev == priv->mesh_dev && !iter_bss->mesh)
|
|
|
|
continue;
|
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
/* Prune old an old scan result */
|
|
|
|
stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE;
|
|
|
|
if (time_after(jiffies, stale_time)) {
|
2008-03-03 11:18:59 +00:00
|
|
|
list_move_tail(&iter_bss->list, &priv->network_free_list);
|
2007-05-25 20:15:56 +00:00
|
|
|
clear_bss_descriptor(iter_bss);
|
|
|
|
continue;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
/* Translate to WE format this entry */
|
2008-06-17 01:50:49 +00:00
|
|
|
next_ev = lbs_translate_scan(priv, info, ev, stop, iter_bss);
|
2007-05-25 20:15:56 +00:00
|
|
|
if (next_ev == NULL)
|
|
|
|
continue;
|
|
|
|
ev = next_ev;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
2007-12-08 20:04:36 +00:00
|
|
|
mutex_unlock(&priv->lock);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
dwrq->length = (ev - extra);
|
2007-02-10 14:25:27 +00:00
|
|
|
dwrq->flags = 0;
|
2009-10-09 02:38:45 +00:00
|
|
|
out:
|
2008-03-05 06:05:32 +00:00
|
|
|
lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", err);
|
2007-05-25 20:15:56 +00:00
|
|
|
return err;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Command execution */
|
|
|
|
/* */
|
|
|
|
/*********************************************************************/
|
|
|
|
|
|
|
|
|
2007-02-10 14:25:27 +00:00
|
|
|
/**
|
|
|
|
* @brief This function handles the command response of scan
|
|
|
|
*
|
2007-10-09 12:15:19 +00:00
|
|
|
* Called from handle_cmd_response() in cmdrespc.
|
|
|
|
*
|
2007-02-10 14:25:27 +00:00
|
|
|
* The response buffer for the scan command has the following
|
|
|
|
* memory layout:
|
|
|
|
*
|
|
|
|
* .-----------------------------------------------------------.
|
|
|
|
* | header (4 * sizeof(u16)): Standard command response hdr |
|
|
|
|
* .-----------------------------------------------------------.
|
|
|
|
* | bufsize (u16) : sizeof the BSS Description data |
|
|
|
|
* .-----------------------------------------------------------.
|
|
|
|
* | NumOfSet (u8) : Number of BSS Descs returned |
|
|
|
|
* .-----------------------------------------------------------.
|
|
|
|
* | BSSDescription data (variable, size given in bufsize) |
|
|
|
|
* .-----------------------------------------------------------.
|
|
|
|
* | TLV data (variable, size calculated using header->size, |
|
|
|
|
* | bufsize and sizeof the fixed fields above) |
|
|
|
|
* .-----------------------------------------------------------.
|
|
|
|
*
|
2007-11-23 14:43:44 +00:00
|
|
|
* @param priv A pointer to struct lbs_private structure
|
2007-02-10 14:25:27 +00:00
|
|
|
* @param resp A pointer to cmd_ds_command
|
|
|
|
*
|
|
|
|
* @return 0 or -1
|
|
|
|
*/
|
2008-03-03 11:18:03 +00:00
|
|
|
static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
|
|
|
|
struct cmd_header *resp)
|
2007-02-10 14:25:27 +00:00
|
|
|
{
|
2008-03-03 11:18:03 +00:00
|
|
|
struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp;
|
2008-03-03 11:18:59 +00:00
|
|
|
struct bss_descriptor *iter_bss;
|
|
|
|
struct bss_descriptor *safe;
|
2008-03-03 11:18:03 +00:00
|
|
|
uint8_t *bssinfo;
|
|
|
|
uint16_t scanrespsize;
|
2007-02-10 14:25:27 +00:00
|
|
|
int bytesleft;
|
|
|
|
int idx;
|
|
|
|
int tlvbufsize;
|
2007-05-25 15:27:16 +00:00
|
|
|
int ret;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-10-09 12:15:19 +00:00
|
|
|
lbs_deb_enter(LBS_DEB_SCAN);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
/* Prune old entries from scan table */
|
2007-12-08 20:04:36 +00:00
|
|
|
list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) {
|
2007-05-25 20:15:56 +00:00
|
|
|
unsigned long stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE;
|
|
|
|
if (time_before(jiffies, stale_time))
|
|
|
|
continue;
|
2007-12-08 20:04:36 +00:00
|
|
|
list_move_tail (&iter_bss->list, &priv->network_free_list);
|
2007-05-25 20:15:56 +00:00
|
|
|
clear_bss_descriptor(iter_bss);
|
|
|
|
}
|
|
|
|
|
2008-03-03 11:18:03 +00:00
|
|
|
if (scanresp->nr_sets > MAX_NETWORK_COUNT) {
|
|
|
|
lbs_deb_scan("SCAN_RESP: too many scan results (%d, max %d)\n",
|
|
|
|
scanresp->nr_sets, MAX_NETWORK_COUNT);
|
2007-05-25 15:27:16 +00:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2009-05-27 18:03:09 +00:00
|
|
|
bytesleft = get_unaligned_le16(&scanresp->bssdescriptsize);
|
2007-05-25 15:27:16 +00:00
|
|
|
lbs_deb_scan("SCAN_RESP: bssdescriptsize %d\n", bytesleft);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-12-11 22:54:36 +00:00
|
|
|
scanrespsize = le16_to_cpu(resp->size);
|
2008-03-03 11:18:03 +00:00
|
|
|
lbs_deb_scan("SCAN_RESP: scan results %d\n", scanresp->nr_sets);
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-03-03 11:18:03 +00:00
|
|
|
bssinfo = scanresp->bssdesc_and_tlvbuffer;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/* The size of the TLV buffer is equal to the entire command response
|
|
|
|
* size (scanrespsize) minus the fixed fields (sizeof()'s), the
|
|
|
|
* BSS Descriptions (bssdescriptsize as bytesLef) and the command
|
2009-10-22 13:30:55 +00:00
|
|
|
* response header (sizeof(struct cmd_header))
|
2007-02-10 14:25:27 +00:00
|
|
|
*/
|
2008-03-03 11:18:03 +00:00
|
|
|
tlvbufsize = scanrespsize - (bytesleft + sizeof(scanresp->bssdescriptsize)
|
|
|
|
+ sizeof(scanresp->nr_sets)
|
2009-10-22 13:30:55 +00:00
|
|
|
+ sizeof(struct cmd_header));
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/*
|
2008-03-03 11:18:03 +00:00
|
|
|
* Process each scan response returned (scanresp->nr_sets). Save
|
2007-02-10 14:25:27 +00:00
|
|
|
* the information in the newbssentry and then insert into the
|
|
|
|
* driver scan table either as an update to an existing entry
|
|
|
|
* or as an addition at the end of the table
|
|
|
|
*/
|
2008-03-03 11:18:03 +00:00
|
|
|
for (idx = 0; idx < scanresp->nr_sets && bytesleft; idx++) {
|
2007-05-25 20:15:56 +00:00
|
|
|
struct bss_descriptor new;
|
2008-03-03 11:18:03 +00:00
|
|
|
struct bss_descriptor *found = NULL;
|
|
|
|
struct bss_descriptor *oldest = NULL;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
|
|
|
/* Process the data fields and IEs returned for this BSS */
|
2007-05-25 20:15:56 +00:00
|
|
|
memset(&new, 0, sizeof (struct bss_descriptor));
|
2008-03-03 11:18:03 +00:00
|
|
|
if (lbs_process_bss(&new, &bssinfo, &bytesleft) != 0) {
|
2007-05-25 20:15:56 +00:00
|
|
|
/* error parsing the scan response, skipped */
|
|
|
|
lbs_deb_scan("SCAN_RESP: process_bss returned ERROR\n");
|
|
|
|
continue;
|
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
/* Try to find this bss in the scan table */
|
2007-12-08 20:04:36 +00:00
|
|
|
list_for_each_entry (iter_bss, &priv->network_list, list) {
|
2007-05-25 20:15:56 +00:00
|
|
|
if (is_same_network(iter_bss, &new)) {
|
|
|
|
found = iter_bss;
|
|
|
|
break;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
if ((oldest == NULL) ||
|
|
|
|
(iter_bss->last_scanned < oldest->last_scanned))
|
|
|
|
oldest = iter_bss;
|
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 20:15:56 +00:00
|
|
|
if (found) {
|
|
|
|
/* found, clear it */
|
|
|
|
clear_bss_descriptor(found);
|
2007-12-08 20:04:36 +00:00
|
|
|
} else if (!list_empty(&priv->network_free_list)) {
|
2007-05-25 20:15:56 +00:00
|
|
|
/* Pull one from the free list */
|
2007-12-08 20:04:36 +00:00
|
|
|
found = list_entry(priv->network_free_list.next,
|
2007-05-25 20:15:56 +00:00
|
|
|
struct bss_descriptor, list);
|
2007-12-08 20:04:36 +00:00
|
|
|
list_move_tail(&found->list, &priv->network_list);
|
2007-05-25 20:15:56 +00:00
|
|
|
} else if (oldest) {
|
|
|
|
/* If there are no more slots, expire the oldest */
|
|
|
|
found = oldest;
|
|
|
|
clear_bss_descriptor(found);
|
2007-12-08 20:04:36 +00:00
|
|
|
list_move_tail(&found->list, &priv->network_list);
|
2007-02-10 14:25:27 +00:00
|
|
|
} else {
|
2007-05-25 20:15:56 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2008-10-27 22:59:26 +00:00
|
|
|
lbs_deb_scan("SCAN_RESP: BSSID %pM\n", new.bssid);
|
2007-05-25 20:15:56 +00:00
|
|
|
|
|
|
|
/* Copy the locally created newbssentry to the scan table */
|
|
|
|
memcpy(found, &new, offsetof(struct bss_descriptor, list));
|
|
|
|
}
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 15:27:16 +00:00
|
|
|
ret = 0;
|
2007-02-10 14:25:27 +00:00
|
|
|
|
2007-05-25 15:27:16 +00:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
|
|
|
|
return ret;
|
2007-02-10 14:25:27 +00:00
|
|
|
}
|