Monday, February 13, 2017

Atheros ath9k CSI Tools

https://github.com/xieyaxiongfly/Atheros-CSI-Tool

Kernel Version 4.1.10

Diff with the origin...  Could it be ported?

diff -uNr linux-4.1.10/arch/sh/boot/compressed/vmlinux.scr Atheros-CSI-Tool/arch/sh/boot/compressed/vmlinux.scr
--- linux-4.1.10/arch/sh/boot/compressed/vmlinux.scr 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/arch/sh/boot/compressed/vmlinux.scr 1969-12-31 19:00:00.000000000 -0500
@@ -1,10 +0,0 @@
-SECTIONS
-{
-  .rodata..compressed : {
- input_len = .;
- LONG(input_data_end - input_data) input_data = .;
- *(.data)
- output_len = . - 4;
- input_data_end = .;
- }
-}
diff -uNr linux-4.1.10/arch/sh/boot/romimage/vmlinux.scr Atheros-CSI-Tool/arch/sh/boot/romimage/vmlinux.scr
--- linux-4.1.10/arch/sh/boot/romimage/vmlinux.scr 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/arch/sh/boot/romimage/vmlinux.scr 1969-12-31 19:00:00.000000000 -0500
@@ -1,8 +0,0 @@
-SECTIONS
-{
-  .text : {
- zero_page_pos = .;
- *(.data)
- end_data = .;
- }
-}
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/ar9003_csi.c Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/ar9003_csi.c
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/ar9003_csi.c 1969-12-31 19:00:00.000000000 -0500
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/ar9003_csi.c 2017-02-13 17:33:46.943579002 -0500
@@ -0,0 +1,325 @@
+/*
+ * =====================================================================================
+ *       Filename:  ath9k_csi.c
+ *
+ *    Description:  extrac csi and data together from hardware
+ *        Version:  1.0
+ *
+ *         Author:  Yaxiong Xie 
+ *         Email :  <xieyaxiongfly@gmail.com>
+ *   Organization:  WANDS group @ Nanyang Technological University 
+ *
+ *   Copyright (c)  WANDS group @ Nanyang Technological University
+ * =====================================================================================
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/wait.h>
+#include <linux/netdevice.h>
+
+#include "ar9003_csi.h"
+#include "ar9003_mac.h"
+#include "ar9003_phy.h"
+#include "mac.h"
+#include "hw.h"
+
+#define Tx_Buf_LEN      20480                 // Generally, buffere with 20480 bits is enough
+                                              // You can change the size freely
+
+//#define Rx_Buf_LEN      128                   // Generally, buffere with 20480 bits is enough
+
+#define BITS_PER_BYTE   8
+#define BITS_PER_SYMBOL 10
+#define BITS_PER_COMPLEX_SYMBOL  (2 * BITS_PER_SYMBOL)
+
+#define DEVICE_NAME     "CSI_dev"
+#define CLASS_NAME      "CSI_class"
+#define AH_MAX_CHAINS   3                     //maximum chain number, we set it to 3
+#define NUM_OF_CHAINMASK (1 << AH_MAX_CHAINS)
+
+
+volatile u32        csi_head;
+volatile u32        csi_tail;
+volatile u32        csi_len;
+volatile u32        csi_valid;
+volatile u32        recording;
+
+static struct       ath9k_csi csi_buf[16];
+static char         tx_buf[Tx_Buf_LEN];
+//static char         rx_buf[Rx_Buf_LEN];
+
+static int          majorNumber;              
+static struct       class*  ebbcharClass  = NULL; 
+static struct       device* ebbcharDevice = NULL; 
+
+DECLARE_WAIT_QUEUE_HEAD(csi_queue);
+
+static int          csi_open(struct inode *inode, struct file *file);
+static int          csi_close(struct inode *inode, struct file *file);
+static ssize_t      csi_read(struct file *file, char __user *user_buf,
+        size_t count, loff_t *ppos);
+static ssize_t      csi_write(struct file *file, const char __user *user_buf,
+            size_t count, loff_t *ppos);
+
+static const struct file_operations csi_fops = {
+ .read           = csi_read,
+ .write          = csi_write,
+ .open           = csi_open,
+    .release        = csi_close,
+ .llseek         = default_llseek,
+};
+
+static u_int8_t Num_bits_on[NUM_OF_CHAINMASK] = {
+    0 /*       000 */,
+    1 /*       001 */,
+    1 /*       010 */,
+    2 /*       011 */,
+    1 /*       100 */,
+    2 /*       101 */,
+    2 /*       110 */,
+    3 /*       111 */
+};
+
+u_int8_t ar9300_get_nrx_csi(struct ath_hw *ah)
+{
+ return Num_bits_on[ah->rxchainmask];
+}
+
+static int __init csi_init(void)
+{
+
+    // initalize parameters 
+    csi_head    = 0;
+    csi_tail    = 0;
+    recording   = 0;
+    csi_valid   = 0;
+    
+    // Try to dynamically allocate a major number for the device -- more difficult but worth it
+    majorNumber = register_chrdev(0, DEVICE_NAME, &csi_fops);
+    if (majorNumber<0){
+       printk(KERN_ALERT "debug_csi: failed to register a major number\n");
+       return majorNumber;
+    }
+    printk(KERN_INFO "debug_csi: registered correctly with major number %d\n", majorNumber);
+
+    // Register the device class
+    ebbcharClass = class_create(THIS_MODULE, CLASS_NAME);
+    if (IS_ERR(ebbcharClass)){                // Check for error and clean up if there is
+       unregister_chrdev(majorNumber, DEVICE_NAME);
+       printk(KERN_ALERT "debug_csi: Failed to register device class\n");
+       return PTR_ERR(ebbcharClass);          // Correct way to return an error on a pointer
+    }
+    printk(KERN_INFO "debug_csi: device class registered correctly\n");
+    
+    // Register the device driver
+    ebbcharDevice = device_create(ebbcharClass, NULL, MKDEV(majorNumber, 0), NULL, DEVICE_NAME);
+    if (IS_ERR(ebbcharDevice)){               // Clean up if there is an error
+       class_destroy(ebbcharClass);           // Repeated code but the alternative is goto statements
+       unregister_chrdev(majorNumber, DEVICE_NAME);
+       printk(KERN_ALERT "Failed to create the device\n");
+       return PTR_ERR(ebbcharDevice);
+    }
+    printk(KERN_INFO "debug_csi: device class created correctly \n"); // Made it! device was initialized
+    
+    return 0;
+}
+
+static void __exit csi_exit(void)
+{
+    /* delete and unregister the devices we have created and registered */
+    device_destroy(ebbcharClass, MKDEV(majorNumber, 0));     // remove the device
+    class_unregister(ebbcharClass);                          // unregister the device class
+    class_destroy(ebbcharClass);                             // remove the device class
+    unregister_chrdev(majorNumber, DEVICE_NAME);             // unregister the major number
+    printk(KERN_INFO "debug_csi: Goodbye CSI device!\n");
+
+}
+
+static int csi_open(struct inode *inode, struct file *file)
+{
+    printk(KERN_ALERT "debug_csi: csi open! \n");
+    recording = 1;                                            // we can begin to record when  
+                                                              // the devices is open 
+    return 0;
+}
+
+static int csi_close(struct inode *inode, struct file *file)
+{
+    printk(KERN_ALERT "debug_csi: csi close! \n");
+    recording = 0;                                            // close and reset 
+ return 0;
+}
+
+static ssize_t csi_read(struct file *file, char __user *user_buf,
+      size_t count, loff_t *ppos)
+{
+    u_int16_t len;
+    u_int8_t *csi_buf_addr;
+    u_int8_t *payload_buf_addr;
+    u_int16_t csi_len, payload_len;
+    struct ath9k_csi* csi;
+    struct csi_pkt_status *RxStatus;
+    
+    *ppos = 0;
+    
+    if (csi_head == csi_tail) 
+    {                                                       // wait until time out
+        wait_event_interruptible_timeout(csi_queue,csi_head != csi_tail,  5*HZ);
+    } 
+    if(csi_head != csi_tail){
+        csi = (struct ath9k_csi*)&csi_buf[csi_tail];
+        len = 0;
+        
+        RxStatus         = &(csi->pkt_status);              // the status struct
+        
+        csi_len          = RxStatus->csi_len;               // csi length (bytes) 
+        csi_buf_addr     = csi->csi_buf;                    // csi buffer 
+        payload_len      = csi->payload_len;                // payload length (bytes)
+        payload_buf_addr = csi->payload_buf;                // payload buffer
+        
+
+        memcpy(tx_buf,RxStatus,23);                         // copy the status to the buffer 
+        len += 23;
+        
+        memcpy(tx_buf+len,&payload_len, 2);                 // record the length of payload 
+        len += 2;
+        
+        if (csi_len > 0){
+            memcpy(tx_buf+len,csi_buf_addr,csi_len);        // copy csi to the buffer
+            len += csi_len;
+        }
+        
+        memcpy(tx_buf+len,payload_buf_addr, payload_len);   // copy payload to the buffer
+        len += payload_len;
+        
+        memcpy(tx_buf+len,&len, 2);                         // record how many bytes we copy 
+        len += 2;
+        
+        copy_to_user(user_buf,tx_buf,len);                  // COPY
+        
+        csi_tail = (csi_tail+1) & 0x0000000F;               // delete the buffer 
+        return len;
+    }else{
+        return 0;
+    }
+}
+
+static ssize_t csi_write(struct file *file, const char __user *user_buf,
+     size_t count, loff_t *ppos)
+{
+    printk(KERN_ALERT "debug_csi: csi write!\n");
+ return 0;
+}
+
+void csi_record_payload(void* data, u_int16_t data_len)
+{
+    struct ath9k_csi* csi;
+    if(recording )
+    {
+        if( ((csi_head + 1) & 0x0000000F) == csi_tail)              // check and update 
+            csi_tail = (csi_tail + 1) & 0x0000000F;
+        
+        csi = (struct ath9k_csi*)&csi_buf[csi_head];
+        memcpy((void*)(csi->payload_buf),data, data_len);           // copy the payload
+        csi->payload_len = data_len;                                // record the payload length (bytes)
+        csi_valid = 1;
+    }
+}
+EXPORT_SYMBOL(csi_record_payload);
+
+void csi_record_status(struct ath_hw *ah, struct ath_rx_status *rxs, struct ar9003_rxs *rxsp,void* data)
+{
+    struct ath9k_csi* csi;
+
+    u_int8_t  nr;
+    u_int8_t  chan_BW;
+    u_int8_t  rx_not_sounding;
+    u_int8_t  rx_hw_upload_data;
+    u_int8_t  rx_hw_upload_data_valid;
+    u_int8_t  rx_hw_upload_data_type;
+    
+    rx_hw_upload_data             = (rxsp->status2 & AR_hw_upload_data) ? 1 : 0;
+    rx_not_sounding               = (rxsp->status4 & AR_rx_not_sounding) ? 1 : 0;
+    rx_hw_upload_data_valid       = (rxsp->status4 & AR_hw_upload_data_valid) ? 1 : 0;
+    rx_hw_upload_data_type        = MS(rxsp->status11, AR_hw_upload_data_type);
+   
+    if(rxs->rs_phyerr == 0 && rx_hw_upload_data == 0 &&
+                rx_hw_upload_data_valid == 0 && rx_hw_upload_data_type == 0){
+        return;
+    }
+
+    if(recording && csi_valid == 1)
+    {
+        csi = (struct ath9k_csi*)&csi_buf[csi_head];
+       
+        csi->pkt_status.tstamp    = rxs->rs_tstamp;     // time stamp of the rx packet 
+        
+        csi->pkt_status.channel   = ah->curchan->channel;               
+        
+        chan_BW                   = (rxsp->status4 & AR_2040) >> 1;        
+        csi->pkt_status.ChanBW    = chan_BW;            // channel bandwidth 
+        nr                        = ar9300_get_nrx_csi(ah);                    
+        csi->pkt_status.nr        = nr;                 // rx antennas number
+        
+        csi->pkt_status.phyerr    = rxs->rs_phyerr;     // PHY layer error code
+        
+        csi->pkt_status.rssi      = rxs->rs_rssi; 
+        csi->pkt_status.rssi_ctl0 = rxs->rs_rssi_ctl[0];            
+        csi->pkt_status.rssi_ctl1 = rxs->rs_rssi_ctl[1];
+        csi->pkt_status.rssi_ctl2 = rxs->rs_rssi_ctl[2];
+        
+        csi->pkt_status.noise     = 0;                  // to be updated
+        csi->pkt_status.rate      = rxs->rs_rate;       // data rate 
+        
+        rx_hw_upload_data         = (rxsp->status2 & AR_hw_upload_data) ? 1 : 0;
+        rx_not_sounding           = (rxsp->status4 & AR_rx_not_sounding) ? 1 : 0;
+        rx_hw_upload_data_valid   = (rxsp->status4 & AR_hw_upload_data_valid) ? 1 : 0;
+        rx_hw_upload_data_type    = MS(rxsp->status11, AR_hw_upload_data_type);
+        
+        // Decides how many tones(subcarriers) are used according to the channel bandwidth
+        if (chan_BW == 0){
+            csi->pkt_status.num_tones = 56;             // 20MHz Channel
+        }
+        else if (chan_BW == 1){
+            csi->pkt_status.num_tones = 114;            // 40MHz Channel
+        } 
+        else{
+            csi->pkt_status.num_tones = 56;             // 20MHz Channel
+            printk("Error happends for channel bandwidth recording!!\n");
+        }
+        
+        /* tx antennas number 
+         * NOTE: when the packet is received with error
+         * The antenna number value is not correct
+         */
+        csi->pkt_status.nc = (int) (rxs->rs_datalen * BITS_PER_BYTE) /
+                        (int) (BITS_PER_COMPLEX_SYMBOL * csi->pkt_status.nr * csi->pkt_status.num_tones);
+        printk("bebug_csi: nr is: %d, nc is %d   \n\n",csi->pkt_status.nr,csi->pkt_status.nc); 
+        /* copy the csi value to the allocated csi buffer */
+        if ( rxs->rs_datalen >0 && rx_hw_upload_data == 1 && rx_hw_upload_data_valid == 1 
+                && rx_hw_upload_data_type == 1){
+            csi->pkt_status.csi_len = rxs->rs_datalen;
+            memcpy((void*)(csi->csi_buf),data,rxs->rs_datalen);
+        }else {
+            csi->pkt_status.csi_len = 0;
+        }
+        
+        csi_valid = 0;                                  // update 
+        csi_head  = (csi_head + 1) & 0x0000000F;
+
+        wake_up_interruptible(&csi_queue);              // wake up waiting queue 
+    }
+}
+EXPORT_SYMBOL(csi_record_status);
+
+
+module_init(csi_init);
+module_exit(csi_exit);
+
+MODULE_AUTHOR("YAXIONG XIE");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("CSI EXTRACTION");
+
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/ar9003_csi.h Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/ar9003_csi.h
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/ar9003_csi.h 1969-12-31 19:00:00.000000000 -0500
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/ar9003_csi.h 2017-02-13 17:33:46.943579002 -0500
@@ -0,0 +1,73 @@
+/*
+ * =====================================================================================
+ *       Filename:  ar003_csi.h
+ *
+ *    Description:  ar003_csi data structure definiation
+ *        Version:  1.0
+ *
+ *         Author:  Yaxiong Xie 
+ *         Email :  <xieyaxiongfly@gmail.com>
+ *   Organization:  WANDS group @ Nanyang Technological University 
+ *
+ *   Copyright (c)  WANDS group @ Nanyang Technological University
+ * =====================================================================================
+ */
+
+#include "hw.h"
+#include "mac.h"
+#include "ar9003_mac.h"
+
+#define DBG_CSI(fmt, args...) printk(fmt,## args)
+#define AR_rx_ness                  0x00000060
+#define AR_rx_ness_S                5
+#define AR_ness                     0xc0000000 
+#define AR_ness_S                   30
+#define AR_hw_upload_data           0x00400000
+#define AR_hw_upload_data_S         22
+#define AR_rx_not_sounding          0x00000010
+#define AR_not_sounding             0x20000000
+#define AR_hw_upload_data_valid     0x00000080
+#define AR_hw_upload_data_valid_S   7  
+#define AR_hw_upload_data_type      0x06000000
+#define AR_hw_upload_data_type_S    25
+
+#define AR_xmit_data_tries0   0x000f0000
+#define AR_xmit_data_tries0_S 16
+#define AR_xmit_data_tries1   0x00f00000
+#define AR_xmit_data_tries1_S 20
+#define AR_xmit_data_tries2   0x0f000000
+#define AR_xmit_data_tries2_S 24
+#define AR_xmit_data_tries3   0xf0000000
+#define AR_xmit_data_tries3_S 28
+
+struct csi_pkt_status {
+    u_int64_t   tstamp;      /* h/w assigned timestamp */
+    u_int16_t   csi_len;     /* csi length */
+    u_int16_t   channel;     /* receiving channel frequency */
+    u_int8_t phyerr;     /* phy error code */
+    
+    u_int8_t    noise;       /* noise floor */
+    u_int8_t rate;     /* h/w receive rate index */
+    u_int8_t    ChanBW;      /* receiving channel bandwidth */
+    u_int8_t    num_tones;   /* number of tones (subcarriers) */
+    u_int8_t    nr;          /* number of receiving antennas */
+    u_int8_t    nc;          /* number of transmitting anteannas */
+    
+    
+    u_int8_t    rssi;        /* rx frame RSSI */
+    u_int8_t    rssi_ctl0;   /* rx frame RSSI [ctl, chain 0] */
+    u_int8_t    rssi_ctl1;   /* rx frame RSSI [ctl, chain 1] */
+    u_int8_t    rssi_ctl2;   /* rx frame RSSI [ctl, chain 2] */
+};
+
+struct ath9k_csi {
+    struct csi_pkt_status pkt_status;
+
+    u_int8_t    csi_buf[2800];     //buffer for csi value, 3 antena, each with 114 subcarriers, real and imagine part
+    u_int8_t    payload_buf[1500]; //buffer for the payload, if you send payload larger than 1500Bytes, change it
+    u_int16_t   payload_len;
+
+};
+void   csi_record_payload(void* data, u_int16_t data_len);
+void   csi_record_status(struct ath_hw *hw, struct ath_rx_status *rxs,struct ar9003_rxs *rxsp,void* data); 
+
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/ar9003_mac.c Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/ar9003_mac.c
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/ar9003_mac.c 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/ar9003_mac.c 2017-02-13 17:33:46.943579002 -0500
@@ -17,6 +17,7 @@
 #include "hw.h"
 #include "ar9003_mac.h"
 #include "ar9003_mci.h"
+#include "ar9003_csi.h"

 static void ar9003_hw_rx_enable(struct ath_hw *hw)
 {
@@ -30,7 +31,8 @@
  int checksum = 0;
  u32 val, ctl12, ctl17;
  u8 desc_len;
-
+    u_int8_t rate1,rate2,rate3,rate4;
+    
  desc_len = ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x18 : 0x17);

  val = (ATHEROS_VENDOR_ID << AR_DescId_S) |
@@ -61,6 +63,7 @@
  ACCESS_ONCE(ads->ctl7) = val;
  checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
  ACCESS_ONCE(ads->ctl9) = val;
+    

  checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
  ACCESS_ONCE(ads->ctl10) = checksum;
@@ -82,7 +85,7 @@
  ACCESS_ONCE(ads->ctl14) = 0;
  }

- ads->ctl20 = 0;
+    ads->ctl20 = 0;
  ads->ctl21 = 0;
  ads->ctl22 = 0;
  ads->ctl23 = 0;
@@ -150,11 +153,29 @@
  | set11nRateFlags(i->rates, 3)
  | SM(i->rtscts_rate, AR_RTSCTSRate);

- ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
-
  ACCESS_ONCE(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1);
  ACCESS_ONCE(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2);
  ACCESS_ONCE(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3);
+
+    rate1 = (ads->ctl14 >> 24) & 0xff;
+    rate2 = (ads->ctl14 >> 16) & 0xff;
+    rate3 = (ads->ctl14 >> 8)  & 0xff;
+    rate4 = (ads->ctl14 >> 0)  & 0xff;
+
+    if ( rate1 >= 0x80 || rate2 >= 0x80 || rate3 >= 0x80){
+    ACCESS_ONCE(ads->ctl19) = 0;
+        ACCESS_ONCE(ads->ctl13) &= ~(AR_xmit_data_tries1 | AR_xmit_data_tries2 | AR_xmit_data_tries3);
+    ACCESS_ONCE(ads->ctl20) &= 0x3f000000;
+    ACCESS_ONCE(ads->ctl21) &= 0x3f000000;
+    ACCESS_ONCE(ads->ctl22) &= 0x3f000000;
+    }else{
+    ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
+    }
+    if ( rate4 >= 0x80){
+    ACCESS_ONCE(ads->ctl19) = 0;
+    }else{
+    ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
+    }
 }

 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
@@ -483,6 +504,9 @@
  struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr;
  unsigned int phyerr;

+ void *data_addr;
+     u_int16_t data_len;
+
  if ((rxsp->status11 & AR_RxDone) == 0)
  return -EINPROGRESS;

@@ -577,9 +601,25 @@
  }
  }
  }
-
- if (rxsp->status11 & AR_KeyMiss)
+   
+    if (rxsp->status11 & AR_KeyMiss)
  rxs->rs_status |= ATH9K_RXERR_KEYMISS;
+    
+    data_len = rxs->rs_datalen;
+    data_addr = buf_addr + 48;
+    
+    if (rxsp->status11 & AR_CRCErr){
+        if (rxs->rs_rate >= 0x80){
+            csi_record_payload(data_addr,data_len);
+            csi_record_status(ah,rxs,rxsp,data_addr);
+        }
+    }else{
+        if  (rxs->rs_more == 1)
+            csi_record_payload(data_addr,data_len);
+
+        if (rxs->rs_rate >= 0x80)
+            csi_record_status(ah,rxs,rxsp,data_addr);
+ }

  return 0;
 }
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/hw.c Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/hw.c
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/hw.c 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/hw.c 2017-02-13 17:33:46.959579002 -0500
@@ -1818,6 +1818,7 @@
  u32 saveLedState;
  u32 saveDefAntenna;
  u32 macStaId1;
+ u32 tmp;
  u64 tsf = 0;
  s64 usec = 0;
  int r;
@@ -2028,6 +2029,10 @@
  ah->radar_conf.ext_channel = IS_CHAN_HT40(chan);
  ath9k_hw_set_radar_params(ah);
  }
+ //csi_debug 
+     tmp = REG_READ(ah,0x8344);
+     tmp |= (1 << 28);
+     REG_WRITE(ah, 0x8344,tmp);

  return 0;
 }
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/init.c Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/init.c
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/init.c 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/init.c 2017-02-13 17:33:46.959579002 -0500
@@ -831,7 +831,7 @@
  hw->flags |= IEEE80211_HW_SUPPORTS_PS;

  if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
- hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;
+ //hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;

  if (AR_SREV_9280_20_OR_LATER(ah))
  hw->radiotap_mcs_details |=
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/main.c Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/main.c
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/main.c 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/main.c 2017-02-13 17:33:46.967579002 -0500
@@ -2116,7 +2116,6 @@
  bf = avp->av_bcbuf;
  if (!bf || !bf->bf_mpdu)
  goto skip;
-
  status = ath9k_hw_txprocdesc(ah, bf->bf_desc, &ts);
  if (status == -EINPROGRESS)
  goto skip;
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/Makefile Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/Makefile
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/Makefile 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/Makefile 2017-02-13 17:33:46.931579002 -0500
@@ -1,3 +1,5 @@
+obj-m   +=      ar9003_csi.o 
+
 ath9k-y += beacon.o \
  gpio.o \
  init.o \
diff -uNr linux-4.1.10/drivers/net/wireless/ath/ath9k/xmit.c Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/xmit.c
--- linux-4.1.10/drivers/net/wireless/ath/ath9k/xmit.c 2015-10-03 07:49:38.000000000 -0400
+++ Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/xmit.c 2017-02-13 17:33:46.967579002 -0500
@@ -2681,7 +2681,7 @@

  lastbf = bf->bf_lastbf;
  ds = lastbf->bf_desc;
-
+        
  memset(&ts, 0, sizeof(ts));
  status = ath9k_hw_txprocdesc(ah, ds, &ts);
  if (status == -EINPROGRESS)
@@ -2736,7 +2736,6 @@
  for (;;) {
  if (test_bit(ATH_OP_HW_RESET, &common->op_flags))
  break;
-
  status = ath9k_hw_txprocdesc(ah, NULL, (void *)&ts);
  if (status == -EINPROGRESS)
  break;

No comments:

Post a Comment