Commit 0fda6d7b authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau
Browse files

mt76: report Rx timestamp



Frame reception timestamp (low 32-bits) that indicates the value of the
local TSF timer value at the time the first bit of the MAC header in the
received frame (PPDU unit) arriving at the MAC.

Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 92e91636
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ mt76_rx_aggr_check_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames)

		nframes--;
		status = (struct mt76_rx_status *)skb->cb;
		if (!time_after(jiffies,
		if (!time_after32(jiffies,
				  status->reorder_time +
				  mt76_aggr_tid_to_timeo(tid->num)))
			continue;
+2 −0
Original line number Diff line number Diff line
@@ -754,6 +754,8 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb,
	status->signal = mstat.signal;
	status->chains = mstat.chains;
	status->ampdu_reference = mstat.ampdu_ref;
	status->device_timestamp = mstat.timestamp;
	status->mactime = mstat.timestamp;

	BUILD_BUG_ON(sizeof(mstat) > sizeof(skb->cb));
	BUILD_BUG_ON(sizeof(status->chain_signal) !=
+2 −1
Original line number Diff line number Diff line
@@ -498,9 +498,10 @@ struct mt76_rx_status {
		u16 wcid_idx;
	};

	unsigned long reorder_time;
	u32 reorder_time;

	u32 ampdu_ref;
	u32 timestamp;

	u8 iv[6];

+3 −0
Original line number Diff line number Diff line
@@ -548,6 +548,9 @@ int mt7603_register_device(struct mt7603_dev *dev)
	hw->max_report_rates = 7;
	hw->max_rate_tries = 11;

	hw->radiotap_timestamp.units_pos =
		IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;

	hw->sta_data_size = sizeof(struct mt7603_sta);
	hw->vif_data_size = sizeof(struct mt7603_vif);

+17 −14
Original line number Diff line number Diff line
@@ -532,20 +532,6 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
		status->flag |= RX_FLAG_MMIC_STRIPPED | RX_FLAG_MIC_STRIPPED;
	}

	if (!(rxd2 & (MT_RXD2_NORMAL_NON_AMPDU_SUB |
		      MT_RXD2_NORMAL_NON_AMPDU))) {
		status->flag |= RX_FLAG_AMPDU_DETAILS;

		/* all subframes of an A-MPDU have the same timestamp */
		if (dev->rx_ampdu_ts != rxd[12]) {
			if (!++dev->ampdu_ref)
				dev->ampdu_ref++;
		}
		dev->rx_ampdu_ts = rxd[12];

		status->ampdu_ref = dev->ampdu_ref;
	}

	remove_pad = rxd1 & MT_RXD1_NORMAL_HDR_OFFSET;

	if (rxd2 & MT_RXD2_NORMAL_MAX_LEN_ERROR)
@@ -579,6 +565,23 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
			return -EINVAL;
	}
	if (rxd0 & MT_RXD0_NORMAL_GROUP_2) {
		status->timestamp = le32_to_cpu(rxd[0]);
		status->flag |= RX_FLAG_MACTIME_START;

		if (!(rxd2 & (MT_RXD2_NORMAL_NON_AMPDU_SUB |
			      MT_RXD2_NORMAL_NON_AMPDU))) {
			status->flag |= RX_FLAG_AMPDU_DETAILS;

			/* all subframes of an A-MPDU have the same timestamp */
			if (dev->rx_ampdu_ts != status->timestamp) {
				if (!++dev->ampdu_ref)
					dev->ampdu_ref++;
			}
			dev->rx_ampdu_ts = status->timestamp;

			status->ampdu_ref = dev->ampdu_ref;
		}

		rxd += 2;
		if ((u8 *)rxd - skb->data >= skb->len)
			return -EINVAL;
Loading