Skip to content

Commit 5953ff6

Browse files
AyalaBkrjmberg-intel
authored andcommitted
mac80211: implement nan_change_conf
Implement nan_change_conf callback which allows to change current NAN configuration (master preference and dual band operation). Store the current NAN configuration in sdata, so it can be used both to provide the driver the updated configuration with changes and also it will be used in hw reconfig flows in next patches. Signed-off-by: Andrei Otcheretianski <[email protected]> Signed-off-by: Emmanuel Grumbach <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 368e5a7 commit 5953ff6

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed

include/net/mac80211.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,6 +3423,12 @@ enum ieee80211_reconfig_type {
34233423
*
34243424
* @start_nan: join an existing NAN cluster, or create a new one.
34253425
* @stop_nan: leave the NAN cluster.
3426+
* @nan_change_conf: change NAN configuration. The data in cfg80211_nan_conf
3427+
* contains full new configuration and changes specify which parameters
3428+
* are changed with respect to the last NAN config.
3429+
* The driver gets both full configuration and the changed parameters since
3430+
* some devices may need the full configuration while others need only the
3431+
* changed parameters.
34263432
*/
34273433
struct ieee80211_ops {
34283434
void (*tx)(struct ieee80211_hw *hw,
@@ -3664,6 +3670,9 @@ struct ieee80211_ops {
36643670
struct cfg80211_nan_conf *conf);
36653671
int (*stop_nan)(struct ieee80211_hw *hw,
36663672
struct ieee80211_vif *vif);
3673+
int (*nan_change_conf)(struct ieee80211_hw *hw,
3674+
struct ieee80211_vif *vif,
3675+
struct cfg80211_nan_conf *conf, u32 changes);
36673676
};
36683677

36693678
/**

net/mac80211/cfg.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,36 @@ static void ieee80211_stop_nan(struct wiphy *wiphy,
186186
ieee80211_sdata_stop(sdata);
187187
}
188188

189+
static int ieee80211_nan_change_conf(struct wiphy *wiphy,
190+
struct wireless_dev *wdev,
191+
struct cfg80211_nan_conf *conf,
192+
u32 changes)
193+
{
194+
struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
195+
struct cfg80211_nan_conf new_conf;
196+
int ret = 0;
197+
198+
if (sdata->vif.type != NL80211_IFTYPE_NAN)
199+
return -EOPNOTSUPP;
200+
201+
if (!ieee80211_sdata_running(sdata))
202+
return -ENETDOWN;
203+
204+
new_conf = sdata->u.nan.conf;
205+
206+
if (changes & CFG80211_NAN_CONF_CHANGED_PREF)
207+
new_conf.master_pref = conf->master_pref;
208+
209+
if (changes & CFG80211_NAN_CONF_CHANGED_DUAL)
210+
new_conf.dual = conf->dual;
211+
212+
ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes);
213+
if (!ret)
214+
sdata->u.nan.conf = new_conf;
215+
216+
return ret;
217+
}
218+
189219
static int ieee80211_set_noack_map(struct wiphy *wiphy,
190220
struct net_device *dev,
191221
u16 noack_map)
@@ -3500,4 +3530,5 @@ const struct cfg80211_ops mac80211_config_ops = {
35003530
.del_tx_ts = ieee80211_del_tx_ts,
35013531
.start_nan = ieee80211_start_nan,
35023532
.stop_nan = ieee80211_stop_nan,
3533+
.nan_change_conf = ieee80211_nan_change_conf,
35033534
};

net/mac80211/driver-ops.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,4 +1192,25 @@ static inline void drv_stop_nan(struct ieee80211_local *local,
11921192
trace_drv_return_void(local);
11931193
}
11941194

1195+
static inline int drv_nan_change_conf(struct ieee80211_local *local,
1196+
struct ieee80211_sub_if_data *sdata,
1197+
struct cfg80211_nan_conf *conf,
1198+
u32 changes)
1199+
{
1200+
int ret;
1201+
1202+
might_sleep();
1203+
check_sdata_in_driver(sdata);
1204+
1205+
if (!local->ops->nan_change_conf)
1206+
return -EOPNOTSUPP;
1207+
1208+
trace_drv_nan_change_conf(local, sdata, conf, changes);
1209+
ret = local->ops->nan_change_conf(&local->hw, &sdata->vif, conf,
1210+
changes);
1211+
trace_drv_return_int(local, ret);
1212+
1213+
return ret;
1214+
}
1215+
11951216
#endif /* __MAC80211_DRIVER_OPS */

net/mac80211/ieee80211_i.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ struct ieee80211_if_mntr {
830830
u8 mu_follow_addr[ETH_ALEN] __aligned(2);
831831
};
832832

833+
/**
834+
* struct ieee80211_if_nan - NAN state
835+
*
836+
* @conf: current NAN configuration
837+
*/
838+
struct ieee80211_if_nan {
839+
struct cfg80211_nan_conf conf;
840+
};
841+
833842
struct ieee80211_sub_if_data {
834843
struct list_head list;
835844

@@ -929,6 +938,7 @@ struct ieee80211_sub_if_data {
929938
struct ieee80211_if_mesh mesh;
930939
struct ieee80211_if_ocb ocb;
931940
struct ieee80211_if_mntr mntr;
941+
struct ieee80211_if_nan nan;
932942
} u;
933943

934944
#ifdef CONFIG_MAC80211_DEBUGFS

net/mac80211/trace.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,37 @@ TRACE_EVENT(drv_stop_nan,
17501750
)
17511751
);
17521752

1753+
TRACE_EVENT(drv_nan_change_conf,
1754+
TP_PROTO(struct ieee80211_local *local,
1755+
struct ieee80211_sub_if_data *sdata,
1756+
struct cfg80211_nan_conf *conf,
1757+
u32 changes),
1758+
1759+
TP_ARGS(local, sdata, conf, changes),
1760+
TP_STRUCT__entry(
1761+
LOCAL_ENTRY
1762+
VIF_ENTRY
1763+
__field(u8, master_pref)
1764+
__field(u8, dual)
1765+
__field(u32, changes)
1766+
),
1767+
1768+
TP_fast_assign(
1769+
LOCAL_ASSIGN;
1770+
VIF_ASSIGN;
1771+
__entry->master_pref = conf->master_pref;
1772+
__entry->dual = conf->dual;
1773+
__entry->changes = changes;
1774+
),
1775+
1776+
TP_printk(
1777+
LOCAL_PR_FMT VIF_PR_FMT
1778+
", master preference: %u, dual: %d, changes: 0x%x",
1779+
LOCAL_PR_ARG, VIF_PR_ARG, __entry->master_pref,
1780+
__entry->dual, __entry->changes
1781+
)
1782+
);
1783+
17531784
/*
17541785
* Tracing for API calls that drivers call.
17551786
*/

0 commit comments

Comments
 (0)