Commit ff25839b authored by Kalle Valo's avatar Kalle Valo Committed by John W. Linville

wl12xx: cmd and acx interface rework

Rework cmd and acx interfaces, it was just too confusing earlier. Now
all commands need to contain all the needed headers, either just cmd
headers or both cmd and acx headers. This accomplish to remove the
extra copy done for each command. The interfaces are now properly
documented as well.

Also try to make all commands safe for DMA transfers. I might have missed
some, but most of them should be fixed now.

And this is not all! As a free bonus you will also get some cosmetic
cleanups and code reorganisation. Order today!
Signed-off-by: default avatarKalle Valo <kalle.valo@nokia.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c4f9f16b
This diff is collapsed.
...@@ -26,10 +26,16 @@ ...@@ -26,10 +26,16 @@
#define __WL12XX_ACX_H__ #define __WL12XX_ACX_H__
#include "wl12xx.h" #include "wl12xx.h"
#include "cmd.h"
/* Target's information element */ /* Target's information element */
struct acx_header { struct acx_header {
struct wl12xx_cmd_header cmd;
/* acx (or information element) header */
u16 id; u16 id;
/* payload length (not including headers */
u16 len; u16 len;
}; };
...@@ -107,25 +113,6 @@ struct acx_sleep_auth { ...@@ -107,25 +113,6 @@ struct acx_sleep_auth {
u8 padding[3]; u8 padding[3];
} __attribute__ ((packed)); } __attribute__ ((packed));
#define TIM_ELE_ID 5
#define PARTIAL_VBM_MAX 251
struct tim {
u8 identity;
u8 length;
u8 dtim_count;
u8 dtim_period;
u8 bitmap_ctrl;
u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
} __attribute__ ((packed));
/* Virtual Bit Map update */
struct vbm_update_request {
__le16 len;
u8 padding[2];
struct tim tim;
} __attribute__ ((packed));
enum { enum {
HOSTIF_PCI_MASTER_HOST_INDIRECT, HOSTIF_PCI_MASTER_HOST_INDIRECT,
HOSTIF_PCI_MASTER_HOST_DIRECT, HOSTIF_PCI_MASTER_HOST_DIRECT,
...@@ -202,7 +189,7 @@ struct acx_data_path_params_resp { ...@@ -202,7 +189,7 @@ struct acx_data_path_params_resp {
#define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF #define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF
#define RX_MSDU_LIFETIME_DEF 512000 #define RX_MSDU_LIFETIME_DEF 512000
struct rx_msdu_lifetime { struct acx_rx_msdu_lifetime {
struct acx_header header; struct acx_header header;
/* /*
...@@ -368,7 +355,7 @@ struct acx_slot { ...@@ -368,7 +355,7 @@ struct acx_slot {
#define ADDRESS_GROUP_MAX (8) #define ADDRESS_GROUP_MAX (8)
#define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX) #define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX)
struct multicast_grp_addr_start { struct acx_dot11_grp_addr_tbl {
struct acx_header header; struct acx_header header;
u8 enabled; u8 enabled;
...@@ -730,22 +717,13 @@ struct acx_fw_gen_frame_rates { ...@@ -730,22 +717,13 @@ struct acx_fw_gen_frame_rates {
} __attribute__ ((packed)); } __attribute__ ((packed));
/* STA MAC */ /* STA MAC */
struct dot11_station_id { struct acx_dot11_station_id {
struct acx_header header; struct acx_header header;
u8 mac[ETH_ALEN]; u8 mac[ETH_ALEN];
u8 pad[2]; u8 pad[2];
} __attribute__ ((packed)); } __attribute__ ((packed));
/* HW encryption keys */
#define NUM_ACCESS_CATEGORIES_COPY 4
#define MAX_KEY_SIZE 32
/* When set, disable HW encryption */
#define DF_ENCRYPTION_DISABLE 0x01
/* When set, disable HW decryption */
#define DF_SNIFF_MODE_ENABLE 0x80
struct acx_feature_config { struct acx_feature_config {
struct acx_header header; struct acx_header header;
...@@ -753,67 +731,6 @@ struct acx_feature_config { ...@@ -753,67 +731,6 @@ struct acx_feature_config {
u32 data_flow_options; u32 data_flow_options;
} __attribute__ ((packed)); } __attribute__ ((packed));
enum acx_key_action {
KEY_ADD_OR_REPLACE = 1,
KEY_REMOVE = 2,
KEY_SET_ID = 3,
MAX_KEY_ACTION = 0xffff,
};
enum acx_key_type {
KEY_WEP_DEFAULT = 0,
KEY_WEP_ADDR = 1,
KEY_AES_GROUP = 4,
KEY_AES_PAIRWISE = 5,
KEY_WEP_GROUP = 6,
KEY_TKIP_MIC_GROUP = 10,
KEY_TKIP_MIC_PAIRWISE = 11,
};
/*
*
* key_type_e key size key format
* ---------- --------- ----------
* 0x00 5, 13, 29 Key data
* 0x01 5, 13, 29 Key data
* 0x04 16 16 bytes of key data
* 0x05 16 16 bytes of key data
* 0x0a 32 16 bytes of TKIP key data
* 8 bytes of RX MIC key data
* 8 bytes of TX MIC key data
* 0x0b 32 16 bytes of TKIP key data
* 8 bytes of RX MIC key data
* 8 bytes of TX MIC key data
*
*/
struct acx_set_key {
/* Ignored for default WEP key */
u8 addr[ETH_ALEN];
/* key_action_e */
u16 key_action;
u16 reserved_1;
/* key size in bytes */
u8 key_size;
/* key_type_e */
u8 key_type;
u8 ssid_profile;
/*
* TKIP, AES: frame's key id field.
* For WEP default key: key id;
*/
u8 id;
u8 reserved_2[6];
u8 key[MAX_KEY_SIZE];
u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
} __attribute__ ((packed));
struct acx_current_tx_power { struct acx_current_tx_power {
struct acx_header header; struct acx_header header;
...@@ -839,26 +756,6 @@ struct acx_tsf_info { ...@@ -839,26 +756,6 @@ struct acx_tsf_info {
u8 pad[3]; u8 pad[3];
} __attribute__ ((packed)); } __attribute__ ((packed));
/* 802.11 PS */
enum acx_ps_mode {
STATION_ACTIVE_MODE,
STATION_POWER_SAVE_MODE
};
struct acx_ps_params {
u8 ps_mode; /* STATION_* */
u8 send_null_data; /* Do we have to send NULL data packet ? */
u8 retries; /* Number of retires for the initial NULL data packet */
/*
* TUs during which the target stays awake after switching
* to power save mode.
*/
u8 hang_over_period;
u16 null_data_rate;
u8 pad[2];
} __attribute__ ((packed));
enum acx_wake_up_event { enum acx_wake_up_event {
WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/ WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/
WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/ WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/
...@@ -892,6 +789,7 @@ enum acx_preamble_type { ...@@ -892,6 +789,7 @@ enum acx_preamble_type {
struct acx_preamble { struct acx_preamble {
struct acx_header header; struct acx_header header;
/* /*
* When set, the WiLink transmits the frames with a short preamble and * When set, the WiLink transmits the frames with a short preamble and
* when cleared, the WiLink transmits the frames with a long preamble. * when cleared, the WiLink transmits the frames with a long preamble.
...@@ -1219,7 +1117,8 @@ int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth); ...@@ -1219,7 +1117,8 @@ int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth);
int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len); int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len);
int wl12xx_acx_tx_power(struct wl12xx *wl, int power); int wl12xx_acx_tx_power(struct wl12xx *wl, int power);
int wl12xx_acx_feature_cfg(struct wl12xx *wl); int wl12xx_acx_feature_cfg(struct wl12xx *wl);
int wl12xx_acx_mem_map(struct wl12xx *wl, void *mem_map, size_t len); int wl12xx_acx_mem_map(struct wl12xx *wl,
struct acx_header *mem_map, size_t len);
int wl12xx_acx_data_path_params(struct wl12xx *wl, int wl12xx_acx_data_path_params(struct wl12xx *wl,
struct acx_data_path_params_resp *data_path); struct acx_data_path_params_resp *data_path);
int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time); int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time);
...@@ -1241,5 +1140,6 @@ int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble); ...@@ -1241,5 +1140,6 @@ int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble);
int wl12xx_acx_cts_protect(struct wl12xx *wl, int wl12xx_acx_cts_protect(struct wl12xx *wl,
enum acx_ctsprotect_type ctsprotect); enum acx_ctsprotect_type ctsprotect);
int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats); int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats);
int wl12xx_acx_tsf_info(struct wl12xx *wl, u64 *mactime);
#endif /* __WL12XX_ACX_H__ */ #endif /* __WL12XX_ACX_H__ */
This diff is collapsed.
...@@ -27,31 +27,26 @@ ...@@ -27,31 +27,26 @@
#include "wl12xx.h" #include "wl12xx.h"
struct acx_header;
int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len); int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len);
int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer); int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer);
int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len, int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 id, void *buf, size_t len);
void *answer); int wl12xx_cmd_configure(struct wl12xx *wl, u16 id, void *buf, size_t len);
int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len);
int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity, int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity,
void *bitmap, u16 bitmap_len, u8 bitmap_control); void *bitmap, u16 bitmap_len, u8 bitmap_control);
int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable); int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, bool enable);
int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval, int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval,
u16 beacon_interval, u8 wait); u16 beacon_interval, u8 wait);
int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode); int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode);
int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer); int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, void *answer,
size_t len);
int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id, int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id,
void *buf, size_t buf_len); void *buf, size_t buf_len);
/* unit ms */ /* unit ms */
#define WL12XX_COMMAND_TIMEOUT 2000 #define WL12XX_COMMAND_TIMEOUT 2000
#define WL12XX_MAX_TEMPLATE_SIZE 300
struct wl12xx_cmd_packet_template {
__le16 size;
u8 template[WL12XX_MAX_TEMPLATE_SIZE];
} __attribute__ ((packed));
enum wl12xx_commands { enum wl12xx_commands {
CMD_RESET = 0, CMD_RESET = 0,
CMD_INTERROGATE = 1, /*use this to read information elements*/ CMD_INTERROGATE = 1, /*use this to read information elements*/
...@@ -100,9 +95,15 @@ enum wl12xx_commands { ...@@ -100,9 +95,15 @@ enum wl12xx_commands {
#define MAX_CMD_PARAMS 572 #define MAX_CMD_PARAMS 572
struct wl12xx_command { struct wl12xx_cmd_header {
u16 id; u16 id;
u16 status; u16 status;
/* payload */
u8 data[0];
} __attribute__ ((packed));
struct wl12xx_command {
struct wl12xx_cmd_header header;
u8 parameters[MAX_CMD_PARAMS]; u8 parameters[MAX_CMD_PARAMS];
}; };
...@@ -144,6 +145,8 @@ enum { ...@@ -144,6 +145,8 @@ enum {
#define MAX_READ_SIZE 256 #define MAX_READ_SIZE 256
struct cmd_read_write_memory { struct cmd_read_write_memory {
struct wl12xx_cmd_header header;
/* The address of the memory to read from or write to.*/ /* The address of the memory to read from or write to.*/
u32 addr; u32 addr;
...@@ -211,6 +214,8 @@ struct basic_scan_channel_parameters { ...@@ -211,6 +214,8 @@ struct basic_scan_channel_parameters {
#define SCAN_MAX_NUM_OF_CHANNELS 16 #define SCAN_MAX_NUM_OF_CHANNELS 16
struct cmd_scan { struct cmd_scan {
struct wl12xx_cmd_header header;
struct basic_scan_parameters params; struct basic_scan_parameters params;
struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS]; struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
} __attribute__ ((packed)); } __attribute__ ((packed));
...@@ -227,6 +232,8 @@ enum { ...@@ -227,6 +232,8 @@ enum {
struct cmd_join { struct cmd_join {
struct wl12xx_cmd_header header;
u32 bssid_lsb; u32 bssid_lsb;
u16 bssid_msb; u16 bssid_msb;
u16 beacon_interval; /* in TBTTs */ u16 beacon_interval; /* in TBTTs */
...@@ -261,5 +268,140 @@ struct cmd_join { ...@@ -261,5 +268,140 @@ struct cmd_join {
u8 reserved; u8 reserved;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct cmd_enabledisable_path {
struct wl12xx_cmd_header header;
u8 channel;
u8 padding[3];
} __attribute__ ((packed));
#define WL12XX_MAX_TEMPLATE_SIZE 300
struct wl12xx_cmd_packet_template {
struct wl12xx_cmd_header header;
__le16 size;
u8 data[0];
} __attribute__ ((packed));
#define TIM_ELE_ID 5
#define PARTIAL_VBM_MAX 251
struct wl12xx_tim {
u8 identity;
u8 length;
u8 dtim_count;
u8 dtim_period;
u8 bitmap_ctrl;
u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
} __attribute__ ((packed));
/* Virtual Bit Map update */
struct wl12xx_cmd_vbm_update {
struct wl12xx_cmd_header header;
__le16 len;
u8 padding[2];
struct wl12xx_tim tim;
} __attribute__ ((packed));
enum wl12xx_cmd_ps_mode {
STATION_ACTIVE_MODE,
STATION_POWER_SAVE_MODE
};
struct wl12xx_cmd_ps_params {
struct wl12xx_cmd_header header;
u8 ps_mode; /* STATION_* */
u8 send_null_data; /* Do we have to send NULL data packet ? */
u8 retries; /* Number of retires for the initial NULL data packet */
/*
* TUs during which the target stays awake after switching
* to power save mode.
*/
u8 hang_over_period;
u16 null_data_rate;
u8 pad[2];
} __attribute__ ((packed));
struct wl12xx_cmd_trigger_scan_to {
struct wl12xx_cmd_header header;
u32 timeout;
};
/* HW encryption keys */
#define NUM_ACCESS_CATEGORIES_COPY 4
#define MAX_KEY_SIZE 32
/* When set, disable HW encryption */
#define DF_ENCRYPTION_DISABLE 0x01
/* When set, disable HW decryption */
#define DF_SNIFF_MODE_ENABLE 0x80
enum wl12xx_cmd_key_action {
KEY_ADD_OR_REPLACE = 1,
KEY_REMOVE = 2,
KEY_SET_ID = 3,
MAX_KEY_ACTION = 0xffff,
};
enum wl12xx_cmd_key_type {
KEY_WEP_DEFAULT = 0,
KEY_WEP_ADDR = 1,
KEY_AES_GROUP = 4,
KEY_AES_PAIRWISE = 5,
KEY_WEP_GROUP = 6,
KEY_TKIP_MIC_GROUP = 10,
KEY_TKIP_MIC_PAIRWISE = 11,
};
/*
*
* key_type_e key size key format
* ---------- --------- ----------
* 0x00 5, 13, 29 Key data
* 0x01 5, 13, 29 Key data
* 0x04 16 16 bytes of key data
* 0x05 16 16 bytes of key data
* 0x0a 32 16 bytes of TKIP key data
* 8 bytes of RX MIC key data
* 8 bytes of TX MIC key data
* 0x0b 32 16 bytes of TKIP key data
* 8 bytes of RX MIC key data
* 8 bytes of TX MIC key data
*
*/
struct wl12xx_cmd_set_keys {
struct wl12xx_cmd_header header;
/* Ignored for default WEP key */
u8 addr[ETH_ALEN];
/* key_action_e */
u16 key_action;
u16 reserved_1;
/* key size in bytes */
u8 key_size;
/* key_type_e */
u8 key_type;
u8 ssid_profile;
/*
* TKIP, AES: frame's key id field.
* For WEP default key: key id;
*/
u8 id;
u8 reserved_2[6];
u8 key[MAX_KEY_SIZE];
u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
} __attribute__ ((packed));
#endif /* __WL12XX_CMD_H__ */ #endif /* __WL12XX_CMD_H__ */
...@@ -618,7 +618,8 @@ static void wl12xx_op_configure_filter(struct ieee80211_hw *hw, ...@@ -618,7 +618,8 @@ static void wl12xx_op_configure_filter(struct ieee80211_hw *hw,
} }
/* HW encryption */ /* HW encryption */
static int wl12xx_set_key_type(struct wl12xx *wl, struct acx_set_key *key, static int wl12xx_set_key_type(struct wl12xx *wl,
struct wl12xx_cmd_set_keys *key,
enum set_key_cmd cmd, enum set_key_cmd cmd,
struct ieee80211_key_conf *mac80211_key, struct ieee80211_key_conf *mac80211_key,
const u8 *addr) const u8 *addr)
...@@ -661,7 +662,7 @@ static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -661,7 +662,7 @@ static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct wl12xx *wl = hw->priv; struct wl12xx *wl = hw->priv;
struct acx_set_key wl_key; struct wl12xx_cmd_set_keys *wl_cmd;
const u8 *addr; const u8 *addr;
int ret; int ret;
...@@ -670,7 +671,11 @@ static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -670,7 +671,11 @@ static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
wl12xx_debug(DEBUG_MAC80211, "mac80211 set key"); wl12xx_debug(DEBUG_MAC80211, "mac80211 set key");
memset(&wl_key, 0, sizeof(wl_key)); wl_cmd = kzalloc(sizeof(*wl_cmd), GFP_KERNEL);
if (!wl_cmd) {
ret = -ENOMEM;
goto out;
}
addr = sta ? sta->addr : bcast_addr; addr = sta ? sta->addr : bcast_addr;
...@@ -680,59 +685,69 @@ static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -680,59 +685,69 @@ static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
key->alg, key->keyidx, key->keylen, key->flags); key->alg, key->keyidx, key->keylen, key->flags);
wl12xx_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen); wl12xx_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen);
if (is_zero_ether_addr(addr)) {
/* We dont support TX only encryption */
ret = -EOPNOTSUPP;
goto out;
}
mutex_lock(&wl->mutex); mutex_lock(&wl->mutex);
switch (cmd) { switch (cmd) {
case SET_KEY: case SET_KEY:
wl_key.key_action = KEY_ADD_OR_REPLACE; wl_cmd->key_action = KEY_ADD_OR_REPLACE;
break; break;
case DISABLE_KEY: case DISABLE_KEY:
wl_key.key_action = KEY_REMOVE; wl_cmd->key_action = KEY_REMOVE;
break; break;
default: default:
wl12xx_error("Unsupported key cmd 0x%x", cmd); wl12xx_error("Unsupported key cmd 0x%x", cmd);
break; break;
} }
ret = wl12xx_set_key_type(wl, &wl_key, cmd, key, addr); ret = wl12xx_set_key_type(wl, wl_cmd, cmd, key, addr);
if (ret < 0) { if (ret < 0) {
wl12xx_error("Set KEY type failed"); wl12xx_error("Set KEY type failed");
goto out; goto out_unlock;
} }
if (wl_key.key_type != KEY_WEP_DEFAULT) if (wl_cmd->key_type != KEY_WEP_DEFAULT)
memcpy(wl_key.addr, addr, ETH_ALEN); memcpy(wl_cmd->addr, addr, ETH_ALEN);
if ((wl_key.key_type == KEY_TKIP_MIC_GROUP) || if ((wl_cmd->key_type == KEY_TKIP_MIC_GROUP) ||
(wl_key.key_type == KEY_TKIP_MIC_PAIRWISE)) { (wl_cmd->key_type == KEY_TKIP_MIC_PAIRWISE)) {
/* /*
* We get the key in the following form: * We get the key in the following form:
* TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes) * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes)
* but the target is expecting: * but the target is expecting:
* TKIP - RX MIC - TX MIC * TKIP - RX MIC - TX MIC
*/ */
memcpy(wl_key.key, key->key, 16); memcpy(wl_cmd->key, key->key, 16);
memcpy(wl_key.key + 16, key->key + 24, 8); memcpy(wl_cmd->key + 16, key->key + 24, 8);
memcpy(wl_key.key + 24, key->key + 16, 8); memcpy(wl_cmd->key + 24, key->key + 16, 8);
} else { } else {
memcpy(wl_key.key, key->key, key->keylen); memcpy(wl_cmd->key, key->key, key->keylen);
} }
wl_key.key_size = key->keylen; wl_cmd->key_size = key->keylen;
wl_key.id = key->keyidx; wl_cmd->id = key->keyidx;
wl_key.ssid_profile = 0; wl_cmd->ssid_profile = 0;
wl12xx_dump(DEBUG_CRYPT, "TARGET KEY: ", &wl_key, sizeof(wl_key)); wl12xx_dump(DEBUG_CRYPT, "TARGET KEY: ", wl_cmd, sizeof(*wl_cmd));
if (wl12xx_cmd_send(wl, CMD_SET_KEYS, &wl_key, sizeof(wl_key)) < 0) { ret = wl12xx_cmd_send(wl, CMD_SET_KEYS, wl_cmd, sizeof(*wl_cmd));
wl12xx_error("Set KEY failed"); if (ret < 0) {
ret = -EOPNOTSUPP; wl12xx_warning("could not set keys");
goto out; goto out_unlock;
} }
out: out_unlock:
mutex_unlock(&wl->mutex); mutex_unlock(&wl->mutex);
out:
kfree(wl_cmd);
return ret; return ret;
} }
...@@ -812,11 +827,10 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len, ...@@ -812,11 +827,10 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len,
u8 active_scan, u8 high_prio, u8 num_channels, u8 active_scan, u8 high_prio, u8 num_channels,
u8 probe_requests) u8 probe_requests)
{ {
struct wl12xx_cmd_trigger_scan_to *trigger = NULL;
struct cmd_scan *params = NULL;
int i, ret; int i, ret;
u32 split_scan = 0;
u16 scan_options = 0; u16 scan_options = 0;
struct cmd_scan *params;
struct wl12xx_command *cmd_answer;
if (wl->scanning) if (wl->scanning)
return -EINVAL; return -EINVAL;
...@@ -870,10 +884,16 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len, ...@@ -870,10 +884,16 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len,
goto out; goto out;
} }
ret = wl12xx_cmd_send(wl, CMD_TRIGGER_SCAN_TO, &split_scan, trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
sizeof(u32)); if (!trigger)
goto out;
trigger->timeout = 0;
ret = wl12xx_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
sizeof(*trigger));
if (ret < 0) { if (ret < 0) {
wl12xx_error("Split SCAN failed"); wl12xx_error("trigger scan to failed for hw scan");
goto out; goto out;
} }
...@@ -887,10 +907,9 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len, ...@@ -887,10 +907,9 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len,
wl12xx_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params)); wl12xx_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params));
cmd_answer = (struct wl12xx_command *) params; if (params->header.status != CMD_STATUS_SUCCESS) {
if (cmd_answer->status != CMD_STATUS_SUCCESS) {
wl12xx_error("TEST command answer error: %d", wl12xx_error("TEST command answer error: %d",
cmd_answer->status); params->header.status);
wl->scanning = false; wl->scanning = false;
ret = -EIO; ret = -EIO;
goto out; goto out;
...@@ -942,7 +961,7 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw, ...@@ -942,7 +961,7 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *bss_conf, struct ieee80211_bss_conf *bss_conf,
u32 changed) u32 changed)
{ {
enum acx_ps_mode mode; enum wl12xx_cmd_ps_mode mode;
struct wl12xx *wl = hw->priv; struct wl12xx *wl = hw->priv;
struct sk_buff *beacon; struct sk_buff *beacon;
int ret; int ret;
......
...@@ -114,7 +114,7 @@ static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable) ...@@ -114,7 +114,7 @@ static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable)
return 0; return 0;
} }
int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode) int wl12xx_ps_set_mode(struct wl12xx *wl, enum wl12xx_cmd_ps_mode mode)
{ {
int ret; int ret;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "wl12xx.h" #include "wl12xx.h"
#include "acx.h" #include "acx.h"
int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode); int wl12xx_ps_set_mode(struct wl12xx *wl, enum wl12xx_cmd_ps_mode mode);
void wl12xx_ps_elp_sleep(struct wl12xx *wl); void wl12xx_ps_elp_sleep(struct wl12xx *wl);
int wl12xx_ps_elp_wakeup(struct wl12xx *wl); int wl12xx_ps_elp_wakeup(struct wl12xx *wl);
......
...@@ -48,6 +48,9 @@ static void wl12xx_rx_status(struct wl12xx *wl, ...@@ -48,6 +48,9 @@ static void wl12xx_rx_status(struct wl12xx *wl,
struct ieee80211_rx_status *status, struct ieee80211_rx_status *status,
u8 beacon) u8 beacon)
{ {
u64 mactime;
int ret;
memset(status, 0, sizeof(struct ieee80211_rx_status)); memset(status, 0, sizeof(struct ieee80211_rx_status));
status->band = IEEE80211_BAND_2GHZ; status->band = IEEE80211_BAND_2GHZ;
...@@ -62,27 +65,9 @@ static void wl12xx_rx_status(struct wl12xx *wl, ...@@ -62,27 +65,9 @@ static void wl12xx_rx_status(struct wl12xx *wl,
* this one must be atomic, while our SPI routines can sleep. * this one must be atomic, while our SPI routines can sleep.
*/ */
if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) { if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) {
u64 mactime; ret = wl12xx_acx_tsf_info(wl, &mactime);
int ret; if (ret == 0)
struct wl12xx_command cmd; status->mactime = mactime;
struct acx_tsf_info *tsf_info;
memset(&cmd, 0, sizeof(cmd));
ret = wl12xx_cmd_interrogate(wl, ACX_TSF_INFO,
sizeof(struct acx_tsf_info),
&cmd);
if (ret < 0) {
wl12xx_warning("ACX_FW_REV interrogate failed");
return;
}
tsf_info = (struct acx_tsf_info *)&(cmd.parameters);
mactime = tsf_info->current_tsf_lsb |
(tsf_info->current_tsf_msb << 31);
status->mactime = mactime;
} }
status->signal = desc->rssi; status->signal = desc->rssi;
......
...@@ -297,45 +297,48 @@ static int wl1251_boot(struct wl12xx *wl) ...@@ -297,45 +297,48 @@ static int wl1251_boot(struct wl12xx *wl)
static int wl1251_mem_cfg(struct wl12xx *wl) static int wl1251_mem_cfg(struct wl12xx *wl)
{ {
struct wl1251_acx_config_memory mem_conf; struct wl1251_acx_config_memory *mem_conf;
int ret, i; int ret, i;
wl12xx_debug(DEBUG_ACX, "wl1251 mem cfg"); wl12xx_debug(DEBUG_ACX, "wl1251 mem cfg");
mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
if (!mem_conf) {
ret = -ENOMEM;
goto out;
}
/* memory config */ /* memory config */
mem_conf.mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS); mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS);
mem_conf.mem_config.rx_mem_block_num = 35; mem_conf->mem_config.rx_mem_block_num = 35;
mem_conf.mem_config.tx_min_mem_block_num = 64; mem_conf->mem_config.tx_min_mem_block_num = 64;
mem_conf.mem_config.num_tx_queues = MAX_TX_QUEUES; mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES;
mem_conf.mem_config.host_if_options = HOSTIF_PKT_RING; mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING;
mem_conf.mem_config.num_ssid_profiles = 1; mem_conf->mem_config.num_ssid_profiles = 1;
mem_conf.mem_config.debug_buffer_size = mem_conf->mem_config.debug_buffer_size =
cpu_to_le16(TRACE_BUFFER_MAX_SIZE); cpu_to_le16(TRACE_BUFFER_MAX_SIZE);
/* RX queue config */ /* RX queue config */
mem_conf.rx_queue_config.dma_address = 0; mem_conf->rx_queue_config.dma_address = 0;
mem_conf.rx_queue_config.num_descs = ACX_RX_DESC_DEF; mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF;
mem_conf.rx_queue_config.priority = DEFAULT_RXQ_PRIORITY; mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY;
mem_conf.rx_queue_config.type = DEFAULT_RXQ_TYPE; mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE;
/* TX queue config */ /* TX queue config */
for (i = 0; i < MAX_TX_QUEUES; i++) { for (i = 0; i < MAX_TX_QUEUES; i++) {
mem_conf.tx_queue_config[i].num_descs = ACX_TX_DESC_DEF; mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF;
mem_conf.tx_queue_config[i].attributes = i; mem_conf->tx_queue_config[i].attributes = i;
} }
mem_conf.header.id = ACX_MEM_CFG; ret = wl12xx_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
mem_conf.header.len = sizeof(struct wl1251_acx_config_memory) - sizeof(*mem_conf));
sizeof(struct acx_header); if (ret < 0) {
mem_conf.header.len -=
(MAX_TX_QUEUE_CONFIGS - mem_conf.mem_config.num_tx_queues) *
sizeof(struct wl1251_acx_tx_queue_config);
ret = wl12xx_cmd_configure(wl, &mem_conf,
sizeof(struct wl1251_acx_config_memory));
if (ret < 0)
wl12xx_warning("wl1251 mem config failed: %d", ret); wl12xx_warning("wl1251 mem config failed: %d", ret);
goto out;
}
out:
kfree(mem_conf);
return ret; return ret;
} }
...@@ -529,28 +532,33 @@ static int wl1251_hw_init_txq_fill(u8 qid, ...@@ -529,28 +532,33 @@ static int wl1251_hw_init_txq_fill(u8 qid,
static int wl1251_hw_init_tx_queue_config(struct wl12xx *wl) static int wl1251_hw_init_tx_queue_config(struct wl12xx *wl)
{ {
struct acx_tx_queue_qos_config config; struct acx_tx_queue_qos_config *config;
struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map; struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map;
int ret, i; int ret, i;
wl12xx_debug(DEBUG_ACX, "acx tx queue config"); wl12xx_debug(DEBUG_ACX, "acx tx queue config");
config.header.id = ACX_TX_QUEUE_CFG; config = kzalloc(sizeof(*config), GFP_KERNEL);
config.header.len = sizeof(struct acx_tx_queue_qos_config) - if (!config) {
sizeof(struct acx_header); ret = -ENOMEM;
goto out;
}
for (i = 0; i < MAX_NUM_OF_AC; i++) { for (i = 0; i < MAX_NUM_OF_AC; i++) {
ret = wl1251_hw_init_txq_fill(i, &config, ret = wl1251_hw_init_txq_fill(i, config,
wl_mem_map->num_tx_mem_blocks); wl_mem_map->num_tx_mem_blocks);
if (ret < 0) if (ret < 0)
return ret; goto out;
ret = wl12xx_cmd_configure(wl, &config, sizeof(config)); ret = wl12xx_cmd_configure(wl, ACX_TX_QUEUE_CFG,
config, sizeof(*config));
if (ret < 0) if (ret < 0)
return ret; goto out;
} }
return 0; out:
kfree(config);
return ret;
} }
static int wl1251_hw_init_data_path_config(struct wl12xx *wl) static int wl1251_hw_init_data_path_config(struct wl12xx *wl)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment