Commit 0d2dfdb8 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman

staging: wfx: fix QoS priority for slow buses

The device is in charge of respecting the QoS constraints. The driver
have to ensure that all the queues contain data and the device choose
the right queue to send.

The things starts to be more difficult when the bandwidth of the bus is
lower than the bandwidth of the WiFi. The device quickly sends the
frames of the highest priority queue. Then, it starts to send frames
from a lower priority queue. Though, there are still some high priority
frames waiting in the driver.

To work around this problem, this patch add some priorities to each
queue. The weigh of the queue was (roughly) calculated experimentally by
checking the speed ratio of each queue when the bus does not limit the
traffic:
    - Be/Bk -> 20Mbps/10Mbps
    - Vi/Be -> 36Mbps/180Kbps
    - Vo/Be -> 35Mbps/600Kbps
    - Vi/Vo -> 24Mbps/12Mbps

So, if we fix the weigh of the Background to 1, the weight of Best
Effort should be 2. The weight of Video should be 116. However, since
there is only 32 queues, it make no sense to use a value greater than
64[1]. And finally, the weight of the Voice is set to 128.

[1] Because of this approximation, with very slow bus, we can still
observe frame starvation when we measure the speed ratio of Vi/Be. It is
around 35Mbps/1Mbps (instead of 36Mbps/180Kbps). However, it is still in
accepted error range.
Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20201007101943.749898-5-Jerome.Pouiller@silabs.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4fd12417
...@@ -60,11 +60,16 @@ void wfx_tx_lock_flush(struct wfx_dev *wdev) ...@@ -60,11 +60,16 @@ void wfx_tx_lock_flush(struct wfx_dev *wdev)
void wfx_tx_queues_init(struct wfx_vif *wvif) void wfx_tx_queues_init(struct wfx_vif *wvif)
{ {
// The device is in charge to respect the details of the QoS parameters.
// The driver just ensure that it roughtly respect the priorities to
// avoid any shortage.
const int priorities[IEEE80211_NUM_ACS] = { 1, 2, 64, 128 };
int i; int i;
for (i = 0; i < IEEE80211_NUM_ACS; ++i) { for (i = 0; i < IEEE80211_NUM_ACS; ++i) {
skb_queue_head_init(&wvif->tx_queue[i].normal); skb_queue_head_init(&wvif->tx_queue[i].normal);
skb_queue_head_init(&wvif->tx_queue[i].cab); skb_queue_head_init(&wvif->tx_queue[i].cab);
wvif->tx_queue[i].priority = priorities[i];
} }
} }
...@@ -219,6 +224,11 @@ bool wfx_tx_queues_has_cab(struct wfx_vif *wvif) ...@@ -219,6 +224,11 @@ bool wfx_tx_queues_has_cab(struct wfx_vif *wvif)
return false; return false;
} }
static int wfx_tx_queue_get_weight(struct wfx_queue *queue)
{
return atomic_read(&queue->pending_frames) * queue->priority;
}
static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev)
{ {
struct wfx_queue *queues[IEEE80211_NUM_ACS * ARRAY_SIZE(wdev->vif)]; struct wfx_queue *queues[IEEE80211_NUM_ACS * ARRAY_SIZE(wdev->vif)];
...@@ -234,8 +244,8 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) ...@@ -234,8 +244,8 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev)
WARN_ON(num_queues >= ARRAY_SIZE(queues)); WARN_ON(num_queues >= ARRAY_SIZE(queues));
queues[num_queues] = &wvif->tx_queue[i]; queues[num_queues] = &wvif->tx_queue[i];
for (j = num_queues; j > 0; j--) for (j = num_queues; j > 0; j--)
if (atomic_read(&queues[j]->pending_frames) < if (wfx_tx_queue_get_weight(queues[j]) <
atomic_read(&queues[j - 1]->pending_frames)) wfx_tx_queue_get_weight(queues[j - 1]))
swap(queues[j - 1], queues[j]); swap(queues[j - 1], queues[j]);
num_queues++; num_queues++;
} }
......
...@@ -18,6 +18,7 @@ struct wfx_queue { ...@@ -18,6 +18,7 @@ struct wfx_queue {
struct sk_buff_head normal; struct sk_buff_head normal;
struct sk_buff_head cab; // Content After (DTIM) Beacon struct sk_buff_head cab; // Content After (DTIM) Beacon
atomic_t pending_frames; atomic_t pending_frames;
int priority;
}; };
void wfx_tx_lock(struct wfx_dev *wdev); void wfx_tx_lock(struct wfx_dev *wdev);
......
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