Commit b2abb6e2 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

mac80211: sync driver before TX

In P2P client mode, the GO (AP) to connect to might
have periods of time where it is not available due
to powersave. To allow the driver to sync with it
and send frames to the GO only when it is available
add a new callback tx_sync (and the corresponding
finish_tx_sync). These callbacks can sleep unlike
the actual TX.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e0d687bd
...@@ -1585,6 +1585,20 @@ enum ieee80211_ampdu_mlme_action { ...@@ -1585,6 +1585,20 @@ enum ieee80211_ampdu_mlme_action {
IEEE80211_AMPDU_TX_OPERATIONAL, IEEE80211_AMPDU_TX_OPERATIONAL,
}; };
/**
* enum ieee80211_tx_sync_type - TX sync type
* @IEEE80211_TX_SYNC_AUTH: sync TX for authentication
* (and possibly also before direct probe)
* @IEEE80211_TX_SYNC_ASSOC: sync TX for association
* @IEEE80211_TX_SYNC_ACTION: sync TX for action frame
* (not implemented yet)
*/
enum ieee80211_tx_sync_type {
IEEE80211_TX_SYNC_AUTH,
IEEE80211_TX_SYNC_ASSOC,
IEEE80211_TX_SYNC_ACTION,
};
/** /**
* struct ieee80211_ops - callbacks from mac80211 to the driver * struct ieee80211_ops - callbacks from mac80211 to the driver
* *
...@@ -1674,6 +1688,26 @@ enum ieee80211_ampdu_mlme_action { ...@@ -1674,6 +1688,26 @@ enum ieee80211_ampdu_mlme_action {
* of the bss parameters has changed when a call is made. The callback * of the bss parameters has changed when a call is made. The callback
* can sleep. * can sleep.
* *
* @tx_sync: Called before a frame is sent to an AP/GO. In the GO case, the
* driver should sync with the GO's powersaving so the device doesn't
* transmit the frame while the GO is asleep. In the regular AP case
* it may be used by drivers for devices implementing other restrictions
* on talking to APs, e.g. due to regulatory enforcement or just HW
* restrictions.
* This function is called for every authentication, association and
* action frame separately since applications might attempt to auth
* with multiple APs before chosing one to associate to. If it returns
* an error, the corresponding authentication, association or frame
* transmission is aborted and reported as having failed. It is always
* called after tuning to the correct channel.
* The callback might be called multiple times before @finish_tx_sync
* (but @finish_tx_sync will be called once for each) but in practice
* this is unlikely to happen. It can also refuse in that case if the
* driver cannot handle that situation.
* This callback can sleep.
* @finish_tx_sync: Called as a counterpart to @tx_sync, unless that returned
* an error. This callback can sleep.
*
* @prepare_multicast: Prepare for multicast filter configuration. * @prepare_multicast: Prepare for multicast filter configuration.
* This callback is optional, and its return value is passed * This callback is optional, and its return value is passed
* to configure_filter(). This callback must be atomic. * to configure_filter(). This callback must be atomic.
...@@ -1901,6 +1935,14 @@ struct ieee80211_ops { ...@@ -1901,6 +1935,14 @@ struct ieee80211_ops {
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *info, struct ieee80211_bss_conf *info,
u32 changed); u32 changed);
int (*tx_sync)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const u8 *bssid, enum ieee80211_tx_sync_type type);
void (*finish_tx_sync)(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
const u8 *bssid,
enum ieee80211_tx_sync_type type);
u64 (*prepare_multicast)(struct ieee80211_hw *hw, u64 (*prepare_multicast)(struct ieee80211_hw *hw,
struct netdev_hw_addr_list *mc_list); struct netdev_hw_addr_list *mc_list);
void (*configure_filter)(struct ieee80211_hw *hw, void (*configure_filter)(struct ieee80211_hw *hw,
......
...@@ -130,6 +130,37 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local, ...@@ -130,6 +130,37 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
trace_drv_return_void(local); trace_drv_return_void(local);
} }
static inline int drv_tx_sync(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
const u8 *bssid,
enum ieee80211_tx_sync_type type)
{
int ret = 0;
might_sleep();
trace_drv_tx_sync(local, sdata, bssid, type);
if (local->ops->tx_sync)
ret = local->ops->tx_sync(&local->hw, &sdata->vif,
bssid, type);
trace_drv_return_int(local, ret);
return ret;
}
static inline void drv_finish_tx_sync(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
const u8 *bssid,
enum ieee80211_tx_sync_type type)
{
might_sleep();
trace_drv_finish_tx_sync(local, sdata, bssid, type);
if (local->ops->finish_tx_sync)
local->ops->finish_tx_sync(&local->hw, &sdata->vif,
bssid, type);
trace_drv_return_void(local);
}
static inline u64 drv_prepare_multicast(struct ieee80211_local *local, static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
struct netdev_hw_addr_list *mc_list) struct netdev_hw_addr_list *mc_list)
{ {
......
...@@ -319,6 +319,49 @@ TRACE_EVENT(drv_bss_info_changed, ...@@ -319,6 +319,49 @@ TRACE_EVENT(drv_bss_info_changed,
) )
); );
DECLARE_EVENT_CLASS(tx_sync_evt,
TP_PROTO(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
const u8 *bssid,
enum ieee80211_tx_sync_type type),
TP_ARGS(local, sdata, bssid, type),
TP_STRUCT__entry(
LOCAL_ENTRY
VIF_ENTRY
__array(char, bssid, ETH_ALEN)
__field(u32, sync_type)
),
TP_fast_assign(
LOCAL_ASSIGN;
VIF_ASSIGN;
memcpy(__entry->bssid, bssid, ETH_ALEN);
__entry->sync_type = type;
),
TP_printk(
LOCAL_PR_FMT VIF_PR_FMT " bssid:%pM type:%d",
LOCAL_PR_ARG, VIF_PR_ARG, __entry->bssid, __entry->sync_type
)
);
DEFINE_EVENT(tx_sync_evt, drv_tx_sync,
TP_PROTO(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
const u8 *bssid,
enum ieee80211_tx_sync_type type),
TP_ARGS(local, sdata, bssid, type)
);
DEFINE_EVENT(tx_sync_evt, drv_finish_tx_sync,
TP_PROTO(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
const u8 *bssid,
enum ieee80211_tx_sync_type type),
TP_ARGS(local, sdata, bssid, type)
);
TRACE_EVENT(drv_prepare_multicast, TRACE_EVENT(drv_prepare_multicast,
TP_PROTO(struct ieee80211_local *local, int mc_count), TP_PROTO(struct ieee80211_local *local, int mc_count),
......
...@@ -323,6 +323,7 @@ struct ieee80211_work { ...@@ -323,6 +323,7 @@ struct ieee80211_work {
u8 key[WLAN_KEY_LEN_WEP104]; u8 key[WLAN_KEY_LEN_WEP104];
u8 key_len, key_idx; u8 key_len, key_idx;
bool privacy; bool privacy;
bool synced;
} probe_auth; } probe_auth;
struct { struct {
struct cfg80211_bss *bss; struct cfg80211_bss *bss;
...@@ -336,6 +337,7 @@ struct ieee80211_work { ...@@ -336,6 +337,7 @@ struct ieee80211_work {
u8 ssid_len; u8 ssid_len;
u8 supp_rates_len; u8 supp_rates_len;
bool wmm_used, use_11n, uapsd_used; bool wmm_used, use_11n, uapsd_used;
bool synced;
} assoc; } assoc;
struct { struct {
u32 duration; u32 duration;
......
...@@ -2335,14 +2335,16 @@ static enum work_done_result ...@@ -2335,14 +2335,16 @@ static enum work_done_result
ieee80211_probe_auth_done(struct ieee80211_work *wk, ieee80211_probe_auth_done(struct ieee80211_work *wk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct ieee80211_local *local = wk->sdata->local;
if (!skb) { if (!skb) {
cfg80211_send_auth_timeout(wk->sdata->dev, wk->filter_ta); cfg80211_send_auth_timeout(wk->sdata->dev, wk->filter_ta);
return WORK_DONE_DESTROY; goto destroy;
} }
if (wk->type == IEEE80211_WORK_AUTH) { if (wk->type == IEEE80211_WORK_AUTH) {
cfg80211_send_rx_auth(wk->sdata->dev, skb->data, skb->len); cfg80211_send_rx_auth(wk->sdata->dev, skb->data, skb->len);
return WORK_DONE_DESTROY; goto destroy;
} }
mutex_lock(&wk->sdata->u.mgd.mtx); mutex_lock(&wk->sdata->u.mgd.mtx);
...@@ -2352,6 +2354,12 @@ ieee80211_probe_auth_done(struct ieee80211_work *wk, ...@@ -2352,6 +2354,12 @@ ieee80211_probe_auth_done(struct ieee80211_work *wk,
wk->type = IEEE80211_WORK_AUTH; wk->type = IEEE80211_WORK_AUTH;
wk->probe_auth.tries = 0; wk->probe_auth.tries = 0;
return WORK_DONE_REQUEUE; return WORK_DONE_REQUEUE;
destroy:
if (wk->probe_auth.synced)
drv_finish_tx_sync(local, wk->sdata, wk->filter_ta,
IEEE80211_TX_SYNC_AUTH);
return WORK_DONE_DESTROY;
} }
int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
...@@ -2424,6 +2432,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, ...@@ -2424,6 +2432,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct ieee80211_local *local = wk->sdata->local;
struct ieee80211_mgmt *mgmt; struct ieee80211_mgmt *mgmt;
struct ieee80211_rx_status *rx_status; struct ieee80211_rx_status *rx_status;
struct ieee802_11_elems elems; struct ieee802_11_elems elems;
...@@ -2431,7 +2440,7 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, ...@@ -2431,7 +2440,7 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
if (!skb) { if (!skb) {
cfg80211_send_assoc_timeout(wk->sdata->dev, wk->filter_ta); cfg80211_send_assoc_timeout(wk->sdata->dev, wk->filter_ta);
return WORK_DONE_DESTROY; goto destroy;
} }
if (wk->type == IEEE80211_WORK_ASSOC_BEACON_WAIT) { if (wk->type == IEEE80211_WORK_ASSOC_BEACON_WAIT) {
...@@ -2451,6 +2460,10 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, ...@@ -2451,6 +2460,10 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
status = le16_to_cpu(mgmt->u.assoc_resp.status_code); status = le16_to_cpu(mgmt->u.assoc_resp.status_code);
if (status == WLAN_STATUS_SUCCESS) { if (status == WLAN_STATUS_SUCCESS) {
if (wk->assoc.synced)
drv_finish_tx_sync(local, wk->sdata, wk->filter_ta,
IEEE80211_TX_SYNC_ASSOC);
mutex_lock(&wk->sdata->u.mgd.mtx); mutex_lock(&wk->sdata->u.mgd.mtx);
if (!ieee80211_assoc_success(wk, mgmt, skb->len)) { if (!ieee80211_assoc_success(wk, mgmt, skb->len)) {
mutex_unlock(&wk->sdata->u.mgd.mtx); mutex_unlock(&wk->sdata->u.mgd.mtx);
...@@ -2464,6 +2477,11 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk, ...@@ -2464,6 +2477,11 @@ static enum work_done_result ieee80211_assoc_done(struct ieee80211_work *wk,
} }
cfg80211_send_rx_assoc(wk->sdata->dev, skb->data, skb->len); cfg80211_send_rx_assoc(wk->sdata->dev, skb->data, skb->len);
destroy:
if (wk->assoc.synced)
drv_finish_tx_sync(local, wk->sdata, wk->filter_ta,
IEEE80211_TX_SYNC_ASSOC);
return WORK_DONE_DESTROY; return WORK_DONE_DESTROY;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ieee80211_i.h" #include "ieee80211_i.h"
#include "rate.h" #include "rate.h"
#include "driver-ops.h"
#define IEEE80211_AUTH_TIMEOUT (HZ / 5) #define IEEE80211_AUTH_TIMEOUT (HZ / 5)
#define IEEE80211_AUTH_MAX_TRIES 3 #define IEEE80211_AUTH_MAX_TRIES 3
...@@ -427,6 +428,14 @@ ieee80211_direct_probe(struct ieee80211_work *wk) ...@@ -427,6 +428,14 @@ ieee80211_direct_probe(struct ieee80211_work *wk)
struct ieee80211_sub_if_data *sdata = wk->sdata; struct ieee80211_sub_if_data *sdata = wk->sdata;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
if (!wk->probe_auth.synced) {
int ret = drv_tx_sync(local, sdata, wk->filter_ta,
IEEE80211_TX_SYNC_AUTH);
if (ret)
return WORK_ACT_TIMEOUT;
}
wk->probe_auth.synced = true;
wk->probe_auth.tries++; wk->probe_auth.tries++;
if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) {
printk(KERN_DEBUG "%s: direct probe to %pM timed out\n", printk(KERN_DEBUG "%s: direct probe to %pM timed out\n",
...@@ -466,6 +475,14 @@ ieee80211_authenticate(struct ieee80211_work *wk) ...@@ -466,6 +475,14 @@ ieee80211_authenticate(struct ieee80211_work *wk)
struct ieee80211_sub_if_data *sdata = wk->sdata; struct ieee80211_sub_if_data *sdata = wk->sdata;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
if (!wk->probe_auth.synced) {
int ret = drv_tx_sync(local, sdata, wk->filter_ta,
IEEE80211_TX_SYNC_AUTH);
if (ret)
return WORK_ACT_TIMEOUT;
}
wk->probe_auth.synced = true;
wk->probe_auth.tries++; wk->probe_auth.tries++;
if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) { if (wk->probe_auth.tries > IEEE80211_AUTH_MAX_TRIES) {
printk(KERN_DEBUG "%s: authentication with %pM" printk(KERN_DEBUG "%s: authentication with %pM"
...@@ -499,6 +516,14 @@ ieee80211_associate(struct ieee80211_work *wk) ...@@ -499,6 +516,14 @@ ieee80211_associate(struct ieee80211_work *wk)
struct ieee80211_sub_if_data *sdata = wk->sdata; struct ieee80211_sub_if_data *sdata = wk->sdata;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
if (!wk->assoc.synced) {
int ret = drv_tx_sync(local, sdata, wk->filter_ta,
IEEE80211_TX_SYNC_ASSOC);
if (ret)
return WORK_ACT_TIMEOUT;
}
wk->assoc.synced = true;
wk->assoc.tries++; wk->assoc.tries++;
if (wk->assoc.tries > IEEE80211_ASSOC_MAX_TRIES) { if (wk->assoc.tries > IEEE80211_ASSOC_MAX_TRIES) {
printk(KERN_DEBUG "%s: association with %pM" printk(KERN_DEBUG "%s: association with %pM"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment