[qca-nss-ecm] Renamed and moved the bond notifier into nss directory.
* This bond notifier is specific to the NSS front end. Each
acceleration engine front end should implement its own bond
notifier.
Change-Id: Ic02d1a92561189a6a86d82177b6c55b25f6ab3fa
Signed-off-by: Murat Sezgin <msezgin@codeaurora.org>
diff --git a/Makefile b/Makefile
index b7ab8a7..efa4c12 100755
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,7 @@
ifneq ($(findstring 3.4, $(KERNELVERSION)),)
ECM_INTERFACE_BOND_ENABLE=y
endif
-ecm-$(ECM_INTERFACE_BOND_ENABLE) += ecm_bond_notifier.o
+ecm-$(ECM_INTERFACE_BOND_ENABLE) += frontends/nss/ecm_nss_bond_notifier.o
ccflags-$(ECM_INTERFACE_BOND_ENABLE) += -DECM_INTERFACE_BOND_ENABLE
# #############################################################################
diff --git a/ecm_init.c b/ecm_init.c
index 5d7a927..d9b6a0c 100644
--- a/ecm_init.c
+++ b/ecm_init.c
@@ -67,12 +67,6 @@
extern int ecm_interface_init(void);
extern void ecm_interface_exit(void);
-#ifdef ECM_INTERFACE_BOND_ENABLE
-extern int ecm_bond_notifier_init(struct dentry *dentry);
-extern void ecm_bond_notifier_stop(int);
-extern void ecm_bond_notifier_exit(void);
-#endif
-
#ifdef ECM_CLASSIFIER_DSCP_ENABLE
extern int ecm_classifier_dscp_init(struct dentry *dentry);
extern void ecm_classifier_dscp_exit(void);
@@ -156,7 +150,7 @@
}
#ifdef ECM_INTERFACE_BOND_ENABLE
- ret = ecm_bond_notifier_init(ecm_dentry);
+ ret = ecm_front_end_bond_notifier_init(ecm_dentry);
if (0 != ret) {
goto err_bond;
}
@@ -201,7 +195,7 @@
ecm_front_end_ipv4_exit();
err_fe_ipv4:
#ifdef ECM_INTERFACE_BOND_ENABLE
- ecm_bond_notifier_exit();
+ ecm_front_end_bond_notifier_exit();
err_bond:
#endif
ecm_interface_exit();
@@ -261,7 +255,7 @@
#endif
#ifdef ECM_INTERFACE_BOND_ENABLE
DEBUG_INFO("stop bond notifier\n");
- ecm_bond_notifier_stop(1);
+ ecm_front_end_bond_notifier_stop(1);
#endif
DEBUG_INFO("defunct all db connections\n");
ecm_db_connection_defunct_all();
@@ -281,7 +275,7 @@
#endif
#ifdef ECM_INTERFACE_BOND_ENABLE
DEBUG_INFO("exit bond notifier\n");
- ecm_bond_notifier_exit();
+ ecm_front_end_bond_notifier_exit();
#endif
DEBUG_INFO("exit interface\n");
ecm_interface_exit();
diff --git a/frontends/ecm_front_end_common.c b/frontends/ecm_front_end_common.c
index 7ded197..99eb885 100644
--- a/frontends/ecm_front_end_common.c
+++ b/frontends/ecm_front_end_common.c
@@ -46,7 +46,7 @@
#include "ecm_tracker_udp.h"
#include "ecm_tracker_tcp.h"
#include "ecm_db.h"
-#include "ecm_nss_conntrack_notifier.h"
+#include "ecm_front_end_common.h"
/*
* ecm_front_end_conntrack_notifier_stop()
@@ -111,3 +111,67 @@
ecm_nss_conntrack_notifier_exit();
}
+
+/*
+ * ecm_front_end_bond_notifier_stop()
+ */
+void ecm_front_end_bond_notifier_stop(int num)
+{
+ /*
+ * If the device tree is used, check which accel engine's bond notifier
+ * will be stopped.
+ * For ipq8064 platforms, we will stop NSS version.
+ */
+#ifdef CONFIG_OF
+ /*
+ * Check the other platforms and use the correct APIs for those platforms.
+ */
+ if (!of_machine_is_compatible("qcom,ipq8064")) {
+ return;
+ }
+#endif
+ ecm_nss_bond_notifier_stop(num);
+}
+
+/*
+ * ecm_front_end_bond_notifier_init()
+ */
+int ecm_front_end_bond_notifier_init(struct dentry *dentry)
+{
+ /*
+ * If the device tree is used, check which accel engine's bond notifier
+ * can be used.
+ * For ipq8064 platform, we will use NSS.
+ */
+#ifdef CONFIG_OF
+ /*
+ * Check the other platforms and use the correct APIs for those platforms.
+ */
+ if (!of_machine_is_compatible("qcom,ipq8064")) {
+ return -1;
+ }
+#endif
+ return ecm_nss_bond_notifier_init(dentry);
+}
+
+/*
+ * ecm_front_end_bond_notifier_exit()
+ */
+void ecm_front_end_bond_notifier_exit(void)
+{
+ /*
+ * If the device tree is used, check which accel engine's conntack notifier
+ * will be exited.
+ * For ipq8064 platforms, we will exit NSS.
+ */
+#ifdef CONFIG_OF
+ /*
+ * Check the other platforms and use the correct APIs for those platforms.
+ */
+ if (!of_machine_is_compatible("qcom,ipq8064")) {
+ return;
+ }
+#endif
+ ecm_nss_bond_notifier_exit();
+}
+
diff --git a/frontends/include/ecm_front_end_common.h b/frontends/include/ecm_front_end_common.h
index ec9356b..0da2d09 100644
--- a/frontends/include/ecm_front_end_common.h
+++ b/frontends/include/ecm_front_end_common.h
@@ -16,6 +16,7 @@
#include <linux/if_pppox.h>
#include "ecm_nss_conntrack_notifier.h"
+#include "ecm_nss_bond_notifier.h"
/*
* ecm_front_end_l2_encap_header_len()
@@ -54,3 +55,7 @@
extern void ecm_front_end_conntrack_notifier_stop(int num);
extern int ecm_front_end_conntrack_notifier_init(struct dentry *dentry);
extern void ecm_front_end_conntrack_notifier_exit(void);
+
+extern void ecm_front_end_bond_notifier_stop(int num);
+extern int ecm_front_end_bond_notifier_init(struct dentry *dentry);
+extern void ecm_front_end_bond_notifier_exit(void);
diff --git a/ecm_bond_notifier.c b/frontends/nss/ecm_nss_bond_notifier.c
similarity index 66%
rename from ecm_bond_notifier.c
rename to frontends/nss/ecm_nss_bond_notifier.c
index 527bcb0..37fb419 100644
--- a/ecm_bond_notifier.c
+++ b/frontends/nss/ecm_nss_bond_notifier.c
@@ -15,7 +15,7 @@
*/
/*
- * ecm_bond_notifier.c
+ * ecm_nss_bond_notifier.c
* Bonding notifier functionality.
*/
@@ -90,34 +90,34 @@
/*
* Locking of the classifier - concurrency control
*/
-static DEFINE_SPINLOCK(ecm_bond_notifier_lock); /* Protect against SMP access between netfilter, events and private threaded function. */
+static DEFINE_SPINLOCK(ecm_nss_bond_notifier_lock); /* Protect against SMP access between netfilter, events and private threaded function. */
/*
* Debugfs dentry object.
*/
-static struct dentry *ecm_bond_notifier_dentry;
+static struct dentry *ecm_nss_bond_notifier_dentry;
/*
* General operational control
*/
-static int ecm_bond_notifier_stopped = 0; /* When non-zero further traffic will not be processed */
+static int ecm_nss_bond_notifier_stopped = 0; /* When non-zero further traffic will not be processed */
/*
- * ecm_bond_notifier_bond_cb
+ * ecm_nss_bond_notifier_bond_cb
* Bond driver notifier
*/
-static struct bond_cb ecm_bond_notifier_bond_cb;
+static struct bond_cb ecm_nss_bond_notifier_bond_cb;
/*
* NSS Context for LAG function
*/
-static void *ecm_bond_notifier_nss_context = NULL; /* Registration for LAG */
+static void *ecm_nss_bond_notifier_nss_context = NULL; /* Registration for LAG */
/*
- * ecm_bond_notifier_send_lag_state()
+ * ecm_nss_bond_notifier_send_lag_state()
* Send the currnet LAG state of a physical interface that has changed state in the bonding driver.
*/
-static nss_tx_status_t ecm_bond_notifier_send_lag_state(struct nss_ctx_instance *nss_ctx, struct net_device *slave, enum nss_lag_state_change_ev slave_state)
+static nss_tx_status_t ecm_nss_bond_notifier_send_lag_state(struct nss_ctx_instance *nss_ctx, struct net_device *slave, enum nss_lag_state_change_ev slave_state)
{
int32_t lagid = 0;
int32_t bondid = 0;
@@ -173,63 +173,63 @@
}
/*
- * ecm_bond_notifier_bond_release()
+ * ecm_nss_bond_notifier_bond_release()
* Callback when a slave device is released from slavedom and no longer a part of a bonded interface.
*/
-static void ecm_bond_notifier_bond_release(struct net_device *slave_dev)
+static void ecm_nss_bond_notifier_bond_release(struct net_device *slave_dev)
{
/*
* If operations have stopped then do not process event
*/
DEBUG_INFO("Bond slave release: %p (%s)\n", slave_dev, slave_dev->name);
- spin_lock_bh(&ecm_bond_notifier_lock);
- if (unlikely(ecm_bond_notifier_stopped)) {
+ spin_lock_bh(&ecm_nss_bond_notifier_lock);
+ if (unlikely(ecm_nss_bond_notifier_stopped)) {
DEBUG_WARN("Ignoring bond release event - stopped\n");
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
return;
}
- spin_unlock_bh(&ecm_bond_notifier_lock);
- ecm_bond_notifier_send_lag_state(ecm_bond_notifier_nss_context, slave_dev, NSS_LAG_RELEASE);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
+ ecm_nss_bond_notifier_send_lag_state(ecm_nss_bond_notifier_nss_context, slave_dev, NSS_LAG_RELEASE);
}
/*
- * ecm_bond_notifier_bond_enslave()
+ * ecm_nss_bond_notifier_bond_enslave()
* Callback when a device is enslaved by a LAG master device
*/
-static void ecm_bond_notifier_bond_enslave(struct net_device *slave_dev)
+static void ecm_nss_bond_notifier_bond_enslave(struct net_device *slave_dev)
{
/*
* If operations have stopped then do not process event
*/
DEBUG_INFO("Bond slave enslave: %p (%s)\n", slave_dev, slave_dev->name);
- spin_lock_bh(&ecm_bond_notifier_lock);
- if (unlikely(ecm_bond_notifier_stopped)) {
+ spin_lock_bh(&ecm_nss_bond_notifier_lock);
+ if (unlikely(ecm_nss_bond_notifier_stopped)) {
DEBUG_WARN("Ignoring bond enslave event - stopped\n");
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
return;
}
- spin_unlock_bh(&ecm_bond_notifier_lock);
- ecm_bond_notifier_send_lag_state(ecm_bond_notifier_nss_context, slave_dev, NSS_LAG_ENSLAVE);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
+ ecm_nss_bond_notifier_send_lag_state(ecm_nss_bond_notifier_nss_context, slave_dev, NSS_LAG_ENSLAVE);
}
/*
- * ecm_bond_notifier_bond_link_down()
+ * ecm_nss_bond_notifier_bond_link_down()
* Callback when a link goes down on a LAG slave
*/
-static void ecm_bond_notifier_bond_link_down(struct net_device *slave_dev)
+static void ecm_nss_bond_notifier_bond_link_down(struct net_device *slave_dev)
{
struct net_device *master;
/*
* If operations have stopped then do not process event
*/
- spin_lock_bh(&ecm_bond_notifier_lock);
- if (unlikely(ecm_bond_notifier_stopped)) {
+ spin_lock_bh(&ecm_nss_bond_notifier_lock);
+ if (unlikely(ecm_nss_bond_notifier_stopped)) {
DEBUG_WARN("Ignoring bond link down event - stopped\n");
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
return;
}
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
/*
* A net device that is a LAG slave has lost link.
@@ -248,20 +248,20 @@
* ecm_bond_notifier_bond_link_up()
* Callback when a device is enslaved by a LAG master device
*/
-static void ecm_bond_notifier_bond_link_up(struct net_device *slave_dev)
+static void ecm_nss_bond_notifier_bond_link_up(struct net_device *slave_dev)
{
struct net_device *master;
/*
* If operations have stopped then do not process event
*/
- spin_lock_bh(&ecm_bond_notifier_lock);
- if (unlikely(ecm_bond_notifier_stopped)) {
+ spin_lock_bh(&ecm_nss_bond_notifier_lock);
+ if (unlikely(ecm_nss_bond_notifier_stopped)) {
DEBUG_WARN("Ignoring bond enslave event - stopped\n");
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
return;
}
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
/*
* Tricky to handle, this one.
@@ -277,21 +277,21 @@
}
/*
- * ecm_bond_notifier_lag_event_cb()
+ * ecm_nss_bond_notifier_lag_event_cb()
* Handle LAG event from the NSS driver
*/
-static void ecm_bond_notifier_lag_event_cb(void *if_ctx, struct nss_lag_msg *msg)
+static void ecm_nss_bond_notifier_lag_event_cb(void *if_ctx, struct nss_lag_msg *msg)
{
/*
* If operations have stopped then do not process event
*/
- spin_lock_bh(&ecm_bond_notifier_lock);
- if (unlikely(ecm_bond_notifier_stopped)) {
+ spin_lock_bh(&ecm_nss_bond_notifier_lock);
+ if (unlikely(ecm_nss_bond_notifier_stopped)) {
DEBUG_WARN("Ignoring LAG event event - stopped\n");
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
return;
}
- spin_unlock_bh(&ecm_bond_notifier_lock);
+ spin_unlock_bh(&ecm_nss_bond_notifier_lock);
/*
* GGG TODO Figure out if there is anything we need to do here, the old CM did nothing..
@@ -304,55 +304,55 @@
}
}
-void ecm_bond_notifier_stop(int num)
+void ecm_nss_bond_notifier_stop(int num)
{
- ecm_bond_notifier_stopped = num;
+ ecm_nss_bond_notifier_stopped = num;
}
-EXPORT_SYMBOL(ecm_bond_notifier_stop);
+EXPORT_SYMBOL(ecm_nss_bond_notifier_stop);
/*
- * ecm_bond_notifier_init()
+ * ecm_nss_bond_notifier_init()
*/
-int ecm_bond_notifier_init(struct dentry *dentry)
+int ecm_nss_bond_notifier_init(struct dentry *dentry)
{
DEBUG_INFO("ECM Bonding Notifier init\n");
- ecm_bond_notifier_dentry = debugfs_create_dir("ecm_bond_notifier", dentry);
- if (!ecm_bond_notifier_dentry) {
+ ecm_nss_bond_notifier_dentry = debugfs_create_dir("ecm_nss_bond_notifier", dentry);
+ if (!ecm_nss_bond_notifier_dentry) {
DEBUG_ERROR("Failed to create ecm bond notifier directory in debugfs\n");
return -1;
}
- if (!debugfs_create_u32("stop", S_IRUGO | S_IWUSR, ecm_bond_notifier_dentry,
- (u32 *)&ecm_bond_notifier_stopped)) {
+ if (!debugfs_create_u32("stop", S_IRUGO | S_IWUSR, ecm_nss_bond_notifier_dentry,
+ (u32 *)&ecm_nss_bond_notifier_stopped)) {
DEBUG_ERROR("Failed to create ecm bond notifier stopped file in debugfs\n");
- debugfs_remove_recursive(ecm_bond_notifier_dentry);
+ debugfs_remove_recursive(ecm_nss_bond_notifier_dentry);
return -1;
}
/*
* Register Link Aggregation interfaces with NSS driver
*/
- ecm_bond_notifier_nss_context = nss_register_lag_if(NSS_LAG0_INTERFACE_NUM, NULL, ecm_bond_notifier_lag_event_cb, NULL);
- ecm_bond_notifier_nss_context = nss_register_lag_if(NSS_LAG1_INTERFACE_NUM, NULL, ecm_bond_notifier_lag_event_cb, NULL);
+ ecm_nss_bond_notifier_nss_context = nss_register_lag_if(NSS_LAG0_INTERFACE_NUM, NULL, ecm_nss_bond_notifier_lag_event_cb, NULL);
+ ecm_nss_bond_notifier_nss_context = nss_register_lag_if(NSS_LAG1_INTERFACE_NUM, NULL, ecm_nss_bond_notifier_lag_event_cb, NULL);
/*
* Register Link Aggregation callbacks with the bonding driver
*/
- ecm_bond_notifier_bond_cb.bond_cb_link_up = ecm_bond_notifier_bond_link_up;
- ecm_bond_notifier_bond_cb.bond_cb_link_down = ecm_bond_notifier_bond_link_down;
- ecm_bond_notifier_bond_cb.bond_cb_release = ecm_bond_notifier_bond_release;
- ecm_bond_notifier_bond_cb.bond_cb_enslave = ecm_bond_notifier_bond_enslave;
- bond_register_cb(&ecm_bond_notifier_bond_cb);
+ ecm_nss_bond_notifier_bond_cb.bond_cb_link_up = ecm_nss_bond_notifier_bond_link_up;
+ ecm_nss_bond_notifier_bond_cb.bond_cb_link_down = ecm_nss_bond_notifier_bond_link_down;
+ ecm_nss_bond_notifier_bond_cb.bond_cb_release = ecm_nss_bond_notifier_bond_release;
+ ecm_nss_bond_notifier_bond_cb.bond_cb_enslave = ecm_nss_bond_notifier_bond_enslave;
+ bond_register_cb(&ecm_nss_bond_notifier_bond_cb);
return 0;
}
-EXPORT_SYMBOL(ecm_bond_notifier_init);
+EXPORT_SYMBOL(ecm_nss_bond_notifier_init);
/*
- * ecm_bond_notifier_exit()
+ * ecm_nss_bond_notifier_exit()
*/
-void ecm_bond_notifier_exit(void)
+void ecm_nss_bond_notifier_exit(void)
{
DEBUG_INFO("ECM Bonding Notifier exit\n");
@@ -370,8 +370,8 @@
/*
* Remove the debugfs files recursively.
*/
- if (ecm_bond_notifier_dentry) {
- debugfs_remove_recursive(ecm_bond_notifier_dentry);
+ if (ecm_nss_bond_notifier_dentry) {
+ debugfs_remove_recursive(ecm_nss_bond_notifier_dentry);
}
}
-EXPORT_SYMBOL(ecm_bond_notifier_exit);
+EXPORT_SYMBOL(ecm_nss_bond_notifier_exit);
diff --git a/frontends/nss/ecm_nss_bond_notifier.h b/frontends/nss/ecm_nss_bond_notifier.h
new file mode 100644
index 0000000..3b78fc6
--- /dev/null
+++ b/frontends/nss/ecm_nss_bond_notifier.h
@@ -0,0 +1,19 @@
+/*
+ **************************************************************************
+ * Copyright (c) 2015, 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
+ * above copyright notice and this permission notice appear in all copies.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ **************************************************************************
+ */
+
+extern void ecm_nss_bond_notifier_stop(int num);
+extern int ecm_nss_bond_notifier_init(struct dentry *dentry);
+extern void ecm_nss_bond_notifier_exit(void);