Clean up the "allow tx" code a little.

This commit is contained in:
Solomon Peachy 2013-02-20 14:59:44 -05:00
parent 068f5ee5b9
commit db04efd195
1 changed files with 35 additions and 44 deletions

View File

@ -1527,24 +1527,18 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
switch (priv->mode) {
case NL80211_IFTYPE_STATION:
/* TODO: revisit this */
if ((priv->join_status <= CW1200_JOIN_STATUS_MONITOR) ||
memcmp(frame->addr3, priv->vif->bss_conf.bssid,
ETH_ALEN)) {
if (ieee80211_is_probe_req(fctl))
action = do_tx;
else if (priv->join_status >=
CW1200_JOIN_STATUS_MONITOR)
action = do_tx;
else
action = do_offchannel;
}
if (priv->join_status == CW1200_JOIN_STATUS_MONITOR)
action = do_tx;
else if (priv->join_status < CW1200_JOIN_STATUS_PRE_STA)
action = do_drop;
else if (memcmp(frame->addr3, priv->vif->bss_conf.bssid, ETH_ALEN))
action = do_offchannel; /* TODO: What is this for? */
break;
case NL80211_IFTYPE_AP:
if (!priv->join_status) {
action = do_drop;
} else if (!(BIT(txpriv->raw_link_id) &
(BIT(0) | priv->link_id_map))) {
(BIT(0) | priv->link_id_map))) {
wiphy_warn(priv->hw->wiphy,
"A frame with expired link id is dropped.\n");
action = do_drop;
@ -1566,7 +1560,8 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
action = do_drop;
break;
case NL80211_IFTYPE_MESH_POINT:
pr_warn("MESH_POINT not tested yet\n");
action = do_tx; /* TODO: Test me! */
break;
case NL80211_IFTYPE_MONITOR:
default:
action = do_drop;
@ -1574,21 +1569,29 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
}
if (action == do_tx) {
if (ieee80211_is_probe_req(fctl))
if (ieee80211_is_probe_req(fctl)) {
action = do_probe;
else if ((fctl & __cpu_to_le32(IEEE80211_FCTL_PROTECTED)) &&
tx_info->control.hw_key &&
tx_info->control.hw_key->keyidx !=
priv->wep_default_key_id &&
(tx_info->control.hw_key->cipher ==
WLAN_CIPHER_SUITE_WEP40 ||
tx_info->control.hw_key->cipher ==
WLAN_CIPHER_SUITE_WEP104))
} else if (ieee80211_is_deauth(fctl) &&
priv->mode != NL80211_IFTYPE_AP) {
pr_debug("[WSM] Issue unjoin command due to tx deauth.\n");
wsm_lock_tx_async(priv);
if (queue_work(priv->workqueue,
&priv->unjoin_work) <= 0)
wsm_unlock_tx(priv);
} else if ((fctl & __cpu_to_le16(IEEE80211_FCTL_PROTECTED)) &&
tx_info->control.hw_key &&
tx_info->control.hw_key->keyidx !=
priv->wep_default_key_id &&
(tx_info->control.hw_key->cipher ==
WLAN_CIPHER_SUITE_WEP40 ||
tx_info->control.hw_key->cipher ==
WLAN_CIPHER_SUITE_WEP104)) {
action = do_wep;
}
}
switch (action) {
case do_probe: {
case do_probe:
/* An interesting FW "feature". Device filters
* probe responses.
* The easiest way to get it back is to convert
@ -1600,17 +1603,13 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
&priv->scan.probe_work, 0);
handled = true;
break;
}
case do_drop: {
/* See detailed description of "join" below.
* We are dropping everything except AUTH in non-joined mode. */
case do_drop:
pr_debug("[WSM] Drop frame (0x%.4X).\n", fctl);
BUG_ON(cw1200_queue_remove(queue,
__le32_to_cpu(wsm->packet_id)));
handled = true;
break;
}
case do_offchannel: {
case do_offchannel:
pr_debug("[WSM] Offchannel TX request.\n");
wsm_lock_tx_async(priv);
priv->pending_frame_id = __le32_to_cpu(wsm->packet_id);
@ -1618,8 +1617,7 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
wsm_unlock_tx(priv);
handled = true;
break;
}
case do_wep: {
case do_wep:
pr_debug("[WSM] Issue set_default_wep_key.\n");
wsm_lock_tx_async(priv);
priv->wep_default_key_id = tx_info->control.hw_key->keyidx;
@ -1628,19 +1626,12 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
wsm_unlock_tx(priv);
handled = true;
break;
}
case do_tx: {
if (ieee80211_is_deauth(fctl) &&
priv->mode != NL80211_IFTYPE_AP) {
/* Shedule unjoin work */
pr_debug("[WSM] Issue unjoin command (TX).\n");
wsm_lock_tx_async(priv);
if (queue_work(priv->workqueue,
&priv->unjoin_work) <= 0)
wsm_unlock_tx(priv);
}
case do_tx:
pr_debug("[WSM] Transmit frame.\n");
break;
default:
/* Do nothing */
break;
}
}
return handled;
}