diff mbox

[v3] 802.11n frame injection

Message ID BANLkTim_YzVXG5g+92AkvJhhQ4OkeW4wMw@mail.gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Matteo Croce June 4, 2011, 5:42 p.m. UTC
Allow to set the tx rate and retries when injecting:
read the information from the radiotap header and populate the retry chain

Signed-off-by: Matteo Croce <matteo@openwrt.org>

Comments

Johannes Berg June 6, 2011, 9:35 a.m. UTC | #1
On Sat, 2011-06-04 at 19:42 +0200, Matteo Croce wrote:

> +		case IEEE80211_RADIOTAP_RATE: {
> +			struct ieee80211_supported_band *sband =
> +				tx->local->hw.wiphy->bands[tx->channel->band];
> +			info->control.rates[0].idx = 0;
> +			if (*iterator.this_arg) {
> +				int i;
> +				for (i = 0; i < sband->n_bitrates; i++)
> +					if (sband->bitrates[i].bitrate ==
> +						*iterator.this_arg * 5) {
> +						info->control.rates[0].idx = i;
> +						break;

I don't think you should set the index if the bitrate doesn't exist.

Also, have you actually _tested_ this patch? I see nothing that would
cause rate control to be skipped, so rate control should always override
the data you set up here.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg June 6, 2011, 10:33 a.m. UTC | #2
On Mon, 2011-06-06 at 12:28 +0200, Matteo Croce wrote:

> > Also, have you actually _tested_ this patch? I see nothing that would
> > cause rate control to be skipped, so rate control should always override
> > the data you set up here.

> Actually I use this patch on many devices.
> The rate control is not an issue as this patch is intended for
> injecting in monitor mode

Even monitor mode frames still go through rate control handling.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/net/mac80211/tx.c	2011-06-01 21:04:32.000000000 +0200
+++ b/net/mac80211/tx.c	2011-06-04 19:38:36.356443309 +0200
@@ -1092,6 +1092,46 @@ 
 				tx->flags |= IEEE80211_TX_FRAGMENTED;
 			break;

+		case IEEE80211_RADIOTAP_RATE: {
+			struct ieee80211_supported_band *sband =
+				tx->local->hw.wiphy->bands[tx->channel->band];
+			info->control.rates[0].idx = 0;
+			if (*iterator.this_arg) {
+				int i;
+				for (i = 0; i < sband->n_bitrates; i++)
+					if (sband->bitrates[i].bitrate ==
+						*iterator.this_arg * 5) {
+						info->control.rates[0].idx = i;
+						break;
+					}
+			}
+			info->control.rates[0].flags = 0;
+			info->control.rates[1].idx = -1;
+			info->control.rates[2].idx = -1;
+			info->control.rates[3].idx = -1;
+			info->control.rates[4].idx = -1;
+			break;
+		}
+
+		case IEEE80211_RADIOTAP_DATA_RETRIES:
+			info->control.rates[0].count = *iterator.this_arg;
+			break;
+
+		case IEEE80211_RADIOTAP_MCS: {
+			u8 flags = iterator.this_arg[1];
+			u8 mcs = iterator.this_arg[2];
+			info->control.rates[0].idx = mcs;
+			info->control.rates[0].flags |=
+				IEEE80211_TX_RC_MCS;
+			if (flags & IEEE80211_RADIOTAP_MCS_BW_40)
+				info->control.rates[0].flags |=
+				IEEE80211_TX_RC_40_MHZ_WIDTH;
+			if (flags & IEEE80211_RADIOTAP_MCS_SGI)
+				info->control.rates[0].flags |=
+				IEEE80211_TX_RC_SHORT_GI;
+			break;
+		}
+
 		/*
 		 * Please update the file
 		 * Documentation/networking/mac80211-injection.txt
--- a/net/wireless/radiotap.c	2011-06-01 21:04:24.000000000 +0200
+++ b/net/wireless/radiotap.c	2011-06-04 19:00:49.453007027 +0200
@@ -40,6 +40,7 @@ 
 	[IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, },
 	[IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, },
 	[IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, },
+	[IEEE80211_RADIOTAP_MCS] = { .align = 1, .size = 3, },
 	/*
 	 * add more here as they are defined in radiotap.h
 	 */