2007-05-06 02:45:53 +08: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 18:34:57 +08:00
|
|
|
/* Default mapping in classifier to work with default
|
2008-05-01 00:51:21 +08:00
|
|
|
* queue setup.
|
|
|
|
*/
|
2008-01-28 20:07:18 +08:00
|
|
|
const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-01-10 01:12:48 +08:00
|
|
|
static const char llc_ip_hdr[8] = {0xAA, 0xAA, 0x3, 0, 0, 0, 0x08, 0};
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-07-15 18:34:57 +08:00
|
|
|
/* Given a data frame determine the 802.1p/1d tag to use. */
|
|
|
|
static unsigned int classify_1d(struct sk_buff *skb)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2008-07-15 18:34:57 +08:00
|
|
|
unsigned int dscp;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
/* skb->priority values from 256->263 are magic values to
|
2008-07-15 18:34:57 +08:00
|
|
|
* directly indicate a specific 802.1d priority. This is used
|
|
|
|
* to allow 802.1d priority to be passed directly in from VLAN
|
|
|
|
* tags, etc.
|
|
|
|
*/
|
2007-05-06 02:45:53 +08:00
|
|
|
if (skb->priority >= 256 && skb->priority <= 263)
|
|
|
|
return skb->priority - 256;
|
|
|
|
|
2008-07-15 18:34:57 +08:00
|
|
|
switch (skb->protocol) {
|
2008-09-21 13:20:49 +08:00
|
|
|
case htons(ETH_P_IP):
|
2008-07-15 18:34:57 +08:00
|
|
|
dscp = ip_hdr(skb)->tos & 0xfc;
|
|
|
|
break;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-07-15 18:34:57 +08:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
return dscp >> 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-15 18:34:57 +08:00
|
|
|
static int wme_downgrade_ac(struct sk_buff *skb)
|
2007-05-06 02:45:53 +08: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 18:34:57 +08:00
|
|
|
/* Indicate which queue to use. */
|
2008-09-26 19:34:54 +08:00
|
|
|
static u16 classify80211(struct ieee80211_local *local, struct sk_buff *skb)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
|
|
|
|
2008-06-12 05:21:59 +08:00
|
|
|
if (!ieee80211_is_data(hdr->frame_control)) {
|
2007-05-06 02:45:53 +08:00
|
|
|
/* management frames go on AC_VO queue, but are sent
|
|
|
|
* without QoS control fields */
|
2008-05-01 00:51:21 +08:00
|
|
|
return 0;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2007-09-28 20:02:09 +08:00
|
|
|
if (0 /* injected */) {
|
|
|
|
/* use AC from radiotap */
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2008-06-12 05:21:59 +08:00
|
|
|
if (!ieee80211_is_data_qos(hdr->frame_control)) {
|
2007-05-06 02:45:53 +08: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-29 05:01:55 +08:00
|
|
|
* data frame has */
|
2008-07-15 18:34:57 +08:00
|
|
|
skb->priority = classify_1d(skb);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2007-08-29 05:01:55 +08:00
|
|
|
/* in case we are a client verify acm is not set for this ac */
|
2007-05-06 02:45:53 +08:00
|
|
|
while (unlikely(local->wmm_acm & BIT(skb->priority))) {
|
|
|
|
if (wme_downgrade_ac(skb)) {
|
2008-07-15 18:34:57 +08:00
|
|
|
/* The old code would drop the packet in this
|
|
|
|
* case.
|
|
|
|
*/
|
|
|
|
return 0;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* look up which queue to use for frames with this 1d tag */
|
|
|
|
return ieee802_1d_to_ac[skb->priority];
|
|
|
|
}
|
|
|
|
|
2008-07-15 18:34:57 +08:00
|
|
|
u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2008-09-26 19:34:54 +08:00
|
|
|
struct ieee80211_master_priv *mpriv = netdev_priv(dev);
|
|
|
|
struct ieee80211_local *local = mpriv->local;
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
2008-07-15 18:34:57 +08:00
|
|
|
u16 queue;
|
2008-01-28 20:07:18 +08:00
|
|
|
u8 tid;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-26 19:34:54 +08:00
|
|
|
queue = classify80211(local, skb);
|
2008-07-15 18:34:57 +08: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-12 07:51:53 +08: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-06 02:45:53 +08:00
|
|
|
*/
|
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-12 07:51:53 +08:00
|
|
|
if (!skb->requeue && ieee80211_is_data_qos(hdr->frame_control)) {
|
2008-06-12 05:21:59 +08:00
|
|
|
u8 *p = ieee80211_get_qos_ctl(hdr);
|
2008-01-28 20:07:18 +08:00
|
|
|
u8 ack_policy = 0;
|
2008-07-03 02:05:34 +08:00
|
|
|
tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
|
2007-05-06 02:45:53 +08:00
|
|
|
if (local->wifi_wme_noack_test)
|
2008-01-28 20:07:18 +08:00
|
|
|
ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK <<
|
2007-05-06 02:45:53 +08:00
|
|
|
QOS_CONTROL_ACK_POLICY_SHIFT;
|
|
|
|
/* qos header is 2 bytes, second reserved */
|
2008-06-12 05:21:59 +08:00
|
|
|
*p++ = ack_policy | tid;
|
2007-05-06 02:45:53 +08:00
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return queue;
|
|
|
|
}
|