qcacmn: Expose full hardware filter capabilities via WMI

The WMI API exposes the broadcast hardware filter. Modify the WMI API
to expose all of the supported modes of the hardware filter.

Change-Id: I185b149f4d1ad38692d8ff5810acd52bf84565b2
CRs-Fixed: 2040419
diff --git a/wmi_unified_pmo_api.c b/wmi_unified_pmo_api.c
index 9b69525..743aa6f 100644
--- a/wmi_unified_pmo_api.c
+++ b/wmi_unified_pmo_api.c
@@ -23,6 +23,7 @@
 #include "ol_defines.h"
 #include "wmi_unified_priv.h"
 #include "wmi_unified_pmo_api.h"
+#include "wlan_pmo_hw_filter_public_struct.h"
 
 QDF_STATUS wmi_unified_add_wow_wakeup_event_cmd(void *wmi_hdl,
 					uint32_t vdev_id,
@@ -195,16 +196,15 @@
 	return QDF_STATUS_E_FAILURE;
 }
 
-QDF_STATUS wmi_unified_configure_broadcast_filter_cmd(void *wmi_hdl,
-			   uint8_t vdev_id, bool bc_filter)
+QDF_STATUS wmi_unified_conf_hw_filter_cmd(void *opaque_wmi,
+					  struct pmo_hw_filter_params *req)
 {
-	wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl;
+	struct wmi_unified *wmi = opaque_wmi;
 
-	if (wmi_handle->ops->send_enable_broadcast_filter_cmd)
-		return wmi_handle->ops->send_enable_broadcast_filter_cmd(
-				wmi_handle, vdev_id, bc_filter);
+	if (!wmi->ops->send_conf_hw_filter_cmd)
+		return QDF_STATUS_E_NOSUPPORT;
 
-	return QDF_STATUS_E_FAILURE;
+	return wmi->ops->send_conf_hw_filter_cmd(wmi, req);
 }
 
 #ifdef FEATURE_WLAN_LPHB
diff --git a/wmi_unified_tlv.c b/wmi_unified_tlv.c
index 64cc9df..c7b007d 100644
--- a/wmi_unified_tlv.c
+++ b/wmi_unified_tlv.c
@@ -33,6 +33,9 @@
 #ifdef CONVERGED_P2P_ENABLE
 #include "wlan_p2p_public_struct.h"
 #endif
+#ifdef WLAN_PMO_ENABLE
+#include "wlan_pmo_hw_filter_public_struct.h"
+#endif
 #include <wlan_utility.h>
 
 /* copy_vdev_create_pdev_id() - copy pdev from host params to target command
@@ -13475,47 +13478,43 @@
 }
 #endif /* FEATURE_WLAN_LPHB */
 
-static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
-			   uint8_t vdev_id, bool enable)
+static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
+					      struct pmo_hw_filter_params *req)
 {
-	int32_t res;
+	QDF_STATUS status;
 	wmi_hw_data_filter_cmd_fixed_param *cmd;
-	A_UINT8 *buf_ptr;
-	wmi_buf_t buf;
-	int32_t len;
+	wmi_buf_t wmi_buf;
 
-	/*
-	 * TLV place holder size for array of ARP tuples
-	 */
-	len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
+	if (!req) {
+		WMI_LOGE("req is null");
+		return QDF_STATUS_E_INVAL;
+	}
 
-	buf = wmi_buf_alloc(wmi_handle, len);
-	if (!buf) {
-		WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
+	wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
+	if (!wmi_buf) {
+		WMI_LOGE(FL("Out of memory"));
 		return QDF_STATUS_E_NOMEM;
 	}
 
-	buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
-	cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
+	cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
 	WMITLV_SET_HDR(&cmd->tlv_header,
-		       WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
-		       WMITLV_GET_STRUCT_TLVLEN
-			       (wmi_hw_data_filter_cmd_fixed_param));
-	cmd->vdev_id = vdev_id;
-	cmd->enable = enable;
-	cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
+		  WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
+		  WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
+	cmd->vdev_id = req->vdev_id;
+	cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
+	cmd->hw_filter_bitmap = req->mode;
 
-	WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
+	WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
+		 req->vdev_id, req->mode);
 
-	res = wmi_unified_cmd_send(wmi_handle, buf, len,
-				     WMI_HW_DATA_FILTER_CMDID);
-	if (res) {
-		WMI_LOGE("Failed to enable ARP NDP/NSffload");
-		wmi_buf_free(buf);
-		return QDF_STATUS_E_FAILURE;
+	status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
+				      WMI_HW_DATA_FILTER_CMDID);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		WMI_LOGE("Failed to configure hw filter");
+		wmi_buf_free(wmi_buf);
 	}
 
-	return QDF_STATUS_SUCCESS;
+	return status;
 }
 
 /**
@@ -17701,8 +17700,7 @@
 	.send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
 	.send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
 	.send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
-	.send_enable_broadcast_filter_cmd =
-		 send_enable_broadcast_filter_cmd_tlv,
+	.send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
 	.send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
 	.send_process_gtk_offload_getinfo_cmd =
 		send_process_gtk_offload_getinfo_cmd_tlv,