[][openwrt][mt7988][crytpo][add debugfs for crypto module]
[Description]
Add debugfs for crypto module to show SPI and CDRT idx of offloaed
xfrm states.
[Release-log]
N/A
Change-Id: I7ab7559eddd2ac92ad3ce2ca516655f581e85edf
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9350757
diff --git a/feed/kernel/crypto-eip/src/xfrm-offload.c b/feed/kernel/crypto-eip/src/xfrm-offload.c
index 2d8702d..1075b77 100644
--- a/feed/kernel/crypto-eip/src/xfrm-offload.c
+++ b/feed/kernel/crypto-eip/src/xfrm-offload.c
@@ -7,6 +7,7 @@
*/
#include <linux/bitops.h>
+#include <linux/spinlock.h>
#include <mtk_eth_soc.h>
@@ -27,7 +28,10 @@
#include "crypto-eip/ddk-wrapper.h"
#include "crypto-eip/internal.h"
-static LIST_HEAD(xfrm_params_head);
+static struct xfrm_params_list xfrm_params_list = {
+ .list = LIST_HEAD_INIT(xfrm_params_list.list),
+ .lock = __SPIN_LOCK_UNLOCKED(xfrm_params_list.lock),
+};
#if IS_ENABLED(CONFIG_NET_MEDIATEK_HNAT)
extern int (*ra_sw_nat_hook_tx)(struct sk_buff *skb, int gmac_no);
@@ -50,6 +54,11 @@
}
#endif // HNAT
+struct xfrm_params_list *mtk_xfrm_params_list_get(void)
+{
+ return &xfrm_params_list;
+}
+
static void mtk_xfrm_offload_cdrt_tear_down(struct mtk_xfrm_params *xfrm_params)
{
memset(&xfrm_params->cdrt->desc, 0, sizeof(struct cdrt_desc));
@@ -220,6 +229,7 @@
int mtk_xfrm_offload_state_add(struct xfrm_state *xs)
{
struct mtk_xfrm_params *xfrm_params;
+ unsigned long flags;
int ret = 0;
/* TODO: maybe support IPv6 in the future? */
@@ -261,7 +271,12 @@
}
xs->xso.offload_handle = (unsigned long)xfrm_params;
- list_add_tail(&xfrm_params->node, &xfrm_params_head);
+
+ spin_lock_irqsave(&xfrm_params_list.lock, flags);
+
+ list_add_tail(&xfrm_params->node, &xfrm_params_list.list);
+
+ spin_unlock_irqrestore(&xfrm_params_list.lock, flags);
out:
return ret;
}
@@ -294,9 +309,14 @@
void mtk_xfrm_offload_state_tear_down(void)
{
struct mtk_xfrm_params *xfrm_params, *tmp;
+ unsigned long flags;
- list_for_each_entry_safe(xfrm_params, tmp, &xfrm_params_head, node)
+ spin_lock_irqsave(&xfrm_params_list.lock, flags);
+
+ list_for_each_entry_safe(xfrm_params, tmp, &xfrm_params_list.list, node)
mtk_xfrm_offload_state_free(xfrm_params->xs);
+
+ spin_unlock_irqrestore(&xfrm_params_list.lock, flags);
}
int mtk_xfrm_offload_policy_add(struct xfrm_policy *xp)