diff options
| author | Nachiket Kukade <nkukade@codeaurora.org> | 2018-02-19 11:50:50 +0530 |
|---|---|---|
| committer | Nachiket Kukade <nkukade@codeaurora.org> | 2018-02-20 15:05:14 +0530 |
| commit | dcd5d53cfb3c634e0760cc62265880f5ab6952b9 (patch) | |
| tree | 8309a9bd9deffb881835ebd9ba8cf1450a16e1ea | |
| parent | 270eca1785f821f149393a53174828562cbbb7dc (diff) | |
qcacmn: Implement the new commands that cover APF 3.0 requirements
Android Packet Filter 3.0 requires the framework to be able to read
and write into the APF work memory in the Firmware. It also requires
to be able to enable or disable the interpreter. New WMI commands
are defined for read/write/enable/disable operations.
Cover the implementation of these commands.
Change-Id: I852d61eb213d9ae530e8a71069144ef35816f5b8
CRs-Fixed: 2184971
| -rw-r--r-- | wmi/inc/wmi_unified_apf_tlv.h | 53 | ||||
| -rw-r--r-- | wmi/inc/wmi_unified_api.h | 58 | ||||
| -rw-r--r-- | wmi/inc/wmi_unified_param.h | 48 | ||||
| -rw-r--r-- | wmi/inc/wmi_unified_priv.h | 13 | ||||
| -rw-r--r-- | wmi/src/wmi_unified_apf_tlv.c | 159 | ||||
| -rw-r--r-- | wmi/src/wmi_unified_api.c | 61 | ||||
| -rw-r--r-- | wmi/src/wmi_unified_tlv.c | 5 |
7 files changed, 382 insertions, 15 deletions
diff --git a/wmi/inc/wmi_unified_apf_tlv.h b/wmi/inc/wmi_unified_apf_tlv.h index 8823acf59221..09eb1b1e2dd6 100644 --- a/wmi/inc/wmi_unified_apf_tlv.h +++ b/wmi/inc/wmi_unified_apf_tlv.h @@ -37,7 +37,7 @@ * @vdev_id: the Id of the vdev to apply the configuration to * @ucast_mode: the active APF mode to configure for unicast packets * @mcast_bcast_mode: the active APF mode to configure for multicast/broadcast - * packets + * packets * * Return: QDF status */ @@ -46,4 +46,55 @@ send_set_active_apf_mode_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id, FW_ACTIVE_BPF_MODE ucast_mode, FW_ACTIVE_BPF_MODE mcast_bcast_mode); + +/** + * send_apf_enable_cmd_tlv() - send cmd to enable/disable APF interpreter + * @wmi_handle: the WMI handle + * @vdev_id: VDEV on which APF interpreter is to be enabled/disabled + * @enable: true: enable, false: disable + * + * Return: QDF status + */ +QDF_STATUS send_apf_enable_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t vdev_id, bool enable); + +/** + * send_apf_write_work_memory_cmd_tlv() - send cmd to write into the APF work + * memory + * @wmi_handle: the WMI handle + * @apf_write_params: parameters and buffer pointer for the write + * + * Return: QDF status + */ +QDF_STATUS +send_apf_write_work_memory_cmd_tlv(wmi_unified_t wmi_handle, + struct wmi_apf_write_memory_params + *apf_write_params); + +/** + * send_apf_read_work_memory_cmd_tlv() - send cmd to read part of APF + * work memory + * @wmi_handle: the WMI handle + * @apf_read_params: contains relative address and length to read from + * + * Return: QDF status + */ +QDF_STATUS +send_apf_read_work_memory_cmd_tlv(wmi_unified_t wmi_handle, + struct wmi_apf_read_memory_params + *apf_read_params); + +/** + * extract_apf_read_memory_resp_event_tlv() - extract read memory response + * event into the given structure pointer + * @wmi_handle: the WMI handle + * @evt_buf: Pointer to the event buffer + * @resp: pointer to memory to extract event parameters into + * + * Return: QDF status + */ +QDF_STATUS +extract_apf_read_memory_resp_event_tlv(wmi_unified_t wmi_handle, void *evt_buf, + struct wmi_apf_read_memory_resp_event_params + *resp); #endif /* _WMI_UNIFIED_APF_TLV_H_ */ diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index 5b0eb0a18ccc..0807735c560e 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -964,18 +964,72 @@ QDF_STATUS wmi_unified_get_buf_extscan_hotlist_cmd(void *wmi_hdl, /** * wmi_unified_set_active_apf_mode_cmd() - config active APF mode in FW - * @wmi_hdl: the WMI handle + * @wmi: the WMI handle * @vdev_id: the Id of the vdev to apply the configuration to * @ucast_mode: the active APF mode to configure for unicast packets * @mcast_bcast_mode: the active APF mode to configure for multicast/broadcast * packets */ QDF_STATUS -wmi_unified_set_active_apf_mode_cmd(void *wmi_hdl, +wmi_unified_set_active_apf_mode_cmd(wmi_unified_t wmi, uint8_t vdev_id, FW_ACTIVE_BPF_MODE ucast_mode, FW_ACTIVE_BPF_MODE mcast_bcast_mode); +/** + * wmi_unified_send_apf_enable_cmd() - send apf enable/disable cmd + * @wmi: wmi handle + * @vdev_id: VDEV id + * @enable: true: enable, false: disable + * + * This function passes the apf enable command to fw + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_send_apf_enable_cmd(wmi_unified_t wmi, + uint32_t vdev_id, bool enable); + +/** + * wmi_unified_send_apf_write_work_memory_cmd() - send cmd to write into the APF + * work memory. + * @wmi: wmi handle + * @write_params: parameters and buffer pointer for the write + * + * This function passes the write apf work mem command to fw + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_send_apf_write_work_memory_cmd(wmi_unified_t wmi, + struct wmi_apf_write_memory_params *write_params); + +/** + * wmi_unified_send_apf_read_work_memory_cmd() - send cmd to read part of APF + * work memory + * @wmi: wmi handle + * @read_params: contains relative address and length to read from + * + * This function passes the read apf work mem command to fw + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_send_apf_read_work_memory_cmd(wmi_unified_t wmi, + struct wmi_apf_read_memory_params *read_params); + +/** + * wmi_extract_apf_read_memory_resp_event() - exctract read mem resp event + * @wmi: wmi handle + * @evt_buf: Pointer to the event buffer + * @resp: pointer to memory to extract event parameters into + * + * This function exctracts read mem response event into the given structure ptr + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS +wmi_extract_apf_read_memory_resp_event(wmi_unified_t wmi, void *evt_buf, + struct wmi_apf_read_memory_resp_event_params + *read_mem_evt); + QDF_STATUS wmi_unified_stats_request_send(void *wmi_hdl, uint8_t macaddr[IEEE80211_ADDR_LEN], struct stats_request_params *param); diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index cea660784c86..b2dfd1e58f46 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -7601,5 +7601,53 @@ struct wmi_invoke_neighbor_report_params { struct mac_ssid ssid; }; +/** + * struct wmi_apf_write_memory_params - Android Packet Filter write memory + * params + * @vdev_id: VDEV on which APF memory is to be written + * @apf_version: APF version number + * @program_len: Length reserved for program in the APF work memory + * @addr_offset: Relative address in APF work memory to start writing + * @length: Size of the write + * @buf: Pointer to the buffer + */ +struct wmi_apf_write_memory_params { + uint8_t vdev_id; + uint32_t apf_version; + uint32_t program_len; + uint32_t addr_offset; + uint32_t length; + uint8_t *buf; +}; + +/** + * struct wmi_apf_read_memory_params - Android Packet Filter read memory params + * @vdev_id: vdev id + * @addr_offset: Relative address in APF work memory to read from + * @length: Size of the memory fetch + */ +struct wmi_apf_read_memory_params { + uint8_t vdev_id; + uint32_t addr_offset; + uint32_t length; +}; + +/** + * struct wmi_apf_read_memory_resp_event_params - Event containing read Android + * Packet Filter memory response + * @vdev_id: vdev id + * @offset: Read memory offset + * @length: Read memory length + * @more_data: Indicates more data to come + * @data: Pointer to the data + */ +struct wmi_apf_read_memory_resp_event_params { + uint32_t vdev_id; + uint32_t offset; + uint32_t length; + bool more_data; + uint8_t *data; +}; + #endif /* _WMI_UNIFIED_PARAM_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 1a0647fe0b0b..f768ede8165c 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -764,6 +764,19 @@ QDF_STATUS (*send_set_active_apf_mode_cmd)(wmi_unified_t wmi_handle, FW_ACTIVE_BPF_MODE ucast_mode, FW_ACTIVE_BPF_MODE mcast_bcast_mode); +QDF_STATUS (*send_apf_enable_cmd)(wmi_unified_t wmi_handle, uint32_t vdev_id, + bool enable); + +QDF_STATUS (*send_apf_write_work_memory_cmd)(wmi_unified_t wmi_handle, + struct wmi_apf_write_memory_params *apf_write_params); + +QDF_STATUS (*send_apf_read_work_memory_cmd)(wmi_unified_t wmi_handle, + struct wmi_apf_read_memory_params *apf_read_params); + +QDF_STATUS (*extract_apf_read_memory_resp_event)(wmi_unified_t wmi_handle, + void *evt_buf, + struct wmi_apf_read_memory_resp_event_params *resp); + QDF_STATUS (*send_pdev_get_tpc_config_cmd)(wmi_unified_t wmi_handle, uint32_t param); diff --git a/wmi/src/wmi_unified_apf_tlv.c b/wmi/src/wmi_unified_apf_tlv.c index 7e7311e5486d..8cb3aba07dc9 100644 --- a/wmi/src/wmi_unified_apf_tlv.c +++ b/wmi/src/wmi_unified_apf_tlv.c @@ -40,7 +40,7 @@ QDF_STATUS send_set_active_apf_mode_cmd_tlv(wmi_unified_t wmi_handle, wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd; wmi_buf_t buf; - WMI_LOGD("Sending WMI_APF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)", + WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)", vdev_id, ucast_mode, mcast_bcast_mode); /* allocate command buffer */ @@ -63,14 +63,167 @@ QDF_STATUS send_set_active_apf_mode_cmd_tlv(wmi_unified_t wmi_handle, status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd), WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID); if (QDF_IS_STATUS_ERROR(status)) { - WMI_LOGE("Failed to send WMI_APF_SET_VDEV_ACTIVE_MODE_CMDID:%d", + WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d", status); wmi_buf_free(buf); return status; } - WMI_LOGD("Sent WMI_APF_SET_VDEV_ACTIVE_MODE_CMDID successfully"); + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS send_apf_enable_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t vdev_id, bool enable) +{ + wmi_bpf_set_vdev_enable_cmd_fixed_param *cmd; + wmi_buf_t buf; + + buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); + if (!buf) { + WMI_LOGP("%s: wmi_buf_alloc failed", __func__); + return QDF_STATUS_E_NOMEM; + } + + cmd = (wmi_bpf_set_vdev_enable_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_bpf_set_vdev_enable_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN( + wmi_bpf_set_vdev_enable_cmd_fixed_param)); + cmd->vdev_id = vdev_id; + cmd->is_enabled = enable; + + if (wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd), + WMI_BPF_SET_VDEV_ENABLE_CMDID)) { + WMI_LOGE("%s: Failed to enable/disable APF interpreter", + __func__); + wmi_buf_free(buf); + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +send_apf_write_work_memory_cmd_tlv(wmi_unified_t wmi_handle, + struct wmi_apf_write_memory_params + *apf_write_params) +{ + wmi_bpf_set_vdev_work_memory_cmd_fixed_param *cmd; + uint32_t wmi_buf_len; + wmi_buf_t buf; + uint8_t *buf_ptr; + uint32_t aligned_len = 0; + + wmi_buf_len = sizeof(*cmd); + if (apf_write_params->length) { + aligned_len = roundup(apf_write_params->length, + sizeof(A_UINT32)); + + wmi_buf_len += WMI_TLV_HDR_SIZE + aligned_len; + + } + + buf = wmi_buf_alloc(wmi_handle, wmi_buf_len); + if (!buf) { + WMI_LOGP("%s: wmi_buf_alloc failed", __func__); + return QDF_STATUS_E_NOMEM; + } + + buf_ptr = wmi_buf_data(buf); + cmd = (wmi_bpf_set_vdev_work_memory_cmd_fixed_param *)buf_ptr; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_bpf_set_vdev_work_memory_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN( + wmi_bpf_set_vdev_work_memory_cmd_fixed_param)); + cmd->vdev_id = apf_write_params->vdev_id; + cmd->bpf_version = apf_write_params->apf_version; + cmd->program_len = apf_write_params->program_len; + cmd->addr_offset = apf_write_params->addr_offset; + cmd->length = apf_write_params->length; + + if (apf_write_params->length) { + buf_ptr += sizeof(*cmd); + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, + aligned_len); + buf_ptr += WMI_TLV_HDR_SIZE; + qdf_mem_copy(buf_ptr, apf_write_params->buf, + apf_write_params->length); + } + + if (wmi_unified_cmd_send(wmi_handle, buf, wmi_buf_len, + WMI_BPF_SET_VDEV_WORK_MEMORY_CMDID)) { + WMI_LOGE("%s: Failed to write APF work memory", __func__); + wmi_buf_free(buf); + return QDF_STATUS_E_FAILURE; + } return QDF_STATUS_SUCCESS; } +QDF_STATUS +send_apf_read_work_memory_cmd_tlv(wmi_unified_t wmi_handle, + struct wmi_apf_read_memory_params + *apf_read_params) +{ + wmi_bpf_get_vdev_work_memory_cmd_fixed_param *cmd; + wmi_buf_t buf; + + buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); + if (!buf) { + WMI_LOGP("%s: wmi_buf_alloc failed", __func__); + return QDF_STATUS_E_NOMEM; + } + + cmd = (wmi_bpf_get_vdev_work_memory_cmd_fixed_param *) + wmi_buf_data(buf); + + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_bpf_get_vdev_work_memory_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN( + wmi_bpf_get_vdev_work_memory_cmd_fixed_param)); + cmd->vdev_id = apf_read_params->vdev_id; + cmd->addr_offset = apf_read_params->addr_offset; + cmd->length = apf_read_params->length; + + if (wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd), + WMI_BPF_GET_VDEV_WORK_MEMORY_CMDID)) { + WMI_LOGE("%s: Failed to get APF work memory", __func__); + wmi_buf_free(buf); + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS +extract_apf_read_memory_resp_event_tlv(wmi_unified_t wmi_handle, void *evt_buf, + struct wmi_apf_read_memory_resp_event_params *resp) +{ + WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID_param_tlvs *param_buf; + wmi_bpf_get_vdev_work_memory_resp_evt_fixed_param *data_event; + + param_buf = evt_buf; + if (!param_buf) { + WMI_LOGE("encrypt decrypt resp evt_buf is NULL"); + return QDF_STATUS_E_INVAL; + } + + data_event = param_buf->fixed_param; + + resp->vdev_id = data_event->vdev_id; + resp->offset = data_event->offset; + resp->more_data = data_event->fragment; + + if (data_event->length > param_buf->num_data) { + WMI_LOGE("FW msg data_len %d more than TLV hdr %d", + data_event->length, + param_buf->num_data); + return QDF_STATUS_E_INVAL; + } + resp->length = data_event->length; + + if (resp->length) + resp->data = (uint8_t *)param_buf->data; + + return QDF_STATUS_SUCCESS; +} diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 167968d84c0e..914870572d34 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -3651,21 +3651,64 @@ QDF_STATUS wmi_unified_get_buf_extscan_hotlist_cmd(void *wmi_hdl, } QDF_STATUS -wmi_unified_set_active_apf_mode_cmd(void *wmi_hdl, +wmi_unified_set_active_apf_mode_cmd(wmi_unified_t wmi, uint8_t vdev_id, FW_ACTIVE_BPF_MODE ucast_mode, FW_ACTIVE_BPF_MODE mcast_bcast_mode) { - wmi_unified_t wmi = (wmi_unified_t)wmi_hdl; - if (!wmi->ops->send_set_active_apf_mode_cmd) { - WMI_LOGD("send_set_active_apf_mode_cmd op is NULL"); - return QDF_STATUS_E_FAILURE; - } + if (wmi->ops->send_set_active_apf_mode_cmd) + return wmi->ops->send_set_active_apf_mode_cmd(wmi, vdev_id, + ucast_mode, + mcast_bcast_mode); + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS +wmi_unified_send_apf_enable_cmd(wmi_unified_t wmi, + uint32_t vdev_id, bool enable) +{ + if (wmi->ops->send_apf_enable_cmd) + return wmi->ops->send_apf_enable_cmd(wmi, vdev_id, enable); - return wmi->ops->send_set_active_apf_mode_cmd(wmi, vdev_id, - ucast_mode, - mcast_bcast_mode); + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS +wmi_unified_send_apf_write_work_memory_cmd(wmi_unified_t wmi, + struct wmi_apf_write_memory_params + *write_params) +{ + if (wmi->ops->send_apf_write_work_memory_cmd) + return wmi->ops->send_apf_write_work_memory_cmd(wmi, + write_params); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS +wmi_unified_send_apf_read_work_memory_cmd(wmi_unified_t wmi, + struct wmi_apf_read_memory_params + *read_params) +{ + if (wmi->ops->send_apf_read_work_memory_cmd) + return wmi->ops->send_apf_read_work_memory_cmd(wmi, + read_params); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS +wmi_extract_apf_read_memory_resp_event(wmi_unified_t wmi, void *evt_buf, + struct wmi_apf_read_memory_resp_event_params + *read_mem_evt) +{ + if (wmi->ops->extract_apf_read_memory_resp_event) + return wmi->ops->extract_apf_read_memory_resp_event(wmi, + evt_buf, + read_mem_evt); + + return QDF_STATUS_E_FAILURE; } /** diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 52a75ca087c0..9a217d6445f1 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -14787,6 +14787,11 @@ struct wmi_ops tlv_ops = { .send_get_buf_extscan_hotlist_cmd = send_get_buf_extscan_hotlist_cmd_tlv, .send_set_active_apf_mode_cmd = send_set_active_apf_mode_cmd_tlv, + .send_apf_enable_cmd = send_apf_enable_cmd_tlv, + .send_apf_write_work_memory_cmd = send_apf_write_work_memory_cmd_tlv, + .send_apf_read_work_memory_cmd = send_apf_read_work_memory_cmd_tlv, + .extract_apf_read_memory_resp_event = + extract_apf_read_memory_resp_event_tlv, .send_adapt_dwelltime_params_cmd = send_adapt_dwelltime_params_cmd_tlv, .send_dbs_scan_sel_params_cmd = |
