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

wifi: mac80211: add support for set_hw_timestamp command



Support the set_hw_timestamp callback for enabling and disabling HW
timestamping if the low level driver supports it.

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/20230301115906.700ded7badde.Ib2f7c228256ce313a04d3d9f9ecc6c7b9aa602bb@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent cbbaf2bb
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -4230,6 +4230,9 @@ struct ieee80211_prep_tx_info {
 *	Note that a sta can also be inserted or removed with valid links,
 *	Note that a sta can also be inserted or removed with valid links,
 *	i.e. passed to @sta_add/@sta_state with sta->valid_links not zero.
 *	i.e. passed to @sta_add/@sta_state with sta->valid_links not zero.
 *	In fact, cannot change from having valid_links and not having them.
 *	In fact, cannot change from having valid_links and not having them.
 * @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames. This is
 *	not restored at HW reset by mac80211 so drivers need to take care of
 *	that.
 */
 */
struct ieee80211_ops {
struct ieee80211_ops {
	void (*tx)(struct ieee80211_hw *hw,
	void (*tx)(struct ieee80211_hw *hw,
@@ -4589,6 +4592,9 @@ struct ieee80211_ops {
				struct ieee80211_vif *vif,
				struct ieee80211_vif *vif,
				struct ieee80211_sta *sta,
				struct ieee80211_sta *sta,
				u16 old_links, u16 new_links);
				u16 old_links, u16 new_links);
	int (*set_hw_timestamp)(struct ieee80211_hw *hw,
				struct ieee80211_vif *vif,
				struct cfg80211_set_hw_timestamp *hwts);
};
};


/**
/**
+17 −0
Original line number Original line Diff line number Diff line
@@ -4904,6 +4904,22 @@ ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev,
	return ret;
	return ret;
}
}


static int ieee80211_set_hw_timestamp(struct wiphy *wiphy,
				      struct net_device *dev,
				      struct cfg80211_set_hw_timestamp *hwts)
{
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
	struct ieee80211_local *local = sdata->local;

	if (!local->ops->set_hw_timestamp)
		return -EOPNOTSUPP;

	if (!check_sdata_in_driver(sdata))
		return -EIO;

	return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts);
}

const struct cfg80211_ops mac80211_config_ops = {
const struct cfg80211_ops mac80211_config_ops = {
	.add_virtual_intf = ieee80211_add_iface,
	.add_virtual_intf = ieee80211_add_iface,
	.del_virtual_intf = ieee80211_del_iface,
	.del_virtual_intf = ieee80211_del_iface,
@@ -5014,4 +5030,5 @@ const struct cfg80211_ops mac80211_config_ops = {
	.add_link_station = ieee80211_add_link_station,
	.add_link_station = ieee80211_add_link_station,
	.mod_link_station = ieee80211_mod_link_station,
	.mod_link_station = ieee80211_mod_link_station,
	.del_link_station = ieee80211_del_link_station,
	.del_link_station = ieee80211_del_link_station,
	.set_hw_timestamp = ieee80211_set_hw_timestamp,
};
};