1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2009 Sam Leffler, Errno Consulting
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * $FreeBSD$
28 */
29 #ifndef _NET80211_IEEE80211_SUPERG_H_
30 #define _NET80211_IEEE80211_SUPERG_H_
31
32 /*
33 * Atheros' 802.11 SuperG protocol support.
34 */
35
36 /*
37 * Atheros advanced capability information element.
38 */
39 struct ieee80211_ath_ie {
40 uint8_t ath_id; /* IEEE80211_ELEMID_VENDOR */
41 uint8_t ath_len; /* length in bytes */
42 uint8_t ath_oui[3]; /* ATH_OUI */
43 uint8_t ath_oui_type; /* ATH_OUI_TYPE */
44 uint8_t ath_oui_subtype; /* ATH_OUI_SUBTYPE */
45 uint8_t ath_version; /* spec revision */
46 uint8_t ath_capability; /* capability info */
47 #define ATHEROS_CAP_TURBO_PRIME 0x01 /* dynamic turbo--aka Turbo' */
48 #define ATHEROS_CAP_COMPRESSION 0x02 /* data compression */
49 #define ATHEROS_CAP_FAST_FRAME 0x04 /* fast (jumbo) frames */
50 #define ATHEROS_CAP_XR 0x08 /* Xtended Range support */
51 #define ATHEROS_CAP_AR 0x10 /* Advanded Radar support */
52 #define ATHEROS_CAP_BURST 0x20 /* Bursting - not negotiated */
53 #define ATHEROS_CAP_WME 0x40 /* CWMin tuning */
54 #define ATHEROS_CAP_BOOST 0x80 /* use turbo/!turbo mode */
55 uint8_t ath_defkeyix[2];
56 } __packed;
57
58 #define ATH_OUI_VERSION 0x00
59 #define ATH_OUI_SUBTYPE 0x01
60
61 #ifdef _KERNEL
62 struct ieee80211_stageq {
63 struct mbuf *head; /* frames linked w/ m_nextpkt */
64 struct mbuf *tail; /* last frame in queue */
65 int depth; /* # items on head */
66 };
67
68 struct ieee80211_superg {
69 /* fast-frames staging q */
70 struct ieee80211_stageq ff_stageq[WME_NUM_AC];
71 /* flush queues automatically */
72 struct timeout_task ff_qtimer;
73 };
74
75 void ieee80211_superg_attach(struct ieee80211com *);
76 void ieee80211_superg_detach(struct ieee80211com *);
77 void ieee80211_superg_vattach(struct ieee80211vap *);
78 void ieee80211_superg_vdetach(struct ieee80211vap *);
79
80 uint8_t *ieee80211_add_ath(uint8_t *, uint8_t, ieee80211_keyix);
81 uint8_t *ieee80211_add_athcaps(uint8_t *, const struct ieee80211_node *);
82 void ieee80211_parse_ath(struct ieee80211_node *, uint8_t *);
83 int ieee80211_parse_athparams(struct ieee80211_node *, uint8_t *,
84 const struct ieee80211_frame *);
85
86 void ieee80211_ff_node_init(struct ieee80211_node *);
87 void ieee80211_ff_node_cleanup(struct ieee80211_node *);
88
89 static inline int
90 ieee80211_amsdu_tx_ok(struct ieee80211_node *ni)
91 {
92
93 /* First: software A-MSDU transmit? */
94 if ((ni->ni_ic->ic_caps & IEEE80211_C_SWAMSDUTX) == 0)
95 return (0);
96
97 /* Next: does the VAP have AMSDU TX enabled? */
98 if ((ni->ni_vap->iv_flags_ht & IEEE80211_FHT_AMSDU_TX) == 0)
99 return (0);
100
101 /* Next: 11n node? (assumed that A-MSDU TX to HT nodes is ok */
102 if ((ni->ni_flags & IEEE80211_NODE_HT) == 0)
103 return (0);
104
105 /* ok, we can at least /do/ AMSDU to this node */
106 return (1);
107 }
108
109 struct mbuf * ieee80211_amsdu_check(struct ieee80211_node *ni, struct mbuf *m);
110 struct mbuf *ieee80211_ff_check(struct ieee80211_node *, struct mbuf *);
111 void ieee80211_ff_age(struct ieee80211com *, struct ieee80211_stageq *,
112 int quanta);
113
114 static __inline void
115 ieee80211_ff_age_all(struct ieee80211com *ic, int quanta)
116 {
117 struct ieee80211_superg *sg = ic->ic_superg;
118
119 if (sg != NULL) {
120 ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VO], quanta);
121 ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_VI], quanta);
122 ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BE], quanta);
123 ieee80211_ff_age(ic, &sg->ff_stageq[WME_AC_BK], quanta);
124 }
125 }
126
127 static __inline void
128 ieee80211_ff_flush(struct ieee80211com *ic, int ac)
129 {
130 struct ieee80211_superg *sg = ic->ic_superg;
131
132 if (sg != NULL)
133 ieee80211_ff_age(ic, &sg->ff_stageq[ac], 0x7fffffff);
134 }
135
136 static __inline void
137 ieee80211_ff_flush_all(struct ieee80211com *ic)
138 {
139 ieee80211_ff_age_all(ic, 0x7fffffff);
140 }
141
142 struct mbuf *ieee80211_ff_encap(struct ieee80211vap *, struct mbuf *,
143 int, struct ieee80211_key *);
144 struct mbuf * ieee80211_amsdu_encap(struct ieee80211vap *vap, struct mbuf *m1,
145 int hdrspace, struct ieee80211_key *key);
146
147 struct mbuf *ieee80211_ff_decap(struct ieee80211_node *, struct mbuf *);
148
149 static __inline struct mbuf *
150 ieee80211_decap_fastframe(struct ieee80211vap *vap, struct ieee80211_node *ni,
151 struct mbuf *m)
152 {
153 return IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF) ?
154 ieee80211_ff_decap(ni, m) : m;
155 }
156 #endif /* _KERNEL */
157 #endif /* _NET80211_IEEE80211_SUPERG_H_ */
Cache object: 954ee1436872d6e93fd08e81388425ed
|