Skip to content

Commit ac364a7

Browse files
committed
drivers: wifi: DMS support
Support for Directed multicast service(DMS). Signed-off-by: Ajay Parida <[email protected]>
1 parent eab5250 commit ac364a7

File tree

7 files changed

+201
-4
lines changed

7 files changed

+201
-4
lines changed

drivers/wifi/nrf700x/inc/fmac_main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ struct nrf_wifi_vif_ctx_zep {
8080
#endif /* CONFIG_NRF700X_DATA_TX */
8181
unsigned long rssi_record_timestamp_us;
8282
signed short rssi;
83+
unsigned char dms_id_map;
84+
unsigned char dms_id_in_progress_map;
8385
#endif /* CONFIG_NRF700X_STA_MODE */
8486
};
8587

drivers/wifi/nrf700x/inc/wifi_mgmt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,10 @@ int nrf_wifi_filter(const struct device *dev,
7070
struct wifi_filter_info *filter);
7171
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */
7272

73+
int nrf_wifi_req_dms(const struct device *dev,
74+
struct wifi_dms_params *dms_params);
75+
76+
void nrf_wifi_event_proc_dms_zep(void *vif_ctx,
77+
struct nrf_wifi_umac_cmd_config_dms *dms_accept_info,
78+
unsigned int event_len);
7379
#endif /* __ZEPHYR_WIFI_MGMT_H__ */

drivers/wifi/nrf700x/src/fmac_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ static int nrf_wifi_drv_main_zep(const struct device *dev)
721721
callbk_fns.event_get_wiphy = nrf_wifi_wpa_supp_event_get_wiphy;
722722
callbk_fns.mgmt_rx_callbk_fn = nrf_wifi_wpa_supp_event_mgmt_rx_callbk_fn;
723723
callbk_fns.get_conn_info_callbk_fn = nrf_wifi_supp_event_proc_get_conn_info;
724+
callbk_fns.dms_callbk_fn = nrf_wifi_event_proc_dms_zep;
724725
#endif /* CONFIG_NRF700X_STA_MODE */
725726

726727
rpu_drv_priv_zep.fmac_priv = nrf_wifi_fmac_init(&data_config,
@@ -786,6 +787,7 @@ static struct wifi_mgmt_ops nrf_wifi_mgmt_ops = {
786787
.set_twt = nrf_wifi_set_twt,
787788
.reg_domain = nrf_wifi_reg_domain,
788789
.get_power_save_config = nrf_wifi_get_power_save_config,
790+
.req_dms = nrf_wifi_req_dms,
789791
#endif /* CONFIG_NRF700X_STA_MODE */
790792
#ifdef CONFIG_NRF700X_SYSTEM_MODE
791793
.mode = nrf_wifi_mode,

drivers/wifi/nrf700x/src/wifi_mgmt.c

Lines changed: 168 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,20 @@ int nrf_wifi_set_twt(const struct device *dev,
508508
twt_params->flow_id >= WIFI_MAX_TWT_FLOWS) {
509509
LOG_ERR("%s: Invalid flow id: %d",
510510
__func__, twt_params->flow_id);
511-
twt_params->fail_reason = WIFI_TWT_FAIL_INVALID_FLOW_ID;
511+
twt_params->fail_reason = WIFI_FAIL_INVALID_FLOW_ID;
512512
goto out;
513513
}
514514

515515
switch (twt_params->operation) {
516516
case WIFI_TWT_SETUP:
517517
if (vif_ctx_zep->twt_flow_in_progress_map & BIT(twt_params->flow_id)) {
518-
twt_params->fail_reason = WIFI_TWT_FAIL_OPERATION_IN_PROGRESS;
518+
twt_params->fail_reason = WIFI_FAIL_OPERATION_IN_PROGRESS;
519519
goto out;
520520
}
521521

522522
if (twt_params->setup_cmd == WIFI_TWT_SETUP_CMD_REQUEST) {
523523
if (vif_ctx_zep->twt_flows_map & BIT(twt_params->flow_id)) {
524-
twt_params->fail_reason = WIFI_TWT_FAIL_FLOW_ALREADY_EXISTS;
524+
twt_params->fail_reason = WIFI_FAIL_FLOW_ALREADY_EXISTS;
525525
goto out;
526526
}
527527
}
@@ -559,7 +559,7 @@ int nrf_wifi_set_twt(const struct device *dev,
559559

560560
if (!twt_params->teardown.teardown_all) {
561561
if (!(vif_ctx_zep->twt_flows_map & BIT(twt_params->flow_id))) {
562-
twt_params->fail_reason = WIFI_TWT_FAIL_INVALID_FLOW_ID;
562+
twt_params->fail_reason = WIFI_FAIL_INVALID_FLOW_ID;
563563
goto out;
564564
}
565565
start_flow_id = twt_params->flow_id;
@@ -948,3 +948,167 @@ int nrf_wifi_filter(const struct device *dev,
948948
return ret;
949949
}
950950
#endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */
951+
952+
static void nrf_wifi_dms_update_internal_state(struct nrf_wifi_vif_ctx_zep *vif_ctx_zep,
953+
bool add, unsigned char dmsid)
954+
{
955+
if (add) {
956+
vif_ctx_zep->dms_id_map |= BIT(dmsid);
957+
vif_ctx_zep->dms_id_in_progress_map &= ~BIT(dmsid);
958+
} else {
959+
vif_ctx_zep->dms_id_map &= ~BIT(dmsid);
960+
}
961+
}
962+
963+
int nrf_wifi_req_dms(const struct device *dev,
964+
struct wifi_dms_params *dms_params)
965+
{
966+
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
967+
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
968+
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
969+
struct nrf_wifi_umac_config_dms_info dms_info = {0};
970+
int ret = -1;
971+
972+
if (!dev || !dms_params) {
973+
LOG_ERR("%s: dev or dms_params is NULL", __func__);
974+
return ret;
975+
}
976+
977+
vif_ctx_zep = dev->data;
978+
979+
if (!vif_ctx_zep) {
980+
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
981+
return ret;
982+
}
983+
984+
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;
985+
986+
if (!rpu_ctx_zep) {
987+
LOG_ERR("%s: rpu_ctx_zep is NULL", __func__);
988+
return ret;
989+
}
990+
991+
k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);
992+
if (!rpu_ctx_zep->rpu_ctx) {
993+
LOG_DBG("%s: RPU context not initialized", __func__);
994+
goto out;
995+
}
996+
997+
switch (dms_params->operation) {
998+
case WIFI_DMS_REQ_ADD:
999+
if (vif_ctx_zep->dms_id_in_progress_map & BIT(dms_params->dmsid)) {
1000+
dms_params->fail_reason = WIFI_FAIL_OPERATION_IN_PROGRESS;
1001+
goto out;
1002+
}
1003+
1004+
if (dms_params->operation == WIFI_DMS_REQ_ADD) {
1005+
if (vif_ctx_zep->dms_id_map & BIT(dms_params->dmsid)) {
1006+
dms_params->fail_reason = WIFI_FAIL_FLOW_ALREADY_EXISTS;
1007+
goto out;
1008+
}
1009+
}
1010+
1011+
dms_info.req_type = NRF_WIFI_DMS_REQ_ADD;
1012+
break;
1013+
case WIFI_DMS_REQ_REMOVE:
1014+
if (!(vif_ctx_zep->dms_id_map & BIT(dms_params->dmsid))) {
1015+
dms_params->fail_reason = WIFI_FAIL_INVALID_DMS_ID;
1016+
goto out;
1017+
}
1018+
dms_info.req_type = NRF_WIFI_DMS_REQ_REMOVE;
1019+
dms_info.dmsid = dms_params->dmsid;
1020+
break;
1021+
case WIFI_DMS_REQ_CHANGE:
1022+
if (vif_ctx_zep->dms_id_in_progress_map & BIT(dms_params->dmsid)) {
1023+
dms_params->fail_reason = WIFI_FAIL_OPERATION_IN_PROGRESS;
1024+
goto out;
1025+
}
1026+
1027+
if (!(vif_ctx_zep->dms_id_map & BIT(dms_params->dmsid))) {
1028+
dms_params->fail_reason = WIFI_FAIL_INVALID_DMS_ID;
1029+
goto out;
1030+
}
1031+
dms_info.req_type = NRF_WIFI_DMS_REQ_CHANGE;
1032+
break;
1033+
default:
1034+
LOG_ERR("Unknown DMS operation");
1035+
status = NRF_WIFI_STATUS_FAIL;
1036+
goto out;
1037+
}
1038+
1039+
dms_info.dmsid = dms_params->dmsid;
1040+
dms_info.dialog_token = dms_params->dialog_token;
1041+
dms_info.up = dms_params->tclas_elem.up;
1042+
dms_info.tclas_type = dms_params->tclas_elem.classifier_info.type;
1043+
dms_info.tclas_mask = dms_params->tclas_elem.classifier_info.mask;
1044+
dms_info.version = dms_params->tclas_elem.classifier_info.param_info.version;
1045+
dms_info.src_ip_addr = dms_params->tclas_elem.classifier_info.param_info.src_ip_addr;
1046+
dms_info.src_port = dms_params->tclas_elem.classifier_info.param_info.src_port;
1047+
dms_info.dest_ip_addr = dms_params->tclas_elem.classifier_info.param_info.dest_ip_addr;
1048+
dms_info.dest_port = dms_params->tclas_elem.classifier_info.param_info.dest_port;
1049+
dms_info.dscp = dms_params->tclas_elem.classifier_info.param_info.dscp;
1050+
dms_info.protocol = dms_params->tclas_elem.classifier_info.param_info.protocol;
1051+
1052+
status = nrf_wifi_fmac_req_dms(rpu_ctx_zep->rpu_ctx,
1053+
vif_ctx_zep->vif_idx,
1054+
&dms_info);
1055+
1056+
if (status != NRF_WIFI_STATUS_SUCCESS) {
1057+
LOG_ERR("%s: nrf_wifi_req_dms %s failed",
1058+
__func__,
1059+
(dms_params->operation == WIFI_DMS_REQ_ADD) ? "add" :
1060+
(dms_params->operation == WIFI_DMS_REQ_REMOVE) ? "remove" : "change");
1061+
goto out;
1062+
}
1063+
1064+
ret = 0;
1065+
out:
1066+
k_mutex_unlock(&vif_ctx_zep->vif_lock);
1067+
return ret;
1068+
}
1069+
1070+
void nrf_wifi_event_proc_dms_zep(void *vif_ctx,
1071+
struct nrf_wifi_umac_cmd_config_dms *dms_info,
1072+
unsigned int event_len)
1073+
{
1074+
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
1075+
struct wifi_dms_params dms_params;
1076+
1077+
if (!vif_ctx || !dms_info) {
1078+
return;
1079+
}
1080+
1081+
vif_ctx_zep = vif_ctx;
1082+
1083+
dms_params.dmsid = dms_info->info.dmsid;
1084+
dms_params.dialog_token = dms_info->info.dialog_token;
1085+
dms_params.tclas_elem.up = dms_info->info.up;
1086+
dms_params.tclas_elem.classifier_info.param_info.version = dms_info->info.version;
1087+
dms_params.tclas_elem.classifier_info.param_info.src_ip_addr = dms_info->info.src_ip_addr;
1088+
dms_params.tclas_elem.classifier_info.param_info.src_port = dms_info->info.src_port;
1089+
dms_params.tclas_elem.classifier_info.param_info.dest_ip_addr = dms_info->info.dest_ip_addr;
1090+
dms_params.tclas_elem.classifier_info.param_info.dest_port = dms_info->info.dest_port;
1091+
dms_params.tclas_elem.classifier_info.param_info.dscp = dms_info->info.dscp;
1092+
dms_params.tclas_elem.classifier_info.param_info.protocol = dms_info->info.protocol;
1093+
dms_params.tclas_elem.classifier_info.type = dms_info->info.tclas_type;
1094+
dms_params.tclas_elem.classifier_info.mask = dms_info->info.tclas_mask;
1095+
1096+
switch(dms_info->event_type) {
1097+
case NRF_WIFI_DMS_EVENT_ACCEPT:
1098+
dms_params.operation = WIFI_DMS_REQ_ADD;
1099+
if (dms_info->dms_resp_status == 0) {
1100+
nrf_wifi_dms_update_internal_state(vif_ctx_zep, true, dms_params.dmsid);
1101+
}
1102+
break;
1103+
case NRF_WIFI_DMS_EVENT_REJECT:
1104+
break;
1105+
case NRF_WIFI_DMS_EVENT_TERMINATE:
1106+
nrf_wifi_dms_update_internal_state(vif_ctx_zep, false, dms_params.dmsid);
1107+
break;
1108+
case NRF_WIFI_DMS_EVENT_INVALID:
1109+
LOG_ERR("Unknown DMS event received");
1110+
break;
1111+
}
1112+
1113+
wifi_mgmt_raise_dms_event(vif_ctx_zep->zep_net_if_ctx, &dms_params);
1114+
}

modules/hostap/src/supp_api.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,19 @@ int z_wpa_supplicant_set_bss_max_idle_period(const struct device *dev,
800800
return ret;
801801
}
802802

803+
int z_wpa_supplicant_req_dms(const struct device *dev,
804+
struct wifi_dms_params *params)
805+
{
806+
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_mgmt_api(dev);
807+
808+
if (!wifi_mgmt_api || !wifi_mgmt_api->req_dms) {
809+
wpa_printf(MSG_ERROR, "Request DMS ops not supported");
810+
return -ENOTSUP;
811+
}
812+
813+
return wifi_mgmt_api->req_dms(dev, params);
814+
}
815+
803816
#ifdef CONFIG_AP
804817
int z_wpa_supplicant_ap_enable(const struct device *dev,
805818
struct wifi_connect_req_params *params)

modules/hostap/src/supp_api.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ int z_wpa_supplicant_channel(const struct device *dev,
151151
int z_wpa_supplicant_set_bss_max_idle_period(const struct device *dev,
152152
unsigned short bss_max_idle_period);
153153

154+
/**
155+
* @brief Req Wi-Fi DMS operation
156+
*
157+
* @param dev Wi-Fi interface name to use
158+
* @param params DMS parameters for operation
159+
* @return 0 for OK; -1 for ERROR
160+
*/
161+
int z_wpa_supplicant_req_dms(const struct device *dev,
162+
struct wifi_dms_params *params);
154163
#ifdef CONFIG_AP
155164
/**
156165
* @brief Set Wi-Fi AP configuration

modules/hostap/src/supp_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static const struct wifi_mgmt_ops wpa_supp_ops = {
8484
.filter = z_wpa_supplicant_filter,
8585
.channel = z_wpa_supplicant_channel,
8686
.set_bss_max_idle_period = z_wpa_supplicant_set_bss_max_idle_period,
87+
.req_dms = z_wpa_supplicant_req_dms,
8788
#ifdef CONFIG_AP
8889
.ap_enable = z_wpa_supplicant_ap_enable,
8990
.ap_disable = z_wpa_supplicant_ap_disable,

0 commit comments

Comments
 (0)