linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kalle.valo@iki.fi>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 06/12] wl1251: fix payload alignment
Date: Thu, 26 Nov 2009 17:09:04 +0200	[thread overview]
Message-ID: <20091126150904.917.8182.stgit@tikku> (raw)
In-Reply-To: <20091126150141.917.35278.stgit@tikku>

From: Kalle Valo <kalle.valo@nokia.com>

mac80211 complained that in some cases IP payload was not aligned, this
happens if the 802.11 header is not aligned with four. In that case we have
to move entire packet to make the payload properly aligned.

Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
---
 drivers/net/wireless/wl12xx/wl1251_rx.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/wl1251_rx.c b/drivers/net/wireless/wl12xx/wl1251_rx.c
index f84cc89..04f3dcd 100644
--- a/drivers/net/wireless/wl12xx/wl1251_rx.c
+++ b/drivers/net/wireless/wl12xx/wl1251_rx.c
@@ -22,6 +22,7 @@
  *
  */
 
+#include <linux/string.h>
 #include <linux/skbuff.h>
 #include <net/mac80211.h>
 
@@ -32,6 +33,9 @@
 #include "wl1251_cmd.h"
 #include "wl1251_acx.h"
 
+/* needs to be divisible by four because of DMA */
+#define WL1251_RX_ALIGNMENT	4
+
 static void wl1251_rx_header(struct wl1251 *wl,
 			     struct wl1251_rx_descriptor *desc)
 {
@@ -106,6 +110,7 @@ static void wl1251_rx_body(struct wl1251 *wl,
 	struct sk_buff *skb;
 	struct ieee80211_rx_status status;
 	u8 *rx_buffer, beacon = 0;
+	unsigned char *from, *to;
 	u16 length, *fc;
 	u32 curr_id, last_id_inc, rx_packet_ring_addr;
 
@@ -126,12 +131,15 @@ static void wl1251_rx_body(struct wl1251 *wl,
 	if (wl->rx_current_buffer)
 		rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size;
 
-	skb = dev_alloc_skb(length);
+	skb = dev_alloc_skb(length + WL1251_RX_ALIGNMENT);
 	if (!skb) {
 		wl1251_error("Couldn't allocate RX frame");
 		return;
 	}
 
+	/* for the case if payload is unaligned */
+	skb_reserve(skb, WL1251_RX_ALIGNMENT);
+
 	rx_buffer = skb_put(skb, length);
 	wl1251_mem_read(wl, rx_packet_ring_addr, rx_buffer, length);
 
@@ -140,6 +148,13 @@ static void wl1251_rx_body(struct wl1251 *wl,
 
 	fc = (u16 *)skb->data;
 
+	if (ieee80211_hdrlen(*fc) & 0x3) {
+		from = skb->data;
+		to = skb_push(skb, 2);
+		memmove(to, from, skb->len);
+		fc = (u16 *) skb->data;
+	}
+
 	if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)
 		beacon = 1;
 


  parent reply	other threads:[~2009-11-26 15:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-26 15:08 [PATCH 00/12] wl1251 WMM support and minor fixes Kalle Valo
2009-11-26 15:08 ` [PATCH 01/12] wl1251: add tx queue status to debugfs Kalle Valo
2009-11-26 15:08 ` [PATCH 02/12] wl1251: print a debug message when tx_queue is full Kalle Valo
2009-11-26 15:08 ` [PATCH 03/12] wl1251: fix error handling in wl1251_op_config() Kalle Valo
2009-11-26 15:08 ` [PATCH 04/12] wl1251: reduce ELP wakeup timeout Kalle Valo
2009-11-26 15:08 ` [PATCH 05/12] wl1251: simplify ELP wakeup time calculation Kalle Valo
2009-11-26 15:09 ` Kalle Valo [this message]
2009-11-26 15:13   ` [PATCH 06/12] wl1251: fix payload alignment Kalle Valo
2009-11-26 18:13     ` Johannes Berg
2009-11-27 11:08       ` Kalle Valo
2009-11-27 11:11         ` Johannes Berg
2009-11-27 11:32           ` Kalle Valo
2009-11-26 15:09 ` [PATCH 07/12] wl1251: use __dev_alloc_skb() on RX Kalle Valo
2009-11-26 15:09 ` [PATCH 08/12] wl1251: implement acx_ac_cfg to configure hardware queues Kalle Valo
2009-11-26 15:09 ` [PATCH 09/12] wl1251: implement wl1251_acx_tid_cfg() Kalle Valo
2009-11-26 15:09 ` [PATCH 10/12] wl1251: implement WMM Kalle Valo
2009-11-26 15:09 ` [PATCH 11/12] wl1251: update tx_hdr when aliging skb in tx Kalle Valo
2009-11-26 15:09 ` [PATCH 12/12] wl1251: enable WMM Kalle Valo
2009-11-27 13:30 ` [PATCH 00/12] wl1251 WMM support and minor fixes Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091126150904.917.8182.stgit@tikku \
    --to=kalle.valo@iki.fi \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).