]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
ath9k: Update spectral scan output data
authorSven Eckelmann <sven@open-mesh.com>
Wed, 23 Jan 2013 19:12:39 +0000 (20:12 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 30 Jan 2013 20:06:42 +0000 (15:06 -0500)
The sample data received through the spectral scan can be either in big or
little endian byteorder. This information isn't stored in the output file.
Therefore it is not possible for the analyzer software to find the correct byte
order.

It is relative common to get the data from a low end AP in big endian mode and
transfer it to another computer in little endian mode to analyze it. Therefore,
it would be better to store it in network (big endian) byte order.

The extension of the 8 bit bins for each bin to 16 bit is not necessary. This
operation can be done in userspace or on a different machine. Instead the
max_exp defining the amount of shifting required for each bin is exported to
userspace.

The change of the output format requires a change of the type in the sample
tlv to allow the userspace program to correctly detect the bin format.

Reported-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
[siwu@hrz.tu-chemnitz.de: squashed patches, update commit message, rebase, fix endianess bug]
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/debug.c
drivers/net/wireless/ath/ath9k/recv.c

index 342edc54366594ef0cb5b82ca641af11fcb9b896..67df8644fef63f78ac15333d1fd92ee39f7560cc 100644 (file)
@@ -864,7 +864,7 @@ static inline u8 spectral_bitmap_weight(u8 *bins)
  * interface.
  */
 enum ath_fft_sample_type {
-       ATH_FFT_SAMPLE_HT20 = 0,
+       ATH_FFT_SAMPLE_HT20 = 1,
 };
 
 struct fft_sample_tlv {
@@ -876,7 +876,7 @@ struct fft_sample_tlv {
 struct fft_sample_ht20 {
        struct fft_sample_tlv tlv;
 
-       u8 __alignment;
+       u8 max_exp;
 
        u16 freq;
        s8 rssi;
@@ -888,7 +888,7 @@ struct fft_sample_ht20 {
 
        u64 tsf;
 
-       u16 data[SPECTRAL_HT20_NUM_BINS];
+       u8 data[SPECTRAL_HT20_NUM_BINS];
 } __packed;
 
 void ath9k_tasklet(unsigned long data);
index 2bbdcf89d39ada74e937ac806697d21a8dd677d9..3714b971d18ebe41a89d1453acc63462c682af8b 100644 (file)
@@ -1236,11 +1236,13 @@ static int remove_buf_file_handler(struct dentry *dentry)
 void ath_debug_send_fft_sample(struct ath_softc *sc,
                               struct fft_sample_tlv *fft_sample_tlv)
 {
+       int length;
        if (!sc->rfs_chan_spec_scan)
                return;
 
-       relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv,
-                   fft_sample_tlv->length + sizeof(*fft_sample_tlv));
+       length = __be16_to_cpu(fft_sample_tlv->length) +
+                sizeof(*fft_sample_tlv);
+       relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv, length);
 }
 
 static struct rchan_callbacks rfs_spec_scan_cb = {
index 13ee37bcdb7d9a2cb0e1f4199ecb37576434c46a..2af6f19d2d2aeeaed09b411e4535a610e6a748d5 100644 (file)
@@ -1035,7 +1035,7 @@ static int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
        struct ath_radar_info *radar_info;
        struct ath_ht20_mag_info *mag_info;
        int len = rs->rs_datalen;
-       int i, dc_pos;
+       int dc_pos;
 
        /* AR9280 and before report via ATH9K_PHYERR_RADAR, AR93xx and newer
         * via ATH9K_PHYERR_SPECTRAL. Haven't seen ATH9K_PHYERR_FALSE_RADAR_EXT
@@ -1064,8 +1064,9 @@ static int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
 
        fft_sample.tlv.type = ATH_FFT_SAMPLE_HT20;
        fft_sample.tlv.length = sizeof(fft_sample) - sizeof(fft_sample.tlv);
+       fft_sample.tlv.length = __cpu_to_be16(fft_sample.tlv.length);
 
-       fft_sample.freq = ah->curchan->chan->center_freq;
+       fft_sample.freq = __cpu_to_be16(ah->curchan->chan->center_freq);
        fft_sample.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl0);
        fft_sample.noise = ah->noise;
 
@@ -1105,14 +1106,15 @@ static int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
        /* mag data is at the end of the frame, in front of radar_info */
        mag_info = ((struct ath_ht20_mag_info *)radar_info) - 1;
 
-       /* Apply exponent and grab further auxiliary information. */
-       for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++)
-               fft_sample.data[i] = bins[i] << mag_info->max_exp;
+       /* copy raw bins without scaling them */
+       memcpy(fft_sample.data, bins, SPECTRAL_HT20_NUM_BINS);
+       fft_sample.max_exp = mag_info->max_exp & 0xf;
 
        fft_sample.max_magnitude = spectral_max_magnitude(mag_info->all_bins);
+       fft_sample.max_magnitude = __cpu_to_be16(fft_sample.max_magnitude);
        fft_sample.max_index = spectral_max_index(mag_info->all_bins);
        fft_sample.bitmap_weight = spectral_bitmap_weight(mag_info->all_bins);
-       fft_sample.tsf = tsf;
+       fft_sample.tsf = __cpu_to_be64(tsf);
 
        ath_debug_send_fft_sample(sc, &fft_sample.tlv);
        return 1;