@@ -398,24 +398,20 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
398398 int ret = 0 ;
399399 int status = 0 ;
400400 struct mwifiex_ds_band_cfg band_cfg ;
401- int mode ;
402- u8 wait_option = MWIFIEX_IOCTL_WAIT ;
403401 u32 config_bands = 0 ;
404402 struct wiphy * wiphy = priv -> wdev -> wiphy ;
405403
406- mode = mwifiex_drv_get_mode (priv , wait_option );
407-
408404 if (chan ) {
409405 memset (& band_cfg , 0 , sizeof (band_cfg ));
410406 /* Set appropriate bands */
411407 if (chan -> band == IEEE80211_BAND_2GHZ )
412408 config_bands = BAND_B | BAND_G | BAND_GN ;
413409 else
414410 config_bands = BAND_AN | BAND_A ;
415- if (mode == MWIFIEX_BSS_MODE_INFRA
416- || mode == MWIFIEX_BSS_MODE_AUTO ) {
411+ if (priv -> bss_mode == NL80211_IFTYPE_STATION
412+ || priv -> bss_mode == NL80211_IFTYPE_UNSPECIFIED ) {
417413 band_cfg .config_bands = config_bands ;
418- } else if (mode == MWIFIEX_BSS_MODE_IBSS ) {
414+ } else if (priv -> bss_mode == NL80211_IFTYPE_ADHOC ) {
419415 band_cfg .config_bands = config_bands ;
420416 band_cfg .adhoc_start_band = config_bands ;
421417 }
@@ -432,7 +428,8 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
432428 }
433429
434430 wiphy_dbg (wiphy , "info: setting band %d, channel offset %d and "
435- "mode %d\n" , config_bands , band_cfg .sec_chan_offset , mode );
431+ "mode %d\n" , config_bands , band_cfg .sec_chan_offset ,
432+ priv -> bss_mode );
436433 if (!chan )
437434 return ret ;
438435
@@ -561,14 +558,6 @@ mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
561558
562559/*
563560 * CFG802.11 operation handler to change interface type.
564- *
565- * This function creates an IOCTL request, populates it accordingly
566- * and issues an IOCTL.
567- *
568- * The function also maps the CFG802.11 mode type into driver mode type.
569- * NL80211_IFTYPE_ADHOC -> MWIFIEX_BSS_MODE_IBSS
570- * NL80211_IFTYPE_STATION -> MWIFIEX_BSS_MODE_INFRA
571- * NL80211_IFTYPE_UNSPECIFIED -> MWIFIEX_BSS_MODE_AUTO
572561 */
573562static int
574563mwifiex_cfg80211_change_virtual_intf (struct wiphy * wiphy ,
@@ -578,41 +567,50 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
578567{
579568 int ret = 0 ;
580569 struct mwifiex_private * priv = mwifiex_netdev_get_priv (dev );
581- int mode = -1 ;
582570 struct mwifiex_wait_queue * wait = NULL ;
583- int status = 0 ;
584571
585- wait = mwifiex_alloc_fill_wait_queue (priv , MWIFIEX_IOCTL_WAIT );
586- if (!wait )
587- return - ENOMEM ;
572+ if (priv -> bss_mode == type ) {
573+ wiphy_warn (wiphy , "already set to required type\n" );
574+ return 0 ;
575+ }
576+
577+ priv -> bss_mode = type ;
588578
589579 switch (type ) {
590580 case NL80211_IFTYPE_ADHOC :
591- mode = MWIFIEX_BSS_MODE_IBSS ;
592581 dev -> ieee80211_ptr -> iftype = NL80211_IFTYPE_ADHOC ;
593582 wiphy_dbg (wiphy , "info: setting interface type to adhoc\n" );
594583 break ;
595584 case NL80211_IFTYPE_STATION :
596- mode = MWIFIEX_BSS_MODE_INFRA ;
597585 dev -> ieee80211_ptr -> iftype = NL80211_IFTYPE_STATION ;
598- wiphy_dbg (wiphy , "info: Setting interface type to managed\n" );
586+ wiphy_dbg (wiphy , "info: setting interface type to managed\n" );
599587 break ;
600588 case NL80211_IFTYPE_UNSPECIFIED :
601- mode = MWIFIEX_BSS_MODE_AUTO ;
602589 dev -> ieee80211_ptr -> iftype = NL80211_IFTYPE_STATION ;
603590 wiphy_dbg (wiphy , "info: setting interface type to auto\n" );
604- break ;
591+ return 0 ;
605592 default :
606- ret = - EINVAL ;
593+ wiphy_err (wiphy , "unknown interface type: %d\n" , type );
594+ return - EINVAL ;
607595 }
608- if (ret )
609- goto done ;
610- status = mwifiex_bss_ioctl_mode (priv , wait , HostCmd_ACT_GEN_SET , & mode );
611596
612- if (mwifiex_request_ioctl (priv , wait , status , MWIFIEX_IOCTL_WAIT ))
597+ wait = mwifiex_alloc_fill_wait_queue (priv , MWIFIEX_IOCTL_WAIT );
598+ if (!wait )
599+ return - ENOMEM ;
600+
601+ mwifiex_deauthenticate (priv , wait , NULL );
602+
603+ priv -> sec_info .authentication_mode = MWIFIEX_AUTH_MODE_OPEN ;
604+
605+ ret = mwifiex_prepare_cmd (priv , HostCmd_CMD_SET_BSS_MODE ,
606+ HostCmd_ACT_GEN_SET , 0 , wait , NULL );
607+ if (!ret )
608+ ret = - EINPROGRESS ;
609+
610+ ret = mwifiex_request_ioctl (priv , wait , ret , MWIFIEX_IOCTL_WAIT );
611+ if (ret )
613612 ret = - EFAULT ;
614613
615- done :
616614 kfree (wait );
617615 return ret ;
618616}
@@ -1046,7 +1044,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
10461044
10471045 ret = mwifiex_set_encode (priv , NULL , 0 , 0 , 1 ); /* Disable keys */
10481046
1049- if (mode == MWIFIEX_BSS_MODE_IBSS ) {
1047+ if (mode == NL80211_IFTYPE_ADHOC ) {
10501048 /* "privacy" is set only for ad-hoc mode */
10511049 if (privacy ) {
10521050 /*
@@ -1108,7 +1106,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
11081106
11091107 memcpy (& ssid_bssid .ssid , & req_ssid , sizeof (struct mwifiex_802_11_ssid ));
11101108
1111- if (mode != MWIFIEX_BSS_MODE_IBSS ) {
1109+ if (mode != NL80211_IFTYPE_ADHOC ) {
11121110 if (mwifiex_find_best_bss (priv , MWIFIEX_IOCTL_WAIT ,
11131111 & ssid_bssid ))
11141112 return - EFAULT ;
@@ -1129,7 +1127,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
11291127 if (mwifiex_bss_start (priv , MWIFIEX_IOCTL_WAIT , & ssid_bssid ))
11301128 return - EFAULT ;
11311129
1132- if (mode == MWIFIEX_BSS_MODE_IBSS ) {
1130+ if (mode == NL80211_IFTYPE_ADHOC ) {
11331131 /* Inform the BSS information to kernel, otherwise
11341132 * kernel will give a panic after successful assoc */
11351133 if (mwifiex_cfg80211_inform_ibss_bss (priv ))
@@ -1152,14 +1150,11 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
11521150{
11531151 struct mwifiex_private * priv = mwifiex_netdev_get_priv (dev );
11541152 int ret = 0 ;
1155- int mode = 0 ;
11561153
11571154 if (priv -> assoc_request )
11581155 return - EBUSY ;
11591156
1160- mode = mwifiex_drv_get_mode (priv , MWIFIEX_IOCTL_WAIT );
1161-
1162- if (mode == MWIFIEX_BSS_MODE_IBSS ) {
1157+ if (priv -> bss_mode == NL80211_IFTYPE_ADHOC ) {
11631158 wiphy_err (wiphy , "received infra assoc request "
11641159 "when station is in ibss mode\n" );
11651160 goto done ;
@@ -1171,7 +1166,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
11711166 (char * ) sme -> ssid , sme -> bssid );
11721167
11731168 ret = mwifiex_cfg80211_assoc (priv , sme -> ssid_len , sme -> ssid , sme -> bssid ,
1174- mode , sme -> channel , sme , 0 );
1169+ priv -> bss_mode , sme -> channel , sme , 0 );
11751170
11761171done :
11771172 priv -> assoc_result = ret ;
@@ -1191,13 +1186,11 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
11911186{
11921187 struct mwifiex_private * priv = mwifiex_cfg80211_get_priv (wiphy );
11931188 int ret = 0 ;
1194- int mode = 0 ;
11951189
11961190 if (priv -> ibss_join_request )
11971191 return - EBUSY ;
11981192
1199- mode = mwifiex_drv_get_mode (priv , MWIFIEX_IOCTL_WAIT );
1200- if (mode != MWIFIEX_BSS_MODE_IBSS ) {
1193+ if (priv -> bss_mode != NL80211_IFTYPE_ADHOC ) {
12011194 wiphy_err (wiphy , "request to join ibss received "
12021195 "when station is not in ibss mode\n" );
12031196 goto done ;
@@ -1209,8 +1202,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
12091202 (char * ) params -> ssid , params -> bssid );
12101203
12111204 ret = mwifiex_cfg80211_assoc (priv , params -> ssid_len , params -> ssid ,
1212- params -> bssid , mode , params -> channel , NULL ,
1213- params -> privacy );
1205+ params -> bssid , priv -> bss_mode ,
1206+ params -> channel , NULL , params -> privacy );
12141207done :
12151208 priv -> ibss_join_result = ret ;
12161209 queue_work (priv -> workqueue , & priv -> cfg_workqueue );
@@ -1301,7 +1294,7 @@ mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info,
13011294 /* Clear all the other values */
13021295 memset (& mcs [rx_mcs_supp ], 0 ,
13031296 sizeof (struct ieee80211_mcs_info ) - rx_mcs_supp );
1304- if (priv -> bss_mode == MWIFIEX_BSS_MODE_INFRA ||
1297+ if (priv -> bss_mode == NL80211_IFTYPE_STATION ||
13051298 ISSUPP_CHANWIDTH40 (adapter -> hw_dot_11n_dev_cap ))
13061299 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
13071300 SETHT_MCS32 (mcs_set .rx_mask );
0 commit comments