xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * NXP Wireless LAN device driver: station command response handling
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright 2011-2020 NXP
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * This software file (the "File") is distributed by NXP
7*4882a593Smuzhiyun  * under the terms of the GNU General Public License Version 2, June 1991
8*4882a593Smuzhiyun  * (the "License").  You may use, redistribute and/or modify this File in
9*4882a593Smuzhiyun  * accordance with the terms and conditions of the License, a copy of which
10*4882a593Smuzhiyun  * is available by writing to the Free Software Foundation, Inc.,
11*4882a593Smuzhiyun  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12*4882a593Smuzhiyun  * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15*4882a593Smuzhiyun  * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16*4882a593Smuzhiyun  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
17*4882a593Smuzhiyun  * this warranty disclaimer.
18*4882a593Smuzhiyun  */
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun #include "decl.h"
21*4882a593Smuzhiyun #include "ioctl.h"
22*4882a593Smuzhiyun #include "util.h"
23*4882a593Smuzhiyun #include "fw.h"
24*4882a593Smuzhiyun #include "main.h"
25*4882a593Smuzhiyun #include "wmm.h"
26*4882a593Smuzhiyun #include "11n.h"
27*4882a593Smuzhiyun #include "11ac.h"
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun /*
31*4882a593Smuzhiyun  * This function handles the command response error case.
32*4882a593Smuzhiyun  *
33*4882a593Smuzhiyun  * For scan response error, the function cancels all the pending
34*4882a593Smuzhiyun  * scan commands and generates an event to inform the applications
35*4882a593Smuzhiyun  * of the scan completion.
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  * For Power Save command failure, we do not retry enter PS
38*4882a593Smuzhiyun  * command in case of Ad-hoc mode.
39*4882a593Smuzhiyun  *
40*4882a593Smuzhiyun  * For all other response errors, the current command buffer is freed
41*4882a593Smuzhiyun  * and returned to the free command queue.
42*4882a593Smuzhiyun  */
43*4882a593Smuzhiyun static void
mwifiex_process_cmdresp_error(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)44*4882a593Smuzhiyun mwifiex_process_cmdresp_error(struct mwifiex_private *priv,
45*4882a593Smuzhiyun 			      struct host_cmd_ds_command *resp)
46*4882a593Smuzhiyun {
47*4882a593Smuzhiyun 	struct mwifiex_adapter *adapter = priv->adapter;
48*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_ps_mode_enh *pm;
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun 	mwifiex_dbg(adapter, ERROR,
51*4882a593Smuzhiyun 		    "CMD_RESP: cmd %#x error, result=%#x\n",
52*4882a593Smuzhiyun 		    resp->command, resp->result);
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun 	if (adapter->curr_cmd->wait_q_enabled)
55*4882a593Smuzhiyun 		adapter->cmd_wait_q.status = -1;
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun 	switch (le16_to_cpu(resp->command)) {
58*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_PS_MODE_ENH:
59*4882a593Smuzhiyun 		pm = &resp->params.psmode_enh;
60*4882a593Smuzhiyun 		mwifiex_dbg(adapter, ERROR,
61*4882a593Smuzhiyun 			    "PS_MODE_ENH cmd failed: result=0x%x action=0x%X\n",
62*4882a593Smuzhiyun 			    resp->result, le16_to_cpu(pm->action));
63*4882a593Smuzhiyun 		/* We do not re-try enter-ps command in ad-hoc mode. */
64*4882a593Smuzhiyun 		if (le16_to_cpu(pm->action) == EN_AUTO_PS &&
65*4882a593Smuzhiyun 		    (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) &&
66*4882a593Smuzhiyun 		    priv->bss_mode == NL80211_IFTYPE_ADHOC)
67*4882a593Smuzhiyun 			adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun 		break;
70*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_SCAN:
71*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_SCAN_EXT:
72*4882a593Smuzhiyun 		mwifiex_cancel_scan(adapter);
73*4882a593Smuzhiyun 		break;
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun 	case HostCmd_CMD_MAC_CONTROL:
76*4882a593Smuzhiyun 		break;
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun 	case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG:
79*4882a593Smuzhiyun 		mwifiex_dbg(adapter, MSG,
80*4882a593Smuzhiyun 			    "SDIO RX single-port aggregation Not support\n");
81*4882a593Smuzhiyun 		break;
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun 	default:
84*4882a593Smuzhiyun 		break;
85*4882a593Smuzhiyun 	}
86*4882a593Smuzhiyun 	/* Handling errors here */
87*4882a593Smuzhiyun 	mwifiex_recycle_cmd_node(adapter, adapter->curr_cmd);
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun 	spin_lock_bh(&adapter->mwifiex_cmd_lock);
90*4882a593Smuzhiyun 	adapter->curr_cmd = NULL;
91*4882a593Smuzhiyun 	spin_unlock_bh(&adapter->mwifiex_cmd_lock);
92*4882a593Smuzhiyun }
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun /*
95*4882a593Smuzhiyun  * This function handles the command response of get RSSI info.
96*4882a593Smuzhiyun  *
97*4882a593Smuzhiyun  * Handling includes changing the header fields into CPU format
98*4882a593Smuzhiyun  * and saving the following parameters in driver -
99*4882a593Smuzhiyun  *      - Last data and beacon RSSI value
100*4882a593Smuzhiyun  *      - Average data and beacon RSSI value
101*4882a593Smuzhiyun  *      - Last data and beacon NF value
102*4882a593Smuzhiyun  *      - Average data and beacon NF value
103*4882a593Smuzhiyun  *
104*4882a593Smuzhiyun  * The parameters are send to the application as well, along with
105*4882a593Smuzhiyun  * calculated SNR values.
106*4882a593Smuzhiyun  */
mwifiex_ret_802_11_rssi_info(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)107*4882a593Smuzhiyun static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv,
108*4882a593Smuzhiyun 					struct host_cmd_ds_command *resp)
109*4882a593Smuzhiyun {
110*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp =
111*4882a593Smuzhiyun 						&resp->params.rssi_info_rsp;
112*4882a593Smuzhiyun 	struct mwifiex_ds_misc_subsc_evt *subsc_evt =
113*4882a593Smuzhiyun 						&priv->async_subsc_evt_storage;
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun 	priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last);
116*4882a593Smuzhiyun 	priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last);
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun 	priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg);
119*4882a593Smuzhiyun 	priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg);
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun 	priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last);
122*4882a593Smuzhiyun 	priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last);
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun 	priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg);
125*4882a593Smuzhiyun 	priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg);
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun 	if (priv->subsc_evt_rssi_state == EVENT_HANDLED)
128*4882a593Smuzhiyun 		return 0;
129*4882a593Smuzhiyun 
130*4882a593Smuzhiyun 	memset(subsc_evt, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt));
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun 	/* Resubscribe low and high rssi events with new thresholds */
133*4882a593Smuzhiyun 	subsc_evt->events = BITMASK_BCN_RSSI_LOW | BITMASK_BCN_RSSI_HIGH;
134*4882a593Smuzhiyun 	subsc_evt->action = HostCmd_ACT_BITWISE_SET;
135*4882a593Smuzhiyun 	if (priv->subsc_evt_rssi_state == RSSI_LOW_RECVD) {
136*4882a593Smuzhiyun 		subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg -
137*4882a593Smuzhiyun 				priv->cqm_rssi_hyst);
138*4882a593Smuzhiyun 		subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
139*4882a593Smuzhiyun 	} else if (priv->subsc_evt_rssi_state == RSSI_HIGH_RECVD) {
140*4882a593Smuzhiyun 		subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
141*4882a593Smuzhiyun 		subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg +
142*4882a593Smuzhiyun 				priv->cqm_rssi_hyst);
143*4882a593Smuzhiyun 	}
144*4882a593Smuzhiyun 	subsc_evt->bcn_l_rssi_cfg.evt_freq = 1;
145*4882a593Smuzhiyun 	subsc_evt->bcn_h_rssi_cfg.evt_freq = 1;
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun 	priv->subsc_evt_rssi_state = EVENT_HANDLED;
148*4882a593Smuzhiyun 
149*4882a593Smuzhiyun 	mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SUBSCRIBE_EVENT,
150*4882a593Smuzhiyun 			 0, 0, subsc_evt, false);
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun 	return 0;
153*4882a593Smuzhiyun }
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun /*
156*4882a593Smuzhiyun  * This function handles the command response of set/get SNMP
157*4882a593Smuzhiyun  * MIB parameters.
158*4882a593Smuzhiyun  *
159*4882a593Smuzhiyun  * Handling includes changing the header fields into CPU format
160*4882a593Smuzhiyun  * and saving the parameter in driver.
161*4882a593Smuzhiyun  *
162*4882a593Smuzhiyun  * The following parameters are supported -
163*4882a593Smuzhiyun  *      - Fragmentation threshold
164*4882a593Smuzhiyun  *      - RTS threshold
165*4882a593Smuzhiyun  *      - Short retry limit
166*4882a593Smuzhiyun  */
mwifiex_ret_802_11_snmp_mib(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,u32 * data_buf)167*4882a593Smuzhiyun static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv,
168*4882a593Smuzhiyun 				       struct host_cmd_ds_command *resp,
169*4882a593Smuzhiyun 				       u32 *data_buf)
170*4882a593Smuzhiyun {
171*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
172*4882a593Smuzhiyun 	u16 oid = le16_to_cpu(smib->oid);
173*4882a593Smuzhiyun 	u16 query_type = le16_to_cpu(smib->query_type);
174*4882a593Smuzhiyun 	u32 ul_temp;
175*4882a593Smuzhiyun 
176*4882a593Smuzhiyun 	mwifiex_dbg(priv->adapter, INFO,
177*4882a593Smuzhiyun 		    "info: SNMP_RESP: oid value = %#x,\t"
178*4882a593Smuzhiyun 		    "query_type = %#x, buf size = %#x\n",
179*4882a593Smuzhiyun 		    oid, query_type, le16_to_cpu(smib->buf_size));
180*4882a593Smuzhiyun 	if (query_type == HostCmd_ACT_GEN_GET) {
181*4882a593Smuzhiyun 		ul_temp = get_unaligned_le16(smib->value);
182*4882a593Smuzhiyun 		if (data_buf)
183*4882a593Smuzhiyun 			*data_buf = ul_temp;
184*4882a593Smuzhiyun 		switch (oid) {
185*4882a593Smuzhiyun 		case FRAG_THRESH_I:
186*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, INFO,
187*4882a593Smuzhiyun 				    "info: SNMP_RESP: FragThsd =%u\n",
188*4882a593Smuzhiyun 				    ul_temp);
189*4882a593Smuzhiyun 			break;
190*4882a593Smuzhiyun 		case RTS_THRESH_I:
191*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, INFO,
192*4882a593Smuzhiyun 				    "info: SNMP_RESP: RTSThsd =%u\n",
193*4882a593Smuzhiyun 				    ul_temp);
194*4882a593Smuzhiyun 			break;
195*4882a593Smuzhiyun 		case SHORT_RETRY_LIM_I:
196*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, INFO,
197*4882a593Smuzhiyun 				    "info: SNMP_RESP: TxRetryCount=%u\n",
198*4882a593Smuzhiyun 				    ul_temp);
199*4882a593Smuzhiyun 			break;
200*4882a593Smuzhiyun 		case DTIM_PERIOD_I:
201*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, INFO,
202*4882a593Smuzhiyun 				    "info: SNMP_RESP: DTIM period=%u\n",
203*4882a593Smuzhiyun 				    ul_temp);
204*4882a593Smuzhiyun 		default:
205*4882a593Smuzhiyun 			break;
206*4882a593Smuzhiyun 		}
207*4882a593Smuzhiyun 	}
208*4882a593Smuzhiyun 
209*4882a593Smuzhiyun 	return 0;
210*4882a593Smuzhiyun }
211*4882a593Smuzhiyun 
212*4882a593Smuzhiyun /*
213*4882a593Smuzhiyun  * This function handles the command response of get log request
214*4882a593Smuzhiyun  *
215*4882a593Smuzhiyun  * Handling includes changing the header fields into CPU format
216*4882a593Smuzhiyun  * and sending the received parameters to application.
217*4882a593Smuzhiyun  */
mwifiex_ret_get_log(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,struct mwifiex_ds_get_stats * stats)218*4882a593Smuzhiyun static int mwifiex_ret_get_log(struct mwifiex_private *priv,
219*4882a593Smuzhiyun 			       struct host_cmd_ds_command *resp,
220*4882a593Smuzhiyun 			       struct mwifiex_ds_get_stats *stats)
221*4882a593Smuzhiyun {
222*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_get_log *get_log =
223*4882a593Smuzhiyun 		&resp->params.get_log;
224*4882a593Smuzhiyun 
225*4882a593Smuzhiyun 	if (stats) {
226*4882a593Smuzhiyun 		stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame);
227*4882a593Smuzhiyun 		stats->failed = le32_to_cpu(get_log->failed);
228*4882a593Smuzhiyun 		stats->retry = le32_to_cpu(get_log->retry);
229*4882a593Smuzhiyun 		stats->multi_retry = le32_to_cpu(get_log->multi_retry);
230*4882a593Smuzhiyun 		stats->frame_dup = le32_to_cpu(get_log->frame_dup);
231*4882a593Smuzhiyun 		stats->rts_success = le32_to_cpu(get_log->rts_success);
232*4882a593Smuzhiyun 		stats->rts_failure = le32_to_cpu(get_log->rts_failure);
233*4882a593Smuzhiyun 		stats->ack_failure = le32_to_cpu(get_log->ack_failure);
234*4882a593Smuzhiyun 		stats->rx_frag = le32_to_cpu(get_log->rx_frag);
235*4882a593Smuzhiyun 		stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame);
236*4882a593Smuzhiyun 		stats->fcs_error = le32_to_cpu(get_log->fcs_error);
237*4882a593Smuzhiyun 		stats->tx_frame = le32_to_cpu(get_log->tx_frame);
238*4882a593Smuzhiyun 		stats->wep_icv_error[0] =
239*4882a593Smuzhiyun 			le32_to_cpu(get_log->wep_icv_err_cnt[0]);
240*4882a593Smuzhiyun 		stats->wep_icv_error[1] =
241*4882a593Smuzhiyun 			le32_to_cpu(get_log->wep_icv_err_cnt[1]);
242*4882a593Smuzhiyun 		stats->wep_icv_error[2] =
243*4882a593Smuzhiyun 			le32_to_cpu(get_log->wep_icv_err_cnt[2]);
244*4882a593Smuzhiyun 		stats->wep_icv_error[3] =
245*4882a593Smuzhiyun 			le32_to_cpu(get_log->wep_icv_err_cnt[3]);
246*4882a593Smuzhiyun 		stats->bcn_rcv_cnt = le32_to_cpu(get_log->bcn_rcv_cnt);
247*4882a593Smuzhiyun 		stats->bcn_miss_cnt = le32_to_cpu(get_log->bcn_miss_cnt);
248*4882a593Smuzhiyun 	}
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun 	return 0;
251*4882a593Smuzhiyun }
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun /*
254*4882a593Smuzhiyun  * This function handles the command response of set/get Tx rate
255*4882a593Smuzhiyun  * configurations.
256*4882a593Smuzhiyun  *
257*4882a593Smuzhiyun  * Handling includes changing the header fields into CPU format
258*4882a593Smuzhiyun  * and saving the following parameters in driver -
259*4882a593Smuzhiyun  *      - DSSS rate bitmap
260*4882a593Smuzhiyun  *      - OFDM rate bitmap
261*4882a593Smuzhiyun  *      - HT MCS rate bitmaps
262*4882a593Smuzhiyun  *
263*4882a593Smuzhiyun  * Based on the new rate bitmaps, the function re-evaluates if
264*4882a593Smuzhiyun  * auto data rate has been activated. If not, it sends another
265*4882a593Smuzhiyun  * query to the firmware to get the current Tx data rate.
266*4882a593Smuzhiyun  */
mwifiex_ret_tx_rate_cfg(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)267*4882a593Smuzhiyun static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
268*4882a593Smuzhiyun 				   struct host_cmd_ds_command *resp)
269*4882a593Smuzhiyun {
270*4882a593Smuzhiyun 	struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
271*4882a593Smuzhiyun 	struct mwifiex_rate_scope *rate_scope;
272*4882a593Smuzhiyun 	struct mwifiex_ie_types_header *head;
273*4882a593Smuzhiyun 	u16 tlv, tlv_buf_len, tlv_buf_left;
274*4882a593Smuzhiyun 	u8 *tlv_buf;
275*4882a593Smuzhiyun 	u32 i;
276*4882a593Smuzhiyun 
277*4882a593Smuzhiyun 	tlv_buf = ((u8 *)rate_cfg) + sizeof(struct host_cmd_ds_tx_rate_cfg);
278*4882a593Smuzhiyun 	tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*rate_cfg);
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun 	while (tlv_buf_left >= sizeof(*head)) {
281*4882a593Smuzhiyun 		head = (struct mwifiex_ie_types_header *)tlv_buf;
282*4882a593Smuzhiyun 		tlv = le16_to_cpu(head->type);
283*4882a593Smuzhiyun 		tlv_buf_len = le16_to_cpu(head->len);
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun 		if (tlv_buf_left < (sizeof(*head) + tlv_buf_len))
286*4882a593Smuzhiyun 			break;
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun 		switch (tlv) {
289*4882a593Smuzhiyun 		case TLV_TYPE_RATE_SCOPE:
290*4882a593Smuzhiyun 			rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
291*4882a593Smuzhiyun 			priv->bitmap_rates[0] =
292*4882a593Smuzhiyun 				le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
293*4882a593Smuzhiyun 			priv->bitmap_rates[1] =
294*4882a593Smuzhiyun 				le16_to_cpu(rate_scope->ofdm_rate_bitmap);
295*4882a593Smuzhiyun 			for (i = 0;
296*4882a593Smuzhiyun 			     i < ARRAY_SIZE(rate_scope->ht_mcs_rate_bitmap);
297*4882a593Smuzhiyun 			     i++)
298*4882a593Smuzhiyun 				priv->bitmap_rates[2 + i] =
299*4882a593Smuzhiyun 					le16_to_cpu(rate_scope->
300*4882a593Smuzhiyun 						    ht_mcs_rate_bitmap[i]);
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun 			if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) {
303*4882a593Smuzhiyun 				for (i = 0; i < ARRAY_SIZE(rate_scope->
304*4882a593Smuzhiyun 							   vht_mcs_rate_bitmap);
305*4882a593Smuzhiyun 				     i++)
306*4882a593Smuzhiyun 					priv->bitmap_rates[10 + i] =
307*4882a593Smuzhiyun 					    le16_to_cpu(rate_scope->
308*4882a593Smuzhiyun 							vht_mcs_rate_bitmap[i]);
309*4882a593Smuzhiyun 			}
310*4882a593Smuzhiyun 			break;
311*4882a593Smuzhiyun 			/* Add RATE_DROP tlv here */
312*4882a593Smuzhiyun 		}
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun 		tlv_buf += (sizeof(*head) + tlv_buf_len);
315*4882a593Smuzhiyun 		tlv_buf_left -= (sizeof(*head) + tlv_buf_len);
316*4882a593Smuzhiyun 	}
317*4882a593Smuzhiyun 
318*4882a593Smuzhiyun 	priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
319*4882a593Smuzhiyun 
320*4882a593Smuzhiyun 	if (priv->is_data_rate_auto)
321*4882a593Smuzhiyun 		priv->data_rate = 0;
322*4882a593Smuzhiyun 	else
323*4882a593Smuzhiyun 		return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
324*4882a593Smuzhiyun 					HostCmd_ACT_GEN_GET, 0, NULL, false);
325*4882a593Smuzhiyun 
326*4882a593Smuzhiyun 	return 0;
327*4882a593Smuzhiyun }
328*4882a593Smuzhiyun 
329*4882a593Smuzhiyun /*
330*4882a593Smuzhiyun  * This function handles the command response of get Tx power level.
331*4882a593Smuzhiyun  *
332*4882a593Smuzhiyun  * Handling includes saving the maximum and minimum Tx power levels
333*4882a593Smuzhiyun  * in driver, as well as sending the values to user.
334*4882a593Smuzhiyun  */
mwifiex_get_power_level(struct mwifiex_private * priv,void * data_buf)335*4882a593Smuzhiyun static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
336*4882a593Smuzhiyun {
337*4882a593Smuzhiyun 	int length, max_power = -1, min_power = -1;
338*4882a593Smuzhiyun 	struct mwifiex_types_power_group *pg_tlv_hdr;
339*4882a593Smuzhiyun 	struct mwifiex_power_group *pg;
340*4882a593Smuzhiyun 
341*4882a593Smuzhiyun 	if (!data_buf)
342*4882a593Smuzhiyun 		return -1;
343*4882a593Smuzhiyun 
344*4882a593Smuzhiyun 	pg_tlv_hdr = (struct mwifiex_types_power_group *)((u8 *)data_buf);
345*4882a593Smuzhiyun 	pg = (struct mwifiex_power_group *)
346*4882a593Smuzhiyun 		((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group));
347*4882a593Smuzhiyun 	length = le16_to_cpu(pg_tlv_hdr->length);
348*4882a593Smuzhiyun 
349*4882a593Smuzhiyun 	/* At least one structure required to update power */
350*4882a593Smuzhiyun 	if (length < sizeof(struct mwifiex_power_group))
351*4882a593Smuzhiyun 		return 0;
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun 	max_power = pg->power_max;
354*4882a593Smuzhiyun 	min_power = pg->power_min;
355*4882a593Smuzhiyun 	length -= sizeof(struct mwifiex_power_group);
356*4882a593Smuzhiyun 
357*4882a593Smuzhiyun 	while (length >= sizeof(struct mwifiex_power_group)) {
358*4882a593Smuzhiyun 		pg++;
359*4882a593Smuzhiyun 		if (max_power < pg->power_max)
360*4882a593Smuzhiyun 			max_power = pg->power_max;
361*4882a593Smuzhiyun 
362*4882a593Smuzhiyun 		if (min_power > pg->power_min)
363*4882a593Smuzhiyun 			min_power = pg->power_min;
364*4882a593Smuzhiyun 
365*4882a593Smuzhiyun 		length -= sizeof(struct mwifiex_power_group);
366*4882a593Smuzhiyun 	}
367*4882a593Smuzhiyun 	priv->min_tx_power_level = (u8) min_power;
368*4882a593Smuzhiyun 	priv->max_tx_power_level = (u8) max_power;
369*4882a593Smuzhiyun 
370*4882a593Smuzhiyun 	return 0;
371*4882a593Smuzhiyun }
372*4882a593Smuzhiyun 
373*4882a593Smuzhiyun /*
374*4882a593Smuzhiyun  * This function handles the command response of set/get Tx power
375*4882a593Smuzhiyun  * configurations.
376*4882a593Smuzhiyun  *
377*4882a593Smuzhiyun  * Handling includes changing the header fields into CPU format
378*4882a593Smuzhiyun  * and saving the current Tx power level in driver.
379*4882a593Smuzhiyun  */
mwifiex_ret_tx_power_cfg(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)380*4882a593Smuzhiyun static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
381*4882a593Smuzhiyun 				    struct host_cmd_ds_command *resp)
382*4882a593Smuzhiyun {
383*4882a593Smuzhiyun 	struct mwifiex_adapter *adapter = priv->adapter;
384*4882a593Smuzhiyun 	struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg;
385*4882a593Smuzhiyun 	struct mwifiex_types_power_group *pg_tlv_hdr;
386*4882a593Smuzhiyun 	struct mwifiex_power_group *pg;
387*4882a593Smuzhiyun 	u16 action = le16_to_cpu(txp_cfg->action);
388*4882a593Smuzhiyun 	u16 tlv_buf_left;
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun 	pg_tlv_hdr = (struct mwifiex_types_power_group *)
391*4882a593Smuzhiyun 		((u8 *)txp_cfg +
392*4882a593Smuzhiyun 		 sizeof(struct host_cmd_ds_txpwr_cfg));
393*4882a593Smuzhiyun 
394*4882a593Smuzhiyun 	pg = (struct mwifiex_power_group *)
395*4882a593Smuzhiyun 		((u8 *)pg_tlv_hdr +
396*4882a593Smuzhiyun 		 sizeof(struct mwifiex_types_power_group));
397*4882a593Smuzhiyun 
398*4882a593Smuzhiyun 	tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*txp_cfg);
399*4882a593Smuzhiyun 	if (tlv_buf_left <
400*4882a593Smuzhiyun 			le16_to_cpu(pg_tlv_hdr->length) + sizeof(*pg_tlv_hdr))
401*4882a593Smuzhiyun 		return 0;
402*4882a593Smuzhiyun 
403*4882a593Smuzhiyun 	switch (action) {
404*4882a593Smuzhiyun 	case HostCmd_ACT_GEN_GET:
405*4882a593Smuzhiyun 		if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
406*4882a593Smuzhiyun 			mwifiex_get_power_level(priv, pg_tlv_hdr);
407*4882a593Smuzhiyun 
408*4882a593Smuzhiyun 		priv->tx_power_level = (u16) pg->power_min;
409*4882a593Smuzhiyun 		break;
410*4882a593Smuzhiyun 
411*4882a593Smuzhiyun 	case HostCmd_ACT_GEN_SET:
412*4882a593Smuzhiyun 		if (!le32_to_cpu(txp_cfg->mode))
413*4882a593Smuzhiyun 			break;
414*4882a593Smuzhiyun 
415*4882a593Smuzhiyun 		if (pg->power_max == pg->power_min)
416*4882a593Smuzhiyun 			priv->tx_power_level = (u16) pg->power_min;
417*4882a593Smuzhiyun 		break;
418*4882a593Smuzhiyun 	default:
419*4882a593Smuzhiyun 		mwifiex_dbg(adapter, ERROR,
420*4882a593Smuzhiyun 			    "CMD_RESP: unknown cmd action %d\n",
421*4882a593Smuzhiyun 			    action);
422*4882a593Smuzhiyun 		return 0;
423*4882a593Smuzhiyun 	}
424*4882a593Smuzhiyun 	mwifiex_dbg(adapter, INFO,
425*4882a593Smuzhiyun 		    "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n",
426*4882a593Smuzhiyun 		    priv->tx_power_level, priv->max_tx_power_level,
427*4882a593Smuzhiyun 		    priv->min_tx_power_level);
428*4882a593Smuzhiyun 
429*4882a593Smuzhiyun 	return 0;
430*4882a593Smuzhiyun }
431*4882a593Smuzhiyun 
432*4882a593Smuzhiyun /*
433*4882a593Smuzhiyun  * This function handles the command response of get RF Tx power.
434*4882a593Smuzhiyun  */
mwifiex_ret_rf_tx_power(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)435*4882a593Smuzhiyun static int mwifiex_ret_rf_tx_power(struct mwifiex_private *priv,
436*4882a593Smuzhiyun 				   struct host_cmd_ds_command *resp)
437*4882a593Smuzhiyun {
438*4882a593Smuzhiyun 	struct host_cmd_ds_rf_tx_pwr *txp = &resp->params.txp;
439*4882a593Smuzhiyun 	u16 action = le16_to_cpu(txp->action);
440*4882a593Smuzhiyun 
441*4882a593Smuzhiyun 	priv->tx_power_level = le16_to_cpu(txp->cur_level);
442*4882a593Smuzhiyun 
443*4882a593Smuzhiyun 	if (action == HostCmd_ACT_GEN_GET) {
444*4882a593Smuzhiyun 		priv->max_tx_power_level = txp->max_power;
445*4882a593Smuzhiyun 		priv->min_tx_power_level = txp->min_power;
446*4882a593Smuzhiyun 	}
447*4882a593Smuzhiyun 
448*4882a593Smuzhiyun 	mwifiex_dbg(priv->adapter, INFO,
449*4882a593Smuzhiyun 		    "Current TxPower Level=%d, Max Power=%d, Min Power=%d\n",
450*4882a593Smuzhiyun 		    priv->tx_power_level, priv->max_tx_power_level,
451*4882a593Smuzhiyun 		    priv->min_tx_power_level);
452*4882a593Smuzhiyun 
453*4882a593Smuzhiyun 	return 0;
454*4882a593Smuzhiyun }
455*4882a593Smuzhiyun 
456*4882a593Smuzhiyun /*
457*4882a593Smuzhiyun  * This function handles the command response of set rf antenna
458*4882a593Smuzhiyun  */
mwifiex_ret_rf_antenna(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)459*4882a593Smuzhiyun static int mwifiex_ret_rf_antenna(struct mwifiex_private *priv,
460*4882a593Smuzhiyun 				  struct host_cmd_ds_command *resp)
461*4882a593Smuzhiyun {
462*4882a593Smuzhiyun 	struct host_cmd_ds_rf_ant_mimo *ant_mimo = &resp->params.ant_mimo;
463*4882a593Smuzhiyun 	struct host_cmd_ds_rf_ant_siso *ant_siso = &resp->params.ant_siso;
464*4882a593Smuzhiyun 	struct mwifiex_adapter *adapter = priv->adapter;
465*4882a593Smuzhiyun 
466*4882a593Smuzhiyun 	if (adapter->hw_dev_mcs_support == HT_STREAM_2X2) {
467*4882a593Smuzhiyun 		priv->tx_ant = le16_to_cpu(ant_mimo->tx_ant_mode);
468*4882a593Smuzhiyun 		priv->rx_ant = le16_to_cpu(ant_mimo->rx_ant_mode);
469*4882a593Smuzhiyun 		mwifiex_dbg(adapter, INFO,
470*4882a593Smuzhiyun 			    "RF_ANT_RESP: Tx action = 0x%x, Tx Mode = 0x%04x\t"
471*4882a593Smuzhiyun 			    "Rx action = 0x%x, Rx Mode = 0x%04x\n",
472*4882a593Smuzhiyun 			    le16_to_cpu(ant_mimo->action_tx),
473*4882a593Smuzhiyun 			    le16_to_cpu(ant_mimo->tx_ant_mode),
474*4882a593Smuzhiyun 			    le16_to_cpu(ant_mimo->action_rx),
475*4882a593Smuzhiyun 			    le16_to_cpu(ant_mimo->rx_ant_mode));
476*4882a593Smuzhiyun 	} else {
477*4882a593Smuzhiyun 		priv->tx_ant = le16_to_cpu(ant_siso->ant_mode);
478*4882a593Smuzhiyun 		priv->rx_ant = le16_to_cpu(ant_siso->ant_mode);
479*4882a593Smuzhiyun 		mwifiex_dbg(adapter, INFO,
480*4882a593Smuzhiyun 			    "RF_ANT_RESP: action = 0x%x, Mode = 0x%04x\n",
481*4882a593Smuzhiyun 			    le16_to_cpu(ant_siso->action),
482*4882a593Smuzhiyun 			    le16_to_cpu(ant_siso->ant_mode));
483*4882a593Smuzhiyun 	}
484*4882a593Smuzhiyun 	return 0;
485*4882a593Smuzhiyun }
486*4882a593Smuzhiyun 
487*4882a593Smuzhiyun /*
488*4882a593Smuzhiyun  * This function handles the command response of set/get MAC address.
489*4882a593Smuzhiyun  *
490*4882a593Smuzhiyun  * Handling includes saving the MAC address in driver.
491*4882a593Smuzhiyun  */
mwifiex_ret_802_11_mac_address(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)492*4882a593Smuzhiyun static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv,
493*4882a593Smuzhiyun 					  struct host_cmd_ds_command *resp)
494*4882a593Smuzhiyun {
495*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_mac_address *cmd_mac_addr =
496*4882a593Smuzhiyun 							&resp->params.mac_addr;
497*4882a593Smuzhiyun 
498*4882a593Smuzhiyun 	memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN);
499*4882a593Smuzhiyun 
500*4882a593Smuzhiyun 	mwifiex_dbg(priv->adapter, INFO,
501*4882a593Smuzhiyun 		    "info: set mac address: %pM\n", priv->curr_addr);
502*4882a593Smuzhiyun 
503*4882a593Smuzhiyun 	return 0;
504*4882a593Smuzhiyun }
505*4882a593Smuzhiyun 
506*4882a593Smuzhiyun /*
507*4882a593Smuzhiyun  * This function handles the command response of set/get MAC multicast
508*4882a593Smuzhiyun  * address.
509*4882a593Smuzhiyun  */
mwifiex_ret_mac_multicast_adr(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)510*4882a593Smuzhiyun static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv,
511*4882a593Smuzhiyun 					 struct host_cmd_ds_command *resp)
512*4882a593Smuzhiyun {
513*4882a593Smuzhiyun 	return 0;
514*4882a593Smuzhiyun }
515*4882a593Smuzhiyun 
516*4882a593Smuzhiyun /*
517*4882a593Smuzhiyun  * This function handles the command response of get Tx rate query.
518*4882a593Smuzhiyun  *
519*4882a593Smuzhiyun  * Handling includes changing the header fields into CPU format
520*4882a593Smuzhiyun  * and saving the Tx rate and HT information parameters in driver.
521*4882a593Smuzhiyun  *
522*4882a593Smuzhiyun  * Both rate configuration and current data rate can be retrieved
523*4882a593Smuzhiyun  * with this request.
524*4882a593Smuzhiyun  */
mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)525*4882a593Smuzhiyun static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv,
526*4882a593Smuzhiyun 					    struct host_cmd_ds_command *resp)
527*4882a593Smuzhiyun {
528*4882a593Smuzhiyun 	priv->tx_rate = resp->params.tx_rate.tx_rate;
529*4882a593Smuzhiyun 	priv->tx_htinfo = resp->params.tx_rate.ht_info;
530*4882a593Smuzhiyun 	if (!priv->is_data_rate_auto)
531*4882a593Smuzhiyun 		priv->data_rate =
532*4882a593Smuzhiyun 			mwifiex_index_to_data_rate(priv, priv->tx_rate,
533*4882a593Smuzhiyun 						   priv->tx_htinfo);
534*4882a593Smuzhiyun 
535*4882a593Smuzhiyun 	return 0;
536*4882a593Smuzhiyun }
537*4882a593Smuzhiyun 
538*4882a593Smuzhiyun /*
539*4882a593Smuzhiyun  * This function handles the command response of a deauthenticate
540*4882a593Smuzhiyun  * command.
541*4882a593Smuzhiyun  *
542*4882a593Smuzhiyun  * If the deauthenticated MAC matches the current BSS MAC, the connection
543*4882a593Smuzhiyun  * state is reset.
544*4882a593Smuzhiyun  */
mwifiex_ret_802_11_deauthenticate(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)545*4882a593Smuzhiyun static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
546*4882a593Smuzhiyun 					     struct host_cmd_ds_command *resp)
547*4882a593Smuzhiyun {
548*4882a593Smuzhiyun 	struct mwifiex_adapter *adapter = priv->adapter;
549*4882a593Smuzhiyun 
550*4882a593Smuzhiyun 	adapter->dbg.num_cmd_deauth++;
551*4882a593Smuzhiyun 	if (!memcmp(resp->params.deauth.mac_addr,
552*4882a593Smuzhiyun 		    &priv->curr_bss_params.bss_descriptor.mac_address,
553*4882a593Smuzhiyun 		    sizeof(resp->params.deauth.mac_addr)))
554*4882a593Smuzhiyun 		mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING,
555*4882a593Smuzhiyun 					    false);
556*4882a593Smuzhiyun 
557*4882a593Smuzhiyun 	return 0;
558*4882a593Smuzhiyun }
559*4882a593Smuzhiyun 
560*4882a593Smuzhiyun /*
561*4882a593Smuzhiyun  * This function handles the command response of ad-hoc stop.
562*4882a593Smuzhiyun  *
563*4882a593Smuzhiyun  * The function resets the connection state in driver.
564*4882a593Smuzhiyun  */
mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)565*4882a593Smuzhiyun static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
566*4882a593Smuzhiyun 					  struct host_cmd_ds_command *resp)
567*4882a593Smuzhiyun {
568*4882a593Smuzhiyun 	mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING, false);
569*4882a593Smuzhiyun 	return 0;
570*4882a593Smuzhiyun }
571*4882a593Smuzhiyun 
572*4882a593Smuzhiyun /*
573*4882a593Smuzhiyun  * This function handles the command response of set/get v1 key material.
574*4882a593Smuzhiyun  *
575*4882a593Smuzhiyun  * Handling includes updating the driver parameters to reflect the
576*4882a593Smuzhiyun  * changes.
577*4882a593Smuzhiyun  */
mwifiex_ret_802_11_key_material_v1(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)578*4882a593Smuzhiyun static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,
579*4882a593Smuzhiyun 					      struct host_cmd_ds_command *resp)
580*4882a593Smuzhiyun {
581*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_key_material *key =
582*4882a593Smuzhiyun 						&resp->params.key_material;
583*4882a593Smuzhiyun 	int len;
584*4882a593Smuzhiyun 
585*4882a593Smuzhiyun 	len = le16_to_cpu(key->key_param_set.key_len);
586*4882a593Smuzhiyun 	if (len > sizeof(key->key_param_set.key))
587*4882a593Smuzhiyun 		return -EINVAL;
588*4882a593Smuzhiyun 
589*4882a593Smuzhiyun 	if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
590*4882a593Smuzhiyun 		if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
591*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, INFO,
592*4882a593Smuzhiyun 				    "info: key: GTK is set\n");
593*4882a593Smuzhiyun 			priv->wpa_is_gtk_set = true;
594*4882a593Smuzhiyun 			priv->scan_block = false;
595*4882a593Smuzhiyun 			priv->port_open = true;
596*4882a593Smuzhiyun 		}
597*4882a593Smuzhiyun 	}
598*4882a593Smuzhiyun 
599*4882a593Smuzhiyun 	memset(priv->aes_key.key_param_set.key, 0,
600*4882a593Smuzhiyun 	       sizeof(key->key_param_set.key));
601*4882a593Smuzhiyun 	priv->aes_key.key_param_set.key_len = cpu_to_le16(len);
602*4882a593Smuzhiyun 	memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, len);
603*4882a593Smuzhiyun 
604*4882a593Smuzhiyun 	return 0;
605*4882a593Smuzhiyun }
606*4882a593Smuzhiyun 
607*4882a593Smuzhiyun /*
608*4882a593Smuzhiyun  * This function handles the command response of set/get v2 key material.
609*4882a593Smuzhiyun  *
610*4882a593Smuzhiyun  * Handling includes updating the driver parameters to reflect the
611*4882a593Smuzhiyun  * changes.
612*4882a593Smuzhiyun  */
mwifiex_ret_802_11_key_material_v2(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)613*4882a593Smuzhiyun static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,
614*4882a593Smuzhiyun 					      struct host_cmd_ds_command *resp)
615*4882a593Smuzhiyun {
616*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_key_material_v2 *key_v2;
617*4882a593Smuzhiyun 	int len;
618*4882a593Smuzhiyun 
619*4882a593Smuzhiyun 	key_v2 = &resp->params.key_material_v2;
620*4882a593Smuzhiyun 
621*4882a593Smuzhiyun 	len = le16_to_cpu(key_v2->key_param_set.key_params.aes.key_len);
622*4882a593Smuzhiyun 	if (len > sizeof(key_v2->key_param_set.key_params.aes.key))
623*4882a593Smuzhiyun 		return -EINVAL;
624*4882a593Smuzhiyun 
625*4882a593Smuzhiyun 	if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) {
626*4882a593Smuzhiyun 		if ((le16_to_cpu(key_v2->key_param_set.key_info) & KEY_MCAST)) {
627*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, INFO, "info: key: GTK is set\n");
628*4882a593Smuzhiyun 			priv->wpa_is_gtk_set = true;
629*4882a593Smuzhiyun 			priv->scan_block = false;
630*4882a593Smuzhiyun 			priv->port_open = true;
631*4882a593Smuzhiyun 		}
632*4882a593Smuzhiyun 	}
633*4882a593Smuzhiyun 
634*4882a593Smuzhiyun 	if (key_v2->key_param_set.key_type != KEY_TYPE_ID_AES)
635*4882a593Smuzhiyun 		return 0;
636*4882a593Smuzhiyun 
637*4882a593Smuzhiyun 	memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0,
638*4882a593Smuzhiyun 	       sizeof(key_v2->key_param_set.key_params.aes.key));
639*4882a593Smuzhiyun 	priv->aes_key_v2.key_param_set.key_params.aes.key_len =
640*4882a593Smuzhiyun 				cpu_to_le16(len);
641*4882a593Smuzhiyun 	memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key,
642*4882a593Smuzhiyun 	       key_v2->key_param_set.key_params.aes.key, len);
643*4882a593Smuzhiyun 
644*4882a593Smuzhiyun 	return 0;
645*4882a593Smuzhiyun }
646*4882a593Smuzhiyun 
647*4882a593Smuzhiyun /* Wrapper function for processing response of key material command */
mwifiex_ret_802_11_key_material(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)648*4882a593Smuzhiyun static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv,
649*4882a593Smuzhiyun 					   struct host_cmd_ds_command *resp)
650*4882a593Smuzhiyun {
651*4882a593Smuzhiyun 	if (priv->adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2)
652*4882a593Smuzhiyun 		return mwifiex_ret_802_11_key_material_v2(priv, resp);
653*4882a593Smuzhiyun 	else
654*4882a593Smuzhiyun 		return mwifiex_ret_802_11_key_material_v1(priv, resp);
655*4882a593Smuzhiyun }
656*4882a593Smuzhiyun 
657*4882a593Smuzhiyun /*
658*4882a593Smuzhiyun  * This function handles the command response of get 11d domain information.
659*4882a593Smuzhiyun  */
mwifiex_ret_802_11d_domain_info(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)660*4882a593Smuzhiyun static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
661*4882a593Smuzhiyun 					   struct host_cmd_ds_command *resp)
662*4882a593Smuzhiyun {
663*4882a593Smuzhiyun 	struct host_cmd_ds_802_11d_domain_info_rsp *domain_info =
664*4882a593Smuzhiyun 		&resp->params.domain_info_resp;
665*4882a593Smuzhiyun 	struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain;
666*4882a593Smuzhiyun 	u16 action = le16_to_cpu(domain_info->action);
667*4882a593Smuzhiyun 	u8 no_of_triplet;
668*4882a593Smuzhiyun 
669*4882a593Smuzhiyun 	no_of_triplet = (u8) ((le16_to_cpu(domain->header.len)
670*4882a593Smuzhiyun 				- IEEE80211_COUNTRY_STRING_LEN)
671*4882a593Smuzhiyun 			      / sizeof(struct ieee80211_country_ie_triplet));
672*4882a593Smuzhiyun 
673*4882a593Smuzhiyun 	mwifiex_dbg(priv->adapter, INFO,
674*4882a593Smuzhiyun 		    "info: 11D Domain Info Resp: no_of_triplet=%d\n",
675*4882a593Smuzhiyun 		    no_of_triplet);
676*4882a593Smuzhiyun 
677*4882a593Smuzhiyun 	if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) {
678*4882a593Smuzhiyun 		mwifiex_dbg(priv->adapter, FATAL,
679*4882a593Smuzhiyun 			    "11D: invalid number of triplets %d returned\n",
680*4882a593Smuzhiyun 			    no_of_triplet);
681*4882a593Smuzhiyun 		return -1;
682*4882a593Smuzhiyun 	}
683*4882a593Smuzhiyun 
684*4882a593Smuzhiyun 	switch (action) {
685*4882a593Smuzhiyun 	case HostCmd_ACT_GEN_SET:  /* Proc Set Action */
686*4882a593Smuzhiyun 		break;
687*4882a593Smuzhiyun 	case HostCmd_ACT_GEN_GET:
688*4882a593Smuzhiyun 		break;
689*4882a593Smuzhiyun 	default:
690*4882a593Smuzhiyun 		mwifiex_dbg(priv->adapter, ERROR,
691*4882a593Smuzhiyun 			    "11D: invalid action:%d\n", domain_info->action);
692*4882a593Smuzhiyun 		return -1;
693*4882a593Smuzhiyun 	}
694*4882a593Smuzhiyun 
695*4882a593Smuzhiyun 	return 0;
696*4882a593Smuzhiyun }
697*4882a593Smuzhiyun 
698*4882a593Smuzhiyun /*
699*4882a593Smuzhiyun  * This function handles the command response of get extended version.
700*4882a593Smuzhiyun  *
701*4882a593Smuzhiyun  * Handling includes forming the extended version string and sending it
702*4882a593Smuzhiyun  * to application.
703*4882a593Smuzhiyun  */
mwifiex_ret_ver_ext(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,struct host_cmd_ds_version_ext * version_ext)704*4882a593Smuzhiyun static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
705*4882a593Smuzhiyun 			       struct host_cmd_ds_command *resp,
706*4882a593Smuzhiyun 			       struct host_cmd_ds_version_ext *version_ext)
707*4882a593Smuzhiyun {
708*4882a593Smuzhiyun 	struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext;
709*4882a593Smuzhiyun 
710*4882a593Smuzhiyun 	if (version_ext) {
711*4882a593Smuzhiyun 		version_ext->version_str_sel = ver_ext->version_str_sel;
712*4882a593Smuzhiyun 		memcpy(version_ext->version_str, ver_ext->version_str,
713*4882a593Smuzhiyun 		       sizeof(char) * 128);
714*4882a593Smuzhiyun 		memcpy(priv->version_str, ver_ext->version_str, 128);
715*4882a593Smuzhiyun 	}
716*4882a593Smuzhiyun 	return 0;
717*4882a593Smuzhiyun }
718*4882a593Smuzhiyun 
719*4882a593Smuzhiyun /*
720*4882a593Smuzhiyun  * This function handles the command response of remain on channel.
721*4882a593Smuzhiyun  */
722*4882a593Smuzhiyun static int
mwifiex_ret_remain_on_chan(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,struct host_cmd_ds_remain_on_chan * roc_cfg)723*4882a593Smuzhiyun mwifiex_ret_remain_on_chan(struct mwifiex_private *priv,
724*4882a593Smuzhiyun 			   struct host_cmd_ds_command *resp,
725*4882a593Smuzhiyun 			   struct host_cmd_ds_remain_on_chan *roc_cfg)
726*4882a593Smuzhiyun {
727*4882a593Smuzhiyun 	struct host_cmd_ds_remain_on_chan *resp_cfg = &resp->params.roc_cfg;
728*4882a593Smuzhiyun 
729*4882a593Smuzhiyun 	if (roc_cfg)
730*4882a593Smuzhiyun 		memcpy(roc_cfg, resp_cfg, sizeof(*roc_cfg));
731*4882a593Smuzhiyun 
732*4882a593Smuzhiyun 	return 0;
733*4882a593Smuzhiyun }
734*4882a593Smuzhiyun 
735*4882a593Smuzhiyun /*
736*4882a593Smuzhiyun  * This function handles the command response of P2P mode cfg.
737*4882a593Smuzhiyun  */
738*4882a593Smuzhiyun static int
mwifiex_ret_p2p_mode_cfg(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,void * data_buf)739*4882a593Smuzhiyun mwifiex_ret_p2p_mode_cfg(struct mwifiex_private *priv,
740*4882a593Smuzhiyun 			 struct host_cmd_ds_command *resp,
741*4882a593Smuzhiyun 			 void *data_buf)
742*4882a593Smuzhiyun {
743*4882a593Smuzhiyun 	struct host_cmd_ds_p2p_mode_cfg *mode_cfg = &resp->params.mode_cfg;
744*4882a593Smuzhiyun 
745*4882a593Smuzhiyun 	if (data_buf)
746*4882a593Smuzhiyun 		put_unaligned_le16(le16_to_cpu(mode_cfg->mode), data_buf);
747*4882a593Smuzhiyun 
748*4882a593Smuzhiyun 	return 0;
749*4882a593Smuzhiyun }
750*4882a593Smuzhiyun 
751*4882a593Smuzhiyun /* This function handles the command response of mem_access command
752*4882a593Smuzhiyun  */
753*4882a593Smuzhiyun static int
mwifiex_ret_mem_access(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,void * pioctl_buf)754*4882a593Smuzhiyun mwifiex_ret_mem_access(struct mwifiex_private *priv,
755*4882a593Smuzhiyun 		       struct host_cmd_ds_command *resp, void *pioctl_buf)
756*4882a593Smuzhiyun {
757*4882a593Smuzhiyun 	struct host_cmd_ds_mem_access *mem = (void *)&resp->params.mem;
758*4882a593Smuzhiyun 
759*4882a593Smuzhiyun 	priv->mem_rw.addr = le32_to_cpu(mem->addr);
760*4882a593Smuzhiyun 	priv->mem_rw.value = le32_to_cpu(mem->value);
761*4882a593Smuzhiyun 
762*4882a593Smuzhiyun 	return 0;
763*4882a593Smuzhiyun }
764*4882a593Smuzhiyun /*
765*4882a593Smuzhiyun  * This function handles the command response of register access.
766*4882a593Smuzhiyun  *
767*4882a593Smuzhiyun  * The register value and offset are returned to the user. For EEPROM
768*4882a593Smuzhiyun  * access, the byte count is also returned.
769*4882a593Smuzhiyun  */
mwifiex_ret_reg_access(u16 type,struct host_cmd_ds_command * resp,void * data_buf)770*4882a593Smuzhiyun static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
771*4882a593Smuzhiyun 				  void *data_buf)
772*4882a593Smuzhiyun {
773*4882a593Smuzhiyun 	struct mwifiex_ds_reg_rw *reg_rw;
774*4882a593Smuzhiyun 	struct mwifiex_ds_read_eeprom *eeprom;
775*4882a593Smuzhiyun 	union reg {
776*4882a593Smuzhiyun 		struct host_cmd_ds_mac_reg_access *mac;
777*4882a593Smuzhiyun 		struct host_cmd_ds_bbp_reg_access *bbp;
778*4882a593Smuzhiyun 		struct host_cmd_ds_rf_reg_access *rf;
779*4882a593Smuzhiyun 		struct host_cmd_ds_pmic_reg_access *pmic;
780*4882a593Smuzhiyun 		struct host_cmd_ds_802_11_eeprom_access *eeprom;
781*4882a593Smuzhiyun 	} r;
782*4882a593Smuzhiyun 
783*4882a593Smuzhiyun 	if (!data_buf)
784*4882a593Smuzhiyun 		return 0;
785*4882a593Smuzhiyun 
786*4882a593Smuzhiyun 	reg_rw = data_buf;
787*4882a593Smuzhiyun 	eeprom = data_buf;
788*4882a593Smuzhiyun 	switch (type) {
789*4882a593Smuzhiyun 	case HostCmd_CMD_MAC_REG_ACCESS:
790*4882a593Smuzhiyun 		r.mac = &resp->params.mac_reg;
791*4882a593Smuzhiyun 		reg_rw->offset = (u32) le16_to_cpu(r.mac->offset);
792*4882a593Smuzhiyun 		reg_rw->value = le32_to_cpu(r.mac->value);
793*4882a593Smuzhiyun 		break;
794*4882a593Smuzhiyun 	case HostCmd_CMD_BBP_REG_ACCESS:
795*4882a593Smuzhiyun 		r.bbp = &resp->params.bbp_reg;
796*4882a593Smuzhiyun 		reg_rw->offset = (u32) le16_to_cpu(r.bbp->offset);
797*4882a593Smuzhiyun 		reg_rw->value = (u32) r.bbp->value;
798*4882a593Smuzhiyun 		break;
799*4882a593Smuzhiyun 
800*4882a593Smuzhiyun 	case HostCmd_CMD_RF_REG_ACCESS:
801*4882a593Smuzhiyun 		r.rf = &resp->params.rf_reg;
802*4882a593Smuzhiyun 		reg_rw->offset = (u32) le16_to_cpu(r.rf->offset);
803*4882a593Smuzhiyun 		reg_rw->value = (u32) r.bbp->value;
804*4882a593Smuzhiyun 		break;
805*4882a593Smuzhiyun 	case HostCmd_CMD_PMIC_REG_ACCESS:
806*4882a593Smuzhiyun 		r.pmic = &resp->params.pmic_reg;
807*4882a593Smuzhiyun 		reg_rw->offset = (u32) le16_to_cpu(r.pmic->offset);
808*4882a593Smuzhiyun 		reg_rw->value = (u32) r.pmic->value;
809*4882a593Smuzhiyun 		break;
810*4882a593Smuzhiyun 	case HostCmd_CMD_CAU_REG_ACCESS:
811*4882a593Smuzhiyun 		r.rf = &resp->params.rf_reg;
812*4882a593Smuzhiyun 		reg_rw->offset = (u32) le16_to_cpu(r.rf->offset);
813*4882a593Smuzhiyun 		reg_rw->value = (u32) r.rf->value;
814*4882a593Smuzhiyun 		break;
815*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_EEPROM_ACCESS:
816*4882a593Smuzhiyun 		r.eeprom = &resp->params.eeprom;
817*4882a593Smuzhiyun 		pr_debug("info: EEPROM read len=%x\n",
818*4882a593Smuzhiyun 				le16_to_cpu(r.eeprom->byte_count));
819*4882a593Smuzhiyun 		if (eeprom->byte_count < le16_to_cpu(r.eeprom->byte_count)) {
820*4882a593Smuzhiyun 			eeprom->byte_count = 0;
821*4882a593Smuzhiyun 			pr_debug("info: EEPROM read length is too big\n");
822*4882a593Smuzhiyun 			return -1;
823*4882a593Smuzhiyun 		}
824*4882a593Smuzhiyun 		eeprom->offset = le16_to_cpu(r.eeprom->offset);
825*4882a593Smuzhiyun 		eeprom->byte_count = le16_to_cpu(r.eeprom->byte_count);
826*4882a593Smuzhiyun 		if (eeprom->byte_count > 0)
827*4882a593Smuzhiyun 			memcpy(&eeprom->value, &r.eeprom->value,
828*4882a593Smuzhiyun 			       min((u16)MAX_EEPROM_DATA, eeprom->byte_count));
829*4882a593Smuzhiyun 		break;
830*4882a593Smuzhiyun 	default:
831*4882a593Smuzhiyun 		return -1;
832*4882a593Smuzhiyun 	}
833*4882a593Smuzhiyun 	return 0;
834*4882a593Smuzhiyun }
835*4882a593Smuzhiyun 
836*4882a593Smuzhiyun /*
837*4882a593Smuzhiyun  * This function handles the command response of get IBSS coalescing status.
838*4882a593Smuzhiyun  *
839*4882a593Smuzhiyun  * If the received BSSID is different than the current one, the current BSSID,
840*4882a593Smuzhiyun  * beacon interval, ATIM window and ERP information are updated, along with
841*4882a593Smuzhiyun  * changing the ad-hoc state accordingly.
842*4882a593Smuzhiyun  */
mwifiex_ret_ibss_coalescing_status(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)843*4882a593Smuzhiyun static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
844*4882a593Smuzhiyun 					      struct host_cmd_ds_command *resp)
845*4882a593Smuzhiyun {
846*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp =
847*4882a593Smuzhiyun 					&(resp->params.ibss_coalescing);
848*4882a593Smuzhiyun 
849*4882a593Smuzhiyun 	if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET)
850*4882a593Smuzhiyun 		return 0;
851*4882a593Smuzhiyun 
852*4882a593Smuzhiyun 	mwifiex_dbg(priv->adapter, INFO,
853*4882a593Smuzhiyun 		    "info: new BSSID %pM\n", ibss_coal_resp->bssid);
854*4882a593Smuzhiyun 
855*4882a593Smuzhiyun 	/* If rsp has NULL BSSID, Just return..... No Action */
856*4882a593Smuzhiyun 	if (is_zero_ether_addr(ibss_coal_resp->bssid)) {
857*4882a593Smuzhiyun 		mwifiex_dbg(priv->adapter, FATAL, "new BSSID is NULL\n");
858*4882a593Smuzhiyun 		return 0;
859*4882a593Smuzhiyun 	}
860*4882a593Smuzhiyun 
861*4882a593Smuzhiyun 	/* If BSSID is diff, modify current BSS parameters */
862*4882a593Smuzhiyun 	if (!ether_addr_equal(priv->curr_bss_params.bss_descriptor.mac_address, ibss_coal_resp->bssid)) {
863*4882a593Smuzhiyun 		/* BSSID */
864*4882a593Smuzhiyun 		memcpy(priv->curr_bss_params.bss_descriptor.mac_address,
865*4882a593Smuzhiyun 		       ibss_coal_resp->bssid, ETH_ALEN);
866*4882a593Smuzhiyun 
867*4882a593Smuzhiyun 		/* Beacon Interval */
868*4882a593Smuzhiyun 		priv->curr_bss_params.bss_descriptor.beacon_period
869*4882a593Smuzhiyun 			= le16_to_cpu(ibss_coal_resp->beacon_interval);
870*4882a593Smuzhiyun 
871*4882a593Smuzhiyun 		/* ERP Information */
872*4882a593Smuzhiyun 		priv->curr_bss_params.bss_descriptor.erp_flags =
873*4882a593Smuzhiyun 			(u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect);
874*4882a593Smuzhiyun 
875*4882a593Smuzhiyun 		priv->adhoc_state = ADHOC_COALESCED;
876*4882a593Smuzhiyun 	}
877*4882a593Smuzhiyun 
878*4882a593Smuzhiyun 	return 0;
879*4882a593Smuzhiyun }
mwifiex_ret_tdls_oper(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)880*4882a593Smuzhiyun static int mwifiex_ret_tdls_oper(struct mwifiex_private *priv,
881*4882a593Smuzhiyun 				 struct host_cmd_ds_command *resp)
882*4882a593Smuzhiyun {
883*4882a593Smuzhiyun 	struct host_cmd_ds_tdls_oper *cmd_tdls_oper = &resp->params.tdls_oper;
884*4882a593Smuzhiyun 	u16 reason = le16_to_cpu(cmd_tdls_oper->reason);
885*4882a593Smuzhiyun 	u16 action = le16_to_cpu(cmd_tdls_oper->tdls_action);
886*4882a593Smuzhiyun 	struct mwifiex_sta_node *node =
887*4882a593Smuzhiyun 			   mwifiex_get_sta_entry(priv, cmd_tdls_oper->peer_mac);
888*4882a593Smuzhiyun 
889*4882a593Smuzhiyun 	switch (action) {
890*4882a593Smuzhiyun 	case ACT_TDLS_DELETE:
891*4882a593Smuzhiyun 		if (reason) {
892*4882a593Smuzhiyun 			if (!node || reason == TDLS_ERR_LINK_NONEXISTENT)
893*4882a593Smuzhiyun 				mwifiex_dbg(priv->adapter, MSG,
894*4882a593Smuzhiyun 					    "TDLS link delete for %pM failed: reason %d\n",
895*4882a593Smuzhiyun 					    cmd_tdls_oper->peer_mac, reason);
896*4882a593Smuzhiyun 			else
897*4882a593Smuzhiyun 				mwifiex_dbg(priv->adapter, ERROR,
898*4882a593Smuzhiyun 					    "TDLS link delete for %pM failed: reason %d\n",
899*4882a593Smuzhiyun 					    cmd_tdls_oper->peer_mac, reason);
900*4882a593Smuzhiyun 		} else {
901*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, MSG,
902*4882a593Smuzhiyun 				    "TDLS link delete for %pM successful\n",
903*4882a593Smuzhiyun 				    cmd_tdls_oper->peer_mac);
904*4882a593Smuzhiyun 		}
905*4882a593Smuzhiyun 		break;
906*4882a593Smuzhiyun 	case ACT_TDLS_CREATE:
907*4882a593Smuzhiyun 		if (reason) {
908*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, ERROR,
909*4882a593Smuzhiyun 				    "TDLS link creation for %pM failed: reason %d",
910*4882a593Smuzhiyun 				    cmd_tdls_oper->peer_mac, reason);
911*4882a593Smuzhiyun 			if (node && reason != TDLS_ERR_LINK_EXISTS)
912*4882a593Smuzhiyun 				node->tdls_status = TDLS_SETUP_FAILURE;
913*4882a593Smuzhiyun 		} else {
914*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, MSG,
915*4882a593Smuzhiyun 				    "TDLS link creation for %pM successful",
916*4882a593Smuzhiyun 				    cmd_tdls_oper->peer_mac);
917*4882a593Smuzhiyun 		}
918*4882a593Smuzhiyun 		break;
919*4882a593Smuzhiyun 	case ACT_TDLS_CONFIG:
920*4882a593Smuzhiyun 		if (reason) {
921*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, ERROR,
922*4882a593Smuzhiyun 				    "TDLS link config for %pM failed, reason %d\n",
923*4882a593Smuzhiyun 				    cmd_tdls_oper->peer_mac, reason);
924*4882a593Smuzhiyun 			if (node)
925*4882a593Smuzhiyun 				node->tdls_status = TDLS_SETUP_FAILURE;
926*4882a593Smuzhiyun 		} else {
927*4882a593Smuzhiyun 			mwifiex_dbg(priv->adapter, MSG,
928*4882a593Smuzhiyun 				    "TDLS link config for %pM successful\n",
929*4882a593Smuzhiyun 				    cmd_tdls_oper->peer_mac);
930*4882a593Smuzhiyun 		}
931*4882a593Smuzhiyun 		break;
932*4882a593Smuzhiyun 	default:
933*4882a593Smuzhiyun 		mwifiex_dbg(priv->adapter, ERROR,
934*4882a593Smuzhiyun 			    "Unknown TDLS command action response %d", action);
935*4882a593Smuzhiyun 		return -1;
936*4882a593Smuzhiyun 	}
937*4882a593Smuzhiyun 
938*4882a593Smuzhiyun 	return 0;
939*4882a593Smuzhiyun }
940*4882a593Smuzhiyun /*
941*4882a593Smuzhiyun  * This function handles the command response for subscribe event command.
942*4882a593Smuzhiyun  */
mwifiex_ret_subsc_evt(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)943*4882a593Smuzhiyun static int mwifiex_ret_subsc_evt(struct mwifiex_private *priv,
944*4882a593Smuzhiyun 				 struct host_cmd_ds_command *resp)
945*4882a593Smuzhiyun {
946*4882a593Smuzhiyun 	struct host_cmd_ds_802_11_subsc_evt *cmd_sub_event =
947*4882a593Smuzhiyun 		&resp->params.subsc_evt;
948*4882a593Smuzhiyun 
949*4882a593Smuzhiyun 	/* For every subscribe event command (Get/Set/Clear), FW reports the
950*4882a593Smuzhiyun 	 * current set of subscribed events*/
951*4882a593Smuzhiyun 	mwifiex_dbg(priv->adapter, EVENT,
952*4882a593Smuzhiyun 		    "Bitmap of currently subscribed events: %16x\n",
953*4882a593Smuzhiyun 		    le16_to_cpu(cmd_sub_event->events));
954*4882a593Smuzhiyun 
955*4882a593Smuzhiyun 	return 0;
956*4882a593Smuzhiyun }
957*4882a593Smuzhiyun 
mwifiex_ret_uap_sta_list(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)958*4882a593Smuzhiyun static int mwifiex_ret_uap_sta_list(struct mwifiex_private *priv,
959*4882a593Smuzhiyun 				    struct host_cmd_ds_command *resp)
960*4882a593Smuzhiyun {
961*4882a593Smuzhiyun 	struct host_cmd_ds_sta_list *sta_list =
962*4882a593Smuzhiyun 		&resp->params.sta_list;
963*4882a593Smuzhiyun 	struct mwifiex_ie_types_sta_info *sta_info = (void *)&sta_list->tlv;
964*4882a593Smuzhiyun 	int i;
965*4882a593Smuzhiyun 	struct mwifiex_sta_node *sta_node;
966*4882a593Smuzhiyun 
967*4882a593Smuzhiyun 	for (i = 0; i < (le16_to_cpu(sta_list->sta_count)); i++) {
968*4882a593Smuzhiyun 		sta_node = mwifiex_get_sta_entry(priv, sta_info->mac);
969*4882a593Smuzhiyun 		if (unlikely(!sta_node))
970*4882a593Smuzhiyun 			continue;
971*4882a593Smuzhiyun 
972*4882a593Smuzhiyun 		sta_node->stats.rssi = sta_info->rssi;
973*4882a593Smuzhiyun 		sta_info++;
974*4882a593Smuzhiyun 	}
975*4882a593Smuzhiyun 
976*4882a593Smuzhiyun 	return 0;
977*4882a593Smuzhiyun }
978*4882a593Smuzhiyun 
979*4882a593Smuzhiyun /* This function handles the command response of set_cfg_data */
mwifiex_ret_cfg_data(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)980*4882a593Smuzhiyun static int mwifiex_ret_cfg_data(struct mwifiex_private *priv,
981*4882a593Smuzhiyun 				struct host_cmd_ds_command *resp)
982*4882a593Smuzhiyun {
983*4882a593Smuzhiyun 	if (resp->result != HostCmd_RESULT_OK) {
984*4882a593Smuzhiyun 		mwifiex_dbg(priv->adapter, ERROR, "Cal data cmd resp failed\n");
985*4882a593Smuzhiyun 		return -1;
986*4882a593Smuzhiyun 	}
987*4882a593Smuzhiyun 
988*4882a593Smuzhiyun 	return 0;
989*4882a593Smuzhiyun }
990*4882a593Smuzhiyun 
991*4882a593Smuzhiyun /** This Function handles the command response of sdio rx aggr */
mwifiex_ret_sdio_rx_aggr_cfg(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)992*4882a593Smuzhiyun static int mwifiex_ret_sdio_rx_aggr_cfg(struct mwifiex_private *priv,
993*4882a593Smuzhiyun 					struct host_cmd_ds_command *resp)
994*4882a593Smuzhiyun {
995*4882a593Smuzhiyun 	struct mwifiex_adapter *adapter = priv->adapter;
996*4882a593Smuzhiyun 	struct host_cmd_sdio_sp_rx_aggr_cfg *cfg =
997*4882a593Smuzhiyun 				&resp->params.sdio_rx_aggr_cfg;
998*4882a593Smuzhiyun 
999*4882a593Smuzhiyun 	adapter->sdio_rx_aggr_enable = cfg->enable;
1000*4882a593Smuzhiyun 	adapter->sdio_rx_block_size = le16_to_cpu(cfg->block_size);
1001*4882a593Smuzhiyun 
1002*4882a593Smuzhiyun 	return 0;
1003*4882a593Smuzhiyun }
1004*4882a593Smuzhiyun 
mwifiex_ret_robust_coex(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,bool * is_timeshare)1005*4882a593Smuzhiyun static int mwifiex_ret_robust_coex(struct mwifiex_private *priv,
1006*4882a593Smuzhiyun 				   struct host_cmd_ds_command *resp,
1007*4882a593Smuzhiyun 				   bool *is_timeshare)
1008*4882a593Smuzhiyun {
1009*4882a593Smuzhiyun 	struct host_cmd_ds_robust_coex *coex = &resp->params.coex;
1010*4882a593Smuzhiyun 	struct mwifiex_ie_types_robust_coex *coex_tlv;
1011*4882a593Smuzhiyun 	u16 action = le16_to_cpu(coex->action);
1012*4882a593Smuzhiyun 	u32 mode;
1013*4882a593Smuzhiyun 
1014*4882a593Smuzhiyun 	coex_tlv = (struct mwifiex_ie_types_robust_coex
1015*4882a593Smuzhiyun 		    *)((u8 *)coex + sizeof(struct host_cmd_ds_robust_coex));
1016*4882a593Smuzhiyun 	if (action == HostCmd_ACT_GEN_GET) {
1017*4882a593Smuzhiyun 		mode = le32_to_cpu(coex_tlv->mode);
1018*4882a593Smuzhiyun 		if (mode == MWIFIEX_COEX_MODE_TIMESHARE)
1019*4882a593Smuzhiyun 			*is_timeshare = true;
1020*4882a593Smuzhiyun 		else
1021*4882a593Smuzhiyun 			*is_timeshare = false;
1022*4882a593Smuzhiyun 	}
1023*4882a593Smuzhiyun 
1024*4882a593Smuzhiyun 	return 0;
1025*4882a593Smuzhiyun }
1026*4882a593Smuzhiyun 
1027*4882a593Smuzhiyun static struct ieee80211_regdomain *
mwifiex_create_custom_regdomain(struct mwifiex_private * priv,u8 * buf,u16 buf_len)1028*4882a593Smuzhiyun mwifiex_create_custom_regdomain(struct mwifiex_private *priv,
1029*4882a593Smuzhiyun 				u8 *buf, u16 buf_len)
1030*4882a593Smuzhiyun {
1031*4882a593Smuzhiyun 	u16 num_chan = buf_len / 2;
1032*4882a593Smuzhiyun 	struct ieee80211_regdomain *regd;
1033*4882a593Smuzhiyun 	struct ieee80211_reg_rule *rule;
1034*4882a593Smuzhiyun 	bool new_rule;
1035*4882a593Smuzhiyun 	int idx, freq, prev_freq = 0;
1036*4882a593Smuzhiyun 	u32 bw, prev_bw = 0;
1037*4882a593Smuzhiyun 	u8 chflags, prev_chflags = 0, valid_rules = 0;
1038*4882a593Smuzhiyun 
1039*4882a593Smuzhiyun 	if (WARN_ON_ONCE(num_chan > NL80211_MAX_SUPP_REG_RULES))
1040*4882a593Smuzhiyun 		return ERR_PTR(-EINVAL);
1041*4882a593Smuzhiyun 
1042*4882a593Smuzhiyun 	regd = kzalloc(struct_size(regd, reg_rules, num_chan), GFP_KERNEL);
1043*4882a593Smuzhiyun 	if (!regd)
1044*4882a593Smuzhiyun 		return ERR_PTR(-ENOMEM);
1045*4882a593Smuzhiyun 
1046*4882a593Smuzhiyun 	for (idx = 0; idx < num_chan; idx++) {
1047*4882a593Smuzhiyun 		u8 chan;
1048*4882a593Smuzhiyun 		enum nl80211_band band;
1049*4882a593Smuzhiyun 
1050*4882a593Smuzhiyun 		chan = *buf++;
1051*4882a593Smuzhiyun 		if (!chan) {
1052*4882a593Smuzhiyun 			kfree(regd);
1053*4882a593Smuzhiyun 			return NULL;
1054*4882a593Smuzhiyun 		}
1055*4882a593Smuzhiyun 		chflags = *buf++;
1056*4882a593Smuzhiyun 		band = (chan <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
1057*4882a593Smuzhiyun 		freq = ieee80211_channel_to_frequency(chan, band);
1058*4882a593Smuzhiyun 		new_rule = false;
1059*4882a593Smuzhiyun 
1060*4882a593Smuzhiyun 		if (chflags & MWIFIEX_CHANNEL_DISABLED)
1061*4882a593Smuzhiyun 			continue;
1062*4882a593Smuzhiyun 
1063*4882a593Smuzhiyun 		if (band == NL80211_BAND_5GHZ) {
1064*4882a593Smuzhiyun 			if (!(chflags & MWIFIEX_CHANNEL_NOHT80))
1065*4882a593Smuzhiyun 				bw = MHZ_TO_KHZ(80);
1066*4882a593Smuzhiyun 			else if (!(chflags & MWIFIEX_CHANNEL_NOHT40))
1067*4882a593Smuzhiyun 				bw = MHZ_TO_KHZ(40);
1068*4882a593Smuzhiyun 			else
1069*4882a593Smuzhiyun 				bw = MHZ_TO_KHZ(20);
1070*4882a593Smuzhiyun 		} else {
1071*4882a593Smuzhiyun 			if (!(chflags & MWIFIEX_CHANNEL_NOHT40))
1072*4882a593Smuzhiyun 				bw = MHZ_TO_KHZ(40);
1073*4882a593Smuzhiyun 			else
1074*4882a593Smuzhiyun 				bw = MHZ_TO_KHZ(20);
1075*4882a593Smuzhiyun 		}
1076*4882a593Smuzhiyun 
1077*4882a593Smuzhiyun 		if (idx == 0 || prev_chflags != chflags || prev_bw != bw ||
1078*4882a593Smuzhiyun 		    freq - prev_freq > 20) {
1079*4882a593Smuzhiyun 			valid_rules++;
1080*4882a593Smuzhiyun 			new_rule = true;
1081*4882a593Smuzhiyun 		}
1082*4882a593Smuzhiyun 
1083*4882a593Smuzhiyun 		rule = &regd->reg_rules[valid_rules - 1];
1084*4882a593Smuzhiyun 
1085*4882a593Smuzhiyun 		rule->freq_range.end_freq_khz = MHZ_TO_KHZ(freq + 10);
1086*4882a593Smuzhiyun 
1087*4882a593Smuzhiyun 		prev_chflags = chflags;
1088*4882a593Smuzhiyun 		prev_freq = freq;
1089*4882a593Smuzhiyun 		prev_bw = bw;
1090*4882a593Smuzhiyun 
1091*4882a593Smuzhiyun 		if (!new_rule)
1092*4882a593Smuzhiyun 			continue;
1093*4882a593Smuzhiyun 
1094*4882a593Smuzhiyun 		rule->freq_range.start_freq_khz = MHZ_TO_KHZ(freq - 10);
1095*4882a593Smuzhiyun 		rule->power_rule.max_eirp = DBM_TO_MBM(19);
1096*4882a593Smuzhiyun 
1097*4882a593Smuzhiyun 		if (chflags & MWIFIEX_CHANNEL_PASSIVE)
1098*4882a593Smuzhiyun 			rule->flags = NL80211_RRF_NO_IR;
1099*4882a593Smuzhiyun 
1100*4882a593Smuzhiyun 		if (chflags & MWIFIEX_CHANNEL_DFS)
1101*4882a593Smuzhiyun 			rule->flags = NL80211_RRF_DFS;
1102*4882a593Smuzhiyun 
1103*4882a593Smuzhiyun 		rule->freq_range.max_bandwidth_khz = bw;
1104*4882a593Smuzhiyun 	}
1105*4882a593Smuzhiyun 
1106*4882a593Smuzhiyun 	regd->n_reg_rules = valid_rules;
1107*4882a593Smuzhiyun 	regd->alpha2[0] = '9';
1108*4882a593Smuzhiyun 	regd->alpha2[1] = '9';
1109*4882a593Smuzhiyun 
1110*4882a593Smuzhiyun 	return regd;
1111*4882a593Smuzhiyun }
1112*4882a593Smuzhiyun 
mwifiex_ret_chan_region_cfg(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)1113*4882a593Smuzhiyun static int mwifiex_ret_chan_region_cfg(struct mwifiex_private *priv,
1114*4882a593Smuzhiyun 				       struct host_cmd_ds_command *resp)
1115*4882a593Smuzhiyun {
1116*4882a593Smuzhiyun 	struct host_cmd_ds_chan_region_cfg *reg = &resp->params.reg_cfg;
1117*4882a593Smuzhiyun 	u16 action = le16_to_cpu(reg->action);
1118*4882a593Smuzhiyun 	u16 tlv, tlv_buf_len, tlv_buf_left;
1119*4882a593Smuzhiyun 	struct mwifiex_ie_types_header *head;
1120*4882a593Smuzhiyun 	struct ieee80211_regdomain *regd;
1121*4882a593Smuzhiyun 	u8 *tlv_buf;
1122*4882a593Smuzhiyun 
1123*4882a593Smuzhiyun 	if (action != HostCmd_ACT_GEN_GET)
1124*4882a593Smuzhiyun 		return 0;
1125*4882a593Smuzhiyun 
1126*4882a593Smuzhiyun 	tlv_buf = (u8 *)reg + sizeof(*reg);
1127*4882a593Smuzhiyun 	tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*reg);
1128*4882a593Smuzhiyun 
1129*4882a593Smuzhiyun 	while (tlv_buf_left >= sizeof(*head)) {
1130*4882a593Smuzhiyun 		head = (struct mwifiex_ie_types_header *)tlv_buf;
1131*4882a593Smuzhiyun 		tlv = le16_to_cpu(head->type);
1132*4882a593Smuzhiyun 		tlv_buf_len = le16_to_cpu(head->len);
1133*4882a593Smuzhiyun 
1134*4882a593Smuzhiyun 		if (tlv_buf_left < (sizeof(*head) + tlv_buf_len))
1135*4882a593Smuzhiyun 			break;
1136*4882a593Smuzhiyun 
1137*4882a593Smuzhiyun 		switch (tlv) {
1138*4882a593Smuzhiyun 		case TLV_TYPE_CHAN_ATTR_CFG:
1139*4882a593Smuzhiyun 			mwifiex_dbg_dump(priv->adapter, CMD_D, "CHAN:",
1140*4882a593Smuzhiyun 					 (u8 *)head + sizeof(*head),
1141*4882a593Smuzhiyun 					 tlv_buf_len);
1142*4882a593Smuzhiyun 			regd = mwifiex_create_custom_regdomain(priv,
1143*4882a593Smuzhiyun 				(u8 *)head + sizeof(*head), tlv_buf_len);
1144*4882a593Smuzhiyun 			if (!IS_ERR(regd))
1145*4882a593Smuzhiyun 				priv->adapter->regd = regd;
1146*4882a593Smuzhiyun 			break;
1147*4882a593Smuzhiyun 		}
1148*4882a593Smuzhiyun 
1149*4882a593Smuzhiyun 		tlv_buf += (sizeof(*head) + tlv_buf_len);
1150*4882a593Smuzhiyun 		tlv_buf_left -= (sizeof(*head) + tlv_buf_len);
1151*4882a593Smuzhiyun 	}
1152*4882a593Smuzhiyun 
1153*4882a593Smuzhiyun 	return 0;
1154*4882a593Smuzhiyun }
1155*4882a593Smuzhiyun 
mwifiex_ret_pkt_aggr_ctrl(struct mwifiex_private * priv,struct host_cmd_ds_command * resp)1156*4882a593Smuzhiyun static int mwifiex_ret_pkt_aggr_ctrl(struct mwifiex_private *priv,
1157*4882a593Smuzhiyun 				     struct host_cmd_ds_command *resp)
1158*4882a593Smuzhiyun {
1159*4882a593Smuzhiyun 	struct host_cmd_ds_pkt_aggr_ctrl *pkt_aggr_ctrl =
1160*4882a593Smuzhiyun 					&resp->params.pkt_aggr_ctrl;
1161*4882a593Smuzhiyun 	struct mwifiex_adapter *adapter = priv->adapter;
1162*4882a593Smuzhiyun 
1163*4882a593Smuzhiyun 	adapter->bus_aggr.enable = le16_to_cpu(pkt_aggr_ctrl->enable);
1164*4882a593Smuzhiyun 	if (adapter->bus_aggr.enable)
1165*4882a593Smuzhiyun 		adapter->intf_hdr_len = INTF_HEADER_LEN;
1166*4882a593Smuzhiyun 	adapter->bus_aggr.mode = MWIFIEX_BUS_AGGR_MODE_LEN_V2;
1167*4882a593Smuzhiyun 	adapter->bus_aggr.tx_aggr_max_size =
1168*4882a593Smuzhiyun 				le16_to_cpu(pkt_aggr_ctrl->tx_aggr_max_size);
1169*4882a593Smuzhiyun 	adapter->bus_aggr.tx_aggr_max_num =
1170*4882a593Smuzhiyun 				le16_to_cpu(pkt_aggr_ctrl->tx_aggr_max_num);
1171*4882a593Smuzhiyun 	adapter->bus_aggr.tx_aggr_align =
1172*4882a593Smuzhiyun 				le16_to_cpu(pkt_aggr_ctrl->tx_aggr_align);
1173*4882a593Smuzhiyun 
1174*4882a593Smuzhiyun 	return 0;
1175*4882a593Smuzhiyun }
1176*4882a593Smuzhiyun 
mwifiex_ret_get_chan_info(struct mwifiex_private * priv,struct host_cmd_ds_command * resp,struct mwifiex_channel_band * channel_band)1177*4882a593Smuzhiyun static int mwifiex_ret_get_chan_info(struct mwifiex_private *priv,
1178*4882a593Smuzhiyun 				     struct host_cmd_ds_command *resp,
1179*4882a593Smuzhiyun 				     struct mwifiex_channel_band *channel_band)
1180*4882a593Smuzhiyun {
1181*4882a593Smuzhiyun 	struct host_cmd_ds_sta_configure *sta_cfg_cmd = &resp->params.sta_cfg;
1182*4882a593Smuzhiyun 	struct host_cmd_tlv_channel_band *tlv_band_channel;
1183*4882a593Smuzhiyun 
1184*4882a593Smuzhiyun 	tlv_band_channel =
1185*4882a593Smuzhiyun 	(struct host_cmd_tlv_channel_band *)sta_cfg_cmd->tlv_buffer;
1186*4882a593Smuzhiyun 	memcpy(&channel_band->band_config, &tlv_band_channel->band_config,
1187*4882a593Smuzhiyun 	       sizeof(struct mwifiex_band_config));
1188*4882a593Smuzhiyun 	channel_band->channel = tlv_band_channel->channel;
1189*4882a593Smuzhiyun 
1190*4882a593Smuzhiyun 	return 0;
1191*4882a593Smuzhiyun }
1192*4882a593Smuzhiyun 
1193*4882a593Smuzhiyun /*
1194*4882a593Smuzhiyun  * This function handles the command responses.
1195*4882a593Smuzhiyun  *
1196*4882a593Smuzhiyun  * This is a generic function, which calls command specific
1197*4882a593Smuzhiyun  * response handlers based on the command ID.
1198*4882a593Smuzhiyun  */
mwifiex_process_sta_cmdresp(struct mwifiex_private * priv,u16 cmdresp_no,struct host_cmd_ds_command * resp)1199*4882a593Smuzhiyun int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
1200*4882a593Smuzhiyun 				struct host_cmd_ds_command *resp)
1201*4882a593Smuzhiyun {
1202*4882a593Smuzhiyun 	int ret = 0;
1203*4882a593Smuzhiyun 	struct mwifiex_adapter *adapter = priv->adapter;
1204*4882a593Smuzhiyun 	void *data_buf = adapter->curr_cmd->data_buf;
1205*4882a593Smuzhiyun 
1206*4882a593Smuzhiyun 	/* If the command is not successful, cleanup and return failure */
1207*4882a593Smuzhiyun 	if (resp->result != HostCmd_RESULT_OK) {
1208*4882a593Smuzhiyun 		mwifiex_process_cmdresp_error(priv, resp);
1209*4882a593Smuzhiyun 		return -1;
1210*4882a593Smuzhiyun 	}
1211*4882a593Smuzhiyun 	/* Command successful, handle response */
1212*4882a593Smuzhiyun 	switch (cmdresp_no) {
1213*4882a593Smuzhiyun 	case HostCmd_CMD_GET_HW_SPEC:
1214*4882a593Smuzhiyun 		ret = mwifiex_ret_get_hw_spec(priv, resp);
1215*4882a593Smuzhiyun 		break;
1216*4882a593Smuzhiyun 	case HostCmd_CMD_CFG_DATA:
1217*4882a593Smuzhiyun 		ret = mwifiex_ret_cfg_data(priv, resp);
1218*4882a593Smuzhiyun 		break;
1219*4882a593Smuzhiyun 	case HostCmd_CMD_MAC_CONTROL:
1220*4882a593Smuzhiyun 		break;
1221*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_MAC_ADDRESS:
1222*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_mac_address(priv, resp);
1223*4882a593Smuzhiyun 		break;
1224*4882a593Smuzhiyun 	case HostCmd_CMD_MAC_MULTICAST_ADR:
1225*4882a593Smuzhiyun 		ret = mwifiex_ret_mac_multicast_adr(priv, resp);
1226*4882a593Smuzhiyun 		break;
1227*4882a593Smuzhiyun 	case HostCmd_CMD_TX_RATE_CFG:
1228*4882a593Smuzhiyun 		ret = mwifiex_ret_tx_rate_cfg(priv, resp);
1229*4882a593Smuzhiyun 		break;
1230*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_SCAN:
1231*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_scan(priv, resp);
1232*4882a593Smuzhiyun 		adapter->curr_cmd->wait_q_enabled = false;
1233*4882a593Smuzhiyun 		break;
1234*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_SCAN_EXT:
1235*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_scan_ext(priv, resp);
1236*4882a593Smuzhiyun 		adapter->curr_cmd->wait_q_enabled = false;
1237*4882a593Smuzhiyun 		break;
1238*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_BG_SCAN_QUERY:
1239*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_scan(priv, resp);
1240*4882a593Smuzhiyun 		cfg80211_sched_scan_results(priv->wdev.wiphy, 0);
1241*4882a593Smuzhiyun 		mwifiex_dbg(adapter, CMD,
1242*4882a593Smuzhiyun 			    "info: CMD_RESP: BG_SCAN result is ready!\n");
1243*4882a593Smuzhiyun 		break;
1244*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_BG_SCAN_CONFIG:
1245*4882a593Smuzhiyun 		break;
1246*4882a593Smuzhiyun 	case HostCmd_CMD_TXPWR_CFG:
1247*4882a593Smuzhiyun 		ret = mwifiex_ret_tx_power_cfg(priv, resp);
1248*4882a593Smuzhiyun 		break;
1249*4882a593Smuzhiyun 	case HostCmd_CMD_RF_TX_PWR:
1250*4882a593Smuzhiyun 		ret = mwifiex_ret_rf_tx_power(priv, resp);
1251*4882a593Smuzhiyun 		break;
1252*4882a593Smuzhiyun 	case HostCmd_CMD_RF_ANTENNA:
1253*4882a593Smuzhiyun 		ret = mwifiex_ret_rf_antenna(priv, resp);
1254*4882a593Smuzhiyun 		break;
1255*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_PS_MODE_ENH:
1256*4882a593Smuzhiyun 		ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf);
1257*4882a593Smuzhiyun 		break;
1258*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_HS_CFG_ENH:
1259*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
1260*4882a593Smuzhiyun 		break;
1261*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_ASSOCIATE:
1262*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_associate(priv, resp);
1263*4882a593Smuzhiyun 		break;
1264*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_DEAUTHENTICATE:
1265*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
1266*4882a593Smuzhiyun 		break;
1267*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_AD_HOC_START:
1268*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_AD_HOC_JOIN:
1269*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_ad_hoc(priv, resp);
1270*4882a593Smuzhiyun 		break;
1271*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_AD_HOC_STOP:
1272*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
1273*4882a593Smuzhiyun 		break;
1274*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_GET_LOG:
1275*4882a593Smuzhiyun 		ret = mwifiex_ret_get_log(priv, resp, data_buf);
1276*4882a593Smuzhiyun 		break;
1277*4882a593Smuzhiyun 	case HostCmd_CMD_RSSI_INFO:
1278*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_rssi_info(priv, resp);
1279*4882a593Smuzhiyun 		break;
1280*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_SNMP_MIB:
1281*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf);
1282*4882a593Smuzhiyun 		break;
1283*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_TX_RATE_QUERY:
1284*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
1285*4882a593Smuzhiyun 		break;
1286*4882a593Smuzhiyun 	case HostCmd_CMD_VERSION_EXT:
1287*4882a593Smuzhiyun 		ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
1288*4882a593Smuzhiyun 		break;
1289*4882a593Smuzhiyun 	case HostCmd_CMD_REMAIN_ON_CHAN:
1290*4882a593Smuzhiyun 		ret = mwifiex_ret_remain_on_chan(priv, resp, data_buf);
1291*4882a593Smuzhiyun 		break;
1292*4882a593Smuzhiyun 	case HostCmd_CMD_11AC_CFG:
1293*4882a593Smuzhiyun 		break;
1294*4882a593Smuzhiyun 	case HostCmd_CMD_PACKET_AGGR_CTRL:
1295*4882a593Smuzhiyun 		ret = mwifiex_ret_pkt_aggr_ctrl(priv, resp);
1296*4882a593Smuzhiyun 		break;
1297*4882a593Smuzhiyun 	case HostCmd_CMD_P2P_MODE_CFG:
1298*4882a593Smuzhiyun 		ret = mwifiex_ret_p2p_mode_cfg(priv, resp, data_buf);
1299*4882a593Smuzhiyun 		break;
1300*4882a593Smuzhiyun 	case HostCmd_CMD_MGMT_FRAME_REG:
1301*4882a593Smuzhiyun 	case HostCmd_CMD_FUNC_INIT:
1302*4882a593Smuzhiyun 	case HostCmd_CMD_FUNC_SHUTDOWN:
1303*4882a593Smuzhiyun 		break;
1304*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_KEY_MATERIAL:
1305*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11_key_material(priv, resp);
1306*4882a593Smuzhiyun 		break;
1307*4882a593Smuzhiyun 	case HostCmd_CMD_802_11D_DOMAIN_INFO:
1308*4882a593Smuzhiyun 		ret = mwifiex_ret_802_11d_domain_info(priv, resp);
1309*4882a593Smuzhiyun 		break;
1310*4882a593Smuzhiyun 	case HostCmd_CMD_11N_ADDBA_REQ:
1311*4882a593Smuzhiyun 		ret = mwifiex_ret_11n_addba_req(priv, resp);
1312*4882a593Smuzhiyun 		break;
1313*4882a593Smuzhiyun 	case HostCmd_CMD_11N_DELBA:
1314*4882a593Smuzhiyun 		ret = mwifiex_ret_11n_delba(priv, resp);
1315*4882a593Smuzhiyun 		break;
1316*4882a593Smuzhiyun 	case HostCmd_CMD_11N_ADDBA_RSP:
1317*4882a593Smuzhiyun 		ret = mwifiex_ret_11n_addba_resp(priv, resp);
1318*4882a593Smuzhiyun 		break;
1319*4882a593Smuzhiyun 	case HostCmd_CMD_RECONFIGURE_TX_BUFF:
1320*4882a593Smuzhiyun 		if (0xffff == (u16)le16_to_cpu(resp->params.tx_buf.buff_size)) {
1321*4882a593Smuzhiyun 			if (adapter->iface_type == MWIFIEX_USB &&
1322*4882a593Smuzhiyun 			    adapter->usb_mc_setup) {
1323*4882a593Smuzhiyun 				if (adapter->if_ops.multi_port_resync)
1324*4882a593Smuzhiyun 					adapter->if_ops.
1325*4882a593Smuzhiyun 						multi_port_resync(adapter);
1326*4882a593Smuzhiyun 				adapter->usb_mc_setup = false;
1327*4882a593Smuzhiyun 				adapter->tx_lock_flag = false;
1328*4882a593Smuzhiyun 			}
1329*4882a593Smuzhiyun 			break;
1330*4882a593Smuzhiyun 		}
1331*4882a593Smuzhiyun 		adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
1332*4882a593Smuzhiyun 							     tx_buf.buff_size);
1333*4882a593Smuzhiyun 		adapter->tx_buf_size = (adapter->tx_buf_size
1334*4882a593Smuzhiyun 					/ MWIFIEX_SDIO_BLOCK_SIZE)
1335*4882a593Smuzhiyun 				       * MWIFIEX_SDIO_BLOCK_SIZE;
1336*4882a593Smuzhiyun 		adapter->curr_tx_buf_size = adapter->tx_buf_size;
1337*4882a593Smuzhiyun 		mwifiex_dbg(adapter, CMD, "cmd: curr_tx_buf_size=%d\n",
1338*4882a593Smuzhiyun 			    adapter->curr_tx_buf_size);
1339*4882a593Smuzhiyun 
1340*4882a593Smuzhiyun 		if (adapter->if_ops.update_mp_end_port)
1341*4882a593Smuzhiyun 			adapter->if_ops.update_mp_end_port(adapter,
1342*4882a593Smuzhiyun 				le16_to_cpu(resp->params.tx_buf.mp_end_port));
1343*4882a593Smuzhiyun 		break;
1344*4882a593Smuzhiyun 	case HostCmd_CMD_AMSDU_AGGR_CTRL:
1345*4882a593Smuzhiyun 		break;
1346*4882a593Smuzhiyun 	case HostCmd_CMD_WMM_GET_STATUS:
1347*4882a593Smuzhiyun 		ret = mwifiex_ret_wmm_get_status(priv, resp);
1348*4882a593Smuzhiyun 		break;
1349*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
1350*4882a593Smuzhiyun 		ret = mwifiex_ret_ibss_coalescing_status(priv, resp);
1351*4882a593Smuzhiyun 		break;
1352*4882a593Smuzhiyun 	case HostCmd_CMD_MEM_ACCESS:
1353*4882a593Smuzhiyun 		ret = mwifiex_ret_mem_access(priv, resp, data_buf);
1354*4882a593Smuzhiyun 		break;
1355*4882a593Smuzhiyun 	case HostCmd_CMD_MAC_REG_ACCESS:
1356*4882a593Smuzhiyun 	case HostCmd_CMD_BBP_REG_ACCESS:
1357*4882a593Smuzhiyun 	case HostCmd_CMD_RF_REG_ACCESS:
1358*4882a593Smuzhiyun 	case HostCmd_CMD_PMIC_REG_ACCESS:
1359*4882a593Smuzhiyun 	case HostCmd_CMD_CAU_REG_ACCESS:
1360*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_EEPROM_ACCESS:
1361*4882a593Smuzhiyun 		ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf);
1362*4882a593Smuzhiyun 		break;
1363*4882a593Smuzhiyun 	case HostCmd_CMD_SET_BSS_MODE:
1364*4882a593Smuzhiyun 		break;
1365*4882a593Smuzhiyun 	case HostCmd_CMD_11N_CFG:
1366*4882a593Smuzhiyun 		break;
1367*4882a593Smuzhiyun 	case HostCmd_CMD_PCIE_DESC_DETAILS:
1368*4882a593Smuzhiyun 		break;
1369*4882a593Smuzhiyun 	case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
1370*4882a593Smuzhiyun 		ret = mwifiex_ret_subsc_evt(priv, resp);
1371*4882a593Smuzhiyun 		break;
1372*4882a593Smuzhiyun 	case HostCmd_CMD_UAP_SYS_CONFIG:
1373*4882a593Smuzhiyun 		break;
1374*4882a593Smuzhiyun 	case HOST_CMD_APCMD_STA_LIST:
1375*4882a593Smuzhiyun 		ret = mwifiex_ret_uap_sta_list(priv, resp);
1376*4882a593Smuzhiyun 		break;
1377*4882a593Smuzhiyun 	case HostCmd_CMD_UAP_BSS_START:
1378*4882a593Smuzhiyun 		adapter->tx_lock_flag = false;
1379*4882a593Smuzhiyun 		adapter->pps_uapsd_mode = false;
1380*4882a593Smuzhiyun 		adapter->delay_null_pkt = false;
1381*4882a593Smuzhiyun 		priv->bss_started = 1;
1382*4882a593Smuzhiyun 		break;
1383*4882a593Smuzhiyun 	case HostCmd_CMD_UAP_BSS_STOP:
1384*4882a593Smuzhiyun 		priv->bss_started = 0;
1385*4882a593Smuzhiyun 		break;
1386*4882a593Smuzhiyun 	case HostCmd_CMD_UAP_STA_DEAUTH:
1387*4882a593Smuzhiyun 		break;
1388*4882a593Smuzhiyun 	case HOST_CMD_APCMD_SYS_RESET:
1389*4882a593Smuzhiyun 		break;
1390*4882a593Smuzhiyun 	case HostCmd_CMD_MEF_CFG:
1391*4882a593Smuzhiyun 		break;
1392*4882a593Smuzhiyun 	case HostCmd_CMD_COALESCE_CFG:
1393*4882a593Smuzhiyun 		break;
1394*4882a593Smuzhiyun 	case HostCmd_CMD_TDLS_OPER:
1395*4882a593Smuzhiyun 		ret = mwifiex_ret_tdls_oper(priv, resp);
1396*4882a593Smuzhiyun 	case HostCmd_CMD_MC_POLICY:
1397*4882a593Smuzhiyun 		break;
1398*4882a593Smuzhiyun 	case HostCmd_CMD_CHAN_REPORT_REQUEST:
1399*4882a593Smuzhiyun 		break;
1400*4882a593Smuzhiyun 	case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG:
1401*4882a593Smuzhiyun 		ret = mwifiex_ret_sdio_rx_aggr_cfg(priv, resp);
1402*4882a593Smuzhiyun 		break;
1403*4882a593Smuzhiyun 	case HostCmd_CMD_HS_WAKEUP_REASON:
1404*4882a593Smuzhiyun 		ret = mwifiex_ret_wakeup_reason(priv, resp, data_buf);
1405*4882a593Smuzhiyun 		break;
1406*4882a593Smuzhiyun 	case HostCmd_CMD_TDLS_CONFIG:
1407*4882a593Smuzhiyun 		break;
1408*4882a593Smuzhiyun 	case HostCmd_CMD_ROBUST_COEX:
1409*4882a593Smuzhiyun 		ret = mwifiex_ret_robust_coex(priv, resp, data_buf);
1410*4882a593Smuzhiyun 		break;
1411*4882a593Smuzhiyun 	case HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG:
1412*4882a593Smuzhiyun 		break;
1413*4882a593Smuzhiyun 	case HostCmd_CMD_CHAN_REGION_CFG:
1414*4882a593Smuzhiyun 		ret = mwifiex_ret_chan_region_cfg(priv, resp);
1415*4882a593Smuzhiyun 		break;
1416*4882a593Smuzhiyun 	case HostCmd_CMD_STA_CONFIGURE:
1417*4882a593Smuzhiyun 		ret = mwifiex_ret_get_chan_info(priv, resp, data_buf);
1418*4882a593Smuzhiyun 		break;
1419*4882a593Smuzhiyun 	default:
1420*4882a593Smuzhiyun 		mwifiex_dbg(adapter, ERROR,
1421*4882a593Smuzhiyun 			    "CMD_RESP: unknown cmd response %#x\n",
1422*4882a593Smuzhiyun 			    resp->command);
1423*4882a593Smuzhiyun 		break;
1424*4882a593Smuzhiyun 	}
1425*4882a593Smuzhiyun 
1426*4882a593Smuzhiyun 	return ret;
1427*4882a593Smuzhiyun }
1428