aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/tx.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r--net/mac80211/tx.c97
1 files changed, 68 insertions, 29 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index baa1be0671e5..dac44cbd036f 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1215,6 +1215,45 @@ retry:
1215 1215
1216/* device xmit handlers */ 1216/* device xmit handlers */
1217 1217
1218static int ieee80211_skb_resize(struct ieee80211_local *local,
1219 struct sk_buff *skb,
1220 int head_need, bool may_encrypt)
1221{
1222 int tail_need = 0;
1223
1224 /*
1225 * This could be optimised, devices that do full hardware
1226 * crypto (including TKIP MMIC) need no tailroom... But we
1227 * have no drivers for such devices currently.
1228 */
1229 if (may_encrypt) {
1230 tail_need = IEEE80211_ENCRYPT_TAILROOM;
1231 tail_need -= skb_tailroom(skb);
1232 tail_need = max_t(int, tail_need, 0);
1233 }
1234
1235 if (head_need || tail_need) {
1236 /* Sorry. Can't account for this any more */
1237 skb_orphan(skb);
1238 }
1239
1240 if (skb_header_cloned(skb))
1241 I802_DEBUG_INC(local->tx_expand_skb_head_cloned);
1242 else
1243 I802_DEBUG_INC(local->tx_expand_skb_head);
1244
1245 if (pskb_expand_head(skb, head_need, tail_need, GFP_ATOMIC)) {
1246 printk(KERN_DEBUG "%s: failed to reallocate TX buffer\n",
1247 wiphy_name(local->hw.wiphy));
1248 return -ENOMEM;
1249 }
1250
1251 /* update truesize too */
1252 skb->truesize += head_need + tail_need;
1253
1254 return 0;
1255}
1256
1218int ieee80211_master_start_xmit(struct sk_buff *skb, 1257int ieee80211_master_start_xmit(struct sk_buff *skb,
1219 struct net_device *dev) 1258 struct net_device *dev)
1220{ 1259{
@@ -1222,6 +1261,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
1222 struct net_device *odev = NULL; 1261 struct net_device *odev = NULL;
1223 struct ieee80211_sub_if_data *osdata; 1262 struct ieee80211_sub_if_data *osdata;
1224 int headroom; 1263 int headroom;
1264 bool may_encrypt;
1225 int ret; 1265 int ret;
1226 1266
1227 if (info->control.ifindex) 1267 if (info->control.ifindex)
@@ -1241,13 +1281,18 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
1241 1281
1242 osdata = IEEE80211_DEV_TO_SUB_IF(odev); 1282 osdata = IEEE80211_DEV_TO_SUB_IF(odev);
1243 1283
1244 headroom = osdata->local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM; 1284 may_encrypt = !(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT);
1245 if (skb_headroom(skb) < headroom) { 1285
1246 if (pskb_expand_head(skb, headroom, 0, GFP_ATOMIC)) { 1286 headroom = osdata->local->tx_headroom;
1247 dev_kfree_skb(skb); 1287 if (may_encrypt)
1248 dev_put(odev); 1288 headroom += IEEE80211_ENCRYPT_HEADROOM;
1249 return 0; 1289 headroom -= skb_headroom(skb);
1250 } 1290 headroom = max_t(int, 0, headroom);
1291
1292 if (ieee80211_skb_resize(osdata->local, skb, headroom, may_encrypt)) {
1293 dev_kfree_skb(skb);
1294 dev_put(odev);
1295 return 0;
1251 } 1296 }
1252 1297
1253 info->control.vif = &osdata->vif; 1298 info->control.vif = &osdata->vif;
@@ -1509,32 +1554,26 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1509 * build in headroom in __dev_alloc_skb() (linux/skbuff.h) and 1554 * build in headroom in __dev_alloc_skb() (linux/skbuff.h) and
1510 * alloc_skb() (net/core/skbuff.c) 1555 * alloc_skb() (net/core/skbuff.c)
1511 */ 1556 */
1512 head_need = hdrlen + encaps_len + meshhdrlen + local->tx_headroom; 1557 head_need = hdrlen + encaps_len + meshhdrlen - skb_headroom(skb);
1513 head_need -= skb_headroom(skb);
1514 1558
1515 /* We are going to modify skb data, so make a copy of it if happens to 1559 /*
1516 * be cloned. This could happen, e.g., with Linux bridge code passing 1560 * So we need to modify the skb header and hence need a copy of
1517 * us broadcast frames. */ 1561 * that. The head_need variable above doesn't, so far, include
1562 * the needed header space that we don't need right away. If we
1563 * can, then we don't reallocate right now but only after the
1564 * frame arrives at the master device (if it does...)
1565 *
1566 * If we cannot, however, then we will reallocate to include all
1567 * the ever needed space. Also, if we need to reallocate it anyway,
1568 * make it big enough for everything we may ever need.
1569 */
1518 1570
1519 if (head_need > 0 || skb_header_cloned(skb)) { 1571 if (head_need > 0 || skb_header_cloned(skb)) {
1520#if 0 1572 head_need += IEEE80211_ENCRYPT_HEADROOM;
1521 printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " 1573 head_need += local->tx_headroom;
1522 "of headroom\n", dev->name, head_need); 1574 head_need = max_t(int, 0, head_need);
1523#endif 1575 if (ieee80211_skb_resize(local, skb, head_need, true))
1524
1525 if (skb_header_cloned(skb))
1526 I802_DEBUG_INC(local->tx_expand_skb_head_cloned);
1527 else
1528 I802_DEBUG_INC(local->tx_expand_skb_head);
1529 /* Since we have to reallocate the buffer, make sure that there
1530 * is enough room for possible WEP IV/ICV and TKIP (8 bytes
1531 * before payload and 12 after). */
1532 if (pskb_expand_head(skb, (head_need > 0 ? head_need + 8 : 8),
1533 12, GFP_ATOMIC)) {
1534 printk(KERN_DEBUG "%s: failed to reallocate TX buffer"
1535 "\n", dev->name);
1536 goto fail; 1576 goto fail;
1537 }
1538 } 1577 }
1539 1578
1540 if (encaps_data) { 1579 if (encaps_data) {