#include "acx.h"
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/crc7.h>
#include "wl1251.h"
#include "reg.h"
#include "cmd.h"
#include "ps.h"
int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod,
u8 mgt_rate, u8 mgt_mod)
{
struct acx_fw_gen_frame_rates *rates;
int ret;
wl1251_debug(DEBUG_ACX, "acx frame rates");
rates = kzalloc(sizeof(*rates), GFP_KERNEL);
if (!rates) {
ret = -ENOMEM;
goto out;
}
rates->tx_ctrl_frame_rate = ctrl_rate;
rates->tx_ctrl_frame_mod = ctrl_mod;
rates->tx_mgt_frame_rate = mgt_rate;
rates->tx_mgt_frame_mod = mgt_mod;
ret = wl1251_cmd_configure(wl, ACX_FW_GEN_FRAME_RATES,
rates, sizeof(*rates));
if (ret < 0) {
wl1251_error("Failed to set FW rates and modulation");
goto out;
}
out:
kfree(rates);
return ret;
}
int wl1251_acx_station_id(struct wl1251 *wl)
{
struct acx_dot11_station_id *mac;
int ret, i;
wl1251_debug(DEBUG_ACX, "acx dot11_station_id");
mac = kzalloc(sizeof(*mac), GFP_KERNEL);
if (!mac) {
ret = -ENOMEM;
goto out;
}
for (i = 0; i < ETH_ALEN; i++)
mac->mac[i] = wl->mac_addr[ETH_ALEN - 1 - i];
ret = wl1251_cmd_configure(wl, DOT11_STATION_ID, mac, sizeof(*mac));
if (ret < 0)
goto out;
out:
kfree(mac);
return ret;
}
int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id)
{
struct acx_dot11_default_key *default_key;
int ret;
wl1251_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id);
default_key = kzalloc(sizeof(*default_key), GFP_KERNEL);
if (!default_key) {
ret = -ENOMEM;
goto out;
}
default_key->id = key_id;
ret = wl1251_cmd_configure(wl, DOT11_DEFAULT_KEY,
default_key, sizeof(*default_key));
if (ret < 0) {
wl1251_error("Couldn't set default key");
goto out;
}
wl->default_key = key_id;
out:
kfree(default_key);
return ret;
}
int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event,
u8 listen_interval)
{
struct acx_wake_up_condition *wake_up;
int ret;
wl1251_debug(DEBUG_ACX, "acx wake up conditions");
wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
if (!wake_up) {
ret = -ENOMEM;
goto out;
}
wake_up->wake_up_event = wake_up_event;
wake_up->listen_interval = listen_interval;
ret = wl1251_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
wake_up, sizeof(*wake_up));
if (ret < 0) {
wl1251_warning("could not set wake up conditions: %d", ret);
goto out;
}
out:
kfree(wake_up);
return ret;
}
int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth)
{
struct acx_sleep_auth *auth;
int ret;
wl1251_debug(DEBUG_ACX, "acx sleep auth");
auth = kzalloc(sizeof(*auth), GFP_KERNEL);
if (!auth) {
ret = -ENOMEM;
goto out;
}
auth->sleep_auth = sleep_auth;
ret = wl1251_cmd_configure