From 361892ec588aad5640d393ba11e09bfab3f9c734 Mon Sep 17 00:00:00 2001 From: Naveen Rawat Date: Thu, 26 Oct 2017 18:50:19 -0700 Subject: [PATCH 1/2] qcacmn: Add Wake timer pattern API Add WOW_TIMER_PATTERN to enable host to set wake timer in FW when required. Change-Id: Id37420ee8295d11fc8fe0f0fcc344d6ef31c315b CRs-Fixed: 2134108 --- wmi/inc/wmi_unified_api.h | 3 ++ wmi/inc/wmi_unified_priv.h | 3 ++ wmi/src/wmi_unified_api.c | 22 ++++++++++ wmi/src/wmi_unified_tlv.c | 88 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+) diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index 5c8505d9cae6..d8d84617bbcd 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -732,6 +732,9 @@ QDF_STATUS wmi_unified_egap_conf_params_cmd(void *wmi_hdl, QDF_STATUS wmi_unified_fw_profiling_data_cmd(void *wmi_hdl, uint32_t cmd, uint32_t value1, uint32_t value2); +QDF_STATUS wmi_unified_wow_timer_pattern_cmd(void *wmi_hdl, uint8_t vdev_id, + uint32_t cookie, uint32_t time); + QDF_STATUS wmi_unified_nat_keepalive_en_cmd(void *wmi_hdl, uint8_t vdev_id); QDF_STATUS wmi_unified_csa_offload_enable(void *wmi_hdl, uint8_t vdev_id); diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index a1caad378536..4fb977f14a89 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1388,6 +1388,9 @@ QDF_STATUS (*send_user_country_code_cmd)(wmi_unified_t wmi_handle, uint8_t pdev_id, struct cc_regdmn_s *rd); QDF_STATUS (*send_limit_off_chan_cmd)(wmi_unified_t wmi_handle, struct wmi_limit_off_chan_param *limit_off_chan_param); + +QDF_STATUS (*send_wow_timer_pattern_cmd)(wmi_unified_t wmi_handle, + uint8_t vdev_id, uint32_t cookie, uint32_t time); }; /* Forward declartion for psoc*/ diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 9d751c041169..6a222d28c659 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -2226,6 +2226,28 @@ QDF_STATUS wmi_unified_fw_profiling_data_cmd(void *wmi_hdl, return QDF_STATUS_E_FAILURE; } +/** + * wmi_unified_wow_timer_pattern_cmd() - set timer pattern tlv, so that firmware + * will wake up host after specified time is elapsed + * @wmi_handle: wmi handle + * @vdev_id: vdev id + * @cookie: value to identify reason why host set up wake call. + * @time: time in ms + * + * Return: QDF status + */ +QDF_STATUS wmi_unified_wow_timer_pattern_cmd(void *wmi_hdl, uint8_t vdev_id, + uint32_t cookie, uint32_t time) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_wow_timer_pattern_cmd) + return wmi_handle->ops->send_wow_timer_pattern_cmd(wmi_handle, + vdev_id, cookie, time); + + return QDF_STATUS_E_FAILURE; +} + /** * wmi_unified_nat_keepalive_en_cmd() - enable NAT keepalive filter * @wmi_handle: wmi handle diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index c41b7db42594..125c6bdfb6fd 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -8915,6 +8915,93 @@ send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle, return QDF_STATUS_SUCCESS; } +/** + * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware + * will wake up host after specified time is elapsed + * @wmi_handle: wmi handle + * @vdev_id: vdev id + * @cookie: value to identify reason why host set up wake call. + * @time: time in ms + * + * Return: QDF status + */ +static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t vdev_id, uint32_t cookie, uint32_t time) +{ + WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd; + wmi_buf_t buf; + uint8_t *buf_ptr; + int32_t len; + int ret; + + len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) + + WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) + + WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) + + WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) + + WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) + + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32) + + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMI_LOGE("%s: Failed allocate wmi buffer", __func__); + return QDF_STATUS_E_NOMEM; + } + + cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf); + buf_ptr = (uint8_t *) cmd; + + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (WMI_WOW_ADD_PATTERN_CMD_fixed_param)); + cmd->vdev_id = vdev_id; + cmd->pattern_id = cookie, + cmd->pattern_type = WOW_TIMER_PATTERN; + buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param); + + /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */ + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); + buf_ptr += WMI_TLV_HDR_SIZE; + + /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */ + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); + buf_ptr += WMI_TLV_HDR_SIZE; + + /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */ + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); + buf_ptr += WMI_TLV_HDR_SIZE; + + /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */ + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); + buf_ptr += WMI_TLV_HDR_SIZE; + + /* Fill TLV for pattern_info_timeout, and time value */ + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32)); + buf_ptr += WMI_TLV_HDR_SIZE; + *((A_UINT32 *) buf_ptr) = time; + buf_ptr += sizeof(A_UINT32); + + /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */ + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32)); + buf_ptr += WMI_TLV_HDR_SIZE; + *((A_UINT32 *) buf_ptr) = 0; + + WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d", + __func__, time, vdev_id); + + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_WOW_ADD_WAKE_PATTERN_CMDID); + if (ret) { + WMI_LOGE("%s: Failed to send wake timer pattern to fw", + __func__); + wmi_buf_free(buf); + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} + #if !defined(REMOVE_PKT_LOG) /** * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target @@ -19981,6 +20068,7 @@ struct wmi_ops tlv_ops = { #if defined(WLAN_FEATURE_FILS_SK) .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv, #endif + .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv, }; /** From 276e8d5911e51b262fd75399cb14f61e9e22441b Mon Sep 17 00:00:00 2001 From: Kiran Venkatappa Date: Fri, 10 Nov 2017 20:50:12 +0530 Subject: [PATCH 2/2] qcacmn: Add API to extract params from WMI ready event WMI ready event provides num_dscp_tid, num_total_peers and other information that is used. Add API to extract these params. Change-Id: I85ffc43f20935d84de133591020468c5e5f102de CRs-Fixed: 2141667 --- wmi/inc/wmi_unified_api.h | 12 ++++++++++++ wmi/inc/wmi_unified_param.h | 19 +++++++++++++++++++ wmi/inc/wmi_unified_priv.h | 2 ++ wmi/src/wmi_unified_api.c | 21 +++++++++++++++++++++ wmi/src/wmi_unified_non_tlv.c | 27 +++++++++++++++++++++++++++ wmi/src/wmi_unified_tlv.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 109 insertions(+) diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index d8d84617bbcd..de7fe13a5d41 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -1200,6 +1200,18 @@ QDF_STATUS wmi_ready_extract_mac_addr(void *wmi_hdl, wmi_host_mac_addr *wmi_ready_extract_mac_addr_list(void *wmi_hdl, void *ev, uint8_t *num_mac_addr); +/** + * wmi_extract_ready_params() - Extract data from ready event apart from + * status, macaddr and version. + * @wmi_handle: Pointer to WMI handle. + * @evt_buf: Pointer to Ready event buffer. + * @ev_param: Pointer to host defined struct to copy the data from event. + * + * Return: QDF_STATUS_SUCCESS on success. + */ +QDF_STATUS wmi_extract_ready_event_params(void *wmi_hdl, + void *evt_buf, struct wmi_host_ready_ev_param *ev_param); + QDF_STATUS wmi_extract_fw_version(void *wmi_hdl, void *ev, struct wmi_host_fw_ver *fw_ver); diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index 2bc6145ce021..a3ed6861acb5 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -7932,4 +7932,23 @@ struct get_arp_stats { uint32_t vdev_id; }; +/** + * struct wmi_host_ready_ev_param - Data revieved in ready event + * @num_dscp_table: Number of DSCP table supported in FW + * @num_extra_mac_addr: Extra mac address present in ready event. Used + * in DBDC mode to provide multiple mac per pdev. + * @num_total_peer: Total number of peers FW could allocate. Zero means + * FW could allocate num peers requested by host in init. + * Otherwise, host need update it max_peer to this value. + * @agile_capability: Boolean specification of whether the target supports + * agile DFS, by means of using one 80 MHz radio chain for + * radar detection, concurrently with using another radio + * chain for non-160 MHz regular operation. + */ +struct wmi_host_ready_ev_param { + uint32_t num_dscp_table; + uint32_t num_extra_mac_addr; + uint32_t num_total_peer; + bool agile_capability; +}; #endif /* _WMI_UNIFIED_PARAM_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 4fb977f14a89..0adf7a3810a0 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -988,6 +988,8 @@ QDF_STATUS (*ready_extract_mac_addr)(wmi_unified_t wmi_hdl, void *ev, uint8_t *macaddr); wmi_host_mac_addr * (*ready_extract_mac_addr_list)(wmi_unified_t wmi_hdl, void *ev, uint8_t *num_mac_addr); +QDF_STATUS (*extract_ready_event_params)(wmi_unified_t wmi_handle, + void *evt_buf, struct wmi_host_ready_ev_param *ev_param); QDF_STATUS (*check_and_update_fw_version)(wmi_unified_t wmi_hdl, void *ev); uint8_t* (*extract_dbglog_data_len)(wmi_unified_t wmi_handle, void *evt_buf, diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 6a222d28c659..22bd20e46515 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -4717,6 +4717,27 @@ wmi_host_mac_addr *wmi_ready_extract_mac_addr_list(void *wmi_hdl, void *ev, return NULL; } +/** + * wmi_extract_ready_params() - Extract data from ready event apart from + * status, macaddr and version. + * @wmi_handle: Pointer to WMI handle. + * @evt_buf: Pointer to Ready event buffer. + * @ev_param: Pointer to host defined struct to copy the data from event. + * + * Return: QDF_STATUS_SUCCESS on success. + */ +QDF_STATUS wmi_extract_ready_event_params(void *wmi_hdl, + void *evt_buf, struct wmi_host_ready_ev_param *ev_param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->extract_ready_event_params) + return wmi_handle->ops->extract_ready_event_params(wmi_handle, + evt_buf, ev_param); + + return QDF_STATUS_E_FAILURE; +} + /** * wmi_extract_dbglog_data_len() - extract debuglog data length * @wmi_handle: wmi handle diff --git a/wmi/src/wmi_unified_non_tlv.c b/wmi/src/wmi_unified_non_tlv.c index 9d54af3344b8..0b4aba397c45 100644 --- a/wmi/src/wmi_unified_non_tlv.c +++ b/wmi/src/wmi_unified_non_tlv.c @@ -5833,6 +5833,32 @@ static QDF_STATUS ready_extract_mac_addr_non_tlv(wmi_unified_t wmi_hdl, return QDF_STATUS_SUCCESS; } +/** + * extract_ready_params_non_tlv() - Extract data from ready event apart from + * status, macaddr and version. + * @wmi_handle: Pointer to WMI handle. + * @evt_buf: Pointer to Ready event buffer. + * @ev_param: Pointer to host defined struct to copy the data from event. + * + * Return: QDF_STATUS_SUCCESS on success. + */ +static QDF_STATUS extract_ready_event_params_non_tlv(wmi_unified_t wmi_handle, + void *evt_buf, struct wmi_host_ready_ev_param *ev_param) +{ + wmi_ready_event *ev = (wmi_ready_event *) evt_buf; + + ev_param->num_dscp_table = ev->num_dscp_table; + if (ev->agile_capability) + ev_param->agile_capability = true; + else + ev_param->agile_capability = false; + /* Following params not present in non-TLV target. Set Defaults */ + ev_param->num_extra_mac_addr = 0; + ev_param->num_total_peer = 0; + + return QDF_STATUS_SUCCESS; +} + /** * extract_dbglog_data_len_non_tlv() - extract debuglog data length * @wmi_handle: wmi handle @@ -8274,6 +8300,7 @@ struct wmi_ops non_tlv_ops = { .extract_dbglog_data_len = extract_dbglog_data_len_non_tlv, .ready_extract_init_status = ready_extract_init_status_non_tlv, .ready_extract_mac_addr = ready_extract_mac_addr_non_tlv, + .extract_ready_event_params = extract_ready_event_params_non_tlv, .extract_wds_addr_event = extract_wds_addr_event_non_tlv, .extract_dcs_interference_type = extract_dcs_interference_type_non_tlv, .extract_dcs_cw_int = extract_dcs_cw_int_non_tlv, diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 125c6bdfb6fd..d4c9e661ce52 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -16719,6 +16719,33 @@ static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamd return (wmi_host_mac_addr *) param_buf->mac_addr_list; } +/** + * extract_ready_params_tlv() - Extract data from ready event apart from + * status, macaddr and version. + * @wmi_handle: Pointer to WMI handle. + * @evt_buf: Pointer to Ready event buffer. + * @ev_param: Pointer to host defined struct to copy the data from event. + * + * Return: QDF_STATUS_SUCCESS on success. + */ +static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle, + void *evt_buf, struct wmi_host_ready_ev_param *ev_param) +{ + WMI_READY_EVENTID_param_tlvs *param_buf = NULL; + wmi_ready_event_fixed_param *ev = NULL; + + param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf; + ev = param_buf->fixed_param; + + ev_param->num_dscp_table = ev->num_dscp_table; + ev_param->num_extra_mac_addr = ev->num_extra_mac_addr; + ev_param->num_total_peer = ev->num_total_peers; + /* Agile_cap in ready event is not supported in TLV target */ + ev_param->agile_capability = false; + + return QDF_STATUS_SUCCESS; +} + /** * extract_dbglog_data_len_tlv() - extract debuglog data length * @wmi_handle: wmi handle @@ -19960,6 +19987,7 @@ struct wmi_ops tlv_ops = { .ready_extract_init_status = ready_extract_init_status_tlv, .ready_extract_mac_addr = ready_extract_mac_addr_tlv, .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv, + .extract_ready_event_params = extract_ready_event_params_tlv, .extract_dbglog_data_len = extract_dbglog_data_len_tlv, .extract_vdev_start_resp = extract_vdev_start_resp_tlv, .extract_tbttoffset_update_params =