linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: allow drivers to indicate failed FCS/PLCP  checksum
@ 2007-08-03 21:44 Johannes Berg
  2007-08-04  7:53 ` Johannes Berg
  2007-08-04 12:25 ` Ivo van Doorn
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Berg @ 2007-08-03 21:44 UTC (permalink / raw)
  To: John W. Linville, linux-wireless, Jiri Benc, Michael Wu
  Cc: Jiri Benc, Michael Wu, linux-wireless

This patch allows drivers to indicate bad FCS/PLCP CRC to the stack and
have the stack drop packets like that except for monitor interfaces.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
Compiles, but otherwise untested. Patch against Jiri's tree, applies to
John's tree (with some fuzz) if you change rx.c to ieee80211.c in the
patch.

 include/net/mac80211.h |    2 ++
 net/mac80211/rx.c      |   21 ++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

--- mac80211.orig/include/net/mac80211.h	2007-08-03 23:06:33.357869508 +0200
+++ mac80211/include/net/mac80211.h	2007-08-03 23:10:01.267869508 +0200
@@ -241,6 +241,8 @@ struct ieee80211_rx_status {
 #define RX_FLAG_MMIC_ERROR	(1<<0)
 #define RX_FLAG_DECRYPTED	(1<<1)
 #define RX_FLAG_RADIOTAP	(1<<2)
+#define RX_FLAG_FAILED_FCS_CRC	(1<<3)
+#define RX_FLAG_FAILED_PLCP_CRC	(1<<4)
 	int flag;
 };
 
--- mac80211.orig/net/mac80211/rx.c	2007-08-03 23:06:54.187869508 +0200
+++ mac80211/net/mac80211/rx.c	2007-08-03 23:39:41.717869508 +0200
@@ -155,6 +155,7 @@ ieee80211_rx_monitor(struct net_device *
 		__le16 chan_freq;
 		__le16 chan_flags;
 		u8 antsignal;
+		__le16 rx_flags;
 	} __attribute__ ((packed)) *rthdr;
 
 	skb->dev = dev;
@@ -179,12 +180,21 @@ ieee80211_rx_monitor(struct net_device *
 		cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
 			    (1 << IEEE80211_RADIOTAP_RATE) |
 			    (1 << IEEE80211_RADIOTAP_CHANNEL) |
-			    (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL));
+			    (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |
+			    (1 << IEEE80211_RADIOTAP_RX_FLAGS));
 	rthdr->flags = local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS ?
 		       IEEE80211_RADIOTAP_F_FCS : 0;
+
+	/* FIXME: when radiotap gets a 'bad PLCP' flag use it here */
+	rthdr->rx_flags = 0;
+	if (status->flag &
+	    (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
+		rthdr->rx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS);
+
 	rate = ieee80211_get_rate(local, status->phymode, status->rate);
 	if (rate)
 		rthdr->rate = rate->rate / 5;
+
 	rthdr->chan_freq = cpu_to_le16(status->freq);
 	rthdr->chan_flags =
 		status->phymode == MODE_IEEE80211A ?
@@ -212,6 +222,15 @@ ieee80211_rx_h_monitor(struct ieee80211_
 		return TXRX_QUEUED;
 	}
 
+	/*
+	 * Drop frames with failed FCS/PLCP checksums here, they are only
+	 * relevant for monitor mode, the rest of the stack should never
+	 * see them.
+	 */
+	if (rx->u.rx.status->flag &
+	    (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
+		return TXRX_DROP;
+
 	if (rx->u.rx.status->flag & RX_FLAG_RADIOTAP)
 		skb_pull(rx->skb, ieee80211_get_radiotap_len(rx->skb->data));
 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mac80211: allow drivers to indicate failed FCS/PLCP   checksum
  2007-08-03 21:44 [PATCH] mac80211: allow drivers to indicate failed FCS/PLCP checksum Johannes Berg
@ 2007-08-04  7:53 ` Johannes Berg
  2007-08-04 12:25 ` Ivo van Doorn
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2007-08-04  7:53 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, Jiri Benc, Michael Wu

On Fri, 2007-08-03 at 23:44 +0200, Johannes Berg wrote:

> --- mac80211.orig/net/mac80211/rx.c	2007-08-03 23:06:54.187869508 +0200
> +++ mac80211/net/mac80211/rx.c	2007-08-03 23:39:41.717869508 +0200
> @@ -155,6 +155,7 @@ ieee80211_rx_monitor(struct net_device *
>  		__le16 chan_freq;
>  		__le16 chan_flags;
>  		u8 antsignal;
> +		__le16 rx_flags;
>  	} __attribute__ ((packed)) *rthdr;

Oh. I overlooked the packed attribute there, this additional patch is
needed:

--- mac80211.orig/net/mac80211/rx.c     2007-08-03 23:06:54.187869508 +0200
+++ mac80211/net/mac80211/rx.c  2007-08-03 23:39:41.717869508 +0200
@@ -155,6 +155,7 @@ ieee80211_rx_monitor(struct net_device *
 		__le16 chan_freq;
 		__le16 chan_flags;
 		u8 antsignal;
+		u8 padding_for_rx_flags;
 		__le16 rx_flags;
 	} __attribute__ ((packed)) *rthdr;
 

(patch fabricated by hand so might not apply)

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mac80211: allow drivers to indicate failed FCS/PLCP checksum
  2007-08-03 21:44 [PATCH] mac80211: allow drivers to indicate failed FCS/PLCP checksum Johannes Berg
  2007-08-04  7:53 ` Johannes Berg
@ 2007-08-04 12:25 ` Ivo van Doorn
  2007-08-06  8:07   ` Johannes Berg
  1 sibling, 1 reply; 4+ messages in thread
From: Ivo van Doorn @ 2007-08-04 12:25 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John W. Linville, linux-wireless, Jiri Benc, Michael Wu

Hi,

> @@ -241,6 +241,8 @@ struct ieee80211_rx_status {
>  #define RX_FLAG_MMIC_ERROR	(1<<0)
>  #define RX_FLAG_DECRYPTED	(1<<1)
>  #define RX_FLAG_RADIOTAP	(1<<2)
> +#define RX_FLAG_FAILED_FCS_CRC	(1<<3)
> +#define RX_FLAG_FAILED_PLCP_CRC	(1<<4)
>  	int flag;
>  };

This looks good, but there is a slight problem for rt2x00.
The package descriptor knows 3 kind of errors for a received frame:

	CRC error
	Physical error
	Cipher error

For the CRC error I don't know if that is the FCS or PLCP error..
And should the other 2 be also passed to mac80211 or should those
be stopped?
For the cipher error it could perhaps be possible to send it to mac80211
without the RX_FLAG_DECRYPTED bit set. (At the moment rt2x00 doesn't
see this error yet, because hardware encryption is not yet implemented).

Ivo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mac80211: allow drivers to indicate failed FCS/PLCP  checksum
  2007-08-04 12:25 ` Ivo van Doorn
@ 2007-08-06  8:07   ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2007-08-06  8:07 UTC (permalink / raw)
  To: Ivo van Doorn; +Cc: John W. Linville, linux-wireless, Jiri Benc, Michael Wu

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

On Sat, 2007-08-04 at 14:25 +0200, Ivo van Doorn wrote:

> The package descriptor knows 3 kind of errors for a received frame:
> 
> 	CRC error
> 	Physical error
> 	Cipher error
> 
> For the CRC error I don't know if that is the FCS or PLCP error..

CRC is most likely FCS. And Physical ist most likely the PLCP CRC.

> For the cipher error it could perhaps be possible to send it to mac80211
> without the RX_FLAG_DECRYPTED bit set. (At the moment rt2x00 doesn't
> see this error yet, because hardware encryption is not yet implemented).

Not sure what mac80211 does for crypto errors, I expect you want to send
them up without having it decrypted, it'll attempt it and then do the
appropriate actions. Seems it should be possible to short-circuit that
somehow, but I don't know if it is right now.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-06  8:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-03 21:44 [PATCH] mac80211: allow drivers to indicate failed FCS/PLCP checksum Johannes Berg
2007-08-04  7:53 ` Johannes Berg
2007-08-04 12:25 ` Ivo van Doorn
2007-08-06  8:07   ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).