nss-crypto: add kernel 6.12 support

This commit is contained in:
coolsnowwolf 2025-07-18 23:28:29 +08:00
parent d26e716639
commit 450f50f08a
4 changed files with 160 additions and 78 deletions

View File

@ -4,10 +4,10 @@ PKG_NAME:=qca-nss-crypto
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2022-12-15
PKG_SOURCE_DATE:=2024-09-16
PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-crypto.git
PKG_SOURCE_VERSION:=3c5a574ce99d7f0b9f892002020f1bf9bfc57a81
PKG_MIRROR_HASH:=ff487c5574481f548eef7b61129fa7be1d83ae285dcc3356a06be237440d8782
PKG_SOURCE_VERSION:=60e27b91f9cdb1d6de38337c03444021ae8c1040
PKG_MIRROR_HASH:=1ba1133bcc3d760a3d77cb6cf49541a293fc08c97a8b1eebebf01ade55606e63
PKG_BUILD_PARALLEL:=1
@ -16,11 +16,7 @@ include $(INCLUDE_DIR)/package.mk
# v1.0 is for Akronite
# v2.0 is for Hawkeye/Cypress/Maple
ifneq (, $(findstring $(CONFIG_TARGET_SUBTARGET), "ipq807x" "ipq60xx"))
NSS_CRYPTO_DIR:=v2.0
else
NSS_CRYPTO_DIR:=v1.0
endif
define KernelPackage/qca-nss-crypto
SECTION:=kernel
@ -43,6 +39,8 @@ define Build/InstallDev
endef
EXTRA_CFLAGS+= \
-Wno-missing-prototypes \
-Wno-missing-declarations \
-DCONFIG_NSS_DEBUG_LEVEL=4 \
-I$(STAGING_DIR)/usr/include/qca-nss-crypto \
-I$(STAGING_DIR)/usr/include/qca-nss-drv \

View File

@ -1,27 +0,0 @@
From 0c6c593783f2d64a429ad38523661a915aa462fc Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Sun, 13 Mar 2022 13:44:47 +0100
Subject: [PATCH 1/3] nss-crypto: fix SHA1 header include
SHA1 header has been merged to the generic SHA one,
and with that the cryptohash.h was dropped.
So, fix include in kernels 5.8 and newer.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
v2.0/src/nss_crypto_hlos.h | 2 ++
1 file changed, 2 insertions(+)
--- a/v2.0/src/nss_crypto_hlos.h
+++ b/v2.0/src/nss_crypto_hlos.h
@@ -55,7 +55,9 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/vmalloc.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
#include <linux/cryptohash.h>
+#endif
#include <crypto/sha.h>
#include <crypto/aes.h>
#include <crypto/des.h>

View File

@ -0,0 +1,155 @@
--- a/v1.0/src/nss_crypto_dtsi.c
+++ b/v1.0/src/nss_crypto_dtsi.c
@@ -346,7 +346,7 @@ static int nss_crypto_probe(struct platf
* nss_crypto_remove()
* remove the crypto engine and deregister everything
*/
-static int nss_crypto_remove(struct platform_device *pdev)
+static void nss_crypto_remove(struct platform_device *pdev)
{
struct nss_crypto_ctrl_eng *e_ctrl;
struct nss_crypto_ctrl *ctrl;
@@ -361,7 +361,6 @@ static int nss_crypto_remove(struct plat
kfree(ctrl->clocks);
}
- return 0;
};
static struct of_device_id nss_crypto_dt_ids[] = {
@@ -375,7 +374,11 @@ MODULE_DEVICE_TABLE(of, nss_crypto_dt_id
*/
static struct platform_driver nss_crypto_drv = {
.probe = nss_crypto_probe,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
+ .remove_new = nss_crypto_remove,
+#else
.remove = nss_crypto_remove,
+#endif
.driver = {
.owner = THIS_MODULE,
.name = "nss-crypto",
--- a/v2.0/src/hal/ipq60xx/nss_crypto_eip197.h
+++ b/v2.0/src/hal/ipq60xx/nss_crypto_eip197.h
@@ -19,7 +19,9 @@
#ifndef __NSS_CRYPTO_EIP197_H
#define __NSS_CRYPTO_EIP197_H
+#include <linux/of_platform.h>
#include <linux/types.h>
+#include <linux/fs.h>
/*
* Common configuration data for command and result
--- a/v2.0/src/hal/ipq60xx/nss_crypto_hw.c
+++ b/v2.0/src/hal/ipq60xx/nss_crypto_hw.c
@@ -15,8 +15,10 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#include <linux/of.h>
#include <linux/of_platform.h>
#include "nss_crypto_eip197.h"
+#include "nss_crypto_hw.h"
/*
* nss_crypto_hw_deinit()
--- a/v2.0/src/hal/ipq807x/nss_crypto_eip197.h
+++ b/v2.0/src/hal/ipq807x/nss_crypto_eip197.h
@@ -20,6 +20,8 @@
#define __NSS_CRYPTO_EIP197_H
#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/of_platform.h>
/*
* Common configuration data for command and result
--- a/v2.0/src/hal/ipq807x/nss_crypto_hw.c
+++ b/v2.0/src/hal/ipq807x/nss_crypto_hw.c
@@ -15,8 +15,10 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#include <linux/of.h>
#include <linux/of_platform.h>
#include "nss_crypto_eip197.h"
+#include "nss_crypto_hw.h"
/*
* nss_crypto_hw_deinit()
@@ -27,7 +29,6 @@ void nss_crypto_hw_deinit(struct platfor
/*
* TODO: Add support for putting HW into reset
*/
- return;
}
/*
--- a/v2.0/src/nss_crypto_ctrl.c
+++ b/v2.0/src/nss_crypto_ctrl.c
@@ -1575,11 +1575,10 @@ static int nss_crypto_device_probe(struc
* nss_crypto_device_remove()
* remove crypto device and deregister everything
*/
-static int nss_crypto_device_remove(struct platform_device *pdev)
+static void nss_crypto_device_remove(struct platform_device *pdev)
{
nss_crypto_hw_deinit(pdev);
nss_crypto_node_free(platform_get_drvdata(pdev));
- return 0;
};
/*
@@ -1588,7 +1587,11 @@ static int nss_crypto_device_remove(stru
*/
static struct platform_driver nss_crypto_device = {
.probe = nss_crypto_device_probe,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
+ .remove_new = nss_crypto_device_remove,
+#else
.remove = nss_crypto_device_remove,
+#endif
.driver = {
.owner = THIS_MODULE,
.name = "nss-crypto-device",
@@ -1656,7 +1659,7 @@ static int nss_crypto_probe(struct platf
* nss_crypto_remove()
* remove the crypto driver
*/
-static int nss_crypto_remove(struct platform_device *pdev)
+static void nss_crypto_remove(struct platform_device *pdev)
{
struct nss_crypto_ctrl *ctrl = platform_get_drvdata(pdev);
@@ -1670,7 +1673,6 @@ static int nss_crypto_remove(struct plat
* Clear the active state of driver
*/
ctrl->active = false;
- return 0;
}
/*
@@ -1679,7 +1681,11 @@ static int nss_crypto_remove(struct plat
*/
static struct platform_driver nss_crypto_drv = {
.probe = nss_crypto_probe,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
+ .remove_new = nss_crypto_remove,
+#else
.remove = nss_crypto_remove,
+#endif
.driver = {
.owner = THIS_MODULE,
.name = "nss-crypto",
--- a/v2.0/tool/nss_crypto_bench.c
+++ b/v2.0/tool/nss_crypto_bench.c
@@ -980,7 +980,7 @@ int __init crypto_bench_init(void)
ctx->attach = crypto_bench_attach;
ctx->detach = crypto_bench_detach;
- strlcpy(ctx->name, "bench", sizeof(ctx->name));
+ strscpy(ctx->name, "bench", sizeof(ctx->name));
ctx->hdr_pool_sz = 1024;
ctx->default_hdr_sz = 512;
ctx->timeout_ticks = 1;

View File

@ -1,44 +0,0 @@
From 96da3ca01ac172e5d858209b3d3d9aefad04423c Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Sun, 13 Mar 2022 13:47:24 +0100
Subject: [PATCH 3/3] nss-crypto: fix SHA header include in 5.15
SHA header was split into SHA-1 and SHA-2 headers in kernel 5.11, so
fix the include for newer kernels.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
v2.0/src/nss_crypto_ctrl.c | 6 ++++++
v2.0/src/nss_crypto_hlos.h | 4 ++++
2 files changed, 10 insertions(+)
--- a/v2.0/src/nss_crypto_ctrl.c
+++ b/v2.0/src/nss_crypto_ctrl.c
@@ -38,7 +38,13 @@
#include <linux/debugfs.h>
#include <linux/log2.h>
#include <linux/completion.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
#include <crypto/sha.h>
+#else
+#include <crypto/sha1.h>
+#include <crypto/sha2.h>
+#endif
#include <crypto/des.h>
#include <crypto/aes.h>
#include <crypto/md5.h>
--- a/v2.0/src/nss_crypto_hlos.h
+++ b/v2.0/src/nss_crypto_hlos.h
@@ -58,7 +58,11 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
#include <linux/cryptohash.h>
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
#include <crypto/sha.h>
+#else
+#include <crypto/sha1.h>
+#endif
#include <crypto/aes.h>
#include <crypto/des.h>
#include <crypto/ghash.h>