d80211: use const
Subsystems (2)
PATCH 1/3 d80211: use const
Use const to indicate constant arguments and encapsulation headers.
Signed-off-by Stephen Hemminger <[email protected]>
--- include/net/d80211.h | 2 +- net/d80211/ieee80211.c | 39 ++++++++++++++++++++------------------- net/d80211/ieee80211_i.h | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-)
include/net/d80211.h +1 -1
@@ -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);
net/d80211/ieee80211.c +20 -19
@@ -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(strstruct 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 kobjeckfree (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(stint 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;
net/d80211/ieee80211_i.h +1 -1
@@ -607,7 +607,7 @@ int ieee80211_if_config(struct net_devicint 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);
Signature · 1 line
1.4.1
PATCH 2/3 bcm43xx: build failure
Looks like the ssi field changed.
Signed-off-by Stephen Hemminger <[email protected]>
--- drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +1 -1
@@ -3681,7 +3681,7 @@ static int bcm43xx_wireless_init(structIEEE80211_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)) {
Signature · 1 line
1.4.1
Re: [PATCH 2/3] bcm43xx: build failure
Quoted 2 lines · Stephen Hemminger
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
PATCH 3/3 d80211: convert to use compare_ether_addr
In reply to Stephen Hemmingercompare_ether_addr is faster than memcmp()
Signed-off-by Stephen Hemminger <[email protected]>
--- net/d80211/ieee80211.c | 45 ++++++++++++++++++++++----------------------- 1 files changed, 22 insertions(+), 23 deletions(-)
net/d80211/ieee80211.c +22 -23
@@ -2310,15 +2310,14 @@ static int ieee80211_open(struct net_devlist_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_txif (!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_hwcontinue ; 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_hwcontinue ; 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_hwbreak ;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_hwif (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 ; }
Signature · 1 line
1.4.1
Re: [PATCH 3/3] d80211: convert to use compare_ether_addr
Quoted 1 line · Stephen Hemminger
compare_ether_addris faster thanmemcmp()
Applied 1 and 3. 2 is already fixed in the latest wireless-dev.
Thanks for the patches,
Jiri
Signature · 2 lines
Jiri Benc SUSE Labs