aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl4965-base.c
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2008-06-30 05:23:09 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-30 17:37:40 -0400
commit1781a07fbe9cce3dc1697288a5edd260ea7edc02 (patch)
treebe06e824b69af8d43edfeab2c78a353f0bf7f8ce /drivers/net/wireless/iwlwifi/iwl4965-base.c
parent37deb2a0baf1bb540b723cc8a3972b42ff2daac6 (diff)
iwlwifi: move RX handlers to iwl-rx.c
This patch moves RX handlers to iwl-rx.c Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c152
1 files changed, 2 insertions, 150 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index a607b39223e7..499705ff8887 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -613,36 +613,6 @@ static void iwl4965_activate_qos(struct iwl_priv *priv, u8 force)
613 } 613 }
614} 614}
615 615
616int iwl4965_is_network_packet(struct iwl_priv *priv, struct ieee80211_hdr *header)
617{
618 /* Filter incoming packets to determine if they are targeted toward
619 * this network, discarding packets coming from ourselves */
620 switch (priv->iw_mode) {
621 case IEEE80211_IF_TYPE_IBSS: /* Header: Dest. | Source | BSSID */
622 /* packets from our adapter are dropped (echo) */
623 if (!compare_ether_addr(header->addr2, priv->mac_addr))
624 return 0;
625 /* {broad,multi}cast packets to our IBSS go through */
626 if (is_multicast_ether_addr(header->addr1))
627 return !compare_ether_addr(header->addr3, priv->bssid);
628 /* packets to our adapter go through */
629 return !compare_ether_addr(header->addr1, priv->mac_addr);
630 case IEEE80211_IF_TYPE_STA: /* Header: Dest. | AP{BSSID} | Source */
631 /* packets from our adapter are dropped (echo) */
632 if (!compare_ether_addr(header->addr3, priv->mac_addr))
633 return 0;
634 /* {broad,multi}cast packets to our BSS go through */
635 if (is_multicast_ether_addr(header->addr1))
636 return !compare_ether_addr(header->addr2, priv->bssid);
637 /* packets to our adapter go through */
638 return !compare_ether_addr(header->addr1, priv->mac_addr);
639 default:
640 break;
641 }
642
643 return 1;
644}
645
646static void iwl4965_sequence_reset(struct iwl_priv *priv) 616static void iwl4965_sequence_reset(struct iwl_priv *priv)
647{ 617{
648 /* Reset ieee stats */ 618 /* Reset ieee stats */
@@ -906,72 +876,6 @@ static void iwl4965_set_rate(struct iwl_priv *priv)
906 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 876 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
907} 877}
908 878
909#define IWL_PACKET_RETRY_TIME HZ
910
911int iwl4965_is_duplicate_packet(struct iwl_priv *priv, struct ieee80211_hdr *header)
912{
913 u16 sc = le16_to_cpu(header->seq_ctrl);
914 u16 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
915 u16 frag = sc & IEEE80211_SCTL_FRAG;
916 u16 *last_seq, *last_frag;
917 unsigned long *last_time;
918
919 switch (priv->iw_mode) {
920 case IEEE80211_IF_TYPE_IBSS:{
921 struct list_head *p;
922 struct iwl4965_ibss_seq *entry = NULL;
923 u8 *mac = header->addr2;
924 int index = mac[5] & (IWL_IBSS_MAC_HASH_SIZE - 1);
925
926 __list_for_each(p, &priv->ibss_mac_hash[index]) {
927 entry = list_entry(p, struct iwl4965_ibss_seq, list);
928 if (!compare_ether_addr(entry->mac, mac))
929 break;
930 }
931 if (p == &priv->ibss_mac_hash[index]) {
932 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
933 if (!entry) {
934 IWL_ERROR("Cannot malloc new mac entry\n");
935 return 0;
936 }
937 memcpy(entry->mac, mac, ETH_ALEN);
938 entry->seq_num = seq;
939 entry->frag_num = frag;
940 entry->packet_time = jiffies;
941 list_add(&entry->list, &priv->ibss_mac_hash[index]);
942 return 0;
943 }
944 last_seq = &entry->seq_num;
945 last_frag = &entry->frag_num;
946 last_time = &entry->packet_time;
947 break;
948 }
949 case IEEE80211_IF_TYPE_STA:
950 last_seq = &priv->last_seq_num;
951 last_frag = &priv->last_frag_num;
952 last_time = &priv->last_packet_time;
953 break;
954 default:
955 return 0;
956 }
957 if ((*last_seq == seq) &&
958 time_after(*last_time + IWL_PACKET_RETRY_TIME, jiffies)) {
959 if (*last_frag == frag)
960 goto drop;
961 if (*last_frag + 1 != frag)
962 /* out-of-order fragment */
963 goto drop;
964 } else
965 *last_seq = seq;
966
967 *last_frag = frag;
968 *last_time = jiffies;
969 return 0;
970
971 drop:
972 return 1;
973}
974
975#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT 879#ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
976 880
977#include "iwl-spectrum.h" 881#include "iwl-spectrum.h"
@@ -1350,17 +1254,6 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv,
1350 wake_up_interruptible(&priv->wait_command_queue); 1254 wake_up_interruptible(&priv->wait_command_queue);
1351} 1255}
1352 1256
1353/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD).
1354 * This will be used later in iwl4965_rx_reply_rx() for REPLY_RX_MPDU_CMD. */
1355static void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv,
1356 struct iwl_rx_mem_buffer *rxb)
1357{
1358 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
1359 priv->last_phy_res[0] = 1;
1360 memcpy(&priv->last_phy_res[1], &(pkt->u.raw[0]),
1361 sizeof(struct iwl4965_rx_phy_res));
1362}
1363
1364/** 1257/**
1365 * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks 1258 * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks
1366 * 1259 *
@@ -1398,8 +1291,8 @@ static void iwl4965_setup_rx_handlers(struct iwl_priv *priv)
1398 priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = 1291 priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] =
1399 iwl_rx_missed_beacon_notif; 1292 iwl_rx_missed_beacon_notif;
1400 /* Rx handlers */ 1293 /* Rx handlers */
1401 priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy; 1294 priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl_rx_reply_rx_phy;
1402 priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl4965_rx_reply_rx; 1295 priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl_rx_reply_rx;
1403 /* Set up hardware specific Rx handlers */ 1296 /* Set up hardware specific Rx handlers */
1404 priv->cfg->ops->lib->rx_handler_setup(priv); 1297 priv->cfg->ops->lib->rx_handler_setup(priv);
1405} 1298}
@@ -1530,47 +1423,6 @@ void iwl_rx_handle(struct iwl_priv *priv)
1530 iwl_rx_queue_restock(priv); 1423 iwl_rx_queue_restock(priv);
1531} 1424}
1532 1425
1533#define PERFECT_RSSI (-20) /* dBm */
1534#define WORST_RSSI (-95) /* dBm */
1535#define RSSI_RANGE (PERFECT_RSSI - WORST_RSSI)
1536
1537/* Calculate an indication of rx signal quality (a percentage, not dBm!).
1538 * See http://www.ces.clemson.edu/linux/signal_quality.shtml for info
1539 * about formulas used below. */
1540int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm)
1541{
1542 int sig_qual;
1543 int degradation = PERFECT_RSSI - rssi_dbm;
1544
1545 /* If we get a noise measurement, use signal-to-noise ratio (SNR)
1546 * as indicator; formula is (signal dbm - noise dbm).
1547 * SNR at or above 40 is a great signal (100%).
1548 * Below that, scale to fit SNR of 0 - 40 dB within 0 - 100% indicator.
1549 * Weakest usable signal is usually 10 - 15 dB SNR. */
1550 if (noise_dbm) {
1551 if (rssi_dbm - noise_dbm >= 40)
1552 return 100;
1553 else if (rssi_dbm < noise_dbm)
1554 return 0;
1555 sig_qual = ((rssi_dbm - noise_dbm) * 5) / 2;
1556
1557 /* Else use just the signal level.
1558 * This formula is a least squares fit of data points collected and
1559 * compared with a reference system that had a percentage (%) display
1560 * for signal quality. */
1561 } else
1562 sig_qual = (100 * (RSSI_RANGE * RSSI_RANGE) - degradation *
1563 (15 * RSSI_RANGE + 62 * degradation)) /
1564 (RSSI_RANGE * RSSI_RANGE);
1565
1566 if (sig_qual > 100)
1567 sig_qual = 100;
1568 else if (sig_qual < 1)
1569 sig_qual = 0;
1570
1571 return sig_qual;
1572}
1573
1574#ifdef CONFIG_IWLWIFI_DEBUG 1426#ifdef CONFIG_IWLWIFI_DEBUG
1575static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv) 1427static void iwl4965_print_rx_config_cmd(struct iwl_priv *priv)
1576{ 1428{