All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] d80211: use const
@ 2007-02-23  0:10 Stephen Hemminger
  2007-02-23  0:11 ` [PATCH 2/3] bcm43xx: build failure Stephen Hemminger
  2007-02-23  0:12 ` [PATCH 3/3] d80211: convert to use compare_ether_addr Stephen Hemminger
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Hemminger @ 2007-02-23  0:10 UTC (permalink / raw)
  To: linux-wireless


Use const to indicate constant arguments and encapsulation headers.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
 include/net/d80211.h     |    2 +-
 net/d80211/ieee80211.c   |   39 ++++++++++++++++++++-------------------
 net/d80211/ieee80211_i.h |    2 +-
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/include/net/d80211.h b/include/net/d80211.h
index 551fe46..5f291e9 100644
--- a/include/net/d80211.h
+++ b/include/net/d80211.h
@@ -931,7 +931,7 @@ int ieee80211_set_aid_for_sta(struct iee
  * headers). If the data in the sk_buff is too short to contain a valid 802.11
  * header the function returns 0.
  */
-int ieee80211_get_hdrlen_from_skb(struct sk_buff *skb);
+int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
 
 /* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */
 int ieee80211_get_hdrlen(u16 fc);
diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index 273cba1..73e34a0 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -34,15 +34,16 @@ #include "ieee80211_led.h"
 
 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
-static unsigned char rfc1042_header[] =
-{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+static const unsigned char rfc1042_header[] =
+	{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+
 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
-static unsigned char bridge_tunnel_header[] =
-{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
-/* No encapsulation header if EtherType < 0x600 (=length) */
+static const unsigned char bridge_tunnel_header[] =
+	{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
 
-static unsigned char eapol_header[] =
-{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e };
+/* No encapsulation header if EtherType < 0x600 (=length) */
+static const unsigned char eapol_header[] =
+	{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e };
 
 
 static u8 * ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
@@ -52,7 +53,7 @@ static int ieee80211_mgmt_start_xmit(str
 
 struct ieee80211_key_conf *
 ieee80211_key_data2conf(struct ieee80211_local *local,
-			struct ieee80211_key *data)
+			const struct ieee80211_key *data)
 {
 	struct ieee80211_key_conf *conf;
 
@@ -114,7 +115,7 @@ void ieee80211_key_release(struct kobjec
 	kfree(key);
 }
 
-static int rate_list_match(int *rate_list, int rate)
+static int rate_list_match(const int *rate_list, int rate)
 {
 	int i;
 
@@ -269,9 +270,9 @@ int ieee80211_get_hdrlen(u16 fc)
 }
 EXPORT_SYMBOL(ieee80211_get_hdrlen);
 
-int ieee80211_get_hdrlen_from_skb(struct sk_buff *skb)
+int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb)
 {
-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+	const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data;
 	int hdrlen;
 
 	if (unlikely(skb->len < 10))
@@ -285,9 +286,9 @@ EXPORT_SYMBOL(ieee80211_get_hdrlen_from_
 
 #ifdef CONFIG_D80211_LOWTX_FRAME_DUMP
 static void ieee80211_dump_frame(const char *ifname, const char *title,
-				 struct sk_buff *skb)
+				 const struct sk_buff *skb)
 {
-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+	const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 	u16 fc;
 	int hdrlen;
 
@@ -322,16 +323,16 @@ static inline void ieee80211_dump_frame(
 #endif /* CONFIG_D80211_LOWTX_FRAME_DUMP */
 
 
-static int ieee80211_is_eapol(struct sk_buff *skb)
+static int ieee80211_is_eapol(const struct sk_buff *skb)
 {
-	struct ieee80211_hdr *hdr;
+	const struct ieee80211_hdr *hdr;
 	u16 fc;
 	int hdrlen;
 
 	if (unlikely(skb->len < 10))
 		return 0;
 
-	hdr = (struct ieee80211_hdr *) skb->data;
+	hdr = (const struct ieee80211_hdr *) skb->data;
 	fc = le16_to_cpu(hdr->frame_control);
 
 	if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
@@ -1118,13 +1119,13 @@ static void inline ieee80211_tx_prepare(
 	__ieee80211_tx_prepare(tx, skb, dev, control);
 }
 
-static inline int __ieee80211_queue_stopped(struct ieee80211_local *local,
+static inline int __ieee80211_queue_stopped(const struct ieee80211_local *local,
 					    int queue)
 {
 	return test_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]);
 }
 
-static inline int __ieee80211_queue_pending(struct ieee80211_local *local,
+static inline int __ieee80211_queue_pending(const struct ieee80211_local *local,
 					    int queue)
 {
 	return test_bit(IEEE80211_LINK_STATE_PENDING, &local->state[queue]);
@@ -1429,7 +1430,7 @@ static int ieee80211_subif_start_xmit(st
 	int ret = 1, head_need;
 	u16 ethertype, hdrlen, fc;
 	struct ieee80211_hdr hdr;
-	u8 *encaps_data;
+	const u8 *encaps_data;
         int encaps_len, skip_header_bytes;
 	int nh_pos, h_pos, no_encrypt = 0;
 	struct sta_info *sta;
diff --git a/net/d80211/ieee80211_i.h b/net/d80211/ieee80211_i.h
index 0c3b054..71eb25f 100644
--- a/net/d80211/ieee80211_i.h
+++ b/net/d80211/ieee80211_i.h
@@ -607,7 +607,7 @@ int ieee80211_if_config(struct net_devic
 int ieee80211_if_config_beacon(struct net_device *dev);
 struct ieee80211_key_conf *
 ieee80211_key_data2conf(struct ieee80211_local *local,
-			struct ieee80211_key *data);
+			const struct ieee80211_key *data);
 struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
 					  int idx, size_t key_len, gfp_t flags);
 void ieee80211_key_free(struct ieee80211_key *key);
-- 
1.4.1


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

* [PATCH 2/3] bcm43xx: build failure
  2007-02-23  0:10 [PATCH 1/3] d80211: use const Stephen Hemminger
@ 2007-02-23  0:11 ` Stephen Hemminger
  2007-02-23  0:31   ` Michael Wu
  2007-02-23  0:12 ` [PATCH 3/3] d80211: convert to use compare_ether_addr Stephen Hemminger
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2007-02-23  0:11 UTC (permalink / raw)
  To: linux-wireless

Looks like the ssi field changed.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
 drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c
index cdce227..5c21b27 100644
--- a/drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c
@@ -3681,7 +3681,7 @@ static int bcm43xx_wireless_init(struct 
 		    IEEE80211_HW_MONITOR_DURING_OPER |
 		    IEEE80211_HW_DEVICE_HIDES_WEP |
 		    IEEE80211_HW_WEP_INCLUDE_IV;
-	hw->maxssi = BCM43xx_RX_MAX_SSI;
+	hw->max_rssi = BCM43xx_RX_MAX_SSI;
 	hw->queues = 1;
 	hw->dev = &dev->dev;
 	if (is_valid_ether_addr(sprom->r1.et1mac)) {
-- 
1.4.1


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

* [PATCH 3/3] d80211: convert to use compare_ether_addr
  2007-02-23  0:10 [PATCH 1/3] d80211: use const Stephen Hemminger
  2007-02-23  0:11 ` [PATCH 2/3] bcm43xx: build failure Stephen Hemminger
@ 2007-02-23  0:12 ` Stephen Hemminger
  2007-02-23 16:55   ` Jiri Benc
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2007-02-23  0:12 UTC (permalink / raw)
  To: linux-wireless

compare_ether_addr is faster than memcmp()

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
 net/d80211/ieee80211.c |   45 ++++++++++++++++++++++-----------------------
 1 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index 73e34a0..6ffba74 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -2310,15 +2310,14 @@ static int ieee80211_open(struct net_dev
 	list_for_each_entry(nsdata, &local->sub_if_list, list) {
 		struct net_device *ndev = nsdata->dev;
 
-		if (ndev != dev && ndev != local->mdev &&
-		    netif_running(ndev) &&
-		    memcmp(dev->dev_addr, ndev->dev_addr, ETH_ALEN) == 0 &&
-		    !identical_mac_addr_allowed(sdata->type, nsdata->type)) {
+		if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
+		    compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0 &&
+		    !identical_mac_addr_allowed(sdata->type, nsdata->type))
 			return -ENOTUNIQ;
-		}
 	}
-	if (sdata->type == IEEE80211_IF_TYPE_WDS &&
-	    memcmp(sdata->u.wds.remote_addr, "\0\0\0\0\0\0", ETH_ALEN) == 0)
+
+	if (sdata->type == IEEE80211_IF_TYPE_WDS && 
+	    is_zero_ether_addr(sdata->u.wds.remote_addr))
 		return -ENOLINK;
 
 	if (sdata->type == IEEE80211_IF_TYPE_MNTR && local->open_count &&
@@ -2436,9 +2435,9 @@ static int header_parse_80211(struct sk_
 	return ETH_ALEN;
 }
 
-static inline int ieee80211_bssid_match(u8 *raddr, u8 *addr)
+static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
 {
-	return memcmp(raddr, addr, ETH_ALEN) == 0 ||
+	return compare_ether_addr(raddr, addr) == 0 ||
 	       is_broadcast_ether_addr(raddr);
 }
 
@@ -2545,9 +2544,9 @@ ieee80211_rx_h_data(struct ieee80211_txr
 
 	ethertype = (payload[6] << 8) | payload[7];
 
-	if (likely((memcmp(payload, rfc1042_header, 6) == 0 &&
+	if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
 		    ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
-		   memcmp(payload, bridge_tunnel_header, 6) == 0)) {
+		   compare_ether_addr(payload, bridge_tunnel_header) == 0)) {
 		/* remove RFC1042 or Bridge-Tunnel encapsulation and
 		 * replace EtherType */
 		skb_pull(skb, hdrlen + 6);
@@ -3038,8 +3037,8 @@ ieee80211_reassemble_find(struct ieee802
 		f_fc = le16_to_cpu(f_hdr->frame_control);
 
 		if ((fc & IEEE80211_FCTL_FTYPE) != (f_fc & IEEE80211_FCTL_FTYPE) ||
-		    memcmp(hdr->addr1, f_hdr->addr1, ETH_ALEN) != 0 ||
-		    memcmp(hdr->addr2, f_hdr->addr2, ETH_ALEN) != 0)
+		    compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 ||
+		    compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0)
 			continue;
 
 		if (entry->first_frag_time + 2 * HZ < jiffies) {
@@ -3208,7 +3207,7 @@ ieee80211_rx_h_check(struct ieee80211_tx
 
 	if (!rx->u.rx.ra_match)
 		rx->skb->pkt_type = PACKET_OTHERHOST;
-	else if (memcmp(rx->dev->dev_addr, hdr->addr1, ETH_ALEN) == 0)
+	else if (compare_ether_addr(rx->dev->dev_addr, hdr->addr1) == 0)
 		rx->skb->pkt_type = PACKET_HOST;
 	else if (is_multicast_ether_addr(hdr->addr1)) {
 		if (is_broadcast_ether_addr(hdr->addr1))
@@ -3318,7 +3317,7 @@ ieee80211_rx_h_sta_process(struct ieee80
 	 * other STAs are using different BSSID. */
 	if (rx->sdata->type == IEEE80211_IF_TYPE_IBSS) {
 		u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
-		if (memcmp(bssid, rx->sdata->u.sta.bssid, ETH_ALEN) == 0)
+		if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0)
 			sta->last_rx = jiffies;
 	} else
 	if (!is_multicast_ether_addr(hdr->addr1) ||
@@ -3797,8 +3796,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 						continue;
 					rx.u.rx.ra_match = 0;
 				} else if (!multicast &&
-					   memcmp(sdata->dev->dev_addr,
-						  hdr->addr1, ETH_ALEN) != 0) {
+					   compare_ether_addr(sdata->dev->dev_addr,
+							      hdr->addr1) != 0) {
 					if (!sdata->promisc)
 						continue;
 					rx.u.rx.ra_match = 0;
@@ -3813,8 +3812,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 						continue;
 					rx.u.rx.ra_match = 0;
 				} else if (!multicast &&
-					   memcmp(sdata->dev->dev_addr,
-						  hdr->addr1, ETH_ALEN) != 0) {
+					   compare_ether_addr(sdata->dev->dev_addr,
+							      hdr->addr1) != 0) {
 					if (!sdata->promisc)
 						continue;
 					rx.u.rx.ra_match = 0;
@@ -3827,8 +3826,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 				break;
 			case IEEE80211_IF_TYPE_AP:
 				if (!bssid) {
-					if (memcmp(sdata->dev->dev_addr,
-						   hdr->addr1, ETH_ALEN) != 0)
+					if (compare_ether_addr(sdata->dev->dev_addr,
+							       hdr->addr1) != 0)
 						continue;
 				} else if (!ieee80211_bssid_match(bssid,
 							sdata->dev->dev_addr)) {
@@ -3846,8 +3845,8 @@ void __ieee80211_rx(struct ieee80211_hw 
 				if (bssid ||
 				    (rx.fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
 					continue;
-				if (memcmp(sdata->u.wds.remote_addr,
-					   hdr->addr2, ETH_ALEN) != 0)
+				if (compare_ether_addr(sdata->u.wds.remote_addr,
+						       hdr->addr2) != 0)
 					continue;
 				break;
 			}
-- 
1.4.1


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

* Re: [PATCH 2/3] bcm43xx: build failure
  2007-02-23  0:11 ` [PATCH 2/3] bcm43xx: build failure Stephen Hemminger
@ 2007-02-23  0:31   ` Michael Wu
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Wu @ 2007-02-23  0:31 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-wireless

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

On Thursday 22 February 2007 19:11, Stephen Hemminger wrote:
> Looks like the ssi field changed.
>
A patch fixing that was sent with the original patch that introduced the new 
wireless statistics API for d80211 and is already in wireless-dev, AFAIK. 
(bcm43xx builds on my system)

-Michael Wu

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH 3/3] d80211: convert to use compare_ether_addr
  2007-02-23  0:12 ` [PATCH 3/3] d80211: convert to use compare_ether_addr Stephen Hemminger
@ 2007-02-23 16:55   ` Jiri Benc
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Benc @ 2007-02-23 16:55 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-wireless

On Thu, 22 Feb 2007 16:12:10 -0800, Stephen Hemminger wrote:
> compare_ether_addr is faster than memcmp()

Applied 1 and 3. 2 is already fixed in the latest wireless-dev.

Thanks for the patches,

 Jiri

-- 
Jiri Benc
SUSE Labs

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

end of thread, other threads:[~2007-02-23 16:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-23  0:10 [PATCH 1/3] d80211: use const Stephen Hemminger
2007-02-23  0:11 ` [PATCH 2/3] bcm43xx: build failure Stephen Hemminger
2007-02-23  0:31   ` Michael Wu
2007-02-23  0:12 ` [PATCH 3/3] d80211: convert to use compare_ether_addr Stephen Hemminger
2007-02-23 16:55   ` Jiri Benc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.