Skip to content

Commit 9f47252

Browse files
committed
wifi: mac80211: refactor chanreq.ap setting
There are now three places setting up chanreq.ap which always depends on the mode (EHT being used or not) and override flag. Refactor that code into a common function with a comment, to make that clearer. Reviewed-by: Miriam Rachel Korenblit <[email protected]> Link: https://msgid.link/20240506215543.5cd6a209e58a.I3be318959d9e2df5dccd2d0938c3d2fcc6688030@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 4540568 commit 9f47252

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

net/mac80211/mlme.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,29 @@ static void ieee80211_rearrange_tpe(struct ieee80211_parsed_tpe *tpe,
789789
}
790790
}
791791

792+
/*
793+
* The AP part of the channel request is used to distinguish settings
794+
* to the device used for wider bandwidth OFDMA. This is used in the
795+
* channel context code to assign two channel contexts even if they're
796+
* both for the same channel, if the AP bandwidths are incompatible.
797+
* If not EHT (or driver override) then ap.chan == NULL indicates that
798+
* there's no wider BW OFDMA used.
799+
*/
800+
static void ieee80211_set_chanreq_ap(struct ieee80211_sub_if_data *sdata,
801+
struct ieee80211_chan_req *chanreq,
802+
struct ieee80211_conn_settings *conn,
803+
struct cfg80211_chan_def *ap_chandef)
804+
{
805+
chanreq->ap.chan = NULL;
806+
807+
if (conn->mode < IEEE80211_CONN_MODE_EHT)
808+
return;
809+
if (sdata->vif.driver_flags & IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW)
810+
return;
811+
812+
chanreq->ap = *ap_chandef;
813+
}
814+
792815
static struct ieee802_11_elems *
793816
ieee80211_determine_chan_mode(struct ieee80211_sub_if_data *sdata,
794817
struct ieee80211_conn_settings *conn,
@@ -886,12 +909,7 @@ ieee80211_determine_chan_mode(struct ieee80211_sub_if_data *sdata,
886909

887910
chanreq->oper = *ap_chandef;
888911

889-
/* wider-bandwidth OFDMA is only done in EHT */
890-
if (conn->mode >= IEEE80211_CONN_MODE_EHT &&
891-
!(sdata->vif.driver_flags & IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW))
892-
chanreq->ap = *ap_chandef;
893-
else
894-
chanreq->ap.chan = NULL;
912+
ieee80211_set_chanreq_ap(sdata, chanreq, conn, ap_chandef);
895913

896914
while (!ieee80211_chandef_usable(sdata, &chanreq->oper,
897915
IEEE80211_CHAN_DISABLED)) {
@@ -999,11 +1017,9 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,
9991017
return -EINVAL;
10001018
}
10011019

1002-
chanreq.ap = ap_chandef;
10031020
chanreq.oper = ap_chandef;
1004-
if (link->u.mgd.conn.mode < IEEE80211_CONN_MODE_EHT ||
1005-
sdata->vif.driver_flags & IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW)
1006-
chanreq.ap.chan = NULL;
1021+
ieee80211_set_chanreq_ap(sdata, &chanreq, &link->u.mgd.conn,
1022+
&ap_chandef);
10071023

10081024
/*
10091025
* if HT operation mode changed store the new one -
@@ -2535,10 +2551,9 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
25352551

25362552
link->u.mgd.csa.ap_chandef = csa_ie.chanreq.ap;
25372553

2538-
link->csa.chanreq = csa_ie.chanreq;
2539-
if (link->u.mgd.conn.mode < IEEE80211_CONN_MODE_EHT ||
2540-
sdata->vif.driver_flags & IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW)
2541-
link->csa.chanreq.ap.chan = NULL;
2554+
link->csa.chanreq.oper = csa_ie.chanreq.oper;
2555+
ieee80211_set_chanreq_ap(sdata, &link->csa.chanreq, &link->u.mgd.conn,
2556+
&csa_ie.chanreq.ap);
25422557

25432558
if (chanctx) {
25442559
res = ieee80211_link_reserve_chanctx(link, &link->csa.chanreq,

0 commit comments

Comments
 (0)