Commit c7eca79d authored by Avraham Stern's avatar Avraham Stern Committed by Johannes Berg
Browse files

wifi: iwlwifi: mvm: report hardware timestamps in RX/TX status



For TM/FTM frames, report the hardware timestamps reported by the
fw as part of the RX/TX status. Since the fw reports the timestamps
in a dedicated notification (and not as part of the RX/TX status),
hold the frame until the fw timestamps notification is received.
Timestamping is enabled when a station is connected and disabled
when disconnected. For AP interface, only the first station will
have timestamping enabled since the fw only supports timestamping
for one peer.

Signed-off-by: default avatarAvraham Stern <avraham.stern@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230320122330.e0392d498101.I9bf12c8ecfb3f17253a13dc48a48647ddd6e7855@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 21fb8da6
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -265,6 +265,24 @@ enum iwl_legacy_cmds {
	 */
	HOT_SPOT_CMD = 0x53,

	/**
	 * @WNM_80211V_TIMING_MEASUREMENT_NOTIFICATION: Time Sync
	 *	measurement notification for TM/FTM. Sent on receipt of
	 *	respective WNM action frame for TM protocol or public action
	 *	frame for FTM protocol from peer device along with additional
	 *	meta data specified in &struct iwl_time_msmt_notify
	 */
	WNM_80211V_TIMING_MEASUREMENT_NOTIFICATION = 0x67,

	/**
	 * @WNM_80211V_TIMING_MEASUREMENT_CONFIRM_NOTIFICATION: Time Sync
	 *	measurement confirmation notification for TM/FTM. Sent on
	 *	receipt of Ack from peer for previously Tx'ed TM/FTM
	 *	action frame along with additional meta data specified in
	 *	&struct iwl_time_msmt_cfm_notify
	 */
	WNM_80211V_TIMING_MEASUREMENT_CONFIRM_NOTIFICATION = 0x68,

	/**
	 * @SCAN_OFFLOAD_COMPLETE:
	 * notification, &struct iwl_periodic_scan_complete
+135 −0
Original line number Diff line number Diff line
@@ -31,6 +31,12 @@ enum iwl_data_path_subcmd_ids {
	 */
	WNM_PLATFORM_PTM_REQUEST_CMD = 0x3,

	/**
	 * @WNM_80211V_TIMING_MEASUREMENT_CONFIG_CMD:
	 *	&struct iwl_time_sync_cfg_cmd
	 */
	WNM_80211V_TIMING_MEASUREMENT_CONFIG_CMD = 0x4,

	/**
	 * @STA_HE_CTXT_CMD: &struct iwl_he_sta_context_cmd
	 */
@@ -151,6 +157,25 @@ enum iwl_channel_estimation_flags {
	IWL_CHANNEL_ESTIMATION_COUNTER	= BIT(2),
};

enum iwl_time_sync_protocol_type {
	IWL_TIME_SYNC_PROTOCOL_TM	= BIT(0),
	IWL_TIME_SYNC_PROTOCOL_FTM	= BIT(1),
}; /* WNM_TIMING_ENABLED_PROTOCOL_API_E_VER_1 */

/**
 * struct iwl_time_sync_cfg_cmd - TM/FTM time sync measurement configuration
 *
 * @protocols: The type of frames to raise notifications for. A bitmap
 *	of @iwl_time_sync_protocol_type
 * @peer_addr: peer address with which TM/FTM measurements are required
 * @reserved: for alignment
 */
struct iwl_time_sync_cfg_cmd {
	__le32 protocols;
	u8 peer_addr[ETH_ALEN];
	u8 reserved[2];
} __packed; /* WNM_80211V_TIMING_MEASUREMENT_CONFIG_CMD_API_S_VER_1 */

/**
 * enum iwl_synced_time_operation - PTM request options
 *
@@ -193,6 +218,116 @@ struct iwl_synced_time_rsp {
	__le32 gp2_timestamp_lo;
} __packed; /* WNM_80211V_TIMING_RSP_API_S_VER_1 */

/* PTP_CTX_MAX_DATA_SIZE_IN_API_D_VER_1 */
#define PTP_CTX_MAX_DATA_SIZE   128

/**
 * struct iwl_time_msmt_ptp_ctx - Vendor specific information element
 * to allow a space for flexibility for the userspace App
 *
 * @element_id: element id of vendor specific ie
 * @length: length of vendor specific ie
 * @reserved: for alignment
 * @data: vendor specific data blob
 */
struct iwl_time_msmt_ptp_ctx {
	/* Differentiate between FTM and TM specific Vendor IEs */
	union {
		struct {
			u8 element_id;
			u8 length;
			__le16 reserved;
			u8 data[PTP_CTX_MAX_DATA_SIZE];
		} ftm; /* FTM specific vendor IE */
		struct {
			u8 element_id;
			u8 length;
			u8 data[PTP_CTX_MAX_DATA_SIZE];
		} tm; /* TM specific vendor IE */
	};
} __packed /* PTP_CTX_VER_1 */;

/**
 * struct iwl_time_msmt_notify - Time Sync measurement notification
 * for TM/FTM, along with additional meta data.
 *
 * @peer_addr: peer address
 * @reserved: for alignment
 * @dialog_token: measurement flow dialog token number
 * @followup_dialog_token: Measurement flow previous dialog token number
 * @t1_hi: high dword of t1-time of the Tx'ed action frame departure on
 *	sender side in units of 10 nano seconds
 * @t1_lo: low dword of t1-time of the Tx'ed action frame departure on
 *	sender side in units of 10 nano seconds
 * @t1_max_err: maximum t1-time error in units of 10 nano seconds
 * @t4_hi: high dword of t4-time of the Rx'ed action frame's Ack arrival on
 *	sender side in units of 10 nano seconds
 * @t4_lo: low dword of t4-time of the Rx'ed action frame's Ack arrival on
 *	sender side in units of 10 nano seconds
 * @t4_max_err: maximum t4-time error in units of 10 nano seconds
 * @t2_hi: high dword of t2-time of the Rx'ed action frame arrival on
 *	receiver side in units of 10 nano seconds
 * @t2_lo: low dword of t2-time of the Rx'ed action frame arrival on
 *	receiver side in units of 10 nano seconds
 * @t2_max_err: maximum t2-time error in units of 10 nano seconds
 * @t3_hi: high dword of t3-time of the Tx'ed action frame's Ack departure on
 *	receiver side in units of 10 nano seconds
 * @t3_lo: low dword of t3-time of the Tx'ed action frame's Ack departure on
 *	receiver side in units of 10 nano seconds
 * @t3_max_err: maximum t3-time error in units of 10 nano seconds
 * @ptp: vendor specific information element
 */
struct iwl_time_msmt_notify {
	u8 peer_addr[ETH_ALEN];
	u8 reserved[2];
	__le32 dialog_token;
	__le32 followup_dialog_token;
	__le32 t1_hi;
	__le32 t1_lo;
	__le32 t1_max_err;
	__le32 t4_hi;
	__le32 t4_lo;
	__le32 t4_max_err;
	__le32 t2_hi;
	__le32 t2_lo;
	__le32 t2_max_err;
	__le32 t3_hi;
	__le32 t3_lo;
	__le32 t3_max_err;
	struct iwl_time_msmt_ptp_ctx ptp;
} __packed; /* WNM_80211V_TIMING_MEASUREMENT_NTFY_API_S_VER_1 */

/**
 * struct iwl_time_msmt_cfm_notify - Time Sync measurement confirmation
 * notification for TM/FTM. Sent on receipt of 802.11 Ack from peer for the
 * Tx'ed TM/FTM measurement action frame.
 *
 * @peer_addr: peer address
 * @reserved: for alignment
 * @dialog_token: measurement flow dialog token number
 * @t1_hi: high dword of t1-time of the Tx'ed action frame departure on
 *	sender side in units of 10 nano seconds
 * @t1_lo: low dword of t1-time of the Tx'ed action frame departure on
 *	sender side in units of 10 nano seconds
 * @t1_max_err: maximum t1-time error in units of 10 nano seconds
 * @t4_hi: high dword of t4-time of the Rx'ed action frame's Ack arrival on
 *	sender side in units of 10 nano seconds
 * @t4_lo: low dword of t4-time of the Rx'ed action frame's Ack arrival on
 *	sender side in units of 10 nano seconds
 * @t4_max_err: maximum t4-time error in units of 10 nano seconds
 */
struct iwl_time_msmt_cfm_notify {
	u8 peer_addr[ETH_ALEN];
	u8 reserved[2];
	__le32 dialog_token;
	__le32 t1_hi;
	__le32 t1_lo;
	__le32 t1_max_err;
	__le32 t4_hi;
	__le32 t4_lo;
	__le32 t4_max_err;
} __packed; /* WNM_80211V_TIMING_MEASUREMENT_CONFIRM_NTFY_API_S_VER_1 */

/**
 * struct iwl_channel_estimation_cfg - channel estimation reporting config
 */
+1 −0
Original line number Diff line number Diff line
@@ -456,6 +456,7 @@ enum iwl_ucode_tlv_capa {
	IWL_UCODE_TLV_CAPA_DRAM_FRAG_SUPPORT		= (__force iwl_ucode_tlv_capa_t)104,
	IWL_UCODE_TLV_CAPA_DUMP_COMPLETE_SUPPORT	= (__force iwl_ucode_tlv_capa_t)105,
	IWL_UCODE_TLV_CAPA_SYNCED_TIME			= (__force iwl_ucode_tlv_capa_t)106,
	IWL_UCODE_TLV_CAPA_TIME_SYNC_BOTH_FTM_TM        = (__force iwl_ucode_tlv_capa_t)108,

#ifdef __CHECKER__
	/* sparse says it cannot increment the previous enum member */
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ iwlmvm-y += ftm-responder.o ftm-initiator.o
iwlmvm-y += rfi.o
iwlmvm-y += mld-key.o mld-mac.o link.o mld-sta.o mld-mac80211.o
iwlmvm-y += ptp.o
iwlmvm-y += time-sync.o
iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o debugfs-vif.o
iwlmvm-$(CONFIG_IWLWIFI_LEDS) += led.o
iwlmvm-$(CONFIG_PM) += d3.o
+8 −0
Original line number Diff line number Diff line
@@ -781,6 +781,12 @@ struct ptp_data {
	struct delayed_work dwork;
};

struct iwl_time_sync_data {
	struct sk_buff_head frame_list;
	u8 peer_addr[ETH_ALEN];
	bool active;
};

struct iwl_mvm {
	/* for logger access */
	struct device *dev;
@@ -1126,6 +1132,8 @@ struct iwl_mvm {
	bool sta_remove_requires_queue_remove;

	bool pldr_sync;

	struct iwl_time_sync_data time_sync;
};

/* Extract MVM priv from op_mode and _hw */
Loading