Skip to content

Commit a26eb27

Browse files
jmberg-intellinvjw
authored andcommitted
mac80211: move fragment flag to info flag as dont-fragment
The purpose of this is two-fold: 1) by moving it out of tx_data.flags, we can in another patch move the radiotap parsing so it no longer is in the hotpath 2) if a device implements fragmentation but can optionally skip it, the radiotap request for not doing fragmentation may be honoured Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 68f2b51 commit a26eb27

4 files changed

Lines changed: 20 additions & 27 deletions

File tree

‎include/net/mac80211.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ struct ieee80211_bss_conf {
375375
* @IEEE80211_TX_CTL_USE_MINRATE: This frame will be sent at lowest rate.
376376
* This flag is used to send nullfunc frame at minimum rate when
377377
* the nullfunc is used for connection monitoring purpose.
378+
* @IEEE80211_TX_CTL_DONTFRAG: Don't fragment this packet even if it
379+
* would be fragmented by size (this is optional, only used for
380+
* monitor injection).
378381
*
379382
* Note: If you have to add new flags to the enumeration, then don't
380383
* forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
@@ -408,6 +411,7 @@ enum mac80211_tx_control_flags {
408411
IEEE80211_TX_CTL_NO_CCK_RATE = BIT(27),
409412
IEEE80211_TX_STATUS_EOSP = BIT(28),
410413
IEEE80211_TX_CTL_USE_MINRATE = BIT(29),
414+
IEEE80211_TX_CTL_DONTFRAG = BIT(30),
411415
};
412416

413417
#define IEEE80211_TX_CTL_STBC_SHIFT 23

‎net/mac80211/ieee80211_i.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ typedef unsigned __bitwise__ ieee80211_tx_result;
136136
#define TX_DROP ((__force ieee80211_tx_result) 1u)
137137
#define TX_QUEUED ((__force ieee80211_tx_result) 2u)
138138

139-
#define IEEE80211_TX_FRAGMENTED BIT(0)
140139
#define IEEE80211_TX_UNICAST BIT(1)
141140
#define IEEE80211_TX_PS_BUFFERED BIT(2)
142141

‎net/mac80211/tx.c‎

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,10 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
898898
int hdrlen;
899899
int fragnum;
900900

901-
if (!(tx->flags & IEEE80211_TX_FRAGMENTED))
901+
if (info->flags & IEEE80211_TX_CTL_DONTFRAG)
902+
return TX_CONTINUE;
903+
904+
if (tx->local->ops->set_frag_threshold)
902905
return TX_CONTINUE;
903906

904907
/*
@@ -911,7 +914,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
911914

912915
hdrlen = ieee80211_hdrlen(hdr->frame_control);
913916

914-
/* internal error, why is TX_FRAGMENTED set? */
917+
/* internal error, why isn't DONTFRAG set? */
915918
if (WARN_ON(skb->len + FCS_LEN <= frag_threshold))
916919
return TX_DROP;
917920

@@ -1050,17 +1053,13 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
10501053
struct ieee80211_radiotap_iterator iterator;
10511054
struct ieee80211_radiotap_header *rthdr =
10521055
(struct ieee80211_radiotap_header *) skb->data;
1053-
bool hw_frag;
10541056
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
10551057
int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len,
10561058
NULL);
10571059
u16 txflags;
10581060

1059-
info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
1060-
tx->flags &= ~IEEE80211_TX_FRAGMENTED;
1061-
1062-
/* packet is fragmented in HW if we have a non-NULL driver callback */
1063-
hw_frag = (tx->local->ops->set_frag_threshold != NULL);
1061+
info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT |
1062+
IEEE80211_TX_CTL_DONTFRAG;
10641063

10651064
/*
10661065
* for every radiotap entry that is present
@@ -1098,9 +1097,8 @@ static bool __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx,
10981097
}
10991098
if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP)
11001099
info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT;
1101-
if ((*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) &&
1102-
!hw_frag)
1103-
tx->flags |= IEEE80211_TX_FRAGMENTED;
1100+
if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG)
1101+
info->flags &= ~IEEE80211_TX_CTL_DONTFRAG;
11041102
break;
11051103

11061104
case IEEE80211_RADIOTAP_TX_FLAGS:
@@ -1206,13 +1204,6 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
12061204
tx->local = local;
12071205
tx->sdata = sdata;
12081206
tx->channel = local->hw.conf.channel;
1209-
/*
1210-
* Set this flag (used below to indicate "automatic fragmentation"),
1211-
* it will be cleared/left by radiotap as desired.
1212-
* Only valid when fragmentation is done by the stack.
1213-
*/
1214-
if (!local->ops->set_frag_threshold)
1215-
tx->flags |= IEEE80211_TX_FRAGMENTED;
12161207

12171208
/* process and remove the injection radiotap header */
12181209
if (unlikely(info->flags & IEEE80211_TX_INTFL_HAS_RADIOTAP)) {
@@ -1281,13 +1272,11 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
12811272
*/
12821273
}
12831274

1284-
if (tx->flags & IEEE80211_TX_FRAGMENTED) {
1285-
if ((tx->flags & IEEE80211_TX_UNICAST) &&
1286-
skb->len + FCS_LEN > local->hw.wiphy->frag_threshold &&
1287-
!(info->flags & IEEE80211_TX_CTL_AMPDU))
1288-
tx->flags |= IEEE80211_TX_FRAGMENTED;
1289-
else
1290-
tx->flags &= ~IEEE80211_TX_FRAGMENTED;
1275+
if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) {
1276+
if (!(tx->flags & IEEE80211_TX_UNICAST) ||
1277+
skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold ||
1278+
info->flags & IEEE80211_TX_CTL_AMPDU)
1279+
info->flags |= IEEE80211_TX_CTL_DONTFRAG;
12911280
}
12921281

12931282
if (!tx->sta)

‎net/mac80211/wpa.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
5353
}
5454

5555
if (info->control.hw_key &&
56-
!(tx->flags & IEEE80211_TX_FRAGMENTED) &&
56+
(info->flags & IEEE80211_TX_CTL_DONTFRAG ||
57+
tx->local->ops->set_frag_threshold) &&
5758
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) {
5859
/* hwaccel - with no need for SW-generated MMIC */
5960
return TX_CONTINUE;

0 commit comments

Comments
 (0)