xref: /linux/drivers/net/wireless/virtual/mac80211_hwsim_nan.h (revision 734bef548a96e8774d6eef5dfa2026c6edc4e80b)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * mac80211_hwsim_nan - NAN software simulation for mac80211_hwsim
4  * Copyright (C) 2025-2026 Intel Corporation
5  */
6 
7 #ifndef __MAC80211_HWSIM_NAN_H
8 #define __MAC80211_HWSIM_NAN_H
9 
10 enum mac80211_hwsim_nan_phase {
11 	MAC80211_HWSIM_NAN_PHASE_SCAN,
12 	MAC80211_HWSIM_NAN_PHASE_WARMUP,
13 	MAC80211_HWSIM_NAN_PHASE_UP,
14 };
15 
16 enum mac80211_hwsim_nan_role {
17 	MAC80211_HWSIM_NAN_ROLE_MASTER,
18 	MAC80211_HWSIM_NAN_ROLE_SYNC,
19 	MAC80211_HWSIM_NAN_ROLE_NON_SYNC,
20 };
21 
22 struct mac80211_hwsim_nan_data {
23 	struct ieee80211_vif *device_vif;
24 	u8 bands;
25 
26 	struct hrtimer slot_timer;
27 	struct hrtimer resume_txqs_timer;
28 	bool notify_dw;
29 
30 	struct hrtimer discovery_beacon_timer;
31 
32 	/* Later members are protected by this lock */
33 	spinlock_t state_lock;
34 
35 	const u8 *extra_nan_attrs;
36 	u16 extra_nan_attrs_len;
37 
38 	u8 master_pref;
39 	u8 random_factor;
40 
41 	u8 random_factor_valid_dwst;
42 
43 	enum mac80211_hwsim_nan_phase phase;
44 	enum mac80211_hwsim_nan_role role;
45 
46 	u8 cluster_id[ETH_ALEN];
47 
48 	struct ieee80211_nan_anchor_master_info current_ami;
49 	struct ieee80211_nan_anchor_master_info last_ami;
50 
51 	/* Wi-Fi Aware version 4.0, section 3.3.6.1 and 3.3.6.2 */
52 	int master_transition_score;
53 	/* Wi-Fi Aware version 4.0, section 3.3.6.3 and 3.3.6.4 */
54 	int sync_transition_score;
55 
56 	bool tsf_adjusted;
57 	bool tsf_discontinuity;
58 
59 	bool instant_comm;
60 	u8 discovery_beacon_interval;
61 
62 	/*
63 	 * Local schedule - stores channel definition for each 16TU slot.
64 	 * Derived from NMI vif->cfg.nan_schedule. chan == NULL means not
65 	 * available in that slot (except DW which is implicit).
66 	 */
67 	struct cfg80211_chan_def local_sched[CFG80211_NAN_SCHED_NUM_TIME_SLOTS];
68 
69 	/* Simulates the firmware completing a deferred schedule update */
70 	struct wiphy_delayed_work sched_update_work;
71 };
72 
73 enum hrtimer_restart
74 mac80211_hwsim_nan_slot_timer(struct hrtimer *timer);
75 enum hrtimer_restart
76 mac80211_hwsim_nan_resume_txqs_timer(struct hrtimer *timer);
77 enum hrtimer_restart
78 mac80211_hwsim_nan_discovery_beacon_timer(struct hrtimer *timer);
79 
80 int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
81 			     struct ieee80211_vif *vif,
82 			     struct cfg80211_nan_conf *conf);
83 
84 int mac80211_hwsim_nan_stop(struct ieee80211_hw *hw,
85 			    struct ieee80211_vif *vif);
86 
87 int mac80211_hwsim_nan_change_config(struct ieee80211_hw *hw,
88 				     struct ieee80211_vif *vif,
89 				     struct cfg80211_nan_conf *conf,
90 				     u32 changes);
91 
92 int mac80211_hwsim_nan_peer_sched_changed(struct ieee80211_hw *hw,
93 					  struct ieee80211_sta *sta);
94 
95 bool mac80211_hwsim_nan_txq_transmitting(struct ieee80211_hw *hw,
96 					 struct ieee80211_txq *txq);
97 
98 void mac80211_hwsim_nan_get_tx_chandef(struct ieee80211_hw *hw,
99 				       struct cfg80211_chan_def *chandef);
100 
101 bool mac80211_hwsim_nan_receive(struct ieee80211_hw *hw,
102 				struct sk_buff *skb,
103 				struct ieee80211_channel *channel,
104 				struct ieee80211_rx_status *rx_status);
105 
106 void mac80211_hwsim_nan_rx(struct ieee80211_hw *hw,
107 			   struct sk_buff *skb);
108 
109 void mac80211_hwsim_nan_local_sched_changed(struct ieee80211_hw *hw,
110 					    struct ieee80211_vif *vif);
111 
112 #endif /* __MAC80211_HWSIM_NAN_H */
113