aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAdel Gadllah <adel.gadllah@gmail.com>2008-07-10 23:53:29 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-07-14 14:52:58 -0400
commit4bd9b4f334c31a79bdfee4db5dbb6aa430090446 (patch)
tree7aa6032306941df681334c1705fde98e48473831 /drivers
parent1e188637902eb4b62d325d3cc76b076724f3ec55 (diff)
iwl3965: remove useless network and duplicate checking
mac802 can handle duplicate packages on its own, so let it do it. The patch is based on patch from Johannes Berg for iwl4965. Signed-off-by: Adel Gadllah <adel.gadllah@gmail.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c50
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c126
4 files changed, 25 insertions, 172 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 94e177a9f51c..c2a76785b665 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -514,6 +514,23 @@ static inline void iwl3945_dbg_report_frame(struct iwl3945_priv *priv,
514} 514}
515#endif 515#endif
516 516
517/* This is necessary only for a number of statistics, see the caller. */
518static int iwl3945_is_network_packet(struct iwl3945_priv *priv,
519 struct ieee80211_hdr *header)
520{
521 /* Filter incoming packets to determine if they are targeted toward
522 * this network, discarding packets coming from ourselves */
523 switch (priv->iw_mode) {
524 case IEEE80211_IF_TYPE_IBSS: /* Header: Dest. | Source | BSSID */
525 /* packets to our IBSS update information */
526 return !compare_ether_addr(header->addr3, priv->bssid);
527 case IEEE80211_IF_TYPE_STA: /* Header: Dest. | AP{BSSID} | Source */
528 /* packets to our IBSS update information */
529 return !compare_ether_addr(header->addr2, priv->bssid);
530 default:
531 return 1;
532 }
533}
517 534
518static void iwl3945_add_radiotap(struct iwl3945_priv *priv, 535static void iwl3945_add_radiotap(struct iwl3945_priv *priv,
519 struct sk_buff *skb, 536 struct sk_buff *skb,
@@ -608,12 +625,12 @@ static void iwl3945_add_radiotap(struct iwl3945_priv *priv,
608 stats->flag |= RX_FLAG_RADIOTAP; 625 stats->flag |= RX_FLAG_RADIOTAP;
609} 626}
610 627
611static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data, 628static void iwl3945_pass_packet_to_mac80211(struct iwl3945_priv *priv,
612 struct iwl3945_rx_mem_buffer *rxb, 629 struct iwl3945_rx_mem_buffer *rxb,
613 struct ieee80211_rx_status *stats) 630 struct ieee80211_rx_status *stats)
614{ 631{
615 struct ieee80211_hdr *hdr;
616 struct iwl3945_rx_packet *pkt = (struct iwl3945_rx_packet *)rxb->skb->data; 632 struct iwl3945_rx_packet *pkt = (struct iwl3945_rx_packet *)rxb->skb->data;
633 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IWL_RX_DATA(pkt);
617 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); 634 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt);
618 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); 635 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt);
619 short len = le16_to_cpu(rx_hdr->len); 636 short len = le16_to_cpu(rx_hdr->len);
@@ -635,8 +652,6 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data,
635 /* Set the size of the skb to the size of the frame */ 652 /* Set the size of the skb to the size of the frame */
636 skb_put(rxb->skb, le16_to_cpu(rx_hdr->len)); 653 skb_put(rxb->skb, le16_to_cpu(rx_hdr->len));
637 654
638 hdr = (void *)rxb->skb->data;
639
640 if (iwl3945_param_hwcrypto) 655 if (iwl3945_param_hwcrypto)
641 iwl3945_set_decrypted_flag(priv, rxb->skb, 656 iwl3945_set_decrypted_flag(priv, rxb->skb,
642 le32_to_cpu(rx_end->status), stats); 657 le32_to_cpu(rx_end->status), stats);
@@ -645,7 +660,7 @@ static void iwl3945_handle_data_packet(struct iwl3945_priv *priv, int is_data,
645 iwl3945_add_radiotap(priv, rxb->skb, rx_hdr, stats); 660 iwl3945_add_radiotap(priv, rxb->skb, rx_hdr, stats);
646 661
647#ifdef CONFIG_IWL3945_LEDS 662#ifdef CONFIG_IWL3945_LEDS
648 if (is_data) 663 if (ieee80211_is_data(hdr->frame_control))
649 priv->rxtxpackets += len; 664 priv->rxtxpackets += len;
650#endif 665#endif
651 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); 666 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
@@ -694,7 +709,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
694 } 709 }
695 710
696 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { 711 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) {
697 iwl3945_handle_data_packet(priv, 1, rxb, &rx_status); 712 iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status);
698 return; 713 return;
699 } 714 }
700 715
@@ -842,27 +857,12 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
842 } 857 }
843 } 858 }
844 859
845 iwl3945_handle_data_packet(priv, 0, rxb, &rx_status); 860 case IEEE80211_FTYPE_DATA:
846 break; 861 /* fall through */
847 862 default:
848 case IEEE80211_FTYPE_CTL: 863 iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status);
849 break;
850
851 case IEEE80211_FTYPE_DATA: {
852 DECLARE_MAC_BUF(mac1);
853 DECLARE_MAC_BUF(mac2);
854 DECLARE_MAC_BUF(mac3);
855
856 if (unlikely(iwl3945_is_duplicate_packet(priv, header)))
857 IWL_DEBUG_DROP("Dropping (dup): %s, %s, %s\n",
858 print_mac(mac1, header->addr1),
859 print_mac(mac2, header->addr2),
860 print_mac(mac3, header->addr3));
861 else
862 iwl3945_handle_data_packet(priv, 1, rxb, &rx_status);
863 break; 864 break;
864 } 865 }
865 }
866} 866}
867 867
868int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl3945_priv *priv, void *ptr, 868int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl3945_priv *priv, void *ptr,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 9c0a09eaca6f..a7ef59bd1943 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -510,8 +510,6 @@ struct iwl3945_ucode {
510 u8 data[0]; /* data in same order as "size" elements */ 510 u8 data[0]; /* data in same order as "size" elements */
511}; 511};
512 512
513#define IWL_IBSS_MAC_HASH_SIZE 32
514
515struct iwl3945_ibss_seq { 513struct iwl3945_ibss_seq {
516 u8 mac[ETH_ALEN]; 514 u8 mac[ETH_ALEN];
517 u16 seq_num; 515 u16 seq_num;
@@ -569,17 +567,8 @@ extern int iwl3945_send_add_station(struct iwl3945_priv *priv,
569 struct iwl3945_addsta_cmd *sta, u8 flags); 567 struct iwl3945_addsta_cmd *sta, u8 flags);
570extern u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *bssid, 568extern u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *bssid,
571 int is_ap, u8 flags); 569 int is_ap, u8 flags);
572extern int iwl3945_is_network_packet(struct iwl3945_priv *priv,
573 struct ieee80211_hdr *header);
574extern int iwl3945_power_init_handle(struct iwl3945_priv *priv); 570extern int iwl3945_power_init_handle(struct iwl3945_priv *priv);
575extern int iwl3945_eeprom_init(struct iwl3945_priv *priv); 571extern int iwl3945_eeprom_init(struct iwl3945_priv *priv);
576extern void iwl3945_handle_data_packet_monitor(struct iwl3945_priv *priv,
577 struct iwl3945_rx_mem_buffer *rxb,
578 void *data, short len,
579 struct ieee80211_rx_status *stats,
580 u16 phy_flags);
581extern int iwl3945_is_duplicate_packet(struct iwl3945_priv *priv,
582 struct ieee80211_hdr *header);
583extern int iwl3945_rx_queue_alloc(struct iwl3945_priv *priv); 572extern int iwl3945_rx_queue_alloc(struct iwl3945_priv *priv);
584extern void iwl3945_rx_queue_reset(struct iwl3945_priv *priv, 573extern void iwl3945_rx_queue_reset(struct iwl3945_priv *priv,
585 struct iwl3945_rx_queue *rxq); 574 struct iwl3945_rx_queue *rxq);
@@ -859,14 +848,6 @@ struct iwl3945_priv {
859 u32 last_beacon_time; 848 u32 last_beacon_time;
860 u64 last_tsf; 849 u64 last_tsf;
861 850
862 /* Duplicate packet detection */
863 u16 last_seq_num;
864 u16 last_frag_num;
865 unsigned long last_packet_time;
866
867 /* Hash table for finding stations in IBSS network */
868 struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE];
869
870 /* eeprom */ 851 /* eeprom */
871 struct iwl3945_eeprom eeprom; 852 struct iwl3945_eeprom eeprom;
872 853
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index c8d3d97cf48d..163502dabf6b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -490,8 +490,6 @@ struct iwl_ucode {
490 u8 data[0]; /* data in same order as "size" elements */ 490 u8 data[0]; /* data in same order as "size" elements */
491}; 491};
492 492
493#define IWL_IBSS_MAC_HASH_SIZE 32
494
495struct iwl4965_ibss_seq { 493struct iwl4965_ibss_seq {
496 u8 mac[ETH_ALEN]; 494 u8 mac[ETH_ALEN];
497 u16 seq_num; 495 u16 seq_num;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 7d015f86ee8c..4a22d3fba75b 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2035,36 +2035,6 @@ static int iwl3945_send_power_mode(struct iwl3945_priv *priv, u32 mode)
2035 return rc; 2035 return rc;
2036} 2036}
2037 2037
2038int iwl3945_is_network_packet(struct iwl3945_priv *priv, struct ieee80211_hdr *header)
2039{
2040 /* Filter incoming packets to determine if they are targeted toward
2041 * this network, discarding packets coming from ourselves */
2042 switch (priv->iw_mode) {
2043 case IEEE80211_IF_TYPE_IBSS: /* Header: Dest. | Source | BSSID */
2044 /* packets from our adapter are dropped (echo) */
2045 if (!compare_ether_addr(header->addr2, priv->mac_addr))
2046 return 0;
2047 /* {broad,multi}cast packets to our IBSS go through */
2048 if (is_multicast_ether_addr(header->addr1))
2049 return !compare_ether_addr(header->addr3, priv->bssid);
2050 /* packets to our adapter go through */
2051 return !compare_ether_addr(header->addr1, priv->mac_addr);
2052 case IEEE80211_IF_TYPE_STA: /* Header: Dest. | AP{BSSID} | Source */
2053 /* packets from our adapter are dropped (echo) */
2054 if (!compare_ether_addr(header->addr3, priv->mac_addr))
2055 return 0;
2056 /* {broad,multi}cast packets to our BSS go through */
2057 if (is_multicast_ether_addr(header->addr1))
2058 return !compare_ether_addr(header->addr2, priv->bssid);
2059 /* packets to our adapter go through */
2060 return !compare_ether_addr(header->addr1, priv->mac_addr);
2061 default:
2062 return 1;
2063 }
2064
2065 return 1;
2066}
2067
2068/** 2038/**
2069 * iwl3945_scan_cancel - Cancel any currently executing HW scan 2039 * iwl3945_scan_cancel - Cancel any currently executing HW scan
2070 * 2040 *
@@ -2117,20 +2087,6 @@ static int iwl3945_scan_cancel_timeout(struct iwl3945_priv *priv, unsigned long
2117 return ret; 2087 return ret;
2118} 2088}
2119 2089
2120static void iwl3945_sequence_reset(struct iwl3945_priv *priv)
2121{
2122 /* Reset ieee stats */
2123
2124 /* We don't reset the net_device_stats (ieee->stats) on
2125 * re-association */
2126
2127 priv->last_seq_num = -1;
2128 priv->last_frag_num = -1;
2129 priv->last_packet_time = 0;
2130
2131 iwl3945_scan_cancel(priv);
2132}
2133
2134#define MAX_UCODE_BEACON_INTERVAL 1024 2090#define MAX_UCODE_BEACON_INTERVAL 1024
2135#define INTEL_CONN_LISTEN_INTERVAL __constant_cpu_to_le16(0xA) 2091#define INTEL_CONN_LISTEN_INTERVAL __constant_cpu_to_le16(0xA)
2136 2092
@@ -2925,72 +2881,6 @@ void iwl3945_set_decrypted_flag(struct iwl3945_priv *priv, struct sk_buff *skb,
2925 } 2881 }
2926} 2882}
2927 2883
2928#define IWL_PACKET_RETRY_TIME HZ
2929
2930int iwl3945_is_duplicate_packet(struct iwl3945_priv *priv, struct ieee80211_hdr *header)
2931{
2932 u16 sc = le16_to_cpu(header->seq_ctrl);
2933 u16 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
2934 u16 frag = sc & IEEE80211_SCTL_FRAG;
2935 u16 *last_seq, *last_frag;
2936 unsigned long *last_time;
2937
2938 switch (priv->iw_mode) {
2939 case IEEE80211_IF_TYPE_IBSS:{
2940 struct list_head *p;
2941 struct iwl3945_ibss_seq *entry = NULL;
2942 u8 *mac = header->addr2;
2943 int index = mac[5] & (IWL_IBSS_MAC_HASH_SIZE - 1);
2944
2945 __list_for_each(p, &priv->ibss_mac_hash[index]) {
2946 entry = list_entry(p, struct iwl3945_ibss_seq, list);
2947 if (!compare_ether_addr(entry->mac, mac))
2948 break;
2949 }
2950 if (p == &priv->ibss_mac_hash[index]) {
2951 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
2952 if (!entry) {
2953 IWL_ERROR("Cannot malloc new mac entry\n");
2954 return 0;
2955 }
2956 memcpy(entry->mac, mac, ETH_ALEN);
2957 entry->seq_num = seq;
2958 entry->frag_num = frag;
2959 entry->packet_time = jiffies;
2960 list_add(&entry->list, &priv->ibss_mac_hash[index]);
2961 return 0;
2962 }
2963 last_seq = &entry->seq_num;
2964 last_frag = &entry->frag_num;
2965 last_time = &entry->packet_time;
2966 break;
2967 }
2968 case IEEE80211_IF_TYPE_STA:
2969 last_seq = &priv->last_seq_num;
2970 last_frag = &priv->last_frag_num;
2971 last_time = &priv->last_packet_time;
2972 break;
2973 default:
2974 return 0;
2975 }
2976 if ((*last_seq == seq) &&
2977 time_after(*last_time + IWL_PACKET_RETRY_TIME, jiffies)) {
2978 if (*last_frag == frag)
2979 goto drop;
2980 if (*last_frag + 1 != frag)
2981 /* out-of-order fragment */
2982 goto drop;
2983 } else
2984 *last_seq = seq;
2985
2986 *last_frag = frag;
2987 *last_time = jiffies;
2988 return 0;
2989
2990 drop:
2991 return 1;
2992}
2993
2994#ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT 2884#ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT
2995 2885
2996#include "iwl-spectrum.h" 2886#include "iwl-spectrum.h"
@@ -6531,8 +6421,6 @@ static void iwl3945_bg_post_associate(struct work_struct *data)
6531 break; 6421 break;
6532 } 6422 }
6533 6423
6534 iwl3945_sequence_reset(priv);
6535
6536 iwl3945_activate_qos(priv, 0); 6424 iwl3945_activate_qos(priv, 0);
6537 6425
6538 /* we have just associated, don't start scan too early */ 6426 /* we have just associated, don't start scan too early */
@@ -7963,7 +7851,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7963 struct iwl3945_priv *priv; 7851 struct iwl3945_priv *priv;
7964 struct ieee80211_hw *hw; 7852 struct ieee80211_hw *hw;
7965 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data); 7853 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data);
7966 int i;
7967 unsigned long flags; 7854 unsigned long flags;
7968 DECLARE_MAC_BUF(mac); 7855 DECLARE_MAC_BUF(mac);
7969 7856
@@ -8024,9 +7911,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8024 spin_lock_init(&priv->sta_lock); 7911 spin_lock_init(&priv->sta_lock);
8025 spin_lock_init(&priv->hcmd_lock); 7912 spin_lock_init(&priv->hcmd_lock);
8026 7913
8027 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
8028 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
8029
8030 INIT_LIST_HEAD(&priv->free_frames); 7914 INIT_LIST_HEAD(&priv->free_frames);
8031 7915
8032 mutex_init(&priv->mutex); 7916 mutex_init(&priv->mutex);
@@ -8199,8 +8083,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8199static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) 8083static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
8200{ 8084{
8201 struct iwl3945_priv *priv = pci_get_drvdata(pdev); 8085 struct iwl3945_priv *priv = pci_get_drvdata(pdev);
8202 struct list_head *p, *q;
8203 int i;
8204 unsigned long flags; 8086 unsigned long flags;
8205 8087
8206 if (!priv) 8088 if (!priv)
@@ -8221,14 +8103,6 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
8221 8103
8222 iwl_synchronize_irq(priv); 8104 iwl_synchronize_irq(priv);
8223 8105
8224 /* Free MAC hash list for ADHOC */
8225 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++) {
8226 list_for_each_safe(p, q, &priv->ibss_mac_hash[i]) {
8227 list_del(p);
8228 kfree(list_entry(p, struct iwl3945_ibss_seq, list));
8229 }
8230 }
8231
8232 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); 8106 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
8233 8107
8234 iwl3945_rfkill_unregister(priv); 8108 iwl3945_rfkill_unregister(priv);