diff --git a/qdf/inc/qdf_types.h b/qdf/inc/qdf_types.h index c2af0dc90f..904bfc5097 100644 --- a/qdf/inc/qdf_types.h +++ b/qdf/inc/qdf_types.h @@ -535,6 +535,7 @@ typedef enum { * @QDF_BTAMP_MODE: BTAMP mode * @QDF_AHDEMO_MODE: AHDEMO mode * @QDF_TDLS_MODE: TDLS device mode + * @QDF_NAN_DISC_MODE: NAN Discovery device mode * @QDF_MAX_NO_OF_MODE: Max place holder * * These are generic IDs that identify the various roles @@ -557,6 +558,7 @@ enum QDF_OPMODE { QDF_BTAMP_MODE, QDF_AHDEMO_MODE, QDF_TDLS_MODE, + QDF_NAN_DISC_MODE, /* Add new OP Modes to qdf_opmode_str as well */ diff --git a/wmi/inc/wmi_unified_nan_api.h b/wmi/inc/wmi_unified_nan_api.h index 77d8225fbf..d45ecfa894 100644 --- a/wmi/inc/wmi_unified_nan_api.h +++ b/wmi/inc/wmi_unified_nan_api.h @@ -25,6 +25,26 @@ #include +/** + * wmi_unified_nan_req_cmd() - to send nan request to target + * @wmi_handle: wmi handle + * @nan_req: request data which will be non-null + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_nan_req_cmd(wmi_unified_t wmi_handle, + struct nan_msg_params *nan_req); + +/** + * wmi_unified_nan_disable_req_cmd() - to send nan disable request to target + * @wmi_handle: wmi handle + * @nan_req: pointer to NAN Disable request structure + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_nan_disable_req_cmd(wmi_unified_t wmi_handle, + struct nan_disable_req *nan_req); + /** * wmi_unified_ndp_initiator_req_cmd_send - api to send initiator request to FW * @wmi_hdl: wmi handle @@ -32,8 +52,9 @@ * * Return: status of operation */ -QDF_STATUS wmi_unified_ndp_initiator_req_cmd_send(void *wmi_hdl, - struct nan_datapath_initiator_req *req); +QDF_STATUS +wmi_unified_ndp_initiator_req_cmd_send(void *wmi_hdl, + struct nan_datapath_initiator_req *req); /** * wmi_unified_ndp_responder_req_cmd_send - api to send responder request to FW @@ -42,8 +63,9 @@ QDF_STATUS wmi_unified_ndp_initiator_req_cmd_send(void *wmi_hdl, * * Return: status of operation */ -QDF_STATUS wmi_unified_ndp_responder_req_cmd_send(void *wmi_hdl, - struct nan_datapath_responder_req *req); +QDF_STATUS +wmi_unified_ndp_responder_req_cmd_send(void *wmi_hdl, + struct nan_datapath_responder_req *req); /** * wmi_unified_ndp_end_req_cmd_send - api to send end request to FW @@ -63,8 +85,9 @@ QDF_STATUS wmi_unified_ndp_end_req_cmd_send(void *wmi_hdl, * * Return: status of operation */ -QDF_STATUS wmi_extract_ndp_initiator_rsp(wmi_unified_t wmi_handle, - uint8_t *data, struct nan_datapath_initiator_rsp *rsp); +QDF_STATUS +wmi_extract_ndp_initiator_rsp(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_datapath_initiator_rsp *rsp); /** * wmi_extract_ndp_ind - api to extract ndp indication struct from even buffer @@ -96,8 +119,9 @@ QDF_STATUS wmi_extract_ndp_confirm(wmi_unified_t wmi_handle, uint8_t *data, * * Return: status of operation */ -QDF_STATUS wmi_extract_ndp_responder_rsp(wmi_unified_t wmi_handle, - uint8_t *data, struct nan_datapath_responder_rsp *rsp); +QDF_STATUS +wmi_extract_ndp_responder_rsp(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_datapath_responder_rsp *rsp); /** * wmi_extract_ndp_end_rsp - api to extract ndp end rsp from even buffer @@ -118,7 +142,8 @@ QDF_STATUS wmi_extract_ndp_end_rsp(wmi_unified_t wmi_handle, uint8_t *data, * * Return: status of operation */ -QDF_STATUS wmi_extract_ndp_end_ind(wmi_unified_t wmi_handle, uint8_t *data, +QDF_STATUS +wmi_extract_ndp_end_ind(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_end_indication_event **ind); /** @@ -129,7 +154,20 @@ QDF_STATUS wmi_extract_ndp_end_ind(wmi_unified_t wmi_handle, uint8_t *data, * * Return: status of operation */ -QDF_STATUS wmi_extract_ndp_sch_update(wmi_unified_t wmi_handle, uint8_t *data, - struct nan_datapath_sch_update_event *ind); +QDF_STATUS +wmi_extract_ndp_sch_update(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_datapath_sch_update_event *ind); +/** + * wmi_extract_nan_event_rsp - api to extract nan event into event parameters + * @wmi_hdl: wmi handle + * @wvt_buf: pointer to the event buffer + * @temp_evt_params: Pointer to a temporary parameters structure to populate + * @nan_msg_buf: Pointer to the NAN Message buffer encapsulated in the event + * + * Return: status of operation + */ +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); #endif /* _WMI_UNIFIED_NAN_API_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 1e8947280e..0a0e9cc5d6 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -832,7 +832,14 @@ QDF_STATUS (*send_set_auto_shutdown_timer_cmd)(wmi_unified_t wmi_handle, #ifdef WLAN_FEATURE_NAN QDF_STATUS (*send_nan_req_cmd)(wmi_unified_t wmi_handle, - struct nan_req_params *nan_req); + struct nan_msg_params *nan_req); + +QDF_STATUS (*send_nan_disable_req_cmd)(wmi_unified_t wmi_handle, + struct nan_disable_req *nan_msg); + +QDF_STATUS (*extract_nan_event_rsp)(wmi_unified_t wmi_handle, void *evt_buf, + struct nan_event_params *evt_params, + uint8_t **msg_buf); #endif QDF_STATUS (*send_process_ch_avoid_update_cmd)(wmi_unified_t wmi_handle); @@ -2239,20 +2246,6 @@ static inline void wmi_sta_attach_tlv(struct wmi_unified *wmi_handle) } #endif -#ifdef WLAN_FEATURE_NAN -/** - * wmi_nan_feature_attach_tlv() - set NAN feature wmi callback - * @wmi_handle: wmi handle - * - * Return: none - */ -void wmi_nan_feature_attach_tlv(struct wmi_unified *wmi_handle); -#else -static inline void wmi_nan_feature_attach_tlv(struct wmi_unified *wmi_handle) -{ -} -#endif - /** * wmi_align() - provides word aligned parameter * @param: parameter to be aligned diff --git a/wmi/inc/wmi_unified_sta_api.h b/wmi/inc/wmi_unified_sta_api.h index 1fb4cfd515..8dae9b09b9 100644 --- a/wmi/inc/wmi_unified_sta_api.h +++ b/wmi/inc/wmi_unified_sta_api.h @@ -146,18 +146,6 @@ QDF_STATUS wmi_unified_nat_keepalive_en_cmd(void *wmi_hdl, uint8_t vdev_id); QDF_STATUS wmi_unified_wlm_latency_level_cmd(void *wmi_hdl, struct wlm_latency_level_param *param); -#ifdef WLAN_FEATURE_NAN -/** - * wmi_unified_nan_req_cmd() - to send nan request to target - * @wmi_handle: wmi handle - * @nan_req: request data which will be non-null - * - * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure - */ -QDF_STATUS wmi_unified_nan_req_cmd(void *wmi_hdl, - struct nan_req_params *nan_req); -#endif - /** * wmi_unified_process_set_ie_info_cmd() - Function to send IE info to firmware * @wmi_handle: Pointer to WMi handle diff --git a/wmi/inc/wmi_unified_sta_param.h b/wmi/inc/wmi_unified_sta_param.h index 8589e1d757..d19747da95 100644 --- a/wmi/inc/wmi_unified_sta_param.h +++ b/wmi/inc/wmi_unified_sta_param.h @@ -99,16 +99,6 @@ struct wlm_latency_level_param { uint16_t vdev_id; }; -/** - * struct nan_req_params - NAN request params - * @request_data_len: request data length - * @request_data: request data - */ -struct nan_req_params { - uint16_t request_data_len; - uint8_t request_data[]; -}; - #ifndef CONVERGED_TDLS_ENABLE /** * struct tdls_chan_switch_params - channel switch parameter structure diff --git a/wmi/src/wmi_unified_nan_api.c b/wmi/src/wmi_unified_nan_api.c index 69b8f2b80a..5339b2cb23 100644 --- a/wmi/src/wmi_unified_nan_api.c +++ b/wmi/src/wmi_unified_nan_api.c @@ -22,6 +22,39 @@ #include #include +QDF_STATUS wmi_unified_nan_req_cmd(wmi_unified_t wmi_handle, + struct nan_msg_params *nan_msg) +{ + if (wmi_handle->ops->send_nan_req_cmd) + return wmi_handle->ops->send_nan_req_cmd(wmi_handle, + nan_msg); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS wmi_unified_nan_disable_req_cmd(wmi_unified_t wmi_handle, + struct nan_disable_req *nan_msg) +{ + if (wmi_handle->ops->send_nan_disable_req_cmd) + return wmi_handle->ops->send_nan_disable_req_cmd(wmi_handle, + nan_msg); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS wmi_extract_nan_event_rsp(wmi_unified_t wmi_handle, void *evt_buf, + struct nan_event_params *nan_evt_params, + uint8_t **nan_msg_buf) +{ + if (wmi_handle->ops->extract_nan_event_rsp) + return wmi_handle->ops->extract_nan_event_rsp(wmi_handle, + evt_buf, + nan_evt_params, + nan_msg_buf); + + return QDF_STATUS_E_FAILURE; +} + QDF_STATUS wmi_unified_ndp_initiator_req_cmd_send(void *wmi_hdl, struct nan_datapath_initiator_req *req) { diff --git a/wmi/src/wmi_unified_nan_tlv.c b/wmi/src/wmi_unified_nan_tlv.c index 27a38953ec..a93ec81156 100644 --- a/wmi/src/wmi_unified_nan_tlv.c +++ b/wmi/src/wmi_unified_nan_tlv.c @@ -22,6 +22,272 @@ #include #include #include +#include + +static QDF_STATUS +extract_nan_event_rsp_tlv(wmi_unified_t wmi_handle, void *evt_buf, + struct nan_event_params *evt_params, + uint8_t **msg_buf) +{ + WMI_NAN_EVENTID_param_tlvs *event; + wmi_nan_event_hdr *nan_rsp_event_hdr; + nan_msg_header_t *nan_msg_hdr; + wmi_nan_event_info *nan_evt_info; + + /* + * This is how received evt looks like + * + * <-------------------- evt_buf -----------------------------------> + * + * <--wmi_nan_event_hdr--><---WMI_TLV_HDR_SIZE---><----- data --------> + * + * +-----------+---------+-----------------------+--------------------+- + * | tlv_header| data_len| WMITLV_TAG_ARRAY_BYTE | nan_rsp_event_data | + * +-----------+---------+-----------------------+--------------------+- + * + * (Only for NAN Enable Resp) + * <--wmi_nan_event_info--> + * +-----------+-----------+ + * | tlv_header| event_info| + * +-----------+-----------+ + * + */ + + event = (WMI_NAN_EVENTID_param_tlvs *)evt_buf; + nan_rsp_event_hdr = event->fixed_param; + + /* Actual data may include some padding, so data_len <= num_data */ + if (nan_rsp_event_hdr->data_len > event->num_data) { + WMI_LOGE("%s: Provided NAN event length(%d) exceeding actual length(%d)!", + __func__, nan_rsp_event_hdr->data_len, + event->num_data); + return QDF_STATUS_E_INVAL; + } + evt_params->buf_len = nan_rsp_event_hdr->data_len; + *msg_buf = event->data; + + if (nan_rsp_event_hdr->data_len < sizeof(nan_msg_header_t) || + nan_rsp_event_hdr->data_len > (WMI_SVC_MSG_MAX_SIZE - + WMI_TLV_HDR_SIZE)) { + WMI_LOGE("%s: Invalid NAN event data length(%d)!", __func__, + nan_rsp_event_hdr->data_len); + return QDF_STATUS_E_INVAL; + } + nan_msg_hdr = (nan_msg_header_t *)event->data; + + if (!wmi_service_enabled(wmi_handle, wmi_service_nan_dbs_support)) { + evt_params->evt_type = nan_event_id_generic_rsp; + return QDF_STATUS_SUCCESS; + } + + switch (nan_msg_hdr->msg_id) { + case NAN_MSG_ID_ENABLE_RSP: + nan_evt_info = event->event_info; + evt_params->evt_type = nan_event_id_enable_rsp; + evt_params->mac_id = nan_evt_info->mac_id; + evt_params->is_nan_enable_success = (nan_evt_info->status == 0); + break; + case NAN_MSG_ID_DISABLE_IND: + evt_params->evt_type = nan_event_id_disable_ind; + break; + case NAN_MSG_ID_ERROR_RSP: + evt_params->evt_type = nan_event_id_error_rsp; + break; + default: + evt_params->evt_type = nan_event_id_generic_rsp; + break; + } + + return QDF_STATUS_SUCCESS; +} + +/** + * send_nan_disable_req_cmd_tlv() - to send nan disable request to target + * @wmi_handle: wmi handle + * @nan_msg: request data which will be non-null + * + * Return: CDF status + */ +static QDF_STATUS send_nan_disable_req_cmd_tlv(wmi_unified_t wmi_handle, + struct nan_disable_req *nan_msg) +{ + QDF_STATUS ret; + wmi_nan_cmd_param *cmd; + wmi_nan_host_config_param *cfg; + wmi_buf_t buf; + /* Initialize with minimum length required, which is Scenario 2*/ + uint16_t len = sizeof(*cmd) + sizeof(*cfg) + 2 * WMI_TLV_HDR_SIZE; + uint16_t nan_data_len, nan_data_len_aligned = 0; + uint8_t *buf_ptr; + + /* + * Scenario 1: NAN Disable with NAN msg data from upper layers + * + * <-----nan cmd param-----><-- WMI_TLV_HDR_SIZE --><--- data ----> + * +------------+----------+-----------------------+--------------+ + * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_msg_data | + * +------------+----------+-----------------------+--------------+ + * + * <-- WMI_TLV_HDR_SIZE --><------nan host config params-----> + * -+-----------------------+---------------------------------+ + * | WMITLV_TAG_ARRAY_STRUC| tlv_header | 2g/5g disable flags| + * -+-----------------------+---------------------------------+ + * + * Scenario 2: NAN Disable without any NAN msg data from upper layers + * + * <------nan cmd param------><--WMI_TLV_HDR_SIZE--><--WMI_TLV_HDR_SI + * +------------+------------+----------------------+---------------- + * | tlv_header | data_len=0 | WMITLV_TAG_ARRAY_BYTE| WMITLV_TAG_ARRA + * +------------+------------+----------------------+---------------- + * + * ZE----><------nan host config params-----> + * -------+---------------------------------+ + * Y_STRUC| tlv_header | 2g/5g disable flags| + * -------+---------------------------------+ + */ + + if (!nan_msg) { + WMI_LOGE("%s:nan req is not valid", __func__); + return QDF_STATUS_E_FAILURE; + } + + nan_data_len = nan_msg->params.request_data_len; + + if (nan_data_len) { + nan_data_len_aligned = roundup(nan_data_len, sizeof(uint32_t)); + if (nan_data_len_aligned < nan_data_len) { + WMI_LOGE("%s: Int overflow while rounding up data_len", + __func__); + return QDF_STATUS_E_FAILURE; + } + + if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE + - WMI_TLV_HDR_SIZE) { + WMI_LOGE("%s: nan_data_len exceeding wmi_max_msg_size", + __func__); + return QDF_STATUS_E_FAILURE; + } + + len += nan_data_len_aligned; + } + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) + return QDF_STATUS_E_NOMEM; + + buf_ptr = (uint8_t *)wmi_buf_data(buf); + cmd = (wmi_nan_cmd_param *)buf_ptr; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_nan_cmd_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param)); + + cmd->data_len = nan_data_len; + WMI_LOGD("%s: nan data len value is %u", __func__, nan_data_len); + buf_ptr += sizeof(wmi_nan_cmd_param); + + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned); + buf_ptr += WMI_TLV_HDR_SIZE; + + if (nan_data_len) { + qdf_mem_copy(buf_ptr, nan_msg->params.request_data, + cmd->data_len); + buf_ptr += nan_data_len_aligned; + } + + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, + sizeof(wmi_nan_host_config_param)); + buf_ptr += WMI_TLV_HDR_SIZE; + + cfg = (wmi_nan_host_config_param *)buf_ptr; + WMITLV_SET_HDR(&cfg->tlv_header, + WMITLV_TAG_STRUC_wmi_nan_host_config_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_nan_host_config_param)); + cfg->nan_2g_disc_disable = nan_msg->disable_2g_discovery; + cfg->nan_5g_disc_disable = nan_msg->disable_5g_discovery; + + wmi_mtrace(WMI_NAN_CMDID, NO_SESSION, 0); + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_NAN_CMDID); + if (QDF_IS_STATUS_ERROR(ret)) { + WMI_LOGE("%s Failed to send set param command ret = %d", + __func__, ret); + wmi_buf_free(buf); + } + + return ret; +} + +/** + * send_nan_req_cmd_tlv() - to send nan request to target + * @wmi_handle: wmi handle + * @nan_msg: request data which will be non-null + * + * Return: CDF status + */ +static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle, + struct nan_msg_params *nan_msg) +{ + QDF_STATUS ret; + wmi_nan_cmd_param *cmd; + wmi_buf_t buf; + uint16_t len = sizeof(*cmd); + uint16_t nan_data_len, nan_data_len_aligned; + uint8_t *buf_ptr; + + /* + * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ----> + * +------------+----------+-----------------------+--------------+ + * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_msg_data | + * +------------+----------+-----------------------+--------------+ + */ + if (!nan_msg) { + WMI_LOGE("%s:nan req is not valid", __func__); + return QDF_STATUS_E_FAILURE; + } + nan_data_len = nan_msg->request_data_len; + nan_data_len_aligned = roundup(nan_msg->request_data_len, + sizeof(uint32_t)); + if (nan_data_len_aligned < nan_msg->request_data_len) { + WMI_LOGE("%s: integer overflow while rounding up data_len", + __func__); + return QDF_STATUS_E_FAILURE; + } + + if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) { + WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen", + __func__); + return QDF_STATUS_E_FAILURE; + } + + len += WMI_TLV_HDR_SIZE + nan_data_len_aligned; + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) + return QDF_STATUS_E_NOMEM; + + buf_ptr = (uint8_t *)wmi_buf_data(buf); + cmd = (wmi_nan_cmd_param *)buf_ptr; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_nan_cmd_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param)); + cmd->data_len = nan_msg->request_data_len; + WMI_LOGD("%s: The data len value is %u", __func__, + nan_msg->request_data_len); + buf_ptr += sizeof(wmi_nan_cmd_param); + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned); + buf_ptr += WMI_TLV_HDR_SIZE; + qdf_mem_copy(buf_ptr, nan_msg->request_data, cmd->data_len); + + wmi_mtrace(WMI_NAN_CMDID, NO_SESSION, 0); + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_NAN_CMDID); + if (QDF_IS_STATUS_ERROR(ret)) { + WMI_LOGE("%s Failed to send set param command ret = %d", + __func__, ret); + wmi_buf_free(buf); + } + + return ret; +} static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle, struct nan_datapath_initiator_req *ndp_req) @@ -846,6 +1112,9 @@ void wmi_nan_attach_tlv(wmi_unified_t wmi_handle) { struct wmi_ops *ops = wmi_handle->ops; + 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_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; diff --git a/wmi/src/wmi_unified_sta_api.c b/wmi/src/wmi_unified_sta_api.c index 5eb5affa80..91d1558a99 100644 --- a/wmi/src/wmi_unified_sta_api.c +++ b/wmi/src/wmi_unified_sta_api.c @@ -123,20 +123,6 @@ QDF_STATUS wmi_unified_wlm_latency_level_cmd(void *wmi_hdl, return QDF_STATUS_E_FAILURE; } -#ifdef WLAN_FEATURE_NAN -QDF_STATUS wmi_unified_nan_req_cmd(void *wmi_hdl, - struct nan_req_params *nan_req) -{ - wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; - - if (wmi_handle->ops->send_nan_req_cmd) - return wmi_handle->ops->send_nan_req_cmd(wmi_handle, - nan_req); - - return QDF_STATUS_E_FAILURE; -} -#endif - QDF_STATUS wmi_unified_process_set_ie_info_cmd(void *wmi_hdl, struct vdev_ie_info_param *ie_info) { diff --git a/wmi/src/wmi_unified_sta_tlv.c b/wmi/src/wmi_unified_sta_tlv.c index ba5a296b2c..327fc80bc1 100644 --- a/wmi/src/wmi_unified_sta_tlv.c +++ b/wmi/src/wmi_unified_sta_tlv.c @@ -502,87 +502,6 @@ static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle, return 0; } -#ifdef WLAN_FEATURE_NAN -/** - * send_nan_req_cmd_tlv() - to send nan request to target - * @wmi_handle: wmi handle - * @nan_req: request data which will be non-null - * - * Return: CDF status - */ -static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle, - struct nan_req_params *nan_req) -{ - QDF_STATUS ret; - wmi_nan_cmd_param *cmd; - wmi_buf_t buf; - uint16_t len = sizeof(*cmd); - uint16_t nan_data_len, nan_data_len_aligned; - uint8_t *buf_ptr; - - /* - * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ----> - * +------------+----------+-----------------------+--------------+ - * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data | - * +------------+----------+-----------------------+--------------+ - */ - if (!nan_req) { - WMI_LOGE("%s:nan req is not valid", __func__); - return QDF_STATUS_E_FAILURE; - } - nan_data_len = nan_req->request_data_len; - nan_data_len_aligned = roundup(nan_req->request_data_len, - sizeof(uint32_t)); - if (nan_data_len_aligned < nan_req->request_data_len) { - WMI_LOGE("%s: integer overflow while rounding up data_len", - __func__); - return QDF_STATUS_E_FAILURE; - } - - if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) { - WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen", - __func__); - return QDF_STATUS_E_FAILURE; - } - - len += WMI_TLV_HDR_SIZE + nan_data_len_aligned; - buf = wmi_buf_alloc(wmi_handle, len); - if (!buf) { - return QDF_STATUS_E_NOMEM; - } - buf_ptr = (uint8_t *) wmi_buf_data(buf); - cmd = (wmi_nan_cmd_param *) buf_ptr; - WMITLV_SET_HDR(&cmd->tlv_header, - WMITLV_TAG_STRUC_wmi_nan_cmd_param, - WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param)); - cmd->data_len = nan_req->request_data_len; - WMI_LOGD("%s: The data len value is %u", - __func__, nan_req->request_data_len); - buf_ptr += sizeof(wmi_nan_cmd_param); - WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned); - buf_ptr += WMI_TLV_HDR_SIZE; - qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len); - - wmi_mtrace(WMI_NAN_CMDID, NO_SESSION, 0); - ret = wmi_unified_cmd_send(wmi_handle, buf, len, - WMI_NAN_CMDID); - if (QDF_IS_STATUS_ERROR(ret)) { - WMI_LOGE("%s Failed to send set param command ret = %d", - __func__, ret); - wmi_buf_free(buf); - } - - return ret; -} - -void wmi_nan_feature_attach_tlv(struct wmi_unified *wmi_handle) -{ - struct wmi_ops *ops = wmi_handle->ops; - - ops->send_nan_req_cmd = send_nan_req_cmd_tlv; -} -#endif /* WLAN_FEATURE_NAN */ - #ifdef CONVERGED_TDLS_ENABLE /** * tdls_get_wmi_offchannel_mode - Get WMI tdls off channel mode @@ -2584,6 +2503,5 @@ void wmi_sta_attach_tlv(wmi_unified_t wmi_handle) wmi_tdls_attach_tlv(wmi_handle); wmi_disa_attach_tlv(wmi_handle); wmi_policy_mgr_attach_tlv(wmi_handle); - wmi_nan_feature_attach_tlv(wmi_handle); }