ath9k: clean up code duplication around ath_tx_start
Merge initial processing for the CAB queue and regular tx. Also move ath_tx_cabq() to beacon.c and make it static. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
c599261825
commit
28d1670862
4 changed files with 45 additions and 79 deletions
|
@ -323,7 +323,6 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
|
||||||
struct ath_tx_control *txctl);
|
struct ath_tx_control *txctl);
|
||||||
void ath_tx_tasklet(struct ath_softc *sc);
|
void ath_tx_tasklet(struct ath_softc *sc);
|
||||||
void ath_tx_edma_tasklet(struct ath_softc *sc);
|
void ath_tx_edma_tasklet(struct ath_softc *sc);
|
||||||
void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb);
|
|
||||||
int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
|
int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
|
||||||
u16 tid, u16 *ssn);
|
u16 tid, u16 *ssn);
|
||||||
void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
|
void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
|
||||||
|
|
|
@ -109,6 +109,25 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,
|
||||||
series, 4, 0);
|
series, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
struct ath_wiphy *aphy = hw->priv;
|
||||||
|
struct ath_softc *sc = aphy->sc;
|
||||||
|
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
||||||
|
struct ath_tx_control txctl;
|
||||||
|
|
||||||
|
memset(&txctl, 0, sizeof(struct ath_tx_control));
|
||||||
|
txctl.txq = sc->beacon.cabq;
|
||||||
|
|
||||||
|
ath_print(common, ATH_DBG_XMIT,
|
||||||
|
"transmitting CABQ packet, skb: %p\n", skb);
|
||||||
|
|
||||||
|
if (ath_tx_start(hw, skb, &txctl) != 0) {
|
||||||
|
ath_print(common, ATH_DBG_XMIT, "CABQ TX failed\n");
|
||||||
|
dev_kfree_skb_any(skb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
|
static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
|
||||||
struct ieee80211_vif *vif)
|
struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1187,12 +1187,10 @@ mutex_unlock:
|
||||||
static int ath9k_tx(struct ieee80211_hw *hw,
|
static int ath9k_tx(struct ieee80211_hw *hw,
|
||||||
struct sk_buff *skb)
|
struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
|
||||||
struct ath_wiphy *aphy = hw->priv;
|
struct ath_wiphy *aphy = hw->priv;
|
||||||
struct ath_softc *sc = aphy->sc;
|
struct ath_softc *sc = aphy->sc;
|
||||||
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
||||||
struct ath_tx_control txctl;
|
struct ath_tx_control txctl;
|
||||||
int padpos, padsize;
|
|
||||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
||||||
|
|
||||||
if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
|
if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
|
||||||
|
@ -1243,29 +1241,6 @@ static int ath9k_tx(struct ieee80211_hw *hw,
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&txctl, 0, sizeof(struct ath_tx_control));
|
memset(&txctl, 0, sizeof(struct ath_tx_control));
|
||||||
|
|
||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add the padding after the header if this is not already done */
|
|
||||||
padpos = ath9k_cmn_padpos(hdr->frame_control);
|
|
||||||
padsize = padpos & 3;
|
|
||||||
if (padsize && skb->len>padpos) {
|
|
||||||
if (skb_headroom(skb) < padsize)
|
|
||||||
return -1;
|
|
||||||
skb_push(skb, padsize);
|
|
||||||
memmove(skb->data, skb->data + padsize, padpos);
|
|
||||||
}
|
|
||||||
|
|
||||||
txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
|
txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
|
||||||
|
|
||||||
ath_print(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb);
|
ath_print(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb);
|
||||||
|
|
|
@ -1742,41 +1742,14 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
|
||||||
int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
|
int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
|
||||||
struct ath_tx_control *txctl)
|
struct ath_tx_control *txctl)
|
||||||
{
|
{
|
||||||
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
||||||
|
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
||||||
struct ath_wiphy *aphy = hw->priv;
|
struct ath_wiphy *aphy = hw->priv;
|
||||||
struct ath_softc *sc = aphy->sc;
|
struct ath_softc *sc = aphy->sc;
|
||||||
struct ath_txq *txq = txctl->txq;
|
struct ath_txq *txq = txctl->txq;
|
||||||
struct ath_buf *bf;
|
struct ath_buf *bf;
|
||||||
int q;
|
|
||||||
|
|
||||||
bf = ath_tx_setup_buffer(hw, skb);
|
|
||||||
if (unlikely(!bf))
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
q = skb_get_queue_mapping(skb);
|
|
||||||
spin_lock_bh(&txq->axq_lock);
|
|
||||||
if (txq == sc->tx.txq_map[q] &&
|
|
||||||
++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
|
|
||||||
ath_mac80211_stop_queue(sc, q);
|
|
||||||
txq->stopped = 1;
|
|
||||||
}
|
|
||||||
spin_unlock_bh(&txq->axq_lock);
|
|
||||||
|
|
||||||
ath_tx_start_dma(sc, bf, txctl);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
|
|
||||||
{
|
|
||||||
struct ath_wiphy *aphy = hw->priv;
|
|
||||||
struct ath_softc *sc = aphy->sc;
|
|
||||||
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
|
|
||||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
|
||||||
int padpos, padsize;
|
int padpos, padsize;
|
||||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
int q;
|
||||||
struct ath_tx_control txctl;
|
|
||||||
|
|
||||||
memset(&txctl, 0, sizeof(struct ath_tx_control));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As a temporary workaround, assign seq# here; this will likely need
|
* As a temporary workaround, assign seq# here; this will likely need
|
||||||
|
@ -1794,29 +1767,29 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
|
||||||
padpos = ath9k_cmn_padpos(hdr->frame_control);
|
padpos = ath9k_cmn_padpos(hdr->frame_control);
|
||||||
padsize = padpos & 3;
|
padsize = padpos & 3;
|
||||||
if (padsize && skb->len > padpos) {
|
if (padsize && skb->len > padpos) {
|
||||||
if (skb_headroom(skb) < padsize) {
|
if (skb_headroom(skb) < padsize)
|
||||||
ath_print(common, ATH_DBG_XMIT,
|
return -ENOMEM;
|
||||||
"TX CABQ padding failed\n");
|
|
||||||
dev_kfree_skb_any(skb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
skb_push(skb, padsize);
|
skb_push(skb, padsize);
|
||||||
memmove(skb->data, skb->data + padsize, padpos);
|
memmove(skb->data, skb->data + padsize, padpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
txctl.txq = sc->beacon.cabq;
|
bf = ath_tx_setup_buffer(hw, skb);
|
||||||
|
if (unlikely(!bf))
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ath_print(common, ATH_DBG_XMIT,
|
q = skb_get_queue_mapping(skb);
|
||||||
"transmitting CABQ packet, skb: %p\n", skb);
|
spin_lock_bh(&txq->axq_lock);
|
||||||
|
if (txq == sc->tx.txq_map[q] &&
|
||||||
if (ath_tx_start(hw, skb, &txctl) != 0) {
|
++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
|
||||||
ath_print(common, ATH_DBG_XMIT, "CABQ TX failed\n");
|
ath_mac80211_stop_queue(sc, q);
|
||||||
goto exit;
|
txq->stopped = 1;
|
||||||
}
|
}
|
||||||
|
spin_unlock_bh(&txq->axq_lock);
|
||||||
|
|
||||||
return;
|
ath_tx_start_dma(sc, bf, txctl);
|
||||||
exit:
|
|
||||||
dev_kfree_skb_any(skb);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
|
|
Loading…
Add table
Reference in a new issue