190921014SLuciano Coelho #include "acx.h" 290921014SLuciano Coelho 390921014SLuciano Coelho #include <linux/module.h> 490921014SLuciano Coelho #include <linux/slab.h> 590921014SLuciano Coelho #include <linux/crc7.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 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 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 if (ret < 0) 5890921014SLuciano Coelho goto out; 5990921014SLuciano Coelho 6090921014SLuciano Coelho out: 6190921014SLuciano Coelho kfree(mac); 6290921014SLuciano Coelho return ret; 6390921014SLuciano Coelho } 6490921014SLuciano Coelho 6590921014SLuciano Coelho int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id) 6690921014SLuciano Coelho { 6790921014SLuciano Coelho struct acx_dot11_default_key *default_key; 6890921014SLuciano Coelho int ret; 6990921014SLuciano Coelho 7090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id); 7190921014SLuciano Coelho 7290921014SLuciano Coelho default_key = kzalloc(sizeof(*default_key), GFP_KERNEL); 7360ce473eSJing Wang if (!default_key) 7460ce473eSJing Wang return -ENOMEM; 7590921014SLuciano Coelho 7690921014SLuciano Coelho default_key->id = key_id; 7790921014SLuciano Coelho 7890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_DEFAULT_KEY, 7990921014SLuciano Coelho default_key, sizeof(*default_key)); 8090921014SLuciano Coelho if (ret < 0) { 8190921014SLuciano Coelho wl1251_error("Couldn't set default key"); 8290921014SLuciano Coelho goto out; 8390921014SLuciano Coelho } 8490921014SLuciano Coelho 8590921014SLuciano Coelho wl->default_key = key_id; 8690921014SLuciano Coelho 8790921014SLuciano Coelho out: 8890921014SLuciano Coelho kfree(default_key); 8990921014SLuciano Coelho return ret; 9090921014SLuciano Coelho } 9190921014SLuciano Coelho 9290921014SLuciano Coelho int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event, 9390921014SLuciano Coelho u8 listen_interval) 9490921014SLuciano Coelho { 9590921014SLuciano Coelho struct acx_wake_up_condition *wake_up; 9690921014SLuciano Coelho int ret; 9790921014SLuciano Coelho 9890921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx wake up conditions"); 9990921014SLuciano Coelho 10090921014SLuciano Coelho wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL); 10160ce473eSJing Wang if (!wake_up) 10260ce473eSJing Wang return -ENOMEM; 10390921014SLuciano Coelho 10490921014SLuciano Coelho wake_up->wake_up_event = wake_up_event; 10590921014SLuciano Coelho wake_up->listen_interval = listen_interval; 10690921014SLuciano Coelho 10790921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS, 10890921014SLuciano Coelho wake_up, sizeof(*wake_up)); 10990921014SLuciano Coelho if (ret < 0) { 11090921014SLuciano Coelho wl1251_warning("could not set wake up conditions: %d", ret); 11190921014SLuciano Coelho goto out; 11290921014SLuciano Coelho } 11390921014SLuciano Coelho 11490921014SLuciano Coelho out: 11590921014SLuciano Coelho kfree(wake_up); 11690921014SLuciano Coelho return ret; 11790921014SLuciano Coelho } 11890921014SLuciano Coelho 11990921014SLuciano Coelho int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth) 12090921014SLuciano Coelho { 12190921014SLuciano Coelho struct acx_sleep_auth *auth; 12290921014SLuciano Coelho int ret; 12390921014SLuciano Coelho 12490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx sleep auth"); 12590921014SLuciano Coelho 12690921014SLuciano Coelho auth = kzalloc(sizeof(*auth), GFP_KERNEL); 12760ce473eSJing Wang if (!auth) 12860ce473eSJing Wang return -ENOMEM; 12990921014SLuciano Coelho 13090921014SLuciano Coelho auth->sleep_auth = sleep_auth; 13190921014SLuciano Coelho 13290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth)); 13390921014SLuciano Coelho 13490921014SLuciano Coelho kfree(auth); 13590921014SLuciano Coelho return ret; 13690921014SLuciano Coelho } 13790921014SLuciano Coelho 13890921014SLuciano Coelho int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len) 13990921014SLuciano Coelho { 14090921014SLuciano Coelho struct acx_revision *rev; 14190921014SLuciano Coelho int ret; 14290921014SLuciano Coelho 14390921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx fw rev"); 14490921014SLuciano Coelho 14590921014SLuciano Coelho rev = kzalloc(sizeof(*rev), GFP_KERNEL); 14660ce473eSJing Wang if (!rev) 14760ce473eSJing Wang return -ENOMEM; 14890921014SLuciano Coelho 14990921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev)); 15090921014SLuciano Coelho if (ret < 0) { 15190921014SLuciano Coelho wl1251_warning("ACX_FW_REV interrogate failed"); 15290921014SLuciano Coelho goto out; 15390921014SLuciano Coelho } 15490921014SLuciano Coelho 15590921014SLuciano Coelho /* be careful with the buffer sizes */ 15690921014SLuciano Coelho strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); 15790921014SLuciano Coelho 15890921014SLuciano Coelho /* 15990921014SLuciano Coelho * if the firmware version string is exactly 16090921014SLuciano Coelho * sizeof(rev->fw_version) long or fw_len is less than 16190921014SLuciano Coelho * sizeof(rev->fw_version) it won't be null terminated 16290921014SLuciano Coelho */ 16390921014SLuciano Coelho buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; 16490921014SLuciano Coelho 16590921014SLuciano Coelho out: 16690921014SLuciano Coelho kfree(rev); 16790921014SLuciano Coelho return ret; 16890921014SLuciano Coelho } 16990921014SLuciano Coelho 17090921014SLuciano Coelho int wl1251_acx_tx_power(struct wl1251 *wl, int power) 17190921014SLuciano Coelho { 17290921014SLuciano Coelho struct acx_current_tx_power *acx; 17390921014SLuciano Coelho int ret; 17490921014SLuciano Coelho 17590921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr"); 17690921014SLuciano Coelho 17790921014SLuciano Coelho if (power < 0 || power > 25) 17890921014SLuciano Coelho return -EINVAL; 17990921014SLuciano Coelho 18090921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 18160ce473eSJing Wang if (!acx) 18260ce473eSJing Wang return -ENOMEM; 18390921014SLuciano Coelho 18490921014SLuciano Coelho acx->current_tx_power = power * 10; 18590921014SLuciano Coelho 18690921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); 18790921014SLuciano Coelho if (ret < 0) { 18890921014SLuciano Coelho wl1251_warning("configure of tx power failed: %d", ret); 18990921014SLuciano Coelho goto out; 19090921014SLuciano Coelho } 19190921014SLuciano Coelho 19290921014SLuciano Coelho out: 19390921014SLuciano Coelho kfree(acx); 19490921014SLuciano Coelho return ret; 19590921014SLuciano Coelho } 19690921014SLuciano Coelho 1974d09b537SDavid Gnedt int wl1251_acx_feature_cfg(struct wl1251 *wl, u32 data_flow_options) 19890921014SLuciano Coelho { 19990921014SLuciano Coelho struct acx_feature_config *feature; 20090921014SLuciano Coelho int ret; 20190921014SLuciano Coelho 20290921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx feature cfg"); 20390921014SLuciano Coelho 20490921014SLuciano Coelho feature = kzalloc(sizeof(*feature), GFP_KERNEL); 20560ce473eSJing Wang if (!feature) 20660ce473eSJing Wang return -ENOMEM; 20790921014SLuciano Coelho 2084d09b537SDavid Gnedt /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE can be set */ 2094d09b537SDavid Gnedt feature->data_flow_options = data_flow_options; 21090921014SLuciano Coelho feature->options = 0; 21190921014SLuciano Coelho 21290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG, 21390921014SLuciano Coelho feature, sizeof(*feature)); 21490921014SLuciano Coelho if (ret < 0) { 21590921014SLuciano Coelho wl1251_error("Couldn't set HW encryption"); 21690921014SLuciano Coelho goto out; 21790921014SLuciano Coelho } 21890921014SLuciano Coelho 21990921014SLuciano Coelho out: 22090921014SLuciano Coelho kfree(feature); 22190921014SLuciano Coelho return ret; 22290921014SLuciano Coelho } 22390921014SLuciano Coelho 22490921014SLuciano Coelho int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map, 22590921014SLuciano Coelho size_t len) 22690921014SLuciano Coelho { 22790921014SLuciano Coelho int ret; 22890921014SLuciano Coelho 22990921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx mem map"); 23090921014SLuciano Coelho 23190921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len); 23290921014SLuciano Coelho if (ret < 0) 23390921014SLuciano Coelho return ret; 23490921014SLuciano Coelho 23590921014SLuciano Coelho return 0; 23690921014SLuciano Coelho } 23790921014SLuciano Coelho 23890921014SLuciano Coelho int wl1251_acx_data_path_params(struct wl1251 *wl, 23990921014SLuciano Coelho struct acx_data_path_params_resp *resp) 24090921014SLuciano Coelho { 24190921014SLuciano Coelho struct acx_data_path_params *params; 24290921014SLuciano Coelho int ret; 24390921014SLuciano Coelho 24490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx data path params"); 24590921014SLuciano Coelho 24690921014SLuciano Coelho params = kzalloc(sizeof(*params), GFP_KERNEL); 24760ce473eSJing Wang if (!params) 24860ce473eSJing Wang return -ENOMEM; 24990921014SLuciano Coelho 25090921014SLuciano Coelho params->rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE; 25190921014SLuciano Coelho params->tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE; 25290921014SLuciano Coelho 25390921014SLuciano Coelho params->rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM; 25490921014SLuciano Coelho params->tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM; 25590921014SLuciano Coelho 25690921014SLuciano Coelho params->tx_complete_threshold = 1; 25790921014SLuciano Coelho 25890921014SLuciano Coelho params->tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE; 25990921014SLuciano Coelho 26090921014SLuciano Coelho params->tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT; 26190921014SLuciano Coelho 26290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_DATA_PATH_PARAMS, 26390921014SLuciano Coelho params, sizeof(*params)); 26490921014SLuciano Coelho if (ret < 0) 26590921014SLuciano Coelho goto out; 26690921014SLuciano Coelho 26790921014SLuciano Coelho /* FIXME: shouldn't this be ACX_DATA_PATH_RESP_PARAMS? */ 26890921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS, 26990921014SLuciano Coelho resp, sizeof(*resp)); 27090921014SLuciano Coelho 27190921014SLuciano Coelho if (ret < 0) { 27290921014SLuciano Coelho wl1251_warning("failed to read data path parameters: %d", ret); 27390921014SLuciano Coelho goto out; 27490921014SLuciano Coelho } else if (resp->header.cmd.status != CMD_STATUS_SUCCESS) { 27590921014SLuciano Coelho wl1251_warning("data path parameter acx status failed"); 27690921014SLuciano Coelho ret = -EIO; 27790921014SLuciano Coelho goto out; 27890921014SLuciano Coelho } 27990921014SLuciano Coelho 28090921014SLuciano Coelho out: 28190921014SLuciano Coelho kfree(params); 28290921014SLuciano Coelho return ret; 28390921014SLuciano Coelho } 28490921014SLuciano Coelho 28590921014SLuciano Coelho int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time) 28690921014SLuciano Coelho { 28790921014SLuciano Coelho struct acx_rx_msdu_lifetime *acx; 28890921014SLuciano Coelho int ret; 28990921014SLuciano Coelho 29090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rx msdu life time"); 29190921014SLuciano Coelho 29290921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 29360ce473eSJing Wang if (!acx) 29460ce473eSJing Wang return -ENOMEM; 29590921014SLuciano Coelho 29690921014SLuciano Coelho acx->lifetime = life_time; 29790921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME, 29890921014SLuciano Coelho acx, sizeof(*acx)); 29990921014SLuciano Coelho if (ret < 0) { 30090921014SLuciano Coelho wl1251_warning("failed to set rx msdu life time: %d", ret); 30190921014SLuciano Coelho goto out; 30290921014SLuciano Coelho } 30390921014SLuciano Coelho 30490921014SLuciano Coelho out: 30590921014SLuciano Coelho kfree(acx); 30690921014SLuciano Coelho return ret; 30790921014SLuciano Coelho } 30890921014SLuciano Coelho 30990921014SLuciano Coelho int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter) 31090921014SLuciano Coelho { 31190921014SLuciano Coelho struct acx_rx_config *rx_config; 31290921014SLuciano Coelho int ret; 31390921014SLuciano Coelho 31490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rx config"); 31590921014SLuciano Coelho 31690921014SLuciano Coelho rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL); 31760ce473eSJing Wang if (!rx_config) 31860ce473eSJing Wang return -ENOMEM; 31990921014SLuciano Coelho 32090921014SLuciano Coelho rx_config->config_options = config; 32190921014SLuciano Coelho rx_config->filter_options = filter; 32290921014SLuciano Coelho 32390921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_RX_CFG, 32490921014SLuciano Coelho rx_config, sizeof(*rx_config)); 32590921014SLuciano Coelho if (ret < 0) { 32690921014SLuciano Coelho wl1251_warning("failed to set rx config: %d", ret); 32790921014SLuciano Coelho goto out; 32890921014SLuciano Coelho } 32990921014SLuciano Coelho 33090921014SLuciano Coelho out: 33190921014SLuciano Coelho kfree(rx_config); 33290921014SLuciano Coelho return ret; 33390921014SLuciano Coelho } 33490921014SLuciano Coelho 33590921014SLuciano Coelho int wl1251_acx_pd_threshold(struct wl1251 *wl) 33690921014SLuciano Coelho { 33790921014SLuciano Coelho struct acx_packet_detection *pd; 33890921014SLuciano Coelho int ret; 33990921014SLuciano Coelho 34090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx data pd threshold"); 34190921014SLuciano Coelho 34290921014SLuciano Coelho pd = kzalloc(sizeof(*pd), GFP_KERNEL); 34360ce473eSJing Wang if (!pd) 34460ce473eSJing Wang return -ENOMEM; 34590921014SLuciano Coelho 34690921014SLuciano Coelho /* FIXME: threshold value not set */ 34790921014SLuciano Coelho 34890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd)); 34990921014SLuciano Coelho if (ret < 0) { 35090921014SLuciano Coelho wl1251_warning("failed to set pd threshold: %d", ret); 35190921014SLuciano Coelho goto out; 35290921014SLuciano Coelho } 35390921014SLuciano Coelho 35490921014SLuciano Coelho out: 35590921014SLuciano Coelho kfree(pd); 35690921014SLuciano Coelho return ret; 35790921014SLuciano Coelho } 35890921014SLuciano Coelho 35990921014SLuciano Coelho int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time) 36090921014SLuciano Coelho { 36190921014SLuciano Coelho struct acx_slot *slot; 36290921014SLuciano Coelho int ret; 36390921014SLuciano Coelho 36490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx slot"); 36590921014SLuciano Coelho 36690921014SLuciano Coelho slot = kzalloc(sizeof(*slot), GFP_KERNEL); 36760ce473eSJing Wang if (!slot) 36860ce473eSJing Wang return -ENOMEM; 36990921014SLuciano Coelho 37090921014SLuciano Coelho slot->wone_index = STATION_WONE_INDEX; 37190921014SLuciano Coelho slot->slot_time = slot_time; 37290921014SLuciano Coelho 37390921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot)); 37490921014SLuciano Coelho if (ret < 0) { 37590921014SLuciano Coelho wl1251_warning("failed to set slot time: %d", ret); 37690921014SLuciano Coelho goto out; 37790921014SLuciano Coelho } 37890921014SLuciano Coelho 37990921014SLuciano Coelho out: 38090921014SLuciano Coelho kfree(slot); 38190921014SLuciano Coelho return ret; 38290921014SLuciano Coelho } 38390921014SLuciano Coelho 3849ed74ba0SDavid Gnedt int wl1251_acx_group_address_tbl(struct wl1251 *wl, bool enable, 3859ed74ba0SDavid Gnedt void *mc_list, u32 mc_list_len) 38690921014SLuciano Coelho { 38790921014SLuciano Coelho struct acx_dot11_grp_addr_tbl *acx; 38890921014SLuciano Coelho int ret; 38990921014SLuciano Coelho 39090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx group address tbl"); 39190921014SLuciano Coelho 39290921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 39360ce473eSJing Wang if (!acx) 39460ce473eSJing Wang return -ENOMEM; 39590921014SLuciano Coelho 39690921014SLuciano Coelho /* MAC filtering */ 3979ed74ba0SDavid Gnedt acx->enabled = enable; 3989ed74ba0SDavid Gnedt acx->num_groups = mc_list_len; 3999ed74ba0SDavid Gnedt memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN); 40090921014SLuciano Coelho 40190921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL, 40290921014SLuciano Coelho acx, sizeof(*acx)); 40390921014SLuciano Coelho if (ret < 0) { 40490921014SLuciano Coelho wl1251_warning("failed to set group addr table: %d", ret); 40590921014SLuciano Coelho goto out; 40690921014SLuciano Coelho } 40790921014SLuciano Coelho 40890921014SLuciano Coelho out: 40990921014SLuciano Coelho kfree(acx); 41090921014SLuciano Coelho return ret; 41190921014SLuciano Coelho } 41290921014SLuciano Coelho 41390921014SLuciano Coelho int wl1251_acx_service_period_timeout(struct wl1251 *wl) 41490921014SLuciano Coelho { 41590921014SLuciano Coelho struct acx_rx_timeout *rx_timeout; 41690921014SLuciano Coelho int ret; 41790921014SLuciano Coelho 41890921014SLuciano Coelho rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL); 41960ce473eSJing Wang if (!rx_timeout) 42060ce473eSJing Wang return -ENOMEM; 42190921014SLuciano Coelho 42290921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx service period timeout"); 42390921014SLuciano Coelho 42490921014SLuciano Coelho rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF; 42590921014SLuciano Coelho rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF; 42690921014SLuciano Coelho 42790921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT, 42890921014SLuciano Coelho rx_timeout, sizeof(*rx_timeout)); 42990921014SLuciano Coelho if (ret < 0) { 43090921014SLuciano Coelho wl1251_warning("failed to set service period timeout: %d", 43190921014SLuciano Coelho ret); 43290921014SLuciano Coelho goto out; 43390921014SLuciano Coelho } 43490921014SLuciano Coelho 43590921014SLuciano Coelho out: 43690921014SLuciano Coelho kfree(rx_timeout); 43790921014SLuciano Coelho return ret; 43890921014SLuciano Coelho } 43990921014SLuciano Coelho 44090921014SLuciano Coelho int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold) 44190921014SLuciano Coelho { 44290921014SLuciano Coelho struct acx_rts_threshold *rts; 44390921014SLuciano Coelho int ret; 44490921014SLuciano Coelho 44590921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rts threshold"); 44690921014SLuciano Coelho 44790921014SLuciano Coelho rts = kzalloc(sizeof(*rts), GFP_KERNEL); 44860ce473eSJing Wang if (!rts) 44960ce473eSJing Wang return -ENOMEM; 45090921014SLuciano Coelho 45190921014SLuciano Coelho rts->threshold = rts_threshold; 45290921014SLuciano Coelho 45390921014SLuciano Coelho ret = wl1251_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); 45490921014SLuciano Coelho if (ret < 0) { 45590921014SLuciano Coelho wl1251_warning("failed to set rts threshold: %d", ret); 45690921014SLuciano Coelho goto out; 45790921014SLuciano Coelho } 45890921014SLuciano Coelho 45990921014SLuciano Coelho out: 46090921014SLuciano Coelho kfree(rts); 46190921014SLuciano Coelho return ret; 46290921014SLuciano Coelho } 46390921014SLuciano Coelho 46490921014SLuciano Coelho int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter) 46590921014SLuciano Coelho { 46690921014SLuciano Coelho struct acx_beacon_filter_option *beacon_filter; 46790921014SLuciano Coelho int ret; 46890921014SLuciano Coelho 46990921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx beacon filter opt"); 47090921014SLuciano Coelho 47190921014SLuciano Coelho beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL); 47260ce473eSJing Wang if (!beacon_filter) 47360ce473eSJing Wang return -ENOMEM; 47490921014SLuciano Coelho 47590921014SLuciano Coelho beacon_filter->enable = enable_filter; 47690921014SLuciano Coelho beacon_filter->max_num_beacons = 0; 47790921014SLuciano Coelho 47890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT, 47990921014SLuciano Coelho beacon_filter, sizeof(*beacon_filter)); 48090921014SLuciano Coelho if (ret < 0) { 48190921014SLuciano Coelho wl1251_warning("failed to set beacon filter opt: %d", ret); 48290921014SLuciano Coelho goto out; 48390921014SLuciano Coelho } 48490921014SLuciano Coelho 48590921014SLuciano Coelho out: 48690921014SLuciano Coelho kfree(beacon_filter); 48790921014SLuciano Coelho return ret; 48890921014SLuciano Coelho } 48990921014SLuciano Coelho 49090921014SLuciano Coelho int wl1251_acx_beacon_filter_table(struct wl1251 *wl) 49190921014SLuciano Coelho { 49290921014SLuciano Coelho struct acx_beacon_filter_ie_table *ie_table; 49390921014SLuciano Coelho int idx = 0; 49490921014SLuciano Coelho int ret; 49590921014SLuciano Coelho 49690921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx beacon filter table"); 49790921014SLuciano Coelho 49890921014SLuciano Coelho ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL); 49960ce473eSJing Wang if (!ie_table) 50060ce473eSJing Wang return -ENOMEM; 50190921014SLuciano Coelho 50290921014SLuciano Coelho /* configure default beacon pass-through rules */ 50390921014SLuciano Coelho ie_table->num_ie = 1; 50490921014SLuciano Coelho ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN; 50590921014SLuciano Coelho ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE; 50690921014SLuciano Coelho 50790921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE, 50890921014SLuciano Coelho ie_table, sizeof(*ie_table)); 50990921014SLuciano Coelho if (ret < 0) { 51090921014SLuciano Coelho wl1251_warning("failed to set beacon filter table: %d", ret); 51190921014SLuciano Coelho goto out; 51290921014SLuciano Coelho } 51390921014SLuciano Coelho 51490921014SLuciano Coelho out: 51590921014SLuciano Coelho kfree(ie_table); 51690921014SLuciano Coelho return ret; 51790921014SLuciano Coelho } 51890921014SLuciano Coelho 51990921014SLuciano Coelho int wl1251_acx_conn_monit_params(struct wl1251 *wl) 52090921014SLuciano Coelho { 52190921014SLuciano Coelho struct acx_conn_monit_params *acx; 52290921014SLuciano Coelho int ret; 52390921014SLuciano Coelho 52490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx connection monitor parameters"); 52590921014SLuciano Coelho 52690921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 52760ce473eSJing Wang if (!acx) 52860ce473eSJing Wang return -ENOMEM; 52990921014SLuciano Coelho 53090921014SLuciano Coelho acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD; 53190921014SLuciano Coelho acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT; 53290921014SLuciano Coelho 53390921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_CONN_MONIT_PARAMS, 53490921014SLuciano Coelho acx, sizeof(*acx)); 53590921014SLuciano Coelho if (ret < 0) { 53690921014SLuciano Coelho wl1251_warning("failed to set connection monitor " 53790921014SLuciano Coelho "parameters: %d", ret); 53890921014SLuciano Coelho goto out; 53990921014SLuciano Coelho } 54090921014SLuciano Coelho 54190921014SLuciano Coelho out: 54290921014SLuciano Coelho kfree(acx); 54390921014SLuciano Coelho return ret; 54490921014SLuciano Coelho } 54590921014SLuciano Coelho 54690921014SLuciano Coelho int wl1251_acx_sg_enable(struct wl1251 *wl) 54790921014SLuciano Coelho { 54890921014SLuciano Coelho struct acx_bt_wlan_coex *pta; 54990921014SLuciano Coelho int ret; 55090921014SLuciano Coelho 55190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx sg enable"); 55290921014SLuciano Coelho 55390921014SLuciano Coelho pta = kzalloc(sizeof(*pta), GFP_KERNEL); 55460ce473eSJing Wang if (!pta) 55560ce473eSJing Wang return -ENOMEM; 55690921014SLuciano Coelho 55790921014SLuciano Coelho pta->enable = SG_ENABLE; 55890921014SLuciano Coelho 55990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta)); 56090921014SLuciano Coelho if (ret < 0) { 56190921014SLuciano Coelho wl1251_warning("failed to set softgemini enable: %d", ret); 56290921014SLuciano Coelho goto out; 56390921014SLuciano Coelho } 56490921014SLuciano Coelho 56590921014SLuciano Coelho out: 56690921014SLuciano Coelho kfree(pta); 56790921014SLuciano Coelho return ret; 56890921014SLuciano Coelho } 56990921014SLuciano Coelho 57090921014SLuciano Coelho int wl1251_acx_sg_cfg(struct wl1251 *wl) 57190921014SLuciano Coelho { 57290921014SLuciano Coelho struct acx_bt_wlan_coex_param *param; 57390921014SLuciano Coelho int ret; 57490921014SLuciano Coelho 57590921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx sg cfg"); 57690921014SLuciano Coelho 57790921014SLuciano Coelho param = kzalloc(sizeof(*param), GFP_KERNEL); 57860ce473eSJing Wang if (!param) 57960ce473eSJing Wang return -ENOMEM; 58090921014SLuciano Coelho 58190921014SLuciano Coelho /* BT-WLAN coext parameters */ 58290921014SLuciano Coelho param->min_rate = RATE_INDEX_24MBPS; 58390921014SLuciano Coelho param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF; 58490921014SLuciano Coelho param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF; 58590921014SLuciano Coelho param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF; 58690921014SLuciano Coelho param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF; 58790921014SLuciano Coelho param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF; 58890921014SLuciano Coelho param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF; 58990921014SLuciano Coelho param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF; 59090921014SLuciano Coelho param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF; 59190921014SLuciano Coelho param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF; 59290921014SLuciano Coelho param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF; 59390921014SLuciano Coelho param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF; 59490921014SLuciano Coelho param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF; 59590921014SLuciano Coelho param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF; 59690921014SLuciano Coelho param->antenna_type = PTA_ANTENNA_TYPE_DEF; 59790921014SLuciano Coelho param->signal_type = PTA_SIGNALING_TYPE_DEF; 59890921014SLuciano Coelho param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF; 59990921014SLuciano Coelho param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF; 60090921014SLuciano Coelho param->max_cts = PTA_MAX_NUM_CTS_DEF; 60190921014SLuciano Coelho param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF; 60290921014SLuciano Coelho param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF; 60390921014SLuciano Coelho param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF; 60490921014SLuciano Coelho param->wlan_elp_hp = PTA_ELP_HP_DEF; 60590921014SLuciano Coelho param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF; 60690921014SLuciano Coelho param->ack_mode_dual_ant = PTA_ACK_MODE_DEF; 60790921014SLuciano Coelho param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF; 60890921014SLuciano Coelho param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF; 60990921014SLuciano Coelho param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF; 61090921014SLuciano Coelho 61190921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param)); 61290921014SLuciano Coelho if (ret < 0) { 61390921014SLuciano Coelho wl1251_warning("failed to set sg config: %d", ret); 61490921014SLuciano Coelho goto out; 61590921014SLuciano Coelho } 61690921014SLuciano Coelho 61790921014SLuciano Coelho out: 61890921014SLuciano Coelho kfree(param); 61990921014SLuciano Coelho return ret; 62090921014SLuciano Coelho } 62190921014SLuciano Coelho 62290921014SLuciano Coelho int wl1251_acx_cca_threshold(struct wl1251 *wl) 62390921014SLuciano Coelho { 62490921014SLuciano Coelho struct acx_energy_detection *detection; 62590921014SLuciano Coelho int ret; 62690921014SLuciano Coelho 62790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx cca threshold"); 62890921014SLuciano Coelho 62990921014SLuciano Coelho detection = kzalloc(sizeof(*detection), GFP_KERNEL); 63060ce473eSJing Wang if (!detection) 63160ce473eSJing Wang return -ENOMEM; 63290921014SLuciano Coelho 63390921014SLuciano Coelho detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D; 63490921014SLuciano Coelho detection->tx_energy_detection = 0; 63590921014SLuciano Coelho 63690921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD, 63790921014SLuciano Coelho detection, sizeof(*detection)); 63890921014SLuciano Coelho if (ret < 0) 63990921014SLuciano Coelho wl1251_warning("failed to set cca threshold: %d", ret); 64090921014SLuciano Coelho 64190921014SLuciano Coelho kfree(detection); 64290921014SLuciano Coelho return ret; 64390921014SLuciano Coelho } 64490921014SLuciano Coelho 64590921014SLuciano Coelho int wl1251_acx_bcn_dtim_options(struct wl1251 *wl) 64690921014SLuciano Coelho { 64790921014SLuciano Coelho struct acx_beacon_broadcast *bb; 64890921014SLuciano Coelho int ret; 64990921014SLuciano Coelho 65090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx bcn dtim options"); 65190921014SLuciano Coelho 65290921014SLuciano Coelho bb = kzalloc(sizeof(*bb), GFP_KERNEL); 65360ce473eSJing Wang if (!bb) 65460ce473eSJing Wang return -ENOMEM; 65590921014SLuciano Coelho 65690921014SLuciano Coelho bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE; 65790921014SLuciano Coelho bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE; 65890921014SLuciano Coelho bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE; 65990921014SLuciano Coelho bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF; 66090921014SLuciano Coelho 66190921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb)); 66290921014SLuciano Coelho if (ret < 0) { 66390921014SLuciano Coelho wl1251_warning("failed to set rx config: %d", ret); 66490921014SLuciano Coelho goto out; 66590921014SLuciano Coelho } 66690921014SLuciano Coelho 66790921014SLuciano Coelho out: 66890921014SLuciano Coelho kfree(bb); 66990921014SLuciano Coelho return ret; 67090921014SLuciano Coelho } 67190921014SLuciano Coelho 67290921014SLuciano Coelho int wl1251_acx_aid(struct wl1251 *wl, u16 aid) 67390921014SLuciano Coelho { 67490921014SLuciano Coelho struct acx_aid *acx_aid; 67590921014SLuciano Coelho int ret; 67690921014SLuciano Coelho 67790921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx aid"); 67890921014SLuciano Coelho 67990921014SLuciano Coelho acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL); 68060ce473eSJing Wang if (!acx_aid) 68160ce473eSJing Wang return -ENOMEM; 68290921014SLuciano Coelho 68390921014SLuciano Coelho acx_aid->aid = aid; 68490921014SLuciano Coelho 68590921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid)); 68690921014SLuciano Coelho if (ret < 0) { 68790921014SLuciano Coelho wl1251_warning("failed to set aid: %d", ret); 68890921014SLuciano Coelho goto out; 68990921014SLuciano Coelho } 69090921014SLuciano Coelho 69190921014SLuciano Coelho out: 69290921014SLuciano Coelho kfree(acx_aid); 69390921014SLuciano Coelho return ret; 69490921014SLuciano Coelho } 69590921014SLuciano Coelho 69690921014SLuciano Coelho int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask) 69790921014SLuciano Coelho { 69890921014SLuciano Coelho struct acx_event_mask *mask; 69990921014SLuciano Coelho int ret; 70090921014SLuciano Coelho 70190921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx event mbox mask"); 70290921014SLuciano Coelho 70390921014SLuciano Coelho mask = kzalloc(sizeof(*mask), GFP_KERNEL); 70460ce473eSJing Wang if (!mask) 70560ce473eSJing Wang return -ENOMEM; 70690921014SLuciano Coelho 70790921014SLuciano Coelho /* high event mask is unused */ 70890921014SLuciano Coelho mask->high_event_mask = 0xffffffff; 70990921014SLuciano Coelho 71090921014SLuciano Coelho mask->event_mask = event_mask; 71190921014SLuciano Coelho 71290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK, 71390921014SLuciano Coelho mask, sizeof(*mask)); 71490921014SLuciano Coelho if (ret < 0) { 71590921014SLuciano Coelho wl1251_warning("failed to set acx_event_mbox_mask: %d", ret); 71690921014SLuciano Coelho goto out; 71790921014SLuciano Coelho } 71890921014SLuciano Coelho 71990921014SLuciano Coelho out: 72090921014SLuciano Coelho kfree(mask); 72190921014SLuciano Coelho return ret; 72290921014SLuciano Coelho } 72390921014SLuciano Coelho 72490921014SLuciano Coelho int wl1251_acx_low_rssi(struct wl1251 *wl, s8 threshold, u8 weight, 72590921014SLuciano Coelho u8 depth, enum wl1251_acx_low_rssi_type type) 72690921014SLuciano Coelho { 72790921014SLuciano Coelho struct acx_low_rssi *rssi; 72890921014SLuciano Coelho int ret; 72990921014SLuciano Coelho 73090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx low rssi"); 73190921014SLuciano Coelho 73290921014SLuciano Coelho rssi = kzalloc(sizeof(*rssi), GFP_KERNEL); 73390921014SLuciano Coelho if (!rssi) 73490921014SLuciano Coelho return -ENOMEM; 73590921014SLuciano Coelho 73690921014SLuciano Coelho rssi->threshold = threshold; 73790921014SLuciano Coelho rssi->weight = weight; 73890921014SLuciano Coelho rssi->depth = depth; 73990921014SLuciano Coelho rssi->type = type; 74090921014SLuciano Coelho 74190921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_LOW_RSSI, rssi, sizeof(*rssi)); 74290921014SLuciano Coelho if (ret < 0) 74390921014SLuciano Coelho wl1251_warning("failed to set low rssi threshold: %d", ret); 74490921014SLuciano Coelho 74590921014SLuciano Coelho kfree(rssi); 74690921014SLuciano Coelho return ret; 74790921014SLuciano Coelho } 74890921014SLuciano Coelho 74990921014SLuciano Coelho int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble) 75090921014SLuciano Coelho { 75190921014SLuciano Coelho struct acx_preamble *acx; 75290921014SLuciano Coelho int ret; 75390921014SLuciano Coelho 75490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx_set_preamble"); 75590921014SLuciano Coelho 75690921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 75760ce473eSJing Wang if (!acx) 75860ce473eSJing Wang return -ENOMEM; 75990921014SLuciano Coelho 76090921014SLuciano Coelho acx->preamble = preamble; 76190921014SLuciano Coelho 76290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx)); 76390921014SLuciano Coelho if (ret < 0) { 76490921014SLuciano Coelho wl1251_warning("Setting of preamble failed: %d", ret); 76590921014SLuciano Coelho goto out; 76690921014SLuciano Coelho } 76790921014SLuciano Coelho 76890921014SLuciano Coelho out: 76990921014SLuciano Coelho kfree(acx); 77090921014SLuciano Coelho return ret; 77190921014SLuciano Coelho } 77290921014SLuciano Coelho 77390921014SLuciano Coelho int wl1251_acx_cts_protect(struct wl1251 *wl, 77490921014SLuciano Coelho enum acx_ctsprotect_type ctsprotect) 77590921014SLuciano Coelho { 77690921014SLuciano Coelho struct acx_ctsprotect *acx; 77790921014SLuciano Coelho int ret; 77890921014SLuciano Coelho 77990921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect"); 78090921014SLuciano Coelho 78190921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 78260ce473eSJing Wang if (!acx) 78360ce473eSJing Wang return -ENOMEM; 78490921014SLuciano Coelho 78590921014SLuciano Coelho acx->ctsprotect = ctsprotect; 78690921014SLuciano Coelho 78790921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx)); 78890921014SLuciano Coelho if (ret < 0) { 78990921014SLuciano Coelho wl1251_warning("Setting of ctsprotect failed: %d", ret); 79090921014SLuciano Coelho goto out; 79190921014SLuciano Coelho } 79290921014SLuciano Coelho 79390921014SLuciano Coelho out: 79490921014SLuciano Coelho kfree(acx); 79590921014SLuciano Coelho return ret; 79690921014SLuciano Coelho } 79790921014SLuciano Coelho 79890921014SLuciano Coelho int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime) 79990921014SLuciano Coelho { 80090921014SLuciano Coelho struct acx_tsf_info *tsf_info; 80190921014SLuciano Coelho int ret; 80290921014SLuciano Coelho 80390921014SLuciano Coelho tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL); 80460ce473eSJing Wang if (!tsf_info) 80560ce473eSJing Wang return -ENOMEM; 80690921014SLuciano Coelho 80790921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO, 80890921014SLuciano Coelho tsf_info, sizeof(*tsf_info)); 80990921014SLuciano Coelho if (ret < 0) { 81090921014SLuciano Coelho wl1251_warning("ACX_FW_REV interrogate failed"); 81190921014SLuciano Coelho goto out; 81290921014SLuciano Coelho } 81390921014SLuciano Coelho 81490921014SLuciano Coelho *mactime = tsf_info->current_tsf_lsb | 815cae6247dSGrazvydas Ignotas ((u64)tsf_info->current_tsf_msb << 32); 81690921014SLuciano Coelho 81790921014SLuciano Coelho out: 81890921014SLuciano Coelho kfree(tsf_info); 81990921014SLuciano Coelho return ret; 82090921014SLuciano Coelho } 82190921014SLuciano Coelho 82290921014SLuciano Coelho int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats) 82390921014SLuciano Coelho { 82490921014SLuciano Coelho int ret; 82590921014SLuciano Coelho 82690921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx statistics"); 82790921014SLuciano Coelho 82890921014SLuciano Coelho ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats, 82990921014SLuciano Coelho sizeof(*stats)); 83090921014SLuciano Coelho if (ret < 0) { 83190921014SLuciano Coelho wl1251_warning("acx statistics failed: %d", ret); 83290921014SLuciano Coelho return -ENOMEM; 83390921014SLuciano Coelho } 83490921014SLuciano Coelho 83590921014SLuciano Coelho return 0; 83690921014SLuciano Coelho } 83790921014SLuciano Coelho 83890921014SLuciano Coelho int wl1251_acx_rate_policies(struct wl1251 *wl) 83990921014SLuciano Coelho { 84090921014SLuciano Coelho struct acx_rate_policy *acx; 84190921014SLuciano Coelho int ret = 0; 84290921014SLuciano Coelho 84390921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx rate policies"); 84490921014SLuciano Coelho 84590921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 84660ce473eSJing Wang if (!acx) 84760ce473eSJing Wang return -ENOMEM; 84890921014SLuciano Coelho 84990921014SLuciano Coelho /* configure one default (one-size-fits-all) rate class */ 850*3d49da74SDavid Gnedt acx->rate_class_cnt = 2; 85190921014SLuciano Coelho acx->rate_class[0].enabled_rates = ACX_RATE_MASK_UNSPECIFIED; 85290921014SLuciano Coelho acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT; 85390921014SLuciano Coelho acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT; 85490921014SLuciano Coelho acx->rate_class[0].aflags = 0; 85590921014SLuciano Coelho 856*3d49da74SDavid Gnedt /* no-retry rate class */ 857*3d49da74SDavid Gnedt acx->rate_class[1].enabled_rates = ACX_RATE_MASK_UNSPECIFIED; 858*3d49da74SDavid Gnedt acx->rate_class[1].short_retry_limit = 0; 859*3d49da74SDavid Gnedt acx->rate_class[1].long_retry_limit = 0; 860*3d49da74SDavid Gnedt acx->rate_class[1].aflags = 0; 861*3d49da74SDavid Gnedt 86290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx)); 86390921014SLuciano Coelho if (ret < 0) { 86490921014SLuciano Coelho wl1251_warning("Setting of rate policies failed: %d", ret); 86590921014SLuciano Coelho goto out; 86690921014SLuciano Coelho } 86790921014SLuciano Coelho 86890921014SLuciano Coelho out: 86990921014SLuciano Coelho kfree(acx); 87090921014SLuciano Coelho return ret; 87190921014SLuciano Coelho } 87290921014SLuciano Coelho 87390921014SLuciano Coelho int wl1251_acx_mem_cfg(struct wl1251 *wl) 87490921014SLuciano Coelho { 87590921014SLuciano Coelho struct wl1251_acx_config_memory *mem_conf; 87690921014SLuciano Coelho int ret, i; 87790921014SLuciano Coelho 87890921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx mem cfg"); 87990921014SLuciano Coelho 88090921014SLuciano Coelho mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL); 88160ce473eSJing Wang if (!mem_conf) 88260ce473eSJing Wang return -ENOMEM; 88390921014SLuciano Coelho 88490921014SLuciano Coelho /* memory config */ 88590921014SLuciano Coelho mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS); 88690921014SLuciano Coelho mem_conf->mem_config.rx_mem_block_num = 35; 88790921014SLuciano Coelho mem_conf->mem_config.tx_min_mem_block_num = 64; 88890921014SLuciano Coelho mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES; 88990921014SLuciano Coelho mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING; 89090921014SLuciano Coelho mem_conf->mem_config.num_ssid_profiles = 1; 89190921014SLuciano Coelho mem_conf->mem_config.debug_buffer_size = 89290921014SLuciano Coelho cpu_to_le16(TRACE_BUFFER_MAX_SIZE); 89390921014SLuciano Coelho 89490921014SLuciano Coelho /* RX queue config */ 89590921014SLuciano Coelho mem_conf->rx_queue_config.dma_address = 0; 89690921014SLuciano Coelho mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF; 89790921014SLuciano Coelho mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY; 89890921014SLuciano Coelho mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE; 89990921014SLuciano Coelho 90090921014SLuciano Coelho /* TX queue config */ 90190921014SLuciano Coelho for (i = 0; i < MAX_TX_QUEUES; i++) { 90290921014SLuciano Coelho mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF; 90390921014SLuciano Coelho mem_conf->tx_queue_config[i].attributes = i; 90490921014SLuciano Coelho } 90590921014SLuciano Coelho 90690921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf, 90790921014SLuciano Coelho sizeof(*mem_conf)); 90890921014SLuciano Coelho if (ret < 0) { 90990921014SLuciano Coelho wl1251_warning("wl1251 mem config failed: %d", ret); 91090921014SLuciano Coelho goto out; 91190921014SLuciano Coelho } 91290921014SLuciano Coelho 91390921014SLuciano Coelho out: 91490921014SLuciano Coelho kfree(mem_conf); 91590921014SLuciano Coelho return ret; 91690921014SLuciano Coelho } 91790921014SLuciano Coelho 91890921014SLuciano Coelho int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim) 91990921014SLuciano Coelho { 92090921014SLuciano Coelho struct wl1251_acx_wr_tbtt_and_dtim *acx; 92190921014SLuciano Coelho int ret; 92290921014SLuciano Coelho 92390921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx tbtt and dtim"); 92490921014SLuciano Coelho 92590921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 92660ce473eSJing Wang if (!acx) 92760ce473eSJing Wang return -ENOMEM; 92890921014SLuciano Coelho 92990921014SLuciano Coelho acx->tbtt = tbtt; 93090921014SLuciano Coelho acx->dtim = dtim; 93190921014SLuciano Coelho 93290921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_WR_TBTT_AND_DTIM, 93390921014SLuciano Coelho acx, sizeof(*acx)); 93490921014SLuciano Coelho if (ret < 0) { 93590921014SLuciano Coelho wl1251_warning("failed to set tbtt and dtim: %d", ret); 93690921014SLuciano Coelho goto out; 93790921014SLuciano Coelho } 93890921014SLuciano Coelho 93990921014SLuciano Coelho out: 94090921014SLuciano Coelho kfree(acx); 94190921014SLuciano Coelho return ret; 94290921014SLuciano Coelho } 94390921014SLuciano Coelho 94490921014SLuciano Coelho int wl1251_acx_bet_enable(struct wl1251 *wl, enum wl1251_acx_bet_mode mode, 94590921014SLuciano Coelho u8 max_consecutive) 94690921014SLuciano Coelho { 94790921014SLuciano Coelho struct wl1251_acx_bet_enable *acx; 94890921014SLuciano Coelho int ret; 94990921014SLuciano Coelho 95090921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx bet enable"); 95190921014SLuciano Coelho 95290921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 95360ce473eSJing Wang if (!acx) 95460ce473eSJing Wang return -ENOMEM; 95590921014SLuciano Coelho 95690921014SLuciano Coelho acx->enable = mode; 95790921014SLuciano Coelho acx->max_consecutive = max_consecutive; 95890921014SLuciano Coelho 95990921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_BET_ENABLE, acx, sizeof(*acx)); 96090921014SLuciano Coelho if (ret < 0) { 96190921014SLuciano Coelho wl1251_warning("wl1251 acx bet enable failed: %d", ret); 96290921014SLuciano Coelho goto out; 96390921014SLuciano Coelho } 96490921014SLuciano Coelho 96590921014SLuciano Coelho out: 96690921014SLuciano Coelho kfree(acx); 96790921014SLuciano Coelho return ret; 96890921014SLuciano Coelho } 96990921014SLuciano Coelho 970204cc5c4SDavid Gnedt int wl1251_acx_arp_ip_filter(struct wl1251 *wl, bool enable, __be32 address) 971204cc5c4SDavid Gnedt { 972204cc5c4SDavid Gnedt struct wl1251_acx_arp_filter *acx; 973204cc5c4SDavid Gnedt int ret; 974204cc5c4SDavid Gnedt 975204cc5c4SDavid Gnedt wl1251_debug(DEBUG_ACX, "acx arp ip filter, enable: %d", enable); 976204cc5c4SDavid Gnedt 977204cc5c4SDavid Gnedt acx = kzalloc(sizeof(*acx), GFP_KERNEL); 978204cc5c4SDavid Gnedt if (!acx) 979204cc5c4SDavid Gnedt return -ENOMEM; 980204cc5c4SDavid Gnedt 981204cc5c4SDavid Gnedt acx->version = ACX_IPV4_VERSION; 982204cc5c4SDavid Gnedt acx->enable = enable; 983204cc5c4SDavid Gnedt 984204cc5c4SDavid Gnedt if (enable) 985204cc5c4SDavid Gnedt memcpy(acx->address, &address, ACX_IPV4_ADDR_SIZE); 986204cc5c4SDavid Gnedt 987204cc5c4SDavid Gnedt ret = wl1251_cmd_configure(wl, ACX_ARP_IP_FILTER, 988204cc5c4SDavid Gnedt acx, sizeof(*acx)); 989204cc5c4SDavid Gnedt if (ret < 0) 990204cc5c4SDavid Gnedt wl1251_warning("failed to set arp ip filter: %d", ret); 991204cc5c4SDavid Gnedt 992204cc5c4SDavid Gnedt kfree(acx); 993204cc5c4SDavid Gnedt return ret; 994204cc5c4SDavid Gnedt } 995204cc5c4SDavid Gnedt 99690921014SLuciano Coelho int wl1251_acx_ac_cfg(struct wl1251 *wl, u8 ac, u8 cw_min, u16 cw_max, 99790921014SLuciano Coelho u8 aifs, u16 txop) 99890921014SLuciano Coelho { 99990921014SLuciano Coelho struct wl1251_acx_ac_cfg *acx; 100090921014SLuciano Coelho int ret = 0; 100190921014SLuciano Coelho 100290921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d " 100390921014SLuciano Coelho "aifs %d txop %d", ac, cw_min, cw_max, aifs, txop); 100490921014SLuciano Coelho 100590921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 100660ce473eSJing Wang if (!acx) 100760ce473eSJing Wang return -ENOMEM; 100890921014SLuciano Coelho 100990921014SLuciano Coelho acx->ac = ac; 101090921014SLuciano Coelho acx->cw_min = cw_min; 101190921014SLuciano Coelho acx->cw_max = cw_max; 101290921014SLuciano Coelho acx->aifsn = aifs; 101390921014SLuciano Coelho acx->txop_limit = txop; 101490921014SLuciano Coelho 101590921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx)); 101690921014SLuciano Coelho if (ret < 0) { 101790921014SLuciano Coelho wl1251_warning("acx ac cfg failed: %d", ret); 101890921014SLuciano Coelho goto out; 101990921014SLuciano Coelho } 102090921014SLuciano Coelho 102190921014SLuciano Coelho out: 102290921014SLuciano Coelho kfree(acx); 102390921014SLuciano Coelho return ret; 102490921014SLuciano Coelho } 102590921014SLuciano Coelho 102690921014SLuciano Coelho int wl1251_acx_tid_cfg(struct wl1251 *wl, u8 queue, 102790921014SLuciano Coelho enum wl1251_acx_channel_type type, 102890921014SLuciano Coelho u8 tsid, enum wl1251_acx_ps_scheme ps_scheme, 102990921014SLuciano Coelho enum wl1251_acx_ack_policy ack_policy) 103090921014SLuciano Coelho { 103190921014SLuciano Coelho struct wl1251_acx_tid_cfg *acx; 103290921014SLuciano Coelho int ret = 0; 103390921014SLuciano Coelho 103490921014SLuciano Coelho wl1251_debug(DEBUG_ACX, "acx tid cfg %d type %d tsid %d " 103590921014SLuciano Coelho "ps_scheme %d ack_policy %d", queue, type, tsid, 103690921014SLuciano Coelho ps_scheme, ack_policy); 103790921014SLuciano Coelho 103890921014SLuciano Coelho acx = kzalloc(sizeof(*acx), GFP_KERNEL); 103960ce473eSJing Wang if (!acx) 104060ce473eSJing Wang return -ENOMEM; 104190921014SLuciano Coelho 104290921014SLuciano Coelho acx->queue = queue; 104390921014SLuciano Coelho acx->type = type; 104490921014SLuciano Coelho acx->tsid = tsid; 104590921014SLuciano Coelho acx->ps_scheme = ps_scheme; 104690921014SLuciano Coelho acx->ack_policy = ack_policy; 104790921014SLuciano Coelho 104890921014SLuciano Coelho ret = wl1251_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx)); 104990921014SLuciano Coelho if (ret < 0) { 105090921014SLuciano Coelho wl1251_warning("acx tid cfg failed: %d", ret); 105190921014SLuciano Coelho goto out; 105290921014SLuciano Coelho } 105390921014SLuciano Coelho 105490921014SLuciano Coelho out: 105590921014SLuciano Coelho kfree(acx); 105690921014SLuciano Coelho return ret; 105790921014SLuciano Coelho } 1058