Browse Source

qcacmn: Fix channel info in radiotap

Fix frequency and channel flags fields in radiotap API

Change-Id: Ic991ea796d0b19f8adc16a5bc33cfde0042c167e
CRs-fixed: 2189914
sumedh baikady 7 years ago
parent
commit
b882f93dbc
3 changed files with 61 additions and 0 deletions
  1. 2 0
      hal/wifi3.0/hal_api_mon.h
  2. 4 0
      qdf/inc/qdf_nbuf.h
  3. 55 0
      qdf/linux/src/qdf_nbuf.c

+ 2 - 0
hal/wifi3.0/hal_api_mon.h

@@ -658,6 +658,7 @@ hal_rx_status_get_tlv_info(void *rx_tlv, struct hal_rx_ppdu_info *ppdu_info)
 		default:
 			break;
 		}
+		ppdu_info->rx_status.cck_flag = 1;
 	break;
 	}
 
@@ -696,6 +697,7 @@ hal_rx_status_get_tlv_info(void *rx_tlv, struct hal_rx_ppdu_info *ppdu_info)
 		default:
 			break;
 		}
+		ppdu_info->rx_status.ofdm_flag = 1;
 	break;
 	}
 

+ 4 - 0
qdf/inc/qdf_nbuf.h

@@ -175,6 +175,8 @@
  * @tid: QoS traffic tid number
  * @rs_fcs_err: FCS error flag
  * @rs_flags: Flags to indicate AMPDU or AMSDU aggregation
+ * @cck_flag: Flag to indicate CCK modulation
+ * @ofdm_flag: Flag to indicate OFDM modulation
  * @he_per_user_1: HE per user info1
  * @he_per_user_2: HE per user info2
  * @he_per_user_position: HE per user position info
@@ -239,6 +241,8 @@ struct mon_rx_status {
 	uint32_t tid;
 	uint8_t  rs_fcs_err;
 	uint8_t      rs_flags;
+	uint8_t cck_flag;
+	uint8_t ofdm_flag;
 	/* New HE radiotap fields */
 	uint16_t he_per_user_1;
 	uint16_t he_per_user_2;

+ 55 - 0
qdf/linux/src/qdf_nbuf.c

@@ -80,6 +80,25 @@
 #define RADIOTAP_VHT_BW_80	4
 #define RADIOTAP_VHT_BW_160	11
 
+/* channel number to freq conversion */
+#define CHANNEL_NUM_14 14
+#define CHANNEL_NUM_15 15
+#define CHANNEL_NUM_27 27
+#define CHANNEL_NUM_35 35
+#define CHANNEL_NUM_182 182
+#define CHANNEL_NUM_197 197
+#define CHANNEL_FREQ_2484 2484
+#define CHANNEL_FREQ_2407 2407
+#define CHANNEL_FREQ_2512 2512
+#define CHANNEL_FREQ_5000 5000
+#define CHANNEL_FREQ_4000 4000
+#define FREQ_MULTIPLIER_CONST_5MHZ 5
+#define FREQ_MULTIPLIER_CONST_20MHZ 20
+#define RADIOTAP_5G_SPECTRUM_CHANNEL 0x0100
+#define RADIOTAP_2G_SPECTRUM_CHANNEL 0x0080
+#define RADIOTAP_CCK_CHANNEL 0x0020
+#define RADIOTAP_OFDM_CHANNEL 0x0040
+
 #ifdef CONFIG_MCL
 #include <qdf_mc_timer.h>
 
@@ -3613,6 +3632,33 @@ qdf_nbuf_update_radiotap_he_mu_other_flags(struct mon_rx_status *rx_status,
 #define IEEE80211_RADIOTAP_HE_MU	24
 #define IEEE80211_RADIOTAP_HE_MU_OTHER	25
 
+/**
+ * radiotap_num_to_freq() - Get frequency from chan number
+ * @chan_num - Input channel number
+ *
+ * Return - Channel frequency in Mhz
+ */
+static uint16_t radiotap_num_to_freq (uint16_t chan_num)
+{
+	if (chan_num == CHANNEL_NUM_14)
+		return CHANNEL_FREQ_2484;
+	if (chan_num < CHANNEL_NUM_14)
+		return CHANNEL_FREQ_2407 +
+			(chan_num * FREQ_MULTIPLIER_CONST_5MHZ);
+
+	if (chan_num < CHANNEL_NUM_27)
+		return CHANNEL_FREQ_2512 +
+			((chan_num - CHANNEL_NUM_15) *
+			 FREQ_MULTIPLIER_CONST_20MHZ);
+
+	if (chan_num > CHANNEL_NUM_182 &&
+			chan_num < CHANNEL_NUM_197)
+		return ((chan_num * FREQ_MULTIPLIER_CONST_5MHZ) +
+			CHANNEL_FREQ_4000);
+
+	return CHANNEL_FREQ_5000 +
+		(chan_num * FREQ_MULTIPLIER_CONST_5MHZ);
+}
 /**
  * qdf_nbuf_update_radiotap() - Update radiotap header from rx_status
  * @rx_status: Pointer to rx_status.
@@ -3651,9 +3697,18 @@ unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status,
 
 	/* IEEE80211_RADIOTAP_CHANNEL 2 x __le16   MHz, bitmap */
 	rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_CHANNEL);
+	rx_status->chan_freq = radiotap_num_to_freq(rx_status->chan_num);
 	put_unaligned_le16(rx_status->chan_freq, &rtap_buf[rtap_len]);
 	rtap_len += 2;
 	/* Channel flags. */
+	if (rx_status->chan_num > CHANNEL_NUM_35)
+		rx_status->chan_flags = RADIOTAP_5G_SPECTRUM_CHANNEL;
+	else
+		rx_status->chan_flags = RADIOTAP_2G_SPECTRUM_CHANNEL;
+	if (rx_status->cck_flag)
+		rx_status->chan_flags |= RADIOTAP_CCK_CHANNEL;
+	if (rx_status->ofdm_flag)
+		rx_status->chan_flags |= RADIOTAP_OFDM_CHANNEL;
 	put_unaligned_le16(rx_status->chan_flags, &rtap_buf[rtap_len]);
 	rtap_len += 2;