Skip to content

Commit f1cae6b

Browse files
rado17kapbh
authored andcommitted
[nrf fromlist] drivers: wifi: nrf_wifi: Add per-peer authorized flag
Add per-peer authorized parameter. Port authorization command from supplicant will set this flag and will be used by driver to allow or nor allow data traffic. Upstream PR #: 97183 Signed-off-by: Ravi Dondaputi <[email protected]>
1 parent a075101 commit f1cae6b

File tree

4 files changed

+69
-14
lines changed

4 files changed

+69
-14
lines changed

drivers/wifi/nrf_wifi/inc/fmac_main.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ struct nrf_wifi_vif_ctx_zep {
7575
#endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
7676
struct net_stats_eth eth_stats;
7777
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
78-
#if defined(CONFIG_NRF70_STA_MODE) || defined(CONFIG_NRF70_RAW_DATA_RX)
79-
bool authorized;
80-
#endif
8178
#ifdef CONFIG_NRF70_STA_MODE
8279
unsigned int assoc_freq;
8380
enum nrf_wifi_fmac_if_carr_state if_carr_state;

drivers/wifi/nrf_wifi/src/net_if.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);
2525

2626
#include "util.h"
2727
#include "common/fmac_util.h"
28+
#include "system/fmac_peer.h"
2829
#include "shim.h"
2930
#include "fmac_main.h"
3031
#include "wpa_supp_if.h"
@@ -388,6 +389,8 @@ int nrf_wifi_if_send(const struct device *dev,
388389
struct rpu_host_stats *host_stats = NULL;
389390
void *nbuf = NULL;
390391
bool locked = false;
392+
unsigned char *ra = NULL;
393+
int peer_id = -1;
391394

392395
if (!dev || !pkt) {
393396
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
@@ -436,12 +439,20 @@ int nrf_wifi_if_send(const struct device *dev,
436439
nbuf);
437440
} else {
438441
#endif /* CONFIG_NRF70_RAW_DATA_TX */
442+
443+
ra = nrf_wifi_util_get_ra(sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx], nbuf);
444+
peer_id = nrf_wifi_fmac_peer_get_id(rpu_ctx_zep->rpu_ctx, ra);
445+
if (peer_id == -1) {
446+
nrf_wifi_osal_log_dbg("%s: Invalid peer",
447+
__func__);
448+
goto out;
449+
}
450+
439451
if ((vif_ctx_zep->if_carr_state != NRF_WIFI_FMAC_IF_CARR_STATE_ON) ||
440-
(!vif_ctx_zep->authorized && !is_eapol(pkt))) {
452+
(!sys_dev_ctx->tx_config.peers[peer_id].authorized && !is_eapol(pkt))) {
441453
ret = -EPERM;
442454
goto drop;
443455
}
444-
445456
ret = nrf_wifi_fmac_start_xmit(rpu_ctx_zep->rpu_ctx,
446457
vif_ctx_zep->vif_idx,
447458
nbuf);

drivers/wifi/nrf_wifi/src/wifi_mgmt.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "system/fmac_api.h"
1919
#include "system/fmac_tx.h"
2020
#include "common/fmac_util.h"
21+
#include "common/fmac_structs_common.h"
2122
#include "fmac_main.h"
2223
#include "wifi_mgmt.h"
2324

@@ -757,6 +758,8 @@ int nrf_wifi_mode(const struct device *dev,
757758
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
758759
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL;
759760
struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL;
761+
struct peers_info *peer = NULL;
762+
int i = 0;
760763
int ret = -1;
761764

762765
if (!dev || !mode) {
@@ -798,10 +801,16 @@ int nrf_wifi_mode(const struct device *dev,
798801
goto out;
799802
}
800803

801-
if (vif_ctx_zep->authorized && (mode->mode == NRF_WIFI_MONITOR_MODE)) {
802-
LOG_ERR("%s: Cannot set monitor mode when station is connected",
803-
__func__);
804-
goto out;
804+
for (i = 0; i < MAX_PEERS; i++) {
805+
peer = &sys_dev_ctx->tx_config.peers[i];
806+
if (peer->peer_id == -1) {
807+
continue;
808+
}
809+
if (peer->authorized && (mode->mode == NRF_WIFI_MONITOR_MODE)) {
810+
LOG_ERR("%s: Cannot set monitor mode when station is connected",
811+
__func__);
812+
goto out;
813+
}
805814
}
806815

807816
/**
@@ -851,6 +860,8 @@ int nrf_wifi_channel(const struct device *dev,
851860
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
852861
struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL;
853862
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL;
863+
struct peers_info *peer = NULL;
864+
int i = 0;
854865
int ret = -1;
855866

856867
if (!dev || !channel) {
@@ -864,9 +875,16 @@ int nrf_wifi_channel(const struct device *dev,
864875
return ret;
865876
}
866877

867-
if (vif_ctx_zep->authorized) {
868-
LOG_ERR("%s: Cannot change channel when in station connected mode", __func__);
869-
return ret;
878+
for (i = 0; i < MAX_PEERS; i++) {
879+
peer = &sys_dev_ctx->tx_config.peers[i];
880+
if (peer->peer_id == -1) {
881+
continue;
882+
}
883+
if (peer->authorized) {
884+
LOG_ERR("%s: Cannot change channel when in station connected mode",
885+
__func__);
886+
return ret;
887+
}
870888
}
871889

872890
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;

drivers/wifi/nrf_wifi/src/wpa_supp_if.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "common/fmac_util.h"
1818
#include "wifi_mgmt.h"
1919
#include "wpa_supp_if.h"
20+
#include <system/fmac_peer.h>
2021

2122
LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);
2223

@@ -1103,7 +1104,9 @@ int nrf_wifi_wpa_set_supp_port(void *if_priv, int authorized, char *bssid)
11031104
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
11041105
struct nrf_wifi_umac_chg_sta_info chg_sta_info;
11051106
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
1107+
struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL;
11061108
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
1109+
int peer_id = -1;
11071110
int ret = -1;
11081111

11091112
if (!if_priv || !bssid) {
@@ -1134,8 +1137,6 @@ int nrf_wifi_wpa_set_supp_port(void *if_priv, int authorized, char *bssid)
11341137

11351138
memcpy(chg_sta_info.mac_addr, bssid, ETH_ALEN);
11361139

1137-
vif_ctx_zep->authorized = authorized;
1138-
11391140
if (authorized) {
11401141
/* BIT(NL80211_STA_FLAG_AUTHORIZED) */
11411142
chg_sta_info.sta_flags2.nrf_wifi_mask = 1 << 1;
@@ -1153,6 +1154,19 @@ int nrf_wifi_wpa_set_supp_port(void *if_priv, int authorized, char *bssid)
11531154
goto out;
11541155
}
11551156

1157+
sys_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx);
1158+
1159+
peer_id = nrf_wifi_fmac_peer_get_id(rpu_ctx_zep->rpu_ctx, chg_sta_info.mac_addr);
1160+
if (peer_id == -1) {
1161+
nrf_wifi_osal_log_err("%s: Invalid peer",
1162+
__func__);
1163+
goto out;
1164+
}
1165+
1166+
if (chg_sta_info.sta_flags2.nrf_wifi_set & NRF_WIFI_STA_FLAG_AUTHORIZED) {
1167+
sys_dev_ctx->tx_config.peers[peer_id].authorized = true;
1168+
}
1169+
11561170
ret = 0;
11571171
out:
11581172
k_mutex_unlock(&vif_ctx_zep->vif_lock);
@@ -2939,7 +2953,9 @@ int nrf_wifi_wpa_supp_sta_set_flags(void *if_priv, const u8 *addr,
29392953
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
29402954
struct nrf_wifi_umac_chg_sta_info chg_sta = {0};
29412955
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
2956+
struct nrf_wifi_sys_fmac_dev_ctx *sys_dev_ctx = NULL;
29422957
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
2958+
int peer_id = -1;
29432959
int ret = -1;
29442960

29452961
if (!if_priv || !addr) {
@@ -2974,6 +2990,19 @@ int nrf_wifi_wpa_supp_sta_set_flags(void *if_priv, const u8 *addr,
29742990
goto out;
29752991
}
29762992

2993+
sys_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx);
2994+
2995+
peer_id = nrf_wifi_fmac_peer_get_id(rpu_ctx_zep->rpu_ctx, chg_sta.mac_addr);
2996+
if (peer_id == -1) {
2997+
nrf_wifi_osal_log_err("%s: Invalid peer",
2998+
__func__);
2999+
goto out;
3000+
}
3001+
3002+
if (chg_sta.sta_flags2.nrf_wifi_set & NRF_WIFI_STA_FLAG_AUTHORIZED) {
3003+
sys_dev_ctx->tx_config.peers[peer_id].authorized = true;
3004+
}
3005+
29773006
ret = 0;
29783007

29793008
out:

0 commit comments

Comments
 (0)