瀏覽代碼

qcacmn: Add support for tx flags for packet capture mode

Fill tx flags in radiotap header based on tx status for
tx packets capture in packet capture component.

Change-Id: I52da01a2c0677d32bfb05a1f3095a0e6df084fca
CRs-Fixed: 3132140
Vulupala Shashank Reddy 3 年之前
父節點
當前提交
f4a25a4af0
共有 2 個文件被更改,包括 55 次插入0 次删除
  1. 2 0
      qdf/inc/qdf_nbuf.h
  2. 53 0
      qdf/linux/src/qdf_nbuf.c

+ 2 - 0
qdf/inc/qdf_nbuf.h

@@ -208,6 +208,7 @@ typedef __qdf_nbuf_queue_t qdf_nbuf_queue_t;
  * increase this when we add more radiotap elements.
  * Number after '+' indicates maximum possible increase due to alignment
  */
+#define RADIOTAP_TX_FLAGS_LEN (2 + 1)
 #define RADIOTAP_VHT_FLAGS_LEN (12 + 1)
 #define RADIOTAP_HE_FLAGS_LEN (12 + 1)
 #define RADIOTAP_HE_MU_FLAGS_LEN (8 + 1)
@@ -228,6 +229,7 @@ typedef __qdf_nbuf_queue_t qdf_nbuf_queue_t;
 	(sizeof(struct qdf_radiotap_ext2))
 #define RADIOTAP_HEADER_LEN (RADIOTAP_BASE_HEADER_LEN + \
 				RADIOTAP_FIXED_HEADER_LEN + \
+				RADIOTAP_TX_FLAGS_LEN + \
 				RADIOTAP_HT_FLAGS_LEN + \
 				RADIOTAP_VHT_FLAGS_LEN + \
 				RADIOTAP_AMPDU_STATUS_LEN + \

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

@@ -73,6 +73,10 @@
 #define RADIOTAP_VHT_BW_80	4
 #define RADIOTAP_VHT_BW_160	11
 
+/* tx status */
+#define RADIOTAP_TX_STATUS_FAIL		1
+#define RADIOTAP_TX_STATUS_NOACK	2
+
 /* channel number to freq conversion */
 #define CHANNEL_NUM_14 14
 #define CHANNEL_NUM_15 15
@@ -4959,6 +4963,41 @@ static unsigned int qdf_nbuf_update_radiotap_ampdu_flags(
 (rx_status->rssi_comb + rx_status->chan_noise_floor)
 #endif
 
+/**
+ * qdf_nbuf_update_radiotap_tx_flags() - Update radiotap header tx flags
+ * @rx_status: Pointer to rx_status.
+ * @rtap_buf: Buf to which tx info has to be updated.
+ * @rtap_len: Current length of radiotap buffer
+ *
+ * Return: Length of radiotap after tx flags updated.
+ */
+static unsigned int qdf_nbuf_update_radiotap_tx_flags(
+						struct mon_rx_status *rx_status,
+						uint8_t *rtap_buf,
+						uint32_t rtap_len)
+{
+	/*
+	 * IEEE80211_RADIOTAP_TX_FLAGS u16
+	 */
+
+	uint16_t tx_flags = 0;
+
+	rtap_len = qdf_align(rtap_len, 2);
+
+	switch (rx_status->tx_status) {
+	case RADIOTAP_TX_STATUS_FAIL:
+		tx_flags |= IEEE80211_RADIOTAP_F_TX_FAIL;
+		break;
+	case RADIOTAP_TX_STATUS_NOACK:
+		tx_flags |= IEEE80211_RADIOTAP_F_TX_NOACK;
+		break;
+	}
+	put_unaligned_le16(tx_flags, &rtap_buf[rtap_len]);
+	rtap_len += 2;
+
+	return rtap_len;
+}
+
 /**
  * qdf_nbuf_update_radiotap() - Update radiotap header from rx_status
  * @rx_status: Pointer to rx_status.
@@ -5062,6 +5101,20 @@ unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status,
 		return 0;
 	}
 
+	/* update tx flags for pkt capture*/
+	if (rx_status->add_rtap_ext) {
+		rthdr->it_present |=
+			cpu_to_le32(1 << IEEE80211_RADIOTAP_TX_FLAGS);
+		rtap_len = qdf_nbuf_update_radiotap_tx_flags(rx_status,
+							     rtap_buf,
+							     rtap_len);
+
+		if ((rtap_len - length) > RADIOTAP_TX_FLAGS_LEN) {
+			qdf_print("length is greater than RADIOTAP_TX_FLAGS_LEN");
+			return 0;
+		}
+	}
+
 	if (rx_status->ht_flags) {
 		length = rtap_len;
 		/* IEEE80211_RADIOTAP_VHT u8, u8, u8 */