qca-wifi: Wmi interface to send hw vlan accel info to fw

wmi interface to sned hw vlan acceleration command to fw.

Change-Id: I6702da276fa89471d327a64810cf7fc85ab66d44
CRs-Fixed: 2596307
diff --git a/wmi/inc/wmi_unified_ap_api.h b/wmi/inc/wmi_unified_ap_api.h
index b9ef12d..8f91a9f 100644
--- a/wmi/inc/wmi_unified_ap_api.h
+++ b/wmi/inc/wmi_unified_ap_api.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018,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
@@ -752,4 +752,18 @@
 		wmi_unified_t wmi_handle,
 		struct wmi_rx_pkt_protocol_routing_info *param);
 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
+
+/**
+ * wmi_unified_peer_vlan_config_send() - WMI function to send vlan command
+ *
+ * @wmi_hdl: WMI handle
+ * @peer_addr: Peer mac address
+ * @param: struct peer_vlan_config_param *
+ *
+ * Return: QDF_STATUS_SUCCESS if success, else returns proper error code.
+ */
+QDF_STATUS wmi_unified_peer_vlan_config_send(wmi_unified_t wmi_handle,
+		uint8_t peer_addr[QDF_MAC_ADDR_SIZE],
+		struct peer_vlan_config_param *param);
+
 #endif /* _WMI_UNIFIED_AP_API_H_ */
diff --git a/wmi/src/wmi_unified_ap_api.c b/wmi/src/wmi_unified_ap_api.c
index 6fdf4c5..7dc68ea 100644
--- a/wmi/src/wmi_unified_ap_api.c
+++ b/wmi/src/wmi_unified_ap_api.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018,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
@@ -593,3 +593,15 @@
 	return QDF_STATUS_E_FAILURE;
 }
 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
+
+QDF_STATUS wmi_unified_peer_vlan_config_send(wmi_unified_t wmi_handle,
+				uint8_t peer_addr[QDF_MAC_ADDR_SIZE],
+				struct peer_vlan_config_param *param)
+{
+	if (wmi_handle->ops->send_peer_vlan_config_cmd)
+		return wmi_handle->ops->send_peer_vlan_config_cmd(wmi_handle,
+							   peer_addr,
+							   param);
+
+	return QDF_STATUS_E_FAILURE;
+}
diff --git a/wmi/src/wmi_unified_ap_tlv.c b/wmi/src/wmi_unified_ap_tlv.c
index 6700f1b..67fc2bc 100644
--- a/wmi/src/wmi_unified_ap_tlv.c
+++ b/wmi/src/wmi_unified_ap_tlv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-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
@@ -1702,6 +1702,93 @@
 }
 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
 
+/**
+ * send_peer_vlan_config_cmd_tlv() - Send PEER vlan hw acceleration cmd to fw
+ * @wmi: wmi handle
+ * @peer_addr: peer mac addr
+ * @param: struct peer_vlan_config_param *
+ *
+ * Return: QDF_STATUS_SUCCESS for success or error code
+ */
+static QDF_STATUS send_peer_vlan_config_cmd_tlv(wmi_unified_t wmi,
+					uint8_t peer_addr[QDF_MAC_ADDR_SIZE],
+					struct peer_vlan_config_param *param)
+{
+	wmi_peer_config_vlan_cmd_fixed_param *cmd;
+	wmi_buf_t buf;
+	uint32_t len = sizeof(*cmd);
+
+	buf = wmi_buf_alloc(wmi, len);
+	if (!buf)
+		return QDF_STATUS_E_NOMEM;
+
+	cmd = (wmi_peer_config_vlan_cmd_fixed_param *)wmi_buf_data(buf);
+	WMITLV_SET_HDR(&cmd->tlv_header,
+		       WMITLV_TAG_STRUC_wmi_peer_config_vlan_cmd_fixed_param,
+		       WMITLV_GET_STRUCT_TLVLEN
+			       (wmi_peer_config_vlan_cmd_fixed_param));
+	WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
+
+	/* vdev id */
+	cmd->vdev_id = param->vdev_id;
+
+	/* Tx command - Check if cmd is Tx then configure Tx cmd */
+	if (param->tx_cmd) {
+		WMI_VLAN_TX_SET(cmd->peer_vlan_config_mask, param->tx_cmd);
+
+		/* Setting insert_or_strip bit for Tx */
+		WMI_TX_INSERT_OR_STRIP_SET(cmd->peer_vlan_config_mask,
+					   param->tx_strip_insert);
+
+		if (param->tx_strip_insert_inner && param->tx_strip_insert) {
+		/* Setting the strip_insert_vlan_inner bit fo Tx */
+			WMI_TX_STRIP_INSERT_VLAN_INNER_SET(cmd->peer_vlan_config_mask,
+				param->tx_strip_insert_inner);
+		/* If Insert inner tag bit is set, then fill inner_tci */
+			WMI_TX_INSERT_VLAN_INNER_TCI_SET(cmd->insert_vlan_tci,
+						param->insert_vlan_inner_tci);
+		}
+
+		if (param->tx_strip_insert_outer && param->tx_strip_insert) {
+			/* Setting the strip_insert_vlan_outer bit fo Tx */
+			WMI_TX_STRIP_INSERT_VLAN_OUTER_SET(cmd->peer_vlan_config_mask,
+					param->tx_strip_insert_outer);
+			/* If Insert outer tag bit is set, then fill outer_tci */
+			WMI_TX_INSERT_VLAN_OUTER_TCI_SET(cmd->insert_vlan_tci,
+						param->insert_vlan_outer_tci);
+		}
+	}
+
+	/* Rx command - Check if cmd is Rx then configure Rx cmd */
+	if (param->rx_cmd) {
+		WMI_VLAN_RX_SET(cmd->peer_vlan_config_mask, param->rx_cmd);
+
+		/* Setting the strip_vlan_c_tag_decap bit in RX */
+		WMI_RX_STRIP_VLAN_C_TAG_SET(cmd->peer_vlan_config_mask,
+				param->rx_strip_c_tag);
+
+		/* Setting the strip_vlan_s_tag_decap bit in RX */
+		WMI_RX_STRIP_VLAN_S_TAG_SET(cmd->peer_vlan_config_mask,
+					    param->rx_strip_s_tag);
+
+		/* Setting the insert_vlan_c_tag_decap bit in RX */
+		WMI_RX_INSERT_VLAN_C_TAG_SET(cmd->peer_vlan_config_mask,
+					     param->rx_insert_c_tag);
+
+		/* Setting the insert_vlan_s_tag_decap bit in RX */
+		WMI_RX_INSERT_VLAN_S_TAG_SET(cmd->peer_vlan_config_mask,
+					     param->rx_insert_s_tag);
+	}
+
+	if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CONFIG_VLAN_CMDID)) {
+		WMI_LOGE("%s: Failed to send peer hw vlan acceleration command", __func__);
+		wmi_buf_free(buf);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
 #ifdef WLAN_SUPPORT_FILS
 /**
  * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
@@ -2469,4 +2556,5 @@
 	ops->set_rx_pkt_type_routing_tag_cmd =
 					set_rx_pkt_type_routing_tag_update_tlv;
 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
+	ops->send_peer_vlan_config_cmd = send_peer_vlan_config_cmd_tlv;
 }
diff --git a/wmi/src/wmi_unified_non_tlv.c b/wmi/src/wmi_unified_non_tlv.c
index 2c9bf31..2b45e99 100644
--- a/wmi/src/wmi_unified_non_tlv.c
+++ b/wmi/src/wmi_unified_non_tlv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-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
@@ -1182,6 +1182,22 @@
 }
 
 /**
+ * send_peer_vlan_config_cmd_non_tlv() - Send PEER vlan hw accel cmdd to fw
+ * @wmi: wmi handle
+ * @peer_addr: peer mac addr
+ * @param: struct peer_vlan_config_param *
+ *
+ * It is not supported for legacy.
+ * Return: QDF_STATUS_E_NOSUPPORT
+ */
+static QDF_STATUS send_peer_vlan_config_cmd_non_tlv(wmi_unified_t wmi,
+					uint8_t peer_addr[QDF_MAC_ADDR_SIZE],
+					struct peer_vlan_config_param *param)
+{
+	return QDF_STATUS_E_NOSUPPORT;
+}
+
+/**
  * send_peer_add_wds_entry_cmd_non_tlv() - send peer add command to fw
  * @wmi_handle: wmi handle
  * @param: pointer holding peer details
@@ -9954,6 +9970,7 @@
 	.send_peer_param_cmd = send_peer_param_cmd_non_tlv,
 	.send_vdev_up_cmd = send_vdev_up_cmd_non_tlv,
 	.send_peer_create_cmd = send_peer_create_cmd_non_tlv,
+	.send_peer_vlan_config_cmd = send_peer_vlan_config_cmd_non_tlv,
 	.send_peer_delete_cmd = send_peer_delete_cmd_non_tlv,
 	.send_peer_delete_all_cmd = send_peer_delete_all_cmd_non_tlv,
 	.send_peer_ft_roam_cmd = send_peer_ft_roam_cmd_non_tlv,