Skip to content

Commit

Permalink
ath6kl: Define interface specific states
Browse files Browse the repository at this point in the history
Currently ar->flag maintains interface stats. Move interface
specific states from ar->flag to vif->flags.

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  • Loading branch information
Vasanthakumar Thiagarajan authored and Kalle Valo committed Nov 11, 2011
1 parent 108438b commit 59c9844
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 76 deletions.
66 changes: 42 additions & 24 deletions drivers/net/wireless/ath/ath6kl/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,14 @@ static void ath6kl_set_key_mgmt(struct ath6kl *ar, u32 key_mgmt)

static bool ath6kl_cfg80211_ready(struct ath6kl *ar)
{
struct ath6kl_vif *vif = ar->vif;

if (!test_bit(WMI_READY, &ar->flag)) {
ath6kl_err("wmi is not ready\n");
return false;
}

if (!test_bit(WLAN_ENABLED, &ar->flag)) {
if (!test_bit(WLAN_ENABLED, &vif->flags)) {
ath6kl_err("wlan disabled\n");
return false;
}
Expand Down Expand Up @@ -295,6 +297,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_connect_params *sme)
{
struct ath6kl *ar = ath6kl_priv(dev);
struct ath6kl_vif *vif = netdev_priv(dev);
int status;

ar->sme_state = SME_CONNECTING;
Expand Down Expand Up @@ -345,7 +348,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
return status;
}

if (test_bit(CONNECTED, &ar->flag) &&
if (test_bit(CONNECTED, &vif->flags) &&
ar->ssid_len == sme->ssid_len &&
!memcmp(ar->ssid, sme->ssid, ar->ssid_len)) {
ar->reconnect_flag = true;
Expand Down Expand Up @@ -420,7 +423,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
}

if (!ar->usr_bss_filter) {
clear_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag);
clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
if (ath6kl_wmi_bssfilter_cmd(ar->wmi, ALL_BSS_FILTER, 0) != 0) {
ath6kl_err("couldn't set bss filtering\n");
up(&ar->sem);
Expand Down Expand Up @@ -469,7 +472,7 @@ static int ath6kl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
}

ar->connect_ctrl_flags &= ~CONNECT_DO_WPA_OFFLOAD;
set_bit(CONNECT_PEND, &ar->flag);
set_bit(CONNECT_PEND, &vif->flags);

return 0;
}
Expand Down Expand Up @@ -529,6 +532,8 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel,
u8 assoc_resp_len, u8 *assoc_info)
{
struct ieee80211_channel *chan;
/* TODO: Findout vif */
struct ath6kl_vif *vif = ar->vif;

/* capinfo + listen interval */
u8 assoc_req_ie_offset = sizeof(u16) + sizeof(u16);
Expand All @@ -548,7 +553,7 @@ void ath6kl_cfg80211_connect_event(struct ath6kl *ar, u16 channel,
* a Beacon frame from the AP is seen.
*/
ar->assoc_bss_beacon_int = beacon_intvl;
clear_bit(DTIM_PERIOD_AVAIL, &ar->flag);
clear_bit(DTIM_PERIOD_AVAIL, &vif->flags);

if (nw_type & ADHOC_NETWORK) {
if (ar->wdev->iftype != NL80211_IFTYPE_ADHOC) {
Expand Down Expand Up @@ -637,6 +642,9 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason,
u8 *bssid, u8 assoc_resp_len,
u8 *assoc_info, u16 proto_reason)
{
/* TODO: Findout vif */
struct ath6kl_vif *vif = ar->vif;

if (ar->scan_req) {
cfg80211_scan_done(ar->scan_req, true);
ar->scan_req = NULL;
Expand Down Expand Up @@ -676,7 +684,7 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl *ar, u8 reason,
return;
}

clear_bit(CONNECT_PEND, &ar->flag);
clear_bit(CONNECT_PEND, &vif->flags);

if (ar->sme_state == SME_CONNECTING) {
cfg80211_connect_result(ar->net_dev,
Expand All @@ -696,6 +704,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
struct cfg80211_scan_request *request)
{
struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev);
struct ath6kl_vif *vif = netdev_priv(ndev);
s8 n_channels = 0;
u16 *channels = NULL;
int ret = 0;
Expand All @@ -705,10 +714,10 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
return -EIO;

if (!ar->usr_bss_filter) {
clear_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag);
clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
ret = ath6kl_wmi_bssfilter_cmd(
ar->wmi,
(test_bit(CONNECTED, &ar->flag) ?
(test_bit(CONNECTED, &vif->flags) ?
ALL_BUT_BSS_FILTER : ALL_BSS_FILTER), 0);
if (ret) {
ath6kl_err("couldn't set bss filtering\n");
Expand Down Expand Up @@ -761,7 +770,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
channels[i] = request->channels[i]->center_freq;
}

if (test_bit(CONNECTED, &ar->flag))
if (test_bit(CONNECTED, &vif->flags))
force_fg_scan = 1;

ret = ath6kl_wmi_startscan_cmd(ar->wmi, WMI_LONG_SCAN, force_fg_scan,
Expand Down Expand Up @@ -810,6 +819,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
struct key_params *params)
{
struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev);
struct ath6kl_vif *vif = netdev_priv(ndev);
struct ath6kl_key *key = NULL;
u8 key_usage;
u8 key_type;
Expand Down Expand Up @@ -888,7 +898,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
ar->ap_mode_bkey.key_type = key_type;
ar->ap_mode_bkey.key_len = key->key_len;
memcpy(ar->ap_mode_bkey.key, key->key, key->key_len);
if (!test_bit(CONNECTED, &ar->flag)) {
if (!test_bit(CONNECTED, &vif->flags)) {
ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delay initial group "
"key configuration until AP mode has been "
"started\n");
Expand All @@ -901,7 +911,7 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
}

if (ar->next_mode == AP_NETWORK && key_type == WEP_CRYPT &&
!test_bit(CONNECTED, &ar->flag)) {
!test_bit(CONNECTED, &vif->flags)) {
/*
* Store the key locally so that it can be re-configured after
* the AP mode has properly started
Expand Down Expand Up @@ -995,6 +1005,7 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy,
bool multicast)
{
struct ath6kl *ar = (struct ath6kl *)ath6kl_priv(ndev);
struct ath6kl_vif *vif = netdev_priv(ndev);
struct ath6kl_key *key = NULL;
int status = 0;
u8 key_usage;
Expand Down Expand Up @@ -1028,7 +1039,7 @@ static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy,
if (multicast)
key_type = ar->grp_crypto;

if (ar->next_mode == AP_NETWORK && !test_bit(CONNECTED, &ar->flag))
if (ar->next_mode == AP_NETWORK && !test_bit(CONNECTED, &vif->flags))
return 0; /* Delay until AP mode has been started */

status = ath6kl_wmi_addkey_cmd(ar->wmi, ar->def_txkey_index,
Expand Down Expand Up @@ -1113,11 +1124,12 @@ static int ath6kl_cfg80211_set_txpower(struct wiphy *wiphy,
static int ath6kl_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
{
struct ath6kl *ar = (struct ath6kl *)wiphy_priv(wiphy);
struct ath6kl_vif *vif = ar->vif;

if (!ath6kl_cfg80211_ready(ar))
return -EIO;

if (test_bit(CONNECTED, &ar->flag)) {
if (test_bit(CONNECTED, &vif->flags)) {
ar->tx_pwr = 0;

if (ath6kl_wmi_get_tx_pwr_cmd(ar->wmi) != 0) {
Expand Down Expand Up @@ -1211,6 +1223,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy,
struct cfg80211_ibss_params *ibss_param)
{
struct ath6kl *ar = ath6kl_priv(dev);
struct ath6kl_vif *vif = netdev_priv(dev);
int status;

if (!ath6kl_cfg80211_ready(ar))
Expand Down Expand Up @@ -1269,7 +1282,7 @@ static int ath6kl_cfg80211_join_ibss(struct wiphy *wiphy,
ar->ssid_len, ar->ssid,
ar->req_bssid, ar->ch_hint,
ar->connect_ctrl_flags);
set_bit(CONNECT_PEND, &ar->flag);
set_bit(CONNECT_PEND, &vif->flags);

return 0;
}
Expand Down Expand Up @@ -1362,6 +1375,7 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev,
u8 *mac, struct station_info *sinfo)
{
struct ath6kl *ar = ath6kl_priv(dev);
struct ath6kl_vif *vif = netdev_priv(dev);
long left;
bool sgi;
s32 rate;
Expand Down Expand Up @@ -1444,8 +1458,8 @@ static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev,

sinfo->filled |= STATION_INFO_TX_BITRATE;

if (test_bit(CONNECTED, &ar->flag) &&
test_bit(DTIM_PERIOD_AVAIL, &ar->flag) &&
if (test_bit(CONNECTED, &vif->flags) &&
test_bit(DTIM_PERIOD_AVAIL, &vif->flags) &&
ar->nw_type == INFRA_NETWORK) {
sinfo->filled |= STATION_INFO_BSS_PARAM;
sinfo->bss_param.flags = 0;
Expand Down Expand Up @@ -1475,7 +1489,9 @@ static int ath6kl_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
{
struct ath6kl *ar = ath6kl_priv(netdev);
if (test_bit(CONNECTED, &ar->flag))
struct ath6kl_vif *vif = netdev_priv(netdev);

if (test_bit(CONNECTED, &vif->flags))
return ath6kl_wmi_setpmkid_cmd(ar->wmi, ar->bssid, NULL, false);
return 0;
}
Expand Down Expand Up @@ -1711,14 +1727,15 @@ static int ath6kl_set_beacon(struct wiphy *wiphy, struct net_device *dev,
static int ath6kl_del_beacon(struct wiphy *wiphy, struct net_device *dev)
{
struct ath6kl *ar = ath6kl_priv(dev);
struct ath6kl_vif *vif = netdev_priv(dev);

if (ar->nw_type != AP_NETWORK)
return -EOPNOTSUPP;
if (!test_bit(CONNECTED, &ar->flag))
if (!test_bit(CONNECTED, &vif->flags))
return -ENOTCONN;

ath6kl_wmi_disconnect_cmd(ar->wmi);
clear_bit(CONNECTED, &ar->flag);
clear_bit(CONNECTED, &vif->flags);

return 0;
}
Expand Down Expand Up @@ -1814,12 +1831,13 @@ static int ath6kl_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
bool dont_wait_for_ack, u64 *cookie)
{
struct ath6kl *ar = ath6kl_priv(dev);
struct ath6kl_vif *vif = netdev_priv(dev);
u32 id;
const struct ieee80211_mgmt *mgmt;

mgmt = (const struct ieee80211_mgmt *) buf;
if (buf + len >= mgmt->u.probe_resp.variable &&
ar->nw_type == AP_NETWORK && test_bit(CONNECTED, &ar->flag) &&
ar->nw_type == AP_NETWORK && test_bit(CONNECTED, &vif->flags) &&
ieee80211_is_probe_resp(mgmt->frame_control)) {
/*
* Send Probe Response frame in AP mode using a separate WMI
Expand Down Expand Up @@ -2039,9 +2057,9 @@ void ath6kl_deinit_if_data(struct ath6kl_vif *vif)

ar->aggr_cntxt = NULL;

if (test_bit(NETDEV_REGISTERED, &ar->flag)) {
if (test_bit(NETDEV_REGISTERED, &vif->flags)) {
unregister_netdev(vif->ndev);
clear_bit(NETDEV_REGISTERED, &ar->flag);
clear_bit(NETDEV_REGISTERED, &vif->flags);
}

free_netdev(vif->ndev);
Expand Down Expand Up @@ -2081,9 +2099,9 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name,
goto err;

ar->sme_state = SME_DISCONNECTED;
set_bit(WLAN_ENABLED, &ar->flag);
set_bit(WLAN_ENABLED, &vif->flags);
ar->wlan_pwr_state = WLAN_POWER_STATE_ON;
set_bit(NETDEV_REGISTERED, &ar->flag);
set_bit(NETDEV_REGISTERED, &vif->flags);

return ndev;

Expand Down
41 changes: 24 additions & 17 deletions drivers/net/wireless/ath/ath6kl/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,30 +380,37 @@ struct ath6kl_req_key {
u8 key_len;
};

/* vif flags info */
enum ath6kl_vif_state {
CONNECTED,
CONNECT_PEND,
WMM_ENABLED,
NETQ_STOPPED,
DTIM_EXPIRED,
NETDEV_REGISTERED,
CLEAR_BSSFILTER_ON_BEACON,
DTIM_PERIOD_AVAIL,
WLAN_ENABLED,
};

struct ath6kl_vif {
struct wireless_dev wdev;
struct net_device *ndev;
struct ath6kl *ar;
unsigned long flags;
};

/* Flag info */
#define WMI_ENABLED 0
#define WMI_READY 1
#define CONNECTED 2
#define STATS_UPDATE_PEND 3
#define CONNECT_PEND 4
#define WMM_ENABLED 5
#define NETQ_STOPPED 6
#define WMI_CTRL_EP_FULL 7
#define DTIM_EXPIRED 8
#define DESTROY_IN_PROGRESS 9
#define NETDEV_REGISTERED 10
#define SKIP_SCAN 11
#define WLAN_ENABLED 12
#define TESTMODE 13
#define CLEAR_BSSFILTER_ON_BEACON 14
#define DTIM_PERIOD_AVAIL 15
#define ROAM_TBL_PEND 16
enum ath6kl_dev_state {
WMI_ENABLED,
WMI_READY,
WMI_CTRL_EP_FULL,
TESTMODE,
DESTROY_IN_PROGRESS,
SKIP_SCAN,
STATS_UPDATE_PEND,
ROAM_TBL_PEND,
};

struct ath6kl {
struct device *dev;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/ath/ath6kl/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,7 @@ int ath6kl_core_init(struct ath6kl *ar)
void ath6kl_stop_txrx(struct ath6kl *ar)
{
struct net_device *ndev = ar->net_dev;
struct ath6kl_vif *vif = ar->vif;

if (!ndev)
return;
Expand All @@ -1589,7 +1590,7 @@ void ath6kl_stop_txrx(struct ath6kl *ar)
if (ar->wlan_pwr_state != WLAN_POWER_STATE_CUT_PWR)
ath6kl_stop_endpoint(ndev, false, true);

clear_bit(WLAN_ENABLED, &ar->flag);
clear_bit(WLAN_ENABLED, &vif->flags);
}

/*
Expand Down
Loading

0 comments on commit 59c9844

Please sign in to comment.