Skip to content

Commit 488dd7b

Browse files
committed
mac80211: pass P2P powersave parameters to driver
While connected to a GO, parse the P2P NoA attribute and pass the CT Window and opportunistic powersave parameters to the driver. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 0ee4535 commit 488dd7b

4 files changed

Lines changed: 53 additions & 0 deletions

File tree

‎include/net/mac80211.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ struct ieee80211_chanctx_conf {
208208
* @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
209209
* @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
210210
* @BSS_CHANGED_TXPOWER: TX power setting changed for this interface
211+
* @BSS_CHANGED_P2P_PS: P2P powersave settings (CTWindow, opportunistic PS)
212+
* changed (currently only in P2P client mode, GO mode will be later)
211213
*/
212214
enum ieee80211_bss_change {
213215
BSS_CHANGED_ASSOC = 1<<0,
@@ -229,6 +231,7 @@ enum ieee80211_bss_change {
229231
BSS_CHANGED_AP_PROBE_RESP = 1<<16,
230232
BSS_CHANGED_PS = 1<<17,
231233
BSS_CHANGED_TXPOWER = 1<<18,
234+
BSS_CHANGED_P2P_PS = 1<<19,
232235

233236
/* when adding here, make sure to change ieee80211_reconfig */
234237
};
@@ -312,6 +315,8 @@ enum ieee80211_rssi_event {
312315
* @ssid_len: Length of SSID given in @ssid.
313316
* @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
314317
* @txpower: TX power in dBm
318+
* @p2p_ctwindow: P2P CTWindow, only for P2P client interfaces
319+
* @p2p_oppps: P2P opportunistic PS is enabled
315320
*/
316321
struct ieee80211_bss_conf {
317322
const u8 *bssid;
@@ -345,6 +350,8 @@ struct ieee80211_bss_conf {
345350
size_t ssid_len;
346351
bool hidden_ssid;
347352
int txpower;
353+
u8 p2p_ctwindow;
354+
bool p2p_oppps;
348355
};
349356

350357
/**

‎net/mac80211/ieee80211_i.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ struct ieee80211_if_managed {
473473

474474
u8 use_4addr;
475475

476+
u8 p2p_noa_index;
477+
476478
/* Signal strength from the last Beacon frame in the current BSS. */
477479
int last_beacon_signal;
478480

‎net/mac80211/mlme.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,22 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
13651365

13661366
sdata->u.mgd.flags |= IEEE80211_STA_RESET_SIGNAL_AVE;
13671367

1368+
if (sdata->vif.p2p) {
1369+
u8 noa[2];
1370+
int ret;
1371+
1372+
ret = cfg80211_get_p2p_attr(cbss->information_elements,
1373+
cbss->len_information_elements,
1374+
IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
1375+
noa, sizeof(noa));
1376+
if (ret >= 2) {
1377+
bss_conf->p2p_oppps = noa[1] & 0x80;
1378+
bss_conf->p2p_ctwindow = noa[1] & 0x7f;
1379+
bss_info_changed |= BSS_CHANGED_P2P_PS;
1380+
sdata->u.mgd.p2p_noa_index = noa[0];
1381+
}
1382+
}
1383+
13681384
/* just to be sure */
13691385
ieee80211_stop_poll(sdata);
13701386

@@ -1487,6 +1503,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
14871503
changed |= BSS_CHANGED_ASSOC;
14881504
sdata->vif.bss_conf.assoc = false;
14891505

1506+
sdata->vif.bss_conf.p2p_ctwindow = 0;
1507+
sdata->vif.bss_conf.p2p_oppps = false;
1508+
14901509
/* on the next assoc, re-program HT parameters */
14911510
memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa));
14921511
memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask));
@@ -2594,6 +2613,27 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
25942613
}
25952614
}
25962615

2616+
if (sdata->vif.p2p) {
2617+
u8 noa[2];
2618+
int ret;
2619+
2620+
ret = cfg80211_get_p2p_attr(mgmt->u.beacon.variable,
2621+
len - baselen,
2622+
IEEE80211_P2P_ATTR_ABSENCE_NOTICE,
2623+
noa, sizeof(noa));
2624+
if (ret >= 2 && sdata->u.mgd.p2p_noa_index != noa[0]) {
2625+
bss_conf->p2p_oppps = noa[1] & 0x80;
2626+
bss_conf->p2p_ctwindow = noa[1] & 0x7f;
2627+
changed |= BSS_CHANGED_P2P_PS;
2628+
sdata->u.mgd.p2p_noa_index = noa[0];
2629+
/*
2630+
* make sure we update all information, the CRC
2631+
* mechanism doesn't look at P2P attributes.
2632+
*/
2633+
ifmgd->beacon_crc_valid = false;
2634+
}
2635+
}
2636+
25972637
if (ncrc == ifmgd->beacon_crc && ifmgd->beacon_crc_valid)
25982638
return;
25992639
ifmgd->beacon_crc = ncrc;

‎net/mac80211/trace.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ TRACE_EVENT(drv_bss_info_changed,
343343
__dynamic_array(u8, ssid, info->ssid_len);
344344
__field(bool, hidden_ssid);
345345
__field(int, txpower)
346+
__field(u8, p2p_ctwindow)
347+
__field(bool, p2p_oppps)
346348
),
347349

348350
TP_fast_assign(
@@ -378,6 +380,8 @@ TRACE_EVENT(drv_bss_info_changed,
378380
memcpy(__get_dynamic_array(ssid), info->ssid, info->ssid_len);
379381
__entry->hidden_ssid = info->hidden_ssid;
380382
__entry->txpower = info->txpower;
383+
__entry->p2p_ctwindow = info->p2p_ctwindow;
384+
__entry->p2p_oppps = info->p2p_oppps;
381385
),
382386

383387
TP_printk(

0 commit comments

Comments
 (0)