summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnson <jjohnson@qca.qualcomm.com>2014-04-02 12:09:25 -0700
committerAkash Patel <c_akashp@qca.qualcomm.com>2014-04-03 05:36:53 -0700
commitd3d769e76b2733b0ecc26a44a6eb0d756a313cce (patch)
treed80241abebc66585d0b36c40ea7fd0b2fdc3d450
parentabc8f16259ad8d50358c8fcac4fc82362a2cbfac (diff)
wlan: qcacld: properly handle SETBAND wext ioctl
The wlan driver has multiple mechanisms for configuring the current operating band including the SETBAND driver command and the SETBAND wext ioctl. Currently both the driver command and the wext ioctl call the same hdd_setBand_helper() API which expects an ASCII command. This is appropriate for the driver command since it uses an ASCII string, but this is not appropriate for the wext ioctl since the data is passed as an integer. Create a new hdd_setBand() API which takes binary data, and modify both hdd_setBand_helper() and the SETBAND wext ioctl to invoke this API. Also clean up other places where hdd_setBand_helper() is being called with an ASCII command when it is more efficient to call hdd_setBand() with an integer parameter. Change-Id: I5ea8668847bb61fae2941a8f222ee560ea8b5600 CRs-fixed: 641993
-rw-r--r--CORE/HDD/inc/wlan_hdd_wext.h5
-rw-r--r--CORE/HDD/src/wlan_hdd_main.c2
-rw-r--r--CORE/HDD/src/wlan_hdd_wext.c68
3 files changed, 34 insertions, 41 deletions
diff --git a/CORE/HDD/inc/wlan_hdd_wext.h b/CORE/HDD/inc/wlan_hdd_wext.h
index dea1cfc57e84..9250e31a69c3 100644
--- a/CORE/HDD/inc/wlan_hdd_wext.h
+++ b/CORE/HDD/inc/wlan_hdd_wext.h
@@ -66,6 +66,8 @@
#define WLAN_HDD_UI_BAND_AUTO 0
#define WLAN_HDD_UI_BAND_5_GHZ 1
#define WLAN_HDD_UI_BAND_2_4_GHZ 2
+/* SETBAND x */
+/* 012345678 */
#define WLAN_HDD_UI_SET_BAND_VALUE_OFFSET 8
typedef enum
@@ -420,4 +422,7 @@ void* wlan_hdd_change_country_code_callback(void *pAdapter);
VOS_STATUS wlan_hdd_set_powersave(hdd_adapter_t *pAdapter, int mode);
+int hdd_setBand(struct net_device *dev, u8 ui_band);
+int hdd_setBand_helper(struct net_device *dev, const char *command);
+
#endif // __WEXT_IW_H__
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index b1336fd42f1e..be367b94703b 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -226,8 +226,6 @@ static void hdd_set_multicast_list(struct net_device *dev);
void hdd_wlan_initial_scan(hdd_adapter_t *pAdapter);
int isWDresetInProgress(void);
-extern int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
-
#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
void hdd_getBand_helper(hdd_context_t *pHddCtx, int *pBand);
static VOS_STATUS hdd_parse_channellist(tANI_U8 *pValue, tANI_U8 *pChannelList, tANI_U8 *pNumChannels);
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 5f39fe037990..b3b28857a675 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -122,7 +122,6 @@ extern void hdd_resume_wlan(struct early_suspend *wlan_suspend);
#define HDD_FINISH_ULA_TIME_OUT 800
extern int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand);
-int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr);
static int ioctl_debug;
module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
@@ -4316,7 +4315,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
case IEEE80211_MODE_11A:
if (band_5g) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11a);
- if ((hdd_setBand_helper(net, "SETBAND 1") == 0))
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_5_GHZ) == 0))
phymode = eCSR_DOT11_MODE_11a;
else {
sme_SetPhyMode(hal, old_phymode);
@@ -4327,7 +4326,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
case IEEE80211_MODE_11B:
if (band_24) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11b);
- if ((hdd_setBand_helper(net, "SETBAND 2") == 0))
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0))
phymode = eCSR_DOT11_MODE_11b;
else {
sme_SetPhyMode(hal, old_phymode);
@@ -4338,7 +4337,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
case IEEE80211_MODE_11G:
if (band_24) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11g);
- if ((hdd_setBand_helper(net, "SETBAND 2") == 0))
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0))
phymode = eCSR_DOT11_MODE_11g;
else {
sme_SetPhyMode(hal, old_phymode);
@@ -4353,7 +4352,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
case IEEE80211_MODE_11NA_HT20:
if (band_5g) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11n);
- if ((hdd_setBand_helper(net, "SETBAND 1") == 0)) {
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
phymode = eCSR_DOT11_MODE_11n;
chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
curr_band = eCSR_BAND_5G;
@@ -4366,7 +4365,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
case IEEE80211_MODE_11NA_HT40:
if (band_5g && ch_bond5g) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11n);
- if ((hdd_setBand_helper(net, "SETBAND 1") == 0)) {
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
phymode = eCSR_DOT11_MODE_11n;
chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
curr_band = eCSR_BAND_5G;
@@ -4379,7 +4378,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
case IEEE80211_MODE_11NG_HT20:
if (band_24) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11n);
- if ((hdd_setBand_helper(net, "SETBAND 2") == 0)) {
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
phymode = eCSR_DOT11_MODE_11n;
chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
curr_band = eCSR_BAND_24;
@@ -4392,7 +4391,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
case IEEE80211_MODE_11NG_HT40:
if (band_24 && ch_bond24) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11n);
- if ((hdd_setBand_helper(net, "SETBAND 2") == 0)) {
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
phymode = eCSR_DOT11_MODE_11n;
chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
curr_band = eCSR_BAND_24;
@@ -4409,7 +4408,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
vhtchanwidth == eHT_CHANNEL_WIDTH_40MHZ) &&
band_5g) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11ac);
- if ((hdd_setBand_helper(net, "SETBAND 1") == 0)) {
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
phymode = eCSR_DOT11_MODE_11ac;
} else {
sme_SetPhyMode(hal, old_phymode);
@@ -4421,7 +4420,7 @@ static int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
if ((vhtchanwidth == eHT_CHANNEL_WIDTH_80MHZ) &&
band_5g) {
sme_SetPhyMode(hal, eCSR_DOT11_MODE_11ac);
- if ((hdd_setBand_helper(net, "SETBAND 1") == 0)) {
+ if ((hdd_setBand(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
phymode = eCSR_DOT11_MODE_11ac;
} else {
sme_SetPhyMode(hal, old_phymode);
@@ -9270,17 +9269,15 @@ static int iw_set_pno_priv(struct net_device *dev,
#endif /*FEATURE_WLAN_SCAN_PNO*/
//Common function to SetBand
-int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
+int hdd_setBand(struct net_device *dev, u8 ui_band)
{
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
- tANI_U8 band = 0;
+ eCsrBand band;
eCsrBand currBand = eCSR_BAND_MAX;
- band = ptr[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0'; /*convert the band value from ascii to integer*/
-
- switch(band)
+ switch(ui_band)
{
case WLAN_HDD_UI_BAND_AUTO:
band = eCSR_BAND_ALL;
@@ -9295,15 +9292,15 @@ int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
band = eCSR_BAND_MAX;
}
- VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
+ VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: change band to %u",
__func__, band);
if (band == eCSR_BAND_MAX)
{
/* Received change band request with invalid band value */
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
- "%s: Invalid band value %u", __func__, band);
- return -EIO;
+ "%s: Invalid band value %u", __func__, ui_band);
+ return -EINVAL;
}
if ( (band == eCSR_BAND_24 && pHddCtx->cfg_ini->nBandCapability==2) ||
@@ -9389,13 +9386,23 @@ int hdd_setBand_helper(struct net_device *dev, tANI_U8* ptr)
return 0;
}
+int hdd_setBand_helper(struct net_device *dev, const char *command)
+{
+ u8 band;
+
+ /*convert the band value from ascii to integer*/
+ band = command[WLAN_HDD_UI_SET_BAND_VALUE_OFFSET] - '0';
+
+ return hdd_setBand(dev, band);
+
+}
+
static int iw_set_band_config(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
- tANI_U8 *ptr = NULL;
- int ret = 0;
+ int *value = (int *)extra;
VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: ", __func__);
@@ -9406,24 +9413,7 @@ static int iw_set_band_config(struct net_device *dev,
return -EBUSY;
}
- /* ODD number is used for set, copy data using copy_from_user */
- ptr = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
- wrqu->data.length);
- if (NULL == ptr)
- {
- VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
- "mem_alloc_copy_from_user_helper fail");
- return -ENOMEM;
- }
-
- if (memcmp(ptr, "SETBAND ", 8) == 0)
- {
- /* Change band request received */
- ret = hdd_setBand_helper(dev, ptr);
- }
- kfree(ptr);
-
- return ret;
+ return hdd_setBand(dev, value[0]);
}
static int iw_set_power_params_priv(struct net_device *dev,
@@ -10788,7 +10778,7 @@ static const struct iw_priv_args we_private_args[] = {
#endif
{
WLAN_SET_BAND_CONFIG,
- IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
0,
"SETBAND" },
/* handlers for dynamic MC BC ioctl */