mirror of https://github.com/hak5/openwrt.git
parent
20ba6d90e3
commit
0b8c1c8dfb
File diff suppressed because it is too large
Load Diff
|
@ -1,96 +0,0 @@
|
|||
From 2d303b4683145f7dbc918bd14d04e1396581b2ce Mon Sep 17 00:00:00 2001
|
||||
From: Imre Kaloz <kaloz@openwrt.org>
|
||||
Date: Thu, 7 Jul 2011 12:05:21 +0200
|
||||
Subject: [PATCH] ARM: support XZ compressed kernels
|
||||
|
||||
Wire up support for the XZ decompressor
|
||||
|
||||
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
|
||||
---
|
||||
arch/arm/Kconfig | 1 +
|
||||
arch/arm/boot/compressed/Makefile | 11 +++++++++--
|
||||
arch/arm/boot/compressed/decompress.c | 4 ++++
|
||||
arch/arm/boot/compressed/piggy.xzkern.S | 6 ++++++
|
||||
lib/xz/xz_dec_stream.c | 1 +
|
||||
5 files changed, 21 insertions(+), 2 deletions(-)
|
||||
create mode 100644 arch/arm/boot/compressed/piggy.xzkern.S
|
||||
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -20,6 +20,7 @@ config ARM
|
||||
select HAVE_KERNEL_GZIP
|
||||
select HAVE_KERNEL_LZO
|
||||
select HAVE_KERNEL_LZMA
|
||||
+ select HAVE_KERNEL_XZ
|
||||
select HAVE_IRQ_WORK
|
||||
select HAVE_PERF_EVENTS
|
||||
select PERF_USE_VMALLOC
|
||||
--- a/arch/arm/boot/compressed/Makefile
|
||||
+++ b/arch/arm/boot/compressed/Makefile
|
||||
@@ -92,6 +92,7 @@ SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/
|
||||
suffix_$(CONFIG_KERNEL_GZIP) = gzip
|
||||
suffix_$(CONFIG_KERNEL_LZO) = lzo
|
||||
suffix_$(CONFIG_KERNEL_LZMA) = lzma
|
||||
+suffix_$(CONFIG_KERNEL_XZ) = xzkern
|
||||
|
||||
# Borrowed libfdt files for the ATAG compatibility mode
|
||||
|
||||
@@ -115,7 +116,7 @@ targets := vmlinux vmlinux.lds \
|
||||
lib1funcs.o lib1funcs.S font.o font.c head.o misc.o $(OBJS)
|
||||
|
||||
# Make sure files are removed during clean
|
||||
-extra-y += piggy.gzip piggy.lzo piggy.lzma lib1funcs.S $(libfdt) $(libfdt_hdrs)
|
||||
+extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern lib1funcs.S ashldi3.S $(libfdt) $(libfdt_hdrs)
|
||||
|
||||
ifeq ($(CONFIG_FUNCTION_TRACER),y)
|
||||
ORIG_CFLAGS := $(KBUILD_CFLAGS)
|
||||
@@ -170,8 +171,14 @@ if [ $(words $(ZRELADDR)) -gt 1 -a "$(CO
|
||||
false; \
|
||||
fi
|
||||
|
||||
+# For __aeabi_llsl
|
||||
+ashldi3 = $(obj)/ashldi3.o
|
||||
+
|
||||
+$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S FORCE
|
||||
+ $(call cmd,shipped)
|
||||
+
|
||||
$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
|
||||
- $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) FORCE
|
||||
+ $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) FORCE
|
||||
@$(check_for_multiple_zreladdr)
|
||||
$(call if_changed,ld)
|
||||
@$(check_for_bad_syms)
|
||||
--- a/arch/arm/boot/compressed/decompress.c
|
||||
+++ b/arch/arm/boot/compressed/decompress.c
|
||||
@@ -44,6 +44,12 @@ extern void error(char *);
|
||||
#include "../../../../lib/decompress_unlzma.c"
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_KERNEL_XZ
|
||||
+#define memmove memmove
|
||||
+#define memcpy memcpy
|
||||
+#include "../../../../lib/decompress_unxz.c"
|
||||
+#endif
|
||||
+
|
||||
int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
|
||||
{
|
||||
return decompress(input, len, NULL, NULL, output, NULL, error);
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/compressed/piggy.xzkern.S
|
||||
@@ -0,0 +1,6 @@
|
||||
+ .section .piggydata,#alloc
|
||||
+ .globl input_data
|
||||
+input_data:
|
||||
+ .incbin "arch/arm/boot/compressed/piggy.xzkern"
|
||||
+ .globl input_data_end
|
||||
+input_data_end:
|
||||
--- a/lib/xz/xz_dec_stream.c
|
||||
+++ b/lib/xz/xz_dec_stream.c
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xz_private.h"
|
||||
#include "xz_stream.h"
|
||||
+#include <linux/kernel.h>
|
||||
|
||||
/* Hash used to validate the Index field */
|
||||
struct xz_dec_hash {
|
|
@ -1,850 +0,0 @@
|
|||
--- a/drivers/ssb/b43_pci_bridge.c
|
||||
+++ b/drivers/ssb/b43_pci_bridge.c
|
||||
@@ -29,6 +29,8 @@ static const struct pci_device_id b43_pc
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4319) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4320) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) },
|
||||
+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4322) },
|
||||
+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43222) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4325) },
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4328) },
|
||||
--- a/drivers/ssb/driver_chipcommon_pmu.c
|
||||
+++ b/drivers/ssb/driver_chipcommon_pmu.c
|
||||
@@ -13,6 +13,9 @@
|
||||
#include <linux/ssb/ssb_driver_chipcommon.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/export.h>
|
||||
+#ifdef CONFIG_BCM47XX
|
||||
+#include <asm/mach-bcm47xx/nvram.h>
|
||||
+#endif
|
||||
|
||||
#include "ssb_private.h"
|
||||
|
||||
@@ -92,10 +95,6 @@ static void ssb_pmu0_pllinit_r0(struct s
|
||||
u32 pmuctl, tmp, pllctl;
|
||||
unsigned int i;
|
||||
|
||||
- if ((bus->chip_id == 0x5354) && !crystalfreq) {
|
||||
- /* The 5354 crystal freq is 25MHz */
|
||||
- crystalfreq = 25000;
|
||||
- }
|
||||
if (crystalfreq)
|
||||
e = pmu0_plltab_find_entry(crystalfreq);
|
||||
if (!e)
|
||||
@@ -321,7 +320,11 @@ static void ssb_pmu_pll_init(struct ssb_
|
||||
u32 crystalfreq = 0; /* in kHz. 0 = keep default freq. */
|
||||
|
||||
if (bus->bustype == SSB_BUSTYPE_SSB) {
|
||||
- /* TODO: The user may override the crystal frequency. */
|
||||
+#ifdef CONFIG_BCM47XX
|
||||
+ char buf[20];
|
||||
+ if (nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
|
||||
+ crystalfreq = simple_strtoul(buf, NULL, 0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
switch (bus->chip_id) {
|
||||
@@ -330,7 +333,11 @@ static void ssb_pmu_pll_init(struct ssb_
|
||||
ssb_pmu1_pllinit_r0(cc, crystalfreq);
|
||||
break;
|
||||
case 0x4328:
|
||||
+ ssb_pmu0_pllinit_r0(cc, crystalfreq);
|
||||
+ break;
|
||||
case 0x5354:
|
||||
+ if (crystalfreq == 0)
|
||||
+ crystalfreq = 25000;
|
||||
ssb_pmu0_pllinit_r0(cc, crystalfreq);
|
||||
break;
|
||||
case 0x4322:
|
||||
@@ -607,3 +614,34 @@ void ssb_pmu_set_ldo_paref(struct ssb_ch
|
||||
|
||||
EXPORT_SYMBOL(ssb_pmu_set_ldo_voltage);
|
||||
EXPORT_SYMBOL(ssb_pmu_set_ldo_paref);
|
||||
+
|
||||
+u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc)
|
||||
+{
|
||||
+ struct ssb_bus *bus = cc->dev->bus;
|
||||
+
|
||||
+ switch (bus->chip_id) {
|
||||
+ case 0x5354:
|
||||
+ /* 5354 chip uses a non programmable PLL of frequency 240MHz */
|
||||
+ return 240000000;
|
||||
+ default:
|
||||
+ ssb_printk(KERN_ERR PFX
|
||||
+ "ERROR: PMU cpu clock unknown for device %04X\n",
|
||||
+ bus->chip_id);
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc)
|
||||
+{
|
||||
+ struct ssb_bus *bus = cc->dev->bus;
|
||||
+
|
||||
+ switch (bus->chip_id) {
|
||||
+ case 0x5354:
|
||||
+ return 120000000;
|
||||
+ default:
|
||||
+ ssb_printk(KERN_ERR PFX
|
||||
+ "ERROR: PMU controlclock unknown for device %04X\n",
|
||||
+ bus->chip_id);
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
--- a/drivers/ssb/driver_mipscore.c
|
||||
+++ b/drivers/ssb/driver_mipscore.c
|
||||
@@ -208,6 +208,9 @@ u32 ssb_cpu_clock(struct ssb_mipscore *m
|
||||
struct ssb_bus *bus = mcore->dev->bus;
|
||||
u32 pll_type, n, m, rate = 0;
|
||||
|
||||
+ if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
|
||||
+ return ssb_pmu_get_cpu_clock(&bus->chipco);
|
||||
+
|
||||
if (bus->extif.dev) {
|
||||
ssb_extif_get_clockcontrol(&bus->extif, &pll_type, &n, &m);
|
||||
} else if (bus->chipco.dev) {
|
||||
--- a/drivers/ssb/driver_pcicore.c
|
||||
+++ b/drivers/ssb/driver_pcicore.c
|
||||
@@ -75,7 +75,7 @@ static u32 get_cfgspace_addr(struct ssb_
|
||||
u32 tmp;
|
||||
|
||||
/* We do only have one cardbus device behind the bridge. */
|
||||
- if (pc->cardbusmode && (dev >= 1))
|
||||
+ if (pc->cardbusmode && (dev > 1))
|
||||
goto out;
|
||||
|
||||
if (bus == 0) {
|
||||
--- a/drivers/ssb/main.c
|
||||
+++ b/drivers/ssb/main.c
|
||||
@@ -140,19 +140,6 @@ static void ssb_device_put(struct ssb_de
|
||||
put_device(dev->dev);
|
||||
}
|
||||
|
||||
-static inline struct ssb_driver *ssb_driver_get(struct ssb_driver *drv)
|
||||
-{
|
||||
- if (drv)
|
||||
- get_driver(&drv->drv);
|
||||
- return drv;
|
||||
-}
|
||||
-
|
||||
-static inline void ssb_driver_put(struct ssb_driver *drv)
|
||||
-{
|
||||
- if (drv)
|
||||
- put_driver(&drv->drv);
|
||||
-}
|
||||
-
|
||||
static int ssb_device_resume(struct device *dev)
|
||||
{
|
||||
struct ssb_device *ssb_dev = dev_to_ssb_dev(dev);
|
||||
@@ -250,11 +237,9 @@ int ssb_devices_freeze(struct ssb_bus *b
|
||||
ssb_device_put(sdev);
|
||||
continue;
|
||||
}
|
||||
- sdrv = ssb_driver_get(drv_to_ssb_drv(sdev->dev->driver));
|
||||
- if (!sdrv || SSB_WARN_ON(!sdrv->remove)) {
|
||||
- ssb_device_put(sdev);
|
||||
+ sdrv = drv_to_ssb_drv(sdev->dev->driver);
|
||||
+ if (SSB_WARN_ON(!sdrv->remove))
|
||||
continue;
|
||||
- }
|
||||
sdrv->remove(sdev);
|
||||
ctx->device_frozen[i] = 1;
|
||||
}
|
||||
@@ -293,7 +278,6 @@ int ssb_devices_thaw(struct ssb_freeze_c
|
||||
dev_name(sdev->dev));
|
||||
result = err;
|
||||
}
|
||||
- ssb_driver_put(sdrv);
|
||||
ssb_device_put(sdev);
|
||||
}
|
||||
|
||||
@@ -1094,6 +1078,9 @@ u32 ssb_clockspeed(struct ssb_bus *bus)
|
||||
u32 plltype;
|
||||
u32 clkctl_n, clkctl_m;
|
||||
|
||||
+ if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU)
|
||||
+ return ssb_pmu_get_controlclock(&bus->chipco);
|
||||
+
|
||||
if (ssb_extif_available(&bus->extif))
|
||||
ssb_extif_get_clockcontrol(&bus->extif, &plltype,
|
||||
&clkctl_n, &clkctl_m);
|
||||
--- a/drivers/ssb/pci.c
|
||||
+++ b/drivers/ssb/pci.c
|
||||
@@ -178,6 +178,18 @@ err_pci:
|
||||
#define SPEX(_outvar, _offset, _mask, _shift) \
|
||||
SPEX16(_outvar, _offset, _mask, _shift)
|
||||
|
||||
+#define SPEX_ARRAY8(_field, _offset, _mask, _shift) \
|
||||
+ do { \
|
||||
+ SPEX(_field[0], _offset + 0, _mask, _shift); \
|
||||
+ SPEX(_field[1], _offset + 2, _mask, _shift); \
|
||||
+ SPEX(_field[2], _offset + 4, _mask, _shift); \
|
||||
+ SPEX(_field[3], _offset + 6, _mask, _shift); \
|
||||
+ SPEX(_field[4], _offset + 8, _mask, _shift); \
|
||||
+ SPEX(_field[5], _offset + 10, _mask, _shift); \
|
||||
+ SPEX(_field[6], _offset + 12, _mask, _shift); \
|
||||
+ SPEX(_field[7], _offset + 14, _mask, _shift); \
|
||||
+ } while (0)
|
||||
+
|
||||
|
||||
static inline u8 ssb_crc8(u8 crc, u8 data)
|
||||
{
|
||||
@@ -331,7 +343,6 @@ static void sprom_extract_r123(struct ss
|
||||
{
|
||||
int i;
|
||||
u16 v;
|
||||
- s8 gain;
|
||||
u16 loc[3];
|
||||
|
||||
if (out->revision == 3) /* rev 3 moved MAC */
|
||||
@@ -361,8 +372,9 @@ static void sprom_extract_r123(struct ss
|
||||
SPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14);
|
||||
SPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15);
|
||||
SPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0);
|
||||
- SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
|
||||
- SSB_SPROM1_BINF_CCODE_SHIFT);
|
||||
+ if (out->revision == 1)
|
||||
+ SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
|
||||
+ SSB_SPROM1_BINF_CCODE_SHIFT);
|
||||
SPEX(ant_available_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA,
|
||||
SSB_SPROM1_BINF_ANTA_SHIFT);
|
||||
SPEX(ant_available_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG,
|
||||
@@ -388,22 +400,16 @@ static void sprom_extract_r123(struct ss
|
||||
SPEX(boardflags_lo, SSB_SPROM1_BFLLO, 0xFFFF, 0);
|
||||
if (out->revision >= 2)
|
||||
SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0);
|
||||
+ SPEX(alpha2[0], SSB_SPROM1_CCODE, 0xff00, 8);
|
||||
+ SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);
|
||||
|
||||
/* Extract the antenna gain values. */
|
||||
- gain = r123_extract_antgain(out->revision, in,
|
||||
- SSB_SPROM1_AGAIN_BG,
|
||||
- SSB_SPROM1_AGAIN_BG_SHIFT);
|
||||
- out->antenna_gain.ghz24.a0 = gain;
|
||||
- out->antenna_gain.ghz24.a1 = gain;
|
||||
- out->antenna_gain.ghz24.a2 = gain;
|
||||
- out->antenna_gain.ghz24.a3 = gain;
|
||||
- gain = r123_extract_antgain(out->revision, in,
|
||||
- SSB_SPROM1_AGAIN_A,
|
||||
- SSB_SPROM1_AGAIN_A_SHIFT);
|
||||
- out->antenna_gain.ghz5.a0 = gain;
|
||||
- out->antenna_gain.ghz5.a1 = gain;
|
||||
- out->antenna_gain.ghz5.a2 = gain;
|
||||
- out->antenna_gain.ghz5.a3 = gain;
|
||||
+ out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
|
||||
+ SSB_SPROM1_AGAIN_BG,
|
||||
+ SSB_SPROM1_AGAIN_BG_SHIFT);
|
||||
+ out->antenna_gain.a1 = r123_extract_antgain(out->revision, in,
|
||||
+ SSB_SPROM1_AGAIN_A,
|
||||
+ SSB_SPROM1_AGAIN_A_SHIFT);
|
||||
}
|
||||
|
||||
/* Revs 4 5 and 8 have partially shared layout */
|
||||
@@ -464,14 +470,17 @@ static void sprom_extract_r45(struct ssb
|
||||
SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0);
|
||||
SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A,
|
||||
SSB_SPROM4_ETHPHY_ET1A_SHIFT);
|
||||
+ SPEX(board_rev, SSB_SPROM4_BOARDREV, 0xFFFF, 0);
|
||||
if (out->revision == 4) {
|
||||
- SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0);
|
||||
+ SPEX(alpha2[0], SSB_SPROM4_CCODE, 0xff00, 8);
|
||||
+ SPEX(alpha2[1], SSB_SPROM4_CCODE, 0x00ff, 0);
|
||||
SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
|
||||
SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0);
|
||||
SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0);
|
||||
SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0);
|
||||
} else {
|
||||
- SPEX(country_code, SSB_SPROM5_CCODE, 0xFFFF, 0);
|
||||
+ SPEX(alpha2[0], SSB_SPROM5_CCODE, 0xff00, 8);
|
||||
+ SPEX(alpha2[1], SSB_SPROM5_CCODE, 0x00ff, 0);
|
||||
SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0);
|
||||
SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0);
|
||||
SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0);
|
||||
@@ -504,16 +513,14 @@ static void sprom_extract_r45(struct ssb
|
||||
}
|
||||
|
||||
/* Extract the antenna gain values. */
|
||||
- SPEX(antenna_gain.ghz24.a0, SSB_SPROM4_AGAIN01,
|
||||
+ SPEX(antenna_gain.a0, SSB_SPROM4_AGAIN01,
|
||||
SSB_SPROM4_AGAIN0, SSB_SPROM4_AGAIN0_SHIFT);
|
||||
- SPEX(antenna_gain.ghz24.a1, SSB_SPROM4_AGAIN01,
|
||||
+ SPEX(antenna_gain.a1, SSB_SPROM4_AGAIN01,
|
||||
SSB_SPROM4_AGAIN1, SSB_SPROM4_AGAIN1_SHIFT);
|
||||
- SPEX(antenna_gain.ghz24.a2, SSB_SPROM4_AGAIN23,
|
||||
+ SPEX(antenna_gain.a2, SSB_SPROM4_AGAIN23,
|
||||
SSB_SPROM4_AGAIN2, SSB_SPROM4_AGAIN2_SHIFT);
|
||||
- SPEX(antenna_gain.ghz24.a3, SSB_SPROM4_AGAIN23,
|
||||
+ SPEX(antenna_gain.a3, SSB_SPROM4_AGAIN23,
|
||||
SSB_SPROM4_AGAIN3, SSB_SPROM4_AGAIN3_SHIFT);
|
||||
- memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
|
||||
- sizeof(out->antenna_gain.ghz5));
|
||||
|
||||
sprom_extract_r458(out, in);
|
||||
|
||||
@@ -523,14 +530,22 @@ static void sprom_extract_r45(struct ssb
|
||||
static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
|
||||
{
|
||||
int i;
|
||||
- u16 v;
|
||||
+ u16 v, o;
|
||||
+ u16 pwr_info_offset[] = {
|
||||
+ SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
|
||||
+ SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
|
||||
+ };
|
||||
+ BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
|
||||
+ ARRAY_SIZE(out->core_pwr_info));
|
||||
|
||||
/* extract the MAC address */
|
||||
for (i = 0; i < 3; i++) {
|
||||
v = in[SPOFF(SSB_SPROM8_IL0MAC) + i];
|
||||
*(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
|
||||
}
|
||||
- SPEX(country_code, SSB_SPROM8_CCODE, 0xFFFF, 0);
|
||||
+ SPEX(board_rev, SSB_SPROM8_BOARDREV, 0xFFFF, 0);
|
||||
+ SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
|
||||
+ SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);
|
||||
SPEX(boardflags_lo, SSB_SPROM8_BFLLO, 0xFFFF, 0);
|
||||
SPEX(boardflags_hi, SSB_SPROM8_BFLHI, 0xFFFF, 0);
|
||||
SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, 0xFFFF, 0);
|
||||
@@ -596,17 +611,127 @@ static void sprom_extract_r8(struct ssb_
|
||||
SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, 0xFFFFFFFF, 0);
|
||||
|
||||
/* Extract the antenna gain values. */
|
||||
- SPEX(antenna_gain.ghz24.a0, SSB_SPROM8_AGAIN01,
|
||||
+ SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
|
||||
SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
|
||||
- SPEX(antenna_gain.ghz24.a1, SSB_SPROM8_AGAIN01,
|
||||
+ SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
|
||||
SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
|
||||
- SPEX(antenna_gain.ghz24.a2, SSB_SPROM8_AGAIN23,
|
||||
+ SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
|
||||
SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
|
||||
- SPEX(antenna_gain.ghz24.a3, SSB_SPROM8_AGAIN23,
|
||||
+ SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
|
||||
SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
|
||||
- memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
|
||||
- sizeof(out->antenna_gain.ghz5));
|
||||
|
||||
+ /* Extract cores power info info */
|
||||
+ for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
|
||||
+ o = pwr_info_offset[i];
|
||||
+ SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
|
||||
+ SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
|
||||
+ SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
|
||||
+ SSB_SPROM8_2G_MAXP, 0);
|
||||
+
|
||||
+ SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
|
||||
+
|
||||
+ SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
|
||||
+ SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
|
||||
+ SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
|
||||
+ SSB_SPROM8_5G_MAXP, 0);
|
||||
+ SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
|
||||
+ SSB_SPROM8_5GH_MAXP, 0);
|
||||
+ SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
|
||||
+ SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
|
||||
+
|
||||
+ SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
|
||||
+ SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
|
||||
+ }
|
||||
+
|
||||
+ /* Extract FEM info */
|
||||
+ SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G,
|
||||
+ SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
|
||||
+ SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G,
|
||||
+ SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
|
||||
+ SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G,
|
||||
+ SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT);
|
||||
+ SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G,
|
||||
+ SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT);
|
||||
+ SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G,
|
||||
+ SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
|
||||
+
|
||||
+ SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G,
|
||||
+ SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
|
||||
+ SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G,
|
||||
+ SSB_SROM8_FEM_EXTPA_GAIN, SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
|
||||
+ SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G,
|
||||
+ SSB_SROM8_FEM_PDET_RANGE, SSB_SROM8_FEM_PDET_RANGE_SHIFT);
|
||||
+ SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G,
|
||||
+ SSB_SROM8_FEM_TR_ISO, SSB_SROM8_FEM_TR_ISO_SHIFT);
|
||||
+ SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G,
|
||||
+ SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
|
||||
+
|
||||
+ SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
|
||||
+ SSB_SPROM8_LEDDC_ON_SHIFT);
|
||||
+ SPEX(leddc_off_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_OFF,
|
||||
+ SSB_SPROM8_LEDDC_OFF_SHIFT);
|
||||
+
|
||||
+ SPEX(txchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_TXCHAIN,
|
||||
+ SSB_SPROM8_TXRXC_TXCHAIN_SHIFT);
|
||||
+ SPEX(rxchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_RXCHAIN,
|
||||
+ SSB_SPROM8_TXRXC_RXCHAIN_SHIFT);
|
||||
+ SPEX(antswitch, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_SWITCH,
|
||||
+ SSB_SPROM8_TXRXC_SWITCH_SHIFT);
|
||||
+
|
||||
+ SPEX(opo, SSB_SPROM8_OFDM2GPO, 0x00ff, 0);
|
||||
+
|
||||
+ SPEX_ARRAY8(mcs2gpo, SSB_SPROM8_2G_MCSPO, ~0, 0);
|
||||
+ SPEX_ARRAY8(mcs5gpo, SSB_SPROM8_5G_MCSPO, ~0, 0);
|
||||
+ SPEX_ARRAY8(mcs5glpo, SSB_SPROM8_5GL_MCSPO, ~0, 0);
|
||||
+ SPEX_ARRAY8(mcs5ghpo, SSB_SPROM8_5GH_MCSPO, ~0, 0);
|
||||
+
|
||||
+ SPEX(rawtempsense, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_RAWTEMP,
|
||||
+ SSB_SPROM8_RAWTS_RAWTEMP_SHIFT);
|
||||
+ SPEX(measpower, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_MEASPOWER,
|
||||
+ SSB_SPROM8_RAWTS_MEASPOWER_SHIFT);
|
||||
+ SPEX(tempsense_slope, SSB_SPROM8_OPT_CORRX,
|
||||
+ SSB_SPROM8_OPT_CORRX_TEMP_SLOPE,
|
||||
+ SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT);
|
||||
+ SPEX(tempcorrx, SSB_SPROM8_OPT_CORRX, SSB_SPROM8_OPT_CORRX_TEMPCORRX,
|
||||
+ SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT);
|
||||
+ SPEX(tempsense_option, SSB_SPROM8_OPT_CORRX,
|
||||
+ SSB_SPROM8_OPT_CORRX_TEMP_OPTION,
|
||||
+ SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT);
|
||||
+ SPEX(freqoffset_corr, SSB_SPROM8_HWIQ_IQSWP,
|
||||
+ SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR,
|
||||
+ SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT);
|
||||
+ SPEX(iqcal_swp_dis, SSB_SPROM8_HWIQ_IQSWP,
|
||||
+ SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP,
|
||||
+ SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT);
|
||||
+ SPEX(hw_iqcal_en, SSB_SPROM8_HWIQ_IQSWP, SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL,
|
||||
+ SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT);
|
||||
+
|
||||
+ SPEX(bw40po, SSB_SPROM8_BW40PO, ~0, 0);
|
||||
+ SPEX(cddpo, SSB_SPROM8_CDDPO, ~0, 0);
|
||||
+ SPEX(stbcpo, SSB_SPROM8_STBCPO, ~0, 0);
|
||||
+ SPEX(bwduppo, SSB_SPROM8_BWDUPPO, ~0, 0);
|
||||
+
|
||||
+ SPEX(tempthresh, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_TRESH,
|
||||
+ SSB_SPROM8_THERMAL_TRESH_SHIFT);
|
||||
+ SPEX(tempoffset, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_OFFSET,
|
||||
+ SSB_SPROM8_THERMAL_OFFSET_SHIFT);
|
||||
+ SPEX(phycal_tempdelta, SSB_SPROM8_TEMPDELTA,
|
||||
+ SSB_SPROM8_TEMPDELTA_PHYCAL,
|
||||
+ SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT);
|
||||
+ SPEX(temps_period, SSB_SPROM8_TEMPDELTA, SSB_SPROM8_TEMPDELTA_PERIOD,
|
||||
+ SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT);
|
||||
+ SPEX(temps_hysteresis, SSB_SPROM8_TEMPDELTA,
|
||||
+ SSB_SPROM8_TEMPDELTA_HYSTERESIS,
|
||||
+ SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT);
|
||||
sprom_extract_r458(out, in);
|
||||
|
||||
/* TODO - get remaining rev 8 stuff needed */
|
||||
@@ -736,7 +861,6 @@ static void ssb_pci_get_boardinfo(struct
|
||||
{
|
||||
bi->vendor = bus->host_pci->subsystem_vendor;
|
||||
bi->type = bus->host_pci->subsystem_device;
|
||||
- bi->rev = bus->host_pci->revision;
|
||||
}
|
||||
|
||||
int ssb_pci_get_invariants(struct ssb_bus *bus,
|
||||
--- a/drivers/ssb/pcmcia.c
|
||||
+++ b/drivers/ssb/pcmcia.c
|
||||
@@ -676,14 +676,10 @@ static int ssb_pcmcia_do_get_invariants(
|
||||
case SSB_PCMCIA_CIS_ANTGAIN:
|
||||
GOTO_ERROR_ON(tuple->TupleDataLen != 2,
|
||||
"antg tpl size");
|
||||
- sprom->antenna_gain.ghz24.a0 = tuple->TupleData[1];
|
||||
- sprom->antenna_gain.ghz24.a1 = tuple->TupleData[1];
|
||||
- sprom->antenna_gain.ghz24.a2 = tuple->TupleData[1];
|
||||
- sprom->antenna_gain.ghz24.a3 = tuple->TupleData[1];
|
||||
- sprom->antenna_gain.ghz5.a0 = tuple->TupleData[1];
|
||||
- sprom->antenna_gain.ghz5.a1 = tuple->TupleData[1];
|
||||
- sprom->antenna_gain.ghz5.a2 = tuple->TupleData[1];
|
||||
- sprom->antenna_gain.ghz5.a3 = tuple->TupleData[1];
|
||||
+ sprom->antenna_gain.a0 = tuple->TupleData[1];
|
||||
+ sprom->antenna_gain.a1 = tuple->TupleData[1];
|
||||
+ sprom->antenna_gain.a2 = tuple->TupleData[1];
|
||||
+ sprom->antenna_gain.a3 = tuple->TupleData[1];
|
||||
break;
|
||||
case SSB_PCMCIA_CIS_BFLAGS:
|
||||
GOTO_ERROR_ON((tuple->TupleDataLen != 3) &&
|
||||
--- a/drivers/ssb/scan.c
|
||||
+++ b/drivers/ssb/scan.c
|
||||
@@ -318,6 +318,9 @@ int ssb_bus_scan(struct ssb_bus *bus,
|
||||
bus->chip_package = 0;
|
||||
}
|
||||
}
|
||||
+ ssb_printk(KERN_INFO PFX "Found chip with id 0x%04X, rev 0x%02X and "
|
||||
+ "package 0x%02X\n", bus->chip_id, bus->chip_rev,
|
||||
+ bus->chip_package);
|
||||
if (!bus->nr_devices)
|
||||
bus->nr_devices = chipid_to_nrcores(bus->chip_id);
|
||||
if (bus->nr_devices > ARRAY_SIZE(bus->devices)) {
|
||||
--- a/drivers/ssb/sdio.c
|
||||
+++ b/drivers/ssb/sdio.c
|
||||
@@ -551,14 +551,10 @@ int ssb_sdio_get_invariants(struct ssb_b
|
||||
case SSB_SDIO_CIS_ANTGAIN:
|
||||
GOTO_ERROR_ON(tuple->size != 2,
|
||||
"antg tpl size");
|
||||
- sprom->antenna_gain.ghz24.a0 = tuple->data[1];
|
||||
- sprom->antenna_gain.ghz24.a1 = tuple->data[1];
|
||||
- sprom->antenna_gain.ghz24.a2 = tuple->data[1];
|
||||
- sprom->antenna_gain.ghz24.a3 = tuple->data[1];
|
||||
- sprom->antenna_gain.ghz5.a0 = tuple->data[1];
|
||||
- sprom->antenna_gain.ghz5.a1 = tuple->data[1];
|
||||
- sprom->antenna_gain.ghz5.a2 = tuple->data[1];
|
||||
- sprom->antenna_gain.ghz5.a3 = tuple->data[1];
|
||||
+ sprom->antenna_gain.a0 = tuple->data[1];
|
||||
+ sprom->antenna_gain.a1 = tuple->data[1];
|
||||
+ sprom->antenna_gain.a2 = tuple->data[1];
|
||||
+ sprom->antenna_gain.a3 = tuple->data[1];
|
||||
break;
|
||||
case SSB_SDIO_CIS_BFLAGS:
|
||||
GOTO_ERROR_ON((tuple->size != 3) &&
|
||||
--- a/drivers/ssb/ssb_private.h
|
||||
+++ b/drivers/ssb/ssb_private.h
|
||||
@@ -207,4 +207,8 @@ static inline void b43_pci_ssb_bridge_ex
|
||||
}
|
||||
#endif /* CONFIG_SSB_B43_PCI_BRIDGE */
|
||||
|
||||
+/* driver_chipcommon_pmu.c */
|
||||
+extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc);
|
||||
+extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc);
|
||||
+
|
||||
#endif /* LINUX_SSB_PRIVATE_H_ */
|
||||
--- a/include/linux/ssb/ssb.h
|
||||
+++ b/include/linux/ssb/ssb.h
|
||||
@@ -16,6 +16,12 @@ struct pcmcia_device;
|
||||
struct ssb_bus;
|
||||
struct ssb_driver;
|
||||
|
||||
+struct ssb_sprom_core_pwr_info {
|
||||
+ u8 itssi_2g, itssi_5g;
|
||||
+ u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
|
||||
+ u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4];
|
||||
+};
|
||||
+
|
||||
struct ssb_sprom {
|
||||
u8 revision;
|
||||
u8 il0mac[6]; /* MAC address for 802.11b/g */
|
||||
@@ -26,9 +32,12 @@ struct ssb_sprom {
|
||||
u8 et0mdcport; /* MDIO for enet0 */
|
||||
u8 et1mdcport; /* MDIO for enet1 */
|
||||
u16 board_rev; /* Board revision number from SPROM. */
|
||||
+ u16 board_num; /* Board number from SPROM. */
|
||||
+ u16 board_type; /* Board type from SPROM. */
|
||||
u8 country_code; /* Country Code */
|
||||
- u16 leddc_on_time; /* LED Powersave Duty Cycle On Count */
|
||||
- u16 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
|
||||
+ char alpha2[2]; /* Country Code as two chars like EU or US */
|
||||
+ u8 leddc_on_time; /* LED Powersave Duty Cycle On Count */
|
||||
+ u8 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
|
||||
u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */
|
||||
u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */
|
||||
u16 pa0b0;
|
||||
@@ -47,10 +56,10 @@ struct ssb_sprom {
|
||||
u8 gpio1; /* GPIO pin 1 */
|
||||
u8 gpio2; /* GPIO pin 2 */
|
||||
u8 gpio3; /* GPIO pin 3 */
|
||||
- u16 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
- u16 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
- u16 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
- u16 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
+ u8 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
+ u8 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
+ u8 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
+ u8 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
|
||||
u8 itssi_a; /* Idle TSSI Target for A-PHY */
|
||||
u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
|
||||
u8 tri2g; /* 2.4GHz TX isolation */
|
||||
@@ -61,8 +70,8 @@ struct ssb_sprom {
|
||||
u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
|
||||
u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
|
||||
u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
|
||||
- u8 rxpo2g; /* 2GHz RX power offset */
|
||||
- u8 rxpo5g; /* 5GHz RX power offset */
|
||||
+ s8 rxpo2g; /* 2GHz RX power offset */
|
||||
+ s8 rxpo5g; /* 5GHz RX power offset */
|
||||
u8 rssisav2g; /* 2GHz RSSI params */
|
||||
u8 rssismc2g;
|
||||
u8 rssismf2g;
|
||||
@@ -82,26 +91,103 @@ struct ssb_sprom {
|
||||
u16 boardflags2_hi; /* Board flags (bits 48-63) */
|
||||
/* TODO store board flags in a single u64 */
|
||||
|
||||
+ struct ssb_sprom_core_pwr_info core_pwr_info[4];
|
||||
+
|
||||
/* Antenna gain values for up to 4 antennas
|
||||
* on each band. Values in dBm/4 (Q5.2). Negative gain means the
|
||||
* loss in the connectors is bigger than the gain. */
|
||||
struct {
|
||||
- struct {
|
||||
- s8 a0, a1, a2, a3;
|
||||
- } ghz24; /* 2.4GHz band */
|
||||
- struct {
|
||||
- s8 a0, a1, a2, a3;
|
||||
- } ghz5; /* 5GHz band */
|
||||
+ s8 a0, a1, a2, a3;
|
||||
} antenna_gain;
|
||||
|
||||
- /* TODO - add any parameters needed from rev 2, 3, 4, 5 or 8 SPROMs */
|
||||
+ struct {
|
||||
+ struct {
|
||||
+ u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
|
||||
+ } ghz2;
|
||||
+ struct {
|
||||
+ u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
|
||||
+ } ghz5;
|
||||
+ } fem;
|
||||
+
|
||||
+ u16 mcs2gpo[8];
|
||||
+ u16 mcs5gpo[8];
|
||||
+ u16 mcs5glpo[8];
|
||||
+ u16 mcs5ghpo[8];
|
||||
+ u8 opo;
|
||||
+
|
||||
+ u8 rxgainerr2ga[3];
|
||||
+ u8 rxgainerr5gla[3];
|
||||
+ u8 rxgainerr5gma[3];
|
||||
+ u8 rxgainerr5gha[3];
|
||||
+ u8 rxgainerr5gua[3];
|
||||
+
|
||||
+ u8 noiselvl2ga[3];
|
||||
+ u8 noiselvl5gla[3];
|
||||
+ u8 noiselvl5gma[3];
|
||||
+ u8 noiselvl5gha[3];
|
||||
+ u8 noiselvl5gua[3];
|
||||
+
|
||||
+ u8 regrev;
|
||||
+ u8 txchain;
|
||||
+ u8 rxchain;
|
||||
+ u8 antswitch;
|
||||
+ u16 cddpo;
|
||||
+ u16 stbcpo;
|
||||
+ u16 bw40po;
|
||||
+ u16 bwduppo;
|
||||
+
|
||||
+ u8 tempthresh;
|
||||
+ u8 tempoffset;
|
||||
+ u16 rawtempsense;
|
||||
+ u8 measpower;
|
||||
+ u8 tempsense_slope;
|
||||
+ u8 tempcorrx;
|
||||
+ u8 tempsense_option;
|
||||
+ u8 freqoffset_corr;
|
||||
+ u8 iqcal_swp_dis;
|
||||
+ u8 hw_iqcal_en;
|
||||
+ u8 elna2g;
|
||||
+ u8 elna5g;
|
||||
+ u8 phycal_tempdelta;
|
||||
+ u8 temps_period;
|
||||
+ u8 temps_hysteresis;
|
||||
+ u8 measpower1;
|
||||
+ u8 measpower2;
|
||||
+ u8 pcieingress_war;
|
||||
+
|
||||
+ /* power per rate from sromrev 9 */
|
||||
+ u16 cckbw202gpo;
|
||||
+ u16 cckbw20ul2gpo;
|
||||
+ u32 legofdmbw202gpo;
|
||||
+ u32 legofdmbw20ul2gpo;
|
||||
+ u32 legofdmbw205glpo;
|
||||
+ u32 legofdmbw20ul5glpo;
|
||||
+ u32 legofdmbw205gmpo;
|
||||
+ u32 legofdmbw20ul5gmpo;
|
||||
+ u32 legofdmbw205ghpo;
|
||||
+ u32 legofdmbw20ul5ghpo;
|
||||
+ u32 mcsbw202gpo;
|
||||
+ u32 mcsbw20ul2gpo;
|
||||
+ u32 mcsbw402gpo;
|
||||
+ u32 mcsbw205glpo;
|
||||
+ u32 mcsbw20ul5glpo;
|
||||
+ u32 mcsbw405glpo;
|
||||
+ u32 mcsbw205gmpo;
|
||||
+ u32 mcsbw20ul5gmpo;
|
||||
+ u32 mcsbw405gmpo;
|
||||
+ u32 mcsbw205ghpo;
|
||||
+ u32 mcsbw20ul5ghpo;
|
||||
+ u32 mcsbw405ghpo;
|
||||
+ u16 mcs32po;
|
||||
+ u16 legofdm40duppo;
|
||||
+ u8 sar2g;
|
||||
+ u8 sar5g;
|
||||
};
|
||||
|
||||
/* Information about the PCB the circuitry is soldered on. */
|
||||
struct ssb_boardinfo {
|
||||
u16 vendor;
|
||||
u16 type;
|
||||
- u8 rev;
|
||||
};
|
||||
|
||||
|
||||
--- a/include/linux/ssb/ssb_driver_gige.h
|
||||
+++ b/include/linux/ssb/ssb_driver_gige.h
|
||||
@@ -2,6 +2,7 @@
|
||||
#define LINUX_SSB_DRIVER_GIGE_H_
|
||||
|
||||
#include <linux/ssb/ssb.h>
|
||||
+#include <linux/bug.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
--- a/include/linux/ssb/ssb_regs.h
|
||||
+++ b/include/linux/ssb/ssb_regs.h
|
||||
@@ -228,6 +228,7 @@
|
||||
#define SSB_SPROM1_AGAIN_BG_SHIFT 0
|
||||
#define SSB_SPROM1_AGAIN_A 0xFF00 /* A-PHY */
|
||||
#define SSB_SPROM1_AGAIN_A_SHIFT 8
|
||||
+#define SSB_SPROM1_CCODE 0x0076
|
||||
|
||||
/* SPROM Revision 2 (inherits from rev 1) */
|
||||
#define SSB_SPROM2_BFLHI 0x0038 /* Boardflags (high 16 bits) */
|
||||
@@ -267,6 +268,7 @@
|
||||
#define SSB_SPROM3_OFDMGPO 0x107A /* G-PHY OFDM Power Offset (4 bytes, BigEndian) */
|
||||
|
||||
/* SPROM Revision 4 */
|
||||
+#define SSB_SPROM4_BOARDREV 0x0042 /* Board revision */
|
||||
#define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */
|
||||
#define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */
|
||||
#define SSB_SPROM4_BFL2LO 0x0048 /* Board flags 2 (low 16 bits) */
|
||||
@@ -389,6 +391,11 @@
|
||||
#define SSB_SPROM8_GPIOB_P2 0x00FF /* Pin 2 */
|
||||
#define SSB_SPROM8_GPIOB_P3 0xFF00 /* Pin 3 */
|
||||
#define SSB_SPROM8_GPIOB_P3_SHIFT 8
|
||||
+#define SSB_SPROM8_LEDDC 0x009A
|
||||
+#define SSB_SPROM8_LEDDC_ON 0xFF00 /* oncount */
|
||||
+#define SSB_SPROM8_LEDDC_ON_SHIFT 8
|
||||
+#define SSB_SPROM8_LEDDC_OFF 0x00FF /* offcount */
|
||||
+#define SSB_SPROM8_LEDDC_OFF_SHIFT 0
|
||||
#define SSB_SPROM8_ANTAVAIL 0x009C /* Antenna available bitfields*/
|
||||
#define SSB_SPROM8_ANTAVAIL_A 0xFF00 /* A-PHY bitfield */
|
||||
#define SSB_SPROM8_ANTAVAIL_A_SHIFT 8
|
||||
@@ -404,6 +411,13 @@
|
||||
#define SSB_SPROM8_AGAIN2_SHIFT 0
|
||||
#define SSB_SPROM8_AGAIN3 0xFF00 /* Antenna 3 */
|
||||
#define SSB_SPROM8_AGAIN3_SHIFT 8
|
||||
+#define SSB_SPROM8_TXRXC 0x00A2
|
||||
+#define SSB_SPROM8_TXRXC_TXCHAIN 0x000f
|
||||
+#define SSB_SPROM8_TXRXC_TXCHAIN_SHIFT 0
|
||||
+#define SSB_SPROM8_TXRXC_RXCHAIN 0x00f0
|
||||
+#define SSB_SPROM8_TXRXC_RXCHAIN_SHIFT 4
|
||||
+#define SSB_SPROM8_TXRXC_SWITCH 0xff00
|
||||
+#define SSB_SPROM8_TXRXC_SWITCH_SHIFT 8
|
||||
#define SSB_SPROM8_RSSIPARM2G 0x00A4 /* RSSI params for 2GHz */
|
||||
#define SSB_SPROM8_RSSISMF2G 0x000F
|
||||
#define SSB_SPROM8_RSSISMC2G 0x00F0
|
||||
@@ -430,8 +444,87 @@
|
||||
#define SSB_SPROM8_TRI5GH_SHIFT 8
|
||||
#define SSB_SPROM8_RXPO 0x00AC /* RX power offsets */
|
||||
#define SSB_SPROM8_RXPO2G 0x00FF /* 2GHz RX power offset */
|
||||
+#define SSB_SPROM8_RXPO2G_SHIFT 0
|
||||
#define SSB_SPROM8_RXPO5G 0xFF00 /* 5GHz RX power offset */
|
||||
#define SSB_SPROM8_RXPO5G_SHIFT 8
|
||||
+#define SSB_SPROM8_FEM2G 0x00AE
|
||||
+#define SSB_SPROM8_FEM5G 0x00B0
|
||||
+#define SSB_SROM8_FEM_TSSIPOS 0x0001
|
||||
+#define SSB_SROM8_FEM_TSSIPOS_SHIFT 0
|
||||
+#define SSB_SROM8_FEM_EXTPA_GAIN 0x0006
|
||||
+#define SSB_SROM8_FEM_EXTPA_GAIN_SHIFT 1
|
||||
+#define SSB_SROM8_FEM_PDET_RANGE 0x00F8
|
||||
+#define SSB_SROM8_FEM_PDET_RANGE_SHIFT 3
|
||||
+#define SSB_SROM8_FEM_TR_ISO 0x0700
|
||||
+#define SSB_SROM8_FEM_TR_ISO_SHIFT 8
|
||||
+#define SSB_SROM8_FEM_ANTSWLUT 0xF800
|
||||
+#define SSB_SROM8_FEM_ANTSWLUT_SHIFT 11
|
||||
+#define SSB_SPROM8_THERMAL 0x00B2
|
||||
+#define SSB_SPROM8_THERMAL_OFFSET 0x00ff
|
||||
+#define SSB_SPROM8_THERMAL_OFFSET_SHIFT 0
|
||||
+#define SSB_SPROM8_THERMAL_TRESH 0xff00
|
||||
+#define SSB_SPROM8_THERMAL_TRESH_SHIFT 8
|
||||
+/* Temp sense related entries */
|
||||
+#define SSB_SPROM8_RAWTS 0x00B4
|
||||
+#define SSB_SPROM8_RAWTS_RAWTEMP 0x01ff
|
||||
+#define SSB_SPROM8_RAWTS_RAWTEMP_SHIFT 0
|
||||
+#define SSB_SPROM8_RAWTS_MEASPOWER 0xfe00
|
||||
+#define SSB_SPROM8_RAWTS_MEASPOWER_SHIFT 9
|
||||
+#define SSB_SPROM8_OPT_CORRX 0x00B6
|
||||
+#define SSB_SPROM8_OPT_CORRX_TEMP_SLOPE 0x00ff
|
||||
+#define SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT 0
|
||||
+#define SSB_SPROM8_OPT_CORRX_TEMPCORRX 0xfc00
|
||||
+#define SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT 10
|
||||
+#define SSB_SPROM8_OPT_CORRX_TEMP_OPTION 0x0300
|
||||
+#define SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT 8
|
||||
+/* FOC: freiquency offset correction, HWIQ: H/W IOCAL enable, IQSWP: IQ CAL swap disable */
|
||||
+#define SSB_SPROM8_HWIQ_IQSWP 0x00B8
|
||||
+#define SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR 0x000f
|
||||
+#define SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT 0
|
||||
+#define SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP 0x0010
|
||||
+#define SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT 4
|
||||
+#define SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL 0x0020
|
||||
+#define SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT 5
|
||||
+#define SSB_SPROM8_TEMPDELTA 0x00BA
|
||||
+#define SSB_SPROM8_TEMPDELTA_PHYCAL 0x00ff
|
||||
+#define SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT 0
|
||||
+#define SSB_SPROM8_TEMPDELTA_PERIOD 0x0f00
|
||||
+#define SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT 8
|
||||
+#define SSB_SPROM8_TEMPDELTA_HYSTERESIS 0xf000
|
||||
+#define SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT 12
|
||||
+
|
||||
+/* There are 4 blocks with power info sharing the same layout */
|
||||
+#define SSB_SROM8_PWR_INFO_CORE0 0x00C0
|
||||
+#define SSB_SROM8_PWR_INFO_CORE1 0x00E0
|
||||
+#define SSB_SROM8_PWR_INFO_CORE2 0x0100
|
||||
+#define SSB_SROM8_PWR_INFO_CORE3 0x0120
|
||||
+
|
||||
+#define SSB_SROM8_2G_MAXP_ITSSI 0x00
|
||||
+#define SSB_SPROM8_2G_MAXP 0x00FF
|
||||
+#define SSB_SPROM8_2G_ITSSI 0xFF00
|
||||
+#define SSB_SPROM8_2G_ITSSI_SHIFT 8
|
||||
+#define SSB_SROM8_2G_PA_0 0x02 /* 2GHz power amp settings */
|
||||
+#define SSB_SROM8_2G_PA_1 0x04
|
||||
+#define SSB_SROM8_2G_PA_2 0x06
|
||||
+#define SSB_SROM8_5G_MAXP_ITSSI 0x08 /* 5GHz ITSSI and 5.3GHz Max Power */
|
||||
+#define SSB_SPROM8_5G_MAXP 0x00FF
|
||||
+#define SSB_SPROM8_5G_ITSSI 0xFF00
|
||||
+#define SSB_SPROM8_5G_ITSSI_SHIFT 8
|
||||
+#define SSB_SPROM8_5GHL_MAXP 0x0A /* 5.2GHz and 5.8GHz Max Power */
|
||||
+#define SSB_SPROM8_5GH_MAXP 0x00FF
|
||||
+#define SSB_SPROM8_5GL_MAXP 0xFF00
|
||||
+#define SSB_SPROM8_5GL_MAXP_SHIFT 8
|
||||
+#define SSB_SROM8_5G_PA_0 0x0C /* 5.3GHz power amp settings */
|
||||
+#define SSB_SROM8_5G_PA_1 0x0E
|
||||
+#define SSB_SROM8_5G_PA_2 0x10
|
||||
+#define SSB_SROM8_5GL_PA_0 0x12 /* 5.2GHz power amp settings */
|
||||
+#define SSB_SROM8_5GL_PA_1 0x14
|
||||
+#define SSB_SROM8_5GL_PA_2 0x16
|
||||
+#define SSB_SROM8_5GH_PA_0 0x18 /* 5.8GHz power amp settings */
|
||||
+#define SSB_SROM8_5GH_PA_1 0x1A
|
||||
+#define SSB_SROM8_5GH_PA_2 0x1C
|
||||
+
|
||||
+/* TODO: Make it deprecated */
|
||||
#define SSB_SPROM8_MAXP_BG 0x00C0 /* Max Power 2GHz in path 1 */
|
||||
#define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power 2GHz */
|
||||
#define SSB_SPROM8_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
|
||||
@@ -456,12 +549,23 @@
|
||||
#define SSB_SPROM8_PA1HIB0 0x00D8 /* 5.8GHz power amp settings */
|
||||
#define SSB_SPROM8_PA1HIB1 0x00DA
|
||||
#define SSB_SPROM8_PA1HIB2 0x00DC
|
||||
+
|
||||
#define SSB_SPROM8_CCK2GPO 0x0140 /* CCK power offset */
|
||||
#define SSB_SPROM8_OFDM2GPO 0x0142 /* 2.4GHz OFDM power offset */
|
||||
#define SSB_SPROM8_OFDM5GPO 0x0146 /* 5.3GHz OFDM power offset */
|
||||
#define SSB_SPROM8_OFDM5GLPO 0x014A /* 5.2GHz OFDM power offset */
|
||||
#define SSB_SPROM8_OFDM5GHPO 0x014E /* 5.8GHz OFDM power offset */
|
||||
|
||||
+#define SSB_SPROM8_2G_MCSPO 0x0152
|
||||
+#define SSB_SPROM8_5G_MCSPO 0x0162
|
||||
+#define SSB_SPROM8_5GL_MCSPO 0x0172
|
||||
+#define SSB_SPROM8_5GH_MCSPO 0x0182
|
||||
+
|
||||
+#define SSB_SPROM8_CDDPO 0x0192
|
||||
+#define SSB_SPROM8_STBCPO 0x0194
|
||||
+#define SSB_SPROM8_BW40PO 0x0196
|
||||
+#define SSB_SPROM8_BWDUPPO 0x0198
|
||||
+
|
||||
/* Values for boardflags_lo read from SPROM */
|
||||
#define SSB_BFL_BTCOEXIST 0x0001 /* implements Bluetooth coexistance */
|
||||
#define SSB_BFL_PACTRL 0x0002 /* GPIO 9 controlling the PA */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,41 +0,0 @@
|
|||
--- a/drivers/usb/host/ehci-hcd.c
|
||||
+++ b/drivers/usb/host/ehci-hcd.c
|
||||
@@ -753,7 +753,7 @@ static int ehci_run (struct usb_hcd *hcd
|
||||
"USB %x.%x started, EHCI %x.%02x%s\n",
|
||||
((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
|
||||
temp >> 8, temp & 0xff,
|
||||
- ignore_oc ? ", overcurrent ignored" : "");
|
||||
+ (ignore_oc || ehci->ignore_oc) ? ", overcurrent ignored" : "");
|
||||
|
||||
ehci_writel(ehci, INTR_MASK,
|
||||
&ehci->regs->intr_enable); /* Turn On Interrupts */
|
||||
--- a/drivers/usb/host/ehci-hub.c
|
||||
+++ b/drivers/usb/host/ehci-hub.c
|
||||
@@ -578,7 +578,7 @@ ehci_hub_status_data (struct usb_hcd *hc
|
||||
* always set, seem to clear PORT_OCC and PORT_CSC when writing to
|
||||
* PORT_POWER; that's surprising, but maybe within-spec.
|
||||
*/
|
||||
- if (!ignore_oc)
|
||||
+ if (!ignore_oc && !ehci->ignore_oc)
|
||||
mask = PORT_CSC | PORT_PEC | PORT_OCC;
|
||||
else
|
||||
mask = PORT_CSC | PORT_PEC;
|
||||
@@ -803,7 +803,7 @@ static int ehci_hub_control (
|
||||
if (temp & PORT_PEC)
|
||||
status |= USB_PORT_STAT_C_ENABLE << 16;
|
||||
|
||||
- if ((temp & PORT_OCC) && !ignore_oc){
|
||||
+ if ((temp & PORT_OCC) && (!ignore_oc && !ehci->ignore_oc)){
|
||||
status |= USB_PORT_STAT_C_OVERCURRENT << 16;
|
||||
|
||||
/*
|
||||
--- a/drivers/usb/host/ehci.h
|
||||
+++ b/drivers/usb/host/ehci.h
|
||||
@@ -147,6 +147,7 @@ struct ehci_hcd { /* one per controlle
|
||||
unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/
|
||||
unsigned has_synopsys_hc_bug:1; /* Synopsys HC */
|
||||
unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */
|
||||
+ unsigned ignore_oc:1;
|
||||
|
||||
/* required for usb32 quirk */
|
||||
#define OHCI_CTRL_HCFS (3 << 6)
|
|
@ -1,10 +0,0 @@
|
|||
--- a/include/linux/mtd/physmap.h
|
||||
+++ b/include/linux/mtd/physmap.h
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
+#include <linux/platform_device.h>
|
||||
|
||||
struct map_info;
|
||||
struct platform_device;
|
|
@ -1,75 +0,0 @@
|
|||
commit 9a5d2bd99e0dfe9a31b3c160073ac445ba3d773f
|
||||
Author: David Woodhouse <dwmw2@infradead.org>
|
||||
Date: Sun Apr 8 10:01:44 2012 +0000
|
||||
|
||||
ppp: Fix race condition with queue start/stop
|
||||
|
||||
Commit e675f0cc9a872fd152edc0c77acfed19bf28b81e ("ppp: Don't stop and
|
||||
restart queue on every TX packet") introduced a race condition which
|
||||
could leave the net queue stopped even when the channel is no longer
|
||||
busy. By calling netif_stop_queue() from ppp_start_xmit(), based on the
|
||||
return value from ppp_xmit_process() but *after* all the locks have been
|
||||
dropped, we could potentially do so *after* the channel has actually
|
||||
finished transmitting and attempted to re-wake the queue.
|
||||
|
||||
Fix this by moving the netif_stop_queue() into ppp_xmit_process() under
|
||||
the xmit lock. I hadn't done this previously, because it gets called
|
||||
from other places than ppp_start_xmit(). But I now think it's the better
|
||||
option. The net queue *should* be stopped if the channel becomes
|
||||
congested due to writes from pppd, anyway.
|
||||
|
||||
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
commit e675f0cc9a872fd152edc0c77acfed19bf28b81e
|
||||
Author: David Woodhouse <dwmw2@infradead.org>
|
||||
Date: Mon Mar 26 00:03:42 2012 +0000
|
||||
|
||||
ppp: Don't stop and restart queue on every TX packet
|
||||
|
||||
For every transmitted packet, ppp_start_xmit() will stop the netdev
|
||||
queue and then, if appropriate, restart it. This causes the TX softirq
|
||||
to run, entirely gratuitously.
|
||||
|
||||
This is "only" a waste of CPU time in the normal case, but it's actively
|
||||
harmful when the PPP device is a TEQL slave — the wakeup will cause the
|
||||
offending device to receive the next TX packet from the TEQL queue, when
|
||||
it *should* have gone to the next slave in the list. We end up seeing
|
||||
large bursts of packets on just *one* slave device, rather than using
|
||||
the full available bandwidth over all slaves.
|
||||
|
||||
This patch fixes the problem by *not* unconditionally stopping the queue
|
||||
in ppp_start_xmit(). It adds a return value from ppp_xmit_process()
|
||||
which indicates whether the queue should be stopped or not.
|
||||
|
||||
It *doesn't* remove the call to netif_wake_queue() from
|
||||
ppp_xmit_process(), because other code paths (especially from
|
||||
ppp_output_wakeup()) need it there and it's messy to push it out to the
|
||||
other callers to do it based on the return value. So we leave it in
|
||||
place — it's a no-op in the case where the queue wasn't stopped, so it's
|
||||
harmless in the TX path.
|
||||
|
||||
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
|
||||
|
||||
--- a/drivers/net/ppp/ppp_generic.c
|
||||
+++ b/drivers/net/ppp/ppp_generic.c
|
||||
@@ -968,7 +968,6 @@ ppp_start_xmit(struct sk_buff *skb, stru
|
||||
proto = npindex_to_proto[npi];
|
||||
put_unaligned_be16(proto, pp);
|
||||
|
||||
- netif_stop_queue(dev);
|
||||
skb_queue_tail(&ppp->file.xq, skb);
|
||||
ppp_xmit_process(ppp);
|
||||
return NETDEV_TX_OK;
|
||||
@@ -1063,6 +1062,8 @@ ppp_xmit_process(struct ppp *ppp)
|
||||
code that we can accept some more. */
|
||||
if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
|
||||
netif_wake_queue(ppp->dev);
|
||||
+ else
|
||||
+ netif_stop_queue(ppp->dev);
|
||||
}
|
||||
ppp_xmit_unlock(ppp);
|
||||
}
|
|
@ -1,188 +0,0 @@
|
|||
From 9d02daf754238adac48fa075ee79e7edd3d79ed3 Mon Sep 17 00:00:00 2001
|
||||
From: David Woodhouse <dwmw2@infradead.org>
|
||||
Date: Sun, 8 Apr 2012 09:55:43 +0000
|
||||
Subject: [PATCH] pppoatm: Fix excessive queue bloat
|
||||
|
||||
We discovered that PPPoATM has an excessively deep transmit queue. A
|
||||
queue the size of the default socket send buffer (wmem_default) is
|
||||
maintained between the PPP generic core and the ATM device.
|
||||
|
||||
Fix it to queue a maximum of *two* packets. The one the ATM device is
|
||||
currently working on, and one more for the ATM driver to process
|
||||
immediately in its TX done interrupt handler. The PPP core is designed
|
||||
to feed packets to the channel with minimal latency, so that really
|
||||
ought to be enough to keep the ATM device busy.
|
||||
|
||||
While we're at it, fix the fact that we were triggering the wakeup
|
||||
tasklet on *every* pppoatm_pop() call. The comment saying "this is
|
||||
inefficient, but doing it right is too hard" turns out to be overly
|
||||
pessimistic... I think :)
|
||||
|
||||
On machines like the Traverse Geos, with a slow Geode CPU and two
|
||||
high-speed ADSL2+ interfaces, there were reports of extremely high CPU
|
||||
usage which could partly be attributed to the extra wakeups.
|
||||
|
||||
(The wakeup handling could actually be made a whole lot easier if we
|
||||
stop checking sk->sk_sndbuf altogether. Given that we now only queue
|
||||
*two* packets ever, one wonders what the point is. As it is, you could
|
||||
already deadlock the thing by setting the sk_sndbuf to a value lower
|
||||
than the MTU of the device, and it'd just block for ever.)
|
||||
|
||||
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
net/atm/pppoatm.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||
1 files changed, 85 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/net/atm/pppoatm.c
|
||||
+++ b/net/atm/pppoatm.c
|
||||
@@ -62,12 +62,25 @@ struct pppoatm_vcc {
|
||||
void (*old_pop)(struct atm_vcc *, struct sk_buff *);
|
||||
/* keep old push/pop for detaching */
|
||||
enum pppoatm_encaps encaps;
|
||||
+ atomic_t inflight;
|
||||
+ unsigned long blocked;
|
||||
int flags; /* SC_COMP_PROT - compress protocol */
|
||||
struct ppp_channel chan; /* interface to generic ppp layer */
|
||||
struct tasklet_struct wakeup_tasklet;
|
||||
};
|
||||
|
||||
/*
|
||||
+ * We want to allow two packets in the queue. The one that's currently in
|
||||
+ * flight, and *one* queued up ready for the ATM device to send immediately
|
||||
+ * from its TX done IRQ. We want to be able to use atomic_inc_not_zero(), so
|
||||
+ * inflight == -2 represents an empty queue, -1 one packet, and zero means
|
||||
+ * there are two packets in the queue.
|
||||
+ */
|
||||
+#define NONE_INFLIGHT -2
|
||||
+
|
||||
+#define BLOCKED 0
|
||||
+
|
||||
+/*
|
||||
* Header used for LLC Encapsulated PPP (4 bytes) followed by the LCP protocol
|
||||
* ID (0xC021) used in autodetection
|
||||
*/
|
||||
@@ -102,16 +115,30 @@ static void pppoatm_wakeup_sender(unsign
|
||||
static void pppoatm_pop(struct atm_vcc *atmvcc, struct sk_buff *skb)
|
||||
{
|
||||
struct pppoatm_vcc *pvcc = atmvcc_to_pvcc(atmvcc);
|
||||
+
|
||||
pvcc->old_pop(atmvcc, skb);
|
||||
+ atomic_dec(&pvcc->inflight);
|
||||
+
|
||||
/*
|
||||
- * We don't really always want to do this since it's
|
||||
- * really inefficient - it would be much better if we could
|
||||
- * test if we had actually throttled the generic layer.
|
||||
- * Unfortunately then there would be a nasty SMP race where
|
||||
- * we could clear that flag just as we refuse another packet.
|
||||
- * For now we do the safe thing.
|
||||
+ * We always used to run the wakeup tasklet unconditionally here, for
|
||||
+ * fear of race conditions where we clear the BLOCKED flag just as we
|
||||
+ * refuse another packet in pppoatm_send(). This was quite inefficient.
|
||||
+ *
|
||||
+ * In fact it's OK. The PPP core will only ever call pppoatm_send()
|
||||
+ * while holding the channel->downl lock. And ppp_output_wakeup() as
|
||||
+ * called by the tasklet will *also* grab that lock. So even if another
|
||||
+ * CPU is in pppoatm_send() right now, the tasklet isn't going to race
|
||||
+ * with it. The wakeup *will* happen after the other CPU is safely out
|
||||
+ * of pppoatm_send() again.
|
||||
+ *
|
||||
+ * So if the CPU in pppoatm_send() has already set the BLOCKED bit and
|
||||
+ * it about to return, that's fine. We trigger a wakeup which will
|
||||
+ * happen later. And if the CPU in pppoatm_send() *hasn't* set the
|
||||
+ * BLOCKED bit yet, that's fine too because of the double check in
|
||||
+ * pppoatm_may_send() which is commented there.
|
||||
*/
|
||||
- tasklet_schedule(&pvcc->wakeup_tasklet);
|
||||
+ if (test_and_clear_bit(BLOCKED, &pvcc->blocked))
|
||||
+ tasklet_schedule(&pvcc->wakeup_tasklet);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -184,6 +211,51 @@ error:
|
||||
ppp_input_error(&pvcc->chan, 0);
|
||||
}
|
||||
|
||||
+static inline int pppoatm_may_send(struct pppoatm_vcc *pvcc, int size)
|
||||
+{
|
||||
+ /*
|
||||
+ * It's not clear that we need to bother with using atm_may_send()
|
||||
+ * to check we don't exceed sk->sk_sndbuf. If userspace sets a
|
||||
+ * value of sk_sndbuf which is lower than the MTU, we're going to
|
||||
+ * block for ever. But the code always did that before we introduced
|
||||
+ * the packet count limit, so...
|
||||
+ */
|
||||
+ if (atm_may_send(pvcc->atmvcc, size) &&
|
||||
+ atomic_inc_not_zero_hint(&pvcc->inflight, NONE_INFLIGHT))
|
||||
+ return 1;
|
||||
+
|
||||
+ /*
|
||||
+ * We use test_and_set_bit() rather than set_bit() here because
|
||||
+ * we need to ensure there's a memory barrier after it. The bit
|
||||
+ * *must* be set before we do the atomic_inc() on pvcc->inflight.
|
||||
+ * There's no smp_mb__after_set_bit(), so it's this or abuse
|
||||
+ * smp_mb__after_clear_bit().
|
||||
+ */
|
||||
+ test_and_set_bit(BLOCKED, &pvcc->blocked);
|
||||
+
|
||||
+ /*
|
||||
+ * We may have raced with pppoatm_pop(). If it ran for the
|
||||
+ * last packet in the queue, *just* before we set the BLOCKED
|
||||
+ * bit, then it might never run again and the channel could
|
||||
+ * remain permanently blocked. Cope with that race by checking
|
||||
+ * *again*. If it did run in that window, we'll have space on
|
||||
+ * the queue now and can return success. It's harmless to leave
|
||||
+ * the BLOCKED flag set, since it's only used as a trigger to
|
||||
+ * run the wakeup tasklet. Another wakeup will never hurt.
|
||||
+ * If pppoatm_pop() is running but hasn't got as far as making
|
||||
+ * space on the queue yet, then it hasn't checked the BLOCKED
|
||||
+ * flag yet either, so we're safe in that case too. It'll issue
|
||||
+ * an "immediate" wakeup... where "immediate" actually involves
|
||||
+ * taking the PPP channel's ->downl lock, which is held by the
|
||||
+ * code path that calls pppoatm_send(), and is thus going to
|
||||
+ * wait for us to finish.
|
||||
+ */
|
||||
+ if (atm_may_send(pvcc->atmvcc, size) &&
|
||||
+ atomic_inc_not_zero(&pvcc->inflight))
|
||||
+ return 1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
/*
|
||||
* Called by the ppp_generic.c to send a packet - returns true if packet
|
||||
* was accepted. If we return false, then it's our job to call
|
||||
@@ -207,7 +279,7 @@ static int pppoatm_send(struct ppp_chann
|
||||
struct sk_buff *n;
|
||||
n = skb_realloc_headroom(skb, LLC_LEN);
|
||||
if (n != NULL &&
|
||||
- !atm_may_send(pvcc->atmvcc, n->truesize)) {
|
||||
+ !pppoatm_may_send(pvcc, n->truesize)) {
|
||||
kfree_skb(n);
|
||||
goto nospace;
|
||||
}
|
||||
@@ -215,12 +287,12 @@ static int pppoatm_send(struct ppp_chann
|
||||
skb = n;
|
||||
if (skb == NULL)
|
||||
return DROP_PACKET;
|
||||
- } else if (!atm_may_send(pvcc->atmvcc, skb->truesize))
|
||||
+ } else if (!pppoatm_may_send(pvcc, skb->truesize))
|
||||
goto nospace;
|
||||
memcpy(skb_push(skb, LLC_LEN), pppllc, LLC_LEN);
|
||||
break;
|
||||
case e_vc:
|
||||
- if (!atm_may_send(pvcc->atmvcc, skb->truesize))
|
||||
+ if (!pppoatm_may_send(pvcc, skb->truesize))
|
||||
goto nospace;
|
||||
break;
|
||||
case e_autodetect:
|
||||
@@ -285,6 +357,9 @@ static int pppoatm_assign_vcc(struct atm
|
||||
if (pvcc == NULL)
|
||||
return -ENOMEM;
|
||||
pvcc->atmvcc = atmvcc;
|
||||
+
|
||||
+ /* Maximum is zero, so that we can use atomic_inc_not_zero() */
|
||||
+ atomic_set(&pvcc->inflight, NONE_INFLIGHT);
|
||||
pvcc->old_push = atmvcc->push;
|
||||
pvcc->old_pop = atmvcc->pop;
|
||||
pvcc->encaps = (enum pppoatm_encaps) be.encaps;
|
|
@ -1,11 +0,0 @@
|
|||
--- a/scripts/setlocalversion
|
||||
+++ b/scripts/setlocalversion
|
||||
@@ -168,7 +168,7 @@ else
|
||||
# annotated or signed tagged state (as git describe only
|
||||
# looks at signed or annotated tags - git tag -a/-s) and
|
||||
# LOCALVERSION= is not specified
|
||||
- if test "${LOCALVERSION+set}" != "set"; then
|
||||
+ if test "${CONFIG_LOCALVERSION+set}" != "set"; then
|
||||
scm=$(scm_version --short)
|
||||
res="$res${scm:++}"
|
||||
fi
|
|
@ -1,24 +0,0 @@
|
|||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -559,9 +559,9 @@ endif # $(dot-config)
|
||||
all: vmlinux
|
||||
|
||||
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
|
||||
-KBUILD_CFLAGS += -Os
|
||||
+KBUILD_CFLAGS += -Os -fno-caller-saves
|
||||
else
|
||||
-KBUILD_CFLAGS += -O2
|
||||
+KBUILD_CFLAGS += -O2 -fno-reorder-blocks -fno-tree-ch -fno-caller-saves
|
||||
endif
|
||||
|
||||
include $(srctree)/arch/$(SRCARCH)/Makefile
|
||||
@@ -620,6 +620,9 @@ endif
|
||||
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
|
||||
CHECKFLAGS += $(NOSTDINC_FLAGS)
|
||||
|
||||
+# improve gcc optimization
|
||||
+CFLAGS += $(call cc-option,-funit-at-a-time,)
|
||||
+
|
||||
# warn about C99 declaration after statement
|
||||
KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -374,7 +374,7 @@ KBUILD_CFLAGS_KERNEL :=
|
||||
KBUILD_AFLAGS := -D__ASSEMBLY__
|
||||
KBUILD_AFLAGS_MODULE := -DMODULE
|
||||
KBUILD_CFLAGS_MODULE := -DMODULE
|
||||
-KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
|
||||
+KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds $(if $(CONFIG_PROFILING),,-s)
|
||||
|
||||
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
|
||||
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
|
|
@ -1,78 +0,0 @@
|
|||
--- a/scripts/kallsyms.c
|
||||
+++ b/scripts/kallsyms.c
|
||||
@@ -22,6 +22,35 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
+#ifdef __APPLE__
|
||||
+/* Darwin has no memmem implementation, this one is ripped of the uClibc-0.9.28 source */
|
||||
+void *memmem (const void *haystack, size_t haystack_len,
|
||||
+ const void *needle, size_t needle_len)
|
||||
+{
|
||||
+ const char *begin;
|
||||
+ const char *const last_possible
|
||||
+ = (const char *) haystack + haystack_len - needle_len;
|
||||
+
|
||||
+ if (needle_len == 0)
|
||||
+ /* The first occurrence of the empty string is deemed to occur at
|
||||
+ the beginning of the string. */
|
||||
+ return (void *) haystack;
|
||||
+
|
||||
+ /* Sanity check, otherwise the loop might search through the whole
|
||||
+ memory. */
|
||||
+ if (__builtin_expect (haystack_len < needle_len, 0))
|
||||
+ return NULL;
|
||||
+
|
||||
+ for (begin = (const char *) haystack; begin <= last_possible; ++begin)
|
||||
+ if (begin[0] == ((const char *) needle)[0] &&
|
||||
+ !memcmp ((const void *) &begin[1],
|
||||
+ (const void *) ((const char *) needle + 1),
|
||||
+ needle_len - 1))
|
||||
+ return (void *) begin;
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+#endif
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
--- a/scripts/kconfig/Makefile
|
||||
+++ b/scripts/kconfig/Makefile
|
||||
@@ -123,6 +123,9 @@ check-lxdialog := $(srctree)/$(src)/lxd
|
||||
# we really need to do so. (Do not call gcc as part of make mrproper)
|
||||
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
|
||||
-DLOCALE
|
||||
+ifeq ($(shell uname -s),Darwin)
|
||||
+HOST_LOADLIBES += -lncurses
|
||||
+endif
|
||||
|
||||
# ===========================================================================
|
||||
# Shared Makefile for the various kconfig executables:
|
||||
--- a/scripts/mod/mk_elfconfig.c
|
||||
+++ b/scripts/mod/mk_elfconfig.c
|
||||
@@ -1,7 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#ifndef __APPLE__
|
||||
#include <elf.h>
|
||||
+#else
|
||||
+#include "../../../../../tools/sstrip/include/elf.h"
|
||||
+#endif
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
--- a/scripts/mod/modpost.h
|
||||
+++ b/scripts/mod/modpost.h
|
||||
@@ -7,7 +7,11 @@
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
+#if !(defined(__APPLE__) || defined(__CYGWIN__))
|
||||
#include <elf.h>
|
||||
+#else
|
||||
+#include "../../../../../tools/sstrip/include/elf.h"
|
||||
+#endif
|
||||
|
||||
#include "elfconfig.h"
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
--- a/include/linux/stddef.h
|
||||
+++ b/include/linux/stddef.h
|
||||
@@ -16,6 +16,7 @@ enum {
|
||||
false = 0,
|
||||
true = 1
|
||||
};
|
||||
+#endif /* __KERNEL__ */
|
||||
|
||||
#undef offsetof
|
||||
#ifdef __compiler_offsetof
|
||||
@@ -23,6 +24,5 @@ enum {
|
||||
#else
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
-#endif /* __KERNEL__ */
|
||||
|
||||
#endif
|
|
@ -1,89 +0,0 @@
|
|||
--- a/include/asm-generic/vmlinux.lds.h
|
||||
+++ b/include/asm-generic/vmlinux.lds.h
|
||||
@@ -52,6 +52,27 @@
|
||||
#define LOAD_OFFSET 0
|
||||
#endif
|
||||
|
||||
+#ifndef SYMTAB_KEEP_STR
|
||||
+#define SYMTAB_KEEP_STR *(__ksymtab_strings+*)
|
||||
+#define SYMTAB_DISCARD_STR
|
||||
+#else
|
||||
+#define SYMTAB_DISCARD_STR *(__ksymtab_strings+*)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef SYMTAB_KEEP
|
||||
+#define SYMTAB_KEEP *(SORT(___ksymtab+*))
|
||||
+#define SYMTAB_DISCARD
|
||||
+#else
|
||||
+#define SYMTAB_DISCARD *(SORT(___ksymtab+*))
|
||||
+#endif
|
||||
+
|
||||
+#ifndef SYMTAB_KEEP_GPL
|
||||
+#define SYMTAB_KEEP_GPL *(SORT(___ksymtab_gpl+*))
|
||||
+#define SYMTAB_DISCARD_GPL
|
||||
+#else
|
||||
+#define SYMTAB_DISCARD_GPL *(SORT(___ksymtab_gpl+*))
|
||||
+#endif
|
||||
+
|
||||
#ifndef SYMBOL_PREFIX
|
||||
#define VMLINUX_SYMBOL(sym) sym
|
||||
#else
|
||||
@@ -275,14 +296,14 @@
|
||||
/* Kernel symbol table: Normal symbols */ \
|
||||
__ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab) = .; \
|
||||
- *(SORT(___ksymtab+*)) \
|
||||
+ SYMTAB_KEEP \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab) = .; \
|
||||
} \
|
||||
\
|
||||
/* Kernel symbol table: GPL-only symbols */ \
|
||||
__ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
|
||||
VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
|
||||
- *(SORT(___ksymtab_gpl+*)) \
|
||||
+ SYMTAB_KEEP_GPL \
|
||||
VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
|
||||
} \
|
||||
\
|
||||
@@ -344,7 +365,7 @@
|
||||
\
|
||||
/* Kernel symbol table: strings */ \
|
||||
__ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
|
||||
- *(__ksymtab_strings) \
|
||||
+ SYMTAB_KEEP_STR \
|
||||
} \
|
||||
\
|
||||
/* __*init sections */ \
|
||||
@@ -676,6 +697,9 @@
|
||||
EXIT_TEXT \
|
||||
EXIT_DATA \
|
||||
EXIT_CALL \
|
||||
+ SYMTAB_DISCARD \
|
||||
+ SYMTAB_DISCARD_GPL \
|
||||
+ SYMTAB_DISCARD_STR \
|
||||
*(.discard) \
|
||||
*(.discard.*) \
|
||||
}
|
||||
--- a/include/linux/export.h
|
||||
+++ b/include/linux/export.h
|
||||
@@ -45,12 +45,19 @@ extern struct module __this_module;
|
||||
#define __CRC_SYMBOL(sym, sec)
|
||||
#endif
|
||||
|
||||
+#ifdef MODULE
|
||||
+#define __EXPORT_SUFFIX(sym)
|
||||
+#else
|
||||
+#define __EXPORT_SUFFIX(sym) "+" #sym
|
||||
+#endif
|
||||
+
|
||||
/* For every exported symbol, place a struct in the __ksymtab section */
|
||||
#define __EXPORT_SYMBOL(sym, sec) \
|
||||
extern typeof(sym) sym; \
|
||||
__CRC_SYMBOL(sym, sec) \
|
||||
static const char __kstrtab_##sym[] \
|
||||
- __attribute__((section("__ksymtab_strings"), aligned(1))) \
|
||||
+ __attribute__((section("__ksymtab_strings" \
|
||||
+ __EXPORT_SUFFIX(sym)), aligned(1))) \
|
||||
= MODULE_SYMBOL_PREFIX #sym; \
|
||||
static const struct kernel_symbol __ksymtab_##sym \
|
||||
__used \
|
|
@ -1,54 +0,0 @@
|
|||
--- a/scripts/Makefile.lib
|
||||
+++ b/scripts/Makefile.lib
|
||||
@@ -296,7 +296,7 @@ cmd_bzip2 = (cat $(filter-out FORCE,$^)
|
||||
|
||||
quiet_cmd_lzma = LZMA $@
|
||||
cmd_lzma = (cat $(filter-out FORCE,$^) | \
|
||||
- lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
|
||||
+ lzma e -d20 -lc1 -lp2 -pb2 -eos -si -so && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
|
||||
(rm -f $@ ; false)
|
||||
|
||||
quiet_cmd_lzo = LZO $@
|
||||
--- a/scripts/gen_initramfs_list.sh
|
||||
+++ b/scripts/gen_initramfs_list.sh
|
||||
@@ -226,7 +226,7 @@ cpio_list=
|
||||
output="/dev/stdout"
|
||||
output_file=""
|
||||
is_cpio_compressed=
|
||||
-compr="gzip -n -9 -f"
|
||||
+compr="gzip -n -9 -f -"
|
||||
|
||||
arg="$1"
|
||||
case "$arg" in
|
||||
@@ -240,9 +240,9 @@ case "$arg" in
|
||||
output_file="$1"
|
||||
cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
|
||||
output=${cpio_list}
|
||||
- echo "$output_file" | grep -q "\.gz$" && compr="gzip -n -9 -f"
|
||||
- echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f"
|
||||
- echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f"
|
||||
+ echo "$output_file" | grep -q "\.gz$" && compr="gzip -n -9 -f -"
|
||||
+ echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f -"
|
||||
+ echo "$output_file" | grep -q "\.lzma$" && compr="lzma e -d20 -lc1 -lp2 -pb2 -eos -si -so"
|
||||
echo "$output_file" | grep -q "\.xz$" && \
|
||||
compr="xz --check=crc32 --lzma2=dict=1MiB"
|
||||
echo "$output_file" | grep -q "\.lzo$" && compr="lzop -9 -f"
|
||||
@@ -303,7 +303,7 @@ if [ ! -z ${output_file} ]; then
|
||||
if [ "${is_cpio_compressed}" = "compressed" ]; then
|
||||
cat ${cpio_tfile} > ${output_file}
|
||||
else
|
||||
- (cat ${cpio_tfile} | ${compr} - > ${output_file}) \
|
||||
+ (cat ${cpio_tfile} | ${compr} > ${output_file}) \
|
||||
|| (rm -f ${output_file} ; false)
|
||||
fi
|
||||
[ -z ${cpio_file} ] && rm ${cpio_tfile}
|
||||
--- a/lib/decompress.c
|
||||
+++ b/lib/decompress.c
|
||||
@@ -40,6 +40,7 @@ static const struct compress_format {
|
||||
{ {037, 0236}, "gzip", gunzip },
|
||||
{ {0x42, 0x5a}, "bzip2", bunzip2 },
|
||||
{ {0x5d, 0x00}, "lzma", unlzma },
|
||||
+ { {0x6d, 0x00}, "lzma-openwrt", unlzma },
|
||||
{ {0xfd, 0x37}, "xz", unxz },
|
||||
{ {0x89, 0x4c}, "lzo", unlzo },
|
||||
{ {0, 0}, NULL, NULL }
|
|
@ -1,18 +0,0 @@
|
|||
--- a/net/netfilter/Kconfig
|
||||
+++ b/net/netfilter/Kconfig
|
||||
@@ -163,7 +163,6 @@ config NF_CONNTRACK_FTP
|
||||
|
||||
config NF_CONNTRACK_H323
|
||||
tristate "H.323 protocol support"
|
||||
- depends on (IPV6 || IPV6=n)
|
||||
depends on NETFILTER_ADVANCED
|
||||
help
|
||||
H.323 is a VoIP signalling protocol from ITU-T. As one of the most
|
||||
@@ -609,7 +608,6 @@ config NETFILTER_XT_TARGET_SECMARK
|
||||
|
||||
config NETFILTER_XT_TARGET_TCPMSS
|
||||
tristate '"TCPMSS" target support'
|
||||
- depends on (IPV6 || IPV6=n)
|
||||
default m if NETFILTER_ADVANCED=n
|
||||
---help---
|
||||
This option adds a `TCPMSS' target, which allows you to alter the
|
|
@ -1,11 +0,0 @@
|
|||
--- a/sound/core/Kconfig
|
||||
+++ b/sound/core/Kconfig
|
||||
@@ -8,7 +8,7 @@ config SND_PCM
|
||||
select GCD
|
||||
|
||||
config SND_HWDEP
|
||||
- tristate
|
||||
+ tristate "Sound hardware support"
|
||||
|
||||
config SND_RAWMIDI
|
||||
tristate
|
|
@ -1,10 +0,0 @@
|
|||
--- a/drivers/crypto/Kconfig
|
||||
+++ b/drivers/crypto/Kconfig
|
||||
@@ -172,6 +172,7 @@ config CRYPTO_DEV_MV_CESA
|
||||
depends on PLAT_ORION
|
||||
select CRYPTO_ALGAPI
|
||||
select CRYPTO_AES
|
||||
+ select CRYPTO_HASH2
|
||||
select CRYPTO_BLKCIPHER2
|
||||
help
|
||||
This driver allows you to utilize the Cryptographic Engines and
|
|
@ -1,29 +0,0 @@
|
|||
--- a/drivers/ssb/Kconfig
|
||||
+++ b/drivers/ssb/Kconfig
|
||||
@@ -29,6 +29,7 @@ config SSB_SPROM
|
||||
config SSB_BLOCKIO
|
||||
bool
|
||||
depends on SSB
|
||||
+ default y
|
||||
|
||||
config SSB_PCIHOST_POSSIBLE
|
||||
bool
|
||||
@@ -49,7 +50,7 @@ config SSB_PCIHOST
|
||||
config SSB_B43_PCI_BRIDGE
|
||||
bool
|
||||
depends on SSB_PCIHOST
|
||||
- default n
|
||||
+ default y
|
||||
|
||||
config SSB_PCMCIAHOST_POSSIBLE
|
||||
bool
|
||||
--- a/drivers/bcma/Kconfig
|
||||
+++ b/drivers/bcma/Kconfig
|
||||
@@ -17,6 +17,7 @@ config BCMA
|
||||
config BCMA_BLOCKIO
|
||||
bool
|
||||
depends on BCMA
|
||||
+ default y
|
||||
|
||||
config BCMA_HOST_PCI_POSSIBLE
|
||||
bool
|
|
@ -1,23 +0,0 @@
|
|||
--- a/lib/Kconfig
|
||||
+++ b/lib/Kconfig
|
||||
@@ -197,16 +197,16 @@ config BCH_CONST_T
|
||||
# Textsearch support is select'ed if needed
|
||||
#
|
||||
config TEXTSEARCH
|
||||
- boolean
|
||||
+ boolean "Textsearch support"
|
||||
|
||||
config TEXTSEARCH_KMP
|
||||
- tristate
|
||||
+ tristate "Textsearch KMP"
|
||||
|
||||
config TEXTSEARCH_BM
|
||||
- tristate
|
||||
+ tristate "Textsearch BM"
|
||||
|
||||
config TEXTSEARCH_FSM
|
||||
- tristate
|
||||
+ tristate "Textsearch FSM"
|
||||
|
||||
config BTREE
|
||||
boolean
|
|
@ -1,19 +0,0 @@
|
|||
--- a/net/wireless/Kconfig
|
||||
+++ b/net/wireless/Kconfig
|
||||
@@ -142,13 +142,13 @@ config LIB80211
|
||||
you want this built into your kernel.
|
||||
|
||||
config LIB80211_CRYPT_WEP
|
||||
- tristate
|
||||
+ tristate "LIB80211_CRYPT_WEP"
|
||||
|
||||
config LIB80211_CRYPT_CCMP
|
||||
- tristate
|
||||
+ tristate "LIB80211_CRYPT_CCMP"
|
||||
|
||||
config LIB80211_CRYPT_TKIP
|
||||
- tristate
|
||||
+ tristate "LIB80211_CRYPT_TKIP"
|
||||
|
||||
config LIB80211_DEBUG
|
||||
bool "lib80211 debugging messages"
|
|
@ -1,47 +0,0 @@
|
|||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -31,7 +31,7 @@ config CRYPTO_FIPS
|
||||
this is.
|
||||
|
||||
config CRYPTO_ALGAPI
|
||||
- tristate
|
||||
+ tristate "ALGAPI"
|
||||
select CRYPTO_ALGAPI2
|
||||
help
|
||||
This option provides the API for cryptographic algorithms.
|
||||
@@ -40,7 +40,7 @@ config CRYPTO_ALGAPI2
|
||||
tristate
|
||||
|
||||
config CRYPTO_AEAD
|
||||
- tristate
|
||||
+ tristate "AEAD"
|
||||
select CRYPTO_AEAD2
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
@@ -49,7 +49,7 @@ config CRYPTO_AEAD2
|
||||
select CRYPTO_ALGAPI2
|
||||
|
||||
config CRYPTO_BLKCIPHER
|
||||
- tristate
|
||||
+ tristate "BLKCIPHER"
|
||||
select CRYPTO_BLKCIPHER2
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
@@ -60,7 +60,7 @@ config CRYPTO_BLKCIPHER2
|
||||
select CRYPTO_WORKQUEUE
|
||||
|
||||
config CRYPTO_HASH
|
||||
- tristate
|
||||
+ tristate "HASH"
|
||||
select CRYPTO_HASH2
|
||||
select CRYPTO_ALGAPI
|
||||
|
||||
@@ -69,7 +69,7 @@ config CRYPTO_HASH2
|
||||
select CRYPTO_ALGAPI2
|
||||
|
||||
config CRYPTO_RNG
|
||||
- tristate
|
||||
+ tristate "RNG"
|
||||
select CRYPTO_RNG2
|
||||
select CRYPTO_ALGAPI
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
--- a/net/wireless/Kconfig
|
||||
+++ b/net/wireless/Kconfig
|
||||
@@ -1,5 +1,5 @@
|
||||
config WIRELESS_EXT
|
||||
- bool
|
||||
+ bool "Wireless extensions"
|
||||
|
||||
config WEXT_CORE
|
||||
def_bool y
|
||||
@@ -11,10 +11,10 @@ config WEXT_PROC
|
||||
depends on WEXT_CORE
|
||||
|
||||
config WEXT_SPY
|
||||
- bool
|
||||
+ bool "WEXT_SPY"
|
||||
|
||||
config WEXT_PRIV
|
||||
- bool
|
||||
+ bool "WEXT_PRIV"
|
||||
|
||||
config CFG80211
|
||||
tristate "cfg80211 - wireless configuration API"
|
|
@ -1,11 +0,0 @@
|
|||
--- a/net/netfilter/Kconfig
|
||||
+++ b/net/netfilter/Kconfig
|
||||
@@ -2,7 +2,7 @@ menu "Core Netfilter Configuration"
|
||||
depends on NET && INET && NETFILTER
|
||||
|
||||
config NETFILTER_NETLINK
|
||||
- tristate
|
||||
+ tristate "Netfilter NFNETLINK interface"
|
||||
|
||||
config NETFILTER_NETLINK_QUEUE
|
||||
tristate "Netfilter NFQUEUE over NFNETLINK interface"
|
|
@ -1,39 +0,0 @@
|
|||
From: Mark Miller <mark@mirell.org>
|
||||
|
||||
This exposes the CONFIG_BOOT_RAW symbol in Kconfig. This is needed on
|
||||
certain Broadcom chipsets running CFE in order to load the kernel.
|
||||
|
||||
Signed-off-by: Mark Miller <mark@mirell.org>
|
||||
Acked-by: Rob Landley <rob@landley.net>
|
||||
---
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -849,9 +849,6 @@ config ARC
|
||||
config ARCH_MAY_HAVE_PC_FDC
|
||||
bool
|
||||
|
||||
-config BOOT_RAW
|
||||
- bool
|
||||
-
|
||||
config CEVT_BCM1480
|
||||
bool
|
||||
|
||||
@@ -2292,6 +2289,18 @@ config USE_OF
|
||||
help
|
||||
Include support for flattened device tree machine descriptions.
|
||||
|
||||
+config BOOT_RAW
|
||||
+ bool "Enable the kernel to be executed from the load address"
|
||||
+ default n
|
||||
+ help
|
||||
+ Allow the kernel to be executed from the load address for
|
||||
+ bootloaders which cannot read the ELF format. This places
|
||||
+ a jump to start_kernel at the load address.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
+
|
||||
+
|
||||
+
|
||||
endmenu
|
||||
|
||||
config LOCKDEP_SUPPORT
|
|
@ -1,28 +0,0 @@
|
|||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -948,6 +948,10 @@ config SYNC_R4K
|
||||
config MIPS_MACHINE
|
||||
def_bool n
|
||||
|
||||
+config IMAGE_CMDLINE_HACK
|
||||
+ bool "OpenWrt specific image command line hack"
|
||||
+ default n
|
||||
+
|
||||
config NO_IOPORT
|
||||
def_bool n
|
||||
|
||||
--- a/arch/mips/kernel/head.S
|
||||
+++ b/arch/mips/kernel/head.S
|
||||
@@ -141,6 +141,12 @@ FEXPORT(__kernel_entry)
|
||||
j kernel_entry
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_IMAGE_CMDLINE_HACK
|
||||
+ .ascii "CMDLINE:"
|
||||
+EXPORT(__image_cmdline)
|
||||
+ .fill 0x400
|
||||
+#endif /* CONFIG_IMAGE_CMDLINE_HACK */
|
||||
+
|
||||
__REF
|
||||
|
||||
NESTED(kernel_entry, 16, sp) # kernel entry point
|
|
@ -1,18 +0,0 @@
|
|||
--- a/arch/mips/include/asm/thread_info.h
|
||||
+++ b/arch/mips/include/asm/thread_info.h
|
||||
@@ -85,6 +85,7 @@ register struct thread_info *__current_t
|
||||
|
||||
#define STACK_WARN (THREAD_SIZE / 8)
|
||||
|
||||
+#if 0
|
||||
#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
|
||||
|
||||
#ifdef CONFIG_DEBUG_STACK_USAGE
|
||||
@@ -96,6 +97,7 @@ register struct thread_info *__current_t
|
||||
#endif
|
||||
|
||||
#define free_thread_info(info) kfree(info)
|
||||
+#endif
|
||||
|
||||
#endif /* !__ASSEMBLY__ */
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
--- a/arch/mips/kernel/machine_kexec.c
|
||||
+++ b/arch/mips/kernel/machine_kexec.c
|
||||
@@ -52,7 +52,7 @@ machine_kexec(struct kimage *image)
|
||||
reboot_code_buffer =
|
||||
(unsigned long)page_address(image->control_code_page);
|
||||
|
||||
- kexec_start_address = image->start;
|
||||
+ kexec_start_address = (unsigned long) phys_to_virt(image->start);
|
||||
kexec_indirection_page =
|
||||
(unsigned long) phys_to_virt(image->head & PAGE_MASK);
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
MIPS: allow disabling the kernel FPU emulator
|
||||
|
||||
This patch allows turning off the in-kernel Algorithmics
|
||||
FPU emulator support, which allows one to save a couple of
|
||||
precious blocks on an embedded system.
|
||||
|
||||
Signed-off-by: Florian Fainelli <florian@openwrt.org>
|
||||
--
|
||||
--- a/arch/mips/Kconfig
|
||||
+++ b/arch/mips/Kconfig
|
||||
@@ -933,6 +933,17 @@ config I8259
|
||||
config MIPS_BONITO64
|
||||
bool
|
||||
|
||||
+config MIPS_FPU_EMU
|
||||
+ bool "Enable FPU emulation"
|
||||
+ default y
|
||||
+ help
|
||||
+ This option allows building a kernel with or without the Algorithmics
|
||||
+ FPU emulator enabled. Turning off this option results in a kernel which
|
||||
+ does not catch floating operations exceptions. Make sure that your toolchain
|
||||
+ is configured to enable software floating point emulation in that case.
|
||||
+
|
||||
+ If unsure say Y here.
|
||||
+
|
||||
config MIPS_MSC
|
||||
bool
|
||||
|
||||
--- a/arch/mips/math-emu/Makefile
|
||||
+++ b/arch/mips/math-emu/Makefile
|
||||
@@ -2,11 +2,13 @@
|
||||
# Makefile for the Linux/MIPS kernel FPU emulation.
|
||||
#
|
||||
|
||||
-obj-y := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
|
||||
+obj-y := kernel_linkage.o dsemul.o cp1emu.o
|
||||
+
|
||||
+obj-$(CONFIG_MIPS_FPU_EMU) += ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
|
||||
ieee754xcpt.o dp_frexp.o dp_modf.o dp_div.o dp_mul.o dp_sub.o \
|
||||
dp_add.o dp_fsp.o dp_cmp.o dp_logb.o dp_scalb.o dp_simple.o \
|
||||
dp_tint.o dp_fint.o dp_tlong.o dp_flong.o sp_frexp.o sp_modf.o \
|
||||
sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
|
||||
sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
|
||||
- dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
|
||||
+ dp_sqrt.o sp_sqrt.o
|
||||
|
||||
--- a/arch/mips/math-emu/cp1emu.c
|
||||
+++ b/arch/mips/math-emu/cp1emu.c
|
||||
@@ -58,7 +58,11 @@
|
||||
#define __mips 4
|
||||
|
||||
/* Function which emulates a floating point instruction. */
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
+DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
|
||||
+#endif
|
||||
|
||||
+#ifdef CONFIG_MIPS_FPU_EMU
|
||||
static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
|
||||
mips_instruction);
|
||||
|
||||
@@ -69,10 +73,6 @@ static int fpux_emu(struct pt_regs *,
|
||||
|
||||
/* Further private data for which no space exists in mips_fpu_struct */
|
||||
|
||||
-#ifdef CONFIG_DEBUG_FS
|
||||
-DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
|
||||
-#endif
|
||||
-
|
||||
/* Control registers */
|
||||
|
||||
#define FPCREG_RID 0 /* $0 = revision id */
|
||||
@@ -1360,7 +1360,6 @@ int fpu_emulator_cop1Handler(struct pt_r
|
||||
|
||||
return sig;
|
||||
}
|
||||
-
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
|
||||
static int fpuemu_stat_get(void *data, u64 *val)
|
||||
@@ -1409,4 +1408,11 @@ static int __init debugfs_fpuemu(void)
|
||||
return 0;
|
||||
}
|
||||
__initcall(debugfs_fpuemu);
|
||||
-#endif
|
||||
+#endif /* CONFIG_DEBUGFS */
|
||||
+#else
|
||||
+int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
|
||||
+ int has_fpu)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif /* CONFIG_MIPS_FPU_EMU */
|
||||
--- a/arch/mips/math-emu/dsemul.c
|
||||
+++ b/arch/mips/math-emu/dsemul.c
|
||||
@@ -109,6 +109,7 @@ int mips_dsemul(struct pt_regs *regs, mi
|
||||
return SIGILL; /* force out of emulation loop */
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_MIPS_FPU_EMU
|
||||
int do_dsemulret(struct pt_regs *xcp)
|
||||
{
|
||||
struct emuframe __user *fr;
|
||||
@@ -165,3 +166,9 @@ int do_dsemulret(struct pt_regs *xcp)
|
||||
|
||||
return 1;
|
||||
}
|
||||
+#else
|
||||
+int do_dsemulret(struct pt_regs *xcp)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif /* CONFIG_MIPS_FPU_EMU */
|
||||
--- a/arch/mips/math-emu/kernel_linkage.c
|
||||
+++ b/arch/mips/math-emu/kernel_linkage.c
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#define SIGNALLING_NAN 0x7ff800007ff80000LL
|
||||
|
||||
+#ifdef CONFIG_MIPS_FPU_EMU
|
||||
void fpu_emulator_init_fpu(void)
|
||||
{
|
||||
static int first = 1;
|
||||
@@ -112,4 +113,36 @@ int fpu_emulator_restore_context32(struc
|
||||
|
||||
return err;
|
||||
}
|
||||
-#endif
|
||||
+#endif /* CONFIG_64BIT */
|
||||
+#else
|
||||
+
|
||||
+void fpu_emulator_init_fpu(void)
|
||||
+{
|
||||
+ printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
|
||||
+ "was compiled with software floating point support (soft-float)\n");
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+int fpu_emulator_save_context(struct sigcontext __user *sc)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int fpu_emulator_restore_context(struct sigcontext __user *sc)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_64BIT
|
||||
+#endif /* CONFIG_64BIT */
|
||||
+#endif /* CONFIG_MIPS_FPU_EMU */
|
|
@ -1,371 +0,0 @@
|
|||
--- a/arch/mips/Makefile
|
||||
+++ b/arch/mips/Makefile
|
||||
@@ -90,8 +90,8 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin
|
||||
cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
|
||||
cflags-y += -msoft-float
|
||||
LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
|
||||
-KBUILD_AFLAGS_MODULE += -mlong-calls
|
||||
-KBUILD_CFLAGS_MODULE += -mlong-calls
|
||||
+KBUILD_AFLAGS_MODULE += -mno-long-calls
|
||||
+KBUILD_CFLAGS_MODULE += -mno-long-calls
|
||||
|
||||
cflags-y += -ffreestanding
|
||||
|
||||
--- a/arch/mips/include/asm/module.h
|
||||
+++ b/arch/mips/include/asm/module.h
|
||||
@@ -9,6 +9,11 @@ struct mod_arch_specific {
|
||||
struct list_head dbe_list;
|
||||
const struct exception_table_entry *dbe_start;
|
||||
const struct exception_table_entry *dbe_end;
|
||||
+
|
||||
+ void *phys_plt_tbl;
|
||||
+ void *virt_plt_tbl;
|
||||
+ unsigned int phys_plt_offset;
|
||||
+ unsigned int virt_plt_offset;
|
||||
};
|
||||
|
||||
typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */
|
||||
--- a/arch/mips/kernel/module.c
|
||||
+++ b/arch/mips/kernel/module.c
|
||||
@@ -44,14 +44,219 @@ static struct mips_hi16 *mips_hi16_list;
|
||||
static LIST_HEAD(dbe_list);
|
||||
static DEFINE_SPINLOCK(dbe_lock);
|
||||
|
||||
-#ifdef MODULE_START
|
||||
+/*
|
||||
+ * Get the potential max trampolines size required of the init and
|
||||
+ * non-init sections. Only used if we cannot find enough contiguous
|
||||
+ * physically mapped memory to put the module into.
|
||||
+ */
|
||||
+static unsigned int
|
||||
+get_plt_size(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
|
||||
+ const char *secstrings, unsigned int symindex, bool is_init)
|
||||
+{
|
||||
+ unsigned long ret = 0;
|
||||
+ unsigned int i, j;
|
||||
+ Elf_Sym *syms;
|
||||
+
|
||||
+ /* Everything marked ALLOC (this includes the exported symbols) */
|
||||
+ for (i = 1; i < hdr->e_shnum; ++i) {
|
||||
+ unsigned int info = sechdrs[i].sh_info;
|
||||
+
|
||||
+ if (sechdrs[i].sh_type != SHT_REL
|
||||
+ && sechdrs[i].sh_type != SHT_RELA)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Not a valid relocation section? */
|
||||
+ if (info >= hdr->e_shnum)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Don't bother with non-allocated sections */
|
||||
+ if (!(sechdrs[info].sh_flags & SHF_ALLOC))
|
||||
+ continue;
|
||||
+
|
||||
+ /* If it's called *.init*, and we're not init, we're
|
||||
+ not interested */
|
||||
+ if ((strstr(secstrings + sechdrs[i].sh_name, ".init") != 0)
|
||||
+ != is_init)
|
||||
+ continue;
|
||||
+
|
||||
+ syms = (Elf_Sym *) sechdrs[symindex].sh_addr;
|
||||
+ if (sechdrs[i].sh_type == SHT_REL) {
|
||||
+ Elf_Mips_Rel *rel = (void *) sechdrs[i].sh_addr;
|
||||
+ unsigned int size = sechdrs[i].sh_size / sizeof(*rel);
|
||||
+
|
||||
+ for (j = 0; j < size; ++j) {
|
||||
+ Elf_Sym *sym;
|
||||
+
|
||||
+ if (ELF_MIPS_R_TYPE(rel[j]) != R_MIPS_26)
|
||||
+ continue;
|
||||
+
|
||||
+ sym = syms + ELF_MIPS_R_SYM(rel[j]);
|
||||
+ if (!is_init && sym->st_shndx != SHN_UNDEF)
|
||||
+ continue;
|
||||
+
|
||||
+ ret += 4 * sizeof(int);
|
||||
+ }
|
||||
+ } else {
|
||||
+ Elf_Mips_Rela *rela = (void *) sechdrs[i].sh_addr;
|
||||
+ unsigned int size = sechdrs[i].sh_size / sizeof(*rela);
|
||||
+
|
||||
+ for (j = 0; j < size; ++j) {
|
||||
+ Elf_Sym *sym;
|
||||
+
|
||||
+ if (ELF_MIPS_R_TYPE(rela[j]) != R_MIPS_26)
|
||||
+ continue;
|
||||
+
|
||||
+ sym = syms + ELF_MIPS_R_SYM(rela[j]);
|
||||
+ if (!is_init && sym->st_shndx != SHN_UNDEF)
|
||||
+ continue;
|
||||
+
|
||||
+ ret += 4 * sizeof(int);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+#ifndef MODULE_START
|
||||
+static void *alloc_phys(unsigned long size)
|
||||
+{
|
||||
+ unsigned order;
|
||||
+ struct page *page;
|
||||
+ struct page *p;
|
||||
+
|
||||
+ size = PAGE_ALIGN(size);
|
||||
+ order = get_order(size);
|
||||
+
|
||||
+ page = alloc_pages(GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN |
|
||||
+ __GFP_THISNODE, order);
|
||||
+ if (!page)
|
||||
+ return NULL;
|
||||
+
|
||||
+ split_page(page, order);
|
||||
+
|
||||
+ for (p = page + (size >> PAGE_SHIFT); p < page + (1 << order); ++p)
|
||||
+ __free_page(p);
|
||||
+
|
||||
+ return page_address(page);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static void free_phys(void *ptr, unsigned long size)
|
||||
+{
|
||||
+ struct page *page;
|
||||
+ struct page *end;
|
||||
+
|
||||
+ page = virt_to_page(ptr);
|
||||
+ end = page + (PAGE_ALIGN(size) >> PAGE_SHIFT);
|
||||
+
|
||||
+ for (; page < end; ++page)
|
||||
+ __free_page(page);
|
||||
+}
|
||||
+
|
||||
+
|
||||
void *module_alloc(unsigned long size)
|
||||
{
|
||||
+#ifdef MODULE_START
|
||||
return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END,
|
||||
GFP_KERNEL, PAGE_KERNEL, -1,
|
||||
__builtin_return_address(0));
|
||||
+#else
|
||||
+ void *ptr;
|
||||
+
|
||||
+ if (size == 0)
|
||||
+ return NULL;
|
||||
+
|
||||
+ ptr = alloc_phys(size);
|
||||
+
|
||||
+ /* If we failed to allocate physically contiguous memory,
|
||||
+ * fall back to regular vmalloc. The module loader code will
|
||||
+ * create jump tables to handle long jumps */
|
||||
+ if (!ptr)
|
||||
+ return vmalloc(size);
|
||||
+
|
||||
+ return ptr;
|
||||
+#endif
|
||||
}
|
||||
+
|
||||
+static inline bool is_phys_addr(void *ptr)
|
||||
+{
|
||||
+#ifdef CONFIG_64BIT
|
||||
+ return (KSEGX((unsigned long)ptr) == CKSEG0);
|
||||
+#else
|
||||
+ return (KSEGX(ptr) == KSEG0);
|
||||
#endif
|
||||
+}
|
||||
+
|
||||
+/* Free memory returned from module_alloc */
|
||||
+void module_free(struct module *mod, void *module_region)
|
||||
+{
|
||||
+ if (is_phys_addr(module_region)) {
|
||||
+ if (mod->module_init == module_region)
|
||||
+ free_phys(module_region, mod->init_size);
|
||||
+ else if (mod->module_core == module_region)
|
||||
+ free_phys(module_region, mod->core_size);
|
||||
+ else
|
||||
+ BUG();
|
||||
+ } else {
|
||||
+ vfree(module_region);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void *__module_alloc(int size, bool phys)
|
||||
+{
|
||||
+ void *ptr;
|
||||
+
|
||||
+ if (phys)
|
||||
+ ptr = kmalloc(size, GFP_KERNEL);
|
||||
+ else
|
||||
+ ptr = vmalloc(size);
|
||||
+ return ptr;
|
||||
+}
|
||||
+
|
||||
+static void __module_free(void *ptr)
|
||||
+{
|
||||
+ if (is_phys_addr(ptr))
|
||||
+ kfree(ptr);
|
||||
+ else
|
||||
+ vfree(ptr);
|
||||
+}
|
||||
+
|
||||
+int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
|
||||
+ char *secstrings, struct module *mod)
|
||||
+{
|
||||
+ unsigned int symindex = 0;
|
||||
+ unsigned int core_size, init_size;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 1; i < hdr->e_shnum; i++)
|
||||
+ if (sechdrs[i].sh_type == SHT_SYMTAB)
|
||||
+ symindex = i;
|
||||
+
|
||||
+ core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false);
|
||||
+ init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true);
|
||||
+
|
||||
+ mod->arch.phys_plt_offset = 0;
|
||||
+ mod->arch.virt_plt_offset = 0;
|
||||
+ mod->arch.phys_plt_tbl = NULL;
|
||||
+ mod->arch.virt_plt_tbl = NULL;
|
||||
+
|
||||
+ if ((core_size + init_size) == 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1);
|
||||
+ if (!mod->arch.phys_plt_tbl)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0);
|
||||
+ if (!mod->arch.virt_plt_tbl) {
|
||||
+ __module_free(mod->arch.phys_plt_tbl);
|
||||
+ mod->arch.phys_plt_tbl = NULL;
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
|
||||
static int apply_r_mips_none(struct module *me, u32 *location, Elf_Addr v)
|
||||
{
|
||||
@@ -72,28 +277,36 @@ static int apply_r_mips_32_rela(struct m
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
|
||||
+static Elf_Addr add_plt_entry_to(unsigned *plt_offset,
|
||||
+ void *start, Elf_Addr v)
|
||||
{
|
||||
- if (v % 4) {
|
||||
- pr_err("module %s: dangerous R_MIPS_26 REL relocation\n",
|
||||
- me->name);
|
||||
- return -ENOEXEC;
|
||||
- }
|
||||
+ unsigned *tramp = start + *plt_offset;
|
||||
+ *plt_offset += 4 * sizeof(int);
|
||||
|
||||
- if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) {
|
||||
- printk(KERN_ERR
|
||||
- "module %s: relocation overflow\n",
|
||||
- me->name);
|
||||
- return -ENOEXEC;
|
||||
- }
|
||||
+ /* adjust carry for addiu */
|
||||
+ if (v & 0x00008000)
|
||||
+ v += 0x10000;
|
||||
|
||||
- *location = (*location & ~0x03ffffff) |
|
||||
- ((*location + (v >> 2)) & 0x03ffffff);
|
||||
+ tramp[0] = 0x3c190000 | (v >> 16); /* lui t9, hi16 */
|
||||
+ tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */
|
||||
+ tramp[2] = 0x03200008; /* jr t9 */
|
||||
+ tramp[3] = 0x00000000; /* nop */
|
||||
|
||||
- return 0;
|
||||
+ return (Elf_Addr) tramp;
|
||||
}
|
||||
|
||||
-static int apply_r_mips_26_rela(struct module *me, u32 *location, Elf_Addr v)
|
||||
+static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v)
|
||||
+{
|
||||
+ if (is_phys_addr(location))
|
||||
+ return add_plt_entry_to(&me->arch.phys_plt_offset,
|
||||
+ me->arch.phys_plt_tbl, v);
|
||||
+ else
|
||||
+ return add_plt_entry_to(&me->arch.virt_plt_offset,
|
||||
+ me->arch.virt_plt_tbl, v);
|
||||
+
|
||||
+}
|
||||
+
|
||||
+static int set_r_mips_26(struct module *me, u32 *location, u32 ofs, Elf_Addr v)
|
||||
{
|
||||
if (v % 4) {
|
||||
pr_err("module %s: dangerous R_MIPS_26 RELArelocation\n",
|
||||
@@ -102,17 +315,31 @@ static int apply_r_mips_26_rela(struct m
|
||||
}
|
||||
|
||||
if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) {
|
||||
- printk(KERN_ERR
|
||||
+ v = add_plt_entry(me, location, v + (ofs << 2));
|
||||
+ if (!v) {
|
||||
+ printk(KERN_ERR
|
||||
"module %s: relocation overflow\n",
|
||||
me->name);
|
||||
- return -ENOEXEC;
|
||||
+ return -ENOEXEC;
|
||||
+ }
|
||||
+ ofs = 0;
|
||||
}
|
||||
|
||||
- *location = (*location & ~0x03ffffff) | ((v >> 2) & 0x03ffffff);
|
||||
+ *location = (*location & ~0x03ffffff) | ((ofs + (v >> 2)) & 0x03ffffff);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
|
||||
+{
|
||||
+ return set_r_mips_26(me, location, *location & 0x03ffffff, v);
|
||||
+}
|
||||
+
|
||||
+static int apply_r_mips_26_rela(struct module *me, u32 *location, Elf_Addr v)
|
||||
+{
|
||||
+ return set_r_mips_26(me, location, 0, v);
|
||||
+}
|
||||
+
|
||||
static int apply_r_mips_hi16_rel(struct module *me, u32 *location, Elf_Addr v)
|
||||
{
|
||||
struct mips_hi16 *n;
|
||||
@@ -380,11 +607,32 @@ int module_finalize(const Elf_Ehdr *hdr,
|
||||
list_add(&me->arch.dbe_list, &dbe_list);
|
||||
spin_unlock_irq(&dbe_lock);
|
||||
}
|
||||
+
|
||||
+ /* Get rid of the fixup trampoline if we're running the module
|
||||
+ * from physically mapped address space */
|
||||
+ if (me->arch.phys_plt_offset == 0) {
|
||||
+ __module_free(me->arch.phys_plt_tbl);
|
||||
+ me->arch.phys_plt_tbl = NULL;
|
||||
+ }
|
||||
+ if (me->arch.virt_plt_offset == 0) {
|
||||
+ __module_free(me->arch.virt_plt_tbl);
|
||||
+ me->arch.virt_plt_tbl = NULL;
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
void module_arch_cleanup(struct module *mod)
|
||||
{
|
||||
+ if (mod->arch.phys_plt_tbl) {
|
||||
+ __module_free(mod->arch.phys_plt_tbl);
|
||||
+ mod->arch.phys_plt_tbl = NULL;
|
||||
+ }
|
||||
+ if (mod->arch.virt_plt_tbl) {
|
||||
+ __module_free(mod->arch.virt_plt_tbl);
|
||||
+ mod->arch.virt_plt_tbl = NULL;
|
||||
+ }
|
||||
+
|
||||
spin_lock_irq(&dbe_lock);
|
||||
list_del(&mod->arch.dbe_list);
|
||||
spin_unlock_irq(&dbe_lock);
|
|
@ -1,83 +0,0 @@
|
|||
--- a/arch/mips/include/asm/string.h
|
||||
+++ b/arch/mips/include/asm/string.h
|
||||
@@ -133,11 +133,44 @@ strncmp(__const__ char *__cs, __const__
|
||||
|
||||
#define __HAVE_ARCH_MEMSET
|
||||
extern void *memset(void *__s, int __c, size_t __count);
|
||||
+#define memset(__s, __c, len) \
|
||||
+({ \
|
||||
+ size_t __len = (len); \
|
||||
+ void *__ret; \
|
||||
+ if (__builtin_constant_p(len) && __len >= 64) \
|
||||
+ __ret = memset((__s), (__c), __len); \
|
||||
+ else \
|
||||
+ __ret = __builtin_memset((__s), (__c), __len); \
|
||||
+ __ret; \
|
||||
+})
|
||||
|
||||
#define __HAVE_ARCH_MEMCPY
|
||||
extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
|
||||
+#define memcpy(dst, src, len) \
|
||||
+({ \
|
||||
+ size_t __len = (len); \
|
||||
+ void *__ret; \
|
||||
+ if (__builtin_constant_p(len) && __len >= 64) \
|
||||
+ __ret = memcpy((dst), (src), __len); \
|
||||
+ else \
|
||||
+ __ret = __builtin_memcpy((dst), (src), __len); \
|
||||
+ __ret; \
|
||||
+})
|
||||
|
||||
#define __HAVE_ARCH_MEMMOVE
|
||||
extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
|
||||
+#define memmove(dst, src, len) \
|
||||
+({ \
|
||||
+ size_t __len = (len); \
|
||||
+ void *__ret; \
|
||||
+ if (__builtin_constant_p(len) && __len >= 64) \
|
||||
+ __ret = memmove((dst), (src), __len); \
|
||||
+ else \
|
||||
+ __ret = __builtin_memmove((dst), (src), __len); \
|
||||
+ __ret; \
|
||||
+})
|
||||
+
|
||||
+#define __HAVE_ARCH_MEMCMP
|
||||
+#define memcmp(src1, src2, len) __builtin_memcmp((src1), (src2), (len))
|
||||
|
||||
#endif /* _ASM_STRING_H */
|
||||
--- a/arch/mips/lib/Makefile
|
||||
+++ b/arch/mips/lib/Makefile
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
|
||||
lib-y += csum_partial.o delay.o memcpy.o memcpy-inatomic.o memset.o \
|
||||
- strlen_user.o strncpy_user.o strnlen_user.o uncached.o
|
||||
+ strlen_user.o strncpy_user.o strnlen_user.o uncached.o memcmp.o
|
||||
|
||||
obj-y += iomap.o
|
||||
obj-$(CONFIG_PCI) += iomap-pci.o
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/lib/memcmp.c
|
||||
@@ -0,0 +1,22 @@
|
||||
+/*
|
||||
+ * copied from linux/lib/string.c
|
||||
+ *
|
||||
+ * Copyright (C) 1991, 1992 Linus Torvalds
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/string.h>
|
||||
+
|
||||
+#undef memcmp
|
||||
+int memcmp(const void *cs, const void *ct, size_t count)
|
||||
+{
|
||||
+ const unsigned char *su1, *su2;
|
||||
+ int res = 0;
|
||||
+
|
||||
+ for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
|
||||
+ if ((res = *su1 - *su2) != 0)
|
||||
+ break;
|
||||
+ return res;
|
||||
+}
|
||||
+EXPORT_SYMBOL(memcmp);
|
||||
+
|
|
@ -1,35 +0,0 @@
|
|||
--- a/arch/mips/oprofile/op_model_mipsxx.c
|
||||
+++ b/arch/mips/oprofile/op_model_mipsxx.c
|
||||
@@ -298,6 +298,11 @@ static void reset_counters(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
+static irqreturn_t mipsxx_perfcount_int(int irq, void *dev_id)
|
||||
+{
|
||||
+ return mipsxx_perfcount_handler();
|
||||
+}
|
||||
+
|
||||
static int __init mipsxx_init(void)
|
||||
{
|
||||
int counters;
|
||||
@@ -374,6 +379,10 @@ static int __init mipsxx_init(void)
|
||||
save_perf_irq = perf_irq;
|
||||
perf_irq = mipsxx_perfcount_handler;
|
||||
|
||||
+ if (cp0_perfcount_irq >= 0)
|
||||
+ return request_irq(cp0_perfcount_irq, mipsxx_perfcount_int,
|
||||
+ IRQF_SHARED, "Perfcounter", save_perf_irq);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -381,6 +390,9 @@ static void mipsxx_exit(void)
|
||||
{
|
||||
int counters = op_model_mipsxx_ops.num_counters;
|
||||
|
||||
+ if (cp0_perfcount_irq >= 0)
|
||||
+ free_irq(cp0_perfcount_irq, save_perf_irq);
|
||||
+
|
||||
counters = counters_per_cpu_to_total(counters);
|
||||
on_each_cpu(reset_counters, (void *)(long)counters, 1);
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
--- a/arch/mips/kernel/cpu-probe.c
|
||||
+++ b/arch/mips/kernel/cpu-probe.c
|
||||
@@ -814,10 +814,13 @@ static inline void cpu_probe_mips(struct
|
||||
__cpu_name[cpu] = "MIPS 20Kc";
|
||||
break;
|
||||
case PRID_IMP_24K:
|
||||
- case PRID_IMP_24KE:
|
||||
c->cputype = CPU_24K;
|
||||
__cpu_name[cpu] = "MIPS 24Kc";
|
||||
break;
|
||||
+ case PRID_IMP_24KE:
|
||||
+ c->cputype = CPU_24K;
|
||||
+ __cpu_name[cpu] = "MIPS 24KEc";
|
||||
+ break;
|
||||
case PRID_IMP_25KF:
|
||||
c->cputype = CPU_25KF;
|
||||
__cpu_name[cpu] = "MIPS 25Kc";
|
|
@ -1,109 +0,0 @@
|
|||
--- a/arch/mips/lib/memset.S
|
||||
+++ b/arch/mips/lib/memset.S
|
||||
@@ -19,6 +19,8 @@
|
||||
#define LONG_S_R sdr
|
||||
#endif
|
||||
|
||||
+#include "prefetch.h"
|
||||
+
|
||||
#define EX(insn,reg,addr,handler) \
|
||||
9: insn reg, addr; \
|
||||
.section __ex_table,"a"; \
|
||||
@@ -75,6 +77,8 @@ FEXPORT(__bzero)
|
||||
bnez t0, .Lsmall_memset
|
||||
andi t0, a0, LONGMASK /* aligned? */
|
||||
|
||||
+ prefetch_store a0, a2, t2, t3, t4
|
||||
+
|
||||
#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
|
||||
beqz t0, 1f
|
||||
PTR_SUBU t0, LONGSIZE /* alignment in bytes */
|
||||
--- a/arch/mips/include/asm/processor.h
|
||||
+++ b/arch/mips/include/asm/processor.h
|
||||
@@ -354,7 +354,7 @@ unsigned long get_wchan(struct task_stru
|
||||
#define prefetch(x) __builtin_prefetch((x), 0, 1)
|
||||
|
||||
#define ARCH_HAS_PREFETCHW
|
||||
-#define prefetchw(x) __builtin_prefetch((x), 1, 1)
|
||||
+#define prefetchw(x) do {} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/lib/prefetch.h
|
||||
@@ -0,0 +1,35 @@
|
||||
+/*
|
||||
+ * This file is subject to the terms and conditions of the GNU General Public
|
||||
+ * License. See the file "COPYING" in the main directory of this archive
|
||||
+ * for more details.
|
||||
+ *
|
||||
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
|
||||
+ */
|
||||
+
|
||||
+.macro prefetch_store dst, size, temp1, temp2, temp3
|
||||
+#ifdef CONFIG_CPU_MIPS32
|
||||
+ li \temp1, ((1 << CONFIG_MIPS_L1_CACHE_SHIFT) - 1)
|
||||
+ nor \temp1, \temp1, \temp1
|
||||
+
|
||||
+ and \temp2, \size, \temp1
|
||||
+ beqz \temp2, 2f
|
||||
+ nop
|
||||
+
|
||||
+ move \temp2, \dst
|
||||
+ PTR_ADDIU \temp2, ((1 << CONFIG_MIPS_L1_CACHE_SHIFT) - 1)
|
||||
+ and \temp2, \temp2, \temp1
|
||||
+
|
||||
+ move \temp3, \dst
|
||||
+ PTR_ADDU \temp3, \size
|
||||
+ and \temp3, \temp3, \temp1
|
||||
+
|
||||
+1: beq \temp2, \temp3, 2f
|
||||
+ nop
|
||||
+
|
||||
+ pref 30, 0(\temp2)
|
||||
+
|
||||
+ b 1b
|
||||
+ PTR_ADDIU \temp2, (1 << CONFIG_MIPS_L1_CACHE_SHIFT)
|
||||
+2:
|
||||
+#endif
|
||||
+.endm
|
||||
--- a/arch/mips/lib/memcpy.S
|
||||
+++ b/arch/mips/lib/memcpy.S
|
||||
@@ -182,6 +182,8 @@
|
||||
.set at=v1
|
||||
#endif
|
||||
|
||||
+#include "prefetch.h"
|
||||
+
|
||||
/*
|
||||
* A combined memcpy/__copy_user
|
||||
* __copy_user sets len to 0 for success; else to an upper bound of
|
||||
@@ -199,6 +201,8 @@ FEXPORT(__copy_user)
|
||||
*/
|
||||
#define rem t8
|
||||
|
||||
+ prefetch_store a0, a2, t0, t1, t2
|
||||
+
|
||||
R10KCBARRIER(0(ra))
|
||||
/*
|
||||
* The "issue break"s below are very approximate.
|
||||
--- a/arch/mips/lib/memcpy-inatomic.S
|
||||
+++ b/arch/mips/lib/memcpy-inatomic.S
|
||||
@@ -182,6 +182,8 @@
|
||||
.set at=v1
|
||||
#endif
|
||||
|
||||
+#include "prefetch.h"
|
||||
+
|
||||
/*
|
||||
* A combined memcpy/__copy_user
|
||||
* __copy_user sets len to 0 for success; else to an upper bound of
|
||||
@@ -196,6 +198,8 @@ LEAF(__copy_user_inatomic)
|
||||
*/
|
||||
#define rem t8
|
||||
|
||||
+ prefetch_store dst, len, t0, t1, t2
|
||||
+
|
||||
/*
|
||||
* The "issue break"s below are very approximate.
|
||||
* Issue delays for dcache fills will perturb the schedule, as will
|
|
@ -1,13 +0,0 @@
|
|||
--- a/arch/arm/kernel/module.c
|
||||
+++ b/arch/arm/kernel/module.c
|
||||
@@ -81,6 +81,10 @@ apply_relocate(Elf32_Shdr *sechdrs, cons
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
+ if ((IS_ERR_VALUE(sym->st_value) || !sym->st_value) &&
|
||||
+ ELF_ST_BIND(sym->st_info) == STB_WEAK)
|
||||
+ continue;
|
||||
+
|
||||
loc = dstsec->sh_addr + rel->r_offset;
|
||||
|
||||
switch (ELF32_R_TYPE(rel->r_info)) {
|
|
@ -1,31 +0,0 @@
|
|||
Upstream doesn't optimize the kernel and bootwrappers for ppc44x because
|
||||
they still want to support gcc 3.3 -- well, we don't.
|
||||
|
||||
--- a/arch/powerpc/Makefile
|
||||
+++ b/arch/powerpc/Makefile
|
||||
@@ -130,7 +130,8 @@ ifeq ($(CONFIG_FUNCTION_TRACER),y)
|
||||
KBUILD_CFLAGS += -mno-sched-epilog
|
||||
endif
|
||||
|
||||
-cpu-as-$(CONFIG_4xx) += -Wa,-m405
|
||||
+cpu-as-$(CONFIG_40x) += -Wa,-m405
|
||||
+cpu-as-$(CONFIG_44x) += -Wa,-m440
|
||||
cpu-as-$(CONFIG_6xx) += -Wa,-maltivec
|
||||
cpu-as-$(CONFIG_POWER4) += -Wa,-maltivec
|
||||
cpu-as-$(CONFIG_E500) += -Wa,-me500
|
||||
--- a/arch/powerpc/boot/Makefile
|
||||
+++ b/arch/powerpc/boot/Makefile
|
||||
@@ -38,10 +38,10 @@ BOOTCFLAGS += -I$(obj) -I$(srctree)/$(ob
|
||||
DTC_FLAGS ?= -p 1024
|
||||
|
||||
$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
|
||||
-$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
|
||||
+$(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
|
||||
$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
|
||||
-$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
|
||||
-$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
|
||||
+$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=440
|
||||
+$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=440
|
||||
$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
|
||||
$(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
|
||||
$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
|
|
@ -1,10 +0,0 @@
|
|||
--- a/arch/powerpc/Makefile
|
||||
+++ b/arch/powerpc/Makefile
|
||||
@@ -94,7 +94,6 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
-KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
|
||||
|
||||
ifeq ($(CONFIG_TUNE_CELL),y)
|
||||
KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
|
|
@ -1,10 +0,0 @@
|
|||
--- a/drivers/crypto/amcc/crypto4xx_core.c
|
||||
+++ b/drivers/crypto/amcc/crypto4xx_core.c
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/spinlock_types.h>
|
||||
#include <linux/random.h>
|
|
@ -1,616 +0,0 @@
|
|||
From eee16330c9de9adf7880cce9f1d32e13f89706bb Mon Sep 17 00:00:00 2001
|
||||
From: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
Date: Tue, 11 Jan 2011 13:16:47 +0000
|
||||
Subject: MIPS: Add crash and kdump support
|
||||
|
||||
From: http://patchwork.linux-mips.org/patch/1025/
|
||||
|
||||
Hello folks,
|
||||
|
||||
Please find here MIPS crash and kdump patches.
|
||||
This is patch set of 3 patches:
|
||||
1. generic MIPS changes (kernel);
|
||||
2. MIPS Cavium Octeon board kexec/kdump code (kernel);
|
||||
3. Kexec user space MIPS changes.
|
||||
|
||||
Patches were tested on the latest linux-mips@ git kernel and the latest
|
||||
kexec-tools git on Cavium Octeon 50xx board.
|
||||
|
||||
I also made the same code working on RMI XLR/XLS boards for both
|
||||
mips32 and mips64 kernels.
|
||||
|
||||
Best regards,
|
||||
Maxim Uvarov.
|
||||
|
||||
------
|
||||
[ Zhangjin: Several trivial building failure has been fixed.
|
||||
|
||||
Note: the 2nd patch can not be cleanly applied, but may be a good
|
||||
reference for the other board development:
|
||||
|
||||
+ MIPS Cavium Octeon board kexec,kdump support
|
||||
http://patchwork.linux-mips.org/patch/1026/
|
||||
|
||||
And the 3rd patch has already been merged into the mainline kexec-tools:
|
||||
|
||||
+ some kexec MIPS improvements
|
||||
http://patchwork.linux-mips.org/patch/1027/
|
||||
|
||||
kexec-tools is available here:
|
||||
|
||||
+ http://horms.net/projects/kexec/
|
||||
git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
|
||||
]
|
||||
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
---
|
||||
(limited to 'arch/mips/kernel')
|
||||
|
||||
--- a/arch/mips/kernel/Makefile
|
||||
+++ b/arch/mips/kernel/Makefile
|
||||
@@ -95,7 +95,8 @@ obj-$(CONFIG_I8253) += i8253.o
|
||||
|
||||
obj-$(CONFIG_GPIO_TXX9) += gpio_txx9.o
|
||||
|
||||
-obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
|
||||
+obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
|
||||
+obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
|
||||
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
|
||||
obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
|
||||
obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/kernel/crash.c
|
||||
@@ -0,0 +1,75 @@
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/smp.h>
|
||||
+#include <linux/reboot.h>
|
||||
+#include <linux/kexec.h>
|
||||
+#include <linux/bootmem.h>
|
||||
+#include <linux/crash_dump.h>
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/irq.h>
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/sched.h>
|
||||
+
|
||||
+#ifdef CONFIG_CRASH_DUMP
|
||||
+unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
|
||||
+#endif
|
||||
+
|
||||
+/* This keeps a track of which one is crashing cpu. */
|
||||
+int crashing_cpu = -1;
|
||||
+static cpumask_t cpus_in_crash = CPU_MASK_NONE;
|
||||
+
|
||||
+#ifdef CONFIG_SMP
|
||||
+void crash_shutdown_secondary(void *ignore)
|
||||
+{
|
||||
+ struct pt_regs *regs;
|
||||
+ int cpu = smp_processor_id();
|
||||
+
|
||||
+ regs = task_pt_regs(current);
|
||||
+
|
||||
+ if (!cpu_online(cpu))
|
||||
+ return;
|
||||
+
|
||||
+ local_irq_disable();
|
||||
+ if (!cpu_isset(cpu, cpus_in_crash))
|
||||
+ crash_save_cpu(regs, cpu);
|
||||
+ cpu_set(cpu, cpus_in_crash);
|
||||
+
|
||||
+ while (!atomic_read(&kexec_ready_to_reboot))
|
||||
+ cpu_relax();
|
||||
+ relocated_kexec_smp_wait(NULL);
|
||||
+ /* NOTREACHED */
|
||||
+}
|
||||
+
|
||||
+static void crash_kexec_prepare_cpus(void)
|
||||
+{
|
||||
+ unsigned int msecs;
|
||||
+
|
||||
+ unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
|
||||
+
|
||||
+ dump_send_ipi(crash_shutdown_secondary);
|
||||
+ smp_wmb();
|
||||
+
|
||||
+ /*
|
||||
+ * The crash CPU sends an IPI and wait for other CPUs to
|
||||
+ * respond. Delay of at least 10 seconds.
|
||||
+ */
|
||||
+ printk(KERN_EMERG "Sending IPI to other cpus...\n");
|
||||
+ msecs = 10000;
|
||||
+ while ((cpus_weight(cpus_in_crash) < ncpus) && (--msecs > 0)) {
|
||||
+ cpu_relax();
|
||||
+ mdelay(1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#else
|
||||
+static void crash_kexec_prepare_cpus(void) {}
|
||||
+#endif
|
||||
+
|
||||
+void default_machine_crash_shutdown(struct pt_regs *regs)
|
||||
+{
|
||||
+ local_irq_disable();
|
||||
+ crashing_cpu = smp_processor_id();
|
||||
+ crash_save_cpu(regs, crashing_cpu);
|
||||
+ crash_kexec_prepare_cpus();
|
||||
+ cpu_set(crashing_cpu, cpus_in_crash);
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/kernel/crash_dump.c
|
||||
@@ -0,0 +1,86 @@
|
||||
+#include <linux/highmem.h>
|
||||
+#include <linux/bootmem.h>
|
||||
+#include <linux/crash_dump.h>
|
||||
+#include <asm/uaccess.h>
|
||||
+
|
||||
+#ifdef CONFIG_PROC_VMCORE
|
||||
+static int __init parse_elfcorehdr(char *p)
|
||||
+{
|
||||
+ if (p)
|
||||
+ elfcorehdr_addr = memparse(p, &p);
|
||||
+ return 1;
|
||||
+}
|
||||
+__setup("elfcorehdr=", parse_elfcorehdr);
|
||||
+#endif
|
||||
+
|
||||
+static int __init parse_savemaxmem(char *p)
|
||||
+{
|
||||
+ if (p)
|
||||
+ saved_max_pfn = (memparse(p, &p) >> PAGE_SHIFT) - 1;
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+__setup("savemaxmem=", parse_savemaxmem);
|
||||
+
|
||||
+
|
||||
+static void *kdump_buf_page;
|
||||
+
|
||||
+/**
|
||||
+ * copy_oldmem_page - copy one page from "oldmem"
|
||||
+ * @pfn: page frame number to be copied
|
||||
+ * @buf: target memory address for the copy; this can be in kernel address
|
||||
+ * space or user address space (see @userbuf)
|
||||
+ * @csize: number of bytes to copy
|
||||
+ * @offset: offset in bytes into the page (based on pfn) to begin the copy
|
||||
+ * @userbuf: if set, @buf is in user address space, use copy_to_user(),
|
||||
+ * otherwise @buf is in kernel address space, use memcpy().
|
||||
+ *
|
||||
+ * Copy a page from "oldmem". For this page, there is no pte mapped
|
||||
+ * in the current kernel.
|
||||
+ *
|
||||
+ * Calling copy_to_user() in atomic context is not desirable. Hence first
|
||||
+ * copying the data to a pre-allocated kernel page and then copying to user
|
||||
+ * space in non-atomic context.
|
||||
+ */
|
||||
+ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
|
||||
+ size_t csize, unsigned long offset, int userbuf)
|
||||
+{
|
||||
+ void *vaddr;
|
||||
+
|
||||
+ if (!csize)
|
||||
+ return 0;
|
||||
+
|
||||
+ vaddr = kmap_atomic_pfn(pfn, KM_PTE0);
|
||||
+
|
||||
+ if (!userbuf) {
|
||||
+ memcpy(buf, (vaddr + offset), csize);
|
||||
+ kunmap_atomic(vaddr, KM_PTE0);
|
||||
+ } else {
|
||||
+ if (!kdump_buf_page) {
|
||||
+ printk(KERN_WARNING "Kdump: Kdump buffer page not"
|
||||
+ " allocated\n");
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+ copy_page(kdump_buf_page, vaddr);
|
||||
+ kunmap_atomic(vaddr, KM_PTE0);
|
||||
+ if (copy_to_user(buf, (kdump_buf_page + offset), csize))
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+ return csize;
|
||||
+}
|
||||
+
|
||||
+static int __init kdump_buf_page_init(void)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ kdump_buf_page = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
+ if (!kdump_buf_page) {
|
||||
+ printk(KERN_WARNING "Kdump: Failed to allocate kdump buffer"
|
||||
+ " page\n");
|
||||
+ ret = -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+arch_initcall(kdump_buf_page_init);
|
||||
--- a/arch/mips/kernel/machine_kexec.c
|
||||
+++ b/arch/mips/kernel/machine_kexec.c
|
||||
@@ -19,9 +19,19 @@ extern const size_t relocate_new_kernel_
|
||||
extern unsigned long kexec_start_address;
|
||||
extern unsigned long kexec_indirection_page;
|
||||
|
||||
+int (*_machine_kexec_prepare)(struct kimage *) = NULL;
|
||||
+void (*_machine_kexec_shutdown)(void) = NULL;
|
||||
+void (*_machine_crash_shutdown)(struct pt_regs *regs) = NULL;
|
||||
+#ifdef CONFIG_SMP
|
||||
+void (*relocated_kexec_smp_wait) (void *);
|
||||
+atomic_t kexec_ready_to_reboot = ATOMIC_INIT(0);
|
||||
+#endif
|
||||
+
|
||||
int
|
||||
machine_kexec_prepare(struct kimage *kimage)
|
||||
{
|
||||
+ if (_machine_kexec_prepare)
|
||||
+ return _machine_kexec_prepare(kimage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -33,11 +43,17 @@ machine_kexec_cleanup(struct kimage *kim
|
||||
void
|
||||
machine_shutdown(void)
|
||||
{
|
||||
+ if (_machine_kexec_shutdown)
|
||||
+ _machine_kexec_shutdown();
|
||||
}
|
||||
|
||||
void
|
||||
machine_crash_shutdown(struct pt_regs *regs)
|
||||
{
|
||||
+ if (_machine_crash_shutdown)
|
||||
+ _machine_crash_shutdown(regs);
|
||||
+ else
|
||||
+ default_machine_crash_shutdown(regs);
|
||||
}
|
||||
|
||||
typedef void (*noretfun_t)(void) __attribute__((noreturn));
|
||||
@@ -52,7 +68,9 @@ machine_kexec(struct kimage *image)
|
||||
reboot_code_buffer =
|
||||
(unsigned long)page_address(image->control_code_page);
|
||||
|
||||
- kexec_start_address = (unsigned long) phys_to_virt(image->start);
|
||||
+ kexec_start_address =
|
||||
+ (unsigned long) phys_to_virt(image->start);
|
||||
+
|
||||
kexec_indirection_page =
|
||||
(unsigned long) phys_to_virt(image->head & PAGE_MASK);
|
||||
|
||||
@@ -63,7 +81,7 @@ machine_kexec(struct kimage *image)
|
||||
* The generic kexec code builds a page list with physical
|
||||
* addresses. they are directly accessible through KSEG0 (or
|
||||
* CKSEG0 or XPHYS if on 64bit system), hence the
|
||||
- * pys_to_virt() call.
|
||||
+ * phys_to_virt() call.
|
||||
*/
|
||||
for (ptr = &image->head; (entry = *ptr) && !(entry &IND_DONE);
|
||||
ptr = (entry & IND_INDIRECTION) ?
|
||||
@@ -81,5 +99,13 @@ machine_kexec(struct kimage *image)
|
||||
printk("Will call new kernel at %08lx\n", image->start);
|
||||
printk("Bye ...\n");
|
||||
__flush_cache_all();
|
||||
+#ifdef CONFIG_SMP
|
||||
+ /* All secondary cpus now may jump to kexec_wait cycle */
|
||||
+ relocated_kexec_smp_wait = reboot_code_buffer +
|
||||
+ (void *)(kexec_smp_wait - relocate_new_kernel);
|
||||
+ smp_wmb();
|
||||
+ atomic_set(&kexec_ready_to_reboot, 1);
|
||||
+#endif
|
||||
((noretfun_t) reboot_code_buffer)();
|
||||
}
|
||||
+
|
||||
--- a/arch/mips/kernel/relocate_kernel.S
|
||||
+++ b/arch/mips/kernel/relocate_kernel.S
|
||||
@@ -15,6 +15,11 @@
|
||||
#include <asm/addrspace.h>
|
||||
|
||||
LEAF(relocate_new_kernel)
|
||||
+ PTR_L a0, arg0
|
||||
+ PTR_L a1, arg1
|
||||
+ PTR_L a2, arg2
|
||||
+ PTR_L a3, arg3
|
||||
+
|
||||
PTR_L s0, kexec_indirection_page
|
||||
PTR_L s1, kexec_start_address
|
||||
|
||||
@@ -26,7 +31,6 @@ process_entry:
|
||||
and s3, s2, 0x1
|
||||
beq s3, zero, 1f
|
||||
and s4, s2, ~0x1 /* store destination addr in s4 */
|
||||
- move a0, s4
|
||||
b process_entry
|
||||
|
||||
1:
|
||||
@@ -60,23 +64,100 @@ copy_word:
|
||||
b process_entry
|
||||
|
||||
done:
|
||||
+#ifdef CONFIG_SMP
|
||||
+ /* kexec_flag reset is signal to other CPUs what kernel
|
||||
+ was moved to it's location. Note - we need relocated address
|
||||
+ of kexec_flag. */
|
||||
+
|
||||
+ bal 1f
|
||||
+ 1: move t1,ra;
|
||||
+ PTR_LA t2,1b
|
||||
+ PTR_LA t0,kexec_flag
|
||||
+ PTR_SUB t0,t0,t2;
|
||||
+ PTR_ADD t0,t1,t0;
|
||||
+ LONG_S zero,(t0)
|
||||
+#endif
|
||||
+
|
||||
+ sync
|
||||
/* jump to kexec_start_address */
|
||||
j s1
|
||||
END(relocate_new_kernel)
|
||||
|
||||
-kexec_start_address:
|
||||
- EXPORT(kexec_start_address)
|
||||
+#ifdef CONFIG_SMP
|
||||
+/*
|
||||
+ * Other CPUs should wait until code is relocated and
|
||||
+ * then start at entry (?) point.
|
||||
+ */
|
||||
+LEAF(kexec_smp_wait)
|
||||
+ PTR_L a0, s_arg0
|
||||
+ PTR_L a1, s_arg1
|
||||
+ PTR_L a2, s_arg2
|
||||
+ PTR_L a3, s_arg3
|
||||
+ PTR_L s1, kexec_start_address
|
||||
+
|
||||
+ /* Non-relocated address works for args and kexec_start_address ( old
|
||||
+ * kernel is not overwritten). But we need relocated address of
|
||||
+ * kexec_flag.
|
||||
+ */
|
||||
+
|
||||
+ bal 1f
|
||||
+1: move t1,ra;
|
||||
+ PTR_LA t2,1b
|
||||
+ PTR_LA t0,kexec_flag
|
||||
+ PTR_SUB t0,t0,t2;
|
||||
+ PTR_ADD t0,t1,t0;
|
||||
+
|
||||
+1: LONG_L s0, (t0)
|
||||
+ bne s0, zero,1b
|
||||
+
|
||||
+ sync
|
||||
+ j s1
|
||||
+ END(kexec_smp_wait)
|
||||
+#endif
|
||||
+
|
||||
+#ifdef __mips64
|
||||
+ /* all PTR's must be aligned to 8 byte in 64-bit mode */
|
||||
+ .align 3
|
||||
+#endif
|
||||
+
|
||||
+/* All parameters to new kernel are passed in registers a0-a3.
|
||||
+ * kexec_args[0..3] are uses to prepare register values.
|
||||
+ */
|
||||
+
|
||||
+EXPORT(kexec_args)
|
||||
+arg0: PTR 0x0
|
||||
+arg1: PTR 0x0
|
||||
+arg2: PTR 0x0
|
||||
+arg3: PTR 0x0
|
||||
+ .size kexec_args,PTRSIZE*4
|
||||
+
|
||||
+#ifdef CONFIG_SMP
|
||||
+/*
|
||||
+ * Secondary CPUs may have different kernel parameters in
|
||||
+ * their registers a0-a3. secondary_kexec_args[0..3] are used
|
||||
+ * to prepare register values.
|
||||
+ */
|
||||
+EXPORT(secondary_kexec_args)
|
||||
+s_arg0: PTR 0x0
|
||||
+s_arg1: PTR 0x0
|
||||
+s_arg2: PTR 0x0
|
||||
+s_arg3: PTR 0x0
|
||||
+ .size secondary_kexec_args,PTRSIZE*4
|
||||
+kexec_flag:
|
||||
+ LONG 0x1
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+EXPORT(kexec_start_address)
|
||||
PTR 0x0
|
||||
.size kexec_start_address, PTRSIZE
|
||||
|
||||
-kexec_indirection_page:
|
||||
- EXPORT(kexec_indirection_page)
|
||||
+EXPORT(kexec_indirection_page)
|
||||
PTR 0
|
||||
.size kexec_indirection_page, PTRSIZE
|
||||
|
||||
relocate_new_kernel_end:
|
||||
|
||||
-relocate_new_kernel_size:
|
||||
- EXPORT(relocate_new_kernel_size)
|
||||
+EXPORT(relocate_new_kernel_size)
|
||||
PTR relocate_new_kernel_end - relocate_new_kernel
|
||||
.size relocate_new_kernel_size, PTRSIZE
|
||||
--- a/arch/mips/kernel/setup.c
|
||||
+++ b/arch/mips/kernel/setup.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <linux/console.h>
|
||||
#include <linux/pfn.h>
|
||||
#include <linux/debugfs.h>
|
||||
+#include <linux/kexec.h>
|
||||
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/bootinfo.h>
|
||||
@@ -488,12 +489,62 @@ static void __init arch_mem_init(char **
|
||||
}
|
||||
|
||||
bootmem_init();
|
||||
+#ifdef CONFIG_KEXEC
|
||||
+ if (crashk_res.start != crashk_res.end)
|
||||
+ reserve_bootmem(crashk_res.start,
|
||||
+ crashk_res.end - crashk_res.start + 1,
|
||||
+ BOOTMEM_DEFAULT);
|
||||
+#endif
|
||||
device_tree_init();
|
||||
sparse_init();
|
||||
plat_swiotlb_setup();
|
||||
paging_init();
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_KEXEC
|
||||
+static inline unsigned long long get_total_mem(void)
|
||||
+{
|
||||
+ unsigned long long total;
|
||||
+ total = max_pfn - min_low_pfn;
|
||||
+ return total << PAGE_SHIFT;
|
||||
+}
|
||||
+
|
||||
+static void __init mips_parse_crashkernel(void)
|
||||
+{
|
||||
+ unsigned long long total_mem;
|
||||
+ unsigned long long crash_size, crash_base;
|
||||
+ int ret;
|
||||
+
|
||||
+ total_mem = get_total_mem();
|
||||
+ ret = parse_crashkernel(boot_command_line, total_mem,
|
||||
+ &crash_size, &crash_base);
|
||||
+ if (ret != 0 || crash_size <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ crashk_res.start = crash_base;
|
||||
+ crashk_res.end = crash_base + crash_size - 1;
|
||||
+}
|
||||
+static void __init request_crashkernel(struct resource *res)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = request_resource(res, &crashk_res);
|
||||
+ if (!ret)
|
||||
+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
|
||||
+ "for crashkernel\n",
|
||||
+ (unsigned long)((crashk_res.end -
|
||||
+ crashk_res.start + 1) >> 20),
|
||||
+ (unsigned long)(crashk_res.start >> 20));
|
||||
+}
|
||||
+#else
|
||||
+static void __init mips_parse_crashkernel(void)
|
||||
+{
|
||||
+}
|
||||
+static void __init request_crashkernel(struct resource *res)
|
||||
+{
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void __init resource_init(void)
|
||||
{
|
||||
int i;
|
||||
@@ -509,6 +560,8 @@ static void __init resource_init(void)
|
||||
/*
|
||||
* Request address space for all standard RAM.
|
||||
*/
|
||||
+ mips_parse_crashkernel();
|
||||
+
|
||||
for (i = 0; i < boot_mem_map.nr_map; i++) {
|
||||
struct resource *res;
|
||||
unsigned long start, end;
|
||||
@@ -544,6 +597,7 @@ static void __init resource_init(void)
|
||||
*/
|
||||
request_resource(res, &code_resource);
|
||||
request_resource(res, &data_resource);
|
||||
+ request_crashkernel(res);
|
||||
}
|
||||
}
|
||||
|
||||
--- a/arch/mips/kernel/smp.c
|
||||
+++ b/arch/mips/kernel/smp.c
|
||||
@@ -433,3 +433,21 @@ void flush_tlb_one(unsigned long vaddr)
|
||||
|
||||
EXPORT_SYMBOL(flush_tlb_page);
|
||||
EXPORT_SYMBOL(flush_tlb_one);
|
||||
+
|
||||
+#if defined(CONFIG_KEXEC)
|
||||
+void (*dump_ipi_function_ptr)(void *) = NULL;
|
||||
+void dump_send_ipi(void (*dump_ipi_callback)(void *))
|
||||
+{
|
||||
+ int i;
|
||||
+ int cpu = smp_processor_id();
|
||||
+
|
||||
+ dump_ipi_function_ptr = dump_ipi_callback;
|
||||
+ smp_mb();
|
||||
+ for_each_online_cpu(i)
|
||||
+ if (i != cpu)
|
||||
+ core_send_ipi(i, SMP_DUMP);
|
||||
+
|
||||
+}
|
||||
+EXPORT_SYMBOL(dump_send_ipi);
|
||||
+#endif
|
||||
+
|
||||
--- a/arch/mips/include/asm/kexec.h
|
||||
+++ b/arch/mips/include/asm/kexec.h
|
||||
@@ -9,22 +9,45 @@
|
||||
#ifndef _MIPS_KEXEC
|
||||
# define _MIPS_KEXEC
|
||||
|
||||
+#include <asm/stacktrace.h>
|
||||
+
|
||||
+extern unsigned long long elfcorehdr_addr;
|
||||
+
|
||||
/* Maximum physical address we can use pages from */
|
||||
#define KEXEC_SOURCE_MEMORY_LIMIT (0x20000000)
|
||||
/* Maximum address we can reach in physical address mode */
|
||||
#define KEXEC_DESTINATION_MEMORY_LIMIT (0x20000000)
|
||||
/* Maximum address we can use for the control code buffer */
|
||||
#define KEXEC_CONTROL_MEMORY_LIMIT (0x20000000)
|
||||
-
|
||||
-#define KEXEC_CONTROL_PAGE_SIZE 4096
|
||||
+/* Reserve 3*4096 bytes for board-specific info */
|
||||
+#define KEXEC_CONTROL_PAGE_SIZE (4096 + 3*4096)
|
||||
|
||||
/* The native architecture */
|
||||
#define KEXEC_ARCH KEXEC_ARCH_MIPS
|
||||
+#define MAX_NOTE_BYTES 1024
|
||||
|
||||
static inline void crash_setup_regs(struct pt_regs *newregs,
|
||||
- struct pt_regs *oldregs)
|
||||
+ struct pt_regs *oldregs)
|
||||
{
|
||||
- /* Dummy implementation for now */
|
||||
+ if (oldregs)
|
||||
+ memcpy(newregs, oldregs, sizeof(*newregs));
|
||||
+ else
|
||||
+ prepare_frametrace(newregs);
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_KEXEC
|
||||
+struct kimage;
|
||||
+extern unsigned long kexec_args[4];
|
||||
+extern int (*_machine_kexec_prepare)(struct kimage *);
|
||||
+extern void (*_machine_kexec_shutdown)(void);
|
||||
+extern void (*_machine_crash_shutdown)(struct pt_regs *regs);
|
||||
+extern void default_machine_crash_shutdown(struct pt_regs *regs);
|
||||
+#ifdef CONFIG_SMP
|
||||
+extern const unsigned char kexec_smp_wait[];
|
||||
+extern unsigned long secondary_kexec_args[4];
|
||||
+extern void (*relocated_kexec_smp_wait) (void *);
|
||||
+extern atomic_t kexec_ready_to_reboot;
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
#endif /* !_MIPS_KEXEC */
|
||||
--- a/arch/mips/include/asm/smp.h
|
||||
+++ b/arch/mips/include/asm/smp.h
|
||||
@@ -40,6 +40,8 @@ extern int __cpu_logical_map[NR_CPUS];
|
||||
#define SMP_CALL_FUNCTION 0x2
|
||||
/* Octeon - Tell another core to flush its icache */
|
||||
#define SMP_ICACHE_FLUSH 0x4
|
||||
+/* Used by kexec crashdump to save all cpu's state */
|
||||
+#define SMP_DUMP 0x8
|
||||
|
||||
extern volatile cpumask_t cpu_callin_map;
|
||||
|
||||
@@ -91,4 +93,9 @@ static inline void arch_send_call_functi
|
||||
mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION);
|
||||
}
|
||||
|
||||
+extern void core_send_ipi(int cpu, unsigned int action);
|
||||
+#if defined(CONFIG_KEXEC)
|
||||
+extern void (*dump_ipi_function_ptr)(void *);
|
||||
+void dump_send_ipi(void (*dump_ipi_callback)(void *));
|
||||
+#endif
|
||||
#endif /* __ASM_SMP_H */
|
|
@ -1,159 +0,0 @@
|
|||
From 03cd81fbca6b91317ec1a7b3b3c09fb8d08f83a6 Mon Sep 17 00:00:00 2001
|
||||
From: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
Date: Tue, 11 Jan 2011 18:42:08 +0000
|
||||
Subject: MIPS: Kexec: Enhance the support
|
||||
|
||||
Changes:
|
||||
o Print more information in machine_kexec() for debugging
|
||||
E.g. with this information, the kexec_start_address has been found
|
||||
it was wrong with 64bit kernel / o32 kexec-tools. Which must be
|
||||
fixed later.
|
||||
o Link relocate_kernel.S to a section for future extension
|
||||
This allows more functions can be added for the kexec relocation
|
||||
part even written in C. to add code into that section, you just need
|
||||
to mark your function or data with __kexec or
|
||||
__attribute__((__section__(".__kexec.relocate")))
|
||||
|
||||
TODO:
|
||||
|
||||
1. Make 64bit kernel / o32|n32|64 kexec-tools works
|
||||
|
||||
Fix the user-space kexec-tools, seems the tool only work for 32bit
|
||||
machine. So, we need to add 64bit support for it. The address of the
|
||||
entry point(kexec_start_address) is wrong and make the "kexec -e" fail.
|
||||
the real entry point must be read from the new kernel image by the
|
||||
user-space kexec-tools, otherwise, it will not work. The above 64bit
|
||||
support tested is 64bit kernel with o32 user-space kexec-tools. The root
|
||||
cause may be the different definition of virt_to_phys() and
|
||||
phys_to_virt() in the kexec-tools and kernel space for 64bit system /
|
||||
o32 kernel.
|
||||
|
||||
Ref: http://www.linux-mips.org/archives/linux-mips/2009-08/msg00149.html
|
||||
|
||||
2. Pass the arguments from kexec-tools to the new kernel image
|
||||
|
||||
Please refer to: "MIPS: Loongson: Kexec: Pass parameters to new kernel"
|
||||
|
||||
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
---
|
||||
--- a/arch/mips/include/asm/kexec.h
|
||||
+++ b/arch/mips/include/asm/kexec.h
|
||||
@@ -36,6 +36,16 @@ static inline void crash_setup_regs(stru
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KEXEC
|
||||
+
|
||||
+#define __kexec __attribute__((__section__(".__kexec.relocate")))
|
||||
+
|
||||
+/* The linker tells us where the relocate_new_kernel part is. */
|
||||
+extern const unsigned char __start___kexec_relocate;
|
||||
+extern const unsigned char __end___kexec_relocate;
|
||||
+
|
||||
+extern unsigned long kexec_start_address;
|
||||
+extern unsigned long kexec_indirection_page;
|
||||
+
|
||||
struct kimage;
|
||||
extern unsigned long kexec_args[4];
|
||||
extern int (*_machine_kexec_prepare)(struct kimage *);
|
||||
--- a/arch/mips/kernel/machine_kexec.c
|
||||
+++ b/arch/mips/kernel/machine_kexec.c
|
||||
@@ -13,12 +13,6 @@
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
-extern const unsigned char relocate_new_kernel[];
|
||||
-extern const size_t relocate_new_kernel_size;
|
||||
-
|
||||
-extern unsigned long kexec_start_address;
|
||||
-extern unsigned long kexec_indirection_page;
|
||||
-
|
||||
int (*_machine_kexec_prepare)(struct kimage *) = NULL;
|
||||
void (*_machine_kexec_shutdown)(void) = NULL;
|
||||
void (*_machine_crash_shutdown)(struct pt_regs *regs) = NULL;
|
||||
@@ -61,21 +55,34 @@ typedef void (*noretfun_t)(void) __attri
|
||||
void
|
||||
machine_kexec(struct kimage *image)
|
||||
{
|
||||
+ unsigned long kexec_relocate_size;
|
||||
unsigned long reboot_code_buffer;
|
||||
unsigned long entry;
|
||||
unsigned long *ptr;
|
||||
|
||||
+ kexec_relocate_size = (unsigned long)(&__end___kexec_relocate) -
|
||||
+ (unsigned long)(&__start___kexec_relocate);
|
||||
+ pr_info("kexec_relocate_size = %lu\n", kexec_relocate_size);
|
||||
+
|
||||
reboot_code_buffer =
|
||||
(unsigned long)page_address(image->control_code_page);
|
||||
+ pr_info("reboot_code_buffer = %p\n", (void *)reboot_code_buffer);
|
||||
|
||||
kexec_start_address =
|
||||
(unsigned long) phys_to_virt(image->start);
|
||||
+ pr_info("kexec_start_address(entry point of new kernel) = %p\n",
|
||||
+ (void *)kexec_start_address);
|
||||
|
||||
kexec_indirection_page =
|
||||
(unsigned long) phys_to_virt(image->head & PAGE_MASK);
|
||||
+ pr_info("kexec_indirection_page = %p\n",
|
||||
+ (void *)kexec_indirection_page);
|
||||
|
||||
- memcpy((void*)reboot_code_buffer, relocate_new_kernel,
|
||||
- relocate_new_kernel_size);
|
||||
+ memcpy((void *)reboot_code_buffer, &__start___kexec_relocate,
|
||||
+ kexec_relocate_size);
|
||||
+
|
||||
+ pr_info("Copy kexec_relocate section from %p to reboot_code_buffer: %p\n",
|
||||
+ &__start___kexec_relocate, (void *)reboot_code_buffer);
|
||||
|
||||
/*
|
||||
* The generic kexec code builds a page list with physical
|
||||
@@ -96,8 +103,8 @@ machine_kexec(struct kimage *image)
|
||||
*/
|
||||
local_irq_disable();
|
||||
|
||||
- printk("Will call new kernel at %08lx\n", image->start);
|
||||
- printk("Bye ...\n");
|
||||
+ pr_info("Will call new kernel at %p\n", (void *)kexec_start_address);
|
||||
+ pr_info("Bye ...\n");
|
||||
__flush_cache_all();
|
||||
#ifdef CONFIG_SMP
|
||||
/* All secondary cpus now may jump to kexec_wait cycle */
|
||||
@@ -108,4 +115,3 @@ machine_kexec(struct kimage *image)
|
||||
#endif
|
||||
((noretfun_t) reboot_code_buffer)();
|
||||
}
|
||||
-
|
||||
--- a/arch/mips/kernel/relocate_kernel.S
|
||||
+++ b/arch/mips/kernel/relocate_kernel.S
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <asm/stackframe.h>
|
||||
#include <asm/addrspace.h>
|
||||
|
||||
+ .section .kexec.relocate, "ax"
|
||||
+
|
||||
LEAF(relocate_new_kernel)
|
||||
PTR_L a0, arg0
|
||||
PTR_L a1, arg1
|
||||
@@ -155,9 +157,3 @@ EXPORT(kexec_start_address)
|
||||
EXPORT(kexec_indirection_page)
|
||||
PTR 0
|
||||
.size kexec_indirection_page, PTRSIZE
|
||||
-
|
||||
-relocate_new_kernel_end:
|
||||
-
|
||||
-EXPORT(relocate_new_kernel_size)
|
||||
- PTR relocate_new_kernel_end - relocate_new_kernel
|
||||
- .size relocate_new_kernel_size, PTRSIZE
|
||||
--- a/arch/mips/kernel/vmlinux.lds.S
|
||||
+++ b/arch/mips/kernel/vmlinux.lds.S
|
||||
@@ -50,6 +50,10 @@ SECTIONS
|
||||
*(.text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
+ __start___kexec_relocate = .;
|
||||
+ KEEP(*(.kexec.relocate))
|
||||
+ KEEP(*(.__kexec.relocate))
|
||||
+ __end___kexec_relocate = .;
|
||||
} :text = 0
|
||||
_etext = .; /* End of text section */
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
From 49d07a29653b1f2c6ae273b3d8fe93d981f43004 Mon Sep 17 00:00:00 2001
|
||||
From: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
Date: Wed, 12 Jan 2011 20:59:32 +0000
|
||||
Subject: MIPS: Kexec: Init the arguments for the new kernel image
|
||||
|
||||
Whenever the kexec-tools pass the command lines to the new kernel image,
|
||||
init the arguments as the ones for the 1st kernel image. This fixed the
|
||||
booting failure of Kexec on YeeLoong.
|
||||
|
||||
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
---
|
||||
--- a/arch/mips/kernel/machine_kexec.c
|
||||
+++ b/arch/mips/kernel/machine_kexec.c
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <linux/mm.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
+#include <asm/bootinfo.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
@@ -21,9 +22,30 @@ void (*relocated_kexec_smp_wait) (void *
|
||||
atomic_t kexec_ready_to_reboot = ATOMIC_INIT(0);
|
||||
#endif
|
||||
|
||||
+static void machine_kexec_init_args(void)
|
||||
+{
|
||||
+ kexec_args[0] = fw_arg0;
|
||||
+ kexec_args[1] = fw_arg1;
|
||||
+ kexec_args[2] = fw_arg2;
|
||||
+ kexec_args[3] = fw_arg3;
|
||||
+
|
||||
+ pr_info("kexec_args[0] (argc): %lu\n", kexec_args[0]);
|
||||
+ pr_info("kexec_args[1] (argv): %p\n", (void *)kexec_args[1]);
|
||||
+ pr_info("kexec_args[2] (env ): %p\n", (void *)kexec_args[2]);
|
||||
+ pr_info("kexec_args[3] (desc): %p\n", (void *)kexec_args[3]);
|
||||
+}
|
||||
+
|
||||
int
|
||||
machine_kexec_prepare(struct kimage *kimage)
|
||||
{
|
||||
+ /*
|
||||
+ * Whenever arguments passed from kexec-tools, Init the arguments as
|
||||
+ * the original ones to avoid booting failure.
|
||||
+ *
|
||||
+ * This can be overrided by _machine_kexec_prepare().
|
||||
+ */
|
||||
+ machine_kexec_init_args();
|
||||
+
|
||||
if (_machine_kexec_prepare)
|
||||
return _machine_kexec_prepare(kimage);
|
||||
return 0;
|
|
@ -1,88 +0,0 @@
|
|||
From 240c76841b26f1b09aaced33414ee1d08b6454cf Mon Sep 17 00:00:00 2001
|
||||
From: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
Date: Sat, 15 Jan 2011 12:46:03 +0000
|
||||
Subject: MIPS: Get kernel parameters from kexec-tools
|
||||
|
||||
Before, we simply use the command lines from the original bootloader,
|
||||
but it is not convenient. Now, we accept the kernel parameters from the
|
||||
--command-line or --append option of the kexec-tools. But If not
|
||||
--command-line or --apend option indicated, will fall back to use the
|
||||
ones from the original bootloader.
|
||||
|
||||
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
---
|
||||
--- a/arch/mips/kernel/machine_kexec.c
|
||||
+++ b/arch/mips/kernel/machine_kexec.c
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/page.h>
|
||||
+#include <asm/uaccess.h>
|
||||
|
||||
int (*_machine_kexec_prepare)(struct kimage *) = NULL;
|
||||
void (*_machine_kexec_shutdown)(void) = NULL;
|
||||
@@ -35,6 +36,56 @@ static void machine_kexec_init_args(void
|
||||
pr_info("kexec_args[3] (desc): %p\n", (void *)kexec_args[3]);
|
||||
}
|
||||
|
||||
+#define ARGV_MAX_ARGS (COMMAND_LINE_SIZE / 15)
|
||||
+
|
||||
+int machine_kexec_pass_args(struct kimage *image)
|
||||
+{
|
||||
+ int i, argc = 0;
|
||||
+ char *bootloader = "kexec";
|
||||
+ int *kexec_argv = (int *)kexec_args[1];
|
||||
+
|
||||
+ for (i = 0; i < image->nr_segments; i++) {
|
||||
+ if (!strncmp(bootloader, (char *)image->segment[i].buf,
|
||||
+ strlen(bootloader))) {
|
||||
+ /*
|
||||
+ * convert command line string to array
|
||||
+ * of parameters (as bootloader does).
|
||||
+ */
|
||||
+ /*
|
||||
+ * Note: we do treat the 1st string "kexec" as an
|
||||
+ * argument ;-) so, argc here is 1.
|
||||
+ */
|
||||
+ char *str = (char *)image->segment[i].buf;
|
||||
+ char *ptr = strchr(str, ' ');
|
||||
+ char *kbuf = (char *)kexec_argv[0];
|
||||
+ /* Whenever --command-line or --append used, "kexec" is copied */
|
||||
+ argc = 1;
|
||||
+ /* Parse the offset */
|
||||
+ while (ptr && (ARGV_MAX_ARGS > argc)) {
|
||||
+ *ptr = '\0';
|
||||
+ if (ptr[1] != ' ' && ptr[1] != '\0') {
|
||||
+ int offt = (int)(ptr - str + 1);
|
||||
+ kexec_argv[argc] = (int)kbuf + offt;
|
||||
+ argc++;
|
||||
+ }
|
||||
+ ptr = strchr(ptr + 1, ' ');
|
||||
+ }
|
||||
+ if (argc > 1) {
|
||||
+ /* Copy to kernel space */
|
||||
+ copy_from_user(kbuf, (char *)image->segment[i].buf, image->segment[i].bufsz);
|
||||
+ fw_arg0 = kexec_args[0] = argc;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ pr_info("argc = %lu\n", kexec_args[0]);
|
||||
+ for (i = 0; i < kexec_args[0]; i++)
|
||||
+ pr_info("argv[%d] = %p, %s\n", i, (char *)kexec_argv[i], (char *)kexec_argv[i]);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
int
|
||||
machine_kexec_prepare(struct kimage *kimage)
|
||||
{
|
||||
@@ -45,6 +96,7 @@ machine_kexec_prepare(struct kimage *kim
|
||||
* This can be overrided by _machine_kexec_prepare().
|
||||
*/
|
||||
machine_kexec_init_args();
|
||||
+ machine_kexec_pass_args(kimage);
|
||||
|
||||
if (_machine_kexec_prepare)
|
||||
return _machine_kexec_prepare(kimage);
|
|
@ -1,83 +0,0 @@
|
|||
From 4aded085fa0057a9a1e1dcec631f950307360c1f Mon Sep 17 00:00:00 2001
|
||||
From: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
Date: Tue, 11 Jan 2011 13:46:19 +0000
|
||||
Subject: MIPS: Fix compiling failure of relocate_kernel.S
|
||||
|
||||
The following errors is fixed with the help of <asm/asm_nosec.h>. for
|
||||
this file need to put different symbols in the same section, the
|
||||
original LEAF, NESTED and EXPORT (without explicit section indication)
|
||||
must be used, <asm/asm_nosec.h> does it.
|
||||
|
||||
arch/mips/kernel/relocate_kernel.S: Assembler messages:
|
||||
arch/mips/kernel/relocate_kernel.S:162: Error: operation combines symbols in different segments
|
||||
|
||||
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
---
|
||||
(limited to 'arch/mips/kernel')
|
||||
|
||||
--- a/arch/mips/kernel/relocate_kernel.S
|
||||
+++ b/arch/mips/kernel/relocate_kernel.S
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <asm/asm.h>
|
||||
+#include <asm/asm_nosec.h>
|
||||
#include <asm/asmmacro.h>
|
||||
#include <asm/regdef.h>
|
||||
#include <asm/page.h>
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/include/asm/asm_nosec.h
|
||||
@@ -0,0 +1,53 @@
|
||||
+/*
|
||||
+ * This file is subject to the terms and conditions of the GNU General Public
|
||||
+ * License. See the file "COPYING" in the main directory of this archive
|
||||
+ * for more details.
|
||||
+ *
|
||||
+ * Copyright (C) 1995, 1996, 1997, 1999, 2001 by Ralf Baechle
|
||||
+ * Copyright (C) 1999 by Silicon Graphics, Inc.
|
||||
+ * Copyright (C) 2001 MIPS Technologies, Inc.
|
||||
+ * Copyright (C) 2002 Maciej W. Rozycki
|
||||
+ * Copyright (C) 2010 Wu Zhangjin <wuzhangjin@gmail.com>
|
||||
+ *
|
||||
+ * Derive from <asm/asm.h>
|
||||
+ *
|
||||
+ * Override the macros without -ffunction-sections and -fdata-sections support.
|
||||
+ * If several functions or data must be put in the same section, please include
|
||||
+ * this header file after the <asm/asm.h> to override the generic definition.
|
||||
+ */
|
||||
+
|
||||
+#ifndef __ASM_ASM_NOSEC_H
|
||||
+#define __ASM_ASM_NOSEC_H
|
||||
+
|
||||
+#undef LEAF
|
||||
+#undef NESTED
|
||||
+#undef EXPORT
|
||||
+
|
||||
+/*
|
||||
+ * LEAF - declare leaf routine
|
||||
+ */
|
||||
+#define LEAF(symbol) \
|
||||
+ .globl symbol; \
|
||||
+ .align 2; \
|
||||
+ .type symbol, @function; \
|
||||
+ .ent symbol, 0; \
|
||||
+symbol: .frame sp, 0, ra
|
||||
+
|
||||
+/*
|
||||
+ * NESTED - declare nested routine entry point
|
||||
+ */
|
||||
+#define NESTED(symbol, framesize, rpc) \
|
||||
+ .globl symbol; \
|
||||
+ .align 2; \
|
||||
+ .type symbol, @function; \
|
||||
+ .ent symbol, 0; \
|
||||
+symbol: .frame sp, framesize, rpc
|
||||
+
|
||||
+/*
|
||||
+ * EXPORT - export definition of symbol
|
||||
+ */
|
||||
+#define EXPORT(symbol) \
|
||||
+ .globl symbol; \
|
||||
+symbol:
|
||||
+
|
||||
+#endif /* __ASM_ASM_NOSEC_H */
|
|
@ -1,186 +0,0 @@
|
|||
--- a/arch/mips/kernel/machine_kexec.c
|
||||
+++ b/arch/mips/kernel/machine_kexec.c
|
||||
@@ -23,67 +23,104 @@ void (*relocated_kexec_smp_wait) (void *
|
||||
atomic_t kexec_ready_to_reboot = ATOMIC_INIT(0);
|
||||
#endif
|
||||
|
||||
-static void machine_kexec_init_args(void)
|
||||
+#define KEXEC_MIPS_ARGV_BUF_SIZE COMMAND_LINE_SIZE
|
||||
+#define KEXEC_MIPS_ARGV_MAX_ARGS (COMMAND_LINE_SIZE / 15)
|
||||
+
|
||||
+char kexec_argv_buf[KEXEC_MIPS_ARGV_BUF_SIZE] __kexec;
|
||||
+char *kexec_argv[KEXEC_MIPS_ARGV_MAX_ARGS] __kexec;
|
||||
+
|
||||
+static void
|
||||
+machine_kexec_print_args(void)
|
||||
{
|
||||
- kexec_args[0] = fw_arg0;
|
||||
- kexec_args[1] = fw_arg1;
|
||||
- kexec_args[2] = fw_arg2;
|
||||
- kexec_args[3] = fw_arg3;
|
||||
+ int i;
|
||||
|
||||
pr_info("kexec_args[0] (argc): %lu\n", kexec_args[0]);
|
||||
pr_info("kexec_args[1] (argv): %p\n", (void *)kexec_args[1]);
|
||||
pr_info("kexec_args[2] (env ): %p\n", (void *)kexec_args[2]);
|
||||
pr_info("kexec_args[3] (desc): %p\n", (void *)kexec_args[3]);
|
||||
-}
|
||||
|
||||
-#define ARGV_MAX_ARGS (COMMAND_LINE_SIZE / 15)
|
||||
+ for (i = 0; i < kexec_args[0]; i++)
|
||||
+ pr_info("kexec_argv[%d] = %p, %s\n", i,
|
||||
+ (char *)kexec_argv[i], (char *)kexec_argv[i]);
|
||||
+}
|
||||
|
||||
-int machine_kexec_pass_args(struct kimage *image)
|
||||
+static void
|
||||
+machine_kexec_init_argv(struct kimage *image)
|
||||
{
|
||||
- int i, argc = 0;
|
||||
- char *bootloader = "kexec";
|
||||
- int *kexec_argv = (int *)kexec_args[1];
|
||||
+ void __user *buf = NULL;
|
||||
+ size_t bufsz;
|
||||
+ size_t size;
|
||||
+ int i;
|
||||
|
||||
+ bufsz = 0;
|
||||
for (i = 0; i < image->nr_segments; i++) {
|
||||
- if (!strncmp(bootloader, (char *)image->segment[i].buf,
|
||||
- strlen(bootloader))) {
|
||||
- /*
|
||||
- * convert command line string to array
|
||||
- * of parameters (as bootloader does).
|
||||
- */
|
||||
- /*
|
||||
- * Note: we do treat the 1st string "kexec" as an
|
||||
- * argument ;-) so, argc here is 1.
|
||||
- */
|
||||
- char *str = (char *)image->segment[i].buf;
|
||||
- char *ptr = strchr(str, ' ');
|
||||
- char *kbuf = (char *)kexec_argv[0];
|
||||
- /* Whenever --command-line or --append used, "kexec" is copied */
|
||||
- argc = 1;
|
||||
- /* Parse the offset */
|
||||
- while (ptr && (ARGV_MAX_ARGS > argc)) {
|
||||
- *ptr = '\0';
|
||||
- if (ptr[1] != ' ' && ptr[1] != '\0') {
|
||||
- int offt = (int)(ptr - str + 1);
|
||||
- kexec_argv[argc] = (int)kbuf + offt;
|
||||
- argc++;
|
||||
- }
|
||||
- ptr = strchr(ptr + 1, ' ');
|
||||
- }
|
||||
- if (argc > 1) {
|
||||
- /* Copy to kernel space */
|
||||
- copy_from_user(kbuf, (char *)image->segment[i].buf, image->segment[i].bufsz);
|
||||
- fw_arg0 = kexec_args[0] = argc;
|
||||
- }
|
||||
- break;
|
||||
+ struct kexec_segment *seg;
|
||||
+
|
||||
+ seg = &image->segment[i];
|
||||
+ if (seg->bufsz < 6)
|
||||
+ continue;
|
||||
+
|
||||
+ if (strncmp((char *) seg->buf, "kexec", 5))
|
||||
+ continue;
|
||||
+
|
||||
+ /* don't copy "kexec" */
|
||||
+ buf = seg->buf + 5;
|
||||
+ bufsz = seg->bufsz - 5;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (!buf)
|
||||
+ return;
|
||||
+
|
||||
+ size = KEXEC_MIPS_ARGV_BUF_SIZE - 1;
|
||||
+ size = min(size, bufsz);
|
||||
+ if (size < bufsz)
|
||||
+ pr_warn("kexec command line truncated to %zd bytes\n", size);
|
||||
+
|
||||
+ /* Copy to kernel space */
|
||||
+ copy_from_user(kexec_argv_buf, buf, size);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+machine_kexec_parse_argv(struct kimage *image)
|
||||
+{
|
||||
+ char *reboot_code_buffer;
|
||||
+ int reloc_delta;
|
||||
+ char *ptr;
|
||||
+ int argc;
|
||||
+ int i;
|
||||
+
|
||||
+ ptr = kexec_argv_buf;
|
||||
+ argc = 0;
|
||||
+
|
||||
+ /*
|
||||
+ * convert command line string to array of parameters
|
||||
+ * (as bootloader does).
|
||||
+ */
|
||||
+ while (ptr && *ptr && (KEXEC_MIPS_ARGV_MAX_ARGS > argc)) {
|
||||
+ if (*ptr == ' ') {
|
||||
+ *ptr++ = '\0';
|
||||
+ continue;
|
||||
}
|
||||
+
|
||||
+ kexec_argv[argc++] = ptr;
|
||||
+ ptr = strchr(ptr, ' ');
|
||||
}
|
||||
|
||||
- pr_info("argc = %lu\n", kexec_args[0]);
|
||||
- for (i = 0; i < kexec_args[0]; i++)
|
||||
- pr_info("argv[%d] = %p, %s\n", i, (char *)kexec_argv[i], (char *)kexec_argv[i]);
|
||||
+ if (!argc)
|
||||
+ return;
|
||||
|
||||
- return 0;
|
||||
+ kexec_args[0] = argc;
|
||||
+ kexec_args[1] = (unsigned long)kexec_argv;
|
||||
+ kexec_args[2] = 0;
|
||||
+ kexec_args[3] = 0;
|
||||
+
|
||||
+ reboot_code_buffer = page_address(image->control_code_page);
|
||||
+ reloc_delta = reboot_code_buffer - (char *) &__start___kexec_relocate;
|
||||
+
|
||||
+ kexec_args[1] += reloc_delta;
|
||||
+ for (i = 0; i < argc; i++)
|
||||
+ kexec_argv[i] += reloc_delta;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -95,8 +132,14 @@ machine_kexec_prepare(struct kimage *kim
|
||||
*
|
||||
* This can be overrided by _machine_kexec_prepare().
|
||||
*/
|
||||
- machine_kexec_init_args();
|
||||
- machine_kexec_pass_args(kimage);
|
||||
+
|
||||
+ kexec_args[0] = fw_arg0;
|
||||
+ kexec_args[1] = fw_arg1;
|
||||
+ kexec_args[2] = fw_arg2;
|
||||
+ kexec_args[3] = fw_arg3;
|
||||
+
|
||||
+ machine_kexec_init_argv(kimage);
|
||||
+ machine_kexec_parse_argv(kimage);
|
||||
|
||||
if (_machine_kexec_prepare)
|
||||
return _machine_kexec_prepare(kimage);
|
||||
@@ -152,11 +195,13 @@ machine_kexec(struct kimage *image)
|
||||
pr_info("kexec_indirection_page = %p\n",
|
||||
(void *)kexec_indirection_page);
|
||||
|
||||
+ pr_info("Copy kexec_relocate section from %p to reboot_code_buffer: %p\n",
|
||||
+ &__start___kexec_relocate, (void *)reboot_code_buffer);
|
||||
+
|
||||
memcpy((void *)reboot_code_buffer, &__start___kexec_relocate,
|
||||
kexec_relocate_size);
|
||||
|
||||
- pr_info("Copy kexec_relocate section from %p to reboot_code_buffer: %p\n",
|
||||
- &__start___kexec_relocate, (void *)reboot_code_buffer);
|
||||
+ machine_kexec_print_args();
|
||||
|
||||
/*
|
||||
* The generic kexec code builds a page list with physical
|
|
@ -1,20 +0,0 @@
|
|||
--- a/kernel/module.c
|
||||
+++ b/kernel/module.c
|
||||
@@ -2283,12 +2283,15 @@ static void dynamic_debug_remove(struct
|
||||
|
||||
void * __weak module_alloc(unsigned long size)
|
||||
{
|
||||
- return size == 0 ? NULL : vmalloc_exec(size);
|
||||
+ return vmalloc_exec(size);
|
||||
}
|
||||
|
||||
static void *module_alloc_update_bounds(unsigned long size)
|
||||
{
|
||||
- void *ret = module_alloc(size);
|
||||
+ void *ret = NULL;
|
||||
+
|
||||
+ if (size)
|
||||
+ ret = module_alloc(size);
|
||||
|
||||
if (ret) {
|
||||
mutex_lock(&module_mutex);
|
|
@ -1,11 +0,0 @@
|
|||
--- a/arch/arm/boot/compressed/Makefile
|
||||
+++ b/arch/arm/boot/compressed/Makefile
|
||||
@@ -127,7 +127,7 @@ ccflags-y := -fpic -fno-builtin -I$(obj)
|
||||
asflags-y := -Wa,-march=all
|
||||
|
||||
# Supply kernel BSS size to the decompressor via a linker symbol.
|
||||
-KBSS_SZ = $(shell size $(obj)/../../../../vmlinux | awk 'END{print $$3}')
|
||||
+KBSS_SZ = $(shell $(CROSS_COMPILE)size $(obj)/../../../../vmlinux | awk 'END{print $$3}')
|
||||
LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
|
||||
# Supply ZRELADDR to the decompressor via a linker symbol.
|
||||
ifneq ($(CONFIG_AUTO_ZRELADDR),y)
|
|
@ -1,327 +0,0 @@
|
|||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -23,6 +23,14 @@ config MTD_TESTS
|
||||
WARNING: some of the tests will ERASE entire MTD device which they
|
||||
test. Do not use these tests unless you really know what you do.
|
||||
|
||||
+config MTD_ROOTFS_ROOT_DEV
|
||||
+ bool "Automatically set 'rootfs' partition to be root filesystem"
|
||||
+ default y
|
||||
+
|
||||
+config MTD_ROOTFS_SPLIT
|
||||
+ bool "Automatically split 'rootfs' partition for squashfs"
|
||||
+ default y
|
||||
+
|
||||
config MTD_REDBOOT_PARTS
|
||||
tristate "RedBoot partition table parsing"
|
||||
---help---
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
+#include <linux/root_dev.h>
|
||||
+#include <linux/magic.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
@@ -50,7 +52,7 @@ struct mtd_part {
|
||||
* the pointer to that structure with this macro.
|
||||
*/
|
||||
#define PART(x) ((struct mtd_part *)(x))
|
||||
-
|
||||
+#define IS_PART(mtd) (mtd->read == part_read)
|
||||
|
||||
/*
|
||||
* MTD methods which simply translate the effective address and pass through
|
||||
@@ -650,6 +652,155 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
+#ifdef CONFIG_MTD_ROOTFS_SPLIT
|
||||
+#define ROOTFS_SPLIT_NAME "rootfs_data"
|
||||
+#define ROOTFS_REMOVED_NAME "<removed>"
|
||||
+
|
||||
+struct squashfs_super_block {
|
||||
+ __le32 s_magic;
|
||||
+ __le32 pad0[9];
|
||||
+ __le64 bytes_used;
|
||||
+};
|
||||
+
|
||||
+
|
||||
+static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
|
||||
+{
|
||||
+ struct squashfs_super_block sb;
|
||||
+ int len, ret;
|
||||
+
|
||||
+ ret = master->read(master, offset, sizeof(sb), &len, (void *) &sb);
|
||||
+ if (ret || (len != sizeof(sb))) {
|
||||
+ printk(KERN_ALERT "split_squashfs: error occured while reading "
|
||||
+ "from \"%s\"\n", master->name);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ if (SQUASHFS_MAGIC != le32_to_cpu(sb.s_magic) ) {
|
||||
+ printk(KERN_ALERT "split_squashfs: no squashfs found in \"%s\"\n",
|
||||
+ master->name);
|
||||
+ *split_offset = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (le64_to_cpu((sb.bytes_used)) <= 0) {
|
||||
+ printk(KERN_ALERT "split_squashfs: squashfs is empty in \"%s\"\n",
|
||||
+ master->name);
|
||||
+ *split_offset = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ len = (u32) le64_to_cpu(sb.bytes_used);
|
||||
+ len += (offset & 0x000fffff);
|
||||
+ len += (master->erasesize - 1);
|
||||
+ len &= ~(master->erasesize - 1);
|
||||
+ len -= (offset & 0x000fffff);
|
||||
+ *split_offset = offset + len;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int split_rootfs_data(struct mtd_info *master, struct mtd_info *rpart, const struct mtd_partition *part)
|
||||
+{
|
||||
+ struct mtd_partition *dpart;
|
||||
+ struct mtd_part *slave = NULL;
|
||||
+ struct mtd_part *spart;
|
||||
+ int ret, split_offset = 0;
|
||||
+
|
||||
+ spart = PART(rpart);
|
||||
+ ret = split_squashfs(master, spart->offset, &split_offset);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (split_offset <= 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ dpart = kmalloc(sizeof(*part)+sizeof(ROOTFS_SPLIT_NAME)+1, GFP_KERNEL);
|
||||
+ if (dpart == NULL) {
|
||||
+ printk(KERN_INFO "split_squashfs: no memory for partition \"%s\"\n",
|
||||
+ ROOTFS_SPLIT_NAME);
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(dpart, part, sizeof(*part));
|
||||
+ dpart->name = (unsigned char *)&dpart[1];
|
||||
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME);
|
||||
+
|
||||
+ dpart->size = rpart->size - (split_offset - spart->offset);
|
||||
+ dpart->offset = split_offset;
|
||||
+
|
||||
+ if (dpart == NULL)
|
||||
+ return 1;
|
||||
+
|
||||
+ printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=%llX, len=%llX \n",
|
||||
+ ROOTFS_SPLIT_NAME, dpart->offset, dpart->size);
|
||||
+
|
||||
+ slave = allocate_partition(master, dpart, 0, split_offset);
|
||||
+ if (IS_ERR(slave))
|
||||
+ return PTR_ERR(slave);
|
||||
+ mutex_lock(&mtd_partitions_mutex);
|
||||
+ list_add(&slave->list, &mtd_partitions);
|
||||
+ mutex_unlock(&mtd_partitions_mutex);
|
||||
+
|
||||
+ add_mtd_device(&slave->mtd);
|
||||
+
|
||||
+ rpart->split = &slave->mtd;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int refresh_rootfs_split(struct mtd_info *mtd)
|
||||
+{
|
||||
+ struct mtd_partition tpart;
|
||||
+ struct mtd_part *part;
|
||||
+ char *name;
|
||||
+ //int index = 0;
|
||||
+ int offset, size;
|
||||
+ int ret;
|
||||
+
|
||||
+ part = PART(mtd);
|
||||
+
|
||||
+ /* check for the new squashfs offset first */
|
||||
+ ret = split_squashfs(part->master, part->offset, &offset);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ if ((offset > 0) && !mtd->split) {
|
||||
+ printk(KERN_INFO "%s: creating new split partition for \"%s\"\n", __func__, mtd->name);
|
||||
+ /* if we don't have a rootfs split partition, create a new one */
|
||||
+ tpart.name = (char *) mtd->name;
|
||||
+ tpart.size = mtd->size;
|
||||
+ tpart.offset = part->offset;
|
||||
+
|
||||
+ return split_rootfs_data(part->master, &part->mtd, &tpart);
|
||||
+ } else if ((offset > 0) && mtd->split) {
|
||||
+ /* update the offsets of the existing partition */
|
||||
+ size = mtd->size + part->offset - offset;
|
||||
+
|
||||
+ part = PART(mtd->split);
|
||||
+ part->offset = offset;
|
||||
+ part->mtd.size = size;
|
||||
+ printk(KERN_INFO "%s: %s partition \"" ROOTFS_SPLIT_NAME "\", offset: 0x%06x (0x%06x)\n",
|
||||
+ __func__, (!strcmp(part->mtd.name, ROOTFS_SPLIT_NAME) ? "updating" : "creating"),
|
||||
+ (u32) part->offset, (u32) part->mtd.size);
|
||||
+ name = kmalloc(sizeof(ROOTFS_SPLIT_NAME) + 1, GFP_KERNEL);
|
||||
+ strcpy(name, ROOTFS_SPLIT_NAME);
|
||||
+ part->mtd.name = name;
|
||||
+ } else if ((offset <= 0) && mtd->split) {
|
||||
+ printk(KERN_INFO "%s: removing partition \"%s\"\n", __func__, mtd->split->name);
|
||||
+
|
||||
+ /* mark existing partition as removed */
|
||||
+ part = PART(mtd->split);
|
||||
+ name = kmalloc(sizeof(ROOTFS_SPLIT_NAME) + 1, GFP_KERNEL);
|
||||
+ strcpy(name, ROOTFS_REMOVED_NAME);
|
||||
+ part->mtd.name = name;
|
||||
+ part->offset = 0;
|
||||
+ part->mtd.size = 0;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif /* CONFIG_MTD_ROOTFS_SPLIT */
|
||||
+
|
||||
/*
|
||||
* This function, given a master MTD object and a partition table, creates
|
||||
* and registers slave MTD objects which are bound to the master according to
|
||||
@@ -666,6 +817,9 @@ int add_mtd_partitions(struct mtd_info *
|
||||
struct mtd_part *slave;
|
||||
uint64_t cur_offset = 0;
|
||||
int i;
|
||||
+#ifdef CONFIG_MTD_ROOTFS_SPLIT
|
||||
+ int ret;
|
||||
+#endif
|
||||
|
||||
printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
|
||||
|
||||
@@ -680,12 +834,53 @@ int add_mtd_partitions(struct mtd_info *
|
||||
|
||||
add_mtd_device(&slave->mtd);
|
||||
|
||||
+ if (!strcmp(parts[i].name, "rootfs")) {
|
||||
+#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
|
||||
+ if (ROOT_DEV == 0) {
|
||||
+ printk(KERN_NOTICE "mtd: partition \"rootfs\" "
|
||||
+ "set to be root filesystem\n");
|
||||
+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, slave->mtd.index);
|
||||
+ }
|
||||
+#endif
|
||||
+#ifdef CONFIG_MTD_ROOTFS_SPLIT
|
||||
+ ret = split_rootfs_data(master, &slave->mtd, &parts[i]);
|
||||
+ /* if (ret == 0)
|
||||
+ * j++; */
|
||||
+#endif
|
||||
+ }
|
||||
+
|
||||
cur_offset = slave->offset + slave->mtd.size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int mtd_device_refresh(struct mtd_info *mtd)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ if (IS_PART(mtd)) {
|
||||
+ struct mtd_part *part;
|
||||
+ struct mtd_info *master;
|
||||
+
|
||||
+ part = PART(mtd);
|
||||
+ master = part->master;
|
||||
+ if (master->refresh_device)
|
||||
+ ret = master->refresh_device(master);
|
||||
+ }
|
||||
+
|
||||
+ if (!ret && mtd->refresh_device)
|
||||
+ ret = mtd->refresh_device(mtd);
|
||||
+
|
||||
+#ifdef CONFIG_MTD_ROOTFS_SPLIT
|
||||
+ if (!ret && IS_PART(mtd) && !strcmp(mtd->name, "rootfs"))
|
||||
+ refresh_rootfs_split(mtd);
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(mtd_device_refresh);
|
||||
+
|
||||
static DEFINE_SPINLOCK(part_parser_lock);
|
||||
static LIST_HEAD(part_parsers);
|
||||
|
||||
--- a/drivers/mtd/mtdchar.c
|
||||
+++ b/drivers/mtd/mtdchar.c
|
||||
@@ -1026,6 +1026,12 @@ static int mtd_ioctl(struct file *file,
|
||||
break;
|
||||
}
|
||||
|
||||
+ case MTDREFRESH:
|
||||
+ {
|
||||
+ ret = mtd_device_refresh(mtd);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
}
|
||||
--- a/include/linux/mtd/mtd.h
|
||||
+++ b/include/linux/mtd/mtd.h
|
||||
@@ -114,6 +114,7 @@ struct nand_ecclayout {
|
||||
|
||||
struct module; /* only needed for owner field in mtd_info */
|
||||
|
||||
+struct mtd_info;
|
||||
struct mtd_info {
|
||||
u_char type;
|
||||
uint32_t flags;
|
||||
@@ -266,6 +267,9 @@ struct mtd_info {
|
||||
struct device dev;
|
||||
int usecount;
|
||||
|
||||
+ int (*refresh_device)(struct mtd_info *mtd);
|
||||
+ struct mtd_info *split;
|
||||
+
|
||||
/* If the driver is something smart, like UBI, it may need to maintain
|
||||
* its own reference counting. The below functions are only for driver.
|
||||
* The driver may register its callbacks. These callbacks are not
|
||||
@@ -321,6 +325,7 @@ extern int mtd_device_parse_register(str
|
||||
int defnr_parts);
|
||||
#define mtd_device_register(master, parts, nr_parts) \
|
||||
mtd_device_parse_register(master, NULL, NULL, parts, nr_parts)
|
||||
+extern int mtd_device_refresh(struct mtd_info *master);
|
||||
extern int mtd_device_unregister(struct mtd_info *master);
|
||||
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
|
||||
extern int __get_mtd_device(struct mtd_info *mtd);
|
||||
--- a/include/linux/mtd/partitions.h
|
||||
+++ b/include/linux/mtd/partitions.h
|
||||
@@ -36,12 +36,14 @@
|
||||
* erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK).
|
||||
*/
|
||||
|
||||
+struct mtd_partition;
|
||||
struct mtd_partition {
|
||||
char *name; /* identifier string */
|
||||
uint64_t size; /* partition size */
|
||||
uint64_t offset; /* offset within the master MTD space */
|
||||
uint32_t mask_flags; /* master MTD flags to mask out for this partition */
|
||||
struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */
|
||||
+ int (*refresh_partition)(struct mtd_info *);
|
||||
};
|
||||
|
||||
#define MTDPART_OFS_RETAIN (-3)
|
||||
--- a/include/mtd/mtd-abi.h
|
||||
+++ b/include/mtd/mtd-abi.h
|
||||
@@ -201,6 +201,7 @@ struct otp_info {
|
||||
* modes (see "struct mtd_write_req")
|
||||
*/
|
||||
#define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
|
||||
+#define MTDREFRESH _IO('M', 50)
|
||||
|
||||
/*
|
||||
* Obsolete legacy interface. Keep it in order not to break userspace
|
|
@ -1,145 +0,0 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include "mtdcore.h"
|
||||
|
||||
+#define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an erase block */
|
||||
+
|
||||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
static DEFINE_MUTEX(mtd_partitions_mutex);
|
||||
@@ -258,13 +260,60 @@ static int part_erase(struct mtd_info *m
|
||||
return -EROFS;
|
||||
if (instr->addr >= mtd->size)
|
||||
return -EINVAL;
|
||||
+
|
||||
+ instr->partial_start = false;
|
||||
+ if (mtd->flags & MTD_ERASE_PARTIAL) {
|
||||
+ size_t readlen = 0;
|
||||
+ u64 mtd_ofs;
|
||||
+
|
||||
+ instr->erase_buf = kmalloc(part->master->erasesize, GFP_ATOMIC);
|
||||
+ if (!instr->erase_buf)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ mtd_ofs = part->offset + instr->addr;
|
||||
+ instr->erase_buf_ofs = do_div(mtd_ofs, part->master->erasesize);
|
||||
+
|
||||
+ if (instr->erase_buf_ofs > 0) {
|
||||
+ instr->addr -= instr->erase_buf_ofs;
|
||||
+ ret = part->master->read(part->master,
|
||||
+ instr->addr + part->offset,
|
||||
+ part->master->erasesize,
|
||||
+ &readlen, instr->erase_buf);
|
||||
+
|
||||
+ instr->partial_start = true;
|
||||
+ } else {
|
||||
+ mtd_ofs = part->offset + part->mtd.size;
|
||||
+ instr->erase_buf_ofs = part->master->erasesize -
|
||||
+ do_div(mtd_ofs, part->master->erasesize);
|
||||
+
|
||||
+ if (instr->erase_buf_ofs > 0) {
|
||||
+ instr->len += instr->erase_buf_ofs;
|
||||
+ ret = part->master->read(part->master,
|
||||
+ part->offset + instr->addr +
|
||||
+ instr->len - part->master->erasesize,
|
||||
+ part->master->erasesize, &readlen,
|
||||
+ instr->erase_buf);
|
||||
+ } else {
|
||||
+ ret = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ if (ret < 0) {
|
||||
+ kfree(instr->erase_buf);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
instr->addr += part->offset;
|
||||
ret = part->master->erase(part->master, instr);
|
||||
if (ret) {
|
||||
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
|
||||
instr->fail_addr -= part->offset;
|
||||
instr->addr -= part->offset;
|
||||
+ if (mtd->flags & MTD_ERASE_PARTIAL)
|
||||
+ kfree(instr->erase_buf);
|
||||
}
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -272,7 +321,25 @@ void mtd_erase_callback(struct erase_inf
|
||||
{
|
||||
if (instr->mtd->erase == part_erase) {
|
||||
struct mtd_part *part = PART(instr->mtd);
|
||||
+ size_t wrlen = 0;
|
||||
|
||||
+ if (instr->mtd->flags & MTD_ERASE_PARTIAL) {
|
||||
+ if (instr->partial_start) {
|
||||
+ part->master->write(part->master,
|
||||
+ instr->addr, instr->erase_buf_ofs,
|
||||
+ &wrlen, instr->erase_buf);
|
||||
+ instr->addr += instr->erase_buf_ofs;
|
||||
+ } else {
|
||||
+ instr->len -= instr->erase_buf_ofs;
|
||||
+ part->master->write(part->master,
|
||||
+ instr->addr + instr->len,
|
||||
+ instr->erase_buf_ofs, &wrlen,
|
||||
+ instr->erase_buf +
|
||||
+ part->master->erasesize -
|
||||
+ instr->erase_buf_ofs);
|
||||
+ }
|
||||
+ kfree(instr->erase_buf);
|
||||
+ }
|
||||
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
|
||||
instr->fail_addr -= part->offset;
|
||||
instr->addr -= part->offset;
|
||||
@@ -543,18 +610,24 @@ static struct mtd_part *allocate_partiti
|
||||
if ((slave->mtd.flags & MTD_WRITEABLE) &&
|
||||
mtd_mod_by_eb(slave->offset, &slave->mtd)) {
|
||||
/* Doesn't start on a boundary of major erase size */
|
||||
- /* FIXME: Let it be writable if it is on a boundary of
|
||||
- * _minor_ erase size though */
|
||||
- slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
- printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
|
||||
- part->name);
|
||||
+ slave->mtd.flags |= MTD_ERASE_PARTIAL;
|
||||
+ if (((u32) slave->mtd.size) > master->erasesize)
|
||||
+ slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
+ else
|
||||
+ slave->mtd.erasesize = slave->mtd.size;
|
||||
}
|
||||
if ((slave->mtd.flags & MTD_WRITEABLE) &&
|
||||
- mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) {
|
||||
- slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
- printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
|
||||
- part->name);
|
||||
+ mtd_mod_by_eb(slave->offset + slave->mtd.size, &slave->mtd)) {
|
||||
+ slave->mtd.flags |= MTD_ERASE_PARTIAL;
|
||||
+
|
||||
+ if ((u32) slave->mtd.size > master->erasesize)
|
||||
+ slave->mtd.flags &= ~MTD_WRITEABLE;
|
||||
+ else
|
||||
+ slave->mtd.erasesize = slave->mtd.size;
|
||||
}
|
||||
+ if ((slave->mtd.flags & (MTD_ERASE_PARTIAL|MTD_WRITEABLE)) == MTD_ERASE_PARTIAL)
|
||||
+ printk(KERN_WARNING"mtd: partition \"%s\" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only\n",
|
||||
+ part->name);
|
||||
|
||||
slave->mtd.ecclayout = master->ecclayout;
|
||||
if (master->block_isbad) {
|
||||
--- a/include/linux/mtd/mtd.h
|
||||
+++ b/include/linux/mtd/mtd.h
|
||||
@@ -58,6 +58,10 @@ struct erase_info {
|
||||
u_long priv;
|
||||
u_char state;
|
||||
struct erase_info *next;
|
||||
+
|
||||
+ u8 *erase_buf;
|
||||
+ u32 erase_buf_ofs;
|
||||
+ bool partial_start;
|
||||
};
|
||||
|
||||
struct mtd_erase_region_info {
|
|
@ -1,18 +0,0 @@
|
|||
--- a/include/linux/mtd/partitions.h
|
||||
+++ b/include/linux/mtd/partitions.h
|
||||
@@ -35,6 +35,7 @@
|
||||
* Note: writeable partitions require their size and offset be
|
||||
* erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK).
|
||||
*/
|
||||
+struct mtd_info;
|
||||
|
||||
struct mtd_partition;
|
||||
struct mtd_partition {
|
||||
@@ -52,7 +53,6 @@ struct mtd_partition {
|
||||
#define MTDPART_SIZ_FULL (0)
|
||||
|
||||
|
||||
-struct mtd_info;
|
||||
struct device_node;
|
||||
|
||||
/**
|
|
@ -1,30 +0,0 @@
|
|||
--- a/drivers/mtd/redboot.c
|
||||
+++ b/drivers/mtd/redboot.c
|
||||
@@ -267,14 +267,21 @@ static int parse_redboot_partitions(stru
|
||||
#endif
|
||||
names += strlen(names)+1;
|
||||
|
||||
-#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
|
||||
if(fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) {
|
||||
- i++;
|
||||
- parts[i].offset = parts[i-1].size + parts[i-1].offset;
|
||||
- parts[i].size = fl->next->img->flash_base - parts[i].offset;
|
||||
- parts[i].name = nullname;
|
||||
- }
|
||||
+ if (!strcmp(parts[i].name, "rootfs")) {
|
||||
+ parts[i].size = fl->next->img->flash_base;
|
||||
+ parts[i].size &= ~(master->erasesize - 1);
|
||||
+ parts[i].size -= parts[i].offset;
|
||||
+#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
|
||||
+ nrparts--;
|
||||
+ } else {
|
||||
+ i++;
|
||||
+ parts[i].offset = parts[i-1].size + parts[i-1].offset;
|
||||
+ parts[i].size = fl->next->img->flash_base - parts[i].offset;
|
||||
+ parts[i].name = nullname;
|
||||
#endif
|
||||
+ }
|
||||
+ }
|
||||
tmp_fl = fl;
|
||||
fl = fl->next;
|
||||
kfree(tmp_fl);
|
|
@ -1,60 +0,0 @@
|
|||
--- a/drivers/mtd/redboot.c
|
||||
+++ b/drivers/mtd/redboot.c
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <linux/mtd/partitions.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
+#define BOARD_CONFIG_PART "boardconfig"
|
||||
+
|
||||
struct fis_image_desc {
|
||||
unsigned char name[16]; // Null terminated name
|
||||
uint32_t flash_base; // Address within FLASH of image
|
||||
@@ -60,6 +62,7 @@ static int parse_redboot_partitions(stru
|
||||
struct mtd_partition **pparts,
|
||||
struct mtd_part_parser_data *data)
|
||||
{
|
||||
+ unsigned long max_offset = 0;
|
||||
int nrparts = 0;
|
||||
struct fis_image_desc *buf;
|
||||
struct mtd_partition *parts;
|
||||
@@ -227,14 +230,14 @@ static int parse_redboot_partitions(stru
|
||||
}
|
||||
}
|
||||
#endif
|
||||
- parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
|
||||
+ parts = kzalloc(sizeof(*parts) * (nrparts + 1) + nulllen + namelen + sizeof(BOARD_CONFIG_PART), GFP_KERNEL);
|
||||
|
||||
if (!parts) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
- nullname = (char *)&parts[nrparts];
|
||||
+ nullname = (char *)&parts[nrparts + 1];
|
||||
#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
|
||||
if (nulllen > 0) {
|
||||
strcpy(nullname, nullstring);
|
||||
@@ -253,6 +256,8 @@ static int parse_redboot_partitions(stru
|
||||
}
|
||||
#endif
|
||||
for ( ; i<nrparts; i++) {
|
||||
+ if(max_offset < buf[i].flash_base + buf[i].size)
|
||||
+ max_offset = buf[i].flash_base + buf[i].size;
|
||||
parts[i].size = fl->img->size;
|
||||
parts[i].offset = fl->img->flash_base;
|
||||
parts[i].name = names;
|
||||
@@ -286,6 +291,14 @@ static int parse_redboot_partitions(stru
|
||||
fl = fl->next;
|
||||
kfree(tmp_fl);
|
||||
}
|
||||
+ if(master->size - max_offset >= master->erasesize)
|
||||
+ {
|
||||
+ parts[nrparts].size = master->size - max_offset;
|
||||
+ parts[nrparts].offset = max_offset;
|
||||
+ parts[nrparts].name = names;
|
||||
+ strcpy(names, BOARD_CONFIG_PART);
|
||||
+ nrparts++;
|
||||
+ }
|
||||
ret = nrparts;
|
||||
*pparts = parts;
|
||||
out:
|
|
@ -1,35 +0,0 @@
|
|||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -148,6 +148,22 @@ config MTD_AR7_PARTS
|
||||
---help---
|
||||
TI AR7 partitioning support
|
||||
|
||||
+config MTD_MYLOADER_PARTS
|
||||
+ tristate "MyLoader partition parsing"
|
||||
+ depends on ADM5120 || ATHEROS_AR231X || ATHEROS_AR71XX || ATH79
|
||||
+ ---help---
|
||||
+ MyLoader is a bootloader which allows the user to define partitions
|
||||
+ in flash devices, by putting a table in the second erase block
|
||||
+ on the device, similar to a partition table. This table gives the
|
||||
+ offsets and lengths of the user defined partitions.
|
||||
+
|
||||
+ If you need code which can detect and parse these tables, and
|
||||
+ register MTD 'partitions' corresponding to each image detected,
|
||||
+ enable this option.
|
||||
+
|
||||
+ You will still need the parsing functions to be called by the driver
|
||||
+ for your particular device. It won't happen automatically.
|
||||
+
|
||||
comment "User Modules And Translation Layers"
|
||||
|
||||
config MTD_CHAR
|
||||
--- a/drivers/mtd/Makefile
|
||||
+++ b/drivers/mtd/Makefile
|
||||
@@ -11,6 +11,7 @@ obj-$(CONFIG_MTD_REDBOOT_PARTS) += redbo
|
||||
obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
|
||||
obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
|
||||
obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o
|
||||
+obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o
|
||||
|
||||
# 'Users' - code which presents functionality to userspace.
|
||||
obj-$(CONFIG_MTD_CHAR) += mtdchar.o
|
|
@ -1,116 +0,0 @@
|
|||
--- a/drivers/mtd/devices/block2mtd.c
|
||||
+++ b/drivers/mtd/devices/block2mtd.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <linux/list.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
+#include <linux/mtd/partitions.h>
|
||||
#include <linux/buffer_head.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/mount.h>
|
||||
@@ -232,11 +233,12 @@ static void block2mtd_free_device(struct
|
||||
|
||||
|
||||
/* FIXME: ensure that mtd->size % erase_size == 0 */
|
||||
-static struct block2mtd_dev *add_device(char *devname, int erase_size)
|
||||
+static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
|
||||
{
|
||||
const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
|
||||
struct block_device *bdev;
|
||||
struct block2mtd_dev *dev;
|
||||
+ struct mtd_partition *part;
|
||||
char *name;
|
||||
|
||||
if (!devname)
|
||||
@@ -275,13 +277,16 @@ static struct block2mtd_dev *add_device(
|
||||
|
||||
/* Setup the MTD structure */
|
||||
/* make the name contain the block device in */
|
||||
- name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
|
||||
+ if (!mtdname)
|
||||
+ mtdname = devname;
|
||||
+ name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
|
||||
if (!name)
|
||||
goto devinit_err;
|
||||
|
||||
+ strcpy(name, mtdname);
|
||||
dev->mtd.name = name;
|
||||
|
||||
- dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
|
||||
+ dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1);
|
||||
dev->mtd.erasesize = erase_size;
|
||||
dev->mtd.writesize = 1;
|
||||
dev->mtd.writebufsize = PAGE_SIZE;
|
||||
@@ -295,14 +300,17 @@ static struct block2mtd_dev *add_device(
|
||||
dev->mtd.priv = dev;
|
||||
dev->mtd.owner = THIS_MODULE;
|
||||
|
||||
- if (mtd_device_register(&dev->mtd, NULL, 0)) {
|
||||
+ part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
|
||||
+ part->name = name;
|
||||
+ part->offset = 0;
|
||||
+ part->size = dev->mtd.size;
|
||||
+ if (mtd_device_register(&dev->mtd, part, 1)) {
|
||||
/* Device didn't get added, so free the entry */
|
||||
goto devinit_err;
|
||||
}
|
||||
list_add(&dev->list, &blkmtd_device_list);
|
||||
INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index,
|
||||
- dev->mtd.name + strlen("block2mtd: "),
|
||||
- dev->mtd.erasesize >> 10, dev->mtd.erasesize);
|
||||
+ mtdname, dev->mtd.erasesize >> 10, dev->mtd.erasesize);
|
||||
return dev;
|
||||
|
||||
devinit_err:
|
||||
@@ -375,9 +383,9 @@ static char block2mtd_paramline[80 + 12]
|
||||
|
||||
static int block2mtd_setup2(const char *val)
|
||||
{
|
||||
- char buf[80 + 12]; /* 80 for device, 12 for erase size */
|
||||
+ char buf[80 + 12 + 80]; /* 80 for device, 12 for erase size, 80 for name */
|
||||
char *str = buf;
|
||||
- char *token[2];
|
||||
+ char *token[3];
|
||||
char *name;
|
||||
size_t erase_size = PAGE_SIZE;
|
||||
int i, ret;
|
||||
@@ -388,7 +396,7 @@ static int block2mtd_setup2(const char *
|
||||
strcpy(str, val);
|
||||
kill_final_newline(str);
|
||||
|
||||
- for (i = 0; i < 2; i++)
|
||||
+ for (i = 0; i < 3; i++)
|
||||
token[i] = strsep(&str, ",");
|
||||
|
||||
if (str)
|
||||
@@ -407,8 +415,10 @@ static int block2mtd_setup2(const char *
|
||||
parse_err("illegal erase size");
|
||||
}
|
||||
}
|
||||
+ if (token[2] && (strlen(token[2]) + 1 > 80))
|
||||
+ parse_err("mtd device name too long");
|
||||
|
||||
- add_device(name, erase_size);
|
||||
+ add_device(name, erase_size, token[2]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -442,7 +452,7 @@ static int block2mtd_setup(const char *v
|
||||
|
||||
|
||||
module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
|
||||
-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
|
||||
+MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
|
||||
|
||||
static int __init block2mtd_init(void)
|
||||
{
|
||||
--- a/fs/partitions/check.c
|
||||
+++ b/fs/partitions/check.c
|
||||
@@ -696,6 +696,7 @@ int invalidate_partitions(struct gendisk
|
||||
|
||||
return 0;
|
||||
}
|
||||
+EXPORT_SYMBOL(rescan_partitions);
|
||||
|
||||
unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p)
|
||||
{
|
|
@ -1,291 +0,0 @@
|
|||
--- a/drivers/mtd/devices/block2mtd.c
|
||||
+++ b/drivers/mtd/devices/block2mtd.c
|
||||
@@ -30,6 +30,8 @@ struct block2mtd_dev {
|
||||
struct block_device *blkdev;
|
||||
struct mtd_info mtd;
|
||||
struct mutex write_mutex;
|
||||
+ rwlock_t bdev_mutex;
|
||||
+ char devname[0];
|
||||
};
|
||||
|
||||
|
||||
@@ -82,6 +84,12 @@ static int block2mtd_erase(struct mtd_in
|
||||
size_t len = instr->len;
|
||||
int err;
|
||||
|
||||
+ read_lock(&dev->bdev_mutex);
|
||||
+ if (!dev->blkdev) {
|
||||
+ err = -EINVAL;
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
instr->state = MTD_ERASING;
|
||||
mutex_lock(&dev->write_mutex);
|
||||
err = _block2mtd_erase(dev, from, len);
|
||||
@@ -93,6 +101,10 @@ static int block2mtd_erase(struct mtd_in
|
||||
instr->state = MTD_ERASE_DONE;
|
||||
|
||||
mtd_erase_callback(instr);
|
||||
+
|
||||
+done:
|
||||
+ read_unlock(&dev->bdev_mutex);
|
||||
+
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -104,10 +116,14 @@ static int block2mtd_read(struct mtd_inf
|
||||
struct page *page;
|
||||
int index = from >> PAGE_SHIFT;
|
||||
int offset = from & (PAGE_SIZE-1);
|
||||
- int cpylen;
|
||||
+ int cpylen, err = 0;
|
||||
+
|
||||
+ read_lock(&dev->bdev_mutex);
|
||||
+ if (!dev->blkdev || (from > mtd->size)) {
|
||||
+ err = -EINVAL;
|
||||
+ goto done;
|
||||
+ }
|
||||
|
||||
- if (from > mtd->size)
|
||||
- return -EINVAL;
|
||||
if (from + len > mtd->size)
|
||||
len = mtd->size - from;
|
||||
|
||||
@@ -122,10 +138,14 @@ static int block2mtd_read(struct mtd_inf
|
||||
len = len - cpylen;
|
||||
|
||||
page = page_read(dev->blkdev->bd_inode->i_mapping, index);
|
||||
- if (!page)
|
||||
- return -ENOMEM;
|
||||
- if (IS_ERR(page))
|
||||
- return PTR_ERR(page);
|
||||
+ if (!page) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto done;
|
||||
+ }
|
||||
+ if (IS_ERR(page)) {
|
||||
+ err = PTR_ERR(page);
|
||||
+ goto done;
|
||||
+ }
|
||||
|
||||
memcpy(buf, page_address(page) + offset, cpylen);
|
||||
page_cache_release(page);
|
||||
@@ -136,7 +156,10 @@ static int block2mtd_read(struct mtd_inf
|
||||
offset = 0;
|
||||
index++;
|
||||
}
|
||||
- return 0;
|
||||
+
|
||||
+done:
|
||||
+ read_unlock(&dev->bdev_mutex);
|
||||
+ return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,12 +211,22 @@ static int block2mtd_write(struct mtd_in
|
||||
size_t *retlen, const u_char *buf)
|
||||
{
|
||||
struct block2mtd_dev *dev = mtd->priv;
|
||||
- int err;
|
||||
+ int err = 0;
|
||||
+
|
||||
+ read_lock(&dev->bdev_mutex);
|
||||
+ if (!dev->blkdev) {
|
||||
+ err = -EINVAL;
|
||||
+ goto done;
|
||||
+ }
|
||||
|
||||
if (!len)
|
||||
- return 0;
|
||||
- if (to >= mtd->size)
|
||||
- return -ENOSPC;
|
||||
+ goto done;
|
||||
+
|
||||
+ if (to >= mtd->size) {
|
||||
+ err = -ENOSPC;
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
if (to + len > mtd->size)
|
||||
len = mtd->size - to;
|
||||
|
||||
@@ -202,6 +235,9 @@ static int block2mtd_write(struct mtd_in
|
||||
mutex_unlock(&dev->write_mutex);
|
||||
if (err > 0)
|
||||
err = 0;
|
||||
+
|
||||
+done:
|
||||
+ read_unlock(&dev->bdev_mutex);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -210,33 +246,110 @@ static int block2mtd_write(struct mtd_in
|
||||
static void block2mtd_sync(struct mtd_info *mtd)
|
||||
{
|
||||
struct block2mtd_dev *dev = mtd->priv;
|
||||
+ read_lock(&dev->bdev_mutex);
|
||||
+ if (dev->blkdev)
|
||||
sync_blockdev(dev->blkdev);
|
||||
+ read_unlock(&dev->bdev_mutex);
|
||||
+
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+static int _open_bdev(struct block2mtd_dev *dev)
|
||||
+{
|
||||
+ const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
|
||||
+ struct block_device *bdev;
|
||||
+
|
||||
+ /* Get a handle on the device */
|
||||
+ bdev = blkdev_get_by_path(dev->devname, mode, dev);
|
||||
+#ifndef MODULE
|
||||
+ if (IS_ERR(bdev)) {
|
||||
+ dev_t devt;
|
||||
+
|
||||
+ /* We might not have rootfs mounted at this point. Try
|
||||
+ to resolve the device name by other means. */
|
||||
+
|
||||
+ devt = name_to_dev_t(dev->devname);
|
||||
+ if (devt)
|
||||
+ bdev = blkdev_get_by_dev(devt, mode, dev);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ if (IS_ERR(bdev)) {
|
||||
+ ERROR("error: cannot open device %s", dev->devname);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ dev->blkdev = bdev;
|
||||
+
|
||||
+ if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
|
||||
+ ERROR("attempting to use an MTD device as a block device");
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void _close_bdev(struct block2mtd_dev *dev)
|
||||
+{
|
||||
+ struct block_device *bdev;
|
||||
+
|
||||
+ if (!dev->blkdev)
|
||||
+ return;
|
||||
+
|
||||
+ bdev = dev->blkdev;
|
||||
+ invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping, 0, -1);
|
||||
+ blkdev_put(dev->blkdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
|
||||
+ dev->blkdev = NULL;
|
||||
+}
|
||||
+
|
||||
static void block2mtd_free_device(struct block2mtd_dev *dev)
|
||||
{
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
kfree(dev->mtd.name);
|
||||
-
|
||||
- if (dev->blkdev) {
|
||||
- invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping,
|
||||
- 0, -1);
|
||||
- blkdev_put(dev->blkdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
|
||||
- }
|
||||
-
|
||||
+ _close_bdev(dev);
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
|
||||
-/* FIXME: ensure that mtd->size % erase_size == 0 */
|
||||
-static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
|
||||
+static int block2mtd_refresh(struct mtd_info *mtd)
|
||||
{
|
||||
- const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
|
||||
+ struct block2mtd_dev *dev = mtd->priv;
|
||||
struct block_device *bdev;
|
||||
+ dev_t devt;
|
||||
+ int err = 0;
|
||||
+
|
||||
+ /* no other mtd function can run at this point */
|
||||
+ write_lock(&dev->bdev_mutex);
|
||||
+
|
||||
+ /* get the device number for the whole disk */
|
||||
+ devt = MKDEV(MAJOR(dev->blkdev->bd_dev), 0);
|
||||
+
|
||||
+ /* close the old block device */
|
||||
+ _close_bdev(dev);
|
||||
+
|
||||
+ /* open the whole disk, issue a partition rescan, then */
|
||||
+ bdev = blkdev_get_by_dev(devt, FMODE_WRITE | FMODE_READ, mtd);
|
||||
+ if (!bdev || !bdev->bd_disk)
|
||||
+ err = -EINVAL;
|
||||
+#ifndef CONFIG_MTD_BLOCK2MTD_MODULE
|
||||
+ else
|
||||
+ err = rescan_partitions(bdev->bd_disk, bdev);
|
||||
+#endif
|
||||
+ if (bdev)
|
||||
+ blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
|
||||
+
|
||||
+ /* try to open the partition block device again */
|
||||
+ _open_bdev(dev);
|
||||
+ write_unlock(&dev->bdev_mutex);
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+/* FIXME: ensure that mtd->size % erase_size == 0 */
|
||||
+static struct block2mtd_dev *add_device(char *devname, int erase_size, char *mtdname)
|
||||
+{
|
||||
struct block2mtd_dev *dev;
|
||||
struct mtd_partition *part;
|
||||
char *name;
|
||||
@@ -244,36 +357,17 @@ static struct block2mtd_dev *add_device(
|
||||
if (!devname)
|
||||
return NULL;
|
||||
|
||||
- dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
|
||||
+ dev = kzalloc(sizeof(struct block2mtd_dev) + strlen(devname) + 1, GFP_KERNEL);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
||||
- /* Get a handle on the device */
|
||||
- bdev = blkdev_get_by_path(devname, mode, dev);
|
||||
-#ifndef MODULE
|
||||
- if (IS_ERR(bdev)) {
|
||||
-
|
||||
- /* We might not have rootfs mounted at this point. Try
|
||||
- to resolve the device name by other means. */
|
||||
+ strcpy(dev->devname, devname);
|
||||
|
||||
- dev_t devt = name_to_dev_t(devname);
|
||||
- if (devt)
|
||||
- bdev = blkdev_get_by_dev(devt, mode, dev);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
- if (IS_ERR(bdev)) {
|
||||
- ERROR("error: cannot open device %s", devname);
|
||||
+ if (_open_bdev(dev))
|
||||
goto devinit_err;
|
||||
- }
|
||||
- dev->blkdev = bdev;
|
||||
-
|
||||
- if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
|
||||
- ERROR("attempting to use an MTD device as a block device");
|
||||
- goto devinit_err;
|
||||
- }
|
||||
|
||||
mutex_init(&dev->write_mutex);
|
||||
+ rwlock_init(&dev->bdev_mutex);
|
||||
|
||||
/* Setup the MTD structure */
|
||||
/* make the name contain the block device in */
|
||||
@@ -299,6 +393,7 @@ static struct block2mtd_dev *add_device(
|
||||
dev->mtd.read = block2mtd_read;
|
||||
dev->mtd.priv = dev;
|
||||
dev->mtd.owner = THIS_MODULE;
|
||||
+ dev->mtd.refresh_device = block2mtd_refresh;
|
||||
|
||||
part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
|
||||
part->name = name;
|
|
@ -1,10 +0,0 @@
|
|||
--- a/drivers/mtd/devices/block2mtd.c
|
||||
+++ b/drivers/mtd/devices/block2mtd.c
|
||||
@@ -269,6 +269,7 @@ static int _open_bdev(struct block2mtd_d
|
||||
/* We might not have rootfs mounted at this point. Try
|
||||
to resolve the device name by other means. */
|
||||
|
||||
+ wait_for_device_probe();
|
||||
devt = name_to_dev_t(dev->devname);
|
||||
if (devt)
|
||||
bdev = blkdev_get_by_dev(devt, mode, dev);
|
|
@ -1,37 +0,0 @@
|
|||
---
|
||||
drivers/mtd/nand/plat_nand.c | 13 ++++++++++++-
|
||||
include/linux/mtd/nand.h | 1 +
|
||||
2 files changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/include/linux/mtd/nand.h
|
||||
+++ b/include/linux/mtd/nand.h
|
||||
@@ -621,6 +621,7 @@ struct platform_nand_chip {
|
||||
unsigned int options;
|
||||
unsigned int bbt_options;
|
||||
const char **part_probe_types;
|
||||
+ int (*chip_fixup)(struct mtd_info *mtd);
|
||||
};
|
||||
|
||||
/* Keep gcc happy */
|
||||
--- a/drivers/mtd/nand/plat_nand.c
|
||||
+++ b/drivers/mtd/nand/plat_nand.c
|
||||
@@ -93,7 +93,18 @@ static int __devinit plat_nand_probe(str
|
||||
}
|
||||
|
||||
/* Scan to find existence of the device */
|
||||
- if (nand_scan(&data->mtd, pdata->chip.nr_chips)) {
|
||||
+ if (nand_scan_ident(&data->mtd, pdata->chip.nr_chips, NULL)) {
|
||||
+ res = -ENXIO;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (pdata->chip.chip_fixup) {
|
||||
+ res = pdata->chip.chip_fixup(&data->mtd);
|
||||
+ if (res)
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (nand_scan_tail(&data->mtd)) {
|
||||
err = -ENXIO;
|
||||
goto out;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
--- a/drivers/mtd/nand/nand_ecc.c
|
||||
+++ b/drivers/mtd/nand/nand_ecc.c
|
||||
@@ -507,8 +507,7 @@ int __nand_correct_data(unsigned char *b
|
||||
if ((bitsperbyte[b0] + bitsperbyte[b1] + bitsperbyte[b2]) == 1)
|
||||
return 1; /* error in ECC data; no action needed */
|
||||
|
||||
- printk(KERN_ERR "uncorrectable error : ");
|
||||
- return -1;
|
||||
+ return -EBADMSG;
|
||||
}
|
||||
EXPORT_SYMBOL(__nand_correct_data);
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
@@ -682,7 +682,7 @@ static int get_chip(struct map_info *map
|
||||
return 0;
|
||||
|
||||
case FL_ERASING:
|
||||
- if (!cfip || !(cfip->EraseSuspend & (0x1|0x2)) ||
|
||||
+ if (1 /* no suspend */ || !cfip || !(cfip->EraseSuspend & (0x1|0x2)) ||
|
||||
!(mode == FL_READY || mode == FL_POINT ||
|
||||
(mode == FL_WRITING && (cfip->EraseSuspend & 0x2))))
|
||||
goto sleep;
|
|
@ -1,39 +0,0 @@
|
|||
--- a/drivers/mtd/devices/m25p80.c
|
||||
+++ b/drivers/mtd/devices/m25p80.c
|
||||
@@ -45,6 +45,7 @@
|
||||
#define OPCODE_BE_4K 0x20 /* Erase 4KiB block */
|
||||
#define OPCODE_BE_32K 0x52 /* Erase 32KiB block */
|
||||
#define OPCODE_CHIP_ERASE 0xc7 /* Erase whole flash chip */
|
||||
+#define OPCODE_BE_4K_PMC 0xd7 /* Erase 4KiB block on PMC chips*/
|
||||
#define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */
|
||||
#define OPCODE_RDID 0x9f /* Read JEDEC ID */
|
||||
|
||||
@@ -625,6 +626,7 @@ struct flash_info {
|
||||
u16 flags;
|
||||
#define SECT_4K 0x01 /* OPCODE_BE_4K works uniformly */
|
||||
#define M25P_NO_ERASE 0x02 /* No erase command needed */
|
||||
+#define SECT_4K_PMC 0x04 /* OPCODE_BE_4K_PMC works uniformly */
|
||||
};
|
||||
|
||||
#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags) \
|
||||
@@ -686,6 +688,10 @@ static const struct spi_device_id m25p_i
|
||||
{ "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
|
||||
{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
|
||||
|
||||
+ /* PMC -- pm25x "blocks" are 32K, sectors are 4K */
|
||||
+ { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) },
|
||||
+ { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) },
|
||||
+
|
||||
/* Spansion -- single (large) sector size only, at least
|
||||
* for the chips listed here (without boot sectors).
|
||||
*/
|
||||
@@ -921,6 +927,9 @@ static int __devinit m25p_probe(struct s
|
||||
if (info->flags & SECT_4K) {
|
||||
flash->erase_opcode = OPCODE_BE_4K;
|
||||
flash->mtd.erasesize = 4096;
|
||||
+ } else if (info->flags & SECT_4K_PMC) {
|
||||
+ flash->erase_opcode = OPCODE_BE_4K_PMC;
|
||||
+ flash->mtd.erasesize = 4096;
|
||||
} else {
|
||||
flash->erase_opcode = OPCODE_SE;
|
||||
flash->mtd.erasesize = info->sector_size;
|
|
@ -1,10 +0,0 @@
|
|||
--- a/drivers/mtd/devices/m25p80.c
|
||||
+++ b/drivers/mtd/devices/m25p80.c
|
||||
@@ -765,6 +765,7 @@ static const struct spi_device_id m25p_i
|
||||
{ "w25q32", INFO(0xef4016, 0, 64 * 1024, 64, SECT_4K) },
|
||||
{ "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) },
|
||||
{ "w25q64", INFO(0xef4017, 0, 64 * 1024, 128, SECT_4K) },
|
||||
+ { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
|
||||
|
||||
/* Catalyst / On Semiconductor -- non-JEDEC */
|
||||
{ "cat25c11", CAT25_INFO( 16, 8, 16, 1) },
|
|
@ -1,12 +0,0 @@
|
|||
--- a/drivers/mtd/mtdconcat.c
|
||||
+++ b/drivers/mtd/mtdconcat.c
|
||||
@@ -619,7 +619,8 @@ static void concat_sync(struct mtd_info
|
||||
|
||||
for (i = 0; i < concat->num_subdev; i++) {
|
||||
struct mtd_info *subdev = concat->subdev[i];
|
||||
- subdev->sync(subdev);
|
||||
+ if (subdev->sync)
|
||||
+ subdev->sync(subdev);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
From: George Kashperko <george@znau.edu.ua>
|
||||
|
||||
Issue map read after Write Buffer Load command to ensure chip is ready
|
||||
to receive data.
|
||||
Signed-off-by: George Kashperko <george@znau.edu.ua>
|
||||
---
|
||||
drivers/mtd/chips/cfi_cmdset_0002.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
|
||||
@@ -1409,6 +1409,7 @@ static int __xipram do_write_buffer(stru
|
||||
|
||||
/* Write Buffer Load */
|
||||
map_write(map, CMD(0x25), cmd_adr);
|
||||
+ (void) map_read(map, cmd_adr);
|
||||
|
||||
chip->state = FL_WRITING_TO_BUFFER;
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
--- a/drivers/mtd/devices/Kconfig
|
||||
+++ b/drivers/mtd/devices/Kconfig
|
||||
@@ -102,6 +102,14 @@ config M25PXX_USE_FAST_READ
|
||||
help
|
||||
This option enables FAST_READ access supported by ST M25Pxx.
|
||||
|
||||
+config M25PXX_PREFER_SMALL_SECTOR_ERASE
|
||||
+ bool "Prefer small sector erase"
|
||||
+ depends on MTD_M25P80
|
||||
+ default y
|
||||
+ help
|
||||
+ This option enables use of the small erase sectors if that is
|
||||
+ supported by the flash chip.
|
||||
+
|
||||
config MTD_SST25L
|
||||
tristate "Support SST25L (non JEDEC) SPI Flash chips"
|
||||
depends on SPI_MASTER
|
||||
--- a/drivers/mtd/devices/m25p80.c
|
||||
+++ b/drivers/mtd/devices/m25p80.c
|
||||
@@ -84,6 +84,12 @@
|
||||
|
||||
#define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16)
|
||||
|
||||
+#ifdef CONFIG_M25PXX_PREFER_SMALL_SECTOR_ERASE
|
||||
+#define PREFER_SMALL_SECTOR_ERASE 1
|
||||
+#else
|
||||
+#define PREFER_SMALL_SECTOR_ERASE 0
|
||||
+#endif
|
||||
+
|
||||
/****************************************************************************/
|
||||
|
||||
struct m25p {
|
||||
@@ -925,7 +931,7 @@ static int __devinit m25p_probe(struct s
|
||||
flash->mtd.write = m25p80_write;
|
||||
|
||||
/* prefer "small sector" erase if possible */
|
||||
- if (info->flags & SECT_4K) {
|
||||
+ if (PREFER_SMALL_SECTOR_ERASE && (info->flags & SECT_4K)) {
|
||||
flash->erase_opcode = OPCODE_BE_4K;
|
||||
flash->mtd.erasesize = 4096;
|
||||
} else if (info->flags & SECT_4K_PMC) {
|
|
@ -1,18 +0,0 @@
|
|||
--- a/fs/Kconfig
|
||||
+++ b/fs/Kconfig
|
||||
@@ -35,6 +35,7 @@ source "fs/gfs2/Kconfig"
|
||||
source "fs/ocfs2/Kconfig"
|
||||
source "fs/btrfs/Kconfig"
|
||||
source "fs/nilfs2/Kconfig"
|
||||
+source "fs/yaffs2/Kconfig"
|
||||
|
||||
endif # BLOCK
|
||||
|
||||
--- a/fs/Makefile
|
||||
+++ b/fs/Makefile
|
||||
@@ -124,3 +124,5 @@ obj-$(CONFIG_GFS2_FS) += gfs2/
|
||||
obj-y += exofs/ # Multiple modules
|
||||
obj-$(CONFIG_CEPH_FS) += ceph/
|
||||
obj-$(CONFIG_PSTORE) += pstore/
|
||||
+obj-$(CONFIG_YAFFS_FS) += yaffs2/
|
||||
+
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,17 +0,0 @@
|
|||
--- a/fs/yaffs2/yaffs_guts.c
|
||||
+++ b/fs/yaffs2/yaffs_guts.c
|
||||
@@ -1709,11 +1709,11 @@ static int yaffs_change_obj_name(yaffs_o
|
||||
}
|
||||
|
||||
/* TODO: Do we need this different handling for YAFFS2 and YAFFS1?? */
|
||||
- if (obj->my_dev->param.is_yaffs2)
|
||||
+ // if (obj->my_dev->param.is_yaffs2)
|
||||
unlinkOp = (new_dir == obj->my_dev->unlinked_dir);
|
||||
- else
|
||||
+ /* else
|
||||
unlinkOp = (new_dir == obj->my_dev->unlinked_dir
|
||||
- && obj->variant_type == YAFFS_OBJECT_TYPE_FILE);
|
||||
+ && obj->variant_type == YAFFS_OBJECT_TYPE_FILE); */
|
||||
|
||||
deleteOp = (new_dir == obj->my_dev->del_dir);
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
--- a/fs/yaffs2/yaffs_vfs_glue.c
|
||||
+++ b/fs/yaffs2/yaffs_vfs_glue.c
|
||||
@@ -3036,7 +3036,7 @@ static struct super_block *yaffs_interna
|
||||
YINIT_LIST_HEAD(&(yaffs_dev_to_lc(dev)->searchContexts));
|
||||
param->remove_obj_fn = yaffs_remove_obj_callback;
|
||||
|
||||
- init_MUTEX(&(yaffs_dev_to_lc(dev)->grossLock));
|
||||
+ sema_init(&(yaffs_dev_to_lc(dev)->grossLock), 1);
|
||||
|
||||
yaffs_gross_lock(dev);
|
||||
|
||||
@@ -3494,7 +3494,7 @@ static int __init init_yaffs_fs(void)
|
||||
|
||||
|
||||
|
||||
- init_MUTEX(&yaffs_context_lock);
|
||||
+ sema_init((&yaffs_context_lock), 1);
|
||||
|
||||
/* Install the proc_fs entries */
|
||||
my_proc_entry = create_proc_entry("yaffs",
|
|
@ -1,147 +0,0 @@
|
|||
--- a/fs/yaffs2/yaffs_vfs_glue.c
|
||||
+++ b/fs/yaffs2/yaffs_vfs_glue.c
|
||||
@@ -72,7 +72,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/proc_fs.h>
|
||||
-#include <linux/smp_lock.h>
|
||||
+#include <linux/mutex.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -97,6 +97,8 @@
|
||||
|
||||
#include <asm/div64.h>
|
||||
|
||||
+static DEFINE_MUTEX(yaffs_mutex);
|
||||
+
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
|
||||
|
||||
#include <linux/statfs.h>
|
||||
@@ -1538,7 +1540,7 @@ static loff_t yaffs_dir_llseek(struct fi
|
||||
{
|
||||
long long retval;
|
||||
|
||||
- lock_kernel();
|
||||
+ mutex_lock(&yaffs_mutex);
|
||||
|
||||
switch (origin){
|
||||
case 2:
|
||||
@@ -1555,7 +1557,7 @@ static loff_t yaffs_dir_llseek(struct fi
|
||||
|
||||
retval = offset;
|
||||
}
|
||||
- unlock_kernel();
|
||||
+ mutex_unlock(&yaffs_mutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -3087,98 +3089,52 @@ static struct super_block *yaffs_interna
|
||||
return sb;
|
||||
}
|
||||
|
||||
-
|
||||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
|
||||
static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data,
|
||||
int silent)
|
||||
{
|
||||
return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL;
|
||||
}
|
||||
|
||||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
|
||||
-static int yaffs_read_super(struct file_system_type *fs,
|
||||
+static struct dentry *yaffs_read_super(struct file_system_type *fs,
|
||||
int flags, const char *dev_name,
|
||||
- void *data, struct vfsmount *mnt)
|
||||
-{
|
||||
-
|
||||
- return get_sb_bdev(fs, flags, dev_name, data,
|
||||
- yaffs_internal_read_super_mtd, mnt);
|
||||
-}
|
||||
-#else
|
||||
-static struct super_block *yaffs_read_super(struct file_system_type *fs,
|
||||
- int flags, const char *dev_name,
|
||||
- void *data)
|
||||
+ void *data)
|
||||
{
|
||||
|
||||
- return get_sb_bdev(fs, flags, dev_name, data,
|
||||
+ return mount_bdev(fs, flags, dev_name, data,
|
||||
yaffs_internal_read_super_mtd);
|
||||
}
|
||||
-#endif
|
||||
|
||||
static struct file_system_type yaffs_fs_type = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "yaffs",
|
||||
- .get_sb = yaffs_read_super,
|
||||
+ .mount = yaffs_read_super,
|
||||
.kill_sb = kill_block_super,
|
||||
.fs_flags = FS_REQUIRES_DEV,
|
||||
};
|
||||
-#else
|
||||
-static struct super_block *yaffs_read_super(struct super_block *sb, void *data,
|
||||
- int silent)
|
||||
-{
|
||||
- return yaffs_internal_read_super(1, sb, data, silent);
|
||||
-}
|
||||
-
|
||||
-static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super,
|
||||
- FS_REQUIRES_DEV);
|
||||
-#endif
|
||||
-
|
||||
|
||||
#ifdef CONFIG_YAFFS_YAFFS2
|
||||
|
||||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
|
||||
static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data,
|
||||
int silent)
|
||||
{
|
||||
return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -EINVAL;
|
||||
}
|
||||
|
||||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
|
||||
-static int yaffs2_read_super(struct file_system_type *fs,
|
||||
- int flags, const char *dev_name, void *data,
|
||||
- struct vfsmount *mnt)
|
||||
+static struct dentry *yaffs2_read_super(struct file_system_type *fs,
|
||||
+ int flags, const char *dev_name,
|
||||
+ void *data)
|
||||
{
|
||||
- return get_sb_bdev(fs, flags, dev_name, data,
|
||||
- yaffs2_internal_read_super_mtd, mnt);
|
||||
+ return mount_bdev(fs, flags, dev_name, data,
|
||||
+ yaffs_internal_read_super_mtd);
|
||||
}
|
||||
-#else
|
||||
-static struct super_block *yaffs2_read_super(struct file_system_type *fs,
|
||||
- int flags, const char *dev_name,
|
||||
- void *data)
|
||||
-{
|
||||
-
|
||||
- return get_sb_bdev(fs, flags, dev_name, data,
|
||||
- yaffs2_internal_read_super_mtd);
|
||||
-}
|
||||
-#endif
|
||||
|
||||
static struct file_system_type yaffs2_fs_type = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "yaffs2",
|
||||
- .get_sb = yaffs2_read_super,
|
||||
+ .mount = yaffs2_read_super,
|
||||
.kill_sb = kill_block_super,
|
||||
.fs_flags = FS_REQUIRES_DEV,
|
||||
};
|
||||
-#else
|
||||
-static struct super_block *yaffs2_read_super(struct super_block *sb,
|
||||
- void *data, int silent)
|
||||
-{
|
||||
- return yaffs_internal_read_super(2, sb, data, silent);
|
||||
-}
|
||||
-
|
||||
-static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super,
|
||||
- FS_REQUIRES_DEV);
|
||||
-#endif
|
||||
|
||||
#endif /* CONFIG_YAFFS_YAFFS2 */
|
||||
|
|
@ -1,289 +0,0 @@
|
|||
--- a/fs/yaffs2/yaffs_vfs_glue.c
|
||||
+++ b/fs/yaffs2/yaffs_vfs_glue.c
|
||||
@@ -220,11 +220,34 @@ static struct inode *yaffs_iget(struct s
|
||||
#define yaffs_SuperToDevice(sb) ((yaffs_dev_t *)sb->u.generic_sbp)
|
||||
#endif
|
||||
|
||||
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
|
||||
+static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink)
|
||||
+{
|
||||
+ set_nlink(inode, nlink);
|
||||
+}
|
||||
+
|
||||
+static inline void yaffs_dec_link_count(struct inode *inode)
|
||||
+{
|
||||
+ inode_dec_link_count(inode);
|
||||
+}
|
||||
+#else
|
||||
+static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink)
|
||||
+{
|
||||
+ inode->i_nlink = nlink;
|
||||
+}
|
||||
+
|
||||
+static inline void yaffs_dec_link_count(struct inode *inode)
|
||||
+{
|
||||
+ inode->i_nlink--;
|
||||
+ mark_inode_dirty(inode)
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
|
||||
#define update_dir_time(dir) do {\
|
||||
(dir)->i_ctime = (dir)->i_mtime = CURRENT_TIME; \
|
||||
} while(0)
|
||||
-
|
||||
+
|
||||
static void yaffs_put_super(struct super_block *sb);
|
||||
|
||||
static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
|
||||
@@ -238,7 +261,10 @@ static int yaffs_file_flush(struct file
|
||||
static int yaffs_file_flush(struct file *file);
|
||||
#endif
|
||||
|
||||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
|
||||
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
|
||||
+static int yaffs_sync_object(struct file *file, loff_t start, loff_t end,
|
||||
+ int datasync);
|
||||
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
|
||||
static int yaffs_sync_object(struct file *file, int datasync);
|
||||
#else
|
||||
static int yaffs_sync_object(struct file *file, struct dentry *dentry,
|
||||
@@ -513,7 +539,7 @@ static unsigned yaffs_gc_control_callbac
|
||||
{
|
||||
return yaffs_gc_control;
|
||||
}
|
||||
-
|
||||
+
|
||||
static void yaffs_gross_lock(yaffs_dev_t *dev)
|
||||
{
|
||||
T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current));
|
||||
@@ -1362,7 +1388,7 @@ static void yaffs_fill_inode_from_obj(st
|
||||
inode->i_size = yaffs_get_obj_length(obj);
|
||||
inode->i_blocks = (inode->i_size + 511) >> 9;
|
||||
|
||||
- inode->i_nlink = yaffs_get_obj_link_count(obj);
|
||||
+ yaffs_set_nlink(inode, yaffs_get_obj_link_count(obj));
|
||||
|
||||
T(YAFFS_TRACE_OS,
|
||||
(TSTR("yaffs_fill_inode mode %x uid %d gid %d size %d count %d\n"),
|
||||
@@ -1810,10 +1836,9 @@ static int yaffs_unlink(struct inode *di
|
||||
retVal = yaffs_unlinker(obj, dentry->d_name.name);
|
||||
|
||||
if (retVal == YAFFS_OK) {
|
||||
- dentry->d_inode->i_nlink--;
|
||||
+ yaffs_dec_link_count(dentry->d_inode);
|
||||
dir->i_version++;
|
||||
yaffs_gross_unlock(dev);
|
||||
- mark_inode_dirty(dentry->d_inode);
|
||||
update_dir_time(dir);
|
||||
return 0;
|
||||
}
|
||||
@@ -1844,7 +1869,8 @@ static int yaffs_link(struct dentry *old
|
||||
obj);
|
||||
|
||||
if (link) {
|
||||
- old_dentry->d_inode->i_nlink = yaffs_get_obj_link_count(obj);
|
||||
+ yaffs_set_nlink(old_dentry->d_inode,
|
||||
+ yaffs_get_obj_link_count(obj));
|
||||
d_instantiate(dentry, old_dentry->d_inode);
|
||||
atomic_inc(&old_dentry->d_inode->i_count);
|
||||
T(YAFFS_TRACE_OS,
|
||||
@@ -1894,7 +1920,10 @@ static int yaffs_symlink(struct inode *d
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
|
||||
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
|
||||
+static int yaffs_sync_object(struct file *file, loff_t start, loff_t end,
|
||||
+ int datasync)
|
||||
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34))
|
||||
static int yaffs_sync_object(struct file *file, int datasync)
|
||||
#else
|
||||
static int yaffs_sync_object(struct file *file, struct dentry *dentry,
|
||||
@@ -1961,11 +1990,9 @@ static int yaffs_rename(struct inode *ol
|
||||
yaffs_gross_unlock(dev);
|
||||
|
||||
if (retVal == YAFFS_OK) {
|
||||
- if (target) {
|
||||
- new_dentry->d_inode->i_nlink--;
|
||||
- mark_inode_dirty(new_dentry->d_inode);
|
||||
- }
|
||||
-
|
||||
+ if (target)
|
||||
+ yaffs_dec_link_count(new_dentry->d_inode);
|
||||
+
|
||||
update_dir_time(old_dir);
|
||||
if(old_dir != new_dir)
|
||||
update_dir_time(new_dir);
|
||||
@@ -1985,7 +2012,7 @@ static int yaffs_setattr(struct dentry *
|
||||
(TSTR("yaffs_setattr of object %d\n"),
|
||||
yaffs_InodeToObject(inode)->obj_id));
|
||||
|
||||
- /* Fail if a requested resize >= 2GB */
|
||||
+ /* Fail if a requested resize >= 2GB */
|
||||
if (attr->ia_valid & ATTR_SIZE &&
|
||||
(attr->ia_size >> 31))
|
||||
error = -EINVAL;
|
||||
@@ -2216,7 +2243,7 @@ static void yaffs_flush_inodes(struct su
|
||||
{
|
||||
struct inode *iptr;
|
||||
yaffs_obj_t *obj;
|
||||
-
|
||||
+
|
||||
list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){
|
||||
obj = yaffs_InodeToObject(iptr);
|
||||
if(obj){
|
||||
@@ -2230,10 +2257,10 @@ static void yaffs_flush_inodes(struct su
|
||||
|
||||
static void yaffs_flush_super(struct super_block *sb, int do_checkpoint)
|
||||
{
|
||||
- yaffs_dev_t *dev = yaffs_SuperToDevice(sb);
|
||||
+ yaffs_dev_t *dev = yaffs_SuperToDevice(sb);
|
||||
if(!dev)
|
||||
return;
|
||||
-
|
||||
+
|
||||
yaffs_flush_inodes(sb);
|
||||
yaffs_update_dirty_dirs(dev);
|
||||
yaffs_flush_whole_cache(dev);
|
||||
@@ -2301,7 +2328,7 @@ static int yaffs_do_sync_fs(struct super
|
||||
* yaffs_bg_start() launches the background thread.
|
||||
* yaffs_bg_stop() cleans up the background thread.
|
||||
*
|
||||
- * NB:
|
||||
+ * NB:
|
||||
* The thread should only run after the yaffs is initialised
|
||||
* The thread should be stopped before yaffs is unmounted.
|
||||
* The thread should not do any writing while the fs is in read only.
|
||||
@@ -2872,7 +2899,7 @@ static struct super_block *yaffs_interna
|
||||
|
||||
dev = kmalloc(sizeof(yaffs_dev_t), GFP_KERNEL);
|
||||
context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL);
|
||||
-
|
||||
+
|
||||
if(!dev || !context ){
|
||||
if(dev)
|
||||
kfree(dev);
|
||||
@@ -2905,7 +2932,7 @@ static struct super_block *yaffs_interna
|
||||
#else
|
||||
sb->u.generic_sbp = dev;
|
||||
#endif
|
||||
-
|
||||
+
|
||||
dev->driver_context = mtd;
|
||||
param->name = mtd->name;
|
||||
|
||||
@@ -3005,7 +3032,7 @@ static struct super_block *yaffs_interna
|
||||
param->gc_control = yaffs_gc_control_callback;
|
||||
|
||||
yaffs_dev_to_lc(dev)->superBlock= sb;
|
||||
-
|
||||
+
|
||||
|
||||
#ifndef CONFIG_YAFFS_DOES_ECC
|
||||
param->use_nand_ecc = 1;
|
||||
@@ -3047,10 +3074,10 @@ static struct super_block *yaffs_interna
|
||||
T(YAFFS_TRACE_OS,
|
||||
(TSTR("yaffs_read_super: guts initialised %s\n"),
|
||||
(err == YAFFS_OK) ? "OK" : "FAILED"));
|
||||
-
|
||||
+
|
||||
if(err == YAFFS_OK)
|
||||
yaffs_bg_start(dev);
|
||||
-
|
||||
+
|
||||
if(!context->bgThread)
|
||||
param->defered_dir_update = 0;
|
||||
|
||||
@@ -3125,7 +3152,7 @@ static struct dentry *yaffs2_read_super(
|
||||
void *data)
|
||||
{
|
||||
return mount_bdev(fs, flags, dev_name, data,
|
||||
- yaffs_internal_read_super_mtd);
|
||||
+ yaffs2_internal_read_super_mtd);
|
||||
}
|
||||
|
||||
static struct file_system_type yaffs2_fs_type = {
|
||||
@@ -3223,7 +3250,7 @@ static int yaffs_proc_read(char *page,
|
||||
buf += sprintf(buf,"\n");
|
||||
else {
|
||||
step-=2;
|
||||
-
|
||||
+
|
||||
down(&yaffs_context_lock);
|
||||
|
||||
/* Locate and print the Nth entry. Order N-squared but N is small. */
|
||||
@@ -3240,7 +3267,7 @@ static int yaffs_proc_read(char *page,
|
||||
buf = yaffs_dump_dev_part0(buf, dev);
|
||||
} else
|
||||
buf = yaffs_dump_dev_part1(buf, dev);
|
||||
-
|
||||
+
|
||||
break;
|
||||
}
|
||||
up(&yaffs_context_lock);
|
||||
@@ -3267,7 +3294,7 @@ static int yaffs_stats_proc_read(char *p
|
||||
int erasedChunks;
|
||||
|
||||
erasedChunks = dev->n_erased_blocks * dev->param.chunks_per_block;
|
||||
-
|
||||
+
|
||||
buf += sprintf(buf,"%d, %d, %d, %u, %u, %u, %u\n",
|
||||
n, dev->n_free_chunks, erasedChunks,
|
||||
dev->bg_gcs, dev->oldest_dirty_gc_count,
|
||||
--- a/fs/yaffs2/yaffs_mtdif1.c
|
||||
+++ b/fs/yaffs2/yaffs_mtdif1.c
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "linux/version.h"
|
||||
#include "linux/types.h"
|
||||
#include "linux/mtd/mtd.h"
|
||||
+#include "mtd/mtd-abi.h"
|
||||
|
||||
/* Don't compile this module if we don't have MTD's mtd_oob_ops interface */
|
||||
#if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17))
|
||||
@@ -127,7 +128,7 @@ int nandmtd1_WriteChunkWithTagsToNAND(ya
|
||||
#endif
|
||||
|
||||
memset(&ops, 0, sizeof(ops));
|
||||
- ops.mode = MTD_OOB_AUTO;
|
||||
+ ops.mode = MTD_OPS_AUTO_OOB;
|
||||
ops.len = (data) ? chunkBytes : 0;
|
||||
ops.ooblen = YTAG1_SIZE;
|
||||
ops.datbuf = (__u8 *)data;
|
||||
@@ -179,7 +180,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(y
|
||||
int deleted;
|
||||
|
||||
memset(&ops, 0, sizeof(ops));
|
||||
- ops.mode = MTD_OOB_AUTO;
|
||||
+ ops.mode = MTD_OPS_AUTO_OOB;
|
||||
ops.len = (data) ? chunkBytes : 0;
|
||||
ops.ooblen = YTAG1_SIZE;
|
||||
ops.datbuf = data;
|
||||
--- a/fs/yaffs2/yaffs_mtdif2.c
|
||||
+++ b/fs/yaffs2/yaffs_mtdif2.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "linux/mtd/mtd.h"
|
||||
#include "linux/types.h"
|
||||
#include "linux/time.h"
|
||||
+#include "mtd/mtd-abi.h"
|
||||
|
||||
#include "yaffs_packedtags2.h"
|
||||
|
||||
@@ -71,7 +72,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(ya
|
||||
yaffs_PackTags2(&pt, tags, !dev->param.no_tags_ecc);
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
|
||||
- ops.mode = MTD_OOB_AUTO;
|
||||
+ ops.mode = MTD_OPS_AUTO_OOB;
|
||||
ops.ooblen = (dev->param.inband_tags) ? 0 : packed_tags_size;
|
||||
ops.len = dev->param.total_bytes_per_chunk;
|
||||
ops.ooboffs = 0;
|
||||
@@ -136,7 +137,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y
|
||||
retval = mtd->read(mtd, addr, dev->param.total_bytes_per_chunk,
|
||||
&dummy, data);
|
||||
else if (tags) {
|
||||
- ops.mode = MTD_OOB_AUTO;
|
||||
+ ops.mode = MTD_OPS_AUTO_OOB;
|
||||
ops.ooblen = packed_tags_size;
|
||||
ops.len = data ? dev->data_bytes_per_chunk : packed_tags_size;
|
||||
ops.ooboffs = 0;
|
File diff suppressed because it is too large
Load Diff
|
@ -1,485 +0,0 @@
|
|||
--- a/include/linux/lzma/LzmaDec.h
|
||||
+++ b/include/linux/lzma/LzmaDec.h
|
||||
@@ -31,14 +31,6 @@ typedef struct _CLzmaProps
|
||||
UInt32 dicSize;
|
||||
} CLzmaProps;
|
||||
|
||||
-/* LzmaProps_Decode - decodes properties
|
||||
-Returns:
|
||||
- SZ_OK
|
||||
- SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||
-*/
|
||||
-
|
||||
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
|
||||
-
|
||||
|
||||
/* ---------- LZMA Decoder state ---------- */
|
||||
|
||||
@@ -70,8 +62,6 @@ typedef struct
|
||||
|
||||
#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
|
||||
|
||||
-void LzmaDec_Init(CLzmaDec *p);
|
||||
-
|
||||
/* There are two types of LZMA streams:
|
||||
0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
|
||||
1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
|
||||
@@ -108,97 +98,6 @@ typedef enum
|
||||
|
||||
/* ELzmaStatus is used only as output value for function call */
|
||||
|
||||
-
|
||||
-/* ---------- Interfaces ---------- */
|
||||
-
|
||||
-/* There are 3 levels of interfaces:
|
||||
- 1) Dictionary Interface
|
||||
- 2) Buffer Interface
|
||||
- 3) One Call Interface
|
||||
- You can select any of these interfaces, but don't mix functions from different
|
||||
- groups for same object. */
|
||||
-
|
||||
-
|
||||
-/* There are two variants to allocate state for Dictionary Interface:
|
||||
- 1) LzmaDec_Allocate / LzmaDec_Free
|
||||
- 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
|
||||
- You can use variant 2, if you set dictionary buffer manually.
|
||||
- For Buffer Interface you must always use variant 1.
|
||||
-
|
||||
-LzmaDec_Allocate* can return:
|
||||
- SZ_OK
|
||||
- SZ_ERROR_MEM - Memory allocation error
|
||||
- SZ_ERROR_UNSUPPORTED - Unsupported properties
|
||||
-*/
|
||||
-
|
||||
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
|
||||
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
|
||||
-
|
||||
-SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
|
||||
-void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
|
||||
-
|
||||
-/* ---------- Dictionary Interface ---------- */
|
||||
-
|
||||
-/* You can use it, if you want to eliminate the overhead for data copying from
|
||||
- dictionary to some other external buffer.
|
||||
- You must work with CLzmaDec variables directly in this interface.
|
||||
-
|
||||
- STEPS:
|
||||
- LzmaDec_Constr()
|
||||
- LzmaDec_Allocate()
|
||||
- for (each new stream)
|
||||
- {
|
||||
- LzmaDec_Init()
|
||||
- while (it needs more decompression)
|
||||
- {
|
||||
- LzmaDec_DecodeToDic()
|
||||
- use data from CLzmaDec::dic and update CLzmaDec::dicPos
|
||||
- }
|
||||
- }
|
||||
- LzmaDec_Free()
|
||||
-*/
|
||||
-
|
||||
-/* LzmaDec_DecodeToDic
|
||||
-
|
||||
- The decoding to internal dictionary buffer (CLzmaDec::dic).
|
||||
- You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
|
||||
-
|
||||
-finishMode:
|
||||
- It has meaning only if the decoding reaches output limit (dicLimit).
|
||||
- LZMA_FINISH_ANY - Decode just dicLimit bytes.
|
||||
- LZMA_FINISH_END - Stream must be finished after dicLimit.
|
||||
-
|
||||
-Returns:
|
||||
- SZ_OK
|
||||
- status:
|
||||
- LZMA_STATUS_FINISHED_WITH_MARK
|
||||
- LZMA_STATUS_NOT_FINISHED
|
||||
- LZMA_STATUS_NEEDS_MORE_INPUT
|
||||
- LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
|
||||
- SZ_ERROR_DATA - Data error
|
||||
-*/
|
||||
-
|
||||
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
|
||||
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||
-
|
||||
-
|
||||
-/* ---------- Buffer Interface ---------- */
|
||||
-
|
||||
-/* It's zlib-like interface.
|
||||
- See LzmaDec_DecodeToDic description for information about STEPS and return results,
|
||||
- but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
|
||||
- to work with CLzmaDec variables manually.
|
||||
-
|
||||
-finishMode:
|
||||
- It has meaning only if the decoding reaches output limit (*destLen).
|
||||
- LZMA_FINISH_ANY - Decode just destLen bytes.
|
||||
- LZMA_FINISH_END - Stream must be finished after (*destLen).
|
||||
-*/
|
||||
-
|
||||
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
|
||||
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
||||
-
|
||||
-
|
||||
/* ---------- One Call Interface ---------- */
|
||||
|
||||
/* LzmaDecode
|
||||
--- a/lib/lzma/LzmaDec.c
|
||||
+++ b/lib/lzma/LzmaDec.c
|
||||
@@ -682,7 +682,7 @@ static void LzmaDec_InitRc(CLzmaDec *p,
|
||||
p->needFlush = 0;
|
||||
}
|
||||
|
||||
-void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
|
||||
+static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
|
||||
{
|
||||
p->needFlush = 1;
|
||||
p->remainLen = 0;
|
||||
@@ -698,7 +698,7 @@ void LzmaDec_InitDicAndState(CLzmaDec *p
|
||||
p->needInitState = 1;
|
||||
}
|
||||
|
||||
-void LzmaDec_Init(CLzmaDec *p)
|
||||
+static void LzmaDec_Init(CLzmaDec *p)
|
||||
{
|
||||
p->dicPos = 0;
|
||||
LzmaDec_InitDicAndState(p, True, True);
|
||||
@@ -716,7 +716,7 @@ static void LzmaDec_InitStateReal(CLzmaD
|
||||
p->needInitState = 0;
|
||||
}
|
||||
|
||||
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
|
||||
+static SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
|
||||
ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||
{
|
||||
SizeT inSize = *srcLen;
|
||||
@@ -837,7 +837,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, Si
|
||||
return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
|
||||
}
|
||||
|
||||
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||
+static __maybe_unused SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
|
||||
{
|
||||
SizeT outSize = *destLen;
|
||||
SizeT inSize = *srcLen;
|
||||
@@ -877,7 +877,7 @@ SRes LzmaDec_DecodeToBuf(CLzmaDec *p, By
|
||||
}
|
||||
}
|
||||
|
||||
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
|
||||
+static void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
|
||||
{
|
||||
alloc->Free(alloc, p->probs);
|
||||
p->probs = 0;
|
||||
@@ -889,13 +889,13 @@ static void LzmaDec_FreeDict(CLzmaDec *p
|
||||
p->dic = 0;
|
||||
}
|
||||
|
||||
-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
|
||||
+static void __maybe_unused LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
|
||||
{
|
||||
LzmaDec_FreeProbs(p, alloc);
|
||||
LzmaDec_FreeDict(p, alloc);
|
||||
}
|
||||
|
||||
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
|
||||
+static SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
|
||||
{
|
||||
UInt32 dicSize;
|
||||
Byte d;
|
||||
@@ -935,7 +935,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
|
||||
+static SRes __maybe_unused LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
|
||||
{
|
||||
CLzmaProps propNew;
|
||||
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
|
||||
@@ -944,7 +944,7 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p,
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
|
||||
+static SRes __maybe_unused LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
|
||||
{
|
||||
CLzmaProps propNew;
|
||||
SizeT dicBufSize;
|
||||
--- a/include/linux/lzma/LzmaEnc.h
|
||||
+++ b/include/linux/lzma/LzmaEnc.h
|
||||
@@ -31,9 +31,6 @@ typedef struct _CLzmaEncProps
|
||||
} CLzmaEncProps;
|
||||
|
||||
void LzmaEncProps_Init(CLzmaEncProps *p);
|
||||
-void LzmaEncProps_Normalize(CLzmaEncProps *p);
|
||||
-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
|
||||
-
|
||||
|
||||
/* ---------- CLzmaEncHandle Interface ---------- */
|
||||
|
||||
@@ -53,26 +50,9 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
|
||||
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
|
||||
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
|
||||
-SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
|
||||
- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||
|
||||
-/* ---------- One Call Interface ---------- */
|
||||
-
|
||||
-/* LzmaEncode
|
||||
-Return code:
|
||||
- SZ_OK - OK
|
||||
- SZ_ERROR_MEM - Memory allocation error
|
||||
- SZ_ERROR_PARAM - Incorrect paramater
|
||||
- SZ_ERROR_OUTPUT_EOF - output buffer overflow
|
||||
- SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
||||
-*/
|
||||
-
|
||||
-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||
- const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
||||
- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
||||
-
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
--- a/lib/lzma/LzmaEnc.c
|
||||
+++ b/lib/lzma/LzmaEnc.c
|
||||
@@ -53,7 +53,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
|
||||
p->writeEndMark = 0;
|
||||
}
|
||||
|
||||
-void LzmaEncProps_Normalize(CLzmaEncProps *p)
|
||||
+static void LzmaEncProps_Normalize(CLzmaEncProps *p)
|
||||
{
|
||||
int level = p->level;
|
||||
if (level < 0) level = 5;
|
||||
@@ -76,7 +76,7 @@ void LzmaEncProps_Normalize(CLzmaEncProp
|
||||
#endif
|
||||
}
|
||||
|
||||
-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
|
||||
+static UInt32 __maybe_unused LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
|
||||
{
|
||||
CLzmaEncProps props = *props2;
|
||||
LzmaEncProps_Normalize(&props);
|
||||
@@ -93,7 +93,7 @@ UInt32 LzmaEncProps_GetDictSize(const CL
|
||||
|
||||
#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); }
|
||||
|
||||
-UInt32 GetPosSlot1(UInt32 pos)
|
||||
+static UInt32 GetPosSlot1(UInt32 pos)
|
||||
{
|
||||
UInt32 res;
|
||||
BSR2_RET(pos, res);
|
||||
@@ -107,7 +107,7 @@ UInt32 GetPosSlot1(UInt32 pos)
|
||||
#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
|
||||
#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
|
||||
|
||||
-void LzmaEnc_FastPosInit(Byte *g_FastPos)
|
||||
+static void LzmaEnc_FastPosInit(Byte *g_FastPos)
|
||||
{
|
||||
int c = 2, slotFast;
|
||||
g_FastPos[0] = 0;
|
||||
@@ -339,7 +339,7 @@ typedef struct
|
||||
CSaveState saveState;
|
||||
} CLzmaEnc;
|
||||
|
||||
-void LzmaEnc_SaveState(CLzmaEncHandle pp)
|
||||
+static void __maybe_unused LzmaEnc_SaveState(CLzmaEncHandle pp)
|
||||
{
|
||||
CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||
CSaveState *dest = &p->saveState;
|
||||
@@ -365,7 +365,7 @@ void LzmaEnc_SaveState(CLzmaEncHandle pp
|
||||
memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
|
||||
}
|
||||
|
||||
-void LzmaEnc_RestoreState(CLzmaEncHandle pp)
|
||||
+static void __maybe_unused LzmaEnc_RestoreState(CLzmaEncHandle pp)
|
||||
{
|
||||
CLzmaEnc *dest = (CLzmaEnc *)pp;
|
||||
const CSaveState *p = &dest->saveState;
|
||||
@@ -600,7 +600,7 @@ static void LitEnc_EncodeMatched(CRangeE
|
||||
while (symbol < 0x10000);
|
||||
}
|
||||
|
||||
-void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
|
||||
+static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
|
||||
@@ -1676,7 +1676,7 @@ static void FillDistancesPrices(CLzmaEnc
|
||||
p->matchPriceCount = 0;
|
||||
}
|
||||
|
||||
-void LzmaEnc_Construct(CLzmaEnc *p)
|
||||
+static void LzmaEnc_Construct(CLzmaEnc *p)
|
||||
{
|
||||
RangeEnc_Construct(&p->rc);
|
||||
MatchFinder_Construct(&p->matchFinderBase);
|
||||
@@ -1709,7 +1709,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAlloc *
|
||||
return p;
|
||||
}
|
||||
|
||||
-void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
|
||||
+static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
|
||||
{
|
||||
alloc->Free(alloc, p->litProbs);
|
||||
alloc->Free(alloc, p->saveState.litProbs);
|
||||
@@ -2074,7 +2074,7 @@ SRes LzmaEnc_MemPrepare(CLzmaEncHandle p
|
||||
return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
|
||||
}
|
||||
|
||||
-void LzmaEnc_Finish(CLzmaEncHandle pp)
|
||||
+static void LzmaEnc_Finish(CLzmaEncHandle pp)
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||
@@ -2108,7 +2108,7 @@ static size_t MyWrite(void *pp, const vo
|
||||
}
|
||||
|
||||
|
||||
-UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
|
||||
+static UInt32 __maybe_unused LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
|
||||
{
|
||||
const CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||
return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
|
||||
@@ -2120,7 +2120,7 @@ const Byte *LzmaEnc_GetCurBuf(CLzmaEncHa
|
||||
return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
|
||||
}
|
||||
|
||||
-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
||||
+static SRes __maybe_unused LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,
|
||||
Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
|
||||
{
|
||||
CLzmaEnc *p = (CLzmaEnc *)pp;
|
||||
@@ -2248,7 +2248,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp
|
||||
return res;
|
||||
}
|
||||
|
||||
-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||
+static __maybe_unused SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
||||
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
||||
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
|
||||
{
|
||||
--- a/include/linux/lzma/LzFind.h
|
||||
+++ b/include/linux/lzma/LzFind.h
|
||||
@@ -55,11 +55,6 @@ typedef struct _CMatchFinder
|
||||
|
||||
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
|
||||
|
||||
-int MatchFinder_NeedMove(CMatchFinder *p);
|
||||
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
|
||||
-void MatchFinder_MoveBlock(CMatchFinder *p);
|
||||
-void MatchFinder_ReadIfRequired(CMatchFinder *p);
|
||||
-
|
||||
void MatchFinder_Construct(CMatchFinder *p);
|
||||
|
||||
/* Conditions:
|
||||
@@ -70,12 +65,6 @@ int MatchFinder_Create(CMatchFinder *p,
|
||||
UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
|
||||
ISzAlloc *alloc);
|
||||
void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
|
||||
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
|
||||
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
|
||||
-
|
||||
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
|
||||
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
|
||||
- UInt32 *distances, UInt32 maxLen);
|
||||
|
||||
/*
|
||||
Conditions:
|
||||
@@ -102,12 +91,6 @@ typedef struct _IMatchFinder
|
||||
|
||||
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
||||
|
||||
-void MatchFinder_Init(CMatchFinder *p);
|
||||
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
||||
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
||||
-
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
--- a/lib/lzma/LzFind.c
|
||||
+++ b/lib/lzma/LzFind.c
|
||||
@@ -42,12 +42,12 @@ static int LzInWindow_Create(CMatchFinde
|
||||
return (p->bufferBase != 0);
|
||||
}
|
||||
|
||||
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
|
||||
-Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
|
||||
+static Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
|
||||
+static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
|
||||
|
||||
-UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
|
||||
+static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
|
||||
|
||||
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
|
||||
+static void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
|
||||
{
|
||||
p->posLimit -= subValue;
|
||||
p->pos -= subValue;
|
||||
@@ -268,7 +268,7 @@ static void MatchFinder_SetLimits(CMatch
|
||||
p->posLimit = p->pos + limit;
|
||||
}
|
||||
|
||||
-void MatchFinder_Init(CMatchFinder *p)
|
||||
+static void MatchFinder_Init(CMatchFinder *p)
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < p->hashSizeSum; i++)
|
||||
@@ -287,7 +287,7 @@ static UInt32 MatchFinder_GetSubValue(CM
|
||||
return (p->pos - p->historySize - 1) & kNormalizeMask;
|
||||
}
|
||||
|
||||
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
|
||||
+static void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems)
|
||||
{
|
||||
UInt32 i;
|
||||
for (i = 0; i < numItems; i++)
|
||||
@@ -350,7 +350,7 @@ static UInt32 * Hc_GetMatchesSpec(UInt32
|
||||
}
|
||||
}
|
||||
|
||||
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||
+static UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
|
||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
|
||||
UInt32 *distances, UInt32 maxLen)
|
||||
{
|
||||
@@ -492,7 +492,7 @@ static UInt32 Bt2_MatchFinder_GetMatches
|
||||
GET_MATCHES_FOOTER(offset, 1)
|
||||
}
|
||||
|
||||
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||
+static __maybe_unused UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||
{
|
||||
UInt32 offset;
|
||||
GET_MATCHES_HEADER(3)
|
||||
@@ -632,7 +632,7 @@ static UInt32 Hc4_MatchFinder_GetMatches
|
||||
MOVE_POS_RET
|
||||
}
|
||||
|
||||
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||
+static __maybe_unused UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
|
||||
{
|
||||
UInt32 offset;
|
||||
GET_MATCHES_HEADER(3)
|
||||
@@ -657,7 +657,7 @@ static void Bt2_MatchFinder_Skip(CMatchF
|
||||
while (--num != 0);
|
||||
}
|
||||
|
||||
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
||||
+static __maybe_unused void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -718,7 +718,7 @@ static void Hc4_MatchFinder_Skip(CMatchF
|
||||
while (--num != 0);
|
||||
}
|
||||
|
||||
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
||||
+static __maybe_unused void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
|
||||
{
|
||||
do
|
||||
{
|
|
@ -1,132 +0,0 @@
|
|||
--- a/fs/jffs2/build.c
|
||||
+++ b/fs/jffs2/build.c
|
||||
@@ -112,6 +112,17 @@ static int jffs2_build_filesystem(struct
|
||||
dbg_fsbuild("scanned flash completely\n");
|
||||
jffs2_dbg_dump_block_lists_nolock(c);
|
||||
|
||||
+ if (c->flags & (1 << 7)) {
|
||||
+ printk("%s(): unlocking the mtd device... ", __func__);
|
||||
+ if (c->mtd->unlock)
|
||||
+ c->mtd->unlock(c->mtd, 0, c->mtd->size);
|
||||
+ printk("done.\n");
|
||||
+
|
||||
+ printk("%s(): erasing all blocks after the end marker... ", __func__);
|
||||
+ jffs2_erase_pending_blocks(c, -1);
|
||||
+ printk("done.\n");
|
||||
+ }
|
||||
+
|
||||
dbg_fsbuild("pass 1 starting\n");
|
||||
c->flags |= JFFS2_SB_FLAG_BUILDING;
|
||||
/* Now scan the directory tree, increasing nlink according to every dirent found. */
|
||||
--- a/fs/jffs2/scan.c
|
||||
+++ b/fs/jffs2/scan.c
|
||||
@@ -72,7 +72,7 @@ static int file_dirty(struct jffs2_sb_in
|
||||
return ret;
|
||||
if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size)))
|
||||
return ret;
|
||||
- /* Turned wasted size into dirty, since we apparently
|
||||
+ /* Turned wasted size into dirty, since we apparently
|
||||
think it's recoverable now. */
|
||||
jeb->dirty_size += jeb->wasted_size;
|
||||
c->dirty_size += jeb->wasted_size;
|
||||
@@ -147,8 +147,11 @@ int jffs2_scan_medium(struct jffs2_sb_in
|
||||
/* reset summary info for next eraseblock scan */
|
||||
jffs2_sum_reset_collected(s);
|
||||
|
||||
- ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
|
||||
- buf_size, s);
|
||||
+ if (c->flags & (1 << 7))
|
||||
+ ret = BLK_STATE_ALLFF;
|
||||
+ else
|
||||
+ ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
|
||||
+ buf_size, s);
|
||||
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
@@ -403,7 +406,7 @@ static int jffs2_scan_xref_node(struct j
|
||||
if (!ref)
|
||||
return -ENOMEM;
|
||||
|
||||
- /* BEFORE jffs2_build_xattr_subsystem() called,
|
||||
+ /* BEFORE jffs2_build_xattr_subsystem() called,
|
||||
* and AFTER xattr_ref is marked as a dead xref,
|
||||
* ref->xid is used to store 32bit xid, xd is not used
|
||||
* ref->ino is used to store 32bit inode-number, ic is not used
|
||||
@@ -476,7 +479,7 @@ static int jffs2_scan_eraseblock (struct
|
||||
struct jffs2_sum_marker *sm;
|
||||
void *sumptr = NULL;
|
||||
uint32_t sumlen;
|
||||
-
|
||||
+
|
||||
if (!buf_size) {
|
||||
/* XIP case. Just look, point at the summary if it's there */
|
||||
sm = (void *)buf + c->sector_size - sizeof(*sm);
|
||||
@@ -492,9 +495,9 @@ static int jffs2_scan_eraseblock (struct
|
||||
buf_len = sizeof(*sm);
|
||||
|
||||
/* Read as much as we want into the _end_ of the preallocated buffer */
|
||||
- err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
|
||||
+ err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
|
||||
jeb->offset + c->sector_size - buf_len,
|
||||
- buf_len);
|
||||
+ buf_len);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -513,9 +516,9 @@ static int jffs2_scan_eraseblock (struct
|
||||
}
|
||||
if (buf_len < sumlen) {
|
||||
/* Need to read more so that the entire summary node is present */
|
||||
- err = jffs2_fill_scan_buf(c, sumptr,
|
||||
+ err = jffs2_fill_scan_buf(c, sumptr,
|
||||
jeb->offset + c->sector_size - sumlen,
|
||||
- sumlen - buf_len);
|
||||
+ sumlen - buf_len);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
@@ -528,7 +531,7 @@ static int jffs2_scan_eraseblock (struct
|
||||
|
||||
if (buf_size && sumlen > buf_size)
|
||||
kfree(sumptr);
|
||||
- /* If it returns with a real error, bail.
|
||||
+ /* If it returns with a real error, bail.
|
||||
If it returns positive, that's a block classification
|
||||
(i.e. BLK_STATE_xxx) so return that too.
|
||||
If it returns zero, fall through to full scan. */
|
||||
@@ -549,6 +552,17 @@ static int jffs2_scan_eraseblock (struct
|
||||
return err;
|
||||
}
|
||||
|
||||
+ if ((buf[0] == 0xde) &&
|
||||
+ (buf[1] == 0xad) &&
|
||||
+ (buf[2] == 0xc0) &&
|
||||
+ (buf[3] == 0xde)) {
|
||||
+ /* end of filesystem. erase everything after this point */
|
||||
+ printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
|
||||
+ c->flags |= (1 << 7);
|
||||
+
|
||||
+ return BLK_STATE_ALLFF;
|
||||
+ }
|
||||
+
|
||||
/* We temporarily use 'ofs' as a pointer into the buffer/jeb */
|
||||
ofs = 0;
|
||||
max_ofs = EMPTY_SCAN_SIZE(c->sector_size);
|
||||
@@ -674,7 +688,7 @@ scan_more:
|
||||
scan_end = buf_len;
|
||||
goto more_empty;
|
||||
}
|
||||
-
|
||||
+
|
||||
/* See how much more there is to read in this eraseblock... */
|
||||
buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
|
||||
if (!buf_len) {
|
||||
@@ -910,7 +924,7 @@ scan_more:
|
||||
|
||||
D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
|
||||
jeb->offset,jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size, jeb->wasted_size));
|
||||
-
|
||||
+
|
||||
/* mark_node_obsolete can add to wasted !! */
|
||||
if (jeb->wasted_size) {
|
||||
jeb->dirty_size += jeb->wasted_size;
|
|
@ -1,25 +0,0 @@
|
|||
From f31b7c0efa255dd17a5f584022a319387f09b0d8 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jonas.gorski@gmail.com>
|
||||
Date: Tue, 12 Apr 2011 19:55:41 +0200
|
||||
Subject: [PATCH] squashfs: update xz compressor options struct.
|
||||
|
||||
Update the xz compressor options struct to match the squashfs userspace
|
||||
one.
|
||||
---
|
||||
fs/squashfs/xz_wrapper.c | 4 +++-
|
||||
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||
|
||||
--- a/fs/squashfs/xz_wrapper.c
|
||||
+++ b/fs/squashfs/xz_wrapper.c
|
||||
@@ -39,8 +39,10 @@ struct squashfs_xz {
|
||||
};
|
||||
|
||||
struct comp_opts {
|
||||
- __le32 dictionary_size;
|
||||
__le32 flags;
|
||||
+ __le16 bit_opts;
|
||||
+ __le16 fb;
|
||||
+ __le32 dictionary_size;
|
||||
};
|
||||
|
||||
static void *squashfs_xz_init(struct squashfs_sb_info *msblk, void *buff,
|
|
@ -1,146 +0,0 @@
|
|||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -886,6 +886,13 @@ config CRYPTO_LZO
|
||||
help
|
||||
This is the LZO 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
|
||||
@@ -82,6 +82,7 @@ obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += mich
|
||||
obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
|
||||
obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
|
||||
obj-$(CONFIG_CRYPTO_LZO) += lzo.o
|
||||
+obj-$(CONFIG_CRYPTO_XZ) += xz.o
|
||||
obj-$(CONFIG_CRYPTO_RNG2) += rng.o
|
||||
obj-$(CONFIG_CRYPTO_RNG2) += krng.o
|
||||
obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
|
||||
--- /dev/null
|
||||
+++ b/crypto/xz.c
|
||||
@@ -0,0 +1,117 @@
|
||||
+/*
|
||||
+ * Cryptographic API.
|
||||
+ *
|
||||
+ * XZ decompression support.
|
||||
+ *
|
||||
+ * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
|
||||
+ *
|
||||
+ * 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 <linux/init.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/crypto.h>
|
||||
+#include <linux/xz.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/mm.h>
|
||||
+#include <linux/net.h>
|
||||
+
|
||||
+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 <juhosg@openwrt.org>");
|
|
@ -1,94 +0,0 @@
|
|||
--- a/fs/ubifs/Kconfig
|
||||
+++ b/fs/ubifs/Kconfig
|
||||
@@ -5,8 +5,10 @@ config UBIFS_FS
|
||||
select CRYPTO if UBIFS_FS_ADVANCED_COMPR
|
||||
select CRYPTO if UBIFS_FS_LZO
|
||||
select CRYPTO if UBIFS_FS_ZLIB
|
||||
+ select CRYPTO if UBIFS_FS_XZ
|
||||
select CRYPTO_LZO if UBIFS_FS_LZO
|
||||
select CRYPTO_DEFLATE if UBIFS_FS_ZLIB
|
||||
+ select CRYPTO_XZ if UBIFS_FS_XZ
|
||||
depends on MTD_UBI
|
||||
help
|
||||
UBIFS is a file system for flash devices which works on top of UBI.
|
||||
@@ -42,6 +44,14 @@ config UBIFS_FS_ZLIB
|
||||
help
|
||||
Zlib compresses better than LZO but it is slower. Say 'Y' if unsure.
|
||||
|
||||
+config UBIFS_FS_XZ
|
||||
+ bool "XZ decompression support" if UBIFS_FS_ADVANCED_COMPR
|
||||
+ depends on UBIFS_FS
|
||||
+ default y
|
||||
+ help
|
||||
+ XZ compresses better the ZLIB but it is slower.
|
||||
+ Say 'Y' if unsure.
|
||||
+
|
||||
# Debugging-related stuff
|
||||
config UBIFS_FS_DEBUG
|
||||
bool "Enable debugging support"
|
||||
--- a/fs/ubifs/compress.c
|
||||
+++ b/fs/ubifs/compress.c
|
||||
@@ -71,6 +71,24 @@ static struct ubifs_compressor zlib_comp
|
||||
};
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_UBIFS_FS_XZ
|
||||
+static DEFINE_MUTEX(xz_enc_mutex);
|
||||
+static DEFINE_MUTEX(xz_dec_mutex);
|
||||
+
|
||||
+static struct ubifs_compressor xz_compr = {
|
||||
+ .compr_type = UBIFS_COMPR_XZ,
|
||||
+ .comp_mutex = &xz_enc_mutex,
|
||||
+ .decomp_mutex = &xz_dec_mutex,
|
||||
+ .name = "xz",
|
||||
+ .capi_name = "xz",
|
||||
+};
|
||||
+#else
|
||||
+static struct ubifs_compressor zlib_compr = {
|
||||
+ .compr_type = UBIFS_COMPR_XZ,
|
||||
+ .name = "xz",
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
/* All UBIFS compressors */
|
||||
struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
|
||||
|
||||
@@ -233,9 +251,15 @@ int __init ubifs_compressors_init(void)
|
||||
if (err)
|
||||
goto out_lzo;
|
||||
|
||||
+ err = compr_init(&xz_compr);
|
||||
+ if (err)
|
||||
+ goto out_zlib;
|
||||
+
|
||||
ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr;
|
||||
return 0;
|
||||
|
||||
+out_zlib:
|
||||
+ compr_exit(&zlib_compr);
|
||||
out_lzo:
|
||||
compr_exit(&lzo_compr);
|
||||
return err;
|
||||
@@ -248,4 +272,5 @@ void ubifs_compressors_exit(void)
|
||||
{
|
||||
compr_exit(&lzo_compr);
|
||||
compr_exit(&zlib_compr);
|
||||
+ compr_exit(&xz_compr);
|
||||
}
|
||||
--- a/fs/ubifs/ubifs-media.h
|
||||
+++ b/fs/ubifs/ubifs-media.h
|
||||
@@ -332,12 +332,14 @@ enum {
|
||||
* UBIFS_COMPR_NONE: no compression
|
||||
* UBIFS_COMPR_LZO: LZO compression
|
||||
* UBIFS_COMPR_ZLIB: ZLIB compression
|
||||
+ * UBIFS_COMPR_XZ: XZ compression
|
||||
* UBIFS_COMPR_TYPES_CNT: count of supported compression types
|
||||
*/
|
||||
enum {
|
||||
UBIFS_COMPR_NONE,
|
||||
UBIFS_COMPR_LZO,
|
||||
UBIFS_COMPR_ZLIB,
|
||||
+ UBIFS_COMPR_XZ,
|
||||
UBIFS_COMPR_TYPES_CNT,
|
||||
};
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
--- a/fs/ubifs/file.c
|
||||
+++ b/fs/ubifs/file.c
|
||||
@@ -1575,6 +1575,12 @@ const struct inode_operations ubifs_syml
|
||||
.follow_link = ubifs_follow_link,
|
||||
.setattr = ubifs_setattr,
|
||||
.getattr = ubifs_getattr,
|
||||
+#ifdef CONFIG_UBIFS_FS_XATTR
|
||||
+ .setxattr = ubifs_setxattr,
|
||||
+ .getxattr = ubifs_getxattr,
|
||||
+ .listxattr = ubifs_listxattr,
|
||||
+ .removexattr = ubifs_removexattr,
|
||||
+#endif
|
||||
};
|
||||
|
||||
const struct file_operations ubifs_file_operations = {
|
||||
--- a/fs/ubifs/journal.c
|
||||
+++ b/fs/ubifs/journal.c
|
||||
@@ -553,7 +553,8 @@ int ubifs_jnl_update(struct ubifs_info *
|
||||
|
||||
dbg_jnl("ino %lu, dent '%.*s', data len %d in dir ino %lu",
|
||||
inode->i_ino, nm->len, nm->name, ui->data_len, dir->i_ino);
|
||||
- ubifs_assert(dir_ui->data_len == 0);
|
||||
+ if (!xent)
|
||||
+ ubifs_assert(dir_ui->data_len == 0);
|
||||
ubifs_assert(mutex_is_locked(&dir_ui->ui_mutex));
|
||||
|
||||
dlen = UBIFS_DENT_NODE_SZ + nm->len + 1;
|
||||
@@ -573,6 +574,13 @@ int ubifs_jnl_update(struct ubifs_info *
|
||||
aligned_dlen = ALIGN(dlen, 8);
|
||||
aligned_ilen = ALIGN(ilen, 8);
|
||||
len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ;
|
||||
+ if (xent) {
|
||||
+ /*
|
||||
+ * Make sure to account for dir_ui->data_len in
|
||||
+ * length calculation in case there is extended attribute.
|
||||
+ */
|
||||
+ len += dir_ui->data_len;
|
||||
+ }
|
||||
dent = kmalloc(len, GFP_NOFS);
|
||||
if (!dent)
|
||||
return -ENOMEM;
|
||||
@@ -649,7 +657,8 @@ int ubifs_jnl_update(struct ubifs_info *
|
||||
|
||||
ino_key_init(c, &ino_key, dir->i_ino);
|
||||
ino_offs += aligned_ilen;
|
||||
- err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, UBIFS_INO_NODE_SZ);
|
||||
+ err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs,
|
||||
+ UBIFS_INO_NODE_SZ + dir_ui->data_len);
|
||||
if (err)
|
||||
goto out_ro;
|
||||
|
||||
--- a/fs/ubifs/xattr.c
|
||||
+++ b/fs/ubifs/xattr.c
|
||||
@@ -211,12 +211,12 @@ static int change_xattr(struct ubifs_inf
|
||||
}
|
||||
memcpy(ui->data, value, size);
|
||||
inode->i_size = ui->ui_size = size;
|
||||
- ui->data_len = size;
|
||||
|
||||
mutex_lock(&host_ui->ui_mutex);
|
||||
host->i_ctime = ubifs_current_time(host);
|
||||
host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
|
||||
host_ui->xattr_size += CALC_XATTR_BYTES(size);
|
||||
+ ui->data_len = size;
|
||||
|
||||
/*
|
||||
* It is important to write the host inode after the xattr inode
|
File diff suppressed because it is too large
Load Diff
|
@ -1,108 +0,0 @@
|
|||
--- a/include/linux/netfilter/xt_layer7.h
|
||||
+++ b/include/linux/netfilter/xt_layer7.h
|
||||
@@ -8,6 +8,7 @@ struct xt_layer7_info {
|
||||
char protocol[MAX_PROTOCOL_LEN];
|
||||
char pattern[MAX_PATTERN_LEN];
|
||||
u_int8_t invert;
|
||||
+ u_int8_t pkt;
|
||||
};
|
||||
|
||||
#endif /* _XT_LAYER7_H */
|
||||
--- a/net/netfilter/xt_layer7.c
|
||||
+++ b/net/netfilter/xt_layer7.c
|
||||
@@ -314,33 +314,35 @@ static int match_no_append(struct nf_con
|
||||
}
|
||||
|
||||
/* add the new app data to the conntrack. Return number of bytes added. */
|
||||
-static int add_data(struct nf_conn * master_conntrack,
|
||||
- char * app_data, int appdatalen)
|
||||
+static int add_datastr(char *target, int offset, char *app_data, int len)
|
||||
{
|
||||
int length = 0, i;
|
||||
- int oldlength = master_conntrack->layer7.app_data_len;
|
||||
-
|
||||
- /* This is a fix for a race condition by Deti Fliegl. However, I'm not
|
||||
- clear on whether the race condition exists or whether this really
|
||||
- fixes it. I might just be being dense... Anyway, if it's not really
|
||||
- a fix, all it does is waste a very small amount of time. */
|
||||
- if(!master_conntrack->layer7.app_data) return 0;
|
||||
+ if (!target) return 0;
|
||||
|
||||
/* Strip nulls. Make everything lower case (our regex lib doesn't
|
||||
do case insensitivity). Add it to the end of the current data. */
|
||||
- for(i = 0; i < maxdatalen-oldlength-1 &&
|
||||
- i < appdatalen; i++) {
|
||||
+ for(i = 0; i < maxdatalen-offset-1 && i < len; i++) {
|
||||
if(app_data[i] != '\0') {
|
||||
/* the kernel version of tolower mungs 'upper ascii' */
|
||||
- master_conntrack->layer7.app_data[length+oldlength] =
|
||||
+ target[length+offset] =
|
||||
isascii(app_data[i])?
|
||||
tolower(app_data[i]) : app_data[i];
|
||||
length++;
|
||||
}
|
||||
}
|
||||
+ target[length+offset] = '\0';
|
||||
+
|
||||
+ return length;
|
||||
+}
|
||||
+
|
||||
+/* add the new app data to the conntrack. Return number of bytes added. */
|
||||
+static int add_data(struct nf_conn * master_conntrack,
|
||||
+ char * app_data, int appdatalen)
|
||||
+{
|
||||
+ int length;
|
||||
|
||||
- master_conntrack->layer7.app_data[length+oldlength] = '\0';
|
||||
- master_conntrack->layer7.app_data_len = length + oldlength;
|
||||
+ length = add_datastr(master_conntrack->layer7.app_data, master_conntrack->layer7.app_data_len, app_data, appdatalen);
|
||||
+ master_conntrack->layer7.app_data_len += length;
|
||||
|
||||
return length;
|
||||
}
|
||||
@@ -438,7 +440,7 @@ match(const struct sk_buff *skbin,
|
||||
|
||||
enum ip_conntrack_info master_ctinfo, ctinfo;
|
||||
struct nf_conn *master_conntrack, *conntrack;
|
||||
- unsigned char * app_data;
|
||||
+ unsigned char *app_data, *tmp_data;
|
||||
unsigned int pattern_result, appdatalen;
|
||||
regexp * comppattern;
|
||||
|
||||
@@ -466,8 +468,8 @@ match(const struct sk_buff *skbin,
|
||||
master_conntrack = master_ct(master_conntrack);
|
||||
|
||||
/* if we've classified it or seen too many packets */
|
||||
- if(total_acct_packets(master_conntrack) > num_packets ||
|
||||
- master_conntrack->layer7.app_proto) {
|
||||
+ if(!info->pkt && (total_acct_packets(master_conntrack) > num_packets ||
|
||||
+ master_conntrack->layer7.app_proto)) {
|
||||
|
||||
pattern_result = match_no_append(conntrack, master_conntrack,
|
||||
ctinfo, master_ctinfo, info);
|
||||
@@ -500,6 +502,25 @@ match(const struct sk_buff *skbin,
|
||||
/* the return value gets checked later, when we're ready to use it */
|
||||
comppattern = compile_and_cache(info->pattern, info->protocol);
|
||||
|
||||
+ if (info->pkt) {
|
||||
+ tmp_data = kmalloc(maxdatalen, GFP_ATOMIC);
|
||||
+ if(!tmp_data){
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_ERR "layer7: out of memory in match, bailing.\n");
|
||||
+ return info->invert;
|
||||
+ }
|
||||
+
|
||||
+ tmp_data[0] = '\0';
|
||||
+ add_datastr(tmp_data, 0, app_data, appdatalen);
|
||||
+ pattern_result = ((comppattern && regexec(comppattern, tmp_data)) ? 1 : 0);
|
||||
+
|
||||
+ kfree(tmp_data);
|
||||
+ tmp_data = NULL;
|
||||
+ spin_unlock_bh(&l7_lock);
|
||||
+
|
||||
+ return (pattern_result ^ info->invert);
|
||||
+ }
|
||||
+
|
||||
/* On the first packet of a connection, allocate space for app data */
|
||||
if(total_acct_packets(master_conntrack) == 1 && !skb->cb[0] &&
|
||||
!master_conntrack->layer7.app_data){
|
|
@ -1,51 +0,0 @@
|
|||
--- a/net/netfilter/xt_layer7.c
|
||||
+++ b/net/netfilter/xt_layer7.c
|
||||
@@ -415,7 +415,9 @@ static int layer7_write_proc(struct file
|
||||
}
|
||||
|
||||
static bool
|
||||
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
|
||||
+match(const struct sk_buff *skbin, struct xt_action_param *par)
|
||||
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
|
||||
match(const struct sk_buff *skbin, const struct xt_match_param *par)
|
||||
#else
|
||||
match(const struct sk_buff *skbin,
|
||||
@@ -597,14 +599,19 @@ match(const struct sk_buff *skbin,
|
||||
}
|
||||
|
||||
// load nf_conntrack_ipv4
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
|
||||
+static int
|
||||
+#else
|
||||
+static bool
|
||||
+#endif
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
|
||||
-static bool check(const struct xt_mtchk_param *par)
|
||||
+check(const struct xt_mtchk_param *par)
|
||||
{
|
||||
if (nf_ct_l3proto_try_module_get(par->match->family) < 0) {
|
||||
printk(KERN_WARNING "can't load conntrack support for "
|
||||
"proto=%d\n", par->match->family);
|
||||
#else
|
||||
-static bool check(const char *tablename, const void *inf,
|
||||
+check(const char *tablename, const void *inf,
|
||||
const struct xt_match *match, void *matchinfo,
|
||||
unsigned int hook_mask)
|
||||
{
|
||||
@@ -612,9 +619,15 @@ static bool check(const char *tablename,
|
||||
printk(KERN_WARNING "can't load conntrack support for "
|
||||
"proto=%d\n", match->family);
|
||||
#endif
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ return 0;
|
||||
+#else
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
+#endif
|
||||
}
|
||||
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
--- a/net/netfilter/Kconfig
|
||||
+++ b/net/netfilter/Kconfig
|
||||
@@ -830,6 +830,27 @@ config NETFILTER_XT_MATCH_IPVS
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
+config NETFILTER_XT_MATCH_LAYER7
|
||||
+ tristate '"layer7" match support'
|
||||
+ depends on EXPERIMENTAL
|
||||
+ depends on NETFILTER_XTABLES
|
||||
+ depends on NETFILTER_ADVANCED
|
||||
+ depends on NF_CONNTRACK
|
||||
+ help
|
||||
+ Say Y if you want to be able to classify connections (and their
|
||||
+ packets) based on regular expression matching of their application
|
||||
+ layer data. This is one way to classify applications such as
|
||||
+ peer-to-peer filesharing systems that do not always use the same
|
||||
+ port.
|
||||
+
|
||||
+ To compile it as a module, choose M here. If unsure, say N.
|
||||
+
|
||||
+config NETFILTER_XT_MATCH_LAYER7_DEBUG
|
||||
+ bool 'Layer 7 debugging output'
|
||||
+ depends on NETFILTER_XT_MATCH_LAYER7
|
||||
+ help
|
||||
+ Say Y to get lots of debugging output.
|
||||
+
|
||||
config NETFILTER_XT_MATCH_LENGTH
|
||||
tristate '"length" match support'
|
||||
depends on NETFILTER_ADVANCED
|
||||
@@ -1016,26 +1037,11 @@ config NETFILTER_XT_MATCH_STATE
|
||||
|
||||
To compile it as a module, choose M here. If unsure, say N.
|
||||
|
||||
-config NETFILTER_XT_MATCH_LAYER7
|
||||
- tristate '"layer7" match support'
|
||||
- depends on NETFILTER_XTABLES
|
||||
- depends on EXPERIMENTAL && (IP_NF_CONNTRACK || NF_CONNTRACK)
|
||||
- depends on NETFILTER_ADVANCED
|
||||
- help
|
||||
- Say Y if you want to be able to classify connections (and their
|
||||
- packets) based on regular expression matching of their application
|
||||
- layer data. This is one way to classify applications such as
|
||||
- peer-to-peer filesharing systems that do not always use the same
|
||||
- port.
|
||||
-
|
||||
- To compile it as a module, choose M here. If unsure, say N.
|
||||
-
|
||||
config NETFILTER_XT_MATCH_LAYER7_DEBUG
|
||||
- bool 'Layer 7 debugging output'
|
||||
- depends on NETFILTER_XT_MATCH_LAYER7
|
||||
- help
|
||||
- Say Y to get lots of debugging output.
|
||||
-
|
||||
+ bool 'Layer 7 debugging output'
|
||||
+ depends on NETFILTER_XT_MATCH_LAYER7
|
||||
+ help
|
||||
+ Say Y to get lots of debugging output.
|
||||
|
||||
config NETFILTER_XT_MATCH_STATISTIC
|
||||
tristate '"statistic" match support'
|
|
@ -1,118 +0,0 @@
|
|||
--- a/include/linux/netfilter/nf_conntrack_sip.h
|
||||
+++ b/include/linux/netfilter/nf_conntrack_sip.h
|
||||
@@ -2,12 +2,15 @@
|
||||
#define __NF_CONNTRACK_SIP_H__
|
||||
#ifdef __KERNEL__
|
||||
|
||||
+#include <linux/types.h>
|
||||
+
|
||||
#define SIP_PORT 5060
|
||||
#define SIP_TIMEOUT 3600
|
||||
|
||||
struct nf_ct_sip_master {
|
||||
unsigned int register_cseq;
|
||||
unsigned int invite_cseq;
|
||||
+ __be16 forced_dport;
|
||||
};
|
||||
|
||||
enum sip_expectation_classes {
|
||||
--- a/net/ipv4/netfilter/nf_nat_sip.c
|
||||
+++ b/net/ipv4/netfilter/nf_nat_sip.c
|
||||
@@ -73,6 +73,7 @@ static int map_addr(struct sk_buff *skb,
|
||||
enum ip_conntrack_info ctinfo;
|
||||
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
|
||||
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
|
||||
+ struct nf_conn_help *help = nfct_help(ct);
|
||||
char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
|
||||
unsigned int buflen;
|
||||
__be32 newaddr;
|
||||
@@ -85,7 +86,8 @@ static int map_addr(struct sk_buff *skb,
|
||||
} else if (ct->tuplehash[dir].tuple.dst.u3.ip == addr->ip &&
|
||||
ct->tuplehash[dir].tuple.dst.u.udp.port == port) {
|
||||
newaddr = ct->tuplehash[!dir].tuple.src.u3.ip;
|
||||
- newport = ct->tuplehash[!dir].tuple.src.u.udp.port;
|
||||
+ newport = help->help.ct_sip_info.forced_dport ? :
|
||||
+ ct->tuplehash[!dir].tuple.src.u.udp.port;
|
||||
} else
|
||||
return 1;
|
||||
|
||||
@@ -121,6 +123,7 @@ static unsigned int ip_nat_sip(struct sk
|
||||
enum ip_conntrack_info ctinfo;
|
||||
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
|
||||
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
|
||||
+ struct nf_conn_help *help = nfct_help(ct);
|
||||
unsigned int coff, matchoff, matchlen;
|
||||
enum sip_header_types hdr;
|
||||
union nf_inet_addr addr;
|
||||
@@ -229,6 +232,20 @@ next:
|
||||
!map_sip_addr(skb, dataoff, dptr, datalen, SIP_HDR_TO))
|
||||
return NF_DROP;
|
||||
|
||||
+ /* Mangle destination port for Cisco phones, then fix up checksums */
|
||||
+ if (dir == IP_CT_DIR_REPLY && help->help.ct_sip_info.forced_dport) {
|
||||
+ struct udphdr *uh;
|
||||
+
|
||||
+ if (!skb_make_writable(skb, skb->len))
|
||||
+ return NF_DROP;
|
||||
+
|
||||
+ uh = (struct udphdr *)(skb->data + ip_hdrlen(skb));
|
||||
+ uh->dest = help->help.ct_sip_info.forced_dport;
|
||||
+
|
||||
+ if (!nf_nat_mangle_udp_packet(skb, ct, ctinfo, 0, 0, NULL, 0))
|
||||
+ return NF_DROP;
|
||||
+ }
|
||||
+
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
@@ -280,8 +297,10 @@ static unsigned int ip_nat_sip_expect(st
|
||||
enum ip_conntrack_info ctinfo;
|
||||
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
|
||||
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
|
||||
+ struct nf_conn_help *help = nfct_help(ct);
|
||||
__be32 newip;
|
||||
u_int16_t port;
|
||||
+ __be16 srcport;
|
||||
char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
|
||||
unsigned buflen;
|
||||
|
||||
@@ -294,8 +313,9 @@ static unsigned int ip_nat_sip_expect(st
|
||||
/* If the signalling port matches the connection's source port in the
|
||||
* original direction, try to use the destination port in the opposite
|
||||
* direction. */
|
||||
- if (exp->tuple.dst.u.udp.port ==
|
||||
- ct->tuplehash[dir].tuple.src.u.udp.port)
|
||||
+ srcport = help->help.ct_sip_info.forced_dport ? :
|
||||
+ ct->tuplehash[dir].tuple.src.u.udp.port;
|
||||
+ if (exp->tuple.dst.u.udp.port == srcport)
|
||||
port = ntohs(ct->tuplehash[!dir].tuple.dst.u.udp.port);
|
||||
else
|
||||
port = ntohs(exp->tuple.dst.u.udp.port);
|
||||
--- a/net/netfilter/nf_conntrack_sip.c
|
||||
+++ b/net/netfilter/nf_conntrack_sip.c
|
||||
@@ -1363,8 +1363,25 @@ static int process_sip_request(struct sk
|
||||
{
|
||||
enum ip_conntrack_info ctinfo;
|
||||
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
|
||||
+ struct nf_conn_help *help = nfct_help(ct);
|
||||
+ enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
|
||||
unsigned int matchoff, matchlen;
|
||||
unsigned int cseq, i;
|
||||
+ union nf_inet_addr addr;
|
||||
+ __be16 port;
|
||||
+
|
||||
+ /* Many Cisco IP phones use a high source port for SIP requests, but
|
||||
+ * listen for the response on port 5060. If we are the local
|
||||
+ * router for one of these phones, save the port number from the
|
||||
+ * Via: header so that nf_nat_sip can redirect the responses to
|
||||
+ * the correct port.
|
||||
+ */
|
||||
+ if (ct_sip_parse_header_uri(ct, *dptr, NULL, *datalen,
|
||||
+ SIP_HDR_VIA_UDP, NULL, &matchoff,
|
||||
+ &matchlen, &addr, &port) > 0 &&
|
||||
+ port != ct->tuplehash[dir].tuple.src.u.udp.port &&
|
||||
+ nf_inet_addr_cmp(&addr, &ct->tuplehash[dir].tuple.src.u3))
|
||||
+ help->help.ct_sip_info.forced_dport = port;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) {
|
||||
const struct sip_handler *handler;
|
|
@ -1,93 +0,0 @@
|
|||
--- a/include/linux/netfilter_ipv4/ip_tables.h
|
||||
+++ b/include/linux/netfilter_ipv4/ip_tables.h
|
||||
@@ -93,6 +93,7 @@ struct ipt_ip {
|
||||
#define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */
|
||||
#define IPT_F_GOTO 0x02 /* Set if jump is a goto */
|
||||
#define IPT_F_MASK 0x03 /* All possible flag bits mask. */
|
||||
+#define IPT_F_NO_DEF_MATCH 0x80 /* Internal: no default match rules present */
|
||||
|
||||
/* Values for "inv" field in struct ipt_ip. */
|
||||
#define IPT_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */
|
||||
--- a/net/ipv4/netfilter/ip_tables.c
|
||||
+++ b/net/ipv4/netfilter/ip_tables.c
|
||||
@@ -81,6 +81,9 @@ ip_packet_match(const struct iphdr *ip,
|
||||
|
||||
#define FWINV(bool, invflg) ((bool) ^ !!(ipinfo->invflags & (invflg)))
|
||||
|
||||
+ if (ipinfo->flags & IPT_F_NO_DEF_MATCH)
|
||||
+ return true;
|
||||
+
|
||||
if (FWINV((ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr,
|
||||
IPT_INV_SRCIP) ||
|
||||
FWINV((ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr,
|
||||
@@ -134,6 +137,29 @@ ip_packet_match(const struct iphdr *ip,
|
||||
return true;
|
||||
}
|
||||
|
||||
+static void
|
||||
+ip_checkdefault(struct ipt_ip *ip)
|
||||
+{
|
||||
+ static const char iface_mask[IFNAMSIZ] = {};
|
||||
+
|
||||
+ if (ip->invflags || ip->flags & IPT_F_FRAG)
|
||||
+ return;
|
||||
+
|
||||
+ if (memcmp(ip->iniface_mask, iface_mask, IFNAMSIZ) != 0)
|
||||
+ return;
|
||||
+
|
||||
+ if (memcmp(ip->outiface_mask, iface_mask, IFNAMSIZ) != 0)
|
||||
+ return;
|
||||
+
|
||||
+ if (ip->smsk.s_addr || ip->dmsk.s_addr)
|
||||
+ return;
|
||||
+
|
||||
+ if (ip->proto)
|
||||
+ return;
|
||||
+
|
||||
+ ip->flags |= IPT_F_NO_DEF_MATCH;
|
||||
+}
|
||||
+
|
||||
static bool
|
||||
ip_checkentry(const struct ipt_ip *ip)
|
||||
{
|
||||
@@ -561,7 +587,7 @@ static void cleanup_match(struct xt_entr
|
||||
}
|
||||
|
||||
static int
|
||||
-check_entry(const struct ipt_entry *e, const char *name)
|
||||
+check_entry(struct ipt_entry *e, const char *name)
|
||||
{
|
||||
const struct xt_entry_target *t;
|
||||
|
||||
@@ -570,6 +596,8 @@ check_entry(const struct ipt_entry *e, c
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
+ ip_checkdefault(&e->ip);
|
||||
+
|
||||
if (e->target_offset + sizeof(struct xt_entry_target) >
|
||||
e->next_offset)
|
||||
return -EINVAL;
|
||||
@@ -931,6 +959,7 @@ copy_entries_to_user(unsigned int total_
|
||||
const struct xt_table_info *private = table->private;
|
||||
int ret = 0;
|
||||
const void *loc_cpu_entry;
|
||||
+ u8 flags;
|
||||
|
||||
counters = alloc_counters(table);
|
||||
if (IS_ERR(counters))
|
||||
@@ -961,6 +990,14 @@ copy_entries_to_user(unsigned int total_
|
||||
ret = -EFAULT;
|
||||
goto free_counters;
|
||||
}
|
||||
+
|
||||
+ flags = e->ip.flags & IPT_F_MASK;
|
||||
+ if (copy_to_user(userptr + off
|
||||
+ + offsetof(struct ipt_entry, ip.flags),
|
||||
+ &flags, sizeof(flags)) != 0) {
|
||||
+ ret = -EFAULT;
|
||||
+ goto free_counters;
|
||||
+ }
|
||||
|
||||
for (i = sizeof(struct ipt_entry);
|
||||
i < e->target_offset;
|
|
@ -1,81 +0,0 @@
|
|||
--- a/net/ipv4/netfilter/ip_tables.c
|
||||
+++ b/net/ipv4/netfilter/ip_tables.c
|
||||
@@ -310,6 +310,33 @@ struct ipt_entry *ipt_next_entry(const s
|
||||
return (void *)entry + entry->next_offset;
|
||||
}
|
||||
|
||||
+static bool
|
||||
+ipt_handle_default_rule(struct ipt_entry *e, unsigned int *verdict)
|
||||
+{
|
||||
+ struct xt_entry_target *t;
|
||||
+ struct xt_standard_target *st;
|
||||
+
|
||||
+ if (e->target_offset != sizeof(struct ipt_entry))
|
||||
+ return false;
|
||||
+
|
||||
+ if (!(e->ip.flags & IPT_F_NO_DEF_MATCH))
|
||||
+ return false;
|
||||
+
|
||||
+ t = ipt_get_target(e);
|
||||
+ if (t->u.kernel.target->target)
|
||||
+ return false;
|
||||
+
|
||||
+ st = (struct xt_standard_target *) t;
|
||||
+ if (st->verdict == XT_RETURN)
|
||||
+ return false;
|
||||
+
|
||||
+ if (st->verdict >= 0)
|
||||
+ return false;
|
||||
+
|
||||
+ *verdict = (unsigned)(-st->verdict) - 1;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
/* Returns one of the generic firewall policies, like NF_ACCEPT. */
|
||||
unsigned int
|
||||
ipt_do_table(struct sk_buff *skb,
|
||||
@@ -334,6 +361,25 @@ ipt_do_table(struct sk_buff *skb,
|
||||
ip = ip_hdr(skb);
|
||||
indev = in ? in->name : nulldevname;
|
||||
outdev = out ? out->name : nulldevname;
|
||||
+
|
||||
+ IP_NF_ASSERT(table->valid_hooks & (1 << hook));
|
||||
+ local_bh_disable();
|
||||
+ addend = xt_write_recseq_begin();
|
||||
+ private = table->private;
|
||||
+ cpu = smp_processor_id();
|
||||
+ table_base = private->entries[cpu];
|
||||
+ jumpstack = (struct ipt_entry **)private->jumpstack[cpu];
|
||||
+ stackptr = per_cpu_ptr(private->stackptr, cpu);
|
||||
+ origptr = *stackptr;
|
||||
+
|
||||
+ e = get_entry(table_base, private->hook_entry[hook]);
|
||||
+ if (ipt_handle_default_rule(e, &verdict)) {
|
||||
+ ADD_COUNTER(e->counters, skb->len, 1);
|
||||
+ xt_write_recseq_end(addend);
|
||||
+ local_bh_enable();
|
||||
+ return verdict;
|
||||
+ }
|
||||
+
|
||||
/* We handle fragments by dealing with the first fragment as
|
||||
* if it was a normal packet. All other fragments are treated
|
||||
* normally, except that they will NEVER match rules that ask
|
||||
@@ -348,18 +394,6 @@ ipt_do_table(struct sk_buff *skb,
|
||||
acpar.family = NFPROTO_IPV4;
|
||||
acpar.hooknum = hook;
|
||||
|
||||
- IP_NF_ASSERT(table->valid_hooks & (1 << hook));
|
||||
- local_bh_disable();
|
||||
- addend = xt_write_recseq_begin();
|
||||
- private = table->private;
|
||||
- cpu = smp_processor_id();
|
||||
- table_base = private->entries[cpu];
|
||||
- jumpstack = (struct ipt_entry **)private->jumpstack[cpu];
|
||||
- stackptr = per_cpu_ptr(private->stackptr, cpu);
|
||||
- origptr = *stackptr;
|
||||
-
|
||||
- e = get_entry(table_base, private->hook_entry[hook]);
|
||||
-
|
||||
pr_debug("Entering %s(hook %u); sp at %u (UF %p)\n",
|
||||
table->name, hook, origptr,
|
||||
get_entry(table_base, private->underflow[hook]));
|
|
@ -1,16 +0,0 @@
|
|||
--- a/net/ipv4/netfilter/ip_tables.c
|
||||
+++ b/net/ipv4/netfilter/ip_tables.c
|
||||
@@ -84,9 +84,11 @@ ip_packet_match(const struct iphdr *ip,
|
||||
if (ipinfo->flags & IPT_F_NO_DEF_MATCH)
|
||||
return true;
|
||||
|
||||
- if (FWINV((ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr,
|
||||
+ if (FWINV(ipinfo->smsk.s_addr &&
|
||||
+ (ip->saddr&ipinfo->smsk.s_addr) != ipinfo->src.s_addr,
|
||||
IPT_INV_SRCIP) ||
|
||||
- FWINV((ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr,
|
||||
+ FWINV(ipinfo->dmsk.s_addr &&
|
||||
+ (ip->daddr&ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr,
|
||||
IPT_INV_DSTIP)) {
|
||||
dprintf("Source or dest mismatch.\n");
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
--- a/net/netfilter/nf_conntrack_proto_tcp.c
|
||||
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
|
||||
@@ -29,6 +29,9 @@
|
||||
#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
|
||||
#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
|
||||
|
||||
+/* Do not check the TCP window for incoming packets */
|
||||
+static int nf_ct_tcp_no_window_check __read_mostly = 1;
|
||||
+
|
||||
/* "Be conservative in what you do,
|
||||
be liberal in what you accept from others."
|
||||
If it's non-zero, we mark only out of window RST segments as INVALID. */
|
||||
@@ -524,6 +527,9 @@ static bool tcp_in_window(const struct n
|
||||
s16 receiver_offset;
|
||||
bool res;
|
||||
|
||||
+ if (nf_ct_tcp_no_window_check)
|
||||
+ return true;
|
||||
+
|
||||
/*
|
||||
* Get the required data from the packet.
|
||||
*/
|
||||
@@ -1321,6 +1327,13 @@ static struct ctl_table tcp_sysctl_table
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{
|
||||
+ .procname = "nf_conntrack_tcp_no_window_check",
|
||||
+ .data = &nf_ct_tcp_no_window_check,
|
||||
+ .maxlen = sizeof(unsigned int),
|
||||
+ .mode = 0644,
|
||||
+ .proc_handler = proc_dointvec,
|
||||
+ },
|
||||
+ {
|
||||
.procname = "nf_conntrack_tcp_be_liberal",
|
||||
.data = &nf_ct_tcp_be_liberal,
|
||||
.maxlen = sizeof(unsigned int),
|
|
@ -1,795 +0,0 @@
|
|||
--- a/include/linux/pkt_sched.h
|
||||
+++ b/include/linux/pkt_sched.h
|
||||
@@ -173,8 +173,37 @@ struct tc_sfq_xstats {
|
||||
*
|
||||
* The only reason for this is efficiency, it is possible
|
||||
* to change these parameters in compile time.
|
||||
+ *
|
||||
+ * If you need to play with these values, use esfq instead.
|
||||
*/
|
||||
|
||||
+/* ESFQ section */
|
||||
+
|
||||
+enum
|
||||
+{
|
||||
+ /* traditional */
|
||||
+ TCA_SFQ_HASH_CLASSIC,
|
||||
+ TCA_SFQ_HASH_DST,
|
||||
+ TCA_SFQ_HASH_SRC,
|
||||
+ TCA_SFQ_HASH_FWMARK,
|
||||
+ /* conntrack */
|
||||
+ TCA_SFQ_HASH_CTORIGDST,
|
||||
+ TCA_SFQ_HASH_CTORIGSRC,
|
||||
+ TCA_SFQ_HASH_CTREPLDST,
|
||||
+ TCA_SFQ_HASH_CTREPLSRC,
|
||||
+ TCA_SFQ_HASH_CTNATCHG,
|
||||
+};
|
||||
+
|
||||
+struct tc_esfq_qopt
|
||||
+{
|
||||
+ unsigned quantum; /* Bytes per round allocated to flow */
|
||||
+ int perturb_period; /* Period of hash perturbation */
|
||||
+ __u32 limit; /* Maximal packets in queue */
|
||||
+ unsigned divisor; /* Hash divisor */
|
||||
+ unsigned flows; /* Maximal number of flows */
|
||||
+ unsigned hash_kind; /* Hash function to use for flow identification */
|
||||
+};
|
||||
+
|
||||
/* RED section */
|
||||
|
||||
enum {
|
||||
--- a/net/sched/Kconfig
|
||||
+++ b/net/sched/Kconfig
|
||||
@@ -148,6 +148,37 @@ config NET_SCH_SFQ
|
||||
To compile this code as a module, choose M here: the
|
||||
module will be called sch_sfq.
|
||||
|
||||
+config NET_SCH_ESFQ
|
||||
+ tristate "Enhanced Stochastic Fairness Queueing (ESFQ)"
|
||||
+ ---help---
|
||||
+ Say Y here if you want to use the Enhanced Stochastic Fairness
|
||||
+ Queueing (ESFQ) packet scheduling algorithm for some of your network
|
||||
+ devices or as a leaf discipline for a classful qdisc such as HTB or
|
||||
+ CBQ (see the top of <file:net/sched/sch_esfq.c> for details and
|
||||
+ references to the SFQ algorithm).
|
||||
+
|
||||
+ This is an enchanced SFQ version which allows you to control some
|
||||
+ hardcoded values in the SFQ scheduler.
|
||||
+
|
||||
+ ESFQ also adds control of the hash function used to identify packet
|
||||
+ flows. The original SFQ discipline hashes by connection; ESFQ add
|
||||
+ several other hashing methods, such as by src IP or by dst IP, which
|
||||
+ can be more fair to users in some networking situations.
|
||||
+
|
||||
+ To compile this code as a module, choose M here: the
|
||||
+ module will be called sch_esfq.
|
||||
+
|
||||
+config NET_SCH_ESFQ_NFCT
|
||||
+ bool "Connection Tracking Hash Types"
|
||||
+ depends on NET_SCH_ESFQ && NF_CONNTRACK
|
||||
+ ---help---
|
||||
+ Say Y here to enable support for hashing based on netfilter connection
|
||||
+ tracking information. This is useful for a router that is also using
|
||||
+ NAT to connect privately-addressed hosts to the Internet. If you want
|
||||
+ to provide fair distribution of upstream bandwidth, ESFQ must use
|
||||
+ connection tracking information, since all outgoing packets will share
|
||||
+ the same source address.
|
||||
+
|
||||
config NET_SCH_TEQL
|
||||
tristate "True Link Equalizer (TEQL)"
|
||||
---help---
|
||||
--- a/net/sched/Makefile
|
||||
+++ b/net/sched/Makefile
|
||||
@@ -26,6 +26,7 @@ obj-$(CONFIG_NET_SCH_INGRESS) += sch_ing
|
||||
obj-$(CONFIG_NET_SCH_DSMARK) += sch_dsmark.o
|
||||
obj-$(CONFIG_NET_SCH_SFB) += sch_sfb.o
|
||||
obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o
|
||||
+obj-$(CONFIG_NET_SCH_ESFQ) += sch_esfq.o
|
||||
obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o
|
||||
obj-$(CONFIG_NET_SCH_TEQL) += sch_teql.o
|
||||
obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
|
||||
--- /dev/null
|
||||
+++ b/net/sched/sch_esfq.c
|
||||
@@ -0,0 +1,702 @@
|
||||
+/*
|
||||
+ * net/sched/sch_esfq.c Extended Stochastic Fairness Queueing discipline.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU General Public License
|
||||
+ * as published by the Free Software Foundation; either version
|
||||
+ * 2 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
||||
+ *
|
||||
+ * Changes: Alexander Atanasov, <alex@ssi.bg>
|
||||
+ * Added dynamic depth,limit,divisor,hash_kind options.
|
||||
+ * Added dst and src hashes.
|
||||
+ *
|
||||
+ * Alexander Clouter, <alex@digriz.org.uk>
|
||||
+ * Ported ESFQ to Linux 2.6.
|
||||
+ *
|
||||
+ * Corey Hickey, <bugfood-c@fatooh.org>
|
||||
+ * Maintenance of the Linux 2.6 port.
|
||||
+ * Added fwmark hash (thanks to Robert Kurjata).
|
||||
+ * Added usage of jhash.
|
||||
+ * Added conntrack support.
|
||||
+ * Added ctnatchg hash (thanks to Ben Pfountz).
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <asm/uaccess.h>
|
||||
+#include <asm/system.h>
|
||||
+#include <linux/bitops.h>
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/jiffies.h>
|
||||
+#include <linux/string.h>
|
||||
+#include <linux/mm.h>
|
||||
+#include <linux/socket.h>
|
||||
+#include <linux/sockios.h>
|
||||
+#include <linux/in.h>
|
||||
+#include <linux/errno.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/if_ether.h>
|
||||
+#include <linux/inet.h>
|
||||
+#include <linux/netdevice.h>
|
||||
+#include <linux/etherdevice.h>
|
||||
+#include <linux/notifier.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <net/ip.h>
|
||||
+#include <net/netlink.h>
|
||||
+#include <linux/ipv6.h>
|
||||
+#include <net/route.h>
|
||||
+#include <linux/skbuff.h>
|
||||
+#include <net/sock.h>
|
||||
+#include <net/pkt_sched.h>
|
||||
+#include <linux/jhash.h>
|
||||
+#ifdef CONFIG_NET_SCH_ESFQ_NFCT
|
||||
+#include <net/netfilter/nf_conntrack.h>
|
||||
+#endif
|
||||
+
|
||||
+/* Stochastic Fairness Queuing algorithm.
|
||||
+ For more comments look at sch_sfq.c.
|
||||
+ The difference is that you can change limit, depth,
|
||||
+ hash table size and choose alternate hash types.
|
||||
+
|
||||
+ classic: same as in sch_sfq.c
|
||||
+ dst: destination IP address
|
||||
+ src: source IP address
|
||||
+ fwmark: netfilter mark value
|
||||
+ ctorigdst: original destination IP address
|
||||
+ ctorigsrc: original source IP address
|
||||
+ ctrepldst: reply destination IP address
|
||||
+ ctreplsrc: reply source IP
|
||||
+
|
||||
+*/
|
||||
+
|
||||
+#define ESFQ_HEAD 0
|
||||
+#define ESFQ_TAIL 1
|
||||
+
|
||||
+/* This type should contain at least SFQ_DEPTH*2 values */
|
||||
+typedef unsigned int esfq_index;
|
||||
+
|
||||
+struct esfq_head
|
||||
+{
|
||||
+ esfq_index next;
|
||||
+ esfq_index prev;
|
||||
+};
|
||||
+
|
||||
+struct esfq_sched_data
|
||||
+{
|
||||
+/* Parameters */
|
||||
+ int perturb_period;
|
||||
+ unsigned quantum; /* Allotment per round: MUST BE >= MTU */
|
||||
+ int limit;
|
||||
+ unsigned depth;
|
||||
+ unsigned hash_divisor;
|
||||
+ unsigned hash_kind;
|
||||
+/* Variables */
|
||||
+ struct timer_list perturb_timer;
|
||||
+ int perturbation;
|
||||
+ esfq_index tail; /* Index of current slot in round */
|
||||
+ esfq_index max_depth; /* Maximal depth */
|
||||
+
|
||||
+ esfq_index *ht; /* Hash table */
|
||||
+ esfq_index *next; /* Active slots link */
|
||||
+ short *allot; /* Current allotment per slot */
|
||||
+ unsigned short *hash; /* Hash value indexed by slots */
|
||||
+ struct sk_buff_head *qs; /* Slot queue */
|
||||
+ struct esfq_head *dep; /* Linked list of slots, indexed by depth */
|
||||
+};
|
||||
+
|
||||
+/* This contains the info we will hash. */
|
||||
+struct esfq_packet_info
|
||||
+{
|
||||
+ u32 proto; /* protocol or port */
|
||||
+ u32 src; /* source from packet header */
|
||||
+ u32 dst; /* destination from packet header */
|
||||
+ u32 ctorigsrc; /* original source from conntrack */
|
||||
+ u32 ctorigdst; /* original destination from conntrack */
|
||||
+ u32 ctreplsrc; /* reply source from conntrack */
|
||||
+ u32 ctrepldst; /* reply destination from conntrack */
|
||||
+ u32 mark; /* netfilter mark (fwmark) */
|
||||
+};
|
||||
+
|
||||
+static __inline__ unsigned esfq_jhash_1word(struct esfq_sched_data *q,u32 a)
|
||||
+{
|
||||
+ return jhash_1word(a, q->perturbation) & (q->hash_divisor-1);
|
||||
+}
|
||||
+
|
||||
+static __inline__ unsigned esfq_jhash_2words(struct esfq_sched_data *q, u32 a, u32 b)
|
||||
+{
|
||||
+ return jhash_2words(a, b, q->perturbation) & (q->hash_divisor-1);
|
||||
+}
|
||||
+
|
||||
+static __inline__ unsigned esfq_jhash_3words(struct esfq_sched_data *q, u32 a, u32 b, u32 c)
|
||||
+{
|
||||
+ return jhash_3words(a, b, c, q->perturbation) & (q->hash_divisor-1);
|
||||
+}
|
||||
+
|
||||
+static unsigned esfq_hash(struct esfq_sched_data *q, struct sk_buff *skb)
|
||||
+{
|
||||
+ struct esfq_packet_info info;
|
||||
+#ifdef CONFIG_NET_SCH_ESFQ_NFCT
|
||||
+ enum ip_conntrack_info ctinfo;
|
||||
+ struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
|
||||
+#endif
|
||||
+
|
||||
+ switch (skb->protocol) {
|
||||
+ case __constant_htons(ETH_P_IP):
|
||||
+ {
|
||||
+ struct iphdr *iph = ip_hdr(skb);
|
||||
+ info.dst = iph->daddr;
|
||||
+ info.src = iph->saddr;
|
||||
+ if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
|
||||
+ (iph->protocol == IPPROTO_TCP ||
|
||||
+ iph->protocol == IPPROTO_UDP ||
|
||||
+ iph->protocol == IPPROTO_SCTP ||
|
||||
+ iph->protocol == IPPROTO_DCCP ||
|
||||
+ iph->protocol == IPPROTO_ESP))
|
||||
+ info.proto = *(((u32*)iph) + iph->ihl);
|
||||
+ else
|
||||
+ info.proto = iph->protocol;
|
||||
+ break;
|
||||
+ }
|
||||
+ case __constant_htons(ETH_P_IPV6):
|
||||
+ {
|
||||
+ struct ipv6hdr *iph = ipv6_hdr(skb);
|
||||
+ /* Hash ipv6 addresses into a u32. This isn't ideal,
|
||||
+ * but the code is simple. */
|
||||
+ info.dst = jhash2(iph->daddr.s6_addr32, 4, q->perturbation);
|
||||
+ info.src = jhash2(iph->saddr.s6_addr32, 4, q->perturbation);
|
||||
+ if (iph->nexthdr == IPPROTO_TCP ||
|
||||
+ iph->nexthdr == IPPROTO_UDP ||
|
||||
+ iph->nexthdr == IPPROTO_SCTP ||
|
||||
+ iph->nexthdr == IPPROTO_DCCP ||
|
||||
+ iph->nexthdr == IPPROTO_ESP)
|
||||
+ info.proto = *(u32*)&iph[1];
|
||||
+ else
|
||||
+ info.proto = iph->nexthdr;
|
||||
+ break;
|
||||
+ }
|
||||
+ default:
|
||||
+ info.dst = (u32)(unsigned long)skb_dst(skb);
|
||||
+ info.src = (u32)(unsigned long)skb->sk;
|
||||
+ info.proto = skb->protocol;
|
||||
+ }
|
||||
+
|
||||
+ info.mark = skb->mark;
|
||||
+
|
||||
+#ifdef CONFIG_NET_SCH_ESFQ_NFCT
|
||||
+ /* defaults if there is no conntrack info */
|
||||
+ info.ctorigsrc = info.src;
|
||||
+ info.ctorigdst = info.dst;
|
||||
+ info.ctreplsrc = info.dst;
|
||||
+ info.ctrepldst = info.src;
|
||||
+ /* collect conntrack info */
|
||||
+ if (ct && ct != &nf_conntrack_untracked) {
|
||||
+ if (skb->protocol == __constant_htons(ETH_P_IP)) {
|
||||
+ info.ctorigsrc = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip;
|
||||
+ info.ctorigdst = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip;
|
||||
+ info.ctreplsrc = ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip;
|
||||
+ info.ctrepldst = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip;
|
||||
+ }
|
||||
+ else if (skb->protocol == __constant_htons(ETH_P_IPV6)) {
|
||||
+ /* Again, hash ipv6 addresses into a single u32. */
|
||||
+ info.ctorigsrc = jhash2(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip6, 4, q->perturbation);
|
||||
+ info.ctorigdst = jhash2(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3.ip6, 4, q->perturbation);
|
||||
+ info.ctreplsrc = jhash2(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip6, 4, q->perturbation);
|
||||
+ info.ctrepldst = jhash2(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip6, 4, q->perturbation);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ switch(q->hash_kind) {
|
||||
+ case TCA_SFQ_HASH_CLASSIC:
|
||||
+ return esfq_jhash_3words(q, info.dst, info.src, info.proto);
|
||||
+ case TCA_SFQ_HASH_DST:
|
||||
+ return esfq_jhash_1word(q, info.dst);
|
||||
+ case TCA_SFQ_HASH_SRC:
|
||||
+ return esfq_jhash_1word(q, info.src);
|
||||
+ case TCA_SFQ_HASH_FWMARK:
|
||||
+ return esfq_jhash_1word(q, info.mark);
|
||||
+#ifdef CONFIG_NET_SCH_ESFQ_NFCT
|
||||
+ case TCA_SFQ_HASH_CTORIGDST:
|
||||
+ return esfq_jhash_1word(q, info.ctorigdst);
|
||||
+ case TCA_SFQ_HASH_CTORIGSRC:
|
||||
+ return esfq_jhash_1word(q, info.ctorigsrc);
|
||||
+ case TCA_SFQ_HASH_CTREPLDST:
|
||||
+ return esfq_jhash_1word(q, info.ctrepldst);
|
||||
+ case TCA_SFQ_HASH_CTREPLSRC:
|
||||
+ return esfq_jhash_1word(q, info.ctreplsrc);
|
||||
+ case TCA_SFQ_HASH_CTNATCHG:
|
||||
+ {
|
||||
+ if (info.ctorigdst == info.ctreplsrc)
|
||||
+ return esfq_jhash_1word(q, info.ctorigsrc);
|
||||
+ return esfq_jhash_1word(q, info.ctreplsrc);
|
||||
+ }
|
||||
+#endif
|
||||
+ default:
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_WARNING "ESFQ: Unknown hash method. Falling back to classic.\n");
|
||||
+ }
|
||||
+ return esfq_jhash_3words(q, info.dst, info.src, info.proto);
|
||||
+}
|
||||
+
|
||||
+static inline void esfq_link(struct esfq_sched_data *q, esfq_index x)
|
||||
+{
|
||||
+ esfq_index p, n;
|
||||
+ int d = q->qs[x].qlen + q->depth;
|
||||
+
|
||||
+ p = d;
|
||||
+ n = q->dep[d].next;
|
||||
+ q->dep[x].next = n;
|
||||
+ q->dep[x].prev = p;
|
||||
+ q->dep[p].next = q->dep[n].prev = x;
|
||||
+}
|
||||
+
|
||||
+static inline void esfq_dec(struct esfq_sched_data *q, esfq_index x)
|
||||
+{
|
||||
+ esfq_index p, n;
|
||||
+
|
||||
+ n = q->dep[x].next;
|
||||
+ p = q->dep[x].prev;
|
||||
+ q->dep[p].next = n;
|
||||
+ q->dep[n].prev = p;
|
||||
+
|
||||
+ if (n == p && q->max_depth == q->qs[x].qlen + 1)
|
||||
+ q->max_depth--;
|
||||
+
|
||||
+ esfq_link(q, x);
|
||||
+}
|
||||
+
|
||||
+static inline void esfq_inc(struct esfq_sched_data *q, esfq_index x)
|
||||
+{
|
||||
+ esfq_index p, n;
|
||||
+ int d;
|
||||
+
|
||||
+ n = q->dep[x].next;
|
||||
+ p = q->dep[x].prev;
|
||||
+ q->dep[p].next = n;
|
||||
+ q->dep[n].prev = p;
|
||||
+ d = q->qs[x].qlen;
|
||||
+ if (q->max_depth < d)
|
||||
+ q->max_depth = d;
|
||||
+
|
||||
+ esfq_link(q, x);
|
||||
+}
|
||||
+
|
||||
+static unsigned int esfq_drop(struct Qdisc *sch)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ esfq_index d = q->max_depth;
|
||||
+ struct sk_buff *skb;
|
||||
+ unsigned int len;
|
||||
+
|
||||
+ /* Queue is full! Find the longest slot and
|
||||
+ drop a packet from it */
|
||||
+
|
||||
+ if (d > 1) {
|
||||
+ esfq_index x = q->dep[d+q->depth].next;
|
||||
+ skb = q->qs[x].prev;
|
||||
+ len = skb->len;
|
||||
+ __skb_unlink(skb, &q->qs[x]);
|
||||
+ kfree_skb(skb);
|
||||
+ esfq_dec(q, x);
|
||||
+ sch->q.qlen--;
|
||||
+ sch->qstats.drops++;
|
||||
+ sch->qstats.backlog -= len;
|
||||
+ return len;
|
||||
+ }
|
||||
+
|
||||
+ if (d == 1) {
|
||||
+ /* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */
|
||||
+ d = q->next[q->tail];
|
||||
+ q->next[q->tail] = q->next[d];
|
||||
+ q->allot[q->next[d]] += q->quantum;
|
||||
+ skb = q->qs[d].prev;
|
||||
+ len = skb->len;
|
||||
+ __skb_unlink(skb, &q->qs[d]);
|
||||
+ kfree_skb(skb);
|
||||
+ esfq_dec(q, d);
|
||||
+ sch->q.qlen--;
|
||||
+ q->ht[q->hash[d]] = q->depth;
|
||||
+ sch->qstats.drops++;
|
||||
+ sch->qstats.backlog -= len;
|
||||
+ return len;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void esfq_q_enqueue(struct sk_buff *skb, struct esfq_sched_data *q, unsigned int end)
|
||||
+{
|
||||
+ unsigned hash = esfq_hash(q, skb);
|
||||
+ unsigned depth = q->depth;
|
||||
+ esfq_index x;
|
||||
+
|
||||
+ x = q->ht[hash];
|
||||
+ if (x == depth) {
|
||||
+ q->ht[hash] = x = q->dep[depth].next;
|
||||
+ q->hash[x] = hash;
|
||||
+ }
|
||||
+
|
||||
+ if (end == ESFQ_TAIL)
|
||||
+ __skb_queue_tail(&q->qs[x], skb);
|
||||
+ else
|
||||
+ __skb_queue_head(&q->qs[x], skb);
|
||||
+
|
||||
+ esfq_inc(q, x);
|
||||
+ if (q->qs[x].qlen == 1) { /* The flow is new */
|
||||
+ if (q->tail == depth) { /* It is the first flow */
|
||||
+ q->tail = x;
|
||||
+ q->next[x] = x;
|
||||
+ q->allot[x] = q->quantum;
|
||||
+ } else {
|
||||
+ q->next[x] = q->next[q->tail];
|
||||
+ q->next[q->tail] = x;
|
||||
+ q->tail = x;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int esfq_enqueue(struct sk_buff *skb, struct Qdisc* sch)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ esfq_q_enqueue(skb, q, ESFQ_TAIL);
|
||||
+ sch->qstats.backlog += skb->len;
|
||||
+ if (++sch->q.qlen < q->limit-1) {
|
||||
+ sch->bstats.bytes += skb->len;
|
||||
+ sch->bstats.packets++;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ sch->qstats.drops++;
|
||||
+ esfq_drop(sch);
|
||||
+ return NET_XMIT_CN;
|
||||
+}
|
||||
+
|
||||
+static struct sk_buff *esfq_peek(struct Qdisc* sch)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ esfq_index a;
|
||||
+
|
||||
+ /* No active slots */
|
||||
+ if (q->tail == q->depth)
|
||||
+ return NULL;
|
||||
+
|
||||
+ a = q->next[q->tail];
|
||||
+ return skb_peek(&q->qs[a]);
|
||||
+}
|
||||
+
|
||||
+static struct sk_buff *esfq_q_dequeue(struct esfq_sched_data *q)
|
||||
+{
|
||||
+ struct sk_buff *skb;
|
||||
+ unsigned depth = q->depth;
|
||||
+ esfq_index a, old_a;
|
||||
+
|
||||
+ /* No active slots */
|
||||
+ if (q->tail == depth)
|
||||
+ return NULL;
|
||||
+
|
||||
+ a = old_a = q->next[q->tail];
|
||||
+
|
||||
+ /* Grab packet */
|
||||
+ skb = __skb_dequeue(&q->qs[a]);
|
||||
+ esfq_dec(q, a);
|
||||
+
|
||||
+ /* Is the slot empty? */
|
||||
+ if (q->qs[a].qlen == 0) {
|
||||
+ q->ht[q->hash[a]] = depth;
|
||||
+ a = q->next[a];
|
||||
+ if (a == old_a) {
|
||||
+ q->tail = depth;
|
||||
+ return skb;
|
||||
+ }
|
||||
+ q->next[q->tail] = a;
|
||||
+ q->allot[a] += q->quantum;
|
||||
+ } else if ((q->allot[a] -= skb->len) <= 0) {
|
||||
+ q->tail = a;
|
||||
+ a = q->next[a];
|
||||
+ q->allot[a] += q->quantum;
|
||||
+ }
|
||||
+
|
||||
+ return skb;
|
||||
+}
|
||||
+
|
||||
+static struct sk_buff *esfq_dequeue(struct Qdisc* sch)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ struct sk_buff *skb;
|
||||
+
|
||||
+ skb = esfq_q_dequeue(q);
|
||||
+ if (skb == NULL)
|
||||
+ return NULL;
|
||||
+ sch->q.qlen--;
|
||||
+ sch->qstats.backlog -= skb->len;
|
||||
+ return skb;
|
||||
+}
|
||||
+
|
||||
+static void esfq_q_destroy(struct esfq_sched_data *q)
|
||||
+{
|
||||
+ del_timer(&q->perturb_timer);
|
||||
+ if(q->ht)
|
||||
+ kfree(q->ht);
|
||||
+ if(q->dep)
|
||||
+ kfree(q->dep);
|
||||
+ if(q->next)
|
||||
+ kfree(q->next);
|
||||
+ if(q->allot)
|
||||
+ kfree(q->allot);
|
||||
+ if(q->hash)
|
||||
+ kfree(q->hash);
|
||||
+ if(q->qs)
|
||||
+ kfree(q->qs);
|
||||
+}
|
||||
+
|
||||
+static void esfq_destroy(struct Qdisc *sch)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ esfq_q_destroy(q);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void esfq_reset(struct Qdisc* sch)
|
||||
+{
|
||||
+ struct sk_buff *skb;
|
||||
+
|
||||
+ while ((skb = esfq_dequeue(sch)) != NULL)
|
||||
+ kfree_skb(skb);
|
||||
+}
|
||||
+
|
||||
+static void esfq_perturbation(unsigned long arg)
|
||||
+{
|
||||
+ struct Qdisc *sch = (struct Qdisc*)arg;
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+
|
||||
+ q->perturbation = net_random()&0x1F;
|
||||
+
|
||||
+ if (q->perturb_period) {
|
||||
+ q->perturb_timer.expires = jiffies + q->perturb_period;
|
||||
+ add_timer(&q->perturb_timer);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static unsigned int esfq_check_hash(unsigned int kind)
|
||||
+{
|
||||
+ switch (kind) {
|
||||
+ case TCA_SFQ_HASH_CTORIGDST:
|
||||
+ case TCA_SFQ_HASH_CTORIGSRC:
|
||||
+ case TCA_SFQ_HASH_CTREPLDST:
|
||||
+ case TCA_SFQ_HASH_CTREPLSRC:
|
||||
+ case TCA_SFQ_HASH_CTNATCHG:
|
||||
+#ifndef CONFIG_NET_SCH_ESFQ_NFCT
|
||||
+ {
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_WARNING "ESFQ: Conntrack hash types disabled in kernel config. Falling back to classic.\n");
|
||||
+ return TCA_SFQ_HASH_CLASSIC;
|
||||
+ }
|
||||
+#endif
|
||||
+ case TCA_SFQ_HASH_CLASSIC:
|
||||
+ case TCA_SFQ_HASH_DST:
|
||||
+ case TCA_SFQ_HASH_SRC:
|
||||
+ case TCA_SFQ_HASH_FWMARK:
|
||||
+ return kind;
|
||||
+ default:
|
||||
+ {
|
||||
+ if (net_ratelimit())
|
||||
+ printk(KERN_WARNING "ESFQ: Unknown hash type. Falling back to classic.\n");
|
||||
+ return TCA_SFQ_HASH_CLASSIC;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int esfq_q_init(struct esfq_sched_data *q, struct nlattr *opt)
|
||||
+{
|
||||
+ struct tc_esfq_qopt *ctl = nla_data(opt);
|
||||
+ esfq_index p = ~0U/2;
|
||||
+ int i;
|
||||
+
|
||||
+ if (opt && opt->nla_len < nla_attr_size(sizeof(*ctl)))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ q->perturbation = 0;
|
||||
+ q->hash_kind = TCA_SFQ_HASH_CLASSIC;
|
||||
+ q->max_depth = 0;
|
||||
+ if (opt == NULL) {
|
||||
+ q->perturb_period = 0;
|
||||
+ q->hash_divisor = 1024;
|
||||
+ q->tail = q->limit = q->depth = 128;
|
||||
+
|
||||
+ } else {
|
||||
+ struct tc_esfq_qopt *ctl = nla_data(opt);
|
||||
+ if (ctl->quantum)
|
||||
+ q->quantum = ctl->quantum;
|
||||
+ q->perturb_period = ctl->perturb_period*HZ;
|
||||
+ q->hash_divisor = ctl->divisor ? : 1024;
|
||||
+ q->tail = q->limit = q->depth = ctl->flows ? : 128;
|
||||
+
|
||||
+ if ( q->depth > p - 1 )
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (ctl->limit)
|
||||
+ q->limit = min_t(u32, ctl->limit, q->depth);
|
||||
+
|
||||
+ if (ctl->hash_kind) {
|
||||
+ q->hash_kind = esfq_check_hash(ctl->hash_kind);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ q->ht = kmalloc(q->hash_divisor*sizeof(esfq_index), GFP_KERNEL);
|
||||
+ if (!q->ht)
|
||||
+ goto err_case;
|
||||
+ q->dep = kmalloc((1+q->depth*2)*sizeof(struct esfq_head), GFP_KERNEL);
|
||||
+ if (!q->dep)
|
||||
+ goto err_case;
|
||||
+ q->next = kmalloc(q->depth*sizeof(esfq_index), GFP_KERNEL);
|
||||
+ if (!q->next)
|
||||
+ goto err_case;
|
||||
+ q->allot = kmalloc(q->depth*sizeof(short), GFP_KERNEL);
|
||||
+ if (!q->allot)
|
||||
+ goto err_case;
|
||||
+ q->hash = kmalloc(q->depth*sizeof(unsigned short), GFP_KERNEL);
|
||||
+ if (!q->hash)
|
||||
+ goto err_case;
|
||||
+ q->qs = kmalloc(q->depth*sizeof(struct sk_buff_head), GFP_KERNEL);
|
||||
+ if (!q->qs)
|
||||
+ goto err_case;
|
||||
+
|
||||
+ for (i=0; i< q->hash_divisor; i++)
|
||||
+ q->ht[i] = q->depth;
|
||||
+ for (i=0; i<q->depth; i++) {
|
||||
+ skb_queue_head_init(&q->qs[i]);
|
||||
+ q->dep[i+q->depth].next = i+q->depth;
|
||||
+ q->dep[i+q->depth].prev = i+q->depth;
|
||||
+ }
|
||||
+
|
||||
+ for (i=0; i<q->depth; i++)
|
||||
+ esfq_link(q, i);
|
||||
+ return 0;
|
||||
+err_case:
|
||||
+ esfq_q_destroy(q);
|
||||
+ return -ENOBUFS;
|
||||
+}
|
||||
+
|
||||
+static int esfq_init(struct Qdisc *sch, struct nlattr *opt)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ int err;
|
||||
+
|
||||
+ q->quantum = psched_mtu(qdisc_dev(sch)); /* default */
|
||||
+ if ((err = esfq_q_init(q, opt)))
|
||||
+ return err;
|
||||
+
|
||||
+ init_timer(&q->perturb_timer);
|
||||
+ q->perturb_timer.data = (unsigned long)sch;
|
||||
+ q->perturb_timer.function = esfq_perturbation;
|
||||
+ if (q->perturb_period) {
|
||||
+ q->perturb_timer.expires = jiffies + q->perturb_period;
|
||||
+ add_timer(&q->perturb_timer);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int esfq_change(struct Qdisc *sch, struct nlattr *opt)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ struct esfq_sched_data new;
|
||||
+ struct sk_buff *skb;
|
||||
+ int err;
|
||||
+
|
||||
+ /* set up new queue */
|
||||
+ memset(&new, 0, sizeof(struct esfq_sched_data));
|
||||
+ new.quantum = psched_mtu(qdisc_dev(sch)); /* default */
|
||||
+ if ((err = esfq_q_init(&new, opt)))
|
||||
+ return err;
|
||||
+
|
||||
+ /* copy all packets from the old queue to the new queue */
|
||||
+ sch_tree_lock(sch);
|
||||
+ while ((skb = esfq_q_dequeue(q)) != NULL)
|
||||
+ esfq_q_enqueue(skb, &new, ESFQ_TAIL);
|
||||
+
|
||||
+ /* clean up the old queue */
|
||||
+ esfq_q_destroy(q);
|
||||
+
|
||||
+ /* copy elements of the new queue into the old queue */
|
||||
+ q->perturb_period = new.perturb_period;
|
||||
+ q->quantum = new.quantum;
|
||||
+ q->limit = new.limit;
|
||||
+ q->depth = new.depth;
|
||||
+ q->hash_divisor = new.hash_divisor;
|
||||
+ q->hash_kind = new.hash_kind;
|
||||
+ q->tail = new.tail;
|
||||
+ q->max_depth = new.max_depth;
|
||||
+ q->ht = new.ht;
|
||||
+ q->dep = new.dep;
|
||||
+ q->next = new.next;
|
||||
+ q->allot = new.allot;
|
||||
+ q->hash = new.hash;
|
||||
+ q->qs = new.qs;
|
||||
+
|
||||
+ /* finish up */
|
||||
+ if (q->perturb_period) {
|
||||
+ q->perturb_timer.expires = jiffies + q->perturb_period;
|
||||
+ add_timer(&q->perturb_timer);
|
||||
+ } else {
|
||||
+ q->perturbation = 0;
|
||||
+ }
|
||||
+ sch_tree_unlock(sch);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int esfq_dump(struct Qdisc *sch, struct sk_buff *skb)
|
||||
+{
|
||||
+ struct esfq_sched_data *q = qdisc_priv(sch);
|
||||
+ unsigned char *b = skb_tail_pointer(skb);
|
||||
+ struct tc_esfq_qopt opt;
|
||||
+
|
||||
+ opt.quantum = q->quantum;
|
||||
+ opt.perturb_period = q->perturb_period/HZ;
|
||||
+
|
||||
+ opt.limit = q->limit;
|
||||
+ opt.divisor = q->hash_divisor;
|
||||
+ opt.flows = q->depth;
|
||||
+ opt.hash_kind = q->hash_kind;
|
||||
+
|
||||
+ NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
|
||||
+
|
||||
+ return skb->len;
|
||||
+
|
||||
+nla_put_failure:
|
||||
+ nlmsg_trim(skb, b);
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static struct Qdisc_ops esfq_qdisc_ops =
|
||||
+{
|
||||
+ .next = NULL,
|
||||
+ .cl_ops = NULL,
|
||||
+ .id = "esfq",
|
||||
+ .priv_size = sizeof(struct esfq_sched_data),
|
||||
+ .enqueue = esfq_enqueue,
|
||||
+ .dequeue = esfq_dequeue,
|
||||
+ .peek = esfq_peek,
|
||||
+ .drop = esfq_drop,
|
||||
+ .init = esfq_init,
|
||||
+ .reset = esfq_reset,
|
||||
+ .destroy = esfq_destroy,
|
||||
+ .change = esfq_change,
|
||||
+ .dump = esfq_dump,
|
||||
+ .owner = THIS_MODULE,
|
||||
+};
|
||||
+
|
||||
+static int __init esfq_module_init(void)
|
||||
+{
|
||||
+ return register_qdisc(&esfq_qdisc_ops);
|
||||
+}
|
||||
+static void __exit esfq_module_exit(void)
|
||||
+{
|
||||
+ unregister_qdisc(&esfq_qdisc_ops);
|
||||
+}
|
||||
+module_init(esfq_module_init)
|
||||
+module_exit(esfq_module_exit)
|
||||
+MODULE_LICENSE("GPL");
|
|
@ -1,172 +0,0 @@
|
|||
--- /dev/null
|
||||
+++ b/net/sched/act_connmark.c
|
||||
@@ -0,0 +1,137 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2011 Felix Fietkau <nbd@openwrt.org>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms and conditions of the GNU General Public License,
|
||||
+ * version 2, as published by the Free Software Foundation.
|
||||
+ *
|
||||
+ * This program is distributed in the hope it will be useful, but WITHOUT
|
||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
+ * more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License along with
|
||||
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/skbuff.h>
|
||||
+#include <linux/rtnetlink.h>
|
||||
+#include <linux/pkt_cls.h>
|
||||
+#include <linux/ip.h>
|
||||
+#include <linux/ipv6.h>
|
||||
+#include <net/netlink.h>
|
||||
+#include <net/pkt_sched.h>
|
||||
+#include <net/act_api.h>
|
||||
+
|
||||
+#include <net/netfilter/nf_conntrack.h>
|
||||
+#include <net/netfilter/nf_conntrack_core.h>
|
||||
+
|
||||
+#define TCA_ACT_CONNMARK 20
|
||||
+
|
||||
+#define CONNMARK_TAB_MASK 3
|
||||
+static struct tcf_common *tcf_connmark_ht[CONNMARK_TAB_MASK + 1];
|
||||
+static u32 connmark_idx_gen;
|
||||
+static DEFINE_RWLOCK(connmark_lock);
|
||||
+
|
||||
+static struct tcf_hashinfo connmark_hash_info = {
|
||||
+ .htab = tcf_connmark_ht,
|
||||
+ .hmask = CONNMARK_TAB_MASK,
|
||||
+ .lock = &connmark_lock,
|
||||
+};
|
||||
+
|
||||
+static int tcf_connmark(struct sk_buff *skb, struct tc_action *a,
|
||||
+ struct tcf_result *res)
|
||||
+{
|
||||
+ struct nf_conn *c;
|
||||
+ enum ip_conntrack_info ctinfo;
|
||||
+ int proto;
|
||||
+ int r;
|
||||
+
|
||||
+ if (skb->protocol == htons(ETH_P_IP)) {
|
||||
+ if (skb->len < sizeof(struct iphdr))
|
||||
+ goto out;
|
||||
+ proto = PF_INET;
|
||||
+ } else if (skb->protocol == htons(ETH_P_IPV6)) {
|
||||
+ if (skb->len < sizeof(struct ipv6hdr))
|
||||
+ goto out;
|
||||
+ proto = PF_INET6;
|
||||
+ } else
|
||||
+ goto out;
|
||||
+
|
||||
+ r = nf_conntrack_in(dev_net(skb->dev), proto, NF_INET_PRE_ROUTING, skb);
|
||||
+ if (r != NF_ACCEPT)
|
||||
+ goto out;
|
||||
+
|
||||
+ c = nf_ct_get(skb, &ctinfo);
|
||||
+ if (!c)
|
||||
+ goto out;
|
||||
+
|
||||
+ skb->mark = c->mark;
|
||||
+ nf_conntrack_put(skb->nfct);
|
||||
+ skb->nfct = NULL;
|
||||
+
|
||||
+out:
|
||||
+ return TC_ACT_PIPE;
|
||||
+}
|
||||
+
|
||||
+static int tcf_connmark_init(struct nlattr *nla, struct nlattr *est,
|
||||
+ struct tc_action *a, int ovr, int bind)
|
||||
+{
|
||||
+ struct tcf_common *pc;
|
||||
+
|
||||
+ pc = tcf_hash_create(0, est, a, sizeof(*pc), bind,
|
||||
+ &connmark_idx_gen, &connmark_hash_info);
|
||||
+ if (IS_ERR(pc))
|
||||
+ return PTR_ERR(pc);
|
||||
+
|
||||
+ tcf_hash_insert(pc, &connmark_hash_info);
|
||||
+
|
||||
+ return ACT_P_CREATED;
|
||||
+}
|
||||
+
|
||||
+static inline int tcf_connmark_cleanup(struct tc_action *a, int bind)
|
||||
+{
|
||||
+ if (a->priv)
|
||||
+ return tcf_hash_release(a->priv, bind, &connmark_hash_info);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,
|
||||
+ int bind, int ref)
|
||||
+{
|
||||
+ return skb->len;
|
||||
+}
|
||||
+
|
||||
+static struct tc_action_ops act_connmark_ops = {
|
||||
+ .kind = "connmark",
|
||||
+ .hinfo = &connmark_hash_info,
|
||||
+ .type = TCA_ACT_CONNMARK,
|
||||
+ .capab = TCA_CAP_NONE,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .act = tcf_connmark,
|
||||
+ .dump = tcf_connmark_dump,
|
||||
+ .cleanup = tcf_connmark_cleanup,
|
||||
+ .init = tcf_connmark_init,
|
||||
+ .walk = tcf_generic_walker,
|
||||
+};
|
||||
+
|
||||
+MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
|
||||
+MODULE_DESCRIPTION("Connection tracking mark restoring");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+
|
||||
+static int __init connmark_init_module(void)
|
||||
+{
|
||||
+ return tcf_register_action(&act_connmark_ops);
|
||||
+}
|
||||
+
|
||||
+static void __exit connmark_cleanup_module(void)
|
||||
+{
|
||||
+ tcf_unregister_action(&act_connmark_ops);
|
||||
+}
|
||||
+
|
||||
+module_init(connmark_init_module);
|
||||
+module_exit(connmark_cleanup_module);
|
||||
--- a/net/sched/Kconfig
|
||||
+++ b/net/sched/Kconfig
|
||||
@@ -602,6 +602,19 @@ config NET_ACT_CSUM
|
||||
To compile this code as a module, choose M here: the
|
||||
module will be called act_csum.
|
||||
|
||||
+config NET_ACT_CONNMARK
|
||||
+ tristate "Connection Tracking Marking"
|
||||
+ depends on NET_CLS_ACT
|
||||
+ depends on NF_CONNTRACK
|
||||
+ depends on NF_CONNTRACK_MARK
|
||||
+ ---help---
|
||||
+ Say Y here to restore the connmark from a scheduler action
|
||||
+
|
||||
+ If unsure, say N.
|
||||
+
|
||||
+ To compile this code as a module, choose M here: the
|
||||
+ module will be called act_connmark.
|
||||
+
|
||||
config NET_CLS_IND
|
||||
bool "Incoming device classification"
|
||||
depends on NET_CLS_U32 || NET_CLS_FW
|
||||
--- a/net/sched/Makefile
|
||||
+++ b/net/sched/Makefile
|
||||
@@ -16,6 +16,7 @@ obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit
|
||||
obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o
|
||||
obj-$(CONFIG_NET_ACT_SKBEDIT) += act_skbedit.o
|
||||
obj-$(CONFIG_NET_ACT_CSUM) += act_csum.o
|
||||
+obj-$(CONFIG_NET_ACT_CONNMARK) += act_connmark.o
|
||||
obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
|
||||
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
|
||||
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
|
|
@ -1,132 +0,0 @@
|
|||
This patch allows the user to specify desired packet types (outgoing,
|
||||
broadcast, unicast, etc.) on packet sockets via setsockopt.
|
||||
This can reduce the load in situations where only a limited number
|
||||
of packet types are necessary
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
|
||||
|
||||
--- a/include/linux/if_packet.h
|
||||
+++ b/include/linux/if_packet.h
|
||||
@@ -29,6 +29,8 @@ struct sockaddr_ll {
|
||||
/* These ones are invisible by user level */
|
||||
#define PACKET_LOOPBACK 5 /* MC/BRD frame looped back */
|
||||
#define PACKET_FASTROUTE 6 /* Fastrouted frame */
|
||||
+#define PACKET_MASK_ANY 0xffffffff /* mask for packet type bits */
|
||||
+
|
||||
|
||||
/* Packet socket options */
|
||||
|
||||
@@ -50,6 +52,7 @@ struct sockaddr_ll {
|
||||
#define PACKET_TX_TIMESTAMP 16
|
||||
#define PACKET_TIMESTAMP 17
|
||||
#define PACKET_FANOUT 18
|
||||
+#define PACKET_RECV_TYPE 19
|
||||
|
||||
#define PACKET_FANOUT_HASH 0
|
||||
#define PACKET_FANOUT_LB 1
|
||||
--- a/net/packet/af_packet.c
|
||||
+++ b/net/packet/af_packet.c
|
||||
@@ -296,6 +296,7 @@ struct packet_sock {
|
||||
unsigned int tp_loss:1;
|
||||
unsigned int tp_tstamp;
|
||||
struct packet_type prot_hook ____cacheline_aligned_in_smp;
|
||||
+ unsigned int pkt_type;
|
||||
};
|
||||
|
||||
#define PACKET_FANOUT_MAX 256
|
||||
@@ -1383,6 +1384,7 @@ static int packet_rcv_spkt(struct sk_buf
|
||||
{
|
||||
struct sock *sk;
|
||||
struct sockaddr_pkt *spkt;
|
||||
+ struct packet_sock *po;
|
||||
|
||||
/*
|
||||
* When we registered the protocol we saved the socket in the data
|
||||
@@ -1390,6 +1392,7 @@ static int packet_rcv_spkt(struct sk_buf
|
||||
*/
|
||||
|
||||
sk = pt->af_packet_priv;
|
||||
+ po = pkt_sk(sk);
|
||||
|
||||
/*
|
||||
* Yank back the headers [hope the device set this
|
||||
@@ -1402,7 +1405,7 @@ static int packet_rcv_spkt(struct sk_buf
|
||||
* so that this procedure is noop.
|
||||
*/
|
||||
|
||||
- if (skb->pkt_type == PACKET_LOOPBACK)
|
||||
+ if (!(po->pkt_type & (1 << skb->pkt_type)))
|
||||
goto out;
|
||||
|
||||
if (!net_eq(dev_net(dev), sock_net(sk)))
|
||||
@@ -1595,12 +1598,12 @@ static int packet_rcv(struct sk_buff *sk
|
||||
int skb_len = skb->len;
|
||||
unsigned int snaplen, res;
|
||||
|
||||
- if (skb->pkt_type == PACKET_LOOPBACK)
|
||||
- goto drop;
|
||||
-
|
||||
sk = pt->af_packet_priv;
|
||||
po = pkt_sk(sk);
|
||||
|
||||
+ if (!(po->pkt_type & (1 << skb->pkt_type)))
|
||||
+ goto drop;
|
||||
+
|
||||
if (!net_eq(dev_net(dev), sock_net(sk)))
|
||||
goto drop;
|
||||
|
||||
@@ -1719,12 +1722,12 @@ static int tpacket_rcv(struct sk_buff *s
|
||||
struct timespec ts;
|
||||
struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
|
||||
|
||||
- if (skb->pkt_type == PACKET_LOOPBACK)
|
||||
- goto drop;
|
||||
-
|
||||
sk = pt->af_packet_priv;
|
||||
po = pkt_sk(sk);
|
||||
|
||||
+ if (!(po->pkt_type & (1 << skb->pkt_type)))
|
||||
+ goto drop;
|
||||
+
|
||||
if (!net_eq(dev_net(dev), sock_net(sk)))
|
||||
goto drop;
|
||||
|
||||
@@ -2590,6 +2593,7 @@ static int packet_create(struct net *net
|
||||
spin_lock_init(&po->bind_lock);
|
||||
mutex_init(&po->pg_vec_lock);
|
||||
po->prot_hook.func = packet_rcv;
|
||||
+ po->pkt_type = PACKET_MASK_ANY & ~(1 << PACKET_LOOPBACK);
|
||||
|
||||
if (sock->type == SOCK_PACKET)
|
||||
po->prot_hook.func = packet_rcv_spkt;
|
||||
@@ -3187,6 +3191,16 @@ packet_setsockopt(struct socket *sock, i
|
||||
|
||||
return fanout_add(sk, val & 0xffff, val >> 16);
|
||||
}
|
||||
+ case PACKET_RECV_TYPE:
|
||||
+ {
|
||||
+ unsigned int val;
|
||||
+ if (optlen != sizeof(val))
|
||||
+ return -EINVAL;
|
||||
+ if (copy_from_user(&val, optval, sizeof(val)))
|
||||
+ return -EFAULT;
|
||||
+ po->pkt_type = val & ~PACKET_LOOPBACK;
|
||||
+ return 0;
|
||||
+ }
|
||||
default:
|
||||
return -ENOPROTOOPT;
|
||||
}
|
||||
@@ -3257,6 +3271,13 @@ static int packet_getsockopt(struct sock
|
||||
|
||||
data = &val;
|
||||
break;
|
||||
+ case PACKET_RECV_TYPE:
|
||||
+ if (len > sizeof(unsigned int))
|
||||
+ len = sizeof(unsigned int);
|
||||
+ val = po->pkt_type;
|
||||
+
|
||||
+ data = &val;
|
||||
+ break;
|
||||
case PACKET_VERSION:
|
||||
if (len > sizeof(int))
|
||||
len = sizeof(int);
|
|
@ -1,15 +0,0 @@
|
|||
--- a/net/bridge/br_input.c
|
||||
+++ b/net/bridge/br_input.c
|
||||
@@ -78,7 +78,11 @@ int br_handle_frame_finish(struct sk_buf
|
||||
|
||||
dst = NULL;
|
||||
|
||||
- if (is_broadcast_ether_addr(dest))
|
||||
+ if (skb->protocol == htons(ETH_P_PAE)) {
|
||||
+ skb2 = skb;
|
||||
+ /* Do not forward 802.1x/EAP frames */
|
||||
+ skb = NULL;
|
||||
+ } else if (is_broadcast_ether_addr(dest))
|
||||
skb2 = skb;
|
||||
else if (is_multicast_ether_addr(dest)) {
|
||||
mdst = br_mdb_get(br, skb);
|
|
@ -1,11 +0,0 @@
|
|||
--- a/net/bridge/br_input.c
|
||||
+++ b/net/bridge/br_input.c
|
||||
@@ -65,7 +65,7 @@ int br_handle_frame_finish(struct sk_buf
|
||||
br_multicast_rcv(br, p, skb))
|
||||
goto drop;
|
||||
|
||||
- if (p->state == BR_STATE_LEARNING)
|
||||
+ if ((p->state == BR_STATE_LEARNING) && skb->protocol != htons(ETH_P_PAE))
|
||||
goto drop;
|
||||
|
||||
BR_INPUT_SKB_CB(skb)->brdev = br->dev;
|
|
@ -1,103 +0,0 @@
|
|||
--- a/net/bridge/br_private.h
|
||||
+++ b/net/bridge/br_private.h
|
||||
@@ -139,6 +139,7 @@ struct net_bridge_port
|
||||
|
||||
unsigned long flags;
|
||||
#define BR_HAIRPIN_MODE 0x00000001
|
||||
+#define BR_ISOLATE_MODE 0x00000002
|
||||
|
||||
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
||||
u32 multicast_startup_queries_sent;
|
||||
--- a/net/bridge/br_sysfs_if.c
|
||||
+++ b/net/bridge/br_sysfs_if.c
|
||||
@@ -149,6 +149,22 @@ static int store_hairpin_mode(struct net
|
||||
static BRPORT_ATTR(hairpin_mode, S_IRUGO | S_IWUSR,
|
||||
show_hairpin_mode, store_hairpin_mode);
|
||||
|
||||
+static ssize_t show_isolate_mode(struct net_bridge_port *p, char *buf)
|
||||
+{
|
||||
+ int isolate_mode = (p->flags & BR_ISOLATE_MODE) ? 1 : 0;
|
||||
+ return sprintf(buf, "%d\n", isolate_mode);
|
||||
+}
|
||||
+static ssize_t store_isolate_mode(struct net_bridge_port *p, unsigned long v)
|
||||
+{
|
||||
+ if (v)
|
||||
+ p->flags |= BR_ISOLATE_MODE;
|
||||
+ else
|
||||
+ p->flags &= ~BR_ISOLATE_MODE;
|
||||
+ return 0;
|
||||
+}
|
||||
+static BRPORT_ATTR(isolate_mode, S_IRUGO | S_IWUSR,
|
||||
+ show_isolate_mode, store_isolate_mode);
|
||||
+
|
||||
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
||||
static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
|
||||
{
|
||||
@@ -181,6 +197,7 @@ static struct brport_attribute *brport_a
|
||||
&brport_attr_hold_timer,
|
||||
&brport_attr_flush,
|
||||
&brport_attr_hairpin_mode,
|
||||
+ &brport_attr_isolate_mode,
|
||||
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
||||
&brport_attr_multicast_router,
|
||||
#endif
|
||||
--- a/net/bridge/br_input.c
|
||||
+++ b/net/bridge/br_input.c
|
||||
@@ -98,7 +98,8 @@ int br_handle_frame_finish(struct sk_buf
|
||||
skb2 = skb;
|
||||
|
||||
br->dev->stats.multicast++;
|
||||
- } else if ((dst = __br_fdb_get(br, dest)) && dst->is_local) {
|
||||
+ } else if ((p->flags & BR_ISOLATE_MODE) ||
|
||||
+ ((dst = __br_fdb_get(br, dest)) && dst->is_local)) {
|
||||
skb2 = skb;
|
||||
/* Do not forward the packet since it's local. */
|
||||
skb = NULL;
|
||||
--- a/net/bridge/br_forward.c
|
||||
+++ b/net/bridge/br_forward.c
|
||||
@@ -109,7 +109,7 @@ void br_deliver(const struct net_bridge_
|
||||
/* called with rcu_read_lock */
|
||||
void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0)
|
||||
{
|
||||
- if (should_deliver(to, skb)) {
|
||||
+ if (should_deliver(to, skb) && !(to->flags & BR_ISOLATE_MODE)) {
|
||||
if (skb0)
|
||||
deliver_clone(to, skb, __br_forward);
|
||||
else
|
||||
@@ -164,7 +164,8 @@ out:
|
||||
static void br_flood(struct net_bridge *br, struct sk_buff *skb,
|
||||
struct sk_buff *skb0,
|
||||
void (*__packet_hook)(const struct net_bridge_port *p,
|
||||
- struct sk_buff *skb))
|
||||
+ struct sk_buff *skb),
|
||||
+ bool forward)
|
||||
{
|
||||
struct net_bridge_port *p;
|
||||
struct net_bridge_port *prev;
|
||||
@@ -172,6 +173,9 @@ static void br_flood(struct net_bridge *
|
||||
prev = NULL;
|
||||
|
||||
list_for_each_entry_rcu(p, &br->port_list, list) {
|
||||
+ if (forward && (p->flags & BR_ISOLATE_MODE))
|
||||
+ continue;
|
||||
+
|
||||
prev = maybe_deliver(prev, p, skb, __packet_hook);
|
||||
if (IS_ERR(prev))
|
||||
goto out;
|
||||
@@ -195,14 +199,14 @@ out:
|
||||
/* called with rcu_read_lock */
|
||||
void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb)
|
||||
{
|
||||
- br_flood(br, skb, NULL, __br_deliver);
|
||||
+ br_flood(br, skb, NULL, __br_deliver, false);
|
||||
}
|
||||
|
||||
/* called under bridge lock */
|
||||
void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,
|
||||
struct sk_buff *skb2)
|
||||
{
|
||||
- br_flood(br, skb, skb2, __br_forward);
|
||||
+ br_flood(br, skb, skb2, __br_forward, true);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
|
@ -1,107 +0,0 @@
|
|||
--- a/include/net/addrconf.h
|
||||
+++ b/include/net/addrconf.h
|
||||
@@ -91,6 +91,12 @@ extern void addrconf_join_solict(struc
|
||||
extern void addrconf_leave_solict(struct inet6_dev *idev,
|
||||
const struct in6_addr *addr);
|
||||
|
||||
+extern int (*ipv6_dev_get_saddr_hook)(struct net *net,
|
||||
+ struct net_device *dev,
|
||||
+ const struct in6_addr *daddr,
|
||||
+ unsigned int srcprefs,
|
||||
+ struct in6_addr *saddr);
|
||||
+
|
||||
static inline unsigned long addrconf_timeout_fixup(u32 timeout,
|
||||
unsigned unit)
|
||||
{
|
||||
--- a/net/bridge/Kconfig
|
||||
+++ b/net/bridge/Kconfig
|
||||
@@ -6,7 +6,6 @@ config BRIDGE
|
||||
tristate "802.1d Ethernet Bridging"
|
||||
select LLC
|
||||
select STP
|
||||
- depends on IPV6 || IPV6=n
|
||||
---help---
|
||||
If you say Y here, then your Linux box will be able to act as an
|
||||
Ethernet bridge, which means that the different Ethernet segments it
|
||||
--- a/net/ipv6/Makefile
|
||||
+++ b/net/ipv6/Makefile
|
||||
@@ -40,3 +40,4 @@ obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.
|
||||
obj-y += addrconf_core.o exthdrs_core.o
|
||||
|
||||
obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o
|
||||
+obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_stubs.o
|
||||
--- a/net/ipv6/addrconf.c
|
||||
+++ b/net/ipv6/addrconf.c
|
||||
@@ -1111,7 +1111,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
-int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
|
||||
+static int __ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
|
||||
const struct in6_addr *daddr, unsigned int prefs,
|
||||
struct in6_addr *saddr)
|
||||
{
|
||||
@@ -1236,7 +1236,6 @@ try_nextdev:
|
||||
in6_ifa_put(hiscore->ifa);
|
||||
return 0;
|
||||
}
|
||||
-EXPORT_SYMBOL(ipv6_dev_get_saddr);
|
||||
|
||||
int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr,
|
||||
unsigned char banned_flags)
|
||||
@@ -4818,6 +4817,9 @@ int __init addrconf_init(void)
|
||||
|
||||
ipv6_addr_label_rtnl_register();
|
||||
|
||||
+ BUG_ON(ipv6_dev_get_saddr_hook != NULL);
|
||||
+ rcu_assign_pointer(ipv6_dev_get_saddr_hook, __ipv6_dev_get_saddr);
|
||||
+
|
||||
return 0;
|
||||
errout:
|
||||
rtnl_af_unregister(&inet6_ops);
|
||||
@@ -4836,6 +4838,9 @@ void addrconf_cleanup(void)
|
||||
struct net_device *dev;
|
||||
int i;
|
||||
|
||||
+ rcu_assign_pointer(ipv6_dev_get_saddr_hook, NULL);
|
||||
+ synchronize_rcu();
|
||||
+
|
||||
unregister_netdevice_notifier(&ipv6_dev_notf);
|
||||
unregister_pernet_subsys(&addrconf_ops);
|
||||
ipv6_addr_label_cleanup();
|
||||
--- /dev/null
|
||||
+++ b/net/ipv6/inet6_stubs.c
|
||||
@@ -0,0 +1,33 @@
|
||||
+/*
|
||||
+ * This program is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU General Public License
|
||||
+ * as published by the Free Software Foundation; either version
|
||||
+ * 2 of the License, or (at your option) any later version.
|
||||
+ */
|
||||
+#include <linux/export.h>
|
||||
+#include <net/ipv6.h>
|
||||
+
|
||||
+int (*ipv6_dev_get_saddr_hook)(struct net *net, struct net_device *dev,
|
||||
+ const struct in6_addr *daddr, unsigned int srcprefs,
|
||||
+ struct in6_addr *saddr);
|
||||
+
|
||||
+EXPORT_SYMBOL(ipv6_dev_get_saddr_hook);
|
||||
+
|
||||
+int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
|
||||
+ const struct in6_addr *daddr, unsigned int prefs,
|
||||
+ struct in6_addr *saddr)
|
||||
+{
|
||||
+ int ret = -EADDRNOTAVAIL;
|
||||
+ typeof(ipv6_dev_get_saddr_hook) dev_get_saddr;
|
||||
+
|
||||
+ rcu_read_lock();
|
||||
+ dev_get_saddr = rcu_dereference(ipv6_dev_get_saddr_hook);
|
||||
+
|
||||
+ if (dev_get_saddr)
|
||||
+ ret = dev_get_saddr(net, dst_dev, daddr, prefs, saddr);
|
||||
+
|
||||
+ rcu_read_unlock();
|
||||
+ return ret;
|
||||
+}
|
||||
+EXPORT_SYMBOL(ipv6_dev_get_saddr);
|
||||
+
|
|
@ -1,146 +0,0 @@
|
|||
--- a/net/bridge/br_netfilter.c
|
||||
+++ b/net/bridge/br_netfilter.c
|
||||
@@ -62,6 +62,15 @@ static int brnf_filter_pppoe_tagged __re
|
||||
#define brnf_filter_pppoe_tagged 0
|
||||
#endif
|
||||
|
||||
+int brnf_call_ebtables __read_mostly = 0;
|
||||
+EXPORT_SYMBOL_GPL(brnf_call_ebtables);
|
||||
+
|
||||
+bool br_netfilter_run_hooks(void)
|
||||
+{
|
||||
+ return brnf_call_iptables | brnf_call_ip6tables | brnf_call_arptables |
|
||||
+ brnf_call_ebtables;
|
||||
+}
|
||||
+
|
||||
static inline __be16 vlan_proto(const struct sk_buff *skb)
|
||||
{
|
||||
if (vlan_tx_tag_present(skb))
|
||||
--- a/net/bridge/br_private.h
|
||||
+++ b/net/bridge/br_private.h
|
||||
@@ -488,15 +488,29 @@ static inline bool br_multicast_is_route
|
||||
|
||||
/* br_netfilter.c */
|
||||
#ifdef CONFIG_BRIDGE_NETFILTER
|
||||
+extern int brnf_call_ebtables;
|
||||
extern int br_netfilter_init(void);
|
||||
extern void br_netfilter_fini(void);
|
||||
extern void br_netfilter_rtable_init(struct net_bridge *);
|
||||
+extern bool br_netfilter_run_hooks(void);
|
||||
#else
|
||||
#define br_netfilter_init() (0)
|
||||
#define br_netfilter_fini() do { } while(0)
|
||||
#define br_netfilter_rtable_init(x)
|
||||
+#define br_netfilter_run_hooks() false
|
||||
#endif
|
||||
|
||||
+static inline int
|
||||
+BR_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
|
||||
+ struct net_device *in, struct net_device *out,
|
||||
+ int (*okfn)(struct sk_buff *))
|
||||
+{
|
||||
+ if (!br_netfilter_run_hooks())
|
||||
+ return okfn(skb);
|
||||
+
|
||||
+ return NF_HOOK(pf, hook, skb, in, out, okfn);
|
||||
+}
|
||||
+
|
||||
/* br_stp.c */
|
||||
extern void br_log_state(const struct net_bridge_port *p);
|
||||
extern struct net_bridge_port *br_get_port(struct net_bridge *br,
|
||||
--- a/net/bridge/br_input.c
|
||||
+++ b/net/bridge/br_input.c
|
||||
@@ -40,7 +40,7 @@ static int br_pass_frame_up(struct sk_bu
|
||||
indev = skb->dev;
|
||||
skb->dev = brdev;
|
||||
|
||||
- return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
|
||||
+ return BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
|
||||
netif_receive_skb);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ rx_handler_result_t br_handle_frame(stru
|
||||
}
|
||||
|
||||
/* Deliver packet to local host only */
|
||||
- if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
|
||||
+ if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
|
||||
NULL, br_handle_local_finish)) {
|
||||
return RX_HANDLER_CONSUMED; /* consumed by filter */
|
||||
} else {
|
||||
@@ -224,7 +224,7 @@ forward:
|
||||
if (!compare_ether_addr(p->br->dev->dev_addr, dest))
|
||||
skb->pkt_type = PACKET_HOST;
|
||||
|
||||
- NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
|
||||
+ BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
|
||||
br_handle_frame_finish);
|
||||
break;
|
||||
default:
|
||||
--- a/net/bridge/br_forward.c
|
||||
+++ b/net/bridge/br_forward.c
|
||||
@@ -55,7 +55,7 @@ int br_dev_queue_push_xmit(struct sk_buf
|
||||
|
||||
int br_forward_finish(struct sk_buff *skb)
|
||||
{
|
||||
- return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
|
||||
+ return BR_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
|
||||
br_dev_queue_push_xmit);
|
||||
|
||||
}
|
||||
@@ -74,7 +74,7 @@ static void __br_deliver(const struct ne
|
||||
return;
|
||||
}
|
||||
|
||||
- NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
|
||||
+ BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
|
||||
br_forward_finish);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ static void __br_forward(const struct ne
|
||||
skb->dev = to->dev;
|
||||
skb_forward_csum(skb);
|
||||
|
||||
- NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
|
||||
+ BR_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
|
||||
br_forward_finish);
|
||||
}
|
||||
|
||||
--- a/net/bridge/br_multicast.c
|
||||
+++ b/net/bridge/br_multicast.c
|
||||
@@ -827,7 +827,7 @@ static void __br_multicast_send_query(st
|
||||
if (port) {
|
||||
__skb_push(skb, sizeof(struct ethhdr));
|
||||
skb->dev = port->dev;
|
||||
- NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
|
||||
+ BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
|
||||
dev_queue_xmit);
|
||||
} else
|
||||
netif_rx(skb);
|
||||
--- a/net/bridge/br_stp_bpdu.c
|
||||
+++ b/net/bridge/br_stp_bpdu.c
|
||||
@@ -52,7 +52,7 @@ static void br_send_bpdu(struct net_brid
|
||||
|
||||
skb_reset_mac_header(skb);
|
||||
|
||||
- NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
|
||||
+ BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
|
||||
dev_queue_xmit);
|
||||
}
|
||||
|
||||
--- a/net/bridge/netfilter/ebtables.c
|
||||
+++ b/net/bridge/netfilter/ebtables.c
|
||||
@@ -2399,11 +2399,13 @@ static int __init ebtables_init(void)
|
||||
}
|
||||
|
||||
printk(KERN_INFO "Ebtables v2.0 registered\n");
|
||||
+ brnf_call_ebtables = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit ebtables_fini(void)
|
||||
{
|
||||
+ brnf_call_ebtables = 0;
|
||||
nf_unregister_sockopt(&ebt_sockopts);
|
||||
xt_unregister_target(&ebt_standard_target);
|
||||
printk(KERN_INFO "Ebtables v2.0 unregistered\n");
|
|
@ -1,20 +0,0 @@
|
|||
--- a/drivers/net/ppp/pppoe.c
|
||||
+++ b/drivers/net/ppp/pppoe.c
|
||||
@@ -856,7 +856,7 @@ static int pppoe_sendmsg(struct kiocb *i
|
||||
goto end;
|
||||
|
||||
|
||||
- skb = sock_wmalloc(sk, total_len + dev->hard_header_len + 32,
|
||||
+ skb = sock_wmalloc(sk, total_len + dev->hard_header_len + 32 + NET_SKB_PAD,
|
||||
0, GFP_KERNEL);
|
||||
if (!skb) {
|
||||
error = -ENOMEM;
|
||||
@@ -864,7 +864,7 @@ static int pppoe_sendmsg(struct kiocb *i
|
||||
}
|
||||
|
||||
/* Reserve space for headers. */
|
||||
- skb_reserve(skb, dev->hard_header_len);
|
||||
+ skb_reserve(skb, dev->hard_header_len + NET_SKB_PAD);
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
skb->dev = dev;
|
|
@ -1,11 +0,0 @@
|
|||
--- a/include/linux/netdevice.h
|
||||
+++ b/include/linux/netdevice.h
|
||||
@@ -142,7 +142,7 @@ static inline bool dev_xmit_complete(int
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_WLAN) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
|
||||
-# if defined(CONFIG_MAC80211_MESH)
|
||||
+# if 1 || defined(CONFIG_MAC80211_MESH)
|
||||
# define LL_MAX_HEADER 128
|
||||
# else
|
||||
# define LL_MAX_HEADER 96
|
|
@ -1,12 +0,0 @@
|
|||
--- a/include/linux/atm.h
|
||||
+++ b/include/linux/atm.h
|
||||
@@ -139,6 +139,9 @@ struct atm_trafprm {
|
||||
int min_pcr; /* minimum PCR in cells per second */
|
||||
int max_cdv; /* maximum CDV in microseconds */
|
||||
int max_sdu; /* maximum SDU in bytes */
|
||||
+ int scr; /* sustained rate in cells per second */
|
||||
+ int mbs; /* maximum burst size (MBS) in cells */
|
||||
+ int cdv; /* Cell delay varition */
|
||||
/* extra params for ABR */
|
||||
unsigned int icr; /* Initial Cell Rate (24-bit) */
|
||||
unsigned int tbe; /* Transient Buffer Exposure (24-bit) */
|
|
@ -1,29 +0,0 @@
|
|||
--- a/drivers/net/phy/Kconfig
|
||||
+++ b/drivers/net/phy/Kconfig
|
||||
@@ -13,6 +13,16 @@ menuconfig PHYLIB
|
||||
|
||||
if PHYLIB
|
||||
|
||||
+config SWCONFIG
|
||||
+ tristate "Switch configuration API"
|
||||
+ ---help---
|
||||
+ Switch configuration API using netlink. This allows
|
||||
+ you to configure the VLAN features of certain switches.
|
||||
+
|
||||
+config SWCONFIG_LEDS
|
||||
+ bool "Switch LED trigger support"
|
||||
+ depends on (SWCONFIG && LEDS_TRIGGERS)
|
||||
+
|
||||
comment "MII PHY device drivers"
|
||||
|
||||
config MARVELL_PHY
|
||||
--- a/drivers/net/phy/Makefile
|
||||
+++ b/drivers/net/phy/Makefile
|
||||
@@ -3,6 +3,7 @@
|
||||
libphy-objs := phy.o phy_device.o mdio_bus.o
|
||||
|
||||
obj-$(CONFIG_PHYLIB) += libphy.o
|
||||
+obj-$(CONFIG_SWCONFIG) += swconfig.o
|
||||
obj-$(CONFIG_MARVELL_PHY) += marvell.o
|
||||
obj-$(CONFIG_DAVICOM_PHY) += davicom.o
|
||||
obj-$(CONFIG_CICADA_PHY) += cicada.o
|
|
@ -1,72 +0,0 @@
|
|||
--- a/drivers/net/phy/phy.c
|
||||
+++ b/drivers/net/phy/phy.c
|
||||
@@ -299,6 +299,50 @@ int phy_ethtool_gset(struct phy_device *
|
||||
}
|
||||
EXPORT_SYMBOL(phy_ethtool_gset);
|
||||
|
||||
+int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr)
|
||||
+{
|
||||
+ u32 cmd;
|
||||
+ int tmp;
|
||||
+ struct ethtool_cmd ecmd = { ETHTOOL_GSET };
|
||||
+ struct ethtool_value edata = { ETHTOOL_GLINK };
|
||||
+
|
||||
+ if (get_user(cmd, (u32 *) useraddr))
|
||||
+ return -EFAULT;
|
||||
+
|
||||
+ switch (cmd) {
|
||||
+ case ETHTOOL_GSET:
|
||||
+ phy_ethtool_gset(phydev, &ecmd);
|
||||
+ if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
|
||||
+ return -EFAULT;
|
||||
+ return 0;
|
||||
+
|
||||
+ case ETHTOOL_SSET:
|
||||
+ if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
|
||||
+ return -EFAULT;
|
||||
+ return phy_ethtool_sset(phydev, &ecmd);
|
||||
+
|
||||
+ case ETHTOOL_NWAY_RST:
|
||||
+ /* if autoneg is off, it's an error */
|
||||
+ tmp = phy_read(phydev, MII_BMCR);
|
||||
+ if (tmp & BMCR_ANENABLE) {
|
||||
+ tmp |= (BMCR_ANRESTART);
|
||||
+ phy_write(phydev, MII_BMCR, tmp);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ case ETHTOOL_GLINK:
|
||||
+ edata.data = (phy_read(phydev,
|
||||
+ MII_BMSR) & BMSR_LSTATUS) ? 1 : 0;
|
||||
+ if (copy_to_user(useraddr, &edata, sizeof(edata)))
|
||||
+ return -EFAULT;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+EXPORT_SYMBOL(phy_ethtool_ioctl);
|
||||
+
|
||||
/**
|
||||
* phy_mii_ioctl - generic PHY MII ioctl interface
|
||||
* @phydev: the phy_device struct
|
||||
@@ -474,7 +518,7 @@ static void phy_force_reduction(struct p
|
||||
int idx;
|
||||
|
||||
idx = phy_find_setting(phydev->speed, phydev->duplex);
|
||||
-
|
||||
+
|
||||
idx++;
|
||||
|
||||
idx = phy_find_valid(idx, phydev->supported);
|
||||
--- a/include/linux/phy.h
|
||||
+++ b/include/linux/phy.h
|
||||
@@ -510,6 +510,7 @@ void phy_start_machine(struct phy_device
|
||||
void phy_stop_machine(struct phy_device *phydev);
|
||||
int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
|
||||
int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
|
||||
+int phy_ethtool_ioctl(struct phy_device *phydev, void *useraddr);
|
||||
int phy_mii_ioctl(struct phy_device *phydev,
|
||||
struct ifreq *ifr, int cmd);
|
||||
int phy_start_interrupts(struct phy_device *phydev);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue