hdr = (void *)skb->data;
if (vif && vif->type == NL80211_IFTYPE_NAN && !data->tmp_chan) {
- /* For NAN Device simulation purposes, assume that NAN is always
- * on channel 6 or channel 149, unless a ROC is in progress (for
- * USD use cases).
- */
- channel = data->nan.channel;
+ channel = mac80211_hwsim_nan_get_tx_channel(hw);
if (WARN_ON(!channel)) {
ieee80211_free_txskb(hw, skb);
return true;
}
+
+struct ieee80211_channel *
+mac80211_hwsim_nan_get_tx_channel(struct ieee80211_hw *hw)
+{
+ struct mac80211_hwsim_data *data = hw->priv;
+ u64 tsf = mac80211_hwsim_get_tsf(data->hw, data->nan.device_vif);
+ u8 slot = hwsim_nan_slot_from_tsf(tsf);
+
+ if (slot == SLOT_24GHZ_DW)
+ return ieee80211_get_channel(hw->wiphy, 2437);
+
+ if (slot == SLOT_5GHZ_DW &&
+ data->nan.bands & BIT(NL80211_BAND_5GHZ))
+ return ieee80211_get_channel(hw->wiphy, 5745);
+
+ /* drop frame and warn, NAN_CHAN_SWITCH_TIME_US should avoid races */
+ return NULL;
+}
bool mac80211_hwsim_nan_txq_transmitting(struct ieee80211_hw *hw,
struct ieee80211_txq *txq);
+struct ieee80211_channel *
+mac80211_hwsim_nan_get_tx_channel(struct ieee80211_hw *hw);
+
#endif /* __MAC80211_HWSIM_NAN_H */