From 4191d4a28510eabc17aed086399d941a648ab13f Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Fri, 13 Jan 2017 15:24:07 -0800 Subject: [PATCH] qcacmn: Add APIs to configure Active BPF Mode Active Mode Berkeley Packet Filter (Active BPF) is a new feature that allows firmware to apply BPF even while the Apps processor is active. There are 3 modes: * Disabled: do not apply BPF in active mode * Enabled: apply BPF to all packets in active mode * Adaptive: apply BPF up to some threshold to avoid performance impact Add WMI APIs and related logic to support configuration of Active BPF Mode. Change-Id: I8c0778b3fa73d148422aa103b0fc0950433fec95 CRs-Fixed: 1111400 --- wmi/inc/wmi_unified_api.h | 13 +++++++++ wmi/inc/wmi_unified_param.h | 13 +++++++++ wmi/inc/wmi_unified_priv.h | 5 ++++ wmi/src/wmi_unified_api.c | 17 +++++++++++ wmi/src/wmi_unified_tlv.c | 58 +++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index d37ac652f7..b54f74333e 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -858,6 +858,19 @@ QDF_STATUS wmi_unified_get_buf_extscan_hotlist_cmd(void *wmi_hdl, struct ext_scan_setbssi_hotlist_params * photlist, int *buf_len); +/** + * wmi_unified_set_active_bpf_mode_cmd() - config active BPF mode in FW + * @wmi_hdl: the WMI handle + * @vdev_id: the Id of the vdev to apply the configuration to + * @ucast_mode: the active BPF mode to configure for unicast packets + * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast + * packets + */ +QDF_STATUS wmi_unified_set_active_bpf_mode_cmd(void *wmi_hdl, + uint8_t vdev_id, + enum wmi_host_active_bpf_mode ucast_mode, + enum wmi_host_active_bpf_mode mcast_bcast_mode); + 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 797ecec9b5..dc525be8cb 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -7245,4 +7245,17 @@ struct pdev_csa_switch_count_status { uint32_t *vdev_ids; }; +/** + * enum wmi_host_active-bpf_mode - FW_ACTIVE_BPF_MODE, replicated from FW header + * @WMI_HOST_ACTIVE_BPF_DISABLED: BPF is disabled for all packets in active mode + * @WMI_HOST_ACTIVE_BPF_ENABLED: BPF is enabled for all packets in active mode + * @WMI_HOST_ACTIVE_BPF_ADAPTIVE: BPF is enabled for packets up to some + * threshold in active mode + */ +enum wmi_host_active_bpf_mode { + WMI_HOST_ACTIVE_BPF_DISABLED = (1 << 1), + WMI_HOST_ACTIVE_BPF_ENABLED = (1 << 2), + WMI_HOST_ACTIVE_BPF_ADAPTIVE = (1 << 3) +}; + #endif /* _WMI_UNIFIED_PARAM_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index e214026f7c..64345137cb 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -724,6 +724,11 @@ QDF_STATUS (*send_get_buf_extscan_hotlist_cmd)(wmi_unified_t wmi_handle, struct ext_scan_setbssi_hotlist_params * photlist, int *buf_len); +QDF_STATUS (*send_set_active_bpf_mode_cmd)(wmi_unified_t wmi_handle, + uint8_t vdev_id, + enum wmi_host_active_bpf_mode ucast_mode, + enum wmi_host_active_bpf_mode mcast_bcast_mode); + QDF_STATUS (*send_pdev_get_tpc_config_cmd)(wmi_unified_t wmi_handle, uint32_t param); diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 84990bc560..b330a47f56 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -3229,6 +3229,23 @@ QDF_STATUS wmi_unified_get_buf_extscan_hotlist_cmd(void *wmi_hdl, return QDF_STATUS_E_FAILURE; } +QDF_STATUS wmi_unified_set_active_bpf_mode_cmd(void *wmi_hdl, + uint8_t vdev_id, + enum wmi_host_active_bpf_mode ucast_mode, + enum wmi_host_active_bpf_mode mcast_bcast_mode) +{ + wmi_unified_t wmi = (wmi_unified_t)wmi_hdl; + + if (!wmi->ops->send_set_active_bpf_mode_cmd) { + WMI_LOGI("send_set_active_bpf_mode_cmd op is NULL"); + return QDF_STATUS_E_FAILURE; + } + + return wmi->ops->send_set_active_bpf_mode_cmd(wmi, vdev_id, + ucast_mode, + mcast_bcast_mode); +} + /** * wmi_unified_pdev_get_tpc_config_cmd_send() - WMI get tpc config function * @param wmi_handle : handle to WMI. diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 66ff9e17e7..8c0db5fe79 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -13334,6 +13334,63 @@ static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle, return QDF_STATUS_SUCCESS; } +/** + * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW + * @wmi_handle: the WMI handle + * @vdev_id: the Id of the vdev to apply the configuration to + * @ucast_mode: the active BPF mode to configure for unicast packets + * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast + * packets + * + * Return: QDF status + */ +static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t vdev_id, + enum wmi_host_active_bpf_mode ucast_mode, + enum wmi_host_active_bpf_mode mcast_bcast_mode) +{ + const WMITLV_TAG_ID tag_id = + WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param; + const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN( + wmi_bpf_set_vdev_active_mode_cmd_fixed_param); + QDF_STATUS status; + wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd; + wmi_buf_t buf; + + WMI_LOGI("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)", + vdev_id, ucast_mode, mcast_bcast_mode); + + /* allocate command buffer */ + buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); + if (!buf) { + WMI_LOGE("%s: wmi_buf_alloc failed", __func__); + return QDF_STATUS_E_NOMEM; + } + + /* set TLV header */ + cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len); + + /* populate data */ + cmd->vdev_id = vdev_id; + cmd->uc_mode = ucast_mode; + cmd->mcbc_mode = mcast_bcast_mode; + + /* send to FW */ + 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_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d", + status); + wmi_buf_free(buf); + return status; + } + + WMI_LOGI("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully"); + + return QDF_STATUS_SUCCESS; +} + /** * send_power_dbg_cmd_tlv() - send power debug commands * @wmi_handle: wmi handle @@ -15770,6 +15827,7 @@ struct wmi_ops tlv_ops = { send_roam_scan_offload_rssi_change_cmd_tlv, .send_get_buf_extscan_hotlist_cmd = send_get_buf_extscan_hotlist_cmd_tlv, + .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv, .send_adapt_dwelltime_params_cmd = send_adapt_dwelltime_params_cmd_tlv, .init_cmd_send = init_cmd_send_tlv,