Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48de2db9 authored by Vulupala Shashank Reddy's avatar Vulupala Shashank Reddy Committed by Madan Koyyalamudi
Browse files

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
parent 8e8bcdca
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for
 * any purpose with or without fee is hereby granted, provided that the
@@ -72,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
@@ -4437,6 +4442,7 @@ qdf_nbuf_update_radiotap_he_mu_other_flags(struct mon_rx_status *rx_status,
 * 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)
@@ -4455,6 +4461,7 @@ qdf_nbuf_update_radiotap_he_mu_other_flags(struct mon_rx_status *rx_status,
	(sizeof(struct qdf_radiotap_ext2))
#define RADIOTAP_HEADER_LEN (sizeof(struct ieee80211_radiotap_header) + \
				RADIOTAP_FIXED_HEADER_LEN + \
				RADIOTAP_TX_FLAGS_LEN + \
				RADIOTAP_HT_FLAGS_LEN + \
				RADIOTAP_VHT_FLAGS_LEN + \
				RADIOTAP_AMPDU_STATUS_LEN + \
@@ -4512,6 +4519,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.
@@ -4605,6 +4647,21 @@ 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) {
		length = rtap_len;
		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 */