1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
290921014SLuciano Coelho #include "acx.h"
390921014SLuciano Coelho
490921014SLuciano Coelho #include <linux/module.h>
590921014SLuciano Coelho #include <linux/slab.h>
690921014SLuciano Coelho
790921014SLuciano Coelho #include "wl1251.h"
890921014SLuciano Coelho #include "reg.h"
990921014SLuciano Coelho #include "cmd.h"
1090921014SLuciano Coelho #include "ps.h"
1190921014SLuciano Coelho
wl1251_acx_frame_rates(struct wl1251 * wl,u8 ctrl_rate,u8 ctrl_mod,u8 mgt_rate,u8 mgt_mod)1290921014SLuciano Coelho int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod,
1390921014SLuciano Coelho u8 mgt_rate, u8 mgt_mod)
1490921014SLuciano Coelho {
1590921014SLuciano Coelho struct acx_fw_gen_frame_rates *rates;
1690921014SLuciano Coelho int ret;
1790921014SLuciano Coelho
1890921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx frame rates");
1990921014SLuciano Coelho
2090921014SLuciano Coelho rates = kzalloc(sizeof(*rates), GFP_KERNEL);
2160ce473eSJing Wang if (!rates)
2260ce473eSJing Wang return -ENOMEM;
2390921014SLuciano Coelho
2490921014SLuciano Coelho rates->tx_ctrl_frame_rate = ctrl_rate;
2590921014SLuciano Coelho rates->tx_ctrl_frame_mod = ctrl_mod;
2690921014SLuciano Coelho rates->tx_mgt_frame_rate = mgt_rate;
2790921014SLuciano Coelho rates->tx_mgt_frame_mod = mgt_mod;
2890921014SLuciano Coelho
2990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_FW_GEN_FRAME_RATES,
3090921014SLuciano Coelho rates, sizeof(*rates));
3190921014SLuciano Coelho if (ret < 0) {
3290921014SLuciano Coelho wl1251_error("Failed to set FW rates and modulation");
3390921014SLuciano Coelho goto out;
3490921014SLuciano Coelho }
3590921014SLuciano Coelho
3690921014SLuciano Coelho out:
3790921014SLuciano Coelho kfree(rates);
3890921014SLuciano Coelho return ret;
3990921014SLuciano Coelho }
4090921014SLuciano Coelho
4190921014SLuciano Coelho
wl1251_acx_station_id(struct wl1251 * wl)4290921014SLuciano Coelho int wl1251_acx_station_id(struct wl1251 *wl)
4390921014SLuciano Coelho {
4490921014SLuciano Coelho struct acx_dot11_station_id *mac;
4590921014SLuciano Coelho int ret, i;
4690921014SLuciano Coelho
4790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx dot11_station_id");
4890921014SLuciano Coelho
4990921014SLuciano Coelho mac = kzalloc(sizeof(*mac), GFP_KERNEL);
5060ce473eSJing Wang if (!mac)
5160ce473eSJing Wang return -ENOMEM;
5290921014SLuciano Coelho
5390921014SLuciano Coelho for (i = 0; i < ETH_ALEN; i++)
5490921014SLuciano Coelho mac->mac[i] = wl->mac_addr[ETH_ALEN - 1 - i];
5590921014SLuciano Coelho
5690921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_STATION_ID, mac, sizeof(*mac));
5790921014SLuciano Coelho
5890921014SLuciano Coelho kfree(mac);
5990921014SLuciano Coelho return ret;
6090921014SLuciano Coelho }
6190921014SLuciano Coelho
wl1251_acx_default_key(struct wl1251 * wl,u8 key_id)6290921014SLuciano Coelho int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id)
6390921014SLuciano Coelho {
6490921014SLuciano Coelho struct acx_dot11_default_key *default_key;
6590921014SLuciano Coelho int ret;
6690921014SLuciano Coelho
6790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id);
6890921014SLuciano Coelho
6990921014SLuciano Coelho default_key = kzalloc(sizeof(*default_key), GFP_KERNEL);
7060ce473eSJing Wang if (!default_key)
7160ce473eSJing Wang return -ENOMEM;
7290921014SLuciano Coelho
7390921014SLuciano Coelho default_key->id = key_id;
7490921014SLuciano Coelho
7590921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_DEFAULT_KEY,
7690921014SLuciano Coelho default_key, sizeof(*default_key));
7790921014SLuciano Coelho if (ret < 0) {
7890921014SLuciano Coelho wl1251_error("Couldn't set default key");
7990921014SLuciano Coelho goto out;
8090921014SLuciano Coelho }
8190921014SLuciano Coelho
8290921014SLuciano Coelho wl->default_key = key_id;
8390921014SLuciano Coelho
8490921014SLuciano Coelho out:
8590921014SLuciano Coelho kfree(default_key);
8690921014SLuciano Coelho return ret;
8790921014SLuciano Coelho }
8890921014SLuciano Coelho
wl1251_acx_wake_up_conditions(struct wl1251 * wl,u8 wake_up_event,u8 listen_interval)8990921014SLuciano Coelho int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event,
9090921014SLuciano Coelho u8 listen_interval)
9190921014SLuciano Coelho {
9290921014SLuciano Coelho struct acx_wake_up_condition *wake_up;
9390921014SLuciano Coelho int ret;
9490921014SLuciano Coelho
9590921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx wake up conditions");
9690921014SLuciano Coelho
9790921014SLuciano Coelho wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL);
9860ce473eSJing Wang if (!wake_up)
9960ce473eSJing Wang return -ENOMEM;
10090921014SLuciano Coelho
10190921014SLuciano Coelho wake_up->wake_up_event = wake_up_event;
10290921014SLuciano Coelho wake_up->listen_interval = listen_interval;
10390921014SLuciano Coelho
10490921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS,
10590921014SLuciano Coelho wake_up, sizeof(*wake_up));
10690921014SLuciano Coelho if (ret < 0) {
10790921014SLuciano Coelho wl1251_warning("could not set wake up conditions: %d", ret);
10890921014SLuciano Coelho goto out;
10990921014SLuciano Coelho }
11090921014SLuciano Coelho
11190921014SLuciano Coelho out:
11290921014SLuciano Coelho kfree(wake_up);
11390921014SLuciano Coelho return ret;
11490921014SLuciano Coelho }
11590921014SLuciano Coelho
wl1251_acx_sleep_auth(struct wl1251 * wl,u8 sleep_auth)11690921014SLuciano Coelho int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth)
11790921014SLuciano Coelho {
11890921014SLuciano Coelho struct acx_sleep_auth *auth;
11990921014SLuciano Coelho int ret;
12090921014SLuciano Coelho
12190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx sleep auth");
12290921014SLuciano Coelho
12390921014SLuciano Coelho auth = kzalloc(sizeof(*auth), GFP_KERNEL);
12460ce473eSJing Wang if (!auth)
12560ce473eSJing Wang return -ENOMEM;
12690921014SLuciano Coelho
12790921014SLuciano Coelho auth->sleep_auth = sleep_auth;
12890921014SLuciano Coelho
12990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
13090921014SLuciano Coelho
13190921014SLuciano Coelho kfree(auth);
13290921014SLuciano Coelho return ret;
13390921014SLuciano Coelho }
13490921014SLuciano Coelho
wl1251_acx_fw_version(struct wl1251 * wl,char * buf,size_t len)13590921014SLuciano Coelho int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len)
13690921014SLuciano Coelho {
13790921014SLuciano Coelho struct acx_revision *rev;
13890921014SLuciano Coelho int ret;
13990921014SLuciano Coelho
14090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx fw rev");
14190921014SLuciano Coelho
14290921014SLuciano Coelho rev = kzalloc(sizeof(*rev), GFP_KERNEL);
14360ce473eSJing Wang if (!rev)
14460ce473eSJing Wang return -ENOMEM;
14590921014SLuciano Coelho
14690921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev));
14790921014SLuciano Coelho if (ret < 0) {
14890921014SLuciano Coelho wl1251_warning("ACX_FW_REV interrogate failed");
14990921014SLuciano Coelho goto out;
15090921014SLuciano Coelho }
15190921014SLuciano Coelho
15290921014SLuciano Coelho /* be careful with the buffer sizes */
15390921014SLuciano Coelho strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
15490921014SLuciano Coelho
15590921014SLuciano Coelho /*
15690921014SLuciano Coelho * if the firmware version string is exactly
15790921014SLuciano Coelho * sizeof(rev->fw_version) long or fw_len is less than
15890921014SLuciano Coelho * sizeof(rev->fw_version) it won't be null terminated
15990921014SLuciano Coelho */
16090921014SLuciano Coelho buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
16190921014SLuciano Coelho
16290921014SLuciano Coelho out:
16390921014SLuciano Coelho kfree(rev);
16490921014SLuciano Coelho return ret;
16590921014SLuciano Coelho }
16690921014SLuciano Coelho
wl1251_acx_tx_power(struct wl1251 * wl,int power)16790921014SLuciano Coelho int wl1251_acx_tx_power(struct wl1251 *wl, int power)
16890921014SLuciano Coelho {
16990921014SLuciano Coelho struct acx_current_tx_power *acx;
17090921014SLuciano Coelho int ret;
17190921014SLuciano Coelho
17290921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr");
17390921014SLuciano Coelho
17490921014SLuciano Coelho if (power < 0 || power > 25)
17590921014SLuciano Coelho return -EINVAL;
17690921014SLuciano Coelho
17790921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
17860ce473eSJing Wang if (!acx)
17960ce473eSJing Wang return -ENOMEM;
18090921014SLuciano Coelho
18190921014SLuciano Coelho acx->current_tx_power = power * 10;
18290921014SLuciano Coelho
18390921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
18490921014SLuciano Coelho if (ret < 0) {
18590921014SLuciano Coelho wl1251_warning("configure of tx power failed: %d", ret);
18690921014SLuciano Coelho goto out;
18790921014SLuciano Coelho }
18890921014SLuciano Coelho
18990921014SLuciano Coelho out:
19090921014SLuciano Coelho kfree(acx);
19190921014SLuciano Coelho return ret;
19290921014SLuciano Coelho }
19390921014SLuciano Coelho
wl1251_acx_feature_cfg(struct wl1251 * wl,u32 data_flow_options)1944d09b537SDavid Gnedt int wl1251_acx_feature_cfg(struct wl1251 *wl, u32 data_flow_options)
19590921014SLuciano Coelho {
19690921014SLuciano Coelho struct acx_feature_config *feature;
19790921014SLuciano Coelho int ret;
19890921014SLuciano Coelho
19990921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx feature cfg");
20090921014SLuciano Coelho
20190921014SLuciano Coelho feature = kzalloc(sizeof(*feature), GFP_KERNEL);
20260ce473eSJing Wang if (!feature)
20360ce473eSJing Wang return -ENOMEM;
20490921014SLuciano Coelho
2054d09b537SDavid Gnedt /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE can be set */
2064d09b537SDavid Gnedt feature->data_flow_options = data_flow_options;
20790921014SLuciano Coelho feature->options = 0;
20890921014SLuciano Coelho
20990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG,
21090921014SLuciano Coelho feature, sizeof(*feature));
21190921014SLuciano Coelho if (ret < 0) {
21290921014SLuciano Coelho wl1251_error("Couldn't set HW encryption");
21390921014SLuciano Coelho goto out;
21490921014SLuciano Coelho }
21590921014SLuciano Coelho
21690921014SLuciano Coelho out:
21790921014SLuciano Coelho kfree(feature);
21890921014SLuciano Coelho return ret;
21990921014SLuciano Coelho }
22090921014SLuciano Coelho
wl1251_acx_mem_map(struct wl1251 * wl,struct acx_header * mem_map,size_t len)22190921014SLuciano Coelho int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map,
22290921014SLuciano Coelho size_t len)
22390921014SLuciano Coelho {
22490921014SLuciano Coelho int ret;
22590921014SLuciano Coelho
22690921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx mem map");
22790921014SLuciano Coelho
22890921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len);
22990921014SLuciano Coelho if (ret < 0)
23090921014SLuciano Coelho return ret;
23190921014SLuciano Coelho
23290921014SLuciano Coelho return 0;
23390921014SLuciano Coelho }
23490921014SLuciano Coelho
wl1251_acx_data_path_params(struct wl1251 * wl,struct acx_data_path_params_resp * resp)23590921014SLuciano Coelho int wl1251_acx_data_path_params(struct wl1251 *wl,
23690921014SLuciano Coelho struct acx_data_path_params_resp *resp)
23790921014SLuciano Coelho {
23890921014SLuciano Coelho struct acx_data_path_params *params;
23990921014SLuciano Coelho int ret;
24090921014SLuciano Coelho
24190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx data path params");
24290921014SLuciano Coelho
24390921014SLuciano Coelho params = kzalloc(sizeof(*params), GFP_KERNEL);
24460ce473eSJing Wang if (!params)
24560ce473eSJing Wang return -ENOMEM;
24690921014SLuciano Coelho
24790921014SLuciano Coelho params->rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE;
24890921014SLuciano Coelho params->tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE;
24990921014SLuciano Coelho
25090921014SLuciano Coelho params->rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM;
25190921014SLuciano Coelho params->tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM;
25290921014SLuciano Coelho
25390921014SLuciano Coelho params->tx_complete_threshold = 1;
25490921014SLuciano Coelho
25590921014SLuciano Coelho params->tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE;
25690921014SLuciano Coelho
25790921014SLuciano Coelho params->tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT;
25890921014SLuciano Coelho
25990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_DATA_PATH_PARAMS,
26090921014SLuciano Coelho params, sizeof(*params));
26190921014SLuciano Coelho if (ret < 0)
26290921014SLuciano Coelho goto out;
26390921014SLuciano Coelho
26490921014SLuciano Coelho /* FIXME: shouldn't this be ACX_DATA_PATH_RESP_PARAMS? */
26590921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS,
26690921014SLuciano Coelho resp, sizeof(*resp));
26790921014SLuciano Coelho
26890921014SLuciano Coelho if (ret < 0) {
26990921014SLuciano Coelho wl1251_warning("failed to read data path parameters: %d", ret);
27090921014SLuciano Coelho goto out;
27190921014SLuciano Coelho } else if (resp->header.cmd.status != CMD_STATUS_SUCCESS) {
27290921014SLuciano Coelho wl1251_warning("data path parameter acx status failed");
27390921014SLuciano Coelho ret = -EIO;
27490921014SLuciano Coelho goto out;
27590921014SLuciano Coelho }
27690921014SLuciano Coelho
27790921014SLuciano Coelho out:
27890921014SLuciano Coelho kfree(params);
27990921014SLuciano Coelho return ret;
28090921014SLuciano Coelho }
28190921014SLuciano Coelho
wl1251_acx_rx_msdu_life_time(struct wl1251 * wl,u32 life_time)28290921014SLuciano Coelho int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time)
28390921014SLuciano Coelho {
28490921014SLuciano Coelho struct acx_rx_msdu_lifetime *acx;
28590921014SLuciano Coelho int ret;
28690921014SLuciano Coelho
28790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rx msdu life time");
28890921014SLuciano Coelho
28990921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
29060ce473eSJing Wang if (!acx)
29160ce473eSJing Wang return -ENOMEM;
29290921014SLuciano Coelho
29390921014SLuciano Coelho acx->lifetime = life_time;
29490921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME,
29590921014SLuciano Coelho acx, sizeof(*acx));
29690921014SLuciano Coelho if (ret < 0) {
29790921014SLuciano Coelho wl1251_warning("failed to set rx msdu life time: %d", ret);
29890921014SLuciano Coelho goto out;
29990921014SLuciano Coelho }
30090921014SLuciano Coelho
30190921014SLuciano Coelho out:
30290921014SLuciano Coelho kfree(acx);
30390921014SLuciano Coelho return ret;
30490921014SLuciano Coelho }
30590921014SLuciano Coelho
wl1251_acx_rx_config(struct wl1251 * wl,u32 config,u32 filter)30690921014SLuciano Coelho int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter)
30790921014SLuciano Coelho {
30890921014SLuciano Coelho struct acx_rx_config *rx_config;
30990921014SLuciano Coelho int ret;
31090921014SLuciano Coelho
31190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rx config");
31290921014SLuciano Coelho
31390921014SLuciano Coelho rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL);
31460ce473eSJing Wang if (!rx_config)
31560ce473eSJing Wang return -ENOMEM;
31690921014SLuciano Coelho
31790921014SLuciano Coelho rx_config->config_options = config;
31890921014SLuciano Coelho rx_config->filter_options = filter;
31990921014SLuciano Coelho
32090921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_RX_CFG,
32190921014SLuciano Coelho rx_config, sizeof(*rx_config));
32290921014SLuciano Coelho if (ret < 0) {
32390921014SLuciano Coelho wl1251_warning("failed to set rx config: %d", ret);
32490921014SLuciano Coelho goto out;
32590921014SLuciano Coelho }
32690921014SLuciano Coelho
32790921014SLuciano Coelho out:
32890921014SLuciano Coelho kfree(rx_config);
32990921014SLuciano Coelho return ret;
33090921014SLuciano Coelho }
33190921014SLuciano Coelho
wl1251_acx_pd_threshold(struct wl1251 * wl)33290921014SLuciano Coelho int wl1251_acx_pd_threshold(struct wl1251 *wl)
33390921014SLuciano Coelho {
33490921014SLuciano Coelho struct acx_packet_detection *pd;
33590921014SLuciano Coelho int ret;
33690921014SLuciano Coelho
33790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx data pd threshold");
33890921014SLuciano Coelho
33990921014SLuciano Coelho pd = kzalloc(sizeof(*pd), GFP_KERNEL);
34060ce473eSJing Wang if (!pd)
34160ce473eSJing Wang return -ENOMEM;
34290921014SLuciano Coelho
34390921014SLuciano Coelho /* FIXME: threshold value not set */
34490921014SLuciano Coelho
34590921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd));
34690921014SLuciano Coelho if (ret < 0) {
34790921014SLuciano Coelho wl1251_warning("failed to set pd threshold: %d", ret);
34890921014SLuciano Coelho goto out;
34990921014SLuciano Coelho }
35090921014SLuciano Coelho
35190921014SLuciano Coelho out:
35290921014SLuciano Coelho kfree(pd);
35390921014SLuciano Coelho return ret;
35490921014SLuciano Coelho }
35590921014SLuciano Coelho
wl1251_acx_slot(struct wl1251 * wl,enum acx_slot_type slot_time)35690921014SLuciano Coelho int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time)
35790921014SLuciano Coelho {
35890921014SLuciano Coelho struct acx_slot *slot;
35990921014SLuciano Coelho int ret;
36090921014SLuciano Coelho
36190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx slot");
36290921014SLuciano Coelho
36390921014SLuciano Coelho slot = kzalloc(sizeof(*slot), GFP_KERNEL);
36460ce473eSJing Wang if (!slot)
36560ce473eSJing Wang return -ENOMEM;
36690921014SLuciano Coelho
36790921014SLuciano Coelho slot->wone_index = STATION_WONE_INDEX;
36890921014SLuciano Coelho slot->slot_time = slot_time;
36990921014SLuciano Coelho
37090921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot));
37190921014SLuciano Coelho if (ret < 0) {
37290921014SLuciano Coelho wl1251_warning("failed to set slot time: %d", ret);
37390921014SLuciano Coelho goto out;
37490921014SLuciano Coelho }
37590921014SLuciano Coelho
37690921014SLuciano Coelho out:
37790921014SLuciano Coelho kfree(slot);
37890921014SLuciano Coelho return ret;
37990921014SLuciano Coelho }
38090921014SLuciano Coelho
wl1251_acx_group_address_tbl(struct wl1251 * wl,bool enable,void * mc_list,u32 mc_list_len)3819ed74ba0SDavid Gnedt int wl1251_acx_group_address_tbl(struct wl1251 *wl, bool enable,
3829ed74ba0SDavid Gnedt void *mc_list, u32 mc_list_len)
38390921014SLuciano Coelho {
38490921014SLuciano Coelho struct acx_dot11_grp_addr_tbl *acx;
38590921014SLuciano Coelho int ret;
38690921014SLuciano Coelho
38790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx group address tbl");
38890921014SLuciano Coelho
38990921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
39060ce473eSJing Wang if (!acx)
39160ce473eSJing Wang return -ENOMEM;
39290921014SLuciano Coelho
39390921014SLuciano Coelho /* MAC filtering */
3949ed74ba0SDavid Gnedt acx->enabled = enable;
3959ed74ba0SDavid Gnedt acx->num_groups = mc_list_len;
3969ed74ba0SDavid Gnedt memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN);
39790921014SLuciano Coelho
39890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL,
39990921014SLuciano Coelho acx, sizeof(*acx));
40090921014SLuciano Coelho if (ret < 0) {
40190921014SLuciano Coelho wl1251_warning("failed to set group addr table: %d", ret);
40290921014SLuciano Coelho goto out;
40390921014SLuciano Coelho }
40490921014SLuciano Coelho
40590921014SLuciano Coelho out:
40690921014SLuciano Coelho kfree(acx);
40790921014SLuciano Coelho return ret;
40890921014SLuciano Coelho }
40990921014SLuciano Coelho
wl1251_acx_service_period_timeout(struct wl1251 * wl)41090921014SLuciano Coelho int wl1251_acx_service_period_timeout(struct wl1251 *wl)
41190921014SLuciano Coelho {
41290921014SLuciano Coelho struct acx_rx_timeout *rx_timeout;
41390921014SLuciano Coelho int ret;
41490921014SLuciano Coelho
41590921014SLuciano Coelho rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL);
41660ce473eSJing Wang if (!rx_timeout)
41760ce473eSJing Wang return -ENOMEM;
41890921014SLuciano Coelho
41990921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx service period timeout");
42090921014SLuciano Coelho
42190921014SLuciano Coelho rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF;
42290921014SLuciano Coelho rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF;
42390921014SLuciano Coelho
42490921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT,
42590921014SLuciano Coelho rx_timeout, sizeof(*rx_timeout));
42690921014SLuciano Coelho if (ret < 0) {
42790921014SLuciano Coelho wl1251_warning("failed to set service period timeout: %d",
42890921014SLuciano Coelho ret);
42990921014SLuciano Coelho goto out;
43090921014SLuciano Coelho }
43190921014SLuciano Coelho
43290921014SLuciano Coelho out:
43390921014SLuciano Coelho kfree(rx_timeout);
43490921014SLuciano Coelho return ret;
43590921014SLuciano Coelho }
43690921014SLuciano Coelho
wl1251_acx_rts_threshold(struct wl1251 * wl,u16 rts_threshold)43790921014SLuciano Coelho int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold)
43890921014SLuciano Coelho {
43990921014SLuciano Coelho struct acx_rts_threshold *rts;
44090921014SLuciano Coelho int ret;
44190921014SLuciano Coelho
44290921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rts threshold");
44390921014SLuciano Coelho
44490921014SLuciano Coelho rts = kzalloc(sizeof(*rts), GFP_KERNEL);
44560ce473eSJing Wang if (!rts)
44660ce473eSJing Wang return -ENOMEM;
44790921014SLuciano Coelho
44890921014SLuciano Coelho rts->threshold = rts_threshold;
44990921014SLuciano Coelho
45090921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts));
45190921014SLuciano Coelho if (ret < 0) {
45290921014SLuciano Coelho wl1251_warning("failed to set rts threshold: %d", ret);
45390921014SLuciano Coelho goto out;
45490921014SLuciano Coelho }
45590921014SLuciano Coelho
45690921014SLuciano Coelho out:
45790921014SLuciano Coelho kfree(rts);
45890921014SLuciano Coelho return ret;
45990921014SLuciano Coelho }
46090921014SLuciano Coelho
wl1251_acx_beacon_filter_opt(struct wl1251 * wl,bool enable_filter)46190921014SLuciano Coelho int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter)
46290921014SLuciano Coelho {
46390921014SLuciano Coelho struct acx_beacon_filter_option *beacon_filter;
46490921014SLuciano Coelho int ret;
46590921014SLuciano Coelho
46690921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx beacon filter opt");
46790921014SLuciano Coelho
46890921014SLuciano Coelho beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL);
46960ce473eSJing Wang if (!beacon_filter)
47060ce473eSJing Wang return -ENOMEM;
47190921014SLuciano Coelho
47290921014SLuciano Coelho beacon_filter->enable = enable_filter;
47390921014SLuciano Coelho beacon_filter->max_num_beacons = 0;
47490921014SLuciano Coelho
47590921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
47690921014SLuciano Coelho beacon_filter, sizeof(*beacon_filter));
47790921014SLuciano Coelho if (ret < 0) {
47890921014SLuciano Coelho wl1251_warning("failed to set beacon filter opt: %d", ret);
47990921014SLuciano Coelho goto out;
48090921014SLuciano Coelho }
48190921014SLuciano Coelho
48290921014SLuciano Coelho out:
48390921014SLuciano Coelho kfree(beacon_filter);
48490921014SLuciano Coelho return ret;
48590921014SLuciano Coelho }
48690921014SLuciano Coelho
wl1251_acx_beacon_filter_table(struct wl1251 * wl)48790921014SLuciano Coelho int wl1251_acx_beacon_filter_table(struct wl1251 *wl)
48890921014SLuciano Coelho {
48990921014SLuciano Coelho struct acx_beacon_filter_ie_table *ie_table;
49090921014SLuciano Coelho int idx = 0;
49190921014SLuciano Coelho int ret;
49290921014SLuciano Coelho
49390921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx beacon filter table");
49490921014SLuciano Coelho
49590921014SLuciano Coelho ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
49660ce473eSJing Wang if (!ie_table)
49760ce473eSJing Wang return -ENOMEM;
49890921014SLuciano Coelho
49990921014SLuciano Coelho /* configure default beacon pass-through rules */
50090921014SLuciano Coelho ie_table->num_ie = 1;
50190921014SLuciano Coelho ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN;
50290921014SLuciano Coelho ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE;
50390921014SLuciano Coelho
50490921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
50590921014SLuciano Coelho ie_table, sizeof(*ie_table));
50690921014SLuciano Coelho if (ret < 0) {
50790921014SLuciano Coelho wl1251_warning("failed to set beacon filter table: %d", ret);
50890921014SLuciano Coelho goto out;
50990921014SLuciano Coelho }
51090921014SLuciano Coelho
51190921014SLuciano Coelho out:
51290921014SLuciano Coelho kfree(ie_table);
51390921014SLuciano Coelho return ret;
51490921014SLuciano Coelho }
51590921014SLuciano Coelho
wl1251_acx_conn_monit_params(struct wl1251 * wl)51690921014SLuciano Coelho int wl1251_acx_conn_monit_params(struct wl1251 *wl)
51790921014SLuciano Coelho {
51890921014SLuciano Coelho struct acx_conn_monit_params *acx;
51990921014SLuciano Coelho int ret;
52090921014SLuciano Coelho
52190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx connection monitor parameters");
52290921014SLuciano Coelho
52390921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
52460ce473eSJing Wang if (!acx)
52560ce473eSJing Wang return -ENOMEM;
52690921014SLuciano Coelho
52790921014SLuciano Coelho acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD;
52890921014SLuciano Coelho acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT;
52990921014SLuciano Coelho
53090921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
53190921014SLuciano Coelho acx, sizeof(*acx));
53290921014SLuciano Coelho if (ret < 0) {
53390921014SLuciano Coelho wl1251_warning("failed to set connection monitor "
53490921014SLuciano Coelho "parameters: %d", ret);
53590921014SLuciano Coelho goto out;
53690921014SLuciano Coelho }
53790921014SLuciano Coelho
53890921014SLuciano Coelho out:
53990921014SLuciano Coelho kfree(acx);
54090921014SLuciano Coelho return ret;
54190921014SLuciano Coelho }
54290921014SLuciano Coelho
wl1251_acx_sg_enable(struct wl1251 * wl)54390921014SLuciano Coelho int wl1251_acx_sg_enable(struct wl1251 *wl)
54490921014SLuciano Coelho {
54590921014SLuciano Coelho struct acx_bt_wlan_coex *pta;
54690921014SLuciano Coelho int ret;
54790921014SLuciano Coelho
54890921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx sg enable");
54990921014SLuciano Coelho
55090921014SLuciano Coelho pta = kzalloc(sizeof(*pta), GFP_KERNEL);
55160ce473eSJing Wang if (!pta)
55260ce473eSJing Wang return -ENOMEM;
55390921014SLuciano Coelho
55490921014SLuciano Coelho pta->enable = SG_ENABLE;
55590921014SLuciano Coelho
55690921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
55790921014SLuciano Coelho if (ret < 0) {
55890921014SLuciano Coelho wl1251_warning("failed to set softgemini enable: %d", ret);
55990921014SLuciano Coelho goto out;
56090921014SLuciano Coelho }
56190921014SLuciano Coelho
56290921014SLuciano Coelho out:
56390921014SLuciano Coelho kfree(pta);
56490921014SLuciano Coelho return ret;
56590921014SLuciano Coelho }
56690921014SLuciano Coelho
wl1251_acx_sg_cfg(struct wl1251 * wl)56790921014SLuciano Coelho int wl1251_acx_sg_cfg(struct wl1251 *wl)
56890921014SLuciano Coelho {
56990921014SLuciano Coelho struct acx_bt_wlan_coex_param *param;
57090921014SLuciano Coelho int ret;
57190921014SLuciano Coelho
57290921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx sg cfg");
57390921014SLuciano Coelho
57490921014SLuciano Coelho param = kzalloc(sizeof(*param), GFP_KERNEL);
57560ce473eSJing Wang if (!param)
57660ce473eSJing Wang return -ENOMEM;
57790921014SLuciano Coelho
57890921014SLuciano Coelho /* BT-WLAN coext parameters */
57990921014SLuciano Coelho param->min_rate = RATE_INDEX_24MBPS;
58090921014SLuciano Coelho param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
58190921014SLuciano Coelho param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
58290921014SLuciano Coelho param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
58390921014SLuciano Coelho param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
58490921014SLuciano Coelho param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
58590921014SLuciano Coelho param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
58690921014SLuciano Coelho param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
58790921014SLuciano Coelho param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
58890921014SLuciano Coelho param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
58990921014SLuciano Coelho param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
59090921014SLuciano Coelho param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
59190921014SLuciano Coelho param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
59290921014SLuciano Coelho param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
59390921014SLuciano Coelho param->antenna_type = PTA_ANTENNA_TYPE_DEF;
59490921014SLuciano Coelho param->signal_type = PTA_SIGNALING_TYPE_DEF;
59590921014SLuciano Coelho param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
59690921014SLuciano Coelho param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
59790921014SLuciano Coelho param->max_cts = PTA_MAX_NUM_CTS_DEF;
59890921014SLuciano Coelho param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
59990921014SLuciano Coelho param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
60090921014SLuciano Coelho param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
60190921014SLuciano Coelho param->wlan_elp_hp = PTA_ELP_HP_DEF;
60290921014SLuciano Coelho param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
60390921014SLuciano Coelho param->ack_mode_dual_ant = PTA_ACK_MODE_DEF;
60490921014SLuciano Coelho param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
60590921014SLuciano Coelho param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
60690921014SLuciano Coelho param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
60790921014SLuciano Coelho
60890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
60990921014SLuciano Coelho if (ret < 0) {
61090921014SLuciano Coelho wl1251_warning("failed to set sg config: %d", ret);
61190921014SLuciano Coelho goto out;
61290921014SLuciano Coelho }
61390921014SLuciano Coelho
61490921014SLuciano Coelho out:
61590921014SLuciano Coelho kfree(param);
61690921014SLuciano Coelho return ret;
61790921014SLuciano Coelho }
61890921014SLuciano Coelho
wl1251_acx_cca_threshold(struct wl1251 * wl)61990921014SLuciano Coelho int wl1251_acx_cca_threshold(struct wl1251 *wl)
62090921014SLuciano Coelho {
62190921014SLuciano Coelho struct acx_energy_detection *detection;
62290921014SLuciano Coelho int ret;
62390921014SLuciano Coelho
62490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx cca threshold");
62590921014SLuciano Coelho
62690921014SLuciano Coelho detection = kzalloc(sizeof(*detection), GFP_KERNEL);
62760ce473eSJing Wang if (!detection)
62860ce473eSJing Wang return -ENOMEM;
62990921014SLuciano Coelho
63090921014SLuciano Coelho detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
63190921014SLuciano Coelho detection->tx_energy_detection = 0;
63290921014SLuciano Coelho
63390921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD,
63490921014SLuciano Coelho detection, sizeof(*detection));
63590921014SLuciano Coelho if (ret < 0)
63690921014SLuciano Coelho wl1251_warning("failed to set cca threshold: %d", ret);
63790921014SLuciano Coelho
63890921014SLuciano Coelho kfree(detection);
63990921014SLuciano Coelho return ret;
64090921014SLuciano Coelho }
64190921014SLuciano Coelho
wl1251_acx_bcn_dtim_options(struct wl1251 * wl)64290921014SLuciano Coelho int wl1251_acx_bcn_dtim_options(struct wl1251 *wl)
64390921014SLuciano Coelho {
64490921014SLuciano Coelho struct acx_beacon_broadcast *bb;
64590921014SLuciano Coelho int ret;
64690921014SLuciano Coelho
64790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx bcn dtim options");
64890921014SLuciano Coelho
64990921014SLuciano Coelho bb = kzalloc(sizeof(*bb), GFP_KERNEL);
65060ce473eSJing Wang if (!bb)
65160ce473eSJing Wang return -ENOMEM;
65290921014SLuciano Coelho
65390921014SLuciano Coelho bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
65490921014SLuciano Coelho bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
65590921014SLuciano Coelho bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
65690921014SLuciano Coelho bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
65790921014SLuciano Coelho
65890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
65990921014SLuciano Coelho if (ret < 0) {
66090921014SLuciano Coelho wl1251_warning("failed to set rx config: %d", ret);
66190921014SLuciano Coelho goto out;
66290921014SLuciano Coelho }
66390921014SLuciano Coelho
66490921014SLuciano Coelho out:
66590921014SLuciano Coelho kfree(bb);
66690921014SLuciano Coelho return ret;
66790921014SLuciano Coelho }
66890921014SLuciano Coelho
wl1251_acx_aid(struct wl1251 * wl,u16 aid)66990921014SLuciano Coelho int wl1251_acx_aid(struct wl1251 *wl, u16 aid)
67090921014SLuciano Coelho {
67190921014SLuciano Coelho struct acx_aid *acx_aid;
67290921014SLuciano Coelho int ret;
67390921014SLuciano Coelho
67490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx aid");
67590921014SLuciano Coelho
67690921014SLuciano Coelho acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
67760ce473eSJing Wang if (!acx_aid)
67860ce473eSJing Wang return -ENOMEM;
67990921014SLuciano Coelho
68090921014SLuciano Coelho acx_aid->aid = aid;
68190921014SLuciano Coelho
68290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
68390921014SLuciano Coelho if (ret < 0) {
68490921014SLuciano Coelho wl1251_warning("failed to set aid: %d", ret);
68590921014SLuciano Coelho goto out;
68690921014SLuciano Coelho }
68790921014SLuciano Coelho
68890921014SLuciano Coelho out:
68990921014SLuciano Coelho kfree(acx_aid);
69090921014SLuciano Coelho return ret;
69190921014SLuciano Coelho }
69290921014SLuciano Coelho
wl1251_acx_event_mbox_mask(struct wl1251 * wl,u32 event_mask)69390921014SLuciano Coelho int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask)
69490921014SLuciano Coelho {
69590921014SLuciano Coelho struct acx_event_mask *mask;
69690921014SLuciano Coelho int ret;
69790921014SLuciano Coelho
69890921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx event mbox mask");
69990921014SLuciano Coelho
70090921014SLuciano Coelho mask = kzalloc(sizeof(*mask), GFP_KERNEL);
70160ce473eSJing Wang if (!mask)
70260ce473eSJing Wang return -ENOMEM;
70390921014SLuciano Coelho
70490921014SLuciano Coelho /* high event mask is unused */
70590921014SLuciano Coelho mask->high_event_mask = 0xffffffff;
70690921014SLuciano Coelho
70790921014SLuciano Coelho mask->event_mask = event_mask;
70890921014SLuciano Coelho
70990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
71090921014SLuciano Coelho mask, sizeof(*mask));
71190921014SLuciano Coelho if (ret < 0) {
71290921014SLuciano Coelho wl1251_warning("failed to set acx_event_mbox_mask: %d", ret);
71390921014SLuciano Coelho goto out;
71490921014SLuciano Coelho }
71590921014SLuciano Coelho
71690921014SLuciano Coelho out:
71790921014SLuciano Coelho kfree(mask);
71890921014SLuciano Coelho return ret;
71990921014SLuciano Coelho }
72090921014SLuciano Coelho
wl1251_acx_low_rssi(struct wl1251 * wl,s8 threshold,u8 weight,u8 depth,enum wl1251_acx_low_rssi_type type)72190921014SLuciano Coelho int wl1251_acx_low_rssi(struct wl1251 *wl, s8 threshold, u8 weight,
72290921014SLuciano Coelho u8 depth, enum wl1251_acx_low_rssi_type type)
72390921014SLuciano Coelho {
72490921014SLuciano Coelho struct acx_low_rssi *rssi;
72590921014SLuciano Coelho int ret;
72690921014SLuciano Coelho
72790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx low rssi");
72890921014SLuciano Coelho
72990921014SLuciano Coelho rssi = kzalloc(sizeof(*rssi), GFP_KERNEL);
73090921014SLuciano Coelho if (!rssi)
73190921014SLuciano Coelho return -ENOMEM;
73290921014SLuciano Coelho
73390921014SLuciano Coelho rssi->threshold = threshold;
73490921014SLuciano Coelho rssi->weight = weight;
73590921014SLuciano Coelho rssi->depth = depth;
73690921014SLuciano Coelho rssi->type = type;
73790921014SLuciano Coelho
73890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_LOW_RSSI, rssi, sizeof(*rssi));
73990921014SLuciano Coelho if (ret < 0)
74090921014SLuciano Coelho wl1251_warning("failed to set low rssi threshold: %d", ret);
74190921014SLuciano Coelho
74290921014SLuciano Coelho kfree(rssi);
74390921014SLuciano Coelho return ret;
74490921014SLuciano Coelho }
74590921014SLuciano Coelho
wl1251_acx_set_preamble(struct wl1251 * wl,enum acx_preamble_type preamble)74690921014SLuciano Coelho int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble)
74790921014SLuciano Coelho {
74890921014SLuciano Coelho struct acx_preamble *acx;
74990921014SLuciano Coelho int ret;
75090921014SLuciano Coelho
75190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx_set_preamble");
75290921014SLuciano Coelho
75390921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
75460ce473eSJing Wang if (!acx)
75560ce473eSJing Wang return -ENOMEM;
75690921014SLuciano Coelho
75790921014SLuciano Coelho acx->preamble = preamble;
75890921014SLuciano Coelho
75990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
76090921014SLuciano Coelho if (ret < 0) {
76190921014SLuciano Coelho wl1251_warning("Setting of preamble failed: %d", ret);
76290921014SLuciano Coelho goto out;
76390921014SLuciano Coelho }
76490921014SLuciano Coelho
76590921014SLuciano Coelho out:
76690921014SLuciano Coelho kfree(acx);
76790921014SLuciano Coelho return ret;
76890921014SLuciano Coelho }
76990921014SLuciano Coelho
wl1251_acx_cts_protect(struct wl1251 * wl,enum acx_ctsprotect_type ctsprotect)77090921014SLuciano Coelho int wl1251_acx_cts_protect(struct wl1251 *wl,
77190921014SLuciano Coelho enum acx_ctsprotect_type ctsprotect)
77290921014SLuciano Coelho {
77390921014SLuciano Coelho struct acx_ctsprotect *acx;
77490921014SLuciano Coelho int ret;
77590921014SLuciano Coelho
77690921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect");
77790921014SLuciano Coelho
77890921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
77960ce473eSJing Wang if (!acx)
78060ce473eSJing Wang return -ENOMEM;
78190921014SLuciano Coelho
78290921014SLuciano Coelho acx->ctsprotect = ctsprotect;
78390921014SLuciano Coelho
78490921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
78590921014SLuciano Coelho if (ret < 0) {
78690921014SLuciano Coelho wl1251_warning("Setting of ctsprotect failed: %d", ret);
78790921014SLuciano Coelho goto out;
78890921014SLuciano Coelho }
78990921014SLuciano Coelho
79090921014SLuciano Coelho out:
79190921014SLuciano Coelho kfree(acx);
79290921014SLuciano Coelho return ret;
79390921014SLuciano Coelho }
79490921014SLuciano Coelho
wl1251_acx_tsf_info(struct wl1251 * wl,u64 * mactime)79590921014SLuciano Coelho int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime)
79690921014SLuciano Coelho {
79790921014SLuciano Coelho struct acx_tsf_info *tsf_info;
79890921014SLuciano Coelho int ret;
79990921014SLuciano Coelho
80090921014SLuciano Coelho tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
80160ce473eSJing Wang if (!tsf_info)
80260ce473eSJing Wang return -ENOMEM;
80390921014SLuciano Coelho
80490921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO,
80590921014SLuciano Coelho tsf_info, sizeof(*tsf_info));
80690921014SLuciano Coelho if (ret < 0) {
80790921014SLuciano Coelho wl1251_warning("ACX_FW_REV interrogate failed");
80890921014SLuciano Coelho goto out;
80990921014SLuciano Coelho }
81090921014SLuciano Coelho
81190921014SLuciano Coelho *mactime = tsf_info->current_tsf_lsb |
812cae6247dSGrazvydas Ignotas ((u64)tsf_info->current_tsf_msb << 32);
81390921014SLuciano Coelho
81490921014SLuciano Coelho out:
81590921014SLuciano Coelho kfree(tsf_info);
81690921014SLuciano Coelho return ret;
81790921014SLuciano Coelho }
81890921014SLuciano Coelho
wl1251_acx_statistics(struct wl1251 * wl,struct acx_statistics * stats)81990921014SLuciano Coelho int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats)
82090921014SLuciano Coelho {
82190921014SLuciano Coelho int ret;
82290921014SLuciano Coelho
82390921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx statistics");
82490921014SLuciano Coelho
82590921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats,
82690921014SLuciano Coelho sizeof(*stats));
82790921014SLuciano Coelho if (ret < 0) {
82890921014SLuciano Coelho wl1251_warning("acx statistics failed: %d", ret);
82990921014SLuciano Coelho return -ENOMEM;
83090921014SLuciano Coelho }
83190921014SLuciano Coelho
83290921014SLuciano Coelho return 0;
83390921014SLuciano Coelho }
83490921014SLuciano Coelho
wl1251_acx_rate_policies(struct wl1251 * wl)83590921014SLuciano Coelho int wl1251_acx_rate_policies(struct wl1251 *wl)
83690921014SLuciano Coelho {
83790921014SLuciano Coelho struct acx_rate_policy *acx;
83890921014SLuciano Coelho int ret = 0;
83990921014SLuciano Coelho
84090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rate policies");
84190921014SLuciano Coelho
84290921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
84360ce473eSJing Wang if (!acx)
84460ce473eSJing Wang return -ENOMEM;
84590921014SLuciano Coelho
84690921014SLuciano Coelho /* configure one default (one-size-fits-all) rate class */
8473d49da74SDavid Gnedt acx->rate_class_cnt = 2;
84890921014SLuciano Coelho acx->rate_class[0].enabled_rates = ACX_RATE_MASK_UNSPECIFIED;
84990921014SLuciano Coelho acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT;
85090921014SLuciano Coelho acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT;
85190921014SLuciano Coelho acx->rate_class[0].aflags = 0;
85290921014SLuciano Coelho
8533d49da74SDavid Gnedt /* no-retry rate class */
8543d49da74SDavid Gnedt acx->rate_class[1].enabled_rates = ACX_RATE_MASK_UNSPECIFIED;
8553d49da74SDavid Gnedt acx->rate_class[1].short_retry_limit = 0;
8563d49da74SDavid Gnedt acx->rate_class[1].long_retry_limit = 0;
8573d49da74SDavid Gnedt acx->rate_class[1].aflags = 0;
8583d49da74SDavid Gnedt
85990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx));
86090921014SLuciano Coelho if (ret < 0) {
86190921014SLuciano Coelho wl1251_warning("Setting of rate policies failed: %d", ret);
86290921014SLuciano Coelho goto out;
86390921014SLuciano Coelho }
86490921014SLuciano Coelho
86590921014SLuciano Coelho out:
86690921014SLuciano Coelho kfree(acx);
86790921014SLuciano Coelho return ret;
86890921014SLuciano Coelho }
86990921014SLuciano Coelho
wl1251_acx_mem_cfg(struct wl1251 * wl)87090921014SLuciano Coelho int wl1251_acx_mem_cfg(struct wl1251 *wl)
87190921014SLuciano Coelho {
87290921014SLuciano Coelho struct wl1251_acx_config_memory *mem_conf;
87390921014SLuciano Coelho int ret, i;
87490921014SLuciano Coelho
87590921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx mem cfg");
87690921014SLuciano Coelho
87790921014SLuciano Coelho mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
87860ce473eSJing Wang if (!mem_conf)
87960ce473eSJing Wang return -ENOMEM;
88090921014SLuciano Coelho
88190921014SLuciano Coelho /* memory config */
88290921014SLuciano Coelho mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS);
88390921014SLuciano Coelho mem_conf->mem_config.rx_mem_block_num = 35;
88490921014SLuciano Coelho mem_conf->mem_config.tx_min_mem_block_num = 64;
88590921014SLuciano Coelho mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES;
88690921014SLuciano Coelho mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING;
88790921014SLuciano Coelho mem_conf->mem_config.num_ssid_profiles = 1;
88890921014SLuciano Coelho mem_conf->mem_config.debug_buffer_size =
88990921014SLuciano Coelho cpu_to_le16(TRACE_BUFFER_MAX_SIZE);
89090921014SLuciano Coelho
89190921014SLuciano Coelho /* RX queue config */
89290921014SLuciano Coelho mem_conf->rx_queue_config.dma_address = 0;
89390921014SLuciano Coelho mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF;
89490921014SLuciano Coelho mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY;
89590921014SLuciano Coelho mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE;
89690921014SLuciano Coelho
89790921014SLuciano Coelho /* TX queue config */
89890921014SLuciano Coelho for (i = 0; i < MAX_TX_QUEUES; i++) {
89990921014SLuciano Coelho mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF;
90090921014SLuciano Coelho mem_conf->tx_queue_config[i].attributes = i;
90190921014SLuciano Coelho }
90290921014SLuciano Coelho
90390921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
90490921014SLuciano Coelho sizeof(*mem_conf));
90590921014SLuciano Coelho if (ret < 0) {
90690921014SLuciano Coelho wl1251_warning("wl1251 mem config failed: %d", ret);
90790921014SLuciano Coelho goto out;
90890921014SLuciano Coelho }
90990921014SLuciano Coelho
91090921014SLuciano Coelho out:
91190921014SLuciano Coelho kfree(mem_conf);
91290921014SLuciano Coelho return ret;
91390921014SLuciano Coelho }
91490921014SLuciano Coelho
wl1251_acx_wr_tbtt_and_dtim(struct wl1251 * wl,u16 tbtt,u8 dtim)91590921014SLuciano Coelho int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim)
91690921014SLuciano Coelho {
91790921014SLuciano Coelho struct wl1251_acx_wr_tbtt_and_dtim *acx;
91890921014SLuciano Coelho int ret;
91990921014SLuciano Coelho
92090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx tbtt and dtim");
92190921014SLuciano Coelho
92290921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
92360ce473eSJing Wang if (!acx)
92460ce473eSJing Wang return -ENOMEM;
92590921014SLuciano Coelho
92690921014SLuciano Coelho acx->tbtt = tbtt;
92790921014SLuciano Coelho acx->dtim = dtim;
92890921014SLuciano Coelho
92990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_WR_TBTT_AND_DTIM,
93090921014SLuciano Coelho acx, sizeof(*acx));
93190921014SLuciano Coelho if (ret < 0) {
93290921014SLuciano Coelho wl1251_warning("failed to set tbtt and dtim: %d", ret);
93390921014SLuciano Coelho goto out;
93490921014SLuciano Coelho }
93590921014SLuciano Coelho
93690921014SLuciano Coelho out:
93790921014SLuciano Coelho kfree(acx);
93890921014SLuciano Coelho return ret;
93990921014SLuciano Coelho }
94090921014SLuciano Coelho
wl1251_acx_bet_enable(struct wl1251 * wl,enum wl1251_acx_bet_mode mode,u8 max_consecutive)94190921014SLuciano Coelho int wl1251_acx_bet_enable(struct wl1251 *wl, enum wl1251_acx_bet_mode mode,
94290921014SLuciano Coelho u8 max_consecutive)
94390921014SLuciano Coelho {
94490921014SLuciano Coelho struct wl1251_acx_bet_enable *acx;
94590921014SLuciano Coelho int ret;
94690921014SLuciano Coelho
94790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx bet enable");
94890921014SLuciano Coelho
94990921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
95060ce473eSJing Wang if (!acx)
95160ce473eSJing Wang return -ENOMEM;
95290921014SLuciano Coelho
95390921014SLuciano Coelho acx->enable = mode;
95490921014SLuciano Coelho acx->max_consecutive = max_consecutive;
95590921014SLuciano Coelho
95690921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx));
95790921014SLuciano Coelho if (ret < 0) {
95890921014SLuciano Coelho wl1251_warning("wl1251 acx bet enable failed: %d", ret);
95990921014SLuciano Coelho goto out;
96090921014SLuciano Coelho }
96190921014SLuciano Coelho
96290921014SLuciano Coelho out:
96390921014SLuciano Coelho kfree(acx);
96490921014SLuciano Coelho return ret;
96590921014SLuciano Coelho }
96690921014SLuciano Coelho
wl1251_acx_arp_ip_filter(struct wl1251 * wl,bool enable,__be32 address)967204cc5c4SDavid Gnedt int wl1251_acx_arp_ip_filter(struct wl1251 *wl, bool enable, __be32 address)
968204cc5c4SDavid Gnedt {
969204cc5c4SDavid Gnedt struct wl1251_acx_arp_filter *acx;
970204cc5c4SDavid Gnedt int ret;
971204cc5c4SDavid Gnedt
972204cc5c4SDavid Gnedt wl1251_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable);
973204cc5c4SDavid Gnedt
974204cc5c4SDavid Gnedt acx = kzalloc(sizeof(*acx), GFP_KERNEL);
975204cc5c4SDavid Gnedt if (!acx)
976204cc5c4SDavid Gnedt return -ENOMEM;
977204cc5c4SDavid Gnedt
978204cc5c4SDavid Gnedt acx->version = ACX_IPV4_VERSION;
979204cc5c4SDavid Gnedt acx->enable = enable;
980204cc5c4SDavid Gnedt
981204cc5c4SDavid Gnedt if (enable)
982204cc5c4SDavid Gnedt memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE);
983204cc5c4SDavid Gnedt
984204cc5c4SDavid Gnedt ret = wl1251_cmd_configure(wl, ACX_ARP_IP_FILTER,
985204cc5c4SDavid Gnedt acx, sizeof(*acx));
986204cc5c4SDavid Gnedt if (ret < 0)
987204cc5c4SDavid Gnedt wl1251_warning("failed to set arp ip filter: %d", ret);
988204cc5c4SDavid Gnedt
989204cc5c4SDavid Gnedt kfree(acx);
990204cc5c4SDavid Gnedt return ret;
991204cc5c4SDavid Gnedt }
992204cc5c4SDavid Gnedt
wl1251_acx_ac_cfg(struct wl1251 * wl,u8 ac,u8 cw_min,u16 cw_max,u8 aifs,u16 txop)99390921014SLuciano Coelho int wl1251_acx_ac_cfg(struct wl1251 *wl, u8 ac, u8 cw_min, u16 cw_max,
99490921014SLuciano Coelho u8 aifs, u16 txop)
99590921014SLuciano Coelho {
99690921014SLuciano Coelho struct wl1251_acx_ac_cfg *acx;
99790921014SLuciano Coelho int ret = 0;
99890921014SLuciano Coelho
99990921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d "
100090921014SLuciano Coelho "aifs %d txop %d", ac, cw_min, cw_max, aifs, txop);
100190921014SLuciano Coelho
100290921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
100360ce473eSJing Wang if (!acx)
100460ce473eSJing Wang return -ENOMEM;
100590921014SLuciano Coelho
100690921014SLuciano Coelho acx->ac = ac;
100790921014SLuciano Coelho acx->cw_min = cw_min;
100890921014SLuciano Coelho acx->cw_max = cw_max;
100990921014SLuciano Coelho acx->aifsn = aifs;
101090921014SLuciano Coelho acx->txop_limit = txop;
101190921014SLuciano Coelho
101290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx));
101390921014SLuciano Coelho if (ret < 0) {
101490921014SLuciano Coelho wl1251_warning("acx ac cfg failed: %d", ret);
101590921014SLuciano Coelho goto out;
101690921014SLuciano Coelho }
101790921014SLuciano Coelho
101890921014SLuciano Coelho out:
101990921014SLuciano Coelho kfree(acx);
102090921014SLuciano Coelho return ret;
102190921014SLuciano Coelho }
102290921014SLuciano Coelho
wl1251_acx_tid_cfg(struct wl1251 * wl,u8 queue,enum wl1251_acx_channel_type type,u8 tsid,enum wl1251_acx_ps_scheme ps_scheme,enum wl1251_acx_ack_policy ack_policy)102390921014SLuciano Coelho int wl1251_acx_tid_cfg(struct wl1251 *wl, u8 queue,
102490921014SLuciano Coelho enum wl1251_acx_channel_type type,
102590921014SLuciano Coelho u8 tsid, enum wl1251_acx_ps_scheme ps_scheme,
102690921014SLuciano Coelho enum wl1251_acx_ack_policy ack_policy)
102790921014SLuciano Coelho {
102890921014SLuciano Coelho struct wl1251_acx_tid_cfg *acx;
102990921014SLuciano Coelho int ret = 0;
103090921014SLuciano Coelho
103190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx tid cfg %d type %d tsid %d "
103290921014SLuciano Coelho "ps_scheme %d ack_policy %d", queue, type, tsid,
103390921014SLuciano Coelho ps_scheme, ack_policy);
103490921014SLuciano Coelho
103590921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL);
103660ce473eSJing Wang if (!acx)
103760ce473eSJing Wang return -ENOMEM;
103890921014SLuciano Coelho
103990921014SLuciano Coelho acx->queue = queue;
104090921014SLuciano Coelho acx->type = type;
104190921014SLuciano Coelho acx->tsid = tsid;
104290921014SLuciano Coelho acx->ps_scheme = ps_scheme;
104390921014SLuciano Coelho acx->ack_policy = ack_policy;
104490921014SLuciano Coelho
104590921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx));
104690921014SLuciano Coelho if (ret < 0) {
104790921014SLuciano Coelho wl1251_warning("acx tid cfg failed: %d", ret);
104890921014SLuciano Coelho goto out;
104990921014SLuciano Coelho }
105090921014SLuciano Coelho
105190921014SLuciano Coelho out:
105290921014SLuciano Coelho kfree(acx);
105390921014SLuciano Coelho return ret;
105490921014SLuciano Coelho }
1055