Skip to content

Commit

Permalink
mwifiex: remove MWIFIEX_BSS_MODE_ macros
Browse files Browse the repository at this point in the history
replace them with NL80211_IFTYPE_ macros

Also remove redundant functions mwifiex_drv_get_mode()
and mwifiex_bss_ioctl_mode().

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Bing Zhao authored and John W. Linville committed Apr 4, 2011
1 parent 6a4c499 commit eecd825
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 165 deletions.
4 changes: 2 additions & 2 deletions drivers/net/wireless/mwifiex/11n.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ mwifiex_fill_cap_info(struct mwifiex_private *priv,
memset(&mcs[rx_mcs_supp], 0,
sizeof(struct ieee80211_mcs_info) - rx_mcs_supp);

if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA ||
if (priv->bss_mode == NL80211_IFTYPE_STATION ||
(ht_cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
/* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask);
Expand Down Expand Up @@ -418,7 +418,7 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
}

if (bss_desc->bcn_ht_info) {
if (priv->bss_mode == MWIFIEX_BSS_MODE_IBSS) {
if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
ht_info = (struct mwifiex_ie_types_htinfo *) *buffer;
memset(ht_info, 0,
sizeof(struct mwifiex_ie_types_htinfo));
Expand Down
85 changes: 39 additions & 46 deletions drivers/net/wireless/mwifiex/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,24 +398,20 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
int ret = 0;
int status = 0;
struct mwifiex_ds_band_cfg band_cfg;
int mode;
u8 wait_option = MWIFIEX_IOCTL_WAIT;
u32 config_bands = 0;
struct wiphy *wiphy = priv->wdev->wiphy;

mode = mwifiex_drv_get_mode(priv, wait_option);

if (chan) {
memset(&band_cfg, 0, sizeof(band_cfg));
/* Set appropriate bands */
if (chan->band == IEEE80211_BAND_2GHZ)
config_bands = BAND_B | BAND_G | BAND_GN;
else
config_bands = BAND_AN | BAND_A;
if (mode == MWIFIEX_BSS_MODE_INFRA
|| mode == MWIFIEX_BSS_MODE_AUTO) {
if (priv->bss_mode == NL80211_IFTYPE_STATION
|| priv->bss_mode == NL80211_IFTYPE_UNSPECIFIED) {
band_cfg.config_bands = config_bands;
} else if (mode == MWIFIEX_BSS_MODE_IBSS) {
} else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
band_cfg.config_bands = config_bands;
band_cfg.adhoc_start_band = config_bands;
}
Expand All @@ -432,7 +428,8 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
}

wiphy_dbg(wiphy, "info: setting band %d, channel offset %d and "
"mode %d\n", config_bands, band_cfg.sec_chan_offset, mode);
"mode %d\n", config_bands, band_cfg.sec_chan_offset,
priv->bss_mode);
if (!chan)
return ret;

Expand Down Expand Up @@ -561,14 +558,6 @@ mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)

/*
* CFG802.11 operation handler to change interface type.
*
* This function creates an IOCTL request, populates it accordingly
* and issues an IOCTL.
*
* The function also maps the CFG802.11 mode type into driver mode type.
* NL80211_IFTYPE_ADHOC -> MWIFIEX_BSS_MODE_IBSS
* NL80211_IFTYPE_STATION -> MWIFIEX_BSS_MODE_INFRA
* NL80211_IFTYPE_UNSPECIFIED -> MWIFIEX_BSS_MODE_AUTO
*/
static int
mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
Expand All @@ -578,41 +567,50 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
{
int ret = 0;
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
int mode = -1;
struct mwifiex_wait_queue *wait = NULL;
int status = 0;

wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
if (!wait)
return -ENOMEM;
if (priv->bss_mode == type) {
wiphy_warn(wiphy, "already set to required type\n");
return 0;
}

priv->bss_mode = type;

switch (type) {
case NL80211_IFTYPE_ADHOC:
mode = MWIFIEX_BSS_MODE_IBSS;
dev->ieee80211_ptr->iftype = NL80211_IFTYPE_ADHOC;
wiphy_dbg(wiphy, "info: setting interface type to adhoc\n");
break;
case NL80211_IFTYPE_STATION:
mode = MWIFIEX_BSS_MODE_INFRA;
dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION;
wiphy_dbg(wiphy, "info: Setting interface type to managed\n");
wiphy_dbg(wiphy, "info: setting interface type to managed\n");
break;
case NL80211_IFTYPE_UNSPECIFIED:
mode = MWIFIEX_BSS_MODE_AUTO;
dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION;
wiphy_dbg(wiphy, "info: setting interface type to auto\n");
break;
return 0;
default:
ret = -EINVAL;
wiphy_err(wiphy, "unknown interface type: %d\n", type);
return -EINVAL;
}
if (ret)
goto done;
status = mwifiex_bss_ioctl_mode(priv, wait, HostCmd_ACT_GEN_SET, &mode);

if (mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT))
wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
if (!wait)
return -ENOMEM;

mwifiex_deauthenticate(priv, wait, NULL);

priv->sec_info.authentication_mode = MWIFIEX_AUTH_MODE_OPEN;

ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_SET_BSS_MODE,
HostCmd_ACT_GEN_SET, 0, wait, NULL);
if (!ret)
ret = -EINPROGRESS;

ret = mwifiex_request_ioctl(priv, wait, ret, MWIFIEX_IOCTL_WAIT);
if (ret)
ret = -EFAULT;

done:
kfree(wait);
return ret;
}
Expand Down Expand Up @@ -1046,7 +1044,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,

ret = mwifiex_set_encode(priv, NULL, 0, 0, 1); /* Disable keys */

if (mode == MWIFIEX_BSS_MODE_IBSS) {
if (mode == NL80211_IFTYPE_ADHOC) {
/* "privacy" is set only for ad-hoc mode */
if (privacy) {
/*
Expand Down Expand Up @@ -1108,7 +1106,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,

memcpy(&ssid_bssid.ssid, &req_ssid, sizeof(struct mwifiex_802_11_ssid));

if (mode != MWIFIEX_BSS_MODE_IBSS) {
if (mode != NL80211_IFTYPE_ADHOC) {
if (mwifiex_find_best_bss(priv, MWIFIEX_IOCTL_WAIT,
&ssid_bssid))
return -EFAULT;
Expand All @@ -1129,7 +1127,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
if (mwifiex_bss_start(priv, MWIFIEX_IOCTL_WAIT, &ssid_bssid))
return -EFAULT;

if (mode == MWIFIEX_BSS_MODE_IBSS) {
if (mode == NL80211_IFTYPE_ADHOC) {
/* Inform the BSS information to kernel, otherwise
* kernel will give a panic after successful assoc */
if (mwifiex_cfg80211_inform_ibss_bss(priv))
Expand All @@ -1152,14 +1150,11 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
{
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
int ret = 0;
int mode = 0;

if (priv->assoc_request)
return -EBUSY;

mode = mwifiex_drv_get_mode(priv, MWIFIEX_IOCTL_WAIT);

if (mode == MWIFIEX_BSS_MODE_IBSS) {
if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
wiphy_err(wiphy, "received infra assoc request "
"when station is in ibss mode\n");
goto done;
Expand All @@ -1171,7 +1166,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
(char *) sme->ssid, sme->bssid);

ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid,
mode, sme->channel, sme, 0);
priv->bss_mode, sme->channel, sme, 0);

done:
priv->assoc_result = ret;
Expand All @@ -1191,13 +1186,11 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
{
struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
int ret = 0;
int mode = 0;

if (priv->ibss_join_request)
return -EBUSY;

mode = mwifiex_drv_get_mode(priv, MWIFIEX_IOCTL_WAIT);
if (mode != MWIFIEX_BSS_MODE_IBSS) {
if (priv->bss_mode != NL80211_IFTYPE_ADHOC) {
wiphy_err(wiphy, "request to join ibss received "
"when station is not in ibss mode\n");
goto done;
Expand All @@ -1209,8 +1202,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
(char *) params->ssid, params->bssid);

ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid,
params->bssid, mode, params->channel, NULL,
params->privacy);
params->bssid, priv->bss_mode,
params->channel, NULL, params->privacy);
done:
priv->ibss_join_result = ret;
queue_work(priv->workqueue, &priv->cfg_workqueue);
Expand Down Expand Up @@ -1301,7 +1294,7 @@ mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info,
/* Clear all the other values */
memset(&mcs[rx_mcs_supp], 0,
sizeof(struct ieee80211_mcs_info) - rx_mcs_supp);
if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA ||
if (priv->bss_mode == NL80211_IFTYPE_STATION ||
ISSUPP_CHANWIDTH40(adapter->hw_dot_11n_dev_cap))
/* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
SETHT_MCS32(mcs_set.rx_mask);
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/wireless/mwifiex/cfp.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates)
{
u32 k = 0;
struct mwifiex_adapter *adapter = priv->adapter;
if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA) {
/* Infra. mode */
if (priv->bss_mode == NL80211_IFTYPE_STATION) {
switch (adapter->config_bands) {
case BAND_B:
dev_dbg(adapter->dev, "info: infra band=%d "
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/mwifiex/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int mwifiex_init_priv(struct mwifiex_private *priv)
memset(priv->curr_addr, 0xff, ETH_ALEN);

priv->pkt_tx_ctrl = 0;
priv->bss_mode = MWIFIEX_BSS_MODE_INFRA;
priv->bss_mode = NL80211_IFTYPE_STATION;
priv->data_rate = 0; /* Initially indicate the rate as auto */
priv->is_data_rate_auto = true;
priv->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR;
Expand Down
6 changes: 0 additions & 6 deletions drivers/net/wireless/mwifiex/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ struct mwifiex_scan_resp {
u8 *scan_table;
};

enum {
MWIFIEX_BSS_MODE_INFRA = 1,
MWIFIEX_BSS_MODE_IBSS,
MWIFIEX_BSS_MODE_AUTO
};

#define MWIFIEX_PROMISC_MODE 1
#define MWIFIEX_MULTICAST_MODE 2
#define MWIFIEX_ALL_MULTI_MODE 4
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/wireless/mwifiex/join.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,

/* Set the BSS mode */
adhoc_start->bss_mode = HostCmd_BSS_MODE_IBSS;
bss_desc->bss_mode = MWIFIEX_BSS_MODE_IBSS;
bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
adhoc_start->beacon_period = cpu_to_le16(priv->beacon_period);
bss_desc->beacon_period = priv->beacon_period;

Expand Down Expand Up @@ -1289,8 +1289,8 @@ int mwifiex_associate(struct mwifiex_private *priv,
u8 current_bssid[ETH_ALEN];

/* Return error if the adapter or table entry is not marked as infra */
if ((priv->bss_mode != MWIFIEX_BSS_MODE_INFRA) ||
(bss_desc->bss_mode != MWIFIEX_BSS_MODE_INFRA))
if ((priv->bss_mode != NL80211_IFTYPE_STATION) ||
(bss_desc->bss_mode != NL80211_IFTYPE_STATION))
return -1;

memcpy(&current_bssid,
Expand Down Expand Up @@ -1358,7 +1358,7 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv,
!mwifiex_ssid_cmp(&bss_desc->ssid,
&priv->curr_bss_params.bss_descriptor.ssid) &&
(priv->curr_bss_params.bss_descriptor.bss_mode ==
MWIFIEX_BSS_MODE_IBSS)) {
NL80211_IFTYPE_ADHOC)) {
dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: new ad-hoc SSID"
" is the same as current; not attempting to re-join\n");
return -1;
Expand Down Expand Up @@ -1421,9 +1421,9 @@ int mwifiex_deauthenticate(struct mwifiex_private *priv,
int ret = 0;

if (priv->media_connected) {
if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA) {
if (priv->bss_mode == NL80211_IFTYPE_STATION) {
ret = mwifiex_deauthenticate_infra(priv, wait, mac);
} else if (priv->bss_mode == MWIFIEX_BSS_MODE_IBSS) {
} else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
ret = mwifiex_prepare_cmd(priv,
HostCmd_CMD_802_11_AD_HOC_STOP,
HostCmd_ACT_GEN_SET, 0, wait, NULL);
Expand Down
7 changes: 1 addition & 6 deletions drivers/net/wireless/mwifiex/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ mwifiex_queuing_ra_based(struct mwifiex_private *priv)
* Currently we assume if we are in Infra, then DA=RA. This might not be
* true in the future
*/
if ((priv->bss_mode == MWIFIEX_BSS_MODE_INFRA) &&
if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
(GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
return false;

Expand Down Expand Up @@ -1003,8 +1003,6 @@ int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel);
int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);

int mwifiex_drv_get_mode(struct mwifiex_private *priv, u8 wait_option);

int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel);

int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
Expand Down Expand Up @@ -1043,9 +1041,6 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, int type, int dbm);

int mwifiex_main_process(struct mwifiex_adapter *);

int mwifiex_bss_ioctl_mode(struct mwifiex_private *,
struct mwifiex_wait_queue *,
u16 action, int *mode);
int mwifiex_bss_ioctl_channel(struct mwifiex_private *,
u16 action,
struct mwifiex_chan_freq_power *cfp);
Expand Down
Loading

0 comments on commit eecd825

Please sign in to comment.