aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorThomas Pedersen <thomas@cozybit.com>2011-10-26 17:47:25 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-11-08 15:54:31 -0500
commit3b69a9c5f264d62a0cf46ea61ed3da732c1f88c2 (patch)
treed40bbdbe62b517696711344e6f56278ac420cdd1 /net/mac80211
parentc63749d347afcb5c4790d1cbe27d9b66e585b9ff (diff)
mac80211: comment allocation of mesh frames
Remove most references to magic numbers, save a few bytes and hopefully improve readability. Signed-off-by: Thomas Pedersen <thomas@cozybit.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/mesh_hwmp.c36
-rw-r--r--net/mac80211/mesh_plink.c28
-rw-r--r--net/mac80211/tx.c19
3 files changed, 48 insertions, 35 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 174040a42887..9a1f8bbc49b8 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -113,20 +113,20 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
113 struct ieee80211_sub_if_data *sdata) 113 struct ieee80211_sub_if_data *sdata)
114{ 114{
115 struct ieee80211_local *local = sdata->local; 115 struct ieee80211_local *local = sdata->local;
116 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 116 struct sk_buff *skb;
117 struct ieee80211_mgmt *mgmt; 117 struct ieee80211_mgmt *mgmt;
118 u8 *pos; 118 u8 *pos, ie_len;
119 int ie_len; 119 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) +
120 sizeof(mgmt->u.action.u.mesh_action);
120 121
122 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
123 hdr_len +
124 2 + 37); /* max HWMP IE */
121 if (!skb) 125 if (!skb)
122 return -1; 126 return -1;
123 skb_reserve(skb, local->hw.extra_tx_headroom); 127 skb_reserve(skb, local->hw.extra_tx_headroom);
124 /* 25 is the size of the common mgmt part (24) plus the size of the 128 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
125 * common action part (1) 129 memset(mgmt, 0, hdr_len);
126 */
127 mgmt = (struct ieee80211_mgmt *)
128 skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action));
129 memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action));
130 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 130 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
131 IEEE80211_STYPE_ACTION); 131 IEEE80211_STYPE_ACTION);
132 132
@@ -240,20 +240,20 @@ int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn,
240 struct ieee80211_sub_if_data *sdata) 240 struct ieee80211_sub_if_data *sdata)
241{ 241{
242 struct ieee80211_local *local = sdata->local; 242 struct ieee80211_local *local = sdata->local;
243 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 243 struct sk_buff *skb;
244 struct ieee80211_mgmt *mgmt; 244 struct ieee80211_mgmt *mgmt;
245 u8 *pos; 245 u8 *pos, ie_len;
246 int ie_len; 246 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) +
247 sizeof(mgmt->u.action.u.mesh_action);
247 248
249 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
250 hdr_len +
251 2 + 15 /* PERR IE */);
248 if (!skb) 252 if (!skb)
249 return -1; 253 return -1;
250 skb_reserve(skb, local->tx_headroom + local->hw.extra_tx_headroom); 254 skb_reserve(skb, local->tx_headroom + local->hw.extra_tx_headroom);
251 /* 25 is the size of the common mgmt part (24) plus the size of the 255 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
252 * common action part (1) 256 memset(mgmt, 0, hdr_len);
253 */
254 mgmt = (struct ieee80211_mgmt *)
255 skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action));
256 memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action));
257 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 257 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
258 IEEE80211_STYPE_ACTION); 258 IEEE80211_STYPE_ACTION);
259 259
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 7e57f5d07f66..351e48c9710c 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -153,23 +153,29 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
153 enum ieee80211_self_protected_actioncode action, 153 enum ieee80211_self_protected_actioncode action,
154 u8 *da, __le16 llid, __le16 plid, __le16 reason) { 154 u8 *da, __le16 llid, __le16 plid, __le16 reason) {
155 struct ieee80211_local *local = sdata->local; 155 struct ieee80211_local *local = sdata->local;
156 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 + 156 struct sk_buff *skb;
157 sdata->u.mesh.ie_len);
158 struct ieee80211_mgmt *mgmt; 157 struct ieee80211_mgmt *mgmt;
159 bool include_plid = false; 158 bool include_plid = false;
160 int ie_len = 4;
161 u16 peering_proto = 0; 159 u16 peering_proto = 0;
162 u8 *pos; 160 u8 *pos, ie_len = 4;
163 161 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) +
162 sizeof(mgmt->u.action.u.self_prot);
163
164 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
165 hdr_len +
166 2 + /* capability info */
167 2 + /* AID */
168 2 + 8 + /* supported rates */
169 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
170 2 + sdata->u.mesh.mesh_id_len +
171 2 + sizeof(struct ieee80211_meshconf_ie) +
172 2 + 8 + /* peering IE */
173 sdata->u.mesh.ie_len);
164 if (!skb) 174 if (!skb)
165 return -1; 175 return -1;
166 skb_reserve(skb, local->hw.extra_tx_headroom); 176 skb_reserve(skb, local->hw.extra_tx_headroom);
167 /* 25 is the size of the common mgmt part (24) plus the size of the 177 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
168 * common action part (1) 178 memset(mgmt, 0, hdr_len);
169 */
170 mgmt = (struct ieee80211_mgmt *)
171 skb_put(skb, 25 + sizeof(mgmt->u.action.u.self_prot));
172 memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.self_prot));
173 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 179 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
174 IEEE80211_STYPE_ACTION); 180 IEEE80211_STYPE_ACTION);
175 memcpy(mgmt->da, da, ETH_ALEN); 181 memcpy(mgmt->da, da, ETH_ALEN);
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 48bbb96d8edb..f4dd339e7cdd 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2278,22 +2278,29 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2278 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { 2278 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
2279 struct ieee80211_mgmt *mgmt; 2279 struct ieee80211_mgmt *mgmt;
2280 u8 *pos; 2280 u8 *pos;
2281 int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) +
2282 sizeof(mgmt->u.beacon);
2281 2283
2282#ifdef CONFIG_MAC80211_MESH 2284#ifdef CONFIG_MAC80211_MESH
2283 if (!sdata->u.mesh.mesh_id_len) 2285 if (!sdata->u.mesh.mesh_id_len)
2284 goto out; 2286 goto out;
2285#endif 2287#endif
2286 2288
2287 /* headroom, head length, tail length and maximum TIM length */ 2289 skb = dev_alloc_skb(local->tx_headroom +
2288 skb = dev_alloc_skb(local->tx_headroom + 400 + 2290 hdr_len +
2289 sdata->u.mesh.ie_len); 2291 2 + /* NULL SSID */
2292 2 + 8 + /* supported rates */
2293 2 + 3 + /* DS params */
2294 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
2295 2 + sdata->u.mesh.mesh_id_len +
2296 2 + sizeof(struct ieee80211_meshconf_ie) +
2297 sdata->u.mesh.ie_len);
2290 if (!skb) 2298 if (!skb)
2291 goto out; 2299 goto out;
2292 2300
2293 skb_reserve(skb, local->hw.extra_tx_headroom); 2301 skb_reserve(skb, local->hw.extra_tx_headroom);
2294 mgmt = (struct ieee80211_mgmt *) 2302 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
2295 skb_put(skb, 24 + sizeof(mgmt->u.beacon)); 2303 memset(mgmt, 0, hdr_len);
2296 memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
2297 mgmt->frame_control = 2304 mgmt->frame_control =
2298 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); 2305 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
2299 memset(mgmt->da, 0xff, ETH_ALEN); 2306 memset(mgmt->da, 0xff, ETH_ALEN);