Skip to content

Commit 239281f

Browse files
lisovyjmberg-intel
authored andcommitted
mac80211: 802.11p OCB mode support
This patch adds 802.11p OCB (Outside the Context of a BSS) mode support. When communicating in OCB mode a mandatory wildcard BSSID (48 '1' bits) is used. The EDCA parameters handling function was changed to support 802.11p specific values. The insertion of a newly discovered STAs is done in the similar way as in the IBSS mode -- through the deferred insertion. The OCB mode uses a periodic 'housekeeping task' for expiration of disconnected STAs (in the similar manner as in the MESH mode). New Kconfig option for verbose OCB debugging outputs is added. Signed-off-by: Rostislav Lisovy <rostislav.lisovy@fel.cvut.cz> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 6e0bd6c commit 239281f

14 files changed

Lines changed: 417 additions & 9 deletions

File tree

‎include/net/mac80211.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ struct ieee80211_vif_chanctx_switch {
263263
* @BSS_CHANGED_BANDWIDTH: The bandwidth used by this interface changed,
264264
* note that this is only called when it changes after the channel
265265
* context had been assigned.
266+
* @BSS_CHANGED_OCB: OCB join status changed
266267
*/
267268
enum ieee80211_bss_change {
268269
BSS_CHANGED_ASSOC = 1<<0,
@@ -287,6 +288,7 @@ enum ieee80211_bss_change {
287288
BSS_CHANGED_P2P_PS = 1<<19,
288289
BSS_CHANGED_BEACON_INFO = 1<<20,
289290
BSS_CHANGED_BANDWIDTH = 1<<21,
291+
BSS_CHANGED_OCB = 1<<22,
290292

291293
/* when adding here, make sure to change ieee80211_reconfig */
292294
};

‎net/mac80211/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ config MAC80211_HT_DEBUG
176176

177177
Do not select this option.
178178

179+
config MAC80211_OCB_DEBUG
180+
bool "Verbose OCB debugging"
181+
depends on MAC80211_DEBUG_MENU
182+
---help---
183+
Selecting this option causes mac80211 to print out
184+
very verbose OCB debugging messages. It should not
185+
be selected on production systems as those messages
186+
are remotely triggerable.
187+
188+
Do not select this option.
189+
179190
config MAC80211_IBSS_DEBUG
180191
bool "Verbose IBSS debugging"
181192
depends on MAC80211_DEBUG_MENU

‎net/mac80211/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ mac80211-y := \
2727
event.o \
2828
chan.o \
2929
trace.o mlme.o \
30-
tdls.o
30+
tdls.o \
31+
ocb.o
3132

3233
mac80211-$(CONFIG_MAC80211_LEDS) += led.o
3334
mac80211-$(CONFIG_MAC80211_DEBUGFS) += \

‎net/mac80211/cfg.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,17 @@ static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
20192019
return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
20202020
}
20212021

2022+
static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
2023+
struct ocb_setup *setup)
2024+
{
2025+
return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
2026+
}
2027+
2028+
static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
2029+
{
2030+
return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
2031+
}
2032+
20222033
static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
20232034
int rate[IEEE80211_NUM_BANDS])
20242035
{
@@ -3693,6 +3704,8 @@ const struct cfg80211_ops mac80211_config_ops = {
36933704
.join_mesh = ieee80211_join_mesh,
36943705
.leave_mesh = ieee80211_leave_mesh,
36953706
#endif
3707+
.join_ocb = ieee80211_join_ocb,
3708+
.leave_ocb = ieee80211_leave_ocb,
36963709
.change_bss = ieee80211_change_bss,
36973710
.set_txq_params = ieee80211_set_txq_params,
36983711
.set_monitor_channel = ieee80211_set_monitor_channel,

‎net/mac80211/chan.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
675675
case NL80211_IFTYPE_ADHOC:
676676
case NL80211_IFTYPE_WDS:
677677
case NL80211_IFTYPE_MESH_POINT:
678+
case NL80211_IFTYPE_OCB:
678679
break;
679680
default:
680681
WARN_ON_ONCE(1);

‎net/mac80211/debug.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#define __MAC80211_DEBUG_H
33
#include <net/cfg80211.h>
44

5+
#ifdef CONFIG_MAC80211_OCB_DEBUG
6+
#define MAC80211_OCB_DEBUG 1
7+
#else
8+
#define MAC80211_OCB_DEBUG 0
9+
#endif
10+
511
#ifdef CONFIG_MAC80211_IBSS_DEBUG
612
#define MAC80211_IBSS_DEBUG 1
713
#else
@@ -131,6 +137,10 @@ do { \
131137
_sdata_dbg(MAC80211_HT_DEBUG && net_ratelimit(), \
132138
sdata, fmt, ##__VA_ARGS__)
133139

140+
#define ocb_dbg(sdata, fmt, ...) \
141+
_sdata_dbg(MAC80211_OCB_DEBUG, \
142+
sdata, fmt, ##__VA_ARGS__)
143+
134144
#define ibss_dbg(sdata, fmt, ...) \
135145
_sdata_dbg(MAC80211_IBSS_DEBUG, \
136146
sdata, fmt, ##__VA_ARGS__)

‎net/mac80211/driver-ops.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
214214
BSS_CHANGED_BEACON_ENABLED) &&
215215
sdata->vif.type != NL80211_IFTYPE_AP &&
216216
sdata->vif.type != NL80211_IFTYPE_ADHOC &&
217-
sdata->vif.type != NL80211_IFTYPE_MESH_POINT))
217+
sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
218+
sdata->vif.type != NL80211_IFTYPE_OCB))
218219
return;
219220

220221
if (WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE ||

‎net/mac80211/ieee80211_i.h‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,25 @@ struct ieee80211_if_ibss {
576576
} state;
577577
};
578578

579+
/**
580+
* struct ieee80211_if_ocb - OCB mode state
581+
*
582+
* @housekeeping_timer: timer for periodic invocation of a housekeeping task
583+
* @wrkq_flags: OCB deferred task action
584+
* @incomplete_lock: delayed STA insertion lock
585+
* @incomplete_stations: list of STAs waiting for delayed insertion
586+
* @joined: indication if the interface is connected to an OCB network
587+
*/
588+
struct ieee80211_if_ocb {
589+
struct timer_list housekeeping_timer;
590+
unsigned long wrkq_flags;
591+
592+
spinlock_t incomplete_lock;
593+
struct list_head incomplete_stations;
594+
595+
bool joined;
596+
};
597+
579598
/**
580599
* struct ieee80211_mesh_sync_ops - Extensible synchronization framework interface
581600
*
@@ -869,6 +888,7 @@ struct ieee80211_sub_if_data {
869888
struct ieee80211_if_managed mgd;
870889
struct ieee80211_if_ibss ibss;
871890
struct ieee80211_if_mesh mesh;
891+
struct ieee80211_if_ocb ocb;
872892
u32 mntr_flags;
873893
} u;
874894

@@ -1505,6 +1525,15 @@ int ieee80211_ibss_csa_beacon(struct ieee80211_sub_if_data *sdata,
15051525
int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata);
15061526
void ieee80211_ibss_stop(struct ieee80211_sub_if_data *sdata);
15071527

1528+
/* OCB code */
1529+
void ieee80211_ocb_work(struct ieee80211_sub_if_data *sdata);
1530+
void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1531+
const u8 *bssid, const u8 *addr, u32 supp_rates);
1532+
void ieee80211_ocb_setup_sdata(struct ieee80211_sub_if_data *sdata);
1533+
int ieee80211_ocb_join(struct ieee80211_sub_if_data *sdata,
1534+
struct ocb_setup *setup);
1535+
int ieee80211_ocb_leave(struct ieee80211_sub_if_data *sdata);
1536+
15081537
/* mesh code */
15091538
void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata);
15101539
void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,

‎net/mac80211/iface.c‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,15 @@ static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata,
258258
/* we hold the RTNL here so can safely walk the list */
259259
list_for_each_entry(nsdata, &local->interfaces, list) {
260260
if (nsdata != sdata && ieee80211_sdata_running(nsdata)) {
261+
/*
262+
* Only OCB and monitor mode may coexist
263+
*/
264+
if ((sdata->vif.type == NL80211_IFTYPE_OCB &&
265+
nsdata->vif.type != NL80211_IFTYPE_MONITOR) ||
266+
(sdata->vif.type != NL80211_IFTYPE_MONITOR &&
267+
nsdata->vif.type == NL80211_IFTYPE_OCB))
268+
return -EBUSY;
269+
261270
/*
262271
* Allow only a single IBSS interface to be up at any
263272
* time. This is restricted because beacon distribution
@@ -1283,6 +1292,9 @@ static void ieee80211_iface_work(struct work_struct *work)
12831292
break;
12841293
ieee80211_mesh_work(sdata);
12851294
break;
1295+
case NL80211_IFTYPE_OCB:
1296+
ieee80211_ocb_work(sdata);
1297+
break;
12861298
default:
12871299
break;
12881300
}
@@ -1302,6 +1314,9 @@ static void ieee80211_recalc_smps_work(struct work_struct *work)
13021314
static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
13031315
enum nl80211_iftype type)
13041316
{
1317+
static const u8 bssid_wildcard[ETH_ALEN] = {0xff, 0xff, 0xff,
1318+
0xff, 0xff, 0xff};
1319+
13051320
/* clear type-dependent union */
13061321
memset(&sdata->u, 0, sizeof(sdata->u));
13071322

@@ -1354,7 +1369,8 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
13541369
ieee80211_sta_setup_sdata(sdata);
13551370
break;
13561371
case NL80211_IFTYPE_OCB:
1357-
/* to be implemented in the future */
1372+
sdata->vif.bss_conf.bssid = bssid_wildcard;
1373+
ieee80211_ocb_setup_sdata(sdata);
13581374
break;
13591375
case NL80211_IFTYPE_ADHOC:
13601376
sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid;
@@ -1403,6 +1419,7 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
14031419
case NL80211_IFTYPE_AP:
14041420
case NL80211_IFTYPE_STATION:
14051421
case NL80211_IFTYPE_ADHOC:
1422+
case NL80211_IFTYPE_OCB:
14061423
/*
14071424
* Could maybe also all others here?
14081425
* Just not sure how that interacts
@@ -1418,6 +1435,7 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
14181435
case NL80211_IFTYPE_AP:
14191436
case NL80211_IFTYPE_STATION:
14201437
case NL80211_IFTYPE_ADHOC:
1438+
case NL80211_IFTYPE_OCB:
14211439
/*
14221440
* Could probably support everything
14231441
* but WDS here (WDS do_open can fail

0 commit comments

Comments
 (0)