2007-02-10 22:25:27 +08:00
|
|
|
/**
|
|
|
|
* This file contains the handling of command
|
|
|
|
* responses as well as events generated by firmware.
|
|
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
|
|
|
|
#include <net/iw_handler.h>
|
|
|
|
|
|
|
|
#include "host.h"
|
|
|
|
#include "decl.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "dev.h"
|
|
|
|
#include "join.h"
|
|
|
|
#include "wext.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function handles disconnect event. it
|
|
|
|
* reports disconnect to upper layer, clean tx/rx packets,
|
|
|
|
* reset link state etc.
|
|
|
|
*
|
|
|
|
* @param priv A pointer to wlan_private structure
|
|
|
|
* @return n/a
|
|
|
|
*/
|
|
|
|
void libertas_mac_event_disconnected(wlan_private * priv)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
union iwreq_data wrqu;
|
|
|
|
|
2007-08-02 23:31:18 +08:00
|
|
|
if (adapter->connect_status != LIBERTAS_CONNECTED)
|
2007-02-10 22:25:27 +08:00
|
|
|
return;
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
|
|
|
|
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cisco AP sends EAP failure and de-auth in less than 0.5 ms.
|
|
|
|
* It causes problem in the Supplicant
|
|
|
|
*/
|
|
|
|
|
|
|
|
msleep_interruptible(1000);
|
2007-05-26 01:05:16 +08:00
|
|
|
wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/* Free Tx and Rx packets */
|
|
|
|
kfree_skb(priv->adapter->currenttxskb);
|
|
|
|
priv->adapter->currenttxskb = NULL;
|
|
|
|
|
|
|
|
/* report disconnect to upper layer */
|
2007-05-26 01:05:16 +08:00
|
|
|
netif_stop_queue(priv->dev);
|
|
|
|
netif_carrier_off(priv->dev);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/* reset SNR/NF/RSSI values */
|
|
|
|
memset(adapter->SNR, 0x00, sizeof(adapter->SNR));
|
|
|
|
memset(adapter->NF, 0x00, sizeof(adapter->NF));
|
|
|
|
memset(adapter->RSSI, 0x00, sizeof(adapter->RSSI));
|
|
|
|
memset(adapter->rawSNR, 0x00, sizeof(adapter->rawSNR));
|
|
|
|
memset(adapter->rawNF, 0x00, sizeof(adapter->rawNF));
|
|
|
|
adapter->nextSNRNF = 0;
|
|
|
|
adapter->numSNRNF = 0;
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("current SSID '%s', length %u\n",
|
2007-05-29 11:54:55 +08:00
|
|
|
escape_essid(adapter->curbssparams.ssid,
|
|
|
|
adapter->curbssparams.ssid_len),
|
|
|
|
adapter->curbssparams.ssid_len);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:31:18 +08:00
|
|
|
adapter->connect_status = LIBERTAS_DISCONNECTED;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-26 05:09:41 +08:00
|
|
|
/* Clear out associated SSID and BSSID since connection is
|
|
|
|
* no longer valid.
|
|
|
|
*/
|
|
|
|
memset(&adapter->curbssparams.bssid, 0, ETH_ALEN);
|
2007-05-29 11:54:55 +08:00
|
|
|
memset(&adapter->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE);
|
|
|
|
adapter->curbssparams.ssid_len = 0;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
if (adapter->psstate != PS_STATE_FULL_POWER) {
|
|
|
|
/* make firmware to exit PS mode */
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("disconnected, so exit PS mode\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
libertas_ps_wakeup(priv, 0);
|
|
|
|
}
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function handles MIC failure event.
|
|
|
|
*
|
|
|
|
* @param priv A pointer to wlan_private structure
|
|
|
|
* @para event the event id
|
|
|
|
* @return n/a
|
|
|
|
*/
|
|
|
|
static void handle_mic_failureevent(wlan_private * priv, u32 event)
|
|
|
|
{
|
|
|
|
char buf[50];
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
|
|
|
|
sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication ");
|
|
|
|
|
|
|
|
if (event == MACREG_INT_CODE_MIC_ERR_UNICAST) {
|
|
|
|
strcat(buf, "unicast ");
|
|
|
|
} else {
|
|
|
|
strcat(buf, "multicast ");
|
|
|
|
}
|
|
|
|
|
|
|
|
libertas_send_iwevcustom_event(priv, buf);
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_reg_access(wlan_private * priv,
|
|
|
|
u16 type, struct cmd_ds_command *resp)
|
|
|
|
{
|
2007-05-25 23:27:16 +08:00
|
|
|
int ret = 0;
|
2007-02-10 22:25:27 +08:00
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
switch (type) {
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_MAC_REG_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
2007-05-26 11:36:54 +08:00
|
|
|
struct cmd_ds_mac_reg_access *reg = &resp->params.macreg;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
|
|
|
|
adapter->offsetvalue.value = le32_to_cpu(reg->value);
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_BBP_REG_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
2007-05-26 11:36:54 +08:00
|
|
|
struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->offsetvalue.value = reg->value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_RF_REG_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
{
|
2007-05-26 11:36:54 +08:00
|
|
|
struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->offsetvalue.value = reg->value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2007-05-25 23:27:16 +08:00
|
|
|
ret = -1;
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret);
|
|
|
|
return ret;
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_get_hw_spec(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
int ret = 0;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
adapter->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo);
|
|
|
|
|
2007-05-26 11:40:21 +08:00
|
|
|
memcpy(adapter->fwreleasenumber, hwspec->fwreleasenumber, 4);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n",
|
2007-05-26 11:40:21 +08:00
|
|
|
adapter->fwreleasenumber[2], adapter->fwreleasenumber[1],
|
|
|
|
adapter->fwreleasenumber[0], adapter->fwreleasenumber[3]);
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("GET_HW_SPEC: MAC addr " MAC_FMT "\n",
|
2007-08-02 23:50:35 +08:00
|
|
|
MAC_ARG(hwspec->permanentaddr));
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
|
2007-02-10 22:25:27 +08:00
|
|
|
hwspec->hwifversion, hwspec->version);
|
|
|
|
|
|
|
|
adapter->regioncode = le16_to_cpu(hwspec->regioncode);
|
|
|
|
|
|
|
|
for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
|
|
|
|
/* use the region code to search for the index */
|
|
|
|
if (adapter->regioncode == libertas_region_code_to_index[i]) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if it's unidentified region code, use the default (USA) */
|
|
|
|
if (i >= MRVDRV_MAX_REGION_CODE) {
|
|
|
|
adapter->regioncode = 0x10;
|
2007-05-26 11:36:54 +08:00
|
|
|
lbs_pr_info("unidentified region code; using the default (USA)\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
2007-05-26 11:36:54 +08:00
|
|
|
if (adapter->current_addr[0] == 0xff)
|
|
|
|
memmove(adapter->current_addr, hwspec->permanentaddr, ETH_ALEN);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-26 01:05:16 +08:00
|
|
|
memcpy(priv->dev->dev_addr, adapter->current_addr, ETH_ALEN);
|
2007-05-25 23:49:19 +08:00
|
|
|
if (priv->mesh_dev)
|
2007-05-26 11:36:54 +08:00
|
|
|
memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
if (libertas_set_regiontable(priv, adapter->regioncode, 0)) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (libertas_set_universaltable(priv, 0)) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
done:
|
|
|
|
lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret);
|
2007-02-10 22:25:27 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_sleep_params(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("error 0x%x, offset 0x%x, stabletime 0x%x, calcontrol 0x%x "
|
|
|
|
"extsleepclk 0x%x\n", le16_to_cpu(sp->error),
|
2007-05-26 11:36:54 +08:00
|
|
|
le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime),
|
|
|
|
sp->calcontrol, sp->externalsleepclk);
|
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->sp.sp_error = le16_to_cpu(sp->error);
|
|
|
|
adapter->sp.sp_offset = le16_to_cpu(sp->offset);
|
|
|
|
adapter->sp.sp_stabletime = le16_to_cpu(sp->stabletime);
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->sp.sp_calcontrol = sp->calcontrol;
|
|
|
|
adapter->sp.sp_extsleepclk = sp->externalsleepclk;
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->sp.sp_reserved = le16_to_cpu(sp->reserved);
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_stat(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
/* currently adapter->wlan802_11Stat is unused
|
|
|
|
|
|
|
|
struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
|
|
|
// TODO Convert it to Big endian befor copy
|
|
|
|
memcpy(&adapter->wlan802_11Stat,
|
|
|
|
p11Stat, sizeof(struct cmd_ds_802_11_get_stat));
|
|
|
|
*/
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_snmp_mib(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
|
|
|
|
u16 oid = le16_to_cpu(smib->oid);
|
|
|
|
u16 querytype = le16_to_cpu(smib->querytype);
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("SNMP_RESP: oid 0x%x, querytype 0x%x\n", oid,
|
2007-02-10 22:25:27 +08:00
|
|
|
querytype);
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("SNMP_RESP: Buf size %d\n", le16_to_cpu(smib->bufsize));
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:31:18 +08:00
|
|
|
if (querytype == CMD_ACT_GET) {
|
2007-02-10 22:25:27 +08:00
|
|
|
switch (oid) {
|
2007-08-02 23:31:18 +08:00
|
|
|
case FRAGTHRESH_I:
|
2007-02-10 22:25:27 +08:00
|
|
|
priv->adapter->fragthsd =
|
2007-05-26 11:36:54 +08:00
|
|
|
le16_to_cpu(*((__le16 *)(smib->value)));
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("SNMP_RESP: frag threshold %u\n",
|
2007-05-26 11:36:54 +08:00
|
|
|
priv->adapter->fragthsd);
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
2007-08-02 23:31:18 +08:00
|
|
|
case RTSTHRESH_I:
|
2007-02-10 22:25:27 +08:00
|
|
|
priv->adapter->rtsthsd =
|
2007-05-26 11:36:54 +08:00
|
|
|
le16_to_cpu(*((__le16 *)(smib->value)));
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("SNMP_RESP: rts threshold %u\n",
|
2007-05-26 11:36:54 +08:00
|
|
|
priv->adapter->rtsthsd);
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
2007-08-02 23:31:18 +08:00
|
|
|
case SHORT_RETRYLIM_I:
|
2007-02-10 22:25:27 +08:00
|
|
|
priv->adapter->txretrycount =
|
2007-05-26 11:36:54 +08:00
|
|
|
le16_to_cpu(*((__le16 *)(smib->value)));
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("SNMP_RESP: tx retry count %u\n",
|
2007-05-26 11:36:54 +08:00
|
|
|
priv->adapter->rtsthsd);
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_key_material(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_key_material *pkeymaterial =
|
|
|
|
&resp->params.keymaterial;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
u16 action = le16_to_cpu(pkeymaterial->action);
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/* Copy the returned key to driver private data */
|
2007-08-02 23:31:18 +08:00
|
|
|
if (action == CMD_ACT_GET) {
|
2007-02-10 22:25:27 +08:00
|
|
|
u8 * buf_ptr = (u8 *) &pkeymaterial->keyParamSet;
|
|
|
|
u8 * resp_end = (u8 *) (resp + le16_to_cpu(resp->size));
|
|
|
|
|
|
|
|
while (buf_ptr < resp_end) {
|
|
|
|
struct MrvlIEtype_keyParamSet * pkeyparamset =
|
|
|
|
(struct MrvlIEtype_keyParamSet *) buf_ptr;
|
2007-08-02 22:45:55 +08:00
|
|
|
struct enc_key * pkey;
|
2007-02-10 22:25:27 +08:00
|
|
|
u16 param_set_len = le16_to_cpu(pkeyparamset->length);
|
|
|
|
u16 key_len = le16_to_cpu(pkeyparamset->keylen);
|
2007-08-02 22:45:55 +08:00
|
|
|
u16 key_flags = le16_to_cpu(pkeyparamset->keyinfo);
|
|
|
|
u16 key_type = le16_to_cpu(pkeyparamset->keytypeid);
|
|
|
|
u8 * end;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
end = (u8 *) pkeyparamset + sizeof (pkeyparamset->type)
|
|
|
|
+ sizeof (pkeyparamset->length)
|
|
|
|
+ param_set_len;
|
|
|
|
/* Make sure we don't access past the end of the IEs */
|
|
|
|
if (end > resp_end)
|
|
|
|
break;
|
|
|
|
|
2007-08-02 22:45:55 +08:00
|
|
|
if (key_flags & KEY_INFO_WPA_UNICAST)
|
2007-02-10 22:25:27 +08:00
|
|
|
pkey = &adapter->wpa_unicast_key;
|
2007-08-02 22:45:55 +08:00
|
|
|
else if (key_flags & KEY_INFO_WPA_MCAST)
|
2007-02-10 22:25:27 +08:00
|
|
|
pkey = &adapter->wpa_mcast_key;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Copy returned key into driver */
|
2007-08-02 22:45:55 +08:00
|
|
|
memset(pkey, 0, sizeof(struct enc_key));
|
2007-02-10 22:25:27 +08:00
|
|
|
if (key_len > sizeof(pkey->key))
|
|
|
|
break;
|
2007-08-02 22:45:55 +08:00
|
|
|
pkey->type = key_type;
|
|
|
|
pkey->flags = key_flags;
|
|
|
|
pkey->len = key_len;
|
2007-02-10 22:25:27 +08:00
|
|
|
memcpy(pkey->key, pkeyparamset->key, pkey->len);
|
|
|
|
|
|
|
|
buf_ptr = end + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_mac_address(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
memcpy(adapter->current_addr, macadd->macadd, ETH_ALEN);
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_rf_tx_power(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
adapter->txpowerlevel = le16_to_cpu(rtp->currentlevel);
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("TX power currently %d\n", adapter->txpowerlevel);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_rate_adapt_rateset(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
2007-05-26 11:36:54 +08:00
|
|
|
struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset;
|
2007-02-10 22:25:27 +08:00
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:31:18 +08:00
|
|
|
if (rates->action == CMD_ACT_GET) {
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->enablehwauto = le16_to_cpu(rates->enablehwauto);
|
|
|
|
adapter->ratebitmap = le16_to_cpu(rates->bitmap);
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_data_rate(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_data_rate *pdatarate = &resp->params.drate;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_hex(LBS_DEB_CMD, "DATA_RATE_RESP", (u8 *) pdatarate,
|
2007-08-02 23:40:45 +08:00
|
|
|
sizeof(struct cmd_ds_802_11_data_rate));
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:40:45 +08:00
|
|
|
/* FIXME: get actual rates FW can do if this command actually returns
|
|
|
|
* all data rates supported.
|
|
|
|
*/
|
|
|
|
adapter->cur_rate = libertas_fw_index_to_data_rate(pdatarate->rates[0]);
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("DATA_RATE: current rate 0x%02x\n", adapter->cur_rate);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:40:45 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_rf_channel(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
2007-05-26 11:36:54 +08:00
|
|
|
struct cmd_ds_802_11_rf_channel *rfchannel = &resp->params.rfchannel;
|
2007-02-10 22:25:27 +08:00
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
u16 action = le16_to_cpu(rfchannel->action);
|
|
|
|
u16 newchannel = le16_to_cpu(rfchannel->currentchannel);
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:31:18 +08:00
|
|
|
if (action == CMD_OPT_802_11_RF_CHANNEL_GET
|
2007-02-10 22:25:27 +08:00
|
|
|
&& adapter->curbssparams.channel != newchannel) {
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("channel switch from %d to %d\n",
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->curbssparams.channel, newchannel);
|
|
|
|
|
|
|
|
/* Update the channel again */
|
|
|
|
adapter->curbssparams.channel = newchannel;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_rssi(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
/* store the non average value */
|
|
|
|
adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR);
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
adapter->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR);
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] =
|
|
|
|
CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG],
|
|
|
|
adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
|
|
|
|
|
|
|
|
adapter->RSSI[TYPE_BEACON][TYPE_AVG] =
|
|
|
|
CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE,
|
|
|
|
adapter->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE);
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("RSSI: beacon %d, avg %d\n",
|
|
|
|
adapter->RSSI[TYPE_BEACON][TYPE_NOAVG],
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->RSSI[TYPE_BEACON][TYPE_AVG]);
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_802_11_eeprom_access(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
struct wlan_ioctl_regrdwr *pbuf;
|
|
|
|
pbuf = (struct wlan_ioctl_regrdwr *) adapter->prdeeprom;
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_enter_args(LBS_DEB_CMD, "len %d",
|
2007-02-10 22:25:27 +08:00
|
|
|
le16_to_cpu(resp->params.rdeeprom.bytecount));
|
|
|
|
if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) {
|
|
|
|
pbuf->NOB = 0;
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("EEPROM read length too big\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
pbuf->NOB = le16_to_cpu(resp->params.rdeeprom.bytecount);
|
|
|
|
if (pbuf->NOB > 0) {
|
|
|
|
|
|
|
|
memcpy(&pbuf->value, (u8 *) & resp->params.rdeeprom.value,
|
|
|
|
le16_to_cpu(resp->params.rdeeprom.bytecount));
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_hex(LBS_DEB_CMD, "EEPROM", (char *)&pbuf->value,
|
2007-02-10 22:25:27 +08:00
|
|
|
le16_to_cpu(resp->params.rdeeprom.bytecount));
|
|
|
|
}
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlan_ret_get_log(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
2007-05-26 11:36:54 +08:00
|
|
|
struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog;
|
2007-02-10 22:25:27 +08:00
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-05-26 11:36:54 +08:00
|
|
|
/* Stored little-endian */
|
|
|
|
memcpy(&adapter->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log));
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-02-10 22:25:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-19 00:01:12 +08:00
|
|
|
static int libertas_ret_802_11_enable_rsn(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
struct cmd_ds_802_11_enable_rsn *enable_rsn = &resp->params.enbrsn;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
u32 * pdata_buf = adapter->cur_cmd->pdata_buf;
|
|
|
|
|
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
|
|
|
|
2007-08-02 23:31:18 +08:00
|
|
|
if (enable_rsn->action == cpu_to_le16(CMD_ACT_GET)) {
|
2007-06-19 00:01:12 +08:00
|
|
|
if (pdata_buf)
|
|
|
|
*pdata_buf = (u32) le16_to_cpu(enable_rsn->enable);
|
|
|
|
}
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_CMD);
|
2007-06-19 00:01:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
static inline int handle_cmd_response(u16 respcmd,
|
|
|
|
struct cmd_ds_command *resp,
|
|
|
|
wlan_private *priv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
unsigned long flags;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_HOST);
|
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
switch (respcmd) {
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_MAC_REG_ACCESS):
|
|
|
|
case CMD_RET(CMD_BBP_REG_ACCESS):
|
|
|
|
case CMD_RET(CMD_RF_REG_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_reg_access(priv, respcmd, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_GET_HW_SPEC):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_get_hw_spec(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_SCAN):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = libertas_ret_80211_scan(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_GET_LOG):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_get_log(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:31:18 +08:00
|
|
|
case CMD_RET_802_11_ASSOCIATE:
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_ASSOCIATE):
|
|
|
|
case CMD_RET(CMD_802_11_REASSOCIATE):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = libertas_ret_80211_associate(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_DISASSOCIATE):
|
|
|
|
case CMD_RET(CMD_802_11_DEAUTHENTICATE):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = libertas_ret_80211_disassociate(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_AD_HOC_START):
|
|
|
|
case CMD_RET(CMD_802_11_AD_HOC_JOIN):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = libertas_ret_80211_ad_hoc_start(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_GET_STAT):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_stat(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_SNMP_MIB):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_snmp_mib(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_RF_TX_POWER):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_rf_tx_power(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_SET_AFC):
|
|
|
|
case CMD_RET(CMD_802_11_GET_AFC):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
2007-05-26 11:36:54 +08:00
|
|
|
memmove(adapter->cur_cmd->pdata_buf, &resp->params.afc,
|
2007-02-10 22:25:27 +08:00
|
|
|
sizeof(struct cmd_ds_802_11_afc));
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_MAC_MULTICAST_ADR):
|
|
|
|
case CMD_RET(CMD_MAC_CONTROL):
|
|
|
|
case CMD_RET(CMD_802_11_SET_WEP):
|
|
|
|
case CMD_RET(CMD_802_11_RESET):
|
|
|
|
case CMD_RET(CMD_802_11_AUTHENTICATE):
|
|
|
|
case CMD_RET(CMD_802_11_RADIO_CONTROL):
|
|
|
|
case CMD_RET(CMD_802_11_BEACON_STOP):
|
2007-06-19 00:01:12 +08:00
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_ENABLE_RSN):
|
2007-06-19 00:01:12 +08:00
|
|
|
ret = libertas_ret_802_11_enable_rsn(priv, resp);
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_DATA_RATE):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_data_rate(priv, resp);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_rate_adapt_rateset(priv, resp);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_RF_CHANNEL):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_rf_channel(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_RSSI):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_rssi(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_MAC_ADDRESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_mac_address(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_AD_HOC_STOP):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = libertas_ret_80211_ad_hoc_stop(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_KEY_MATERIAL):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_key_material(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_EEPROM_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_eeprom_access(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11D_DOMAIN_INFO):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = libertas_ret_802_11d_domain_info(priv, resp);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_SLEEP_PARAMS):
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = wlan_ret_802_11_sleep_params(priv, resp);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
|
|
|
*((u16 *) adapter->cur_cmd->pdata_buf) =
|
|
|
|
le16_to_cpu(resp->params.inactivity_timeout.timeout);
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_TPC_CFG):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
2007-05-26 11:36:54 +08:00
|
|
|
memmove(adapter->cur_cmd->pdata_buf, &resp->params.tpccfg,
|
2007-02-10 22:25:27 +08:00
|
|
|
sizeof(struct cmd_ds_802_11_tpc_cfg));
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_LED_GPIO_CTRL):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
2007-05-26 11:36:54 +08:00
|
|
|
memmove(adapter->cur_cmd->pdata_buf, &resp->params.ledgpio,
|
2007-02-10 22:25:27 +08:00
|
|
|
sizeof(struct cmd_ds_802_11_led_ctrl));
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_802_11_PWR_CFG):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
2007-05-26 11:36:54 +08:00
|
|
|
memmove(adapter->cur_cmd->pdata_buf, &resp->params.pwrcfg,
|
2007-02-10 22:25:27 +08:00
|
|
|
sizeof(struct cmd_ds_802_11_pwr_cfg));
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_GET_TSF):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
|
|
|
memcpy(priv->adapter->cur_cmd->pdata_buf,
|
|
|
|
&resp->params.gettsf.tsfvalue, sizeof(u64));
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_BT_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
|
|
|
if (adapter->cur_cmd->pdata_buf)
|
|
|
|
memcpy(adapter->cur_cmd->pdata_buf,
|
|
|
|
&resp->params.bt.addr1, 2 * ETH_ALEN);
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_FWT_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
|
|
|
if (adapter->cur_cmd->pdata_buf)
|
2007-05-26 11:36:54 +08:00
|
|
|
memcpy(adapter->cur_cmd->pdata_buf, &resp->params.fwt,
|
|
|
|
sizeof(resp->params.fwt));
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
break;
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_MESH_ACCESS):
|
2007-02-10 22:25:27 +08:00
|
|
|
if (adapter->cur_cmd->pdata_buf)
|
2007-05-26 11:36:54 +08:00
|
|
|
memcpy(adapter->cur_cmd->pdata_buf, &resp->params.mesh,
|
2007-02-10 22:25:27 +08:00
|
|
|
sizeof(resp->params.mesh));
|
|
|
|
break;
|
|
|
|
default:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n",
|
2007-05-26 11:36:54 +08:00
|
|
|
resp->command);
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
}
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave(LBS_DEB_HOST);
|
2007-02-10 22:25:27 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_process_rx_command(wlan_private * priv)
|
|
|
|
{
|
|
|
|
u16 respcmd;
|
|
|
|
struct cmd_ds_command *resp;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
int ret = 0;
|
|
|
|
ulong flags;
|
|
|
|
u16 result;
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_HOST);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/* Now we got response from FW, cancel the command timer */
|
|
|
|
del_timer(&adapter->command_timer);
|
|
|
|
|
|
|
|
mutex_lock(&adapter->lock);
|
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
|
|
|
|
|
|
|
if (!adapter->cur_cmd) {
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: cur_cmd is NULL\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
ret = -1;
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
resp = (struct cmd_ds_command *)(adapter->cur_cmd->bufvirtualaddr);
|
|
|
|
|
|
|
|
respcmd = le16_to_cpu(resp->command);
|
|
|
|
result = le16_to_cpu(resp->result);
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: response 0x%04x, size %d, jiffies %lu\n",
|
|
|
|
respcmd, priv->upld_len, jiffies);
|
|
|
|
lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", adapter->cur_cmd->bufvirtualaddr,
|
|
|
|
priv->upld_len);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
if (!(respcmd & 0x8000)) {
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("invalid response!\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->cur_cmd_retcode = -1;
|
|
|
|
__libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd);
|
|
|
|
adapter->nr_cmd_pending--;
|
|
|
|
adapter->cur_cmd = NULL;
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store the response code to cur_cmd_retcode. */
|
2007-05-26 11:36:54 +08:00
|
|
|
adapter->cur_cmd_retcode = result;;
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:53:36 +08:00
|
|
|
if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
|
2007-05-26 11:36:54 +08:00
|
|
|
struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode;
|
|
|
|
u16 action = le16_to_cpu(psmode->action);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host(
|
|
|
|
"CMD_RESP: PS_MODE cmd reply result 0x%x, action 0x%x\n",
|
2007-05-26 11:36:54 +08:00
|
|
|
result, action);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
if (result) {
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n",
|
2007-05-26 11:36:54 +08:00
|
|
|
result);
|
|
|
|
/*
|
|
|
|
* We should not re-try enter-ps command in
|
|
|
|
* ad-hoc mode. It takes place in
|
|
|
|
* libertas_execute_next_command().
|
|
|
|
*/
|
|
|
|
if (adapter->mode == IW_MODE_ADHOC &&
|
2007-08-02 23:31:18 +08:00
|
|
|
action == CMD_SUBCMD_ENTER_PS)
|
|
|
|
adapter->psmode = WLAN802_11POWERMODECAM;
|
|
|
|
} else if (action == CMD_SUBCMD_ENTER_PS) {
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->needtowakeup = 0;
|
|
|
|
adapter->psstate = PS_STATE_AWAKE;
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: ENTER_PS command response\n");
|
2007-08-02 23:31:18 +08:00
|
|
|
if (adapter->connect_status != LIBERTAS_CONNECTED) {
|
2007-02-10 22:25:27 +08:00
|
|
|
/*
|
|
|
|
* When Deauth Event received before Enter_PS command
|
|
|
|
* response, We need to wake up the firmware.
|
|
|
|
*/
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host(
|
|
|
|
"disconnected, invoking libertas_ps_wakeup\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
2007-05-26 05:33:28 +08:00
|
|
|
mutex_unlock(&adapter->lock);
|
2007-02-10 22:25:27 +08:00
|
|
|
libertas_ps_wakeup(priv, 0);
|
|
|
|
mutex_lock(&adapter->lock);
|
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
|
|
|
}
|
2007-08-02 23:31:18 +08:00
|
|
|
} else if (action == CMD_SUBCMD_EXIT_PS) {
|
2007-02-10 22:25:27 +08:00
|
|
|
adapter->needtowakeup = 0;
|
|
|
|
adapter->psstate = PS_STATE_FULL_POWER;
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: EXIT_PS command response\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
} else {
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
|
2007-02-10 22:25:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd);
|
|
|
|
adapter->nr_cmd_pending--;
|
|
|
|
adapter->cur_cmd = NULL;
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adapter->cur_cmd->cmdflags & CMD_F_HOSTCMD) {
|
|
|
|
/* Copy the response back to response buffer */
|
|
|
|
memcpy(adapter->cur_cmd->pdata_buf, resp, resp->size);
|
|
|
|
|
|
|
|
adapter->cur_cmd->cmdflags &= ~CMD_F_HOSTCMD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the command is not successful, cleanup and return failure */
|
|
|
|
if ((result != 0 || !(respcmd & 0x8000))) {
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n",
|
|
|
|
result, respcmd);
|
2007-02-10 22:25:27 +08:00
|
|
|
/*
|
|
|
|
* Handling errors here
|
|
|
|
*/
|
|
|
|
switch (respcmd) {
|
2007-08-02 23:53:36 +08:00
|
|
|
case CMD_RET(CMD_GET_HW_SPEC):
|
|
|
|
case CMD_RET(CMD_802_11_RESET):
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_host("CMD_RESP: reset failed\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
__libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd);
|
|
|
|
adapter->nr_cmd_pending--;
|
|
|
|
adapter->cur_cmd = NULL;
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
|
|
|
|
ret = handle_cmd_response(respcmd, resp, priv);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&adapter->driver_lock, flags);
|
|
|
|
if (adapter->cur_cmd) {
|
|
|
|
/* Clean up and Put current command back to cmdfreeq */
|
|
|
|
__libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd);
|
|
|
|
adapter->nr_cmd_pending--;
|
|
|
|
WARN_ON(adapter->nr_cmd_pending > 128);
|
|
|
|
adapter->cur_cmd = NULL;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&adapter->driver_lock, flags);
|
|
|
|
|
|
|
|
done:
|
|
|
|
mutex_unlock(&adapter->lock);
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
|
2007-02-10 22:25:27 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_process_event(wlan_private * priv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
u32 eventcause;
|
|
|
|
|
2007-08-03 01:14:07 +08:00
|
|
|
lbs_deb_enter(LBS_DEB_CMD);
|
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
spin_lock_irq(&adapter->driver_lock);
|
|
|
|
eventcause = adapter->eventcause;
|
|
|
|
spin_unlock_irq(&adapter->driver_lock);
|
|
|
|
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("event cause 0x%x\n", eventcause);
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
switch (eventcause >> SBI_EVENT_CAUSE_SHIFT) {
|
|
|
|
case MACREG_INT_CODE_LINK_SENSED:
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_cmd("EVENT: MACREG_INT_CODE_LINK_SENSED\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_DEAUTHENTICATED:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("EVENT: deauthenticated\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
libertas_mac_event_disconnected(priv);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_DISASSOCIATED:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("EVENT: disassociated\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
libertas_mac_event_disconnected(priv);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_LINK_LOSE_NO_SCAN:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("EVENT: link lost\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
libertas_mac_event_disconnected(priv);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_PS_SLEEP:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("EVENT: sleep\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/* handle unexpected PS SLEEP event */
|
|
|
|
if (adapter->psstate == PS_STATE_FULL_POWER) {
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_cmd(
|
2007-08-02 23:54:10 +08:00
|
|
|
"EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
adapter->psstate = PS_STATE_PRE_SLEEP;
|
|
|
|
|
|
|
|
libertas_ps_confirm_sleep(priv, (u16) adapter->psmode);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_PS_AWAKE:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("EVENT: awake\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
|
|
|
|
/* handle unexpected PS AWAKE event */
|
|
|
|
if (adapter->psstate == PS_STATE_FULL_POWER) {
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_cmd(
|
2007-02-10 22:25:27 +08:00
|
|
|
"EVENT: In FULL POWER mode - ignore PS AWAKE\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
adapter->psstate = PS_STATE_AWAKE;
|
|
|
|
|
|
|
|
if (adapter->needtowakeup) {
|
|
|
|
/*
|
|
|
|
* wait for the command processing to finish
|
|
|
|
* before resuming sending
|
|
|
|
* adapter->needtowakeup will be set to FALSE
|
|
|
|
* in libertas_ps_wakeup()
|
|
|
|
*/
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("waking up ...\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
libertas_ps_wakeup(priv, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_MIC_ERR_UNICAST:
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_MIC_ERR_MULTICAST:
|
2007-05-25 23:27:16 +08:00
|
|
|
lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST);
|
|
|
|
break;
|
|
|
|
case MACREG_INT_CODE_MIB_CHANGED:
|
|
|
|
case MACREG_INT_CODE_INIT_DONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_ADHOC_BCN_LOST:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACREG_INT_CODE_RSSI_LOW:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_pr_alert("EVENT: rssi low\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
case MACREG_INT_CODE_SNR_LOW:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_pr_alert("EVENT: snr low\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
case MACREG_INT_CODE_MAX_FAIL:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_pr_alert("EVENT: max fail\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
case MACREG_INT_CODE_RSSI_HIGH:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_pr_alert("EVENT: rssi high\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
case MACREG_INT_CODE_SNR_HIGH:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_pr_alert("EVENT: snr high\n");
|
2007-02-10 22:25:27 +08:00
|
|
|
break;
|
|
|
|
|
2007-05-26 11:12:19 +08:00
|
|
|
case MACREG_INT_CODE_MESH_AUTO_STARTED:
|
2007-08-02 23:55:22 +08:00
|
|
|
lbs_pr_info("EVENT: MESH_AUTO_STARTED\n");
|
|
|
|
adapter->connect_status = LIBERTAS_CONNECTED;
|
2007-05-26 11:12:19 +08:00
|
|
|
if (priv->mesh_open == 1) {
|
2007-08-02 23:55:22 +08:00
|
|
|
netif_wake_queue(priv->mesh_dev);
|
|
|
|
netif_carrier_on(priv->mesh_dev);
|
2007-05-26 11:12:19 +08:00
|
|
|
}
|
2007-08-02 23:55:22 +08:00
|
|
|
adapter->mode = IW_MODE_ADHOC;
|
2007-05-31 00:14:34 +08:00
|
|
|
schedule_work(&priv->sync_channel);
|
2007-05-26 11:12:19 +08:00
|
|
|
break;
|
|
|
|
|
2007-02-10 22:25:27 +08:00
|
|
|
default:
|
2007-08-02 23:54:10 +08:00
|
|
|
lbs_pr_alert("EVENT: unknown event id 0x%04x\n",
|
2007-02-10 22:25:27 +08:00
|
|
|
eventcause >> SBI_EVENT_CAUSE_SHIFT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irq(&adapter->driver_lock);
|
|
|
|
adapter->eventcause = 0;
|
|
|
|
spin_unlock_irq(&adapter->driver_lock);
|
2007-05-25 23:27:16 +08:00
|
|
|
|
2007-08-03 01:14:07 +08:00
|
|
|
lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
|
2007-02-10 22:25:27 +08:00
|
|
|
return ret;
|
|
|
|
}
|