From d0d0ed0bf72b2bc4f3da8b84a417de3e0920a194 Mon Sep 17 00:00:00 2001
From: Ecco Park <eccopark@broadcom.com>
Date: Mon, 3 Aug 2015 18:19:02 -0700
Subject: [PATCH] net: wireless: bcmdhd: prioritize 802.1x pkt

1) Bug : 22339691
2) Prioritize EAPOL packets to avoid delay
   In the processing EAPOL packets in case of high data traffic
3) This code is required to work with new FW(7.35.79.96)
Signed-off-by: Ecco Park <eccopark@broadcom.com>

Change-Id: I65e03b57ba2f23c60d8fa663df5843abc0ee34fe
---
 drivers/net/wireless/bcmdhd/Makefile       | 2 ++
 drivers/net/wireless/bcmdhd/bcmutils.c     | 6 ++++++
 drivers/net/wireless/bcmdhd/dhd_flowring.c | 6 +++++-
 drivers/net/wireless/bcmdhd/dhd_flowring.h | 7 ++++---
 drivers/net/wireless/bcmdhd/dhd_linux.c    | 4 ++++
 5 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/bcmdhd/Makefile b/drivers/net/wireless/bcmdhd/Makefile
index 571fd23dfd85..3f9937af4411 100644
--- a/drivers/net/wireless/bcmdhd/Makefile
+++ b/drivers/net/wireless/bcmdhd/Makefile
@@ -258,6 +258,8 @@ endif
 
 # Print 802.1X packets
   DHDCFLAGS += -DDHD_8021X_DUMP
+# prioritize 802.1x packet
+  DHDCFLAGS += -DEAPOL_PKT_PRIO
 # Print DHCP packets
 #  DHDCFLAGS += -DDHD_DHCP_DUMP
 endif
diff --git a/drivers/net/wireless/bcmdhd/bcmutils.c b/drivers/net/wireless/bcmdhd/bcmutils.c
index 1e940842c0eb..1c1432516e22 100644
--- a/drivers/net/wireless/bcmdhd/bcmutils.c
+++ b/drivers/net/wireless/bcmdhd/bcmutils.c
@@ -798,6 +798,12 @@ pktsetprio(void *pkt, bool update_vtag)
 			evh->vlan_tag = hton16(vlan_tag);
 			rc |= PKTPRIO_UPD;
 		}
+
+#ifdef EAPOL_PKT_PRIO
+	} else if (eh->ether_type == hton16(ETHER_TYPE_802_1X)) {
+		priority = PRIO_8021D_NC;
+		rc = PKTPRIO_DSCP;
+#endif /* EAPOL_PKT_PRIO */
 	} else if ((eh->ether_type == hton16(ETHER_TYPE_IP)) ||
 		(eh->ether_type == hton16(ETHER_TYPE_IPV6))) {
 		uint8 *ip_body = pktdata + sizeof(struct ether_header);
diff --git a/drivers/net/wireless/bcmdhd/dhd_flowring.c b/drivers/net/wireless/bcmdhd/dhd_flowring.c
index 95d186efb14e..d5addad1da7b 100644
--- a/drivers/net/wireless/bcmdhd/dhd_flowring.c
+++ b/drivers/net/wireless/bcmdhd/dhd_flowring.c
@@ -56,7 +56,11 @@ int BCMFASTPATH dhd_flow_queue_overflow(flow_queue_t *queue, void *pkt);
 #define FLOW_QUEUE_PKT_NEXT(p)          PKTLINK(p)
 #define FLOW_QUEUE_PKT_SETNEXT(p, x)    PKTSETLINK((p), (x))
 
+#ifdef EAPOL_PKT_PRIO
+const uint8 prio2ac[8] = { 0, 1, 1, 0, 2, 2, 3, 7 };
+#else
 const uint8 prio2ac[8] = { 0, 1, 1, 0, 2, 2, 3, 3 };
+#endif /* EAPOL_PKT_PRIO  */
 const uint8 prio2tid[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
 
 int BCMFASTPATH
@@ -769,7 +773,7 @@ int dhd_update_flow_prio_map(dhd_pub_t *dhdp, uint8 map)
 	uint16 flowid;
 	flow_ring_node_t *flow_ring_node;
 
-	if (map > DHD_FLOW_PRIO_TID_MAP)
+	if (map > DHD_FLOW_PRIO_LLR_MAP)
 		return BCME_BADOPTION;
 
 	/* Check if we need to change prio map */
diff --git a/drivers/net/wireless/bcmdhd/dhd_flowring.h b/drivers/net/wireless/bcmdhd/dhd_flowring.h
index 9f263b3a7450..211a0a1f8a61 100644
--- a/drivers/net/wireless/bcmdhd/dhd_flowring.h
+++ b/drivers/net/wireless/bcmdhd/dhd_flowring.h
@@ -6,13 +6,13 @@
  * flow rings at high level
  *
  * Copyright (C) 1999-2014, Broadcom Corporation
- * 
+ *
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
  * under the terms of the GNU General Public License version 2 (the "GPL"),
  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  * following added to such license:
- * 
+ *
  *      As a special exception, the copyright holders of this software give you
  * permission to link this software with independent modules, and to copy and
  * distribute the resulting executable under terms of your choice, provided that
@@ -20,7 +20,7 @@
  * the license of that module.  An independent module is a module which is not
  * derived from this software.  The special exception does not apply to any
  * modifications of the software.
- * 
+ *
  *      Notwithstanding the above, under no circumstances may you combine this
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
@@ -54,6 +54,7 @@
 
 #define DHD_FLOW_PRIO_AC_MAP		0
 #define DHD_FLOW_PRIO_TID_MAP		1
+#define DHD_FLOW_PRIO_LLR_MAP		2
 
 
 /* Pkttag not compatible with PROP_TXSTATUS or WLFC */
diff --git a/drivers/net/wireless/bcmdhd/dhd_linux.c b/drivers/net/wireless/bcmdhd/dhd_linux.c
index ef34207d4920..82e66b4b5593 100644
--- a/drivers/net/wireless/bcmdhd/dhd_linux.c
+++ b/drivers/net/wireless/bcmdhd/dhd_linux.c
@@ -5985,6 +5985,10 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
 #endif /* WL_CFG80211 */
 	setbit(eventmask, WLC_E_TRACE);
 
+#ifdef EAPOL_PKT_PRIO
+	dhd_update_flow_prio_map(dhd, DHD_FLOW_PRIO_LLR_MAP);
+#endif /* EAPOL_PKT_PRIO */
+
 	/* Write updated Event mask */
 	bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf));
 	if ((ret = dhd_wl_ioctl_cmd(dhd, WLC_SET_VAR, iovbuf, sizeof(iovbuf), TRUE, 0)) < 0) {
-- 
GitLab