wme.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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. #include <linux/netdevice.h>
  9. #include <linux/skbuff.h>
  10. #include <linux/module.h>
  11. #include <linux/if_arp.h>
  12. #include <linux/types.h>
  13. #include <net/ip.h>
  14. #include <net/pkt_sched.h>
  15. #include <net/mac80211.h>
  16. #include "ieee80211_i.h"
  17. #include "wme.h"
  18. static inline int WLAN_FC_IS_QOS_DATA(u16 fc)
  19. {
  20. return (fc & 0x8C) == 0x88;
  21. }
  22. ieee80211_txrx_result
  23. ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx)
  24. {
  25. u8 *data = rx->skb->data;
  26. int tid;
  27. /* does the frame have a qos control field? */
  28. if (WLAN_FC_IS_QOS_DATA(rx->fc)) {
  29. u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN;
  30. /* frame has qos control */
  31. tid = qc[0] & QOS_CONTROL_TID_MASK;
  32. } else {
  33. if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) {
  34. /* Separate TID for management frames */
  35. tid = NUM_RX_DATA_QUEUES - 1;
  36. } else {
  37. /* no qos control present */
  38. tid = 0; /* 802.1d - Best Effort */
  39. }
  40. }
  41. #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
  42. I802_DEBUG_INC(rx->local->wme_rx_queue[tid]);
  43. if (rx->sta) {
  44. I802_DEBUG_INC(rx->sta->wme_rx_queue[tid]);
  45. }
  46. #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
  47. rx->u.rx.queue = tid;
  48. /* Set skb->priority to 1d tag if highest order bit of TID is not set.
  49. * For now, set skb->priority to 0 for other cases. */
  50. rx->skb->priority = (tid > 7) ? 0 : tid;
  51. return TXRX_CONTINUE;
  52. }
  53. ieee80211_txrx_result
  54. ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx)
  55. {
  56. u16 fc = rx->fc;
  57. u8 *data = rx->skb->data;
  58. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data;
  59. if (!WLAN_FC_IS_QOS_DATA(fc))
  60. return TXRX_CONTINUE;
  61. /* remove the qos control field, update frame type and meta-data */
  62. memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2);
  63. hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2);
  64. /* change frame type to non QOS */
  65. rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA;
  66. hdr->frame_control = cpu_to_le16(fc);
  67. return TXRX_CONTINUE;
  68. }
  69. #ifdef CONFIG_NET_SCHED
  70. /* maximum number of hardware queues we support. */
  71. #define TC_80211_MAX_QUEUES 8
  72. struct ieee80211_sched_data
  73. {
  74. struct tcf_proto *filter_list;
  75. struct Qdisc *queues[TC_80211_MAX_QUEUES];
  76. struct sk_buff_head requeued[TC_80211_MAX_QUEUES];
  77. };
  78. /* given a data frame determine the 802.1p/1d tag to use */
  79. static inline unsigned classify_1d(struct sk_buff *skb, struct Qdisc *qd)
  80. {
  81. struct iphdr *ip;
  82. int dscp;
  83. int offset;
  84. struct ieee80211_sched_data *q = qdisc_priv(qd);
  85. struct tcf_result res = { -1, 0 };
  86. /* if there is a user set filter list, call out to that */
  87. if (q->filter_list) {
  88. tc_classify(skb, q->filter_list, &res);
  89. if (res.class != -1)
  90. return res.class;
  91. }
  92. /* skb->priority values from 256->263 are magic values to
  93. * directly indicate a specific 802.1d priority.
  94. * This is used to allow 802.1d priority to be passed directly in
  95. * from VLAN tags, etc. */
  96. if (skb->priority >= 256 && skb->priority <= 263)
  97. return skb->priority - 256;
  98. /* check there is a valid IP header present */
  99. offset = ieee80211_get_hdrlen_from_skb(skb) + 8 /* LLC + proto */;
  100. if (skb->protocol != __constant_htons(ETH_P_IP) ||
  101. skb->len < offset + sizeof(*ip))
  102. return 0;
  103. ip = (struct iphdr *) (skb->data + offset);
  104. dscp = ip->tos & 0xfc;
  105. if (dscp & 0x1c)
  106. return 0;
  107. return dscp >> 5;
  108. }
  109. static inline int wme_downgrade_ac(struct sk_buff *skb)
  110. {
  111. switch (skb->priority) {
  112. case 6:
  113. case 7:
  114. skb->priority = 5; /* VO -> VI */
  115. return 0;
  116. case 4:
  117. case 5:
  118. skb->priority = 3; /* VI -> BE */
  119. return 0;
  120. case 0:
  121. case 3:
  122. skb->priority = 2; /* BE -> BK */
  123. return 0;
  124. default:
  125. return -1;
  126. }
  127. }
  128. /* positive return value indicates which queue to use
  129. * negative return value indicates to drop the frame */
  130. static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
  131. {
  132. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  133. struct ieee80211_tx_packet_data *pkt_data =
  134. (struct ieee80211_tx_packet_data *) skb->cb;
  135. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  136. unsigned short fc = le16_to_cpu(hdr->frame_control);
  137. int qos;
  138. const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
  139. /* see if frame is data or non data frame */
  140. if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)) {
  141. /* management frames go on AC_VO queue, but are sent
  142. * without QoS control fields */
  143. return IEEE80211_TX_QUEUE_DATA0;
  144. }
  145. if (unlikely(pkt_data->mgmt_iface)) {
  146. /* Data frames from hostapd (mainly, EAPOL) use AC_VO
  147. * and they will include QoS control fields if
  148. * the target STA is using WME. */
  149. skb->priority = 7;
  150. return ieee802_1d_to_ac[skb->priority];
  151. }
  152. /* is this a QoS frame? */
  153. qos = fc & IEEE80211_STYPE_QOS_DATA;
  154. if (!qos) {
  155. skb->priority = 0; /* required for correct WPA/11i MIC */
  156. return ieee802_1d_to_ac[skb->priority];
  157. }
  158. /* use the data classifier to determine what 802.1d tag the
  159. * data frame has */
  160. skb->priority = classify_1d(skb, qd);
  161. /* incase we are a client verify acm is not set for this ac */
  162. while (unlikely(local->wmm_acm & BIT(skb->priority))) {
  163. if (wme_downgrade_ac(skb)) {
  164. /* No AC with lower priority has acm=0,
  165. * drop packet. */
  166. return -1;
  167. }
  168. }
  169. /* look up which queue to use for frames with this 1d tag */
  170. return ieee802_1d_to_ac[skb->priority];
  171. }
  172. static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
  173. {
  174. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  175. struct ieee80211_sched_data *q = qdisc_priv(qd);
  176. struct ieee80211_tx_packet_data *pkt_data =
  177. (struct ieee80211_tx_packet_data *) skb->cb;
  178. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  179. unsigned short fc = le16_to_cpu(hdr->frame_control);
  180. struct Qdisc *qdisc;
  181. int err, queue;
  182. if (pkt_data->requeue) {
  183. skb_queue_tail(&q->requeued[pkt_data->queue], skb);
  184. qd->q.qlen++;
  185. return 0;
  186. }
  187. queue = classify80211(skb, qd);
  188. /* now we know the 1d priority, fill in the QoS header if there is one
  189. */
  190. if (WLAN_FC_IS_QOS_DATA(fc)) {
  191. u8 *p = skb->data + ieee80211_get_hdrlen(fc) - 2;
  192. u8 qos_hdr = skb->priority & QOS_CONTROL_TAG1D_MASK;
  193. if (local->wifi_wme_noack_test)
  194. qos_hdr |= QOS_CONTROL_ACK_POLICY_NOACK <<
  195. QOS_CONTROL_ACK_POLICY_SHIFT;
  196. /* qos header is 2 bytes, second reserved */
  197. *p = qos_hdr;
  198. p++;
  199. *p = 0;
  200. }
  201. if (unlikely(queue >= local->hw.queues)) {
  202. #if 0
  203. if (net_ratelimit()) {
  204. printk(KERN_DEBUG "%s - queue=%d (hw does not "
  205. "support) -> %d\n",
  206. __func__, queue, local->hw.queues - 1);
  207. }
  208. #endif
  209. queue = local->hw.queues - 1;
  210. }
  211. if (unlikely(queue < 0)) {
  212. kfree_skb(skb);
  213. err = NET_XMIT_DROP;
  214. } else {
  215. pkt_data->queue = (unsigned int) queue;
  216. qdisc = q->queues[queue];
  217. err = qdisc->enqueue(skb, qdisc);
  218. if (err == NET_XMIT_SUCCESS) {
  219. qd->q.qlen++;
  220. qd->bstats.bytes += skb->len;
  221. qd->bstats.packets++;
  222. return NET_XMIT_SUCCESS;
  223. }
  224. }
  225. qd->qstats.drops++;
  226. return err;
  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);
  234. struct ieee80211_tx_packet_data *pkt_data =
  235. (struct ieee80211_tx_packet_data *) skb->cb;
  236. struct Qdisc *qdisc;
  237. int err;
  238. /* we recorded which queue to use earlier! */
  239. qdisc = q->queues[pkt_data->queue];
  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. static struct sk_buff *wme_qdiscop_dequeue(struct Qdisc* qd)
  248. {
  249. struct ieee80211_sched_data *q = qdisc_priv(qd);
  250. struct net_device *dev = qd->dev;
  251. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  252. struct ieee80211_hw *hw = &local->hw;
  253. struct sk_buff *skb;
  254. struct Qdisc *qdisc;
  255. int queue;
  256. /* check all the h/w queues in numeric/priority order */
  257. for (queue = 0; queue < hw->queues; queue++) {
  258. /* see if there is room in this hardware queue */
  259. if (test_bit(IEEE80211_LINK_STATE_XOFF,
  260. &local->state[queue]) ||
  261. test_bit(IEEE80211_LINK_STATE_PENDING,
  262. &local->state[queue]))
  263. continue;
  264. /* there is space - try and get a frame */
  265. skb = skb_dequeue(&q->requeued[queue]);
  266. if (skb) {
  267. qd->q.qlen--;
  268. return skb;
  269. }
  270. qdisc = q->queues[queue];
  271. skb = qdisc->dequeue(qdisc);
  272. if (skb) {
  273. qd->q.qlen--;
  274. return skb;
  275. }
  276. }
  277. /* returning a NULL here when all the h/w queues are full means we
  278. * never need to call netif_stop_queue in the driver */
  279. return NULL;
  280. }
  281. static void wme_qdiscop_reset(struct Qdisc* qd)
  282. {
  283. struct ieee80211_sched_data *q = qdisc_priv(qd);
  284. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  285. struct ieee80211_hw *hw = &local->hw;
  286. int queue;
  287. /* QUESTION: should we have some hardware flush functionality here? */
  288. for (queue = 0; queue < hw->queues; queue++) {
  289. skb_queue_purge(&q->requeued[queue]);
  290. qdisc_reset(q->queues[queue]);
  291. }
  292. qd->q.qlen = 0;
  293. }
  294. static void wme_qdiscop_destroy(struct Qdisc* qd)
  295. {
  296. struct ieee80211_sched_data *q = qdisc_priv(qd);
  297. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  298. struct ieee80211_hw *hw = &local->hw;
  299. int queue;
  300. tcf_destroy_chain(q->filter_list);
  301. q->filter_list = NULL;
  302. for (queue=0; queue < hw->queues; queue++) {
  303. skb_queue_purge(&q->requeued[queue]);
  304. qdisc_destroy(q->queues[queue]);
  305. q->queues[queue] = &noop_qdisc;
  306. }
  307. }
  308. /* called whenever parameters are updated on existing qdisc */
  309. static int wme_qdiscop_tune(struct Qdisc *qd, struct rtattr *opt)
  310. {
  311. /* struct ieee80211_sched_data *q = qdisc_priv(qd);
  312. */
  313. /* check our options block is the right size */
  314. /* copy any options to our local structure */
  315. /* Ignore options block for now - always use static mapping
  316. struct tc_ieee80211_qopt *qopt = RTA_DATA(opt);
  317. if (opt->rta_len < RTA_LENGTH(sizeof(*qopt)))
  318. return -EINVAL;
  319. memcpy(q->tag2queue, qopt->tag2queue, sizeof(qopt->tag2queue));
  320. */
  321. return 0;
  322. }
  323. /* called during initial creation of qdisc on device */
  324. static int wme_qdiscop_init(struct Qdisc *qd, struct rtattr *opt)
  325. {
  326. struct ieee80211_sched_data *q = qdisc_priv(qd);
  327. struct net_device *dev = qd->dev;
  328. struct ieee80211_local *local;
  329. int queues;
  330. int err = 0, i;
  331. /* check that device is a mac80211 device */
  332. if (!dev->ieee80211_ptr ||
  333. dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
  334. return -EINVAL;
  335. /* check this device is an ieee80211 master type device */
  336. if (dev->type != ARPHRD_IEEE80211)
  337. return -EINVAL;
  338. /* check that there is no qdisc currently attached to device
  339. * this ensures that we will be the root qdisc. (I can't find a better
  340. * way to test this explicitly) */
  341. if (dev->qdisc_sleeping != &noop_qdisc)
  342. return -EINVAL;
  343. if (qd->flags & TCQ_F_INGRESS)
  344. return -EINVAL;
  345. local = wdev_priv(dev->ieee80211_ptr);
  346. queues = local->hw.queues;
  347. /* if options were passed in, set them */
  348. if (opt) {
  349. err = wme_qdiscop_tune(qd, opt);
  350. }
  351. /* create child queues */
  352. for (i = 0; i < queues; i++) {
  353. skb_queue_head_init(&q->requeued[i]);
  354. q->queues[i] = qdisc_create_dflt(qd->dev, &pfifo_qdisc_ops,
  355. qd->handle);
  356. if (q->queues[i] == 0) {
  357. q->queues[i] = &noop_qdisc;
  358. printk(KERN_ERR "%s child qdisc %i creation failed", dev->name, i);
  359. }
  360. }
  361. return err;
  362. }
  363. static int wme_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb)
  364. {
  365. /* struct ieee80211_sched_data *q = qdisc_priv(qd);
  366. unsigned char *p = skb->tail;
  367. struct tc_ieee80211_qopt opt;
  368. memcpy(&opt.tag2queue, q->tag2queue, TC_80211_MAX_TAG + 1);
  369. RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
  370. */ return skb->len;
  371. /*
  372. rtattr_failure:
  373. skb_trim(skb, p - skb->data);*/
  374. return -1;
  375. }
  376. static int wme_classop_graft(struct Qdisc *qd, unsigned long arg,
  377. struct Qdisc *new, struct Qdisc **old)
  378. {
  379. struct ieee80211_sched_data *q = qdisc_priv(qd);
  380. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  381. struct ieee80211_hw *hw = &local->hw;
  382. unsigned long queue = arg - 1;
  383. if (queue >= hw->queues)
  384. return -EINVAL;
  385. if (!new)
  386. new = &noop_qdisc;
  387. sch_tree_lock(qd);
  388. *old = q->queues[queue];
  389. q->queues[queue] = new;
  390. qdisc_reset(*old);
  391. sch_tree_unlock(qd);
  392. return 0;
  393. }
  394. static struct Qdisc *
  395. wme_classop_leaf(struct Qdisc *qd, unsigned long arg)
  396. {
  397. struct ieee80211_sched_data *q = qdisc_priv(qd);
  398. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  399. struct ieee80211_hw *hw = &local->hw;
  400. unsigned long queue = arg - 1;
  401. if (queue >= hw->queues)
  402. return NULL;
  403. return q->queues[queue];
  404. }
  405. static unsigned long wme_classop_get(struct Qdisc *qd, u32 classid)
  406. {
  407. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  408. struct ieee80211_hw *hw = &local->hw;
  409. unsigned long queue = TC_H_MIN(classid);
  410. if (queue - 1 >= hw->queues)
  411. return 0;
  412. return queue;
  413. }
  414. static unsigned long wme_classop_bind(struct Qdisc *qd, unsigned long parent,
  415. u32 classid)
  416. {
  417. return wme_classop_get(qd, classid);
  418. }
  419. static void wme_classop_put(struct Qdisc *q, unsigned long cl)
  420. {
  421. }
  422. static int wme_classop_change(struct Qdisc *qd, u32 handle, u32 parent,
  423. struct rtattr **tca, unsigned long *arg)
  424. {
  425. unsigned long cl = *arg;
  426. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  427. struct ieee80211_hw *hw = &local->hw;
  428. if (cl - 1 > hw->queues)
  429. return -ENOENT;
  430. /* TODO: put code to program hardware queue parameters here,
  431. * to allow programming from tc command line */
  432. return 0;
  433. }
  434. /* we don't support deleting hardware queues
  435. * when we add WMM-SA support - TSPECs may be deleted here */
  436. static int wme_classop_delete(struct Qdisc *qd, unsigned long cl)
  437. {
  438. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  439. struct ieee80211_hw *hw = &local->hw;
  440. if (cl - 1 > hw->queues)
  441. return -ENOENT;
  442. return 0;
  443. }
  444. static int wme_classop_dump_class(struct Qdisc *qd, unsigned long cl,
  445. struct sk_buff *skb, struct tcmsg *tcm)
  446. {
  447. struct ieee80211_sched_data *q = qdisc_priv(qd);
  448. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  449. struct ieee80211_hw *hw = &local->hw;
  450. if (cl - 1 > hw->queues)
  451. return -ENOENT;
  452. tcm->tcm_handle = TC_H_MIN(cl);
  453. tcm->tcm_parent = qd->handle;
  454. tcm->tcm_info = q->queues[cl-1]->handle; /* do we need this? */
  455. return 0;
  456. }
  457. static void wme_classop_walk(struct Qdisc *qd, struct qdisc_walker *arg)
  458. {
  459. struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
  460. struct ieee80211_hw *hw = &local->hw;
  461. int queue;
  462. if (arg->stop)
  463. return;
  464. for (queue = 0; queue < hw->queues; queue++) {
  465. if (arg->count < arg->skip) {
  466. arg->count++;
  467. continue;
  468. }
  469. /* we should return classids for our internal queues here
  470. * as well as the external ones */
  471. if (arg->fn(qd, queue+1, arg) < 0) {
  472. arg->stop = 1;
  473. break;
  474. }
  475. arg->count++;
  476. }
  477. }
  478. static struct tcf_proto ** wme_classop_find_tcf(struct Qdisc *qd,
  479. unsigned long cl)
  480. {
  481. struct ieee80211_sched_data *q = qdisc_priv(qd);
  482. if (cl)
  483. return NULL;
  484. return &q->filter_list;
  485. }
  486. /* this qdisc is classful (i.e. has classes, some of which may have leaf qdiscs attached)
  487. * - these are the operations on the classes */
  488. static struct Qdisc_class_ops class_ops =
  489. {
  490. .graft = wme_classop_graft,
  491. .leaf = wme_classop_leaf,
  492. .get = wme_classop_get,
  493. .put = wme_classop_put,
  494. .change = wme_classop_change,
  495. .delete = wme_classop_delete,
  496. .walk = wme_classop_walk,
  497. .tcf_chain = wme_classop_find_tcf,
  498. .bind_tcf = wme_classop_bind,
  499. .unbind_tcf = wme_classop_put,
  500. .dump = wme_classop_dump_class,
  501. };
  502. /* queueing discipline operations */
  503. static struct Qdisc_ops wme_qdisc_ops =
  504. {
  505. .next = NULL,
  506. .cl_ops = &class_ops,
  507. .id = "ieee80211",
  508. .priv_size = sizeof(struct ieee80211_sched_data),
  509. .enqueue = wme_qdiscop_enqueue,
  510. .dequeue = wme_qdiscop_dequeue,
  511. .requeue = wme_qdiscop_requeue,
  512. .drop = NULL, /* drop not needed since we are always the root qdisc */
  513. .init = wme_qdiscop_init,
  514. .reset = wme_qdiscop_reset,
  515. .destroy = wme_qdiscop_destroy,
  516. .change = wme_qdiscop_tune,
  517. .dump = wme_qdiscop_dump,
  518. };
  519. void ieee80211_install_qdisc(struct net_device *dev)
  520. {
  521. struct Qdisc *qdisc;
  522. qdisc = qdisc_create_dflt(dev, &wme_qdisc_ops, TC_H_ROOT);
  523. if (!qdisc) {
  524. printk(KERN_ERR "%s: qdisc installation failed\n", dev->name);
  525. return;
  526. }
  527. /* same handle as would be allocated by qdisc_alloc_handle() */
  528. qdisc->handle = 0x80010000;
  529. qdisc_lock_tree(dev);
  530. list_add_tail(&qdisc->list, &dev->qdisc_list);
  531. dev->qdisc_sleeping = qdisc;
  532. qdisc_unlock_tree(dev);
  533. }
  534. int ieee80211_qdisc_installed(struct net_device *dev)
  535. {
  536. return dev->qdisc_sleeping->ops == &wme_qdisc_ops;
  537. }
  538. int ieee80211_wme_register(void)
  539. {
  540. return register_qdisc(&wme_qdisc_ops);
  541. }
  542. void ieee80211_wme_unregister(void)
  543. {
  544. unregister_qdisc(&wme_qdisc_ops);
  545. }
  546. #endif /* CONFIG_NET_SCHED */