[qca-nss-ecm] Enable/Disable ECM features

Add facility in Makefile and code to select features based on
kernel version or user preference.

Change-Id: Ia224eacfb4a75c170d64216d3b84a8513a12297c
Signed-off-by: Gareth Williams <garethw@codeaurora.org>
diff --git a/Makefile b/Makefile
index b716fa7..3db60f9 100755
--- a/Makefile
+++ b/Makefile
@@ -19,28 +19,76 @@
 obj-m += ecm.o
 
 ecm-y := \
-	 ecm_classifier_dscp.o \
-	 ecm_classifier_nl.o \
 	 ecm_tracker_udp.o \
 	 ecm_tracker_tcp.o \
 	 ecm_tracker_datagram.o \
 	 ecm_tracker.o \
 	 ecm_front_end_ipv4.o \
-	 ecm_front_end_ipv6.o \
 	 ecm_db.o \
 	 ecm_classifier_default.o \
 	 ecm_conntrack_notifier.o \
 	 ecm_interface.o \
-	 ecm_bond_notifier.o \
 	 ecm_init.o
 
-#
-# Define ECM_CLASSIFIER_HYFI_ENABLE=y in order to enable
-# the Hy-Fi classifier in ECM. Currently disabled until
-# the integration with Hy-Fi is completed.
-#
-ecm-$(ECM_CLASSIFIER_HYFI_ENABLE) += ecm_classifier_hyfi.o
+# #############################################################################
+# Define ECM_INTERFACE_BOND_ENABLE=y in order to enable
+# Bonding / Link Aggregation support.
+# #############################################################################
+ifeq ("$(KERNELVERSION)","3.4.0")
+ECM_INTERFACE_BOND_ENABLE=y
+endif
+ecm-$(ECM_INTERFACE_BOND_ENABLE) += ecm_bond_notifier.o
+ccflags-$(ECM_INTERFACE_BOND_ENABLE) += -DECM_INTERFACE_BOND_ENABLE
 
+# #############################################################################
+# Define ECM_INTERFACE_PPP_SUPPORT=y in order
+# to enable support for PPP and, specifically, PPPoE acceleration.
+# #############################################################################
+ifeq ("$(KERNELVERSION)","3.4.0")
+ECM_INTERFACE_PPP_ENABLE=y
+endif
+ccflags-$(ECM_INTERFACE_PPP_ENABLE) += -DECM_INTERFACE_PPP_ENABLE
+
+# #############################################################################
+# Define ECM_FRONT_END_IPV6_ENABLE=y in order to enable IPv6 front end.
+# #############################################################################
+ifeq ("$(KERNELVERSION)","3.4.0")
+ECM_FRONT_END_IPV6_ENABLE=y
+endif
+ecm-$(ECM_FRONT_END_IPV6_ENABLE) += ecm_front_end_ipv6.o
+ccflags-$(ECM_FRONT_END_IPV6_ENABLE) += -DECM_FRONT_END_IPV6_ENABLE
+
+# #############################################################################
+# Define ECM_CLASSIFIER_NL_ENABLE=y in order to enable NL classifier.
+# #############################################################################
+ifeq ("$(KERNELVERSION)","3.4.0")
+ECM_CLASSIFIER_NL_ENABLE=y
+endif
+ecm-$(ECM_CLASSIFIER_NL_ENABLE) += ecm_classifier_nl.o
+ccflags-$(ECM_CLASSIFIER_NL_ENABLE) += -DECM_CLASSIFIER_NL_ENABLE
+
+# #############################################################################
+# Define ECM_CLASSIFIER_DSCP_ENABLE=y in order to enable DSCP classifier.
+# #############################################################################
+ifeq ("$(KERNELVERSION)","3.4.0")
+ECM_CLASSIFIER_DSCP_ENABLE=y
+endif
+ecm-$(ECM_CLASSIFIER_DSCP_ENABLE) += ecm_classifier_dscp.o
+ccflags-$(ECM_CLASSIFIER_DSCP_ENABLE) += -DECM_CLASSIFIER_DSCP_ENABLE
+
+# #############################################################################
+# Define ECM_CLASSIFIER_HYFI_ENABLE=y in order to enable
+# the Hy-Fi classifier in ECM. Currently disabled until the integration
+# with Hy-Fi is completed.
+# #############################################################################
+ecm-$(ECM_CLASSIFIER_HYFI_ENABLE) += ecm_classifier_hyfi.o
+ccflags-$(ECM_CLASSIFIER_HYFI_ENABLE) += -DECM_CLASSIFIER_HYFI_ENABLE
+
+# #############################################################################
+# Debug flags, set these to = 0 if you want to disable all debugging for that
+# file.
+# By turning off debugs you gain maximum ECM performance.
+# #############################################################################
 ccflags-y += -DECM_CLASSIFIER_DSCP_DEBUG_LEVEL=1
 ccflags-y += -DECM_CLASSIFIER_HYFI_DEBUG_LEVEL=1
 ccflags-y += -DECM_CLASSIFIER_NL_DEBUG_LEVEL=1
@@ -55,7 +103,6 @@
 ccflags-y += -DECM_TRACKER_UDP_DEBUG_LEVEL=1
 ccflags-y += -DECM_BOND_NOTIFIER_DEBUG_LEVEL=1
 ccflags-y += -DECM_INTERFACE_DEBUG_LEVEL=1
-ccflags-$(ECM_CLASSIFIER_HYFI_ENABLE) += -DECM_CLASSIFIER_HYFI_ENABLE
 
 obj ?= .
 
diff --git a/ecm_conntrack_notifier.c b/ecm_conntrack_notifier.c
index 70849c8..2a19664 100644
--- a/ecm_conntrack_notifier.c
+++ b/ecm_conntrack_notifier.c
@@ -81,7 +81,9 @@
 #include "ecm_db.h"
 #include "ecm_classifier_default.h"
 #include "ecm_front_end_ipv4.h"
+#ifdef ECM_CLASSIFIER_FRONT_END_IPV6
 #include "ecm_front_end_ipv6.h"
+#endif
 
 /*
  * Locking of the classifier - concurrency control
@@ -143,10 +145,14 @@
 	 */
 	if (nf_ct_l3num(ct) == AF_INET) {
 		return ecm_front_end_ipv4_conntrack_event(events, ct);
+	}
+#ifndef ECM_CLASSIFIER_FRONT_END_IPV6
+	}
+#else
 	} else if (nf_ct_l3num(ct) == AF_INET6) {
 		return ecm_front_end_ipv6_conntrack_event(events, ct);
 	}
-
+#endif
 	return NOTIFY_DONE;
 }
 
diff --git a/ecm_front_end_ipv6.c b/ecm_front_end_ipv6.c
index e2259e4..d4eff84 100644
--- a/ecm_front_end_ipv6.c
+++ b/ecm_front_end_ipv6.c
@@ -457,7 +457,7 @@
 		 * will use to emit to the destination address.
 		 */
 		do {
-#ifdef ECM_INTERFACE_PPP_SUPPORT
+#ifdef ECM_INTERFACE_PPP_ENABLE
 			int channel_count;
 			struct ppp_channel *ppp_chan[1];
 			int channel_protocol;
@@ -657,7 +657,7 @@
 				break;
 			}
 
-#ifndef ECM_INTERFACE_PPP_SUPPORT
+#ifndef ECM_INTERFACE_PPP_ENABLE
 			DEBUG_TRACE("Net device: %p is UNKNOWN (PPP Unsupported) type: %d\n", dest_dev, dest_dev_type);
 #else
 			/*
diff --git a/ecm_interface.c b/ecm_interface.c
index 7c89ae4..7856a8c 100644
--- a/ecm_interface.c
+++ b/ecm_interface.c
@@ -700,7 +700,7 @@
 	return nii;
 }
 
-#ifdef ECM_INTERFACE_PPP_SUPPORT
+#ifdef ECM_INTERFACE_PPP_ENABLE
 /*
  * ecm_interface_pppoe_interface_establish()
  *	Returns a reference to a iface of the PPPoE type, possibly creating one if necessary.
@@ -1031,7 +1031,7 @@
 		struct ecm_db_interface_info_tunipip6 tunipip6;		/* type == ECM_DB_IFACE_TYPE_TUNIPIP6 */
 	} type_info;
 
-#ifdef ECM_INTERFACE_PPP_SUPPORT
+#ifdef ECM_INTERFACE_PPP_ENABLE
 	int channel_count;
 	struct ppp_channel *ppp_chan[1];
 	int channel_protocol;
@@ -1238,7 +1238,7 @@
 		return ii;
 	}
 
-#ifndef ECM_INTERFACE_PPP_SUPPORT
+#ifndef ECM_INTERFACE_PPP_ENABLE
 	/*
 	 * PPP support is NOT provided for.
 	 * Interface is therefore unknown
@@ -1551,7 +1551,7 @@
 		 * will use to emit to the destination address.
 		 */
 		do {
-#ifdef ECM_INTERFACE_PPP_SUPPORT
+#ifdef ECM_INTERFACE_PPP_ENABLE
 			int channel_count;
 			struct ppp_channel *ppp_chan[1];
 			int channel_protocol;
@@ -1824,7 +1824,7 @@
 				break;
 			}
 
-#ifndef ECM_INTERFACE_PPP_SUPPORT
+#ifndef ECM_INTERFACE_PPP_ENABLE
 			DEBUG_TRACE("Net device: %p is UNKNOWN (PPP Unsupported) type: %d\n", dest_dev, dest_dev_type);
 #else
 			/*