ath9k patches
v2 cover ath9k patches
From: Sujith Manoharan <[email protected]>
Various fixes.
Sujith Manoharan (6):
ath: Fix smatch warning
ath9k: Fix crash in MCC mode
ath9k: Fix sequence number assignment
ath9k: Use sta_state() callback
ath9k: Enable multi-channel properly
ath9k: Process beacons properly
drivers/net/wireless/ath/ath9k/ath9k.h | 6 +++-- drivers/net/wireless/ath/ath9k/beacon.c | 12 ++------- drivers/net/wireless/ath/ath9k/channel.c | 11 +++++--- drivers/net/wireless/ath/ath9k/main.c | 43 +++++++++++++++++++++++++------- drivers/net/wireless/ath/ath9k/xmit.c | 34 +++++++++++++++++-------- drivers/net/wireless/ath/main.c | 8 +++--- 6 files changed, 75 insertions(+), 39 deletions(-)
Signature · 1 line
2.1.2
PATCH v2 1/6 ath: Fix smatch warning
From: Sujith Manoharan <[email protected]>
drivers/net/wireless/ath/main.c:88 ath_printk()
error: we previously assumed 'common->hw' could be null (see line 82)
--- drivers/net/wireless/ath/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/main.c +4 -4
@@ -79,13 +79,13 @@ void ath_printk(const char *level, const struct ath_common* common, vaf.fmt = fmt; vaf.va = &args; -if (common && common->hw && common->hw->wiphy) +if (common && common->hw && common->hw->wiphy) {printk ("%sath: %s: %pV" , level,wiphy_name (common->hw->wiphy), &vaf); -else +trace_ath_log (common->hw->wiphy, &vaf); + }else {printk ("%sath: %pV" , level, &vaf); - -trace_ath_log (common->hw->wiphy, &vaf); + }va_end (args); }
Signature · 1 line
2.1.2
PATCH v2 2/6 ath9k: Fix crash in MCC mode
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
When a channel context is removed, the hw_queue_base is set to -1, this will result in a panic because ath9k_chanctx_stop_queues() can be called on an interface that is not assigned to any context yet - for example, when trying to scan.
Fix this issue by setting the hw_queue_base to zero when a channel context is removed.
--- drivers/net/wireless/ath/ath9k/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/main.c +1 -1
@@ -2332,7 +2332,7 @@ static void ath9k_remove_chanctx(struct ieee80211_hw *hw, conf->def.chan->center_freq); ctx->assigned = false; - ctx->hw_queue_base =-1 ; + ctx->hw_queue_base =0 ;ath_chanctx_event (sc,NULL ,ATH_CHANCTX_EVENT_UNASSIGN );mutex_unlock (&sc->mutex);
Signature · 1 line
2.1.2
PATCH v2 3/6 ath9k: Fix sequence number assignment
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Currently, ath9k uses a global counter for all frames that need to be assigned a sequence number. QoS-data frames are handled properly since they have a per-tid counter. But, beacons and other management frames use the same counter even if multiple interfaces or contexts are present.
Fix this issue by making the counter per-interface and using it when mac80211 sets IEEE80211_TX_CTL_ASSIGN_SEQ.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 4 +++- drivers/net/wireless/ath/ath9k/beacon.c | 12 ++---------- drivers/net/wireless/ath/ath9k/xmit.c | 34 ++++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 22 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +3 -1
@@ -294,7 +294,6 @@ struct ath_tx_control {* (axq_qnum). */ struct ath_tx { -u16 seq_no;u32 txqsetup;spinlock_t txbuflock;struct list_head txbuf;
@@ -563,6 +562,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs);int ath_txq_update (struct ath_softc *sc,int qnum,struct ath9k_tx_queue_info *q);void ath_update_max_aggr_framelen (struct ath_softc *sc,int queue,int txop); +void ath_assign_seq (struct ath_common *common,struct sk_buff *skb);int ath_tx_start (struct ieee80211_hw *hw,struct sk_buff *skb,struct ath_tx_control *txctl); void ath_tx_cabq(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
@@ -592,6 +592,8 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,struct ath_vif {struct list_head list; +u16 seq_no; +/* BSS info */ u8 bssid[ETH_ALEN ];u16 aid;
drivers/net/wireless/ath/ath9k/beacon.c +2 -10
@@ -144,16 +144,8 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, mgmt_hdr->u.beacon.timestamp = avp->tsf_adjust; info =IEEE80211_SKB_CB (skb); -if (info->flags &IEEE80211_TX_CTL_ASSIGN_SEQ ) { -/* -* TODO: make sure the seq# gets assigned properly (vs. other -* TX frames) -*/ -struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - sc->tx.seq_no +=0x10 ; - hdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); - hdr->seq_ctrl |=cpu_to_le16 (sc->tx.seq_no); - } + +ath_assign_seq (common, skb);if (vif->p2p)ath9k_beacon_add_noa (sc, avp, skb);
drivers/net/wireless/ath/ath9k/xmit.c +23 -11
@@ -2139,6 +2139,28 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,return bf; } +void ath_assign_seq (struct ath_common *common,struct sk_buff *skb) +{ +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); +struct ieee80211_vif *vif = info->control.vif; +struct ath_vif *avp; + +if (!(info->flags &IEEE80211_TX_CTL_ASSIGN_SEQ )) +return ; + +if (!vif) +return ; + + avp = (struct ath_vif *)vif->drv_priv; + +if (info->flags &IEEE80211_TX_CTL_FIRST_FRAGMENT ) + avp->seq_no +=0x10 ; + + hdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); + hdr->seq_ctrl |=cpu_to_le16 (avp->seq_no); +} +static int ath_tx_prepare (struct ieee80211_hw *hw,struct sk_buff *skb,struct ath_tx_control *txctl) {
@@ -2162,17 +2184,7 @@ static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,if (info->control.hw_key) frmlen += info->control.hw_key->icv_len; -/* -* As a temporary workaround, assign seq# here; this will likely need -* to be cleaned up to work better with Beacon transmission and virtual -* BSSes. -*/ -if (info->flags &IEEE80211_TX_CTL_ASSIGN_SEQ ) { -if (info->flags &IEEE80211_TX_CTL_FIRST_FRAGMENT ) - sc->tx.seq_no +=0x10 ; - hdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); - hdr->seq_ctrl |=cpu_to_le16 (sc->tx.seq_no); - } +ath_assign_seq (ath9k_hw_common (sc->sc_ah), skb); if ((vif && vif->type != NL80211_IFTYPE_AP && vif->type != NL80211_IFTYPE_AP_VLAN) ||
Signature · 1 line
2.1.2
Re: [PATCH v2 3/6] ath9k: Fix sequence number assignment
Hmmm...am I missing something?
CC drivers/net/wireless/ath/ath9k/tx99.o
In file included from include/linux/byteorder/little_endian.h:4:0,
from ./arch/x86/include/uapi/asm/byteorder.h:4,
from include/asm-generic/bitops/le.h:5,
from ./arch/x86/include/asm/bitops.h:506,
from include/linux/bitops.h:33,
from include/linux/kernel.h:10,
from include/linux/skbuff.h:17,
from include/linux/if_ether.h:23,
from include/linux/etherdevice.h:25,
from drivers/net/wireless/ath/ath9k/ath9k.h:20,
from drivers/net/wireless/ath/ath9k/tx99.c:17:
drivers/net/wireless/ath/ath9k/tx99.c: In function ‘ath9k_build_tx99_skb’:
drivers/net/wireless/ath/ath9k/tx99.c:74:37: error: ‘struct ath_tx’ has no member named ‘seq_no’
hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
^
include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro ‘__cpu_to_le16’
#define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
^
drivers/net/wireless/ath/ath9k/tx99.c:74:19: note: in expansion of macro ‘cpu_to_le16’
hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
^make[3]: *** [drivers/net/wireless/ath/ath9k/tx99.o] Error 1
Quoted 127 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
Currently, ath9k uses a global counter for all frames that need to be assigned a sequence number. QoS-data frames are handled properly since they have a per-tid counter. But, beacons and other management frames use the same counter even if multiple interfaces or contexts are present.
Fix this issue by making the counter per-interface and using it when mac80211 sets
IEEE80211_TX_CTL_ASSIGN_SEQ.Signed-off-by Sujith Manoharan <[email protected]>--- drivers/net/wireless/ath/ath9k/ath9k.h | 4 +++- drivers/net/wireless/ath/ath9k/beacon.c | 12 ++---------- drivers/net/wireless/ath/ath9k/xmit.c | 34 ++++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 22 deletions(-)drivers/net/wireless/ath/ath9k/ath9k.h +3
-1@@ -294,7 +294,6 @@ struct ath_tx_control {* (axq_qnum). */ struct ath_tx { -u16 seq_no;u32 txqsetup;spinlock_t txbuflock;struct list_head txbuf;@@ -563,6 +562,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs);int ath_txq_update (struct ath_softc *sc,int qnum,struct ath9k_tx_queue_info *q);void ath_update_max_aggr_framelen (struct ath_softc *sc,int queue,int txop); +void ath_assign_seq (struct ath_common *common,struct sk_buff *skb);int ath_tx_start (struct ieee80211_hw *hw,struct sk_buff *skb,struct ath_tx_control *txctl); void ath_tx_cabq(struct ieee80211_hw *hw, struct ieee80211_vif *vif,@@ -592,6 +592,8 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,struct ath_vif {struct list_head list; +u16 seq_no; +/* BSS info */ u8 bssid[ETH_ALEN ];u16 aid;drivers/net/wireless/ath/ath9k/beacon.c +2
-10@@ -144,16 +144,8 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw, mgmt_hdr->u.beacon.timestamp = avp->tsf_adjust; info =IEEE80211_SKB_CB (skb); -if (info->flags &IEEE80211_TX_CTL_ASSIGN_SEQ ) { -/* -* TODO: make sure the seq# gets assigned properly (vs. other -* TX frames) -*/ -struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - sc->tx.seq_no +=0x10 ; - hdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); - hdr->seq_ctrl |=cpu_to_le16 (sc->tx.seq_no); - } + +ath_assign_seq (common, skb);if (vif->p2p)ath9k_beacon_add_noa (sc, avp, skb);drivers/net/wireless/ath/ath9k/xmit.c +23
-11@@ -2139,6 +2139,28 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,return bf; } +void ath_assign_seq (struct ath_common *common,struct sk_buff *skb) +{ +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); +struct ieee80211_vif *vif = info->control.vif; +struct ath_vif *avp; + +if (!(info->flags &IEEE80211_TX_CTL_ASSIGN_SEQ )) +return ; + +if (!vif) +return ; + + avp = (struct ath_vif *)vif->drv_priv; + +if (info->flags &IEEE80211_TX_CTL_FIRST_FRAGMENT ) + avp->seq_no +=0x10 ; + + hdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); + hdr->seq_ctrl |=cpu_to_le16 (avp->seq_no); +} +static int ath_tx_prepare (struct ieee80211_hw *hw,struct sk_buff *skb,struct ath_tx_control *txctl) {@@ -2162,17 +2184,7 @@ static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,if (info->control.hw_key) frmlen += info->control.hw_key->icv_len; -/* -* As a temporary workaround, assign seq# here; this will likely need -* to be cleaned up to work better with Beacon transmission and virtual -* BSSes. -*/ -if (info->flags &IEEE80211_TX_CTL_ASSIGN_SEQ ) { -if (info->flags &IEEE80211_TX_CTL_FIRST_FRAGMENT ) - sc->tx.seq_no +=0x10 ; - hdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); - hdr->seq_ctrl |=cpu_to_le16 (sc->tx.seq_no); - } +ath_assign_seq (ath9k_hw_common (sc->sc_ah), skb); if ((vif && vif->type != NL80211_IFTYPE_AP && vif->type != NL80211_IFTYPE_AP_VLAN) ||Signature · 1 line
2.1.2
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Re: [PATCH v2 3/6] ath9k: Fix sequence number assignment
Quoted 24 lines · John W. Linville
Hmmm...am I missing something?
CC
drivers/net/wireless/ath/ath9k/tx99.o
In file included frominclude/linux/byteorder/little_endian.h:4:0,from ./arch/x86/include/uapi/asm/byteorder.h:4, from include/asm-generic/bitops/le.h:5, from ./arch/x86/include/asm/bitops.h:506, from include/linux/bitops.h:33, from include/linux/kernel.h:10, from include/linux/skbuff.h:17, from include/linux/if_ether.h:23, from include/linux/etherdevice.h:25, from drivers/net/wireless/ath/ath9k/ath9k.h:20, from drivers/net/wireless/ath/ath9k/tx99.c:17: drivers/net/wireless/ath/ath9k/tx99.c: In function ‘ath9k_build_tx99_skb’: drivers/net/wireless/ath/ath9k/tx99.c:74:37: error: ‘struct ath_tx’ has no member named ‘seq_no’ hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no); ^ include/uapi/linux/byteorder/little_endian.h:34:51: note: in definition of macro ‘__cpu_to_le16’ #define __cpu_to_le16(x) ((__force __le16)(__u16)(x)) ^ drivers/net/wireless/ath/ath9k/tx99.c:74:19: note: in expansion of macro ‘cpu_to_le16’ hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no); ^
Quoted 1 line
make[3]: *** [
drivers/net/wireless/ath/ath9k/tx99.o] Error 1
This is my mistake. I did not test with CONFIG_ATH9K_TX99 enabled, sorry. I'll send an updated series.
Sujith
PATCH v2 4/6 ath9k: Use sta_state() callback
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Instead of using the sta_add()/sta_remove() callbacks, use the sta_state() callback since this gives more fine-grained control.
--- drivers/net/wireless/ath/ath9k/main.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +26 -2
@@ -1547,6 +1547,31 @@ static int ath9k_sta_remove(struct ieee80211_hw *hw,return 0 ; } +static int ath9k_sta_state (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +enum ieee80211_sta_state old_state, +enum ieee80211_sta_state new_state) +{ +struct ath_softc *sc = hw->priv; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); +int ret =0 ; + +if (old_state ==IEEE80211_STA_AUTH && + new_state ==IEEE80211_STA_ASSOC ) { + ret =ath9k_sta_add (hw, vif, sta); +ath_dbg (common,CONFIG , +"Add station: %pM\n" , sta->addr); + }else if (old_state ==IEEE80211_STA_ASSOC && + new_state ==IEEE80211_STA_AUTH ) { + ret =ath9k_sta_remove (hw, vif, sta); +ath_dbg (common,CONFIG , +"Remove station: %pM\n" , sta->addr); + } + +return ret; +} +static void ath9k_sta_set_tx_filter (struct ath_hw *ah,struct ath_node *an,bool set)
@@ -2471,8 +2496,7 @@ struct ieee80211_ops ath9k_ops = { .remove_interface = ath9k_remove_interface, .config = ath9k_config, .configure_filter = ath9k_configure_filter, - .sta_add = ath9k_sta_add, - .sta_remove = ath9k_sta_remove, + .sta_state = ath9k_sta_state, .sta_notify = ath9k_sta_notify, .conf_tx = ath9k_conf_tx, .bss_info_changed = ath9k_bss_info_changed,
Signature · 1 line
2.1.2
PATCH v2 5/6 ath9k: Enable multi-channel properly
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
In MCC mode, currently the decision to enable the multi-channel state machine is done based on the association status if one of the interfaces assigned to a context is in station mode.
This allows the driver to switch to the other context before the current station is able to complete the 4-way handshake in case it is required and this causes problems.
Instead, enable multi-channel mode when the station moves to the authorized state. This disallows an early switch to the other channel.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 2 +- drivers/net/wireless/ath/ath9k/channel.c | 4 ++-- drivers/net/wireless/ath/ath9k/main.c | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
@@ -362,7 +362,7 @@ enum ath_chanctx_event {ATH_CHANCTX_EVENT_BEACON_SENT ,ATH_CHANCTX_EVENT_TSF_TIMER ,ATH_CHANCTX_EVENT_BEACON_RECEIVED , -ATH_CHANCTX_EVENT_ASSOC , +ATH_CHANCTX_EVENT_AUTHORIZED ,ATH_CHANCTX_EVENT_SWITCH ,ATH_CHANCTX_EVENT_ASSIGN , ATH_CHANCTX_EVENT_UNASSIGN,
drivers/net/wireless/ath/ath9k/channel.c +2 -2
@@ -171,7 +171,7 @@ static const char *chanctx_event_string(enum ath_chanctx_event ev)case_rtn_string (ATH_CHANCTX_EVENT_BEACON_SENT );case_rtn_string (ATH_CHANCTX_EVENT_TSF_TIMER );case_rtn_string (ATH_CHANCTX_EVENT_BEACON_RECEIVED ); -case_rtn_string (ATH_CHANCTX_EVENT_ASSOC ); +case_rtn_string (ATH_CHANCTX_EVENT_AUTHORIZED );case_rtn_string (ATH_CHANCTX_EVENT_SWITCH );case_rtn_string (ATH_CHANCTX_EVENT_ASSIGN );case_rtn_string (ATH_CHANCTX_EVENT_UNASSIGN );
@@ -510,7 +510,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,ath_chanctx_setup_timer (sc, tsf_time);break ; -case ATH_CHANCTX_EVENT_ASSOC : +case ATH_CHANCTX_EVENT_AUTHORIZED :if (sc->sched.state !=ATH_CHANCTX_STATE_FORCE_ACTIVE || avp->chanctx != sc->cur_chan)break ;
drivers/net/wireless/ath/ath9k/main.c +7 -6
@@ -1569,6 +1569,13 @@ static int ath9k_sta_state(struct ieee80211_hw *hw, "Remove station: %pM\n", sta->addr); } +if (ath9k_is_chanctx_enabled ()) { +if (old_state ==IEEE80211_STA_ASSOC && + new_state ==IEEE80211_STA_AUTHORIZED ) +ath_chanctx_event (sc, vif, +ATH_CHANCTX_EVENT_AUTHORIZED ); + } +return ret; }
@@ -1761,12 +1768,6 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw, avp->assoc = bss_conf->assoc;ath9k_calculate_summary_state (sc, avp->chanctx); - -if (ath9k_is_chanctx_enabled ()) { -if (bss_conf->assoc) -ath_chanctx_event (sc, vif, -ATH_CHANCTX_EVENT_ASSOC ); - } }if (changed &BSS_CHANGED_IBSS ) {
Signature · 1 line
2.1.2
PATCH v2 6/6 ath9k: Process beacons properly
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
When the current operating channel context has been marked as ATH_CHANCTX_STATE_FORCE_ACTIVE, do not process beacons that might be received, since we have to wait for the station to become authorized.
Also, since the cached TSF value will be zero initially do not rearm the timer in this case when a beacon is received, since it results in spurious values.
--- drivers/net/wireless/ath/ath9k/channel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/channel.c +6 -1
@@ -495,10 +495,15 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, sc->cur_chan == &sc->offchannel.chan)break ; -ath_chanctx_adjust_tbtt_delta (sc); sc->sched.beacon_pending = false; sc->sched.beacon_miss =0 ; +if (sc->sched.state ==ATH_CHANCTX_STATE_FORCE_ACTIVE || + !sc->cur_chan->tsf_val) +break ; + +ath_chanctx_adjust_tbtt_delta (sc); +/* TSF time might have been updated by the incoming beacon, * need update the channel switch timer to reflect the change. */
Signature · 1 line
2.1.2