Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004, Instant802 Networks, Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
| 8 | |
| 9 | #include <linux/netdevice.h> |
| 10 | #include <linux/skbuff.h> |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/if_arp.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <net/ip.h> |
| 15 | #include <net/pkt_sched.h> |
| 16 | |
| 17 | #include <net/mac80211.h> |
| 18 | #include "ieee80211_i.h" |
| 19 | #include "wme.h" |
| 20 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 21 | /* maximum number of hardware queues we support. */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 22 | #define QD_MAX_QUEUES (IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_QUEUES) |
| 23 | /* current number of hardware queues we support. */ |
| 24 | #define QD_NUM(hw) ((hw)->queues + (hw)->ampdu_queues) |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 25 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 26 | /* |
| 27 | * Default mapping in classifier to work with default |
| 28 | * queue setup. |
| 29 | */ |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 30 | const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 31 | |
| 32 | struct ieee80211_sched_data |
| 33 | { |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 34 | unsigned long qdisc_pool[BITS_TO_LONGS(QD_MAX_QUEUES)]; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 35 | struct tcf_proto *filter_list; |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 36 | struct Qdisc *queues[QD_MAX_QUEUES]; |
| 37 | struct sk_buff_head requeued[QD_MAX_QUEUES]; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
Guy Cohen | a8bdf29 | 2008-01-09 19:12:48 +0200 | [diff] [blame] | 40 | static const char llc_ip_hdr[8] = {0xAA, 0xAA, 0x3, 0, 0, 0, 0x08, 0}; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 41 | |
| 42 | /* given a data frame determine the 802.1p/1d tag to use */ |
| 43 | static inline unsigned classify_1d(struct sk_buff *skb, struct Qdisc *qd) |
| 44 | { |
| 45 | struct iphdr *ip; |
| 46 | int dscp; |
| 47 | int offset; |
| 48 | |
| 49 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
| 50 | struct tcf_result res = { -1, 0 }; |
| 51 | |
| 52 | /* if there is a user set filter list, call out to that */ |
| 53 | if (q->filter_list) { |
| 54 | tc_classify(skb, q->filter_list, &res); |
| 55 | if (res.class != -1) |
| 56 | return res.class; |
| 57 | } |
| 58 | |
| 59 | /* skb->priority values from 256->263 are magic values to |
| 60 | * directly indicate a specific 802.1d priority. |
| 61 | * This is used to allow 802.1d priority to be passed directly in |
| 62 | * from VLAN tags, etc. */ |
| 63 | if (skb->priority >= 256 && skb->priority <= 263) |
| 64 | return skb->priority - 256; |
| 65 | |
| 66 | /* check there is a valid IP header present */ |
Guy Cohen | a8bdf29 | 2008-01-09 19:12:48 +0200 | [diff] [blame] | 67 | offset = ieee80211_get_hdrlen_from_skb(skb); |
| 68 | if (skb->len < offset + sizeof(llc_ip_hdr) + sizeof(*ip) || |
| 69 | memcmp(skb->data + offset, llc_ip_hdr, sizeof(llc_ip_hdr))) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 70 | return 0; |
| 71 | |
Guy Cohen | a8bdf29 | 2008-01-09 19:12:48 +0200 | [diff] [blame] | 72 | ip = (struct iphdr *) (skb->data + offset + sizeof(llc_ip_hdr)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 73 | |
| 74 | dscp = ip->tos & 0xfc; |
| 75 | if (dscp & 0x1c) |
| 76 | return 0; |
| 77 | return dscp >> 5; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | static inline int wme_downgrade_ac(struct sk_buff *skb) |
| 82 | { |
| 83 | switch (skb->priority) { |
| 84 | case 6: |
| 85 | case 7: |
| 86 | skb->priority = 5; /* VO -> VI */ |
| 87 | return 0; |
| 88 | case 4: |
| 89 | case 5: |
| 90 | skb->priority = 3; /* VI -> BE */ |
| 91 | return 0; |
| 92 | case 0: |
| 93 | case 3: |
| 94 | skb->priority = 2; /* BE -> BK */ |
| 95 | return 0; |
| 96 | default: |
| 97 | return -1; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |
| 102 | /* positive return value indicates which queue to use |
| 103 | * negative return value indicates to drop the frame */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 104 | static int classify80211(struct sk_buff *skb, struct Qdisc *qd) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 105 | { |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 106 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 107 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 108 | |
Harvey Harrison | 002aaf4 | 2008-06-11 14:21:59 -0700 | [diff] [blame] | 109 | if (!ieee80211_is_data(hdr->frame_control)) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 110 | /* management frames go on AC_VO queue, but are sent |
| 111 | * without QoS control fields */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 112 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Johannes Berg | f9d540e | 2007-09-28 14:02:09 +0200 | [diff] [blame] | 115 | if (0 /* injected */) { |
| 116 | /* use AC from radiotap */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Harvey Harrison | 002aaf4 | 2008-06-11 14:21:59 -0700 | [diff] [blame] | 119 | if (!ieee80211_is_data_qos(hdr->frame_control)) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 120 | skb->priority = 0; /* required for correct WPA/11i MIC */ |
| 121 | return ieee802_1d_to_ac[skb->priority]; |
| 122 | } |
| 123 | |
| 124 | /* use the data classifier to determine what 802.1d tag the |
Johannes Berg | 3c3b00c | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 125 | * data frame has */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 126 | skb->priority = classify_1d(skb, qd); |
| 127 | |
Johannes Berg | 3c3b00c | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 128 | /* in case we are a client verify acm is not set for this ac */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 129 | while (unlikely(local->wmm_acm & BIT(skb->priority))) { |
| 130 | if (wme_downgrade_ac(skb)) { |
Johannes Berg | 3c3b00c | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 131 | /* No AC with lower priority has acm=0, drop packet. */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 132 | return -1; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /* look up which queue to use for frames with this 1d tag */ |
| 137 | return ieee802_1d_to_ac[skb->priority]; |
| 138 | } |
| 139 | |
| 140 | |
| 141 | static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd) |
| 142 | { |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 143 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 144 | struct ieee80211_hw *hw = &local->hw; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 145 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 146 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 147 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 148 | struct Qdisc *qdisc; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 149 | struct sta_info *sta; |
Johannes Berg | 5c5e128 | 2008-05-03 00:44:09 +0200 | [diff] [blame] | 150 | int err, queue; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 151 | u8 tid; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 152 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 153 | if (info->flags & IEEE80211_TX_CTL_REQUEUE) { |
Johannes Berg | e253008 | 2008-05-17 00:57:14 +0200 | [diff] [blame] | 154 | queue = skb_get_queue_mapping(skb); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 155 | rcu_read_lock(); |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 156 | sta = sta_info_get(local, hdr->addr1); |
Harvey Harrison | 238f74a | 2008-07-02 11:05:34 -0700 | [diff] [blame] | 157 | tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 158 | if (sta) { |
| 159 | int ampdu_queue = sta->tid_to_tx_q[tid]; |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 160 | if ((ampdu_queue < QD_NUM(hw)) && |
Ron Rindjunsky | a9af201 | 2008-01-30 12:58:45 +0200 | [diff] [blame] | 161 | test_bit(ampdu_queue, q->qdisc_pool)) { |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 162 | queue = ampdu_queue; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 163 | info->flags |= IEEE80211_TX_CTL_AMPDU; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 164 | } else { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 165 | info->flags &= ~IEEE80211_TX_CTL_AMPDU; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 166 | } |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 167 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 168 | rcu_read_unlock(); |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 169 | skb_queue_tail(&q->requeued[queue], skb); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 170 | qd->q.qlen++; |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | queue = classify80211(skb, qd); |
| 175 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 176 | if (unlikely(queue >= local->hw.queues)) |
| 177 | queue = local->hw.queues - 1; |
| 178 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 179 | /* now we know the 1d priority, fill in the QoS header if there is one |
| 180 | */ |
Harvey Harrison | 002aaf4 | 2008-06-11 14:21:59 -0700 | [diff] [blame] | 181 | if (ieee80211_is_data_qos(hdr->frame_control)) { |
| 182 | u8 *p = ieee80211_get_qos_ctl(hdr); |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 183 | u8 ack_policy = 0; |
Harvey Harrison | 238f74a | 2008-07-02 11:05:34 -0700 | [diff] [blame] | 184 | tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 185 | if (local->wifi_wme_noack_test) |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 186 | ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK << |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 187 | QOS_CONTROL_ACK_POLICY_SHIFT; |
| 188 | /* qos header is 2 bytes, second reserved */ |
Harvey Harrison | 002aaf4 | 2008-06-11 14:21:59 -0700 | [diff] [blame] | 189 | *p++ = ack_policy | tid; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 190 | *p = 0; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 191 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 192 | rcu_read_lock(); |
| 193 | |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 194 | sta = sta_info_get(local, hdr->addr1); |
| 195 | if (sta) { |
| 196 | int ampdu_queue = sta->tid_to_tx_q[tid]; |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 197 | if ((ampdu_queue < QD_NUM(hw)) && |
| 198 | test_bit(ampdu_queue, q->qdisc_pool)) { |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 199 | queue = ampdu_queue; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 200 | info->flags |= IEEE80211_TX_CTL_AMPDU; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 201 | } else { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 202 | info->flags &= ~IEEE80211_TX_CTL_AMPDU; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 203 | } |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 204 | } |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 205 | |
| 206 | rcu_read_unlock(); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 207 | } |
| 208 | |
Johannes Berg | 5c5e128 | 2008-05-03 00:44:09 +0200 | [diff] [blame] | 209 | if (unlikely(queue < 0)) { |
| 210 | kfree_skb(skb); |
| 211 | err = NET_XMIT_DROP; |
| 212 | } else { |
Johannes Berg | e253008 | 2008-05-17 00:57:14 +0200 | [diff] [blame] | 213 | skb_set_queue_mapping(skb, queue); |
Johannes Berg | 5c5e128 | 2008-05-03 00:44:09 +0200 | [diff] [blame] | 214 | qdisc = q->queues[queue]; |
| 215 | err = qdisc->enqueue(skb, qdisc); |
| 216 | if (err == NET_XMIT_SUCCESS) { |
| 217 | qd->q.qlen++; |
| 218 | qd->bstats.bytes += skb->len; |
| 219 | qd->bstats.packets++; |
| 220 | return NET_XMIT_SUCCESS; |
| 221 | } |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 222 | } |
| 223 | qd->qstats.drops++; |
| 224 | return err; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | /* TODO: clean up the cases where master_hard_start_xmit |
| 229 | * returns non 0 - it shouldn't ever do that. Once done we |
| 230 | * can remove this function */ |
| 231 | static int wme_qdiscop_requeue(struct sk_buff *skb, struct Qdisc* qd) |
| 232 | { |
| 233 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 234 | struct Qdisc *qdisc; |
| 235 | int err; |
| 236 | |
| 237 | /* we recorded which queue to use earlier! */ |
Johannes Berg | e253008 | 2008-05-17 00:57:14 +0200 | [diff] [blame] | 238 | qdisc = q->queues[skb_get_queue_mapping(skb)]; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 239 | |
| 240 | if ((err = qdisc->ops->requeue(skb, qdisc)) == 0) { |
| 241 | qd->q.qlen++; |
| 242 | return 0; |
| 243 | } |
| 244 | qd->qstats.drops++; |
| 245 | return err; |
| 246 | } |
| 247 | |
| 248 | |
| 249 | static struct sk_buff *wme_qdiscop_dequeue(struct Qdisc* qd) |
| 250 | { |
| 251 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 252 | struct net_device *dev = qdisc_dev(qd); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 253 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 254 | struct ieee80211_hw *hw = &local->hw; |
| 255 | struct sk_buff *skb; |
| 256 | struct Qdisc *qdisc; |
| 257 | int queue; |
| 258 | |
| 259 | /* check all the h/w queues in numeric/priority order */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 260 | for (queue = 0; queue < QD_NUM(hw); queue++) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 261 | /* see if there is room in this hardware queue */ |
Johannes Berg | e253008 | 2008-05-17 00:57:14 +0200 | [diff] [blame] | 262 | if (__netif_subqueue_stopped(local->mdev, queue) || |
| 263 | !test_bit(queue, q->qdisc_pool)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 264 | continue; |
| 265 | |
| 266 | /* there is space - try and get a frame */ |
| 267 | skb = skb_dequeue(&q->requeued[queue]); |
| 268 | if (skb) { |
| 269 | qd->q.qlen--; |
| 270 | return skb; |
| 271 | } |
| 272 | |
| 273 | qdisc = q->queues[queue]; |
| 274 | skb = qdisc->dequeue(qdisc); |
| 275 | if (skb) { |
| 276 | qd->q.qlen--; |
| 277 | return skb; |
| 278 | } |
| 279 | } |
| 280 | /* returning a NULL here when all the h/w queues are full means we |
| 281 | * never need to call netif_stop_queue in the driver */ |
| 282 | return NULL; |
| 283 | } |
| 284 | |
| 285 | |
| 286 | static void wme_qdiscop_reset(struct Qdisc* qd) |
| 287 | { |
| 288 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 289 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 290 | struct ieee80211_hw *hw = &local->hw; |
| 291 | int queue; |
| 292 | |
| 293 | /* QUESTION: should we have some hardware flush functionality here? */ |
| 294 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 295 | for (queue = 0; queue < QD_NUM(hw); queue++) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 296 | skb_queue_purge(&q->requeued[queue]); |
| 297 | qdisc_reset(q->queues[queue]); |
| 298 | } |
| 299 | qd->q.qlen = 0; |
| 300 | } |
| 301 | |
| 302 | |
| 303 | static void wme_qdiscop_destroy(struct Qdisc* qd) |
| 304 | { |
| 305 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 306 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 307 | struct ieee80211_hw *hw = &local->hw; |
| 308 | int queue; |
| 309 | |
Patrick McHardy | ff31ab5 | 2008-07-01 19:52:38 -0700 | [diff] [blame] | 310 | tcf_destroy_chain(&q->filter_list); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 311 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 312 | for (queue = 0; queue < QD_NUM(hw); queue++) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 313 | skb_queue_purge(&q->requeued[queue]); |
| 314 | qdisc_destroy(q->queues[queue]); |
| 315 | q->queues[queue] = &noop_qdisc; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | |
| 320 | /* called whenever parameters are updated on existing qdisc */ |
Patrick McHardy | 1e90474 | 2008-01-22 22:11:17 -0800 | [diff] [blame] | 321 | static int wme_qdiscop_tune(struct Qdisc *qd, struct nlattr *opt) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 322 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | /* called during initial creation of qdisc on device */ |
Patrick McHardy | 1e90474 | 2008-01-22 22:11:17 -0800 | [diff] [blame] | 328 | static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 329 | { |
| 330 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 331 | struct net_device *dev = qdisc_dev(qd); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 332 | struct ieee80211_local *local; |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 333 | struct ieee80211_hw *hw; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 334 | int err = 0, i; |
| 335 | |
| 336 | /* check that device is a mac80211 device */ |
| 337 | if (!dev->ieee80211_ptr || |
| 338 | dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid) |
| 339 | return -EINVAL; |
| 340 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 341 | local = wdev_priv(dev->ieee80211_ptr); |
| 342 | hw = &local->hw; |
| 343 | |
| 344 | /* only allow on master dev */ |
| 345 | if (dev != local->mdev) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 346 | return -EINVAL; |
| 347 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 348 | /* ensure that we are root qdisc */ |
| 349 | if (qd->parent != TC_H_ROOT) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 350 | return -EINVAL; |
| 351 | |
| 352 | if (qd->flags & TCQ_F_INGRESS) |
| 353 | return -EINVAL; |
| 354 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 355 | /* if options were passed in, set them */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 356 | if (opt) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 357 | err = wme_qdiscop_tune(qd, opt); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 358 | |
| 359 | /* create child queues */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 360 | for (i = 0; i < QD_NUM(hw); i++) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 361 | skb_queue_head_init(&q->requeued[i]); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 362 | q->queues[i] = qdisc_create_dflt(qdisc_dev(qd), qd->dev_queue, |
David S. Miller | bb949fb | 2008-07-08 16:55:56 -0700 | [diff] [blame] | 363 | &pfifo_qdisc_ops, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 364 | qd->handle); |
Johannes Berg | 136e83d | 2007-09-10 13:55:08 +0200 | [diff] [blame] | 365 | if (!q->queues[i]) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 366 | q->queues[i] = &noop_qdisc; |
Pavel Roskin | a4278e1 | 2008-05-12 09:02:24 -0400 | [diff] [blame] | 367 | printk(KERN_ERR "%s child qdisc %i creation failed\n", |
| 368 | dev->name, i); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 372 | /* non-aggregation queues: reserve/mark as used */ |
| 373 | for (i = 0; i < local->hw.queues; i++) |
Ron Rindjunsky | a9af201 | 2008-01-30 12:58:45 +0200 | [diff] [blame] | 374 | set_bit(i, q->qdisc_pool); |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 375 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 376 | return err; |
| 377 | } |
| 378 | |
| 379 | static int wme_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb) |
| 380 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 381 | return -1; |
| 382 | } |
| 383 | |
| 384 | |
| 385 | static int wme_classop_graft(struct Qdisc *qd, unsigned long arg, |
| 386 | struct Qdisc *new, struct Qdisc **old) |
| 387 | { |
| 388 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 389 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 390 | struct ieee80211_hw *hw = &local->hw; |
| 391 | unsigned long queue = arg - 1; |
| 392 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 393 | if (queue >= QD_NUM(hw)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 394 | return -EINVAL; |
| 395 | |
| 396 | if (!new) |
| 397 | new = &noop_qdisc; |
| 398 | |
| 399 | sch_tree_lock(qd); |
| 400 | *old = q->queues[queue]; |
| 401 | q->queues[queue] = new; |
| 402 | qdisc_reset(*old); |
| 403 | sch_tree_unlock(qd); |
| 404 | |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | |
| 409 | static struct Qdisc * |
| 410 | wme_classop_leaf(struct Qdisc *qd, unsigned long arg) |
| 411 | { |
| 412 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 413 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 414 | struct ieee80211_hw *hw = &local->hw; |
| 415 | unsigned long queue = arg - 1; |
| 416 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 417 | if (queue >= QD_NUM(hw)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 418 | return NULL; |
| 419 | |
| 420 | return q->queues[queue]; |
| 421 | } |
| 422 | |
| 423 | |
| 424 | static unsigned long wme_classop_get(struct Qdisc *qd, u32 classid) |
| 425 | { |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 426 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 427 | struct ieee80211_hw *hw = &local->hw; |
| 428 | unsigned long queue = TC_H_MIN(classid); |
| 429 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 430 | if (queue - 1 >= QD_NUM(hw)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 431 | return 0; |
| 432 | |
| 433 | return queue; |
| 434 | } |
| 435 | |
| 436 | |
| 437 | static unsigned long wme_classop_bind(struct Qdisc *qd, unsigned long parent, |
| 438 | u32 classid) |
| 439 | { |
| 440 | return wme_classop_get(qd, classid); |
| 441 | } |
| 442 | |
| 443 | |
| 444 | static void wme_classop_put(struct Qdisc *q, unsigned long cl) |
| 445 | { |
| 446 | } |
| 447 | |
| 448 | |
| 449 | static int wme_classop_change(struct Qdisc *qd, u32 handle, u32 parent, |
Patrick McHardy | 1e90474 | 2008-01-22 22:11:17 -0800 | [diff] [blame] | 450 | struct nlattr **tca, unsigned long *arg) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 451 | { |
| 452 | unsigned long cl = *arg; |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 453 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 454 | struct ieee80211_hw *hw = &local->hw; |
| 455 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 456 | if (cl - 1 > QD_NUM(hw)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 457 | return -ENOENT; |
| 458 | |
| 459 | /* TODO: put code to program hardware queue parameters here, |
| 460 | * to allow programming from tc command line */ |
| 461 | |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | |
| 466 | /* we don't support deleting hardware queues |
| 467 | * when we add WMM-SA support - TSPECs may be deleted here */ |
| 468 | static int wme_classop_delete(struct Qdisc *qd, unsigned long cl) |
| 469 | { |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 470 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 471 | struct ieee80211_hw *hw = &local->hw; |
| 472 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 473 | if (cl - 1 > QD_NUM(hw)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 474 | return -ENOENT; |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | |
| 479 | static int wme_classop_dump_class(struct Qdisc *qd, unsigned long cl, |
| 480 | struct sk_buff *skb, struct tcmsg *tcm) |
| 481 | { |
| 482 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 483 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 484 | struct ieee80211_hw *hw = &local->hw; |
| 485 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 486 | if (cl - 1 > QD_NUM(hw)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 487 | return -ENOENT; |
| 488 | tcm->tcm_handle = TC_H_MIN(cl); |
| 489 | tcm->tcm_parent = qd->handle; |
| 490 | tcm->tcm_info = q->queues[cl-1]->handle; /* do we need this? */ |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | |
| 495 | static void wme_classop_walk(struct Qdisc *qd, struct qdisc_walker *arg) |
| 496 | { |
David S. Miller | 5ce2d48 | 2008-07-08 17:06:30 -0700 | [diff] [blame] | 497 | struct ieee80211_local *local = wdev_priv(qdisc_dev(qd)->ieee80211_ptr); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 498 | struct ieee80211_hw *hw = &local->hw; |
| 499 | int queue; |
| 500 | |
| 501 | if (arg->stop) |
| 502 | return; |
| 503 | |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 504 | for (queue = 0; queue < QD_NUM(hw); queue++) { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 505 | if (arg->count < arg->skip) { |
| 506 | arg->count++; |
| 507 | continue; |
| 508 | } |
| 509 | /* we should return classids for our internal queues here |
| 510 | * as well as the external ones */ |
| 511 | if (arg->fn(qd, queue+1, arg) < 0) { |
| 512 | arg->stop = 1; |
| 513 | break; |
| 514 | } |
| 515 | arg->count++; |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | |
| 520 | static struct tcf_proto ** wme_classop_find_tcf(struct Qdisc *qd, |
| 521 | unsigned long cl) |
| 522 | { |
| 523 | struct ieee80211_sched_data *q = qdisc_priv(qd); |
| 524 | |
| 525 | if (cl) |
| 526 | return NULL; |
| 527 | |
| 528 | return &q->filter_list; |
| 529 | } |
| 530 | |
| 531 | |
| 532 | /* this qdisc is classful (i.e. has classes, some of which may have leaf qdiscs attached) |
| 533 | * - these are the operations on the classes */ |
Eric Dumazet | 20fea08 | 2007-11-14 01:44:41 -0800 | [diff] [blame] | 534 | static const struct Qdisc_class_ops class_ops = |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 535 | { |
| 536 | .graft = wme_classop_graft, |
| 537 | .leaf = wme_classop_leaf, |
| 538 | |
| 539 | .get = wme_classop_get, |
| 540 | .put = wme_classop_put, |
| 541 | .change = wme_classop_change, |
| 542 | .delete = wme_classop_delete, |
| 543 | .walk = wme_classop_walk, |
| 544 | |
| 545 | .tcf_chain = wme_classop_find_tcf, |
| 546 | .bind_tcf = wme_classop_bind, |
| 547 | .unbind_tcf = wme_classop_put, |
| 548 | |
| 549 | .dump = wme_classop_dump_class, |
| 550 | }; |
| 551 | |
| 552 | |
| 553 | /* queueing discipline operations */ |
Eric Dumazet | 20fea08 | 2007-11-14 01:44:41 -0800 | [diff] [blame] | 554 | static struct Qdisc_ops wme_qdisc_ops __read_mostly = |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 555 | { |
| 556 | .next = NULL, |
| 557 | .cl_ops = &class_ops, |
| 558 | .id = "ieee80211", |
| 559 | .priv_size = sizeof(struct ieee80211_sched_data), |
| 560 | |
| 561 | .enqueue = wme_qdiscop_enqueue, |
| 562 | .dequeue = wme_qdiscop_dequeue, |
| 563 | .requeue = wme_qdiscop_requeue, |
| 564 | .drop = NULL, /* drop not needed since we are always the root qdisc */ |
| 565 | |
| 566 | .init = wme_qdiscop_init, |
| 567 | .reset = wme_qdiscop_reset, |
| 568 | .destroy = wme_qdiscop_destroy, |
| 569 | .change = wme_qdiscop_tune, |
| 570 | |
| 571 | .dump = wme_qdiscop_dump, |
| 572 | }; |
| 573 | |
| 574 | |
| 575 | void ieee80211_install_qdisc(struct net_device *dev) |
| 576 | { |
| 577 | struct Qdisc *qdisc; |
| 578 | |
David S. Miller | bb949fb | 2008-07-08 16:55:56 -0700 | [diff] [blame] | 579 | qdisc = qdisc_create_dflt(dev, &dev->tx_queue, |
| 580 | &wme_qdisc_ops, TC_H_ROOT); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 581 | if (!qdisc) { |
| 582 | printk(KERN_ERR "%s: qdisc installation failed\n", dev->name); |
| 583 | return; |
| 584 | } |
| 585 | |
| 586 | /* same handle as would be allocated by qdisc_alloc_handle() */ |
| 587 | qdisc->handle = 0x80010000; |
| 588 | |
| 589 | qdisc_lock_tree(dev); |
| 590 | list_add_tail(&qdisc->list, &dev->qdisc_list); |
| 591 | dev->qdisc_sleeping = qdisc; |
| 592 | qdisc_unlock_tree(dev); |
| 593 | } |
| 594 | |
| 595 | |
| 596 | int ieee80211_qdisc_installed(struct net_device *dev) |
| 597 | { |
| 598 | return dev->qdisc_sleeping->ops == &wme_qdisc_ops; |
| 599 | } |
| 600 | |
| 601 | |
| 602 | int ieee80211_wme_register(void) |
| 603 | { |
| 604 | return register_qdisc(&wme_qdisc_ops); |
| 605 | } |
| 606 | |
| 607 | |
| 608 | void ieee80211_wme_unregister(void) |
| 609 | { |
| 610 | unregister_qdisc(&wme_qdisc_ops); |
| 611 | } |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 612 | |
| 613 | int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, |
| 614 | struct sta_info *sta, u16 tid) |
| 615 | { |
| 616 | int i; |
| 617 | struct ieee80211_sched_data *q = |
| 618 | qdisc_priv(local->mdev->qdisc_sleeping); |
| 619 | DECLARE_MAC_BUF(mac); |
| 620 | |
| 621 | /* prepare the filter and save it for the SW queue |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 622 | * matching the received HW queue */ |
| 623 | |
| 624 | if (!local->hw.ampdu_queues) |
| 625 | return -EPERM; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 626 | |
| 627 | /* try to get a Qdisc from the pool */ |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 628 | for (i = local->hw.queues; i < QD_NUM(&local->hw); i++) |
Ron Rindjunsky | a9af201 | 2008-01-30 12:58:45 +0200 | [diff] [blame] | 629 | if (!test_and_set_bit(i, q->qdisc_pool)) { |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 630 | ieee80211_stop_queue(local_to_hw(local), i); |
| 631 | sta->tid_to_tx_q[tid] = i; |
| 632 | |
| 633 | /* IF there are already pending packets |
| 634 | * on this tid first we need to drain them |
| 635 | * on the previous queue |
| 636 | * since HT is strict in order */ |
| 637 | #ifdef CONFIG_MAC80211_HT_DEBUG |
| 638 | if (net_ratelimit()) |
| 639 | printk(KERN_DEBUG "allocated aggregation queue" |
Tomas Winkler | 995ad6c | 2008-06-12 20:08:19 +0300 | [diff] [blame] | 640 | " %d tid %d addr %s pool=0x%lX\n", |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 641 | i, tid, print_mac(mac, sta->addr), |
Ron Rindjunsky | a9af201 | 2008-01-30 12:58:45 +0200 | [diff] [blame] | 642 | q->qdisc_pool[0]); |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 643 | #endif /* CONFIG_MAC80211_HT_DEBUG */ |
| 644 | return 0; |
| 645 | } |
| 646 | |
| 647 | return -EAGAIN; |
| 648 | } |
| 649 | |
| 650 | /** |
David S. Miller | dc2b484 | 2008-07-08 17:18:23 -0700 | [diff] [blame] | 651 | * the caller needs to hold local->mdev->tx_queue.lock |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 652 | */ |
| 653 | void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, |
| 654 | struct sta_info *sta, u16 tid, |
| 655 | u8 requeue) |
| 656 | { |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 657 | struct ieee80211_hw *hw = &local->hw; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 658 | struct ieee80211_sched_data *q = |
| 659 | qdisc_priv(local->mdev->qdisc_sleeping); |
| 660 | int agg_queue = sta->tid_to_tx_q[tid]; |
| 661 | |
| 662 | /* return the qdisc to the pool */ |
Ron Rindjunsky | a9af201 | 2008-01-30 12:58:45 +0200 | [diff] [blame] | 663 | clear_bit(agg_queue, q->qdisc_pool); |
Johannes Berg | e100bb6 | 2008-04-30 18:51:21 +0200 | [diff] [blame] | 664 | sta->tid_to_tx_q[tid] = QD_NUM(hw); |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 665 | |
| 666 | if (requeue) |
| 667 | ieee80211_requeue(local, agg_queue); |
| 668 | else |
| 669 | q->queues[agg_queue]->ops->reset(q->queues[agg_queue]); |
| 670 | } |
| 671 | |
| 672 | void ieee80211_requeue(struct ieee80211_local *local, int queue) |
| 673 | { |
| 674 | struct Qdisc *root_qd = local->mdev->qdisc_sleeping; |
| 675 | struct ieee80211_sched_data *q = qdisc_priv(root_qd); |
| 676 | struct Qdisc *qdisc = q->queues[queue]; |
| 677 | struct sk_buff *skb = NULL; |
Ron Rindjunsky | 0da926f | 2008-04-23 13:45:12 +0300 | [diff] [blame] | 678 | u32 len; |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 679 | |
| 680 | if (!qdisc || !qdisc->dequeue) |
| 681 | return; |
| 682 | |
Ron Rindjunsky | 9e72349 | 2008-01-28 14:07:18 +0200 | [diff] [blame] | 683 | for (len = qdisc->q.qlen; len > 0; len--) { |
| 684 | skb = qdisc->dequeue(qdisc); |
| 685 | root_qd->q.qlen--; |
| 686 | /* packet will be classified again and */ |
| 687 | /* skb->packet_data->queue will be overridden if needed */ |
| 688 | if (skb) |
| 689 | wme_qdiscop_enqueue(skb, root_qd); |
| 690 | } |
| 691 | } |