Snap for 4797264 from 649bd455bff730fe94c53fabcf8722a37bfcb49a to p-keystone-qcom-release

Change-Id: I08654f637d65a2cd387baae5a81333173bd8e6ed
diff --git a/tc/Android.mk b/tc/Android.mk
index 78463a8..601b61c 100644
--- a/tc/Android.mk
+++ b/tc/Android.mk
@@ -3,7 +3,8 @@
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES :=  tc.c tc_exec.c tc_qdisc.c q_cbq.c tc_util.c tc_class.c tc_core.c m_action.c \
                     m_estimator.c tc_filter.c tc_monitor.c tc_stab.c tc_cbq.c \
-                    tc_estimator.c f_u32.c m_police.c q_ingress.c m_mirred.c q_htb.c
+                    tc_estimator.c f_u32.c m_police.c q_ingress.c m_mirred.c q_htb.c \
+                    f_fw.c q_prio.c q_fifo.c
 
 LOCAL_MODULE := tc
 
@@ -14,7 +15,9 @@
 
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include $(UAPI_INCLUDES)
 
-LOCAL_CFLAGS := -O2 -g -W -Wall -Wno-pointer-arith -Wno-sign-compare -Werror \
+LOCAL_CFLAGS := -DFEATURE_PRIO
+
+LOCAL_CFLAGS += -O2 -g -W -Wall -Wno-pointer-arith -Wno-sign-compare -Werror \
     -Wno-unused-parameter \
     -Wno-missing-field-initializers
 
diff --git a/tc/q_prio.c b/tc/q_prio.c
index a28928a..7db9f01 100644
--- a/tc/q_prio.c
+++ b/tc/q_prio.c
@@ -23,16 +23,22 @@
 #include "utils.h"
 #include "tc_util.h"
 
+struct prio_qopt {
+	int bands;			/* Number of bands */
+	__u8 priomap[TC_PRIO_MAX+1];	/* Map: logical priority -> PRIO band */
+	__u8 enable_flow; 		/* Enable dequeue */
+};
+
 static void explain(void)
 {
-	fprintf(stderr, "Usage: ... prio bands NUMBER priomap P1 P2...[multiqueue]\n");
+	fprintf(stderr, "Usage: ... prio bands NUMBER priomap P1 P2...[multiqueue] [flow (enable|disable)]\n");
 }
 
 static int prio_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
 {
 	int pmap_mode = 0;
 	int idx = 0;
-	struct tc_prio_qopt opt = {3, { 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 } };
+	struct prio_qopt opt = {3, { 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }, 1};
 	struct rtattr *nest;
 	unsigned char mq = 0;
 
@@ -53,6 +59,21 @@
 			pmap_mode = 1;
 		} else if (strcmp(*argv, "multiqueue") == 0) {
 			mq = 1;
+		} else if (strcmp(*argv, "flow") == 0) {
+			NEXT_ARG();
+			if (strcmp(*argv, "enable") == 0)
+			{
+				opt.enable_flow = 1;
+			}
+			else if (strcmp(*argv, "disable") == 0)
+			{
+				opt.enable_flow = 0;
+			}
+			else
+			{
+				explain();
+				return -1;
+			}
 		} else if (strcmp(*argv, "help") == 0) {
 			explain();
 			return -1;
@@ -97,7 +118,7 @@
 int prio_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 {
 	int i;
-	struct tc_prio_qopt *qopt;
+	struct prio_qopt *qopt;
 	struct rtattr *tb[TCA_PRIO_MAX+1];
 
 	if (opt == NULL)
@@ -115,6 +136,9 @@
 		fprintf(f, " multiqueue: %s ",
 			rta_getattr_u8(tb[TCA_PRIO_MQ]) ? "on" : "off");
 
+	if (qu && !strcmp(qu->id, "prio"))
+		fprintf(f, " flow %s", qopt->enable_flow ? "enabled" : "disabled");
+
 	return 0;
 }
 
diff --git a/tc/tc.c b/tc/tc.c
index 82a3004..52616d9 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -56,6 +56,12 @@
 extern struct qdisc_util htb_qdisc_util;
 extern struct qdisc_util ingress_qdisc_util;
 extern struct filter_util u32_filter_util;
+#ifdef FEATURE_PRIO
+extern struct filter_util fw_filter_util;
+extern struct qdisc_util prio_qdisc_util;
+extern struct qdisc_util pfifo_fast_qdisc_util;
+extern struct qdisc_util pfifo_qdisc_util;
+#endif
 #endif
 
 static int print_noqopt(struct qdisc_util *qu, FILE *f,
@@ -119,6 +125,14 @@
 		return &htb_qdisc_util;
 	else if (!strcmp(str, "ingress"))
 		return &ingress_qdisc_util;
+#ifdef FEATURE_PRIO
+	else if (!strcmp(str, "pfifo_fast"))
+		return &pfifo_fast_qdisc_util;
+	else if (!strcmp(str, "prio"))
+		return &prio_qdisc_util;
+	else if (!strcmp(str, "pfifo"))
+		return &pfifo_qdisc_util;
+#endif
 	else {
 		fprintf(stderr, "Android does not support qdisc '%s'\n", str);
 		return NULL;
@@ -170,6 +184,10 @@
 #ifdef ANDROID
 	if (!strcmp(str, "u32"))
 		return &u32_filter_util;
+#ifdef FEATURE_PRIO
+	else if (!strcmp(str, "fw"))
+		return &fw_filter_util;
+#endif
 	else {
 		fprintf(stderr, "Android does not support filter '%s'\n", str);
 		return NULL;
diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c
index 493538c..b30bb04 100644
--- a/tc/tc_qdisc.c
+++ b/tc/tc_qdisc.c
@@ -262,11 +262,7 @@
 	if (t->tcm_info != 1)
 		fprintf(fp, "refcnt %d ", t->tcm_info);
 
-	/* pfifo_fast is generic enough to warrant the hardcoding --JHS */
-	if (strcmp("pfifo_fast", RTA_DATA(tb[TCA_KIND])) == 0)
-		q = get_qdisc_kind("prio");
-	else
-		q = get_qdisc_kind(RTA_DATA(tb[TCA_KIND]));
+	q = get_qdisc_kind(RTA_DATA(tb[TCA_KIND]));
 
 	if (tb[TCA_OPTIONS]) {
 		if (q)