From: Ivo van Doorn <ivdoorn@gmail.com>
To: Jiri Benc <jbenc@suse.cz>, "John Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH v2] d80211: Add software sequence support
Date: Wed, 14 Feb 2007 14:23:27 +0100 [thread overview]
Message-ID: <200702141423.27823.IvDoorn@gmail.com> (raw)
Most hardware can keep track of sequence numbers themselves,
unfortunately *most* doesn't cover all devices. ;)
This patch will keep track of the (per-bss) sequence number
if the flag IEEE80211_HW_SOFTWARE_SEQUENCE has been set.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
---
diff --git a/include/net/d80211.h b/include/net/d80211.h
index 326def5..5dd4943 100644
--- a/include/net/d80211.h
+++ b/include/net/d80211.h
@@ -534,6 +534,9 @@ struct ieee80211_hw {
* per-packet RC4 key with each TX frame when doing hwcrypto */
#define IEEE80211_HW_TKIP_REQ_PHASE2_KEY (1<<14)
+ /* Does the HOST need to insert the frame sequence counter */
+#define IEEE80211_HW_SOFTWARE_SEQUENCE (1<<15)
+
u32 flags; /* hardware flags defined above */
/* Set to the size of a needed device specific skb headroom for TX skbs. */
diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index 82daeb8..455f67a 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -50,6 +50,29 @@ static u8 * ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
static int ieee80211_mgmt_start_xmit(struct sk_buff *skb,
struct net_device *dev);
+static void ieee80211_include_sequence(struct net_device *dev,
+ struct ieee80211_hdr *hdr)
+{
+ struct ieee80211_sta_bss *bss;
+ u8 *bssid = ieee80211_get_bssid(hdr, sizeof(*hdr));
+
+ bss = ieee80211_rx_bss_get(dev, bssid);
+ if (!bss)
+ return;
+
+ /*
+ * Set the sequence number for this frame.
+ */
+ hdr->seq_ctrl = cpu_to_le16(bss->sequence & IEEE80211_SCTL_SEQ);
+
+ /*
+ * Increase the sequence number.
+ */
+ bss->sequence = (bss->sequence + 0x10) & IEEE80211_SCTL_SEQ;
+
+ ieee80211_rx_bss_put(dev, bss);
+}
+
struct ieee80211_key_conf *
ieee80211_key_data2conf(struct ieee80211_local *local,
struct ieee80211_key *data)
@@ -441,6 +464,7 @@ ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx)
size_t hdrlen, per_fragm, num_fragm, payload_len, left;
struct sk_buff **frags, *first, *frag;
int i;
+ u16 seq;
u8 *pos;
int frag_threshold = tx->local->fragmentation_threshold;
@@ -459,6 +483,7 @@ ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx)
goto fail;
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS);
+ seq = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ;
pos = first->data + hdrlen + per_fragm;
left = payload_len - per_fragm;
for (i = 0; i < num_fragm - 1; i++) {
@@ -486,7 +511,7 @@ ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx)
memcpy(fhdr, first->data, hdrlen);
if (i == num_fragm - 2)
fhdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREFRAGS);
- fhdr->seq_ctrl = cpu_to_le16(i + 1);
+ fhdr->seq_ctrl = cpu_to_le16(seq + ((i + 1) & IEEE80211_SCTL_FRAG));
copylen = left > per_fragm ? per_fragm : left;
memcpy(skb_put(frag, copylen), pos, copylen);
@@ -896,6 +921,17 @@ ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx)
return TXRX_CONTINUE;
}
+static ieee80211_txrx_result
+ieee80211_tx_h_sequence(struct ieee80211_txrx_data *tx)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
+
+ if ((tx->local->hw.flags & IEEE80211_HW_SOFTWARE_SEQUENCE) &&
+ ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24)
+ ieee80211_include_sequence(tx->dev, hdr);
+
+ return TXRX_CONTINUE;
+}
/* This function is called whenever the AP is about to exceed the maximum limit
* of buffered frames for power saving STAs. This situation should not really
@@ -1765,6 +1801,10 @@ struct sk_buff * ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id,
skb_reserve(skb, local->hw.extra_tx_headroom);
memcpy(skb_put(skb, bh_len), b_head, bh_len);
+ if (hw->flags & IEEE80211_HW_SOFTWARE_SEQUENCE)
+ ieee80211_include_sequence(bdev,
+ (struct ieee80211_hdr *)skb->data);
+
ieee80211_beacon_add_tim(local, ap, skb);
if (b_tail) {
@@ -4369,6 +4409,7 @@ static ieee80211_rx_handler ieee80211_rx_handlers[] =
static ieee80211_tx_handler ieee80211_tx_handlers[] =
{
ieee80211_tx_h_check_assoc,
+ ieee80211_tx_h_sequence,
ieee80211_tx_h_ps_buf,
ieee80211_tx_h_select_key,
ieee80211_tx_h_michael_mic_add,
diff --git a/net/d80211/ieee80211_i.h b/net/d80211/ieee80211_i.h
index 5ab9eb5..1891e05 100644
--- a/net/d80211/ieee80211_i.h
+++ b/net/d80211/ieee80211_i.h
@@ -80,6 +80,7 @@ struct ieee80211_sta_bss {
u8 ssid[IEEE80211_MAX_SSID_LEN];
size_t ssid_len;
u16 capability; /* host byte order */
+ u16 sequence;
int hw_mode;
int channel;
int freq;
@@ -682,6 +683,10 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
u8 *addr);
int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
+struct ieee80211_sta_bss *
+ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid);
+void ieee80211_rx_bss_put(struct net_device *dev,
+ struct ieee80211_sta_bss *bss);
/* ieee80211_dev.c */
int ieee80211_dev_alloc_index(struct ieee80211_local *local);
diff --git a/net/d80211/ieee80211_sta.c b/net/d80211/ieee80211_sta.c
index 433a11b..64c9c9f 100644
--- a/net/d80211/ieee80211_sta.c
+++ b/net/d80211/ieee80211_sta.c
@@ -57,10 +57,6 @@
static void ieee80211_send_probe_req(struct net_device *dev, u8 *dst,
u8 *ssid, size_t ssid_len);
-static struct ieee80211_sta_bss *
-ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid);
-static void ieee80211_rx_bss_put(struct net_device *dev,
- struct ieee80211_sta_bss *bss);
static int ieee80211_sta_find_ibss(struct net_device *dev,
struct ieee80211_if_sta *ifsta);
static int ieee80211_sta_wep_configured(struct net_device *dev);
@@ -1274,7 +1270,7 @@ ieee80211_rx_bss_add(struct net_device *dev, u8 *bssid)
}
-static struct ieee80211_sta_bss *
+struct ieee80211_sta_bss *
ieee80211_rx_bss_get(struct net_device *dev, u8 *bssid)
{
struct ieee80211_local *local = dev->ieee80211_ptr;
@@ -1303,8 +1299,8 @@ static void ieee80211_rx_bss_free(struct ieee80211_sta_bss *bss)
}
-static void ieee80211_rx_bss_put(struct net_device *dev,
- struct ieee80211_sta_bss *bss)
+void ieee80211_rx_bss_put(struct net_device *dev,
+ struct ieee80211_sta_bss *bss)
{
struct ieee80211_local *local = dev->ieee80211_ptr;
if (!atomic_dec_and_test(&bss->users))
next reply other threads:[~2007-02-14 13:24 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-14 13:23 Ivo van Doorn [this message]
2007-02-15 16:42 ` [PATCH v2] d80211: Add software sequence support Johannes Berg
2007-02-15 17:41 ` John W. Linville
2007-02-15 18:54 ` Ivo Van Doorn
2007-02-15 19:02 ` Michael Wu
2007-02-15 19:11 ` Jiri Benc
2007-02-15 19:22 ` Michael Wu
2007-02-15 20:04 ` Jouni Malinen
2007-02-15 19:09 ` Jiri Benc
2007-02-15 20:48 ` Michael Wu
2007-02-15 20:57 ` Jiri Benc
2007-02-15 22:18 ` Ivo Van Doorn
2007-02-16 12:03 ` Jiri Benc
2007-02-16 12:25 ` Ivo van Doorn
2007-02-16 12:58 ` Jiri Benc
2007-02-16 14:29 ` Ivo van Doorn
2007-02-16 21:14 ` Johannes Berg
2007-02-16 22:07 ` Ivo van Doorn
2007-02-16 22:12 ` Johannes Berg
2007-02-19 19:40 ` Jiri Benc
2007-02-19 19:52 ` Johannes Berg
2007-03-10 14:38 ` Ivo van Doorn
2007-03-10 17:51 ` Michael Wu
2007-03-10 19:01 ` Ivo van Doorn
2007-03-10 19:21 ` [PATCH v3] " Ivo van Doorn
2007-03-10 19:32 ` Michael Buesch
2007-03-10 23:25 ` Ivo van Doorn
2007-03-23 17:52 ` Jiri Benc
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=200702141423.27823.IvDoorn@gmail.com \
--to=ivdoorn@gmail.com \
--cc=jbenc@suse.cz \
--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).