diff --git a/wmi/inc/wmi_unified_nan_api.h b/wmi/inc/wmi_unified_nan_api.h index 07f500de5e..ee0fafd999 100644 --- a/wmi/inc/wmi_unified_nan_api.h +++ b/wmi/inc/wmi_unified_nan_api.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2020 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 @@ -111,6 +111,16 @@ wmi_extract_ndp_initiator_rsp(wmi_unified_t wmi_handle, uint8_t *data, QDF_STATUS wmi_extract_ndp_ind(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_indication_event *ind); +/** + * wmi_extract_nan_msg - api to extract ndp dmesg buffer to print logs + * @data: event buffer + * @msg: buffer to populate + * + * Return: status of operation + */ +QDF_STATUS wmi_extract_nan_msg(wmi_unified_t wmi_handle, uint8_t *data, + struct nan_dump_msg *msg); + /** * wmi_extract_ndp_confirm - api to extract ndp confim struct from even buffer * @wmi_hdl: wmi handle diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index c0bc79d523..30867a3f74 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -4526,6 +4526,7 @@ typedef enum { wmi_ndp_responder_rsp_event_id, wmi_ndp_end_indication_event_id, wmi_ndp_end_rsp_event_id, + wmi_nan_dmesg_event_id, wmi_ndl_schedule_update_event_id, wmi_ndp_event_id, wmi_oem_response_event_id, diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 664c04611d..90c6832c58 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1960,6 +1960,8 @@ QDF_STATUS (*extract_ndp_initiator_rsp)(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_initiator_rsp *rsp); QDF_STATUS (*extract_ndp_ind)(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_indication_event *ind); +QDF_STATUS (*extract_nan_msg)(uint8_t *data, + struct nan_dump_msg *msg); QDF_STATUS (*extract_ndp_confirm)(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_confirm_event *ev); QDF_STATUS (*extract_ndp_responder_rsp)(wmi_unified_t wmi_handle, diff --git a/wmi/src/wmi_unified_nan_api.c b/wmi/src/wmi_unified_nan_api.c index d4c5a2cd09..91953f8a12 100644 --- a/wmi/src/wmi_unified_nan_api.c +++ b/wmi/src/wmi_unified_nan_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2020 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 @@ -98,6 +98,16 @@ QDF_STATUS wmi_unified_ndp_end_req_cmd_send(wmi_unified_t wmi_handle, return QDF_STATUS_E_FAILURE; } +QDF_STATUS wmi_extract_nan_msg(wmi_unified_t wmi_handle, + uint8_t *data, + struct nan_dump_msg *msg) +{ + if (wmi_handle->ops->extract_nan_msg) + return wmi_handle->ops->extract_nan_msg(data, msg); + + return QDF_STATUS_E_FAILURE; +} + QDF_STATUS wmi_extract_ndp_initiator_rsp(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_initiator_rsp *rsp) { diff --git a/wmi/src/wmi_unified_nan_tlv.c b/wmi/src/wmi_unified_nan_tlv.c index 1eb6c79bfd..f972554952 100644 --- a/wmi/src/wmi_unified_nan_tlv.c +++ b/wmi/src/wmi_unified_nan_tlv.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2020 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 @@ -755,6 +755,29 @@ static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle, return QDF_STATUS_SUCCESS; } +#define MAX_NAN_MSG_LEN 200 + +static QDF_STATUS extract_nan_msg_tlv(uint8_t *data, + struct nan_dump_msg *msg) +{ + WMI_NAN_DMESG_EVENTID_param_tlvs *event; + wmi_nan_dmesg_event_fixed_param *fixed_params; + + event = (WMI_NAN_DMESG_EVENTID_param_tlvs *)data; + fixed_params = (wmi_nan_dmesg_event_fixed_param *)event->fixed_param; + if (!fixed_params->msg_len || + fixed_params->msg_len > MAX_NAN_MSG_LEN || + fixed_params->msg_len > event->num_msg) + return QDF_STATUS_E_FAILURE; + + msg->data_len = fixed_params->msg_len; + msg->msg = event->msg; + + msg->msg[fixed_params->msg_len - 1] = (uint8_t)'\0'; + + return QDF_STATUS_SUCCESS; +} + static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle, uint8_t *data, struct nan_datapath_indication_event *rsp) { @@ -1239,6 +1262,7 @@ void wmi_nan_attach_tlv(wmi_unified_t wmi_handle) ops->send_ndp_end_req_cmd = nan_ndp_end_req_tlv; ops->extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv; ops->extract_ndp_ind = extract_ndp_ind_tlv; + ops->extract_nan_msg = extract_nan_msg_tlv, ops->extract_ndp_confirm = extract_ndp_confirm_tlv; ops->extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv; ops->extract_ndp_end_rsp = extract_ndp_end_rsp_tlv; diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 7868b04f21..c94b4ca01e 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -14047,6 +14047,8 @@ static void populate_tlv_events_id(uint32_t *event_ids) event_ids[wmi_oem_data_event_id] = WMI_OEM_DATA_EVENTID; event_ids[wmi_mgmt_offload_data_event_id] = WMI_VDEV_MGMT_OFFLOAD_EVENTID; + event_ids[wmi_nan_dmesg_event_id] = + WMI_NAN_DMESG_EVENTID; event_ids[wmi_pdev_multi_vdev_restart_response_event_id] = WMI_PDEV_MULTIPLE_VDEV_RESTART_RESP_EVENTID; event_ids[wmi_roam_pmkid_request_event_id] =