2019-06-04 11:11:33 +03:00
// SPDX-License-Identifier: GPL-2.0-only
2008-02-23 17:17:13 +03:00
/*
2009-11-10 02:46:58 +03:00
* Copyright ( c ) 2008 , 2009 open80211s Ltd .
2024-01-29 22:19:27 +03:00
* Copyright ( C ) 2019 , 2021 - 2024 Intel Corporation
2008-02-23 17:17:13 +03:00
* Author : Luis Carlos Cobo < luisca @ cozybit . com >
*/
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
# include <linux/gfp.h>
2008-02-23 17:17:19 +03:00
# include <linux/kernel.h>
# include <linux/random.h>
2017-02-04 03:27:20 +03:00
# include <linux/rculist.h>
2008-02-23 17:17:13 +03:00
# include "ieee80211_i.h"
2008-04-08 23:14:40 +04:00
# include "rate.h"
2008-02-23 17:17:13 +03:00
# include "mesh.h"
2015-07-14 15:31:58 +03:00
# define PLINK_CNF_AID(mgmt) ((mgmt)->u.action.u.self_prot.variable + 2)
2011-08-13 07:01:00 +04:00
# define PLINK_GET_LLID(p) (p + 2)
# define PLINK_GET_PLID(p) (p + 4)
2008-02-23 17:17:13 +03:00
2015-06-17 11:31:00 +03:00
# define mod_plink_timer(s, t) (mod_timer(&s->mesh->plink_timer, \
2015-03-02 12:54:13 +03:00
jiffies + msecs_to_jiffies ( t ) ) )
2008-02-23 17:17:13 +03:00
enum plink_event {
PLINK_UNDEFINED ,
OPN_ACPT ,
OPN_RJCT ,
OPN_IGNR ,
CNF_ACPT ,
CNF_RJCT ,
CNF_IGNR ,
CLS_ACPT ,
CLS_IGNR
} ;
2013-02-16 22:41:05 +04:00
static const char * const mplstates [ ] = {
[ NL80211_PLINK_LISTEN ] = " LISTEN " ,
[ NL80211_PLINK_OPN_SNT ] = " OPN-SNT " ,
[ NL80211_PLINK_OPN_RCVD ] = " OPN-RCVD " ,
[ NL80211_PLINK_CNF_RCVD ] = " CNF_RCVD " ,
[ NL80211_PLINK_ESTAB ] = " ESTAB " ,
[ NL80211_PLINK_HOLDING ] = " HOLDING " ,
[ NL80211_PLINK_BLOCKED ] = " BLOCKED "
} ;
static const char * const mplevents [ ] = {
[ PLINK_UNDEFINED ] = " NONE " ,
[ OPN_ACPT ] = " OPN_ACPT " ,
[ OPN_RJCT ] = " OPN_RJCT " ,
[ OPN_IGNR ] = " OPN_IGNR " ,
[ CNF_ACPT ] = " CNF_ACPT " ,
[ CNF_RJCT ] = " CNF_RJCT " ,
[ CNF_IGNR ] = " CNF_IGNR " ,
[ CLS_ACPT ] = " CLS_ACPT " ,
[ CLS_IGNR ] = " CLS_IGNR "
} ;
2013-11-05 23:16:54 +04:00
/* We only need a valid sta if user configured a minimum rssi_threshold. */
static bool rssi_threshold_check ( struct ieee80211_sub_if_data * sdata ,
struct sta_info * sta )
{
s32 rssi_threshold = sdata - > u . mesh . mshcfg . rssi_threshold ;
return rssi_threshold = = 0 | |
2015-10-16 18:54:47 +03:00
( sta & &
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
( s8 ) - ewma_signal_read ( & sta - > deflink . rx_stats_avg . signal ) >
rssi_threshold ) ;
2013-11-05 23:16:54 +04:00
}
2008-02-23 17:17:13 +03:00
/**
* mesh_plink_fsm_restart - restart a mesh peer link finite state machine
*
2009-11-10 02:46:42 +03:00
* @ sta : mesh peer link to restart
2008-02-23 17:17:13 +03:00
*
2015-06-17 11:31:00 +03:00
* Locking : this function must be called holding sta - > mesh - > plink_lock
2008-02-23 17:17:13 +03:00
*/
static inline void mesh_plink_fsm_restart ( struct sta_info * sta )
{
2015-06-17 11:31:00 +03:00
lockdep_assert_held ( & sta - > mesh - > plink_lock ) ;
sta - > mesh - > plink_state = NL80211_PLINK_LISTEN ;
sta - > mesh - > llid = sta - > mesh - > plid = sta - > mesh - > reason = 0 ;
sta - > mesh - > plink_retries = 0 ;
2008-02-23 17:17:13 +03:00
}
2013-01-27 04:39:55 +04:00
/*
* mesh_set_short_slot_time - enable / disable ERP short slot time .
*
* The standard indirectly mandates mesh STAs to turn off short slot time by
* disallowing advertising this ( 802.11 - 2012 8.4 .1 .4 ) , but that doesn ' t mean we
* can ' t be sneaky about it . Enable short slot time if all mesh STAs in the
* MBSS support ERP rates .
*
* Returns BSS_CHANGED_ERP_SLOT or 0 for no change .
*/
2023-06-04 12:11:26 +03:00
static u64 mesh_set_short_slot_time ( struct ieee80211_sub_if_data * sdata )
2013-01-27 04:39:55 +04:00
{
struct ieee80211_local * local = sdata - > local ;
2017-04-27 10:15:38 +03:00
struct ieee80211_supported_band * sband ;
2013-01-27 04:39:55 +04:00
struct sta_info * sta ;
2023-06-04 12:11:26 +03:00
u32 erp_rates = 0 ;
u64 changed = 0 ;
2013-01-27 04:39:55 +04:00
int i ;
bool short_slot = false ;
2017-04-27 10:15:38 +03:00
sband = ieee80211_get_sband ( sdata ) ;
if ( ! sband )
return changed ;
if ( sband - > band = = NL80211_BAND_5GHZ ) {
2013-01-27 04:39:55 +04:00
/* (IEEE 802.11-2012 19.4.5) */
short_slot = true ;
goto out ;
2017-04-27 10:15:38 +03:00
} else if ( sband - > band ! = NL80211_BAND_2GHZ ) {
2013-01-27 04:39:55 +04:00
goto out ;
2017-04-27 10:15:38 +03:00
}
2013-01-27 04:39:55 +04:00
for ( i = 0 ; i < sband - > n_bitrates ; i + + )
if ( sband - > bitrates [ i ] . flags & IEEE80211_RATE_ERP_G )
erp_rates | = BIT ( i ) ;
if ( ! erp_rates )
goto out ;
rcu_read_lock ( ) ;
list_for_each_entry_rcu ( sta , & local - > sta_list , list ) {
if ( sdata ! = sta - > sdata | |
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state ! = NL80211_PLINK_ESTAB )
2013-01-27 04:39:55 +04:00
continue ;
short_slot = false ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
if ( erp_rates & sta - > sta . deflink . supp_rates [ sband - > band ] )
2013-01-27 04:39:55 +04:00
short_slot = true ;
else
break ;
}
rcu_read_unlock ( ) ;
out :
if ( sdata - > vif . bss_conf . use_short_slot ! = short_slot ) {
sdata - > vif . bss_conf . use_short_slot = short_slot ;
changed = BSS_CHANGED_ERP_SLOT ;
mpl_dbg ( sdata , " mesh_plink %pM: ERP short slot time %d \n " ,
sdata - > vif . addr , short_slot ) ;
}
return changed ;
}
2012-07-10 14:55:09 +04:00
/**
2012-05-08 08:00:31 +04:00
* mesh_set_ht_prot_mode - set correct HT protection mode
2020-09-28 14:51:30 +03:00
* @ sdata : the ( mesh ) interface to handle
2012-05-01 01:20:30 +04:00
*
2012-05-08 08:00:31 +04:00
* Section 9.23 .3 .5 of IEEE 80211 - 2012 describes the protection rules for HT
* mesh STA in a MBSS . Three HT protection modes are supported for now , non - HT
* mixed mode , 20 MHz - protection and no - protection mode . non - HT mixed mode is
* selected if any non - HT peers are present in our MBSS . 20 MHz - protection mode
2021-06-07 18:00:47 +03:00
* is selected if all peers in our 20 / 40 MHz MBSS support HT and at least one
2012-05-08 08:00:31 +04:00
* HT20 peer is present . Otherwise no - protection mode is selected .
2023-09-28 17:35:29 +03:00
*
* Returns : BSS_CHANGED_HT or 0 for no change
2012-05-01 01:20:30 +04:00
*/
2023-06-04 12:11:26 +03:00
static u64 mesh_set_ht_prot_mode ( struct ieee80211_sub_if_data * sdata )
2012-05-01 01:20:30 +04:00
{
struct ieee80211_local * local = sdata - > local ;
struct sta_info * sta ;
u16 ht_opmode ;
bool non_ht_sta = false , ht20_sta = false ;
wifi: mac80211: introduce 'channel request'
For channel contexts, mac80211 currently uses the cfg80211
chandef struct (control channel, center freq(s), width) to
define towards drivers and internally how these behave. In
fact, there are _two_ such structs used, where the min_def
can reduce bandwidth according to the stations connected.
Unfortunately, with EHT this is longer be sufficient, at
least not for all hardware. EHT requires that non-AP STAs
that are connected to an AP with a lower bandwidth than it
(the AP) advertises (e.g. 160 MHz STA connected to 320 MHz
AP) still be able to receive downlink OFDMA and respond to
trigger frames for uplink OFDMA that specify the position
and bandwidth for the non-AP STA relative to the channel
the AP is using. Therefore, they need to be aware of this,
and at least for some hardware (e.g. Intel) this awareness
is in the hardware. As a result, use of the "same" channel
may need to be split over two channel contexts where they
differ by the AP being used.
As a first step, introduce a concept of a channel request
('chanreq') for each interface, to control the context it
requests. This step does nothing but reorganise the code,
so that later the AP's chandef can be added to the request
in order to handle the EHT case described above.
Link: https://msgid.link/20240129194108.2e88e48bd2e9.I4256183debe975c5ed71621611206fdbb69ba330@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2024-01-29 21:34:40 +03:00
switch ( sdata - > vif . bss_conf . chanreq . oper . width ) {
2013-05-16 15:00:31 +04:00
case NL80211_CHAN_WIDTH_20_NOHT :
case NL80211_CHAN_WIDTH_5 :
case NL80211_CHAN_WIDTH_10 :
2012-05-01 01:20:30 +04:00
return 0 ;
2013-05-16 15:00:31 +04:00
default :
break ;
}
2012-05-01 01:20:30 +04:00
rcu_read_lock ( ) ;
list_for_each_entry_rcu ( sta , & local - > sta_list , list ) {
2012-05-08 08:00:31 +04:00
if ( sdata ! = sta - > sdata | |
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state ! = NL80211_PLINK_ESTAB )
2012-05-08 08:00:31 +04:00
continue ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
if ( sta - > sta . deflink . bandwidth > IEEE80211_STA_RX_BW_20 )
2013-02-16 22:41:04 +04:00
continue ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
if ( ! sta - > sta . deflink . ht_cap . ht_supported ) {
2013-02-16 22:41:04 +04:00
mpl_dbg ( sdata , " nonHT sta (%pM) is present \n " ,
sta - > sta . addr ) ;
2012-05-08 08:00:31 +04:00
non_ht_sta = true ;
break ;
2012-05-01 01:20:30 +04:00
}
2013-02-16 22:41:04 +04:00
mpl_dbg ( sdata , " HT20 sta (%pM) is present \n " , sta - > sta . addr ) ;
ht20_sta = true ;
2012-05-01 01:20:30 +04:00
}
rcu_read_unlock ( ) ;
if ( non_ht_sta )
ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED ;
2012-07-25 15:51:49 +04:00
else if ( ht20_sta & &
wifi: mac80211: introduce 'channel request'
For channel contexts, mac80211 currently uses the cfg80211
chandef struct (control channel, center freq(s), width) to
define towards drivers and internally how these behave. In
fact, there are _two_ such structs used, where the min_def
can reduce bandwidth according to the stations connected.
Unfortunately, with EHT this is longer be sufficient, at
least not for all hardware. EHT requires that non-AP STAs
that are connected to an AP with a lower bandwidth than it
(the AP) advertises (e.g. 160 MHz STA connected to 320 MHz
AP) still be able to receive downlink OFDMA and respond to
trigger frames for uplink OFDMA that specify the position
and bandwidth for the non-AP STA relative to the channel
the AP is using. Therefore, they need to be aware of this,
and at least for some hardware (e.g. Intel) this awareness
is in the hardware. As a result, use of the "same" channel
may need to be split over two channel contexts where they
differ by the AP being used.
As a first step, introduce a concept of a channel request
('chanreq') for each interface, to control the context it
requests. This step does nothing but reorganise the code,
so that later the AP's chandef can be added to the request
in order to handle the EHT case described above.
Link: https://msgid.link/20240129194108.2e88e48bd2e9.I4256183debe975c5ed71621611206fdbb69ba330@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2024-01-29 21:34:40 +03:00
sdata - > vif . bss_conf . chanreq . oper . width > NL80211_CHAN_WIDTH_20 )
2012-05-01 01:20:30 +04:00
ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ ;
else
ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONE ;
2013-02-16 22:41:04 +04:00
if ( sdata - > vif . bss_conf . ht_operation_mode = = ht_opmode )
return 0 ;
2012-05-01 01:20:30 +04:00
2013-02-16 22:41:04 +04:00
sdata - > vif . bss_conf . ht_operation_mode = ht_opmode ;
sdata - > u . mesh . mshcfg . ht_opmode = ht_opmode ;
mpl_dbg ( sdata , " selected new HT protection mode %d \n " , ht_opmode ) ;
return BSS_CHANGED_HT ;
2012-05-01 01:20:30 +04:00
}
2008-08-03 04:04:37 +04:00
static int mesh_plink_frame_tx ( struct ieee80211_sub_if_data * sdata ,
2015-07-14 15:31:58 +03:00
struct sta_info * sta ,
2013-02-15 17:40:31 +04:00
enum ieee80211_self_protected_actioncode action ,
2013-11-13 11:43:03 +04:00
u8 * da , u16 llid , u16 plid , u16 reason )
2013-02-15 17:40:31 +04:00
{
2008-08-03 04:04:37 +04:00
struct ieee80211_local * local = sdata - > local ;
2011-10-27 01:47:25 +04:00
struct sk_buff * skb ;
2012-08-03 23:21:34 +04:00
struct ieee80211_tx_info * info ;
2008-02-23 17:17:13 +03:00
struct ieee80211_mgmt * mgmt ;
bool include_plid = false ;
2011-08-13 07:01:00 +04:00
u16 peering_proto = 0 ;
2011-10-27 01:47:25 +04:00
u8 * pos , ie_len = 4 ;
2023-03-27 20:07:42 +03:00
u8 ie_len_he_cap , ie_len_eht_cap ;
2017-09-08 12:54:46 +03:00
int hdr_len = offsetofend ( struct ieee80211_mgmt , u . action . u . self_prot ) ;
2012-08-03 23:21:35 +04:00
int err = - ENOMEM ;
2011-10-27 01:47:25 +04:00
2024-01-29 22:19:27 +03:00
ie_len_he_cap = ieee80211_ie_len_he_cap ( sdata ) ;
ie_len_eht_cap = ieee80211_ie_len_eht_cap ( sdata ) ;
2012-01-18 06:17:46 +04:00
skb = dev_alloc_skb ( local - > tx_headroom +
2011-10-27 01:47:25 +04:00
hdr_len +
2 + /* capability info */
2 + /* AID */
2 + 8 + /* supported rates */
2 + ( IEEE80211_MAX_SUPP_RATES - 8 ) +
2 + sdata - > u . mesh . mesh_id_len +
2 + sizeof ( struct ieee80211_meshconf_ie ) +
2011-10-27 01:47:27 +04:00
2 + sizeof ( struct ieee80211_ht_cap ) +
2012-03-15 22:45:16 +04:00
2 + sizeof ( struct ieee80211_ht_operation ) +
2015-08-27 16:00:18 +03:00
2 + sizeof ( struct ieee80211_vht_cap ) +
2 + sizeof ( struct ieee80211_vht_operation ) +
2019-07-24 19:33:56 +03:00
ie_len_he_cap +
2 + 1 + sizeof ( struct ieee80211_he_operation ) +
2020-05-28 22:34:33 +03:00
sizeof ( struct ieee80211_he_6ghz_oper ) +
2020-05-28 22:34:32 +03:00
2 + 1 + sizeof ( struct ieee80211_he_6ghz_capa ) +
2023-03-27 20:07:42 +03:00
ie_len_eht_cap +
2 + 1 + offsetof ( struct ieee80211_eht_operation , optional ) +
offsetof ( struct ieee80211_eht_operation_info , optional ) +
2011-10-27 01:47:25 +04:00
2 + 8 + /* peering IE */
sdata - > u . mesh . ie_len ) ;
2008-02-23 17:17:13 +03:00
if ( ! skb )
2013-11-05 23:16:57 +04:00
return err ;
2012-08-03 23:21:34 +04:00
info = IEEE80211_SKB_CB ( skb ) ;
2012-01-18 06:17:46 +04:00
skb_reserve ( skb , local - > tx_headroom ) ;
networking: convert many more places to skb_put_zero()
There were many places that my previous spatch didn't find,
as pointed out by yuan linyu in various patches.
The following spatch found many more and also removes the
now unnecessary casts:
@@
identifier p, p2;
expression len;
expression skb;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_zero(skb, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_zero(skb, len);
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, len);
|
-memset(p, 0, len);
)
@@
type t, t2;
identifier p, p2;
expression skb;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, sizeof(*p));
|
-memset(p, 0, sizeof(*p));
)
@@
expression skb, len;
@@
-memset(skb_put(skb, len), 0, len);
+skb_put_zero(skb, len);
Apply it to the tree (with one manual fixup to keep the
comment in vxlan.c, which spatch removed.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 15:29:19 +03:00
mgmt = skb_put_zero ( skb , hdr_len ) ;
2008-07-16 05:44:13 +04:00
mgmt - > frame_control = cpu_to_le16 ( IEEE80211_FTYPE_MGMT |
IEEE80211_STYPE_ACTION ) ;
2008-02-23 17:17:13 +03:00
memcpy ( mgmt - > da , da , ETH_ALEN ) ;
2009-11-25 19:46:19 +03:00
memcpy ( mgmt - > sa , sdata - > vif . addr , ETH_ALEN ) ;
2011-05-04 03:57:10 +04:00
memcpy ( mgmt - > bssid , sdata - > vif . addr , ETH_ALEN ) ;
2011-08-13 07:01:00 +04:00
mgmt - > u . action . category = WLAN_CATEGORY_SELF_PROTECTED ;
mgmt - > u . action . u . self_prot . action_code = action ;
2008-02-23 17:17:13 +03:00
2011-08-13 07:01:00 +04:00
if ( action ! = WLAN_SP_MESH_PEERING_CLOSE ) {
2017-04-27 10:15:38 +03:00
struct ieee80211_supported_band * sband ;
2024-01-29 22:19:32 +03:00
u32 rate_flags , basic_rates ;
2017-04-27 10:15:38 +03:00
sband = ieee80211_get_sband ( sdata ) ;
if ( ! sband ) {
err = - EINVAL ;
goto free ;
}
2012-07-26 19:24:39 +04:00
2011-08-13 07:01:00 +04:00
/* capability info */
2017-05-24 10:07:47 +03:00
pos = skb_put_zero ( skb , 2 ) ;
2011-08-12 06:35:12 +04:00
if ( action = = WLAN_SP_MESH_PEERING_CONFIRM ) {
2011-08-13 07:01:00 +04:00
/* AID */
pos = skb_put ( skb , 2 ) ;
2015-07-14 15:31:58 +03:00
put_unaligned_le16 ( sta - > sta . aid , pos ) ;
2008-02-23 17:17:13 +03:00
}
2024-01-29 22:19:32 +03:00
rate_flags =
ieee80211_chandef_rate_flags ( & sdata - > vif . bss_conf . chanreq . oper ) ;
basic_rates = sdata - > vif . bss_conf . basic_rates ;
if ( ieee80211_put_srates_elem ( skb , sband , basic_rates ,
rate_flags , 0 ,
WLAN_EID_SUPP_RATES ) | |
ieee80211_put_srates_elem ( skb , sband , basic_rates ,
rate_flags , 0 ,
WLAN_EID_EXT_SUPP_RATES ) | |
2013-02-15 17:40:31 +04:00
mesh_add_rsn_ie ( sdata , skb ) | |
mesh_add_meshid_ie ( sdata , skb ) | |
mesh_add_meshconf_ie ( sdata , skb ) )
2012-08-03 23:21:35 +04:00
goto free ;
2011-08-13 07:01:00 +04:00
} else { /* WLAN_SP_MESH_PEERING_CLOSE */
2012-08-03 23:21:34 +04:00
info - > flags | = IEEE80211_TX_CTL_NO_ACK ;
2013-02-15 17:40:31 +04:00
if ( mesh_add_meshid_ie ( sdata , skb ) )
2012-08-03 23:21:35 +04:00
goto free ;
2008-02-23 17:17:13 +03:00
}
2011-08-13 07:01:00 +04:00
/* Add Mesh Peering Management element */
2008-02-23 17:17:13 +03:00
switch ( action ) {
2011-08-12 06:35:12 +04:00
case WLAN_SP_MESH_PEERING_OPEN :
2008-02-23 17:17:13 +03:00
break ;
2011-08-12 06:35:12 +04:00
case WLAN_SP_MESH_PEERING_CONFIRM :
2011-08-13 07:01:00 +04:00
ie_len + = 2 ;
2008-02-23 17:17:13 +03:00
include_plid = true ;
break ;
2011-08-12 06:35:12 +04:00
case WLAN_SP_MESH_PEERING_CLOSE :
2011-08-13 07:01:00 +04:00
if ( plid ) {
ie_len + = 2 ;
2008-02-23 17:17:13 +03:00
include_plid = true ;
}
2011-08-13 07:01:00 +04:00
ie_len + = 2 ; /* reason code */
2008-02-23 17:17:13 +03:00
break ;
2011-08-13 07:01:00 +04:00
default :
2012-08-03 23:21:35 +04:00
err = - EINVAL ;
goto free ;
2008-02-23 17:17:13 +03:00
}
2011-08-13 07:01:00 +04:00
if ( WARN_ON ( skb_tailroom ( skb ) < 2 + ie_len ) )
2012-08-03 23:21:35 +04:00
goto free ;
2011-08-13 07:01:00 +04:00
2008-02-23 17:17:13 +03:00
pos = skb_put ( skb , 2 + ie_len ) ;
2011-08-13 07:01:00 +04:00
* pos + + = WLAN_EID_PEER_MGMT ;
2008-02-23 17:17:13 +03:00
* pos + + = ie_len ;
2011-08-13 07:01:00 +04:00
memcpy ( pos , & peering_proto , 2 ) ;
pos + = 2 ;
2013-11-13 11:43:03 +04:00
put_unaligned_le16 ( llid , pos ) ;
2011-08-13 07:01:00 +04:00
pos + = 2 ;
2008-02-23 17:17:13 +03:00
if ( include_plid ) {
2013-11-13 11:43:03 +04:00
put_unaligned_le16 ( plid , pos ) ;
2011-08-13 07:01:00 +04:00
pos + = 2 ;
2008-02-23 17:17:13 +03:00
}
2011-08-12 06:35:12 +04:00
if ( action = = WLAN_SP_MESH_PEERING_CLOSE ) {
2013-11-13 11:43:03 +04:00
put_unaligned_le16 ( reason , pos ) ;
2011-08-13 07:01:00 +04:00
pos + = 2 ;
2008-02-23 17:17:13 +03:00
}
2011-10-27 01:47:27 +04:00
if ( action ! = WLAN_SP_MESH_PEERING_CLOSE ) {
2013-02-15 17:40:31 +04:00
if ( mesh_add_ht_cap_ie ( sdata , skb ) | |
2015-08-27 16:00:18 +03:00
mesh_add_ht_oper_ie ( sdata , skb ) | |
mesh_add_vht_cap_ie ( sdata , skb ) | |
2019-07-24 19:33:56 +03:00
mesh_add_vht_oper_ie ( sdata , skb ) | |
mesh_add_he_cap_ie ( sdata , skb , ie_len_he_cap ) | |
2020-05-28 22:34:32 +03:00
mesh_add_he_oper_ie ( sdata , skb ) | |
2023-03-27 20:07:42 +03:00
mesh_add_he_6ghz_cap_ie ( sdata , skb ) | |
mesh_add_eht_cap_ie ( sdata , skb , ie_len_eht_cap ) | |
mesh_add_eht_oper_ie ( sdata , skb ) )
2012-08-03 23:21:35 +04:00
goto free ;
2011-10-27 01:47:27 +04:00
}
2013-02-15 17:40:31 +04:00
if ( mesh_add_vendor_ies ( sdata , skb ) )
2012-08-03 23:21:35 +04:00
goto free ;
2008-02-23 17:17:13 +03:00
2009-11-18 20:42:05 +03:00
ieee80211_tx_skb ( sdata , skb ) ;
2008-02-23 17:17:13 +03:00
return 0 ;
2012-08-03 23:21:35 +04:00
free :
kfree_skb ( skb ) ;
return err ;
2008-02-23 17:17:13 +03:00
}
2015-07-14 15:31:57 +03:00
/**
* __mesh_plink_deactivate - deactivate mesh peer link
*
* @ sta : mesh peer link to deactivate
*
2016-03-26 18:27:19 +03:00
* Mesh paths with this peer as next hop should be flushed
* by the caller outside of plink_lock .
*
2023-09-28 17:35:29 +03:00
* Returns : beacon changed flag if the beacon content changed .
2015-07-14 15:31:57 +03:00
*
* Locking : the caller must hold sta - > mesh - > plink_lock
*/
2023-06-04 12:11:26 +03:00
static u64 __mesh_plink_deactivate ( struct sta_info * sta )
2015-07-14 15:31:57 +03:00
{
struct ieee80211_sub_if_data * sdata = sta - > sdata ;
2023-06-04 12:11:26 +03:00
u64 changed = 0 ;
2015-07-14 15:31:57 +03:00
lockdep_assert_held ( & sta - > mesh - > plink_lock ) ;
if ( sta - > mesh - > plink_state = = NL80211_PLINK_ESTAB )
changed = mesh_plink_dec_estab_count ( sdata ) ;
sta - > mesh - > plink_state = NL80211_PLINK_BLOCKED ;
ieee80211_mps_sta_status_update ( sta ) ;
changed | = ieee80211_mps_set_sta_local_pm ( sta ,
NL80211_MESH_POWER_UNKNOWN ) ;
return changed ;
}
/**
* mesh_plink_deactivate - deactivate mesh peer link
*
* @ sta : mesh peer link to deactivate
*
* All mesh paths with this peer as next hop will be flushed
2023-09-28 17:35:29 +03:00
*
* Returns : beacon changed flag if the beacon content changed .
2015-07-14 15:31:57 +03:00
*/
2023-06-04 12:11:26 +03:00
u64 mesh_plink_deactivate ( struct sta_info * sta )
2015-07-14 15:31:57 +03:00
{
struct ieee80211_sub_if_data * sdata = sta - > sdata ;
2023-06-04 12:11:26 +03:00
u64 changed ;
2015-07-14 15:31:57 +03:00
spin_lock_bh ( & sta - > mesh - > plink_lock ) ;
changed = __mesh_plink_deactivate ( sta ) ;
2016-06-26 02:14:16 +03:00
if ( ! sdata - > u . mesh . user_mpm ) {
sta - > mesh - > reason = WLAN_REASON_MESH_PEER_CANCELED ;
mesh_plink_frame_tx ( sdata , sta , WLAN_SP_MESH_PEERING_CLOSE ,
sta - > sta . addr , sta - > mesh - > llid ,
sta - > mesh - > plid , sta - > mesh - > reason ) ;
}
2015-07-14 15:31:57 +03:00
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2016-06-26 02:14:16 +03:00
if ( ! sdata - > u . mesh . user_mpm )
del_timer_sync ( & sta - > mesh - > plink_timer ) ;
2016-03-26 18:27:19 +03:00
mesh_path_flush_by_nexthop ( sta ) ;
2015-07-14 15:31:57 +03:00
2016-06-26 02:14:16 +03:00
/* make sure no readers can access nexthop sta from here on */
synchronize_net ( ) ;
2015-07-14 15:31:57 +03:00
return changed ;
}
2013-01-24 00:18:12 +04:00
static void mesh_sta_info_init ( struct ieee80211_sub_if_data * sdata ,
struct sta_info * sta ,
2018-05-17 16:09:28 +03:00
struct ieee802_11_elems * elems )
2008-02-23 17:17:13 +03:00
{
2008-08-03 04:04:37 +04:00
struct ieee80211_local * local = sdata - > local ;
2012-04-19 06:23:42 +04:00
struct ieee80211_supported_band * sband ;
2013-01-24 00:18:13 +04:00
u32 rates , basic_rates = 0 , changed = 0 ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
enum ieee80211_sta_rx_bandwidth bw = sta - > sta . deflink . bandwidth ;
2008-02-23 17:17:13 +03:00
2017-04-27 10:15:38 +03:00
sband = ieee80211_get_sband ( sdata ) ;
if ( ! sband )
return ;
rates = ieee80211_sta_get_rates ( sdata , elems , sband - > band ,
& basic_rates ) ;
2008-02-25 18:27:46 +03:00
2015-06-17 11:31:00 +03:00
spin_lock_bh ( & sta - > mesh - > plink_lock ) ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
sta - > deflink . rx_stats . last_rx = jiffies ;
2013-01-24 00:18:12 +04:00
/* rates and capabilities don't change during peering */
2015-06-17 11:31:00 +03:00
if ( sta - > mesh - > plink_state = = NL80211_PLINK_ESTAB & &
sta - > mesh - > processed_beacon )
2013-01-24 00:18:12 +04:00
goto out ;
2015-06-17 11:31:00 +03:00
sta - > mesh - > processed_beacon = true ;
2012-07-24 07:52:35 +04:00
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
if ( sta - > sta . deflink . supp_rates [ sband - > band ] ! = rates )
2013-01-24 00:18:13 +04:00
changed | = IEEE80211_RC_SUPP_RATES_CHANGED ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
sta - > sta . deflink . supp_rates [ sband - > band ] = rates ;
2012-04-19 06:23:42 +04:00
2013-02-16 22:41:04 +04:00
if ( ieee80211_ht_cap_ie_to_sta_ht_cap ( sdata , sband ,
2022-06-15 10:20:45 +03:00
elems - > ht_cap_elem ,
& sta - > deflink ) )
2013-02-16 22:41:04 +04:00
changed | = IEEE80211_RC_BW_CHANGED ;
2012-11-09 14:39:59 +04:00
2015-08-27 16:00:18 +03:00
ieee80211_vht_cap_ie_to_sta_vht_cap ( sdata , sband ,
2023-09-18 14:10:55 +03:00
elems - > vht_cap_elem , NULL ,
2022-06-15 10:20:45 +03:00
& sta - > deflink ) ;
2015-08-27 16:00:18 +03:00
2019-07-24 19:33:56 +03:00
ieee80211_he_cap_ie_to_sta_he_cap ( sdata , sband , elems - > he_cap ,
2020-05-28 22:34:38 +03:00
elems - > he_cap_len ,
elems - > he_6ghz_capa ,
2022-06-15 10:20:45 +03:00
& sta - > deflink ) ;
2019-07-24 19:33:56 +03:00
2023-03-27 20:07:42 +03:00
ieee80211_eht_cap_ie_to_sta_eht_cap ( sdata , sband , elems - > he_cap ,
elems - > he_cap_len ,
elems - > eht_cap , elems - > eht_cap_len ,
& sta - > deflink ) ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
if ( bw ! = sta - > sta . deflink . bandwidth )
2015-03-20 08:37:01 +03:00
changed | = IEEE80211_RC_BW_CHANGED ;
2013-02-16 22:41:04 +04:00
/* HT peer is operating 20MHz-only */
if ( elems - > ht_operation & &
! ( elems - > ht_operation - > ht_param &
IEEE80211_HT_PARAM_CHAN_WIDTH_ANY ) ) {
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
if ( sta - > sta . deflink . bandwidth ! = IEEE80211_STA_RX_BW_20 )
2013-01-24 00:18:13 +04:00
changed | = IEEE80211_RC_BW_CHANGED ;
mac80211: prepare sta handling for MLO support
Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.
With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.
To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.
For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.
For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.
Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.
Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.
@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@
(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)
@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@
(
si->
- var
+ deflink.var
)
Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-04-04 18:41:23 +03:00
sta - > sta . deflink . bandwidth = IEEE80211_STA_RX_BW_20 ;
2012-05-01 01:20:30 +04:00
}
2012-04-27 02:01:07 +04:00
2018-05-17 16:09:28 +03:00
if ( ! test_sta_flag ( sta , WLAN_STA_RATE_CONTROL ) )
2012-11-27 21:03:13 +04:00
rate_control_rate_init ( sta ) ;
2013-01-24 00:18:13 +04:00
else
2022-05-30 19:35:23 +03:00
rate_control_rate_update ( local , sband , sta , 0 , changed ) ;
2013-01-24 00:18:12 +04:00
out :
2015-06-17 11:31:00 +03:00
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2013-01-24 00:18:12 +04:00
}
2015-07-14 15:31:59 +03:00
static int mesh_allocate_aid ( struct ieee80211_sub_if_data * sdata )
{
struct sta_info * sta ;
unsigned long * aid_map ;
int aid ;
2022-07-04 22:16:09 +03:00
aid_map = bitmap_zalloc ( IEEE80211_MAX_AID + 1 , GFP_KERNEL ) ;
2015-07-14 15:31:59 +03:00
if ( ! aid_map )
return - ENOMEM ;
/* reserve aid 0 for mcast indication */
__set_bit ( 0 , aid_map ) ;
rcu_read_lock ( ) ;
list_for_each_entry_rcu ( sta , & sdata - > local - > sta_list , list )
__set_bit ( sta - > sta . aid , aid_map ) ;
rcu_read_unlock ( ) ;
aid = find_first_zero_bit ( aid_map , IEEE80211_MAX_AID + 1 ) ;
2022-07-04 22:16:09 +03:00
bitmap_free ( aid_map ) ;
2015-07-14 15:31:59 +03:00
if ( aid > IEEE80211_MAX_AID )
return - ENOBUFS ;
return aid ;
}
2013-01-24 00:18:12 +04:00
static struct sta_info *
__mesh_sta_info_alloc ( struct ieee80211_sub_if_data * sdata , u8 * hw_addr )
{
struct sta_info * sta ;
2015-07-14 15:31:59 +03:00
int aid ;
2012-04-19 06:23:42 +04:00
2013-01-24 00:18:12 +04:00
if ( sdata - > local - > num_sta > = MESH_MAX_PLINKS )
2012-04-27 02:01:06 +04:00
return NULL ;
2015-07-14 15:31:59 +03:00
aid = mesh_allocate_aid ( sdata ) ;
if ( aid < 0 )
return NULL ;
2022-07-15 00:40:47 +03:00
sta = sta_info_alloc ( sdata , hw_addr , GFP_KERNEL ) ;
2013-01-24 00:18:12 +04:00
if ( ! sta )
return NULL ;
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = NL80211_PLINK_LISTEN ;
2014-07-22 16:50:47 +04:00
sta - > sta . wme = true ;
2015-07-14 15:31:59 +03:00
sta - > sta . aid = aid ;
2013-01-24 00:18:12 +04:00
sta_info_pre_move_state ( sta , IEEE80211_STA_AUTH ) ;
sta_info_pre_move_state ( sta , IEEE80211_STA_ASSOC ) ;
sta_info_pre_move_state ( sta , IEEE80211_STA_AUTHORIZED ) ;
return sta ;
}
static struct sta_info *
mesh_sta_info_alloc ( struct ieee80211_sub_if_data * sdata , u8 * addr ,
2018-10-26 17:03:50 +03:00
struct ieee802_11_elems * elems ,
struct ieee80211_rx_status * rx_status )
2013-01-24 00:18:12 +04:00
{
struct sta_info * sta = NULL ;
2013-03-05 01:06:12 +04:00
/* Userspace handles station allocation */
if ( sdata - > u . mesh . user_mpm | |
2016-11-30 03:06:04 +03:00
sdata - > u . mesh . security & IEEE80211_MESH_SEC_AUTHED ) {
if ( mesh_peer_accepts_plinks ( elems ) & &
2018-10-26 17:03:50 +03:00
mesh_plink_availables ( sdata ) ) {
int sig = 0 ;
if ( ieee80211_hw_check ( & sdata - > local - > hw , SIGNAL_DBM ) )
sig = rx_status - > signal ;
2016-11-30 03:06:04 +03:00
cfg80211_notify_new_peer_candidate ( sdata - > dev , addr ,
elems - > ie_start ,
elems - > total_len ,
2018-10-26 17:03:50 +03:00
sig , GFP_KERNEL ) ;
}
2016-11-30 03:06:04 +03:00
} else
2013-01-24 00:18:12 +04:00
sta = __mesh_sta_info_alloc ( sdata , addr ) ;
2012-04-19 06:23:42 +04:00
return sta ;
}
2013-01-24 00:18:12 +04:00
/*
* mesh_sta_info_get - return mesh sta info entry for @ addr .
*
* @ sdata : local meshif
* @ addr : peer ' s address
* @ elems : IEs from beacon or mesh peering frame .
2018-10-26 17:03:50 +03:00
* @ rx_status : rx status for the frame for signal reporting
2013-01-24 00:18:12 +04:00
*
* Return existing or newly allocated sta_info under RCU read lock .
* ( re ) initialize with given IEs .
*/
static struct sta_info *
mesh_sta_info_get ( struct ieee80211_sub_if_data * sdata ,
2018-10-26 17:03:50 +03:00
u8 * addr , struct ieee802_11_elems * elems ,
struct ieee80211_rx_status * rx_status ) __acquires ( RCU )
2013-01-24 00:18:12 +04:00
{
struct sta_info * sta = NULL ;
rcu_read_lock ( ) ;
sta = sta_info_get ( sdata , addr ) ;
if ( sta ) {
2018-05-17 16:09:28 +03:00
mesh_sta_info_init ( sdata , sta , elems ) ;
2013-01-24 00:18:12 +04:00
} else {
rcu_read_unlock ( ) ;
/* can't run atomic */
2018-10-26 17:03:50 +03:00
sta = mesh_sta_info_alloc ( sdata , addr , elems , rx_status ) ;
2013-01-24 00:18:12 +04:00
if ( ! sta ) {
rcu_read_lock ( ) ;
return NULL ;
}
2018-05-17 16:09:28 +03:00
mesh_sta_info_init ( sdata , sta , elems ) ;
2013-01-27 05:00:02 +04:00
2013-01-24 00:18:12 +04:00
if ( sta_info_insert_rcu ( sta ) )
return NULL ;
}
return sta ;
}
/*
* mesh_neighbour_update - update or initialize new mesh neighbor .
*
* @ sdata : local meshif
* @ addr : peer ' s address
* @ elems : IEs from beacon or mesh peering frame
2018-10-26 17:03:50 +03:00
* @ rx_status : rx status for the frame for signal reporting
2013-01-24 00:18:12 +04:00
*
* Initiates peering if appropriate .
*/
2012-04-19 06:23:43 +04:00
void mesh_neighbour_update ( struct ieee80211_sub_if_data * sdata ,
u8 * hw_addr ,
2018-10-26 17:03:50 +03:00
struct ieee802_11_elems * elems ,
struct ieee80211_rx_status * rx_status )
2012-04-19 06:23:42 +04:00
{
struct sta_info * sta ;
2023-06-04 12:11:26 +03:00
u64 changed = 0 ;
2012-04-19 06:23:42 +04:00
2018-10-26 17:03:50 +03:00
sta = mesh_sta_info_get ( sdata , hw_addr , elems , rx_status ) ;
2012-04-19 06:23:42 +04:00
if ( ! sta )
goto out ;
2018-10-25 22:48:53 +03:00
sta - > mesh - > connected_to_gate = elems - > mesh_config - > meshconf_form &
IEEE80211_MESHCONF_FORM_CONNECTED_TO_GATE ;
2011-04-08 02:08:35 +04:00
if ( mesh_peer_accepts_plinks ( elems ) & &
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = = NL80211_PLINK_LISTEN & &
2012-04-19 06:23:42 +04:00
sdata - > u . mesh . accepting_plinks & &
sdata - > u . mesh . mshcfg . auto_open_plinks & &
2013-11-05 23:16:54 +04:00
rssi_threshold_check ( sdata , sta ) )
2013-02-14 00:14:19 +04:00
changed = mesh_plink_open ( sta ) ;
2008-02-23 17:17:13 +03:00
2013-01-30 21:14:08 +04:00
ieee80211_mps_frame_release ( sta , elems ) ;
2012-04-19 06:23:42 +04:00
out :
2008-02-25 18:27:46 +03:00
rcu_read_unlock ( ) ;
2013-02-14 23:20:13 +04:00
ieee80211_mbss_info_change_notify ( sdata , changed ) ;
2008-02-23 17:17:13 +03:00
}
2017-10-05 20:39:10 +03:00
void mesh_plink_timer ( struct timer_list * t )
2008-02-23 17:17:13 +03:00
{
2017-10-05 20:39:10 +03:00
struct mesh_sta * mesh = from_timer ( mesh , t , plink_timer ) ;
2008-02-23 17:17:13 +03:00
struct sta_info * sta ;
2013-11-13 11:43:03 +04:00
u16 reason = 0 ;
2008-02-23 17:17:13 +03:00
struct ieee80211_sub_if_data * sdata ;
2012-11-22 06:40:32 +04:00
struct mesh_config * mshcfg ;
2013-11-05 23:16:50 +04:00
enum ieee80211_self_protected_actioncode action = 0 ;
2008-02-23 17:17:13 +03:00
2008-02-25 18:27:46 +03:00
/*
* This STA is valid because sta_info_destroy ( ) will
* del_timer_sync ( ) this timer after having made sure
* it cannot be readded ( by deleting the plink . )
*/
2017-10-05 20:39:10 +03:00
sta = mesh - > plink_sta ;
2008-02-23 17:17:13 +03:00
2013-02-28 13:55:29 +04:00
if ( sta - > sdata - > local - > quiescing )
2009-05-17 13:40:42 +04:00
return ;
2015-06-17 11:31:00 +03:00
spin_lock_bh ( & sta - > mesh - > plink_lock ) ;
2014-06-04 17:27:31 +04:00
/* If a timer fires just before a state transition on another CPU,
* we may have already extended the timeout and changed state by the
* time we ' ve acquired the lock and arrived here . In that case ,
* skip this timer and wait for the new one .
*/
2015-06-17 11:31:00 +03:00
if ( time_before ( jiffies , sta - > mesh - > plink_timer . expires ) ) {
2014-06-04 17:27:31 +04:00
mpl_dbg ( sta - > sdata ,
" Ignoring timer for %pM in state %s (timer adjusted) " ,
2015-06-17 11:31:00 +03:00
sta - > sta . addr , mplstates [ sta - > mesh - > plink_state ] ) ;
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2008-02-23 17:17:13 +03:00
return ;
}
2014-06-04 17:27:31 +04:00
/* del_timer() and handler may race when entering these states */
2015-06-17 11:31:00 +03:00
if ( sta - > mesh - > plink_state = = NL80211_PLINK_LISTEN | |
sta - > mesh - > plink_state = = NL80211_PLINK_ESTAB ) {
2014-06-04 17:27:31 +04:00
mpl_dbg ( sta - > sdata ,
" Ignoring timer for %pM in state %s (timer deleted) " ,
2015-06-17 11:31:00 +03:00
sta - > sta . addr , mplstates [ sta - > mesh - > plink_state ] ) ;
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2014-06-04 17:27:31 +04:00
return ;
}
2012-06-22 13:29:50 +04:00
mpl_dbg ( sta - > sdata ,
2013-04-08 22:06:16 +04:00
" Mesh plink timer for %pM fired on state %s \n " ,
2015-06-17 11:31:00 +03:00
sta - > sta . addr , mplstates [ sta - > mesh - > plink_state ] ) ;
2008-02-25 18:27:46 +03:00
sdata = sta - > sdata ;
2012-11-22 06:40:32 +04:00
mshcfg = & sdata - > u . mesh . mshcfg ;
2008-02-23 17:17:13 +03:00
2015-06-17 11:31:00 +03:00
switch ( sta - > mesh - > plink_state ) {
2011-05-13 21:45:43 +04:00
case NL80211_PLINK_OPN_RCVD :
case NL80211_PLINK_OPN_SNT :
2008-02-23 17:17:13 +03:00
/* retry timer */
2015-06-17 11:31:00 +03:00
if ( sta - > mesh - > plink_retries < mshcfg - > dot11MeshMaxRetries ) {
2008-02-23 17:17:13 +03:00
u32 rand ;
2012-06-22 13:29:50 +04:00
mpl_dbg ( sta - > sdata ,
" Mesh plink for %pM (retry, timeout): %d %d \n " ,
2015-06-17 11:31:00 +03:00
sta - > sta . addr , sta - > mesh - > plink_retries ,
sta - > mesh - > plink_timeout ) ;
2008-02-23 17:17:13 +03:00
get_random_bytes ( & rand , sizeof ( u32 ) ) ;
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_timeout = sta - > mesh - > plink_timeout +
rand % sta - > mesh - > plink_timeout ;
+ + sta - > mesh - > plink_retries ;
mod_plink_timer ( sta , sta - > mesh - > plink_timeout ) ;
2013-11-05 23:16:50 +04:00
action = WLAN_SP_MESH_PEERING_OPEN ;
2008-02-23 17:17:13 +03:00
break ;
}
2013-11-13 11:43:03 +04:00
reason = WLAN_REASON_MESH_MAX_RETRIES ;
2020-07-07 23:45:48 +03:00
fallthrough ;
2011-05-13 21:45:43 +04:00
case NL80211_PLINK_CNF_RCVD :
2008-02-23 17:17:13 +03:00
/* confirm timer */
if ( ! reason )
2013-11-13 11:43:03 +04:00
reason = WLAN_REASON_MESH_CONFIRM_TIMEOUT ;
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = NL80211_PLINK_HOLDING ;
2012-11-22 06:40:32 +04:00
mod_plink_timer ( sta , mshcfg - > dot11MeshHoldingTimeout ) ;
2013-11-05 23:16:50 +04:00
action = WLAN_SP_MESH_PEERING_CLOSE ;
2008-02-23 17:17:13 +03:00
break ;
2011-05-13 21:45:43 +04:00
case NL80211_PLINK_HOLDING :
2008-02-23 17:17:13 +03:00
/* holding timer */
2015-06-17 11:31:00 +03:00
del_timer ( & sta - > mesh - > plink_timer ) ;
2008-02-23 17:17:13 +03:00
mesh_plink_fsm_restart ( sta ) ;
break ;
default :
break ;
}
2015-06-17 11:31:00 +03:00
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2013-11-05 23:16:50 +04:00
if ( action )
2015-07-14 15:31:58 +03:00
mesh_plink_frame_tx ( sdata , sta , action , sta - > sta . addr ,
2015-06-17 11:31:00 +03:00
sta - > mesh - > llid , sta - > mesh - > plid , reason ) ;
2008-02-23 17:17:13 +03:00
}
2015-03-02 12:54:14 +03:00
static inline void mesh_plink_timer_set ( struct sta_info * sta , u32 timeout )
2008-02-23 17:17:13 +03:00
{
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_timeout = timeout ;
2017-10-05 20:39:10 +03:00
mod_timer ( & sta - > mesh - > plink_timer , jiffies + msecs_to_jiffies ( timeout ) ) ;
2008-02-23 17:17:13 +03:00
}
2013-11-05 23:17:05 +04:00
static bool llid_in_use ( struct ieee80211_sub_if_data * sdata ,
2013-11-13 11:43:03 +04:00
u16 llid )
2013-11-05 23:17:05 +04:00
{
struct ieee80211_local * local = sdata - > local ;
bool in_use = false ;
struct sta_info * sta ;
rcu_read_lock ( ) ;
list_for_each_entry_rcu ( sta , & local - > sta_list , list ) {
2015-10-24 22:25:51 +03:00
if ( sdata ! = sta - > sdata )
continue ;
2015-06-17 11:31:00 +03:00
if ( ! memcmp ( & sta - > mesh - > llid , & llid , sizeof ( llid ) ) ) {
2013-11-05 23:17:05 +04:00
in_use = true ;
break ;
}
}
rcu_read_unlock ( ) ;
return in_use ;
}
2013-11-13 11:43:03 +04:00
static u16 mesh_get_new_llid ( struct ieee80211_sub_if_data * sdata )
2013-11-05 23:17:05 +04:00
{
u16 llid ;
do {
get_random_bytes ( & llid , sizeof ( llid ) ) ;
2013-11-13 11:43:03 +04:00
} while ( llid_in_use ( sdata , llid ) ) ;
2013-11-05 23:17:05 +04:00
2013-11-13 11:43:03 +04:00
return llid ;
2013-11-05 23:17:05 +04:00
}
2023-06-04 12:11:26 +03:00
u64 mesh_plink_open ( struct sta_info * sta )
2008-02-23 17:17:13 +03:00
{
2008-02-25 18:27:46 +03:00
struct ieee80211_sub_if_data * sdata = sta - > sdata ;
2023-06-04 12:11:26 +03:00
u64 changed ;
2008-02-23 17:17:13 +03:00
2011-09-29 18:04:36 +04:00
if ( ! test_sta_flag ( sta , WLAN_STA_AUTH ) )
2013-02-14 00:14:19 +04:00
return 0 ;
2011-04-08 02:08:32 +04:00
2015-06-17 11:31:00 +03:00
spin_lock_bh ( & sta - > mesh - > plink_lock ) ;
sta - > mesh - > llid = mesh_get_new_llid ( sdata ) ;
if ( sta - > mesh - > plink_state ! = NL80211_PLINK_LISTEN & &
sta - > mesh - > plink_state ! = NL80211_PLINK_BLOCKED ) {
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2013-02-14 00:14:19 +04:00
return 0 ;
2008-02-23 17:17:13 +03:00
}
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = NL80211_PLINK_OPN_SNT ;
2012-11-22 06:40:32 +04:00
mesh_plink_timer_set ( sta , sdata - > u . mesh . mshcfg . dot11MeshRetryTimeout ) ;
2015-06-17 11:31:00 +03:00
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2012-06-22 13:29:50 +04:00
mpl_dbg ( sdata ,
" Mesh plink: starting establishment with %pM \n " ,
2008-10-28 01:56:10 +03:00
sta - > sta . addr ) ;
2008-02-23 17:17:13 +03:00
2013-01-30 21:14:08 +04:00
/* set the non-peer mode to active during peering */
2013-02-14 00:14:19 +04:00
changed = ieee80211_mps_local_status_update ( sdata ) ;
2013-01-30 21:14:08 +04:00
2015-07-14 15:31:58 +03:00
mesh_plink_frame_tx ( sdata , sta , WLAN_SP_MESH_PEERING_OPEN ,
2015-06-17 11:31:00 +03:00
sta - > sta . addr , sta - > mesh - > llid , 0 , 0 ) ;
2013-02-14 00:14:19 +04:00
return changed ;
2008-02-23 17:17:13 +03:00
}
2023-06-04 12:11:26 +03:00
u64 mesh_plink_block ( struct sta_info * sta )
2008-02-23 17:17:13 +03:00
{
2023-06-04 12:11:26 +03:00
u64 changed ;
2010-06-22 01:14:07 +04:00
2015-06-17 11:31:00 +03:00
spin_lock_bh ( & sta - > mesh - > plink_lock ) ;
2012-08-08 09:58:43 +04:00
changed = __mesh_plink_deactivate ( sta ) ;
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = NL80211_PLINK_BLOCKED ;
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2016-03-26 18:27:19 +03:00
mesh_path_flush_by_nexthop ( sta ) ;
2010-06-22 01:14:07 +04:00
2013-02-14 00:14:19 +04:00
return changed ;
2008-02-23 17:17:13 +03:00
}
2013-11-05 23:16:52 +04:00
static void mesh_plink_close ( struct ieee80211_sub_if_data * sdata ,
struct sta_info * sta ,
enum plink_event event )
{
struct mesh_config * mshcfg = & sdata - > u . mesh . mshcfg ;
2013-11-13 11:43:03 +04:00
u16 reason = ( event = = CLS_ACPT ) ?
WLAN_REASON_MESH_CLOSE : WLAN_REASON_MESH_CONFIG ;
2013-11-05 23:16:52 +04:00
2015-06-17 11:31:00 +03:00
sta - > mesh - > reason = reason ;
sta - > mesh - > plink_state = NL80211_PLINK_HOLDING ;
2013-11-05 23:16:56 +04:00
mod_plink_timer ( sta , mshcfg - > dot11MeshHoldingTimeout ) ;
2013-11-05 23:16:52 +04:00
}
2023-06-04 12:11:26 +03:00
static u64 mesh_plink_establish ( struct ieee80211_sub_if_data * sdata ,
2013-11-05 23:16:52 +04:00
struct sta_info * sta )
{
struct mesh_config * mshcfg = & sdata - > u . mesh . mshcfg ;
2023-06-04 12:11:26 +03:00
u64 changed = 0 ;
2013-11-05 23:16:52 +04:00
2015-06-17 11:31:00 +03:00
del_timer ( & sta - > mesh - > plink_timer ) ;
sta - > mesh - > plink_state = NL80211_PLINK_ESTAB ;
2013-11-05 23:16:52 +04:00
changed | = mesh_plink_inc_estab_count ( sdata ) ;
changed | = mesh_set_ht_prot_mode ( sdata ) ;
changed | = mesh_set_short_slot_time ( sdata ) ;
mpl_dbg ( sdata , " Mesh plink with %pM ESTABLISHED \n " , sta - > sta . addr ) ;
ieee80211_mps_sta_status_update ( sta ) ;
changed | = ieee80211_mps_set_sta_local_pm ( sta , mshcfg - > power_mode ) ;
return changed ;
}
2013-11-05 23:17:02 +04:00
/**
* mesh_plink_fsm - step @ sta MPM based on @ event
*
* @ sdata : interface
* @ sta : mesh neighbor
* @ event : peering event
*
* Return : changed MBSS flags
*/
2023-06-04 12:11:26 +03:00
static u64 mesh_plink_fsm ( struct ieee80211_sub_if_data * sdata ,
2013-11-05 23:17:02 +04:00
struct sta_info * sta , enum plink_event event )
{
struct mesh_config * mshcfg = & sdata - > u . mesh . mshcfg ;
enum ieee80211_self_protected_actioncode action = 0 ;
2023-06-04 12:11:26 +03:00
u64 changed = 0 ;
2016-03-26 18:27:19 +03:00
bool flush = false ;
2013-11-05 23:17:02 +04:00
mpl_dbg ( sdata , " peer %pM in state %s got event %s \n " , sta - > sta . addr ,
2015-06-17 11:31:00 +03:00
mplstates [ sta - > mesh - > plink_state ] , mplevents [ event ] ) ;
2013-11-05 23:17:02 +04:00
2015-06-17 11:31:00 +03:00
spin_lock_bh ( & sta - > mesh - > plink_lock ) ;
switch ( sta - > mesh - > plink_state ) {
2013-11-05 23:17:02 +04:00
case NL80211_PLINK_LISTEN :
switch ( event ) {
case CLS_ACPT :
mesh_plink_fsm_restart ( sta ) ;
break ;
case OPN_ACPT :
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = NL80211_PLINK_OPN_RCVD ;
sta - > mesh - > llid = mesh_get_new_llid ( sdata ) ;
2013-11-05 23:17:02 +04:00
mesh_plink_timer_set ( sta ,
mshcfg - > dot11MeshRetryTimeout ) ;
/* set the non-peer mode to active during peering */
changed | = ieee80211_mps_local_status_update ( sdata ) ;
action = WLAN_SP_MESH_PEERING_OPEN ;
break ;
default :
break ;
}
break ;
case NL80211_PLINK_OPN_SNT :
switch ( event ) {
case OPN_RJCT :
case CNF_RJCT :
case CLS_ACPT :
mesh_plink_close ( sdata , sta , event ) ;
action = WLAN_SP_MESH_PEERING_CLOSE ;
break ;
case OPN_ACPT :
/* retry timer is left untouched */
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = NL80211_PLINK_OPN_RCVD ;
2013-11-05 23:17:02 +04:00
action = WLAN_SP_MESH_PEERING_CONFIRM ;
break ;
case CNF_ACPT :
2015-06-17 11:31:00 +03:00
sta - > mesh - > plink_state = NL80211_PLINK_CNF_RCVD ;
2014-06-04 17:27:31 +04:00
mod_plink_timer ( sta , mshcfg - > dot11MeshConfirmTimeout ) ;
2013-11-05 23:17:02 +04:00
break ;
default :
break ;
}
break ;
case NL80211_PLINK_OPN_RCVD :
switch ( event ) {
case OPN_RJCT :
case CNF_RJCT :
case CLS_ACPT :
mesh_plink_close ( sdata , sta , event ) ;
action = WLAN_SP_MESH_PEERING_CLOSE ;
break ;
case OPN_ACPT :
action = WLAN_SP_MESH_PEERING_CONFIRM ;
break ;
case CNF_ACPT :
changed | = mesh_plink_establish ( sdata , sta ) ;
break ;
default :
break ;
}
break ;
case NL80211_PLINK_CNF_RCVD :
switch ( event ) {
case OPN_RJCT :
case CNF_RJCT :
case CLS_ACPT :
mesh_plink_close ( sdata , sta , event ) ;
action = WLAN_SP_MESH_PEERING_CLOSE ;
break ;
case OPN_ACPT :
changed | = mesh_plink_establish ( sdata , sta ) ;
action = WLAN_SP_MESH_PEERING_CONFIRM ;
break ;
default :
break ;
}
break ;
case NL80211_PLINK_ESTAB :
switch ( event ) {
case CLS_ACPT :
changed | = __mesh_plink_deactivate ( sta ) ;
changed | = mesh_set_ht_prot_mode ( sdata ) ;
changed | = mesh_set_short_slot_time ( sdata ) ;
mesh_plink_close ( sdata , sta , event ) ;
action = WLAN_SP_MESH_PEERING_CLOSE ;
2016-03-26 18:27:19 +03:00
flush = true ;
2013-11-05 23:17:02 +04:00
break ;
case OPN_ACPT :
action = WLAN_SP_MESH_PEERING_CONFIRM ;
break ;
default :
break ;
}
break ;
case NL80211_PLINK_HOLDING :
switch ( event ) {
case CLS_ACPT :
2015-06-17 11:31:00 +03:00
del_timer ( & sta - > mesh - > plink_timer ) ;
2013-11-05 23:17:02 +04:00
mesh_plink_fsm_restart ( sta ) ;
break ;
case OPN_ACPT :
case CNF_ACPT :
case OPN_RJCT :
case CNF_RJCT :
action = WLAN_SP_MESH_PEERING_CLOSE ;
break ;
default :
break ;
}
break ;
default :
/* should not get here, PLINK_BLOCKED is dealt with at the
* beginning of the function
*/
break ;
}
2015-06-17 11:31:00 +03:00
spin_unlock_bh ( & sta - > mesh - > plink_lock ) ;
2016-03-26 18:27:19 +03:00
if ( flush )
mesh_path_flush_by_nexthop ( sta ) ;
2013-11-05 23:17:02 +04:00
if ( action ) {
2015-07-14 15:31:58 +03:00
mesh_plink_frame_tx ( sdata , sta , action , sta - > sta . addr ,
2015-06-17 11:31:00 +03:00
sta - > mesh - > llid , sta - > mesh - > plid ,
sta - > mesh - > reason ) ;
2013-11-05 23:17:02 +04:00
/* also send confirm in open case */
if ( action = = WLAN_SP_MESH_PEERING_OPEN ) {
2015-07-14 15:31:58 +03:00
mesh_plink_frame_tx ( sdata , sta ,
2013-11-05 23:17:02 +04:00
WLAN_SP_MESH_PEERING_CONFIRM ,
2015-06-17 11:31:00 +03:00
sta - > sta . addr , sta - > mesh - > llid ,
sta - > mesh - > plid , 0 ) ;
2013-11-05 23:17:02 +04:00
}
}
return changed ;
}
2013-11-05 23:17:03 +04:00
/*
* mesh_plink_get_event - get correct MPM event
*
* @ sdata : interface
* @ sta : peer , leave NULL if processing a frame from a new suitable peer
* @ elems : peering management IEs
* @ ftype : frame type
* @ llid : peer ' s peer link ID
* @ plid : peer ' s local link ID
*
* Return : new peering event for @ sta , but PLINK_UNDEFINED should be treated as
* an error .
*/
static enum plink_event
mesh_plink_get_event ( struct ieee80211_sub_if_data * sdata ,
struct sta_info * sta ,
struct ieee802_11_elems * elems ,
enum ieee80211_self_protected_actioncode ftype ,
2013-11-13 11:43:03 +04:00
u16 llid , u16 plid )
2013-11-05 23:17:03 +04:00
{
enum plink_event event = PLINK_UNDEFINED ;
u8 ie_len = elems - > peering_len ;
bool matches_local ;
matches_local = ( ftype = = WLAN_SP_MESH_PEERING_CLOSE | |
mesh_matches_local ( sdata , elems ) ) ;
/* deny open request from non-matching peer */
if ( ! matches_local & & ! sta ) {
event = OPN_RJCT ;
goto out ;
}
if ( ! sta ) {
if ( ftype ! = WLAN_SP_MESH_PEERING_OPEN ) {
mpl_dbg ( sdata , " Mesh plink: cls or cnf from unknown peer \n " ) ;
goto out ;
}
/* ftype == WLAN_SP_MESH_PEERING_OPEN */
if ( ! mesh_plink_free_count ( sdata ) ) {
mpl_dbg ( sdata , " Mesh plink error: no more free plinks \n " ) ;
goto out ;
}
2016-01-21 08:36:25 +03:00
/* new matching peer */
event = OPN_ACPT ;
goto out ;
2013-11-05 23:17:03 +04:00
} else {
if ( ! test_sta_flag ( sta , WLAN_STA_AUTH ) ) {
mpl_dbg ( sdata , " Mesh plink: Action frame from non-authed peer \n " ) ;
goto out ;
}
2015-06-17 11:31:00 +03:00
if ( sta - > mesh - > plink_state = = NL80211_PLINK_BLOCKED )
2013-11-05 23:17:03 +04:00
goto out ;
}
switch ( ftype ) {
case WLAN_SP_MESH_PEERING_OPEN :
if ( ! matches_local )
event = OPN_RJCT ;
2023-12-11 10:05:31 +03:00
else if ( ! mesh_plink_free_count ( sdata ) | |
( sta - > mesh - > plid & & sta - > mesh - > plid ! = plid ) )
2013-11-05 23:17:03 +04:00
event = OPN_IGNR ;
else
event = OPN_ACPT ;
break ;
case WLAN_SP_MESH_PEERING_CONFIRM :
if ( ! matches_local )
event = CNF_RJCT ;
2023-12-11 10:05:31 +03:00
else if ( ! mesh_plink_free_count ( sdata ) | |
sta - > mesh - > llid ! = llid | |
( sta - > mesh - > plid & & sta - > mesh - > plid ! = plid ) )
2013-11-05 23:17:03 +04:00
event = CNF_IGNR ;
else
event = CNF_ACPT ;
break ;
case WLAN_SP_MESH_PEERING_CLOSE :
2015-06-17 11:31:00 +03:00
if ( sta - > mesh - > plink_state = = NL80211_PLINK_ESTAB )
2013-11-05 23:17:03 +04:00
/* Do not check for llid or plid. This does not
* follow the standard but since multiple plinks
* per sta are not supported , it is necessary in
* order to avoid a livelock when MP A sees an
* establish peer link to MP B but MP B does not
* see it . This can be caused by a timeout in
* B ' s peer link establishment or B beign
* restarted .
*/
event = CLS_ACPT ;
2015-06-17 11:31:00 +03:00
else if ( sta - > mesh - > plid ! = plid )
2013-11-05 23:17:03 +04:00
event = CLS_IGNR ;
2015-06-17 11:31:00 +03:00
else if ( ie_len = = 8 & & sta - > mesh - > llid ! = llid )
2013-11-05 23:17:03 +04:00
event = CLS_IGNR ;
else
event = CLS_ACPT ;
break ;
default :
mpl_dbg ( sdata , " Mesh plink: unknown frame subtype \n " ) ;
break ;
}
out :
return event ;
}
2013-11-05 23:16:59 +04:00
static void
mesh_process_plink_frame ( struct ieee80211_sub_if_data * sdata ,
struct ieee80211_mgmt * mgmt ,
2018-10-26 17:03:50 +03:00
struct ieee802_11_elems * elems ,
struct ieee80211_rx_status * rx_status )
2008-02-23 17:17:13 +03:00
{
2013-11-05 23:16:59 +04:00
2008-02-23 17:17:13 +03:00
struct sta_info * sta ;
enum plink_event event ;
2011-08-12 06:35:12 +04:00
enum ieee80211_self_protected_actioncode ftype ;
2023-06-04 12:11:26 +03:00
u64 changed = 0 ;
2013-11-05 23:17:03 +04:00
u8 ie_len = elems - > peering_len ;
2013-11-13 11:43:03 +04:00
u16 plid , llid = 0 ;
2008-02-23 17:17:13 +03:00
2013-11-05 23:16:59 +04:00
if ( ! elems - > peering ) {
2012-06-22 13:29:50 +04:00
mpl_dbg ( sdata ,
" Mesh plink: missing necessary peer link ie \n " ) ;
2008-02-23 17:17:13 +03:00
return ;
}
2013-02-15 17:40:31 +04:00
2013-11-05 23:16:59 +04:00
if ( elems - > rsn_len & &
2013-02-15 17:40:31 +04:00
sdata - > u . mesh . security = = IEEE80211_MESH_SEC_NONE ) {
2012-06-22 13:29:50 +04:00
mpl_dbg ( sdata ,
" Mesh plink: can't establish link with secure peer \n " ) ;
2011-04-08 02:08:29 +04:00
return ;
}
2008-02-23 17:17:13 +03:00
2011-08-13 07:01:00 +04:00
ftype = mgmt - > u . action . u . self_prot . action_code ;
if ( ( ftype = = WLAN_SP_MESH_PEERING_OPEN & & ie_len ! = 4 ) | |
( ftype = = WLAN_SP_MESH_PEERING_CONFIRM & & ie_len ! = 6 ) | |
( ftype = = WLAN_SP_MESH_PEERING_CLOSE & & ie_len ! = 6
& & ie_len ! = 8 ) ) {
2012-06-22 13:29:50 +04:00
mpl_dbg ( sdata ,
" Mesh plink: incorrect plink ie length %d %d \n " ,
ftype , ie_len ) ;
2008-02-23 17:17:13 +03:00
return ;
}
2011-08-12 06:35:12 +04:00
if ( ftype ! = WLAN_SP_MESH_PEERING_CLOSE & &
2013-11-05 23:16:59 +04:00
( ! elems - > mesh_id | | ! elems - > mesh_config ) ) {
2012-06-22 13:29:50 +04:00
mpl_dbg ( sdata , " Mesh plink: missing necessary ie \n " ) ;
2008-02-23 17:17:13 +03:00
return ;
}
/* Note the lines below are correct, the llid in the frame is the plid
* from the point of view of this host .
*/
2014-06-29 00:35:26 +04:00
plid = get_unaligned_le16 ( PLINK_GET_LLID ( elems - > peering ) ) ;
2011-08-12 06:35:12 +04:00
if ( ftype = = WLAN_SP_MESH_PEERING_CONFIRM | |
2014-06-29 00:35:26 +04:00
( ftype = = WLAN_SP_MESH_PEERING_CLOSE & & ie_len = = 8 ) )
llid = get_unaligned_le16 ( PLINK_GET_PLID ( elems - > peering ) ) ;
2008-02-23 17:17:13 +03:00
2013-01-24 00:18:12 +04:00
/* WARNING: Only for sta pointer, is dropped & re-acquired */
2008-02-25 18:27:46 +03:00
rcu_read_lock ( ) ;
2009-11-25 19:46:18 +03:00
sta = sta_info_get ( sdata , mgmt - > sa ) ;
2013-11-05 23:16:53 +04:00
2012-02-29 05:04:08 +04:00
if ( ftype = = WLAN_SP_MESH_PEERING_OPEN & &
2013-11-05 23:16:54 +04:00
! rssi_threshold_check ( sdata , sta ) ) {
2012-06-22 13:29:50 +04:00
mpl_dbg ( sdata , " Mesh plink: %pM does not meet rssi threshold \n " ,
2012-03-07 00:48:30 +04:00
mgmt - > sa ) ;
2013-11-05 23:17:00 +04:00
goto unlock_rcu ;
2012-02-29 05:04:08 +04:00
}
2008-02-23 17:17:13 +03:00
/* Now we will figure out the appropriate event... */
2013-11-05 23:17:03 +04:00
event = mesh_plink_get_event ( sdata , sta , elems , ftype , llid , plid ) ;
2012-04-19 06:23:42 +04:00
if ( event = = OPN_ACPT ) {
2013-01-24 00:18:12 +04:00
rcu_read_unlock ( ) ;
2012-04-19 06:23:42 +04:00
/* allocate sta entry if necessary and update info */
2018-10-26 17:03:50 +03:00
sta = mesh_sta_info_get ( sdata , mgmt - > sa , elems , rx_status ) ;
2012-04-19 06:23:42 +04:00
if ( ! sta ) {
2012-06-22 13:29:50 +04:00
mpl_dbg ( sdata , " Mesh plink: failed to init peer! \n " ) ;
2013-11-05 23:17:00 +04:00
goto unlock_rcu ;
2012-04-19 06:23:42 +04:00
}
2015-06-17 11:31:00 +03:00
sta - > mesh - > plid = plid ;
2013-11-05 23:17:03 +04:00
} else if ( ! sta & & event = = OPN_RJCT ) {
2015-07-14 15:31:58 +03:00
mesh_plink_frame_tx ( sdata , NULL , WLAN_SP_MESH_PEERING_CLOSE ,
2013-11-05 23:17:03 +04:00
mgmt - > sa , 0 , plid ,
2013-11-13 11:43:03 +04:00
WLAN_REASON_MESH_CONFIG ) ;
2013-11-05 23:17:03 +04:00
goto unlock_rcu ;
} else if ( ! sta | | event = = PLINK_UNDEFINED ) {
/* something went wrong */
goto unlock_rcu ;
2008-02-23 17:17:13 +03:00
}
2015-07-14 15:31:58 +03:00
if ( event = = CNF_ACPT ) {
/* 802.11-2012 13.3.7.2 - update plid on CNF if not set */
2015-07-14 15:31:59 +03:00
if ( ! sta - > mesh - > plid )
2015-07-14 15:31:58 +03:00
sta - > mesh - > plid = plid ;
sta - > mesh - > aid = get_unaligned_le16 ( PLINK_CNF_AID ( mgmt ) ) ;
}
2014-06-29 00:35:25 +04:00
2013-11-05 23:17:02 +04:00
changed | = mesh_plink_fsm ( sdata , sta , event ) ;
2008-02-25 18:27:46 +03:00
2013-11-05 23:17:00 +04:00
unlock_rcu :
2008-02-25 18:27:46 +03:00
rcu_read_unlock ( ) ;
2012-05-01 01:20:30 +04:00
2013-06-11 00:17:21 +04:00
if ( changed )
2013-02-14 23:20:13 +04:00
ieee80211_mbss_info_change_notify ( sdata , changed ) ;
2008-02-23 17:17:13 +03:00
}
2013-11-05 23:16:59 +04:00
void mesh_rx_plink_frame ( struct ieee80211_sub_if_data * sdata ,
struct ieee80211_mgmt * mgmt , size_t len ,
struct ieee80211_rx_status * rx_status )
{
mac80211: always allocate struct ieee802_11_elems
As the 802.11 spec evolves, we need to parse more and more
elements. This is causing the struct to grow, and we can no
longer get away with putting it on the stack.
Change the API to always dynamically allocate and return an
allocated pointer that must be kfree()d later.
As an alternative, I contemplated a scheme whereby we'd say
in the code which elements we needed, e.g.
DECLARE_ELEMENT_PARSER(elems,
SUPPORTED_CHANNELS,
CHANNEL_SWITCH,
EXT(KEY_DELIVERY));
ieee802_11_parse_elems(..., &elems, ...);
and while I think this is possible and will save us a lot
since most individual places only care about a small subset
of the elements, it ended up being a bit more work since a
lot of places do the parsing and then pass the struct to
other functions, sometimes with multiple levels.
Link: https://lore.kernel.org/r/20210920154009.26caff6b5998.I05ae58768e990e611aee8eca8abefd9d7bc15e05@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-09-20 16:40:10 +03:00
struct ieee802_11_elems * elems ;
2013-11-05 23:16:59 +04:00
size_t baselen ;
u8 * baseaddr ;
/* need action_code, aux */
if ( len < IEEE80211_MIN_ACTION_SIZE + 3 )
return ;
if ( sdata - > u . mesh . user_mpm )
/* userspace must register for these */
return ;
if ( is_multicast_ether_addr ( mgmt - > da ) ) {
mpl_dbg ( sdata ,
" Mesh plink: ignore frame from multicast address \n " ) ;
return ;
}
baseaddr = mgmt - > u . action . u . self_prot . variable ;
baselen = ( u8 * ) mgmt - > u . action . u . self_prot . variable - ( u8 * ) mgmt ;
if ( mgmt - > u . action . u . self_prot . action_code = =
WLAN_SP_MESH_PEERING_CONFIRM ) {
baseaddr + = 4 ;
baselen + = 4 ;
2015-07-14 15:31:56 +03:00
if ( baselen > len )
return ;
2013-11-05 23:16:59 +04:00
}
2022-06-29 14:29:05 +03:00
elems = ieee802_11_parse_elems ( baseaddr , len - baselen , true , NULL ) ;
2023-12-11 10:05:32 +03:00
if ( elems ) {
mesh_process_plink_frame ( sdata , mgmt , elems , rx_status ) ;
kfree ( elems ) ;
}
2013-11-05 23:16:59 +04:00
}