Merge "[qca-nss-drv] Support for IGS module reference APIs."
diff --git a/exports/nss_igs.h b/exports/nss_igs.h
index 3f766c5..651fea4 100644
--- a/exports/nss_igs.h
+++ b/exports/nss_igs.h
@@ -22,8 +22,14 @@
#ifndef _NSS_IGS_H_
#define _NSS_IGS_H_
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+#ifdef CONFIG_NET_CLS_ACT
+#include <net/act_api.h>
+#endif
+#endif
+
/**
- * @addtogroup NSS ingress shaper subsystem
+ * @addtogroup nss_ingress_shaper_subsystem
* @{
*/
@@ -163,6 +169,44 @@
*/
extern bool nss_igs_verify_if_num(uint32_t if_num);
+
+#ifdef CONFIG_NET_CLS_ACT
+/*
+ * nss_igs_module_save()
+ * Save the ingress shaping module reference.
+ *
+ * @datatypes
+ * tc_action_ops \n
+ * module
+ *
+ * @param[in] act Operation structure for ingress shaping action.
+ * @param[in] module Module structure of ingress shaping module.
+ *
+ * @return
+ * None.
+ */
+extern void nss_igs_module_save(struct tc_action_ops *act, struct module *module);
+#endif
+
+/*
+ * nss_igs_module_get()
+ * Get the ingress shaping module reference.
+ *
+ * @return
+ * False if not able to take the ingress shaping module reference, otherwise true.
+ *
+ */
+extern bool nss_igs_module_get(void);
+
+/*
+ * nss_igs_module_put()
+ * Release the ingress shaping module reference.
+ *
+ * @return
+ * None.
+ */
+extern void nss_igs_module_put(void);
+
/**
* @}
*/
diff --git a/nss_igs.c b/nss_igs.c
index 1fd91eb..5b10bdd 100644
--- a/nss_igs.c
+++ b/nss_igs.c
@@ -14,9 +14,15 @@
**************************************************************************
*/
+#ifdef CONFIG_NET_CLS_ACT
+#include <linux/tc_act/tc_nss_mirred.h>
+#endif
+
#include "nss_tx_rx_common.h"
#include "nss_igs_stats.h"
+static struct module *nss_igs_module;
+
/*
* nss_igs_verify_if_num()
* Verify interface number passed to us.
@@ -152,3 +158,40 @@
return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.igs_handler_id];
}
EXPORT_SYMBOL(nss_igs_get_context);
+
+#ifdef CONFIG_NET_CLS_ACT
+/*
+ * nss_igs_module_save()
+ * Save the ingress shaping module reference.
+ */
+void nss_igs_module_save(struct tc_action_ops *act, struct module *module)
+{
+ nss_assert(act);
+ nss_assert(act->type == TCA_ACT_MIRRED_NSS);
+
+ nss_igs_module = module;
+}
+EXPORT_SYMBOL(nss_igs_module_save);
+#endif
+
+/*
+ * nss_igs_module_get()
+ * Get the ingress shaping module reference.
+ */
+bool nss_igs_module_get()
+{
+ nss_assert(nss_igs_module);
+ return try_module_get(nss_igs_module);
+}
+EXPORT_SYMBOL(nss_igs_module_get);
+
+/*
+ * nss_igs_module_put()
+ * Release the ingress shaping module reference.
+ */
+void nss_igs_module_put()
+{
+ nss_assert(nss_igs_module);
+ module_put(nss_igs_module);
+}
+EXPORT_SYMBOL(nss_igs_module_put);