Add function to get bonding nss context.
Add function to get nss interface number for a net
device without needing an nss context.
Change-Id: I8b26ebdb3a8dfd7ee6153547d0b5ecdf9e9235cd
Signed-off-by: Gareth Williams <garethw@codeaurora.org>
diff --git a/nss_cmn.c b/nss_cmn.c
index f2d26c7..4af208b 100644
--- a/nss_cmn.c
+++ b/nss_cmn.c
@@ -90,6 +90,31 @@
}
/*
+ * nss_cmn_get_interface_number_by_dev()
+ * Return the NSS interface id for the net_device.
+ *
+ * Returns < 0 on failure or the NSS interface id for the given device.
+ */
+int32_t nss_cmn_get_interface_number_by_dev(struct net_device *dev)
+{
+ int i;
+
+ nss_assert(dev != 0);
+
+ /*
+ * Check physical interface table
+ */
+ for (i = 0; i < NSS_MAX_NET_INTERFACES; i++) {
+ if (dev == nss_top_main.if_ctx[i]) {
+ return i;
+ }
+ }
+
+ nss_warning("Interface number could not be found for %p (%s) as interface has not registered yet", dev, dev->name);
+ return -1;
+}
+
+/*
* nss_cmn_get_state()
* return the NSS initialization state
*/
@@ -176,6 +201,7 @@
EXPORT_SYMBOL(nss_cmn_get_state);
EXPORT_SYMBOL(nss_cmn_interface_is_virtual);
EXPORT_SYMBOL(nss_cmn_msg_init);
+EXPORT_SYMBOL(nss_cmn_get_interface_number_by_dev);
EXPORT_SYMBOL(nss_cmn_register_queue_decongestion);
EXPORT_SYMBOL(nss_cmn_unregister_queue_decongestion);