From 6ba8d510b89c97230f216a9a7be4b1cd158182a6 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Fri, 31 Dec 2021 10:19:57 +0000 Subject: [PATCH 01/73] lua: add HOST_FPIC for host builds Compiling without fPIC causes linking issues for packages using liblua. Add $(HOST_FPIC) to host builds for both lua and lua5.3. Suggested-by: Rosen Penev Signed-off-by: Paul Spooren --- package/utils/lua/Makefile | 4 ++-- package/utils/lua5.3/Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package/utils/lua/Makefile b/package/utils/lua/Makefile index e15142d8d2..279759e972 100644 --- a/package/utils/lua/Makefile +++ b/package/utils/lua/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lua PKG_VERSION:=5.1.5 -PKG_RELEASE:=9 +PKG_RELEASE:=10 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.lua.org/ftp/ \ @@ -125,7 +125,7 @@ endif define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) \ - CC="$(HOSTCC) -std=gnu99" \ + CC="$(HOSTCC) $(HOST_FPIC) -std=gnu99" \ $(LUA_OS) endef diff --git a/package/utils/lua5.3/Makefile b/package/utils/lua5.3/Makefile index c9e9bebb1a..19f3b4dfda 100644 --- a/package/utils/lua5.3/Makefile +++ b/package/utils/lua5.3/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lua PKG_VERSION:=5.3.5 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.lua.org/ftp/ \ @@ -110,7 +110,7 @@ endif define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) \ - CC="$(HOSTCC) -std=gnu99" \ + CC="$(HOSTCC) $(HOST_FPIC) -std=gnu99" \ $(LUA_OS) endef From 4a2cca78245e9291096e7c8c98627426df50ef58 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Sat, 1 Jan 2022 17:42:30 +0000 Subject: [PATCH 02/73] ipq807x: drop target The target is in an incomplete state and will not receive Kernel 5.10 support, ego it should be dropped before the next release. People are working on ipq807x with Kernel 5.15 which is only relevant for the second next release. Once a working patchset exists the target can be added again. Signed-off-by: Paul Spooren --- target/linux/ipq807x/Makefile | 14 - target/linux/ipq807x/config-default | 643 ----------------------- target/linux/ipq807x/image/Makefile | 40 -- target/linux/ipq807x/profiles/default.mk | 8 - 4 files changed, 705 deletions(-) delete mode 100644 target/linux/ipq807x/Makefile delete mode 100644 target/linux/ipq807x/config-default delete mode 100644 target/linux/ipq807x/image/Makefile delete mode 100644 target/linux/ipq807x/profiles/default.mk diff --git a/target/linux/ipq807x/Makefile b/target/linux/ipq807x/Makefile deleted file mode 100644 index dab05ca204..0000000000 --- a/target/linux/ipq807x/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -include $(TOPDIR)/rules.mk - -ARCH:=aarch64 -BOARD:=ipq807x -BOARDNAME:=Qualcomm Atheros IPQ807x -FEATURES:=squashfs ramdisk source-only -KERNELNAME:=Image dtbs -CPU_TYPE:=cortex-a53 - -KERNEL_PATCHVER:=5.4 - -include $(INCLUDE_DIR)/target.mk - -$(eval $(call BuildTarget)) diff --git a/target/linux/ipq807x/config-default b/target/linux/ipq807x/config-default deleted file mode 100644 index ad4aca1b48..0000000000 --- a/target/linux/ipq807x/config-default +++ /dev/null @@ -1,643 +0,0 @@ -CONFIG_64BIT=y -# CONFIG_ACPI is not set -# CONFIG_ALLOW_DEV_COREDUMP is not set -# CONFIG_APQ_GCC_8084 is not set -# CONFIG_APQ_MMCC_8084 is not set -CONFIG_AQUANTIA_PHY=y -CONFIG_ARCH_CLOCKSOURCE_DATA=y -CONFIG_ARCH_DMA_ADDR_T_64BIT=y -CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y -CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y -CONFIG_ARCH_HAS_ELF_RANDOMIZE=y -CONFIG_ARCH_HAS_FAST_MULTIPLIER=y -CONFIG_ARCH_HAS_FORTIFY_SOURCE=y -CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y -CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y -CONFIG_ARCH_HAS_KCOV=y -CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y -CONFIG_ARCH_HAS_PTE_SPECIAL=y -CONFIG_ARCH_HAS_SET_MEMORY=y -CONFIG_ARCH_HAS_SG_CHAIN=y -CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y -CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y -CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y -CONFIG_ARCH_HAS_TICK_BROADCAST=y -CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y -CONFIG_ARCH_HIBERNATION_POSSIBLE=y -CONFIG_ARCH_MMAP_RND_BITS=18 -CONFIG_ARCH_MMAP_RND_BITS_MAX=24 -CONFIG_ARCH_MMAP_RND_BITS_MIN=18 -CONFIG_ARCH_MMAP_RND_COMPAT_BITS=11 -CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11 -CONFIG_ARCH_PROC_KCORE_TEXT=y -CONFIG_ARCH_QCOM=y -CONFIG_ARCH_SELECT_MEMORY_MODEL=y -CONFIG_ARCH_SPARSEMEM_DEFAULT=y -CONFIG_ARCH_SPARSEMEM_ENABLE=y -CONFIG_ARCH_SUPPORTS_ACPI=y -CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y -CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y -CONFIG_ARCH_SUPPORTS_INT128=y -CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y -CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y -CONFIG_ARCH_SUPPORTS_UPROBES=y -CONFIG_ARCH_SUSPEND_POSSIBLE=y -CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y -CONFIG_ARCH_USE_QUEUED_RWLOCKS=y -CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y -CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y -CONFIG_ARCH_WANT_FRAME_POINTERS=y -CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y -CONFIG_ARM64=y -# CONFIG_ARM64_16K_PAGES is not set -CONFIG_ARM64_4K_PAGES=y -# CONFIG_ARM64_64K_PAGES is not set -CONFIG_ARM64_CONT_SHIFT=4 -# CONFIG_ARM64_CRYPTO is not set -CONFIG_ARM64_ERRATUM_819472=y -CONFIG_ARM64_ERRATUM_824069=y -CONFIG_ARM64_ERRATUM_826319=y -CONFIG_ARM64_ERRATUM_827319=y -CONFIG_ARM64_ERRATUM_832075=y -CONFIG_ARM64_ERRATUM_843419=y -CONFIG_ARM64_ERRATUM_845719=y -CONFIG_ARM64_HW_AFDBM=y -# CONFIG_ARM64_LSE_ATOMICS is not set -CONFIG_ARM64_MODULE_PLTS=y -CONFIG_ARM64_PAGE_SHIFT=12 -CONFIG_ARM64_PAN=y -CONFIG_ARM64_PA_BITS=48 -CONFIG_ARM64_PA_BITS_48=y -# CONFIG_ARM64_PMEM is not set -# CONFIG_ARM64_PTDUMP_DEBUGFS is not set -# CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET is not set -CONFIG_ARM64_SSBD=y -CONFIG_ARM64_SVE=y -CONFIG_ARM64_UAO=y -CONFIG_ARM64_VA_BITS=39 -CONFIG_ARM64_VA_BITS_39=y -# CONFIG_ARM64_VA_BITS_48 is not set -CONFIG_ARM64_VHE=y -# CONFIG_ARMV8_DEPRECATED is not set -CONFIG_ARM_AMBA=y -CONFIG_ARM_ARCH_TIMER=y -CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y -CONFIG_ARM_CCI=y -CONFIG_ARM_CCI400_COMMON=y -CONFIG_ARM_CCI400_PMU=y -CONFIG_ARM_CCI_PMU=y -CONFIG_ARM_CPUIDLE=y -CONFIG_ARM_GIC=y -CONFIG_ARM_GIC_V2M=y -CONFIG_ARM_GIC_V3=y -CONFIG_ARM_GIC_V3_ITS=y -CONFIG_ARM_GIC_V3_ITS_PCI=y -CONFIG_ARM_PMU=y -CONFIG_ARM_PSCI_FW=y -# CONFIG_ARM_QCOM_CPUFREQ_KRYO is not set -# CONFIG_ARM_SCMI_PROTOCOL is not set -# CONFIG_ARM_SP805_WATCHDOG is not set -CONFIG_ASN1=y -CONFIG_ASSOCIATIVE_ARRAY=y -CONFIG_ASYMMETRIC_KEY_TYPE=y -CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y -CONFIG_AT803X_PHY=y -CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y -CONFIG_BLK_DEV_NVME=y -CONFIG_BLK_DEV_RAM=y -CONFIG_BLK_DEV_RAM_COUNT=16 -CONFIG_BLK_DEV_RAM_SIZE=4096 -CONFIG_BLK_MQ_PCI=y -CONFIG_BLK_MQ_VIRTIO=y -CONFIG_BLOCK_COMPAT=y -CONFIG_BUILD_BIN2C=y -# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set -CONFIG_CC_OPTIMIZE_FOR_SIZE=y -CONFIG_CLEANCACHE=y -CONFIG_CLKDEV_LOOKUP=y -CONFIG_CLONE_BACKWARDS=y -CONFIG_CLZ_TAB=y -CONFIG_COMMON_CLK=y -CONFIG_COMMON_CLK_QCOM=y -CONFIG_COMMON_CLK_XGENE=y -CONFIG_COMPAT=y -CONFIG_COMPAT_32BIT_TIME=y -CONFIG_COMPAT_BINFMT_ELF=y -CONFIG_COMPAT_NETLINK_MESSAGES=y -CONFIG_COMPAT_OLD_SIGACTION=y -CONFIG_CONFIGFS_FS=y -CONFIG_COREDUMP=y -CONFIG_CORESIGHT=y -# CONFIG_CORESIGHT_CATU is not set -# CONFIG_CORESIGHT_CPU_DEBUG is not set -# CONFIG_CORESIGHT_DYNAMIC_REPLICATOR is not set -CONFIG_CORESIGHT_LINKS_AND_SINKS=y -CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y -# CONFIG_CORESIGHT_SINK_ETBV10 is not set -CONFIG_CORESIGHT_SINK_TPIU=y -CONFIG_CORESIGHT_SOURCE_ETM4X=y -CONFIG_CORESIGHT_STM=y -CONFIG_CPUFREQ_DT=y -CONFIG_CPUFREQ_DT_PLATDEV=y -# CONFIG_CPU_BIG_ENDIAN is not set -CONFIG_CPU_FREQ=y -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y -CONFIG_CPU_FREQ_GOV_ATTR_SET=y -CONFIG_CPU_FREQ_GOV_COMMON=y -CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y -CONFIG_CPU_FREQ_GOV_ONDEMAND=y -CONFIG_CPU_FREQ_GOV_PERFORMANCE=y -CONFIG_CPU_FREQ_GOV_POWERSAVE=y -CONFIG_CPU_FREQ_GOV_USERSPACE=y -CONFIG_CPU_FREQ_STAT=y -# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set -CONFIG_CPU_IDLE=y -CONFIG_CPU_IDLE_GOV_LADDER=y -CONFIG_CPU_IDLE_GOV_MENU=y -CONFIG_CPU_IDLE_MULTIPLE_DRIVERS=y -CONFIG_CPU_PM=y -CONFIG_CPU_RMAP=y -# CONFIG_CPU_THERMAL is not set -CONFIG_CRC16=y -# CONFIG_CRC32_SARWATE is not set -CONFIG_CRC32_SLICEBY8=y -CONFIG_CROSS_MEMORY_ATTACH=y -CONFIG_CRYPTO_ACOMP2=y -CONFIG_CRYPTO_AEAD=y -CONFIG_CRYPTO_AEAD2=y -CONFIG_CRYPTO_AKCIPHER=y -CONFIG_CRYPTO_AKCIPHER2=y -CONFIG_CRYPTO_ARC4=y -CONFIG_CRYPTO_CCM=y -CONFIG_CRYPTO_CMAC=y -CONFIG_CRYPTO_CRC32C=y -CONFIG_CRYPTO_CTR=y -CONFIG_CRYPTO_DEFLATE=y -# CONFIG_CRYPTO_DEV_QCOM_RNG is not set -CONFIG_CRYPTO_DRBG=y -CONFIG_CRYPTO_DRBG_HMAC=y -CONFIG_CRYPTO_DRBG_MENU=y -CONFIG_CRYPTO_ECHAINIV=y -CONFIG_CRYPTO_GCM=y -CONFIG_CRYPTO_GF128MUL=y -CONFIG_CRYPTO_GHASH=y -CONFIG_CRYPTO_HASH=y -CONFIG_CRYPTO_HASH2=y -CONFIG_CRYPTO_HASH_INFO=y -CONFIG_CRYPTO_HMAC=y -CONFIG_CRYPTO_HW=y -CONFIG_CRYPTO_JITTERENTROPY=y -CONFIG_CRYPTO_KPP2=y -CONFIG_CRYPTO_LZO=y -CONFIG_CRYPTO_MANAGER=y -CONFIG_CRYPTO_MANAGER2=y -# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set -CONFIG_CRYPTO_NULL=y -CONFIG_CRYPTO_NULL2=y -CONFIG_CRYPTO_RNG=y -CONFIG_CRYPTO_RNG2=y -CONFIG_CRYPTO_RNG_DEFAULT=y -CONFIG_CRYPTO_SEQIV=y -CONFIG_CRYPTO_SHA256=y -CONFIG_CRYPTO_SHA512=y -CONFIG_CRYPTO_WORKQUEUE=y -CONFIG_DCACHE_WORD_ACCESS=y -CONFIG_DEBUG_BUGVERBOSE=y -CONFIG_DEBUG_GPIO=y -CONFIG_DECOMPRESS_GZIP=y -CONFIG_DEVMEM=y -CONFIG_DMADEVICES=y -CONFIG_DMA_DIRECT_OPS=y -CONFIG_DMA_ENGINE=y -CONFIG_DMA_OF=y -CONFIG_DMA_VIRTUAL_CHANNELS=y -CONFIG_DMI=y -CONFIG_DMIID=y -# CONFIG_DMI_SYSFS is not set -CONFIG_DTC=y -CONFIG_DT_IDLE_STATES=y -CONFIG_DYNAMIC_DEBUG=y -CONFIG_EDAC_SUPPORT=y -CONFIG_EFI=y -CONFIG_EFIVAR_FS=m -CONFIG_EFI_ARMSTUB=y -CONFIG_EFI_ARMSTUB_DTB_LOADER=y -# CONFIG_EFI_CAPSULE_LOADER is not set -CONFIG_EFI_ESRT=y -CONFIG_EFI_PARAMS_FROM_FDT=y -CONFIG_EFI_RUNTIME_WRAPPERS=y -CONFIG_EFI_STUB=y -# CONFIG_EFI_TEST is not set -# CONFIG_EFI_VARS is not set -CONFIG_EXT4_FS=y -# CONFIG_EXT4_USE_FOR_EXT2 is not set -CONFIG_FB=y -CONFIG_FB_CMDLINE=y -# CONFIG_FB_EFI is not set -CONFIG_FIXED_PHY=y -CONFIG_FIX_EARLYCON_MEM=y -# CONFIG_FLATMEM_MANUAL is not set -CONFIG_FRAME_POINTER=y -CONFIG_FRAME_WARN=2048 -CONFIG_FREEZER=y -CONFIG_FS_IOMAP=y -CONFIG_FS_MBCACHE=y -CONFIG_GENERIC_ALLOCATOR=y -CONFIG_GENERIC_ARCH_TOPOLOGY=y -CONFIG_GENERIC_BUG=y -CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y -CONFIG_GENERIC_CLOCKEVENTS=y -CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y -CONFIG_GENERIC_CPU_AUTOPROBE=y -CONFIG_GENERIC_CPU_VULNERABILITIES=y -CONFIG_GENERIC_CSUM=y -CONFIG_GENERIC_EARLY_IOREMAP=y -CONFIG_GENERIC_IDLE_POLL_SETUP=y -CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y -CONFIG_GENERIC_IRQ_MIGRATION=y -CONFIG_GENERIC_IRQ_MULTI_HANDLER=y -CONFIG_GENERIC_IRQ_SHOW=y -CONFIG_GENERIC_IRQ_SHOW_LEVEL=y -CONFIG_GENERIC_MSI_IRQ=y -CONFIG_GENERIC_MSI_IRQ_DOMAIN=y -CONFIG_GENERIC_PCI_IOMAP=y -CONFIG_GENERIC_PHY=y -CONFIG_GENERIC_PINCONF=y -CONFIG_GENERIC_PINCTRL_GROUPS=y -CONFIG_GENERIC_PINMUX_FUNCTIONS=y -CONFIG_GENERIC_SCHED_CLOCK=y -CONFIG_GENERIC_SMP_IDLE_THREAD=y -CONFIG_GENERIC_STRNCPY_FROM_USER=y -CONFIG_GENERIC_STRNLEN_USER=y -CONFIG_GENERIC_TIME_VSYSCALL=y -CONFIG_GPIOLIB=y -CONFIG_GPIOLIB_IRQCHIP=y -CONFIG_HANDLE_DOMAIN_IRQ=y -CONFIG_HARDEN_BRANCH_PREDICTOR=y -CONFIG_HARDIRQS_SW_RESEND=y -CONFIG_HAS_DMA=y -CONFIG_HAS_IOMEM=y -CONFIG_HAS_IOPORT_MAP=y -CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y -CONFIG_HAVE_ARCH_AUDITSYSCALL=y -CONFIG_HAVE_ARCH_BITREVERSE=y -CONFIG_HAVE_ARCH_HUGE_VMAP=y -CONFIG_HAVE_ARCH_JUMP_LABEL=y -CONFIG_HAVE_ARCH_KASAN=y -CONFIG_HAVE_ARCH_KGDB=y -CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS=y -CONFIG_HAVE_ARCH_PFN_VALID=y -CONFIG_HAVE_ARCH_PREL32_RELOCATIONS=y -CONFIG_HAVE_ARCH_SECCOMP_FILTER=y -CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y -CONFIG_HAVE_ARCH_TRACEHOOK=y -CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y -CONFIG_HAVE_ARCH_VMAP_STACK=y -CONFIG_HAVE_ARM_SMCCC=y -CONFIG_HAVE_CLK=y -CONFIG_HAVE_CLK_PREPARE=y -CONFIG_HAVE_CMPXCHG_DOUBLE=y -CONFIG_HAVE_CMPXCHG_LOCAL=y -CONFIG_HAVE_CONTEXT_TRACKING=y -CONFIG_HAVE_C_RECORDMCOUNT=y -CONFIG_HAVE_DEBUG_BUGVERBOSE=y -CONFIG_HAVE_DEBUG_KMEMLEAK=y -CONFIG_HAVE_DMA_CONTIGUOUS=y -CONFIG_HAVE_DYNAMIC_FTRACE=y -CONFIG_HAVE_EBPF_JIT=y -CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y -CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y -CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y -CONFIG_HAVE_FUNCTION_TRACER=y -CONFIG_HAVE_GENERIC_DMA_COHERENT=y -CONFIG_HAVE_GENERIC_GUP=y -CONFIG_HAVE_HW_BREAKPOINT=y -CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y -CONFIG_HAVE_MEMBLOCK=y -CONFIG_HAVE_MEMORY_PRESENT=y -CONFIG_HAVE_MOD_ARCH_SPECIFIC=y -CONFIG_HAVE_NET_DSA=y -CONFIG_HAVE_PATA_PLATFORM=y -CONFIG_HAVE_PERF_EVENTS=y -CONFIG_HAVE_PERF_REGS=y -CONFIG_HAVE_PERF_USER_STACK_DUMP=y -CONFIG_HAVE_RCU_TABLE_FREE=y -CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y -CONFIG_HAVE_RSEQ=y -CONFIG_HAVE_SCHED_AVG_IRQ=y -CONFIG_HAVE_SYSCALL_TRACEPOINTS=y -CONFIG_HAVE_UID16=y -CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y -CONFIG_HOLES_IN_ZONE=y -CONFIG_HOTPLUG_CPU=y -# CONFIG_HUGETLBFS is not set -CONFIG_HWSPINLOCK=y -CONFIG_HWSPINLOCK_QCOM=y -CONFIG_HW_RANDOM=y -CONFIG_I2C=y -CONFIG_I2C_BOARDINFO=y -CONFIG_I2C_CHARDEV=y -CONFIG_I2C_COMPAT=y -CONFIG_I2C_HELPER_AUTO=y -CONFIG_I2C_QUP=y -CONFIG_IIO=y -# CONFIG_IIO_BUFFER is not set -# CONFIG_IIO_TRIGGER is not set -CONFIG_IKCONFIG=y -CONFIG_IKCONFIG_PROC=y -CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 -CONFIG_INITRAMFS_SOURCE="" -# CONFIG_IPQ_GCC_4019 is not set -# CONFIG_IPQ_GCC_806X is not set -CONFIG_IPQ_GCC_8074=y -# CONFIG_IPQ_LCC_806X is not set -CONFIG_IRQCHIP=y -CONFIG_IRQ_DOMAIN=y -CONFIG_IRQ_DOMAIN_HIERARCHY=y -CONFIG_IRQ_FORCED_THREADING=y -CONFIG_IRQ_TIME_ACCOUNTING=y -CONFIG_IRQ_WORK=y -CONFIG_JBD2=y -CONFIG_KEYS=y -CONFIG_KEYS_COMPAT=y -# CONFIG_KVM is not set -CONFIG_LEDS_TLC591XX=y -CONFIG_LIBFDT=y -CONFIG_LOCK_DEBUGGING_SUPPORT=y -CONFIG_LOCK_SPIN_ON_OWNER=y -CONFIG_LZO_COMPRESS=y -CONFIG_LZO_DECOMPRESS=y -CONFIG_MAILBOX=y -# CONFIG_MAILBOX_TEST is not set -CONFIG_MDIO_BITBANG=y -CONFIG_MDIO_BUS=y -CONFIG_MDIO_DEVICE=y -CONFIG_MDIO_GPIO=y -# CONFIG_MDM_GCC_9615 is not set -# CONFIG_MDM_LCC_9615 is not set -CONFIG_MEMFD_CREATE=y -CONFIG_MFD_QCOM_RPM=y -CONFIG_MFD_SPMI_PMIC=y -CONFIG_MFD_SYSCON=y -CONFIG_MIGRATION=y -CONFIG_MMC=y -CONFIG_MMC_ARMMMCI=y -CONFIG_MMC_BLOCK=y -CONFIG_MMC_BLOCK_MINORS=32 -CONFIG_MMC_QCOM_DML=y -CONFIG_MMC_SDHCI=y -CONFIG_MMC_SDHCI_IO_ACCESSORS=y -CONFIG_MMC_SDHCI_MSM=y -# CONFIG_MMC_SDHCI_PCI is not set -CONFIG_MMC_SDHCI_PLTFM=y -CONFIG_MODULES_TREE_LOOKUP=y -CONFIG_MODULES_USE_ELF_RELA=y -CONFIG_MPILIB=y -# CONFIG_MSM_GCC_8660 is not set -# CONFIG_MSM_GCC_8916 is not set -# CONFIG_MSM_GCC_8960 is not set -# CONFIG_MSM_GCC_8974 is not set -# CONFIG_MSM_GCC_8994 is not set -# CONFIG_MSM_GCC_8996 is not set -# CONFIG_MSM_GCC_8998 is not set -# CONFIG_MSM_LCC_8960 is not set -# CONFIG_MSM_MMCC_8960 is not set -# CONFIG_MSM_MMCC_8974 is not set -# CONFIG_MSM_MMCC_8996 is not set -CONFIG_MTD_CMDLINE_PARTS=y -CONFIG_MTD_M25P80=y -CONFIG_MTD_NAND=y -CONFIG_MTD_NAND_ECC=y -CONFIG_MTD_NAND_QCOM=y -CONFIG_MTD_SPI_NOR=y -CONFIG_MTD_SPLIT_FIRMWARE=y -CONFIG_MTD_SPLIT_FIT_FW=y -CONFIG_MTD_UBI=y -CONFIG_MTD_UBI_BEB_LIMIT=20 -CONFIG_MTD_UBI_BLOCK=y -CONFIG_MTD_UBI_GLUEBI=y -CONFIG_MTD_UBI_WL_THRESHOLD=4096 -CONFIG_MUTEX_SPIN_ON_OWNER=y -CONFIG_NEED_DMA_MAP_STATE=y -CONFIG_NEED_SG_DMA_LENGTH=y -CONFIG_NET_FLOW_LIMIT=y -CONFIG_NET_PTP_CLASSIFY=y -CONFIG_NET_SWITCHDEV=y -# CONFIG_NET_VENDOR_CAVIUM is not set -CONFIG_NLS=y -CONFIG_NO_BOOTMEM=y -CONFIG_NO_HZ=y -CONFIG_NO_HZ_COMMON=y -CONFIG_NO_HZ_IDLE=y -CONFIG_NR_CPUS=4 -# CONFIG_NUMA is not set -CONFIG_NVMEM=y -CONFIG_NVME_CORE=y -# CONFIG_NVME_MULTIPATH is not set -CONFIG_OF=y -CONFIG_OF_ADDRESS=y -CONFIG_OF_EARLY_FLATTREE=y -CONFIG_OF_FLATTREE=y -CONFIG_OF_GPIO=y -CONFIG_OF_IRQ=y -CONFIG_OF_KOBJ=y -CONFIG_OF_MDIO=y -CONFIG_OF_NET=y -CONFIG_OF_RESERVED_MEM=y -CONFIG_OID_REGISTRY=y -CONFIG_OLD_SIGSUSPEND3=y -CONFIG_PADATA=y -CONFIG_PANIC_TIMEOUT=5 -CONFIG_PARTITION_PERCPU=y -CONFIG_PCI=y -CONFIG_PCIE_DW=y -CONFIG_PCIE_DW_HOST=y -CONFIG_PCIE_QCOM=y -CONFIG_PCI_DOMAINS=y -CONFIG_PCI_DOMAINS_GENERIC=y -CONFIG_PCI_LABEL=y -CONFIG_PCI_MSI=y -CONFIG_PCI_MSI_IRQ_DOMAIN=y -CONFIG_PGTABLE_LEVELS=3 -CONFIG_PHYLIB=y -CONFIG_PHYS_ADDR_T_64BIT=y -# CONFIG_PHY_QCOM_APQ8064_SATA is not set -# CONFIG_PHY_QCOM_IPQ806X_SATA is not set -# CONFIG_PHY_QCOM_QMP is not set -# CONFIG_PHY_QCOM_QUSB2 is not set -# CONFIG_PHY_QCOM_UFS is not set -CONFIG_PINCTRL=y -# CONFIG_PINCTRL_APQ8064 is not set -# CONFIG_PINCTRL_APQ8084 is not set -# CONFIG_PINCTRL_IPQ4019 is not set -# CONFIG_PINCTRL_IPQ8064 is not set -CONFIG_PINCTRL_IPQ8074=y -# CONFIG_PINCTRL_MDM9615 is not set -CONFIG_PINCTRL_MSM=y -# CONFIG_PINCTRL_MSM8660 is not set -# CONFIG_PINCTRL_MSM8916 is not set -# CONFIG_PINCTRL_MSM8960 is not set -# CONFIG_PINCTRL_MSM8994 is not set -# CONFIG_PINCTRL_MSM8996 is not set -# CONFIG_PINCTRL_MSM8998 is not set -CONFIG_PINCTRL_QCOM_SPMI_PMIC=y -# CONFIG_PINCTRL_QCOM_SSBI_PMIC is not set -# CONFIG_PINCTRL_SDM845 is not set -CONFIG_PM=y -CONFIG_PM_CLK=y -# CONFIG_PM_DEBUG is not set -CONFIG_PM_OPP=y -CONFIG_PM_SLEEP=y -CONFIG_PM_SLEEP_SMP=y -CONFIG_POWER_RESET=y -CONFIG_POWER_RESET_MSM=y -# CONFIG_POWER_RESET_QCOM_PON is not set -CONFIG_POWER_SUPPLY=y -CONFIG_PPS=y -CONFIG_PREEMPT=y -CONFIG_PREEMPT_COUNT=y -# CONFIG_PREEMPT_NONE is not set -CONFIG_PREEMPT_RCU=y -CONFIG_PRINTK_TIME=y -CONFIG_PROC_PAGE_MONITOR=y -CONFIG_PTP_1588_CLOCK=y -CONFIG_PWM=y -CONFIG_PWM_SYSFS=y -CONFIG_QCOM_A53PLL=y -# CONFIG_QCOM_APCS_IPC is not set -CONFIG_QCOM_BAM_DMA=y -# CONFIG_QCOM_CLK_RPM is not set -# CONFIG_QCOM_COINCELL is not set -# CONFIG_QCOM_COMMAND_DB is not set -CONFIG_QCOM_EBI2=y -# CONFIG_QCOM_GENI_SE is not set -CONFIG_QCOM_GSBI=y -# CONFIG_QCOM_LLCC is not set -# CONFIG_QCOM_PDC is not set -CONFIG_QCOM_QFPROM=y -# CONFIG_QCOM_RMTFS_MEM is not set -# CONFIG_QCOM_RPMH is not set -CONFIG_QCOM_SMEM=y -CONFIG_QCOM_SMEM_STATE=y -CONFIG_QCOM_SMP2P=y -# CONFIG_QCOM_SMSM is not set -CONFIG_QCOM_SPMI_VADC=y -CONFIG_QCOM_TSENS=y -CONFIG_QCOM_VADC_COMMON=y -CONFIG_QCOM_WDT=y -# CONFIG_QRTR is not set -CONFIG_QUEUED_RWLOCKS=y -CONFIG_QUEUED_SPINLOCKS=y -# CONFIG_RANDOMIZE_BASE is not set -CONFIG_RATIONAL=y -CONFIG_RD_GZIP=y -CONFIG_REFCOUNT_FULL=y -CONFIG_REGMAP=y -CONFIG_REGMAP_I2C=y -CONFIG_REGMAP_MMIO=y -CONFIG_REGMAP_SPI=y -CONFIG_REGMAP_SPMI=y -CONFIG_REGULATOR=y -CONFIG_REGULATOR_FIXED_VOLTAGE=y -CONFIG_REGULATOR_GPIO=y -CONFIG_REGULATOR_QCOM_RPM=y -CONFIG_REGULATOR_QCOM_SPMI=y -CONFIG_RELAY=y -CONFIG_REMOTEPROC=y -# CONFIG_RESET_ATTACK_MITIGATION is not set -CONFIG_RESET_CONTROLLER=y -# CONFIG_RESET_QCOM_AOSS is not set -CONFIG_RFS_ACCEL=y -# CONFIG_RPMSG_QCOM_GLINK_SMEM is not set -# CONFIG_RPMSG_QCOM_SMD is not set -CONFIG_RPS=y -CONFIG_RTC_CLASS=y -# CONFIG_RTC_DRV_EFI is not set -# CONFIG_RTC_DRV_PM8XXX is not set -CONFIG_RTC_I2C_AND_SPI=y -CONFIG_RWSEM_SPIN_ON_OWNER=y -CONFIG_RWSEM_XCHGADD_ALGORITHM=y -# CONFIG_SDM_DISPCC_845 is not set -# CONFIG_SDM_GCC_845 is not set -# CONFIG_SDM_VIDEOCC_845 is not set -# CONFIG_SERIAL_8250 is not set -# CONFIG_SERIAL_AMBA_PL011 is not set -CONFIG_SERIAL_MSM=y -CONFIG_SERIAL_MSM_CONSOLE=y -CONFIG_SGL_ALLOC=y -CONFIG_SMP=y -CONFIG_SND=y -# CONFIG_SND_COMPRESS_OFFLOAD is not set -CONFIG_SND_JACK=y -CONFIG_SND_PCM=y -CONFIG_SND_SOC=y -# CONFIG_SND_SOC_APQ8016_SBC is not set -CONFIG_SND_SOC_I2C_AND_SPI=y -CONFIG_SND_SOC_QCOM=y -# CONFIG_SND_SOC_STORM is not set -CONFIG_SOUND=y -CONFIG_SOUND_OSS_CORE=y -CONFIG_SOUND_OSS_CORE_PRECLAIM=y -CONFIG_SPARSEMEM=y -CONFIG_SPARSEMEM_EXTREME=y -CONFIG_SPARSEMEM_MANUAL=y -CONFIG_SPARSEMEM_VMEMMAP=y -CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y -CONFIG_SPARSE_IRQ=y -CONFIG_SPI=y -CONFIG_SPI_MASTER=y -CONFIG_SPI_MEM=y -CONFIG_SPI_QUP=y -CONFIG_SPI_SPIDEV=y -CONFIG_SPMI=y -CONFIG_SPMI_MSM_PMIC_ARB=y -# CONFIG_SPMI_PMIC_CLKDIV is not set -CONFIG_SRCU=y -CONFIG_STM=y -# CONFIG_STM_SOURCE_HEARTBEAT is not set -# CONFIG_STRIP_ASM_SYMS is not set -CONFIG_SUSPEND=y -CONFIG_SUSPEND_FREEZER=y -# CONFIG_SWAP is not set -CONFIG_SWCONFIG=y -CONFIG_SWIOTLB=y -CONFIG_SWPHY=y -CONFIG_SYSCTL_EXCEPTION_TRACE=y -CONFIG_SYSVIPC_COMPAT=y -CONFIG_SYS_SUPPORTS_HUGETLBFS=y -CONFIG_TASKS_RCU=y -CONFIG_THERMAL=y -CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y -CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 -CONFIG_THERMAL_GOV_STEP_WISE=y -CONFIG_THERMAL_GOV_USER_SPACE=y -CONFIG_THERMAL_OF=y -CONFIG_THERMAL_WRITABLE_TRIPS=y -CONFIG_THREAD_INFO_IN_TASK=y -CONFIG_TICK_CPU_ACCOUNTING=y -CONFIG_TIMER_OF=y -CONFIG_TIMER_PROBE=y -CONFIG_TREE_SRCU=y -CONFIG_UBIFS_FS=y -CONFIG_UCS2_STRING=y -CONFIG_UEVENT_HELPER_PATH="" -CONFIG_UNINLINE_SPIN_UNLOCK=y -CONFIG_UNMAP_KERNEL_AT_EL0=y -CONFIG_USB_SUPPORT=y -CONFIG_VIRTIO=y -# CONFIG_VIRTIO_BLK is not set -# CONFIG_VIRTIO_CONSOLE is not set -# CONFIG_VIRTIO_NET is not set -CONFIG_VIRTUALIZATION=y -CONFIG_VMAP_STACK=y -CONFIG_VM_EVENT_COUNTERS=y -CONFIG_WANT_DEV_COREDUMP=y -CONFIG_WATCHDOG_CORE=y -# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set -CONFIG_X509_CERTIFICATE_PARSER=y -CONFIG_XPS=y -CONFIG_XZ_DEC_ARM=y -CONFIG_XZ_DEC_BCJ=y -CONFIG_ZLIB_DEFLATE=y -CONFIG_ZLIB_INFLATE=y -CONFIG_ZONE_DMA32=y diff --git a/target/linux/ipq807x/image/Makefile b/target/linux/ipq807x/image/Makefile deleted file mode 100644 index 2a0c74554f..0000000000 --- a/target/linux/ipq807x/image/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -include $(TOPDIR)/rules.mk -include $(INCLUDE_DIR)/image.mk - -IPQ807X_KERNEL_LOADADDR = 0x41080000 -DEVICE_DTS_CONFIG = "config@hk01" - -define Image/BuildKernel/FIT - gzip -9 -c $(KDIR)/Image > $(KDIR)/Image.gz - $(call CompressLzma,$(KDIR)/Image,$(KDIR)/Image.gz) - $(call Image/BuildKernel/MkFIT,$(1), $(KDIR)/Image.gz, $(DTS_DIR)/qcom/$(1).dtb,gzip,$(2),$(2)) - $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb - mkdir -p $(BIN_DIR)/dtbs/ - $(CP) $(DTS_DIR)/qcom/ipq*.dtb $(BIN_DIR)/dtbs/ - $(CP) $(KDIR)/Image $(BIN_DIR)/dtbs/ -endef - -define Image/BuildKernel/FITInitramfs - $(CP) $(KDIR)/Image-initramfs $(BIN_DIR)/dtbs/ - $(CP) $(KDIR)/Image-initramfs $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs.bin - $(call Image/BuildKernel/MkFIT,$(1), $(KDIR)/Image-initramfs, $(DTS_DIR)/qcom/$(1).dtb, none,$(2),$(2),-initramfs) - $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb -endef - -define Image/Build/squashfs - $(call prepare_generic_squashfs,$(KDIR)/root.squashfs) -endef - -define Image/BuildKernel - $(call Image/BuildKernel/FIT,ipq8074-hk01,$(IPQ807X_KERNEL_LOADADDR)) -endef - -define Image/BuildKernel/Initramfs - $(call Image/BuildKernel/FITInitramfs,ipq8074-hk01,$(IPQ807X_KERNEL_LOADADDR)) -endef - -define Image/Build - $(call Image/Build/$(1),$(1)) -endef - -$(eval $(call BuildImage)) diff --git a/target/linux/ipq807x/profiles/default.mk b/target/linux/ipq807x/profiles/default.mk deleted file mode 100644 index 44935d6905..0000000000 --- a/target/linux/ipq807x/profiles/default.mk +++ /dev/null @@ -1,8 +0,0 @@ -define Profile/Default - NAME:=Default Profile (minimum package set) -endef - -define Profile/Default/Description - Default package set compatible with most boards. -endef -$(eval $(call Profile,Default)) From 02852d55380dfae5452a51b508608adf499bb656 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Tue, 4 Jan 2022 13:05:13 +0100 Subject: [PATCH 03/73] uml: switch to Kernel 5.10 Switch over from testing version. Signed-off-by: Paul Spooren --- target/linux/uml/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/linux/uml/Makefile b/target/linux/uml/Makefile index 3707ab4b19..ec662989ec 100644 --- a/target/linux/uml/Makefile +++ b/target/linux/uml/Makefile @@ -13,8 +13,7 @@ BOARD:=uml BOARDNAME:=User Mode Linux FEATURES:=squashfs ext4 audio -KERNEL_PATCHVER:=5.4 -KERNEL_TESTING_PATCHVER:=5.10 +KERNEL_PATCHVER:=5.10 include $(INCLUDE_DIR)/target.mk From cb85aea869dcc501d8fc58b6c52ab5e5cae0d4f0 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Tue, 4 Jan 2022 13:06:03 +0100 Subject: [PATCH 04/73] uml: drop Kernel 5.4 After the switch to Kernel 5.10 the old files are no longer required. Signed-off-by: Paul Spooren --- target/linux/uml/config-5.4 | 142 ------------ .../uml/patches-5.4/101-mconsole-exec.patch | 205 ------------------ .../patches-5.4/102-pseudo-random-mac.patch | 130 ----------- 3 files changed, 477 deletions(-) delete mode 100644 target/linux/uml/config-5.4 delete mode 100644 target/linux/uml/patches-5.4/101-mconsole-exec.patch delete mode 100644 target/linux/uml/patches-5.4/102-pseudo-random-mac.patch diff --git a/target/linux/uml/config-5.4 b/target/linux/uml/config-5.4 deleted file mode 100644 index 1d35dda2dc..0000000000 --- a/target/linux/uml/config-5.4 +++ /dev/null @@ -1,142 +0,0 @@ -CONFIG_3_LEVEL_PGTABLES=y -CONFIG_64BIT=y -CONFIG_ARCH_DEFCONFIG="arch/um/configs/x86_64_defconfig" -CONFIG_ARCH_DMA_ADDR_T_64BIT=y -CONFIG_ARCH_HAS_KCOV=y -CONFIG_ARCH_NO_PREEMPT=y -CONFIG_BLK_DEV_COW_COMMON=y -CONFIG_BLK_DEV_LOOP=y -CONFIG_BLK_DEV_UBD=y -CONFIG_BLK_DEV_UBD_SYNC=y -CONFIG_BLK_MQ_VIRTIO=y -CONFIG_CC_HAS_KASAN_GENERIC=y -CONFIG_CON_CHAN="xterm" -CONFIG_CON_ZERO_CHAN="fd:0,fd:1" -CONFIG_CPU_SUP_AMD=y -CONFIG_CPU_SUP_CENTAUR=y -CONFIG_CPU_SUP_HYGON=y -CONFIG_CPU_SUP_INTEL=y -CONFIG_CPU_SUP_ZHAOXIN=y -CONFIG_CRC16=y -CONFIG_CRYPTO_CRC32=y -CONFIG_CRYPTO_CRC32C=y -CONFIG_CRYPTO_HASH=y -CONFIG_CRYPTO_HASH2=y -CONFIG_CRYPTO_RNG2=y -CONFIG_CRYPTO_SHA1=y -# CONFIG_CRYPTO_TWOFISH_X86_64 is not set -CONFIG_DEBUG_MEMORY_INIT=y -CONFIG_DECOMPRESS_BZIP2=y -CONFIG_DECOMPRESS_GZIP=y -CONFIG_DNOTIFY=y -# CONFIG_EARLY_PRINTK is not set -CONFIG_EXT4_FS=y -CONFIG_F2FS_FS=y -CONFIG_FAILOVER=y -CONFIG_FS_IOMAP=y -CONFIG_FS_MBCACHE=y -CONFIG_FW_LOADER_PAGED_BUF=y -CONFIG_GENERIC_CLOCKEVENTS=y -# CONFIG_GENERIC_CPU is not set -CONFIG_GENERIC_CPU_DEVICES=y -CONFIG_GENERIC_FIND_FIRST_BIT=y -CONFIG_GENERIC_IRQ_SHOW=y -CONFIG_HAVE_ARCH_AUDITSYSCALL=y -CONFIG_HAVE_ARCH_SECCOMP_FILTER=y -CONFIG_HAVE_ASM_MODVERSIONS=y -CONFIG_HAVE_COPY_THREAD_TLS=y -CONFIG_HAVE_DEBUG_BUGVERBOSE=y -CONFIG_HAVE_DEBUG_KMEMLEAK=y -CONFIG_HAVE_FUTEX_CMPXCHG=y -CONFIG_HAVE_NET_DSA=y -CONFIG_HAVE_UID16=y -CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y -CONFIG_HOSTFS=y -CONFIG_HVC_DRIVER=y -CONFIG_HZ_PERIODIC=y -CONFIG_INITRAMFS_SOURCE="" -CONFIG_INIT_ENV_ARG_LIMIT=128 -CONFIG_IRQ_WORK=y -CONFIG_ISO9660_FS=y -CONFIG_JBD2=y -# CONFIG_JFFS2_FS is not set -CONFIG_KALLSYMS=y -CONFIG_KERNEL_STACK_ORDER=2 -CONFIG_LD_SCRIPT_STATIC=y -CONFIG_LOCK_DEBUGGING_SUPPORT=y -# CONFIG_MATOM is not set -CONFIG_MCONSOLE=y -# CONFIG_MCORE2 is not set -CONFIG_MEMFD_CREATE=y -CONFIG_MIGRATION=y -CONFIG_MK8=y -# CONFIG_MMAPPER is not set -CONFIG_MODULES_USE_ELF_RELA=y -# CONFIG_MPSC is not set -CONFIG_NAMESPACES=y -CONFIG_NEED_PER_CPU_KM=y -CONFIG_NET_FAILOVER=y -# CONFIG_NET_NS is not set -CONFIG_NLS=y -CONFIG_NO_DMA=y -CONFIG_NO_IOMEM=y -CONFIG_NR_CPUS=1 -CONFIG_NULL_CHAN=y -# CONFIG_OF is not set -CONFIG_PGTABLE_LEVELS=3 -CONFIG_PHYS_ADDR_T_64BIT=y -CONFIG_PORT_CHAN=y -CONFIG_POSIX_MQUEUE=y -CONFIG_POSIX_MQUEUE_SYSCTL=y -# CONFIG_PROCESSOR_SELECT is not set -CONFIG_PROC_PAGE_MONITOR=y -CONFIG_PTY_CHAN=y -CONFIG_RD_BZIP2=y -CONFIG_RD_GZIP=y -CONFIG_RELAY=y -CONFIG_SOFT_WATCHDOG=m -CONFIG_SRCU=y -CONFIG_SSL=y -CONFIG_SSL_CHAN="pty" -CONFIG_STACKTRACE=y -CONFIG_STATIC_LINK=y -CONFIG_STDERR_CONSOLE=y -CONFIG_TICK_CPU_ACCOUNTING=y -CONFIG_TINY_SRCU=y -CONFIG_TTY_CHAN=y -CONFIG_UML=y -CONFIG_UML_NET=y -CONFIG_UML_NET_DAEMON=y -CONFIG_UML_NET_DETERMINISTIC_MAC=y -CONFIG_UML_NET_ETHERTAP=y -CONFIG_UML_NET_MCAST=y -# CONFIG_UML_NET_PCAP is not set -CONFIG_UML_NET_SLIP=y -CONFIG_UML_NET_SLIRP=y -CONFIG_UML_NET_TUNTAP=y -# CONFIG_UML_NET_VDE is not set -CONFIG_UML_NET_VECTOR=y -CONFIG_UML_RANDOM=y -# CONFIG_UML_SOUND is not set -CONFIG_UML_TIME_TRAVEL_SUPPORT=y -CONFIG_UML_WATCHDOG=y -CONFIG_UML_X86=y -# CONFIG_USER_NS is not set -CONFIG_VIRTIO=y -CONFIG_VIRTIO_BLK=y -CONFIG_VIRTIO_CONSOLE=y -CONFIG_VIRTIO_NET=y -CONFIG_VIRTIO_UML=y -CONFIG_VM_EVENT_COUNTERS=y -CONFIG_WATCHDOG_CORE=y -CONFIG_X86_64=y -CONFIG_X86_CMOV=y -CONFIG_X86_CMPXCHG64=y -CONFIG_X86_INTEL_USERCOPY=y -CONFIG_X86_INTERNODE_CACHE_SHIFT=6 -CONFIG_X86_L1_CACHE_SHIFT=6 -CONFIG_X86_MINIMUM_CPU_FAMILY=64 -CONFIG_X86_TSC=y -CONFIG_X86_USE_PPRO_CHECKSUM=y -CONFIG_XTERM_CHAN=y -CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/uml/patches-5.4/101-mconsole-exec.patch b/target/linux/uml/patches-5.4/101-mconsole-exec.patch deleted file mode 100644 index ca4f27b53f..0000000000 --- a/target/linux/uml/patches-5.4/101-mconsole-exec.patch +++ /dev/null @@ -1,205 +0,0 @@ -# -# Minimalist mconsole exec patch -# -# 3.10 version (with bit more synchronous behavior) by fingon at iki dot fi -# Adaptation to kernel 3.3.8 made by David Fernández (david at dit.upm.es) for -# Starting point: mconsole-exec-2.6.30.patch for kernel 2.6.30 -# Author of original patch: Paolo Giarrusso, aka Blaisorblade -# (http://www.user-mode-linux.org/~blaisorblade) -# -# Known misfeatures: -# -# - If output is too long, blocks (and breaks horribly) -# (this misfeature from 3.10 patches, when minimalizing the patch; -# workaround: redirect to a shared filesystem if long output is expected) -# -# - Nothing useful is done with stdin -# ---- a/arch/um/drivers/mconsole.h -+++ b/arch/um/drivers/mconsole.h -@@ -85,6 +85,7 @@ extern void mconsole_cad(struct mc_reque - extern void mconsole_stop(struct mc_request *req); - extern void mconsole_go(struct mc_request *req); - extern void mconsole_log(struct mc_request *req); -+extern void mconsole_exec(struct mc_request *req); - extern void mconsole_proc(struct mc_request *req); - extern void mconsole_stack(struct mc_request *req); - ---- a/arch/um/drivers/mconsole_kern.c -+++ b/arch/um/drivers/mconsole_kern.c -@@ -4,6 +4,7 @@ - * Copyright (C) 2001 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) - */ - -+#include - #include - #include - #include -@@ -26,6 +27,7 @@ - #include - #include - #include -+#include - #include - - #include -@@ -121,6 +123,59 @@ void mconsole_log(struct mc_request *req - mconsole_reply(req, "", 0, 0); - } - -+void mconsole_exec(struct mc_request *req) -+{ -+ struct subprocess_info *sub_info; -+ int res, len; -+ struct file *out; -+ char buf[MCONSOLE_MAX_DATA]; -+ -+ char *envp[] = { -+ "HOME=/", "TERM=linux", -+ "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin", -+ NULL -+ }; -+ char *argv[] = { -+ "/bin/sh", "-c", -+ req->request.data + strlen("exec "), -+ NULL -+ }; -+ -+ sub_info = call_usermodehelper_setup("/bin/sh", argv, envp, GFP_ATOMIC, NULL, NULL, NULL); -+ if (sub_info == NULL) { -+ mconsole_reply(req, "call_usermodehelper_setup failed", 1, 0); -+ return; -+ } -+ res = call_usermodehelper_stdoutpipe(sub_info, &out); -+ if (res < 0) { -+ kfree(sub_info); -+ mconsole_reply(req, "call_usermodehelper_stdoutpipe failed", 1, 0); -+ return; -+ } -+ -+ res = call_usermodehelper_exec(sub_info, UMH_WAIT_PROC); -+ if (res < 0) { -+ kfree(sub_info); -+ mconsole_reply(req, "call_usermodehelper_exec failed", 1, 0); -+ return; -+ } -+ -+ for (;;) { -+ len = out->f_op->read(out, buf, sizeof(buf), &out->f_pos); -+ if (len < 0) { -+ mconsole_reply(req, "reading output failed", 1, 0); -+ break; -+ } -+ if (len == 0) -+ break; -+ mconsole_reply_len(req, buf, len, 0, 1); -+ } -+ fput(out); -+ -+ mconsole_reply_len(req, NULL, 0, 0, 0); -+} -+ -+ - void mconsole_proc(struct mc_request *req) - { - struct vfsmount *mnt = task_active_pid_ns(current)->proc_mnt; -@@ -183,6 +238,7 @@ void mconsole_proc(struct mc_request *re - stop - pause the UML; it will do nothing until it receives a 'go' \n\ - go - continue the UML after a 'stop' \n\ - log - make UML enter into the kernel log\n\ -+ exec - pass to /bin/sh -c synchronously\n\ - proc - returns the contents of the UML's /proc/\n\ - stack - returns the stack of the specified pid\n\ - " ---- a/arch/um/drivers/mconsole_user.c -+++ b/arch/um/drivers/mconsole_user.c -@@ -30,6 +30,7 @@ static struct mconsole_command commands[ - { "stop", mconsole_stop, MCONSOLE_PROC }, - { "go", mconsole_go, MCONSOLE_INTR }, - { "log", mconsole_log, MCONSOLE_INTR }, -+ { "exec", mconsole_exec, MCONSOLE_PROC }, - { "proc", mconsole_proc, MCONSOLE_PROC }, - { "stack", mconsole_stack, MCONSOLE_INTR }, - }; ---- a/arch/um/os-Linux/file.c -+++ b/arch/um/os-Linux/file.c -@@ -557,6 +557,8 @@ int os_create_unix_socket(const char *fi - - addr.sun_family = AF_UNIX; - -+ if (len > sizeof(addr.sun_path)) -+ len = sizeof(addr.sun_path); - snprintf(addr.sun_path, len, "%s", file); - - err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); ---- a/include/linux/kmod.h -+++ b/include/linux/kmod.h -@@ -32,4 +32,6 @@ static inline int request_module_nowait( - #define try_then_request_module(x, mod...) (x) - #endif - -+int call_usermodehelper_stdoutpipe(struct subprocess_info *sub_info, struct file **filp); -+ - #endif /* __LINUX_KMOD_H__ */ ---- a/include/linux/umh.h -+++ b/include/linux/umh.h -@@ -23,6 +23,7 @@ struct subprocess_info { - char **argv; - char **envp; - struct file *file; -+ struct file *stdout; - int wait; - int retval; - pid_t pid; ---- a/kernel/umh.c -+++ b/kernel/umh.c -@@ -76,6 +76,28 @@ static int call_usermodehelper_exec_asyn - flush_signal_handlers(current, 1); - spin_unlock_irq(¤t->sighand->siglock); - -+ /* Install output when needed */ -+ if (sub_info->stdout) { -+ struct files_struct *f = current->files; -+ struct fdtable *fdt; -+ -+ sys_close(1); -+ sys_close(2); -+ get_file(sub_info->stdout); -+ fd_install(1, sub_info->stdout); -+ fd_install(2, sub_info->stdout); -+ spin_lock(&f->file_lock); -+ fdt = files_fdtable(f); -+ __set_bit(1, fdt->open_fds); -+ __clear_bit(1, fdt->close_on_exec); -+ __set_bit(2, fdt->open_fds); -+ __clear_bit(2, fdt->close_on_exec); -+ spin_unlock(&f->file_lock); -+ -+ /* disallow core files */ -+ current->signal->rlim[RLIMIT_CORE] = (struct rlimit){0, 0}; -+ } -+ - /* - * Initial kernel threads share ther FS with init, in order to - * get the init root directory. But we've now created a new -@@ -362,6 +384,20 @@ static void helper_unlock(void) - wake_up(&running_helpers_waitq); - } - -+int call_usermodehelper_stdoutpipe(struct subprocess_info *sub_info, -+ struct file **filp) -+{ -+ struct file *f[2]; -+ -+ if (create_pipe_files(f, 0) < 0) -+ return PTR_ERR(f); -+ -+ sub_info->stdout = f[1]; -+ *filp = f[0]; -+ return 0; -+} -+EXPORT_SYMBOL(call_usermodehelper_stdoutpipe); -+ - /** - * call_usermodehelper_setup - prepare to call a usermode helper - * @path: path to usermode executable diff --git a/target/linux/uml/patches-5.4/102-pseudo-random-mac.patch b/target/linux/uml/patches-5.4/102-pseudo-random-mac.patch deleted file mode 100644 index 19696365a1..0000000000 --- a/target/linux/uml/patches-5.4/102-pseudo-random-mac.patch +++ /dev/null @@ -1,130 +0,0 @@ -=============================================================================== - -This patch makes MAC addresses of network interfaces predictable. In -particular, it adds a small routine that computes MAC addresses of based on -a SHA1 hash of the virtual machine name and interface ID. - -TECHNICAL INFORMATION: - -Applies to vanilla kernel 3.9.4. - -=============================================================================== ---- a/arch/um/drivers/Kconfig -+++ b/arch/um/drivers/Kconfig -@@ -146,6 +146,20 @@ config UML_NET - enable at least one of the following transport options to actually - make use of UML networking. - -+config UML_NET_DETERMINISTIC_MAC -+ bool "Use deterministic MAC addresses for network interfaces" -+ default y -+ depends on UML_NET -+ select CRYPTO_SHA1 -+ help -+ Virtual network devices inside a User-Mode Linux instance must be -+ assigned a MAC (Ethernet) address. If none is specified on the UML -+ command line, one must be automatically computed. If this option is -+ enabled, a randomly generated address is used. Otherwise, if this -+ option is disabled, the address is generated from a SHA1 hash of -+ the umid of the UML instance and the interface name. The latter choice -+ is useful to make MAC addresses predictable. -+ - config UML_NET_ETHERTAP - bool "Ethertap transport" - depends on UML_NET ---- a/arch/um/drivers/net_kern.c -+++ b/arch/um/drivers/net_kern.c -@@ -25,6 +25,14 @@ - #include - #include - -+#include -+#include -+#include -+#include -+#include -+#include -+#include "os.h" -+ - #define DRIVER_NAME "uml-netdev" - - static DEFINE_SPINLOCK(opened_lock); -@@ -286,9 +294,51 @@ static void uml_net_user_timer_expire(st - #endif - } - -+#ifdef CONFIG_UML_NET_DETERMINISTIC_MAC -+ -+/* Compute a SHA1 hash of the UML instance's id and -+ * * an interface name. */ -+static int compute_hash(const char *umid, const char *ifname, char *hash) -+{ -+ struct ahash_request *desc; -+ struct crypto_ahash *tfm; -+ struct scatterlist sg; -+ char vmif[1024]; -+ int ret; -+ -+ strcpy (vmif, umid); -+ strcat (vmif, ifname); -+ -+ tfm = crypto_alloc_ahash("sha1", 0, CRYPTO_ALG_ASYNC); -+ if (IS_ERR(tfm)) -+ return -ENOMEM; -+ -+ desc = ahash_request_alloc(tfm, GFP_KERNEL); -+ if (!desc) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ crypto_ahash_clear_flags(tfm, ~0); -+ -+ sg_init_table(&sg, 1); -+ sg_set_buf(&sg, vmif, strlen(vmif)); -+ -+ ahash_request_set_crypt(desc, &sg, hash, strlen(vmif)); -+ -+ ret = crypto_ahash_digest(desc); -+out: -+ crypto_free_ahash(tfm); -+ -+ return ret; -+} -+ -+#endif -+ - void uml_net_setup_etheraddr(struct net_device *dev, char *str) - { - unsigned char *addr = dev->dev_addr; -+ u8 hash[SHA1_DIGEST_SIZE]; - char *end; - int i; - -@@ -331,9 +381,26 @@ void uml_net_setup_etheraddr(struct net_ - return; - - random: -+#ifndef CONFIG_UML_NET_DETERMINISTIC_MAC - printk(KERN_INFO - "Choosing a random ethernet address for device %s\n", dev->name); - eth_hw_addr_random(dev); -+#else -+ printk(KERN_INFO -+ "Computing a digest to use as ethernet address for device %s\n", dev->name); -+ if (compute_hash(get_umid(), dev->name, hash) < 0) { -+ printk(KERN_WARNING -+ "Could not compute digest to use as ethernet address for device %s. " -+ "Using random address instead.\n", dev->name); -+ random_ether_addr(addr); -+ } -+ else { -+ for (i=0; i < 6; i++) -+ addr[i] = (hash[i] + hash[i+6]) % 0x100; -+ } -+ addr [0] &= 0xfe; /* clear multicast bit */ -+ addr [0] |= 0x02; /* set local assignment bit (IEEE802) */ -+#endif - } - - static DEFINE_SPINLOCK(devices_lock); From 6c312d9717e1fd37552a6e840967cb0061f7bc8f Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Tue, 4 Jan 2022 23:01:53 +0000 Subject: [PATCH 05/73] kernel: improve driver support for gen-3 Aquantia Ethernet PHYs * correctly set system side interface, the original patch was errornous and there is a follow-up fix for it * enable phy statistics for AQR112(+R/C) and ARQ412 (ethtool --phy-statistics ethX) Tested, including phy-statistics, on - IEI Puzzle M901 (AQR112, AQR112C, AQR112R) - IEI Puzzle M902 (AQR113, AQR112R) - Ubiquiti UniFi 6 LR (AQR112C) Signed-off-by: Daniel Golle --- ...y-aquantia-enable-AQR112-and-AQR412.patch} | 16 ++++++--- ...aquantia-fix-system-side-protocol-mi.patch | 34 +++++++++++++++++++ ...-aquantia-Add-AQR113-driver-support.patch} | 8 ++--- ...tia-add-PHY_IDs-for-AQR112-variants.patch} | 14 ++++++-- 4 files changed, 61 insertions(+), 11 deletions(-) rename target/linux/generic/hack-5.10/{721-net-phy-aquantia-enable-AQR112-and-AQR412.patch => 722-net-phy-aquantia-enable-AQR112-and-AQR412.patch} (90%) create mode 100644 target/linux/generic/hack-5.10/723-net-phy-aquantia-fix-system-side-protocol-mi.patch rename target/linux/generic/hack-5.10/{722-net-phy-aquantia-Add-AQR113-driver-support.patch => 724-net-phy-aquantia-Add-AQR113-driver-support.patch} (86%) rename target/linux/generic/hack-5.10/{723-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch => 725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch} (79%) diff --git a/target/linux/generic/hack-5.10/721-net-phy-aquantia-enable-AQR112-and-AQR412.patch b/target/linux/generic/hack-5.10/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch similarity index 90% rename from target/linux/generic/hack-5.10/721-net-phy-aquantia-enable-AQR112-and-AQR412.patch rename to target/linux/generic/hack-5.10/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch index 882f20c6d1..e3541400d7 100644 --- a/target/linux/generic/hack-5.10/721-net-phy-aquantia-enable-AQR112-and-AQR412.patch +++ b/target/linux/generic/hack-5.10/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch @@ -109,30 +109,38 @@ Signed-off-by: Alex Marginean static int aqr_config_intr(struct phy_device *phydev) { bool en = phydev->interrupts == PHY_INTERRUPT_ENABLED; -@@ -738,6 +808,22 @@ static struct phy_driver aqr_driver[] = +@@ -738,6 +808,30 @@ static struct phy_driver aqr_driver[] = .get_stats = aqr107_get_stats, .link_change_notify = aqr107_link_change_notify, }, +{ + PHY_ID_MATCH_MODEL(PHY_ID_AQR112), + .name = "Aquantia AQR112", -+ .config_aneg = aqr_config_aneg_set_prot, ++ .probe = aqr107_probe, ++ .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .ack_interrupt = aqr_ack_interrupt, + .read_status = aqr107_read_status, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, +}, +{ + PHY_ID_MATCH_MODEL(PHY_ID_AQR412), + .name = "Aquantia AQR412", -+ .config_aneg = aqr_config_aneg_set_prot, ++ .probe = aqr107_probe, ++ .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .ack_interrupt = aqr_ack_interrupt, + .read_status = aqr107_read_status, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, +}, }; module_phy_driver(aqr_driver); -@@ -748,9 +834,11 @@ static struct mdio_device_id __maybe_unu +@@ -748,9 +842,11 @@ static struct mdio_device_id __maybe_unu { PHY_ID_MATCH_MODEL(PHY_ID_AQR105) }, { PHY_ID_MATCH_MODEL(PHY_ID_AQR106) }, { PHY_ID_MATCH_MODEL(PHY_ID_AQR107) }, diff --git a/target/linux/generic/hack-5.10/723-net-phy-aquantia-fix-system-side-protocol-mi.patch b/target/linux/generic/hack-5.10/723-net-phy-aquantia-fix-system-side-protocol-mi.patch new file mode 100644 index 0000000000..9c5df905bb --- /dev/null +++ b/target/linux/generic/hack-5.10/723-net-phy-aquantia-fix-system-side-protocol-mi.patch @@ -0,0 +1,34 @@ +From 5f008cb22f60da4e10375f22266c1a4e20b1252e Mon Sep 17 00:00:00 2001 +From: Alex Marginean +Date: Fri, 20 Sep 2019 18:22:52 +0300 +Subject: [PATCH] drivers: net: phy: aquantia: fix system side protocol + misconfiguration + +Do not set up protocols for speeds that are not supported by FW. Enabling +these protocols leads to link issues on system side. + +Signed-off-by: Alex Marginean +--- + drivers/net/phy/aquantia_main.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/aquantia_main.c ++++ b/drivers/net/phy/aquantia_main.c +@@ -301,10 +301,16 @@ static int aqr_config_aneg_set_prot(stru + phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GSTART_RATE, + aquantia_syscfg[if_type].start_rate); + +- for (i = 0; i <= aquantia_syscfg[if_type].cnt; i++) ++ for (i = 0; i <= aquantia_syscfg[if_type].cnt; i++) { ++ u16 reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, ++ AQUANTIA_VND1_GSYSCFG_BASE + i); ++ if (!reg) ++ continue; ++ + phy_write_mmd(phydev, MDIO_MMD_VEND1, + AQUANTIA_VND1_GSYSCFG_BASE + i, + aquantia_syscfg[if_type].syscfg); ++ } + + /* wake PHY back up */ + phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0); diff --git a/target/linux/generic/hack-5.10/722-net-phy-aquantia-Add-AQR113-driver-support.patch b/target/linux/generic/hack-5.10/724-net-phy-aquantia-Add-AQR113-driver-support.patch similarity index 86% rename from target/linux/generic/hack-5.10/722-net-phy-aquantia-Add-AQR113-driver-support.patch rename to target/linux/generic/hack-5.10/724-net-phy-aquantia-Add-AQR113-driver-support.patch index 2b7a38d1c7..7a661309f9 100644 --- a/target/linux/generic/hack-5.10/722-net-phy-aquantia-Add-AQR113-driver-support.patch +++ b/target/linux/generic/hack-5.10/724-net-phy-aquantia-Add-AQR113-driver-support.patch @@ -18,8 +18,8 @@ Add a new entry for AQR113 PHY_ID #define PHY_ID_AQR113C 0x31c31c12 #define PHY_ID_AQCS109 0x03a1b5c2 #define PHY_ID_AQR405 0x03a1b4b0 -@@ -817,6 +818,14 @@ static struct phy_driver aqr_driver[] = - .read_status = aqr107_read_status, +@@ -827,6 +828,14 @@ static struct phy_driver aqr_driver[] = + .get_stats = aqr107_get_stats, }, { + PHY_ID_MATCH_MODEL(PHY_ID_AQR113), @@ -32,8 +32,8 @@ Add a new entry for AQR113 PHY_ID +{ PHY_ID_MATCH_MODEL(PHY_ID_AQR412), .name = "Aquantia AQR412", - .config_aneg = aqr_config_aneg_set_prot, -@@ -835,6 +844,7 @@ static struct mdio_device_id __maybe_unu + .probe = aqr107_probe, +@@ -849,6 +858,7 @@ static struct mdio_device_id __maybe_unu { PHY_ID_MATCH_MODEL(PHY_ID_AQR106) }, { PHY_ID_MATCH_MODEL(PHY_ID_AQR107) }, { PHY_ID_MATCH_MODEL(PHY_ID_AQR112) }, diff --git a/target/linux/generic/hack-5.10/723-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch b/target/linux/generic/hack-5.10/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch similarity index 79% rename from target/linux/generic/hack-5.10/723-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch rename to target/linux/generic/hack-5.10/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch index b60d009241..40ad0ff583 100644 --- a/target/linux/generic/hack-5.10/723-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch +++ b/target/linux/generic/hack-5.10/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch @@ -21,30 +21,38 @@ Signed-off-by: Daniel Golle #define PHY_ID_AQR113 0x31c31c40 #define PHY_ID_AQR113C 0x31c31c12 #define PHY_ID_AQCS109 0x03a1b5c2 -@@ -818,6 +820,22 @@ static struct phy_driver aqr_driver[] = - .read_status = aqr107_read_status, +@@ -828,6 +830,30 @@ static struct phy_driver aqr_driver[] = + .get_stats = aqr107_get_stats, }, { + PHY_ID_MATCH_MODEL(PHY_ID_AQR112C), + .name = "Aquantia AQR112C", ++ .probe = aqr107_probe, + .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .ack_interrupt = aqr_ack_interrupt, + .read_status = aqr107_read_status, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, +}, +{ + PHY_ID_MATCH_MODEL(PHY_ID_AQR112R), + .name = "Aquantia AQR112R", ++ .probe = aqr107_probe, + .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .ack_interrupt = aqr_ack_interrupt, + .read_status = aqr107_read_status, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, +}, +{ PHY_ID_MATCH_MODEL(PHY_ID_AQR113), .name = "Aquantia AQR113", .config_aneg = aqr_config_aneg, -@@ -844,6 +862,8 @@ static struct mdio_device_id __maybe_unu +@@ -858,6 +884,8 @@ static struct mdio_device_id __maybe_unu { PHY_ID_MATCH_MODEL(PHY_ID_AQR106) }, { PHY_ID_MATCH_MODEL(PHY_ID_AQR107) }, { PHY_ID_MATCH_MODEL(PHY_ID_AQR112) }, From ef1a64caf40e589a5c13cfc68032b3f95d02b715 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Tue, 4 Jan 2022 23:34:23 +0000 Subject: [PATCH 06/73] mediatek: let mtk_eth_soc MAC announce 2500Base-T mode To allows Ethernet phys supporting 2500Base-T mode to announce that speed, enable the corresponding bit in mtk_eth_soc driver. This should hopefully unlock 2500Base-T speed on the UniFi 6 LR. Signed-off-by: Daniel Golle --- ...3-net-ethernet-mtk_eth_soc-announce-2500baseT.patch | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 target/linux/mediatek/patches-5.10/703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch diff --git a/target/linux/mediatek/patches-5.10/703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch b/target/linux/mediatek/patches-5.10/703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch new file mode 100644 index 0000000000..3dbeec08ac --- /dev/null +++ b/target/linux/mediatek/patches-5.10/703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch @@ -0,0 +1,10 @@ +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -564,6 +564,7 @@ static void mtk_validate(struct phylink_ + if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII)) { + phylink_set(mask, 1000baseT_Full); + phylink_set(mask, 1000baseX_Full); ++ phylink_set(mask, 2500baseT_Full); + phylink_set(mask, 2500baseX_Full); + } + if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_RGMII)) { From b2d769673ad8714bcb74a43144d3d58b31d7dbf7 Mon Sep 17 00:00:00 2001 From: Matt Fawcett Date: Fri, 24 Dec 2021 06:45:13 +0000 Subject: [PATCH 07/73] qoriq: Expand generic subtarget description Signed-off-by: Matt Fawcett [remove trailing whitespace] Signed-off-by: Stijn Tintel --- target/linux/qoriq/generic/target.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/linux/qoriq/generic/target.mk b/target/linux/qoriq/generic/target.mk index b3bdb405f7..c0af2feb76 100644 --- a/target/linux/qoriq/generic/target.mk +++ b/target/linux/qoriq/generic/target.mk @@ -1,3 +1,5 @@ define Target/Description - Build firmware images for NXP QorIQ boards in the AMP series. + Build firmware images for NXP QorIQ boards in the + T-Series(T1-T5) aka AMP Series platforms. + Features the e5500 and e6500 64-bit Power Architecture cores. endef From 87b6e10c71203d2dedd8a56dea91390dac00c525 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 5 Jan 2022 14:11:06 +0000 Subject: [PATCH 08/73] mediatek: Clause-45 MDIO patch accepted upstream To easy future maintainance, replace the local patch with what has been accepted into net-next and is likely to end up in Linux 5.17. Signed-off-by: Daniel Golle --- ...eth_soc-fix-return-value-of-MDIO-ops.patch | 97 ----------- ..._eth_soc-fix-return-values-and-refac.patch | 128 ++++++++++++++ ..._soc-implement-Clause-45-MDIO-access.patch | 157 ------------------ ...pers-to-extract-clause-45-regad-and-.patch | 53 ++++++ ..._eth_soc-implement-Clause-45-MDIO-ac.patch | 128 ++++++++++++++ ...rnet-mtk_eth_soc-announce-2500baseT.patch} | 2 +- 6 files changed, 310 insertions(+), 255 deletions(-) delete mode 100644 target/linux/mediatek/patches-5.10/701-net-ethernet-mtk_eth_soc-fix-return-value-of-MDIO-ops.patch create mode 100644 target/linux/mediatek/patches-5.10/701-v5.17-net-ethernet-mtk_eth_soc-fix-return-values-and-refac.patch delete mode 100644 target/linux/mediatek/patches-5.10/702-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-access.patch create mode 100644 target/linux/mediatek/patches-5.10/702-v5.17-net-mdio-add-helpers-to-extract-clause-45-regad-and-.patch create mode 100644 target/linux/mediatek/patches-5.10/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch rename target/linux/mediatek/patches-5.10/{703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch => 704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch} (85%) diff --git a/target/linux/mediatek/patches-5.10/701-net-ethernet-mtk_eth_soc-fix-return-value-of-MDIO-ops.patch b/target/linux/mediatek/patches-5.10/701-net-ethernet-mtk_eth_soc-fix-return-value-of-MDIO-ops.patch deleted file mode 100644 index 696b68df47..0000000000 --- a/target/linux/mediatek/patches-5.10/701-net-ethernet-mtk_eth_soc-fix-return-value-of-MDIO-ops.patch +++ /dev/null @@ -1,97 +0,0 @@ -From patchwork Mon Dec 27 18:31:09 2021 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Daniel Golle -X-Patchwork-Id: 12699993 -X-Patchwork-Delegate: kuba@kernel.org -Return-Path: -Date: Mon, 27 Dec 2021 18:31:09 +0000 -From: Daniel Golle -To: linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org -Cc: Felix Fietkau , John Crispin , - Sean Wang , - Mark Lee , - "David S. Miller" , - Jakub Kicinski , - Matthias Brugger , - Russell King , - Andrew Lunn -Subject: [PATCH v5 1/2] net: ethernet: mtk_eth_soc: fix return value of MDIO - ops -Message-ID: -References: - -MIME-Version: 1.0 -Content-Disposition: inline -In-Reply-To: - -Precedence: bulk -List-ID: -X-Mailing-List: netdev@vger.kernel.org -X-Patchwork-Delegate: kuba@kernel.org - -Instead of returning -1 (-EPERM) when MDIO bus is stuck busy -while writing or 0xffff if it happens while reading, return the -appropriate -EBUSY. Also fix return type to int instead of u32. - -Fixes: 656e705243fd0 ("net-next: mediatek: add support for MT7623 ethernet") -Signed-off-by: Daniel Golle ---- -v5: fix incomplete unification of variable names phy_reg vs. phy_register -v4: clean-up return values and types, split into two commits - - drivers/net/ethernet/mediatek/mtk_eth_soc.c | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - ---- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c -+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -95,31 +95,31 @@ static int mtk_mdio_busy_wait(struct mtk - return -1; - } - --static u32 _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr, -- u32 phy_register, u32 write_data) -+static int _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr, u32 phy_reg, -+ u32 write_data) - { - if (mtk_mdio_busy_wait(eth)) -- return -1; -+ return -EBUSY; - - write_data &= 0xffff; - - mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_WRITE | -- (phy_register << PHY_IAC_REG_SHIFT) | -+ (phy_reg << PHY_IAC_REG_SHIFT) | - (phy_addr << PHY_IAC_ADDR_SHIFT) | write_data, - MTK_PHY_IAC); - - if (mtk_mdio_busy_wait(eth)) -- return -1; -+ return -EBUSY; - - return 0; - } - --static u32 _mtk_mdio_read(struct mtk_eth *eth, int phy_addr, int phy_reg) -+static int _mtk_mdio_read(struct mtk_eth *eth, int phy_addr, int phy_reg) - { - u32 d; - - if (mtk_mdio_busy_wait(eth)) -- return 0xffff; -+ return -EBUSY; - - mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_READ | - (phy_reg << PHY_IAC_REG_SHIFT) | -@@ -127,7 +127,7 @@ static u32 _mtk_mdio_read(struct mtk_eth - MTK_PHY_IAC); - - if (mtk_mdio_busy_wait(eth)) -- return 0xffff; -+ return -EBUSY; - - d = mtk_r32(eth, MTK_PHY_IAC) & 0xffff; - diff --git a/target/linux/mediatek/patches-5.10/701-v5.17-net-ethernet-mtk_eth_soc-fix-return-values-and-refac.patch b/target/linux/mediatek/patches-5.10/701-v5.17-net-ethernet-mtk_eth_soc-fix-return-values-and-refac.patch new file mode 100644 index 0000000000..5da46f07e0 --- /dev/null +++ b/target/linux/mediatek/patches-5.10/701-v5.17-net-ethernet-mtk_eth_soc-fix-return-values-and-refac.patch @@ -0,0 +1,128 @@ +From eda80b249df7bbc7b3dd13907343a3e59bfc57fd Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 4 Jan 2022 12:06:22 +0000 +Subject: [PATCH 1/3] net: ethernet: mtk_eth_soc: fix return values and + refactor MDIO ops + +Instead of returning -1 (-EPERM) when MDIO bus is stuck busy +while writing or 0xffff if it happens while reading, return the +appropriate -ETIMEDOUT. Also fix return type to int instead of u32. +Refactor functions to use bitfield helpers instead of having various +masking and shifting constants in the code, which also results in the +register definitions in the header file being more obviously related +to what is stated in the MediaTek's Reference Manual. + +Fixes: 656e705243fd0 ("net-next: mediatek: add support for MT7623 ethernet") +Signed-off-by: Daniel Golle +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 53 ++++++++++++--------- + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 16 +++++-- + 2 files changed, 41 insertions(+), 28 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -92,46 +92,53 @@ static int mtk_mdio_busy_wait(struct mtk + } + + dev_err(eth->dev, "mdio: MDIO timeout\n"); +- return -1; ++ return -ETIMEDOUT; + } + +-static u32 _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr, +- u32 phy_register, u32 write_data) ++static int _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr, u32 phy_reg, ++ u32 write_data) + { +- if (mtk_mdio_busy_wait(eth)) +- return -1; ++ int ret; + +- write_data &= 0xffff; +- +- mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_WRITE | +- (phy_register << PHY_IAC_REG_SHIFT) | +- (phy_addr << PHY_IAC_ADDR_SHIFT) | write_data, ++ ret = mtk_mdio_busy_wait(eth); ++ if (ret < 0) ++ return ret; ++ ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C22 | ++ PHY_IAC_CMD_WRITE | ++ PHY_IAC_REG(phy_reg) | ++ PHY_IAC_ADDR(phy_addr) | ++ PHY_IAC_DATA(write_data), + MTK_PHY_IAC); + +- if (mtk_mdio_busy_wait(eth)) +- return -1; ++ ret = mtk_mdio_busy_wait(eth); ++ if (ret < 0) ++ return ret; + + return 0; + } + +-static u32 _mtk_mdio_read(struct mtk_eth *eth, int phy_addr, int phy_reg) ++static int _mtk_mdio_read(struct mtk_eth *eth, u32 phy_addr, u32 phy_reg) + { +- u32 d; +- +- if (mtk_mdio_busy_wait(eth)) +- return 0xffff; ++ int ret; + +- mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_READ | +- (phy_reg << PHY_IAC_REG_SHIFT) | +- (phy_addr << PHY_IAC_ADDR_SHIFT), ++ ret = mtk_mdio_busy_wait(eth); ++ if (ret < 0) ++ return ret; ++ ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C22 | ++ PHY_IAC_CMD_C22_READ | ++ PHY_IAC_REG(phy_reg) | ++ PHY_IAC_ADDR(phy_addr), + MTK_PHY_IAC); + +- if (mtk_mdio_busy_wait(eth)) +- return 0xffff; +- +- d = mtk_r32(eth, MTK_PHY_IAC) & 0xffff; ++ ret = mtk_mdio_busy_wait(eth); ++ if (ret < 0) ++ return ret; + +- return d; ++ return mtk_r32(eth, MTK_PHY_IAC) & PHY_IAC_DATA_MASK; + } + + static int mtk_mdio_write(struct mii_bus *bus, int phy_addr, +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -340,11 +340,17 @@ + /* PHY Indirect Access Control registers */ + #define MTK_PHY_IAC 0x10004 + #define PHY_IAC_ACCESS BIT(31) +-#define PHY_IAC_READ BIT(19) +-#define PHY_IAC_WRITE BIT(18) +-#define PHY_IAC_START BIT(16) +-#define PHY_IAC_ADDR_SHIFT 20 +-#define PHY_IAC_REG_SHIFT 25 ++#define PHY_IAC_REG_MASK GENMASK(29, 25) ++#define PHY_IAC_REG(x) FIELD_PREP(PHY_IAC_REG_MASK, (x)) ++#define PHY_IAC_ADDR_MASK GENMASK(24, 20) ++#define PHY_IAC_ADDR(x) FIELD_PREP(PHY_IAC_ADDR_MASK, (x)) ++#define PHY_IAC_CMD_MASK GENMASK(19, 18) ++#define PHY_IAC_CMD_WRITE FIELD_PREP(PHY_IAC_CMD_MASK, 1) ++#define PHY_IAC_CMD_C22_READ FIELD_PREP(PHY_IAC_CMD_MASK, 2) ++#define PHY_IAC_START_MASK GENMASK(17, 16) ++#define PHY_IAC_START_C22 FIELD_PREP(PHY_IAC_START_MASK, 1) ++#define PHY_IAC_DATA_MASK GENMASK(15, 0) ++#define PHY_IAC_DATA(x) FIELD_PREP(PHY_IAC_DATA_MASK, (x)) + #define PHY_IAC_TIMEOUT HZ + + #define MTK_MAC_MISC 0x1000c diff --git a/target/linux/mediatek/patches-5.10/702-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-access.patch b/target/linux/mediatek/patches-5.10/702-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-access.patch deleted file mode 100644 index f7732cae9b..0000000000 --- a/target/linux/mediatek/patches-5.10/702-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-access.patch +++ /dev/null @@ -1,157 +0,0 @@ -From patchwork Mon Dec 27 18:31:43 2021 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Daniel Golle -X-Patchwork-Id: 12699994 -X-Patchwork-Delegate: kuba@kernel.org -Return-Path: -Date: Mon, 27 Dec 2021 18:31:43 +0000 -From: Daniel Golle -To: linux-mediatek@lists.infradead.org, netdev@vger.kernel.org, - linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org -Cc: Felix Fietkau , John Crispin , - Sean Wang , - Mark Lee , - "David S. Miller" , - Jakub Kicinski , - Matthias Brugger , - Russell King , - Andrew Lunn -Subject: [PATCH v5 2/2] net: ethernet: mtk_eth_soc: implement Clause 45 MDIO - access -Message-ID: -References: - -MIME-Version: 1.0 -Content-Disposition: inline -In-Reply-To: - -Precedence: bulk -List-ID: -X-Mailing-List: netdev@vger.kernel.org -X-Patchwork-Delegate: kuba@kernel.org - -Implement read and write access to IEEE 802.3 Clause 45 Ethernet -phy registers. -Tested on the Ubiquiti UniFi 6 LR access point featuring -MediaTek MT7622BV WiSoC with Aquantia AQR112C. - -Signed-off-by: Daniel Golle ---- -v5: unchanged -v4: clean-up return values and types, split into two commits -v3: return -1 instead of 0xffff on error in _mtk_mdio_write -v2: use MII_DEVADDR_C45_SHIFT and MII_REGADDR_C45_MASK to extract - device id and register address. Unify read and write functions to - have identical types and parameter names where possible as we are - anyway already replacing both function bodies. - - - drivers/net/ethernet/mediatek/mtk_eth_soc.c | 60 +++++++++++++++++---- - drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 ++ - 2 files changed, 53 insertions(+), 10 deletions(-) - ---- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c -+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -103,10 +103,30 @@ static int _mtk_mdio_write(struct mtk_et - - write_data &= 0xffff; - -- mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_WRITE | -- (phy_reg << PHY_IAC_REG_SHIFT) | -- (phy_addr << PHY_IAC_ADDR_SHIFT) | write_data, -- MTK_PHY_IAC); -+ if (phy_reg & MII_ADDR_C45) { -+ u8 dev_num = (phy_reg >> MII_DEVADDR_C45_SHIFT) & GENMASK(4, 0); -+ u16 reg = (u16)(phy_reg & MII_REGADDR_C45_MASK); -+ -+ mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START_C45 | PHY_IAC_SET_ADDR | -+ (phy_addr << PHY_IAC_ADDR_SHIFT) | -+ (dev_num << PHY_IAC_REG_SHIFT) | -+ reg, -+ MTK_PHY_IAC); -+ -+ if (mtk_mdio_busy_wait(eth)) -+ return -EBUSY; -+ -+ mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START_C45 | PHY_IAC_WRITE | -+ (phy_addr << PHY_IAC_ADDR_SHIFT) | -+ (dev_num << PHY_IAC_REG_SHIFT) | -+ write_data, -+ MTK_PHY_IAC); -+ } else { -+ mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_WRITE | -+ (phy_reg << PHY_IAC_REG_SHIFT) | -+ (phy_addr << PHY_IAC_ADDR_SHIFT) | write_data, -+ MTK_PHY_IAC); -+ } - - if (mtk_mdio_busy_wait(eth)) - return -EBUSY; -@@ -114,17 +134,36 @@ static int _mtk_mdio_write(struct mtk_et - return 0; - } - --static int _mtk_mdio_read(struct mtk_eth *eth, int phy_addr, int phy_reg) -+static int _mtk_mdio_read(struct mtk_eth *eth, u32 phy_addr, u32 phy_reg) - { -- u32 d; -+ int d; - - if (mtk_mdio_busy_wait(eth)) - return -EBUSY; - -- mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_READ | -- (phy_reg << PHY_IAC_REG_SHIFT) | -- (phy_addr << PHY_IAC_ADDR_SHIFT), -- MTK_PHY_IAC); -+ if (phy_reg & MII_ADDR_C45) { -+ u8 dev_num = (phy_reg >> MII_DEVADDR_C45_SHIFT) & GENMASK(4, 0); -+ u16 reg = (u16)(phy_reg & MII_REGADDR_C45_MASK); -+ -+ mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START_C45 | PHY_IAC_SET_ADDR | -+ (phy_addr << PHY_IAC_ADDR_SHIFT) | -+ (dev_num << PHY_IAC_REG_SHIFT) | -+ reg, -+ MTK_PHY_IAC); -+ -+ if (mtk_mdio_busy_wait(eth)) -+ return -EBUSY; -+ -+ mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START_C45 | PHY_IAC_READ_C45 | -+ (phy_addr << PHY_IAC_ADDR_SHIFT) | -+ (dev_num << PHY_IAC_REG_SHIFT), -+ MTK_PHY_IAC); -+ } else { -+ mtk_w32(eth, PHY_IAC_ACCESS | PHY_IAC_START | PHY_IAC_READ | -+ (phy_reg << PHY_IAC_REG_SHIFT) | -+ (phy_addr << PHY_IAC_ADDR_SHIFT), -+ MTK_PHY_IAC); -+ } - - if (mtk_mdio_busy_wait(eth)) - return -EBUSY; -@@ -584,6 +623,7 @@ static int mtk_mdio_init(struct mtk_eth - eth->mii_bus->name = "mdio"; - eth->mii_bus->read = mtk_mdio_read; - eth->mii_bus->write = mtk_mdio_write; -+ eth->mii_bus->probe_capabilities = MDIOBUS_C22_C45; - eth->mii_bus->priv = eth; - eth->mii_bus->parent = eth->dev; - ---- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h -+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h -@@ -340,9 +340,12 @@ - /* PHY Indirect Access Control registers */ - #define MTK_PHY_IAC 0x10004 - #define PHY_IAC_ACCESS BIT(31) -+#define PHY_IAC_SET_ADDR 0 - #define PHY_IAC_READ BIT(19) -+#define PHY_IAC_READ_C45 (BIT(18) | BIT(19)) - #define PHY_IAC_WRITE BIT(18) - #define PHY_IAC_START BIT(16) -+#define PHY_IAC_START_C45 0 - #define PHY_IAC_ADDR_SHIFT 20 - #define PHY_IAC_REG_SHIFT 25 - #define PHY_IAC_TIMEOUT HZ diff --git a/target/linux/mediatek/patches-5.10/702-v5.17-net-mdio-add-helpers-to-extract-clause-45-regad-and-.patch b/target/linux/mediatek/patches-5.10/702-v5.17-net-mdio-add-helpers-to-extract-clause-45-regad-and-.patch new file mode 100644 index 0000000000..ef2e225717 --- /dev/null +++ b/target/linux/mediatek/patches-5.10/702-v5.17-net-mdio-add-helpers-to-extract-clause-45-regad-and-.patch @@ -0,0 +1,53 @@ +From c6af53f038aa32cec12e8a305ba07c7ef168f1b0 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 4 Jan 2022 12:07:00 +0000 +Subject: [PATCH 2/3] net: mdio: add helpers to extract clause 45 regad and + devad fields + +Add a couple of helpers and definitions to extract the clause 45 regad +and devad fields from the regnum passed into MDIO drivers. + +Tested-by: Daniel Golle +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Signed-off-by: Daniel Golle +Signed-off-by: David S. Miller +--- + include/linux/mdio.h | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +--- a/include/linux/mdio.h ++++ b/include/linux/mdio.h +@@ -7,6 +7,7 @@ + #define __LINUX_MDIO_H__ + + #include ++#include + #include + + /* Or MII_ADDR_C45 into regnum for read/write on mii_bus to enable the 21 bit +@@ -14,6 +15,7 @@ + */ + #define MII_ADDR_C45 (1<<30) + #define MII_DEVADDR_C45_SHIFT 16 ++#define MII_DEVADDR_C45_MASK GENMASK(20, 16) + #define MII_REGADDR_C45_MASK GENMASK(15, 0) + + struct gpio_desc; +@@ -342,6 +344,16 @@ static inline u32 mdiobus_c45_addr(int d + return MII_ADDR_C45 | devad << MII_DEVADDR_C45_SHIFT | regnum; + } + ++static inline u16 mdiobus_c45_regad(u32 regnum) ++{ ++ return FIELD_GET(MII_REGADDR_C45_MASK, regnum); ++} ++ ++static inline u16 mdiobus_c45_devad(u32 regnum) ++{ ++ return FIELD_GET(MII_DEVADDR_C45_MASK, regnum); ++} ++ + static inline int __mdiobus_c45_read(struct mii_bus *bus, int prtad, int devad, + u16 regnum) + { diff --git a/target/linux/mediatek/patches-5.10/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch b/target/linux/mediatek/patches-5.10/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch new file mode 100644 index 0000000000..88c600f791 --- /dev/null +++ b/target/linux/mediatek/patches-5.10/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch @@ -0,0 +1,128 @@ +From e2e7f6e29c99a1c6afc0e0aa4b9ea80302d28720 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 4 Jan 2022 12:07:46 +0000 +Subject: [PATCH 3/3] net: ethernet: mtk_eth_soc: implement Clause 45 MDIO + access + +Implement read and write access to IEEE 802.3 Clause 45 Ethernet +phy registers while making use of new mdiobus_c45_regad and +mdiobus_c45_devad helpers. + +Tested on the Ubiquiti UniFi 6 LR access point featuring +MediaTek MT7622BV WiSoC with Aquantia AQR112C. + +Signed-off-by: Daniel Golle +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 70 +++++++++++++++++---- + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 + + 2 files changed, 60 insertions(+), 13 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -104,13 +104,35 @@ static int _mtk_mdio_write(struct mtk_et + if (ret < 0) + return ret; + +- mtk_w32(eth, PHY_IAC_ACCESS | +- PHY_IAC_START_C22 | +- PHY_IAC_CMD_WRITE | +- PHY_IAC_REG(phy_reg) | +- PHY_IAC_ADDR(phy_addr) | +- PHY_IAC_DATA(write_data), +- MTK_PHY_IAC); ++ if (phy_reg & MII_ADDR_C45) { ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C45 | ++ PHY_IAC_CMD_C45_ADDR | ++ PHY_IAC_REG(mdiobus_c45_devad(phy_reg)) | ++ PHY_IAC_ADDR(phy_addr) | ++ PHY_IAC_DATA(mdiobus_c45_regad(phy_reg)), ++ MTK_PHY_IAC); ++ ++ ret = mtk_mdio_busy_wait(eth); ++ if (ret < 0) ++ return ret; ++ ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C45 | ++ PHY_IAC_CMD_WRITE | ++ PHY_IAC_REG(mdiobus_c45_devad(phy_reg)) | ++ PHY_IAC_ADDR(phy_addr) | ++ PHY_IAC_DATA(write_data), ++ MTK_PHY_IAC); ++ } else { ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C22 | ++ PHY_IAC_CMD_WRITE | ++ PHY_IAC_REG(phy_reg) | ++ PHY_IAC_ADDR(phy_addr) | ++ PHY_IAC_DATA(write_data), ++ MTK_PHY_IAC); ++ } + + ret = mtk_mdio_busy_wait(eth); + if (ret < 0) +@@ -127,12 +149,33 @@ static int _mtk_mdio_read(struct mtk_eth + if (ret < 0) + return ret; + +- mtk_w32(eth, PHY_IAC_ACCESS | +- PHY_IAC_START_C22 | +- PHY_IAC_CMD_C22_READ | +- PHY_IAC_REG(phy_reg) | +- PHY_IAC_ADDR(phy_addr), +- MTK_PHY_IAC); ++ if (phy_reg & MII_ADDR_C45) { ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C45 | ++ PHY_IAC_CMD_C45_ADDR | ++ PHY_IAC_REG(mdiobus_c45_devad(phy_reg)) | ++ PHY_IAC_ADDR(phy_addr) | ++ PHY_IAC_DATA(mdiobus_c45_regad(phy_reg)), ++ MTK_PHY_IAC); ++ ++ ret = mtk_mdio_busy_wait(eth); ++ if (ret < 0) ++ return ret; ++ ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C45 | ++ PHY_IAC_CMD_C45_READ | ++ PHY_IAC_REG(mdiobus_c45_devad(phy_reg)) | ++ PHY_IAC_ADDR(phy_addr), ++ MTK_PHY_IAC); ++ } else { ++ mtk_w32(eth, PHY_IAC_ACCESS | ++ PHY_IAC_START_C22 | ++ PHY_IAC_CMD_C22_READ | ++ PHY_IAC_REG(phy_reg) | ++ PHY_IAC_ADDR(phy_addr), ++ MTK_PHY_IAC); ++ } + + ret = mtk_mdio_busy_wait(eth); + if (ret < 0) +@@ -591,6 +634,7 @@ static int mtk_mdio_init(struct mtk_eth + eth->mii_bus->name = "mdio"; + eth->mii_bus->read = mtk_mdio_read; + eth->mii_bus->write = mtk_mdio_write; ++ eth->mii_bus->probe_capabilities = MDIOBUS_C22_C45; + eth->mii_bus->priv = eth; + eth->mii_bus->parent = eth->dev; + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -345,9 +345,12 @@ + #define PHY_IAC_ADDR_MASK GENMASK(24, 20) + #define PHY_IAC_ADDR(x) FIELD_PREP(PHY_IAC_ADDR_MASK, (x)) + #define PHY_IAC_CMD_MASK GENMASK(19, 18) ++#define PHY_IAC_CMD_C45_ADDR FIELD_PREP(PHY_IAC_CMD_MASK, 0) + #define PHY_IAC_CMD_WRITE FIELD_PREP(PHY_IAC_CMD_MASK, 1) + #define PHY_IAC_CMD_C22_READ FIELD_PREP(PHY_IAC_CMD_MASK, 2) ++#define PHY_IAC_CMD_C45_READ FIELD_PREP(PHY_IAC_CMD_MASK, 3) + #define PHY_IAC_START_MASK GENMASK(17, 16) ++#define PHY_IAC_START_C45 FIELD_PREP(PHY_IAC_START_MASK, 0) + #define PHY_IAC_START_C22 FIELD_PREP(PHY_IAC_START_MASK, 1) + #define PHY_IAC_DATA_MASK GENMASK(15, 0) + #define PHY_IAC_DATA(x) FIELD_PREP(PHY_IAC_DATA_MASK, (x)) diff --git a/target/linux/mediatek/patches-5.10/703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch b/target/linux/mediatek/patches-5.10/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch similarity index 85% rename from target/linux/mediatek/patches-5.10/703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch rename to target/linux/mediatek/patches-5.10/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch index 3dbeec08ac..3afbc01017 100644 --- a/target/linux/mediatek/patches-5.10/703-net-ethernet-mtk_eth_soc-announce-2500baseT.patch +++ b/target/linux/mediatek/patches-5.10/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch @@ -1,6 +1,6 @@ --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -564,6 +564,7 @@ static void mtk_validate(struct phylink_ +@@ -575,6 +575,7 @@ static void mtk_validate(struct phylink_ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII)) { phylink_set(mask, 1000baseT_Full); phylink_set(mask, 1000baseX_Full); From 11d2c71538944ad55aca33d60d8bd442b8246ed6 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Mon, 19 Apr 2021 20:36:58 +0200 Subject: [PATCH 09/73] ltq-deu: init des/aes before registering crpyto algorithms The crypto algorithms are registered and available to the system before the chip is actually powered on and the generic parameter for the DEU behaviour set. The issue can mainly be observed if the crypto manager tests are enabled in the kernel config. The crypto manager test run directly after an algorithm is registered. Signed-off-by: Mathias Kresin [fix commit title prefix] Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 3 +-- package/kernel/lantiq/ltq-deu/src/ifxmips_des.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 76abfafb4e..7ce6df0ac6 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -894,6 +894,7 @@ int ifxdeu_init_aes (void) { int ret = -ENOSYS; + aes_chip_init(); if ((ret = crypto_register_alg(&ifxdeu_aes_alg))) goto aes_err; @@ -910,8 +911,6 @@ int ifxdeu_init_aes (void) if ((ret = crypto_register_alg(&ifxdeu_ctr_rfc3686_aes_alg))) goto ctr_rfc3686_aes_err; - aes_chip_init (); - CRTCL_SECT_INIT; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c index 6d7d82fcb9..69a758c33c 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c @@ -690,6 +690,7 @@ int ifxdeu_init_des (void) { int ret = -ENOSYS; + des_chip_init(); ret = crypto_register_alg(&ifxdeu_des_alg); if (ret < 0) @@ -715,7 +716,6 @@ int ifxdeu_init_des (void) if (ret < 0) goto cbc_des3_ede_err; - des_chip_init(); CRTCL_SECT_INIT; From ab270c6fbc38f81669529300daee85b809111c39 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sun, 18 Apr 2021 14:26:01 +0200 Subject: [PATCH 10/73] ltq-deu: aes: do not read/write behind buffer When handling non-aligned remaining data (not padded to 16 byte [AES_BLOCK_SIZE]), a full 16 byte block is read from the input buffer and written to the output buffer after en-/decryption. While code already assumes that an input buffer could have less than 16 byte remaining, as it can be seen by the code zeroing the remaining bytes till AES_BLOCK_SIZE, the full AES_BLOCK_SIZE is read. An output buffer size of a multiple of AES_BLOCK_SIZE is expected but never validated. To get rid of the read/write behind buffer, use a temporary buffer when dealing with not padded data and only write as much bytes to the output as we read. Do not memcpy directly to the register, to make used of the endian swap macro and to trigger the crypto start operator via the ID0R to trigger the register. Since we might need an endian swap for the output in future, use a temporary buffer for the output as well. The issue could not be observed so far, since all caller of ifx_deu_aes will ignore the padded (remaining) data. Considering that the minimum blocksize for the algorithm is set to AES_BLOCK_SIZE, the behaviour could be called expected. Signed-off-by: Mathias Kresin [fix commit title prefix] Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 7ce6df0ac6..62ce563181 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -251,23 +251,25 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, /* To handle all non-aligned bytes (not aligned to 16B size) */ if (byte_cnt) { - aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 0)); - aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 1)); - aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 2)); - aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 3)); /* start crypto */ + u8 *input[16]; + u8 *output[16]; + + memcpy(input, ((u32 *) in_arg + (i * 4)), byte_cnt); + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 3)); /* start crypto */ while (aes->controlr.BUS) { } - *((volatile u32 *) out_arg + (i * 4) + 0) = aes->OD3R; - *((volatile u32 *) out_arg + (i * 4) + 1) = aes->OD2R; - *((volatile u32 *) out_arg + (i * 4) + 2) = aes->OD1R; - *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R; - - /* to ensure that the extended pages are clean */ - memset (out_arg + (i * 16) + (nbytes % AES_BLOCK_SIZE), 0, - (AES_BLOCK_SIZE - (nbytes % AES_BLOCK_SIZE))); + *((volatile u32 *) output + (i * 4) + 0) = aes->OD3R; + *((volatile u32 *) output + (i * 4) + 1) = aes->OD2R; + *((volatile u32 *) output + (i * 4) + 2) = aes->OD1R; + *((volatile u32 *) output + (i * 4) + 3) = aes->OD0R; + memcpy(((u32 *) out_arg + (i * 4)), output, byte_cnt); } //tc.chen : copy iv_arg back From 17656f21f36b6d33fd55d1b63435e85cc79865de Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sun, 18 Apr 2021 14:37:24 +0200 Subject: [PATCH 11/73] ltq-deu: aes-ctr: process all input data Even if the minimum blocksize is set to 16 (AES_BLOCK_SIZE), the crypto manager tests pass 499 bytes of data to the aes-ctr encryption, from which only 496 bytes are actually encrypted. Reading the comment regarding the minimum blocksize, it only states that it's the "smallest possible unit which can be transformed with this algorithm". Which doesn't necessarily mean, the data have to be a multiple of the minimal blocksize. All kernel hardware crypto driver enforce a minimum blocksize of 1, which perfect fine works for the lantiq data encryption unit as well. Lower the blocksize limit to 1, to process not padded data as well. In AES for processing the remaining bytes, uninitialized pointers were used. This patch fixes using uninitialized pointers and wrong offsets. Signed-off-by: Mathias Kresin [fix commit title prefix] Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 52 ++++++++----------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 62ce563181..ab30293340 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -251,25 +251,24 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, /* To handle all non-aligned bytes (not aligned to 16B size) */ if (byte_cnt) { - u8 *input[16]; - u8 *output[16]; + u8 temparea[16] = {0,}; - memcpy(input, ((u32 *) in_arg + (i * 4)), byte_cnt); + memcpy(temparea, ((u32 *) in_arg + (i * 4)), byte_cnt); - aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 0)); - aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 1)); - aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 2)); - aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) input + (i * 4) + 3)); /* start crypto */ + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) temparea + 3)); /* start crypto */ while (aes->controlr.BUS) { } - *((volatile u32 *) output + (i * 4) + 0) = aes->OD3R; - *((volatile u32 *) output + (i * 4) + 1) = aes->OD2R; - *((volatile u32 *) output + (i * 4) + 2) = aes->OD1R; - *((volatile u32 *) output + (i * 4) + 3) = aes->OD0R; + *((volatile u32 *) temparea + 0) = aes->OD3R; + *((volatile u32 *) temparea + 1) = aes->OD2R; + *((volatile u32 *) temparea + 2) = aes->OD1R; + *((volatile u32 *) temparea + 3) = aes->OD0R; - memcpy(((u32 *) out_arg + (i * 4)), output, byte_cnt); + memcpy(((u32 *) out_arg + (i * 4)), temparea, byte_cnt); } //tc.chen : copy iv_arg back @@ -671,20 +670,15 @@ int ctr_basic_aes_encrypt(struct blkcipher_desc *desc, struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; int err; - unsigned int enc_bytes; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); - while ((nbytes = enc_bytes = walk.nbytes)) { - u8 *iv = walk.iv; - enc_bytes -= (nbytes % AES_BLOCK_SIZE); - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); - nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + while ((nbytes = walk.nbytes)) { + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); + err = blkcipher_walk_done(desc, &walk, 0); } - return err; } @@ -704,18 +698,14 @@ int ctr_basic_aes_decrypt(struct blkcipher_desc *desc, struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; int err; - unsigned int dec_bytes; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); - while ((nbytes = dec_bytes = walk.nbytes)) { - u8 *iv = walk.iv; - dec_bytes -= (nbytes % AES_BLOCK_SIZE); - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); - nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + while ((nbytes = walk.nbytes)) { + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, nbytes, CRYPTO_DIR_DECRYPT, 0); + err = blkcipher_walk_done(desc, &walk, 0); } return err; @@ -729,7 +719,7 @@ struct crypto_alg ifxdeu_ctr_basic_aes_alg = { .cra_driver_name = "ifxdeu-ctr(aes)", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, @@ -869,7 +859,7 @@ struct crypto_alg ifxdeu_ctr_rfc3686_aes_alg = { .cra_driver_name = "ifxdeu-ctr-rfc3686(aes)", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, From 8dafa98bfb545cb6c014f6e85bc3fd6a78834c6c Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Thu, 15 Apr 2021 00:38:36 +0200 Subject: [PATCH 12/73] ltq-deu: make cipher/digest usable by openssl OpenSSL with cryptdev support uses the data encryption unit (DEU) driver for hard accelerated processing of ciphers/digests, if the flag CRYPTO_ALG_KERN_DRIVER_ONLY is set. Signed-off-by: Mathias Kresin [fix commit title prefix] Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 10 +++++----- package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c | 4 ++-- .../kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c | 10 +++++----- .../kernel/lantiq/ltq-deu/src/ifxmips_async_des.c | 12 ++++++------ package/kernel/lantiq/ltq-deu/src/ifxmips_des.c | 12 ++++++------ package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c | 2 +- package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 2 +- package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c | 2 +- .../kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 2 +- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index ab30293340..7d11a251de 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -457,7 +457,7 @@ struct crypto_alg ifxdeu_aes_alg = { .cra_name = "aes", .cra_driver_name = "ifxdeu-aes", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_module = THIS_MODULE, @@ -544,7 +544,7 @@ struct crypto_alg ifxdeu_ecb_aes_alg = { .cra_name = "ecb(aes)", .cra_driver_name = "ifxdeu-ecb(aes)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_blkcipher_type, @@ -635,7 +635,7 @@ struct crypto_alg ifxdeu_cbc_aes_alg = { .cra_name = "cbc(aes)", .cra_driver_name = "ifxdeu-cbc(aes)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_blkcipher_type, @@ -718,7 +718,7 @@ struct crypto_alg ifxdeu_ctr_basic_aes_alg = { .cra_name = "ctr(aes)", .cra_driver_name = "ifxdeu-ctr(aes)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_blkcipher_type, @@ -858,7 +858,7 @@ struct crypto_alg ifxdeu_ctr_rfc3686_aes_alg = { .cra_name = "rfc3686(ctr(aes))", .cra_driver_name = "ifxdeu-ctr-rfc3686(aes)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = 1, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_blkcipher_type, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c index 9faad94016..b2e7c9d145 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c @@ -243,7 +243,7 @@ static struct crypto_alg ifxdeu_arc4_alg = { .cra_name = "arc4", .cra_driver_name = "ifxdeu-arc4", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = ARC4_BLOCK_SIZE, .cra_ctxsize = sizeof(struct arc4_ctx), .cra_module = THIS_MODULE, @@ -326,7 +326,7 @@ static struct crypto_alg ifxdeu_ecb_arc4_alg = { .cra_name = "ecb(arc4)", .cra_driver_name = "ifxdeu-ecb(arc4)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = ARC4_BLOCK_SIZE, .cra_ctxsize = sizeof(struct arc4_ctx), .cra_type = &crypto_blkcipher_type, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c index dcd059371f..8184fed71f 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_aes.c @@ -964,7 +964,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "aes", .cra_driver_name = "ifxdeu-aes", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -984,7 +984,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "ecb(aes)", .cra_driver_name = "ifxdeu-ecb(aes)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -1004,7 +1004,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "cbc(aes)", .cra_driver_name = "ifxdeu-cbc(aes)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -1024,7 +1024,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "ctr(aes)", .cra_driver_name = "ifxdeu-ctr(aes)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, @@ -1044,7 +1044,7 @@ static struct lq_aes_alg aes_drivers_alg[] = { .alg = { .cra_name = "rfc3686(ctr(aes))", .cra_driver_name = "ifxdeu-rfc3686(ctr(aes))", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), .cra_type = &crypto_ablkcipher_type, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c index 1523763ccd..bd560bf659 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_async_des.c @@ -761,7 +761,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "des", .cra_driver_name = "lqdeu-des", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -782,7 +782,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "ecb(des)", .cra_driver_name = "lqdeu-ecb(des)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -802,7 +802,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "cbc(des)", .cra_driver_name = "lqdeu-cbc(des)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -822,7 +822,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "des3_ede", .cra_driver_name = "lqdeu-des3_ede", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -842,7 +842,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "ecb(des3_ede)", .cra_driver_name = "lqdeu-ecb(des3_ede)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, @@ -862,7 +862,7 @@ static struct lq_des_alg des_drivers_alg [] = { .alg = { .cra_name = "cbc(des3_ede)", .cra_driver_name = "lqdeu-cbc(des3_ede)", - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_ablkcipher_type, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c index 69a758c33c..7bb14b4d57 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c @@ -417,7 +417,7 @@ struct crypto_alg ifxdeu_des_alg = { .cra_name = "des", .cra_driver_name = "ifxdeu-des", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_module = THIS_MODULE, @@ -438,7 +438,7 @@ struct crypto_alg ifxdeu_des3_ede_alg = { .cra_name = "des3_ede", .cra_driver_name = "ifxdeu-des3_ede", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_module = THIS_MODULE, @@ -523,7 +523,7 @@ struct crypto_alg ifxdeu_ecb_des_alg = { .cra_name = "ecb(des)", .cra_driver_name = "ifxdeu-ecb(des)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_blkcipher_type, @@ -547,7 +547,7 @@ struct crypto_alg ifxdeu_ecb_des3_ede_alg = { .cra_name = "ecb(des3_ede)", .cra_driver_name = "ifxdeu-ecb(des3_ede)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_blkcipher_type, @@ -639,7 +639,7 @@ struct crypto_alg ifxdeu_cbc_des_alg = { .cra_name = "cbc(des)", .cra_driver_name = "ifxdeu-cbc(des)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_blkcipher_type, @@ -664,7 +664,7 @@ struct crypto_alg ifxdeu_cbc_des3_ede_alg = { .cra_name = "cbc(des3_ede)", .cra_driver_name = "ifxdeu-cbc(des3_ede)", .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, + .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_type = &crypto_blkcipher_type, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c index 11cb64799e..14967c30d6 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c @@ -270,7 +270,7 @@ static struct shash_alg ifxdeu_md5_alg = { .cra_name = "md5", .cra_driver_name= "ifxdeu-md5", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_HASH, + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = MD5_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, } diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index 6cb2e5a417..b6e65c8b22 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -346,7 +346,7 @@ static struct shash_alg ifxdeu_md5_hmac_alg = { .cra_driver_name= "ifxdeu-md5_hmac", .cra_priority = 400, .cra_ctxsize = sizeof(struct md5_hmac_ctx), - .cra_flags = CRYPTO_ALG_TYPE_HASH, + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = MD5_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, } diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c index d711c4804d..9112febbb7 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c @@ -259,7 +259,7 @@ static struct shash_alg ifxdeu_sha1_alg = { .cra_name = "sha1", .cra_driver_name= "ifxdeu-sha1", .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_HASH, + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, } diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index 7776c51686..465c58f105 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -334,7 +334,7 @@ static struct shash_alg ifxdeu_sha1_hmac_alg = { .cra_driver_name= "ifxdeu-sha1_hmac", .cra_priority = 400, .cra_ctxsize = sizeof(struct sha1_hmac_ctx), - .cra_flags = CRYPTO_ALG_TYPE_HASH, + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, } From c8967d6d12b25cf50b7e060485004c1332a40367 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Mon, 31 May 2021 14:13:42 +0200 Subject: [PATCH 13/73] ltq-deu: set correct control register for AES Some devices initialize AES during boot and AES works out of the box and the correct endianess is set. NDC means (No Danube Compatibility Mode) and the endianess setting has no effect if its set to 0. NDC 0: OFF ENDI bit cannot be written as in Danube To make it work for other devices, the NDC control register needs to be set to 1. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c index aaa7bce237..8063672613 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_vr9.c @@ -107,7 +107,7 @@ void aes_chip_init (void) // start crypto engine with write to ILR aes->controlr.SM = 1; - aes->controlr.NDC = 0; + aes->controlr.NDC = 1; asm("sync"); aes->controlr.ENDI = 1; asm("sync"); From 737bd4f2969dd65a6348cb6ddac935543531e568 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Mon, 31 May 2021 14:25:00 +0200 Subject: [PATCH 14/73] ltq-deu: convert blkcipher to skcipher Convert blkcipher to skcipher for the synchronous versions of AES, DES and ARC4. The Block Cipher API was depracated for a while and was removed with Linux 5.5. So switch this driver to the skcipher API. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 543 ++++++++---------- .../kernel/lantiq/ltq-deu/src/ifxmips_arc4.c | 103 ++-- .../kernel/lantiq/ltq-deu/src/ifxmips_des.c | 309 +++++----- 3 files changed, 452 insertions(+), 503 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 7d11a251de..bd52564692 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -57,6 +57,7 @@ #include #include #include +#include #include "ifxmips_deu.h" @@ -130,14 +131,12 @@ extern int disable_multiblock; int aes_set_key (struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); - unsigned long *flags = (unsigned long *) &tfm->crt_flags; //printk("set_key in %s\n", __FILE__); //aes_chip_init(); if (key_len != 16 && key_len != 24 && key_len != 32) { - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; return -EINVAL; } @@ -149,6 +148,20 @@ int aes_set_key (struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len) } +/*! \fn int aes_set_key_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for skcipher + * \param tfm linux crypto skcipher + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int aes_set_key_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) +{ + return aes_set_key(crypto_skcipher_tfm(tfm), in_key, key_len); +} + + /*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec, int mode) * \ingroup IFX_AES_FUNCTIONS * \brief main interface to AES hardware @@ -295,7 +308,6 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); - unsigned long *flags = (unsigned long *)&tfm->crt_flags; //printk("ctr_rfc3686_aes_set_key in %s\n", __FILE__); @@ -305,7 +317,6 @@ int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsi key_len -= CTR_RFC3686_NONCE_SIZE; // remove 4 bytes of nonce if (key_len != 16 && key_len != 24 && key_len != 32) { - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; return -EINVAL; } @@ -316,6 +327,22 @@ int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsi return 0; } +/*! + * \fn int ctr_rfc3686_aes_set_key_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets RFC3686 key for skcipher + * \param tfm linux crypto skcipher + * \param in_key input key + * \param key_len key lengths of 20, 28 and 36 bytes supported; last 4 bytes is nonce + * \return 0 - SUCCESS + * -EINVAL - bad key length +*/ +int ctr_rfc3686_aes_set_key_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) +{ + return ctr_rfc3686_aes_set_key(crypto_skcipher_tfm(tfm), in_key, key_len); +} + + /*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) * \ingroup IFX_AES_FUNCTIONS * \brief main interface with deu hardware in DMA mode @@ -424,11 +451,11 @@ void ifx_deu_aes_ctr (void *ctx, uint8_t *dst, const uint8_t *src, /*! \fn void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_AES_FUNCTIONS - * \brief encrypt AES_BLOCK_SIZE of data - * \param tfm linux crypto algo transform - * \param out output bytestream - * \param in input bytestream -*/ + * \brief encrypt AES_BLOCK_SIZE of data + * \param tfm linux crypto algo transform + * \param out output bytestream + * \param in input bytestream +*/ void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); @@ -438,11 +465,11 @@ void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) /*! \fn void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_AES_FUNCTIONS - * \brief decrypt AES_BLOCK_SIZE of data - * \param tfm linux crypto algo transform - * \param out output bytestream - * \param in input bytestream -*/ + * \brief decrypt AES_BLOCK_SIZE of data + * \param tfm linux crypto algo transform + * \param out output bytestream + * \param in input bytestream +*/ void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); @@ -450,8 +477,8 @@ void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) CRYPTO_DIR_DECRYPT, 0); } -/* - * \brief AES function mappings +/* + * \brief AES function mappings */ struct crypto_alg ifxdeu_aes_alg = { .cra_name = "aes", @@ -473,156 +500,53 @@ struct crypto_alg ifxdeu_aes_alg = { } }; -/*! \fn int ecb_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ecb_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief ECB AES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief ECB AES encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ecb_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ecb_aes_encrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; - - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = enc_bytes = walk.nbytes)) { enc_bytes -= (nbytes % AES_BLOCK_SIZE); ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn int ecb_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ecb_aes_decrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief ECB AES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief ECB AES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ecb_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ecb_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = dec_bytes = walk.nbytes)) { dec_bytes -= (nbytes % AES_BLOCK_SIZE); ifx_deu_aes_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); - } - - return err; -} - -/* - * \brief AES function mappings -*/ -struct crypto_alg ifxdeu_ecb_aes_alg = { - .cra_name = "ecb(aes)", - .cra_driver_name = "ifxdeu-ecb(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .setkey = aes_set_key, - .encrypt = ecb_aes_encrypt, - .decrypt = ecb_aes_decrypt, - } - } -}; - - -/*! \fn int cbc_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_AES_FUNCTIONS - * \brief CBC AES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes - * \return err -*/ -int cbc_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) -{ - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; - int err; - unsigned int enc_bytes; - - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); - - while ((nbytes = enc_bytes = walk.nbytes)) { - u8 *iv = walk.iv; - enc_bytes -= (nbytes % AES_BLOCK_SIZE); - ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); - nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); - } - - return err; -} - -/*! \fn int cbc_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_AES_FUNCTIONS - * \brief CBC AES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes - * \return err -*/ -int cbc_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) -{ - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; - int err; - unsigned int dec_bytes; - - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); - - while ((nbytes = dec_bytes = walk.nbytes)) { - u8 *iv = walk.iv; - dec_bytes -= (nbytes % AES_BLOCK_SIZE); - ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); - nbytes &= AES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -631,133 +555,184 @@ int cbc_aes_decrypt(struct blkcipher_desc *desc, /* * \brief AES function mappings */ -struct crypto_alg ifxdeu_cbc_aes_alg = { - .cra_name = "cbc(aes)", - .cra_driver_name = "ifxdeu-cbc(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, - .setkey = aes_set_key, - .encrypt = cbc_aes_encrypt, - .decrypt = cbc_aes_decrypt, - } - } +struct skcipher_alg ifxdeu_ecb_aes_alg = { + .base.cra_name = "ecb(aes)", + .base.cra_driver_name = "ifxdeu-ecb(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = AES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = ecb_aes_encrypt, + .decrypt = ecb_aes_decrypt, }; -/*! \fn int ctr_basic_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ecb_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief CBC AES encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_basic_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int cbc_aes_encrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = enc_bytes = walk.nbytes)) { + u8 *iv = walk.iv; + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + return err; +} + +/*! \fn int cbc_aes_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CBC AES decrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int cbc_aes_decrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int dec_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = dec_bytes = walk.nbytes)) { + u8 *iv = walk.iv; + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + return err; +} + +/* + * \brief AES function mappings +*/ +struct skcipher_alg ifxdeu_cbc_aes_alg = { + .base.cra_name = "cbc(aes)", + .base.cra_driver_name = "ifxdeu-cbc(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = AES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = cbc_aes_encrypt, + .decrypt = cbc_aes_decrypt, +}; + + +/*! \fn int ctr_basic_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief Counter mode AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int ctr_basic_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; int err; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = walk.nbytes)) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, walk.iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); - err = blkcipher_walk_done(desc, &walk, 0); + err = skcipher_walk_done(&walk, 0); } return err; } -/*! \fn int ctr_basic_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ctr_basic_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief Counter mode AES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_basic_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ctr_basic_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; int err; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = walk.nbytes)) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, walk.iv, nbytes, CRYPTO_DIR_DECRYPT, 0); - err = blkcipher_walk_done(desc, &walk, 0); + err = skcipher_walk_done(&walk, 0); } return err; } -/* +/* * \brief AES function mappings */ -struct crypto_alg ifxdeu_ctr_basic_aes_alg = { - .cra_name = "ctr(aes)", - .cra_driver_name = "ifxdeu-ctr(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = 1, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_basic_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, - .setkey = aes_set_key, - .encrypt = ctr_basic_aes_encrypt, - .decrypt = ctr_basic_aes_decrypt, - } - } +struct skcipher_alg ifxdeu_ctr_basic_aes_alg = { + .base.cra_name = "ctr(aes)", + .base.cra_driver_name = "ifxdeu-ctr(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ctr_basic_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = ctr_basic_aes_encrypt, + .decrypt = ctr_basic_aes_decrypt, }; -/*! \fn int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ctr_rfc3686_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES (rfc3686) encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief Counter mode AES (rfc3686) encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ctr_rfc3686_aes_encrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; - int err, bsize = nbytes; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; + int err, bsize; u8 rfc3686_iv[16]; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); - + err = skcipher_walk_virt(&walk, req, false); + nbytes = walk.nbytes; + bsize = nbytes; + /* set up counter block */ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE); memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, walk.iv, CTR_RFC3686_IV_SIZE); @@ -771,7 +746,7 @@ int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); nbytes -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); return err; } @@ -781,39 +756,36 @@ int ctr_rfc3686_aes_encrypt(struct blkcipher_desc *desc, nbytes -= walk.nbytes; bsize -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } /* to handle remaining bytes < AES_BLOCK_SIZE */ if (walk.nbytes) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, rfc3686_iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); - err = blkcipher_walk_done(desc, &walk, 0); + err = skcipher_walk_done(&walk, 0); } - + return err; } -/*! \fn int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn int ctr_rfc3686_aes_decrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS - * \brief Counter mode AES (rfc3686) decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes + * \brief Counter mode AES (rfc3686) decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ctr_rfc3686_aes_decrypt(struct skcipher_request *req) { - struct aes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; - int err, bsize = nbytes; + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; + int err, bsize; u8 rfc3686_iv[16]; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); + nbytes = walk.nbytes; + bsize = nbytes; /* set up counter block */ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE); @@ -828,7 +800,7 @@ int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); nbytes -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); return err; } @@ -838,50 +810,45 @@ int ctr_rfc3686_aes_decrypt(struct blkcipher_desc *desc, nbytes -= walk.nbytes; bsize -= walk.nbytes; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } /* to handle remaining bytes < AES_BLOCK_SIZE */ if (walk.nbytes) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, rfc3686_iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); - err = blkcipher_walk_done(desc, &walk, 0); + err = skcipher_walk_done(&walk, 0); } return err; } -/* +/* * \brief AES function mappings */ -struct crypto_alg ifxdeu_ctr_rfc3686_aes_alg = { - .cra_name = "rfc3686(ctr(aes))", - .cra_driver_name = "ifxdeu-ctr-rfc3686(aes)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = 1, - .cra_ctxsize = sizeof(struct aes_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ctr_rfc3686_aes_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = CTR_RFC3686_MAX_KEY_SIZE, - .ivsize = CTR_RFC3686_IV_SIZE, - .setkey = ctr_rfc3686_aes_set_key, - .encrypt = ctr_rfc3686_aes_encrypt, - .decrypt = ctr_rfc3686_aes_decrypt, - } - } +struct skcipher_alg ifxdeu_ctr_rfc3686_aes_alg = { + .base.cra_name = "rfc3686(ctr(aes))", + .base.cra_driver_name = "ifxdeu-ctr-rfc3686(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ctr_rfc3686_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = CTR_RFC3686_MAX_KEY_SIZE, + .ivsize = CTR_RFC3686_IV_SIZE, + .setkey = ctr_rfc3686_aes_set_key_skcipher, + .encrypt = ctr_rfc3686_aes_encrypt, + .decrypt = ctr_rfc3686_aes_decrypt, }; /*! \fn int ifxdeu_init_aes (void) * \ingroup IFX_AES_FUNCTIONS - * \brief function to initialize AES driver - * \return ret -*/ + * \brief function to initialize AES driver + * \return ret +*/ int ifxdeu_init_aes (void) { int ret = -ENOSYS; @@ -891,16 +858,16 @@ int ifxdeu_init_aes (void) if ((ret = crypto_register_alg(&ifxdeu_aes_alg))) goto aes_err; - if ((ret = crypto_register_alg(&ifxdeu_ecb_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_ecb_aes_alg))) goto ecb_aes_err; - if ((ret = crypto_register_alg(&ifxdeu_cbc_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_cbc_aes_alg))) goto cbc_aes_err; - if ((ret = crypto_register_alg(&ifxdeu_ctr_basic_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_ctr_basic_aes_alg))) goto ctr_basic_aes_err; - if ((ret = crypto_register_alg(&ifxdeu_ctr_rfc3686_aes_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_ctr_rfc3686_aes_alg))) goto ctr_rfc3686_aes_err; CRTCL_SECT_INIT; @@ -910,19 +877,19 @@ int ifxdeu_init_aes (void) return ret; ctr_rfc3686_aes_err: - crypto_unregister_alg(&ifxdeu_ctr_rfc3686_aes_alg); + crypto_unregister_skcipher(&ifxdeu_ctr_rfc3686_aes_alg); printk (KERN_ERR "IFX ctr_rfc3686_aes initialization failed!\n"); return ret; ctr_basic_aes_err: - crypto_unregister_alg(&ifxdeu_ctr_basic_aes_alg); + crypto_unregister_skcipher(&ifxdeu_ctr_basic_aes_alg); printk (KERN_ERR "IFX ctr_basic_aes initialization failed!\n"); return ret; cbc_aes_err: - crypto_unregister_alg(&ifxdeu_cbc_aes_alg); + crypto_unregister_skcipher(&ifxdeu_cbc_aes_alg); printk (KERN_ERR "IFX cbc_aes initialization failed!\n"); return ret; ecb_aes_err: - crypto_unregister_alg(&ifxdeu_ecb_aes_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_aes_alg); printk (KERN_ERR "IFX aes initialization failed!\n"); return ret; aes_err: @@ -933,16 +900,14 @@ aes_err: /*! \fn void ifxdeu_fini_aes (void) * \ingroup IFX_AES_FUNCTIONS - * \brief unregister aes driver -*/ + * \brief unregister aes driver +*/ void ifxdeu_fini_aes (void) { crypto_unregister_alg (&ifxdeu_aes_alg); - crypto_unregister_alg (&ifxdeu_ecb_aes_alg); - crypto_unregister_alg (&ifxdeu_cbc_aes_alg); - crypto_unregister_alg (&ifxdeu_ctr_basic_aes_alg); - crypto_unregister_alg (&ifxdeu_ctr_rfc3686_aes_alg); + crypto_unregister_skcipher (&ifxdeu_ecb_aes_alg); + crypto_unregister_skcipher (&ifxdeu_cbc_aes_alg); + crypto_unregister_skcipher (&ifxdeu_ctr_basic_aes_alg); + crypto_unregister_skcipher (&ifxdeu_ctr_rfc3686_aes_alg); } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c index b2e7c9d145..6afd783b6b 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -203,6 +204,19 @@ static int arc4_set_key(struct crypto_tfm *tfm, const u8 *inkey, return 0; } +/*! \fn static int arc4_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) + \ingroup IFX_ARC4_FUNCTIONS + \brief sets ARC4 key + \param tfm linux crypto skcipher + \param in_key input key + \param key_len key lengths less than or equal to 16 bytes supported +*/ +static int arc4_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *inkey, + unsigned int key_len) +{ + return arc4_set_key(crypto_skcipher_ctx(tfm), inkey, key_len); +} + /*! \fn static void _deu_arc4_ecb(void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace) \ingroup IFX_ARC4_FUNCTIONS \brief sets ARC4 hardware to ECB mode @@ -259,61 +273,51 @@ static struct crypto_alg ifxdeu_arc4_alg = { } }; -/*! \fn static int ecb_arc4_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn static int ecb_arc4_encrypt(struct skcipher_request *req) \ingroup IFX_ARC4_FUNCTIONS - \brief ECB ARC4 encrypt using linux crypto blkcipher - \param desc blkcipher descriptor - \param dst output scatterlist - \param src input scatterlist - \param nbytes data size in bytes -*/ -static int ecb_arc4_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) + \brief ECB ARC4 encrypt using linux crypto skcipher + \param req skcipher_request +*/ +static int ecb_arc4_encrypt(struct skcipher_request *req) { - struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct arc4_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; int err; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = walk.nbytes)) { _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= ARC4_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn static int ecb_arc4_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) +/*! \fn static int ecb_arc4_decrypt(struct skcipher_request *req) \ingroup IFX_ARC4_FUNCTIONS - \brief ECB ARC4 decrypt using linux crypto blkcipher - \param desc blkcipher descriptor - \param dst output scatterlist - \param src input scatterlist - \param nbytes data size in bytes -*/ -static int ecb_arc4_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) + \brief ECB ARC4 decrypt using linux crypto skcipher + \param desc skcipher_request +*/ +static int ecb_arc4_decrypt(struct skcipher_request *req) { - struct arc4_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct arc4_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + unsigned int nbytes; int err; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = walk.nbytes)) { _deu_arc4_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, nbytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= ARC4_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -322,25 +326,20 @@ static int ecb_arc4_decrypt(struct blkcipher_desc *desc, /* * \brief ARC4 function mappings */ -static struct crypto_alg ifxdeu_ecb_arc4_alg = { - .cra_name = "ecb(arc4)", - .cra_driver_name = "ifxdeu-ecb(arc4)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = ARC4_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct arc4_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_arc4_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = ARC4_MIN_KEY_SIZE, - .max_keysize = ARC4_MAX_KEY_SIZE, - .setkey = arc4_set_key, - .encrypt = ecb_arc4_encrypt, - .decrypt = ecb_arc4_decrypt, - } - } +static struct skcipher_alg ifxdeu_ecb_arc4_alg = { + .base.cra_name = "ecb(arc4)", + .base.cra_driver_name = "ifxdeu-ecb(arc4)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = ARC4_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct arc4_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_arc4_alg.base.cra_list), + .min_keysize = ARC4_MIN_KEY_SIZE, + .max_keysize = ARC4_MAX_KEY_SIZE, + .setkey = arc4_set_key_skcipher, + .encrypt = ecb_arc4_encrypt, + .decrypt = ecb_arc4_decrypt, }; /*! \fn int ifxdeu_init_arc4(void) @@ -355,7 +354,7 @@ int ifxdeu_init_arc4(void) if ((ret = crypto_register_alg(&ifxdeu_arc4_alg))) goto arc4_err; - if ((ret = crypto_register_alg(&ifxdeu_ecb_arc4_alg))) + if ((ret = crypto_register_skcipher(&ifxdeu_ecb_arc4_alg))) goto ecb_arc4_err; arc4_chip_init (); @@ -370,7 +369,7 @@ arc4_err: printk(KERN_ERR "IFX arc4 initialization failed!\n"); return ret; ecb_arc4_err: - crypto_unregister_alg(&ifxdeu_ecb_arc4_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_arc4_alg); printk (KERN_ERR "IFX ecb_arc4 initialization failed!\n"); return ret; @@ -383,7 +382,7 @@ ecb_arc4_err: void ifxdeu_fini_arc4(void) { crypto_unregister_alg (&ifxdeu_arc4_alg); - crypto_unregister_alg (&ifxdeu_ecb_arc4_alg); + crypto_unregister_skcipher (&ifxdeu_ecb_arc4_alg); } diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c index 7bb14b4d57..6b24e0f4b4 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c @@ -50,6 +50,7 @@ #include #include #include +#include #include "ifxmips_deu.h" #if defined(CONFIG_DANUBE) @@ -139,6 +140,20 @@ int des_setkey(struct crypto_tfm *tfm, const u8 *key, } +/*! \fn int des_set_key (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for skcipher + * \param tfm linux crypto skcipher + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int des_setkey_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) +{ + return des_setkey(crypto_skcipher_tfm(tfm), in_key, key_len); +} + + /*! \fn void ifx_deu_des(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) * \ingroup IFX_DES_FUNCTIONS * \brief main interface to DES hardware @@ -410,6 +425,19 @@ int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, return 0; } +/*! \fn int des3_ede_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) + * \ingroup IFX_DES_FUNCTIONS + * \brief sets 3DES key + * \param tfm linux crypto skcipher transform + * \param key input key + * \param keylen key length +*/ +int des3_ede_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, + unsigned int keylen) +{ + return des3_ede_setkey(crypto_skcipher_tfm(tfm), key, keylen); +} + /* * \brief DES function mappings */ @@ -452,65 +480,54 @@ struct crypto_alg ifxdeu_des3_ede_alg = { .cia_decrypt = des_decrypt } } }; -/*! \fn int ecb_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief ECB DES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes -*/ -int ecb_des_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +/*! \fn int ecb_des_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief ECB DES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int ecb_des_encrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; + unsigned int enc_bytes, nbytes; - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = enc_bytes = walk.nbytes)) { enc_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn int ecb_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief ECB DES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes +/*! \fn int ecb_des_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief ECB DES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int ecb_des_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int ecb_des_decrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = dec_bytes = walk.nbytes)) { dec_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, NULL, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -518,73 +535,57 @@ int ecb_des_decrypt(struct blkcipher_desc *desc, /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_ecb_des_alg = { - .cra_name = "ecb(des)", - .cra_driver_name = "ifxdeu-ecb(des)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES_KEY_SIZE, - .max_keysize = DES_KEY_SIZE, - .setkey = des_setkey, - .encrypt = ecb_des_encrypt, - .decrypt = ecb_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_ecb_des_alg = { + .base.cra_name = "ecb(des)", + .base.cra_driver_name = "ifxdeu-ecb(des)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des_alg.base.cra_list), + .min_keysize = DES_KEY_SIZE, + .max_keysize = DES_KEY_SIZE, + .setkey = des_setkey_skcipher, + .encrypt = ecb_des_encrypt, + .decrypt = ecb_des_decrypt, }; /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_ecb_des3_ede_alg = { - .cra_name = "ecb(des3_ede)", - .cra_driver_name = "ifxdeu-ecb(des3_ede)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = DES3_EDE_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des3_ede_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES3_EDE_KEY_SIZE, - .max_keysize = DES3_EDE_KEY_SIZE, - .setkey = des3_ede_setkey, - .encrypt = ecb_des_encrypt, - .decrypt = ecb_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_ecb_des3_ede_alg = { + .base.cra_name = "ecb(des3_ede)", + .base.cra_driver_name = "ifxdeu-ecb(des3_ede)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des3_ede_alg.base.cra_list), + .min_keysize = DES3_EDE_KEY_SIZE, + .max_keysize = DES3_EDE_KEY_SIZE, + .setkey = des3_ede_setkey_skcipher, + .encrypt = ecb_des_encrypt, + .decrypt = ecb_des_decrypt, }; -/*! \fn int cbc_des_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief CBC DES encrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes +/*! \fn int cbc_des_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CBC DES encrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int cbc_des_encrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int cbc_des_encrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int enc_bytes; + unsigned int enc_bytes, nbytes; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = enc_bytes = walk.nbytes)) { u8 *iv = walk.iv; @@ -592,33 +593,27 @@ int cbc_des_encrypt(struct blkcipher_desc *desc, ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; } -/*! \fn int cbc_des_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) - * \ingroup IFX_DES_FUNCTIONS - * \brief CBC DES decrypt using linux crypto blkcipher - * \param desc blkcipher descriptor - * \param dst output scatterlist - * \param src input scatterlist - * \param nbytes data size in bytes +/*! \fn int cbc_des_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CBC DES decrypt using linux crypto skcipher + * \param req skcipher request * \return err -*/ -int cbc_des_decrypt(struct blkcipher_desc *desc, - struct scatterlist *dst, struct scatterlist *src, - unsigned int nbytes) +*/ +int cbc_des_decrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - struct blkcipher_walk walk; + struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; int err; - unsigned int dec_bytes; + unsigned int dec_bytes, nbytes; DPRINTF(1, "\n"); - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); + err = skcipher_walk_virt(&walk, req, false); while ((nbytes = dec_bytes = walk.nbytes)) { u8 *iv = walk.iv; @@ -626,7 +621,7 @@ int cbc_des_decrypt(struct blkcipher_desc *desc, ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; - err = blkcipher_walk_done(desc, &walk, nbytes); + err = skcipher_walk_done(&walk, nbytes); } return err; @@ -634,52 +629,42 @@ int cbc_des_decrypt(struct blkcipher_desc *desc, /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_cbc_des_alg = { - .cra_name = "cbc(des)", - .cra_driver_name = "ifxdeu-cbc(des)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES_KEY_SIZE, - .max_keysize = DES_KEY_SIZE, - .ivsize = DES_BLOCK_SIZE, - .setkey = des_setkey, - .encrypt = cbc_des_encrypt, - .decrypt = cbc_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_cbc_des_alg = { + .base.cra_name = "cbc(des)", + .base.cra_driver_name = "ifxdeu-cbc(des)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des_alg.base.cra_list), + .min_keysize = DES_KEY_SIZE, + .max_keysize = DES_KEY_SIZE, + .ivsize = DES_BLOCK_SIZE, + .setkey = des_setkey_skcipher, + .encrypt = cbc_des_encrypt, + .decrypt = cbc_des_decrypt, }; /* * \brief DES function mappings -*/ -struct crypto_alg ifxdeu_cbc_des3_ede_alg = { - .cra_name = "cbc(des3_ede)", - .cra_driver_name = "ifxdeu-cbc(des3_ede)", - .cra_priority = 400, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = DES3_EDE_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des3_ede_alg.cra_list), - .cra_u = { - .blkcipher = { - .min_keysize = DES3_EDE_KEY_SIZE, - .max_keysize = DES3_EDE_KEY_SIZE, - .ivsize = DES_BLOCK_SIZE, - .setkey = des3_ede_setkey, - .encrypt = cbc_des_encrypt, - .decrypt = cbc_des_decrypt, - } - } +*/ +struct skcipher_alg ifxdeu_cbc_des3_ede_alg = { + .base.cra_name = "cbc(des3_ede)", + .base.cra_driver_name = "ifxdeu-cbc(des3_ede)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des3_ede_alg.base.cra_list), + .min_keysize = DES3_EDE_KEY_SIZE, + .max_keysize = DES3_EDE_KEY_SIZE, + .ivsize = DES_BLOCK_SIZE, + .setkey = des3_ede_setkey_skcipher, + .encrypt = cbc_des_encrypt, + .decrypt = cbc_des_decrypt, }; /*! \fn int ifxdeu_init_des (void) @@ -696,11 +681,11 @@ int ifxdeu_init_des (void) if (ret < 0) goto des_err; - ret = crypto_register_alg(&ifxdeu_ecb_des_alg); + ret = crypto_register_skcipher(&ifxdeu_ecb_des_alg); if (ret < 0) goto ecb_des_err; - ret = crypto_register_alg(&ifxdeu_cbc_des_alg); + ret = crypto_register_skcipher(&ifxdeu_cbc_des_alg); if (ret < 0) goto cbc_des_err; @@ -708,11 +693,11 @@ int ifxdeu_init_des (void) if (ret < 0) goto des3_ede_err; - ret = crypto_register_alg(&ifxdeu_ecb_des3_ede_alg); + ret = crypto_register_skcipher(&ifxdeu_ecb_des3_ede_alg); if (ret < 0) goto ecb_des3_ede_err; - ret = crypto_register_alg(&ifxdeu_cbc_des3_ede_alg); + ret = crypto_register_skcipher(&ifxdeu_cbc_des3_ede_alg); if (ret < 0) goto cbc_des3_ede_err; @@ -728,11 +713,11 @@ des_err: printk(KERN_ERR "IFX des initialization failed!\n"); return ret; ecb_des_err: - crypto_unregister_alg(&ifxdeu_ecb_des_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_des_alg); printk (KERN_ERR "IFX ecb_des initialization failed!\n"); return ret; cbc_des_err: - crypto_unregister_alg(&ifxdeu_cbc_des_alg); + crypto_unregister_skcipher(&ifxdeu_cbc_des_alg); printk (KERN_ERR "IFX cbc_des initialization failed!\n"); return ret; des3_ede_err: @@ -740,11 +725,11 @@ des3_ede_err: printk(KERN_ERR "IFX des3_ede initialization failed!\n"); return ret; ecb_des3_ede_err: - crypto_unregister_alg(&ifxdeu_ecb_des3_ede_alg); + crypto_unregister_skcipher(&ifxdeu_ecb_des3_ede_alg); printk (KERN_ERR "IFX ecb_des3_ede initialization failed!\n"); return ret; cbc_des3_ede_err: - crypto_unregister_alg(&ifxdeu_cbc_des3_ede_alg); + crypto_unregister_skcipher(&ifxdeu_cbc_des3_ede_alg); printk (KERN_ERR "IFX cbc_des3_ede initialization failed!\n"); return ret; @@ -757,11 +742,11 @@ cbc_des3_ede_err: void ifxdeu_fini_des (void) { crypto_unregister_alg (&ifxdeu_des_alg); - crypto_unregister_alg (&ifxdeu_ecb_des_alg); - crypto_unregister_alg (&ifxdeu_cbc_des_alg); + crypto_unregister_skcipher (&ifxdeu_ecb_des_alg); + crypto_unregister_skcipher (&ifxdeu_cbc_des_alg); crypto_unregister_alg (&ifxdeu_des3_ede_alg); - crypto_unregister_alg (&ifxdeu_ecb_des3_ede_alg); - crypto_unregister_alg (&ifxdeu_cbc_des3_ede_alg); + crypto_unregister_skcipher (&ifxdeu_ecb_des3_ede_alg); + crypto_unregister_skcipher (&ifxdeu_cbc_des3_ede_alg); } From e84c4b54f34591b51a2503cadabe37218173036c Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Mon, 31 May 2021 14:32:27 +0200 Subject: [PATCH 15/73] ltq-deu: convert SHA1 after library impl of SHA1 was removed The was removed with Linux 5.8, because it only contained the library implementation of SHA1, which was folded into . So switch this driver away from using . Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c | 16 ++++++++-------- .../lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c index 9112febbb7..362fe89c92 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c @@ -44,8 +44,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -92,13 +92,13 @@ struct sha1_ctx { extern int disable_deudma; -/*! \fn static void sha1_transform (u32 *state, const u32 *in) +/*! \fn static void sha1_transform1 (u32 *state, const u32 *in) * \ingroup IFX_SHA1_FUNCTIONS * \brief main interface to sha1 hardware * \param state current state * \param in 64-byte block of input */ -static void sha1_transform (struct sha1_ctx *sctx, u32 *state, const u32 *in) +static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in) { int i = 0; volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; @@ -140,12 +140,12 @@ static void sha1_transform (struct sha1_ctx *sctx, u32 *state, const u32 *in) CRTCL_SECT_END; } -/*! \fn static void sha1_init(struct crypto_tfm *tfm) +/*! \fn static void sha1_init1(struct crypto_tfm *tfm) * \ingroup IFX_SHA1_FUNCTIONS * \brief initialize sha1 hardware * \param tfm linux crypto algo transform */ -static int sha1_init(struct shash_desc *desc) +static int sha1_init1(struct shash_desc *desc) { struct sha1_ctx *sctx = shash_desc_ctx(desc); @@ -174,9 +174,9 @@ static int sha1_update(struct shash_desc * desc, const u8 *data, if ((j + len) > 63) { memcpy (&sctx->buffer[j], data, (i = 64 - j)); - sha1_transform (sctx, sctx->state, (const u32 *)sctx->buffer); + sha1_transform1 (sctx, sctx->state, (const u32 *)sctx->buffer); for (; i + 63 < len; i += 64) { - sha1_transform (sctx, sctx->state, (const u32 *)&data[i]); + sha1_transform1 (sctx, sctx->state, (const u32 *)&data[i]); } j = 0; @@ -250,7 +250,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) */ static struct shash_alg ifxdeu_sha1_alg = { .digestsize = SHA1_DIGEST_SIZE, - .init = sha1_init, + .init = sha1_init1, .update = sha1_update, .final = sha1_final, .descsize = sizeof(struct sha1_ctx), diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index 465c58f105..09496c509b 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -44,8 +44,8 @@ #include #include #include -#include #include +#include #include #include #include From 19cb3c9dff96da86d81907ef503ddf93b7ad562c Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Mon, 31 May 2021 14:43:08 +0200 Subject: [PATCH 16/73] ltq-deu: fix cryptomgr test errors for des When running cryptomgr tests against the driver, there are several occurences of different errors for setkey of des and des3-ede algorithms. Those key checks are already implemented in the kernels des implementation, so this is added as dependency and the kernel methods are called. It also required adding the kernels des/des3 context definitions to the des_ctx internal structure to be able to call the kernel methods. Fixed ifxdeu-des... setkey unexpectedly succeeded on test vector x; expected_error=-22. Fixed ifxdeu-des... setkey failed on test vector x; expected_error=0, actual_error=-22. Renamed des_ctx internal structure and des_encrypt/des_decrypt methods because they are already defined in the kernel module. Fixed wrong DES_xxx constant definitions in crypto_alg definition for ifxdeu_des3_ede_alg. Fixed method comment errors. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/Makefile | 2 +- .../kernel/lantiq/ltq-deu/src/ifxmips_des.c | 87 ++++++++++++------- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/Makefile b/package/kernel/lantiq/ltq-deu/Makefile index e5a7d0d86f..8ac37f5d2d 100644 --- a/package/kernel/lantiq/ltq-deu/Makefile +++ b/package/kernel/lantiq/ltq-deu/Makefile @@ -21,7 +21,7 @@ define KernelPackage/ltq-deu-template TITLE:=deu driver for $(1) URL:=http://www.lantiq.com/ VARIANT:=$(1) - DEPENDS:=@TARGET_lantiq_$(2) +kmod-crypto-manager @LINUX_5_4 + DEPENDS:=@TARGET_lantiq_$(2) +kmod-crypto-manager +kmod-crypto-des @LINUX_5_4 FILES:=$(PKG_BUILD_DIR)/ltq_deu_$(1).ko AUTOLOAD:=$(call AutoProbe,ltq_deu_$(1)) endef diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c index 6b24e0f4b4..a223e8ec38 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include "ifxmips_deu.h" @@ -106,11 +107,13 @@ void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes); void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode); -struct des_ctx { +struct ifx_deu_des_ctx { int controlr_M; int key_length; u8 iv[DES_BLOCK_SIZE]; u32 expkey[DES3_EDE_EXPKEY_WORDS]; + struct des_ctx des_context; + struct des3_ede_ctx des3_ede_context; }; extern int disable_multiblock; @@ -127,20 +130,32 @@ extern int disable_deudma; int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { - struct des_ctx *dctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *dctx = crypto_tfm_ctx(tfm); + int err; //printk("setkey in %s\n", __FILE__); + err = des_expand_key(&dctx->des_context, key, keylen); + if (err == -ENOKEY) { + if (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) + err = -EINVAL; + else + err = 0; + } + dctx->controlr_M = 0; // des dctx->key_length = keylen; memcpy ((u8 *) (dctx->expkey), key, keylen); - return 0; + if (err) + memset(dctx, 0, sizeof(*dctx)); + + return err; } -/*! \fn int des_set_key (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) +/*! \fn int des_setkey_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) * \ingroup IFX_AES_FUNCTIONS * \brief sets the AES keys for skcipher * \param tfm linux crypto skcipher @@ -170,7 +185,7 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) { volatile struct des_t *des = (struct des_t *) DES_3DES_START; - struct des_ctx *dctx = ctx_arg; + struct ifx_deu_des_ctx *dctx = ctx_arg; u32 *key = dctx->expkey; unsigned long flag; @@ -360,31 +375,31 @@ void ifx_deu_des_ctr (void *ctx, uint8_t *dst, const uint8_t *src, ifx_deu_des (ctx, dst, src, iv, nbytes, encdec, 4); } -/*! \fn void des_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +/*! \fn void ifx_deu_des_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_DES_FUNCTIONS * \brief encrypt DES_BLOCK_SIZE of data * \param tfm linux crypto algo transform * \param out output bytestream * \param in input bytestream */ -void des_encrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) +void ifx_deu_des_encrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) { - struct des_ctx *ctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(tfm); ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE, CRYPTO_DIR_ENCRYPT, 0); } -/*! \fn void des_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +/*! \fn void ifx_deu_des_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_DES_FUNCTIONS * \brief encrypt DES_BLOCK_SIZE of data * \param tfm linux crypto algo transform * \param out output bytestream * \param in input bytestream */ -void des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) +void ifx_deu_des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) { - struct des_ctx *ctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(tfm); ifx_deu_des (ctx, out, in, NULL, DES_BLOCK_SIZE, CRYPTO_DIR_DECRYPT, 0); } @@ -413,16 +428,28 @@ void des_decrypt (struct crypto_tfm *tfm, uint8_t * out, const uint8_t * in) int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { - struct des_ctx *dctx = crypto_tfm_ctx(tfm); + struct ifx_deu_des_ctx *dctx = crypto_tfm_ctx(tfm); + int err; //printk("setkey in %s\n", __FILE__); + err = des3_ede_expand_key(&dctx->des3_ede_context, key, keylen); + if (err == -ENOKEY) { + if (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) + err = -EINVAL; + else + err = 0; + } + dctx->controlr_M = keylen / 8 + 1; // 3DES EDE1 / EDE2 / EDE3 Mode dctx->key_length = keylen; memcpy ((u8 *) (dctx->expkey), key, keylen); - return 0; + if (err) + memset(dctx, 0, sizeof(*dctx)); + + return err; } /*! \fn int des3_ede_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) @@ -447,7 +474,7 @@ struct crypto_alg ifxdeu_des_alg = { .cra_priority = 300, .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), + .cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .cra_module = THIS_MODULE, .cra_alignmask = 3, .cra_list = LIST_HEAD_INIT(ifxdeu_des_alg.cra_list), @@ -455,8 +482,8 @@ struct crypto_alg ifxdeu_des_alg = { .cia_min_keysize = DES_KEY_SIZE, .cia_max_keysize = DES_KEY_SIZE, .cia_setkey = des_setkey, - .cia_encrypt = des_encrypt, - .cia_decrypt = des_decrypt } } + .cia_encrypt = ifx_deu_des_encrypt, + .cia_decrypt = ifx_deu_des_decrypt } } }; /* @@ -467,17 +494,17 @@ struct crypto_alg ifxdeu_des3_ede_alg = { .cra_driver_name = "ifxdeu-des3_ede", .cra_priority = 300, .cra_flags = CRYPTO_ALG_TYPE_CIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct des_ctx), + .cra_blocksize = DES3_EDE_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .cra_module = THIS_MODULE, .cra_alignmask = 3, .cra_list = LIST_HEAD_INIT(ifxdeu_des3_ede_alg.cra_list), .cra_u = { .cipher = { - .cia_min_keysize = DES_KEY_SIZE, - .cia_max_keysize = DES_KEY_SIZE, + .cia_min_keysize = DES3_EDE_KEY_SIZE, + .cia_max_keysize = DES3_EDE_KEY_SIZE, .cia_setkey = des3_ede_setkey, - .cia_encrypt = des_encrypt, - .cia_decrypt = des_decrypt } } + .cia_encrypt = ifx_deu_des_encrypt, + .cia_decrypt = ifx_deu_des_decrypt } } }; /*! \fn int ecb_des_encrypt(struct skcipher_req *req) @@ -488,7 +515,7 @@ struct crypto_alg ifxdeu_des3_ede_alg = { */ int ecb_des_encrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; int err; unsigned int enc_bytes, nbytes; @@ -514,7 +541,7 @@ int ecb_des_encrypt(struct skcipher_request *req) */ int ecb_des_decrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; int err; unsigned int dec_bytes, nbytes; @@ -542,7 +569,7 @@ struct skcipher_alg ifxdeu_ecb_des_alg = { .base.cra_priority = 400, .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .base.cra_blocksize = DES_BLOCK_SIZE, - .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .base.cra_module = THIS_MODULE, .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des_alg.base.cra_list), .min_keysize = DES_KEY_SIZE, @@ -561,7 +588,7 @@ struct skcipher_alg ifxdeu_ecb_des3_ede_alg = { .base.cra_priority = 400, .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, - .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .base.cra_module = THIS_MODULE, .base.cra_list = LIST_HEAD_INIT(ifxdeu_ecb_des3_ede_alg.base.cra_list), .min_keysize = DES3_EDE_KEY_SIZE, @@ -579,7 +606,7 @@ struct skcipher_alg ifxdeu_ecb_des3_ede_alg = { */ int cbc_des_encrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; int err; unsigned int enc_bytes, nbytes; @@ -607,7 +634,7 @@ int cbc_des_encrypt(struct skcipher_request *req) */ int cbc_des_decrypt(struct skcipher_request *req) { - struct des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct ifx_deu_des_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; int err; unsigned int dec_bytes, nbytes; @@ -636,7 +663,7 @@ struct skcipher_alg ifxdeu_cbc_des_alg = { .base.cra_priority = 400, .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .base.cra_blocksize = DES_BLOCK_SIZE, - .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .base.cra_module = THIS_MODULE, .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des_alg.base.cra_list), .min_keysize = DES_KEY_SIZE, @@ -656,7 +683,7 @@ struct skcipher_alg ifxdeu_cbc_des3_ede_alg = { .base.cra_priority = 400, .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, - .base.cra_ctxsize = sizeof(struct des_ctx), + .base.cra_ctxsize = sizeof(struct ifx_deu_des_ctx), .base.cra_module = THIS_MODULE, .base.cra_list = LIST_HEAD_INIT(ifxdeu_cbc_des3_ede_alg.base.cra_list), .min_keysize = DES3_EDE_KEY_SIZE, From cd01d41c77626731b3fe6a915bb4eecd188f6fb3 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Mon, 31 May 2021 15:17:16 +0200 Subject: [PATCH 17/73] ltq-deu: fix cryptomgr test errors for aes When running cryptomgr tests against the driver, there are several occurences of different errors for even and uneven splitted data in the underlying scatterlists for the ctr and ctr_rfc3686 algorithms which are now fixed. Fixed error in ctr_rfc3686_aes_decrypt function which was introduced with the previous commit by using CRYPTO_DIR_ENCRYPT in the decrypt function. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 89 +++++++++---------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index bd52564692..952f08f314 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -657,16 +657,26 @@ int ctr_basic_aes_encrypt(struct skcipher_request *req) { struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; - unsigned int nbytes; int err; + unsigned int enc_bytes, nbytes; err = skcipher_walk_virt(&walk, req, false); - while ((nbytes = walk.nbytes)) { + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - walk.iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); + walk.iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); err = skcipher_walk_done(&walk, 0); } + return err; } @@ -680,14 +690,23 @@ int ctr_basic_aes_decrypt(struct skcipher_request *req) { struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; - unsigned int nbytes; int err; + unsigned int dec_bytes, nbytes; err = skcipher_walk_virt(&walk, req, false); - while ((nbytes = walk.nbytes)) { + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - walk.iv, nbytes, CRYPTO_DIR_DECRYPT, 0); + walk.iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); err = skcipher_walk_done(&walk, 0); } @@ -709,6 +728,7 @@ struct skcipher_alg ifxdeu_ctr_basic_aes_alg = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, + .walksize = AES_BLOCK_SIZE, .setkey = aes_set_key_skcipher, .encrypt = ctr_basic_aes_encrypt, .decrypt = ctr_basic_aes_decrypt, @@ -725,13 +745,12 @@ int ctr_rfc3686_aes_encrypt(struct skcipher_request *req) { struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; - unsigned int nbytes; - int err, bsize; + unsigned int nbytes, enc_bytes; + int err; u8 rfc3686_iv[16]; err = skcipher_walk_virt(&walk, req, false); nbytes = walk.nbytes; - bsize = nbytes; /* set up counter block */ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE); @@ -741,22 +760,12 @@ int ctr_rfc3686_aes_encrypt(struct skcipher_request *req) *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) = cpu_to_be32(1); - /* scatterlist source is the same size as request size, just process once */ - if (nbytes == walk.nbytes) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); - nbytes -= walk.nbytes; - err = skcipher_walk_done(&walk, nbytes); - return err; - } - - while ((nbytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); - - nbytes -= walk.nbytes; - bsize -= walk.nbytes; - err = skcipher_walk_done(&walk, nbytes); + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + rfc3686_iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); } /* to handle remaining bytes < AES_BLOCK_SIZE */ @@ -779,13 +788,12 @@ int ctr_rfc3686_aes_decrypt(struct skcipher_request *req) { struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); struct skcipher_walk walk; - unsigned int nbytes; - int err, bsize; + unsigned int nbytes, dec_bytes; + int err; u8 rfc3686_iv[16]; err = skcipher_walk_virt(&walk, req, false); nbytes = walk.nbytes; - bsize = nbytes; /* set up counter block */ memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE); @@ -795,28 +803,18 @@ int ctr_rfc3686_aes_decrypt(struct skcipher_request *req) *(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) = cpu_to_be32(1); - /* scatterlist source is the same size as request size, just process once */ - if (nbytes == walk.nbytes) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); - nbytes -= walk.nbytes; - err = skcipher_walk_done(&walk, nbytes); - return err; - } - - while ((nbytes = walk.nbytes) % (walk.nbytes >= AES_BLOCK_SIZE)) { - ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, nbytes, CRYPTO_DIR_DECRYPT, 0); - - nbytes -= walk.nbytes; - bsize -= walk.nbytes; - err = skcipher_walk_done(&walk, nbytes); + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + rfc3686_iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); } /* to handle remaining bytes < AES_BLOCK_SIZE */ if (walk.nbytes) { ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, - rfc3686_iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + rfc3686_iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); err = skcipher_walk_done(&walk, 0); } @@ -838,6 +836,7 @@ struct skcipher_alg ifxdeu_ctr_rfc3686_aes_alg = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = CTR_RFC3686_MAX_KEY_SIZE, .ivsize = CTR_RFC3686_IV_SIZE, + .walksize = AES_BLOCK_SIZE, .setkey = ctr_rfc3686_aes_set_key_skcipher, .encrypt = ctr_rfc3686_aes_encrypt, .decrypt = ctr_rfc3686_aes_decrypt, From 536dc6f16467f7f029ddf30fb8d47770b3010190 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Mon, 31 May 2021 15:22:43 +0200 Subject: [PATCH 18/73] ltq-deu: add aes_ofb and aes_cfb algorithms The functions ifx_deu_aes_cfg and ifx_deu_aes_ofb have been part of the driver ever since. But the functions and definitions to make the algorithms actually usable were missing. This patch adds the neccessary code for aes_ofb and aes_cfb algorithms. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 952f08f314..b4417f2ef3 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -647,6 +647,184 @@ struct skcipher_alg ifxdeu_cbc_aes_alg = { }; +/*! \fn int ofb_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief OFB AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int ofb_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + return err; +} + +/*! \fn int ofb_aes_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief OFB AES decrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int ofb_aes_decrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int dec_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_ofb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + return err; +} + +/* + * \brief AES function mappings +*/ +struct skcipher_alg ifxdeu_ofb_aes_alg = { + .base.cra_name = "ofb(aes)", + .base.cra_driver_name = "ifxdeu-ofb(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_ofb_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .chunksize = AES_BLOCK_SIZE, + .walksize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = ofb_aes_encrypt, + .decrypt = ofb_aes_decrypt, +}; + + +/*! \fn int cfb_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CFB AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int cfb_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + return err; +} + +/*! \fn int cfb_aes_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief CFB AES decrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int cfb_aes_decrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int dec_bytes, nbytes; + + err = skcipher_walk_virt(&walk, req, false); + + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* to handle remaining bytes < AES_BLOCK_SIZE */ + if (walk.nbytes) { + ifx_deu_aes_cfb(ctx, walk.dst.virt.addr, walk.src.virt.addr, + walk.iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + return err; +} + +/* + * \brief AES function mappings +*/ +struct skcipher_alg ifxdeu_cfb_aes_alg = { + .base.cra_name = "cfb(aes)", + .base.cra_driver_name = "ifxdeu-cfb(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_cfb_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .chunksize = AES_BLOCK_SIZE, + .walksize = AES_BLOCK_SIZE, + .setkey = aes_set_key_skcipher, + .encrypt = cfb_aes_encrypt, + .decrypt = cfb_aes_decrypt, +}; + + /*! \fn int ctr_basic_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS * \brief Counter mode AES encrypt using linux crypto skcipher @@ -863,6 +1041,12 @@ int ifxdeu_init_aes (void) if ((ret = crypto_register_skcipher(&ifxdeu_cbc_aes_alg))) goto cbc_aes_err; + if ((ret = crypto_register_skcipher(&ifxdeu_ofb_aes_alg))) + goto ofb_aes_err; + + if ((ret = crypto_register_skcipher(&ifxdeu_cfb_aes_alg))) + goto cfb_aes_err; + if ((ret = crypto_register_skcipher(&ifxdeu_ctr_basic_aes_alg))) goto ctr_basic_aes_err; @@ -883,6 +1067,14 @@ ctr_basic_aes_err: crypto_unregister_skcipher(&ifxdeu_ctr_basic_aes_alg); printk (KERN_ERR "IFX ctr_basic_aes initialization failed!\n"); return ret; +cfb_aes_err: + crypto_unregister_skcipher(&ifxdeu_cfb_aes_alg); + printk (KERN_ERR "IFX cfb_aes initialization failed!\n"); + return ret; +ofb_aes_err: + crypto_unregister_skcipher(&ifxdeu_ofb_aes_alg); + printk (KERN_ERR "IFX ofb_aes initialization failed!\n"); + return ret; cbc_aes_err: crypto_unregister_skcipher(&ifxdeu_cbc_aes_alg); printk (KERN_ERR "IFX cbc_aes initialization failed!\n"); @@ -906,6 +1098,8 @@ void ifxdeu_fini_aes (void) crypto_unregister_alg (&ifxdeu_aes_alg); crypto_unregister_skcipher (&ifxdeu_ecb_aes_alg); crypto_unregister_skcipher (&ifxdeu_cbc_aes_alg); + crypto_unregister_skcipher (&ifxdeu_ofb_aes_alg); + crypto_unregister_skcipher (&ifxdeu_cfb_aes_alg); crypto_unregister_skcipher (&ifxdeu_ctr_basic_aes_alg); crypto_unregister_skcipher (&ifxdeu_ctr_rfc3686_aes_alg); From 87a19c9345db7554441dbd10f8c4460f6629c10a Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Sat, 5 Jun 2021 21:37:53 +0200 Subject: [PATCH 19/73] ltq-deu: make deu hash lock global and remove md5_hmac_ exports All hash algorithms use the same base IFX_HASH_CON to access the hash unit. Parallel threads should not be able to call different hash algorithms and therefor a global lock is required. Fixed linker warning, that md5_hmac_init, md5_hmac_update and md5_hmac_final are static export symbols. The export symbols are not required, because the functions are exposed using shash_alg structure. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_deu.c | 3 +++ .../kernel/lantiq/ltq-deu/src/ifxmips_deu.h | 4 ++++ .../kernel/lantiq/ltq-deu/src/ifxmips_md5.c | 15 ++++----------- .../lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 19 ++++--------------- .../kernel/lantiq/ltq-deu/src/ifxmips_sha1.c | 15 ++++----------- .../lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 15 ++++----------- 6 files changed, 23 insertions(+), 48 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c index 3947b31a40..a102568f97 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.c @@ -69,6 +69,8 @@ #endif /* CONFIG_xxxx */ int disable_deudma = 1; +spinlock_t ltq_deu_hash_lock; +EXPORT_SYMBOL_GPL(ltq_deu_hash_lock); void chip_version(void); @@ -84,6 +86,7 @@ static int ltq_deu_probe(struct platform_device *pdev) START_DEU_POWER; + CRTCL_SECT_HASH_INIT; #define IFX_DEU_DRV_VERSION "2.0.0" printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION); diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h index 8045c2081a..3c994cb346 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu.h @@ -131,6 +131,10 @@ void __exit lqdeu_fini_async_des(void); void __exit deu_fini (void); int deu_dma_init (void); +extern spinlock_t ltq_deu_hash_lock; +#define CRTCL_SECT_HASH_INIT spin_lock_init(<q_deu_hash_lock) +#define CRTCL_SECT_HASH_START spin_lock_irqsave(<q_deu_hash_lock, flag) +#define CRTCL_SECT_HASH_END spin_unlock_irqrestore(<q_deu_hash_lock, flag) #define DEU_WAKELIST_INIT(queue) \ diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c index 14967c30d6..f7dbee4fdc 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c @@ -64,11 +64,6 @@ #define MD5_HASH_WORDS 4 #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -110,7 +105,7 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; unsigned long flag; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; if (mctx->started) { hashs->D1R = endian_swap(*((u32 *) hash + 0)); @@ -136,7 +131,7 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) mctx->started = 1; - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; } /*! \fn static inline void md5_transform_helper(struct md5_ctx *ctx) @@ -242,14 +237,14 @@ static int md5_final(struct shash_desc *desc, u8 *out) md5_transform(mctx, mctx->hash, mctx->block); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; *((u32 *) out + 0) = endian_swap (hashs->D1R); *((u32 *) out + 1) = endian_swap (hashs->D2R); *((u32 *) out + 2) = endian_swap (hashs->D3R); *((u32 *) out + 3) = endian_swap (hashs->D4R); - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; // Wipe context memset(mctx, 0, sizeof(*mctx)); @@ -288,8 +283,6 @@ int ifxdeu_init_md5 (void) if ((ret = crypto_register_shash(&ifxdeu_md5_alg))) goto md5_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU MD5 initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index b6e65c8b22..9cc6eb7a55 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -63,11 +63,6 @@ #define MD5_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -167,7 +162,7 @@ static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) //printk("\nsetkey keylen: %d\n key: ", keylen); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; j = 0; for (i = 0; i < keylen; i+=4) { @@ -177,7 +172,7 @@ static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) asm("sync"); j++; } - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; } @@ -198,7 +193,6 @@ static int md5_hmac_init(struct shash_desc *desc) return 0; } -EXPORT_SYMBOL(md5_hmac_init); /*! \fn void md5_hmac_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len) * \ingroup IFX_MD5_HMAC_FUNCTIONS @@ -237,7 +231,6 @@ static int md5_hmac_update(struct shash_desc *desc, const u8 *data, unsigned int memcpy(mctx->block, data, len); return 0; } -EXPORT_SYMBOL(md5_hmac_update); /*! \fn void md5_hmac_final(struct crypto_tfm *tfm, u8 *out) * \ingroup IFX_MD5_HMAC_FUNCTIONS @@ -272,7 +265,7 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) md5_hmac_transform(desc, mctx->block); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; //printk("\ndbn = %d\n", mctx->dbn); hashs->DBN = mctx->dbn; @@ -322,14 +315,12 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS)); memset(&temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; } -EXPORT_SYMBOL(md5_hmac_final); - /* * \brief MD5_HMAC function mappings */ @@ -365,8 +356,6 @@ int ifxdeu_init_md5_hmac (void) if ((ret = crypto_register_shash(&ifxdeu_md5_hmac_alg))) goto md5_hmac_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU MD5_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c index 362fe89c92..70271b2dd0 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c @@ -65,11 +65,6 @@ #define SHA1_HMAC_BLOCK_SIZE 64 #define HASH_START IFX_HASH_CON -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - //#define CRYPTO_DEBUG #ifdef CRYPTO_DEBUG extern char debug_level; @@ -104,7 +99,7 @@ static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in) volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; unsigned long flag; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; /* For context switching purposes, the previous hash output * is loaded back into the output register @@ -137,7 +132,7 @@ static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in) sctx->started = 1; - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; } /*! \fn static void sha1_init1(struct crypto_tfm *tfm) @@ -229,7 +224,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) /* Append length */ sha1_update (desc, bits, sizeof bits); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; *((u32 *) out + 0) = hashs->D1R; *((u32 *) out + 1) = hashs->D2R; @@ -237,7 +232,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) *((u32 *) out + 3) = hashs->D4R; *((u32 *) out + 4) = hashs->D5R; - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; // Wipe context memset (sctx, 0, sizeof *sctx); @@ -278,8 +273,6 @@ int ifxdeu_init_sha1 (void) if ((ret = crypto_register_shash(&ifxdeu_sha1_alg))) goto sha1_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU SHA1 initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index 09496c509b..a1461e6e5b 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -66,11 +66,6 @@ #define SHA1_HMAC_MAX_KEYLEN 64 -static spinlock_t lock; -#define CRTCL_SECT_INIT spin_lock_init(&lock) -#define CRTCL_SECT_START spin_lock_irqsave(&lock, flag) -#define CRTCL_SECT_END spin_unlock_irqrestore(&lock, flag) - #ifdef CRYPTO_DEBUG extern char debug_level; #define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args); @@ -158,7 +153,7 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) j = 0; - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; for (i = 0; i < keylen; i+=4) { hash->KIDX = j; @@ -167,7 +162,7 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) j++; } - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; } @@ -265,7 +260,7 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) /* Append length */ sha1_hmac_update (desc, bits, sizeof bits); - CRTCL_SECT_START; + CRTCL_SECT_HASH_START; hashs->DBN = sctx->dbn; @@ -312,7 +307,7 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) sctx->count = 0; //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); - CRTCL_SECT_END; + CRTCL_SECT_HASH_END; return 0; @@ -355,8 +350,6 @@ int ifxdeu_init_sha1_hmac (void) if ((ret = crypto_register_shash(&ifxdeu_sha1_hmac_alg))) goto sha1_err; - CRTCL_SECT_INIT; - printk (KERN_NOTICE "IFX DEU SHA1_HMAC initialized%s.\n", disable_deudma ? "" : " (DMA)"); return ret; From 34a3eaf07f6a814d77cbdaa6c8a14604a37f7784 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Sat, 5 Jun 2021 23:46:58 +0200 Subject: [PATCH 20/73] ltq-deu: changes for hash multithread callers and md5 endianess The algorithms sha1, sha1_hmac and md5_hmac all use ENDI=1. The md5 algorithm uses ENDI=0 and the endian_swap methods to reverse the endianess switch by using user CPU time, which is unnecessary overhead. Danube and AR9 devices do not set endianess for SHA1, so is done for MD5. Furthermore the patch replaces endian_swap with le32_to_cpu for md5 and md5 hmac algorithms and removes endian_swap for them. The init functions initialize the algorithm in the hardware. The lock is not used to write to the control register. If another thread calls another hash algo before update or final, the result will be wrong. Therefore move the algorithm init to the lock protected sections in the transform or final methods. Setting the hw key for the hmac algorithms is now done from within the lock protected sections in their final methods. The lock protecting is removed from the _hmac_setkey_hw functions. In final for md5 and sha1 the lock section is removed, because all the work was already done in transform (which is called from final). As such only copying the hash to the output is required. MD5 and MD5_HMAC produce 16 byte hashes (4 DWORDS) only, therefor writing register D5R to the hash output is removed for MD5_HMAC. Signed-off-by: Daniel Kestrel --- .../lantiq/ltq-deu/src/ifxmips_deu_ar9.h | 8 +++ .../lantiq/ltq-deu/src/ifxmips_deu_danube.h | 8 +++ .../kernel/lantiq/ltq-deu/src/ifxmips_md5.c | 57 +++++-------------- .../lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 26 ++------- .../kernel/lantiq/ltq-deu/src/ifxmips_sha1.c | 14 +---- .../lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 11 ++-- 6 files changed, 45 insertions(+), 79 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h index 69414553de..2f373589a5 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_ar9.h @@ -117,6 +117,14 @@ hash->controlr.INIT = 1; \ } while(0) +#define MD5_HASH_INIT \ + do { \ + volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \ + hash->controlr.SM = 1; \ + hash->controlr.ALGO = 1; \ + hash->controlr.INIT = 1; \ + } while(0) + /* DEU Common Structures for AR9*/ struct clc_controlr_t { diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h index 25efa04a69..25561cf6e0 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_deu_danube.h @@ -104,6 +104,14 @@ hash->controlr.INIT = 1; \ } while(0) +#define MD5_HASH_INIT \ + do { \ + volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; \ + hash->controlr.SM = 1; \ + hash->controlr.ALGO = 1; \ + hash->controlr.INIT = 1; \ + } while(0) + /* DEU STRUCTURES */ struct clc_controlr_t { diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c index f7dbee4fdc..376ff64d05 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c @@ -81,18 +81,6 @@ struct md5_ctx { extern int disable_deudma; -/*! \fn static u32 endian_swap(u32 input) - * \ingroup IFX_MD5_FUNCTIONS - * \brief perform dword level endian swap - * \param input value of dword that requires to be swapped -*/ -static u32 endian_swap(u32 input) -{ - u8 *ptr = (u8 *)&input; - - return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]); -} - /*! \fn static void md5_transform(u32 *hash, u32 const *in) * \ingroup IFX_MD5_FUNCTIONS * \brief main interface to md5 hardware @@ -107,16 +95,18 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) CRTCL_SECT_HASH_START; + MD5_HASH_INIT; + if (mctx->started) { - hashs->D1R = endian_swap(*((u32 *) hash + 0)); - hashs->D2R = endian_swap(*((u32 *) hash + 1)); - hashs->D3R = endian_swap(*((u32 *) hash + 2)); - hashs->D4R = endian_swap(*((u32 *) hash + 3)); + hashs->D1R = *((u32 *) hash + 0); + hashs->D2R = *((u32 *) hash + 1); + hashs->D3R = *((u32 *) hash + 2); + hashs->D4R = *((u32 *) hash + 3); } for (i = 0; i < 16; i++) { - hashs->MR = endian_swap(in[i]); -// printk("in[%d]: %08x\n", i, endian_swap(in[i])); + hashs->MR = in[i]; +// printk("in[%d]: %08x\n", i, in[i]); }; //wait for processing @@ -124,10 +114,10 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) // this will not take long } - *((u32 *) hash + 0) = endian_swap (hashs->D1R); - *((u32 *) hash + 1) = endian_swap (hashs->D2R); - *((u32 *) hash + 2) = endian_swap (hashs->D3R); - *((u32 *) hash + 3) = endian_swap (hashs->D4R); + *((u32 *) hash + 0) = hashs->D1R; + *((u32 *) hash + 1) = hashs->D2R; + *((u32 *) hash + 2) = hashs->D3R; + *((u32 *) hash + 3) = hashs->D4R; mctx->started = 1; @@ -155,11 +145,6 @@ static int md5_init(struct shash_desc *desc) struct md5_ctx *mctx = shash_desc_ctx(desc); volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; - hash->controlr.ENDI = 0; - hash->controlr.SM = 1; - hash->controlr.ALGO = 1; // 1 = md5 0 = sha1 - hash->controlr.INIT = 1; // Initialize the hash operation by writing a '1' to the INIT bit. - mctx->byte_count = 0; mctx->started = 0; return 0; @@ -227,24 +212,12 @@ static int md5_final(struct shash_desc *desc, u8 *out) } memset(p, 0, padding); - mctx->block[14] = endian_swap(mctx->byte_count << 3); - mctx->block[15] = endian_swap(mctx->byte_count >> 29); - -#if 0 - le32_to_cpu_array(mctx->block, (sizeof(mctx->block) - - sizeof(u64)) / sizeof(u32)); -#endif + mctx->block[14] = le32_to_cpu(mctx->byte_count << 3); + mctx->block[15] = le32_to_cpu(mctx->byte_count >> 29); md5_transform(mctx, mctx->hash, mctx->block); - CRTCL_SECT_HASH_START; - - *((u32 *) out + 0) = endian_swap (hashs->D1R); - *((u32 *) out + 1) = endian_swap (hashs->D2R); - *((u32 *) out + 2) = endian_swap (hashs->D3R); - *((u32 *) out + 3) = endian_swap (hashs->D4R); - - CRTCL_SECT_HASH_END; + memcpy(out, mctx->hash, MD5_DIGEST_SIZE); // Wipe context memset(mctx, 0, sizeof(*mctx)); diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index 9cc6eb7a55..277879fbbb 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -86,18 +86,6 @@ static u32 temp[MD5_HMAC_DBN_TEMP_SIZE]; extern int disable_deudma; -/*! \fn static u32 endian_swap(u32 input) - * \ingroup IFX_MD5_HMAC_FUNCTIONS - * \brief perform dword level endian swap - * \param input value of dword that requires to be swapped -*/ -static u32 endian_swap(u32 input) -{ - u8 *ptr = (u8 *)&input; - - return ((ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0]); -} - /*! \fn static void md5_hmac_transform(struct crypto_tfm *tfm, u32 const *in) * \ingroup IFX_MD5_HMAC_FUNCTIONS * \brief save input block to context @@ -128,7 +116,6 @@ static void md5_hmac_transform(struct shash_desc *desc, u32 const *in) static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(tfm); - volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; //printk("copying keys to context with length %d\n", keylen); if (keylen > MAX_HASH_KEYLEN) { @@ -137,7 +124,6 @@ static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int } - hash->KIDX |= 0x80000000; // reset all 16 words of the key to '0' memcpy(&mctx->key, key, keylen); mctx->keylen = keylen; @@ -156,13 +142,12 @@ static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) { volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; - unsigned long flag; int i, j; u32 *in_key = (u32 *)key; //printk("\nsetkey keylen: %d\n key: ", keylen); - CRTCL_SECT_HASH_START; + hash->KIDX |= 0x80000000; // reset all 16 words of the key to '0' j = 0; for (i = 0; i < keylen; i+=4) { @@ -172,7 +157,6 @@ static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) asm("sync"); j++; } - CRTCL_SECT_HASH_END; return 0; } @@ -189,7 +173,6 @@ static int md5_hmac_init(struct shash_desc *desc) mctx->dbn = 0; //dbn workaround - md5_hmac_setkey_hw(mctx->key, mctx->keylen); return 0; } @@ -260,13 +243,17 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) } memset(p, 0, padding); - mctx->block[14] = endian_swap((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation + mctx->block[14] = le32_to_cpu((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation mctx->block[15] = 0x00000000; md5_hmac_transform(desc, mctx->block); CRTCL_SECT_HASH_START; + MD5_HASH_INIT; + + md5_hmac_setkey_hw(mctx->key, mctx->keylen); + //printk("\ndbn = %d\n", mctx->dbn); hashs->DBN = mctx->dbn; asm("sync"); @@ -307,7 +294,6 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) *((u32 *) out + 1) = hashs->D2R; *((u32 *) out + 2) = hashs->D3R; *((u32 *) out + 3) = hashs->D4R; - *((u32 *) out + 4) = hashs->D5R; /* reset the context after we finish with the hash */ mctx->byte_count = 0; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c index 70271b2dd0..a139f8d9d4 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c @@ -101,6 +101,8 @@ static void sha1_transform1 (struct sha1_ctx *sctx, u32 *state, const u32 *in) CRTCL_SECT_HASH_START; + SHA_HASH_INIT; + /* For context switching purposes, the previous hash output * is loaded back into the output register */ @@ -144,8 +146,6 @@ static int sha1_init1(struct shash_desc *desc) { struct sha1_ctx *sctx = shash_desc_ctx(desc); - SHA_HASH_INIT; - sctx->started = 0; sctx->count = 0; return 0; @@ -224,15 +224,7 @@ static int sha1_final(struct shash_desc *desc, u8 *out) /* Append length */ sha1_update (desc, bits, sizeof bits); - CRTCL_SECT_HASH_START; - - *((u32 *) out + 0) = hashs->D1R; - *((u32 *) out + 1) = hashs->D2R; - *((u32 *) out + 2) = hashs->D3R; - *((u32 *) out + 3) = hashs->D4R; - *((u32 *) out + 4) = hashs->D5R; - - CRTCL_SECT_HASH_END; + memcpy(out, sctx->hash, SHA1_DIGEST_SIZE); // Wipe context memset (sctx, 0, sizeof *sctx); diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index a1461e6e5b..cee0041e8f 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -119,7 +119,6 @@ static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in) static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(tfm); - volatile struct deu_hash_t *hashs = (struct deu_hash_t *) HASH_START; if (keylen > SHA1_HMAC_MAX_KEYLEN) { printk("Key length exceeds maximum key length\n"); @@ -128,7 +127,6 @@ static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned in //printk("Setting keys of len: %d\n", keylen); - hashs->KIDX |= 0x80000000; //reset keys back to 0 memcpy(&sctx->key, key, keylen); sctx->keylen = keylen; @@ -148,12 +146,11 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) { volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; int i, j; - unsigned long flag; u32 *in_key = (u32 *)key; j = 0; - CRTCL_SECT_HASH_START; + hash->KIDX |= 0x80000000; //reset keys back to 0 for (i = 0; i < keylen; i+=4) { hash->KIDX = j; @@ -162,7 +159,6 @@ static int sha1_hmac_setkey_hw(const u8 *key, unsigned int keylen) j++; } - CRTCL_SECT_HASH_END; return 0; } @@ -177,7 +173,6 @@ static int sha1_hmac_init(struct shash_desc *desc) //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); sctx->dbn = 0; //dbn workaround - sha1_hmac_setkey_hw(sctx->key, sctx->keylen); return 0; } @@ -261,6 +256,10 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) sha1_hmac_update (desc, bits, sizeof bits); CRTCL_SECT_HASH_START; + + SHA_HASH_INIT; + + sha1_hmac_setkey_hw(sctx->key, sctx->keylen); hashs->DBN = sctx->dbn; From 9cb1875d2fcf20c208a63693d7395eb4963f59cb Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Sat, 5 Jun 2021 23:49:59 +0200 Subject: [PATCH 21/73] ltq-deu: fix ifxdeu-ctr-rfc3686(aes) not matching generic impl Error ifxdeu-ctr-rfc3686(aes) (16) doesn't match generic impl (20) occurs when running the cryptomgr extra tests that compare against the linux kernels generic implementation. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index b4417f2ef3..a55766a4ac 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -86,6 +86,7 @@ spinlock_t aes_lock; #define AES_BLOCK_SIZE 16 #define CTR_RFC3686_NONCE_SIZE 4 #define CTR_RFC3686_IV_SIZE 8 +#define CTR_RFC3686_MIN_KEY_SIZE (AES_MIN_KEY_SIZE + CTR_RFC3686_NONCE_SIZE) #define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE) #ifdef CRYPTO_DEBUG @@ -1011,7 +1012,7 @@ struct skcipher_alg ifxdeu_ctr_rfc3686_aes_alg = { .base.cra_ctxsize = sizeof(struct aes_ctx), .base.cra_module = THIS_MODULE, .base.cra_list = LIST_HEAD_INIT(ifxdeu_ctr_rfc3686_aes_alg.base.cra_list), - .min_keysize = AES_MIN_KEY_SIZE, + .min_keysize = CTR_RFC3686_MIN_KEY_SIZE, .max_keysize = CTR_RFC3686_MAX_KEY_SIZE, .ivsize = CTR_RFC3686_IV_SIZE, .walksize = AES_BLOCK_SIZE, From 85383b311212576e7afd9d01dec49f69ef6fb886 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Sun, 6 Jun 2021 21:16:32 +0200 Subject: [PATCH 22/73] ltq-deu: fix setkey errors and static shared temp for hmac algos The hmac algorithms state, that keys larger than the key size should be hashed with the underlying hash algorithms and then those hashes are to be used as keys. This patch implements this. In order to avoid allocating a descriptor during setkey, a shash_desc pointer is added to the context. Another issue for multithreaded callers is the shared temp array. The temp array is static and as such would be shared among multithreaded callers, which obviously would neither work nor produce correct results. The temp array (4k size) is moved to the context and since the size of the context is limited, it can only be defined as pointer otherwise the initialisation of the hash algorithm fails. The allocations and freeing of both the temp and the desc pointer in the context are done by implementing cra_init and cra_exit functions for the hmac algorithms. Also improved indentation in some areas. Signed-off-by: Daniel Kestrel --- .../lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 68 ++++++++-- .../lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 123 ++++++++++++------ 2 files changed, 138 insertions(+), 53 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index 277879fbbb..092b0581cc 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -80,10 +80,10 @@ struct md5_hmac_ctx { u64 byte_count; u32 dbn; unsigned int keylen; + struct shash_desc *desc; + u32 (*temp)[MD5_BLOCK_WORDS]; }; -static u32 temp[MD5_HMAC_DBN_TEMP_SIZE]; - extern int disable_deudma; /*! \fn static void md5_hmac_transform(struct crypto_tfm *tfm, u32 const *in) @@ -96,7 +96,7 @@ static void md5_hmac_transform(struct shash_desc *desc, u32 const *in) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm); - memcpy(&temp[mctx->dbn<<4], in, 64); //dbn workaround + memcpy(&mctx->temp[mctx->dbn], in, 64); //dbn workaround mctx->dbn += 1; if ( (mctx->dbn<<4) > MD5_HMAC_DBN_TEMP_SIZE ) @@ -116,19 +116,30 @@ static void md5_hmac_transform(struct shash_desc *desc, u32 const *in) static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(tfm); + volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; + int err; //printk("copying keys to context with length %d\n", keylen); if (keylen > MAX_HASH_KEYLEN) { - printk("Key length more than what DEU hash can handle\n"); - return -EINVAL; - } - + char *hash_alg_name = "md5"; - memcpy(&mctx->key, key, keylen); - mctx->keylen = keylen; + mctx->desc->tfm = crypto_alloc_shash(hash_alg_name, 0, 0); + if (IS_ERR(mctx->desc->tfm)) return PTR_ERR(mctx->desc->tfm); + + memset(mctx->key, 0, MAX_HASH_KEYLEN); + err = crypto_shash_digest(mctx->desc, key, keylen, mctx->key); + if (err) return err; + + mctx->keylen = MD5_DIGEST_SIZE; + + crypto_free_shash(mctx->desc->tfm); + } else { + memcpy(mctx->key, key, keylen); + mctx->keylen = keylen; + } + memset(mctx->key + mctx->keylen, 0, MAX_HASH_KEYLEN - mctx->keylen); return 0; - } @@ -231,7 +242,7 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) unsigned long flag; int i = 0; int dbn; - u32 *in = &temp[0]; + u32 *in = mctx->temp[0]; *p++ = 0x80; @@ -299,7 +310,7 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) mctx->byte_count = 0; memset(&mctx->hash[0], 0, sizeof(MD5_HASH_WORDS)); memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS)); - memset(&temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); + memset(&mctx->temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); CRTCL_SECT_HASH_END; @@ -307,6 +318,35 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) return 0; } +/*! \fn void md5_hmac_init_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_MD5_HMAC_FUNCTIONS + * \brief initialize pointers in md5_hmac_ctx + * \param tfm linux crypto algo transform +*/ +static int md5_hmac_init_tfm(struct crypto_tfm *tfm) +{ + struct md5_hmac_ctx *mctx = crypto_tfm_ctx(tfm); + mctx->temp = kzalloc(4 * MD5_HMAC_DBN_TEMP_SIZE, GFP_KERNEL); + if (IS_ERR(mctx->temp)) return PTR_ERR(mctx->temp); + mctx->desc = kzalloc(sizeof(struct shash_desc), GFP_KERNEL); + if (IS_ERR(mctx->desc)) return PTR_ERR(mctx->desc); + + return 0; +} + +/*! \fn void md5_hmac_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_MD5_HMAC_FUNCTIONS + * \brief free pointers in md5_hmac_ctx + * \param tfm linux crypto algo transform +*/ +static void md5_hmac_exit_tfm(struct crypto_tfm *tfm) +{ + struct md5_hmac_ctx *mctx = crypto_tfm_ctx(tfm); + kfree(mctx->temp); + kfree(mctx->desc); +} + + /* * \brief MD5_HMAC function mappings */ @@ -322,10 +362,12 @@ static struct shash_alg ifxdeu_md5_hmac_alg = { .cra_name = "hmac(md5)", .cra_driver_name= "ifxdeu-md5_hmac", .cra_priority = 400, - .cra_ctxsize = sizeof(struct md5_hmac_ctx), + .cra_ctxsize = sizeof(struct md5_hmac_ctx), .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, .cra_blocksize = MD5_HMAC_BLOCK_SIZE, .cra_module = THIS_MODULE, + .cra_init = md5_hmac_init_tfm, + .cra_exit = md5_hmac_exit_tfm, } }; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index cee0041e8f..a9e1d64d6f 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -60,6 +60,7 @@ #endif #define SHA1_DIGEST_SIZE 20 +#define SHA1_BLOCK_WORDS 16 #define SHA1_HMAC_BLOCK_SIZE 64 #define SHA1_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround #define HASH_START IFX_HASH_CON @@ -82,10 +83,10 @@ struct sha1_hmac_ctx { u32 dbn; u64 count; + struct shash_desc *desc; + u32 (*temp)[SHA1_BLOCK_WORDS]; }; -static u32 temp[SHA1_HMAC_DBN_TEMP_SIZE]; - extern int disable_deudma; /*! \fn static void sha1_hmac_transform(struct crypto_tfm *tfm, u32 const *in) @@ -98,7 +99,7 @@ static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm); - memcpy(&temp[sctx->dbn<<4], in, 64); //dbn workaround + memcpy(&sctx->temp[sctx->dbn], in, 64); //dbn workaround sctx->dbn += 1; if ( (sctx->dbn<<4) > SHA1_HMAC_DBN_TEMP_SIZE ) @@ -119,19 +120,31 @@ static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in) static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(tfm); - + volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; + int err; + if (keylen > SHA1_HMAC_MAX_KEYLEN) { - printk("Key length exceeds maximum key length\n"); - return -EINVAL; + char *hash_alg_name = "sha1"; + + sctx->desc->tfm = crypto_alloc_shash(hash_alg_name, 0, 0); + if (IS_ERR(sctx->desc->tfm)) return PTR_ERR(sctx->desc->tfm); + + memset(sctx->key, 0, SHA1_HMAC_MAX_KEYLEN); + err = crypto_shash_digest(sctx->desc, key, keylen, sctx->key); + if (err) return err; + + sctx->keylen = SHA1_DIGEST_SIZE; + + crypto_free_shash(sctx->desc->tfm); + } else { + memcpy(sctx->key, key, keylen); + sctx->keylen = keylen; } + memset(sctx->key + sctx->keylen, 0, SHA1_HMAC_MAX_KEYLEN - sctx->keylen); //printk("Setting keys of len: %d\n", keylen); - - memcpy(&sctx->key, key, keylen); - sctx->keylen = keylen; return 0; - } @@ -218,7 +231,6 @@ static int sha1_hmac_update(struct shash_desc *desc, const u8 *data, */ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) { - //struct sha1_hmac_ctx *sctx = shash_desc_ctx(desc); struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm); u32 index, padlen; u64 t; @@ -228,7 +240,7 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) unsigned long flag; int i = 0; int dbn; - u32 *in = &temp[0]; + u32 *in = sctx->temp[0]; t = sctx->count + 512; // need to add 512 bit of the IPAD operation bits[7] = 0xff & t; @@ -273,20 +285,20 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) for (dbn = 0; dbn < sctx->dbn; dbn++) { - for (i = 0; i < 16; i++) { - hashs->MR = in[i]; - }; + for (i = 0; i < 16; i++) { + hashs->MR = in[i]; + }; - hashs->controlr.GO = 1; - asm("sync"); + hashs->controlr.GO = 1; + asm("sync"); - //wait for processing - while (hashs->controlr.BSY) { + //wait for processing + while (hashs->controlr.BSY) { // this will not take long - } + } - in += 16; -} + in += 16; + } #if 1 @@ -313,26 +325,57 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) } -/* - * \brief SHA1-HMAC function mappings +/*! \fn void sha1_hmac_init_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_SHA1_HMAC_FUNCTIONS + * \brief initialize pointers in sha1_hmac_ctx + * \param tfm linux crypto algo transform */ -static struct shash_alg ifxdeu_sha1_hmac_alg = { - .digestsize = SHA1_DIGEST_SIZE, - .init = sha1_hmac_init, - .update = sha1_hmac_update, - .final = sha1_hmac_final, - .setkey = sha1_hmac_setkey, - .descsize = sizeof(struct sha1_hmac_ctx), - .base = { - .cra_name = "hmac(sha1)", - .cra_driver_name= "ifxdeu-sha1_hmac", - .cra_priority = 400, - .cra_ctxsize = sizeof(struct sha1_hmac_ctx), - .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, - .cra_module = THIS_MODULE, - } +static int sha1_hmac_init_tfm(struct crypto_tfm *tfm) +{ + struct sha1_hmac_ctx *sctx = crypto_tfm_ctx(tfm); + sctx->temp = kzalloc(4 * SHA1_HMAC_DBN_TEMP_SIZE, GFP_KERNEL); + if (IS_ERR(sctx->temp)) return PTR_ERR(sctx->temp); + sctx->desc = kzalloc(sizeof(struct shash_desc), GFP_KERNEL); + if (IS_ERR(sctx->desc)) return PTR_ERR(sctx->desc); + return 0; +} + +/*! \fn void sha1_hmac_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_SHA1_HMAC_FUNCTIONS + * \brief free pointers in sha1_hmac_ctx + * \param tfm linux crypto algo transform +*/ +static void sha1_hmac_exit_tfm(struct crypto_tfm *tfm) +{ + struct sha1_hmac_ctx *sctx = crypto_tfm_ctx(tfm); + kfree(sctx->temp); + kfree(sctx->desc); +} + + +/* + * \brief SHA1_HMAC function mappings +*/ + +static struct shash_alg ifxdeu_sha1_hmac_alg = { + .digestsize = SHA1_DIGEST_SIZE, + .init = sha1_hmac_init, + .update = sha1_hmac_update, + .final = sha1_hmac_final, + .setkey = sha1_hmac_setkey, + .descsize = sizeof(struct sha1_hmac_ctx), + .base = { + .cra_name = "hmac(sha1)", + .cra_driver_name= "ifxdeu-sha1_hmac", + .cra_priority = 400, + .cra_ctxsize = sizeof(struct sha1_hmac_ctx), + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, + .cra_module = THIS_MODULE, + .cra_init = sha1_hmac_init_tfm, + .cra_exit = sha1_hmac_exit_tfm, + } }; From 0470b05b568c9d9b7188e83c1303d0acac64921d Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Tue, 15 Jun 2021 17:23:05 +0200 Subject: [PATCH 23/73] ltq-deu: fix temp size exceed in hmac algorithms Exceeding the temp array size was not checked and instead storage not allocated by the driver was used/overwritten which in most cases resulted in reboots. This patch implements processing the input to the hash algorithm in tempsize chunks. The _hmac_final methods were changed to _hmac_final_impl adding a parameter that indicates intermediate or final processing. The started variable was added to the context to indicate, if there is an intermediate result in the context. For sha1_hmac the variable to store the intermediate hash was added to the context too. In order to avoid md5_hmac_final_impl being recursively called if the padding of the input and the resulting last transform during the hmac algorighms final processing causes the temp array to overflow and to make sure that there is at least one block in the temp array when the _hmac_final for final processing is called, the check for exceeding the temp array in _hmac_transform was moved before copying the block and incrementing dbn. dbn needs to be at least 1 at final processing time to let the hash engine apply the opad operation. To make the hash engine not apply the hmac algorithms final opad operation, for intermediate processing the dbn in the control register is set to a higher value than number of dbns are actually processed. Signed-off-by: Daniel Kestrel --- .../lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 91 +++++++++---- .../lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 122 ++++++++++++------ 2 files changed, 144 insertions(+), 69 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index 092b0581cc..ea808fdc5b 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -79,6 +79,7 @@ struct md5_hmac_ctx { u32 block[MD5_BLOCK_WORDS]; u64 byte_count; u32 dbn; + int started; unsigned int keylen; struct shash_desc *desc; u32 (*temp)[MD5_BLOCK_WORDS]; @@ -86,6 +87,8 @@ struct md5_hmac_ctx { extern int disable_deudma; +static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final); + /*! \fn static void md5_hmac_transform(struct crypto_tfm *tfm, u32 const *in) * \ingroup IFX_MD5_HMAC_FUNCTIONS * \brief save input block to context @@ -96,14 +99,14 @@ static void md5_hmac_transform(struct shash_desc *desc, u32 const *in) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm); - memcpy(&mctx->temp[mctx->dbn], in, 64); //dbn workaround - mctx->dbn += 1; - - if ( (mctx->dbn<<4) > MD5_HMAC_DBN_TEMP_SIZE ) + if ( ((mctx->dbn<<4)+1) > MD5_HMAC_DBN_TEMP_SIZE ) { - printk("MD5_HMAC_DBN_TEMP_SIZE exceeded\n"); + //printk("MD5_HMAC_DBN_TEMP_SIZE exceeded\n"); + md5_hmac_final_impl(desc, (u8 *)mctx->hash, false); } + memcpy(&mctx->temp[mctx->dbn], in, 64); //dbn workaround + mctx->dbn += 1; } /*! \fn int md5_hmac_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) @@ -184,6 +187,7 @@ static int md5_hmac_init(struct shash_desc *desc) mctx->dbn = 0; //dbn workaround + mctx->started = 0; return 0; } @@ -226,13 +230,25 @@ static int md5_hmac_update(struct shash_desc *desc, const u8 *data, unsigned int return 0; } -/*! \fn void md5_hmac_final(struct crypto_tfm *tfm, u8 *out) +/*! \fn static int md5_hmac_final(struct crypto_tfm *tfm, u8 *out) * \ingroup IFX_MD5_HMAC_FUNCTIONS - * \brief compute final md5 hmac value + * \brief call md5_hmac_final_impl with hash_final true * \param tfm linux crypto algo transform * \param out final md5 hmac output value */ static int md5_hmac_final(struct shash_desc *desc, u8 *out) +{ + return md5_hmac_final_impl(desc, out, true); +} + +/*! \fn static int md5_hmac_final_impl(struct crypto_tfm *tfm, u8 *out, bool hash_final) + * \ingroup IFX_MD5_HMAC_FUNCTIONS + * \brief compute final or intermediate md5 hmac value + * \param tfm linux crypto algo transform + * \param out final md5 hmac output value + * \param in finalize or intermediate processing +*/ +static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(desc->tfm); const unsigned int offset = mctx->byte_count & 0x3f; @@ -244,21 +260,22 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) int dbn; u32 *in = mctx->temp[0]; + if (hash_final) { + *p++ = 0x80; + if (padding < 0) { + memset(p, 0x00, padding + sizeof (u64)); + md5_hmac_transform(desc, mctx->block); + p = (char *)mctx->block; + padding = 56; + } + + memset(p, 0, padding); + mctx->block[14] = le32_to_cpu((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation + mctx->block[15] = 0x00000000; - *p++ = 0x80; - if (padding < 0) { - memset(p, 0x00, padding + sizeof (u64)); md5_hmac_transform(desc, mctx->block); - p = (char *)mctx->block; - padding = 56; } - memset(p, 0, padding); - mctx->block[14] = le32_to_cpu((mctx->byte_count + 64) << 3); // need to add 512 bit of the IPAD operation - mctx->block[15] = 0x00000000; - - md5_hmac_transform(desc, mctx->block); - CRTCL_SECT_HASH_START; MD5_HASH_INIT; @@ -266,7 +283,11 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) md5_hmac_setkey_hw(mctx->key, mctx->keylen); //printk("\ndbn = %d\n", mctx->dbn); - hashs->DBN = mctx->dbn; + if (hash_final) { + hashs->DBN = mctx->dbn; + } else { + hashs->DBN = mctx->dbn + 5; + } asm("sync"); *IFX_HASH_CON = 0x0703002D; //khs, go, init, ndc, endi, kyue, hmen, md5 @@ -276,6 +297,15 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) // this will not take long } + if (mctx->started) { + hashs->D1R = *((u32 *) mctx->hash + 0); + hashs->D2R = *((u32 *) mctx->hash + 1); + hashs->D3R = *((u32 *) mctx->hash + 2); + hashs->D4R = *((u32 *) mctx->hash + 3); + } else { + mctx->started = 1; + } + for (dbn = 0; dbn < mctx->dbn; dbn++) { for (i = 0; i < 16; i++) { @@ -295,9 +325,11 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) #if 1 - //wait for digest ready - while (! hashs->controlr.DGRY) { - // this will not take long + if (hash_final) { + //wait for digest ready + while (! hashs->controlr.DGRY) { + // this will not take long + } } #endif @@ -306,12 +338,15 @@ static int md5_hmac_final(struct shash_desc *desc, u8 *out) *((u32 *) out + 2) = hashs->D3R; *((u32 *) out + 3) = hashs->D4R; - /* reset the context after we finish with the hash */ - mctx->byte_count = 0; - memset(&mctx->hash[0], 0, sizeof(MD5_HASH_WORDS)); - memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS)); - memset(&mctx->temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); - + if (hash_final) { + /* reset the context after we finish with the hash */ + mctx->byte_count = 0; + memset(&mctx->hash[0], 0, sizeof(MD5_HASH_WORDS)); + memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS)); + memset(&mctx->temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); + } else { + mctx->dbn = 0; + } CRTCL_SECT_HASH_END; diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index a9e1d64d6f..72770a38e8 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -61,6 +61,7 @@ #define SHA1_DIGEST_SIZE 20 #define SHA1_BLOCK_WORDS 16 +#define SHA1_HASH_WORDS 5 #define SHA1_HMAC_BLOCK_SIZE 64 #define SHA1_HMAC_DBN_TEMP_SIZE 1024 // size in dword, needed for dbn workaround #define HASH_START IFX_HASH_CON @@ -79,8 +80,9 @@ struct sha1_hmac_ctx { u8 buffer[SHA1_HMAC_BLOCK_SIZE]; u8 key[SHA1_HMAC_MAX_KEYLEN]; - u32 state[5]; + u32 hash[SHA1_HASH_WORDS]; u32 dbn; + int started; u64 count; struct shash_desc *desc; @@ -89,6 +91,8 @@ struct sha1_hmac_ctx { extern int disable_deudma; +static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final); + /*! \fn static void sha1_hmac_transform(struct crypto_tfm *tfm, u32 const *in) * \ingroup IFX_SHA1_HMAC_FUNCTIONS * \brief save input block to context @@ -99,14 +103,15 @@ static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm); + if ( ((sctx->dbn<<4)+1) > SHA1_HMAC_DBN_TEMP_SIZE ) + { + //printk("SHA1_HMAC_DBN_TEMP_SIZE exceeded\n"); + sha1_hmac_final_impl(desc, (u8 *)sctx->hash, false); + } + memcpy(&sctx->temp[sctx->dbn], in, 64); //dbn workaround sctx->dbn += 1; - - if ( (sctx->dbn<<4) > SHA1_HMAC_DBN_TEMP_SIZE ) - { - printk("SHA1_HMAC_DBN_TEMP_SIZE exceeded\n"); - } - + return 0; } @@ -186,6 +191,7 @@ static int sha1_hmac_init(struct shash_desc *desc) //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); sctx->dbn = 0; //dbn workaround + sctx->started = 0; return 0; } @@ -223,13 +229,25 @@ static int sha1_hmac_update(struct shash_desc *desc, const u8 *data, return 0; } -/*! \fn static void sha1_hmac_final(struct crypto_tfm *tfm, u8 *out) +/*! \fn static int sha1_hmac_final(struct crypto_tfm *tfm, u8 *out) * \ingroup IFX_SHA1_HMAC_FUNCTIONS - * \brief ompute final sha1 hmac value + * \brief call sha1_hmac_final_impl with hash_final true * \param tfm linux crypto algo transform * \param out final sha1 hmac output value */ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) +{ + return sha1_hmac_final_impl(desc, out, true); +} + +/*! \fn static int sha1_hmac_final_impl(struct crypto_tfm *tfm, u8 *out, bool hash_final) + * \ingroup IFX_SHA1_HMAC_FUNCTIONS + * \brief ompute final or intermediate sha1 hmac value + * \param tfm linux crypto algo transform + * \param out final sha1 hmac output value + * \param in finalize or intermediate processing +*/ +static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(desc->tfm); u32 index, padlen; @@ -241,40 +259,47 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) int i = 0; int dbn; u32 *in = sctx->temp[0]; - - t = sctx->count + 512; // need to add 512 bit of the IPAD operation - bits[7] = 0xff & t; - t >>= 8; - bits[6] = 0xff & t; - t >>= 8; - bits[5] = 0xff & t; - t >>= 8; - bits[4] = 0xff & t; - t >>= 8; - bits[3] = 0xff & t; - t >>= 8; - bits[2] = 0xff & t; - t >>= 8; - bits[1] = 0xff & t; - t >>= 8; - bits[0] = 0xff & t; - /* Pad out to 56 mod 64 */ - index = (sctx->count >> 3) & 0x3f; - padlen = (index < 56) ? (56 - index) : ((64 + 56) - index); - sha1_hmac_update (desc, padding, padlen); + if (hash_final) { + t = sctx->count + 512; // need to add 512 bit of the IPAD operation + bits[7] = 0xff & t; + t >>= 8; + bits[6] = 0xff & t; + t >>= 8; + bits[5] = 0xff & t; + t >>= 8; + bits[4] = 0xff & t; + t >>= 8; + bits[3] = 0xff & t; + t >>= 8; + bits[2] = 0xff & t; + t >>= 8; + bits[1] = 0xff & t; + t >>= 8; + bits[0] = 0xff & t; - /* Append length */ - sha1_hmac_update (desc, bits, sizeof bits); + /* Pad out to 56 mod 64 */ + index = (sctx->count >> 3) & 0x3f; + padlen = (index < 56) ? (56 - index) : ((64 + 56) - index); + sha1_hmac_update (desc, padding, padlen); + + /* Append length */ + sha1_hmac_update (desc, bits, sizeof bits); + } CRTCL_SECT_HASH_START; SHA_HASH_INIT; sha1_hmac_setkey_hw(sctx->key, sctx->keylen); - - hashs->DBN = sctx->dbn; - + + if (hash_final) { + hashs->DBN = sctx->dbn; + } else { + hashs->DBN = sctx->dbn + 5; + } + asm("sync"); + //for vr9 change, ENDI = 1 *IFX_HASH_CON = HASH_CON_VALUE; @@ -283,6 +308,16 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) // this will not take long } + if (sctx->started) { + hashs->D1R = *((u32 *) sctx->hash + 0); + hashs->D2R = *((u32 *) sctx->hash + 1); + hashs->D3R = *((u32 *) sctx->hash + 2); + hashs->D4R = *((u32 *) sctx->hash + 3); + hashs->D5R = *((u32 *) sctx->hash + 4); + } else { + sctx->started = 1; + } + for (dbn = 0; dbn < sctx->dbn; dbn++) { for (i = 0; i < 16; i++) { @@ -302,9 +337,11 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) #if 1 - //wait for digest ready - while (! hashs->controlr.DGRY) { - // this will not take long + if (hash_final) { + //wait for digest ready + while (! hashs->controlr.DGRY) { + // this will not take long + } } #endif @@ -314,9 +351,12 @@ static int sha1_hmac_final(struct shash_desc *desc, u8 *out) *((u32 *) out + 3) = hashs->D4R; *((u32 *) out + 4) = hashs->D5R; - memset(&sctx->buffer[0], 0, SHA1_HMAC_BLOCK_SIZE); - sctx->count = 0; - + if (hash_final) { + memset(&sctx->buffer[0], 0, SHA1_HMAC_BLOCK_SIZE); + sctx->count = 0; + } else { + sctx->dbn = 0; + } //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); CRTCL_SECT_HASH_END; From 6ade9d1ddac660e7f06116359c0812adde86bf9e Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Tue, 15 Jun 2021 17:33:24 +0200 Subject: [PATCH 24/73] ltq-deu: remove compiler warning and shorten locked sections Removing hash pointer in _hmac_setkey since its not needed and causes a compiler warning. Make the spinlock control sections shorter and move initializations out of the control sections to free the spinlock faster for allowing other threads to use the hash engine. Minor improvements for indentation and removal of blanks and blank lines in some areas. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 6 ------ package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c | 3 --- package/kernel/lantiq/ltq-deu/src/ifxmips_des.c | 7 ------- package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c | 5 ++--- .../kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 15 +++------------ package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c | 4 ---- .../kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 10 ++-------- 7 files changed, 7 insertions(+), 43 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index a55766a4ac..e0adc18d62 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -343,7 +343,6 @@ int ctr_rfc3686_aes_set_key_skcipher (struct crypto_skcipher *tfm, const uint8_t return ctr_rfc3686_aes_set_key(crypto_skcipher_tfm(tfm), in_key, key_len); } - /*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) * \ingroup IFX_AES_FUNCTIONS * \brief main interface with deu hardware in DMA mode @@ -572,7 +571,6 @@ struct skcipher_alg ifxdeu_ecb_aes_alg = { .decrypt = ecb_aes_decrypt, }; - /*! \fn int ecb_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS * \brief CBC AES encrypt using linux crypto skcipher @@ -736,7 +734,6 @@ struct skcipher_alg ifxdeu_ofb_aes_alg = { .decrypt = ofb_aes_decrypt, }; - /*! \fn int cfb_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS * \brief CFB AES encrypt using linux crypto skcipher @@ -825,7 +822,6 @@ struct skcipher_alg ifxdeu_cfb_aes_alg = { .decrypt = cfb_aes_decrypt, }; - /*! \fn int ctr_basic_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS * \brief Counter mode AES encrypt using linux crypto skcipher @@ -913,7 +909,6 @@ struct skcipher_alg ifxdeu_ctr_basic_aes_alg = { .decrypt = ctr_basic_aes_decrypt, }; - /*! \fn int ctr_rfc3686_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS * \brief Counter mode AES (rfc3686) encrypt using linux crypto skcipher @@ -1021,7 +1016,6 @@ struct skcipher_alg ifxdeu_ctr_rfc3686_aes_alg = { .decrypt = ctr_rfc3686_aes_decrypt, }; - /*! \fn int ifxdeu_init_aes (void) * \ingroup IFX_AES_FUNCTIONS * \brief function to initialize AES driver diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c index 6afd783b6b..51f988fe43 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_arc4.c @@ -89,7 +89,6 @@ struct arc4_ctx { extern int disable_deudma; extern int disable_multiblock; - /*! \fn static void _deu_arc4 (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) \ingroup IFX_ARC4_FUNCTIONS \brief main interface to ARC4 hardware @@ -386,5 +385,3 @@ void ifxdeu_fini_arc4(void) } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c index a223e8ec38..8c12a26070 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c @@ -119,7 +119,6 @@ struct ifx_deu_des_ctx { extern int disable_multiblock; extern int disable_deudma; - /*! \fn int des_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) * \ingroup IFX_DES_FUNCTIONS * \brief sets DES key @@ -154,7 +153,6 @@ int des_setkey(struct crypto_tfm *tfm, const u8 *key, return err; } - /*! \fn int des_setkey_skcipher (struct crypto_skcipher *tfm, const uint8_t *in_key, unsigned int key_len) * \ingroup IFX_AES_FUNCTIONS * \brief sets the AES keys for skcipher @@ -168,7 +166,6 @@ int des_setkey_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigned return des_setkey(crypto_skcipher_tfm(tfm), in_key, key_len); } - /*! \fn void ifx_deu_des(void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, u32 nbytes, int encdec, int mode) * \ingroup IFX_DES_FUNCTIONS * \brief main interface to DES hardware @@ -287,8 +284,6 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, * \param mode operation mode such as ebc, cbc */ - - /*! \fn void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace) * \ingroup IFX_DES_FUNCTIONS * \brief sets DES hardware to ECB mode @@ -300,7 +295,6 @@ void ifx_deu_des (void *ctx_arg, u8 *out_arg, const u8 *in_arg, * \param encdec 1 for encrypt; 0 for decrypt * \param inplace not used */ - void ifx_deu_des_ecb (void *ctx, uint8_t *dst, const uint8_t *src, uint8_t *iv, size_t nbytes, int encdec, int inplace) { @@ -776,4 +770,3 @@ void ifxdeu_fini_des (void) crypto_unregister_skcipher (&ifxdeu_cbc_des3_ede_alg); } - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c index 376ff64d05..51782e0b6a 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5.c @@ -119,9 +119,9 @@ static void md5_transform(struct md5_ctx *mctx, u32 *hash, u32 const *in) *((u32 *) hash + 2) = hashs->D3R; *((u32 *) hash + 3) = hashs->D4R; - mctx->started = 1; - CRTCL_SECT_HASH_END; + + mctx->started = 1; } /*! \fn static inline void md5_transform_helper(struct md5_ctx *ctx) @@ -274,4 +274,3 @@ void ifxdeu_fini_md5 (void) crypto_unregister_shash(&ifxdeu_md5_alg); } - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index ea808fdc5b..fc3a5ea668 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -119,7 +119,6 @@ static void md5_hmac_transform(struct shash_desc *desc, u32 const *in) static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct md5_hmac_ctx *mctx = crypto_shash_ctx(tfm); - volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; int err; //printk("copying keys to context with length %d\n", keylen); @@ -145,14 +144,12 @@ static int md5_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int return 0; } - /*! \fn int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) * \ingroup IFX_MD5_HMAC_FUNCTIONS * \brief sets md5 hmac key into the hardware registers * \param key input key * \param keylen key length greater than 64 bytes IS NOT SUPPORTED */ - static int md5_hmac_setkey_hw(const u8 *key, unsigned int keylen) { volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; @@ -323,7 +320,6 @@ static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final in += 16; } - #if 1 if (hash_final) { //wait for digest ready @@ -338,6 +334,8 @@ static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final *((u32 *) out + 2) = hashs->D3R; *((u32 *) out + 3) = hashs->D4R; + CRTCL_SECT_HASH_END; + if (hash_final) { /* reset the context after we finish with the hash */ mctx->byte_count = 0; @@ -347,10 +345,7 @@ static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final } else { mctx->dbn = 0; } - CRTCL_SECT_HASH_END; - - - return 0; + return 0; } /*! \fn void md5_hmac_init_tfm(struct crypto_tfm *tfm) @@ -381,11 +376,9 @@ static void md5_hmac_exit_tfm(struct crypto_tfm *tfm) kfree(mctx->desc); } - /* * \brief MD5_HMAC function mappings */ - static struct shash_alg ifxdeu_md5_hmac_alg = { .digestsize = MD5_DIGEST_SIZE, .init = md5_hmac_init, @@ -435,5 +428,3 @@ void ifxdeu_fini_md5_hmac (void) { crypto_unregister_shash(&ifxdeu_md5_hmac_alg); } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c index a139f8d9d4..a20430c448 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1.c @@ -38,7 +38,6 @@ \brief ifx deu sha1 functions */ - /* Project header */ #include #include @@ -86,7 +85,6 @@ struct sha1_ctx { extern int disable_deudma; - /*! \fn static void sha1_transform1 (u32 *state, const u32 *in) * \ingroup IFX_SHA1_FUNCTIONS * \brief main interface to sha1 hardware @@ -283,5 +281,3 @@ void ifxdeu_fini_sha1 (void) } - - diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index 72770a38e8..9adf4d4710 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -38,7 +38,6 @@ \brief ifx sha1 hmac functions */ - /* Project header */ #include #include @@ -125,7 +124,6 @@ static int sha1_hmac_transform(struct shash_desc *desc, u32 const *in) static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) { struct sha1_hmac_ctx *sctx = crypto_shash_ctx(tfm); - volatile struct deu_hash_t *hash = (struct deu_hash_t *) HASH_START; int err; if (keylen > SHA1_HMAC_MAX_KEYLEN) { @@ -152,7 +150,6 @@ static int sha1_hmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned in return 0; } - /*! \fn int sha1_hmac_setkey_hw(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) * \ingroup IFX_SHA1_HMAC_FUNCTIONS * \brief sets sha1 hmac key into hw registers @@ -351,6 +348,8 @@ static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_fina *((u32 *) out + 3) = hashs->D4R; *((u32 *) out + 4) = hashs->D5R; + CRTCL_SECT_HASH_END; + if (hash_final) { memset(&sctx->buffer[0], 0, SHA1_HMAC_BLOCK_SIZE); sctx->count = 0; @@ -358,8 +357,6 @@ static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_fina sctx->dbn = 0; } //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); - CRTCL_SECT_HASH_END; - return 0; @@ -393,7 +390,6 @@ static void sha1_hmac_exit_tfm(struct crypto_tfm *tfm) kfree(sctx->desc); } - /* * \brief SHA1_HMAC function mappings */ @@ -418,7 +414,6 @@ static struct shash_alg ifxdeu_sha1_hmac_alg = { } }; - /*! \fn int ifxdeu_init_sha1_hmac (void) * \ingroup IFX_SHA1_HMAC_FUNCTIONS * \brief initialize sha1 hmac driver @@ -451,4 +446,3 @@ void ifxdeu_fini_sha1_hmac (void) } - From 006fee0dadd184aab8a1a18d629674f8f06e9eda Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Sun, 20 Jun 2021 21:33:22 +0200 Subject: [PATCH 25/73] ltq-deu: update initialisations for hmac algorithms The processing in the hmac algorithms depends on the status fields: count, dbn and started. Not all were initialised in the init method and after finishing the final method. Added missing fields to init method and call init method after finishing final. The memsets have the wrong size in the original driver and did not clear everything and are not necessary. Since no memset is done in the kernels generic implementation, memsets were removed. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c | 6 ++---- package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c index fc3a5ea668..109d27cbfb 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c @@ -185,6 +185,7 @@ static int md5_hmac_init(struct shash_desc *desc) mctx->dbn = 0; //dbn workaround mctx->started = 0; + mctx->byte_count = 0; return 0; } @@ -338,10 +339,7 @@ static int md5_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final if (hash_final) { /* reset the context after we finish with the hash */ - mctx->byte_count = 0; - memset(&mctx->hash[0], 0, sizeof(MD5_HASH_WORDS)); - memset(&mctx->block[0], 0, sizeof(MD5_BLOCK_WORDS)); - memset(&mctx->temp[0], 0, MD5_HMAC_DBN_TEMP_SIZE); + md5_hmac_init(desc); } else { mctx->dbn = 0; } diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c index 9adf4d4710..69504efe93 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c @@ -189,6 +189,7 @@ static int sha1_hmac_init(struct shash_desc *desc) //printk("debug ln: %d, fn: %s\n", __LINE__, __func__); sctx->dbn = 0; //dbn workaround sctx->started = 0; + sctx->count = 0; return 0; } @@ -351,8 +352,7 @@ static int sha1_hmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_fina CRTCL_SECT_HASH_END; if (hash_final) { - memset(&sctx->buffer[0], 0, SHA1_HMAC_BLOCK_SIZE); - sctx->count = 0; + sha1_hmac_init(desc); } else { sctx->dbn = 0; } From 43422deed3939073a2acc23fcc33e18ab3a11924 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Thu, 24 Jun 2021 17:41:33 +0200 Subject: [PATCH 26/73] ltq-deu: add aes_xts algorithm The lantiq AES hardware does not support the xts algorithm. Apart from the cipher text stealing (XTS), the AES XTS implementation is just an XOR with the IV, followed by AES ECB, followed by another XOR with the IV and as such can be also implemented by using the lantiq hardware's CBC AES implemention plus one additional XOR with the IV in the driver. The output IV by CBC AES is also not usable and the gfmul operation not supported by lantiq hardware. Both need to be done in the driver too in addition to the IV treatment which is the initial encryption by the other half of the input key and to set the IV to the IV registers for every block. In the generic kernel implementation, the block size for XTS is set to 16 bytes, although the algorithm is designed to process any size of input larger than 16 bytes. But since there is no way to indicate a minimum input length, the block size is used. This leads to certain issues when the skcipher walk functions are used, e.g. processing less than block size bytes is not supported by calling skcipher_walk_done. The walksize is 2 AES blocks because otherwise for splitted input or output data, less than blocksize is to be returned in some cases, which cannot be processed. Another issue was that depending on possible split of input/output data, just 16 bytes are returned while less than 16 bytes were remaining, while cipher text stealing requires 17 bytes or more for processing. For example, if the input is 60 bytes and the walk is 48, then processing 48 bytes leads to a return code of -EINVAL for skcipher_walk_done. Therefor the processed counter is used to figure out, when the actual cipher text stealing for the remaining bytes less than blocksize needs to be applied. Measured with cryptsetup benchmark, this XTS AES implementation is about 19% faster than the kernels XTS implementation that uses the hardware ECB AES (ca. 18.6 MiB/s vs. 15.8 MiB/s decryption 256b key). The implementation was tested with the kernels crypto testmgr against the kernels generic XTS AES implementation including extended tests. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 324 ++++++++++++++++++ 1 file changed, 324 insertions(+) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index e0adc18d62..1853e0e9de 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -57,6 +57,10 @@ #include #include #include +#include +#include +#include +#include #include #include "ifxmips_deu.h" @@ -115,7 +119,10 @@ extern void ifx_deu_aes (void *ctx_arg, uint8_t *out_arg, const uint8_t *in_arg, struct aes_ctx { int key_length; u32 buf[AES_MAX_KEY_SIZE]; + u32 tweakkey[AES_MAX_KEY_SIZE]; u8 nonce[CTR_RFC3686_NONCE_SIZE]; + u8 lastbuffer[4 * XTS_BLOCK_SIZE]; + int use_tweak; }; extern int disable_deudma; @@ -142,6 +149,7 @@ int aes_set_key (struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len) } ctx->key_length = key_len; + ctx->use_tweak = 0; DPRINTF(0, "ctx @%p, key_len %d, ctx->key_length %d\n", ctx, key_len, ctx->key_length); memcpy ((u8 *) (ctx->buf), in_key, key_len); @@ -190,6 +198,7 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, int i = 0; int byte_cnt = nbytes; + if (ctx->use_tweak) in_key = ctx->tweakkey; CRTCL_SECT_START; /* 128, 192 or 256 bit key length */ @@ -322,6 +331,7 @@ int ctr_rfc3686_aes_set_key (struct crypto_tfm *tfm, const uint8_t *in_key, unsi } ctx->key_length = key_len; + ctx->use_tweak = 0; memcpy ((u8 *) (ctx->buf), in_key, key_len); @@ -645,6 +655,312 @@ struct skcipher_alg ifxdeu_cbc_aes_alg = { .decrypt = cbc_aes_decrypt, }; +/*! \fn void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec) + * \ingroup IFX_AES_FUNCTIONS + * \brief main interface to AES hardware for XTS impl + * \param ctx_arg crypto algo context + * \param out_arg output bytestream + * \param in_arg input bytestream + * \param iv_arg initialization vector + * \param nbytes length of bytestream + * \param encdec 1 for encrypt; 0 for decrypt + * +*/ +void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, + u8 *iv_arg, size_t nbytes, int encdec) +{ + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; + struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; + u32 *in_key = ctx->buf; + unsigned long flag; + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + int key_len = ctx->key_length; + u8 oldiv[16]; + int i = 0; + int byte_cnt = nbytes; + + CRTCL_SECT_START; + + //prepare the key + /* 128, 192 or 256 bit key length */ + aes->controlr.K = key_len / 8 - 2; + if (key_len == 128 / 8) { + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + } + else if (key_len == 192 / 8) { + aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); + } + else if (key_len == 256 / 8) { + aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7)); + } + else { + printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len); + CRTCL_SECT_END; + return;// -EINVAL; + } + + /* let HW pre-process DEcryption key in any case (even if + ENcryption is used). Key Valid (KV) bit is then only + checked in decryption routine! */ + aes->controlr.PNK = 1; + + aes->controlr.E_D = !encdec; //encryption + aes->controlr.O = 1; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR - CBC mode for xts + + i = 0; + while (byte_cnt >= 16) { + + if (!encdec) { + if (((byte_cnt % 16) > 0) && (byte_cnt < (2*XTS_BLOCK_SIZE))) { + memcpy(oldiv, iv_arg, 16); + gf128mul_x_ble((le128 *)iv_arg, (le128 *)iv_arg); + } + u128_xor((u128 *)((u32 *) in_arg + (i * 4) + 0), (u128 *)((u32 *) in_arg + (i * 4) + 0), (u128 *)iv_arg); + } + + aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg); + aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1)); + aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2)); + aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3)); + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in_arg + (i * 4) + 3)); /* start crypto */ + + while (aes->controlr.BUS) { + // this will not take long + } + + *((volatile u32 *) out_arg + (i * 4) + 0) = aes->OD3R; + *((volatile u32 *) out_arg + (i * 4) + 1) = aes->OD2R; + *((volatile u32 *) out_arg + (i * 4) + 2) = aes->OD1R; + *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R; + + if (encdec) { + u128_xor((u128 *)((volatile u32 *) out_arg + (i * 4) + 0), (u128 *)((volatile u32 *) out_arg + (i * 4) + 0), (u128 *)iv_arg); + } + gf128mul_x_ble((le128 *)iv_arg, (le128 *)iv_arg); + i++; + byte_cnt -= 16; + } + + if (byte_cnt) { + u8 state[XTS_BLOCK_SIZE] = {0,}; + + if (!encdec) memcpy(iv_arg, oldiv, 16); + + aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg); + aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1)); + aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2)); + aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3)); + + memcpy(state, ((u32 *) in_arg + (i * 4) + 0), byte_cnt); + memcpy((state + byte_cnt), (out_arg + ((i - 1) * 16) + byte_cnt), (XTS_BLOCK_SIZE - byte_cnt)); + if (!encdec) { + u128_xor((u128 *)state, (u128 *)state, (u128 *)iv_arg); + } + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) state + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) state + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) state + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) state + 3)); /* start crypto */ + + memcpy(((u32 *) out_arg + (i * 4) + 0), ((u32 *) out_arg + ((i - 1) * 4) + 0), byte_cnt); + + while (aes->controlr.BUS) { + // this will not take long + } + + *((volatile u32 *) out_arg + ((i-1) * 4) + 0) = aes->OD3R; + *((volatile u32 *) out_arg + ((i-1) * 4) + 1) = aes->OD2R; + *((volatile u32 *) out_arg + ((i-1) * 4) + 2) = aes->OD1R; + *((volatile u32 *) out_arg + ((i-1) * 4) + 3) = aes->OD0R; + + if (encdec) { + u128_xor((u128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (u128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (u128 *)iv_arg); + } + } + + CRTCL_SECT_END; +} + +/*! \fn int xts_aes_encrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief XTS AES encrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int xts_aes_encrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int enc_bytes, nbytes, processed; + + err = skcipher_walk_virt(&walk, req, false); + + if (req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + + ctx->use_tweak = 1; + aes_encrypt(req->base.tfm, walk.iv, walk.iv); + ctx->use_tweak = 0; + processed = 0; + + while ((nbytes = walk.nbytes) && (walk.nbytes >= (XTS_BLOCK_SIZE * 2)) ) { + u8 *iv = walk.iv; + if (nbytes == walk.total) { + enc_bytes = nbytes; + } else { + enc_bytes = nbytes & ~(XTS_BLOCK_SIZE - 1); + if ((req->cryptlen - processed - enc_bytes) < (XTS_BLOCK_SIZE)) { + if (enc_bytes > (2 * XTS_BLOCK_SIZE)) { + enc_bytes -= XTS_BLOCK_SIZE; + } else { + break; + } + } + } + ifx_deu_aes_xts(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, enc_bytes, CRYPTO_DIR_ENCRYPT); + err = skcipher_walk_done(&walk, nbytes - enc_bytes); + processed += enc_bytes; + } + + if ((walk.nbytes)) { + u8 *iv = walk.iv; + nbytes = req->cryptlen - processed; + scatterwalk_map_and_copy(ctx->lastbuffer, req->src, (req->cryptlen - nbytes), nbytes, 0); + ifx_deu_aes_xts(ctx, ctx->lastbuffer, ctx->lastbuffer, + iv, nbytes, CRYPTO_DIR_ENCRYPT); + scatterwalk_map_and_copy(ctx->lastbuffer, req->dst, (req->cryptlen - nbytes), nbytes, 1); + skcipher_request_complete(req, 0); + } + + return err; +} + +/*! \fn int xts_aes_decrypt(struct skcipher_req *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief XTS AES decrypt using linux crypto skcipher + * \param req skcipher request + * \return err +*/ +int xts_aes_decrypt(struct skcipher_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + int err; + unsigned int dec_bytes, nbytes, processed; + + err = skcipher_walk_virt(&walk, req, false); + + if (req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + + ctx->use_tweak = 1; + aes_encrypt(req->base.tfm, walk.iv, walk.iv); + ctx->use_tweak = 0; + processed = 0; + + while ((nbytes = walk.nbytes) && (walk.nbytes >= (XTS_BLOCK_SIZE * 2))) { + u8 *iv = walk.iv; + if (nbytes == walk.total) { + dec_bytes = nbytes; + } else { + dec_bytes = nbytes & ~(XTS_BLOCK_SIZE - 1); + if ((req->cryptlen - processed - dec_bytes) < (XTS_BLOCK_SIZE)) { + if (dec_bytes > (2 * XTS_BLOCK_SIZE)) { + dec_bytes -= XTS_BLOCK_SIZE; + } else { + break; + } + } + } + ifx_deu_aes_xts(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, dec_bytes, CRYPTO_DIR_DECRYPT); + err = skcipher_walk_done(&walk, nbytes - dec_bytes); + processed += dec_bytes; + } + + if ((walk.nbytes)) { + u8 *iv = walk.iv; + nbytes = req->cryptlen - processed; + scatterwalk_map_and_copy(ctx->lastbuffer, req->src, (req->cryptlen - nbytes), nbytes, 0); + ifx_deu_aes_xts(ctx, ctx->lastbuffer, ctx->lastbuffer, + iv, nbytes, CRYPTO_DIR_DECRYPT); + scatterwalk_map_and_copy(ctx->lastbuffer, req->dst, (req->cryptlen - nbytes), nbytes, 1); + skcipher_request_complete(req, 0); + } + + return err; +} + +/*! \fn int xts_aes_set_key_skcipher (struct crypto_tfm *tfm, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for XTS + * \param tfm linux crypto algo transform + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int xts_aes_set_key_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(crypto_skcipher_tfm(tfm)); + unsigned int keylen = (key_len / 2); + + if (key_len % 2) return -EINVAL; + + if (keylen != 16 && keylen != 24 && keylen != 32) { + return -EINVAL; + } + + ctx->key_length = keylen; + ctx->use_tweak = 0; + DPRINTF(0, "ctx @%p, key_len %d, ctx->key_length %d\n", ctx, key_len, ctx->key_length); + memcpy ((u8 *) (ctx->buf), in_key, keylen); + memcpy ((u8 *) (ctx->tweakkey), in_key + keylen, keylen); + + return 0; +} + +/* + * \brief AES function mappings +*/ +struct skcipher_alg ifxdeu_xts_aes_alg = { + .base.cra_name = "xts(aes)", + .base.cra_driver_name = "ifxdeu-xts(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = XTS_BLOCK_SIZE, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_xts_aes_alg.base.cra_list), + .min_keysize = AES_MIN_KEY_SIZE * 2, + .max_keysize = AES_MAX_KEY_SIZE * 2, + .ivsize = XTS_BLOCK_SIZE, + .walksize = 2 * XTS_BLOCK_SIZE, + .setkey = xts_aes_set_key_skcipher, + .encrypt = xts_aes_encrypt, + .decrypt = xts_aes_decrypt, +}; /*! \fn int ofb_aes_encrypt(struct skcipher_req *req) * \ingroup IFX_AES_FUNCTIONS @@ -1036,6 +1352,9 @@ int ifxdeu_init_aes (void) if ((ret = crypto_register_skcipher(&ifxdeu_cbc_aes_alg))) goto cbc_aes_err; + if ((ret = crypto_register_skcipher(&ifxdeu_xts_aes_alg))) + goto xts_aes_err; + if ((ret = crypto_register_skcipher(&ifxdeu_ofb_aes_alg))) goto ofb_aes_err; @@ -1070,6 +1389,10 @@ ofb_aes_err: crypto_unregister_skcipher(&ifxdeu_ofb_aes_alg); printk (KERN_ERR "IFX ofb_aes initialization failed!\n"); return ret; +xts_aes_err: + crypto_unregister_skcipher(&ifxdeu_xts_aes_alg); + printk (KERN_ERR "IFX xts_aes initialization failed!\n"); + return ret; cbc_aes_err: crypto_unregister_skcipher(&ifxdeu_cbc_aes_alg); printk (KERN_ERR "IFX cbc_aes initialization failed!\n"); @@ -1093,6 +1416,7 @@ void ifxdeu_fini_aes (void) crypto_unregister_alg (&ifxdeu_aes_alg); crypto_unregister_skcipher (&ifxdeu_ecb_aes_alg); crypto_unregister_skcipher (&ifxdeu_cbc_aes_alg); + crypto_unregister_skcipher (&ifxdeu_xts_aes_alg); crypto_unregister_skcipher (&ifxdeu_ofb_aes_alg); crypto_unregister_skcipher (&ifxdeu_cfb_aes_alg); crypto_unregister_skcipher (&ifxdeu_ctr_basic_aes_alg); From f8e5c6080c2eb7397b03a4e6f64d3f6ea01b05d1 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Thu, 1 Jul 2021 11:38:05 +0200 Subject: [PATCH 27/73] ltq-deu: remove driver disablement for kernel 5.4 and above Remove the dependency on kernel 5.4 from the Makefile to allow the driver to compile with kernel 5.10 or kernel versions higher than 5.4. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kernel/lantiq/ltq-deu/Makefile b/package/kernel/lantiq/ltq-deu/Makefile index 8ac37f5d2d..9bfdf663ed 100644 --- a/package/kernel/lantiq/ltq-deu/Makefile +++ b/package/kernel/lantiq/ltq-deu/Makefile @@ -21,7 +21,7 @@ define KernelPackage/ltq-deu-template TITLE:=deu driver for $(1) URL:=http://www.lantiq.com/ VARIANT:=$(1) - DEPENDS:=@TARGET_lantiq_$(2) +kmod-crypto-manager +kmod-crypto-des @LINUX_5_4 + DEPENDS:=@TARGET_lantiq_$(2) +kmod-crypto-manager +kmod-crypto-des FILES:=$(PKG_BUILD_DIR)/ltq_deu_$(1).ko AUTOLOAD:=$(call AutoProbe,ltq_deu_$(1)) endef From 79efaa7f8fa5c4e2010c9948155838cfb5e72663 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Thu, 8 Jul 2021 07:59:41 +0200 Subject: [PATCH 28/73] ltq-deu: add shash cbcmac-aes algorithm to the driver Since commit 53b6783 hostapd is using the kernel api which includes the cbcmac-aes shash algorithm. The kernels implementation is a wrapper around the aes encryption algorithm, which encrypts block (16 bytes) by block. When the ltq-deu driver is present, it uses hardware aes, but every 16 byte encrypt requires setting the key. This is very inefficient and is a huge overhead. Since the cbcmac-aes is simply a hash that uses the cbc aes algorithm starting with an iv set to x'00' with an optional ecb aes encryption of a possible last incomplete block that is padded with the positional bytes of the last cbc encrypted block, this algorithm is now added to the driver. Most of the code is derived from md5-hmac and tailored for aes. Tested with the kernels crypto testmgr including extra tests against the kernels generic ccm module implementation. This patch also fixes the overallocation in the aes_ctx that is caused by using u32 instead of u8 for the aes keys. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 367 +++++++++++++++++- 1 file changed, 362 insertions(+), 5 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 1853e0e9de..8bfd434cd0 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -61,6 +61,7 @@ #include #include #include +#include #include #include "ifxmips_deu.h" @@ -88,10 +89,12 @@ spinlock_t aes_lock; #define AES_MIN_KEY_SIZE 16 #define AES_MAX_KEY_SIZE 32 #define AES_BLOCK_SIZE 16 +#define AES_BLOCK_WORDS 4 #define CTR_RFC3686_NONCE_SIZE 4 #define CTR_RFC3686_IV_SIZE 8 #define CTR_RFC3686_MIN_KEY_SIZE (AES_MIN_KEY_SIZE + CTR_RFC3686_NONCE_SIZE) #define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE) +#define AES_CBCMAC_DBN_TEMP_SIZE 128 #ifdef CRYPTO_DEBUG extern char debug_level; @@ -118,11 +121,17 @@ extern void ifx_deu_aes (void *ctx_arg, uint8_t *out_arg, const uint8_t *in_arg, struct aes_ctx { int key_length; - u32 buf[AES_MAX_KEY_SIZE]; - u32 tweakkey[AES_MAX_KEY_SIZE]; + u8 buf[AES_MAX_KEY_SIZE]; + u8 tweakkey[AES_MAX_KEY_SIZE]; u8 nonce[CTR_RFC3686_NONCE_SIZE]; u8 lastbuffer[4 * XTS_BLOCK_SIZE]; int use_tweak; + u32 byte_count; + u32 dbn; + int started; + u32 (*temp)[AES_BLOCK_WORDS]; + u8 block[AES_BLOCK_SIZE]; + u8 hash[AES_BLOCK_SIZE]; }; extern int disable_deudma; @@ -171,6 +180,62 @@ int aes_set_key_skcipher (struct crypto_skcipher *tfm, const u8 *in_key, unsigne } +/*! \fn void aes_set_key_skcipher (void *ctx_arg) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES key to the hardware, requires spinlock to be set by caller + * \param ctx_arg crypto algo context + * \return +*/ +void aes_set_key_hw (void *ctx_arg) +{ + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; + struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; + u8 *in_key = ctx->buf; + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + int key_len = ctx->key_length; + + if (ctx->use_tweak) in_key = ctx->tweakkey; + + /* 128, 192 or 256 bit key length */ + aes->controlr.K = key_len / 8 - 2; + if (key_len == 128 / 8) { + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + } + else if (key_len == 192 / 8) { + aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); + } + else if (key_len == 256 / 8) { + aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7)); + } + else { + printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len); + return; //-EINVAL; + } + + /* let HW pre-process DEcryption key in any case (even if + ENcryption is used). Key Valid (KV) bit is then only + checked in decryption routine! */ + aes->controlr.PNK = 1; + +} + + /*! \fn void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg, size_t nbytes, int encdec, int mode) * \ingroup IFX_AES_FUNCTIONS * \brief main interface to AES hardware @@ -190,7 +255,7 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; - u32 *in_key = ctx->buf; + u8 *in_key = ctx->buf; unsigned long flag; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ int key_len = ctx->key_length; @@ -672,7 +737,7 @@ void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; - u32 *in_key = ctx->buf; + u8 *in_key = ctx->buf; unsigned long flag; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ int key_len = ctx->key_length; @@ -1332,6 +1397,291 @@ struct skcipher_alg ifxdeu_ctr_rfc3686_aes_alg = { .decrypt = ctr_rfc3686_aes_decrypt, }; +static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final); + +/*! \fn static void aes_cbcmac_transform(struct shash_desc *desc, u8 const *in) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief save input block to context + * \param desc linux crypto shash descriptor + * \param in 16-byte block of input +*/ +static void aes_cbcmac_transform(struct shash_desc *desc, u8 const *in) +{ + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + + if ( ((mctx->dbn)+1) > AES_CBCMAC_DBN_TEMP_SIZE ) + { + //printk("aes_cbcmac_DBN_TEMP_SIZE exceeded\n"); + aes_cbcmac_final_impl(desc, (u8 *)mctx->hash, false); + } + + memcpy(&mctx->temp[mctx->dbn], in, 16); //dbn workaround + mctx->dbn += 1; +} + +/*! \fn int aes_cbcmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief sets cbcmac aes key + * \param tfm linux crypto shash transform + * \param key input key + * \param keylen key +*/ +static int aes_cbcmac_setkey(struct crypto_shash *tfm, const u8 *key, unsigned int keylen) +{ + return aes_set_key(crypto_shash_tfm(tfm), key, keylen); + + return 0; +} + +/*! \fn void aes_cbcmac_init(struct shash_desc *desc) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief initialize md5 hmac context + * \param desc linux crypto shash descriptor +*/ +static int aes_cbcmac_init(struct shash_desc *desc) +{ + + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + + mctx->dbn = 0; //dbn workaround + mctx->started = 0; + mctx->byte_count = 0; + memset(mctx->hash, 0, AES_BLOCK_SIZE); + + return 0; +} + +/*! \fn void aes_cbcmac_update(struct shash_desc *desc, const u8 *data, unsigned int len) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief on-the-fly cbcmac aes computation + * \param desc linux crypto shash descriptor + * \param data input data + * \param len size of input data +*/ +static int aes_cbcmac_update(struct shash_desc *desc, const u8 *data, unsigned int len) +{ + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x0f); + + mctx->byte_count += len; + + if (avail > len) { + memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), + data, len); + return 0; + } + + memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), + data, avail); + + aes_cbcmac_transform(desc, mctx->block); + data += avail; + len -= avail; + + while (len >= sizeof(mctx->block)) { + memcpy(mctx->block, data, sizeof(mctx->block)); + aes_cbcmac_transform(desc, mctx->block); + data += sizeof(mctx->block); + len -= sizeof(mctx->block); + } + + memcpy(mctx->block, data, len); + return 0; +} + +/*! \fn static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief compute final or intermediate md5 hmac value + * \param desc linux crypto shash descriptor + * \param out final cbcmac aes output value + * \param in finalize or intermediate processing +*/ +static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_final) +{ + struct aes_ctx *mctx = crypto_shash_ctx(desc->tfm); + const unsigned int offset = mctx->byte_count & 0x0f; + char *p = (char *)mctx->block + offset; + volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; + int key_len = mctx->key_length; + u8 *in_key = mctx->buf; + unsigned long flag; + int i = 0; + int dbn; + u32 *in = mctx->temp[0]; + + CRTCL_SECT_START; + + /* 128, 192 or 256 bit key length */ + aes->controlr.K = key_len / 8 - 2; + if (key_len == 128 / 8) { + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + } + else if (key_len == 192 / 8) { + aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); + } + else if (key_len == 256 / 8) { + aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); + aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); + aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); + aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); + aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); + aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); + aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6)); + aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7)); + } + else { + printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len); + CRTCL_SECT_END; + return -EINVAL; + } + + /* let HW pre-process DEcryption key in any case (even if + ENcryption is used). Key Valid (KV) bit is then only + checked in decryption routine! */ + aes->controlr.PNK = 1; + + + aes->controlr.E_D = !CRYPTO_DIR_ENCRYPT; //encryption + aes->controlr.O = 1; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR + + //aes->controlr.F = 128; //default; only for CFB and OFB modes; change only for customer-specific apps + + //printk("\ndbn = %d\n", mctx->dbn); + + if (mctx->started) { + aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) mctx->hash); + aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) mctx->hash + 1)); + aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) mctx->hash + 2)); + aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) mctx->hash + 3)); + } else { + mctx->started = 1; + aes->IV3R = 0; + aes->IV2R = 0; + aes->IV1R = 0; + aes->IV0R = 0; + } + + i = 0; + for (dbn = 0; dbn < mctx->dbn; dbn++) + { + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) in + (i * 4) + 3)); /* start crypto */ + + while (aes->controlr.BUS) { + // this will not take long + } + + in += 4; + } + + *((u32 *) mctx->hash) = DEU_ENDIAN_SWAP(aes->IV3R); + *((u32 *) mctx->hash + 1) = DEU_ENDIAN_SWAP(aes->IV2R); + *((u32 *) mctx->hash + 2) = DEU_ENDIAN_SWAP(aes->IV1R); + *((u32 *) mctx->hash + 3) = DEU_ENDIAN_SWAP(aes->IV0R); + + if (hash_final && offset) { + aes->controlr.O = 0; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR + crypto_xor(mctx->block, mctx->hash, offset); + + memcpy(p, mctx->hash + offset, (AES_BLOCK_SIZE - offset)); + + aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 0)); + aes->ID2R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 1)); + aes->ID1R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 2)); + aes->ID0R = INPUT_ENDIAN_SWAP(*((u32 *) mctx->block + 3)); /* start crypto */ + + while (aes->controlr.BUS) { + // this will not take long + } + + *((u32 *) mctx->hash) = DEU_ENDIAN_SWAP(aes->OD3R); + *((u32 *) mctx->hash + 1) = DEU_ENDIAN_SWAP(aes->OD2R); + *((u32 *) mctx->hash + 2) = DEU_ENDIAN_SWAP(aes->OD1R); + *((u32 *) mctx->hash + 3) = DEU_ENDIAN_SWAP(aes->OD0R); + } + + CRTCL_SECT_END; + + if (hash_final) { + memcpy(out, mctx->hash, AES_BLOCK_SIZE); + /* reset the context after we finish with the hash */ + aes_cbcmac_init(desc); + } else { + mctx->dbn = 0; + } + return 0; +} + +/*! \fn static int aes_cbcmac_final(struct crypto_tfm *tfm, u8 *out) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief call aes_cbcmac_final_impl with hash_final true + * \param tfm linux crypto algo transform + * \param out final md5 hmac output value +*/ +static int aes_cbcmac_final(struct shash_desc *desc, u8 *out) +{ + return aes_cbcmac_final_impl(desc, out, true); +} + +/*! \fn void aes_cbcmac_init_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief initialize pointers in aes_ctx + * \param tfm linux crypto shash transform +*/ +static int aes_cbcmac_init_tfm(struct crypto_tfm *tfm) +{ + struct aes_ctx *mctx = crypto_tfm_ctx(tfm); + mctx->temp = kzalloc(AES_BLOCK_SIZE * AES_CBCMAC_DBN_TEMP_SIZE, GFP_KERNEL); + if (IS_ERR(mctx->temp)) return PTR_ERR(mctx->temp); + + return 0; +} + +/*! \fn void aes_cbcmac_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief free pointers in aes_ctx + * \param tfm linux crypto shash transform +*/ +static void aes_cbcmac_exit_tfm(struct crypto_tfm *tfm) +{ + struct aes_ctx *mctx = crypto_tfm_ctx(tfm); + kfree(mctx->temp); +} + +/* + * \brief aes_cbcmac function mappings +*/ +static struct shash_alg ifxdeu_cbcmac_aes_alg = { + .digestsize = AES_BLOCK_SIZE, + .init = aes_cbcmac_init, + .update = aes_cbcmac_update, + .final = aes_cbcmac_final, + .setkey = aes_cbcmac_setkey, + .descsize = sizeof(struct aes_ctx), + .base = { + .cra_name = "cbcmac(aes)", + .cra_driver_name= "ifxdeu-cbcmac(aes)", + .cra_priority = 400, + .cra_ctxsize = sizeof(struct aes_ctx), + .cra_flags = CRYPTO_ALG_TYPE_HASH | CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = 1, + .cra_module = THIS_MODULE, + .cra_init = aes_cbcmac_init_tfm, + .cra_exit = aes_cbcmac_exit_tfm, + } +}; + + /*! \fn int ifxdeu_init_aes (void) * \ingroup IFX_AES_FUNCTIONS * \brief function to initialize AES driver @@ -1367,12 +1717,19 @@ int ifxdeu_init_aes (void) if ((ret = crypto_register_skcipher(&ifxdeu_ctr_rfc3686_aes_alg))) goto ctr_rfc3686_aes_err; + if ((ret = crypto_register_shash(&ifxdeu_cbcmac_aes_alg))) + goto cbcmac_aes_err; + CRTCL_SECT_INIT; printk (KERN_NOTICE "IFX DEU AES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)"); return ret; +cbcmac_aes_err: + crypto_unregister_shash(&ifxdeu_cbcmac_aes_alg); + printk (KERN_ERR "IFX cbcmac_aes initialization failed!\n"); + return ret; ctr_rfc3686_aes_err: crypto_unregister_skcipher(&ifxdeu_ctr_rfc3686_aes_alg); printk (KERN_ERR "IFX ctr_rfc3686_aes initialization failed!\n"); @@ -1421,5 +1778,5 @@ void ifxdeu_fini_aes (void) crypto_unregister_skcipher (&ifxdeu_cfb_aes_alg); crypto_unregister_skcipher (&ifxdeu_ctr_basic_aes_alg); crypto_unregister_skcipher (&ifxdeu_ctr_rfc3686_aes_alg); - + crypto_unregister_shash (&ifxdeu_cbcmac_aes_alg); } From a0d6b09c3646b219a56a68adf253bae0f3f29443 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Thu, 8 Jul 2021 08:06:57 +0200 Subject: [PATCH 29/73] ltq-deu: remove redundant code for setting the key in aes After adding xts and cbcmac the aes algorithm source had three sections for setting the aes key to the hardware which are identical. Method aes_set_key_hw was created which is now called from within the spinlock secured control sections in methods ifx_deu_aes, ifx_deu_aes_xts and aes_cbcmac_final_impl and reduces the size of ifxmips_aes.c. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 124 +----------------- 1 file changed, 4 insertions(+), 120 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 8bfd434cd0..eefdd1a959 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -192,8 +192,8 @@ void aes_set_key_hw (void *ctx_arg) volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; u8 *in_key = ctx->buf; - /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ int key_len = ctx->key_length; + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ if (ctx->use_tweak) in_key = ctx->tweakkey; @@ -255,54 +255,14 @@ void ifx_deu_aes (void *ctx_arg, u8 *out_arg, const u8 *in_arg, /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; - u8 *in_key = ctx->buf; unsigned long flag; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - int key_len = ctx->key_length; - int i = 0; int byte_cnt = nbytes; - if (ctx->use_tweak) in_key = ctx->tweakkey; - CRTCL_SECT_START; - /* 128, 192 or 256 bit key length */ - aes->controlr.K = key_len / 8 - 2; - if (key_len == 128 / 8) { - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - } - else if (key_len == 192 / 8) { - aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); - } - else if (key_len == 256 / 8) { - aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7)); - } - else { - printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len); - CRTCL_SECT_END; - return;// -EINVAL; - } - - /* let HW pre-process DEcryption key in any case (even if - ENcryption is used). Key Valid (KV) bit is then only - checked in decryption routine! */ - aes->controlr.PNK = 1; + aes_set_key_hw (ctx_arg); aes->controlr.E_D = !encdec; //encryption aes->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR @@ -737,53 +697,15 @@ void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg; - u8 *in_key = ctx->buf; unsigned long flag; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - int key_len = ctx->key_length; u8 oldiv[16]; int i = 0; int byte_cnt = nbytes; CRTCL_SECT_START; - //prepare the key - /* 128, 192 or 256 bit key length */ - aes->controlr.K = key_len / 8 - 2; - if (key_len == 128 / 8) { - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - } - else if (key_len == 192 / 8) { - aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); - } - else if (key_len == 256 / 8) { - aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7)); - } - else { - printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len); - CRTCL_SECT_END; - return;// -EINVAL; - } - - /* let HW pre-process DEcryption key in any case (even if - ENcryption is used). Key Valid (KV) bit is then only - checked in decryption routine! */ - aes->controlr.PNK = 1; + aes_set_key_hw (ctx_arg); aes->controlr.E_D = !encdec; //encryption aes->controlr.O = 1; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR - CBC mode for xts @@ -1502,8 +1424,6 @@ static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_fin const unsigned int offset = mctx->byte_count & 0x0f; char *p = (char *)mctx->block + offset; volatile struct aes_t *aes = (volatile struct aes_t *) AES_START; - int key_len = mctx->key_length; - u8 *in_key = mctx->buf; unsigned long flag; int i = 0; int dbn; @@ -1511,43 +1431,7 @@ static int aes_cbcmac_final_impl(struct shash_desc *desc, u8 *out, bool hash_fin CRTCL_SECT_START; - /* 128, 192 or 256 bit key length */ - aes->controlr.K = key_len / 8 - 2; - if (key_len == 128 / 8) { - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - } - else if (key_len == 192 / 8) { - aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); - } - else if (key_len == 256 / 8) { - aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0)); - aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1)); - aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2)); - aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3)); - aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4)); - aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5)); - aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6)); - aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7)); - } - else { - printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len); - CRTCL_SECT_END; - return -EINVAL; - } - - /* let HW pre-process DEcryption key in any case (even if - ENcryption is used). Key Valid (KV) bit is then only - checked in decryption routine! */ - aes->controlr.PNK = 1; - + aes_set_key_hw (mctx); aes->controlr.E_D = !CRYPTO_DIR_ENCRYPT; //encryption aes->controlr.O = 1; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR From 973e28f248d5a56a309daa46800a60a5d7cf694d Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Thu, 8 Jul 2021 08:14:34 +0200 Subject: [PATCH 30/73] ltq-deu: change PKG_RELEASE to AUTORELEASE As per suggestion by adschm, PKG_RELEASE is set to AUTORELEASE. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kernel/lantiq/ltq-deu/Makefile b/package/kernel/lantiq/ltq-deu/Makefile index 9bfdf663ed..32a3b5c1b0 100644 --- a/package/kernel/lantiq/ltq-deu/Makefile +++ b/package/kernel/lantiq/ltq-deu/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-deu -PKG_RELEASE:=1 +PKG_RELEASE:=$(AUTORELEASE) PKG_MAINTAINER:=John Crispin PKG_LICENSE:=GPL-2.0+ From fc4d88cf73bc8dbd715524fd0a10a7f3a4c47775 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Tue, 4 Jan 2022 21:56:09 +0100 Subject: [PATCH 31/73] ltq-deu: add aes_gcm algorithm The lantiq AES hardware does not support the gcm algorithm. But it can be implemented in the driver as a combination of the aes_ctr algorithm and the xor plus gfmul operations for the hashing. Due to the wrapping of the several algorithms and the inefficient 16 byte block by 16 byte block invokation in the kernel implementations, this driver is about 3 times faster for the larger block sizes. Signed-off-by: Daniel Kestrel --- .../kernel/lantiq/ltq-deu/src/ifxmips_aes.c | 313 ++++++++++++++++++ 1 file changed, 313 insertions(+) diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index eefdd1a959..c0861a503f 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -58,9 +58,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -132,6 +134,7 @@ struct aes_ctx { u32 (*temp)[AES_BLOCK_WORDS]; u8 block[AES_BLOCK_SIZE]; u8 hash[AES_BLOCK_SIZE]; + struct gf128mul_4k *gf128; }; extern int disable_deudma; @@ -1565,6 +1568,308 @@ static struct shash_alg ifxdeu_cbcmac_aes_alg = { } }; +/*! \fn int aes_set_key_aead (struct crypto_aead *aead, const uint8_t *in_key, unsigned int key_len) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for aead gcm + * \param aead linux crypto aead + * \param in_key input key + * \param key_len key lengths of 16, 24 and 32 bytes supported + * \return -EINVAL - bad key length, 0 - SUCCESS +*/ +int aes_set_key_aead (struct crypto_aead *aead, const u8 *in_key, unsigned int key_len) +{ + struct aes_ctx *ctx = crypto_aead_ctx(aead); + int err; + + err = aes_set_key(&aead->base, in_key, key_len); + if (err) return err; + + memset(ctx->block, 0, sizeof(ctx->block)); + memset(ctx->lastbuffer, 0, AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, ctx->block, ctx->block, + ctx->lastbuffer, AES_BLOCK_SIZE, CRYPTO_DIR_ENCRYPT, 0); + if (ctx->gf128) gf128mul_free_4k(ctx->gf128); + ctx->gf128 = gf128mul_init_4k_lle((be128 *)ctx->block); + + return err; +} + +/*! \fn int gcm_aes_setauthsize (struct crypto_aead *aead, unsigned int authsize) + * \ingroup IFX_AES_FUNCTIONS + * \brief sets the AES keys for aead gcm + * \param aead linux crypto aead + * \param in_key input authsize + * \return -EINVAL - bad authsize length, 0 - SUCCESS +*/ +int gcm_aes_setauthsize (struct crypto_aead *aead, unsigned int authsize) +{ + return crypto_gcm_check_authsize(authsize); +} + +/*! \fn int gcm_aes_encrypt(struct aead_request *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief GCM AES encrypt using linux crypto aead + * \param req aead request + * \return err +*/ +int gcm_aes_encrypt(struct aead_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + struct skcipher_request request; + int err; + unsigned int enc_bytes, nbytes; + be128 lengths; + u8 iv[AES_BLOCK_SIZE]; + + lengths.a = cpu_to_be64(req->assoclen * 8); + lengths.b = cpu_to_be64(req->cryptlen * 8); + + memset(ctx->hash, 0, sizeof(ctx->hash)); + memset(ctx->block, 0, sizeof(ctx->block)); + memcpy(iv, req->iv, GCM_AES_IV_SIZE); + *(__be32 *)((void *)iv + GCM_AES_IV_SIZE) = cpu_to_be32(1); + ifx_deu_aes_ctr(ctx, ctx->block, ctx->block, + iv, 16, CRYPTO_DIR_ENCRYPT, 0); + + request.cryptlen = req->cryptlen + req->assoclen; + request.src = req->src; + request.dst = req->dst; + request.base = req->base; + + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = AES_BLOCK_SIZE; + + if (req->assoclen && (req->assoclen < AES_BLOCK_SIZE)) + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = req->assoclen; + + err = skcipher_walk_virt(&walk, &request, false); + + //process assoc data if available + if (req->assoclen > 0) { + unsigned int assoc_remain, ghashlen; + + assoc_remain = req->assoclen; + ghashlen = min(req->assoclen, walk.nbytes); + while ((nbytes = enc_bytes = ghashlen) && (ghashlen >= AES_BLOCK_SIZE)) { + u8 *temp; + if (nbytes > req->assoclen) nbytes = enc_bytes = req->assoclen; + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, enc_bytes); + assoc_remain -= enc_bytes; + temp = walk.dst.virt.addr; + while (enc_bytes > 0) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + enc_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + if (assoc_remain < AES_BLOCK_SIZE) walk.stride = assoc_remain; + if (assoc_remain == 0) walk.stride = AES_BLOCK_SIZE; + enc_bytes = nbytes - (nbytes % AES_BLOCK_SIZE); + err = skcipher_walk_done(&walk, (walk.nbytes - enc_bytes)); + ghashlen = min(assoc_remain, walk.nbytes); + } + + if ((enc_bytes = ghashlen)) { + memcpy(ctx->lastbuffer, walk.src.virt.addr, enc_bytes); + memset(ctx->lastbuffer + enc_bytes, 0, (AES_BLOCK_SIZE - enc_bytes)); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, ghashlen); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + walk.stride = AES_BLOCK_SIZE; + err = skcipher_walk_done(&walk, (walk.nbytes - ghashlen)); + } + } + + //crypt and hash + while ((nbytes = enc_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + u8 *temp; + enc_bytes -= (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + temp = walk.dst.virt.addr; + while (enc_bytes) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + enc_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + err = skcipher_walk_done(&walk, nbytes); + } + + /* crypt and hash remaining bytes < AES_BLOCK_SIZE */ + if ((enc_bytes = walk.nbytes)) { + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); + memcpy(ctx->lastbuffer, walk.dst.virt.addr, enc_bytes); + memset(ctx->lastbuffer + enc_bytes, 0, (AES_BLOCK_SIZE - enc_bytes)); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + err = skcipher_walk_done(&walk, 0); + } + + //finalize and copy hash + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)&lengths); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->block); + scatterwalk_map_and_copy(ctx->hash, req->dst, req->cryptlen + req->assoclen, crypto_aead_authsize(crypto_aead_reqtfm(req)), 1); + + aead_request_complete(req, 0); + + return err; +} + +/*! \fn int gcm_aes_decrypt(struct aead_request *req) + * \ingroup IFX_AES_FUNCTIONS + * \brief GCM AES decrypt using linux crypto aead + * \param req aead request + * \return err +*/ +int gcm_aes_decrypt(struct aead_request *req) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(req->base.tfm); + struct skcipher_walk walk; + struct skcipher_request request; + int err; + unsigned int dec_bytes, nbytes, authsize; + be128 lengths; + u8 iv[AES_BLOCK_SIZE]; + + authsize = crypto_aead_authsize(crypto_aead_reqtfm(req)); + + lengths.a = cpu_to_be64(req->assoclen * 8); + lengths.b = cpu_to_be64((req->cryptlen - authsize) * 8); + + memset(ctx->hash, 0, sizeof(ctx->hash)); + memset(ctx->block, 0, sizeof(ctx->block)); + memcpy(iv, req->iv, GCM_AES_IV_SIZE); + *(__be32 *)((void *)iv + GCM_AES_IV_SIZE) = cpu_to_be32(1); + ifx_deu_aes_ctr(ctx, ctx->block, ctx->block, + iv, 16, CRYPTO_DIR_ENCRYPT, 0); + + request.cryptlen = req->cryptlen + req->assoclen - authsize; + request.src = req->src; + request.dst = req->dst; + request.base = req->base; + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = AES_BLOCK_SIZE; + + if (req->assoclen && (req->assoclen < AES_BLOCK_SIZE)) + crypto_skcipher_alg(crypto_skcipher_reqtfm(&request))->walksize = req->assoclen; + + err = skcipher_walk_virt(&walk, &request, false); + + //process assoc data if available + if (req->assoclen > 0) { + unsigned int assoc_remain, ghashlen; + + assoc_remain = req->assoclen; + ghashlen = min(req->assoclen, walk.nbytes); + while ((nbytes = dec_bytes = ghashlen) && (ghashlen >= AES_BLOCK_SIZE)) { + u8 *temp; + if (nbytes > req->assoclen) nbytes = dec_bytes = req->assoclen; + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, dec_bytes); + assoc_remain -= dec_bytes; + temp = walk.dst.virt.addr; + while (dec_bytes > 0) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + dec_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + if (assoc_remain < AES_BLOCK_SIZE) walk.stride = assoc_remain; + if (assoc_remain == 0) walk.stride = AES_BLOCK_SIZE; + dec_bytes = nbytes - (nbytes % AES_BLOCK_SIZE); + err = skcipher_walk_done(&walk, (walk.nbytes - dec_bytes)); + ghashlen = min(assoc_remain, walk.nbytes); + } + + if ((dec_bytes = ghashlen)) { + memcpy(ctx->lastbuffer, walk.src.virt.addr, dec_bytes); + memset(ctx->lastbuffer + dec_bytes, 0, (AES_BLOCK_SIZE - dec_bytes)); + memcpy(walk.dst.virt.addr, walk.src.virt.addr, ghashlen); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + walk.stride = AES_BLOCK_SIZE; + err = skcipher_walk_done(&walk, (walk.nbytes - ghashlen)); + } + } + + //crypt and hash + while ((nbytes = dec_bytes = walk.nbytes) && (walk.nbytes >= AES_BLOCK_SIZE)) { + u8 *temp; + dec_bytes -= (nbytes % AES_BLOCK_SIZE); + temp = walk.src.virt.addr; + while (dec_bytes) { + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + dec_bytes -= AES_BLOCK_SIZE; + temp += 16; + } + dec_bytes = nbytes - (nbytes % AES_BLOCK_SIZE); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); + nbytes &= AES_BLOCK_SIZE - 1; + err = skcipher_walk_done(&walk, nbytes); + } + + /* crypt and hash remaining bytes < AES_BLOCK_SIZE */ + if ((dec_bytes = walk.nbytes)) { + memcpy(ctx->lastbuffer, walk.src.virt.addr, dec_bytes); + memset(ctx->lastbuffer + dec_bytes, 0, (AES_BLOCK_SIZE - dec_bytes)); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, + iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); + err = skcipher_walk_done(&walk, 0); + } + + //finalize and copy hash + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)&lengths); + gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); + u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->block); + + scatterwalk_map_and_copy(ctx->lastbuffer, req->src, req->cryptlen + req->assoclen - authsize, authsize, 0); + err = crypto_memneq(ctx->lastbuffer, ctx->hash, authsize) ? -EBADMSG : 0; + + aead_request_complete(req, 0); + + return err; +} + +/*! \fn void aes_gcm_exit_tfm(struct crypto_tfm *tfm) + * \ingroup IFX_aes_cbcmac_FUNCTIONS + * \brief free pointers in aes_ctx + * \param tfm linux crypto shash transform +*/ +static void aes_gcm_exit_tfm(struct crypto_tfm *tfm) +{ + struct aes_ctx *ctx = crypto_tfm_ctx(tfm); + if (ctx->gf128) gf128mul_free_4k(ctx->gf128); +} + +/* + * \brief AES function mappings +*/ +struct aead_alg ifxdeu_gcm_aes_alg = { + .base.cra_name = "gcm(aes)", + .base.cra_driver_name = "ifxdeu-gcm(aes)", + .base.cra_priority = 400, + .base.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER | CRYPTO_ALG_KERN_DRIVER_ONLY, + .base.cra_blocksize = 1, + .base.cra_ctxsize = sizeof(struct aes_ctx), + .base.cra_module = THIS_MODULE, + .base.cra_list = LIST_HEAD_INIT(ifxdeu_gcm_aes_alg.base.cra_list), + .base.cra_exit = aes_gcm_exit_tfm, + .ivsize = GCM_AES_IV_SIZE, + .maxauthsize = AES_BLOCK_SIZE, + .chunksize = AES_BLOCK_SIZE, + .setkey = aes_set_key_aead, + .encrypt = gcm_aes_encrypt, + .decrypt = gcm_aes_decrypt, + .setauthsize = gcm_aes_setauthsize, +}; /*! \fn int ifxdeu_init_aes (void) * \ingroup IFX_AES_FUNCTIONS @@ -1604,12 +1909,19 @@ int ifxdeu_init_aes (void) if ((ret = crypto_register_shash(&ifxdeu_cbcmac_aes_alg))) goto cbcmac_aes_err; + if ((ret = crypto_register_aead(&ifxdeu_gcm_aes_alg))) + goto gcm_aes_err; + CRTCL_SECT_INIT; printk (KERN_NOTICE "IFX DEU AES initialized%s%s.\n", disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)"); return ret; +gcm_aes_err: + crypto_unregister_aead(&ifxdeu_gcm_aes_alg); + printk (KERN_ERR "IFX gcm_aes initialization failed!\n"); + return ret; cbcmac_aes_err: crypto_unregister_shash(&ifxdeu_cbcmac_aes_alg); printk (KERN_ERR "IFX cbcmac_aes initialization failed!\n"); @@ -1663,4 +1975,5 @@ void ifxdeu_fini_aes (void) crypto_unregister_skcipher (&ifxdeu_ctr_basic_aes_alg); crypto_unregister_skcipher (&ifxdeu_ctr_rfc3686_aes_alg); crypto_unregister_shash (&ifxdeu_cbcmac_aes_alg); + crypto_unregister_aead (&ifxdeu_gcm_aes_alg); } From b61d756b6c8fedb7094ec29198dd3dbba49a1807 Mon Sep 17 00:00:00 2001 From: Daniel Kestrel Date: Tue, 4 Jan 2022 22:22:51 +0100 Subject: [PATCH 32/73] ltq-deu: disable arc4 algorithm ARC4 was used for WEP, which is not secure anymore. Therefor it is disabled in the driver, but the code is not removed for now. Signed-off-by: Daniel Kestrel --- package/kernel/lantiq/ltq-deu/src/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package/kernel/lantiq/ltq-deu/src/Makefile b/package/kernel/lantiq/ltq-deu/src/Makefile index 93ae7ca922..13f3dccaee 100644 --- a/package/kernel/lantiq/ltq-deu/src/Makefile +++ b/package/kernel/lantiq/ltq-deu/src/Makefile @@ -7,18 +7,18 @@ endif ifeq ($(BUILD_VARIANT),ar9) CFLAGS_MODULE = -DCONFIG_AR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \ - -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \ + -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 \ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC obj-m = ltq_deu_ar9.o - ltq_deu_ar9-objs = ifxmips_deu.o ifxmips_deu_ar9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \ + ltq_deu_ar9-objs = ifxmips_deu.o ifxmips_deu_ar9.o ifxmips_des.o ifxmips_aes.o \ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o endif ifeq ($(BUILD_VARIANT),vr9) CFLAGS_MODULE = -DCONFIG_VR9 -DCONFIG_CRYPTO_DEV_DEU -DCONFIG_CRYPTO_DEV_SPEED_TEST -DCONFIG_CRYPTO_DEV_DES \ - -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 -DCONFIG_CRYPTO_DEV_ARC4 \ + -DCONFIG_CRYPTO_DEV_AES -DCONFIG_CRYPTO_DEV_SHA1 -DCONFIG_CRYPTO_DEV_MD5 \ -DCONFIG_CRYPTO_DEV_SHA1_HMAC -DCONFIG_CRYPTO_DEV_MD5_HMAC obj-m = ltq_deu_vr9.o - ltq_deu_vr9-objs = ifxmips_deu.o ifxmips_deu_vr9.o ifxmips_des.o ifxmips_aes.o ifxmips_arc4.o \ + ltq_deu_vr9-objs = ifxmips_deu.o ifxmips_deu_vr9.o ifxmips_des.o ifxmips_aes.o \ ifxmips_sha1.o ifxmips_md5.o ifxmips_sha1_hmac.o ifxmips_md5_hmac.o endif From 3d4acc34bb58131804c018271ada6a535d7405e2 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Sat, 6 Nov 2021 15:24:34 +0200 Subject: [PATCH 33/73] firewall4: drop kmod-ipt-nat from CONFLICTS The limitation of not being able to use iptables and nft nat at the same time exists only in kernels before 4.18. Signed-off-by: Stijn Tintel Reviewed-by: Jo-Philipp Wich --- package/network/config/firewall4/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index a4f63a91ee..57af47062f 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -22,7 +22,7 @@ define Package/firewall4 CATEGORY:=Base system TITLE:=OpenWrt 4th gen firewall DEPENDS:=+ucode +ucode-mod-fs +ucode-mod-uci +ucode-mod-ubus +kmod-nft-core +kmod-nft-fib +kmod-nft-nat +kmod-nft-nat6 +nftables-json - CONFLICTS:=firewall kmod-ipt-nat + CONFLICTS:=firewall endef define Package/firewall4/description From ae60af8572d845c0867d70cca6772eb16a0af642 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Fri, 3 Dec 2021 17:45:28 +0200 Subject: [PATCH 34/73] firewall4: order DEPENDS alphabetically Add some line breaks while at at, to improve readability. Signed-off-by: Stijn Tintel Reviewed-by: Jo-Philipp Wich --- package/network/config/firewall4/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index 57af47062f..21b29793c3 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -21,7 +21,11 @@ define Package/firewall4 SECTION:=net CATEGORY:=Base system TITLE:=OpenWrt 4th gen firewall - DEPENDS:=+ucode +ucode-mod-fs +ucode-mod-uci +ucode-mod-ubus +kmod-nft-core +kmod-nft-fib +kmod-nft-nat +kmod-nft-nat6 +nftables-json + DEPENDS:=+ \ + +kmod-nft-core +kmod-nft-fib \ + +kmod-nft-nat +kmod-nft-nat6 \ + +nftables-json \ + +ucode +ucode-mod-fs +ucode-mod-ubus +ucode-mod-uci CONFLICTS:=firewall endef From 3ec25a657d527427d401562697d6be9b8f375132 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Sat, 6 Nov 2021 15:42:30 +0200 Subject: [PATCH 35/73] firewall4: bump to git HEAD 4ead2a6 treewide: move executables to /sbin 9ebc2f4 fw4.uc: filter duplicates in fw4.set 85b74f3 treewide: support flow offloading be3b4e6 treewide: support hardware flow offloading 38889b7 treewide: support set timeout 31c7550 fw4.uc: do not skip defaults with invalid option 334a127 fw4.uc: introduce DEPRECATED flag 7a0d38f fw4.uc: add _name as deprecated option 5e7ad3b fw4.uc: don't fail on unknown options be5f4e3 fw4.uc: allow use of cidr in ipsets Signed-off-by: Stijn Tintel Reviewed-by: Jo-Philipp Wich --- package/network/config/firewall4/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index 21b29793c3..c95a15a839 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -9,9 +9,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firewall4.git -PKG_SOURCE_DATE:=2021-10-25 -PKG_SOURCE_VERSION:=eb0a3ee812d48f1faecbf6258c293e475b4016a0 -PKG_MIRROR_HASH:=46b5bdea13a285dbd1b3432fe8cfd8cb98a2797b86b176d7762e0987ec2f230c +PKG_SOURCE_DATE:=2022-01-06 +PKG_SOURCE_VERSION:=be5f4e33c6388935651e6a87c4e5348ade0bd714 +PKG_MIRROR_HASH:=771ca10763754772eb3c420612a109bf7bb1eab240835c74c8e87e198b2beb95 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC @@ -22,7 +22,7 @@ define Package/firewall4 CATEGORY:=Base system TITLE:=OpenWrt 4th gen firewall DEPENDS:=+ \ - +kmod-nft-core +kmod-nft-fib \ + +kmod-nft-core +kmod-nft-fib +kmod-nft-offload \ +kmod-nft-nat +kmod-nft-nat6 \ +nftables-json \ +ucode +ucode-mod-fs +ucode-mod-ubus +ucode-mod-uci From 53b87a7a28525a634577f9215e2bb9170cf14dfb Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Tue, 19 Oct 2021 00:42:02 +0200 Subject: [PATCH 36/73] firewall/firewall4: provide uci-firewall Provide uci-firewall via PROVIDES in both firewall and firewall4. This will allow us to change the dependency of luci-app-firewall to uci-firewall, making it possible to use it with either implementation. Move CONFLICTS from firewall4 to firewall, to solve this recursive dependency problem: tmp/.config-package.in:307:error: recursive dependency detected! tmp/.config-package.in:307: symbol PACKAGE_firewall is selected by PACKAGE_firewall4 tmp/.config-package.in:328: symbol PACKAGE_firewall4 depends on PACKAGE_firewall Signed-off-by: Stijn Tintel Reviewed-by: Jo-Philipp Wich --- package/network/config/firewall/Makefile | 4 +++- package/network/config/firewall4/Makefile | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package/network/config/firewall/Makefile b/package/network/config/firewall/Makefile index 378a912f9d..815e33604c 100644 --- a/package/network/config/firewall/Makefile +++ b/package/network/config/firewall/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=firewall -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firewall3.git @@ -29,6 +29,8 @@ define Package/firewall CATEGORY:=Base system TITLE:=OpenWrt C Firewall DEPENDS:=+libubox +libubus +libuci +libip4tc +IPV6:libip6tc +libxtables +kmod-ipt-core +kmod-ipt-conntrack +IPV6:kmod-nf-conntrack6 +kmod-ipt-nat + PROVIDES:=uci-firewall + CONFLICTS:=firewall4 endef define Package/firewall/description diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index c95a15a839..d7f8334dfc 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -26,7 +26,7 @@ define Package/firewall4 +kmod-nft-nat +kmod-nft-nat6 \ +nftables-json \ +ucode +ucode-mod-fs +ucode-mod-ubus +ucode-mod-uci - CONFLICTS:=firewall + PROVIDES:=uci-firewall endef define Package/firewall4/description From 7881dce7d85a6682a68cc78b934c36ced7e308e5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 6 Jan 2022 16:55:13 +0100 Subject: [PATCH 37/73] firewall4: fix syntax error in dependency spec Fixes: ae60af8572 ("firewall4: order DEPENDS alphabetically") Signed-off-by: Jo-Philipp Wich --- package/network/config/firewall4/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index d7f8334dfc..3e32d546fa 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -21,7 +21,7 @@ define Package/firewall4 SECTION:=net CATEGORY:=Base system TITLE:=OpenWrt 4th gen firewall - DEPENDS:=+ \ + DEPENDS:= \ +kmod-nft-core +kmod-nft-fib +kmod-nft-offload \ +kmod-nft-nat +kmod-nft-nat6 \ +nftables-json \ From 4d1f13356196103769e610920a9681b731b089d3 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Thu, 6 Jan 2022 21:30:14 +0200 Subject: [PATCH 38/73] firewall4: bump to git HEAD main.uc: fix device gathering Signed-off-by: Stijn Tintel --- package/network/config/firewall4/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index 3e32d546fa..c667e530dc 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -10,8 +10,8 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firewall4.git PKG_SOURCE_DATE:=2022-01-06 -PKG_SOURCE_VERSION:=be5f4e33c6388935651e6a87c4e5348ade0bd714 -PKG_MIRROR_HASH:=771ca10763754772eb3c420612a109bf7bb1eab240835c74c8e87e198b2beb95 +PKG_SOURCE_VERSION:=b68cf67019452527d6a5a967b823a39dd1ba1edd +PKG_MIRROR_HASH:=8ae8bc8ce71e55adc6d89bd5f97c90834127c733d22e37182119d45eb77c0583 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC From e708bf76d5a3d936228ae414f999cce36fd66d98 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Dec 2021 21:25:16 +0100 Subject: [PATCH 39/73] toolchain: glibc: Update to version 2.34 glibc version 2.34 does not provide versioned shared libraries any more, it only provides shared libraries using the ABI version. Do not try to copy them any more. The functions from libpthread and librt were integrated into the main binary, the libpthread.so and librt.so are only used for backwards compatibility any more. Signed-off-by: Hauke Mehrtens --- package/libs/toolchain/Makefile | 5 +---- toolchain/glibc/common.mk | 8 ++++---- ...rt-Disallow-use-of-DES-encryption-functions-in-n.patch | 6 +++--- toolchain/glibc/patches/200-add-dl-search-paths.patch | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile index dea99060f9..682efd1970 100644 --- a/package/libs/toolchain/Makefile +++ b/package/libs/toolchain/Makefile @@ -519,10 +519,9 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) $(INSTALL_DIR) $(1)/lib $(CP) \ $(TOOLCHAIN_DIR)/lib/ld*.so.* \ - $(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \ $(1)/lib/ for file in libanl libc libcidn libcrypt libdl libm libnsl libnss_dns libnss_files libresolv libutil; do \ - for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \ + for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.*; do \ if [ -e "$$$$file" ]; then \ $(CP) $$$$file $(1)/lib/; \ fi; \ @@ -561,7 +560,6 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) ifneq ($(CONFIG_USE_MUSL),y) $(CP) \ $(TOOLCHAIN_DIR)/lib/libpthread.so.* \ - $(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \ $(1)/lib/ endif endef @@ -581,7 +579,6 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) ifneq ($(CONFIG_USE_MUSL),y) $(CP) \ $(TOOLCHAIN_DIR)/lib/librt.so.* \ - $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \ $(1)/lib/ endif endef diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk index b5f2a513b1..aa8458360f 100644 --- a/toolchain/glibc/common.mk +++ b/toolchain/glibc/common.mk @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=glibc -PKG_VERSION:=2.33 -PKG_RELEASE:=2 +PKG_VERSION:=2.34 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=9b01145592fdbffbcbb949d680c152ed2bf2375d -PKG_MIRROR_HASH:=a1bf0858828ee0f68c7847ce9504bb10ce943d0c8fe801d7ba307add2a238c5b +PKG_SOURCE_VERSION:=d5ba02f67dd62a63e29c29eebd6c543722aa6b5b +PKG_MIRROR_HASH:=19e49929c7ea3480a0d1213b6763a23a5ed8129a34fe201a985498927c583ce1 PKG_SOURCE_URL:=https://sourceware.org/git/glibc.git PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz diff --git a/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch b/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch index 10d9f65d18..cb2ae0550b 100644 --- a/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch +++ b/toolchain/glibc/patches/050-Revert-Disallow-use-of-DES-encryption-functions-in-n.patch @@ -469,7 +469,7 @@ provides them. * Encode Binary Data:: Encoding and Decoding of Binary Data. * Argz and Envz Vectors:: Null-separated string vectors. @end menu -@@ -2426,73 +2426,73 @@ functionality under a different name, su +@@ -2423,73 +2423,73 @@ functionality under a different name, su systems it may be in @file{strings.h} instead. @end deftypefun @@ -596,7 +596,7 @@ provides them. /* The enhanced internationalization capabilities according to XPG4.2 are present. */ #define _XOPEN_ENH_I18N 1 -@@ -1129,17 +1132,25 @@ ssize_t copy_file_range (int __infd, __o +@@ -1146,17 +1149,25 @@ ssize_t copy_file_range (int __infd, __o extern int fdatasync (int __fildes); #endif /* Use POSIX199309 */ @@ -627,7 +627,7 @@ provides them. range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h -@@ -962,6 +962,12 @@ extern int getsubopt (char **__restrict +@@ -968,6 +968,12 @@ extern int getsubopt (char **__restrict #endif diff --git a/toolchain/glibc/patches/200-add-dl-search-paths.patch b/toolchain/glibc/patches/200-add-dl-search-paths.patch index 18d751dd1a..08e901d2e6 100644 --- a/toolchain/glibc/patches/200-add-dl-search-paths.patch +++ b/toolchain/glibc/patches/200-add-dl-search-paths.patch @@ -2,7 +2,7 @@ add /usr/lib to default search path for the dynamic linker --- a/Makeconfig +++ b/Makeconfig -@@ -601,6 +601,9 @@ else +@@ -610,6 +610,9 @@ else default-rpath = $(libdir) endif From 1b251d36ef4e63385b48befe6ce80fcff57264e1 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Dec 2021 21:28:53 +0100 Subject: [PATCH 40/73] toolchain: glibc: Increase minimum kernel version to 5.4 Increase the minimum kernel version needed by the glibc compiled for OpenWrt to version 5.4. With this setting the glibc build will remove all code needed to support older kernel versions. Signed-off-by: Hauke Mehrtens --- toolchain/glibc/common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk index aa8458360f..19610c1e90 100644 --- a/toolchain/glibc/common.mk +++ b/toolchain/glibc/common.mk @@ -63,7 +63,7 @@ GLIBC_CONFIGURE:= \ --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp \ $(if $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),--enable-stack-protector=yes) \ $(if $(CONFIG_PKG_CC_STACKPROTECTOR_STRONG),--enable-stack-protector=strong) \ - --enable-kernel=4.14.0 + --enable-kernel=5.4.0 export libc_cv_ssp=no export libc_cv_ssp_strong=no From 77df120bc8b220a79a8b158a457847d0d3d3c94b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Dec 2021 21:37:21 +0100 Subject: [PATCH 41/73] toolchain: glibc: Enable --enable-bind-now Enable --enable-bind-now when CONFIG_PKG_RELRO_FULL is set. This option is activated by default. This will enable full RELRO protection. Signed-off-by: Hauke Mehrtens --- toolchain/glibc/common.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk index 19610c1e90..e957ff52e5 100644 --- a/toolchain/glibc/common.mk +++ b/toolchain/glibc/common.mk @@ -63,6 +63,7 @@ GLIBC_CONFIGURE:= \ --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp \ $(if $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),--enable-stack-protector=yes) \ $(if $(CONFIG_PKG_CC_STACKPROTECTOR_STRONG),--enable-stack-protector=strong) \ + $(if $(CONFIG_PKG_RELRO_FULL),--enable-bind-now) \ --enable-kernel=5.4.0 export libc_cv_ssp=no From 9f08557649a733b236bb7fd111f6113549a18558 Mon Sep 17 00:00:00 2001 From: John Audia Date: Wed, 5 Jan 2022 10:54:47 -0500 Subject: [PATCH 42/73] kernel: bump 5.4 to 5.4.170 All patches automatically rebased. Build system: x86_64 Build-tested: ramips/mt7621 Signed-off-by: John Audia --- include/kernel-version.mk | 4 ++-- ...set-linkstation-poweroff-prepare-for-new-dev.patch | 11 +++-------- ...er-reset-linkstation-poweroff-add-new-device.patch | 9 ++------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/include/kernel-version.mk b/include/kernel-version.mk index 9cd2b77e16..5d462f7b06 100644 --- a/include/kernel-version.mk +++ b/include/kernel-version.mk @@ -6,10 +6,10 @@ ifdef CONFIG_TESTING_KERNEL KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER) endif -LINUX_VERSION-5.4 = .169 +LINUX_VERSION-5.4 = .170 LINUX_VERSION-5.10 = .89 -LINUX_KERNEL_HASH-5.4.169 = 554382d95f71afd5f9b49292eb5d1cbe3be1a0bad22d21487c9e6d506ee01a19 +LINUX_KERNEL_HASH-5.4.170 = b09f74e0cf5fc7cf5de6aa932fe654c962cb10118bdbbdddb397022c6e6d382c LINUX_KERNEL_HASH-5.10.89 = 92218b1a4a18f1cb9ec07d2b7fce41577452aa552c54c25b6d5fe9b4b543bb30 remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1)))) diff --git a/target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch b/target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch index 03253cfe83..4b4d03839a 100644 --- a/target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch +++ b/target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch @@ -15,8 +15,6 @@ Signed-off-by: Pawel Dembicki drivers/power/reset/linkstation-poweroff.c | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) -diff --git a/drivers/power/reset/linkstation-poweroff.c b/drivers/power/reset/linkstation-poweroff.c -index f1e843df0e16..8691cf98600d 100644 --- a/drivers/power/reset/linkstation-poweroff.c +++ b/drivers/power/reset/linkstation-poweroff.c @@ -29,11 +29,21 @@ @@ -42,7 +40,7 @@ index f1e843df0e16..8691cf98600d 100644 saved_page = phy_select_page(phydev, MII_MARVELL_LED_PAGE); if (saved_page < 0) -@@ -66,11 +76,16 @@ static void mvphy_reg_intn(u16 data) +@@ -66,11 +76,16 @@ err: dev_err(&phydev->mdio.dev, "Write register failed, %d\n", rc); } @@ -60,7 +58,7 @@ index f1e843df0e16..8691cf98600d 100644 return NOTIFY_DONE; } -@@ -82,14 +97,18 @@ static struct notifier_block linkstation_reboot_nb = { +@@ -82,14 +97,18 @@ static struct notifier_block linkstation static void linkstation_poweroff(void) { unregister_reboot_notifier(&linkstation_reboot_nb); @@ -82,7 +80,7 @@ index f1e843df0e16..8691cf98600d 100644 { }, }; -@@ -97,13 +116,17 @@ static int __init linkstation_poweroff_init(void) +@@ -97,13 +116,17 @@ static int __init linkstation_poweroff_i { struct mii_bus *bus; struct device_node *dn; @@ -101,6 +99,3 @@ index f1e843df0e16..8691cf98600d 100644 if (!dn) return -ENODEV; --- -2.25.1 - diff --git a/target/linux/kirkwood/patches-5.4/801-power-reset-linkstation-poweroff-add-new-device.patch b/target/linux/kirkwood/patches-5.4/801-power-reset-linkstation-poweroff-add-new-device.patch index 0b3b4ad2d7..a929aacfd0 100644 --- a/target/linux/kirkwood/patches-5.4/801-power-reset-linkstation-poweroff-add-new-device.patch +++ b/target/linux/kirkwood/patches-5.4/801-power-reset-linkstation-poweroff-add-new-device.patch @@ -17,8 +17,6 @@ Signed-off-by: Pawel Dembicki drivers/power/reset/linkstation-poweroff.c | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) -diff --git a/drivers/power/reset/linkstation-poweroff.c b/drivers/power/reset/linkstation-poweroff.c -index 8691cf98600d..2a92b6052cac 100644 --- a/drivers/power/reset/linkstation-poweroff.c +++ b/drivers/power/reset/linkstation-poweroff.c @@ -19,6 +19,7 @@ @@ -38,7 +36,7 @@ index 8691cf98600d..2a92b6052cac 100644 struct power_off_cfg { char *mdio_node_name; void (*phy_set_reg)(bool restart); -@@ -76,11 +79,48 @@ static void linkstation_mvphy_reg_intn(bool restart) +@@ -76,11 +79,48 @@ err: dev_err(&phydev->mdio.dev, "Write register failed, %d\n", rc); } @@ -87,7 +85,7 @@ index 8691cf98600d..2a92b6052cac 100644 static int linkstation_reboot_notifier(struct notifier_block *nb, unsigned long action, void *unused) { -@@ -109,6 +149,9 @@ static const struct of_device_id ls_poweroff_of_match[] = { +@@ -109,6 +149,9 @@ static const struct of_device_id ls_powe { .compatible = "buffalo,ls421de", .data = &linkstation_power_off_cfg, }, @@ -97,6 +95,3 @@ index 8691cf98600d..2a92b6052cac 100644 { }, }; --- -2.25.1 - From 536f051b971c8b3aada21c35ca7deefb94e7dd74 Mon Sep 17 00:00:00 2001 From: Rui Salvaterra Date: Wed, 5 Jan 2022 13:27:56 +0000 Subject: [PATCH 43/73] kernel: bump 5.10 to 5.10.90 Add and enable a new kconfig knob to disable unprivileged eBPF by default. Patches automatically rebased. Signed-off-by: Rui Salvaterra --- include/kernel-version.mk | 4 ++-- .../802-usb-xhci-force-msi-renesas-xhci.patch | 2 +- ...355-xhci-quirks-add-link-TRB-quirk-for-VL805.patch | 2 +- ...et-pass-the-dst-buffer-to-of_get_mac_address.patch | 2 +- target/linux/generic/config-5.10 | 1 + target/linux/generic/hack-5.10/204-module_strip.patch | 2 +- .../generic/pending-5.10/920-mangle_bootargs.patch | 2 +- ...set-linkstation-poweroff-prepare-for-new-dev.patch | 11 +++-------- ...er-reset-linkstation-poweroff-add-new-device.patch | 9 ++------- 9 files changed, 13 insertions(+), 22 deletions(-) diff --git a/include/kernel-version.mk b/include/kernel-version.mk index 5d462f7b06..677693ad08 100644 --- a/include/kernel-version.mk +++ b/include/kernel-version.mk @@ -7,10 +7,10 @@ ifdef CONFIG_TESTING_KERNEL endif LINUX_VERSION-5.4 = .170 -LINUX_VERSION-5.10 = .89 +LINUX_VERSION-5.10 = .90 LINUX_KERNEL_HASH-5.4.170 = b09f74e0cf5fc7cf5de6aa932fe654c962cb10118bdbbdddb397022c6e6d382c -LINUX_KERNEL_HASH-5.10.89 = 92218b1a4a18f1cb9ec07d2b7fce41577452aa552c54c25b6d5fe9b4b543bb30 +LINUX_KERNEL_HASH-5.10.90 = 945e4264c014a3d9dfc0a4639309dd1ec2fb545416556421f931b95da78c2725 remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1)))) sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1))))))) diff --git a/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch b/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch index daaf46bc5f..d7376abc80 100644 --- a/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch +++ b/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch @@ -13,7 +13,7 @@ produce a noisy warning. --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c -@@ -276,6 +276,7 @@ static void xhci_pci_quirks(struct devic +@@ -279,6 +279,7 @@ static void xhci_pci_quirks(struct devic pdev->device == 0x0015) { xhci->quirks |= XHCI_RESET_ON_RESUME; xhci->quirks |= XHCI_ZERO_64B_REGS; diff --git a/target/linux/bcm27xx/patches-5.10/950-0355-xhci-quirks-add-link-TRB-quirk-for-VL805.patch b/target/linux/bcm27xx/patches-5.10/950-0355-xhci-quirks-add-link-TRB-quirk-for-VL805.patch index 92a35bec92..1d2aca4e06 100644 --- a/target/linux/bcm27xx/patches-5.10/950-0355-xhci-quirks-add-link-TRB-quirk-for-VL805.patch +++ b/target/linux/bcm27xx/patches-5.10/950-0355-xhci-quirks-add-link-TRB-quirk-for-VL805.patch @@ -22,7 +22,7 @@ Signed-off-by: Jonathan Bell --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c -@@ -288,6 +288,7 @@ static void xhci_pci_quirks(struct devic +@@ -291,6 +291,7 @@ static void xhci_pci_quirks(struct devic if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483) { xhci->quirks |= XHCI_LPM_SUPPORT; xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS; diff --git a/target/linux/generic/backport-5.10/732-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch b/target/linux/generic/backport-5.10/732-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch index 696892786e..65619e0837 100644 --- a/target/linux/generic/backport-5.10/732-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch +++ b/target/linux/generic/backport-5.10/732-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch @@ -319,7 +319,7 @@ Signed-off-by: David S. Miller int tx_size, err, i; struct ag71xx *ag; -@@ -1957,10 +1956,8 @@ static int ag71xx_probe(struct platform_ +@@ -1952,10 +1951,8 @@ static int ag71xx_probe(struct platform_ ag->stop_desc->ctrl = 0; ag->stop_desc->next = (u32)ag->stop_desc_dma; diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index c37e33b13d..bd2e72e54f 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -705,6 +705,7 @@ CONFIG_BPF_JIT_DEFAULT_ON=y # CONFIG_BPF_PRELOAD is not set # CONFIG_BPF_STREAM_PARSER is not set CONFIG_BPF_SYSCALL=y +CONFIG_BPF_UNPRIV_DEFAULT_OFF=y # CONFIG_BPQETHER is not set CONFIG_BQL=y CONFIG_BRANCH_PROFILE_NONE=y diff --git a/target/linux/generic/hack-5.10/204-module_strip.patch b/target/linux/generic/hack-5.10/204-module_strip.patch index f372687ba1..645074821f 100644 --- a/target/linux/generic/hack-5.10/204-module_strip.patch +++ b/target/linux/generic/hack-5.10/204-module_strip.patch @@ -88,7 +88,7 @@ Signed-off-by: Felix Fietkau --- a/init/Kconfig +++ b/init/Kconfig -@@ -2337,6 +2337,13 @@ config UNUSED_KSYMS_WHITELIST +@@ -2347,6 +2347,13 @@ config UNUSED_KSYMS_WHITELIST one per line. The path can be absolute, or relative to the kernel source tree. diff --git a/target/linux/generic/pending-5.10/920-mangle_bootargs.patch b/target/linux/generic/pending-5.10/920-mangle_bootargs.patch index d8f5c06b7e..fc64a4205e 100644 --- a/target/linux/generic/pending-5.10/920-mangle_bootargs.patch +++ b/target/linux/generic/pending-5.10/920-mangle_bootargs.patch @@ -13,7 +13,7 @@ Signed-off-by: Imre Kaloz --- a/init/Kconfig +++ b/init/Kconfig -@@ -1790,6 +1790,15 @@ config EMBEDDED +@@ -1800,6 +1800,15 @@ config EMBEDDED an embedded system so certain expert options are available for configuration. diff --git a/target/linux/kirkwood/patches-5.10/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch b/target/linux/kirkwood/patches-5.10/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch index 03253cfe83..4b4d03839a 100644 --- a/target/linux/kirkwood/patches-5.10/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch +++ b/target/linux/kirkwood/patches-5.10/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch @@ -15,8 +15,6 @@ Signed-off-by: Pawel Dembicki drivers/power/reset/linkstation-poweroff.c | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) -diff --git a/drivers/power/reset/linkstation-poweroff.c b/drivers/power/reset/linkstation-poweroff.c -index f1e843df0e16..8691cf98600d 100644 --- a/drivers/power/reset/linkstation-poweroff.c +++ b/drivers/power/reset/linkstation-poweroff.c @@ -29,11 +29,21 @@ @@ -42,7 +40,7 @@ index f1e843df0e16..8691cf98600d 100644 saved_page = phy_select_page(phydev, MII_MARVELL_LED_PAGE); if (saved_page < 0) -@@ -66,11 +76,16 @@ static void mvphy_reg_intn(u16 data) +@@ -66,11 +76,16 @@ err: dev_err(&phydev->mdio.dev, "Write register failed, %d\n", rc); } @@ -60,7 +58,7 @@ index f1e843df0e16..8691cf98600d 100644 return NOTIFY_DONE; } -@@ -82,14 +97,18 @@ static struct notifier_block linkstation_reboot_nb = { +@@ -82,14 +97,18 @@ static struct notifier_block linkstation static void linkstation_poweroff(void) { unregister_reboot_notifier(&linkstation_reboot_nb); @@ -82,7 +80,7 @@ index f1e843df0e16..8691cf98600d 100644 { }, }; -@@ -97,13 +116,17 @@ static int __init linkstation_poweroff_init(void) +@@ -97,13 +116,17 @@ static int __init linkstation_poweroff_i { struct mii_bus *bus; struct device_node *dn; @@ -101,6 +99,3 @@ index f1e843df0e16..8691cf98600d 100644 if (!dn) return -ENODEV; --- -2.25.1 - diff --git a/target/linux/kirkwood/patches-5.10/801-power-reset-linkstation-poweroff-add-new-device.patch b/target/linux/kirkwood/patches-5.10/801-power-reset-linkstation-poweroff-add-new-device.patch index 0b3b4ad2d7..a929aacfd0 100644 --- a/target/linux/kirkwood/patches-5.10/801-power-reset-linkstation-poweroff-add-new-device.patch +++ b/target/linux/kirkwood/patches-5.10/801-power-reset-linkstation-poweroff-add-new-device.patch @@ -17,8 +17,6 @@ Signed-off-by: Pawel Dembicki drivers/power/reset/linkstation-poweroff.c | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) -diff --git a/drivers/power/reset/linkstation-poweroff.c b/drivers/power/reset/linkstation-poweroff.c -index 8691cf98600d..2a92b6052cac 100644 --- a/drivers/power/reset/linkstation-poweroff.c +++ b/drivers/power/reset/linkstation-poweroff.c @@ -19,6 +19,7 @@ @@ -38,7 +36,7 @@ index 8691cf98600d..2a92b6052cac 100644 struct power_off_cfg { char *mdio_node_name; void (*phy_set_reg)(bool restart); -@@ -76,11 +79,48 @@ static void linkstation_mvphy_reg_intn(bool restart) +@@ -76,11 +79,48 @@ err: dev_err(&phydev->mdio.dev, "Write register failed, %d\n", rc); } @@ -87,7 +85,7 @@ index 8691cf98600d..2a92b6052cac 100644 static int linkstation_reboot_notifier(struct notifier_block *nb, unsigned long action, void *unused) { -@@ -109,6 +149,9 @@ static const struct of_device_id ls_poweroff_of_match[] = { +@@ -109,6 +149,9 @@ static const struct of_device_id ls_powe { .compatible = "buffalo,ls421de", .data = &linkstation_power_off_cfg, }, @@ -97,6 +95,3 @@ index 8691cf98600d..2a92b6052cac 100644 { }, }; --- -2.25.1 - From 033b6cef94a4aae6244f75f34bc2879869335002 Mon Sep 17 00:00:00 2001 From: Matthew Hagan Date: Mon, 3 Jan 2022 23:00:18 +0000 Subject: [PATCH 44/73] kernel: enhance multicast routing support Certain utilities, such as smcroute [1], require additional multicast routing options to be enabled, otherwise they will not function correctly. Enable these relevant dependancies when IPv4 and/or IPv6 multicast routing are enabled. [1] https://github.com/troglobit/smcroute/blob/master/README.md#linux-requirements This increases the uncompressed kernel size on MIPS 24kc by 8KBytes and the compressed kernel size by 1.8KBytes. Signed-off-by: Matthew Hagan --- config/Config-kernel.in | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/config/Config-kernel.in b/config/Config-kernel.in index 07d65bc465..98dab9b6fd 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -986,6 +986,19 @@ config KERNEL_IP_MROUTE Multicast routing requires a multicast routing daemon in addition to kernel support. +if KERNEL_IP_MROUTE + + config KERNEL_IP_MROUTE_MULTIPLE_TABLES + def_bool y + + config KERNEL_IP_PIMSM_V1 + def_bool y + + config KERNEL_IP_PIMSM_V2 + def_bool y + +endif + # # IPv6 configuration # @@ -1008,8 +1021,15 @@ if KERNEL_IPV6 Multicast routing requires a multicast routing daemon in addition to kernel support. - config KERNEL_IPV6_PIMSM_V2 - def_bool n + if KERNEL_IPV6_MROUTE + + config KERNEL_IPV6_MROUTE_MULTIPLE_TABLES + def_bool y + + config KERNEL_IPV6_PIMSM_V2 + def_bool y + + endif config KERNEL_IPV6_SEG6_LWTUNNEL bool "Enable support for lightweight tunnels" From 04e6434c62dc8271767f3c675832647477eb9998 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sun, 2 Jan 2022 22:18:04 +0300 Subject: [PATCH 45/73] utils/mdadm: fix build on hosts without /run dir CHECK_RUN_DIR=0 must be a part of MAKE_FLAGS, not MAKE_VARS, otherwise it is not possible to compile mdadm on host without /run dir. Signed-off-by: Sergey V. Lobanov --- package/utils/mdadm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile index f20a58b704..f6696bf21c 100644 --- a/package/utils/mdadm/Makefile +++ b/package/utils/mdadm/Makefile @@ -52,7 +52,7 @@ TARGET_CFLAGS += \ TARGET_LDFLAGS += -Wl,--gc-sections -MAKE_VARS += CHECK_RUN_DIR=0 +MAKE_FLAGS += CHECK_RUN_DIR=0 define Build/Compile $(call Build/Compile/Default,mdadm) From 766733e17226221a310a30c91927a79f07a456e5 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Fri, 10 Dec 2021 20:09:37 +0000 Subject: [PATCH 46/73] ramips: add support for Joowin WR758AC V1 and V2 This commit adds support for Joowin (aka Comfast) WR758AC V1 and V2 devices. Both have the same wall AP/repeater form factor and differ only in the 5Ghz chipset (V1 has MT7662, V2 has MT7663). OpenWrt developers forum page: https://forum.openwrt.org/t/87355 Specifications: - CPU: MediaTek MT7628AN (580MHz) - Flash: 8MB - RAM: 64MB DDR2 - 2.4 GHz: 802.11b/g/n (MT7603) - 5 GHz: 802.11ac (V1 has MT7662, V2 has MT7663) - Antennas: 4x external single band antennas - LAN: 1x 10/100M - LED: Wifi 3x blue. Programmable - Button: WPS MAC addresses as verified by OEM firmware: use address source LAN *:83 factory 0xe000 2g *:85 factory 0x4 5g *:86 factory 0x8004 How to install: 1- Setup a TFTP server on a machine with IP address 192.168.1.10/24 2- Name the image as `firmware_auto.bin` and place it on the root of the TFTP server 3- Connect the device via Ethernet, it should pick and flash the image Signed-off-by: Rodrigo Araujo --- .../dts/mt7628an_joowin_jw-wr758ac-v1.dts | 8 ++ .../dts/mt7628an_joowin_jw-wr758ac-v2.dts | 8 ++ .../dts/mt7628an_joowin_jw-wr758ac.dtsi | 124 ++++++++++++++++++ target/linux/ramips/image/mt76x8.mk | 20 +++ .../mt76x8/base-files/etc/board.d/02_network | 2 + 5 files changed, 162 insertions(+) create mode 100644 target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v1.dts create mode 100644 target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v2.dts create mode 100644 target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac.dtsi diff --git a/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v1.dts b/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v1.dts new file mode 100644 index 0000000000..c3b52c82c1 --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v1.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an_joowin_jw-wr758ac.dtsi" + +/ { + compatible = "joowin,jw-wr758ac-v1", "mediatek,mt7628an-soc"; + model = "Joowin WR758AC V1"; +}; diff --git a/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v2.dts b/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v2.dts new file mode 100644 index 0000000000..1cc0d5d38d --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac-v2.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an_joowin_jw-wr758ac.dtsi" + +/ { + compatible = "joowin,jw-wr758ac-v2", "mediatek,mt7628an-soc"; + model = "Joowin WR758AC V2"; +}; diff --git a/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac.dtsi b/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac.dtsi new file mode 100644 index 0000000000..97845cf02b --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_joowin_jw-wr758ac.dtsi @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an.dtsi" + +#include +#include + +/ { + compatible = "joowin,jw-wr758ac", "mediatek,mt7628an-soc"; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&gpio 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + wifi-high { + label = "blue:wifi-high"; + gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; + + wifi-med { + label = "blue:wifi-med"; + gpios = <&gpio 44 GPIO_ACTIVE_LOW>; + }; + + wifi-low { + label = "blue:wifi-low"; + gpios = <&gpio 37 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&state_default { + gpio { + groups = "refclk", "wdt", "wled_an"; + function = "gpio"; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0x7b0000>; + }; + }; + }; +}; + +&wmac { + status = "okay"; + + mediatek,mtd-eeprom = <&factory 0x0>; +}; + +ðernet { + nvmem-cells = <&macaddr_factory_e000>; + nvmem-cell-names = "mac-address"; +}; + +&esw { + mediatek,portdisable = <0x2f>; +}; + +&factory { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_e000: macaddr@e000 { + reg = <0xe000 0x6>; + }; +}; diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index e9188e7405..29c2613685 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -220,6 +220,26 @@ define Device/iptime_a604m endef TARGET_DEVICES += iptime_a604m +define Device/joowin_jw-wr758ac + IMAGE_SIZE := 7872k + DEVICE_VENDOR := Joowin + DEVICE_MODEL := WR758AC +endef + +define Device/joowin_jw-wr758ac-v1 + $(Device/joowin_jw-wr758ac) + DEVICE_PACKAGES := kmod-mt76x2 + DEVICE_VARIANT := V1 +endef +TARGET_DEVICES += joowin_jw-wr758ac-v1 + +define Device/joowin_jw-wr758ac-v2 + $(Device/joowin_jw-wr758ac) + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7663-firmware-ap + DEVICE_VARIANT := V2 +endef +TARGET_DEVICES += joowin_jw-wr758ac-v2 + define Device/jotale_js76x8 DEVICE_VENDOR := Jotale DEVICE_MODEL := JS76x8 diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network index 08b2e6cebc..43d2647cf0 100644 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -129,6 +129,8 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:wan" "6@eth0" ;; + joowin,jw-wr758ac-v1|\ + joowin,jw-wr758ac-v2|\ tplink,tl-wr902ac-v3|\ wavlink,wl-wn576a2) ucidef_add_switch "switch0" \ From bc7d36ba3a43bc3bc4eeab6ea127032aba3e1f4e Mon Sep 17 00:00:00 2001 From: Liangkuan Yang Date: Wed, 11 Aug 2021 15:47:22 +0800 Subject: [PATCH 47/73] ramips: add support for RAISECOM MSG1500 X.00 RAISECOM MSG1500 X.00 is a 2.4/5 GHz band 11ac (Wi-Fi 5) router. Apart from the general model, there are two ISP customized models: China Mobile and China Telecom. Specifications: - SoC: Mediatek MT7621AT - RAM: 256MiB DDR3 - Flash: 128MiB NAND - Ethernet: 5 * 10/100/1000Mbps: 4 * LAN + 1 * WAN - Switch: MediaTek MT7530 (SoC) - WLAN: 1 * MT7615DN Dual-Band 2.4GHz 2T2R (400Mbps) 5GHz 2T2R (867Mbps) - USB: 1 * USB 2.0 port - Button: 1 * RESET button, 1 * WPS button, 1 * WIFI button - LED: blue color: POWER, WAN, WPS, 2.4G, 5G, LAN1, LAN2, LAN3, LAN4, USB - UART: 1 * serial port header (4-pin) - Power: DC 12V, 1A - Switch: 1 * POWER switch MAC addresses as verified by vendor firmware: use address source LAN C8:XX:XX:3A:XX:E7 Config "protest_lan_mac" ascii (label) WAN C8:XX:XX:3A:XX:EA Config "protest_wan_mac" ascii 5G C8:XX:XX:3A:XX:E8 Factory "0x4" hex 2.4G CA:XX:XX:4A:XX:E8 [not on flash] The increment of the 4th byte for the 2.4g address appears to vary. Reported cases: 5g 2.4g increment C8:XX:XX:90:XX:C3 CA:XX:XX:C0:XX:C3 0x30 C8:XX:XX:3A:XX:08 CA:XX:XX:4A:XX:08 0x10 C8:XX:XX:3A:XX:E8 CA:XX:XX:4A:XX:E8 0x10 Since increment is inconsistent and there is no obvious pattern in swapping bytes, and the 2.4g address has local bit set anyway, it seems safer to use the LAN address with flipped byte here in order to prevent collisions between OpenWrt devices and OEM devices for this interface. This way we at least use an address as base that is definitely owned by the device at hand. Notes: 1. The vendor firmware allows you to connect to the router by telnet. (known version 1.0.0 can open telnet.) There is no official binary firmware available. Backup the important partitions data: "Bootloader", "Config", "Factory", and "firmware". Note that with the vendor firmware the memory is detected only 128MiB and the last 512KiB in NAND flash is not used. 2. The POWER LED is default on after press POWER switch. The WAN and LAN1 - 4 LEDs are wired to ethernet switch. The WPS LED is controlled by MT7615DN's GPIO. Currently there is no proper way to configure it. 3. At the time of adding support the wireless config needs to be set up by editing the wireless config file: * Setting the country code is mandatory, otherwise the router loses connectivity at the next reboot. This is mandatory and can be done from luci. After setting the country code the router boots correctly. A reset with the reset button will fix the issue and the user has to reconfigure. * This is minor since the 5g interface does not come up online although it is not set as disabled. 2 options here: 1- Either run the "wifi" command. Can be added from LuCI in system - startup - local startup and just add wifi above "exit 0". 2- Or add the serialize option in the wireless config file as shown below. This one would work and bring both interfaces automatically at every boot: config wifi-device 'radio0' option serialize '1' config wifi-device 'radio1' option serialize '1' Flash instructions using initramfs image: 1. Press POWER switch to power down if the router is running. 2. Connect PC to one of LAN ports, and set static IP address to "10.10.10.2", netmask to "255.255.255.0", and gateway to "10.10.10.1" manually on the PC. 3. Push and hold the WIFI button, and then power up the router. After about 10s (or you can call the recovery page, see "4" below) you can release the WIFI button. There is no clear indication when the router is entering or has entered into "RAISECOM Router Recovery Mode". 4. Call the recovery page for the router at "http://10.10.10.1". Keep an eye on the "WARNING!! tip" of the recovery page. Click "Choose File" to select initramfs image, then click "Upload". 5. If image is uploaded successfully, you will see the page display "Device is upgrading the firmware... %". Keep an eye on the "WARNING!! tip" of the recovery page. When the page display "Upgrade Successfully", you can set IP address as "automatically obtain". 6. After the rebooting (PC should automatically obtain an IP address), open the SSH connection, then download the sysupgrade image to the router and perform sysupgrade with it. Flash back to vendor firmware: See "Flash instructions 1 - 5" above. The only difference is that in step 4 you should select the vendor firmware which you backup. Signed-off-by: Liangkuan Yang --- .../dts/mt7621_raisecom_msg1500-x-00.dts | 162 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 17 ++ .../mt7621/base-files/etc/board.d/02_network | 5 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 5 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 5 files changed, 190 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts diff --git a/target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts b/target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts new file mode 100644 index 0000000000..13d39195a9 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "raisecom,msg1500-x-00", "mediatek,mt7621-soc"; + model = "RAISECOM MSG1500 X.00"; + + aliases { + led-boot = &led_usb; + led-failsafe = &led_usb; + led-upgrade = &led_usb; + }; + + leds { + compatible = "gpio-leds"; + + wlan2g { + label = "blue:wlan2g"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + + wlan5g { + label = "blue:wlan5g"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1radio"; + }; + + led_usb: usb { + label = "blue:usb"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + trigger-sources = <&ehci_port2>; + linux,default-trigger = "usbport"; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wifi { + label = "wifi"; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "Config"; + reg = <0x80000 0x80000>; + read-only; + }; + + factory: partition@100000 { + label = "Factory"; + reg = <0x100000 0x40000>; + read-only; + }; + + partition@140000 { + label = "kernel"; + reg = <0x140000 0x400000>; + }; + + partition@540000 { + label = "ubi"; + reg = <0x540000 0x7a40000>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + /* 5 GHz (phy1) does not take the address from calibration data, + but setting it manually here works */ + nvmem-cells = <&macaddr_factory_4>; + nvmem-cell-names = "mac-address"; + }; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; + + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + + port@4 { + status = "okay"; + label = "wan"; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "jtag", "uart3", "wdt"; + function = "gpio"; + }; +}; + +&factory { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_4: macaddr@4 { + reg = <0x4 0x6>; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 18a29270d7..46097f231e 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1284,6 +1284,23 @@ define Device/planex_vr500 endef TARGET_DEVICES += planex_vr500 +define Device/raisecom_msg1500-x-00 + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 129280k + UBINIZE_OPTS := -E 5 + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_VENDOR := RAISECOM + DEVICE_MODEL := MSG1500 + DEVICE_VARIANT := X.00 + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 \ + kmod-usb-ledtrig-usbport uboot-envtools +endef +TARGET_DEVICES += raisecom_msg1500-x-00 + define Device/samknows_whitebox-v8 $(Device/dsa-migration) IMAGE_SIZE := 16064k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 0b11c05c84..b2bca0f3cd 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -165,6 +165,11 @@ ramips_setup_macs() wan_mac=$label_mac lan_mac=$(macaddr_add $label_mac 1) ;; + raisecom,msg1500-x-00) + lan_mac=$(mtd_get_mac_ascii Config protest_lan_mac) + wan_mac=$(mtd_get_mac_ascii Config protest_wan_mac) + label_mac=$lan_mac + ;; esac [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 8b7c7ab7f0..6ef44138cc 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -39,6 +39,11 @@ case "$board" in [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress ;; + raisecom,msg1500-x-00) + [ "$PHYNBR" = "0" ] && \ + macaddr_setbit_la "$(mtd_get_mac_ascii Config protest_lan_mac)" \ + > /sys${DEVPATH}/macaddress + ;; tenbay,t-mb5eu-v01) hw_mac_addr="$(mtd_get_mac_binary factory 0x4)" [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr "1" > /sys${DEVPATH}/macaddress diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index c7ddb55b34..52c334e05e 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -79,6 +79,7 @@ platform_do_upgrade() { netgear,wac104|\ netgear,wac124|\ netis,wf2881|\ + raisecom,msg1500-x-00|\ sercomm,na502|\ xiaomi,mi-router-3g|\ xiaomi,mi-router-3-pro|\ From e0a574d4b73b6444d493866128cf3be3fae10892 Mon Sep 17 00:00:00 2001 From: Nick McKinney Date: Fri, 10 Dec 2021 08:23:01 -0500 Subject: [PATCH 48/73] ramips: add support for Linksys EA6350 v4 Specifications: - SoC: MT7621DAT (880MHz, 2 Cores) - RAM: 128 MB - Flash: 128 MB NAND - Ethernet: 5x 1GiE MT7530 - WiFi: MT7603/MT7613 - USB: 1x USB 3.0 This is another MT7621 device, very similar to other Linksys EA7300 series devices. Installation: Upload the generated factory.bin image via the stock web firmware updater. Reverting to factory firmware: Like other EA7300 devices, this device has an A/B router configuration to prevent bricking. Hard-resetting this device three (3) times will put the device in failsafe (default) mode. At this point, flash the OEM image to itself and reboot. This puts the router back into the 'B' image and allows for a firmware upgrade. Troubleshooting: If the firmware will not boot, first restore the factory as described above. This will then allow the factory.bin update to be applied properly. Signed-off-by: Nick McKinney --- package/boot/uboot-envtools/files/ramips | 1 + .../ramips/dts/mt7621_linksys_ea6350-v4.dts | 37 +++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 9 +++++ .../mt7621/base-files/etc/board.d/01_leds | 1 + .../mt7621/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 1 + .../mt7621/base-files/etc/init.d/bootcount | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 8 files changed, 52 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_linksys_ea6350-v4.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 9ad4d64ed9..d4c8424571 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -52,6 +52,7 @@ ravpower,rp-wd03) jcg,q20) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ;; +linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ diff --git a/target/linux/ramips/dts/mt7621_linksys_ea6350-v4.dts b/target/linux/ramips/dts/mt7621_linksys_ea6350-v4.dts new file mode 100644 index 0000000000..272b01af1e --- /dev/null +++ b/target/linux/ramips/dts/mt7621_linksys_ea6350-v4.dts @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_linksys_ea7xxx.dtsi" + +/ { + compatible = "linksys,ea6350-v4", "mediatek,mt7621-soc"; + model = "Linksys EA6350 v4"; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; + + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan4"; + }; + + port@4 { + status = "okay"; + label = "wan"; + }; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 46097f231e..7755fbef81 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -912,6 +912,15 @@ define Device/linksys_ea7xxx append-ubi | check-size | linksys-image type=$$$$(LINKSYS_HWNAME) endef +define Device/linksys_ea6350-v4 + $(Device/linksys_ea7xxx) + DEVICE_MODEL := EA6350 + DEVICE_VARIANT := v4 + LINKSYS_HWNAME := EA6350 + DEVICE_PACKAGES += kmod-mt7603 kmod-mt7663-firmware-ap +endef +TARGET_DEVICES += linksys_ea6350-v4 + define Device/linksys_ea7300-v1 $(Device/linksys_ea7xxx) DEVICE_MODEL := EA7300 diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 6e6cd747c4..29962f41d7 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -55,6 +55,7 @@ gnubee,gb-pc2) linksys,e5600) ucidef_set_led_netdev "wan" "wan link" "blue:wan" "wan" "link" ;; +linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index b2bca0f3cd..52e0b6b572 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -148,6 +148,7 @@ ramips_setup_macs() label_mac=$(mtd_get_mac_binary factory 0x4) ;; linksys,e5600|\ + linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 6ef44138cc..3c3b1e62e7 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -30,6 +30,7 @@ case "$board" in macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress ;; linksys,e5600|\ + linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index 7b4a63d663..8382bdf0c5 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -9,6 +9,7 @@ boot() { echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s - ;; linksys,e5600|\ + linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 52c334e05e..8e1bdc157f 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -62,6 +62,7 @@ platform_do_upgrade() { iptime,t5004|\ jcg,q20|\ linksys,e5600|\ + linksys,ea6350-v4|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ From 6835ea13f0fa2c3a6036e2af7d6f52839cf93d9a Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Tue, 4 Jan 2022 17:22:07 +0300 Subject: [PATCH 49/73] elfutils: update to 0.186 Upstreamed patches (deleted): 0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch - https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=8382833a257b57b0d288be07d2d5e7af6c102869 110-no-cdefs.patch - https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=d390548df1942e98a1d836269a5e41ba52e121f1 Auto-refreshed: 006-Fix-build-on-aarch64-musl.patch 101-no-fts.patch Manually updated and refreshed: 005-build_only_libs.patch 003-libintl-compatibility.patch 100-musl-compat.patch Disabled _obstack_free check (via configure vars) Signed-off-by: Sergey V. Lobanov --- package/libs/elfutils/Makefile | 10 +++- ...cliude-asm-ptrace.h-for-pt_regs-defi.patch | 29 ---------- .../patches/003-libintl-compatibility.patch | 54 ++----------------- .../patches/005-build_only_libs.patch | 2 +- .../elfutils/patches/100-musl-compat.patch | 48 ++++++----------- .../libs/elfutils/patches/101-no-fts.patch | 6 +-- .../libs/elfutils/patches/110-no-cdefs.patch | 26 --------- 7 files changed, 30 insertions(+), 145 deletions(-) delete mode 100644 package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch delete mode 100644 package/libs/elfutils/patches/110-no-cdefs.patch diff --git a/package/libs/elfutils/Makefile b/package/libs/elfutils/Makefile index b0c9b8bd8c..f9a350f9fe 100644 --- a/package/libs/elfutils/Makefile +++ b/package/libs/elfutils/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=elfutils -PKG_VERSION:=0.182 +PKG_VERSION:=0.186 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) -PKG_HASH:=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858 +PKG_HASH:=7f6fb9149b1673d38d9178a0d3e0fb8a1ec4f53a9f4c2ff89469609879641177 PKG_MAINTAINER:=Luiz Angelo Daros de Luca PKG_LICENSE:=GPL-3.0-or-later @@ -74,6 +74,12 @@ CONFIGURE_ARGS += \ --without-lzma \ --without-zstd +HOST_CONFIGURE_VARS += \ + ac_cv_search__obstack_free=yes + +CONFIGURE_VARS += \ + ac_cv_search__obstack_free=yes + TARGET_CFLAGS += -D_GNU_SOURCE -Wno-unused-result -Wno-format-nonliteral define Build/InstallDev diff --git a/package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch b/package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch deleted file mode 100644 index 839f86ee6a..0000000000 --- a/package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch +++ /dev/null @@ -1,29 +0,0 @@ -From http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/elfutils/files/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch - -From 2e2232d0935bf8ef6e66ebffba3be68a73b5b3e5 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Sun, 8 Sep 2019 15:57:59 -0700 -Subject: [PATCH] ppc_initreg.c: Incliude asm/ptrace.h for pt_regs definition - -Fixes -| ../../elfutils-0.176/backends/ppc_initreg.c:79:22: error: field 'r' has incomplete type -| struct pt_regs r; -| ^ - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - backends/ppc_initreg.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/backends/ppc_initreg.c -+++ b/backends/ppc_initreg.c -@@ -33,6 +33,7 @@ - #include - #if defined(__powerpc__) && defined(__linux__) - # include -+# include - # include - #endif - diff --git a/package/libs/elfutils/patches/003-libintl-compatibility.patch b/package/libs/elfutils/patches/003-libintl-compatibility.patch index 26fcc85c8b..3254dcffb2 100644 --- a/package/libs/elfutils/patches/003-libintl-compatibility.patch +++ b/package/libs/elfutils/patches/003-libintl-compatibility.patch @@ -11,9 +11,9 @@ Requires.private: zlib --- a/configure.ac +++ b/configure.ac -@@ -590,6 +590,9 @@ AC_CONFIG_FILES([config/libelf.pc config - AC_SUBST(USE_NLS, yes) - AM_PO_SUBDIRS +@@ -610,6 +610,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo + AM_GNU_GETTEXT_VERSION([0.19.6]) + AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6]) +case "$USE_NLS" in yes) intl_LDFLAGS="-lintl" ;; esac +AC_SUBST([intl_LDFLAGS]) @@ -21,51 +21,3 @@ dnl Appended to the config.h file. dnl We hide all kinds of configuration magic in lib/eu-config.h. AH_BOTTOM([#include ]) ---- a/libasm/libasmP.h -+++ b/libasm/libasmP.h -@@ -36,6 +36,9 @@ - - #include "libdwelf.h" - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) - ---- a/libdw/libdwP.h -+++ b/libdw/libdwP.h -@@ -37,6 +37,9 @@ - #include - #include "atomics.h" - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) ---- a/libdwfl/libdwflP.h -+++ b/libdwfl/libdwflP.h -@@ -47,6 +47,9 @@ - - typedef struct Dwfl_Process Dwfl_Process; - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) - ---- a/libelf/libelfP.h -+++ b/libelf/libelfP.h -@@ -39,6 +39,9 @@ - #include - #include - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) - diff --git a/package/libs/elfutils/patches/005-build_only_libs.patch b/package/libs/elfutils/patches/005-build_only_libs.patch index 501348f21c..304b85c47a 100644 --- a/package/libs/elfutils/patches/005-build_only_libs.patch +++ b/package/libs/elfutils/patches/005-build_only_libs.patch @@ -3,7 +3,7 @@ @@ -27,7 +27,7 @@ AM_MAKEFLAGS = --no-print-directory pkginclude_HEADERS = version.h - SUBDIRS = config m4 lib libelf libcpu backends libebl libdwelf libdwfl libdw \ + SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \ - libasm debuginfod src po doc tests + libasm diff --git a/package/libs/elfutils/patches/100-musl-compat.patch b/package/libs/elfutils/patches/100-musl-compat.patch index 508ff9e946..52b9f2c43b 100644 --- a/package/libs/elfutils/patches/100-musl-compat.patch +++ b/package/libs/elfutils/patches/100-musl-compat.patch @@ -1,27 +1,3 @@ -https://sourceware.org/bugzilla/show_bug.cgi?id=21002 - ---- a/lib/system.h -+++ b/lib/system.h -@@ -30,7 +30,18 @@ - #define LIB_SYSTEM_H 1 - - #include --#include -+#ifdef HAVE_ERROR_H -+#include "error.h" -+#else -+#include "err.h" -+#include -+#define error(status, errno, ...) \ -+ do { \ -+ fflush(stdout); \ -+ warn(__VA_ARGS__); \ -+ if (status) exit(status); \ -+ } while(0) -+#endif - #include - #include - #include --- a/libdw/libdw_alloc.c +++ b/libdw/libdw_alloc.c @@ -152,5 +152,5 @@ __attribute ((noreturn)) attribute_hidde @@ -33,15 +9,21 @@ https://sourceware.org/bugzilla/show_bug.cgi?id=21002 } --- a/libdwfl/dwfl_error.c +++ b/libdwfl/dwfl_error.c -@@ -154,7 +154,11 @@ dwfl_errmsg (int error) - switch (error &~ 0xffff) - { - case OTHER_ERROR (ERRNO): +@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) + static const char * + errnomsg(int error) + { +#if defined(__GLIBC__) && !defined(__UCLIBC__) - return strerror_r (error & 0xffff, "bad", 0); + /* Won't be changed by strerror_r, but not const so compiler doesn't throw warning */ + static char unknown[] = "unknown error"; + +@@ -150,6 +151,9 @@ errnomsg(int error) + static __thread char msg[128]; + return strerror_r (error, msg, sizeof (msg)) ? unknown : msg; + #endif +#else -+ return strerror (error & 0xffff); ++ return strerror (error & 0xffff); +#endif - case OTHER_ERROR (LIBELF): - return elf_errmsg (error & 0xffff); - case OTHER_ERROR (LIBDW): + } + + const char * diff --git a/package/libs/elfutils/patches/101-no-fts.patch b/package/libs/elfutils/patches/101-no-fts.patch index 29ec9ecac0..c4f0b88233 100644 --- a/package/libs/elfutils/patches/101-no-fts.patch +++ b/package/libs/elfutils/patches/101-no-fts.patch @@ -1,6 +1,6 @@ --- a/libdwfl/argp-std.c +++ b/libdwfl/argp-std.c -@@ -56,9 +56,6 @@ static const struct argp_option options[ +@@ -53,9 +53,6 @@ static const struct argp_option options[ { "linux-process-map", 'M', "FILE", 0, N_("Find addresses in files mapped as read from FILE" " in Linux /proc/PID/maps format"), 0 }, @@ -10,7 +10,7 @@ { "debuginfo-path", OPT_DEBUGINFO, "PATH", 0, N_("Search path for separate debuginfo files"), 0 }, { NULL, 0, NULL, 0, NULL, 0 } -@@ -85,15 +82,6 @@ static const Dwfl_Callbacks proc_callbac +@@ -82,15 +79,6 @@ static const Dwfl_Callbacks proc_callbac .find_elf = INTUSE(dwfl_linux_proc_find_elf), }; @@ -26,7 +26,7 @@ /* Structure held at state->HOOK. */ struct parse_opt { -@@ -226,43 +214,6 @@ parse_opt (int key, char *arg, struct ar +@@ -223,43 +211,6 @@ parse_opt (int key, char *arg, struct ar } break; diff --git a/package/libs/elfutils/patches/110-no-cdefs.patch b/package/libs/elfutils/patches/110-no-cdefs.patch deleted file mode 100644 index d66f1e924f..0000000000 --- a/package/libs/elfutils/patches/110-no-cdefs.patch +++ /dev/null @@ -1,26 +0,0 @@ -From e399540ab67ffe83ca3c4cb768a2f0f2f32a9057 Mon Sep 17 00:00:00 2001 -From: Rosen Penev -Date: Sun, 5 Apr 2020 15:56:59 -0700 -Subject: [PATCH] libelf: remove usage of sys/cdefs - -sys/cdefs is a deprecated glibc header that is unavailable with other -libc implementations such as musl. - -features.h under glibc includes sys/cdefs whereas it does not under musl. - -Signed-off-by: Rosen Penev ---- - lib/fixedsizehash.h | 1 - - libelf/elf.h | 10 ++++++---- - 2 files changed, 6 insertions(+), 5 deletions(-) - ---- a/lib/fixedsizehash.h -+++ b/lib/fixedsizehash.h -@@ -30,7 +30,6 @@ - #include - #include - #include --#include - - #include - From a8513e24615b01d3199f7f5c610ceb8ca8c74f20 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Wed, 28 Oct 2020 16:39:58 -0400 Subject: [PATCH 50/73] mbedtls: enable session tickets session tickets are a feature of TLSv1.2 and require less memory and overhead on the server than does managing a session cache Building mbedtls with support for session tickets will allow the feature to be used with lighttpd-1.4.56 and later. Signed-off-by: Glenn Strauss --- package/libs/mbedtls/patches/200-config.patch | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/package/libs/mbedtls/patches/200-config.patch b/package/libs/mbedtls/patches/200-config.patch index 1e3d41f0eb..67f331674c 100644 --- a/package/libs/mbedtls/patches/200-config.patch +++ b/package/libs/mbedtls/patches/200-config.patch @@ -126,15 +126,6 @@ /** * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO -@@ -1690,7 +1690,7 @@ - * - * Comment this macro to disable support for SSL session tickets - */ --#define MBEDTLS_SSL_SESSION_TICKETS -+//#define MBEDTLS_SSL_SESSION_TICKETS - - /** - * \def MBEDTLS_SSL_EXPORT_KEYS @@ -1720,7 +1720,7 @@ * * Comment this macro to disable support for truncated HMAC in SSL @@ -216,15 +207,6 @@ /** * \def MBEDTLS_RSA_C -@@ -2913,7 +2913,7 @@ - * - * Requires: MBEDTLS_CIPHER_C - */ --#define MBEDTLS_SSL_TICKET_C -+//#define MBEDTLS_SSL_TICKET_C - - /** - * \def MBEDTLS_SSL_CLI_C @@ -3013,7 +3013,7 @@ * * This module provides run-time version information. From a54b406ccb7b29a86e43e5535b86efede52157e6 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Mon, 3 Jan 2022 09:29:53 +0200 Subject: [PATCH 51/73] busybox: update to 1.35.0 Update busybox to 1.35.0 * refresh patches Config refresh: Refresh commands, run after busybox is first built once: cd package/utils/busybox/config/ ../convert_menuconfig.pl ../../../../build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/busybox-default/busybox-1.35.0 cd .. ./convert_defaults.pl ../../../build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/busybox-default/busybox-1.35.0/.config > Config-defaults.in Manual edits needed after config refresh: * Config-defaults.in: OpenWrt config symbol IPV6 logic applied to BUSYBOX_DEFAULT_FEATURE_IPV6 * Config-defaults.in: OpenWrt configTARGET_bcm53xx logic applied to BUSYBOX_DEFAULT_TRUNCATE (commit 547f1ec) * Config-defaults.in: OpenWrt logic applied to BUSYBOX_DEFAULT_LOGIN_SESSION_AS_CHILD (commit dc92917) * config/editors/Config.in: Add USE_GLIBC dependency to BUSYBOX_CONFIG_FEATURE_VI_REGEX_SEARCH (commit f141090) * config/shell/Config.in : change at "Options common to all shells" the symbol SHELL_ASH --> BUSYBOX_CONFIG_SHELL_ASH (discussion in http://lists.openwrt.org/pipermail/openwrt-devel/2021-January/033140.html Apparently our script does not see the hidden option while prepending config options with "BUSYBOX_CONFIG_" which leads to a missed dependency when the options are later evaluated.) * Edit Config.in files by adding quotes to sourced items in config/Config.in, config/networking/Config.in and config/util-linux/Config.in (commit 1da014f) Signed-off-by: Hannu Nyman --- package/utils/busybox/Config-defaults.in | 116 +++++++----- package/utils/busybox/Makefile | 4 +- .../utils/busybox/config/archival/Config.in | 14 ++ .../utils/busybox/config/coreutils/Config.in | 91 ++++++--- .../utils/busybox/config/findutils/Config.in | 43 ++++- package/utils/busybox/config/libbb/Config.in | 176 ++++++------------ .../utils/busybox/config/mailutils/Config.in | 14 +- .../utils/busybox/config/networking/Config.in | 39 +++- package/utils/busybox/config/procps/Config.in | 23 ++- .../301-ip-link-fix-netlink-msg-size.patch | 2 +- 10 files changed, 314 insertions(+), 208 deletions(-) diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in index 4b264a09a2..abe6d5431a 100644 --- a/package/utils/busybox/Config-defaults.in +++ b/package/utils/busybox/Config-defaults.in @@ -211,15 +211,24 @@ config BUSYBOX_DEFAULT_MD5_SMALL config BUSYBOX_DEFAULT_SHA3_SMALL int default 1 -config BUSYBOX_DEFAULT_FEATURE_FAST_TOP +config BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP bool default y -config BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS +config BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE bool default n -config BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES +config BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE bool - default n + default y +config BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB + int + default 4 +config BUSYBOX_DEFAULT_MONOTONIC_SYSCALL + bool + default y +config BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR + bool + default y config BUSYBOX_DEFAULT_FEATURE_EDITING bool default y @@ -289,30 +298,6 @@ config BUSYBOX_DEFAULT_UNICODE_NEUTRAL_TABLE config BUSYBOX_DEFAULT_UNICODE_PRESERVE_BROKEN bool default n -config BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP - bool - default y -config BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE - bool - default n -config BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE - bool - default y -config BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB - int - default 4 -config BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS - bool - default n -config BUSYBOX_DEFAULT_MONOTONIC_SYSCALL - bool - default y -config BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR - bool - default y -config BUSYBOX_DEFAULT_FEATURE_HWIB - bool - default n config BUSYBOX_DEFAULT_FEATURE_SEAMLESS_XZ bool default n @@ -391,6 +376,12 @@ config BUSYBOX_DEFAULT_FEATURE_CPIO_O config BUSYBOX_DEFAULT_FEATURE_CPIO_P bool default n +config BUSYBOX_DEFAULT_FEATURE_CPIO_IGNORE_DEVNO + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CPIO_RENUMBER_INODES + bool + default n config BUSYBOX_DEFAULT_DPKG bool default n @@ -484,6 +475,18 @@ config BUSYBOX_DEFAULT_FEATURE_UNZIP_XZ config BUSYBOX_DEFAULT_FEATURE_LZMA_FAST bool default n +config BUSYBOX_DEFAULT_FEATURE_VERBOSE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TIMEZONE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE + bool + default y config BUSYBOX_DEFAULT_BASENAME bool default y @@ -568,6 +571,9 @@ config BUSYBOX_DEFAULT_DF config BUSYBOX_DEFAULT_FEATURE_DF_FANCY bool default n +config BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS + bool + default n config BUSYBOX_DEFAULT_DIRNAME bool default y @@ -908,15 +914,6 @@ config BUSYBOX_DEFAULT_WHOAMI config BUSYBOX_DEFAULT_YES bool default y -config BUSYBOX_DEFAULT_FEATURE_VERBOSE - bool - default n -config BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS - bool - default y -config BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE - bool - default y config BUSYBOX_DEFAULT_CHVT bool default n @@ -1118,9 +1115,21 @@ config BUSYBOX_DEFAULT_FEATURE_FIND_PRINT0 config BUSYBOX_DEFAULT_FEATURE_FIND_MTIME bool default y +config BUSYBOX_DEFAULT_FEATURE_FIND_ATIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_CTIME + bool + default n config BUSYBOX_DEFAULT_FEATURE_FIND_MMIN bool default y +config BUSYBOX_DEFAULT_FEATURE_FIND_AMIN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_CMIN + bool + default n config BUSYBOX_DEFAULT_FEATURE_FIND_PERM bool default y @@ -1142,6 +1151,9 @@ config BUSYBOX_DEFAULT_FEATURE_FIND_NEWER config BUSYBOX_DEFAULT_FEATURE_FIND_INUM bool default n +config BUSYBOX_DEFAULT_FEATURE_FIND_SAMEFILE + bool + default n config BUSYBOX_DEFAULT_FEATURE_FIND_EXEC bool default y @@ -2211,6 +2223,15 @@ config BUSYBOX_DEFAULT_FEATURE_PREFER_IPV4_ADDRESS config BUSYBOX_DEFAULT_VERBOSE_RESOLUTION_ERRORS bool default y +config BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HWIB + bool + default n config BUSYBOX_DEFAULT_FEATURE_TLS_SHA1 bool default n @@ -2265,6 +2286,9 @@ config BUSYBOX_DEFAULT_DNSDOMAINNAME config BUSYBOX_DEFAULT_HTTPD bool default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_PORT_DEFAULT + int + default 80 config BUSYBOX_DEFAULT_FEATURE_HTTPD_RANGES bool default n @@ -2544,6 +2568,9 @@ config BUSYBOX_DEFAULT_TELNETD config BUSYBOX_DEFAULT_FEATURE_TELNETD_STANDALONE bool default n +config BUSYBOX_DEFAULT_FEATURE_TELNETD_PORT_DEFAULT + int + default 23 config BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT bool default n @@ -2700,6 +2727,9 @@ config BUSYBOX_DEFAULT_LPR config BUSYBOX_DEFAULT_LPQ bool default n +config BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET + string + default "" config BUSYBOX_DEFAULT_MAKEMIME bool default n @@ -2718,9 +2748,12 @@ config BUSYBOX_DEFAULT_FEATURE_REFORMIME_COMPAT config BUSYBOX_DEFAULT_SENDMAIL bool default n -config BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET - string - default "" +config BUSYBOX_DEFAULT_FEATURE_FAST_TOP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS + bool + default n config BUSYBOX_DEFAULT_FREE bool default y @@ -2835,9 +2868,6 @@ config BUSYBOX_DEFAULT_FEATURE_UPTIME_UTMP_SUPPORT config BUSYBOX_DEFAULT_WATCH bool default n -config BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS - bool - default n config BUSYBOX_DEFAULT_CHPST bool default n diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index 90d323b92b..2861e7d2e9 100644 --- a/package/utils/busybox/Makefile +++ b/package/utils/busybox/Makefile @@ -5,14 +5,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=busybox -PKG_VERSION:=1.34.1 +PKG_VERSION:=1.35.0 PKG_RELEASE:=$(AUTORELEASE) PKG_FLAGS:=essential PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://www.busybox.net/downloads \ http://sources.buildroot.net -PKG_HASH:=415fbd89e5344c96acf449d94a6f956dbed62e18e835fc83e064db33a34bd549 +PKG_HASH:=faeeb244c35a348a334f4a59e44626ee870fb07b6884d68c10ae8bc19f83a694 PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam PKG_BUILD_PARALLEL:=1 diff --git a/package/utils/busybox/config/archival/Config.in b/package/utils/busybox/config/archival/Config.in index ea167a46af..ac2b3d2056 100644 --- a/package/utils/busybox/config/archival/Config.in +++ b/package/utils/busybox/config/archival/Config.in @@ -204,6 +204,20 @@ config BUSYBOX_CONFIG_FEATURE_CPIO_P depends on BUSYBOX_CONFIG_FEATURE_CPIO_O help Passthrough mode. Rarely used. + +config BUSYBOX_CONFIG_FEATURE_CPIO_IGNORE_DEVNO + bool "Support --ignore-devno like GNU cpio" + default BUSYBOX_DEFAULT_FEATURE_CPIO_IGNORE_DEVNO + depends on BUSYBOX_CONFIG_FEATURE_CPIO_O && BUSYBOX_CONFIG_LONG_OPTS + help + Optionally ignore device numbers when creating archives. + +config BUSYBOX_CONFIG_FEATURE_CPIO_RENUMBER_INODES + bool "Support --renumber-inodes like GNU cpio" + default BUSYBOX_DEFAULT_FEATURE_CPIO_RENUMBER_INODES + depends on BUSYBOX_CONFIG_FEATURE_CPIO_O && BUSYBOX_CONFIG_LONG_OPTS + help + Optionally renumber inodes when creating archives. config BUSYBOX_CONFIG_DPKG bool "dpkg (43 kb)" default BUSYBOX_DEFAULT_DPKG diff --git a/package/utils/busybox/config/coreutils/Config.in b/package/utils/busybox/config/coreutils/Config.in index c84c1d5a94..835ce7950a 100644 --- a/package/utils/busybox/config/coreutils/Config.in +++ b/package/utils/busybox/config/coreutils/Config.in @@ -6,6 +6,47 @@ menu "Coreutils" +config BUSYBOX_CONFIG_FEATURE_VERBOSE + bool "Support verbose options (usually -v) for various applets" + default BUSYBOX_DEFAULT_FEATURE_VERBOSE + help + Enable cp -v, rm -v and similar messages. + Also enables long option (--verbose) if it exists. + Without this option, -v is accepted but ignored. + +comment "Common options for date and touch" + +config BUSYBOX_CONFIG_FEATURE_TIMEZONE + bool "Allow timezone in dates" + default BUSYBOX_DEFAULT_FEATURE_TIMEZONE + depends on BUSYBOX_CONFIG_DESKTOP + help + Permit the use of timezones when parsing user-provided data + strings, e.g. '1996-04-09 12:45:00 -0500'. + + This requires support for the '%z' extension to strptime() which + may not be available in all implementations. + +comment "Common options for cp and mv" + depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV + +config BUSYBOX_CONFIG_FEATURE_PRESERVE_HARDLINKS + bool "Preserve hard links" + default BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS + depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV + help + Allow cp and mv to preserve hard links. + +comment "Common options for df, du, ls" + depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS + +config BUSYBOX_CONFIG_FEATURE_HUMAN_READABLE + bool "Support human readable output (example 13k, 23M, 235G)" + default BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE + depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS + help + Allow df, du, and ls to have human readable output. + config BUSYBOX_CONFIG_BASENAME bool "basename (438 bytes)" default BUSYBOX_DEFAULT_BASENAME @@ -200,6 +241,26 @@ config BUSYBOX_CONFIG_FEATURE_DF_FANCY -a Show all filesystems -i Inodes -B Blocksize + +config BUSYBOX_CONFIG_FEATURE_SKIP_ROOTFS + bool "Skip rootfs in mount table" + default BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS + depends on BUSYBOX_CONFIG_DF + help + Ignore rootfs entry in mount table. + + In Linux, kernel has a special filesystem, rootfs, which is initially + mounted on /. It contains initramfs data, if kernel is configured + to have one. Usually, another file system is mounted over / early + in boot process, and therefore most tools which manipulate + mount table, such as df, will skip rootfs entry. + + However, some systems do not mount anything on /. + If you need to configure busybox for one of these systems, + you may find it useful to turn this option off to make df show + initramfs statistics. + + Otherwise, choose Y. config BUSYBOX_CONFIG_DIRNAME bool "dirname (329 bytes)" default BUSYBOX_DEFAULT_DIRNAME @@ -896,34 +957,4 @@ config BUSYBOX_CONFIG_YES yes is used to repeatedly output a specific string, or the default string 'y'. -comment "Common options" - -config BUSYBOX_CONFIG_FEATURE_VERBOSE - bool "Support verbose options (usually -v) for various applets" - default BUSYBOX_DEFAULT_FEATURE_VERBOSE - help - Enable cp -v, rm -v and similar messages. - Also enables long option (--verbose) if it exists. - Without this option, -v is accepted but ignored. - -comment "Common options for cp and mv" - depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV - -config BUSYBOX_CONFIG_FEATURE_PRESERVE_HARDLINKS - bool "Preserve hard links" - default BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS - depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV - help - Allow cp and mv to preserve hard links. - -comment "Common options for df, du, ls" - depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS - -config BUSYBOX_CONFIG_FEATURE_HUMAN_READABLE - bool "Support human readable output (example 13k, 23M, 235G)" - default BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE - depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS - help - Allow df, du, and ls to have human readable output. - endmenu diff --git a/package/utils/busybox/config/findutils/Config.in b/package/utils/busybox/config/findutils/Config.in index 89901ca59d..805d44f149 100644 --- a/package/utils/busybox/config/findutils/Config.in +++ b/package/utils/busybox/config/findutils/Config.in @@ -23,21 +23,53 @@ config BUSYBOX_CONFIG_FEATURE_FIND_PRINT0 interpreted by other programs. config BUSYBOX_CONFIG_FEATURE_FIND_MTIME - bool "Enable -mtime: modified time matching" + bool "Enable -mtime: modification time matching" default BUSYBOX_DEFAULT_FEATURE_FIND_MTIME depends on BUSYBOX_CONFIG_FIND help Allow searching based on the modification time of files, in days. +config BUSYBOX_CONFIG_FEATURE_FIND_ATIME + bool "Enable -atime: access time matching" + default BUSYBOX_DEFAULT_FEATURE_FIND_ATIME + depends on BUSYBOX_CONFIG_FEATURE_FIND_MTIME + help + Allow searching based on the access time of + files, in days. + +config BUSYBOX_CONFIG_FEATURE_FIND_CTIME + bool "Enable -ctime: status change timestamp matching" + default BUSYBOX_DEFAULT_FEATURE_FIND_CTIME + depends on BUSYBOX_CONFIG_FEATURE_FIND_MTIME + help + Allow searching based on the status change timestamp of + files, in days. + config BUSYBOX_CONFIG_FEATURE_FIND_MMIN - bool "Enable -mmin: modified time matching by minutes" + bool "Enable -mmin: modification time matching by minutes" default BUSYBOX_DEFAULT_FEATURE_FIND_MMIN depends on BUSYBOX_CONFIG_FIND help Allow searching based on the modification time of files, in minutes. +config BUSYBOX_CONFIG_FEATURE_FIND_AMIN + bool "Enable -amin: access time matching by minutes" + default BUSYBOX_DEFAULT_FEATURE_FIND_AMIN + depends on BUSYBOX_CONFIG_FEATURE_FIND_MMIN + help + Allow searching based on the access time of + files, in minutes. + +config BUSYBOX_CONFIG_FEATURE_FIND_CMIN + bool "Enable -cmin: status change timestamp matching by minutes" + default BUSYBOX_DEFAULT_FEATURE_FIND_CMIN + depends on BUSYBOX_CONFIG_FEATURE_FIND_MMIN + help + Allow searching based on the status change timestamp of + files, in minutes. + config BUSYBOX_CONFIG_FEATURE_FIND_PERM bool "Enable -perm: permissions matching" default BUSYBOX_DEFAULT_FEATURE_FIND_PERM @@ -79,6 +111,13 @@ config BUSYBOX_CONFIG_FEATURE_FIND_INUM default BUSYBOX_DEFAULT_FEATURE_FIND_INUM depends on BUSYBOX_CONFIG_FIND +config BUSYBOX_CONFIG_FEATURE_FIND_SAMEFILE + bool "Enable -samefile: reference file matching" + default BUSYBOX_DEFAULT_FEATURE_FIND_SAMEFILE + depends on BUSYBOX_CONFIG_FIND + help + Support the 'find -samefile' option for searching by a reference file. + config BUSYBOX_CONFIG_FEATURE_FIND_EXEC bool "Enable -exec: execute commands" default BUSYBOX_DEFAULT_FEATURE_FIND_EXEC diff --git a/package/utils/busybox/config/libbb/Config.in b/package/utils/busybox/config/libbb/Config.in index 906649c5c9..e050c4a915 100644 --- a/package/utils/busybox/config/libbb/Config.in +++ b/package/utils/busybox/config/libbb/Config.in @@ -117,32 +117,73 @@ config BUSYBOX_CONFIG_SHA3_SMALL 64-bit x86: +270 bytes of code, 45% faster 32-bit x86: +450 bytes of code, 75% faster -config BUSYBOX_CONFIG_FEATURE_FAST_TOP - bool "Faster /proc scanning code (+100 bytes)" - default BUSYBOX_DEFAULT_FEATURE_FAST_TOP # all "fast or small" options default to small +config BUSYBOX_CONFIG_FEATURE_NON_POSIX_CP + bool "Non-POSIX, but safer, copying to special nodes" + default BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP help - This option makes top and ps ~20% faster (or 20% less CPU hungry), - but code size is slightly bigger. + With this option, "cp file symlink" will delete symlink + and create a regular file. This does not conform to POSIX, + but prevents a symlink attack. + Similarly, "cp file device" will not send file's data + to the device. (To do that, use "cat file >device") -config BUSYBOX_CONFIG_FEATURE_ETC_NETWORKS - bool "Support /etc/networks" - default BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS +config BUSYBOX_CONFIG_FEATURE_VERBOSE_CP_MESSAGE + bool "Give more precise messages when copy fails (cp, mv etc)" + default BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE help - Enable support for network names in /etc/networks. This is - a rarely used feature which allows you to use names - instead of IP/mask pairs in route command. + Error messages with this feature enabled: -config BUSYBOX_CONFIG_FEATURE_ETC_SERVICES - bool "Consult /etc/services even for well-known ports" - default BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES + $ cp file /does_not_exist/file + cp: cannot create '/does_not_exist/file': Path does not exist + $ cp file /vmlinuz/file + cp: cannot stat '/vmlinuz/file': Path has non-directory component + + If this feature is not enabled, they will be, respectively: + + cp: cannot create '/does_not_exist/file': No such file or directory + cp: cannot stat '/vmlinuz/file': Not a directory + + This will cost you ~60 bytes. + +config BUSYBOX_CONFIG_FEATURE_USE_SENDFILE + bool "Use sendfile system call" + default BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE help - Look up e.g. "telnet" and "http" in /etc/services file - instead of assuming ports 23 and 80. - This is almost never necessary (everybody uses standard ports), - and it makes sense to avoid reading this file. - If you disable this option, in the cases where port is explicitly - specified as a service name (e.g. "telnet HOST PORTNAME"), - it will still be looked up in /etc/services. + When enabled, busybox will use the kernel sendfile() function + instead of read/write loops to copy data between file descriptors + (for example, cp command does this a lot). + If sendfile() doesn't work, copying code falls back to read/write + loop. sendfile() was originally implemented for faster I/O + from files to sockets, but since Linux 2.6.33 it was extended + to work for many more file types. + +config BUSYBOX_CONFIG_FEATURE_COPYBUF_KB + int "Copy buffer size, in kilobytes" + range 1 1024 + default BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB + help + Size of buffer used by cp, mv, install, wget etc. + Buffers which are 4 kb or less will be allocated on stack. + Bigger buffers will be allocated with mmap, with fallback to 4 kb + stack buffer if mmap fails. + +config BUSYBOX_CONFIG_MONOTONIC_SYSCALL + bool "Use clock_gettime(CLOCK_MONOTONIC) syscall" + default BUSYBOX_DEFAULT_MONOTONIC_SYSCALL + help + Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring + time intervals (time, ping, traceroute etc need this). + Probably requires Linux 2.6+. If not selected, gettimeofday + will be used instead (which gives wrong results if date/time + is reset). + +config BUSYBOX_CONFIG_IOCTL_HEX2STR_ERROR + bool "Use ioctl names rather than hex values in error messages" + default BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR + help + Use ioctl names rather than hex values in error messages + (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this + saves about 1400 bytes. config BUSYBOX_CONFIG_FEATURE_EDITING bool "Command line editing" @@ -358,96 +399,3 @@ config BUSYBOX_CONFIG_UNICODE_PRESERVE_BROKEN For example, this means that entering 'l', 's', ' ', 0xff, [Enter] at shell prompt will list file named 0xff (single char name with char value 255), not file named '?'. - -config BUSYBOX_CONFIG_FEATURE_NON_POSIX_CP - bool "Non-POSIX, but safer, copying to special nodes" - default BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP - help - With this option, "cp file symlink" will delete symlink - and create a regular file. This does not conform to POSIX, - but prevents a symlink attack. - Similarly, "cp file device" will not send file's data - to the device. (To do that, use "cat file >device") - -config BUSYBOX_CONFIG_FEATURE_VERBOSE_CP_MESSAGE - bool "Give more precise messages when copy fails (cp, mv etc)" - default BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE - help - Error messages with this feature enabled: - - $ cp file /does_not_exist/file - cp: cannot create '/does_not_exist/file': Path does not exist - $ cp file /vmlinuz/file - cp: cannot stat '/vmlinuz/file': Path has non-directory component - - If this feature is not enabled, they will be, respectively: - - cp: cannot create '/does_not_exist/file': No such file or directory - cp: cannot stat '/vmlinuz/file': Not a directory - - This will cost you ~60 bytes. - -config BUSYBOX_CONFIG_FEATURE_USE_SENDFILE - bool "Use sendfile system call" - default BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE - help - When enabled, busybox will use the kernel sendfile() function - instead of read/write loops to copy data between file descriptors - (for example, cp command does this a lot). - If sendfile() doesn't work, copying code falls back to read/write - loop. sendfile() was originally implemented for faster I/O - from files to sockets, but since Linux 2.6.33 it was extended - to work for many more file types. - -config BUSYBOX_CONFIG_FEATURE_COPYBUF_KB - int "Copy buffer size, in kilobytes" - range 1 1024 - default BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB - help - Size of buffer used by cp, mv, install, wget etc. - Buffers which are 4 kb or less will be allocated on stack. - Bigger buffers will be allocated with mmap, with fallback to 4 kb - stack buffer if mmap fails. - -config BUSYBOX_CONFIG_FEATURE_SKIP_ROOTFS - bool "Skip rootfs in mount table" - default BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS - help - Ignore rootfs entry in mount table. - - In Linux, kernel has a special filesystem, rootfs, which is initially - mounted on /. It contains initramfs data, if kernel is configured - to have one. Usually, another file system is mounted over / early - in boot process, and therefore most tools which manipulate - mount table, such as df, will skip rootfs entry. - - However, some systems do not mount anything on /. - If you need to configure busybox for one of these systems, - you may find it useful to turn this option off to make df show - initramfs statistics. - - Otherwise, choose Y. - -config BUSYBOX_CONFIG_MONOTONIC_SYSCALL - bool "Use clock_gettime(CLOCK_MONOTONIC) syscall" - default BUSYBOX_DEFAULT_MONOTONIC_SYSCALL - help - Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring - time intervals (time, ping, traceroute etc need this). - Probably requires Linux 2.6+. If not selected, gettimeofday - will be used instead (which gives wrong results if date/time - is reset). - -config BUSYBOX_CONFIG_IOCTL_HEX2STR_ERROR - bool "Use ioctl names rather than hex values in error messages" - default BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR - help - Use ioctl names rather than hex values in error messages - (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this - saves about 1400 bytes. - -config BUSYBOX_CONFIG_FEATURE_HWIB - bool "Support infiniband HW" - default BUSYBOX_DEFAULT_FEATURE_HWIB - help - Support for printing infiniband addresses in network applets. diff --git a/package/utils/busybox/config/mailutils/Config.in b/package/utils/busybox/config/mailutils/Config.in index a8632471a8..ea7ae6d649 100644 --- a/package/utils/busybox/config/mailutils/Config.in +++ b/package/utils/busybox/config/mailutils/Config.in @@ -1,6 +1,13 @@ # DO NOT EDIT. This file is generated from Config.src menu "Mail Utilities" +config BUSYBOX_CONFIG_FEATURE_MIME_CHARSET + string "Default charset" + default BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET + depends on BUSYBOX_CONFIG_MAKEMIME || BUSYBOX_CONFIG_REFORMIME || BUSYBOX_CONFIG_SENDMAIL + help + Default charset of the message. + config BUSYBOX_CONFIG_MAKEMIME bool "makemime (5.4 kb)" default BUSYBOX_DEFAULT_MAKEMIME @@ -41,11 +48,4 @@ config BUSYBOX_CONFIG_SENDMAIL help Barebones sendmail. -config BUSYBOX_CONFIG_FEATURE_MIME_CHARSET - string "Default charset" - default BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET - depends on BUSYBOX_CONFIG_MAKEMIME || BUSYBOX_CONFIG_REFORMIME || BUSYBOX_CONFIG_SENDMAIL - help - Default charset of the message. - endmenu diff --git a/package/utils/busybox/config/networking/Config.in b/package/utils/busybox/config/networking/Config.in index 79bb6b1f53..861e4f9bbf 100644 --- a/package/utils/busybox/config/networking/Config.in +++ b/package/utils/busybox/config/networking/Config.in @@ -47,6 +47,32 @@ config BUSYBOX_CONFIG_VERBOSE_RESOLUTION_ERRORS "can't resolve 'hostname.com'" and want to know more. This may increase size of your executable a bit. +config BUSYBOX_CONFIG_FEATURE_ETC_NETWORKS + bool "Support /etc/networks" + default BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS + help + Enable support for network names in /etc/networks. This is + a rarely used feature which allows you to use names + instead of IP/mask pairs in route command. + +config BUSYBOX_CONFIG_FEATURE_ETC_SERVICES + bool "Consult /etc/services even for well-known ports" + default BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES + help + Look up e.g. "telnet" and "http" in /etc/services file + instead of assuming ports 23 and 80. + This is almost never necessary (everybody uses standard ports), + and it makes sense to avoid reading this file. + If you disable this option, in the cases where port is explicitly + specified as a service name (e.g. "telnet HOST PORTNAME"), + it will still be looked up in /etc/services. + +config BUSYBOX_CONFIG_FEATURE_HWIB + bool "Support infiniband HW" + default BUSYBOX_DEFAULT_FEATURE_HWIB + help + Support for printing infiniband addresses in network applets. + config BUSYBOX_CONFIG_FEATURE_TLS_SHA1 bool "In TLS code, support ciphers which use deprecated SHA1" depends on BUSYBOX_CONFIG_TLS @@ -173,6 +199,12 @@ config BUSYBOX_CONFIG_HTTPD help HTTP server. +config BUSYBOX_CONFIG_FEATURE_HTTPD_PORT_DEFAULT + int "Default port" + default BUSYBOX_DEFAULT_FEATURE_HTTPD_PORT_DEFAULT + range 1 65535 + depends on BUSYBOX_CONFIG_HTTPD + config BUSYBOX_CONFIG_FEATURE_HTTPD_RANGES bool "Support 'Ranges:' header" default BUSYBOX_DEFAULT_FEATURE_HTTPD_RANGES @@ -774,7 +806,6 @@ config BUSYBOX_CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS bool "Enable long options" default BUSYBOX_DEFAULT_FEATURE_NSLOOKUP_LONG_OPTIONS depends on BUSYBOX_CONFIG_FEATURE_NSLOOKUP_BIG && BUSYBOX_CONFIG_LONG_OPTS - config BUSYBOX_CONFIG_NTPD bool "ntpd (22 kb)" default BUSYBOX_DEFAULT_NTPD @@ -945,6 +976,12 @@ config BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE help Selecting this will make telnetd able to run standalone. +config BUSYBOX_CONFIG_FEATURE_TELNETD_PORT_DEFAULT + int "Default port" + default BUSYBOX_DEFAULT_FEATURE_TELNETD_PORT_DEFAULT + range 1 65535 + depends on BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE + config BUSYBOX_CONFIG_FEATURE_TELNETD_INETD_WAIT bool "Support -w SEC option (inetd wait mode)" default BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT diff --git a/package/utils/busybox/config/procps/Config.in b/package/utils/busybox/config/procps/Config.in index e6c3271254..0501daf8fd 100644 --- a/package/utils/busybox/config/procps/Config.in +++ b/package/utils/busybox/config/procps/Config.in @@ -6,6 +6,21 @@ menu "Process Utilities" +config BUSYBOX_CONFIG_FEATURE_FAST_TOP + bool "Faster /proc scanning code (+100 bytes)" + default BUSYBOX_DEFAULT_FEATURE_FAST_TOP # all "fast or small" options default to small + help + This option makes top and ps ~20% faster (or 20% less CPU hungry), + but code size is slightly bigger. + +config BUSYBOX_CONFIG_FEATURE_SHOW_THREADS + bool "Support thread display in ps/pstree/top" + default BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS + depends on BUSYBOX_CONFIG_PS || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_PSTREE + help + Enables the ps -T option, showing of threads in pstree, + and 'h' command in top. + config BUSYBOX_CONFIG_FREE bool "free (3.1 kb)" default BUSYBOX_DEFAULT_FREE @@ -259,12 +274,4 @@ config BUSYBOX_CONFIG_WATCH watch is used to execute a program periodically, showing output to the screen. -config BUSYBOX_CONFIG_FEATURE_SHOW_THREADS - bool "Support thread display in ps/pstree/top" - default BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS - depends on BUSYBOX_CONFIG_PS || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_PSTREE - help - Enables the ps -T option, showing of threads in pstree, - and 'h' command in top. - endmenu diff --git a/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch b/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch index f7cd2322c9..f4c0a80922 100644 --- a/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch +++ b/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch @@ -1,6 +1,6 @@ --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c -@@ -652,7 +652,7 @@ static int do_add_or_delete(char **argv, +@@ -683,7 +683,7 @@ static int do_add_or_delete(char **argv, } xrtnl_open(&rth); ll_init_map(&rth); From 5ee1e045174bad1b7f2754bb022346acc60220f5 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Thu, 16 Dec 2021 12:50:59 +0100 Subject: [PATCH 52/73] ltq-vdsl: move to the default device name /dev/dsl_cpe_api/0 This makes patching it for ltq-vdsl-app unnecessary and paves the way for VRX518 support. Signed-off-by: Andre Heider --- .../kernel/lantiq/ltq-vdsl/patches/100-compat.patch | 4 ++-- .../config/ltq-vdsl-app/patches/100-compat.patch | 11 ----------- .../config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/package/kernel/lantiq/ltq-vdsl/patches/100-compat.patch b/package/kernel/lantiq/ltq-vdsl/patches/100-compat.patch index edacd5f6b8..7670fe6a00 100644 --- a/package/kernel/lantiq/ltq-vdsl/patches/100-compat.patch +++ b/package/kernel/lantiq/ltq-vdsl/patches/100-compat.patch @@ -82,9 +82,9 @@ DSL_DRV_DevNodeInit(); -+ dsl_class = class_create(THIS_MODULE, "dsl_cpe_api0"); ++ dsl_class = class_create(THIS_MODULE, DRV_DSL_CPE_API_DEV_NAME); + dsl_devt = MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0); -+ device_create(dsl_class, NULL, dsl_devt, NULL, "dsl_cpe_api0"); ++ device_create(dsl_class, NULL, dsl_devt, NULL, "dsl_cpe_api/0"); + return 0; } diff --git a/package/network/config/ltq-vdsl-app/patches/100-compat.patch b/package/network/config/ltq-vdsl-app/patches/100-compat.patch index 6b738cfe66..6bc359c3cc 100644 --- a/package/network/config/ltq-vdsl-app/patches/100-compat.patch +++ b/package/network/config/ltq-vdsl-app/patches/100-compat.patch @@ -9,14 +9,3 @@ DSL_CPE_SIC_SET(DSL_TC_ATM, DSL_EMF_TC_CLEANED, DSL_EMF_TC_CLEANED, DSL_SYSTEMIF_MII, \ DSL_TC_EFM, DSL_EMF_TC_CLEANED, DSL_EMF_TC_CLEANED, DSL_SYSTEMIF_MII), DSL_CPE_MAC_CFG_SET(DSL_EFM_SPEED_100, DSL_EFM_DUPLEX_FULL, DSL_EFM_FLOWCTRL_ON, DSL_EFM_AUTONEG_OFF, \ ---- a/src/dsl_cpe_control.c -+++ b/src/dsl_cpe_control.c -@@ -6761,7 +6761,7 @@ DSL_int_t dsl_cpe_daemon ( - for (nDevice = 0; nDevice < DSL_CPE_MAX_DSL_ENTITIES; nDevice++) - { - #if defined(INCLUDE_DSL_CPE_API_VRX) -- sprintf (device, "%s/%d", DSL_CPE_DEVICE_NAME, nDevice); -+ sprintf (device, "%s%d", DSL_CPE_DEVICE_NAME, nDevice); - #else - sprintf (device, "%s", DSL_CPE_DEVICE_NAME); - #endif /* defined(INCLUDE_DSL_CPE_API_VRX)*/ diff --git a/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c b/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c index 707acdc606..93eecaf71d 100644 --- a/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c +++ b/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c @@ -735,7 +735,7 @@ static int metrics(struct ubus_context *ctx, struct ubus_object *obj, vector_t vector = VECTOR_UNKNOWN; #ifndef INCLUDE_DSL_CPE_API_DANUBE - fd = open(DSL_CPE_DEVICE_NAME "0", O_RDWR, 0644); + fd = open(DSL_CPE_DEVICE_NAME "/0", O_RDWR, 0644); #else fd = open(DSL_CPE_DEVICE_NAME, O_RDWR, 0644); #endif From 9d878d84227ffac92b5616fb9a4253cae28fc580 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Thu, 28 Oct 2021 18:56:13 +0200 Subject: [PATCH 53/73] ltq-ifxos: update to 1.7.1 Signed-off-by: Jan Hoffmann [fix warnings, switch to tag tarball, update patches] Signed-off-by: Andre Heider --- package/kernel/lantiq/ltq-ifxos/Makefile | 20 ++- .../ltq-ifxos/patches/001-warnings.patch | 32 ++-- .../ltq-ifxos/patches/002-fix-compile.patch | 18 +-- .../lantiq/ltq-ifxos/patches/020-no-O3.patch | 2 +- .../lantiq/ltq-ifxos/patches/100-compat.patch | 142 +----------------- ...ion-failure-from-inclusion-of-wrong-.patch | 54 ------- 6 files changed, 34 insertions(+), 234 deletions(-) delete mode 100644 package/kernel/lantiq/ltq-ifxos/patches/200-Fix-app-compilation-failure-from-inclusion-of-wrong-.patch diff --git a/package/kernel/lantiq/ltq-ifxos/Makefile b/package/kernel/lantiq/ltq-ifxos/Makefile index e98cb21eff..bc586faaf1 100644 --- a/package/kernel/lantiq/ltq-ifxos/Makefile +++ b/package/kernel/lantiq/ltq-ifxos/Makefile @@ -6,13 +6,17 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk -PKG_NAME:=lib_ifxos -PKG_VERSION:=1.5.19 -PKG_RELEASE:=4 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_URL:=https://github.com/xdarklight/$(PKG_NAME)/archive/v$(PKG_VERSION) -PKG_HASH:=ed7fe39311d7a4a13d23ed0ae2445c0d825b472b5a98da9b72bcaabcf5ed2d5f +PKG_NAME:=ifxos +PKG_VERSION:=1.7.1 +PKG_RELEASE:=$(AUTORELEASE) + +UGW_VERSION=8.5.2.10 +UGW_BASENAME=$(PKG_NAME)-ugw_$(UGW_VERSION) + +PKG_SOURCE:=$(UGW_BASENAME).tar.bz2 +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(UGW_BASENAME) +PKG_SOURCE_URL:=https://gitlab.com/prpl-foundation/intel/$(PKG_NAME)/-/archive/ugw_$(UGW_VERSION)/ +PKG_HASH:=055a1f5eab0abfaac34ac7b1613b93ec341fe9ae8462cb11c36c2b0989ce0ca7 PKG_MAINTAINER:=John Crispin PKG_LICENSE:=GPL-2.0 BSD-2-Clause PKG_LICENSE_FILES:=LICENSE @@ -45,7 +49,7 @@ ifdef CONFIG_TARGET_lantiq $(INSTALL_DIR) $(1)/usr/{lib,include/ifxos} $(CP) $(PKG_BUILD_DIR)/src/include/* $(1)/usr/include/ifxos mkdir -p $(1)/usr/lib - $(CP) $(PKG_BUILD_DIR)/src/libifxos.a $(1)/usr/lib/libifxos.a + $(CP) $(PKG_BUILD_DIR)/src/.libs/libifxos.a $(1)/usr/lib/libifxos.a endef endif diff --git a/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch b/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch index 78940649c5..2c04f9b009 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/001-warnings.patch @@ -1,24 +1,10 @@ ---- a/src/include/linux/ifxos_linux_thread.h -+++ b/src/include/linux/ifxos_linux_thread.h -@@ -206,7 +206,7 @@ typedef struct - /** - LINUX User Thread - map the Thread ID. - */ --typedef int IFXOS_thread_t; -+typedef pthread_t IFXOS_thread_t; +--- a/src/include/linux/ifxos_linux_common.h ++++ b/src/include/linux/ifxos_linux_common.h +@@ -49,6 +49,7 @@ + IFX Linux adaptation - Includes (Linux Kernel) + ========================================================================= */ + #include ++#include + #include - /** - LINUX Kernel Process - map the Process ID. ---- a/src/linux/ifxos_linux_socket_appl.c -+++ b/src/linux/ifxos_linux_socket_appl.c -@@ -363,8 +363,8 @@ IFX_int_t IFXOS_SocketSendTo( - IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR); - IFXOS_RETURN_IF_ARG_LE_ZERO(bufSize_byte, IFX_ERROR); - -- ret = (IFX_int_t)sendto((int)socFd, (const char*)pBuffer, -- (int)bufSize_byte, 0, pSocAddr, sizeof(IFXOS_sockAddr_t)); -+ ret = (IFX_int_t)sendto(socFd, pBuffer, -+ bufSize_byte, 0, (struct sockaddr *)pSocAddr, sizeof(IFXOS_sockAddr_t)); - - return ret; - } + /* ============================================================================ diff --git a/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch b/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch index 38722290de..7d78c12685 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch @@ -1,18 +1,18 @@ ---- a/src/linux/ifxos_linux_copy_user_space_drv.c -+++ b/src/linux/ifxos_linux_copy_user_space_drv.c -@@ -29,7 +29,7 @@ - #ifdef MODULE - #include - #endif +--- a/src/linux/ifxos_linux_socket_drv.c ++++ b/src/linux/ifxos_linux_socket_drv.c +@@ -28,7 +28,7 @@ + #include + #include + #include -#include +#include #include "ifx_types.h" #include "ifxos_rt_if_check.h" ---- a/src/linux/ifxos_linux_socket_drv.c -+++ b/src/linux/ifxos_linux_socket_drv.c +--- a/src/linux/ifxos_linux_socket_ipv6_drv.c ++++ b/src/linux/ifxos_linux_socket_ipv6_drv.c @@ -25,7 +25,7 @@ - #endif + #include #include #include -#include diff --git a/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch b/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch index d2e816f5c0..e883b5b1fd 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/020-no-O3.patch @@ -1,6 +1,6 @@ --- a/src/Makefile.am +++ b/src/Makefile.am -@@ -45,8 +45,6 @@ endif !HAVE_GCC +@@ -48,8 +48,6 @@ endif !HAVE_GCC if ENABLE_DEBUG used_gcc_cflags += -O1 -g diff --git a/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch b/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch index d9bbf8d7cc..0fc2c2c5e6 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/100-compat.patch @@ -1,119 +1,3 @@ ---- a/src/linux/ifxos_linux_thread_drv.c -+++ b/src/linux/ifxos_linux_thread_drv.c -@@ -38,6 +38,7 @@ - #include - #endif - #include -+#include - - - #include "ifx_types.h" -@@ -70,10 +71,6 @@ - #if ( defined(IFXOS_HAVE_THREAD) && (IFXOS_HAVE_THREAD == 1) ) - - --IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup( -- IFXOS_ThreadCtrl_t *pThrCntrl); -- -- - /* ============================================================================ - IFX Linux adaptation - Kernel Thread handling - ========================================================================= */ -@@ -98,9 +95,9 @@ IFXOS_STATIC IFX_int32_t IFXOS_KernelThr - - IFX_SUCCESS on success - - IFX_ERROR on error - */ --IFXOS_STATIC IFX_int32_t IFXOS_KernelThreadStartup( -- IFXOS_ThreadCtrl_t *pThrCntrl) -+int IFXOS_KernelThreadStartup(void *data) - { -+ IFXOS_ThreadCtrl_t *pThrCntrl = (IFXOS_ThreadCtrl_t*) data; - IFX_int32_t retVal = IFX_ERROR; - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) - struct task_struct *kthread = current; -@@ -141,7 +138,7 @@ IFXOS_STATIC IFX_int32_t IFXOS_KernelThr - /* let others run */ - unlock_kernel(); - #else -- daemonize(pThrCntrl->thrParams.pName); -+ //daemonize(pThrCntrl->thrParams.pName); - - /* Enable signals in Kernel >= 2.6 */ - allow_signal(SIGKILL); -@@ -221,9 +218,11 @@ IFX_int32_t IFXOS_ThreadInit( - init_completion(&pThrCntrl->thrCompletion); - - /* start kernel thread via the wrapper function */ -- pThrCntrl->tid = kernel_thread( (IFXOS_KERNEL_THREAD_StartRoutine)IFXOS_KernelThreadStartup, -- (void *)pThrCntrl, -- IFXOS_DRV_THREAD_OPTIONS); -+ pThrCntrl->tid = kthread_run(IFXOS_KernelThreadStartup, (void *)pThrCntrl, pThrCntrl->thrParams.pName); -+ if (IS_ERR(pThrCntrl->tid)) { -+ IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, -+ ("IFXOS ERROR - Problem creating thread: %li" IFXOS_CRLF, PTR_ERR(pThrCntrl->tid))); -+ } - - pThrCntrl->bValid = IFX_TRUE; - ---- a/src/include/linux/ifxos_linux_thread.h -+++ b/src/include/linux/ifxos_linux_thread.h -@@ -152,7 +152,7 @@ typedef struct - IFXOS_ThreadFunction_t pThrFct; - - /** Kernel thread process ID */ -- IFX_int32_t tid; -+ struct task_struct *tid; - - /** requested kernel thread priority */ - IFX_int32_t nPriority; ---- a/src/linux/ifxos_linux_socket_drv.c -+++ b/src/linux/ifxos_linux_socket_drv.c -@@ -19,6 +19,7 @@ - /* ============================================================================ - IFX Linux adaptation - Global Includes - Kernel - ========================================================================= */ -+#include - #include - #ifdef MODULE - #include -@@ -166,23 +167,33 @@ IFX_int_t IFXOS_SocketSendTo( - IFXOS_RETURN_IF_POINTER_NULL(pBuffer, IFX_ERROR); - IFXOS_RETURN_IF_ARG_LE_ZERO(bufSize_byte, IFX_ERROR); - -+ iov.iov_base = pBuffer; -+ iov.iov_len = (unsigned int) bufSize_byte; -+ - msg.msg_name = (void *) pSocAddr; - msg.msg_namelen = sizeof(IFXOS_sockAddr_t); -- msg.msg_iov = &iov; -- msg.msg_iovlen = 1; - msg.msg_control = IFX_NULL; - msg.msg_controllen = 0; - msg.msg_flags = MSG_DONTWAIT; - -- msg.msg_iov->iov_base = pBuffer; -- msg.msg_iov->iov_len = (unsigned int) bufSize_byte; -+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) -+ msg.msg_iov = &iov; -+ msg.msg_iovlen = 1; -+#else -+ iov_iter_init(&msg.msg_iter, WRITE, &iov, 1, bufSize_byte); -+#endif - - /* Modify address limitation which is used if user space is calling - kernel space, otherwise sock_sendmsg() will fail.*/ - old_fs = get_fs(); - set_fs(KERNEL_DS); - -+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) - ret = sock_sendmsg((struct socket *) socFd, &msg, bufSize_byte); -+#else -+ ret = sock_sendmsg((struct socket *) socFd, &msg); -+#endif -+ - set_fs(old_fs); - - return ret; --- a/src/linux/ifxos_linux_memory_map_drv.c +++ b/src/linux/ifxos_linux_memory_map_drv.c @@ -25,6 +25,7 @@ @@ -124,28 +8,8 @@ #include #ifdef MODULE #include -@@ -87,6 +88,7 @@ IFX_int32_t IFXOS_Phy2VirtMap( - IFXOS_RETURN_IF_POINTER_NOT_NULL(*ppVirtAddr, IFX_ERROR); - IFXOS_RETURN_IF_ARG_LE_ZERO(addrRangeSize_byte, IFX_ERROR); - -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) - if ( check_mem_region(physicalAddr, addrRangeSize_byte) ) - { - IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, -@@ -98,10 +100,25 @@ IFX_int32_t IFXOS_Phy2VirtMap( - - /* can't fail */ - request_mem_region(physicalAddr, addrRangeSize_byte, pName); -+#else -+ if ( !request_mem_region(physicalAddr, addrRangeSize_byte, pName) ) -+ { -+ IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, -+ ("IFXOS: ERROR Phy2Virt map, region request - addr 0x%08lX (size 0x%lX) not free" IFXOS_CRLF, -+ physicalAddr, addrRangeSize_byte)); -+ -+ return IFX_ERROR; -+ } -+#endif +@@ -97,8 +98,13 @@ IFX_int32_t IFXOS_Phy2VirtMap( + } /* remap memory (not cache able): physical --> virtual */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) @@ -157,4 +21,4 @@ + if (pVirtAddr == IFX_NULL) { - IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, + IFXOS_PRN_USR_ERR_NL( IFXOS, IFXOS_PRN_LEVEL_ERR, diff --git a/package/kernel/lantiq/ltq-ifxos/patches/200-Fix-app-compilation-failure-from-inclusion-of-wrong-.patch b/package/kernel/lantiq/ltq-ifxos/patches/200-Fix-app-compilation-failure-from-inclusion-of-wrong-.patch deleted file mode 100644 index 453d85849b..0000000000 --- a/package/kernel/lantiq/ltq-ifxos/patches/200-Fix-app-compilation-failure-from-inclusion-of-wrong-.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 7d52945b0b261c54ec736ecc435936c5fb8b81a4 Mon Sep 17 00:00:00 2001 -From: Yousong Zhou -Date: Thu, 30 Nov 2017 11:07:12 +0800 -Subject: [PATCH] Fix app compilation failure from inclusion of wrong headers - -Compiling against glibc can fail with the following errors - - In file included from /home/stefan/Router/o26431-vmmc_v5/source/staging_dir/toolchain-mips_24kc_gcc-5.5.0_glibc/include/bits/fcntl-linux.h:321:0, - from /home/stefan/Router/o26431-vmmc_v5/source/staging_dir/toolchain-mips_24kc_gcc-5.5.0_glibc/include/bits/fcntl.h:104, - from /home/stefan/Router/o26431-vmmc_v5/source/staging_dir/toolchain-mips_24kc_gcc-5.5.0_glibc/include/fcntl.h:35, - from linux/ifxos_linux_device_access_appl.c:30: - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:12:2: error: unknown type name '__s16' - __s16 l_type; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:13:2: error: unknown type name '__s16' - __s16 l_whence; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:14:2: error: unknown type name '__s64' - __s64 l_start; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:15:2: error: unknown type name '__s64' - __s64 l_len; /* len == 0 means until end of file */ - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:16:2: error: unknown type name '__s32' - __s32 l_sysid; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:17:2: error: unknown type name '__u32' - __u32 l_pid; - ^ - /home/stefan/Router/o26431-vmmc_v5/source/build_dir/target-mips_24kc_glibc/linux-lantiq_xrx200/linux-4.9.65/include/linux/falloc.h:18:2: error: unknown type name '__s32' - __s32 l_pad[4]; /* reserved area */ - ^ - Makefile:1945: recipe for target 'libifxos_a-ifxos_linux_device_access_appl.o' failed - -Ref: https://bugs.openwrt.org/index.php?do=details&task_id=1196 ---- - src/Makefile.am | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -14,11 +14,7 @@ lib_LIBRARIES = libifxos.a - - AM_CPPFLAGS = \ - -I@srcdir@\ -- -I@srcdir@/include \ -- -I@KERNEL_INCL_PATH@ \ -- -I@KERNEL_BUILD_PATH@/include \ -- -I@KERNEL_BUILD_PATH@/include2 \ -- -I$(TARGET_INCL_PATH) -+ -I@srcdir@/include - - if HAVE_GCC - From 3fe253c6abc2ccc02ea789cffc47761b2381c6ca Mon Sep 17 00:00:00 2001 From: Marty Jones Date: Sat, 10 Jul 2021 04:00:30 -0400 Subject: [PATCH 54/73] linux-firmware: add new package r8152-firmware Linux upstream commit https://github.com/torvalds/linux/commit/9370f2d05a2a150b0aa719a3070b26d478180df3 add load firmware file through request_firmware,this affect the nanopi r2s and some USB adapters in kernel 5.10 with this error: 'r8152 4-1:1.0: unable to load firmware patch rtl_nic/rtl8153b-2.fw' This patch split the USB NIC firmware files from r8169 firmware, and adds r8152-firmware to r8152 driver. Add kmod-usb-net-cdc-ncm to support RTL8156A and RTL8156B 2.5G ethernet adapters supported since v5.13-rc1. https://github.com/torvalds/linux/commit/195aae321c829dd1945900d75561e6aa79cce208 Signed-off-by: Marty Jones --- package/firmware/linux-firmware/realtek.mk | 15 ++++++++++++++- package/kernel/linux/modules/usb.mk | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package/firmware/linux-firmware/realtek.mk b/package/firmware/linux-firmware/realtek.mk index 081cc1b37c..c883e8ba59 100644 --- a/package/firmware/linux-firmware/realtek.mk +++ b/package/firmware/linux-firmware/realtek.mk @@ -1,8 +1,21 @@ +Package/r8152-firmware = $(call Package/firmware-default,RealTek RTL8152 firmware) +define Package/r8152-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/rtl_nic + $(CP) \ + $(PKG_BUILD_DIR)/rtl_nic/rtl8153* \ + $(PKG_BUILD_DIR)/rtl_nic/rtl8156* \ + $(1)/lib/firmware/rtl_nic +endef +$(eval $(call BuildPackage,r8152-firmware)) + Package/r8169-firmware = $(call Package/firmware-default,RealTek RTL8169 firmware) define Package/r8169-firmware/install $(INSTALL_DIR) $(1)/lib/firmware/rtl_nic $(CP) \ - $(PKG_BUILD_DIR)/rtl_nic/* \ + $(PKG_BUILD_DIR)/rtl_nic/rtl810* \ + $(PKG_BUILD_DIR)/rtl_nic/rtl8125* \ + $(PKG_BUILD_DIR)/rtl_nic/rtl8168* \ + $(PKG_BUILD_DIR)/rtl_nic/rtl84* \ $(1)/lib/firmware/rtl_nic endef $(eval $(call BuildPackage,r8169-firmware)) diff --git a/package/kernel/linux/modules/usb.mk b/package/kernel/linux/modules/usb.mk index ce7c57bf73..8815b153ef 100644 --- a/package/kernel/linux/modules/usb.mk +++ b/package/kernel/linux/modules/usb.mk @@ -1356,6 +1356,7 @@ $(eval $(call KernelPackage,usb-net-rtl8150)) define KernelPackage/usb-net-rtl8152 TITLE:=Kernel module for USB-to-Ethernet Realtek convertors + DEPENDS:=+r8152-firmware +kmod-crypto-sha256 +kmod-usb-net-cdc-ncm KCONFIG:=CONFIG_USB_RTL8152 FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/r8152.ko AUTOLOAD:=$(call AutoProbe,r8152) From a372946e6080b253f42ab1d3af97f4929c269ed9 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Fri, 7 Jan 2022 20:50:50 -0800 Subject: [PATCH 55/73] elfutils: Add missing musl-fts dependency libdw depends on libfts.so when building with the musl-libc library, add this missing dependency. Fixes: 6835ea13f0fa ("elfutils: update to 0.186") Signed-off-by: Florian Fainelli --- package/libs/elfutils/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/libs/elfutils/Makefile b/package/libs/elfutils/Makefile index f9a350f9fe..9aa78d8352 100644 --- a/package/libs/elfutils/Makefile +++ b/package/libs/elfutils/Makefile @@ -44,7 +44,7 @@ endef define Package/libdw $(call Package/elfutils/Default) - DEPENDS:=+libelf +libbz2 + DEPENDS:=+libelf +libbz2 +USE_MUSL:musl-fts TITLE+= (libdw) endef From 46468fc9d5d95279ab0b70914ae85a31a0a5efd6 Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski Date: Sat, 22 May 2021 20:07:56 +0200 Subject: [PATCH 56/73] lantiq: replace patches with version accepted upstream Replace recently added patches with version accepted upstream. Signed-off-by: Aleksander Jan Bajkowski --- .../files/arch/mips/boot/dts/lantiq/vr9.dtsi | 2 - ...ake-the-burst-length-configurable-b.patch} | 12 +-- ...ure-the-burst-length-in-ethernet-dr.patch} | 18 +++-- ...x200-Hardcode-the-burst-length-value.patch | 73 +++++++++++++++++++ ...et-lantiq_etop-Fix-compilation-error.patch | 26 +++++++ 5 files changed, 116 insertions(+), 15 deletions(-) rename target/linux/lantiq/patches-5.10/{0113-MIPS-lantiq-dma-make-a-burst-length-configurable-in-.patch => 0310-v5.16-MIPS-lantiq-dma-make-the-burst-length-configurable-b.patch} (86%) rename target/linux/lantiq/patches-5.10/{0710-net-lantiq-configure-burst-length-for-ethernet.patch => 0710-v5.16-net-lantiq-configure-the-burst-length-in-ethernet-dr.patch} (86%) create mode 100644 target/linux/lantiq/patches-5.10/0711-v5.16-net-lantiq_xrx200-Hardcode-the-burst-length-value.patch create mode 100644 target/linux/lantiq/patches-5.10/0712-v5.16-net-ethernet-lantiq_etop-Fix-compilation-error.patch diff --git a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi index e379b07b53..27858be28f 100644 --- a/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi +++ b/target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9.dtsi @@ -488,8 +488,6 @@ interrupt-names = "tx", "rx"; resets = <&reset0 21 16>, <&reset0 8 8>, <&reset0 3 3>; reset-names = "switch", "ppe", "ppe_dsp"; - lantiq,tx-burst-length = <8>; - lantiq,rx-burst-length = <8>; #address-cells = <1>; #size-cells = <0>; diff --git a/target/linux/lantiq/patches-5.10/0113-MIPS-lantiq-dma-make-a-burst-length-configurable-in-.patch b/target/linux/lantiq/patches-5.10/0310-v5.16-MIPS-lantiq-dma-make-the-burst-length-configurable-b.patch similarity index 86% rename from target/linux/lantiq/patches-5.10/0113-MIPS-lantiq-dma-make-a-burst-length-configurable-in-.patch rename to target/linux/lantiq/patches-5.10/0310-v5.16-MIPS-lantiq-dma-make-the-burst-length-configurable-b.patch index fab2440453..33c06e9d77 100644 --- a/target/linux/lantiq/patches-5.10/0113-MIPS-lantiq-dma-make-a-burst-length-configurable-in-.patch +++ b/target/linux/lantiq/patches-5.10/0310-v5.16-MIPS-lantiq-dma-make-the-burst-length-configurable-b.patch @@ -1,12 +1,14 @@ -From 6615eeb39f7a110a196f20acbfb3a017da4d75d2 Mon Sep 17 00:00:00 2001 +From 49293bbc50cb7d44223eb49e0f7cb38e7dac2361 Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski -Date: Fri, 14 May 2021 21:25:08 +0200 -Subject: [PATCH 4/5] MIPS: lantiq: dma: make a burst length configurable in - drivers +Date: Tue, 14 Sep 2021 23:21:01 +0200 +Subject: [PATCH 4/5] MIPS: lantiq: dma: make the burst length configurable by + the drivers -Make a burst length configurable in drivers. +Make the burst length configurable by the drivers. Signed-off-by: Aleksander Jan Bajkowski +Acked-by: Hauke Mehrtens +Signed-off-by: David S. Miller --- .../include/asm/mach-lantiq/xway/xway_dma.h | 2 +- arch/mips/lantiq/xway/dma.c | 38 ++++++++++++++++--- diff --git a/target/linux/lantiq/patches-5.10/0710-net-lantiq-configure-burst-length-for-ethernet.patch b/target/linux/lantiq/patches-5.10/0710-v5.16-net-lantiq-configure-the-burst-length-in-ethernet-dr.patch similarity index 86% rename from target/linux/lantiq/patches-5.10/0710-net-lantiq-configure-burst-length-for-ethernet.patch rename to target/linux/lantiq/patches-5.10/0710-v5.16-net-lantiq-configure-the-burst-length-in-ethernet-dr.patch index 0a2996813a..bf3b903616 100644 --- a/target/linux/lantiq/patches-5.10/0710-net-lantiq-configure-burst-length-for-ethernet.patch +++ b/target/linux/lantiq/patches-5.10/0710-v5.16-net-lantiq-configure-the-burst-length-in-ethernet-dr.patch @@ -1,11 +1,12 @@ -From ec1a17a11aced3cd756e59d91ad6f50b7a2fabfb Mon Sep 17 00:00:00 2001 +From 14d4e308e0aa0b78dc7a059716861a4380de3535 Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski -Date: Sun, 16 May 2021 15:52:06 +0200 -Subject: [PATCH 5/5] net: lantiq: configure burst length for ethernet +Date: Tue, 14 Sep 2021 23:21:02 +0200 +Subject: [PATCH 5/5] net: lantiq: configure the burst length in ethernet + drivers -Configure the burst length for Ethernet. This improves Ethernet -performance by 58%. According to the vendor BSP, 8W burst length -is supported by ar9 and newer SoCs. +Configure the burst length in Ethernet drivers. This improves +Ethernet performance by 58%. According to the vendor BSP, +8W burst length is supported by ar9 and newer SoCs. The NAT benchmark results on xRX200 (Down/Up): * 2W: 330 Mb/s @@ -15,6 +16,7 @@ The NAT benchmark results on xRX200 (Down/Up): Tested on xRX200 and xRX330. Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: David S. Miller --- drivers/net/ethernet/lantiq_etop.c | 21 ++++++++++++++++++--- drivers/net/ethernet/lantiq_xrx200.c | 21 ++++++++++++++++++--- @@ -37,7 +39,7 @@ Signed-off-by: Aleksander Jan Bajkowski int err; - ltq_dma_init_port(DMA_PORT_ETOP); -+ ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, priv->rx_burst_len); ++ ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len); priv->txch.dma.nr = tx; priv->txch.dma.dev = &priv->pdev->dev; @@ -99,7 +101,7 @@ Signed-off-by: Aleksander Jan Bajkowski int i; - ltq_dma_init_port(DMA_PORT_ETOP); -+ ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, priv->rx_burst_len); ++ ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len); ch_rx->dma.nr = XRX200_DMA_RX; ch_rx->dma.dev = priv->dev; diff --git a/target/linux/lantiq/patches-5.10/0711-v5.16-net-lantiq_xrx200-Hardcode-the-burst-length-value.patch b/target/linux/lantiq/patches-5.10/0711-v5.16-net-lantiq_xrx200-Hardcode-the-burst-length-value.patch new file mode 100644 index 0000000000..0b68179a48 --- /dev/null +++ b/target/linux/lantiq/patches-5.10/0711-v5.16-net-lantiq_xrx200-Hardcode-the-burst-length-value.patch @@ -0,0 +1,73 @@ +From 7e553c44f09a8f536090904c6db5b8c9dbafa03b Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Tue, 26 Oct 2021 22:59:01 +0200 +Subject: [PATCH] net: lantiq_xrx200: Hardcode the burst length value + +All SoCs with this IP core support 8 burst length. Hauke +suggested to hardcode this value and simplify the driver. + +Link: https://lkml.org/lkml/2021/9/14/1533 +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/lantiq_xrx200.c | 21 ++++----------------- + 1 file changed, 4 insertions(+), 17 deletions(-) + +--- a/drivers/net/ethernet/lantiq_xrx200.c ++++ b/drivers/net/ethernet/lantiq_xrx200.c +@@ -23,6 +23,7 @@ + #define XRX200_DMA_DATA_LEN 0x600 + #define XRX200_DMA_RX 0 + #define XRX200_DMA_TX 1 ++#define XRX200_DMA_BURST_LEN 8 + + /* cpu port mac */ + #define PMAC_RX_IPG 0x0024 +@@ -71,9 +72,6 @@ struct xrx200_priv { + struct net_device *net_dev; + struct device *dev; + +- int tx_burst_len; +- int rx_burst_len; +- + __iomem void *pmac_reg; + }; + +@@ -320,7 +318,7 @@ static netdev_tx_t xrx200_start_xmit(str + goto err_drop; + + /* dma needs to start on a burst length value aligned address */ +- byte_offset = mapping % (priv->tx_burst_len * 4); ++ byte_offset = mapping % (XRX200_DMA_BURST_LEN * 4); + + desc->addr = mapping - byte_offset; + /* Make sure the address is written before we give it to HW */ +@@ -372,7 +370,8 @@ static int xrx200_dma_init(struct xrx200 + int ret = 0; + int i; + +- ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len); ++ ltq_dma_init_port(DMA_PORT_ETOP, XRX200_DMA_BURST_LEN, ++ XRX200_DMA_BURST_LEN); + + ch_rx->dma.nr = XRX200_DMA_RX; + ch_rx->dma.dev = priv->dev; +@@ -490,18 +489,6 @@ static int xrx200_probe(struct platform_ + if (err) + eth_hw_addr_random(net_dev); + +- err = device_property_read_u32(dev, "lantiq,tx-burst-length", &priv->tx_burst_len); +- if (err < 0) { +- dev_err(dev, "unable to read tx-burst-length property\n"); +- return err; +- } +- +- err = device_property_read_u32(dev, "lantiq,rx-burst-length", &priv->rx_burst_len); +- if (err < 0) { +- dev_err(dev, "unable to read rx-burst-length property\n"); +- return err; +- } +- + /* bring up the dma engine and IP core */ + err = xrx200_dma_init(priv); + if (err) diff --git a/target/linux/lantiq/patches-5.10/0712-v5.16-net-ethernet-lantiq_etop-Fix-compilation-error.patch b/target/linux/lantiq/patches-5.10/0712-v5.16-net-ethernet-lantiq_etop-Fix-compilation-error.patch new file mode 100644 index 0000000000..06f4bc2eee --- /dev/null +++ b/target/linux/lantiq/patches-5.10/0712-v5.16-net-ethernet-lantiq_etop-Fix-compilation-error.patch @@ -0,0 +1,26 @@ +From 68eabc348148ae051631e8dab13c3b1a85c82896 Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Tue, 9 Nov 2021 23:23:54 +0100 +Subject: [PATCH] net: ethernet: lantiq_etop: Fix compilation error + +This fixes the error detected when compiling the driver. + +Fixes: 14d4e308e0aa ("net: lantiq: configure the burst length in ethernet drivers") +Reported-by: kernel test robot +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/lantiq_etop.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/lantiq_etop.c ++++ b/drivers/net/ethernet/lantiq_etop.c +@@ -402,7 +402,7 @@ ltq_etop_dma_init(struct net_device *dev + int rx = priv->rx_irq - LTQ_DMA_ETOP; + int err; + +- ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len); ++ ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, priv->rx_burst_len); + + priv->txch.dma.nr = tx; + priv->txch.dma.dev = &priv->pdev->dev; From 8c501bf9feeaadfb9d950806a312b328baabddcb Mon Sep 17 00:00:00 2001 From: Hirokazu MORIKAWA Date: Sat, 8 Jan 2022 09:33:32 +0900 Subject: [PATCH 57/73] toolchain/binutils: v2.37 Close the file descriptor if there is no archive fd This fixes the following build error: /home/build/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-11.2.0_musl/lib/gcc/aarch64-openwrt-linux-musl/11.2.0/../../../../aarch64-openwrt-linux-musl/bin/ld: /home/sergey/openwrt2/build_dir/target-aarch64_cortex-a53_musl/node-v14.18.2/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a: error adding symbols: malformed archive collect2: error: ld returned 1 exit status It's a bad error handling related to -EMFILE (too many open files). nodejs is probably just very close to open file limit. https://sourceware.org/bugzilla/show_bug.cgi?id=28138 https://github.com/nodejs/node/issues/39452 https://github.com/openwrt/packages/issues/17496 https://github.com/openwrt/packages/issues/16729 https://github.com/openwrt/packages/issues/17164 Signed-off-by: Hirokazu MORIKAWA [Take full patch from 2.37 branch and refresh] Signed-off-by: Hauke Mehrtens --- .../2.37/600-Close_the_file_descriptor.patch | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch diff --git a/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch b/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch new file mode 100644 index 0000000000..fef86a9cb5 --- /dev/null +++ b/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch @@ -0,0 +1,184 @@ +From: H.J. Lu +Date: Mon, 26 Jul 2021 12:59:55 +0000 (-0700) +Subject: bfd: Close the file descriptor if there is no archive fd +X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=1c611b40e6bfc8029bff7696814330b5bc0ee5c0 + +bfd: Close the file descriptor if there is no archive fd + +Close the file descriptor if there is no archive plugin file descriptor +to avoid running out of file descriptors on thin archives with many +archive members. + +bfd/ + + PR ld/28138 + * plugin.c (bfd_plugin_close_file_descriptor): Close the file + descriptor there is no archive plugin file descriptor. + +ld/ + + PR ld/28138 + * testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for + native build. + + PR ld/28138 + * testsuite/ld-plugin/lto.exp: Run ld/28138 tests. + * testsuite/ld-plugin/pr28138.c: New file. + * testsuite/ld-plugin/pr28138-1.c: Likewise. + * testsuite/ld-plugin/pr28138-2.c: Likewise. + * testsuite/ld-plugin/pr28138-3.c: Likewise. + * testsuite/ld-plugin/pr28138-4.c: Likewise. + * testsuite/ld-plugin/pr28138-5.c: Likewise. + * testsuite/ld-plugin/pr28138-6.c: Likewise. + * testsuite/ld-plugin/pr28138-7.c: Likewise. + +(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742) +(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2) +--- + +--- a/bfd/plugin.c ++++ b/bfd/plugin.c +@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *a + && !bfd_is_thin_archive (abfd->my_archive)) + abfd = abfd->my_archive; + ++ /* Close the file descriptor if there is no archive plugin file ++ descriptor. */ ++ if (abfd->archive_plugin_fd == -1) ++ { ++ close (fd); ++ return; ++ } ++ + abfd->archive_plugin_fd_open_count--; + /* Dup the archive plugin file descriptor for later use, which + will be closed by _bfd_archive_close_and_cleanup. */ +--- a/ld/testsuite/ld-plugin/lto.exp ++++ b/ld/testsuite/ld-plugin/lto.exp +@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_share + } + } + ++run_cc_link_tests [list \ ++ [list \ ++ "Build pr28138.a" \ ++ "-T" "" \ ++ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \ ++ pr28138-6.c pr28138-7.c} {} "pr28138.a" \ ++ ] \ ++ [list \ ++ "Build pr28138.o" \ ++ "" "" \ ++ {pr28138.c} {} \ ++ ] \ ++] ++ ++set exec_output [run_host_cmd "sh" \ ++ "-c \"ulimit -n 20; \ ++ $CC -Btmpdir/ld -o tmpdir/pr28138 \ ++ tmpdir/pr28138.o tmpdir/pr28138.a\""] ++set exec_output [prune_warnings $exec_output] ++if [string match "" $exec_output] then { ++ if { [isnative] } { ++ set exec_output [run_host_cmd "tmpdir/pr28138" ""] ++ if [string match "PASS" $exec_output] then { ++ pass "PR ld/28138" ++ } else { ++ fail "PR ld/28138" ++ } ++ } else { ++ pass "PR ld/28138" ++ } ++} else { ++ fail "PR ld/28138" ++} ++ + set testname "Build liblto-11.a" + remote_file host delete "tmpdir/liblto-11.a" + set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"] +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-1.c +@@ -0,0 +1,6 @@ ++extern int a0(void); ++int ++a1(void) ++{ ++ return 1 + a0(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-2.c +@@ -0,0 +1,6 @@ ++extern int a1(void); ++int ++a2(void) ++{ ++ return 1 + a1(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-3.c +@@ -0,0 +1,6 @@ ++extern int a2(void); ++int ++a3(void) ++{ ++ return 1 + a2(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-4.c +@@ -0,0 +1,6 @@ ++extern int a3(void); ++int ++a4(void) ++{ ++ return 1 + a3(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-5.c +@@ -0,0 +1,6 @@ ++extern int a4(void); ++int ++a5(void) ++{ ++ return 1 + a4(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-6.c +@@ -0,0 +1,6 @@ ++extern int a5(void); ++int ++a6(void) ++{ ++ return 1 + a5(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-7.c +@@ -0,0 +1,6 @@ ++extern int a6(void); ++int ++a7(void) ++{ ++ return 1 + a6(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138.c +@@ -0,0 +1,20 @@ ++#include ++ ++extern int a7(void); ++ ++int ++a0(void) ++{ ++ return 0; ++} ++ ++int ++main() ++{ ++ if (a7() == 7) ++ { ++ printf ("PASS\n"); ++ return 0; ++ } ++ return 1; ++} From d9ff9a4270de3f97124eac7ae9a5174c859f87cd Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Thu, 30 Dec 2021 20:03:48 +0100 Subject: [PATCH 58/73] kernel: add kmod-phy-microchip phy drivers for Microchip's LAN88xx PHYs. This is needed for the "LAN7801" variant of the upstream lan78xx usb ethernet driver. Signed-off-by: Christian Lamparter --- package/kernel/linux/modules/netdevices.mk | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index 6bbaf21e4a..91f51f5be6 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -196,6 +196,21 @@ endef $(eval $(call KernelPackage,et131x)) +define KernelPackage/phy-microchip + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Microchip Ethernet PHY driver + KCONFIG:=CONFIG_MICROCHIP_PHY + DEPENDS:=+kmod-libphy + FILES:=$(LINUX_DIR)/drivers/net/phy/microchip.ko + AUTOLOAD:=$(call AutoLoad,18,microchip,1) +endef + +define KernelPackage/phy-microchip/description + Supports the LAN88XX PHYs. +endef + +$(eval $(call KernelPackage,phy-microchip)) + define KernelPackage/phylib-broadcom SUBMENU:=$(NETWORK_DEVICES_MENU) From 3fabca88944e736176310be06e97f0f3cc9010cb Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Thu, 30 Dec 2021 20:05:15 +0100 Subject: [PATCH 59/73] kernel: provide kmod-fixed-phy as separate kmod Almost all targets have the fixed-phy feature built into the kernel. One big exception is x86. This caused a problem with the upcoming LAN78xx usb driver. Hence this patch breaks out the fixed-phy from of_mdio (which didn't include the .ko) and puts into a separate module. Signed-off-by: Christian Lamparter --- package/kernel/linux/modules/netdevices.mk | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index 91f51f5be6..6d263bdc34 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -1034,13 +1034,28 @@ endef $(eval $(call KernelPackage,forcedeth)) +define KernelPackage/fixed-phy + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=MDIO Bus/PHY emulation with fixed speed/link PHYs + DEPENDS:=+kmod-libphy + KCONFIG:=CONFIG_FIXED_PHY + FILES:=$(LINUX_DIR)/drivers/net/phy/fixed_phy.ko + AUTOLOAD:=$(call AutoProbe,fixed_phy) +endef + +define KernelPackage/fixed-phy/description + Kernel driver for "fixed" MDIO Bus to cover the boards + and devices that use PHYs that are not connected to the real MDIO bus. +endef + +$(eval $(call KernelPackage,fixed-phy)) + define KernelPackage/of-mdio SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=OpenFirmware MDIO support - DEPENDS:=+kmod-libphy @!TARGET_x86 + DEPENDS:=+kmod-libphy +kmod-fixed-phy @!TARGET_x86 KCONFIG:=CONFIG_OF_MDIO FILES:= \ - $(LINUX_DIR)/drivers/net/phy/fixed_phy.ko \ $(LINUX_DIR)/drivers/of/of_mdio.ko@lt5.10 \ $(LINUX_DIR)/drivers/net/mdio/of_mdio.ko@ge5.10 AUTOLOAD:=$(call AutoLoad,41,of_mdio) From 31647d8be8c60bfb6690c87c739b8abe6dc03950 Mon Sep 17 00:00:00 2001 From: Josef Schlehofer Date: Tue, 28 Dec 2021 23:43:57 +0100 Subject: [PATCH 60/73] kernel: add kmod-usb-net-lan78xx Add kernel module for Microchip LAN78XX based USB 2 & USB 3 10/100/1000 Ethernet adapters. [1] This kernel module is required for the Seeed Studio's Mini Router based on RPI CM4 [2]. [1] [2] Link: Signed-off-by: Josef Schlehofer (added kmod-phy-microchip and kmod-fixed-phy dependencies, rpi3 needs lan78xx but has it built-in) Signed-off-by: Christian Lamparter --- package/kernel/linux/modules/usb.mk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/package/kernel/linux/modules/usb.mk b/package/kernel/linux/modules/usb.mk index 8815b153ef..6f73c96a29 100644 --- a/package/kernel/linux/modules/usb.mk +++ b/package/kernel/linux/modules/usb.mk @@ -1201,6 +1201,23 @@ endef $(eval $(call KernelPackage,usb-net-kaweth)) +define KernelPackage/usb-net-lan78xx + TITLE:=USB-To-Ethernet Microchip LAN78XX convertors + DEPENDS:=+kmod-fixed-phy +kmod-phy-microchip + KCONFIG:=CONFIG_USB_LAN78XX + FILES:=$(LINUX_DIR)/drivers/$(USBNET_DIR)/lan78xx.ko + AUTOLOAD:=$(call AutoProbe,lan78xx) + $(call AddDepends/usb-net) +endef + +define KernelPackage/usb-net-lan78xx/description + Kernel module for Microchip LAN78XX based USB 2 & USB 3 + 10/100/1000 Ethernet adapters. +endef + +$(eval $(call KernelPackage,usb-net-lan78xx)) + + define KernelPackage/usb-net-pegasus TITLE:=Kernel module for USB-to-Ethernet Pegasus convertors KCONFIG:=CONFIG_USB_PEGASUS From 479acf03cc8ce475892684d61eea936cf2bbe240 Mon Sep 17 00:00:00 2001 From: Alex Lewontin Date: Sat, 1 Jan 2022 16:25:27 -0500 Subject: [PATCH 61/73] ipq806x: modularize generic subtarget This commit moves the device profiles within the ipq806x/generic subtarget into their own includable .mk file, to support eventually having subtargets other than generic. Signed-off-by: Alex Lewontin --- target/linux/ipq806x/image/Makefile | 431 +------------------------- target/linux/ipq806x/image/generic.mk | 430 +++++++++++++++++++++++++ 2 files changed, 431 insertions(+), 430 deletions(-) create mode 100644 target/linux/ipq806x/image/generic.mk diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile index fc0080cf84..f4f829b35c 100644 --- a/target/linux/ipq806x/image/Makefile +++ b/target/linux/ipq806x/image/Makefile @@ -3,26 +3,6 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/image.mk -DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID -DEVICE_VARS += TPLINK_BOARD_ID - -define Build/buffalo-rootfs-cksum - ( \ - echo -ne "\x$$(od -A n -t u1 $@ | tr -s ' ' '\n' | \ - $(STAGING_DIR_HOST)/bin/awk '{s+=$$0}END{printf "%x", 255-s%256}')"; \ - ) >> $@ -endef - -define Build/edimax-header - $(eval edimax_model=$(word 1,$(1))) - - $(STAGING_DIR_HOST)/bin/mkedimaximg \ - -b -s CSYS -m $(edimax_model) \ - -f 0x70000 -S 0x1200000 \ - -i $@ -o $@.new - @mv $@.new $@ -endef - define Device/Default PROFILES := Default KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts) @@ -59,415 +39,6 @@ define Device/UbiFit IMAGE/nand-sysupgrade.bin := sysupgrade-tar | append-metadata endef -define Device/DniImage - KERNEL_SUFFIX := -uImage - KERNEL = kernel-bin | append-dtb | uImage none - KERNEL_NAME := zImage - NETGEAR_BOARD_ID := - NETGEAR_HW_ID := - UBINIZE_OPTS := -E 5 - IMAGES += factory.img - IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | append-ubi | netgear-dni - IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | append-metadata -endef - -define Device/TpSafeImage - KERNEL_SUFFIX := -uImage - KERNEL = kernel-bin | append-dtb | uImage none - KERNEL_NAME := zImage - TPLINK_BOARD_ID := - IMAGES += factory.bin - IMAGE/factory.bin := append-rootfs | tplink-safeloader factory - IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | append-metadata -endef - -define Device/ZyXELImage - KERNEL_SUFFIX := -uImage - KERNEL = kernel-bin | append-dtb | uImage none | pad-to $$(KERNEL_SIZE) - KERNEL_NAME := zImage - IMAGES += factory.bin - IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to $$$$(BLOCKSIZE) | zyxel-ras-image separate-kernel - IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to $$$$(BLOCKSIZE) | sysupgrade-tar rootfs=$$$$@ | append-metadata -endef - -define Device/askey_rt4230w-rev6 - $(call Device/LegacyImage) - DEVICE_VENDOR := Askey - DEVICE_MODEL := RT4230W - DEVICE_VARIANT := REV6 - SOC := qcom-ipq8065 - BLOCKSIZE := 128k - PAGESIZE := 2048 - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct - KERNEL_IN_UBI := 1 -endef -TARGET_DEVICES += askey_rt4230w-rev6 - -define Device/asrock_g10 - $(call Device/FitImage) - $(call Device/UbiFit) - SOC := qcom-ipq8064 - DEVICE_VENDOR := ASRock - DEVICE_MODEL := G10 - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_SIZE := 5332k - DEVICE_PACKAGES := kmod-i2c-gpio ath10k-firmware-qca99x0-ct - IMAGE/nand-factory.bin := append-ubi | edimax-header RN67 -endef -TARGET_DEVICES += asrock_g10 - -define Device/buffalo_wxr-2533dhp - $(call Device/LegacyImage) - SOC := qcom-ipq8064 - DEVICE_VENDOR := Buffalo - DEVICE_MODEL := WXR-2533DHP - BLOCKSIZE := 128k - PAGESIZE := 2048 - IMAGE_SIZE := 65536k - KERNEL_IN_UBI := 1 - IMAGE/sysupgrade.bin := append-rootfs | buffalo-rootfs-cksum | \ - sysupgrade-tar rootfs=$$$$@ | append-metadata - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += buffalo_wxr-2533dhp - -define Device/compex_wpq864 - $(call Device/FitImage) - $(call Device/UbiFit) - DEVICE_VENDOR := Compex - DEVICE_MODEL := WPQ864 - BLOCKSIZE := 128k - PAGESIZE := 2048 - SOC := qcom-ipq8064 - DEVICE_PACKAGES := kmod-gpio-beeper -endef -TARGET_DEVICES += compex_wpq864 - -define Device/edgecore_ecw5410 - $(call Device/FitImage) - $(call Device/UbiFit) - DEVICE_VENDOR := Edgecore - DEVICE_MODEL := ECW5410 - SOC := qcom-ipq8068 - BLOCKSIZE := 128k - PAGESIZE := 2048 - DEVICE_DTS_CONFIG := config@v2.0-ap160 - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct ipq-wifi-edgecore_ecw5410 -endef -TARGET_DEVICES += edgecore_ecw5410 - -define Device/linksys_ea7500-v1 - $(call Device/LegacyImage) - DEVICE_VENDOR := Linksys - DEVICE_MODEL := EA7500 - DEVICE_VARIANT := v1 - SOC := qcom-ipq8064 - PAGESIZE := 2048 - BLOCKSIZE := 128k - KERNEL_SIZE := 3072k - KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakehdr filesystem - UBINIZE_OPTS := -E 5 - IMAGES := factory.bin sysupgrade.bin - IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE) - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += linksys_ea7500-v1 - -define Device/linksys_ea8500 - $(call Device/LegacyImage) - DEVICE_VENDOR := Linksys - DEVICE_MODEL := EA8500 - SOC := qcom-ipq8064 - PAGESIZE := 2048 - BLOCKSIZE := 128k - KERNEL_SIZE := 3072k - KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakehdr filesystem - BOARD_NAME := ea8500 - SUPPORTED_DEVICES += ea8500 - UBINIZE_OPTS := -E 5 - IMAGES += factory.bin - IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += linksys_ea8500 - -define Device/meraki_mr42 - $(call Device/FitImage) - DEVICE_VENDOR := Cisco Meraki - DEVICE_MODEL := MR42 - SOC := qcom-ipq8068 - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_LOADADDR = 0x44208000 - DEVICE_PACKAGES := -swconfig -kmod-ata-ahci -kmod-ata-ahci-platform \ - -kmod-usb-ohci -kmod-usb2 -kmod-usb-ledtrig-usbport \ - -kmod-phy-qcom-ipq806x-usb -kmod-usb3 -kmod-usb-dwc3-qcom \ - -uboot-envtools ath10k-firmware-qca9887-ct \ - ath10k-firmware-qca99x0-ct kmod-eeprom-at24 kmod-hwmon-ina2xx \ - kmod-leds-tlc591xx -endef -TARGET_DEVICES += meraki_mr42 - -define Device/meraki_mr52 - $(call Device/FitImage) - DEVICE_VENDOR := Cisco Meraki - DEVICE_MODEL := MR52 - SOC := qcom-ipq8068 - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_LOADADDR = 0x44208000 - DEVICE_DTS_CONFIG := config@2 - DEVICE_PACKAGES := -swconfig -kmod-ata-ahci -kmod-ata-ahci-platform \ - -kmod-usb-ohci -kmod-usb2 -kmod-usb-ledtrig-usbport \ - -kmod-phy-qcom-ipq806x-usb -kmod-usb3 -kmod-usb-dwc3-qcom \ - -uboot-envtools ath10k-firmware-qca9887-ct \ - ath10k-firmware-qca9984-ct kmod-eeprom-at24 kmod-hwmon-ina2xx \ - kmod-leds-tlc591xx -endef -TARGET_DEVICES += meraki_mr52 - -define Device/nec_wg2600hp - $(call Device/LegacyImage) - DEVICE_VENDOR := NEC - DEVICE_MODEL := Aterm WG2600HP - SOC := qcom-ipq8064 - BLOCKSIZE := 64k - BOARD_NAME := wg2600hp - IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += nec_wg2600hp - -define Device/nec_wg2600hp3 - $(call Device/LegacyImage) - DEVICE_VENDOR := NEC Platforms - DEVICE_MODEL := Aterm WG2600HP3 - SOC := qcom-ipq8062 - BLOCKSIZE := 64k - IMAGES := sysupgrade.bin - IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata - DEVICE_PACKAGES := -kmod-ata-ahci -kmod-ata-ahci-platform -kmod-usb-ohci -kmod-usb2 \ - -kmod-usb-ledtrig-usbport -kmod-usb-phy-qcom-dwc3 -kmod-usb3 -kmod-usb-dwc3-qcom \ - ath10k-firmware-qca9984-ct ipq-wifi-nec_wg2600hp3 -endef -TARGET_DEVICES += nec_wg2600hp3 - -define Device/netgear_d7800 - $(call Device/DniImage) - DEVICE_VENDOR := NETGEAR - DEVICE_MODEL := Nighthawk X4 D7800 - SOC := qcom-ipq8064 - KERNEL_SIZE := 4096k - NETGEAR_BOARD_ID := D7800 - NETGEAR_HW_ID := 29764958+0+128+512+4x4+4x4 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := d7800 - SUPPORTED_DEVICES += d7800 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += netgear_d7800 - -define Device/netgear_r7500 - $(call Device/DniImage) - DEVICE_VENDOR := NETGEAR - DEVICE_MODEL := Nighthawk X4 R7500 - DEVICE_VARIANT := v1 - SOC := qcom-ipq8064 - KERNEL_SIZE := 4096k - NETGEAR_BOARD_ID := R7500 - NETGEAR_HW_ID := 29764841+0+128+256+3x3+4x4 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := r7500 - SUPPORTED_DEVICES += r7500 - DEVICE_PACKAGES := ath10k-firmware-qca988x-ct -endef -TARGET_DEVICES += netgear_r7500 - -define Device/netgear_r7500v2 - $(call Device/DniImage) - DEVICE_VENDOR := NETGEAR - DEVICE_MODEL := Nighthawk X4 R7500 - DEVICE_VARIANT := v2 - SOC := qcom-ipq8064 - KERNEL_SIZE := 4096k - NETGEAR_BOARD_ID := R7500v2 - NETGEAR_HW_ID := 29764958+0+128+512+3x3+4x4 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := r7500v2 - SUPPORTED_DEVICES += r7500v2 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct ath10k-firmware-qca988x-ct -endef -TARGET_DEVICES += netgear_r7500v2 - -define Device/netgear_r7800 - $(call Device/DniImage) - DEVICE_VENDOR := NETGEAR - DEVICE_MODEL := Nighthawk X4S R7800 - SOC := qcom-ipq8065 - KERNEL_SIZE := 4096k - NETGEAR_BOARD_ID := R7800 - NETGEAR_HW_ID := 29764958+0+128+512+4x4+4x4+cascade - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := r7800 - SUPPORTED_DEVICES += r7800 - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct -endef -TARGET_DEVICES += netgear_r7800 - -define Device/netgear_xr500 - $(call Device/DniImage) - DEVICE_VENDOR := NETGEAR - DEVICE_MODEL := Nighthawk XR500 - SOC := qcom-ipq8065 - KERNEL_SIZE := 4096k - NETGEAR_BOARD_ID := XR500 - NETGEAR_HW_ID := 29764958+0+256+512+4x4+4x4+cascade - BLOCKSIZE := 128k - PAGESIZE := 2048 - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct -endef -TARGET_DEVICES += netgear_xr500 - -define Device/qcom_ipq8064-ap148 - $(call Device/FitImage) - $(call Device/UbiFit) - DEVICE_VENDOR := Qualcomm - DEVICE_MODEL := AP148 - DEVICE_VARIANT := standard - SOC := qcom-ipq8064 - DEVICE_DTS := qcom-ipq8064-ap148 - KERNEL_INSTALL := 1 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := ap148 - SUPPORTED_DEVICES += ap148 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += qcom_ipq8064-ap148 - -define Device/qcom_ipq8064-ap148-legacy - $(call Device/LegacyImage) - $(call Device/UbiFit) - DEVICE_VENDOR := Qualcomm - DEVICE_MODEL := AP148 - DEVICE_VARIANT := legacy - SOC := qcom-ipq8064 - DEVICE_DTS := qcom-ipq8064-ap148 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := ap148 - SUPPORTED_DEVICES := qcom,ipq8064-ap148 ap148 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += qcom_ipq8064-ap148-legacy - -define Device/qcom_ipq8064-ap161 - $(call Device/FitImage) - $(call Device/UbiFit) - DEVICE_VENDOR := Qualcomm - DEVICE_MODEL := AP161 - SOC := qcom-ipq8064 - DEVICE_DTS := qcom-ipq8064-ap161 - KERNEL_INSTALL := 1 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := ap161 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += qcom_ipq8064-ap161 - -define Device/qcom_ipq8064-db149 - $(call Device/FitImage) - DEVICE_VENDOR := Qualcomm - DEVICE_MODEL := DB149 - SOC := qcom-ipq8064 - DEVICE_DTS := qcom-ipq8064-db149 - KERNEL_INSTALL := 1 - BOARD_NAME := db149 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += qcom_ipq8064-db149 - -define Device/tplink_ad7200 - $(call Device/TpSafeImage) - DEVICE_VENDOR := TP-Link - DEVICE_MODEL := AD7200 - DEVICE_VARIANT := v1/v2 - DEVICE_ALT0_VENDOR := TP-Link - DEVICE_ALT0_MODEL := Talon AD7200 - DEVICE_ALT0_VARIANT := v1/v2 - SOC := qcom-ipq8064 - BLOCKSIZE := 128k - PAGESIZE := 2048 - TPLINK_BOARD_ID := AD7200 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct kmod-wil6210 -endef -TARGET_DEVICES += tplink_ad7200 - -define Device/tplink_c2600 - $(call Device/TpSafeImage) - DEVICE_VENDOR := TP-Link - DEVICE_MODEL := Archer C2600 - DEVICE_VARIANT := v1 - SOC := qcom-ipq8064 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := c2600 - SUPPORTED_DEVICES += c2600 - TPLINK_BOARD_ID := C2600 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct -endef -TARGET_DEVICES += tplink_c2600 - -define Device/tplink_vr2600v - DEVICE_VENDOR := TP-Link - DEVICE_MODEL := Archer VR2600v - DEVICE_VARIANT := v1 - KERNEL_SUFFIX := -uImage - KERNEL = kernel-bin | append-dtb | uImage none - KERNEL_NAME := zImage - KERNEL_SIZE := 3072k - SOC := qcom-ipq8064 - BLOCKSIZE := 128k - PAGESIZE := 2048 - BOARD_NAME := vr2600v - SUPPORTED_DEVICES += vr2600v - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct - IMAGE/sysupgrade.bin := pad-extra 512 | append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | append-metadata -endef -TARGET_DEVICES += tplink_vr2600v - -define Device/ubnt_unifi-ac-hd - $(call Device/FitImageLzma) - DEVICE_VENDOR := Ubiquiti - DEVICE_MODEL := UniFi AC HD - SOC := qcom-ipq8064 - BLOCKSIZE := 64k - IMAGE_SIZE := 14784k - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct - IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size | append-metadata -endef -TARGET_DEVICES += ubnt_unifi-ac-hd - -define Device/zyxel_nbg6817 - DEVICE_VENDOR := ZyXEL - DEVICE_MODEL := NBG6817 - SOC := qcom-ipq8065 - KERNEL_SIZE := 4096k - BLOCKSIZE := 64k - BOARD_NAME := nbg6817 - RAS_BOARD := NBG6817 - RAS_ROOTFS_SIZE := 20934k - RAS_VERSION := "V1.99(OWRT.9999)C0" - SUPPORTED_DEVICES += nbg6817 - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct e2fsprogs kmod-fs-ext4 losetup - $(call Device/ZyXELImage) -endef -TARGET_DEVICES += zyxel_nbg6817 +include $(SUBTARGET).mk $(eval $(call BuildImage)) diff --git a/target/linux/ipq806x/image/generic.mk b/target/linux/ipq806x/image/generic.mk new file mode 100644 index 0000000000..ffe77c1ef5 --- /dev/null +++ b/target/linux/ipq806x/image/generic.mk @@ -0,0 +1,430 @@ +DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID +DEVICE_VARS += TPLINK_BOARD_ID + +define Build/buffalo-rootfs-cksum + ( \ + echo -ne "\x$$(od -A n -t u1 $@ | tr -s ' ' '\n' | \ + $(STAGING_DIR_HOST)/bin/awk '{s+=$$0}END{printf "%x", 255-s%256}')"; \ + ) >> $@ +endef + +define Build/edimax-header + $(eval edimax_model=$(word 1,$(1))) + + $(STAGING_DIR_HOST)/bin/mkedimaximg \ + -b -s CSYS -m $(edimax_model) \ + -f 0x70000 -S 0x1200000 \ + -i $@ -o $@.new + @mv $@.new $@ +endef + +define Device/DniImage + KERNEL_SUFFIX := -uImage + KERNEL = kernel-bin | append-dtb | uImage none + KERNEL_NAME := zImage + NETGEAR_BOARD_ID := + NETGEAR_HW_ID := + UBINIZE_OPTS := -E 5 + IMAGES += factory.img + IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | append-ubi | netgear-dni + IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | append-metadata +endef + +define Device/TpSafeImage + KERNEL_SUFFIX := -uImage + KERNEL = kernel-bin | append-dtb | uImage none + KERNEL_NAME := zImage + TPLINK_BOARD_ID := + IMAGES += factory.bin + IMAGE/factory.bin := append-rootfs | tplink-safeloader factory + IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | append-metadata +endef + +define Device/ZyXELImage + KERNEL_SUFFIX := -uImage + KERNEL = kernel-bin | append-dtb | uImage none | pad-to $$(KERNEL_SIZE) + KERNEL_NAME := zImage + IMAGES += factory.bin + IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to $$$$(BLOCKSIZE) | zyxel-ras-image separate-kernel + IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to $$$$(BLOCKSIZE) | sysupgrade-tar rootfs=$$$$@ | append-metadata +endef + +define Device/askey_rt4230w-rev6 + $(call Device/LegacyImage) + DEVICE_VENDOR := Askey + DEVICE_MODEL := RT4230W + DEVICE_VARIANT := REV6 + SOC := qcom-ipq8065 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct + KERNEL_IN_UBI := 1 +endef +TARGET_DEVICES += askey_rt4230w-rev6 + +define Device/asrock_g10 + $(call Device/FitImage) + $(call Device/UbiFit) + SOC := qcom-ipq8064 + DEVICE_VENDOR := ASRock + DEVICE_MODEL := G10 + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 5332k + DEVICE_PACKAGES := kmod-i2c-gpio ath10k-firmware-qca99x0-ct + IMAGE/nand-factory.bin := append-ubi | edimax-header RN67 +endef +TARGET_DEVICES += asrock_g10 + +define Device/buffalo_wxr-2533dhp + $(call Device/LegacyImage) + SOC := qcom-ipq8064 + DEVICE_VENDOR := Buffalo + DEVICE_MODEL := WXR-2533DHP + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 65536k + KERNEL_IN_UBI := 1 + IMAGE/sysupgrade.bin := append-rootfs | buffalo-rootfs-cksum | \ + sysupgrade-tar rootfs=$$$$@ | append-metadata + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += buffalo_wxr-2533dhp + +define Device/compex_wpq864 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Compex + DEVICE_MODEL := WPQ864 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := qcom-ipq8064 + DEVICE_PACKAGES := kmod-gpio-beeper +endef +TARGET_DEVICES += compex_wpq864 + +define Device/edgecore_ecw5410 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Edgecore + DEVICE_MODEL := ECW5410 + SOC := qcom-ipq8068 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@v2.0-ap160 + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct ipq-wifi-edgecore_ecw5410 +endef +TARGET_DEVICES += edgecore_ecw5410 + +define Device/linksys_ea7500-v1 + $(call Device/LegacyImage) + DEVICE_VENDOR := Linksys + DEVICE_MODEL := EA7500 + DEVICE_VARIANT := v1 + SOC := qcom-ipq8064 + PAGESIZE := 2048 + BLOCKSIZE := 128k + KERNEL_SIZE := 3072k + KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakehdr filesystem + UBINIZE_OPTS := -E 5 + IMAGES := factory.bin sysupgrade.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE) + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += linksys_ea7500-v1 + +define Device/linksys_ea8500 + $(call Device/LegacyImage) + DEVICE_VENDOR := Linksys + DEVICE_MODEL := EA8500 + SOC := qcom-ipq8064 + PAGESIZE := 2048 + BLOCKSIZE := 128k + KERNEL_SIZE := 3072k + KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakehdr filesystem + BOARD_NAME := ea8500 + SUPPORTED_DEVICES += ea8500 + UBINIZE_OPTS := -E 5 + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += linksys_ea8500 + +define Device/meraki_mr42 + $(call Device/FitImage) + DEVICE_VENDOR := Cisco Meraki + DEVICE_MODEL := MR42 + SOC := qcom-ipq8068 + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_LOADADDR = 0x44208000 + DEVICE_PACKAGES := -swconfig -kmod-ata-ahci -kmod-ata-ahci-platform \ + -kmod-usb-ohci -kmod-usb2 -kmod-usb-ledtrig-usbport \ + -kmod-phy-qcom-ipq806x-usb -kmod-usb3 -kmod-usb-dwc3-qcom \ + -uboot-envtools ath10k-firmware-qca9887-ct \ + ath10k-firmware-qca99x0-ct kmod-eeprom-at24 kmod-hwmon-ina2xx \ + kmod-leds-tlc591xx +endef +TARGET_DEVICES += meraki_mr42 + +define Device/meraki_mr52 + $(call Device/FitImage) + DEVICE_VENDOR := Cisco Meraki + DEVICE_MODEL := MR52 + SOC := qcom-ipq8068 + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_LOADADDR = 0x44208000 + DEVICE_DTS_CONFIG := config@2 + DEVICE_PACKAGES := -swconfig -kmod-ata-ahci -kmod-ata-ahci-platform \ + -kmod-usb-ohci -kmod-usb2 -kmod-usb-ledtrig-usbport \ + -kmod-phy-qcom-ipq806x-usb -kmod-usb3 -kmod-usb-dwc3-qcom \ + -uboot-envtools ath10k-firmware-qca9887-ct \ + ath10k-firmware-qca9984-ct kmod-eeprom-at24 kmod-hwmon-ina2xx \ + kmod-leds-tlc591xx +endef +TARGET_DEVICES += meraki_mr52 + +define Device/nec_wg2600hp + $(call Device/LegacyImage) + DEVICE_VENDOR := NEC + DEVICE_MODEL := Aterm WG2600HP + SOC := qcom-ipq8064 + BLOCKSIZE := 64k + BOARD_NAME := wg2600hp + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += nec_wg2600hp + +define Device/nec_wg2600hp3 + $(call Device/LegacyImage) + DEVICE_VENDOR := NEC Platforms + DEVICE_MODEL := Aterm WG2600HP3 + SOC := qcom-ipq8062 + BLOCKSIZE := 64k + IMAGES := sysupgrade.bin + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata + DEVICE_PACKAGES := -kmod-ata-ahci -kmod-ata-ahci-platform -kmod-usb-ohci -kmod-usb2 \ + -kmod-usb-ledtrig-usbport -kmod-usb-phy-qcom-dwc3 -kmod-usb3 -kmod-usb-dwc3-qcom \ + ath10k-firmware-qca9984-ct ipq-wifi-nec_wg2600hp3 +endef +TARGET_DEVICES += nec_wg2600hp3 + +define Device/netgear_d7800 + $(call Device/DniImage) + DEVICE_VENDOR := NETGEAR + DEVICE_MODEL := Nighthawk X4 D7800 + SOC := qcom-ipq8064 + KERNEL_SIZE := 4096k + NETGEAR_BOARD_ID := D7800 + NETGEAR_HW_ID := 29764958+0+128+512+4x4+4x4 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := d7800 + SUPPORTED_DEVICES += d7800 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += netgear_d7800 + +define Device/netgear_r7500 + $(call Device/DniImage) + DEVICE_VENDOR := NETGEAR + DEVICE_MODEL := Nighthawk X4 R7500 + DEVICE_VARIANT := v1 + SOC := qcom-ipq8064 + KERNEL_SIZE := 4096k + NETGEAR_BOARD_ID := R7500 + NETGEAR_HW_ID := 29764841+0+128+256+3x3+4x4 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := r7500 + SUPPORTED_DEVICES += r7500 + DEVICE_PACKAGES := ath10k-firmware-qca988x-ct +endef +TARGET_DEVICES += netgear_r7500 + +define Device/netgear_r7500v2 + $(call Device/DniImage) + DEVICE_VENDOR := NETGEAR + DEVICE_MODEL := Nighthawk X4 R7500 + DEVICE_VARIANT := v2 + SOC := qcom-ipq8064 + KERNEL_SIZE := 4096k + NETGEAR_BOARD_ID := R7500v2 + NETGEAR_HW_ID := 29764958+0+128+512+3x3+4x4 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := r7500v2 + SUPPORTED_DEVICES += r7500v2 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct ath10k-firmware-qca988x-ct +endef +TARGET_DEVICES += netgear_r7500v2 + +define Device/netgear_r7800 + $(call Device/DniImage) + DEVICE_VENDOR := NETGEAR + DEVICE_MODEL := Nighthawk X4S R7800 + SOC := qcom-ipq8065 + KERNEL_SIZE := 4096k + NETGEAR_BOARD_ID := R7800 + NETGEAR_HW_ID := 29764958+0+128+512+4x4+4x4+cascade + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := r7800 + SUPPORTED_DEVICES += r7800 + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct +endef +TARGET_DEVICES += netgear_r7800 + +define Device/netgear_xr500 + $(call Device/DniImage) + DEVICE_VENDOR := NETGEAR + DEVICE_MODEL := Nighthawk XR500 + SOC := qcom-ipq8065 + KERNEL_SIZE := 4096k + NETGEAR_BOARD_ID := XR500 + NETGEAR_HW_ID := 29764958+0+256+512+4x4+4x4+cascade + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct +endef +TARGET_DEVICES += netgear_xr500 + +define Device/qcom_ipq8064-ap148 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Qualcomm + DEVICE_MODEL := AP148 + DEVICE_VARIANT := standard + SOC := qcom-ipq8064 + DEVICE_DTS := qcom-ipq8064-ap148 + KERNEL_INSTALL := 1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := ap148 + SUPPORTED_DEVICES += ap148 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += qcom_ipq8064-ap148 + +define Device/qcom_ipq8064-ap148-legacy + $(call Device/LegacyImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Qualcomm + DEVICE_MODEL := AP148 + DEVICE_VARIANT := legacy + SOC := qcom-ipq8064 + DEVICE_DTS := qcom-ipq8064-ap148 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := ap148 + SUPPORTED_DEVICES := qcom,ipq8064-ap148 ap148 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += qcom_ipq8064-ap148-legacy + +define Device/qcom_ipq8064-ap161 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Qualcomm + DEVICE_MODEL := AP161 + SOC := qcom-ipq8064 + DEVICE_DTS := qcom-ipq8064-ap161 + KERNEL_INSTALL := 1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := ap161 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += qcom_ipq8064-ap161 + +define Device/qcom_ipq8064-db149 + $(call Device/FitImage) + DEVICE_VENDOR := Qualcomm + DEVICE_MODEL := DB149 + SOC := qcom-ipq8064 + DEVICE_DTS := qcom-ipq8064-db149 + KERNEL_INSTALL := 1 + BOARD_NAME := db149 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += qcom_ipq8064-db149 + +define Device/tplink_ad7200 + $(call Device/TpSafeImage) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := AD7200 + DEVICE_VARIANT := v1/v2 + DEVICE_ALT0_VENDOR := TP-Link + DEVICE_ALT0_MODEL := Talon AD7200 + DEVICE_ALT0_VARIANT := v1/v2 + SOC := qcom-ipq8064 + BLOCKSIZE := 128k + PAGESIZE := 2048 + TPLINK_BOARD_ID := AD7200 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct kmod-wil6210 +endef +TARGET_DEVICES += tplink_ad7200 + +define Device/tplink_c2600 + $(call Device/TpSafeImage) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := Archer C2600 + DEVICE_VARIANT := v1 + SOC := qcom-ipq8064 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := c2600 + SUPPORTED_DEVICES += c2600 + TPLINK_BOARD_ID := C2600 + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += tplink_c2600 + +define Device/tplink_vr2600v + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := Archer VR2600v + DEVICE_VARIANT := v1 + KERNEL_SUFFIX := -uImage + KERNEL = kernel-bin | append-dtb | uImage none + KERNEL_NAME := zImage + KERNEL_SIZE := 3072k + SOC := qcom-ipq8064 + BLOCKSIZE := 128k + PAGESIZE := 2048 + BOARD_NAME := vr2600v + SUPPORTED_DEVICES += vr2600v + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct + IMAGE/sysupgrade.bin := pad-extra 512 | append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | append-metadata +endef +TARGET_DEVICES += tplink_vr2600v + +define Device/ubnt_unifi-ac-hd + $(call Device/FitImageLzma) + DEVICE_VENDOR := Ubiquiti + DEVICE_MODEL := UniFi AC HD + SOC := qcom-ipq8064 + BLOCKSIZE := 64k + IMAGE_SIZE := 14784k + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct + IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size | append-metadata +endef +TARGET_DEVICES += ubnt_unifi-ac-hd + +define Device/zyxel_nbg6817 + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := NBG6817 + SOC := qcom-ipq8065 + KERNEL_SIZE := 4096k + BLOCKSIZE := 64k + BOARD_NAME := nbg6817 + RAS_BOARD := NBG6817 + RAS_ROOTFS_SIZE := 20934k + RAS_VERSION := "V1.99(OWRT.9999)C0" + SUPPORTED_DEVICES += nbg6817 + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct e2fsprogs kmod-fs-ext4 losetup + $(call Device/ZyXELImage) +endef +TARGET_DEVICES += zyxel_nbg6817 From 62a2bfaff81bccd4440dc0482b77b692bf996bd7 Mon Sep 17 00:00:00 2001 From: Alex Lewontin Date: Sat, 1 Jan 2022 16:43:57 -0500 Subject: [PATCH 62/73] ipq806x: janitorial work, respect line lengths This commit breaks up some lines so that they are shorter than 74 charcters. Signed-off-by: Alex Lewontin --- target/linux/ipq806x/image/generic.mk | 60 ++++++++++++++++++--------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/target/linux/ipq806x/image/generic.mk b/target/linux/ipq806x/image/generic.mk index ffe77c1ef5..524eb98226 100644 --- a/target/linux/ipq806x/image/generic.mk +++ b/target/linux/ipq806x/image/generic.mk @@ -26,8 +26,12 @@ define Device/DniImage NETGEAR_HW_ID := UBINIZE_OPTS := -E 5 IMAGES += factory.img - IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | append-ubi | netgear-dni - IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | append-metadata + IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ + append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | \ + append-ubi | netgear-dni + IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ + append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | \ + append-metadata endef define Device/TpSafeImage @@ -37,16 +41,21 @@ define Device/TpSafeImage TPLINK_BOARD_ID := IMAGES += factory.bin IMAGE/factory.bin := append-rootfs | tplink-safeloader factory - IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | append-metadata + IMAGE/sysupgrade.bin := append-rootfs | \ + tplink-safeloader sysupgrade | append-metadata endef define Device/ZyXELImage KERNEL_SUFFIX := -uImage - KERNEL = kernel-bin | append-dtb | uImage none | pad-to $$(KERNEL_SIZE) + KERNEL = kernel-bin | append-dtb | uImage none | \ + pad-to $$(KERNEL_SIZE) KERNEL_NAME := zImage IMAGES += factory.bin - IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to $$$$(BLOCKSIZE) | zyxel-ras-image separate-kernel - IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to $$$$(BLOCKSIZE) | sysupgrade-tar rootfs=$$$$@ | append-metadata + IMAGE/factory.bin := append-rootfs | pad-rootfs | \ + pad-to $$$$(BLOCKSIZE) | zyxel-ras-image separate-kernel + IMAGE/sysupgrade.bin/squashfs := append-rootfs | \ + pad-to $$$$(BLOCKSIZE) | sysupgrade-tar rootfs=$$$$@ | \ + append-metadata endef define Device/askey_rt4230w-rev6 @@ -112,7 +121,8 @@ define Device/edgecore_ecw5410 BLOCKSIZE := 128k PAGESIZE := 2048 DEVICE_DTS_CONFIG := config@v2.0-ap160 - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct ipq-wifi-edgecore_ecw5410 + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct \ + ipq-wifi-edgecore_ecw5410 endef TARGET_DEVICES += edgecore_ecw5410 @@ -125,10 +135,12 @@ define Device/linksys_ea7500-v1 PAGESIZE := 2048 BLOCKSIZE := 128k KERNEL_SIZE := 3072k - KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakehdr filesystem + KERNEL = kernel-bin | append-dtb | uImage none | \ + append-uImage-fakehdr filesystem UBINIZE_OPTS := -E 5 IMAGES := factory.bin sysupgrade.bin - IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE) + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \ + append-ubi | pad-to $$$$(PAGESIZE) DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct endef TARGET_DEVICES += linksys_ea7500-v1 @@ -141,12 +153,14 @@ define Device/linksys_ea8500 PAGESIZE := 2048 BLOCKSIZE := 128k KERNEL_SIZE := 3072k - KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakehdr filesystem + KERNEL = kernel-bin | append-dtb | uImage none | \ + append-uImage-fakehdr filesystem BOARD_NAME := ea8500 SUPPORTED_DEVICES += ea8500 UBINIZE_OPTS := -E 5 IMAGES += factory.bin - IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \ + append-ubi DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct endef TARGET_DEVICES += linksys_ea8500 @@ -193,7 +207,8 @@ define Device/nec_wg2600hp SOC := qcom-ipq8064 BLOCKSIZE := 64k BOARD_NAME := wg2600hp - IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ + pad-rootfs | append-metadata DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct endef TARGET_DEVICES += nec_wg2600hp @@ -205,9 +220,11 @@ define Device/nec_wg2600hp3 SOC := qcom-ipq8062 BLOCKSIZE := 64k IMAGES := sysupgrade.bin - IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata - DEVICE_PACKAGES := -kmod-ata-ahci -kmod-ata-ahci-platform -kmod-usb-ohci -kmod-usb2 \ - -kmod-usb-ledtrig-usbport -kmod-usb-phy-qcom-dwc3 -kmod-usb3 -kmod-usb-dwc3-qcom \ + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ + pad-rootfs | append-metadata + DEVICE_PACKAGES := -kmod-ata-ahci -kmod-ata-ahci-platform \ + -kmod-usb-ohci -kmod-usb2 -kmod-usb-ledtrig-usbport \ + -kmod-usb-phy-qcom-dwc3 -kmod-usb3 -kmod-usb-dwc3-qcom \ ath10k-firmware-qca9984-ct ipq-wifi-nec_wg2600hp3 endef TARGET_DEVICES += nec_wg2600hp3 @@ -258,7 +275,8 @@ define Device/netgear_r7500v2 PAGESIZE := 2048 BOARD_NAME := r7500v2 SUPPORTED_DEVICES += r7500v2 - DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct ath10k-firmware-qca988x-ct + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct \ + ath10k-firmware-qca988x-ct endef TARGET_DEVICES += netgear_r7500v2 @@ -397,7 +415,9 @@ define Device/tplink_vr2600v BOARD_NAME := vr2600v SUPPORTED_DEVICES += vr2600v DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct - IMAGE/sysupgrade.bin := pad-extra 512 | append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | append-metadata + IMAGE/sysupgrade.bin := pad-extra 512 | append-kernel | \ + pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | \ + append-metadata endef TARGET_DEVICES += tplink_vr2600v @@ -409,7 +429,8 @@ define Device/ubnt_unifi-ac-hd BLOCKSIZE := 64k IMAGE_SIZE := 14784k DEVICE_PACKAGES := ath10k-firmware-qca9984-ct - IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size | append-metadata + IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | \ + append-rootfs | pad-rootfs | check-size | append-metadata endef TARGET_DEVICES += ubnt_unifi-ac-hd @@ -424,7 +445,8 @@ define Device/zyxel_nbg6817 RAS_ROOTFS_SIZE := 20934k RAS_VERSION := "V1.99(OWRT.9999)C0" SUPPORTED_DEVICES += nbg6817 - DEVICE_PACKAGES := ath10k-firmware-qca9984-ct e2fsprogs kmod-fs-ext4 losetup + DEVICE_PACKAGES := ath10k-firmware-qca9984-ct e2fsprogs \ + kmod-fs-ext4 losetup $(call Device/ZyXELImage) endef TARGET_DEVICES += zyxel_nbg6817 From abc2821286e4d9ccc98146a5bc3cf3f8e1ff4b9f Mon Sep 17 00:00:00 2001 From: Stefan Lippers-Hollmann Date: Thu, 30 Dec 2021 03:52:07 +0100 Subject: [PATCH 63/73] x86: improve sysinfo handling of dummy values Fall back to using board_vendor and board_name, if known dummy values are used for sys_vendor and product_name. Examples: To be filled by O.E.M.:To be filled by O.E.M. --> INTEL Corporation:ChiefRiver System manufacturer:System Product Name --> ASUSTeK COMPUTER INC.:P8H77-M PRO To Be Filled By O.E.M.:To Be Filled By O.E.M. --> ASRock:Q1900DC-ITX Gigabyte Technology Co., Ltd.:To be filled by O.E.M. --> Gigabyte Technology Co., Ltd.:H77M-D3H empty:empty --> TYAN Computer Corporation:TYAN Toledo i3210W/i3200R S5211 To Be Filled By O.E.M.:To Be Filled By O.E.M. --> ASRock:H77 Pro4-M Signed-off-by: Stefan Lippers-Hollmann --- target/linux/x86/base-files/lib/preinit/01_sysinfo | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/linux/x86/base-files/lib/preinit/01_sysinfo b/target/linux/x86/base-files/lib/preinit/01_sysinfo index 498b076998..97e8e003f3 100644 --- a/target/linux/x86/base-files/lib/preinit/01_sysinfo +++ b/target/linux/x86/base-files/lib/preinit/01_sysinfo @@ -12,12 +12,24 @@ do_sysinfo_x86() { for file in sys_vendor board_vendor; do vendor="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)" + case "$vendor" in + empty | \ + System\ manufacturer | \ + To\ [bB]e\ [fF]illed\ [bB]y\ O\.E\.M\.) + continue + ;; + esac [ -n "$vendor" ] && break done for file in product_name board_name; do product="$(cat /sys/devices/virtual/dmi/id/$file 2>/dev/null)" case "$vendor:$product" in + ?*:empty | \ + ?*:System\ Product\ Name | \ + ?*:To\ [bB]e\ [fF]illed\ [bB]y\ O\.E\.M\.) + continue + ;; "PC Engines:APU") product="apu1" break From 693958497a8cd55aa2eaba602ac5ab72d23fc1a8 Mon Sep 17 00:00:00 2001 From: "Fritz D. Ansel" Date: Mon, 2 Aug 2021 19:42:37 +0200 Subject: [PATCH 64/73] mediatek mt7622: fix 300mhz typo in dts The lowest frequency should be 300MHz, since that is the label assigned to the OPP in the mt7622.dtsi device tree, while there is one missing zero in the actual value. To be clear, the lowest frequency should be 300MHz instead of 30MHz. As mentioned @dangowrt on the OpenWrt forum there is no benefit in leaving 30MHz as the lowest frequency. Signed-off-by: Jip de Beer Signed-off-by: Fritz D. Ansel --- .../721-dts-mt7622-mediatek-fix-300mhz.patch | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 target/linux/mediatek/patches-5.10/721-dts-mt7622-mediatek-fix-300mhz.patch diff --git a/target/linux/mediatek/patches-5.10/721-dts-mt7622-mediatek-fix-300mhz.patch b/target/linux/mediatek/patches-5.10/721-dts-mt7622-mediatek-fix-300mhz.patch new file mode 100644 index 0000000000..f9a5fdbd0d --- /dev/null +++ b/target/linux/mediatek/patches-5.10/721-dts-mt7622-mediatek-fix-300mhz.patch @@ -0,0 +1,27 @@ +From: Jip de Beer +Date: Sun, 9 Jan 2022 13:14:04 +0100 +Subject: [PATCH] mediatek mt7622: fix 300mhz typo in dts + +The lowest frequency should be 300MHz, since that is the label +assigned to the OPP in the mt7622.dtsi device tree, while there is one +missing zero in the actual value. + +To be clear, the lowest frequency should be 300MHz instead of 30MHz. + +As mentioned @dangowrt on the OpenWrt forum there is no benefit in +leaving 30MHz as the lowest frequency. + +Signed-off-by: Jip de Beer +Signed-off-by: Fritz D. Ansel +--- +--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi ++++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi +@@ -24,7 +24,7 @@ + compatible = "operating-points-v2"; + opp-shared; + opp-300000000 { +- opp-hz = /bits/ 64 <30000000>; ++ opp-hz = /bits/ 64 <300000000>; + opp-microvolt = <950000>; + }; + From 0f50d3daff19a1eae513630a70f0c66af16db796 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Sun, 9 Jan 2022 15:30:24 +0200 Subject: [PATCH 65/73] firewall4: bump to git HEAD 9a509d4 ruleset.uc: consolidate ip and ip6 offload 21f311d ruleset.uc: don't trim newline before comment sign f121383 tests: enable flow offloading in tests 550df40 tests: add test for unknown defaults option 47c5a5b tests: add test for deprecated rule option 69a89d6 tests: add test for unknown rule option 07579df fw4.uc: handle interface zone option Signed-off-by: Stijn Tintel --- package/network/config/firewall4/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/config/firewall4/Makefile b/package/network/config/firewall4/Makefile index c667e530dc..94aa278774 100644 --- a/package/network/config/firewall4/Makefile +++ b/package/network/config/firewall4/Makefile @@ -9,9 +9,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firewall4.git -PKG_SOURCE_DATE:=2022-01-06 -PKG_SOURCE_VERSION:=b68cf67019452527d6a5a967b823a39dd1ba1edd -PKG_MIRROR_HASH:=8ae8bc8ce71e55adc6d89bd5f97c90834127c733d22e37182119d45eb77c0583 +PKG_SOURCE_DATE:=2022-01-09 +PKG_SOURCE_VERSION:=07579df54f38d75afea44b2a3b41a6d9af9497a1 +PKG_MIRROR_HASH:=3326e5e9fd53fe9f679b62cdada83aea4951aefe95ed6d2b5eca5a4695add45c PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC From b29f4cf34cc8c83034b696d185325a655a23bc06 Mon Sep 17 00:00:00 2001 From: Tamas Balogh Date: Mon, 27 Dec 2021 18:04:51 +0100 Subject: [PATCH 66/73] ath79: add support for ASUS RP-AC66 Asus RP-AC66 Repeater Hardware specifications: Board: AP152 SoC: QCA9563 DRAM: 64MB DDR2 Flash: 25l128 16MB SPI-NOR LAN/WAN: 1x1000M QCA8033 WiFi 5GHz: QCA9880 Clocks: CPU:775.000MHz, DDR:650.000MHz, AHB:258.333MHz, Ref:25.000MHz MAC addresses as verified by OEM firmware: use address source Lan/Wan *:24 art 0x1002 (label) 2G *:24 art 0x1002 5G *:26 art 0x5006 Installation: Asus windows recovery tool: - install the Asus firmware restoration utility - unplug the router, hold the reset button while powering it on - release when the power LED flashes slowly - specify a static IP on your computer: IP address: 192.168.1.75 Subnet mask 255.255.255.0 - Start the Asus firmware restoration utility, specify the factory image and press upload - Do not power off the device after OpenWrt has booted until the LED flashing. TFTP Recovery method: - set computer to a static ip, 192.168.1.75 - connect computer to the LAN 1 port of the router - hold the reset button while powering on the router for a few seconds - send firmware image using a tftp client; i.e from linux: $ tftp tftp> binary tftp> connect 192.168.1.1 tftp> put factory.bin tftp> quit Signed-off-by: Tamas Balogh --- .../linux/ath79/dts/qca9563_asus_rp-ac66.dts | 158 ++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 10 ++ .../generic/base-files/etc/board.d/02_network | 5 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 3 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 1 + target/linux/ath79/image/generic.mk | 12 ++ 6 files changed, 189 insertions(+) create mode 100644 target/linux/ath79/dts/qca9563_asus_rp-ac66.dts diff --git a/target/linux/ath79/dts/qca9563_asus_rp-ac66.dts b/target/linux/ath79/dts/qca9563_asus_rp-ac66.dts new file mode 100644 index 0000000000..b1317d55ec --- /dev/null +++ b/target/linux/ath79/dts/qca9563_asus_rp-ac66.dts @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "qca956x.dtsi" + +#include +#include +#include + +/ { + model = "ASUS RP-AC66"; + compatible = "asus,rp-ac66", "qca,qca9563"; + + aliases { + led-boot = &led_orange; + led-failsafe = &led_orange; + led-running = &led_power; + led-upgrade = &led_orange; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "green:power"; + gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + }; + + led_orange: wps { + label = "orange:wps"; + gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + }; + + rssilow-wlan0 { + label = "blue:rssilow-wlan0"; + gpios = <&gpio 14 GPIO_ACTIVE_HIGH>; + }; + + rssimedium-wlan0 { + label = "red:rssimedium-wlan0"; + gpios = <&gpio 16 GPIO_ACTIVE_HIGH>; + }; + + rssihigh-wlan0 { + label = "green:rssihigh-wlan0"; + gpios = <&gpio 15 GPIO_ACTIVE_HIGH>; + }; + + rssilow-wlan1 { + label = "blue:rssilow-wlan1"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + }; + + rssimedium-wlan1 { + label = "red:rssimedium-wlan1"; + gpios = <&gpio 9 GPIO_ACTIVE_HIGH>; + }; + + rssihigh-wlan1 { + label = "green:rssihigh-wlan1"; + gpios = <&gpio 8 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + linux,code = ; + gpios = <&gpio 5 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + reset { + linux,code = ; + gpios = <&gpio 2 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x40000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x040000 0x10000>; + read-only; + }; + + art: partition@50000 { + label = "art"; + reg = <0x050000 0x10000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_art_1002: macaddr@1002 { + reg = <0x1002 0x6>; + }; + }; + + partition@60000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x060000 0xf20000>; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy-mask = <0>; + + phy0: ethernet-phy@3 { + reg = <0x3>; + phy-mode = "sgmii"; + qca,mib-poll-interval = <500>; + }; +}; + +ð0 { + status = "okay"; + + phy-mode = "sgmii"; + nvmem-cells = <&macaddr_art_1002>; + nvmem-cell-names = "mac-address"; + phy-handle = <&phy0>; +}; + +&wmac { + status = "okay"; + + qca,no-eeprom; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 1c112b4952..7b27dd8910 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -48,6 +48,16 @@ alfa-network,r36a) ucidef_set_led_netdev "lan" "LAN" "blue:lan" "eth0" ucidef_set_led_switch "wan" "WAN" "blue:wan" "switch0" "0x10" ;; +asus,rp-ac66) + ucidef_set_rssimon "wlan0" "200000" "1" + ucidef_set_rssimon "wlan1" "200000" "1" + ucidef_set_led_rssi "rssilow-wlan0" "RSSILOW" "blue:rssilow-wlan0" "wlan0" "1" "1" + ucidef_set_led_rssi "rssimedium-wlan0" "RSSIMEDIUM" "red:rssimedium-wlan0" "wlan0" "1" "79" + ucidef_set_led_rssi "rssihigh-wlan0" "RSSIHIGH" "green:rssihigh-wlan0" "wlan0" "70" "100" + ucidef_set_led_rssi "rssilow-wlan1" "RSSILOW" "blue:rssilow-wlan1" "wlan1" "1" "1" + ucidef_set_led_rssi "rssimedium-wlan1" "RSSIMEDIUM" "red:rssimedium-wlan1" "wlan1" "1" "79" + ucidef_set_led_rssi "rssihigh-wlan1" "RSSIHIGH" "green:rssihigh-wlan1" "wlan1" "70" "100" + ;; avm,fritz1750e) ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0" ucidef_set_rssimon "wlan1" "200000" "1" diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index edd79b606e..e49e9bd3a1 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -15,6 +15,7 @@ ath79_setup_interfaces() alfa-network,pi-wifi4|\ arduino,yun|\ aruba,ap-105|\ + asus,rp-ac66|\ avm,fritz1750e|\ avm,fritz300e|\ avm,fritzdvbc|\ @@ -533,6 +534,10 @@ ath79_setup_macs() lan_mac=$(macaddr_setbit $base_mac 29) [ $lan_mac = $base_mac ] && lan_mac=$(macaddr_unsetbit $base_mac 29) ;; + asus,rp-ac66) + lan_mac=$(mtd_get_mac_binary art 0x1002) + label_mac=$lan_mac + ;; avm,fritz1750e|\ avm,fritz450e|\ avm,fritzdvbc) diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 219e618cb9..89a6adf5a6 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -12,6 +12,9 @@ case "$FIRMWARE" in 8dev,lima) caldata_extract "art" 0x1000 0x800 ;; + asus,rp-ac66) + caldata_extract "art" 0x1000 0x440 + ;; avm,fritz1750e|\ avm,fritz4020|\ avm,fritz450e|\ diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index 829d042036..ef9b8dee91 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -21,6 +21,7 @@ case "$FIRMWARE" in avm,fritzdvbc) caldata_extract "urlader" 0x198a 0x844 ;; + asus,rp-ac66|\ comfast,cf-wr650ac-v1|\ comfast,cf-wr650ac-v2|\ devolo,dlan-pro-1200plus-ac|\ diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index ff24764740..5e211a33a4 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -330,6 +330,18 @@ define Device/aruba_ap-105 endef TARGET_DEVICES += aruba_ap-105 +define Device/asus_rp-ac66 + SOC := qca9563 + DEVICE_VENDOR := ASUS + DEVICE_MODEL := RP-AC66 + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | \ + append-rootfs | pad-rootfs + DEVICE_PACKAGES := kmod-ath10k-ct-smallbuffers ath10k-firmware-qca988x-ct \ + rssileds -swconfig +endef +TARGET_DEVICES += asus_rp-ac66 + define Device/atheros_db120 $(Device/loader-okli-uimage) SOC := ar9344 From 000825d7925f4f6a2900a2b13eb4245df0e6521b Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 9 Jan 2022 20:09:15 +0000 Subject: [PATCH 67/73] opkg: update to git HEAD of 2022-01-09 db7fb64 libopkg: pkg_hash: prefer to-be-installed packages 2edcfad libopkg: set 'const' attribute for argv This should fix the ImageBuilder problems people are having since we introduced the 'uci-firewall' providers. Signed-off-by: Daniel Golle --- package/system/opkg/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile index bd9fab474c..8ac822f17e 100644 --- a/package/system/opkg/Makefile +++ b/package/system/opkg/Makefile @@ -12,9 +12,9 @@ PKG_FLAGS:=essential PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/opkg-lede.git -PKG_SOURCE_DATE:=2021-06-13 -PKG_SOURCE_VERSION:=1bf042dd06751b693a8544d2317e5b969d666b69 -PKG_MIRROR_HASH:=aeda4e0f11805bf95fc7be6d38391ce579acd965c8ba6a490b3e8669815b7264 +PKG_SOURCE_DATE:=2022-01-09 +PKG_SOURCE_VERSION:=2edcfad1bb9a32f31199d5842aa087b4d30ec6f5 +PKG_MIRROR_HASH:=b21e51ffe5bae3ca01865415630cc1f4b471f69e0d7947264a579165c7d44294 PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=COPYING From 72ef5945508193228544bcd7fcfe81b32e8dc042 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Mon, 23 Nov 2020 13:41:34 +0100 Subject: [PATCH 68/73] ath79: Add support for OpenMesh OM5P-AN Device specifications: ====================== * Qualcomm/Atheros AR9344 rev 2 * 560/450/225 MHz (CPU/DDR/AHB) * 64 MB of RAM * 16 MB of SPI NOR flash - 2x 7 MB available; but one of the 7 MB regions is the recovery image * 1T1R 2.4 GHz Wi-Fi * 2T2R 5 GHz Wi-Fi * 6x GPIO-LEDs (3x wifi, 2x ethernet, 1x power) * 1x GPIO-button (reset) * external h/w watchdog (enabled by default) * TTL pins are on board (arrow points to VCC, then follows: GND, TX, RX) * TI tmp423 (package kmod-hwmon-tmp421) for temperature monitoring * 2x ethernet - eth0 + AR8035 ethernet PHY + 10/100/1000 Mbps Ethernet + 802.3af POE + used as LAN interface - eth1 + 10/100 Mbps Ethernet + builtin switch port 1 + 18-24V passive POE (mode B) + used as WAN interface * 12-24V 1A DC * internal antennas Flashing instructions: ====================== Various methods can be used to install the actual image on the flash. Two easy ones are: ap51-flash ---------- The tool ap51-flash (https://github.com/ap51-flash/ap51-flash) should be used to transfer the image to the u-boot when the device boots up. initramfs from TFTP ------------------- The serial console must be used to access the u-boot shell during bootup. It can then be used to first boot up the initramfs image from a TFTP server (here with the IP 192.168.1.21): setenv serverip 192.168.1.21 setenv ipaddr 192.168.1.1 tftpboot 0c00000 .bin && bootm $fileaddr The actual sysupgrade image can then be transferred (on the LAN port) to the device via scp .bin root@192.168.1.1:/tmp/ On the device, the sysupgrade must then be started using sysupgrade -n /tmp/.bin Signed-off-by: Sven Eckelmann --- package/boot/uboot-envtools/files/ath79 | 1 + .../ath79/dts/ar9344_openmesh_om5p-an.dts | 230 ++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 4 + .../etc/hotplug.d/firmware/10-ath9k-eeprom | 3 +- .../base-files/lib/upgrade/platform.sh | 3 +- target/linux/ath79/image/generic.mk | 9 + 6 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 00339dcbcc..2ad15a7a40 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -57,6 +57,7 @@ openmesh,mr900-v2|\ openmesh,mr1750-v1|\ openmesh,mr1750-v2|\ openmesh,om5p|\ +openmesh,om5p-an|\ openmesh,om5p-ac-v2|\ samsung,wam250|\ ubnt,nanostation-m|\ diff --git a/target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts b/target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts new file mode 100644 index 0000000000..e15e296f82 --- /dev/null +++ b/target/linux/ath79/dts/ar9344_openmesh_om5p-an.dts @@ -0,0 +1,230 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar9344.dtsi" + +#include +#include + +/ { + compatible = "openmesh,om5p-an", "qca,ar9344"; + model = "OpenMesh OM5P-AN"; + + chosen { + /delete-property/ bootargs; + }; + + aliases { + led-boot = &led_power_blue; + led-failsafe = &led_power_blue; + led-running = &led_power_blue; + led-upgrade = &led_power_blue; + label-mac-device = ð0; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + pinctrl-names = "default"; + pinctrl-0 = <&led_lan_wan_blue_pin>; + + led_power_blue: power_blue { + label = "blue:power"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + wan_blue { + label = "blue:wan"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + lan_blue { + label = "blue:lan"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + wifi_green { + label = "green:wifi"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wifi_yellow { + label = "yellow:wifi"; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + }; + + wifi_red { + label = "red:wifi"; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + }; + }; + + i2c { + compatible = "i2c-gpio"; + gpios = <&gpio 21 GPIO_ACTIVE_HIGH /* sda */ + &gpio 20 GPIO_ACTIVE_HIGH /* scl */ + >; + #address-cells = <1>; + #size-cells = <0>; + + i2c-gpio,scl-open-drain; + i2c-gpio,sda-open-drain; + + tmp423a@4c { + compatible = "ti,tmp423"; + reg = <0x4c>; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + hw_algo = "toggle"; + /* hw_margin_ms is actually 300s but driver limits it to 60s */ + hw_margin_ms = <60000>; + always-running; + }; +}; + +&ref { + clock-frequency = <40000000>; +}; + +&pinmux { + led_lan_wan_blue_pin: pinmux_lan_wan_blue_pin { + pinctrl-single,bits = <0xc 0x0 0xffff0000>; + }; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <40000000>; + + /* partitions are passed via bootloader */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x040000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x040000 0x010000>; + }; + + partition@50000 { + label = "custom"; + reg = <0x050000 0x060000>; + read-only; + }; + + partition@b0000 { + label = "inactive"; + reg = <0x0b0000 0x7a0000>; + }; + + partition@850000 { + label = "inactive2"; + reg = <0x850000 0x7a0000>; + }; + + art: partition@ff0000 { + label = "ART"; + reg = <0xff0000 0x010000>; + read-only; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy-mask = <0x80>; + + phy7: ethernet-phy@7 { + reg = <7>; + eee-broken-100tx; + eee-broken-1000t; + }; +}; + +ð0 { + status = "okay"; + + pll-data = <0x02000000 0x00000101 0x00001313>; + + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + + phy-mode = "rgmii-id"; + phy-handle = <&phy7>; + + gmac-config { + device = <&gmac>; + rgmii-gmac0 = <1>; + rxd-delay = <2>; + rxdv-delay = <2>; + switch-phy-swap = <1>; + }; +}; + +ð1 { + status = "okay"; + + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <2>; +}; + +&pcie { + status = "okay"; + + wifi@0,0 { + compatible = "pci168c,0030"; + reg = <0x0000 0 0 0 0>; + qca,no-eeprom; + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <16>; + }; +}; + +&art { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_art_0: macaddr@0 { + reg = <0x0 0x6>; + }; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 7b27dd8910..14b38b4e66 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -271,6 +271,10 @@ openmesh,om2p-hs-v4) ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth0" ucidef_set_led_switch "lan" "LAN" "blue:lan" "switch0" "0x02" ;; +openmesh,om5p-an) + ucidef_set_led_netdev "lan" "LAN" "blue:lan" "eth0" + ucidef_set_led_switch "wan" "WAN" "blue:wan" "switch0" "0x02" + ;; pcs,cr3000) ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth1" ucidef_set_led_switch "lan1" "LAN1" "blue:lan1" "switch0" "0x04" diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 89a6adf5a6..10421c2e28 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -127,7 +127,8 @@ case "$FIRMWARE" in caldata_extract "art" 0x1000 0x1000 ;; openmesh,mr600-v1|\ - openmesh,mr600-v2) + openmesh,mr600-v2|\ + openmesh,om5p-an) caldata_extract "ART" 0x5000 0x440 ;; wd,mynet-n600|\ diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh index 20041e4c95..b7e2930129 100644 --- a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -80,7 +80,8 @@ platform_do_upgrade() { openmesh,om2p-hs-v3|\ openmesh,om2p-hs-v4|\ openmesh,om2p-lc|\ - openmesh,om5p) + openmesh,om5p|\ + openmesh,om5p-an) PART_NAME="inactive" platform_do_upgrade_openmesh "$1" ;; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 5e211a33a4..e17b498d88 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -1924,6 +1924,15 @@ define Device/openmesh_om5p-ac-v2 endef TARGET_DEVICES += openmesh_om5p-ac-v2 +define Device/openmesh_om5p-an + $(Device/openmesh_common_64k) + SOC := ar9344 + DEVICE_MODEL := OM5P-AN + OPENMESH_CE_TYPE := OM5P + SUPPORTED_DEVICES += om5p-an +endef +TARGET_DEVICES += openmesh_om5p-an + define Device/pcs_cap324 SOC := ar9344 DEVICE_VENDOR := PowerCloud Systems From 97f561725962ddb8823b2e01563a0f37f7930477 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Mon, 23 Nov 2020 13:41:34 +0100 Subject: [PATCH 69/73] ath79: Add support for OpenMesh OM5P-AC v1 Device specifications: ====================== * Qualcomm/Atheros QCA9558 ver 1 rev 0 * 720/600/240 MHz (CPU/DDR/AHB) * 128 MB of RAM * 16 MB of SPI NOR flash - 2x 7 MB available; but one of the 7 MB regions is the recovery image * 2T2R 2.4 GHz Wi-Fi (11n) * 2T2R 5 GHz Wi-Fi (11ac) * 6x GPIO-LEDs (3x wifi, 2x ethernet, 1x power) * external h/w watchdog (enabled by default)) * TTL pins are on board (arrow points to VCC, then follows: GND, TX, RX) * TI tmp423 (package kmod-hwmon-tmp421) for temperature monitoring * 2x ethernet - eth0 + AR8035 ethernet PHY (RGMII) + 10/100/1000 Mbps Ethernet + 802.3af POE + used as LAN interface - eth1 + AR8035 ethernet PHY (SGMII) + 10/100/1000 Mbps Ethernet + 18-24V passive POE (mode B) + used as WAN interface * 12-24V 1A DC * internal antennas Flashing instructions: ====================== Various methods can be used to install the actual image on the flash. Two easy ones are: ap51-flash ---------- The tool ap51-flash (https://github.com/ap51-flash/ap51-flash) should be used to transfer the image to the u-boot when the device boots up. initramfs from TFTP ------------------- The serial console must be used to access the u-boot shell during bootup. It can then be used to first boot up the initramfs image from a TFTP server (here with the IP 192.168.1.21): setenv serverip 192.168.1.21 setenv ipaddr 192.168.1.1 tftpboot 0c00000 .bin && bootm $fileaddr The actual sysupgrade image can then be transferred (on the LAN port) to the device via scp .bin root@192.168.1.1:/tmp/ On the device, the sysupgrade must then be started using sysupgrade -n /tmp/.bin Signed-off-by: Sven Eckelmann --- package/boot/uboot-envtools/files/ath79 | 1 + .../ath79/dts/qca9558_openmesh_om5p-ac-v1.dts | 216 ++++++++++++++++++ .../generic/base-files/etc/board.d/01_leds | 4 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 4 + .../base-files/lib/upgrade/platform.sh | 1 + target/linux/ath79/image/generic.mk | 11 + 6 files changed, 237 insertions(+) create mode 100644 target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 2ad15a7a40..b01a713705 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -58,6 +58,7 @@ openmesh,mr1750-v1|\ openmesh,mr1750-v2|\ openmesh,om5p|\ openmesh,om5p-an|\ +openmesh,om5p-ac-v1|\ openmesh,om5p-ac-v2|\ samsung,wam250|\ ubnt,nanostation-m|\ diff --git a/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts new file mode 100644 index 0000000000..de21f0119f --- /dev/null +++ b/target/linux/ath79/dts/qca9558_openmesh_om5p-ac-v1.dts @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "qca955x.dtsi" + +#include +#include + +/ { + compatible = "openmesh,om5p-ac-v1", "qca,qca9558"; + model = "OpenMesh OM5P-AC v1"; + + chosen { + /delete-property/ bootargs; + }; + + aliases { + serial0 = &uart; + led-boot = &led_power_blue; + led-failsafe = &led_power_blue; + led-running = &led_power_blue; + led-upgrade = &led_power_blue; + label-mac-device = ð0; + }; + + leds { + compatible = "gpio-leds"; + + led_power_blue: power_blue { + label = "blue:power"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + wan_blue { + label = "blue:wan"; + gpios = <&gpio 19 GPIO_ACTIVE_LOW>; + }; + + lan_blue { + label = "blue:lan"; + gpios = <&gpio 20 GPIO_ACTIVE_LOW>; + }; + + wifi_green { + label = "green:wifi"; + gpios = <&gpio 21 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wifi_yellow { + label = "yellow:wifi"; + gpios = <&gpio 22 GPIO_ACTIVE_LOW>; + }; + + wifi_red { + label = "red:wifi"; + gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + }; + }; + + i2c { + compatible = "i2c-gpio"; + gpios = <&gpio 11 GPIO_ACTIVE_HIGH /* sda */ + &gpio 12 GPIO_ACTIVE_HIGH /* scl */ + >; + #address-cells = <1>; + #size-cells = <0>; + + i2c-gpio,scl-open-drain; + i2c-gpio,sda-open-drain; + + tmp423a@4c { + compatible = "ti,tmp423"; + reg = <0x4c>; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + hw_algo = "toggle"; + /* hw_margin_ms is actually 300s but driver limits it to 60s */ + hw_margin_ms = <60000>; + always-running; + }; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <40000000>; + + /* partitions are passed via bootloader */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x040000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x040000 0x010000>; + }; + + partition@50000 { + label = "custom"; + reg = <0x050000 0x060000>; + read-only; + }; + + partition@b0000 { + label = "inactive"; + reg = <0x0b0000 0x7a0000>; + }; + + partition@850000 { + label = "inactive2"; + reg = <0x850000 0x7a0000>; + }; + + art: partition@ff0000 { + label = "ART"; + reg = <0xff0000 0x010000>; + read-only; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy-mask = <0x6>; + + phy1: ethernet-phy@1 { + reg = <1>; + eee-broken-100tx; + eee-broken-1000t; + }; + + phy2: ethernet-phy@2 { + reg = <2>; + eee-broken-100tx; + eee-broken-1000t; + at803x-override-sgmii-link-check; + }; +}; + +ð0 { + status = "okay"; + + pll-data = <0x82000101 0x80000101 0x80001313>; + + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + + phy-mode = "rgmii-id"; + phy-handle = <&phy1>; + + gmac-config { + device = <&gmac>; + rgmii-enabled = <1>; + rxd-delay = <3>; + rxdv-delay = <3>; + txd-delay = <0>; + txen-delay = <0>; + }; +}; + +ð1 { + status = "okay"; + + pll-data = <0x03000101 0x80000101 0x80001313>; + + nvmem-cells = <&macaddr_art_6>; + nvmem-cell-names = "mac-address"; + + qca955x-sgmii-fixup; + + phy-handle = <&phy2>; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; + nvmem-cells = <&macaddr_art_0>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <2>; +}; + +&pcie1 { + status = "okay"; +}; + +&art { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_art_0: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_art_6: macaddr@6 { + reg = <0x6 0x6>; + }; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds index 14b38b4e66..652b54092e 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds +++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds @@ -271,6 +271,10 @@ openmesh,om2p-hs-v4) ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth0" ucidef_set_led_switch "lan" "LAN" "blue:lan" "switch0" "0x02" ;; +openmesh,om5p-ac-v1) + ucidef_set_led_netdev "lan" "LAN" "blue:lan" "eth0" + ucidef_set_led_netdev "wan" "WAN" "blue:wan" "eth1" + ;; openmesh,om5p-an) ucidef_set_led_netdev "lan" "LAN" "blue:lan" "eth0" ucidef_set_led_switch "wan" "WAN" "blue:wan" "switch0" "0x02" diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index ef9b8dee91..c0e5078bdb 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -165,6 +165,10 @@ case "$FIRMWARE" in ;; "ath10k/cal-pci-0000:01:00.0.bin") case $board in + openmesh,om5p-ac-v1) + caldata_extract "ART" 0x5000 0x844 + ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16) + ;; sitecom,wlr-8100) caldata_extract "art" 0x5000 0x844 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) 1) diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh index b7e2930129..3d953d7982 100644 --- a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -81,6 +81,7 @@ platform_do_upgrade() { openmesh,om2p-hs-v4|\ openmesh,om2p-lc|\ openmesh,om5p|\ + openmesh,om5p-ac-v1|\ openmesh,om5p-an) PART_NAME="inactive" platform_do_upgrade_openmesh "$1" diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index e17b498d88..8e97fec402 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -1913,6 +1913,17 @@ define Device/openmesh_om5p endef TARGET_DEVICES += openmesh_om5p +define Device/openmesh_om5p-ac-v1 + $(Device/openmesh_common_64k) + SOC := qca9558 + DEVICE_MODEL := OM5P-AC + DEVICE_VARIANT := v1 + DEVICE_PACKAGES += kmod-ath10k-ct ath10k-firmware-qca988x-ct + OPENMESH_CE_TYPE := OM5PAC + SUPPORTED_DEVICES += om5p-ac +endef +TARGET_DEVICES += openmesh_om5p-ac-v1 + define Device/openmesh_om5p-ac-v2 SOC := qca9558 DEVICE_VENDOR := OpenMesh From e955a083407e075c5576fc60792f24f116f01596 Mon Sep 17 00:00:00 2001 From: Kevin Darbyshire-Bryant Date: Mon, 10 Jan 2022 10:19:45 +0000 Subject: [PATCH 70/73] firewall: update to latest HEAD 0f16ea5 options.c: add DSCP code LE Least Effort 24ba465 firewall3: remove redundant syn check df1306a firewall3: fix locking issue 3624c37 firewall3: support table load on access on Linux 5.15+ Signed-off-by: Kevin Darbyshire-Bryant --- package/network/config/firewall/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/config/firewall/Makefile b/package/network/config/firewall/Makefile index 815e33604c..f0123aa7fb 100644 --- a/package/network/config/firewall/Makefile +++ b/package/network/config/firewall/Makefile @@ -13,9 +13,9 @@ PKG_RELEASE:=2 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/firewall3.git -PKG_SOURCE_DATE:=2021-08-14 -PKG_SOURCE_VERSION:=40e5f6a2bd0b5406eff7e1d2d4f95bbf8f9410a4 -PKG_MIRROR_HASH:=4acd7d3c688d31a07ad871dcdbcd06d975ac86745d9f3a6caed68e694635965c +PKG_SOURCE_DATE:=2022-01-10 +PKG_SOURCE_VERSION:=0f16ea5f055722a532d4e68c7ba34ed084b48b37 +PKG_MIRROR_HASH:=219478ef95b170b5122030715eac7b3317f2ac4d67e1a936c22a78b10e056123 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC From 4648a60058eeb5c841ba7bc2f78480d957c692ab Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 10 Jan 2022 09:46:22 +0000 Subject: [PATCH 71/73] mediatek: mt7623: Disable power button reset for U7623-02 board The Unielec U7623 doesn't have a physical power button; I think it's hard wired so that it turns on automatically when power is applied (unlike the Banana Pi R2 which is a pain). So the 'reset on long press of power button' behaviour that we get when we enable the PMIC keyboard driver is kind of unhelpful. Disable it. Signed-off-by: David Woodhouse Fixes: 0d3f3323a2 ("mediatek: mt7623: enable more hardware features") --- target/linux/mediatek/dts/mt7623a-unielec-u7623-02-emmc.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/linux/mediatek/dts/mt7623a-unielec-u7623-02-emmc.dtsi b/target/linux/mediatek/dts/mt7623a-unielec-u7623-02-emmc.dtsi index aa1e82b58a..0a2972e23b 100644 --- a/target/linux/mediatek/dts/mt7623a-unielec-u7623-02-emmc.dtsi +++ b/target/linux/mediatek/dts/mt7623a-unielec-u7623-02-emmc.dtsi @@ -298,6 +298,10 @@ }; }; +&mt6323keys { + mediatek,long-press-mode = <0>; +}; + &uart2 { pinctrl-names = "default"; pinctrl-0 = <&uart2_pins_b>; From 8cdc356f8c30b55698d5f57abbd1f3e16d8c653e Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 10 Jan 2022 10:23:46 +0000 Subject: [PATCH 72/73] mediatek: mt7623: Re-enable ARM arch timer CONFIG_ARM_ARCH_TIMER cannot be enabled in the config directly; it is only selected by CONFIG_HAVE_ARM_ARCH_TIMER. We need to enable the latter in our config. Signed-off-by: David Woodhouse Fixes: 4f1c5b01c1 ("mediatek: mt7623: backport musb, improve HDMI console") --- target/linux/mediatek/mt7623/config-5.10 | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/mediatek/mt7623/config-5.10 b/target/linux/mediatek/mt7623/config-5.10 index aabc3b775e..308a08413b 100644 --- a/target/linux/mediatek/mt7623/config-5.10 +++ b/target/linux/mediatek/mt7623/config-5.10 @@ -260,6 +260,7 @@ CONFIG_HARDIRQS_SW_RESEND=y CONFIG_HAS_DMA=y CONFIG_HAS_IOMEM=y CONFIG_HAS_IOPORT_MAP=y +CONFIG_HAVE_ARM_ARCH_TIMER=y CONFIG_HAVE_SMP=y CONFIG_HDMI=y CONFIG_HID=y From f2c3875dfcbf82d993ebe20f9563125c5fde2c60 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Tue, 11 Jan 2022 00:00:36 +0000 Subject: [PATCH 73/73] generic: deny write to uImage.FIT sub-image partitions Set policy bit to force read-only mode on uImage.FIT filesystem sub-images mapped as block partitions by the FIT partition parser. Signed-off-by: Daniel Golle --- target/linux/generic/files/block/partitions/fit.c | 2 +- .../hack-5.10/410-block-fit-partition-parser.patch | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/target/linux/generic/files/block/partitions/fit.c b/target/linux/generic/files/block/partitions/fit.c index a0aa0eadf5..fa73e64af8 100644 --- a/target/linux/generic/files/block/partitions/fit.c +++ b/target/linux/generic/files/block/partitions/fit.c @@ -230,7 +230,7 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector, strlcat(state->pp_buf, tmp, PAGE_SIZE); state->parts[*slot].has_info = true; - + state->parts[*slot].flags |= ADDPART_FLAG_READONLY; if (config_loadables && !strcmp(image_name, config_loadables)) { printk(KERN_DEBUG "FIT: selecting configured loadable \"%s\" to be root filesystem\n", image_name); state->parts[*slot].flags |= ADDPART_FLAG_ROOTDEV; diff --git a/target/linux/generic/hack-5.10/410-block-fit-partition-parser.patch b/target/linux/generic/hack-5.10/410-block-fit-partition-parser.patch index c0b3c25339..bc48296d9c 100644 --- a/target/linux/generic/hack-5.10/410-block-fit-partition-parser.patch +++ b/target/linux/generic/hack-5.10/410-block-fit-partition-parser.patch @@ -1,10 +1,11 @@ --- a/block/blk.h +++ b/block/blk.h -@@ -361,6 +361,7 @@ char *disk_name(struct gendisk *hd, int +@@ -361,6 +361,8 @@ char *disk_name(struct gendisk *hd, int #define ADDPART_FLAG_NONE 0 #define ADDPART_FLAG_RAID 1 #define ADDPART_FLAG_WHOLEDISK 2 -+#define ADDPART_FLAG_ROOTDEV 4 ++#define ADDPART_FLAG_READONLY 4 ++#define ADDPART_FLAG_ROOTDEV 8 void delete_partition(struct hd_struct *part); int bdev_add_partition(struct block_device *bdev, int partno, sector_t start, sector_t length); @@ -73,13 +74,16 @@ #ifdef CONFIG_SGI_PARTITION sgi_partition, #endif -@@ -694,6 +701,11 @@ static bool blk_add_partition(struct gen +@@ -694,6 +701,14 @@ static bool blk_add_partition(struct gen (state->parts[p].flags & ADDPART_FLAG_RAID)) md_autodetect_dev(part_to_dev(part)->devt); +#ifdef CONFIG_FIT_PARTITION + if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0) + ROOT_DEV = part_to_dev(part)->devt; ++ ++ if (state->parts[p].flags & ADDPART_FLAG_READONLY) ++ part->policy = true; +#endif + return true;