summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/virtual/mac80211_hwsim_nan.h
blob: 81e105ac7b8eda7978f32e8e8fef3a368f979530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// SPDX-License-Identifier: GPL-2.0-only
/*
 * mac80211_hwsim_nan - NAN software simulation for mac80211_hwsim
 * Copyright (C) 2025-2026 Intel Corporation
 */

#ifndef __MAC80211_HWSIM_NAN_H
#define __MAC80211_HWSIM_NAN_H

enum mac80211_hwsim_nan_phase {
	MAC80211_HWSIM_NAN_PHASE_SCAN,
	MAC80211_HWSIM_NAN_PHASE_WARMUP,
	MAC80211_HWSIM_NAN_PHASE_UP,
};

enum mac80211_hwsim_nan_role {
	MAC80211_HWSIM_NAN_ROLE_MASTER,
	MAC80211_HWSIM_NAN_ROLE_SYNC,
	MAC80211_HWSIM_NAN_ROLE_NON_SYNC,
};

struct mac80211_hwsim_nan_data {
	struct ieee80211_vif *device_vif;
	u8 bands;

	struct hrtimer slot_timer;
	struct hrtimer resume_txqs_timer;
	bool notify_dw;

	struct hrtimer discovery_beacon_timer;

	/* Later members are protected by this lock */
	spinlock_t state_lock;

	u8 master_pref;
	u8 random_factor;

	u8 random_factor_valid_dwst;

	enum mac80211_hwsim_nan_phase phase;
	enum mac80211_hwsim_nan_role role;

	u8 cluster_id[ETH_ALEN];

	struct ieee80211_nan_anchor_master_info current_ami;
	struct ieee80211_nan_anchor_master_info last_ami;

	/* Wi-Fi Aware version 4.0, section 3.3.6.1 and 3.3.6.2 */
	int master_transition_score;
	/* Wi-Fi Aware version 4.0, section 3.3.6.3 and 3.3.6.4 */
	int sync_transition_score;

	bool tsf_adjusted;
	bool tsf_discontinuity;

	/*
	 * Local schedule - stores channel definition for each 16TU slot.
	 * Derived from NMI vif->cfg.nan_schedule. chan == NULL means not
	 * available in that slot (except DW which is implicit).
	 */
	struct cfg80211_chan_def local_sched[CFG80211_NAN_SCHED_NUM_TIME_SLOTS];
};

enum hrtimer_restart
mac80211_hwsim_nan_slot_timer(struct hrtimer *timer);
enum hrtimer_restart
mac80211_hwsim_nan_resume_txqs_timer(struct hrtimer *timer);
enum hrtimer_restart
mac80211_hwsim_nan_discovery_beacon_timer(struct hrtimer *timer);

int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
			     struct ieee80211_vif *vif,
			     struct cfg80211_nan_conf *conf);

int mac80211_hwsim_nan_stop(struct ieee80211_hw *hw,
			    struct ieee80211_vif *vif);

int mac80211_hwsim_nan_change_config(struct ieee80211_hw *hw,
				     struct ieee80211_vif *vif,
				     struct cfg80211_nan_conf *conf,
				     u32 changes);

int mac80211_hwsim_nan_peer_sched_changed(struct ieee80211_hw *hw,
					  struct ieee80211_sta *sta);

bool mac80211_hwsim_nan_txq_transmitting(struct ieee80211_hw *hw,
					 struct ieee80211_txq *txq);

void mac80211_hwsim_nan_get_tx_chandef(struct ieee80211_hw *hw,
				       struct cfg80211_chan_def *chandef);

bool mac80211_hwsim_nan_receive(struct ieee80211_hw *hw,
				struct ieee80211_channel *channel,
				struct ieee80211_rx_status *rx_status);

void mac80211_hwsim_nan_rx(struct ieee80211_hw *hw,
			   struct sk_buff *skb);

void mac80211_hwsim_nan_local_sched_changed(struct ieee80211_hw *hw,
					    struct ieee80211_vif *vif);

#endif /* __MAC80211_HWSIM_NAN_H */