diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-06-17 11:43:56 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-24 15:05:30 -0400 |
commit | 3b8d81e020f77c9da8b85b0685c8cd2ca7c7b150 (patch) | |
tree | a19fcddbf28fecdbd13ad009fe07b8afc5e95c90 /net/mac80211/tx.c | |
parent | c4029083e2acb82229c43b791c07afb089d972ff (diff) |
mac80211: remove master netdev
With the internal 'pending' queue system in place, we can simply
put packets there instead of pushing them off to the master dev,
getting rid of the master interface completely.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/tx.c')
-rw-r--r-- | net/mac80211/tx.c | 299 |
1 files changed, 123 insertions, 176 deletions
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f3efd4f16e91..7adaeb2c53e8 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -451,7 +451,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
451 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 451 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
452 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | 452 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; |
453 | 453 | ||
454 | if (unlikely(tx->skb->do_not_encrypt)) | 454 | if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) |
455 | tx->key = NULL; | 455 | tx->key = NULL; |
456 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) | 456 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) |
457 | tx->key = key; | 457 | tx->key = key; |
@@ -497,7 +497,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
497 | } | 497 | } |
498 | 498 | ||
499 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) | 499 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
500 | tx->skb->do_not_encrypt = 1; | 500 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
501 | 501 | ||
502 | return TX_CONTINUE; | 502 | return TX_CONTINUE; |
503 | } | 503 | } |
@@ -774,9 +774,7 @@ static int ieee80211_fragment(struct ieee80211_local *local, | |||
774 | memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); | 774 | memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); |
775 | skb_copy_queue_mapping(tmp, skb); | 775 | skb_copy_queue_mapping(tmp, skb); |
776 | tmp->priority = skb->priority; | 776 | tmp->priority = skb->priority; |
777 | tmp->do_not_encrypt = skb->do_not_encrypt; | ||
778 | tmp->dev = skb->dev; | 777 | tmp->dev = skb->dev; |
779 | tmp->iif = skb->iif; | ||
780 | 778 | ||
781 | /* copy header and data */ | 779 | /* copy header and data */ |
782 | memcpy(skb_put(tmp, hdrlen), skb->data, hdrlen); | 780 | memcpy(skb_put(tmp, hdrlen), skb->data, hdrlen); |
@@ -804,7 +802,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
804 | 802 | ||
805 | /* | 803 | /* |
806 | * Warn when submitting a fragmented A-MPDU frame and drop it. | 804 | * Warn when submitting a fragmented A-MPDU frame and drop it. |
807 | * This scenario is handled in __ieee80211_tx_prepare but extra | 805 | * This scenario is handled in ieee80211_tx_prepare but extra |
808 | * caution taken here as fragmented ampdu may cause Tx stop. | 806 | * caution taken here as fragmented ampdu may cause Tx stop. |
809 | */ | 807 | */ |
810 | if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) | 808 | if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) |
@@ -943,11 +941,12 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
943 | struct ieee80211_radiotap_header *rthdr = | 941 | struct ieee80211_radiotap_header *rthdr = |
944 | (struct ieee80211_radiotap_header *) skb->data; | 942 | (struct ieee80211_radiotap_header *) skb->data; |
945 | struct ieee80211_supported_band *sband; | 943 | struct ieee80211_supported_band *sband; |
944 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
946 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); | 945 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); |
947 | 946 | ||
948 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; | 947 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; |
949 | 948 | ||
950 | skb->do_not_encrypt = 1; | 949 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
951 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; | 950 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; |
952 | 951 | ||
953 | /* | 952 | /* |
@@ -985,7 +984,7 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
985 | skb_trim(skb, skb->len - FCS_LEN); | 984 | skb_trim(skb, skb->len - FCS_LEN); |
986 | } | 985 | } |
987 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) | 986 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) |
988 | tx->skb->do_not_encrypt = 0; | 987 | info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT; |
989 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) | 988 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) |
990 | tx->flags |= IEEE80211_TX_FRAGMENTED; | 989 | tx->flags |= IEEE80211_TX_FRAGMENTED; |
991 | break; | 990 | break; |
@@ -1018,13 +1017,12 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
1018 | * initialises @tx | 1017 | * initialises @tx |
1019 | */ | 1018 | */ |
1020 | static ieee80211_tx_result | 1019 | static ieee80211_tx_result |
1021 | __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | 1020 | ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, |
1022 | struct sk_buff *skb, | 1021 | struct ieee80211_tx_data *tx, |
1023 | struct net_device *dev) | 1022 | struct sk_buff *skb) |
1024 | { | 1023 | { |
1025 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1024 | struct ieee80211_local *local = sdata->local; |
1026 | struct ieee80211_hdr *hdr; | 1025 | struct ieee80211_hdr *hdr; |
1027 | struct ieee80211_sub_if_data *sdata; | ||
1028 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1026 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1029 | int hdrlen, tid; | 1027 | int hdrlen, tid; |
1030 | u8 *qc, *state; | 1028 | u8 *qc, *state; |
@@ -1032,9 +1030,9 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1032 | 1030 | ||
1033 | memset(tx, 0, sizeof(*tx)); | 1031 | memset(tx, 0, sizeof(*tx)); |
1034 | tx->skb = skb; | 1032 | tx->skb = skb; |
1035 | tx->dev = dev; /* use original interface */ | 1033 | tx->dev = sdata->dev; /* use original interface */ |
1036 | tx->local = local; | 1034 | tx->local = local; |
1037 | tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1035 | tx->sdata = sdata; |
1038 | tx->channel = local->hw.conf.channel; | 1036 | tx->channel = local->hw.conf.channel; |
1039 | /* | 1037 | /* |
1040 | * Set this flag (used below to indicate "automatic fragmentation"), | 1038 | * Set this flag (used below to indicate "automatic fragmentation"), |
@@ -1043,7 +1041,6 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1043 | tx->flags |= IEEE80211_TX_FRAGMENTED; | 1041 | tx->flags |= IEEE80211_TX_FRAGMENTED; |
1044 | 1042 | ||
1045 | /* process and remove the injection radiotap header */ | 1043 | /* process and remove the injection radiotap header */ |
1046 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1047 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) { | 1044 | if (unlikely(info->flags & IEEE80211_TX_CTL_INJECTED)) { |
1048 | if (!__ieee80211_parse_tx_radiotap(tx, skb)) | 1045 | if (!__ieee80211_parse_tx_radiotap(tx, skb)) |
1049 | return TX_DROP; | 1046 | return TX_DROP; |
@@ -1139,50 +1136,28 @@ __ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1139 | return TX_CONTINUE; | 1136 | return TX_CONTINUE; |
1140 | } | 1137 | } |
1141 | 1138 | ||
1142 | /* | ||
1143 | * NB: @tx is uninitialised when passed in here | ||
1144 | */ | ||
1145 | static int ieee80211_tx_prepare(struct ieee80211_local *local, | ||
1146 | struct ieee80211_tx_data *tx, | ||
1147 | struct sk_buff *skb) | ||
1148 | { | ||
1149 | struct net_device *dev; | ||
1150 | |||
1151 | dev = dev_get_by_index(&init_net, skb->iif); | ||
1152 | if (unlikely(dev && !is_ieee80211_device(local, dev))) { | ||
1153 | dev_put(dev); | ||
1154 | dev = NULL; | ||
1155 | } | ||
1156 | if (unlikely(!dev)) | ||
1157 | return -ENODEV; | ||
1158 | /* | ||
1159 | * initialises tx with control | ||
1160 | * | ||
1161 | * return value is safe to ignore here because this function | ||
1162 | * can only be invoked for multicast frames | ||
1163 | * | ||
1164 | * XXX: clean up | ||
1165 | */ | ||
1166 | __ieee80211_tx_prepare(tx, skb, dev); | ||
1167 | dev_put(dev); | ||
1168 | return 0; | ||
1169 | } | ||
1170 | |||
1171 | static int __ieee80211_tx(struct ieee80211_local *local, | 1139 | static int __ieee80211_tx(struct ieee80211_local *local, |
1172 | struct sk_buff **skbp, | 1140 | struct sk_buff **skbp, |
1173 | struct sta_info *sta) | 1141 | struct sta_info *sta, |
1142 | bool txpending) | ||
1174 | { | 1143 | { |
1175 | struct sk_buff *skb = *skbp, *next; | 1144 | struct sk_buff *skb = *skbp, *next; |
1176 | struct ieee80211_tx_info *info; | 1145 | struct ieee80211_tx_info *info; |
1146 | unsigned long flags; | ||
1177 | int ret, len; | 1147 | int ret, len; |
1178 | bool fragm = false; | 1148 | bool fragm = false; |
1179 | 1149 | ||
1180 | local->mdev->trans_start = jiffies; | ||
1181 | |||
1182 | while (skb) { | 1150 | while (skb) { |
1183 | if (ieee80211_queue_stopped(&local->hw, | 1151 | int q = skb_get_queue_mapping(skb); |
1184 | skb_get_queue_mapping(skb))) | 1152 | |
1185 | return IEEE80211_TX_PENDING; | 1153 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
1154 | ret = IEEE80211_TX_OK; | ||
1155 | if (local->queue_stop_reasons[q] || | ||
1156 | (!txpending && !skb_queue_empty(&local->pending[q]))) | ||
1157 | ret = IEEE80211_TX_PENDING; | ||
1158 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
1159 | if (ret != IEEE80211_TX_OK) | ||
1160 | return ret; | ||
1186 | 1161 | ||
1187 | info = IEEE80211_SKB_CB(skb); | 1162 | info = IEEE80211_SKB_CB(skb); |
1188 | 1163 | ||
@@ -1254,10 +1229,10 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) | |||
1254 | return 0; | 1229 | return 0; |
1255 | } | 1230 | } |
1256 | 1231 | ||
1257 | static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | 1232 | static void ieee80211_tx(struct ieee80211_sub_if_data *sdata, |
1258 | bool txpending) | 1233 | struct sk_buff *skb, bool txpending) |
1259 | { | 1234 | { |
1260 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1235 | struct ieee80211_local *local = sdata->local; |
1261 | struct ieee80211_tx_data tx; | 1236 | struct ieee80211_tx_data tx; |
1262 | ieee80211_tx_result res_prepare; | 1237 | ieee80211_tx_result res_prepare; |
1263 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1238 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
@@ -1268,8 +1243,6 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1268 | 1243 | ||
1269 | queue = skb_get_queue_mapping(skb); | 1244 | queue = skb_get_queue_mapping(skb); |
1270 | 1245 | ||
1271 | WARN_ON(!txpending && !skb_queue_empty(&local->pending[queue])); | ||
1272 | |||
1273 | if (unlikely(skb->len < 10)) { | 1246 | if (unlikely(skb->len < 10)) { |
1274 | dev_kfree_skb(skb); | 1247 | dev_kfree_skb(skb); |
1275 | return; | 1248 | return; |
@@ -1278,7 +1251,7 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1278 | rcu_read_lock(); | 1251 | rcu_read_lock(); |
1279 | 1252 | ||
1280 | /* initialises tx */ | 1253 | /* initialises tx */ |
1281 | res_prepare = __ieee80211_tx_prepare(&tx, skb, dev); | 1254 | res_prepare = ieee80211_tx_prepare(sdata, &tx, skb); |
1282 | 1255 | ||
1283 | if (unlikely(res_prepare == TX_DROP)) { | 1256 | if (unlikely(res_prepare == TX_DROP)) { |
1284 | dev_kfree_skb(skb); | 1257 | dev_kfree_skb(skb); |
@@ -1297,7 +1270,7 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1297 | 1270 | ||
1298 | retries = 0; | 1271 | retries = 0; |
1299 | retry: | 1272 | retry: |
1300 | ret = __ieee80211_tx(local, &tx.skb, tx.sta); | 1273 | ret = __ieee80211_tx(local, &tx.skb, tx.sta, txpending); |
1301 | switch (ret) { | 1274 | switch (ret) { |
1302 | case IEEE80211_TX_OK: | 1275 | case IEEE80211_TX_OK: |
1303 | break; | 1276 | break; |
@@ -1315,34 +1288,35 @@ static void ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |||
1315 | 1288 | ||
1316 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 1289 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
1317 | 1290 | ||
1318 | if (__netif_subqueue_stopped(local->mdev, queue)) { | 1291 | if (local->queue_stop_reasons[queue] || |
1292 | !skb_queue_empty(&local->pending[queue])) { | ||
1293 | /* | ||
1294 | * if queue is stopped, queue up frames for later | ||
1295 | * transmission from the tasklet | ||
1296 | */ | ||
1319 | do { | 1297 | do { |
1320 | next = skb->next; | 1298 | next = skb->next; |
1321 | skb->next = NULL; | 1299 | skb->next = NULL; |
1322 | if (unlikely(txpending)) | 1300 | if (unlikely(txpending)) |
1323 | skb_queue_head(&local->pending[queue], | 1301 | __skb_queue_head(&local->pending[queue], |
1324 | skb); | 1302 | skb); |
1325 | else | 1303 | else |
1326 | skb_queue_tail(&local->pending[queue], | 1304 | __skb_queue_tail(&local->pending[queue], |
1327 | skb); | 1305 | skb); |
1328 | } while ((skb = next)); | 1306 | } while ((skb = next)); |
1329 | 1307 | ||
1330 | /* | ||
1331 | * Make sure nobody will enable the queue on us | ||
1332 | * (without going through the tasklet) nor disable the | ||
1333 | * netdev queue underneath the pending handling code. | ||
1334 | */ | ||
1335 | __set_bit(IEEE80211_QUEUE_STOP_REASON_PENDING, | ||
1336 | &local->queue_stop_reasons[queue]); | ||
1337 | |||
1338 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, | 1308 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, |
1339 | flags); | 1309 | flags); |
1340 | } else { | 1310 | } else { |
1311 | /* | ||
1312 | * otherwise retry, but this is a race condition or | ||
1313 | * a driver bug (which we warn about if it persists) | ||
1314 | */ | ||
1341 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, | 1315 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, |
1342 | flags); | 1316 | flags); |
1343 | 1317 | ||
1344 | retries++; | 1318 | retries++; |
1345 | if (WARN(retries > 10, "tx refused but queue active")) | 1319 | if (WARN(retries > 10, "tx refused but queue active\n")) |
1346 | goto drop; | 1320 | goto drop; |
1347 | goto retry; | 1321 | goto retry; |
1348 | } | 1322 | } |
@@ -1403,14 +1377,13 @@ static int ieee80211_skb_resize(struct ieee80211_local *local, | |||
1403 | return 0; | 1377 | return 0; |
1404 | } | 1378 | } |
1405 | 1379 | ||
1406 | int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | 1380 | static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, |
1381 | struct sk_buff *skb) | ||
1407 | { | 1382 | { |
1408 | struct ieee80211_master_priv *mpriv = netdev_priv(dev); | 1383 | struct ieee80211_local *local = sdata->local; |
1409 | struct ieee80211_local *local = mpriv->local; | ||
1410 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1384 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1411 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 1385 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
1412 | struct net_device *odev = NULL; | 1386 | struct ieee80211_sub_if_data *tmp_sdata; |
1413 | struct ieee80211_sub_if_data *osdata; | ||
1414 | int headroom; | 1387 | int headroom; |
1415 | bool may_encrypt; | 1388 | bool may_encrypt; |
1416 | enum { | 1389 | enum { |
@@ -1419,20 +1392,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1419 | UNKNOWN_ADDRESS, | 1392 | UNKNOWN_ADDRESS, |
1420 | } monitor_iface = NOT_MONITOR; | 1393 | } monitor_iface = NOT_MONITOR; |
1421 | 1394 | ||
1422 | if (skb->iif) | 1395 | dev_hold(sdata->dev); |
1423 | odev = dev_get_by_index(&init_net, skb->iif); | ||
1424 | if (unlikely(odev && !is_ieee80211_device(local, odev))) { | ||
1425 | dev_put(odev); | ||
1426 | odev = NULL; | ||
1427 | } | ||
1428 | if (unlikely(!odev)) { | ||
1429 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | ||
1430 | printk(KERN_DEBUG "%s: Discarded packet with nonexistent " | ||
1431 | "originating device\n", dev->name); | ||
1432 | #endif | ||
1433 | dev_kfree_skb(skb); | ||
1434 | return NETDEV_TX_OK; | ||
1435 | } | ||
1436 | 1396 | ||
1437 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && | 1397 | if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && |
1438 | local->hw.conf.dynamic_ps_timeout > 0 && | 1398 | local->hw.conf.dynamic_ps_timeout > 0 && |
@@ -1448,26 +1408,21 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1448 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); | 1408 | msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); |
1449 | } | 1409 | } |
1450 | 1410 | ||
1451 | memset(info, 0, sizeof(*info)); | ||
1452 | |||
1453 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; | 1411 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; |
1454 | 1412 | ||
1455 | osdata = IEEE80211_DEV_TO_SUB_IF(odev); | 1413 | if (ieee80211_vif_is_mesh(&sdata->vif) && |
1456 | |||
1457 | if (ieee80211_vif_is_mesh(&osdata->vif) && | ||
1458 | ieee80211_is_data(hdr->frame_control)) { | 1414 | ieee80211_is_data(hdr->frame_control)) { |
1459 | if (is_multicast_ether_addr(hdr->addr3)) | 1415 | if (is_multicast_ether_addr(hdr->addr3)) |
1460 | memcpy(hdr->addr1, hdr->addr3, ETH_ALEN); | 1416 | memcpy(hdr->addr1, hdr->addr3, ETH_ALEN); |
1461 | else | 1417 | else |
1462 | if (mesh_nexthop_lookup(skb, osdata)) { | 1418 | if (mesh_nexthop_lookup(skb, sdata)) { |
1463 | dev_put(odev); | 1419 | dev_put(sdata->dev); |
1464 | return NETDEV_TX_OK; | 1420 | return; |
1465 | } | 1421 | } |
1466 | if (memcmp(odev->dev_addr, hdr->addr4, ETH_ALEN) != 0) | 1422 | if (memcmp(sdata->dev->dev_addr, hdr->addr4, ETH_ALEN) != 0) |
1467 | IEEE80211_IFSTA_MESH_CTR_INC(&osdata->u.mesh, | 1423 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, |
1468 | fwded_frames); | 1424 | fwded_frames); |
1469 | } else if (unlikely(osdata->vif.type == NL80211_IFTYPE_MONITOR)) { | 1425 | } else if (unlikely(sdata->vif.type == NL80211_IFTYPE_MONITOR)) { |
1470 | struct ieee80211_sub_if_data *sdata; | ||
1471 | int hdrlen; | 1426 | int hdrlen; |
1472 | u16 len_rthdr; | 1427 | u16 len_rthdr; |
1473 | 1428 | ||
@@ -1491,19 +1446,17 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1491 | */ | 1446 | */ |
1492 | 1447 | ||
1493 | rcu_read_lock(); | 1448 | rcu_read_lock(); |
1494 | list_for_each_entry_rcu(sdata, &local->interfaces, | 1449 | list_for_each_entry_rcu(tmp_sdata, &local->interfaces, |
1495 | list) { | 1450 | list) { |
1496 | if (!netif_running(sdata->dev)) | 1451 | if (!netif_running(tmp_sdata->dev)) |
1497 | continue; | 1452 | continue; |
1498 | if (sdata->vif.type != NL80211_IFTYPE_AP) | 1453 | if (tmp_sdata->vif.type != NL80211_IFTYPE_AP) |
1499 | continue; | 1454 | continue; |
1500 | if (compare_ether_addr(sdata->dev->dev_addr, | 1455 | if (compare_ether_addr(tmp_sdata->dev->dev_addr, |
1501 | hdr->addr2)) { | 1456 | hdr->addr2)) { |
1502 | dev_hold(sdata->dev); | 1457 | dev_hold(tmp_sdata->dev); |
1503 | dev_put(odev); | 1458 | dev_put(sdata->dev); |
1504 | osdata = sdata; | 1459 | sdata = tmp_sdata; |
1505 | odev = osdata->dev; | ||
1506 | skb->iif = sdata->dev->ifindex; | ||
1507 | monitor_iface = FOUND_SDATA; | 1460 | monitor_iface = FOUND_SDATA; |
1508 | break; | 1461 | break; |
1509 | } | 1462 | } |
@@ -1512,31 +1465,31 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1512 | } | 1465 | } |
1513 | } | 1466 | } |
1514 | 1467 | ||
1515 | may_encrypt = !skb->do_not_encrypt; | 1468 | may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); |
1516 | 1469 | ||
1517 | headroom = osdata->local->tx_headroom; | 1470 | headroom = local->tx_headroom; |
1518 | if (may_encrypt) | 1471 | if (may_encrypt) |
1519 | headroom += IEEE80211_ENCRYPT_HEADROOM; | 1472 | headroom += IEEE80211_ENCRYPT_HEADROOM; |
1520 | headroom -= skb_headroom(skb); | 1473 | headroom -= skb_headroom(skb); |
1521 | headroom = max_t(int, 0, headroom); | 1474 | headroom = max_t(int, 0, headroom); |
1522 | 1475 | ||
1523 | if (ieee80211_skb_resize(osdata->local, skb, headroom, may_encrypt)) { | 1476 | if (ieee80211_skb_resize(local, skb, headroom, may_encrypt)) { |
1524 | dev_kfree_skb(skb); | 1477 | dev_kfree_skb(skb); |
1525 | dev_put(odev); | 1478 | dev_put(sdata->dev); |
1526 | return NETDEV_TX_OK; | 1479 | return; |
1527 | } | 1480 | } |
1528 | 1481 | ||
1529 | if (osdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 1482 | tmp_sdata = sdata; |
1530 | osdata = container_of(osdata->bss, | 1483 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
1531 | struct ieee80211_sub_if_data, | 1484 | tmp_sdata = container_of(sdata->bss, |
1532 | u.ap); | 1485 | struct ieee80211_sub_if_data, |
1486 | u.ap); | ||
1533 | if (likely(monitor_iface != UNKNOWN_ADDRESS)) | 1487 | if (likely(monitor_iface != UNKNOWN_ADDRESS)) |
1534 | info->control.vif = &osdata->vif; | 1488 | info->control.vif = &tmp_sdata->vif; |
1535 | |||
1536 | ieee80211_tx(odev, skb, false); | ||
1537 | dev_put(odev); | ||
1538 | 1489 | ||
1539 | return NETDEV_TX_OK; | 1490 | ieee80211_select_queue(local, skb); |
1491 | ieee80211_tx(sdata, skb, false); | ||
1492 | dev_put(sdata->dev); | ||
1540 | } | 1493 | } |
1541 | 1494 | ||
1542 | int ieee80211_monitor_start_xmit(struct sk_buff *skb, | 1495 | int ieee80211_monitor_start_xmit(struct sk_buff *skb, |
@@ -1546,6 +1499,7 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1546 | struct ieee80211_channel *chan = local->hw.conf.channel; | 1499 | struct ieee80211_channel *chan = local->hw.conf.channel; |
1547 | struct ieee80211_radiotap_header *prthdr = | 1500 | struct ieee80211_radiotap_header *prthdr = |
1548 | (struct ieee80211_radiotap_header *)skb->data; | 1501 | (struct ieee80211_radiotap_header *)skb->data; |
1502 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1549 | u16 len_rthdr; | 1503 | u16 len_rthdr; |
1550 | 1504 | ||
1551 | /* | 1505 | /* |
@@ -1583,15 +1537,9 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1583 | if (unlikely(skb->len < len_rthdr)) | 1537 | if (unlikely(skb->len < len_rthdr)) |
1584 | goto fail; /* skb too short for claimed rt header extent */ | 1538 | goto fail; /* skb too short for claimed rt header extent */ |
1585 | 1539 | ||
1586 | skb->dev = local->mdev; | ||
1587 | |||
1588 | /* needed because we set skb device to master */ | 1540 | /* needed because we set skb device to master */ |
1589 | skb->iif = dev->ifindex; | 1541 | skb->iif = dev->ifindex; |
1590 | 1542 | ||
1591 | /* sometimes we do encrypt injected frames, will be fixed | ||
1592 | * up in radiotap parser if not wanted */ | ||
1593 | skb->do_not_encrypt = 0; | ||
1594 | |||
1595 | /* | 1543 | /* |
1596 | * fix up the pointers accounting for the radiotap | 1544 | * fix up the pointers accounting for the radiotap |
1597 | * header still being in there. We are being given | 1545 | * header still being in there. We are being given |
@@ -1606,8 +1554,10 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1606 | skb_set_network_header(skb, len_rthdr); | 1554 | skb_set_network_header(skb, len_rthdr); |
1607 | skb_set_transport_header(skb, len_rthdr); | 1555 | skb_set_transport_header(skb, len_rthdr); |
1608 | 1556 | ||
1609 | /* pass the radiotap header up to the next stage intact */ | 1557 | memset(info, 0, sizeof(*info)); |
1610 | dev_queue_xmit(skb); | 1558 | |
1559 | /* pass the radiotap header up to xmit */ | ||
1560 | ieee80211_xmit(IEEE80211_DEV_TO_SUB_IF(dev), skb); | ||
1611 | return NETDEV_TX_OK; | 1561 | return NETDEV_TX_OK; |
1612 | 1562 | ||
1613 | fail: | 1563 | fail: |
@@ -1635,6 +1585,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1635 | { | 1585 | { |
1636 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1586 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1637 | struct ieee80211_local *local = sdata->local; | 1587 | struct ieee80211_local *local = sdata->local; |
1588 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1638 | int ret = NETDEV_TX_BUSY, head_need; | 1589 | int ret = NETDEV_TX_BUSY, head_need; |
1639 | u16 ethertype, hdrlen, meshhdrlen = 0; | 1590 | u16 ethertype, hdrlen, meshhdrlen = 0; |
1640 | __le16 fc; | 1591 | __le16 fc; |
@@ -1864,7 +1815,6 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1864 | 1815 | ||
1865 | skb->iif = dev->ifindex; | 1816 | skb->iif = dev->ifindex; |
1866 | 1817 | ||
1867 | skb->dev = local->mdev; | ||
1868 | dev->stats.tx_packets++; | 1818 | dev->stats.tx_packets++; |
1869 | dev->stats.tx_bytes += skb->len; | 1819 | dev->stats.tx_bytes += skb->len; |
1870 | 1820 | ||
@@ -1875,8 +1825,10 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1875 | skb_set_network_header(skb, nh_pos); | 1825 | skb_set_network_header(skb, nh_pos); |
1876 | skb_set_transport_header(skb, h_pos); | 1826 | skb_set_transport_header(skb, h_pos); |
1877 | 1827 | ||
1828 | memset(info, 0, sizeof(*info)); | ||
1829 | |||
1878 | dev->trans_start = jiffies; | 1830 | dev->trans_start = jiffies; |
1879 | dev_queue_xmit(skb); | 1831 | ieee80211_xmit(sdata, skb); |
1880 | 1832 | ||
1881 | return NETDEV_TX_OK; | 1833 | return NETDEV_TX_OK; |
1882 | 1834 | ||
@@ -1918,7 +1870,6 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local, | |||
1918 | return true; | 1870 | return true; |
1919 | } | 1871 | } |
1920 | 1872 | ||
1921 | /* validate info->control.vif against skb->iif */ | ||
1922 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1873 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1923 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | 1874 | if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) |
1924 | sdata = container_of(sdata->bss, | 1875 | sdata = container_of(sdata->bss, |
@@ -1932,12 +1883,13 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local, | |||
1932 | } | 1883 | } |
1933 | 1884 | ||
1934 | if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { | 1885 | if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { |
1935 | ieee80211_tx(dev, skb, true); | 1886 | /* do not use sdata, it may have been changed above */ |
1887 | ieee80211_tx(IEEE80211_DEV_TO_SUB_IF(dev), skb, true); | ||
1936 | } else { | 1888 | } else { |
1937 | hdr = (struct ieee80211_hdr *)skb->data; | 1889 | hdr = (struct ieee80211_hdr *)skb->data; |
1938 | sta = sta_info_get(local, hdr->addr1); | 1890 | sta = sta_info_get(local, hdr->addr1); |
1939 | 1891 | ||
1940 | ret = __ieee80211_tx(local, &skb, sta); | 1892 | ret = __ieee80211_tx(local, &skb, sta, true); |
1941 | if (ret != IEEE80211_TX_OK) | 1893 | if (ret != IEEE80211_TX_OK) |
1942 | result = false; | 1894 | result = false; |
1943 | } | 1895 | } |
@@ -1949,59 +1901,43 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local, | |||
1949 | } | 1901 | } |
1950 | 1902 | ||
1951 | /* | 1903 | /* |
1952 | * Transmit all pending packets. Called from tasklet, locks master device | 1904 | * Transmit all pending packets. Called from tasklet. |
1953 | * TX lock so that no new packets can come in. | ||
1954 | */ | 1905 | */ |
1955 | void ieee80211_tx_pending(unsigned long data) | 1906 | void ieee80211_tx_pending(unsigned long data) |
1956 | { | 1907 | { |
1957 | struct ieee80211_local *local = (struct ieee80211_local *)data; | 1908 | struct ieee80211_local *local = (struct ieee80211_local *)data; |
1958 | struct net_device *dev = local->mdev; | ||
1959 | unsigned long flags; | 1909 | unsigned long flags; |
1960 | int i; | 1910 | int i; |
1961 | bool next; | 1911 | bool txok; |
1962 | 1912 | ||
1963 | rcu_read_lock(); | 1913 | rcu_read_lock(); |
1964 | netif_tx_lock_bh(dev); | ||
1965 | 1914 | ||
1915 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | ||
1966 | for (i = 0; i < local->hw.queues; i++) { | 1916 | for (i = 0; i < local->hw.queues; i++) { |
1967 | /* | 1917 | /* |
1968 | * If queue is stopped by something other than due to pending | 1918 | * If queue is stopped by something other than due to pending |
1969 | * frames, or we have no pending frames, proceed to next queue. | 1919 | * frames, or we have no pending frames, proceed to next queue. |
1970 | */ | 1920 | */ |
1971 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 1921 | if (local->queue_stop_reasons[i] || |
1972 | next = false; | ||
1973 | if (local->queue_stop_reasons[i] != | ||
1974 | BIT(IEEE80211_QUEUE_STOP_REASON_PENDING) || | ||
1975 | skb_queue_empty(&local->pending[i])) | 1922 | skb_queue_empty(&local->pending[i])) |
1976 | next = true; | ||
1977 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
1978 | |||
1979 | if (next) | ||
1980 | continue; | 1923 | continue; |
1981 | 1924 | ||
1982 | /* | ||
1983 | * start the queue now to allow processing our packets, | ||
1984 | * we're under the tx lock here anyway so nothing will | ||
1985 | * happen as a result of this | ||
1986 | */ | ||
1987 | netif_start_subqueue(local->mdev, i); | ||
1988 | |||
1989 | while (!skb_queue_empty(&local->pending[i])) { | 1925 | while (!skb_queue_empty(&local->pending[i])) { |
1990 | struct sk_buff *skb = skb_dequeue(&local->pending[i]); | 1926 | struct sk_buff *skb = __skb_dequeue(&local->pending[i]); |
1991 | 1927 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, | |
1992 | if (!ieee80211_tx_pending_skb(local, skb)) { | 1928 | flags); |
1993 | skb_queue_head(&local->pending[i], skb); | 1929 | |
1930 | txok = ieee80211_tx_pending_skb(local, skb); | ||
1931 | if (!txok) | ||
1932 | __skb_queue_head(&local->pending[i], skb); | ||
1933 | spin_lock_irqsave(&local->queue_stop_reason_lock, | ||
1934 | flags); | ||
1935 | if (!txok) | ||
1994 | break; | 1936 | break; |
1995 | } | ||
1996 | } | 1937 | } |
1997 | |||
1998 | /* Start regular packet processing again. */ | ||
1999 | if (skb_queue_empty(&local->pending[i])) | ||
2000 | ieee80211_wake_queue_by_reason(&local->hw, i, | ||
2001 | IEEE80211_QUEUE_STOP_REASON_PENDING); | ||
2002 | } | 1938 | } |
1939 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); | ||
2003 | 1940 | ||
2004 | netif_tx_unlock_bh(dev); | ||
2005 | rcu_read_unlock(); | 1941 | rcu_read_unlock(); |
2006 | } | 1942 | } |
2007 | 1943 | ||
@@ -2176,8 +2112,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
2176 | 2112 | ||
2177 | info = IEEE80211_SKB_CB(skb); | 2113 | info = IEEE80211_SKB_CB(skb); |
2178 | 2114 | ||
2179 | skb->do_not_encrypt = 1; | 2115 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
2180 | |||
2181 | info->band = band; | 2116 | info->band = band; |
2182 | /* | 2117 | /* |
2183 | * XXX: For now, always use the lowest rate | 2118 | * XXX: For now, always use the lowest rate |
@@ -2248,9 +2183,6 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2248 | sdata = vif_to_sdata(vif); | 2183 | sdata = vif_to_sdata(vif); |
2249 | bss = &sdata->u.ap; | 2184 | bss = &sdata->u.ap; |
2250 | 2185 | ||
2251 | if (!bss) | ||
2252 | return NULL; | ||
2253 | |||
2254 | rcu_read_lock(); | 2186 | rcu_read_lock(); |
2255 | beacon = rcu_dereference(bss->beacon); | 2187 | beacon = rcu_dereference(bss->beacon); |
2256 | 2188 | ||
@@ -2276,7 +2208,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2276 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); | 2208 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); |
2277 | } | 2209 | } |
2278 | 2210 | ||
2279 | if (!ieee80211_tx_prepare(local, &tx, skb)) | 2211 | if (!ieee80211_tx_prepare(sdata, &tx, skb)) |
2280 | break; | 2212 | break; |
2281 | dev_kfree_skb_any(skb); | 2213 | dev_kfree_skb_any(skb); |
2282 | } | 2214 | } |
@@ -2296,3 +2228,18 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2296 | return skb; | 2228 | return skb; |
2297 | } | 2229 | } |
2298 | EXPORT_SYMBOL(ieee80211_get_buffered_bc); | 2230 | EXPORT_SYMBOL(ieee80211_get_buffered_bc); |
2231 | |||
2232 | void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, | ||
2233 | int encrypt) | ||
2234 | { | ||
2235 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
2236 | skb_set_mac_header(skb, 0); | ||
2237 | skb_set_network_header(skb, 0); | ||
2238 | skb_set_transport_header(skb, 0); | ||
2239 | |||
2240 | skb->iif = sdata->dev->ifindex; | ||
2241 | if (!encrypt) | ||
2242 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | ||
2243 | |||
2244 | ieee80211_xmit(sdata, skb); | ||
2245 | } | ||