--- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -1437,6 +1437,13 @@ config CRYPTO_LZ4HC help This is the LZ4 high compression mode algorithm. +config CRYPTO_XZ + tristate "XZ compression algorithm" + select CRYPTO_ALGAPI + select XZ_DEC + help + This is the XZ algorithm. Only decompression is supported for now. + comment "Random Number Generation" config CRYPTO_ANSI_CPRNG --- a/crypto/Makefile +++ b/crypto/Makefile @@ -89,6 +89,7 @@ obj-$(CONFIG_CRYPTO_AUTHENC) += authenc. obj-$(CONFIG_CRYPTO_LZO) += lzo.o obj-$(CONFIG_CRYPTO_LZ4) += lz4.o obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o +obj-$(CONFIG_CRYPTO_XZ) += xz.o obj-$(CONFIG_CRYPTO_842) += 842.o obj-$(CONFIG_CRYPTO_RNG2) += rng.o obj-$(CONFIG_CRYPTO_RNG2) += krng.o --- /dev/null +++ b/crypto/xz.c @@ -0,0 +1,117 @@ +/* + * Cryptographic API. + * + * XZ decompression support. + * + * Copyright (c) 2012 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + */ +#include +#include +#include +#include +#include +#include +#include + +struct xz_comp_ctx { + struct xz_dec *decomp_state; + struct xz_buf decomp_buf; +}; + +static int crypto_xz_decomp_init(struct xz_comp_ctx *ctx) +{ + ctx->decomp_state = xz_dec_init(XZ_SINGLE, 0); + if (!ctx->decomp_state) + return -ENOMEM; + + return 0; +} + +static void crypto_xz_decomp_exit(struct xz_comp_ctx *ctx) +{ + xz_dec_end(ctx->decomp_state); +} + +static int crypto_xz_init(struct crypto_tfm *tfm) +{ + struct xz_comp_ctx *ctx = crypto_tfm_ctx(tfm); + + return crypto_xz_decomp_init(ctx); +} + +static void crypto_xz_exit(struct crypto_tfm *tfm) +{ + struct xz_comp_ctx *ctx = crypto_tfm_ctx(tfm); + + crypto_xz_decomp_exit(ctx); +} + +static int crypto_xz_compress(struct crypto_tfm *tfm, const u8 *src, + unsigned int slen, u8 *dst, unsigned int *dlen) +{ + return -EOPNOTSUPP; +} + +static int crypto_xz_decompress(struct crypto_tfm *tfm, const u8 *src, + unsigned int slen, u8 *dst, unsigned int *dlen) +{ + struct xz_comp_ctx *dctx = crypto_tfm_ctx(tfm); + struct xz_buf *xz_buf = &dctx->decomp_buf; + int ret; + + memset(xz_buf, '\0', sizeof(struct xz_buf)); + + xz_buf->in = (u8 *) src; + xz_buf->in_pos = 0; + xz_buf->in_size = slen; + xz_buf->out = (u8 *) dst; + xz_buf->out_pos = 0; + xz_buf->out_size = *dlen; + + ret = xz_dec_run(dctx->decomp_state, xz_buf); + if (ret != XZ_STREAM_END) { + ret = -EINVAL; + goto out; + } + + *dlen = xz_buf->out_pos; + ret = 0; + +out: + return ret; +} + +static struct crypto_alg crypto_xz_alg = { + .cra_name = "xz", + .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, + .cra_ctxsize = sizeof(struct xz_comp_ctx), + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(crypto_xz_alg.cra_list), + .cra_init = crypto_xz_init, + .cra_exit = crypto_xz_exit, + .cra_u = { .compress = { + .coa_compress = crypto_xz_compress, + .coa_decompress = crypto_xz_decompress } } +}; + +static int __init crypto_xz_mod_init(void) +{ + return crypto_register_alg(&crypto_xz_alg); +} + +static void __exit crypto_xz_mod_exit(void) +{ + crypto_unregister_alg(&crypto_xz_alg); +} + +module_init(crypto_xz_mod_init); +module_exit(crypto_xz_mod_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Crypto XZ decompression support"); +MODULE_AUTHOR("Gabor Juhos "); ref='/cgit/openwrt/upstream/tree/target?h=v21.02.1&id=d81a8ad5239d2f65683845645fef527e6d39ac2e'>target/linux/ar71xx/patches-3.14/722-MIPS-ath79-add-airGateway-support.patch
blob: 6b17c025a97e2f465059bc0273043e79bb3a760e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--- a/arch/mips/ath79/mach-ubnt-xm.c
+++ b/arch/mips/ath79/mach-ubnt-xm.c
@@ -17,9 +17,11 @@
 #include <linux/etherdevice.h>
 #include <linux/ar8216_platform.h>
 
+#include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/irq.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
 
+#include "common.h"
 #include "dev-ap9x-pci.h"
 #include "dev-eth.h"
 #include "dev-gpio-buttons.h"
@@ -407,3 +409,65 @@ MIPS_MACHINE(ATH79_MACH_UBNT_NANO_M_XW, 
 
 MIPS_MACHINE(ATH79_MACH_UBNT_LOCO_M_XW, "UBNT-LOCO-XW", "Ubiquiti Loco M XW",
 	     ubnt_loco_m_xw_setup);
+
+static struct gpio_led ubnt_airgateway_gpio_leds[] __initdata = {
+	{
+		.name	   = "ubnt:blue:wlan",
+		.gpio	   = 0,
+	}, {
+		.name	   = "ubnt:white:status",
+		.gpio	   = 1,
+	},
+};
+
+static struct gpio_keys_button airgateway_gpio_keys[] __initdata = {
+	{
+		.desc		= "reset",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.debounce_interval	= UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= 12,
+		.active_low	= 1,
+	}
+};
+
+static void __init ubnt_airgateway_setup(void)
+{
+	u32 t;
+	u8 *mac0 = (u8 *) KSEG1ADDR(0x1fff0000);
+	u8 *mac1 = (u8 *) KSEG1ADDR(0x1fff0000 + ETH_ALEN);
+	u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
+
+
+	ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
+				     AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
+				     AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
+				     AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
+				     AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
+	t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
+	t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
+	ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
+
+	ath79_register_m25p80(NULL);
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_airgateway_gpio_leds),
+				 ubnt_airgateway_gpio_leds);
+
+	ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(airgateway_gpio_keys),
+					airgateway_gpio_keys);
+
+	ath79_init_mac(ath79_eth1_data.mac_addr, mac0, 0);
+	ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
+
+	ath79_register_mdio(0, 0x0);
+
+	ath79_register_eth(1);
+	ath79_register_eth(0);
+
+	ath79_register_wmac(ee, NULL);
+}
+
+MIPS_MACHINE(ATH79_MACH_UBNT_AIRGW, "UBNT-AGW", "Ubiquiti AirGateway",
+	     ubnt_airgateway_setup);
+
--- a/arch/mips/ath79/machtypes.h
+++ b/arch/mips/ath79/machtypes.h
@@ -144,6 +144,7 @@ enum ath79_mach_type {
 	ATH79_MACH_TL_WR842N_V2,	/* TP-LINK TL-WR842N/ND v2 */
 	ATH79_MACH_TL_WR941ND,		/* TP-LINK TL-WR941ND */
 	ATH79_MACH_TUBE2H,		/* Alfa Network Tube2H */
+	ATH79_MACH_UBNT_AIRGW,		/* Ubiquiti AirGateway */
 	ATH79_MACH_UBNT_AIRROUTER,	/* Ubiquiti AirRouter */
 	ATH79_MACH_UBNT_BULLET_M,	/* Ubiquiti Bullet M */
 	ATH79_MACH_UBNT_LOCO_M_XW, 	/* Ubiquiti Loco M XW */