Merge remote-tracking branch 'origin/Bitra.LA.3.2.1-target' into fp4t-target-0414
diff --git a/dp/inc/cdp_txrx_stats_struct.h b/dp/inc/cdp_txrx_stats_struct.h
index 1612a35..f07bcd3 100644
--- a/dp/inc/cdp_txrx_stats_struct.h
+++ b/dp/inc/cdp_txrx_stats_struct.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2021 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
@@ -1729,6 +1729,7 @@
 
 	struct cdp_tso_stats tso_stats;
 	struct cdp_cfr_rcc_stats rcc;
+	uint32_t peer_unauth_rx_pkt_drop;
 };
 
 #ifdef QCA_ENH_V3_STATS_SUPPORT
diff --git a/dp/wifi3.0/dp_rx.c b/dp/wifi3.0/dp_rx.c
index b410709..065a5e2 100644
--- a/dp/wifi3.0/dp_rx.c
+++ b/dp/wifi3.0/dp_rx.c
@@ -2593,6 +2593,22 @@
 			nbuf = next;
 			continue;
 		}
+		/*
+		 * Drop non-EAPOL frames from unauthorized peer.
+		 */
+		if (qdf_likely(peer) && qdf_unlikely(!peer->authorize)) {
+			bool is_eapol = qdf_nbuf_is_ipv4_eapol_pkt(nbuf) ||
+					qdf_nbuf_is_ipv4_wapi_pkt(nbuf);
+
+			if (!is_eapol) {
+				DP_STATS_INC(soc,
+					     rx.err.peer_unauth_rx_pkt_drop,
+					     1);
+				qdf_nbuf_free(nbuf);
+				nbuf = next;
+				continue;
+			}
+		}
 
 		/*
 		 * Drop non-EAPOL frames from unauthorized peer.
diff --git a/dp/wifi3.0/dp_rx_err.c b/dp/wifi3.0/dp_rx_err.c
index b9fded4..2d7d2c2 100644
--- a/dp/wifi3.0/dp_rx_err.c
+++ b/dp/wifi3.0/dp_rx_err.c
@@ -1159,6 +1159,22 @@
 			/* IEEE80211_SEQ_MAX indicates invalid start_seq */
 	}
 
+       eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
+
+       if (peer && !peer->authorize) {
+               bool is_eapol = qdf_nbuf_is_ipv4_eapol_pkt(nbuf) ||
+                               qdf_nbuf_is_ipv4_wapi_pkt(nbuf);
+
+               bool is_not_match = qdf_mem_cmp(eh->ether_dhost,
+                                               &vdev->mac_addr.raw[0],
+                                               QDF_MAC_ADDR_SIZE);
+
+               if (!is_eapol)
+                       goto drop_nbuf;
+               else if(is_not_match)
+                       goto drop_nbuf;
+       }
+
 	if (qdf_unlikely(vdev->rx_decap_type == htt_cmn_pkt_type_raw)) {
 		qdf_nbuf_set_next(nbuf, NULL);
 		dp_rx_deliver_raw(vdev, nbuf, peer);
diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h
index cefa475..3297d5e 100644
--- a/dp/wifi3.0/dp_types.h
+++ b/dp/wifi3.0/dp_types.h
@@ -869,6 +869,8 @@
 			uint32_t nbuf_sanity_fail;
 			/* Duplicate link desc refilled */
 			uint32_t dup_refill_link_desc;
+			/* Non Eapol pkt drop cnt due to peer not authorized */
+			uint32_t peer_unauth_rx_pkt_drop;
 			/* EAPOL drop count in intrabss scenario */
 			uint32_t intrabss_eapol_drop;
 			/* Non Eapol pkt drop cnt due to peer not authorized */
diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c
index fc70592..9c40df0 100644
--- a/wmi/src/wmi_unified_tlv.c
+++ b/wmi/src/wmi_unified_tlv.c
@@ -13276,6 +13276,9 @@
 
 	param->vdev_id = resp_event->vdev_id;
 	param->num_qtime = param_buf->num_audio_sync_q_master_slave_times;
+	if (param->num_qtime > FTM_TIME_SYNC_QTIME_PAIR_MAX)
+		param->num_qtime = FTM_TIME_SYNC_QTIME_PAIR_MAX;
+
 	q_pair = param_buf->audio_sync_q_master_slave_times;
 	if (!q_pair) {
 		WMI_LOGE("Invalid q_master_slave_times buffer");