1fcab1890SEliad Peller /* 2fcab1890SEliad Peller * This file is part of wl18xx 3fcab1890SEliad Peller * 4fcab1890SEliad Peller * Copyright (C) 2011 Texas Instruments Inc. 5fcab1890SEliad Peller * 6fcab1890SEliad Peller * This program is free software; you can redistribute it and/or 7fcab1890SEliad Peller * modify it under the terms of the GNU General Public License 8fcab1890SEliad Peller * version 2 as published by the Free Software Foundation. 9fcab1890SEliad Peller * 10fcab1890SEliad Peller * This program is distributed in the hope that it will be useful, but 11fcab1890SEliad Peller * WITHOUT ANY WARRANTY; without even the implied warranty of 12fcab1890SEliad Peller * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13fcab1890SEliad Peller * General Public License for more details. 14fcab1890SEliad Peller * 15fcab1890SEliad Peller * You should have received a copy of the GNU General Public License 16fcab1890SEliad Peller * along with this program; if not, write to the Free Software 17fcab1890SEliad Peller * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18fcab1890SEliad Peller * 02110-1301 USA 19fcab1890SEliad Peller * 20fcab1890SEliad Peller */ 21fcab1890SEliad Peller 22fcab1890SEliad Peller #include "../wlcore/cmd.h" 23fcab1890SEliad Peller #include "../wlcore/debug.h" 24fcab1890SEliad Peller #include "../wlcore/hw_ops.h" 25fcab1890SEliad Peller 26fcab1890SEliad Peller #include "cmd.h" 27fcab1890SEliad Peller 28fcab1890SEliad Peller int wl18xx_cmd_channel_switch(struct wl1271 *wl, 29fcab1890SEliad Peller struct wl12xx_vif *wlvif, 30fcab1890SEliad Peller struct ieee80211_channel_switch *ch_switch) 31fcab1890SEliad Peller { 32fcab1890SEliad Peller struct wl18xx_cmd_channel_switch *cmd; 33fcab1890SEliad Peller u32 supported_rates; 34fcab1890SEliad Peller int ret; 35fcab1890SEliad Peller 36fcab1890SEliad Peller wl1271_debug(DEBUG_ACX, "cmd channel switch"); 37fcab1890SEliad Peller 38fcab1890SEliad Peller cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 39fcab1890SEliad Peller if (!cmd) { 40fcab1890SEliad Peller ret = -ENOMEM; 41fcab1890SEliad Peller goto out; 42fcab1890SEliad Peller } 43fcab1890SEliad Peller 44fcab1890SEliad Peller cmd->role_id = wlvif->role_id; 4585220d71SJohannes Berg cmd->channel = ch_switch->chandef.chan->hw_value; 46fcab1890SEliad Peller cmd->switch_time = ch_switch->count; 47fcab1890SEliad Peller cmd->stop_tx = ch_switch->block_tx; 48fcab1890SEliad Peller 4985220d71SJohannes Berg switch (ch_switch->chandef.chan->band) { 50fcab1890SEliad Peller case IEEE80211_BAND_2GHZ: 51fcab1890SEliad Peller cmd->band = WLCORE_BAND_2_4GHZ; 52fcab1890SEliad Peller break; 53fcab1890SEliad Peller case IEEE80211_BAND_5GHZ: 54fcab1890SEliad Peller cmd->band = WLCORE_BAND_5GHZ; 55fcab1890SEliad Peller break; 56fcab1890SEliad Peller default: 57fcab1890SEliad Peller wl1271_error("invalid channel switch band: %d", 5885220d71SJohannes Berg ch_switch->chandef.chan->band); 59fcab1890SEliad Peller ret = -EINVAL; 60fcab1890SEliad Peller goto out_free; 61fcab1890SEliad Peller } 62fcab1890SEliad Peller 63fcab1890SEliad Peller supported_rates = CONF_TX_ENABLED_RATES | CONF_TX_MCS_RATES | 64fcab1890SEliad Peller wlcore_hw_sta_get_ap_rate_mask(wl, wlvif); 65fcab1890SEliad Peller if (wlvif->p2p) 66fcab1890SEliad Peller supported_rates &= ~CONF_TX_CCK_RATES; 67fcab1890SEliad Peller cmd->local_supported_rates = cpu_to_le32(supported_rates); 68fcab1890SEliad Peller cmd->channel_type = wlvif->channel_type; 69fcab1890SEliad Peller 70fcab1890SEliad Peller ret = wl1271_cmd_send(wl, CMD_CHANNEL_SWITCH, cmd, sizeof(*cmd), 0); 71fcab1890SEliad Peller if (ret < 0) { 72fcab1890SEliad Peller wl1271_error("failed to send channel switch command"); 73fcab1890SEliad Peller goto out_free; 74fcab1890SEliad Peller } 75fcab1890SEliad Peller 76fcab1890SEliad Peller out_free: 77fcab1890SEliad Peller kfree(cmd); 78fcab1890SEliad Peller out: 79fcab1890SEliad Peller return ret; 80fcab1890SEliad Peller } 81*ccb1df94SEliad Peller 82*ccb1df94SEliad Peller int wl18xx_cmd_smart_config_start(struct wl1271 *wl, u32 group_bitmap) 83*ccb1df94SEliad Peller { 84*ccb1df94SEliad Peller struct wl18xx_cmd_smart_config_start *cmd; 85*ccb1df94SEliad Peller int ret = 0; 86*ccb1df94SEliad Peller 87*ccb1df94SEliad Peller wl1271_debug(DEBUG_CMD, "cmd smart config start group_bitmap=0x%x", 88*ccb1df94SEliad Peller group_bitmap); 89*ccb1df94SEliad Peller 90*ccb1df94SEliad Peller cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 91*ccb1df94SEliad Peller if (!cmd) { 92*ccb1df94SEliad Peller ret = -ENOMEM; 93*ccb1df94SEliad Peller goto out; 94*ccb1df94SEliad Peller } 95*ccb1df94SEliad Peller 96*ccb1df94SEliad Peller cmd->group_id_bitmask = cpu_to_le32(group_bitmap); 97*ccb1df94SEliad Peller 98*ccb1df94SEliad Peller ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_START, cmd, sizeof(*cmd), 0); 99*ccb1df94SEliad Peller if (ret < 0) { 100*ccb1df94SEliad Peller wl1271_error("failed to send smart config start command"); 101*ccb1df94SEliad Peller goto out_free; 102*ccb1df94SEliad Peller } 103*ccb1df94SEliad Peller 104*ccb1df94SEliad Peller out_free: 105*ccb1df94SEliad Peller kfree(cmd); 106*ccb1df94SEliad Peller out: 107*ccb1df94SEliad Peller return ret; 108*ccb1df94SEliad Peller } 109*ccb1df94SEliad Peller 110*ccb1df94SEliad Peller int wl18xx_cmd_smart_config_stop(struct wl1271 *wl) 111*ccb1df94SEliad Peller { 112*ccb1df94SEliad Peller struct wl1271_cmd_header *cmd; 113*ccb1df94SEliad Peller int ret = 0; 114*ccb1df94SEliad Peller 115*ccb1df94SEliad Peller wl1271_debug(DEBUG_CMD, "cmd smart config stop"); 116*ccb1df94SEliad Peller 117*ccb1df94SEliad Peller cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 118*ccb1df94SEliad Peller if (!cmd) { 119*ccb1df94SEliad Peller ret = -ENOMEM; 120*ccb1df94SEliad Peller goto out; 121*ccb1df94SEliad Peller } 122*ccb1df94SEliad Peller 123*ccb1df94SEliad Peller ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_STOP, cmd, sizeof(*cmd), 0); 124*ccb1df94SEliad Peller if (ret < 0) { 125*ccb1df94SEliad Peller wl1271_error("failed to send smart config stop command"); 126*ccb1df94SEliad Peller goto out_free; 127*ccb1df94SEliad Peller } 128*ccb1df94SEliad Peller 129*ccb1df94SEliad Peller out_free: 130*ccb1df94SEliad Peller kfree(cmd); 131*ccb1df94SEliad Peller out: 132*ccb1df94SEliad Peller return ret; 133*ccb1df94SEliad Peller } 134*ccb1df94SEliad Peller 135*ccb1df94SEliad Peller int wl18xx_cmd_smart_config_set_group_key(struct wl1271 *wl, u16 group_id, 136*ccb1df94SEliad Peller u8 key_len, u8 *key) 137*ccb1df94SEliad Peller { 138*ccb1df94SEliad Peller struct wl18xx_cmd_smart_config_set_group_key *cmd; 139*ccb1df94SEliad Peller int ret = 0; 140*ccb1df94SEliad Peller 141*ccb1df94SEliad Peller wl1271_debug(DEBUG_CMD, "cmd smart config set group key id=0x%x", 142*ccb1df94SEliad Peller group_id); 143*ccb1df94SEliad Peller 144*ccb1df94SEliad Peller if (key_len != sizeof(cmd->key)) { 145*ccb1df94SEliad Peller wl1271_error("invalid group key size: %d", key_len); 146*ccb1df94SEliad Peller return -E2BIG; 147*ccb1df94SEliad Peller } 148*ccb1df94SEliad Peller 149*ccb1df94SEliad Peller cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 150*ccb1df94SEliad Peller if (!cmd) { 151*ccb1df94SEliad Peller ret = -ENOMEM; 152*ccb1df94SEliad Peller goto out; 153*ccb1df94SEliad Peller } 154*ccb1df94SEliad Peller 155*ccb1df94SEliad Peller cmd->group_id = cpu_to_le32(group_id); 156*ccb1df94SEliad Peller memcpy(cmd->key, key, key_len); 157*ccb1df94SEliad Peller 158*ccb1df94SEliad Peller ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_SET_GROUP_KEY, cmd, 159*ccb1df94SEliad Peller sizeof(*cmd), 0); 160*ccb1df94SEliad Peller if (ret < 0) { 161*ccb1df94SEliad Peller wl1271_error("failed to send smart config set group key cmd"); 162*ccb1df94SEliad Peller goto out_free; 163*ccb1df94SEliad Peller } 164*ccb1df94SEliad Peller 165*ccb1df94SEliad Peller out_free: 166*ccb1df94SEliad Peller kfree(cmd); 167*ccb1df94SEliad Peller out: 168*ccb1df94SEliad Peller return ret; 169*ccb1df94SEliad Peller } 170