2 * Marvell Wireless LAN device driver: AP specific command handling
4 * Copyright (C) 2012, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
22 /* Parse AP config structure and prepare TLV based command structure
23 * to be sent to FW for uAP configuration
25 static int mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command
*cmd
,
26 u16 cmd_action
, void *cmd_buf
)
29 struct host_cmd_ds_sys_config
*sys_config
= &cmd
->params
.uap_sys_config
;
30 struct host_cmd_tlv_channel_band
*chan_band
;
31 struct mwifiex_uap_bss_param
*bss_cfg
= cmd_buf
;
34 cmd
->command
= cpu_to_le16(HostCmd_CMD_UAP_SYS_CONFIG
);
35 cmd_size
= (u16
)(sizeof(struct host_cmd_ds_sys_config
) + S_DS_GEN
);
37 sys_config
->action
= cpu_to_le16(cmd_action
);
39 tlv
= sys_config
->tlv
;
41 if (bss_cfg
->channel
&& bss_cfg
->channel
<= MAX_CHANNEL_BAND_BG
) {
42 chan_band
= (struct host_cmd_tlv_channel_band
*)tlv
;
43 chan_band
->tlv
.type
= cpu_to_le16(TLV_TYPE_CHANNELBANDLIST
);
45 cpu_to_le16(sizeof(struct host_cmd_tlv_channel_band
) -
46 sizeof(struct host_cmd_tlv
));
47 chan_band
->band_config
= bss_cfg
->band_cfg
;
48 chan_band
->channel
= bss_cfg
->channel
;
49 cmd_size
+= sizeof(struct host_cmd_tlv_channel_band
);
50 tlv
+= sizeof(struct host_cmd_tlv_channel_band
);
53 cmd
->size
= cpu_to_le16(cmd_size
);
57 /* This function prepares the AP specific commands before sending them
59 * This is a generic function which calls specific command preparation
60 * routines based upon the command number.
62 int mwifiex_uap_prepare_cmd(struct mwifiex_private
*priv
, u16 cmd_no
,
63 u16 cmd_action
, u32 cmd_oid
,
64 void *data_buf
, void *cmd_buf
)
66 struct host_cmd_ds_command
*cmd
= cmd_buf
;
69 case HostCmd_CMD_UAP_SYS_CONFIG
:
70 if (mwifiex_cmd_uap_sys_config(cmd
, cmd_action
, data_buf
))
73 case HostCmd_CMD_UAP_BSS_START
:
74 case HostCmd_CMD_UAP_BSS_STOP
:
75 cmd
->command
= cpu_to_le16(cmd_no
);
76 cmd
->size
= cpu_to_le16(S_DS_GEN
);
79 dev_err(priv
->adapter
->dev
,
80 "PREP_CMD: unknown cmd %#x\n", cmd_no
);
87 /* This function sets the RF channel for AP.
89 * This function populates channel information in AP config structure
90 * and sends command to configure channel information in AP.
92 int mwifiex_uap_set_channel(struct mwifiex_private
*priv
, int channel
)
94 struct mwifiex_uap_bss_param
*bss_cfg
;
95 struct wiphy
*wiphy
= priv
->wdev
->wiphy
;
97 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
101 bss_cfg
->band_cfg
= BAND_CONFIG_MANUAL
;
102 bss_cfg
->channel
= channel
;
104 if (mwifiex_send_cmd_async(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
105 HostCmd_ACT_GEN_SET
, 0, bss_cfg
)) {
106 wiphy_err(wiphy
, "Failed to set the uAP channel\n");