2007-05-05 12:45:53 -06:00
|
|
|
/*
|
|
|
|
* Copyright 2004, Instant802 Networks, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <net/ip.h>
|
|
|
|
#include <net/pkt_sched.h>
|
|
|
|
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
#include "ieee80211_i.h"
|
|
|
|
#include "wme.h"
|
|
|
|
|
2008-07-15 04:34:57 -06:00
|
|
|
/* Default mapping in classifier to work with default
|
2008-04-30 10:51:21 -06:00
|
|
|
* queue setup.
|
|
|
|
*/
|
2008-01-28 05:07:18 -07:00
|
|
|
const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2008-07-15 04:34:57 -06:00
|
|
|
static int wme_downgrade_ac(struct sk_buff *skb)
|
2007-05-05 12:45:53 -06:00
|
|
|
{
|
|
|
|
switch (skb->priority) {
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
skb->priority = 5; /* VO -> VI */
|
|
|
|
return 0;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
skb->priority = 3; /* VI -> BE */
|
|
|
|
return 0;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
skb->priority = 2; /* BE -> BK */
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-15 04:34:57 -06:00
|
|
|
/* Indicate which queue to use. */
|
2008-09-26 05:34:54 -06:00
|
|
|
static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
|
2007-05-05 12:45:53 -06:00
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
|
|
|
|
2008-06-11 15:21:59 -06:00
|
|
|
if (!ieee80211_is_data(hdr->frame_control)) {
|
2007-05-05 12:45:53 -06:00
|
|
|
/* management frames go on AC_VO queue, but are sent
|
|
|
|
* without QoS control fields */
|
2008-04-30 10:51:21 -06:00
|
|
|
return 0;
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
|
|
|
|
2007-09-28 06:02:09 -06:00
|
|
|
if (0 /* injected */) {
|
|
|
|
/* use AC from radiotap */
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
|
|
|
|
2008-06-11 15:21:59 -06:00
|
|
|
if (!ieee80211_is_data_qos(hdr->frame_control)) {
|
2007-05-05 12:45:53 -06:00
|
|
|
skb->priority = 0; /* required for correct WPA/11i MIC */
|
|
|
|
return ieee802_1d_to_ac[skb->priority];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* use the data classifier to determine what 802.1d tag the
|
2007-08-28 15:01:55 -06:00
|
|
|
* data frame has */
|
2009-05-21 07:47:03 -06:00
|
|
|
skb->priority = cfg80211_classify8021d(skb);
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2007-08-28 15:01:55 -06:00
|
|
|
/* in case we are a client verify acm is not set for this ac */
|
2007-05-05 12:45:53 -06:00
|
|
|
while (unlikely(local->wmm_acm & BIT(skb->priority))) {
|
|
|
|
if (wme_downgrade_ac(skb)) {
|
2009-03-05 08:23:46 -07:00
|
|
|
/*
|
|
|
|
* This should not really happen. The AP has marked all
|
|
|
|
* lower ACs to require admission control which is not
|
|
|
|
* a reasonable configuration. Allow the frame to be
|
|
|
|
* transmitted using AC_BK as a workaround.
|
2008-07-15 04:34:57 -06:00
|
|
|
*/
|
2009-03-05 08:23:46 -07:00
|
|
|
break;
|
2007-05-05 12:45:53 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* look up which queue to use for frames with this 1d tag */
|
|
|
|
return ieee802_1d_to_ac[skb->priority];
|
|
|
|
}
|
|
|
|
|
2008-07-15 04:34:57 -06:00
|
|
|
u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb)
|
2007-05-05 12:45:53 -06:00
|
|
|
{
|
2008-09-26 05:34:54 -06:00
|
|
|
struct ieee80211_master_priv *mpriv = netdev_priv(dev);
|
|
|
|
struct ieee80211_local *local = mpriv->local;
|
2007-05-05 12:45:53 -06:00
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
2008-07-15 04:34:57 -06:00
|
|
|
u16 queue;
|
2008-01-28 05:07:18 -07:00
|
|
|
u8 tid;
|
2007-05-05 12:45:53 -06:00
|
|
|
|
2008-09-26 05:34:54 -06:00
|
|
|
queue = classify80211(local, skb);
|
2008-07-15 04:34:57 -06:00
|
|
|
if (unlikely(queue >= local->hw.queues))
|
|
|
|
queue = local->hw.queues - 1;
|
|
|
|
|
mac80211: fix aggregation for hardware with ampdu queues
Hardware with AMPDU queues currently has broken aggregation.
This patch fixes it by making all A-MPDUs go over the regular AC queues,
but keeping track of the hardware queues in mac80211. As a first rough
version, it actually stops the AC queue for extended periods of time,
which can be removed by adding buffering internal to mac80211, but is
currently not a huge problem because people rarely use multiple TIDs
that are in the same AC (and iwlwifi currently doesn't operate as AP).
This is a short-term fix, my current medium-term plan, which I hope to
execute soon as well, but am not sure can finish before .30, looks like
this:
1) rework the internal queuing layer in mac80211 that we use for
fragments if the driver stopped queue in the middle of a fragmented
frame to be able to queue more frames at once (rather than just a
single frame with its fragments)
2) instead of stopping the entire AC queue, queue up the frames in a
per-station/per-TID queue during aggregation session initiation,
when the session has come up take all those frames and put them
onto the queue from 1)
3) push the ampdu queue layer abstraction this patch introduces in
mac80211 into the driver, and remove the virtual queue stuff from
mac80211 again
This plan will probably also affect ath9k in that mac80211 queues the
frames instead of passing them down, even when there are no ampdu queues.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-02-11 16:51:53 -07:00
|
|
|
/*
|
|
|
|
* Now we know the 1d priority, fill in the QoS header if
|
|
|
|
* there is one (and we haven't done this before).
|
2007-05-05 12:45:53 -06:00
|
|
|
*/
|
2009-06-07 13:58:37 -06:00
|
|
|
if (ieee80211_is_data_qos(hdr->frame_control)) {
|
2008-06-11 15:21:59 -06:00
|
|
|
u8 *p = ieee80211_get_qos_ctl(hdr);
|
2008-01-28 05:07:18 -07:00
|
|
|
u8 ack_policy = 0;
|
2008-07-02 12:05:34 -06:00
|
|
|
tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
|
2009-05-12 14:05:40 -06:00
|
|
|
if (unlikely(local->wifi_wme_noack_test))
|
2008-01-28 05:07:18 -07:00
|
|
|
ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK <<
|
2007-05-05 12:45:53 -06:00
|
|
|
QOS_CONTROL_ACK_POLICY_SHIFT;
|
|
|
|
/* qos header is 2 bytes, second reserved */
|
2008-06-11 15:21:59 -06:00
|
|
|
*p++ = ack_policy | tid;
|
2007-05-05 12:45:53 -06:00
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return queue;
|
|
|
|
}
|