aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-rx.c
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2008-07-30 11:20:14 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-22 16:29:50 -0400
commit6f0a2c4dfc96d268233a6a882f3805975f91216c (patch)
treefbc60eec2c3a2f91b06b605ebaaa659d7fd4621b /drivers/net/wireless/iwlwifi/iwl-rx.c
parent9deb1ae572364a37d054d916c5bae858f91a3f9a (diff)
iwlwifi: use generic mac80211 radiotap headers
remove drivers own implementation of radiotap in favor of the generic one provided by mac80211. also remove priv->add_radiotap because it is not used any more. Signed-off-by: Bruno Randolf <br1@einfach.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-rx.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c125
1 files changed, 20 insertions, 105 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index f3f6ea49fdd2..b92a580ed2f9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -789,107 +789,6 @@ static inline void iwl_dbg_report_frame(struct iwl_priv *priv,
789} 789}
790#endif 790#endif
791 791
792static void iwl_add_radiotap(struct iwl_priv *priv,
793 struct sk_buff *skb,
794 struct iwl_rx_phy_res *rx_start,
795 struct ieee80211_rx_status *stats,
796 u32 ampdu_status)
797{
798 s8 signal = stats->signal;
799 s8 noise = 0;
800 int rate = stats->rate_idx;
801 u64 tsf = stats->mactime;
802 __le16 antenna;
803 __le16 phy_flags_hw = rx_start->phy_flags;
804 struct iwl4965_rt_rx_hdr {
805 struct ieee80211_radiotap_header rt_hdr;
806 __le64 rt_tsf; /* TSF */
807 u8 rt_flags; /* radiotap packet flags */
808 u8 rt_rate; /* rate in 500kb/s */
809 __le16 rt_channelMHz; /* channel in MHz */
810 __le16 rt_chbitmask; /* channel bitfield */
811 s8 rt_dbmsignal; /* signal in dBm, kluged to signed */
812 s8 rt_dbmnoise;
813 u8 rt_antenna; /* antenna number */
814 } __attribute__ ((packed)) *iwl4965_rt;
815
816 /* TODO: We won't have enough headroom for HT frames. Fix it later. */
817 if (skb_headroom(skb) < sizeof(*iwl4965_rt)) {
818 if (net_ratelimit())
819 printk(KERN_ERR "not enough headroom [%d] for "
820 "radiotap head [%zd]\n",
821 skb_headroom(skb), sizeof(*iwl4965_rt));
822 return;
823 }
824
825 /* put radiotap header in front of 802.11 header and data */
826 iwl4965_rt = (void *)skb_push(skb, sizeof(*iwl4965_rt));
827
828 /* initialise radiotap header */
829 iwl4965_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
830 iwl4965_rt->rt_hdr.it_pad = 0;
831
832 /* total header + data */
833 put_unaligned_le16(sizeof(*iwl4965_rt), &iwl4965_rt->rt_hdr.it_len);
834
835 /* Indicate all the fields we add to the radiotap header */
836 put_unaligned_le32((1 << IEEE80211_RADIOTAP_TSFT) |
837 (1 << IEEE80211_RADIOTAP_FLAGS) |
838 (1 << IEEE80211_RADIOTAP_RATE) |
839 (1 << IEEE80211_RADIOTAP_CHANNEL) |
840 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
841 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |
842 (1 << IEEE80211_RADIOTAP_ANTENNA),
843 &(iwl4965_rt->rt_hdr.it_present));
844
845 /* Zero the flags, we'll add to them as we go */
846 iwl4965_rt->rt_flags = 0;
847
848 put_unaligned_le64(tsf, &iwl4965_rt->rt_tsf);
849
850 iwl4965_rt->rt_dbmsignal = signal;
851 iwl4965_rt->rt_dbmnoise = noise;
852
853 /* Convert the channel frequency and set the flags */
854 put_unaligned(cpu_to_le16(stats->freq), &iwl4965_rt->rt_channelMHz);
855 if (!(phy_flags_hw & RX_RES_PHY_FLAGS_BAND_24_MSK))
856 put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ,
857 &iwl4965_rt->rt_chbitmask);
858 else if (phy_flags_hw & RX_RES_PHY_FLAGS_MOD_CCK_MSK)
859 put_unaligned_le16(IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ,
860 &iwl4965_rt->rt_chbitmask);
861 else /* 802.11g */
862 put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ,
863 &iwl4965_rt->rt_chbitmask);
864
865 if (rate == -1)
866 iwl4965_rt->rt_rate = 0;
867 else
868 iwl4965_rt->rt_rate = iwl_rates[rate].ieee;
869
870 /*
871 * "antenna number"
872 *
873 * It seems that the antenna field in the phy flags value
874 * is actually a bitfield. This is undefined by radiotap,
875 * it wants an actual antenna number but I always get "7"
876 * for most legacy frames I receive indicating that the
877 * same frame was received on all three RX chains.
878 *
879 * I think this field should be removed in favour of a
880 * new 802.11n radiotap field "RX chains" that is defined
881 * as a bitmask.
882 */
883 antenna = phy_flags_hw & RX_RES_PHY_FLAGS_ANTENNA_MSK;
884 iwl4965_rt->rt_antenna = le16_to_cpu(antenna) >> 4;
885
886 /* set the preamble flag if appropriate */
887 if (phy_flags_hw & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
888 iwl4965_rt->rt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
889
890 stats->flag |= RX_FLAG_RADIOTAP;
891}
892
893static void iwl_update_rx_stats(struct iwl_priv *priv, u16 fc, u16 len) 792static void iwl_update_rx_stats(struct iwl_priv *priv, u16 fc, u16 len)
894{ 793{
895 /* 0 - mgmt, 1 - cnt, 2 - data */ 794 /* 0 - mgmt, 1 - cnt, 2 - data */
@@ -1074,9 +973,6 @@ static void iwl_pass_packet_to_mac80211(struct iwl_priv *priv,
1074 iwl_set_decrypted_flag(priv, hdr, ampdu_status, stats)) 973 iwl_set_decrypted_flag(priv, hdr, ampdu_status, stats))
1075 return; 974 return;
1076 975
1077 if (priv->add_radiotap)
1078 iwl_add_radiotap(priv, rxb->skb, rx_start, stats, ampdu_status);
1079
1080 iwl_update_rx_stats(priv, le16_to_cpu(hdr->frame_control), len); 976 iwl_update_rx_stats(priv, le16_to_cpu(hdr->frame_control), len);
1081 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); 977 ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats);
1082 priv->alloc_rxb_skb--; 978 priv->alloc_rxb_skb--;
@@ -1171,7 +1067,6 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1171 if (rx_status.band == IEEE80211_BAND_5GHZ) 1067 if (rx_status.band == IEEE80211_BAND_5GHZ)
1172 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; 1068 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE;
1173 1069
1174 rx_status.antenna = 0;
1175 rx_status.flag = 0; 1070 rx_status.flag = 0;
1176 rx_status.flag |= RX_FLAG_TSFT; 1071 rx_status.flag |= RX_FLAG_TSFT;
1177 1072
@@ -1250,6 +1145,26 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1250 rx_status.signal, rx_status.noise, rx_status.signal, 1145 rx_status.signal, rx_status.noise, rx_status.signal,
1251 (unsigned long long)rx_status.mactime); 1146 (unsigned long long)rx_status.mactime);
1252 1147
1148 /*
1149 * "antenna number"
1150 *
1151 * It seems that the antenna field in the phy flags value
1152 * is actually a bitfield. This is undefined by radiotap,
1153 * it wants an actual antenna number but I always get "7"
1154 * for most legacy frames I receive indicating that the
1155 * same frame was received on all three RX chains.
1156 *
1157 * I think this field should be removed in favour of a
1158 * new 802.11n radiotap field "RX chains" that is defined
1159 * as a bitmask.
1160 */
1161 rx_status.antenna = le16_to_cpu(rx_start->phy_flags &
1162 RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4;
1163
1164 /* set the preamble flag if appropriate */
1165 if (rx_start->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
1166 rx_status.flag |= RX_FLAG_SHORTPRE;
1167
1253 /* Take shortcut when only in monitor mode */ 1168 /* Take shortcut when only in monitor mode */
1254 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { 1169 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) {
1255 iwl_pass_packet_to_mac80211(priv, include_phy, 1170 iwl_pass_packet_to_mac80211(priv, include_phy,