Commit 9b9c5aae authored by Christian Lamparter's avatar Christian Lamparter Committed by John W. Linville

ar9170: xmit code revamp

This patch is a back-port from aggregation testing code.

In the past, we didn't limit the amount of active tx urbs.
However, ar9170 only has a limited buffer reserved for
pending data frames.

This wasn't much of a problem with the slower 802.11b/g.
We simply stopped the full queue and moved on to something different
in the mean time. But - as you guessed it -  this simple approach
stands in way for a decent aggregation implementation.
Signed-off-by: default avatarChristian Lamparter <chunkeey@web.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 2543a0c4
...@@ -109,6 +109,11 @@ struct ar9170_rxstream_mpdu_merge { ...@@ -109,6 +109,11 @@ struct ar9170_rxstream_mpdu_merge {
bool has_plcp; bool has_plcp;
}; };
#define AR9170_QUEUE_TIMEOUT 64
#define AR9170_TX_TIMEOUT 8
#define AR9170_JANITOR_DELAY 128
#define AR9170_TX_INVALID_RATE 0xffffffff
struct ar9170 { struct ar9170 {
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct mutex mutex; struct mutex mutex;
...@@ -117,10 +122,11 @@ struct ar9170 { ...@@ -117,10 +122,11 @@ struct ar9170 {
int (*open)(struct ar9170 *); int (*open)(struct ar9170 *);
void (*stop)(struct ar9170 *); void (*stop)(struct ar9170 *);
int (*tx)(struct ar9170 *, struct sk_buff *, bool, unsigned int); int (*tx)(struct ar9170 *, struct sk_buff *);
int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 , int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 ,
void *, u32 , void *); void *, u32 , void *);
void (*callback_cmd)(struct ar9170 *, u32 , void *); void (*callback_cmd)(struct ar9170 *, u32 , void *);
int (*flush)(struct ar9170 *);
/* interface mode settings */ /* interface mode settings */
struct ieee80211_vif *vif; struct ieee80211_vif *vif;
...@@ -177,10 +183,10 @@ struct ar9170 { ...@@ -177,10 +183,10 @@ struct ar9170 {
struct ar9170_eeprom eeprom; struct ar9170_eeprom eeprom;
struct ath_regulatory regulatory; struct ath_regulatory regulatory;
/* global tx status for unregistered Stations. */ /* tx queues - as seen by hw - */
struct sk_buff_head global_tx_status; struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
struct sk_buff_head global_tx_status_waste; struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
struct delayed_work tx_status_janitor; struct delayed_work tx_janitor;
/* rxstream mpdu merge */ /* rxstream mpdu merge */
struct ar9170_rxstream_mpdu_merge rx_mpdu; struct ar9170_rxstream_mpdu_merge rx_mpdu;
...@@ -189,11 +195,19 @@ struct ar9170 { ...@@ -189,11 +195,19 @@ struct ar9170 {
}; };
struct ar9170_sta_info { struct ar9170_sta_info {
struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
}; };
#define IS_STARTED(a) (a->state >= AR9170_STARTED) #define AR9170_TX_FLAG_WAIT_FOR_ACK BIT(0)
#define IS_ACCEPTING_CMD(a) (a->state >= AR9170_IDLE) #define AR9170_TX_FLAG_NO_ACK BIT(1)
#define AR9170_TX_FLAG_BLOCK_ACK BIT(2)
struct ar9170_tx_info {
unsigned long timeout;
unsigned int flags;
};
#define IS_STARTED(a) (((struct ar9170 *)a)->state >= AR9170_STARTED)
#define IS_ACCEPTING_CMD(a) (((struct ar9170 *)a)->state >= AR9170_IDLE)
#define AR9170_FILTER_CHANGED_MODE BIT(0) #define AR9170_FILTER_CHANGED_MODE BIT(0)
#define AR9170_FILTER_CHANGED_MULTICAST BIT(1) #define AR9170_FILTER_CHANGED_MULTICAST BIT(1)
...@@ -204,9 +218,9 @@ void *ar9170_alloc(size_t priv_size); ...@@ -204,9 +218,9 @@ void *ar9170_alloc(size_t priv_size);
int ar9170_register(struct ar9170 *ar, struct device *pdev); int ar9170_register(struct ar9170 *ar, struct device *pdev);
void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb); void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb);
void ar9170_unregister(struct ar9170 *ar); void ar9170_unregister(struct ar9170 *ar);
void ar9170_handle_tx_status(struct ar9170 *ar, struct sk_buff *skb, void ar9170_tx_callback(struct ar9170 *ar, struct sk_buff *skb);
bool update_statistics, u16 tx_status);
void ar9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len); void ar9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
int ar9170_nag_limiter(struct ar9170 *ar);
/* MAC */ /* MAC */
int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb); int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
......
...@@ -420,4 +420,7 @@ enum ar9170_txq { ...@@ -420,4 +420,7 @@ enum ar9170_txq {
__AR9170_NUM_TXQ, __AR9170_NUM_TXQ,
}; };
#define AR9170_TXQ_DEPTH 32
#define AR9170_TX_MAX_PENDING 128
#endif /* __AR9170_HW_H */ #endif /* __AR9170_HW_H */
This diff is collapsed.
...@@ -96,7 +96,49 @@ static struct usb_device_id ar9170_usb_ids[] = { ...@@ -96,7 +96,49 @@ static struct usb_device_id ar9170_usb_ids[] = {
}; };
MODULE_DEVICE_TABLE(usb, ar9170_usb_ids); MODULE_DEVICE_TABLE(usb, ar9170_usb_ids);
static void ar9170_usb_tx_urb_complete_free(struct urb *urb) static void ar9170_usb_submit_urb(struct ar9170_usb *aru)
{
struct urb *urb;
unsigned long flags;
int err;
if (unlikely(!IS_STARTED(&aru->common)))
return ;
spin_lock_irqsave(&aru->tx_urb_lock, flags);
if (aru->tx_submitted_urbs >= AR9170_NUM_TX_URBS) {
spin_unlock_irqrestore(&aru->tx_urb_lock, flags);
return ;
}
aru->tx_submitted_urbs++;
urb = usb_get_from_anchor(&aru->tx_pending);
if (!urb) {
aru->tx_submitted_urbs--;
spin_unlock_irqrestore(&aru->tx_urb_lock, flags);
return ;
}
spin_unlock_irqrestore(&aru->tx_urb_lock, flags);
aru->tx_pending_urbs--;
usb_anchor_urb(urb, &aru->tx_submitted);
err = usb_submit_urb(urb, GFP_ATOMIC);
if (unlikely(err)) {
if (ar9170_nag_limiter(&aru->common))
dev_err(&aru->udev->dev, "submit_urb failed (%d).\n",
err);
usb_unanchor_urb(urb);
aru->tx_submitted_urbs--;
ar9170_tx_callback(&aru->common, urb->context);
}
usb_free_urb(urb);
}
static void ar9170_usb_tx_urb_complete_frame(struct urb *urb)
{ {
struct sk_buff *skb = urb->context; struct sk_buff *skb = urb->context;
struct ar9170_usb *aru = (struct ar9170_usb *) struct ar9170_usb *aru = (struct ar9170_usb *)
...@@ -107,8 +149,11 @@ static void ar9170_usb_tx_urb_complete_free(struct urb *urb) ...@@ -107,8 +149,11 @@ static void ar9170_usb_tx_urb_complete_free(struct urb *urb)
return ; return ;
} }
ar9170_handle_tx_status(&aru->common, skb, false, aru->tx_submitted_urbs--;
AR9170_TX_STATUS_COMPLETE);
ar9170_tx_callback(&aru->common, skb);
ar9170_usb_submit_urb(aru);
} }
static void ar9170_usb_tx_urb_complete(struct urb *urb) static void ar9170_usb_tx_urb_complete(struct urb *urb)
...@@ -290,21 +335,47 @@ static int ar9170_usb_alloc_rx_bulk_urbs(struct ar9170_usb *aru) ...@@ -290,21 +335,47 @@ static int ar9170_usb_alloc_rx_bulk_urbs(struct ar9170_usb *aru)
return err; return err;
} }
static void ar9170_usb_cancel_urbs(struct ar9170_usb *aru) static int ar9170_usb_flush(struct ar9170 *ar)
{ {
int ret; struct ar9170_usb *aru = (void *) ar;
struct urb *urb;
int ret, err = 0;
aru->common.state = AR9170_UNKNOWN_STATE; if (IS_STARTED(ar))
aru->common.state = AR9170_IDLE;
usb_unlink_anchored_urbs(&aru->tx_submitted); usb_wait_anchor_empty_timeout(&aru->tx_pending,
msecs_to_jiffies(800));
while ((urb = usb_get_from_anchor(&aru->tx_pending))) {
ar9170_tx_callback(&aru->common, (void *) urb->context);
usb_free_urb(urb);
}
/* give the LED OFF command and the deauth frame a chance to air. */ /* lets wait a while until the tx - queues are dried out */
ret = usb_wait_anchor_empty_timeout(&aru->tx_submitted, ret = usb_wait_anchor_empty_timeout(&aru->tx_submitted,
msecs_to_jiffies(100)); msecs_to_jiffies(100));
if (ret == 0) if (ret == 0)
dev_err(&aru->udev->dev, "kill pending tx urbs.\n"); err = -ETIMEDOUT;
usb_poison_anchored_urbs(&aru->tx_submitted);
usb_kill_anchored_urbs(&aru->tx_submitted);
if (IS_ACCEPTING_CMD(ar))
aru->common.state = AR9170_STARTED;
return err;
}
static void ar9170_usb_cancel_urbs(struct ar9170_usb *aru)
{
int err;
aru->common.state = AR9170_UNKNOWN_STATE;
err = ar9170_usb_flush(&aru->common);
if (err)
dev_err(&aru->udev->dev, "stuck tx urbs!\n");
usb_poison_anchored_urbs(&aru->tx_submitted);
usb_poison_anchored_urbs(&aru->rx_submitted); usb_poison_anchored_urbs(&aru->rx_submitted);
} }
...@@ -388,12 +459,10 @@ static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd, ...@@ -388,12 +459,10 @@ static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd,
return err; return err;
} }
static int ar9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb, static int ar9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb)
bool txstatus_needed, unsigned int extra_len)
{ {
struct ar9170_usb *aru = (struct ar9170_usb *) ar; struct ar9170_usb *aru = (struct ar9170_usb *) ar;
struct urb *urb; struct urb *urb;
int err;
if (unlikely(!IS_STARTED(ar))) { if (unlikely(!IS_STARTED(ar))) {
/* Seriously, what were you drink... err... thinking!? */ /* Seriously, what were you drink... err... thinking!? */
...@@ -406,18 +475,17 @@ static int ar9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb, ...@@ -406,18 +475,17 @@ static int ar9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb,
usb_fill_bulk_urb(urb, aru->udev, usb_fill_bulk_urb(urb, aru->udev,
usb_sndbulkpipe(aru->udev, AR9170_EP_TX), usb_sndbulkpipe(aru->udev, AR9170_EP_TX),
skb->data, skb->len + extra_len, (txstatus_needed ? skb->data, skb->len,
ar9170_usb_tx_urb_complete : ar9170_usb_tx_urb_complete_frame, skb);
ar9170_usb_tx_urb_complete_free), skb);
urb->transfer_flags |= URB_ZERO_PACKET; urb->transfer_flags |= URB_ZERO_PACKET;
usb_anchor_urb(urb, &aru->tx_submitted); usb_anchor_urb(urb, &aru->tx_pending);
err = usb_submit_urb(urb, GFP_ATOMIC); aru->tx_pending_urbs++;
if (unlikely(err))
usb_unanchor_urb(urb);
usb_free_urb(urb); usb_free_urb(urb);
return err;
ar9170_usb_submit_urb(aru);
return 0;
} }
static void ar9170_usb_callback_cmd(struct ar9170 *ar, u32 len , void *buffer) static void ar9170_usb_callback_cmd(struct ar9170 *ar, u32 len , void *buffer)
...@@ -617,10 +685,8 @@ static void ar9170_usb_stop(struct ar9170 *ar) ...@@ -617,10 +685,8 @@ static void ar9170_usb_stop(struct ar9170 *ar)
if (IS_ACCEPTING_CMD(ar)) if (IS_ACCEPTING_CMD(ar))
aru->common.state = AR9170_STOPPED; aru->common.state = AR9170_STOPPED;
/* lets wait a while until the tx - queues are dried out */ ret = ar9170_usb_flush(ar);
ret = usb_wait_anchor_empty_timeout(&aru->tx_submitted, if (ret)
msecs_to_jiffies(1000));
if (ret == 0)
dev_err(&aru->udev->dev, "kill pending tx urbs.\n"); dev_err(&aru->udev->dev, "kill pending tx urbs.\n");
usb_poison_anchored_urbs(&aru->tx_submitted); usb_poison_anchored_urbs(&aru->tx_submitted);
...@@ -716,10 +782,16 @@ static int ar9170_usb_probe(struct usb_interface *intf, ...@@ -716,10 +782,16 @@ static int ar9170_usb_probe(struct usb_interface *intf,
SET_IEEE80211_DEV(ar->hw, &udev->dev); SET_IEEE80211_DEV(ar->hw, &udev->dev);
init_usb_anchor(&aru->rx_submitted); init_usb_anchor(&aru->rx_submitted);
init_usb_anchor(&aru->tx_pending);
init_usb_anchor(&aru->tx_submitted); init_usb_anchor(&aru->tx_submitted);
init_completion(&aru->cmd_wait); init_completion(&aru->cmd_wait);
spin_lock_init(&aru->tx_urb_lock);
aru->tx_pending_urbs = 0;
aru->tx_submitted_urbs = 0;
aru->common.stop = ar9170_usb_stop; aru->common.stop = ar9170_usb_stop;
aru->common.flush = ar9170_usb_flush;
aru->common.open = ar9170_usb_open; aru->common.open = ar9170_usb_open;
aru->common.tx = ar9170_usb_tx; aru->common.tx = ar9170_usb_tx;
aru->common.exec_cmd = ar9170_usb_exec_cmd; aru->common.exec_cmd = ar9170_usb_exec_cmd;
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "ar9170.h" #include "ar9170.h"
#define AR9170_NUM_RX_URBS 16 #define AR9170_NUM_RX_URBS 16
#define AR9170_NUM_TX_URBS 8
struct firmware; struct firmware;
...@@ -60,11 +61,15 @@ struct ar9170_usb { ...@@ -60,11 +61,15 @@ struct ar9170_usb {
struct usb_interface *intf; struct usb_interface *intf;
struct usb_anchor rx_submitted; struct usb_anchor rx_submitted;
struct usb_anchor tx_pending;
struct usb_anchor tx_submitted; struct usb_anchor tx_submitted;
bool req_one_stage_fw; bool req_one_stage_fw;
spinlock_t cmdlock; spinlock_t tx_urb_lock;
unsigned int tx_submitted_urbs;
unsigned int tx_pending_urbs;
struct completion cmd_wait; struct completion cmd_wait;
int readlen; int readlen;
u8 *readbuf; u8 *readbuf;
......
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