Skip to content

Commit aaeeeb5

Browse files
committed
[nrf fromlist] drivers: wifi: nrf_wifi: Add RoC support
Add ops for remain-on-channel and cancelling remain-on-channel. Upstream PR #: 97183 Signed-off-by: Ravi Dondaputi <[email protected]>
1 parent a346ad8 commit aaeeeb5

File tree

3 files changed

+151
-0
lines changed

3 files changed

+151
-0
lines changed

drivers/wifi/nrf_wifi/inc/wpa_supp_if.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,16 @@ int nrf_wifi_supp_get_conn_info(void *if_priv, struct wpa_conn_info *info);
123123
void nrf_wifi_supp_event_proc_get_conn_info(void *os_vif_ctx,
124124
struct nrf_wifi_umac_event_conn_info *info,
125125
unsigned int event_len);
126+
void nrf_wifi_supp_event_roc_complete(void *os_vif_ctx,
127+
struct nrf_wifi_event_remain_on_channel *info,
128+
unsigned int event_len);
129+
void nrf_wifi_supp_event_roc_cancel_complete(void *os_vif_ctx,
130+
struct nrf_wifi_event_remain_on_channel *info,
131+
unsigned int event_len);
126132
int nrf_wifi_supp_set_country(void *if_priv, const char *alpha2);
127133
int nrf_wifi_supp_get_country(void *if_priv, char *alpha2);
134+
int nrf_wifi_supp_remain_on_channel(void *if_priv, unsigned int freq, unsigned int duration);
135+
int nrf_wifi_supp_cancel_remain_on_channel(void *if_priv);
128136

129137
#endif /* CONFIG_NRF70_STA_MODE */
130138
#ifdef CONFIG_NRF70_AP_MODE

drivers/wifi/nrf_wifi/src/fmac_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,8 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
843843
callbk_fns.event_get_wiphy = nrf_wifi_wpa_supp_event_get_wiphy;
844844
callbk_fns.mgmt_rx_callbk_fn = nrf_wifi_wpa_supp_event_mgmt_rx_callbk_fn;
845845
callbk_fns.get_conn_info_callbk_fn = nrf_wifi_supp_event_proc_get_conn_info;
846+
callbk_fns.roc_callbk_fn = nrf_wifi_supp_event_roc_complete;
847+
callbk_fns.roc_cancel_callbk_fn = nrf_wifi_supp_event_roc_cancel_complete;
846848
#endif /* CONFIG_NRF70_STA_MODE */
847849

848850
/* The OSAL layer needs to be initialized before any other initialization
@@ -963,6 +965,8 @@ static const struct zep_wpa_supp_dev_ops wpa_supp_ops = {
963965
.get_conn_info = nrf_wifi_supp_get_conn_info,
964966
.set_country = nrf_wifi_supp_set_country,
965967
.get_country = nrf_wifi_supp_get_country,
968+
.remain_on_channel = nrf_wifi_supp_remain_on_channel,
969+
.cancel_remain_on_channel = nrf_wifi_supp_cancel_remain_on_channel,
966970
#ifdef CONFIG_NRF70_AP_MODE
967971
.init_ap = nrf_wifi_wpa_supp_init_ap,
968972
.start_ap = nrf_wifi_wpa_supp_start_ap,

drivers/wifi/nrf_wifi/src/wpa_supp_if.c

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,145 @@ void nrf_wifi_supp_event_proc_get_conn_info(void *if_priv,
19861986
k_sem_give(&wait_for_event_sem);
19871987
}
19881988

1989+
void nrf_wifi_supp_event_roc_complete(void *if_priv,
1990+
struct nrf_wifi_event_remain_on_channel *roc_complete,
1991+
unsigned int event_len)
1992+
{
1993+
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
1994+
1995+
if (!if_priv) {
1996+
LOG_ERR("%s: Missing interface context", __func__);
1997+
return;
1998+
}
1999+
2000+
vif_ctx_zep = if_priv;
2001+
2002+
if (!roc_complete) {
2003+
LOG_ERR("%s: Missing ROC complete event data", __func__);
2004+
return;
2005+
}
2006+
2007+
LOG_DBG("%s: ROC complete on freq %d, dur %d, vif_idx %d",
2008+
__func__, roc_complete->frequency,
2009+
roc_complete->dur, vif_ctx_zep->vif_idx);
2010+
2011+
if (vif_ctx_zep->supp_drv_if_ctx && vif_ctx_zep->supp_callbk_fns.roc_complete) {
2012+
vif_ctx_zep->supp_callbk_fns.roc_complete(vif_ctx_zep->supp_drv_if_ctx,
2013+
roc_complete->frequency,
2014+
roc_complete->dur);
2015+
}
2016+
}
2017+
2018+
void nrf_wifi_supp_event_roc_cancel_complete(void *if_priv,
2019+
struct nrf_wifi_event_remain_on_channel *roc_cancel_complete,
2020+
unsigned int event_len)
2021+
{
2022+
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
2023+
2024+
if (!if_priv) {
2025+
LOG_ERR("%s: Missing interface context", __func__);
2026+
return;
2027+
}
2028+
2029+
vif_ctx_zep = if_priv;
2030+
2031+
if (!roc_cancel_complete) {
2032+
LOG_ERR("%s: Missing ROC cancel complete event data", __func__);
2033+
return;
2034+
}
2035+
2036+
LOG_DBG("%s: ROC cancel complete on freq %d, vif_idx %d",
2037+
__func__, roc_cancel_complete->frequency,
2038+
vif_ctx_zep->vif_idx);
2039+
2040+
if (vif_ctx_zep->supp_drv_if_ctx && vif_ctx_zep->supp_callbk_fns.roc_cancel_complete) {
2041+
vif_ctx_zep->supp_callbk_fns.roc_cancel_complete(vif_ctx_zep->supp_drv_if_ctx,
2042+
roc_cancel_complete->frequency);
2043+
}
2044+
}
2045+
2046+
int nrf_wifi_supp_remain_on_channel(void *if_priv, unsigned int freq,
2047+
unsigned int duration)
2048+
{
2049+
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
2050+
#ifdef NRF70_P2P_MODE
2051+
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
2052+
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
2053+
struct remain_on_channel_info roc_info;
2054+
2055+
if (!if_priv) {
2056+
LOG_ERR("%s: Invalid params", __func__);
2057+
return -1;
2058+
}
2059+
2060+
vif_ctx_zep = if_priv;
2061+
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;
2062+
if (!rpu_ctx_zep) {
2063+
LOG_ERR("%s: rpu_ctx_zep is NULL", __func__);
2064+
return -1;
2065+
}
2066+
2067+
k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);
2068+
if (!rpu_ctx_zep->rpu_ctx) {
2069+
LOG_DBG("%s: RPU context not initialized", __func__);
2070+
goto out;
2071+
}
2072+
2073+
memset(&roc_info, 0, sizeof(roc_info));
2074+
roc_info.nrf_wifi_freq_params.frequency = freq;
2075+
roc_info.nrf_wifi_freq_params.channel_width = NRF_WIFI_CHAN_WIDTH_20;
2076+
roc_info.nrf_wifi_freq_params.center_frequency1 = freq;
2077+
roc_info.nrf_wifi_freq_params.center_frequency2 = 0;
2078+
roc_info.nrf_wifi_freq_params.channel_type = NRF_WIFI_CHAN_HT20;
2079+
roc_info.dur = duration;
2080+
2081+
status = nrf_wifi_sys_fmac_p2p_roc_start(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, &roc_info);
2082+
if (status != NRF_WIFI_STATUS_SUCCESS) {
2083+
LOG_ERR("%s: nrf_wifi_fmac_remain_on_channel failed", __func__);
2084+
goto out;
2085+
}
2086+
out:
2087+
k_mutex_unlock(&vif_ctx_zep->vif_lock);
2088+
#endif /* NRF70_P2P_MODE */
2089+
return status;
2090+
}
2091+
2092+
int nrf_wifi_supp_cancel_remain_on_channel(void *if_priv)
2093+
{
2094+
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
2095+
#ifdef NRF70_P2P_MODE
2096+
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
2097+
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
2098+
2099+
if (!if_priv) {
2100+
LOG_ERR("%s: Invalid params", __func__);
2101+
return -1;
2102+
}
2103+
2104+
vif_ctx_zep = if_priv;
2105+
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;
2106+
if (!rpu_ctx_zep) {
2107+
LOG_ERR("%s: rpu_ctx_zep is NULL", __func__);
2108+
return -1;
2109+
}
2110+
2111+
k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);
2112+
if (!rpu_ctx_zep->rpu_ctx) {
2113+
LOG_DBG("%s: RPU context not initialized", __func__);
2114+
goto out;
2115+
}
2116+
2117+
status = nrf_wifi_sys_fmac_p2p_roc_stop(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx, 0);
2118+
if (status != NRF_WIFI_STATUS_SUCCESS) {
2119+
LOG_ERR("%s: nrf_wifi_fmac_cancel_remain_on_channel failed", __func__);
2120+
goto out;
2121+
}
2122+
out:
2123+
k_mutex_unlock(&vif_ctx_zep->vif_lock);
2124+
#endif /* NRF70_P2P_MODE */
2125+
return status;
2126+
}
2127+
19892128
#ifdef CONFIG_NRF70_AP_MODE
19902129
static int nrf_wifi_vif_state_change(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep,
19912130
enum nrf_wifi_fmac_if_op_state state)

0 commit comments

Comments
 (0)