From ab9c7479e472afa668fc8a503dbaaece381a09da Mon Sep 17 00:00:00 2001 From: Nachiket Kukade Date: Wed, 6 Feb 2019 19:02:38 +0530 Subject: [PATCH] qcacmn: Add modules to support new NDP command and event Add modules and API's to issue command WMI_NDP_CMDID. This command, for now, can request Firmware to terminate all NDP's associated with the given vdev. Add module that extracts event information from event WMI_NDP_EVENTID. This event acts as a response to command WMI_NDP_CMDID, and carries NDP related status information for the host. Extract mac_id from the updated TLV of NDP confirm and schedule update events. Add modules and API's to support new NDP command and event. Change-Id: Ibf6312cb3669b5e62ada3f4ad852be87f14ae09f CRs-Fixed: 2384535 --- .../inc/wlan_serialization_api.h | 1 + wmi/inc/wmi_unified_nan_api.h | 24 +++- wmi/inc/wmi_unified_param.h | 1 + wmi/inc/wmi_unified_priv.h | 4 + wmi/src/wmi_unified_nan_api.c | 22 +++- wmi/src/wmi_unified_nan_tlv.c | 108 ++++++++++++++++-- wmi/src/wmi_unified_tlv.c | 1 + 7 files changed, 147 insertions(+), 14 deletions(-) diff --git a/umac/cmn_services/serialization/inc/wlan_serialization_api.h b/umac/cmn_services/serialization/inc/wlan_serialization_api.h index c97d871e9d..6816264da3 100644 --- a/umac/cmn_services/serialization/inc/wlan_serialization_api.h +++ b/umac/cmn_services/serialization/inc/wlan_serialization_api.h @@ -167,6 +167,7 @@ enum wlan_serialization_cmd_type { WLAN_SER_CMD_NDP_INIT_REQ, WLAN_SER_CMD_NDP_RESP_REQ, WLAN_SER_CMD_NDP_DATA_END_INIT_REQ, + WLAN_SER_CMD_NDP_END_ALL_REQ, WLAN_SER_CMD_ADDTS, WLAN_SER_CMD_DELTS, WLAN_SER_CMD_TDLS_SEND_MGMT, diff --git a/wmi/inc/wmi_unified_nan_api.h b/wmi/inc/wmi_unified_nan_api.h index d45ecfa894..8de969f783 100644 --- a/wmi/inc/wmi_unified_nan_api.h +++ b/wmi/inc/wmi_unified_nan_api.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -77,6 +77,17 @@ wmi_unified_ndp_responder_req_cmd_send(void *wmi_hdl, QDF_STATUS wmi_unified_ndp_end_req_cmd_send(void *wmi_hdl, struct nan_datapath_end_req *req); +/** + * wmi_unified_terminate_all_ndps_req_cmd - api to request Firmware for + * termination of all NDP's associated with the given vdev id. + * @wmi_handle: wmi handle + * @vdev_id: vdev id + * + * Return: status of operation + */ +QDF_STATUS wmi_unified_terminate_all_ndps_req_cmd(wmi_unified_t wmi_handle, + uint32_t vdev_id); + /** * wmi_extract_ndp_initiator_rsp - api to extract initiator rsp from even buffer * @wmi_hdl: wmi handle @@ -170,4 +181,15 @@ wmi_extract_ndp_sch_update(wmi_unified_t wmi_handle, uint8_t *data, QDF_STATUS wmi_extract_nan_event_rsp(wmi_unified_t wmi_handle, void *evt_buf, struct nan_event_params *temp_evt_params, uint8_t **nan_msg_buf); + +/** + * wmi_extract_ndp_host_event - api to extract ndp event from event buffer + * @wmi_hdl: wmi handle + * @data: event buffer + * @evt: event buffer to populate + * + * Return: status of operation + */ +QDF_STATUS wmi_extract_ndp_host_event(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_datapath_host_event *evt); #endif /* _WMI_UNIFIED_NAN_API_H_ */ diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index be255ae870..ec8649ae0e 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -4715,6 +4715,7 @@ typedef enum { wmi_ndp_end_indication_event_id, wmi_ndp_end_rsp_event_id, wmi_ndl_schedule_update_event_id, + wmi_ndp_event_id, wmi_oem_response_event_id, wmi_peer_stats_info_event_id, wmi_pdev_chip_power_stats_event_id, diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 591cd7837d..f6c0483433 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1759,6 +1759,8 @@ QDF_STATUS (*send_ndp_responder_req_cmd)(wmi_unified_t wmi_handle, struct nan_datapath_responder_req *req); QDF_STATUS (*send_ndp_end_req_cmd)(wmi_unified_t wmi_handle, struct nan_datapath_end_req *req); +QDF_STATUS (*send_terminate_all_ndps_req_cmd)(wmi_unified_t wmi_handle, + uint32_t vdev_id); QDF_STATUS (*extract_ndp_initiator_rsp)(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_initiator_rsp *rsp); @@ -1774,6 +1776,8 @@ QDF_STATUS (*extract_ndp_end_ind)(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_end_indication_event **ind); QDF_STATUS (*extract_ndp_sch_update)(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_sch_update_event *ind); +QDF_STATUS (*extract_ndp_host_event)(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_datapath_host_event *evt); #endif /* WLAN_FEATURE_NAN */ QDF_STATUS (*send_obss_detection_cfg_cmd)(wmi_unified_t wmi_handle, diff --git a/wmi/src/wmi_unified_nan_api.c b/wmi/src/wmi_unified_nan_api.c index 5339b2cb23..d6ba01cf24 100644 --- a/wmi/src/wmi_unified_nan_api.c +++ b/wmi/src/wmi_unified_nan_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -79,6 +79,17 @@ QDF_STATUS wmi_unified_ndp_responder_req_cmd_send(void *wmi_hdl, return QDF_STATUS_E_FAILURE; } +QDF_STATUS wmi_unified_terminate_all_ndps_req_cmd(wmi_unified_t wmi_handle, + uint32_t vdev_id) +{ + if (wmi_handle->ops->send_terminate_all_ndps_req_cmd) + return wmi_handle->ops->send_terminate_all_ndps_req_cmd( + wmi_handle, + vdev_id); + + return QDF_STATUS_E_FAILURE; +} + QDF_STATUS wmi_unified_ndp_end_req_cmd_send(void *wmi_hdl, struct nan_datapath_end_req *req) { @@ -162,3 +173,12 @@ QDF_STATUS wmi_extract_ndp_sch_update(wmi_unified_t wmi_handle, uint8_t *data, return QDF_STATUS_E_FAILURE; } +QDF_STATUS wmi_extract_ndp_host_event(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_datapath_host_event *evt) +{ + if (wmi_handle->ops->extract_ndp_host_event) + return wmi_handle->ops->extract_ndp_host_event(wmi_handle, + data, evt); + + return QDF_STATUS_E_FAILURE; +} diff --git a/wmi/src/wmi_unified_nan_tlv.c b/wmi/src/wmi_unified_nan_tlv.c index d6a08513d7..402f5a779a 100644 --- a/wmi/src/wmi_unified_nan_tlv.c +++ b/wmi/src/wmi_unified_nan_tlv.c @@ -293,6 +293,47 @@ static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle, return ret; } +/** + * send_terminate_all_ndps_cmd_tlv() - send NDP Terminate for all NDP's + * associated with the given vdev id + * @wmi_handle: wmi handle + * @vdev_id: vdev id + * + * Return: QDF status + */ +static QDF_STATUS send_terminate_all_ndps_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t vdev_id) +{ + wmi_ndp_cmd_param *cmd; + wmi_buf_t wmi_buf; + uint32_t len; + QDF_STATUS status; + + WMI_LOGD(FL("Enter")); + + len = sizeof(*cmd); + wmi_buf = wmi_buf_alloc(wmi_handle, len); + if (!wmi_buf) + return QDF_STATUS_E_NOMEM; + + cmd = (wmi_ndp_cmd_param *)wmi_buf_data(wmi_buf); + + WMITLV_SET_HDR(&cmd->tlv_header, WMITLV_TAG_STRUC_wmi_ndp_cmd_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_cmd_param)); + + cmd->vdev_id = vdev_id; + cmd->ndp_disable = 1; + + wmi_mtrace(WMI_NDP_CMDID, NO_SESSION, 0); + status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len, WMI_NDP_CMDID); + if (QDF_IS_STATUS_ERROR(status)) { + WMI_LOGE("Failed to send NDP Terminate cmd: %d", status); + wmi_buf_free(wmi_buf); + } + + return status; +} + static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle, struct nan_datapath_initiator_req *ndp_req) { @@ -642,6 +683,31 @@ static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle, return status; } +static QDF_STATUS +extract_ndp_host_event_tlv(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_datapath_host_event *evt) +{ + WMI_NDP_EVENTID_param_tlvs *event; + wmi_ndp_event_param *fixed_params; + + event = (WMI_NDP_EVENTID_param_tlvs *)data; + fixed_params = event->fixed_param; + + evt->vdev = + wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc, + fixed_params->vdev_id, + WLAN_NAN_ID); + if (!evt->vdev) { + WMI_LOGE("vdev is null"); + return QDF_STATUS_E_INVAL; + } + + evt->ndp_termination_in_progress = + fixed_params->ndp_termination_in_progress ? true : false; + + return QDF_STATUS_SUCCESS; +} + static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_initiator_rsp *rsp) { @@ -839,11 +905,13 @@ static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle, } if (fixed_params->num_ndp_channels > event->num_ndp_channel_list || - fixed_params->num_ndp_channels > event->num_nss_list) { - WMI_LOGE(FL("NDP Ch count %d greater than NDP Ch TLV len (%d) or NSS TLV len (%d)"), + fixed_params->num_ndp_channels > event->num_nss_list || + fixed_params->num_ndp_channels > event->num_ndp_channel_info) { + WMI_LOGE(FL("NDP Ch count %d greater than NDP Ch TLV len(%d) or NSS TLV len(%d) or NDP Ch info(%d)"), fixed_params->num_ndp_channels, event->num_ndp_channel_list, - event->num_nss_list); + event->num_nss_list, + event->num_ndp_channel_info); return QDF_STATUS_E_INVAL; } @@ -872,15 +940,21 @@ static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle, } for (i = 0; i < rsp->num_channels; i++) { - rsp->ch[i].channel = event->ndp_channel_list[i].mhz; + rsp->ch[i].freq = event->ndp_channel_list[i].mhz; rsp->ch[i].nss = event->nss_list[i]; ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]); rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle, ch_mode); - WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"), - rsp->ch[i].channel, + WMI_LOGD(FL("Freq: %d, ch_mode: %d, nss: %d"), + rsp->ch[i].freq, rsp->ch[i].ch_width, rsp->ch[i].nss); + + if (wmi_service_enabled(wmi_handle, + wmi_service_ndi_dbs_support)) { + rsp->ch[i].mac_id = event->ndp_channel_info[i].mac_id; + WMI_LOGD("mac_id: %d", rsp->ch[i].mac_id); + } } if (event->ndp_transport_ip_param && @@ -1040,11 +1114,13 @@ static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle, fixed_params->num_ndp_instances); if (fixed_params->num_channels > event->num_ndl_channel_list || - fixed_params->num_channels > event->num_nss_list) { - WMI_LOGE(FL("Channel count %d greater than NDP Ch list TLV len (%d) or NSS list TLV len (%d)"), + fixed_params->num_channels > event->num_nss_list || + fixed_params->num_channels > event->num_ndp_channel_info) { + WMI_LOGE(FL("Channel count %d greater than NDP Ch list TLV len(%d) or NSS list TLV len(%d) or NDP Ch info(%d)"), fixed_params->num_channels, event->num_ndl_channel_list, - event->num_nss_list); + event->num_nss_list, + event->num_ndp_channel_info); return QDF_STATUS_E_INVAL; } if (fixed_params->num_ndp_instances > event->num_ndp_instance_list) { @@ -1084,15 +1160,21 @@ static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle, } for (i = 0; i < ind->num_channels; i++) { - ind->ch[i].channel = event->ndl_channel_list[i].mhz; + ind->ch[i].freq = event->ndl_channel_list[i].mhz; ind->ch[i].nss = event->nss_list[i]; ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]); ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle, ch_mode); - WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"), - ind->ch[i].channel, + WMI_LOGD(FL("Freq: %d, ch_mode: %d, nss: %d"), + ind->ch[i].freq, ind->ch[i].ch_width, ind->ch[i].nss); + + if (wmi_service_enabled(wmi_handle, + wmi_service_ndi_dbs_support)) { + ind->ch[i].mac_id = event->ndp_channel_info[i].mac_id; + WMI_LOGD("mac_id: %d", ind->ch[i].mac_id); + } } for (i = 0; i < fixed_params->num_ndp_instances; i++) @@ -1109,6 +1191,7 @@ void wmi_nan_attach_tlv(wmi_unified_t wmi_handle) ops->send_nan_req_cmd = send_nan_req_cmd_tlv; ops->send_nan_disable_req_cmd = send_nan_disable_req_cmd_tlv; ops->extract_nan_event_rsp = extract_nan_event_rsp_tlv; + ops->send_terminate_all_ndps_req_cmd = send_terminate_all_ndps_cmd_tlv; ops->send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv; ops->send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv; ops->send_ndp_end_req_cmd = nan_ndp_end_req_tlv; @@ -1119,4 +1202,5 @@ void wmi_nan_attach_tlv(wmi_unified_t wmi_handle) ops->extract_ndp_end_rsp = extract_ndp_end_rsp_tlv; ops->extract_ndp_end_ind = extract_ndp_end_ind_tlv; ops->extract_ndp_sch_update = extract_ndp_sch_update_tlv; + ops->extract_ndp_host_event = extract_ndp_host_event_tlv; } diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index a1696713a7..81204299f2 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -11499,6 +11499,7 @@ static void populate_tlv_events_id(uint32_t *event_ids) event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID; event_ids[wmi_ndl_schedule_update_event_id] = WMI_NDL_SCHEDULE_UPDATE_EVENTID; + event_ids[wmi_ndp_event_id] = WMI_NDP_EVENTID; event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID; event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;