1 --- a/net80211/ieee80211_output.c
2 +++ b/net80211/ieee80211_output.c
3 @@ -73,6 +73,29 @@ doprint(struct ieee80211vap *vap, int su
7 +static const int ieee802_1d_to_ac[8] = {
8 + WME_AC_BE, WME_AC_BK, WME_AC_BK, WME_AC_BE,
9 + WME_AC_VI, WME_AC_VI, WME_AC_VO, WME_AC_VO
12 +/* Given a data frame determine the 802.1p/1d tag to use. */
13 +static unsigned int ieee80211_classify_ip(struct sk_buff *skb)
15 + const struct ether_header *eh = (struct ether_header *) skb->data;
16 + const struct iphdr *ip = (struct iphdr *)
17 + (skb->data + sizeof (struct ether_header));
20 + switch (skb->protocol) {
21 + case __constant_htons(ETH_P_IP):
22 + dscp = ip->tos & 0xfc;
32 * Determine the priority based on VLAN and/or IP TOS. Priority is
33 @@ -83,90 +106,24 @@ static int
34 ieee80211_classify(struct ieee80211_node *ni, struct sk_buff *skb)
36 struct ieee80211vap *vap = ni->ni_vap;
37 - struct ether_header *eh = (struct ether_header *) skb->data;
38 - int v_wme_ac = 0, d_wme_ac = 0;
40 - /* default priority */
41 - skb->priority = WME_AC_BE;
43 - if (!(ni->ni_flags & IEEE80211_NODE_QOS))
47 - * If node has a vlan tag then all traffic
48 - * to it must have a matching vlan id.
49 + /* skb->priority values from 256->263 are magic values to
50 + * directly indicate a specific 802.1d priority. This is used
51 + * to allow 802.1d priority to be passed directly in from VLAN
54 - if (ni->ni_vlan != 0 && vlan_tx_tag_present(skb)) {
58 - if (vap->iv_vlgrp == NULL) {
59 - IEEE80211_NODE_STAT(ni, tx_novlantag);
60 - ni->ni_stats.ns_tx_novlantag++;
63 - if (((tag = vlan_tx_tag_get(skb)) & VLAN_VID_MASK) !=
64 - (ni->ni_vlan & VLAN_VID_MASK)) {
65 - IEEE80211_NODE_STAT(ni, tx_vlanmismatch);
66 - ni->ni_stats.ns_tx_vlanmismatch++;
69 - if (ni->ni_flags & IEEE80211_NODE_QOS) {
70 - v_pri = (tag >> VLAN_PRI_SHIFT) & VLAN_PRI_MASK;
73 - case 2: /* Background (BK) */
74 - v_wme_ac = WME_AC_BK;
77 - case 3: /* Best Effort (BE) */
78 - v_wme_ac = WME_AC_BE;
81 - case 5: /* Video (VI) */
82 - v_wme_ac = WME_AC_VI;
85 - case 7: /* Voice (VO) */
86 - v_wme_ac = WME_AC_VO;
90 + if (skb->priority >= 256 && skb->priority <= 263) {
91 + skb->priority = ieee802_1d_to_ac[skb->priority - 256];
95 - if (eh->ether_type == __constant_htons(ETHERTYPE_IP)) {
96 - const struct iphdr *ip = (struct iphdr *)
97 - (skb->data + sizeof (struct ether_header));
99 - * IP frame, map the TOS field.
101 - * XXX: fill out these mappings???
104 - case 0x08: /* Background */
106 - d_wme_ac = WME_AC_BK;
108 - case 0x28: /* Video */
110 - d_wme_ac = WME_AC_VI;
112 - case 0x30: /* Voice */
114 - case 0x88: /* XXX UPSD */
116 - d_wme_ac = WME_AC_VO;
118 - default: /* All others */
119 - d_wme_ac = WME_AC_BE;
123 - d_wme_ac = WME_AC_BE;
124 + if (!(ni->ni_flags & IEEE80211_NODE_QOS)) {
125 + /* default priority */
126 + skb->priority = WME_AC_BE;
129 - skb->priority = d_wme_ac;
130 - if (v_wme_ac > d_wme_ac)
131 - skb->priority = v_wme_ac;
133 + skb->priority = ieee802_1d_to_ac[ieee80211_classify_ip(skb)];
135 /* Applying ACM policy */
136 if (vap->iv_opmode == IEEE80211_M_STA) {