summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2013-09-19 10:35:44 +0300
committerRoman Yeryomin <roman@advem.lv>2013-09-19 10:35:44 +0300
commit178f5c8a01fbc67d6512f6f99d10cf0e111781bb (patch)
treede70934bce86cd2bafb63fbbb38d4e406cfe9eed
parentb6cafc25acec492a9f1fb0fb7c301fcb3a96442b (diff)
Break drivers patch into several files
Signed-off-by: Roman Yeryomin <roman@advem.lv>
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-Makefile.patch27
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-char.patch29
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-crypto.patch36
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-media.patch17
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-mtd.patch1292
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-net.patch1342
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-pci.patch61
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-scsi.patch25
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-serial.patch (renamed from target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-nonewfiles.patch)2877
-rw-r--r--target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-staging.patch21
10 files changed, 2850 insertions, 2877 deletions
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-Makefile.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-Makefile.patch
new file mode 100644
index 000000000..dfd55f0f2
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-Makefile.patch
@@ -0,0 +1,27 @@
+--- linux-2.6.30.9/drivers/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/Makefile 2013-05-02 01:47:49.674227386 +0300
+@@ -24,7 +24,7 @@ obj-$(CONFIG_REGULATOR) += regulator/
+ # char/ comes before serial/ etc so that the VT console is the boot-time
+ # default.
+ obj-y += char/
+-
++obj-$(CONFIG_STAGING) += staging/
+ # gpu/ comes after char for AGP vs DRM startup
+ obj-y += gpu/
+
+@@ -65,7 +65,7 @@ obj-$(CONFIG_USB_OTG_UTILS) += usb/otg/
+ obj-$(CONFIG_USB) += usb/
+ obj-$(CONFIG_USB_MUSB_HDRC) += usb/musb/
+ obj-$(CONFIG_PCI) += usb/
+-obj-$(CONFIG_USB_GADGET) += usb/gadget/
++## obj-$(CONFIG_USB_GADGET) += usb/gadget/
+ obj-$(CONFIG_SERIO) += input/serio/
+ obj-$(CONFIG_GAMEPORT) += input/gameport/
+ obj-$(CONFIG_INPUT) += input/
+@@ -105,5 +105,5 @@ obj-$(CONFIG_PPC_PS3) += ps3/
+ obj-$(CONFIG_OF) += of/
+ obj-$(CONFIG_SSB) += ssb/
+ obj-$(CONFIG_VIRTIO) += virtio/
+-obj-$(CONFIG_STAGING) += staging/
++
+ obj-y += platform/
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-char.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-char.patch
new file mode 100644
index 000000000..d0abecdef
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-char.patch
@@ -0,0 +1,29 @@
+--- linux-2.6.30.9/drivers/char/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/char/Makefile 2013-05-02 01:47:50.410227327 +0300
+@@ -8,6 +8,7 @@
+ FONTMAPFILE = cp437.uni
+
+ obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o tty_port.o
++EXTRA_CFLAGS += -I.
+
+ obj-$(CONFIG_LEGACY_PTYS) += pty.o
+ obj-$(CONFIG_UNIX98_PTYS) += pty.o
+@@ -97,6 +98,8 @@ obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio
+ obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
+ obj-$(CONFIG_GPIO_TB0219) += tb0219.o
+ obj-$(CONFIG_TELCLOCK) += tlclk.o
++obj-$(CONFIG_RTL_NFBI_MDIO) += rtl_mdio/
++obj-$(CONFIG_NFBI_HOST) += rtl_nfbi/
+
+ obj-$(CONFIG_MWAVE) += mwave/
+ obj-$(CONFIG_AGP) += agp/
+--- linux-2.6.30.9/drivers/char/pty.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/char/pty.c 2013-05-02 01:47:50.487227320 +0300
+@@ -27,6 +27,7 @@
+ #include <linux/uaccess.h>
+ #include <linux/bitops.h>
+ #include <linux/devpts_fs.h>
++#include <linux/smp_lock.h>
+
+ #include <asm/system.h>
+
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-crypto.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-crypto.patch
new file mode 100644
index 000000000..d212e14f4
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-crypto.patch
@@ -0,0 +1,36 @@
+--- linux-2.6.30.9/drivers/crypto/Kconfig 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/crypto/Kconfig 2013-05-02 01:47:50.559227314 +0300
+@@ -209,4 +209,26 @@ config CRYPTO_DEV_PPC4XX
+ help
+ This option allows you to have support for AMCC crypto acceleration.
+
++config CRYPTO_DEV_REALTEK
++ tristate "Driver Realtek Crypto Engine"
++ select CRYPTO_HASH
++ select CRYPTO_ALGAPI
++ select CRYPTO_BLKCIPHER
++ select CRYPTO_CBC
++ select CRYPTO_CTR
++ select CRYPTO_ECB
++ select CRYPTO_MD5
++ select CRYPTO_SHA1
++ select CRYPTO_AES
++ select CRYPTO_DES
++ help
++ This option allows you to have support for Realtek Crypto Engine.
++
++config CRYPTO_DEV_REALTEK_TEST
++ tristate "Driver Realtek Crypto Engine Test"
++ select CRYPTO_TEST
++ depends on CRYPTO_DEV_REALTEK
++ help
++ This option for Realtek Crypto Engine Internal Test.
++
+ endif # CRYPTO_HW
+--- linux-2.6.30.9/drivers/crypto/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/crypto/Makefile 2013-05-02 01:47:50.559227314 +0300
+@@ -5,3 +5,4 @@ obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hi
+ obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
+ obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o
+ obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
++obj-$(CONFIG_CRYPTO_DEV_REALTEK) += realtek/
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-media.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-media.patch
new file mode 100644
index 000000000..c146eb0f1
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-media.patch
@@ -0,0 +1,17 @@
+--- linux-2.6.30.9/drivers/media/video/uvc/uvc_video.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/media/video/uvc/uvc_video.c 2013-05-02 01:47:52.326227171 +0300
+@@ -531,6 +531,14 @@ static void uvc_video_decode_isoc(struct
+ if (urb->iso_frame_desc[i].status < 0) {
+ uvc_trace(UVC_TRACE_FRAME, "USB isochronous frame "
+ "lost (%d).\n", urb->iso_frame_desc[i].status);
++
++ //Start to avoid to flicking images with isochronous by jason
++ if (buf) {
++ buf->state = UVC_BUF_STATE_QUEUED;
++ buf->buf.bytesused = 0;
++ i = urb->number_of_packets;
++ }
++ //End to avoid to flicking images with isochronous by jason
+ continue;
+ }
+
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-mtd.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-mtd.patch
new file mode 100644
index 000000000..46c99bbe3
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-mtd.patch
@@ -0,0 +1,1292 @@
+--- linux-2.6.30.9/drivers/mtd/chips/Kconfig 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/mtd/chips/Kconfig 2013-05-02 01:47:52.620227148 +0300
+@@ -240,6 +240,12 @@ config MTD_XIP
+ This allows MTD support to work with flash memory which is also
+ used for XIP purposes. If you're not sure what this is all about
+ then say N.
++config RTL819X_SPI_FLASH
++ bool "RTL819x SPI flash support"
++ depends on MTD
++ help
++ Support SPI flash for MX25L,SST series
++
+
+ endmenu
+
+--- linux-2.6.30.9/drivers/mtd/chips/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/mtd/chips/Makefile 2013-05-02 01:47:52.620227148 +0300
+@@ -13,3 +13,4 @@ obj-$(CONFIG_MTD_JEDECPROBE) += jedec_pr
+ obj-$(CONFIG_MTD_RAM) += map_ram.o
+ obj-$(CONFIG_MTD_ROM) += map_rom.o
+ obj-$(CONFIG_MTD_ABSENT) += map_absent.o
++obj-$(CONFIG_RTL819X_SPI_FLASH) += rtl819x/
+--- linux-2.6.30.9/drivers/mtd/devices/doc2001.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/mtd/devices/doc2001.c 2013-05-02 01:47:52.629227147 +0300
+@@ -10,8 +10,11 @@
+ #include <asm/errno.h>
+ #include <asm/io.h>
+ #include <asm/uaccess.h>
++#include <linux/miscdevice.h>
++#include <linux/pci.h>
+ #include <linux/delay.h>
+ #include <linux/slab.h>
++#include <linux/sched.h>
+ #include <linux/init.h>
+ #include <linux/types.h>
+ #include <linux/bitops.h>
+@@ -20,6 +23,48 @@
+ #include <linux/mtd/nand.h>
+ #include <linux/mtd/doc2000.h>
+
++#ifdef CONFIG_RTL_819X
++/*porting for RTL865xC-RTL8190 SDK by alva_zhang@2007.11*/
++#include <linux/config.h>
++#include <linux/mtd/partitions.h>
++
++#define CALL_APP_TO_LOAD_DEFAULT // call user program to load default
++extern int flash_hw_start;
++#define noCONFIG_MTD_DEBUG
++#define CONFIG_MTD_DEBUG_VERBOSE 3
++extern int flash_hw_start, flash_hw_len, flash_ds_start, flash_ds_len, flash_write_flag;
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++#define RTL_BOOTCODE_END (0x6000)
++static struct mtd_partition rtl8196_partitions[ ] = {
++ {
++ name: "boot+cfg+linux",
++ size: (CONFIG_RTL_ROOT_IMAGE_OFFSET-0),
++ offset: 0x00000000,
++ },
++ {
++ name: "root fs",
++ size: (CONFIG_RTL_FLASH_SIZE-CONFIG_RTL_ROOT_IMAGE_OFFSET),
++ offset: (CONFIG_RTL_ROOT_IMAGE_OFFSET),
++ }
++};
++#else
++static struct mtd_partition rtl8196_partitions[ ] = {
++ {
++ name: "boot+cfg+linux",
++ size: 0xF0000,
++ offset: 0x00000000,
++ },
++ {
++ name: "root fs",
++ size: 0x110000,
++ offset: 0xF0000,
++ }
++};
++#endif
++#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
++#endif /*#ifdef CONFIG_RTL_819X */
++
++
+ /* #define ECC_DEBUG */
+
+ /* I have no idea why some DoC chips can not use memcop_form|to_io().
+@@ -32,12 +77,29 @@ static int doc_read(struct mtd_info *mtd
+ size_t *retlen, u_char *buf);
+ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
+ size_t *retlen, const u_char *buf);
++
++#ifdef CONFIG_RTL_819X
++/* Do nothing here*/
++#else
+ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
+ struct mtd_oob_ops *ops);
+ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
+ struct mtd_oob_ops *ops);
++#endif
++
+ static int doc_erase (struct mtd_info *mtd, struct erase_info *instr);
+
++#ifdef CONFIG_RTL_819X
++/*porting for RTL865xC-RTL8190 SDK by alva_zhang@2007.11*/
++static int erase_one_block(struct DiskOnChip *this, __u32 addr, __u32 len);
++#endif
++
++#ifdef CONFIG_RTL_819X
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++int find_section_boundary(struct mtd_info *mtd,unsigned int start, unsigned int end, unsigned int *rstart, unsigned *rend);
++#endif
++#endif
++
+ static struct mtd_info *docmillist = NULL;
+
+ /* Perform the required delay cycles by reading from the NOP register */
+@@ -149,6 +211,10 @@ static inline void DoC_Address(void __io
+ DoC_Delay(docptr, 4);
+ }
+
++#ifdef CONFIG_RTL_819X
++/*porting for RTL865xC-RTL8190 SDK by alva_zhang@2007.11*/
++/* Do nothing here*/
++#else
+ /* DoC_SelectChip: Select a given flash chip within the current floor */
+ static int DoC_SelectChip(void __iomem * docptr, int chip)
+ {
+@@ -281,6 +347,7 @@ static void DoC_ScanChips(struct DiskOnC
+ printk(KERN_INFO "%d flash chips found. Total DiskOnChip size: %ld MiB\n",
+ this->numchips ,this->totlen >> 20);
+ }
++#endif /*#ifdef CONFIG_RTL_819X */
+
+ static int DoCMil_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
+ {
+@@ -318,9 +385,16 @@ static int DoCMil_is_alias(struct DiskOn
+ void DoCMil_init(struct mtd_info *mtd)
+ {
+ struct DiskOnChip *this = mtd->priv;
++#ifdef CONFIG_RTL_819X
++/*do nothing here*/
++#else
+ struct DiskOnChip *old = NULL;
++#endif
+
+ /* We must avoid being called twice for the same device. */
++#ifdef CONFIG_RTL_819X
++/*do nothing here*/
++#else
+ if (docmillist)
+ old = docmillist->priv;
+
+@@ -337,17 +411,31 @@ void DoCMil_init(struct mtd_info *mtd)
+ else
+ old = NULL;
+ }
++#endif /*CONFIG_RTL_819X*/
+
+ mtd->name = "DiskOnChip Millennium";
++#ifdef CONFIG_RTL_819X
++/*do nothing here*/
++#else
+ printk(KERN_NOTICE "DiskOnChip Millennium found at address 0x%lX\n",
+ this->physadr);
++#endif
++
++ mtd->type = MTD_NORFLASH;
++ mtd->flags = MTD_CAP_NORFLASH;
++#ifdef CONFIG_RTL_819X
++#else
++ mtd->ecctype = MTD_ECC_RS_DiskOnChip;
++#endif
+
+- mtd->type = MTD_NANDFLASH;
+- mtd->flags = MTD_CAP_NANDFLASH;
++#ifdef CONFIG_RTL_819X
++/*do nothing here*/
++#else
+ mtd->size = 0;
+
+ /* FIXME: erase size is not always 8KiB */
+ mtd->erasesize = 0x2000;
++#endif
+
+ mtd->writesize = 512;
+ mtd->oobsize = 16;
+@@ -357,10 +445,19 @@ void DoCMil_init(struct mtd_info *mtd)
+ mtd->unpoint = NULL;
+ mtd->read = doc_read;
+ mtd->write = doc_write;
++
++#ifdef CONFIG_RTL_819X
++/*do nothing here*/
++#else
+ mtd->read_oob = doc_read_oob;
+ mtd->write_oob = doc_write_oob;
++#endif
++
+ mtd->sync = NULL;
+
++#ifdef CONFIG_RTL_819X
++/*do nothing here*/
++#else
+ this->totlen = 0;
+ this->numchips = 0;
+ this->curfloor = -1;
+@@ -368,6 +465,7 @@ void DoCMil_init(struct mtd_info *mtd)
+
+ /* Ident all the chips present. */
+ DoC_ScanChips(this);
++#endif
+
+ if (!this->totlen) {
+ kfree(mtd);
+@@ -376,15 +474,199 @@ void DoCMil_init(struct mtd_info *mtd)
+ this->nextdoc = docmillist;
+ docmillist = mtd;
+ mtd->size = this->totlen;
++//#ifdef CONFIG_RTK_MTD_ROOT
++#ifdef CONFIG_RTL_819X
++ add_mtd_partitions(mtd, rtl8196_partitions, NB_OF(rtl8196_partitions));
++#else
+ add_mtd_device(mtd);
++#endif
+ return;
+ }
+ }
+ EXPORT_SYMBOL_GPL(DoCMil_init);
+
++#ifdef CONFIG_RTL_819X
++static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
++ size_t *retlen, const u_char *buf, u_char *eccbuf)
++{
++ int i,ret;
++ struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
++ unsigned long docptr =(unsigned long) this->virtadr;
++ unsigned int ofs;
++ unsigned short val,val1;
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ unsigned int rstart,rend;
++ unsigned int start,end;
++#endif
++// david ------------
++unsigned long timeo, offset;
++unsigned long flags;
++//-------------------
++
++ /* Don't allow write past end of device */
++ if (to >= this->totlen)
++ {
++// david
++// printk("write to >= total len\n");
++ printk(KERN_WARNING "write to >= total len\n");
++ return -EINVAL;
++ }
++ DEBUG(MTD_DEBUG_LEVEL1,"going to write len=0x%x,to =0x%x\n", (int)len, (int)to);
++
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ start=to;
++ end=0xFFFFFFF;
++ if(flash_write_flag & 1)
++ {
++ if(0 == start)
++ start = CONFIG_RTL_HW_SETTING_OFFSET;
++ else if( start > CONFIG_RTL_HW_SETTING_OFFSET )
++ start = CONFIG_RTL_HW_SETTING_OFFSET;
++ end=CONFIG_RTL_DEFAULT_SETTING_OFFSET;
++ }
++
++ if(flash_write_flag & 2 )
++ {
++ if(0 == start)
++ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
++ else if( start > CONFIG_RTL_DEFAULT_SETTING_OFFSET )
++ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
++
++ end = CONFIG_RTL_CURRENT_SETTING_OFFSET;
++ }
++
++ if( flash_write_flag & 4 )
++ {
++ if(0 == start)
++ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
++ else if( start > CONFIG_RTL_CURRENT_SETTING_OFFSET )
++ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
++ end = CONFIG_RTL_WEB_PAGES_OFFSET;
++ }
++ find_section_boundary(mtd,start,end,&rstart,&rend);
++
++#endif
++
++ *retlen = len;
++ ofs = docptr + to;
++ for(i=0; i< len; i+=2)
++ {
++// david -----------------------------------------------------
++#if 0
++ val = *(unsigned short *)buf;
++
++ *(volatile unsigned short *)(0xbfc00000 + 0x555 * 2)= 0xaa;
++ *(volatile unsigned short *)(0xbfc00000 + 0x2aa * 2)= 0x55;
++ *(volatile unsigned short *)(0xbfc00000 + 0x555 * 2)= 0xa0;
++ *(volatile unsigned short *)(ofs )= val;
++
++ j=0xfffff1;
++ do{
++ val1=*(volatile unsigned short *)(ofs);
++ if( ((val1^val) & 0x80)==0 )
++ break;
++
++ }while(j--!=1);
++ if (j <= 2)
++ printk("program fails\n");
++#else
++
++// if ( ofs < (docptr+CONFIG_MTD_DOCPROBE_ADDRESS) )
++// goto next_word;
++
++ offset = (to >> this->chipshift)*(1 << this->chipshift);
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ if(ofs <(docptr+rstart))
++ goto next_word;
++ if(ofs >= (docptr+rend))
++ {
++ return 0;
++ }
++#else
++#if !defined(COMPACK_SETTING) && !defined(NO_CHECK_REGION)
++ if ( flash_write_flag != 0x8000
++//#ifdef CONFIG_RTK_MTD_ROOT
++#ifdef CONFIG_RTL_819X
++ || offset < (rtl8196_partitions[0].size+ rtl8196_partitions[0].offset)
++#endif
++ )
++ {
++
++ if ( (flash_write_flag & 1) && (ofs < (docptr+flash_hw_start)) )
++ goto next_word;
++
++ if ( (flash_write_flag & 2) && (ofs < (docptr+flash_ds_start)) )
++ goto next_word;
++
++ if ( (flash_write_flag & 4) && (ofs < (docptr+flash_ds_start+flash_ds_len)) )
++ goto next_word;
++ }
++#endif // COMPACK_SETTING && NO_CHECK_REGION
++#endif //CONFIG_RTL_FLASH_MAPPING_ENABLE
++ val = *(unsigned short *)buf;
++
++ mtd_save_flags(flags);mtd_cli(); // david
++
++ *(volatile unsigned short *)(0xbfc00000 + offset + 0x555 * 2)= 0xaa;
++ *(volatile unsigned short *)(0xbfc00000 + offset + 0x2aa * 2)= 0x55;
++ *(volatile unsigned short *)(0xbfc00000 + offset + 0x555 * 2)= 0xa0;
++ *(volatile unsigned short *)(ofs )= val;
++
++ mtd_restore_flags(flags); // david
++
++ timeo = jiffies + (HZ * 50);
++ do{
++#if 0
++ val1=*(volatile unsigned short *)(ofs);
++ if ( val1 == val )
++ break;
++#endif
++ unsigned short val2;
++
++ val2=*(volatile unsigned short *)(ofs);
++ val1=*(volatile unsigned short *)(ofs);
++
++ if (((val1^val2) & 0x40) != 0)
++ continue;
++ if (((val1^val) & 0x80) != 0)
++ continue;
++ if ( val1 == val )
++ break;
++//--------------
++ } while ( !time_after(jiffies, timeo) );
++
++ if ( time_after(jiffies, timeo)) {
++ printk(KERN_WARNING "program timeout!");
++ printk(KERN_WARNING " write: %x, read:%x, addr: %x\n", val, val1, ofs);
++ return -1;
++ }
++
++#ifndef COMPACK_SETTING
++next_word:
++#endif
++
++#endif
++//---------------------------------------------------------
++ ofs += 2;
++ buf += 2;
++
++ }
++
++ ret = 0 ;
++// printk("in doc_write_ecc ret=%08x\n", ret);
++ return ret;
++}
++#endif /* #ifdef CONFIG_RTL_819X */
++
+ static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, u_char *buf)
+ {
++#ifdef CONFIG_RTL_819X
++static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
++ size_t *retlen, u_char *buf, u_char *eccbuf);
++/* Just a special case of doc_read_ecc */
++ return doc_read_ecc(mtd, from, len, retlen, buf, NULL);
++#else
+ int i, ret;
+ volatile char dummy;
+ unsigned char syndrome[6], eccbuf[6];
+@@ -491,11 +773,49 @@ static int doc_read (struct mtd_info *mt
+ WriteDOC(DOC_ECC_DIS, docptr , ECCConf);
+
+ return ret;
++
++#endif /* #ifdef CONFIG_RTL_819X */
++}
++
++#ifdef CONFIG_RTL_819X
++static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
++ size_t *retlen, u_char *buf, u_char *eccbuf)
++{
++ int i;
++ unsigned short tmp;
++ struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
++ unsigned long docptr = this->virtadr+from;
++
++ /* Don't allow read past end of device */
++ if (from >= this->totlen)
++ return -EINVAL;
++ for(i=0; i< len; i+=2)
++ {
++ tmp = *(volatile unsigned short *)(docptr);
++ *(unsigned short *)buf = tmp;
++ buf += 2;
++ docptr +=2;
++ }
++ if (len & 0x01)
++ {
++ tmp = *(volatile unsigned long *)(docptr);
++ *(unsigned char *)buf = (tmp >> 8) & 0xff;
++ }
++
++ /* Let the caller know we completed it */
++ *retlen = len;
++
++ return 0;
+ }
++#endif /*#ifdef CONFIG_RTL_819X */
+
+ static int doc_write (struct mtd_info *mtd, loff_t to, size_t len,
+ size_t *retlen, const u_char *buf)
+ {
++#ifdef CONFIG_RTL_819X
++ char eccbuf[6];
++ return doc_write_ecc(mtd, to, len, retlen, buf, eccbuf);
++#else
+ int i,ret = 0;
+ char eccbuf[6];
+ volatile char dummy;
+@@ -617,8 +937,12 @@ static int doc_write (struct mtd_info *m
+ *retlen = len;
+
+ return ret;
++#endif /*#ifdef CONFIG_RTL_819X */
+ }
+
++#ifdef CONFIG_RTL_819X
++/*do nothing here*/
++#else
+ static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
+ struct mtd_oob_ops *ops)
+ {
+@@ -753,9 +1077,229 @@ static int doc_write_oob(struct mtd_info
+
+ return ret;
+ }
++#endif /*#ifdef CONFIG_RTL_819X */
++
++#ifdef CONFIG_RTL_819X
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++int find_section_boundary(struct mtd_info *mtd,unsigned int start, unsigned int end, unsigned int *rstart, unsigned *rend)
++{
++ int i = 0;
++ int j = 0;
++ struct mtd_erase_region_info *regions = mtd->eraseregions;
++ while ((i < mtd->numeraseregions) &&
++ (start >= regions[i].offset)) {
++ i++;
++ }
++ i--;
++
++ j = 1;
++ while((j <= regions[i].numblocks) &&
++ (start >= (regions[i].offset+regions[i].erasesize*j))) {
++ j++;
++ }
++ *rstart=(regions[i].offset+regions[i].erasesize*(j-1));
++
++ i=0;
++ while ((i < mtd->numeraseregions) &&
++ (end >= regions[i].offset)) {
++ i++;
++ }
++ i--;
++
++ j = 1;
++ while((j <= regions[i].numblocks) &&
++ (end >= (regions[i].offset+regions[i].erasesize*j))) {
++ j++;
++ }
++ *rend=(regions[i].offset+regions[i].erasesize*j);
++
++}
++#endif
++#endif
+
+ int doc_erase (struct mtd_info *mtd, struct erase_info *instr)
+ {
++#ifdef CONFIG_RTL_819X
++
++struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
++ unsigned long adr, len;
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ unsigned int rstart,rend;
++ unsigned int start,end;
++#endif
++ int i;
++ int first;
++ struct mtd_erase_region_info *regions = mtd->eraseregions;
++
++ DEBUG(MTD_DEBUG_LEVEL1, "going to erase sector addr=%08x,len=%08x\n",
++ instr->addr, instr->len);
++
++ if (instr->addr > mtd->size) {
++ printk(KERN_WARNING "Erase addr greater than max size (0x%x > 0x%x)\n",
++ instr->addr, mtd->size );
++ return -EINVAL;
++ }
++
++ if ((instr->len + instr->addr) > mtd->size) {
++ printk(KERN_WARNING "Erase size greater than max size (0x%x + 0x%x > 0x%x)\n",
++ instr->addr, instr->len, mtd->size );
++ return -EINVAL;
++ }
++
++ /* Check that both start and end of the requested erase are
++ * aligned with the erasesize at the appropriate addresses.
++ */
++
++ i = 0;
++
++ /* Skip all erase regions which are ended before the start of
++ the requested erase. Actually, to save on the calculations,
++ we skip to the first erase region which starts after the
++ start of the requested erase, and then go back one.
++ */
++
++ while ((i < mtd->numeraseregions) &&
++ (instr->addr >= regions[i].offset)) {
++ i++;
++ }
++ i--;
++
++ /* OK, now i is pointing at the erase region in which this
++ * erase request starts. Check the start of the requested
++ * erase range is aligned with the erase size which is in
++ * effect here.
++ */
++
++ if (instr->addr & (regions[i].erasesize-1)) {
++ return -EINVAL;
++ }
++
++ /* Remember the erase region we start on. */
++
++ first = i;
++
++ /* Next, check that the end of the requested erase is aligned
++ * with the erase region at that address.
++ */
++
++ while ((i < mtd->numeraseregions) &&
++ ((instr->addr + instr->len) >= regions[i].offset)) {
++ i++;
++ }
++
++ /* As before, drop back one to point at the region in which
++ * the address actually falls.
++ */
++
++ i--;
++
++ if ((instr->addr + instr->len) & (regions[i].erasesize-1)) {
++ return -EINVAL;
++ }
++
++
++ adr = instr->addr;
++ len = instr->len;
++
++ i = first;
++ instr->state = MTD_ERASING;
++
++
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ start=adr;
++ end=0xFFFFFFF;
++ if(flash_write_flag & 1)
++ {
++ if(0 == start)
++ start = CONFIG_RTL_HW_SETTING_OFFSET;
++ else if( start > CONFIG_RTL_HW_SETTING_OFFSET )
++ start = CONFIG_RTL_HW_SETTING_OFFSET;
++ end = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
++ }
++
++ if(flash_write_flag & 2 )
++ {
++ if(0 == start)
++ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
++ else if( start > CONFIG_RTL_DEFAULT_SETTING_OFFSET )
++ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
++ end = CONFIG_RTL_CURRENT_SETTING_OFFSET;
++ }
++
++ if(flash_write_flag & 4 )
++ {
++ if(0 == start)
++ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
++ else if( start > CONFIG_RTL_CURRENT_SETTING_OFFSET )
++ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
++
++ end = CONFIG_RTL_WEB_PAGES_OFFSET;
++ }
++
++ find_section_boundary(mtd,start,end,&rstart,&rend);
++
++ //printk("line[%d] rstart 0x%x rend 0x%x\n",__LINE__,rstart,rend);
++
++ /*don't erase bootcode*/
++ if(rstart < RTL_BOOTCODE_END)
++ rstart = RTL_BOOTCODE_END;
++
++ //printk("line[%d] rstart 0x%x rend 0x%x\n",__LINE__,rstart,rend);
++#endif
++
++ while (len) {
++// if (adr >= CONFIG_MTD_DOCPROBE_ADDRESS) {
++
++#if defined(COMPACK_SETTING) || defined(NO_CHECK_REGION)
++ if ( erase_one_block(this, adr, regions[i].erasesize) )
++ return -1;
++
++#else
++
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ if(adr >= rstart)
++#else
++ if ( ((flash_write_flag & 1) && (adr == flash_hw_start)) ||
++ ((flash_write_flag & 2) &&(adr >= flash_ds_start && adr < (flash_ds_start+flash_ds_len)))
++ || ((flash_write_flag & 4) && (adr >= (flash_ds_start+flash_ds_len)))
++//#ifdef CONFIG_RTK_MTD_ROOT
++#ifdef CONFIG_RTL_819X
++ || (adr >= (rtl8196_partitions[0].size+ rtl8196_partitions[0].offset))
++#endif
++ || (flash_write_flag == 0x8000)
++ )
++#endif
++ {
++ if ( erase_one_block(this, adr, regions[i].erasesize) )
++ return -1;
++ }
++
++#endif // COMPACK_SETTING || NO_CHECK_REGION
++
++ adr += regions[i].erasesize;
++ if (len < regions[i].erasesize)
++ len = 0;
++ else
++ len -= regions[i].erasesize;
++
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ if(rend <= adr)
++ {
++ /*no need to erase other block*/
++ len=0;
++ }
++#endif
++ if ( adr >= (regions[i].offset + regions[i].erasesize*regions[i].numblocks))
++ i++;
++ }
++
++ instr->state = MTD_ERASE_DONE;
++ if (instr->callback) {
++ instr->callback(instr);
++ }
++
++ return 0;
++#else
+ volatile char dummy;
+ struct DiskOnChip *this = mtd->priv;
+ __u32 ofs = instr->addr;
+@@ -809,7 +1353,52 @@ int doc_erase (struct mtd_info *mtd, str
+ mtd_erase_callback(instr);
+
+ return 0;
++
++#endif /*#ifdef CONFIG_RTL_819X */
++}
++
++#ifdef CONFIG_RTL_819X
++static int erase_one_block(struct DiskOnChip *this, __u32 addr, __u32 len)
++{
++ unsigned long timeo;
++ unsigned long docptr = this->virtadr;
++ __u32 ofs, offset;
++ unsigned long flags; // david
++
++
++ DEBUG(MTD_DEBUG_LEVEL1, "Erase sector, addr=0x%x, docptr=0x%x, len=0x%x\n",
++ (int)addr, (int)docptr, (int)len);
++
++ // issue erase command!
++ ofs = docptr + addr;
++
++ offset = (addr >> this->chipshift)*(1 << this->chipshift);
++
++ mtd_save_flags(flags);mtd_cli(); // david
++ *(volatile unsigned short *)(docptr + offset + 0x555 * 2) = 0xaa;
++ *(volatile unsigned short *)(docptr + offset + 0x2aa * 2) = 0x55;
++ *(volatile unsigned short *)(docptr + offset + 0x555 * 2) = 0x80;
++ *(volatile unsigned short *)(docptr + offset + 0x555 * 2) = 0xaa;
++ *(volatile unsigned short *)(docptr + offset + 0x2aa * 2) = 0x55;
++ *(volatile unsigned short *)(ofs ) = 0x30;
++ mtd_restore_flags(flags); // david
++
++ timeo = jiffies + (HZ * 40);
++
++ while (1) {
++ if ((*(volatile unsigned short *)(ofs))==0xffff) {
++ DEBUG(MTD_DEBUG_LEVEL1, "Erase success!\n");
++ break;
++ }
++ if (time_after(jiffies, timeo)) {
++ printk(KERN_WARNING "Erase timeout!\n");
++ return -1;
++ }
++ udelay(1);
++ }
++ return 0;
+ }
++#endif /*#ifdef CONFIG_RTL_819X */
+
+ /****************************************************************************
+ *
+--- linux-2.6.30.9/drivers/mtd/devices/docprobe.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/mtd/devices/docprobe.c 2013-05-02 01:47:52.630227147 +0300
+@@ -36,7 +36,7 @@
+ <linux-mtd@lists.infradead.org>.
+ */
+ #define DOC_SINGLE_DRIVER
+-
++#include <linux/config.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <asm/errno.h>
+@@ -56,10 +56,68 @@
+ #define CONFIG_MTD_DOCPROBE_ADDRESS 0
+ #endif
+
++#ifdef CONFIG_RTL_819X
++// david ----------------------
++/* MXIC */
++#define MANUFACTURER_MXIC 0x00C2
++#define MX29LV800B 0x225B
++#define MX29LV160AB 0x2249
++#define MX29LV320AB 0x22A8
++#define MX29LV640AB 0x22CB
++
++/*AMD*/
++#define MANUFACTURER_AMD 0x0001
++#define AM29LV800BB 0x225B
++#define AM29LV160DB 0x2249
++#define AM29LV320DB 0x22F9
++
++/*ST*/
++#define MANUFACTURER_ST 0x0020
++#define M29W160DB 0X2249
++
++/* ESMT */
++#define MANUFACTURER_ESMT 0x008C
++#define F49L160BA 0x2249
++
++/* SAMSUNG */
++#define MANUFACTURER_SAMSUNG 0x00EC
++#define K8D1716UBC 0x2277
++
++/* ESI */
++#define MANUFACTURER_ESI 0x004A
++#define ES29LV320D 0x22F9
++
++/* EON */
++#define MANUFACTURER_EON 0x007F
++#define EN29LV160A 0x2249
++
++#ifdef CONFIG_RTL8196B
++#define FLASH_BASE 0xbd000000
++#else
++#define FLASH_BASE 0xbe000000
++#endif
++
++struct flash_info {
++ const __u16 mfr_id;
++ const __u16 dev_id;
++ const char *name;
++ const u_long size;
++ const int shift; // shift number of chip size
++ const int numeraseregions;
++ const struct mtd_erase_region_info regions[4];
++};
++
++static int probeChip(struct DiskOnChip *doc, struct mtd_info *mtd);
++//-----------------------------
++#endif /*#ifdef CONFIG_RTL_819X*/
++
++//static unsigned long doc_config_location = CONFIG_MTD_DOCPROBE_ADDRESS;
++//module_param(doc_config_location, ulong, 0);
++//MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
+
+-static unsigned long doc_config_location = CONFIG_MTD_DOCPROBE_ADDRESS;
+-module_param(doc_config_location, ulong, 0);
+-MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
++#ifdef CONFIG_RTL_819X
++ /* Do nothing here*/
++#else
+
+ static unsigned long __initdata doc_locations[] = {
+ #if defined (__alpha__) || defined(__i386__) || defined(__x86_64__)
+@@ -76,6 +134,13 @@ static unsigned long __initdata doc_loca
+ 0xe0000, 0xe2000, 0xe4000, 0xe6000,
+ 0xe8000, 0xea000, 0xec000, 0xee000,
+ #endif /* CONFIG_MTD_DOCPROBE_HIGH */
++#elif defined(__PPC__)
++ 0xe4000000,
++#elif defined(CONFIG_MOMENCO_OCELOT)
++ 0x2f000000,
++ 0xff000000,
++#elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C)
++ 0xff000000,
+ #else
+ #warning Unknown architecture for DiskOnChip. No default probe locations defined
+ #endif
+@@ -217,8 +282,9 @@ static inline int __init doccheck(void _
+ #endif
+ return 0;
+ }
++#endif /*#ifdef CONFIG_RTL_819X*/
+
+-static int docfound;
++//static int docfound;
+
+ extern void DoC2k_init(struct mtd_info *);
+ extern void DoCMil_init(struct mtd_info *);
+@@ -229,11 +295,18 @@ static void __init DoC_Probe(unsigned lo
+ void __iomem *docptr;
+ struct DiskOnChip *this;
+ struct mtd_info *mtd;
+- int ChipID;
++ //int ChipID;
+ char namebuf[15];
+ char *name = namebuf;
++
++
++ char *im_funcname = NULL;
++ char *im_modname = NULL;
++
++
+ void (*initroutine)(struct mtd_info *) = NULL;
+
++#ifndef CONFIG_RTL_819X
+ docptr = ioremap(physadr, DOC_IOREMAP_LEN);
+
+ if (!docptr)
+@@ -302,8 +375,286 @@ static void __init DoC_Probe(unsigned lo
+ kfree(mtd);
+ }
+ iounmap(docptr);
++#else
++ docptr = FLASH_BASE;
++ //-----------------------------
++
++
++ mtd = kmalloc(sizeof(struct DiskOnChip) + sizeof(struct mtd_info), GFP_KERNEL);
++
++ if (!mtd) {
++ printk(KERN_WARNING "Cannot allocate memory for data structures. Dropping.\n");
++ iounmap((void *)docptr);
++ return;
+ }
+
++ this = (struct DiskOnChip *)(&mtd[1]);
++
++ memset((char *)mtd,0, sizeof(struct mtd_info));
++ memset((char *)this, 0, sizeof(struct DiskOnChip));
++
++ mtd->priv = this;
++ this->virtadr = docptr;
++ this->physadr = physadr;
++ this->ChipID = DOC_ChipID_DocMil;
++
++ name="Millennium";
++ im_funcname = "DoCMil_init";
++ im_modname = "doc2001";
++
++ if ( probeChip(this, mtd) == 0) // david added,
++ initroutine = &DoCMil_init;
++
++ if (initroutine) {
++ (*initroutine)(mtd);
++ return;
++ }
++ printk(KERN_NOTICE "Cannot find driver for DiskOnChip %s at 0x%lX\n", name, physadr);
++ iounmap((void *)docptr);
++
++#endif /*#ifdef CONFIG_RTL_819X*/
++}
++
++#ifdef CONFIG_RTL_819X
++// david -------------------------------------------------------------------
++static int probeChip(struct DiskOnChip *doc, struct mtd_info *mtd)
++{
++ /* Keep this table on the stack so that it gets deallocated after the
++ * probe is done.
++ */
++ const struct flash_info table[] = {
++ {
++ mfr_id: MANUFACTURER_MXIC,
++ dev_id: MX29LV800B,
++ name: "MXIC MX29LV800B",
++ size: 0x00100000,
++ shift: 20,
++ numeraseregions: 4,
++ regions: {
++ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
++ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
++ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 15 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_MXIC,
++ dev_id: MX29LV160AB,
++ name: "MXIC MX29LV160AB",
++ size: 0x00200000,
++ shift: 21,
++ numeraseregions: 4,
++ regions: {
++ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
++ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
++ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_MXIC,
++ dev_id: MX29LV320AB,
++ name: "MXIC MX29LV320AB",
++ size: 0x00400000,
++ shift: 22,
++ numeraseregions: 2,
++ regions: {
++ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 63 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_AMD,
++ dev_id: AM29LV800BB,
++ name: "AMD AM29LV800BB",
++ size: 0x00100000,
++ shift: 20,
++ numeraseregions: 4,
++ regions: {
++ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
++ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
++ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 15 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_AMD,
++ dev_id: AM29LV160DB,
++ name: "AMD AM29LV160DB",
++ size: 0x00200000,
++ shift: 21,
++ numeraseregions: 4,
++ regions: {
++ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
++ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
++ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_AMD,
++ dev_id: AM29LV320DB,
++ name: "AMD AM29LV320DB",
++ size: 0x00400000,
++ shift: 22,
++ numeraseregions: 2,
++ regions: {
++ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 63 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_ST,
++ dev_id: M29W160DB,
++ name: "ST M29W160DB",
++ size: 0x00200000,
++ shift: 21,/*21 bit=> that is 2 MByte size*/
++ numeraseregions: 4,
++ regions: {
++ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
++ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
++ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_MXIC,
++ dev_id: MX29LV640AB,
++ name: "MXIC MX29LV640AB",
++ size: 0x00800000,
++ shift: 23,/*22 bit=> that is 8 MByte size*/
++ numeraseregions: 2,
++ regions: {
++ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 127 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_SAMSUNG,
++ dev_id: K8D1716UBC,
++ name: "SAMSUNG K8D1716UBC",
++ size: 0x00200000,
++ shift: 21,/*21 bit=> that is 2 MByte size*/
++ numeraseregions: 2,
++ regions: {
++ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_ESMT,
++ dev_id: F49L160BA,
++ name: "ESMT F49L160BA",
++ size: 0x00200000,
++ shift: 21,/*21 bit=> that is 2 MByte size*/
++ numeraseregions: 4,
++ regions: {
++ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
++ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
++ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_ESI,
++ dev_id: ES29LV320D,
++ name: "ESI ES29LV320D",
++ size: 0x00400000,
++ shift: 22,/*22 bit=> that is 4 MByte size*/
++ numeraseregions: 2,
++ regions: {
++ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 63 }
++ }
++ },
++ {
++ mfr_id: MANUFACTURER_EON,
++ dev_id: EN29LV160A,
++ name: "EON EN29LV160A",
++ size: 0x00200000,
++ shift: 21,
++ numeraseregions: 4,
++ regions: {
++ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
++ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
++ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
++ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
++ }
++ }
++ };
++
++ struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
++ unsigned long docptr = this->virtadr;
++ __u16 mfid, devid;
++ int i, j, k, interleave=1, chipsize;
++
++ // issue reset and auto-selection command
++ *(volatile unsigned short *)(FLASH_BASE) = 0xf0;
++
++ *(volatile unsigned short *)(FLASH_BASE + 0x555 * 2) = 0xaa;
++ *(volatile unsigned short *)(FLASH_BASE + 0x2aa * 2) = 0x55;
++ *(volatile unsigned short *)(FLASH_BASE + 0x555 * 2) = 0x90;
++
++ mfid = *((volatile unsigned short *)docptr);
++ devid = *((volatile unsigned short *)(docptr + 1*2));
++
++ *(volatile unsigned short *)(FLASH_BASE) = 0xf0;
++
++ for (i=0; i< sizeof(table)/sizeof(table[0]); i++) {
++ if ( mfid==table[i].mfr_id && devid==table[i].dev_id)
++ break;
++ }
++ if ( i == sizeof(table)/sizeof(table[0]) )
++ return -1;
++
++ // Look for 2nd flash
++ *(volatile unsigned short *)(FLASH_BASE + table[i].size) = 0xf0;
++ *(volatile unsigned short *)(FLASH_BASE + table[i].size + 0x555 * 2) = 0xaa;
++ *(volatile unsigned short *)(FLASH_BASE + table[i].size + 0x2aa * 2) = 0x55;
++ *(volatile unsigned short *)(FLASH_BASE + table[i].size + 0x555 * 2) = 0x90;
++
++ mfid = *((volatile unsigned short *)(docptr + table[i].size));
++ devid = *((volatile unsigned short *)(docptr + table[i].size + 1*2));
++
++ *(volatile unsigned short *)(FLASH_BASE+table[i].size) = 0xf0;
++ if ( mfid==table[i].mfr_id && devid==table[i].dev_id) {
++ interleave++;
++ }
++
++ printk(KERN_NOTICE "Found %d x %ldM Byte %s at 0x%lx\n",
++ interleave, (table[i].size)/(1024*1024), table[i].name, docptr);
++
++ mtd->size = table[i].size*interleave;
++ mtd->numeraseregions = table[i].numeraseregions*interleave;
++
++ mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) *
++ mtd->numeraseregions*interleave, GFP_KERNEL);
++ if (!mtd->eraseregions) {
++ printk(KERN_WARNING "Failed to allocate "
++ "memory for MTD erase region info\n");
++ kfree(mtd);
++ return -1;
++ }
++
++ for (k=0, chipsize=0; interleave>0; interleave--, chipsize+=table[i].size) {
++ for (j=0; j<table[i].numeraseregions; j++, k++) {
++ mtd->eraseregions[k].offset = table[i].regions[j].offset+chipsize;
++ mtd->eraseregions[k].erasesize = table[i].regions[j].erasesize;
++ mtd->eraseregions[k].numblocks = table[i].regions[j].numblocks;
++ if (mtd->erasesize < mtd->eraseregions[k].erasesize)
++ mtd->erasesize = mtd->eraseregions[k].erasesize;
++ }
++ }
++
++ this->totlen = mtd->size;
++ this->numchips = interleave;
++ this->chipshift = table[i].shift;
++
++ return 0;
++}
++//---------------------------------------------------------------------------
++#endif /*#ifdef CONFIG_RTL_819X */
++
+
+ /****************************************************************************
+ *
+@@ -313,6 +664,14 @@ static void __init DoC_Probe(unsigned lo
+
+ static int __init init_doc(void)
+ {
++#ifdef CONFIG_RTL_819X
++ printk(KERN_NOTICE "RealTek E-Flash System Driver. (C) 2002 RealTek Corp.\n");
++ DoC_Probe(CONFIG_MTD_DOCPROBE_ADDRESS);
++ /* So it looks like we've been used and we get unloaded */
++// MOD_INC_USE_COUNT;
++// MOD_DEC_USE_COUNT;
++ return 0;
++#else
+ int i;
+
+ if (doc_config_location) {
+@@ -328,6 +687,7 @@ static int __init init_doc(void)
+ if (!docfound)
+ printk(KERN_INFO "No recognised DiskOnChip devices found\n");
+ return -EAGAIN;
++#endif
+ }
+
+ module_init(init_doc);
+--- linux-2.6.30.9/drivers/mtd/maps/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/mtd/maps/Makefile 2013-05-02 01:47:52.636227146 +0300
+@@ -62,3 +62,4 @@ obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_
+ obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o
+ obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o
+ obj-$(CONFIG_MTD_VMU) += vmu-flash.o
++obj-$(CONFIG_RTL819X_SPI_FLASH) += rtl819x_flash.o
+--- linux-2.6.30.9/drivers/mtd/mtdblock.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/mtd/mtdblock.c 2013-05-02 01:47:52.649227145 +0300
+@@ -18,6 +18,26 @@
+ #include <linux/mtd/blktrans.h>
+ #include <linux/mutex.h>
+
++#include <linux/config.h>
++
++#ifdef CONFIG_RTL_819X
++// david ---------------
++//#define CONFIG_MTD_DEBUG
++#define CONFIG_MTD_DEBUG_VERBOSE 3
++
++
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++int flash_write_flag=0; // 1: hw setting 2: default setting, 4: current setting, 8: system image
++#else
++int flash_hw_start=0x6000; // hw setting start address
++int flash_hw_len=0x2000; // hw setting length
++int flash_ds_start=0x8000; // default & current setting start address
++int flash_ds_len=0x8000; // default & current setting length
++
++int flash_write_flag=0; // 1: hw setting 2: default setting, 4: current setting, 8: system image
++#endif
++#endif /*#ifdef CONFIG_RTL_819X */
++
+
+ static struct mtdblk_dev {
+ struct mtd_info *mtd;
+@@ -134,6 +154,58 @@ static int do_cached_write (struct mtdbl
+ DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: write on \"%s\" at 0x%lx, size 0x%x\n",
+ mtd->name, pos, len);
+
++
++#ifdef CONFIG_RTL_819X
++#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
++ /*since len is normal 0x200 less than every section*/
++ if(flash_write_flag != 0x8000)
++ {
++ flash_write_flag = 0;
++ if ( pos >= CONFIG_RTL_HW_SETTING_OFFSET && pos < CONFIG_RTL_DEFAULT_SETTING_OFFSET ) {
++ flash_write_flag |= 1;
++ if ((pos+len) > CONFIG_RTL_DEFAULT_SETTING_OFFSET ) {
++ flash_write_flag |= 2;
++ if ((pos+len) > CONFIG_RTL_CURRENT_SETTING_OFFSET )
++ flash_write_flag |= 4;
++ }
++ }
++ if ( pos >= CONFIG_RTL_DEFAULT_SETTING_OFFSET && pos < CONFIG_RTL_CURRENT_SETTING_OFFSET ) {
++ flash_write_flag |= 2;
++ if ((pos+len) > CONFIG_RTL_CURRENT_SETTING_OFFSET ) {
++ flash_write_flag |= 4;
++ }
++ }
++ else if ( pos >= CONFIG_RTL_CURRENT_SETTING_OFFSET && pos < CONFIG_RTL_WEB_PAGES_OFFSET ){
++ flash_write_flag |= 4;
++ }
++ }
++#else
++// david --------------
++ if ( flash_write_flag != 0x8000)
++ {
++ flash_write_flag = 0;
++ if (pos >= flash_hw_start && pos < (flash_hw_start+flash_hw_len) ) {
++ flash_write_flag |= 1;
++ if ((len - flash_hw_len) > 0) {
++ flash_write_flag |= 2;
++ if ((len - flash_ds_len -flash_hw_len) > 0)
++ flash_write_flag |= 4;
++ }
++ }
++ if (pos >= flash_ds_start && pos < (flash_ds_start+flash_ds_len) ) {
++ flash_write_flag |= 2;
++ if ((len - flash_ds_len) > 0) {
++ flash_write_flag |= 4;
++ }
++ }
++ else if ( pos >= (flash_ds_start+flash_ds_len) ){
++ flash_write_flag |= 4;
++ }
++ }
++//---------------------
++#endif //CONFIG_RTL_FLASH_MAPPING_ENABLE
++#endif
++
+ if (!sect_size)
+ return mtd->write(mtd, pos, len, &retlen, buf);
+
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-net.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-net.patch
new file mode 100644
index 000000000..f2ccbb2c8
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-net.patch
@@ -0,0 +1,1342 @@
+--- linux-2.6.30.9/drivers/net/Kconfig 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/net/Kconfig 2013-05-02 01:47:52.704227141 +0300
+@@ -27,7 +27,7 @@ menuconfig NETDEVICES
+ if NETDEVICES
+
+ config COMPAT_NET_DEV_OPS
+- default y
++ default n
+ bool "Enable older network device API compatibility"
+ ---help---
+ This option enables kernel compatibility with older network devices
+@@ -2146,6 +2146,22 @@ config R8169_VLAN
+
+ If in doubt, say Y.
+
++config R8168
++ tristate "Realtek 8168 gigabit ethernet support"
++ depends on PCI
++ select CRC32
++ default y
++ ---help---
++ Say Y here if you have a Realtek 8168 PCI Gigabit Ethernet adapter.
++
++ To compile this driver as a module, choose M here: the module
++ will be called r8168. This is recommended.
++
++config R8168_NAPI
++ bool "NAPI support"
++ depends on R8168
++ default y
++
+ config SB1250_MAC
+ tristate "SB1250 Gigabit Ethernet support"
+ depends on SIBYTE_SB1xxx_SOC
+@@ -2987,19 +3003,39 @@ config PPP_BSDCOMP
+ module; it is called bsd_comp and will show up in the directory
+ modules once you have said "make modules". If unsure, say N.
+
+-config PPP_MPPE
+- tristate "PPP MPPE compression (encryption) (EXPERIMENTAL)"
+- depends on PPP && EXPERIMENTAL
+- select CRYPTO
++config PPP_MPPE_MPPC
++ tristate "Microsoft PPP compression/encryption (MPPC/MPPE)"
++ depends on PPP
+ select CRYPTO_SHA1
+ select CRYPTO_ARC4
+- select CRYPTO_ECB
+ ---help---
+- Support for the MPPE Encryption protocol, as employed by the
+- Microsoft Point-to-Point Tunneling Protocol.
++ Support for the Microsoft Point-To-Point Compression (RFC2118) and
++ Microsoft Point-To-Point Encryption (RFC3078). These protocols are
++ supported by Microsoft Windows and wide range of "hardware" access
++ servers. MPPE is common protocol in Virtual Private Networks. According
++ to RFC3078, MPPE supports 40, 56 and 128-bit key lengths. Depending on
++ PPP daemon configuration on both ends of the link, following scenarios
++ are possible:
++ - only compression (MPPC) is used,
++ - only encryption (MPPE) is used,
++ - compression and encryption (MPPC+MPPE) are used.
++
++ Please note that Hi/Fn (http://www.hifn.com) holds patent on MPPC so
++ you should check if this patent is valid in your country in order to
++ avoid legal problems.
+
+- See http://pptpclient.sourceforge.net/ for information on
+- configuring PPTP clients and servers to utilize this method.
++ For more information please visit http://mppe-mppc.alphacron.de
++
++ To compile this driver as a module, choose M here. The module will
++ be called ppp_mppe_mppc.ko.
++
++
++config PPP_IDLE_TIMEOUT_REFINE
++ tristate "PPP idle timeout refine"
++ depends on PPP
++ help
++ skip some kinds of packets from DUT to WAN or WAN to DUT that will cause PPPoE/PPTP/L2TP idle timeout
++ can't work well
+
+ config PPPOE
+ tristate "PPP over Ethernet (EXPERIMENTAL)"
+@@ -3155,4 +3191,22 @@ config VIRTIO_NET
+ This is the virtual network driver for virtio. It can be used with
+ lguest or QEMU based VMMs (like KVM or Xen). Say Y or M.
+
++config R8198EP
++ bool "Realtek 8198 slave pcie support"
++ ---help---
++ Say Y here if you have a Realtek 8198 slave pcie Ethernet adapter.
++
++config R8198EP_HOST
++ tristate "Host site view for slave PCIe RTL8198"
++ depends on R8198EP
++ ---help---
++ Say Y here if you have a Realtek 8198 slave pcie Ethernet adapter.
++config R8198EP_DEVICE
++ tristate "Device site view for salve PCIe RTL8198"
++ depends on R8198EP
++ ---help---
++ Say Y here if you have a Realtek 8198 slave pcie Ethernet adapter.
++
++
++source "drivers/net/rtl819x/Kconfig"
+ endif # NETDEVICES
+--- linux-2.6.30.9/drivers/net/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/net/Makefile 2013-05-02 01:47:52.705227141 +0300
+@@ -142,7 +142,7 @@ obj-$(CONFIG_PPP_ASYNC) += ppp_async.o
+ obj-$(CONFIG_PPP_SYNC_TTY) += ppp_synctty.o
+ obj-$(CONFIG_PPP_DEFLATE) += ppp_deflate.o
+ obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o
+-obj-$(CONFIG_PPP_MPPE) += ppp_mppe.o
++obj-$(CONFIG_PPP_MPPE_MPPC) += ppp_mppe_mppc.o
+ obj-$(CONFIG_PPPOE) += pppox.o pppoe.o
+ obj-$(CONFIG_PPPOL2TP) += pppox.o pppol2tp.o
+
+@@ -218,6 +218,7 @@ obj-$(CONFIG_VETH) += veth.o
+ obj-$(CONFIG_NET_NETX) += netx-eth.o
+ obj-$(CONFIG_DL2K) += dl2k.o
+ obj-$(CONFIG_R8169) += r8169.o
++obj-$(CONFIG_R8168) += r8168/
+ obj-$(CONFIG_AMD8111_ETH) += amd8111e.o
+ obj-$(CONFIG_IBMVETH) += ibmveth.o
+ obj-$(CONFIG_S2IO) += s2io.o
+@@ -271,3 +272,12 @@ obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
+ obj-$(CONFIG_SFC) += sfc/
+
+ obj-$(CONFIG_WIMAX) += wimax/
++
++obj-$(CONFIG_RTL_819X_SWCORE) += rtl819x/built-in.o
++subdir-$(CONFIG_RTL_819X_SWCORE) += rtl819x
++
++obj-$(CONFIG_RTK_VLAN_SUPPORT) += rtk_vlan.o
++obj-$(CONFIG_R8198EP) += r8198ep/
++
++#DIR_RTLASIC = $(DIR_LINUX)/drivers/net/rtl819x/
++#EXTRA_CFLAGS += -I$(DIR_RTLASIC)
+--- linux-2.6.30.9/drivers/net/ppp_generic.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/net/ppp_generic.c 2013-05-02 01:47:53.185227102 +0300
+@@ -42,6 +42,9 @@
+ #include <linux/tcp.h>
+ #include <linux/smp_lock.h>
+ #include <linux/spinlock.h>
++#if defined(CONFIG_PPP_MPPE_MPPC)
++#include <linux/smp_lock.h>
++#endif
+ #include <linux/rwsem.h>
+ #include <linux/stddef.h>
+ #include <linux/device.h>
+@@ -52,6 +55,49 @@
+ #include <linux/nsproxy.h>
+ #include <net/net_namespace.h>
+ #include <net/netns/generic.h>
++#include <linux/icmp.h>
++
++#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
++#include <linux/if_pppox.h>
++#endif
++
++#include <net/rtl/rtl_types.h>
++#if defined(CONFIG_RTL_819X)
++#include <net/rtl/rtl_nic.h>
++#endif
++
++#include <net/rtl/rtl865x_netif.h>
++#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
++#include <net/rtl/rtl865x_ppp.h>
++#endif
++
++#if defined (CONFIG_RTL_HW_QOS_SUPPORT) // sync from voip customer for multiple ppp
++#include <net/rtl/rtl865x_outputQueue.h>
++#endif
++
++#if defined(NAT_SPEEDUP)||defined(CONFIG_RTL_IPTABLES_FAST_PATH)
++ #define FAST_PPTP
++ #define FAST_L2TP
++#endif
++
++#ifdef CONFIG_RTL_LAYERED_DRIVER
++enum SE_TYPE
++{
++ /*1:if_ether, 2:pppoe,3:pptp,4:l2tp*/
++ SE_ETHER = 1,
++ SE_PPPOE = 2,
++ SE_PPTP = 3,
++ SE_L2TP = 4,
++};
++#else
++enum SE_TYPE
++{
++ SE_PPPOE = 1,
++ SE_PPTP = 2,
++ SE_L2TP = 3,
++};
++#endif /*CONFIG_RTL865X_LAYERED_DRIVER*/
++
+
+ #define PPP_VERSION "2.4.2"
+
+@@ -88,10 +134,18 @@ struct ppp_file {
+ int dead; /* unit/channel has been shut down */
+ };
+
++#if defined(CONFIG_PPP_MPPE_MPPC)
++#define PF_TO_X(pf, X) ((X *)((char *)(pf) - offsetof(X, file)))
++#else
+ #define PF_TO_X(pf, X) container_of(pf, X, file)
++#endif
+
+ #define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp)
+ #define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel)
++//#if defined(CONFIG_PPP_MPPE_MPPC)
++//#undef ROUNDUP
++//#define ROUNDUP(n, x) (((n) + (x) - 1) / (x))
++//#endif
+
+ /*
+ * Data structure describing one ppp unit.
+@@ -107,6 +161,9 @@ struct ppp {
+ spinlock_t rlock; /* lock for receive side 58 */
+ spinlock_t wlock; /* lock for transmit side 5c */
+ int mru; /* max receive unit 60 */
++#if defined(CONFIG_PPP_MPPE_MPPC)
++ int mru_alloc; /* MAX(1500,MRU) for dev_alloc_skb() */
++#endif
+ unsigned int flags; /* control bits 64 */
+ unsigned int xstate; /* transmit state bits 68 */
+ unsigned int rstate; /* receive state bits 6c */
+@@ -130,6 +187,7 @@ struct ppp {
+ u32 minseq; /* MP: min of most recent seqnos */
+ struct sk_buff_head mrq; /* MP: receive reconstruction queue */
+ #endif /* CONFIG_PPP_MULTILINK */
++ struct net_device_stats stats; /* statistics */
+ #ifdef CONFIG_PPP_FILTER
+ struct sock_filter *pass_filter; /* filter for packets to pass */
+ struct sock_filter *active_filter;/* filter for pkts to reset idle */
+@@ -138,6 +196,67 @@ struct ppp {
+ struct net *ppp_net; /* the net we belong to */
+ };
+
++#ifdef FAST_PPTP
++#define MPPE_CCOUNT(p) ((((p)[2] & 0x0f) << 8) + (p)[3])
++typedef struct {
++ unsigned i;
++ unsigned j;
++ unsigned char S[256];
++} arcfour_context;
++
++
++#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */ /* reference from ppp_mppe.h*/
++
++
++#if defined(CONFIG_PPP_MPPE_MPPC)
++typedef struct ppp_mppe_state { /* reference from ppp_mppe_mppc.c */
++ struct crypto_tfm *arc4_tfm;
++ u8 master_key[MPPE_MAX_KEY_LEN];
++ u8 session_key[MPPE_MAX_KEY_LEN];
++ u8 mppc; /* do we use compression (MPPC)? */
++ u8 mppe; /* do we use encryption (MPPE)? */
++ u8 keylen; /* key length in bytes */
++ u8 bitkeylen; /* key length in bits */
++ u16 ccount; /* coherency counter */
++ u16 bits; /* MPPC/MPPE control bits */
++ u8 stateless; /* do we use stateless mode? */
++ u8 nextflushed; /* set A bit in the next outgoing packet;
++ used only by compressor*/
++ u8 flushexpected; /* drop packets until A bit is received;
++ used only by decompressor*/
++ u8 *hist; /* MPPC history */
++ u16 *hash; /* Hash table; used only by compressor */
++ u16 histptr; /* history "cursor" */
++ int unit;
++ int debug;
++ int mru;
++ struct compstat stats;
++}ppp_mppe_state;
++#else
++typedef struct ppp_mppe_state { /* reference from ppp_mppe.c */
++ struct crypto_blkcipher *arc4;
++ struct crypto_hash *sha1;
++ unsigned char *sha1_digest;
++ unsigned char master_key[MPPE_MAX_KEY_LEN];
++ unsigned char session_key[MPPE_MAX_KEY_LEN];
++ unsigned keylen; /* key length in bytes */
++ /* NB: 128-bit == 16, 40-bit == 8! */
++ /* If we want to support 56-bit, */
++ /* the unit has to change to bits */
++ unsigned char bits; /* MPPE control bits */
++ unsigned ccount; /* 12-bit coherency count (seqno) */
++ unsigned stateful; /* stateful mode flag */
++ int discard; /* stateful mode packet loss flag */
++ int sanity_errors; /* take down LCP if too many */
++ int unit;
++ int debug;
++ struct compstat stats;
++} ppp_mppe_state;
++#endif
++
++#endif
++
++
+ /*
+ * Bits in flags: SC_NO_TCP_CCID, SC_CCP_OPEN, SC_CCP_UP, SC_LOOP_TRAFFIC,
+ * SC_MULTILINK, SC_MP_SHORTSEQ, SC_MP_XSHORTSEQ, SC_COMP_TCP, SC_REJ_COMP_TCP,
+@@ -145,9 +264,15 @@ struct ppp {
+ * Bits in rstate: SC_DECOMP_RUN, SC_DC_ERROR, SC_DC_FERROR.
+ * Bits in xstate: SC_COMP_RUN
+ */
++#if defined(CONFIG_PPP_MPPE_MPPC)
++#define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \
++ |SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
++ |SC_COMP_TCP|SC_REJ_COMP_TCP)
++#else
+ #define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \
+ |SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
+ |SC_COMP_TCP|SC_REJ_COMP_TCP|SC_MUST_COMP)
++#endif
+
+ /*
+ * Private data structure for each channel.
+@@ -169,6 +294,12 @@ struct channel {
+ u32 lastseq; /* MP: last sequence # received */
+ int speed; /* speed of the corresponding ppp channel*/
+ #endif /* CONFIG_PPP_MULTILINK */
++#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
++ u8 pppoe;
++ u8 rsv1;
++ u16 rsv2;
++#endif /* CONFIG_RTL865X_HW_TABLES */
++
+ };
+
+ /*
+@@ -235,13 +366,31 @@ struct ppp_net {
+ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
+ struct file *file, unsigned int cmd, unsigned long arg);
+ static void ppp_xmit_process(struct ppp *ppp);
++#ifdef FAST_PPTP
++static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw);
++#else
+ static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
++#endif
++
+ static void ppp_push(struct ppp *ppp);
+ static void ppp_channel_push(struct channel *pch);
+ static void ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb,
+ struct channel *pch);
+ static void ppp_receive_error(struct ppp *ppp);
++#ifdef FAST_PPTP
++struct sk_buff *ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw);
++#ifdef CONFIG_FAST_PATH_MODULE
++int (*FastPath_hook9)( void )=NULL;
++int (*FastPath_hook10)(struct sk_buff *skb)=NULL;
++EXPORT_SYMBOL(FastPath_hook9);
++EXPORT_SYMBOL(FastPath_hook10);
++EXPORT_SYMBOL(ppp_receive_nonmp_frame);
++#endif
++
++#else
+ static void ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb);
++#endif
++
+ static struct sk_buff *ppp_decompress_frame(struct ppp *ppp,
+ struct sk_buff *skb);
+ #ifdef CONFIG_PPP_MULTILINK
+@@ -555,10 +704,25 @@ static int get_filter(void __user *arg,
+ }
+ #endif /* CONFIG_PPP_FILTER */
+
++#if defined (CONFIG_RTL_FAST_PPPOE)
++extern int set_pppoe_info(char *ppp_dev, char *wan_dev, unsigned short sid,
++ unsigned int our_ip,unsigned int peer_ip,
++ unsigned char * our_mac, unsigned char *peer_mac);
++
++extern int clear_pppoe_info(char *ppp_dev, char *wan_dev, unsigned short sid,
++ unsigned int our_ip,unsigned int peer_ip,
++ unsigned char * our_mac, unsigned char *peer_mac);
++extern int get_pppoe_last_rx_tx(char * ppp_dev,char * wan_dev,unsigned short sid,
++ unsigned int our_ip,unsigned int peer_ip,
++ unsigned char * our_mac,unsigned char * peer_mac,
++ unsigned long * last_rx,unsigned long * last_tx);
++extern int fast_pppoe_fw;
++
++#endif
+ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+ {
+ struct ppp_file *pf = file->private_data;
+- struct ppp *ppp;
++ struct ppp *ppp = NULL;
+ int err = -EFAULT, val, val2, i;
+ struct ppp_idle idle;
+ struct npioctl npi;
+@@ -611,11 +775,83 @@ static long ppp_ioctl(struct file *file,
+ case PPPIOCCONNECT:
+ if (get_user(unit, p))
+ break;
++#ifdef CONFIG_RTL_LAYERED_DRIVER_L2 // sync from voip customer for multiple ppp
++ #if defined (CONFIG_RTL_HW_QOS_SUPPORT)
++ rtl865x_qosRearrangeRule();
++ #endif
++#endif
+ err = ppp_connect_channel(pch, unit);
++
++#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
++ if(err == 0 && pch->pppoe==TRUE)
++ {
++ struct sock *sk = (struct sock *) pch->chan->private;
++ struct pppox_sock *po = pppox_sk(sk);
++ struct net_device *local_dev = po->pppoe_dev;
++#ifdef CONFIG_RTL_LAYERED_DRIVER
++#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
++ {
++
++
++ rtl865x_attachMasterNetif(pch->ppp->dev->name, local_dev->name);
++ //add the netif mapping table
++ rtl_add_ps_drv_netif_mapping(pch->ppp->dev,pch->ppp->dev->name); // sync from voip customer for multiple ppp
++ }
++ rtl865x_addPpp(pch->ppp->dev->name , (ether_addr_t*)po->pppoe_pa.remote, po->pppoe_pa.sid, SE_PPPOE);
++#endif
++#endif
++#if defined (CONFIG_RTL_FAST_PPPOE)
++ set_pppoe_info(pch->ppp->dev->name, local_dev->name, po->pppoe_pa.sid,
++ 0,0,NULL, (unsigned char *)po->pppoe_pa.remote);
++#endif
++ }
++#endif
++
++
++ #ifdef FAST_PPTP // sync from voip customer for multiple ppp
++ {
++ extern void set_pptp_device(char *ppp_device);
++ extern int fast_pptp_fw;
++ if (err==0 && fast_pptp_fw)
++ set_pptp_device(pch->ppp->dev->name);
++ }
++ #endif
++
++ #ifdef FAST_L2TP // sync from voip customer for multiple ppp
++ {
++ extern void set_l2tp_device(char *ppp_device);
++ if (err==0)
++ set_l2tp_device(pch->ppp->dev->name);
++ }
++ #endif
++
+ break;
+
+ case PPPIOCDISCONN:
+ err = ppp_disconnect_channel(pch);
++#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
++ if (err == 0 && pch->pppoe==TRUE)
++ {
++ pch->pppoe = FALSE;
++
++#ifdef CONFIG_RTL_LAYERED_DRIVER
++#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
++
++ rtl865x_detachMasterNetif(ppp->dev->name);
++ //del the netif mapping table
++ rtl_del_ps_drv_netif_mapping(pch->ppp->dev);
++ rtl865x_delPppbyIfName(ppp->dev->name);
++#endif
++
++#endif
++
++#if defined (CONFIG_RTL_FAST_PPPOE)
++ clear_pppoe_info(pch->ppp->dev->name, NULL, 0,
++ 0,0,NULL, NULL);
++#endif
++ }
++#endif
++
+ break;
+
+ default:
+@@ -642,7 +878,13 @@ static long ppp_ioctl(struct file *file,
+ case PPPIOCSMRU:
+ if (get_user(val, p))
+ break;
++#if defined(CONFIG_PPP_MPPE_MPPC)
++ ppp->mru_alloc = ppp->mru = val;
++ if (ppp->mru_alloc < PPP_MRU)
++ ppp->mru_alloc = PPP_MRU; /* increase for broken peers */
++#else
+ ppp->mru = val;
++#endif
+ err = 0;
+ break;
+
+@@ -689,6 +931,53 @@ static long ppp_ioctl(struct file *file,
+ break;
+
+ case PPPIOCGIDLE:
++#ifdef FAST_L2TP
++ {
++ extern int fast_l2tp_fw;
++ unsigned long get_fast_l2tp_lastxmit(void);
++ unsigned long fastl2tp_lastxmit;
++ if(fast_l2tp_fw)
++ {
++ fastl2tp_lastxmit = get_fast_l2tp_lastxmit();
++ if(ppp->last_xmit < fastl2tp_lastxmit)
++ ppp->last_xmit = fastl2tp_lastxmit;
++ }
++ }
++#endif
++#ifdef FAST_PPTP
++ {
++ extern int fast_pptp_fw;
++ extern unsigned long get_fastpptp_lastxmit(void);
++ unsigned long fastpptp_lastxmit;
++ if(fast_pptp_fw)
++ {
++ fastpptp_lastxmit = get_fastpptp_lastxmit();
++ if(ppp->last_xmit < fastpptp_lastxmit)
++ ppp->last_xmit = fastpptp_lastxmit;
++ }
++ }
++#endif
++#if defined (CONFIG_RTL_FAST_PPPOE)
++ {
++ unsigned long fast_pppoe_last_rx=0;
++ unsigned long fast_pppoe_last_tx=0;
++
++ if(fast_pppoe_fw)
++ {
++ if(ppp->dev!=NULL)
++ {
++ get_pppoe_last_rx_tx(ppp->dev->name,NULL,0,0,0,NULL,NULL,&fast_pppoe_last_rx,&fast_pppoe_last_tx);
++
++ if(ppp->last_xmit < fast_pppoe_last_tx)
++ ppp->last_xmit = fast_pppoe_last_tx;
++
++ if(ppp->last_recv < fast_pppoe_last_rx)
++ ppp->last_xmit = fast_pppoe_last_rx;
++ }
++ }
++ }
++#endif
++
+ idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
+ idle.recv_idle = (jiffies - ppp->last_recv) / HZ;
+ if (copy_to_user(argp, &idle, sizeof(idle)))
+@@ -788,6 +1077,15 @@ static long ppp_ioctl(struct file *file,
+ return err;
+ }
+
++struct net_device_stats *get_ppp_stats(struct ppp *ppp)
++{
++ return (&ppp->stats);
++}
++
++#ifdef CONFIG_FAST_PATH_MODULE
++EXPORT_SYMBOL(get_ppp_stats);
++#endif
++
+ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
+ struct file *file, unsigned int cmd, unsigned long arg)
+ {
+@@ -951,13 +1249,114 @@ out:
+ /*
+ * Network interface unit routines.
+ */
+-static int
+-ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
++ #if defined(FAST_L2TP)
++extern int fast_l2tp_to_wan(void *skb);
++extern int check_for_fast_l2tp_to_wan(void *skb);
++extern void event_ppp_dev_down(const char * name);
++#endif
++#if defined(FAST_PPTP) || defined(FAST_L2TP)
++int ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
++#else
++static int ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
++#endif
++
+ {
+ struct ppp *ppp = netdev_priv(dev);
+ int npi, proto;
+ unsigned char *pp;
+
++#ifdef FAST_PPTP
++ int is_fast_fw=0;
++ #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
++ extern int fast_pptp_fw;
++ #ifdef CONFIG_FAST_PATH_MODULE
++ if((FastPath_hook9!=NULL) &&(FastPath_hook10!=NULL))
++ {
++ if (FastPath_hook9()) {
++ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L')
++ {
++ is_fast_fw=1;
++ memset(skb->cb, '\x0', 3);
++ }
++ else {
++ extern int fast_pptp_to_wan(struct sk_buff *skb);
++ if (FastPath_hook10(skb))
++ return 0;
++ }
++ }
++ }
++ #else
++ if (fast_pptp_fw) {
++ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L')
++ {
++ is_fast_fw=1;
++ memset(skb->cb, '\x0', 3);
++ }
++ else {
++ extern int is_pptp_device(char *ppp_device); // sync from voip customer for multiple ppp
++ extern int fast_pptp_to_wan(void *skb);
++ if (is_pptp_device(ppp->dev->name) && fast_pptp_to_wan((void*)skb)) // sync from voip customer for multiple ppp
++ return 0;
++ }
++ }
++ #endif
++ #else
++ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L')
++ is_fast_fw=1;
++ #endif
++#endif
++
++#if 0
++#ifdef FAST_L2TP
++#ifndef FAST_PPTP
++ int is_fast_fw=0;
++#endif
++
++#ifdef CONFIG_RTL_IPTABLES_FAST_PATH
++#if 0//def CONFIG_FAST_PATH_MODULE
++ if((FastPath_hook9!=NULL) &&(FastPath_hook10!=NULL))
++ {
++ if (FastPath_hook9()) {
++ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L') {
++ is_fast_fw = 1;
++ memset(skb->cb, '\x0', 3);
++ }
++ else {
++ //extern int fast_pptp_to_wan(struct sk_buff *skb);
++#ifdef CONFIG_RTL865X_HW_PPTPL2TP
++ if (!accelerate && FastPath_hook10(skb))
++ return 0;
++#else
++ if (FastPath_hook10(skb))
++ return 0;
++#endif /* CONFIG_RTL865X_HW_PPTPL2TP */
++ }
++ }
++ }
++#else
++ extern int fast_l2tp_fw;
++ if (fast_l2tp_fw) {
++ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L') {
++ is_fast_fw = 1;
++ memset(skb->cb, '\x0', 3);
++ }
++ else {
++ extern int is_l2tp_device(char *ppp_device);
++ extern int fast_l2tp_to_wan(struct sk_buff *skb);
++ if (is_l2tp_device(ppp->dev->name)&&fast_l2tp_to_wan(skb))
++ return 0;
++ }
++ }
++#endif
++#else
++ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L') {
++ is_fast_fw = 1;
++ memset(skb->cb, '\x0', 3);
++ }
++#endif
++#endif
++#endif
++
+ npi = ethertype_to_npindex(ntohs(skb->protocol));
+ if (npi < 0)
+ goto outf;
+@@ -985,9 +1384,37 @@ ppp_start_xmit(struct sk_buff *skb, stru
+ pp[0] = proto >> 8;
+ pp[1] = proto;
+
++#ifdef FAST_PPTP
++ if (is_fast_fw)
++ ppp_send_frame(ppp, skb, 1);
++ else {
++#ifdef FAST_L2TP
++ skb_pull(skb,2);
++ extern int is_l2tp_device(char *ppp_device); // sync from voip customer for multiple ppp
++ if (is_l2tp_device(ppp->dev->name) && (check_for_fast_l2tp_to_wan((void*)skb)==1) && (fast_l2tp_to_wan((void*)skb) == 1)) // sync from voip customer for multiple ppp
++ {
++ /* Note: if pkt go here, l2tp dial-on-demand will not be triggered,
++ so some risk exist here! -- 2010/04/25 zj */
++ return 0;
++ }
++ else
++ {
++ pp = skb_push(skb, 2);
++ proto = npindex_to_proto[npi];
++ pp[0] = proto >> 8;
++ pp[1] = proto;
++ }
++#endif
++ netif_stop_queue(dev);
++ skb_queue_tail(&ppp->file.xq, skb);
++ ppp_xmit_process(ppp);
++ }
++#else
+ netif_stop_queue(dev);
+ skb_queue_tail(&ppp->file.xq, skb);
+ ppp_xmit_process(ppp);
++#endif
++
+ return 0;
+
+ outf:
+@@ -1050,7 +1477,11 @@ static void ppp_setup(struct net_device
+ dev->hard_header_len = PPP_HDRLEN;
+ dev->mtu = PPP_MTU;
+ dev->addr_len = 0;
++#if defined(CONFIG_RTL_819X)
++ dev->tx_queue_len = 64;
++#else
+ dev->tx_queue_len = 3;
++#endif
+ dev->type = ARPHRD_PPP;
+ dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
+ dev->features |= NETIF_F_NETNS_LOCAL;
+@@ -1074,7 +1505,12 @@ ppp_xmit_process(struct ppp *ppp)
+ ppp_push(ppp);
+ while (!ppp->xmit_pending
+ && (skb = skb_dequeue(&ppp->file.xq)))
++#ifdef FAST_PPTP
++ ppp_send_frame(ppp, skb, 0);
++#else
+ ppp_send_frame(ppp, skb);
++#endif
++
+ /* If there's no work left to do, tell the core net
+ code that we can accept some more. */
+ if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
+@@ -1083,6 +1519,7 @@ ppp_xmit_process(struct ppp *ppp)
+ ppp_xmit_unlock(ppp);
+ }
+
++#if !defined(CONFIG_PPP_MPPE_MPPC)
+ static inline struct sk_buff *
+ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
+ {
+@@ -1132,19 +1569,81 @@ pad_compress_skb(struct ppp *ppp, struct
+ }
+ return new_skb;
+ }
++#endif
++
++/*
++ * some kinds of packets from DUT to WAN will cause ppp interface active when lan==>wan traffic is off,
++ * so we skip these packets. otherwise the ppp idletime out can't work well
++ * return value 1 means this packet won't set the ppp to active
++ */
++#if defined(CONFIG_PPP_IDLE_TIMEOUT_REFINE)
++int timeoutCheck_skipp_pkt(struct iphdr *iph)
++{
++
++ if(iph == NULL)
++ {
++ printk("the iphdr for PPP_IDLE_TIMEOUT_REFINE is NULL, is may cause some isses\n");
++ return 0;
++ }
++
++ if(iph->protocol == IPPROTO_ICMP)
++ {
++ struct icmphdr *icmph= (void *)iph + iph->ihl*4;
++ // we don't care dest unreacheable pkts(to wan) while recode last tx time
++ if(icmph->type==ICMP_DEST_UNREACH)
++ {
++ printk("it is ICMP dest unreacheable packet\n");
++ //if(net_ratelimit())printk("skip a icmp dest unreachable pkt from lan to wan\n");
++ return 1;
++ }
++ }
++ else if(iph->protocol == IPPROTO_TCP)
++ {
++ struct tcphdr *tcph;
++ tcph = (void *)iph + iph->ihl*4;
++ // we don't care tcp fin/rst pkts(to wan) while recode last tx time
++ if(tcph->fin || tcph->rst)
++ {
++ //if(net_ratelimit())printk("skip a tcp fin/rst pkt fin: %d rst :%d from lan to wan\n", tcph->fin, tcph->rst);
++ return 1;
++ }
++ }
++ else if(iph->protocol == IPPROTO_IGMP)
++ {
++ // we don't care IGMP packets
++ printk("it is ICMP packet\n");
++ return 1;
++ }
++
++ return 0;
++}
++#else //fastpath assemble code will call this function anyway.
++int timeoutCheck_skipp_pkt(struct iphdr *iph)
++{
++ return 0;
++}
++#endif
+
+ /*
+ * Compress and send a frame.
+ * The caller should have locked the xmit path,
+ * and xmit_pending should be 0.
+ */
+-static void
+-ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
++#ifdef FAST_PPTP
++static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw)
++#else
++static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
++#endif
++
+ {
+ int proto = PPP_PROTO(skb);
+ struct sk_buff *new_skb;
+ int len;
+ unsigned char *cp;
++#if defined(CONFIG_PPP_IDLE_TIMEOUT_REFINE)
++ struct iphdr *iphp;
++ iphp = (struct iphdr *)((unsigned char *)(skb->data+2));
++#endif
+
+ if (proto < 0x8000) {
+ #ifdef CONFIG_PPP_FILTER
+@@ -1168,6 +1667,9 @@ ppp_send_frame(struct ppp *ppp, struct s
+ skb_pull(skb, 2);
+ #else
+ /* for data packets, record the time */
++#if defined(CONFIG_PPP_IDLE_TIMEOUT_REFINE)
++ if(timeoutCheck_skipp_pkt(iphp)!=1)
++#endif
+ ppp->last_xmit = jiffies;
+ #endif /* CONFIG_PPP_FILTER */
+ }
+@@ -1175,6 +1677,13 @@ ppp_send_frame(struct ppp *ppp, struct s
+ ++ppp->dev->stats.tx_packets;
+ ppp->dev->stats.tx_bytes += skb->len - 2;
+
++#if defined(FAST_PPTP) && defined(NAT_SPEEDUP)
++{
++ extern void update_fast_pptp_state(void);
++ update_fast_pptp_state();
++}
++#endif
++
+ switch (proto) {
+ case PPP_IP:
+ if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0)
+@@ -1213,12 +1722,69 @@ ppp_send_frame(struct ppp *ppp, struct s
+ case PPP_CCP:
+ /* peek at outbound CCP frames */
+ ppp_ccp_peek(ppp, skb, 0);
++#if defined(CONFIG_PPP_MPPE_MPPC)
++ if (CCP_CODE(skb->data+2) == CCP_RESETACK
++ && (ppp->xcomp->compress_proto == CI_MPPE
++ || ppp->xcomp->compress_proto == CI_LZS)) {
++ --ppp->dev->stats.tx_packets;
++ ppp->dev->stats.tx_bytes -= skb->len - 2;
++ kfree_skb(skb);
++ return;
++ }
++#endif
+ break;
+ }
+
+ /* try to do packet compression */
+ if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state
+ && proto != PPP_LCP && proto != PPP_CCP) {
++#if defined(CONFIG_PPP_MPPE_MPPC)
++ int comp_ovhd = 0;
++ /*
++ * because of possible data expansion when MPPC or LZS
++ * is used, allocate compressor's buffer 12.5% bigger
++ * than MTU
++ */
++ if (ppp->xcomp->compress_proto == CI_MPPE)
++ comp_ovhd = ((ppp->dev->mtu * 9) / 8) + 1 + MPPE_OVHD;
++ else if (ppp->xcomp->compress_proto == CI_LZS)
++ comp_ovhd = ((ppp->dev->mtu * 9) / 8) + 1 + LZS_OVHD;
++ new_skb = alloc_skb(ppp->dev->mtu + ppp->dev->hard_header_len
++ + comp_ovhd, GFP_ATOMIC);
++ if (new_skb == 0) {
++ printk(KERN_ERR "PPP: no memory (comp pkt)\n");
++ goto drop;
++ }
++ if (ppp->dev->hard_header_len > PPP_HDRLEN)
++ skb_reserve(new_skb,
++ ppp->dev->hard_header_len - PPP_HDRLEN);
++
++ /* compressor still expects A/C bytes in hdr */
++ len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
++ new_skb->data, skb->len + 2,
++ ppp->dev->mtu + PPP_HDRLEN);
++ if (len > 0 && (ppp->flags & SC_CCP_UP)) {
++ kfree_skb(skb);
++ skb = new_skb;
++ skb_put(skb, len);
++ skb_pull(skb, 2); /* pull off A/C bytes */
++ } else if (len == 0) {
++ /* didn't compress, or CCP not up yet */
++ kfree_skb(new_skb);
++ } else {
++ /*
++ * (len < 0)
++ * MPPE requires that we do not send unencrypted
++ * frames. The compressor will return -1 if we
++ * should drop the frame. We cannot simply test
++ * the compress_proto because MPPE and MPPC share
++ * the same number.
++ */
++ printk(KERN_ERR "ppp: compressor dropped pkt\n");
++ kfree_skb(new_skb);
++ goto drop;
++ }
++#else
+ if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
+ if (net_ratelimit())
+ printk(KERN_ERR "ppp: compression required but down - pkt dropped.\n");
+@@ -1227,6 +1793,7 @@ ppp_send_frame(struct ppp *ppp, struct s
+ skb = pad_compress_skb(ppp, skb);
+ if (!skb)
+ goto drop;
++#endif
+ }
+
+ /*
+@@ -1242,6 +1809,9 @@ ppp_send_frame(struct ppp *ppp, struct s
+ }
+
+ ppp->xmit_pending = skb;
++#ifdef FAST_PPTP
++ if (!is_fast_fw)
++#endif
+ ppp_push(ppp);
+ return;
+
+@@ -1637,7 +2207,11 @@ ppp_receive_frame(struct ppp *ppp, struc
+ ppp_receive_mp_frame(ppp, skb, pch);
+ else
+ #endif /* CONFIG_PPP_MULTILINK */
++#ifdef FAST_PPTP
++ ppp_receive_nonmp_frame(ppp, skb, 0);
++#else
+ ppp_receive_nonmp_frame(ppp, skb);
++#endif
+ return;
+ }
+
+@@ -1657,12 +2231,38 @@ ppp_receive_error(struct ppp *ppp)
+ slhc_toss(ppp->vj);
+ }
+
+-static void
+-ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
++#ifdef FAST_PPTP
++struct sk_buff *ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw)
++#else
++static void ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
++#endif
++
+ {
+ struct sk_buff *ns;
+ int proto, len, npi;
+
++//brad add for pptp mppe rx out of order
++#ifdef FAST_PPTP
++ if(is_fast_fw){
++ ppp_mppe_state *state;
++ unsigned int curr_ccount=0;
++ if((skb->data[2] & 0x10) == 0x10){
++ state = (ppp_mppe_state *) ppp->rc_state;
++ curr_ccount = MPPE_CCOUNT(skb->data);
++ if(state->ccount < 4096 && state->ccount != 0 ){
++ if(curr_ccount < state->ccount && curr_ccount > 0){
++ kfree_skb(skb);
++ return NULL;
++ }
++ }else if(curr_ccount == 4095 && state->ccount == 0){
++ kfree_skb(skb);
++ return NULL;
++
++ }
++ }
++ }
++#endif
++
+ /*
+ * Decompress the frame, if compressed.
+ * Note that some decompressors need to see uncompressed frames
+@@ -1672,8 +2272,10 @@ ppp_receive_nonmp_frame(struct ppp *ppp,
+ && (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0)
+ skb = ppp_decompress_frame(ppp, skb);
+
++#if !defined(CONFIG_PPP_MPPE_MPPC)
+ if (ppp->flags & SC_MUST_COMP && ppp->rstate & SC_DC_FERROR)
+ goto err;
++#endif
+
+ proto = PPP_PROTO(skb);
+ switch (proto) {
+@@ -1737,6 +2339,12 @@ ppp_receive_nonmp_frame(struct ppp *ppp,
+
+ npi = proto_to_npindex(proto);
+ if (npi < 0) {
++#ifdef FAST_PPTP
++ if (is_fast_fw) {
++ kfree_skb(skb);
++ return NULL;
++ }
++#endif
+ /* control or unknown frame - pass it to pppd */
+ skb_queue_tail(&ppp->file.rq, skb);
+ /* limit queue length by dropping old frames */
+@@ -1786,14 +2394,30 @@ ppp_receive_nonmp_frame(struct ppp *ppp,
+ skb->dev = ppp->dev;
+ skb->protocol = htons(npindex_to_ethertype[npi]);
+ skb_reset_mac_header(skb);
++#ifdef FAST_PPTP
++ if (is_fast_fw)
++ return skb;
++ else
++#endif
++#if defined(CONFIG_RTL_819X)&&defined(RX_TASKLET)
++ netif_receive_skb(skb);
++#else
+ netif_rx(skb);
++#endif
+ }
+ }
++#ifdef FAST_PPTP
++ return NULL;
++#else
+ return;
++#endif
+
+ err:
+ kfree_skb(skb);
+ ppp_receive_error(ppp);
++#ifdef FAST_PPTP
++ return NULL;
++#endif
+ }
+
+ static struct sk_buff *
+@@ -1814,10 +2438,18 @@ ppp_decompress_frame(struct ppp *ppp, st
+
+ switch(ppp->rcomp->compress_proto) {
+ case CI_MPPE:
++#if defined(CONFIG_PPP_MPPE_MPPC)
++ obuff_size = ppp->mru_alloc + PPP_HDRLEN + 1;
++#else
+ obuff_size = ppp->mru + PPP_HDRLEN + 1;
++#endif
+ break;
+ default:
++#if defined(CONFIG_PPP_MPPE_MPPC)
++ obuff_size = ppp->mru_alloc + PPP_HDRLEN;
++#else
+ obuff_size = ppp->mru + PPP_HDRLEN;
++#endif
+ break;
+ }
+
+@@ -1854,7 +2486,18 @@ ppp_decompress_frame(struct ppp *ppp, st
+ return skb;
+
+ err:
++ #if defined(CONFIG_PPP_MPPE_MPPC)
++ if (ppp->rcomp->compress_proto != CI_MPPE
++ && ppp->rcomp->compress_proto != CI_LZS) {
++ /*
++ * If decompression protocol isn't MPPE/MPPC or LZS, we set
++ * SC_DC_ERROR flag and wait for CCP_RESETACK
++ */
+ ppp->rstate |= SC_DC_ERROR;
++ }
++ #else
++ ppp->rstate |= SC_DC_ERROR;
++ #endif
+ ppp_receive_error(ppp);
+ return skb;
+ }
+@@ -1943,7 +2586,11 @@ ppp_receive_mp_frame(struct ppp *ppp, st
+
+ /* Pull completed packets off the queue and receive them. */
+ while ((skb = ppp_mp_reconstruct(ppp)))
++#ifdef FAST_PPTP
++ ppp_receive_nonmp_frame(ppp, skb, 0);
++#else
+ ppp_receive_nonmp_frame(ppp, skb);
++#endif
+
+ return;
+
+@@ -2169,6 +2816,19 @@ int ppp_unit_number(struct ppp_channel *
+ return unit;
+ }
+
++#if defined (CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
++/*
++ * Mark the pppoe type for a channel
++ */
++void ppp_channel_pppoe(struct ppp_channel *chan)
++{
++ struct channel *pch = chan->ppp;
++
++ pch->pppoe = TRUE;
++}
++#endif
++
++
+ /*
+ * Disconnect a channel from the generic layer.
+ * This must be called in process context.
+@@ -2541,6 +3201,9 @@ ppp_create_interface(struct net *net, in
+ ppp = netdev_priv(dev);
+ ppp->dev = dev;
+ ppp->mru = PPP_MRU;
++#if defined(CONFIG_PPP_MPPE_MPPC)
++ ppp->mru_alloc = PPP_MRU;
++#endif
+ init_ppp_file(&ppp->file, INTERFACE);
+ ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */
+ for (i = 0; i < NUM_NP; ++i)
+@@ -2633,7 +3296,15 @@ init_ppp_file(struct ppp_file *pf, int k
+ static void ppp_shutdown_interface(struct ppp *ppp)
+ {
+ struct ppp_net *pn;
+-
++#ifdef CONFIG_RTL_PPPOE_HWACC
++ char dev_name[IFNAMSIZ];
++ memcpy(dev_name, ppp->dev->name, IFNAMSIZ);
++#endif
++
++#if defined (CONFIG_RTL_FAST_PPPOE)
++ clear_pppoe_info(ppp->dev->name, NULL, 0,
++ 0,0,NULL, NULL);
++#endif
+ pn = ppp_pernet(ppp->ppp_net);
+ mutex_lock(&pn->all_ppp_mutex);
+
+@@ -2649,6 +3320,33 @@ static void ppp_shutdown_interface(struc
+ unit_put(&pn->units_idr, ppp->file.index);
+ ppp->file.dead = 1;
+ ppp->owner = NULL;
++
++#if defined(FAST_L2TP)
++ {
++ extern int fast_l2tp_fw;
++ if(fast_l2tp_fw)
++ event_ppp_dev_down(dev_name);
++ }
++#endif
++
++#ifdef CONFIG_RTL_PPPOE_HWACC
++#ifdef CONFIG_RTL_LAYERED_DRIVER
++#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
++#if 1
++ rtl865x_detachMasterNetif(dev_name);
++#endif
++#ifdef CONFIG_RTL_LAYERED_DRIVER_L2 // sync from voip customer for multiple ppp
++ #if defined (CONFIG_RTL_HW_QOS_SUPPORT)
++ rtl865x_qosFlushMarkRuleByDev(dev_name);
++ #endif
++#endif
++ rtl865x_delPppbyIfName(dev_name);
++#endif
++#else
++ rtl865x_delPppSession(dev_name, SE_PPPOE);
++#endif
++#endif
++
+ wake_up_interruptible(&ppp->file.rwait);
+
+ mutex_unlock(&pn->all_ppp_mutex);
+@@ -2892,6 +3590,12 @@ static void *unit_find(struct idr *p, in
+ module_init(ppp_init);
+ module_exit(ppp_cleanup);
+
++#if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
++ #if defined(CONFIG_FAST_PATH_MODULE)
++ EXPORT_SYMBOL(ppp_start_xmit);
++ #endif
++#endif
++
+ EXPORT_SYMBOL(ppp_register_net_channel);
+ EXPORT_SYMBOL(ppp_register_channel);
+ EXPORT_SYMBOL(ppp_unregister_channel);
+--- linux-2.6.30.9/drivers/net/pppoe.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/net/pppoe.c 2013-05-02 01:47:53.188227102 +0300
+@@ -304,6 +304,11 @@ static void pppoe_flush_dev(struct net_d
+ for (i = 0; i < PPPOE_HASH_SIZE; i++) {
+ struct pppox_sock *po = pn->hash_table[i];
+
++ if(!((unsigned int)po & 0x80000000))
++ {
++ continue;
++ }
++
+ while (po != NULL) {
+ struct sock *sk;
+ if (po->pppoe_dev != dev) {
+@@ -699,6 +704,10 @@ static int pppoe_connect(struct socket *
+ if (error)
+ goto err_put;
+
++#if defined (CONFIG_RTL_PPPOE_HWACC) || defined(CONFIG_RTL_FAST_PPPOE)
++ ppp_channel_pppoe(&po->chan);
++#endif
++
+ sk->sk_state = PPPOX_CONNECTED;
+ }
+
+@@ -908,6 +917,9 @@ end:
+ * xmit function for internal use.
+ *
+ ***********************************************************************/
++ #if defined(CONFIG_NET_SCHED)
++ extern int gQosEnabled;
++ #endif
+ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
+ {
+ struct pppox_sock *po = pppox_sk(sk);
+@@ -943,7 +955,17 @@ static int __pppoe_xmit(struct sock *sk,
+ dev_hard_header(skb, dev, ETH_P_PPP_SES,
+ po->pppoe_pa.remote, NULL, data_len);
+
++ /*Improve pppoe wantype throughput when QoS disabled.*/
++#if defined(CONFIG_NET_SCHED)
++ if (gQosEnabled)
++ {
+ dev_queue_xmit(skb);
++ }
++ else
++#endif
++ {
++ skb->dev->netdev_ops->ndo_start_xmit(skb,skb->dev);
++ }
+
+ return 1;
+
+--- linux-2.6.30.9/drivers/net/tg3.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/net/tg3.c 2013-05-02 01:47:53.528227074 +0300
+@@ -6242,6 +6242,11 @@ static int tg3_chip_reset(struct tg3 *tp
+ PCI_EXP_DEVSTA_URD);
+ }
+
++ /* tonywu */
++ pci_write_config_word(tp->pdev, tp->pcie_cap + PCI_EXP_DEVCTL, 0);
++ pcie_set_readrq(tp->pdev, 128);
++ /* tonywu */
++
+ tg3_restore_pci_state(tp);
+
+ tp->tg3_flags &= ~TG3_FLAG_CHIP_RESETTING;
+--- linux-2.6.30.9/drivers/net/wireless/Kconfig 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/net/wireless/Kconfig 2013-05-02 01:47:53.615227067 +0300
+@@ -434,6 +434,12 @@ config RTL8187
+
+ Thanks to Realtek for their support!
+
++config RTL8192SE_mac80211
++ tristate "Realtek 8192SE wireless chip support"
++ depends on MAC80211 && WLAN_80211
++ ---help---
++ This is a driver for RTL8192SE that support mac80211
++
+ config ADM8211
+ tristate "ADMtek ADM8211 support"
+ depends on MAC80211 && PCI && WLAN_80211 && EXPERIMENTAL
+@@ -483,17 +489,9 @@ config MWL8K
+ To compile this driver as a module, choose M here: the module
+ will be called mwl8k. If unsure, say N.
+
+-source "drivers/net/wireless/p54/Kconfig"
+-source "drivers/net/wireless/ath5k/Kconfig"
+-source "drivers/net/wireless/ath9k/Kconfig"
+-source "drivers/net/wireless/ar9170/Kconfig"
+-source "drivers/net/wireless/ipw2x00/Kconfig"
+ source "drivers/net/wireless/iwlwifi/Kconfig"
+ source "drivers/net/wireless/hostap/Kconfig"
+-source "drivers/net/wireless/b43/Kconfig"
+-source "drivers/net/wireless/b43legacy/Kconfig"
+-source "drivers/net/wireless/zd1211rw/Kconfig"
+-source "drivers/net/wireless/rt2x00/Kconfig"
+-source "drivers/net/wireless/orinoco/Kconfig"
++source "drivers/net/wireless/rtl8192cd/Kconfig"
++source "drivers/net/wireless/rtl8192e/Kconfig"
+
+ endmenu
+--- linux-2.6.30.9/drivers/net/wireless/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/net/wireless/Makefile 2013-05-02 01:47:53.615227067 +0300
+@@ -2,8 +2,6 @@
+ # Makefile for the Linux Wireless network device drivers.
+ #
+
+-obj-$(CONFIG_IPW2100) += ipw2x00/
+-obj-$(CONFIG_IPW2200) += ipw2x00/
+
+ obj-$(CONFIG_STRIP) += strip.o
+ obj-$(CONFIG_ARLAN) += arlan.o
+@@ -24,16 +22,9 @@ obj-$(CONFIG_ATMEL) += atmel
+ obj-$(CONFIG_PCI_ATMEL) += atmel_pci.o
+ obj-$(CONFIG_PCMCIA_ATMEL) += atmel_cs.o
+
+-obj-$(CONFIG_AT76C50X_USB) += at76c50x-usb.o
+
+-obj-$(CONFIG_PRISM54) += prism54/
+
+ obj-$(CONFIG_HOSTAP) += hostap/
+-obj-$(CONFIG_B43) += b43/
+-obj-$(CONFIG_B43LEGACY) += b43legacy/
+-obj-$(CONFIG_ZD1211RW) += zd1211rw/
+-obj-$(CONFIG_RTL8180) += rtl818x/
+-obj-$(CONFIG_RTL8187) += rtl818x/
+
+ # 16-bit wireless PCMCIA client drivers
+ obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
+@@ -51,12 +42,8 @@ obj-$(CONFIG_ADM8211) += adm8211.o
+ obj-$(CONFIG_MWL8K) += mwl8k.o
+
+ obj-$(CONFIG_IWLWIFI) += iwlwifi/
+-obj-$(CONFIG_RT2X00) += rt2x00/
+
+-obj-$(CONFIG_P54_COMMON) += p54/
+
+-obj-$(CONFIG_ATH5K) += ath5k/
+-obj-$(CONFIG_ATH9K) += ath9k/
+-obj-$(CONFIG_AR9170_USB) += ar9170/
+
+-obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o
++obj-$(CONFIG_RTL8192CD) += rtl8192cd/
++obj-$(CONFIG_WLAN_HAL_8192EE) += rtl8192e/
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-pci.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-pci.patch
new file mode 100644
index 000000000..786ddc15a
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-pci.patch
@@ -0,0 +1,61 @@
+--- linux-2.6.30.9/drivers/pci/access.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/pci/access.c 2013-05-02 01:47:54.647226984 +0300
+@@ -38,6 +38,46 @@ int pci_bus_read_config_##size \
+ spin_unlock_irqrestore(&pci_lock, flags); \
+ return res; \
+ }
++#ifdef CONFIG_RTL8198_REVISION_B
++int pci_bus_read_config_word
++ (struct pci_bus *bus, unsigned int devfn, int pos, u16 *value)
++{
++ int res;
++ unsigned long flags;
++ u32 data = 0;
++ if (PCI_word_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;
++ spin_lock_irqsave(&pci_lock, flags);
++
++ int swap[4]={0,8,16,24}; int diff = pos&0x3;
++ res = bus->ops->read(bus, devfn, (pos&0xFFFFC), 4, &data);
++ *value =(u16)( (data>>(swap[diff]))&0xffff);
++
++
++
++
++ //*value = (type)data;
++ spin_unlock_irqrestore(&pci_lock, flags);
++ return res;
++}
++int pci_bus_read_config_byte
++ (struct pci_bus *bus, unsigned int devfn, int pos, u8 *value)
++{
++ int res;
++ unsigned long flags;
++ u32 data = 0;
++ if (PCI_word_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;
++ spin_lock_irqsave(&pci_lock, flags);
++
++ int swap[4]={0,8,16,24}; int diff = pos&0x3;
++ res = bus->ops->read(bus, devfn, (pos&0xFFFFC), 4, &data);
++ *value =(u8)( (data>>(swap[diff]))&0xff);
++ //*value = (type)data;
++ spin_unlock_irqrestore(&pci_lock, flags);
++ return res;
++}
++
++#endif
++
+
+ #define PCI_OP_WRITE(size,type,len) \
+ int pci_bus_write_config_##size \
+@@ -52,8 +92,11 @@ int pci_bus_write_config_##size \
+ return res; \
+ }
+
++#ifndef CONFIG_RTL8198_REVISION_B
+ PCI_OP_READ(byte, u8, 1)
++
+ PCI_OP_READ(word, u16, 2)
++#endif
+ PCI_OP_READ(dword, u32, 4)
+ PCI_OP_WRITE(byte, u8, 1)
+ PCI_OP_WRITE(word, u16, 2)
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-scsi.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-scsi.patch
new file mode 100644
index 000000000..deb8b120c
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-scsi.patch
@@ -0,0 +1,25 @@
+--- linux-2.6.30.9/drivers/scsi/Kconfig 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/scsi/Kconfig 2013-05-02 01:47:55.017226954 +0300
+@@ -82,6 +82,11 @@ config BLK_DEV_SD
+ In this case, do not compile the driver for your SCSI host adapter
+ (below) as a module either.
+
++config 4KB_HARDDISK_SUPPORT
++ bool "4kb sector size disk support"
++ depends on BLK_DEV_SD
++ default n
++
+ config CHR_DEV_ST
+ tristate "SCSI tape support"
+ depends on SCSI
+--- linux-2.6.30.9/drivers/scsi/scsi_lib.c 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/scsi/scsi_lib.c 2013-05-02 01:47:55.252226935 +0300
+@@ -1626,7 +1626,7 @@ u64 scsi_calculate_bounce_limit(struct S
+
+ host_dev = scsi_get_device(shost);
+ if (host_dev && host_dev->dma_mask)
+- bounce_limit = *host_dev->dma_mask;
++ bounce_limit = *(host_dev->dma_mask);
+
+ return bounce_limit;
+ }
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-nonewfiles.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-serial.patch
index abf2c625e..29a0f38c2 100644
--- a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-nonewfiles.patch
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-serial.patch
@@ -1,2859 +1,3 @@
---- linux-2.6.30.9/drivers/char/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/char/Makefile 2013-05-02 01:47:50.410227327 +0300
-@@ -8,6 +8,7 @@
- FONTMAPFILE = cp437.uni
-
- obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o tty_buffer.o tty_port.o
-+EXTRA_CFLAGS += -I.
-
- obj-$(CONFIG_LEGACY_PTYS) += pty.o
- obj-$(CONFIG_UNIX98_PTYS) += pty.o
-@@ -97,6 +98,8 @@ obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio
- obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
- obj-$(CONFIG_GPIO_TB0219) += tb0219.o
- obj-$(CONFIG_TELCLOCK) += tlclk.o
-+obj-$(CONFIG_RTL_NFBI_MDIO) += rtl_mdio/
-+obj-$(CONFIG_NFBI_HOST) += rtl_nfbi/
-
- obj-$(CONFIG_MWAVE) += mwave/
- obj-$(CONFIG_AGP) += agp/
---- linux-2.6.30.9/drivers/char/pty.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/char/pty.c 2013-05-02 01:47:50.487227320 +0300
-@@ -27,6 +27,7 @@
- #include <linux/uaccess.h>
- #include <linux/bitops.h>
- #include <linux/devpts_fs.h>
-+#include <linux/smp_lock.h>
-
- #include <asm/system.h>
-
---- linux-2.6.30.9/drivers/crypto/Kconfig 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/crypto/Kconfig 2013-05-02 01:47:50.559227314 +0300
-@@ -209,4 +209,26 @@ config CRYPTO_DEV_PPC4XX
- help
- This option allows you to have support for AMCC crypto acceleration.
-
-+config CRYPTO_DEV_REALTEK
-+ tristate "Driver Realtek Crypto Engine"
-+ select CRYPTO_HASH
-+ select CRYPTO_ALGAPI
-+ select CRYPTO_BLKCIPHER
-+ select CRYPTO_CBC
-+ select CRYPTO_CTR
-+ select CRYPTO_ECB
-+ select CRYPTO_MD5
-+ select CRYPTO_SHA1
-+ select CRYPTO_AES
-+ select CRYPTO_DES
-+ help
-+ This option allows you to have support for Realtek Crypto Engine.
-+
-+config CRYPTO_DEV_REALTEK_TEST
-+ tristate "Driver Realtek Crypto Engine Test"
-+ select CRYPTO_TEST
-+ depends on CRYPTO_DEV_REALTEK
-+ help
-+ This option for Realtek Crypto Engine Internal Test.
-+
- endif # CRYPTO_HW
---- linux-2.6.30.9/drivers/crypto/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/crypto/Makefile 2013-05-02 01:47:50.559227314 +0300
-@@ -5,3 +5,4 @@ obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hi
- obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
- obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o
- obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
-+obj-$(CONFIG_CRYPTO_DEV_REALTEK) += realtek/
---- linux-2.6.30.9/drivers/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/Makefile 2013-05-02 01:47:49.674227386 +0300
-@@ -24,7 +24,7 @@ obj-$(CONFIG_REGULATOR) += regulator/
- # char/ comes before serial/ etc so that the VT console is the boot-time
- # default.
- obj-y += char/
--
-+obj-$(CONFIG_STAGING) += staging/
- # gpu/ comes after char for AGP vs DRM startup
- obj-y += gpu/
-
-@@ -65,7 +65,7 @@ obj-$(CONFIG_USB_OTG_UTILS) += usb/otg/
- obj-$(CONFIG_USB) += usb/
- obj-$(CONFIG_USB_MUSB_HDRC) += usb/musb/
- obj-$(CONFIG_PCI) += usb/
--obj-$(CONFIG_USB_GADGET) += usb/gadget/
-+## obj-$(CONFIG_USB_GADGET) += usb/gadget/
- obj-$(CONFIG_SERIO) += input/serio/
- obj-$(CONFIG_GAMEPORT) += input/gameport/
- obj-$(CONFIG_INPUT) += input/
-@@ -105,5 +105,5 @@ obj-$(CONFIG_PPC_PS3) += ps3/
- obj-$(CONFIG_OF) += of/
- obj-$(CONFIG_SSB) += ssb/
- obj-$(CONFIG_VIRTIO) += virtio/
--obj-$(CONFIG_STAGING) += staging/
-+
- obj-y += platform/
---- linux-2.6.30.9/drivers/media/video/uvc/uvc_video.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/media/video/uvc/uvc_video.c 2013-05-02 01:47:52.326227171 +0300
-@@ -531,6 +531,14 @@ static void uvc_video_decode_isoc(struct
- if (urb->iso_frame_desc[i].status < 0) {
- uvc_trace(UVC_TRACE_FRAME, "USB isochronous frame "
- "lost (%d).\n", urb->iso_frame_desc[i].status);
-+
-+ //Start to avoid to flicking images with isochronous by jason
-+ if (buf) {
-+ buf->state = UVC_BUF_STATE_QUEUED;
-+ buf->buf.bytesused = 0;
-+ i = urb->number_of_packets;
-+ }
-+ //End to avoid to flicking images with isochronous by jason
- continue;
- }
-
---- linux-2.6.30.9/drivers/mtd/chips/cfi_cmdset_0001.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/mtd/chips/cfi_cmdset_0001.c 2013-05-02 01:47:52.621227148 +0300
-@@ -1,20 +1,10 @@
- /*
-- * Common Flash Interface support:
-- * Intel Extended Vendor Command Set (ID 0x0001)
- *
-- * (C) 2000 Red Hat. GPL'd
-+ * Copyright (c) 2011 Realtek Semiconductor Corp.
- *
-- *
-- * 10/10/2000 Nicolas Pitre <nico@cam.org>
-- * - completely revamped method functions so they are aware and
-- * independent of the flash geometry (buswidth, interleave, etc.)
-- * - scalability vs code size is completely set at compile-time
-- * (see include/linux/mtd/cfi.h for selection)
-- * - optimized write buffer method
-- * 02/05/2002 Christopher Hoover <ch@hpl.hp.com>/<ch@murgatroid.com>
-- * - reworked lock/unlock/erase support for var size flash
-- * 21/03/2007 Rodolfo Giometti <giometti@linux.it>
-- * - auto unlock sectors on resume for auto locking flash on power up
-+ * 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/module.h>
---- linux-2.6.30.9/drivers/mtd/chips/Kconfig 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/mtd/chips/Kconfig 2013-05-02 01:47:52.620227148 +0300
-@@ -240,6 +240,12 @@ config MTD_XIP
- This allows MTD support to work with flash memory which is also
- used for XIP purposes. If you're not sure what this is all about
- then say N.
-+config RTL819X_SPI_FLASH
-+ bool "RTL819x SPI flash support"
-+ depends on MTD
-+ help
-+ Support SPI flash for MX25L,SST series
-+
-
- endmenu
-
---- linux-2.6.30.9/drivers/mtd/chips/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/mtd/chips/Makefile 2013-05-02 01:47:52.620227148 +0300
-@@ -13,3 +13,4 @@ obj-$(CONFIG_MTD_JEDECPROBE) += jedec_pr
- obj-$(CONFIG_MTD_RAM) += map_ram.o
- obj-$(CONFIG_MTD_ROM) += map_rom.o
- obj-$(CONFIG_MTD_ABSENT) += map_absent.o
-+obj-$(CONFIG_RTL819X_SPI_FLASH) += rtl819x/
---- linux-2.6.30.9/drivers/mtd/devices/doc2001.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/mtd/devices/doc2001.c 2013-05-02 01:47:52.629227147 +0300
-@@ -10,8 +10,11 @@
- #include <asm/errno.h>
- #include <asm/io.h>
- #include <asm/uaccess.h>
-+#include <linux/miscdevice.h>
-+#include <linux/pci.h>
- #include <linux/delay.h>
- #include <linux/slab.h>
-+#include <linux/sched.h>
- #include <linux/init.h>
- #include <linux/types.h>
- #include <linux/bitops.h>
-@@ -20,6 +23,48 @@
- #include <linux/mtd/nand.h>
- #include <linux/mtd/doc2000.h>
-
-+#ifdef CONFIG_RTL_819X
-+/*porting for RTL865xC-RTL8190 SDK by alva_zhang@2007.11*/
-+#include <linux/config.h>
-+#include <linux/mtd/partitions.h>
-+
-+#define CALL_APP_TO_LOAD_DEFAULT // call user program to load default
-+extern int flash_hw_start;
-+#define noCONFIG_MTD_DEBUG
-+#define CONFIG_MTD_DEBUG_VERBOSE 3
-+extern int flash_hw_start, flash_hw_len, flash_ds_start, flash_ds_len, flash_write_flag;
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+#define RTL_BOOTCODE_END (0x6000)
-+static struct mtd_partition rtl8196_partitions[ ] = {
-+ {
-+ name: "boot+cfg+linux",
-+ size: (CONFIG_RTL_ROOT_IMAGE_OFFSET-0),
-+ offset: 0x00000000,
-+ },
-+ {
-+ name: "root fs",
-+ size: (CONFIG_RTL_FLASH_SIZE-CONFIG_RTL_ROOT_IMAGE_OFFSET),
-+ offset: (CONFIG_RTL_ROOT_IMAGE_OFFSET),
-+ }
-+};
-+#else
-+static struct mtd_partition rtl8196_partitions[ ] = {
-+ {
-+ name: "boot+cfg+linux",
-+ size: 0xF0000,
-+ offset: 0x00000000,
-+ },
-+ {
-+ name: "root fs",
-+ size: 0x110000,
-+ offset: 0xF0000,
-+ }
-+};
-+#endif
-+#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
-+#endif /*#ifdef CONFIG_RTL_819X */
-+
-+
- /* #define ECC_DEBUG */
-
- /* I have no idea why some DoC chips can not use memcop_form|to_io().
-@@ -32,12 +77,29 @@ static int doc_read(struct mtd_info *mtd
- size_t *retlen, u_char *buf);
- static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf);
-+
-+#ifdef CONFIG_RTL_819X
-+/* Do nothing here*/
-+#else
- static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
- struct mtd_oob_ops *ops);
- static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
- struct mtd_oob_ops *ops);
-+#endif
-+
- static int doc_erase (struct mtd_info *mtd, struct erase_info *instr);
-
-+#ifdef CONFIG_RTL_819X
-+/*porting for RTL865xC-RTL8190 SDK by alva_zhang@2007.11*/
-+static int erase_one_block(struct DiskOnChip *this, __u32 addr, __u32 len);
-+#endif
-+
-+#ifdef CONFIG_RTL_819X
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+int find_section_boundary(struct mtd_info *mtd,unsigned int start, unsigned int end, unsigned int *rstart, unsigned *rend);
-+#endif
-+#endif
-+
- static struct mtd_info *docmillist = NULL;
-
- /* Perform the required delay cycles by reading from the NOP register */
-@@ -149,6 +211,10 @@ static inline void DoC_Address(void __io
- DoC_Delay(docptr, 4);
- }
-
-+#ifdef CONFIG_RTL_819X
-+/*porting for RTL865xC-RTL8190 SDK by alva_zhang@2007.11*/
-+/* Do nothing here*/
-+#else
- /* DoC_SelectChip: Select a given flash chip within the current floor */
- static int DoC_SelectChip(void __iomem * docptr, int chip)
- {
-@@ -281,6 +347,7 @@ static void DoC_ScanChips(struct DiskOnC
- printk(KERN_INFO "%d flash chips found. Total DiskOnChip size: %ld MiB\n",
- this->numchips ,this->totlen >> 20);
- }
-+#endif /*#ifdef CONFIG_RTL_819X */
-
- static int DoCMil_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2)
- {
-@@ -318,9 +385,16 @@ static int DoCMil_is_alias(struct DiskOn
- void DoCMil_init(struct mtd_info *mtd)
- {
- struct DiskOnChip *this = mtd->priv;
-+#ifdef CONFIG_RTL_819X
-+/*do nothing here*/
-+#else
- struct DiskOnChip *old = NULL;
-+#endif
-
- /* We must avoid being called twice for the same device. */
-+#ifdef CONFIG_RTL_819X
-+/*do nothing here*/
-+#else
- if (docmillist)
- old = docmillist->priv;
-
-@@ -337,17 +411,31 @@ void DoCMil_init(struct mtd_info *mtd)
- else
- old = NULL;
- }
-+#endif /*CONFIG_RTL_819X*/
-
- mtd->name = "DiskOnChip Millennium";
-+#ifdef CONFIG_RTL_819X
-+/*do nothing here*/
-+#else
- printk(KERN_NOTICE "DiskOnChip Millennium found at address 0x%lX\n",
- this->physadr);
-+#endif
-+
-+ mtd->type = MTD_NORFLASH;
-+ mtd->flags = MTD_CAP_NORFLASH;
-+#ifdef CONFIG_RTL_819X
-+#else
-+ mtd->ecctype = MTD_ECC_RS_DiskOnChip;
-+#endif
-
-- mtd->type = MTD_NANDFLASH;
-- mtd->flags = MTD_CAP_NANDFLASH;
-+#ifdef CONFIG_RTL_819X
-+/*do nothing here*/
-+#else
- mtd->size = 0;
-
- /* FIXME: erase size is not always 8KiB */
- mtd->erasesize = 0x2000;
-+#endif
-
- mtd->writesize = 512;
- mtd->oobsize = 16;
-@@ -357,10 +445,19 @@ void DoCMil_init(struct mtd_info *mtd)
- mtd->unpoint = NULL;
- mtd->read = doc_read;
- mtd->write = doc_write;
-+
-+#ifdef CONFIG_RTL_819X
-+/*do nothing here*/
-+#else
- mtd->read_oob = doc_read_oob;
- mtd->write_oob = doc_write_oob;
-+#endif
-+
- mtd->sync = NULL;
-
-+#ifdef CONFIG_RTL_819X
-+/*do nothing here*/
-+#else
- this->totlen = 0;
- this->numchips = 0;
- this->curfloor = -1;
-@@ -368,6 +465,7 @@ void DoCMil_init(struct mtd_info *mtd)
-
- /* Ident all the chips present. */
- DoC_ScanChips(this);
-+#endif
-
- if (!this->totlen) {
- kfree(mtd);
-@@ -376,15 +474,199 @@ void DoCMil_init(struct mtd_info *mtd)
- this->nextdoc = docmillist;
- docmillist = mtd;
- mtd->size = this->totlen;
-+//#ifdef CONFIG_RTK_MTD_ROOT
-+#ifdef CONFIG_RTL_819X
-+ add_mtd_partitions(mtd, rtl8196_partitions, NB_OF(rtl8196_partitions));
-+#else
- add_mtd_device(mtd);
-+#endif
- return;
- }
- }
- EXPORT_SYMBOL_GPL(DoCMil_init);
-
-+#ifdef CONFIG_RTL_819X
-+static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
-+ size_t *retlen, const u_char *buf, u_char *eccbuf)
-+{
-+ int i,ret;
-+ struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-+ unsigned long docptr =(unsigned long) this->virtadr;
-+ unsigned int ofs;
-+ unsigned short val,val1;
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ unsigned int rstart,rend;
-+ unsigned int start,end;
-+#endif
-+// david ------------
-+unsigned long timeo, offset;
-+unsigned long flags;
-+//-------------------
-+
-+ /* Don't allow write past end of device */
-+ if (to >= this->totlen)
-+ {
-+// david
-+// printk("write to >= total len\n");
-+ printk(KERN_WARNING "write to >= total len\n");
-+ return -EINVAL;
-+ }
-+ DEBUG(MTD_DEBUG_LEVEL1,"going to write len=0x%x,to =0x%x\n", (int)len, (int)to);
-+
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ start=to;
-+ end=0xFFFFFFF;
-+ if(flash_write_flag & 1)
-+ {
-+ if(0 == start)
-+ start = CONFIG_RTL_HW_SETTING_OFFSET;
-+ else if( start > CONFIG_RTL_HW_SETTING_OFFSET )
-+ start = CONFIG_RTL_HW_SETTING_OFFSET;
-+ end=CONFIG_RTL_DEFAULT_SETTING_OFFSET;
-+ }
-+
-+ if(flash_write_flag & 2 )
-+ {
-+ if(0 == start)
-+ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
-+ else if( start > CONFIG_RTL_DEFAULT_SETTING_OFFSET )
-+ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
-+
-+ end = CONFIG_RTL_CURRENT_SETTING_OFFSET;
-+ }
-+
-+ if( flash_write_flag & 4 )
-+ {
-+ if(0 == start)
-+ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
-+ else if( start > CONFIG_RTL_CURRENT_SETTING_OFFSET )
-+ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
-+ end = CONFIG_RTL_WEB_PAGES_OFFSET;
-+ }
-+ find_section_boundary(mtd,start,end,&rstart,&rend);
-+
-+#endif
-+
-+ *retlen = len;
-+ ofs = docptr + to;
-+ for(i=0; i< len; i+=2)
-+ {
-+// david -----------------------------------------------------
-+#if 0
-+ val = *(unsigned short *)buf;
-+
-+ *(volatile unsigned short *)(0xbfc00000 + 0x555 * 2)= 0xaa;
-+ *(volatile unsigned short *)(0xbfc00000 + 0x2aa * 2)= 0x55;
-+ *(volatile unsigned short *)(0xbfc00000 + 0x555 * 2)= 0xa0;
-+ *(volatile unsigned short *)(ofs )= val;
-+
-+ j=0xfffff1;
-+ do{
-+ val1=*(volatile unsigned short *)(ofs);
-+ if( ((val1^val) & 0x80)==0 )
-+ break;
-+
-+ }while(j--!=1);
-+ if (j <= 2)
-+ printk("program fails\n");
-+#else
-+
-+// if ( ofs < (docptr+CONFIG_MTD_DOCPROBE_ADDRESS) )
-+// goto next_word;
-+
-+ offset = (to >> this->chipshift)*(1 << this->chipshift);
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ if(ofs <(docptr+rstart))
-+ goto next_word;
-+ if(ofs >= (docptr+rend))
-+ {
-+ return 0;
-+ }
-+#else
-+#if !defined(COMPACK_SETTING) && !defined(NO_CHECK_REGION)
-+ if ( flash_write_flag != 0x8000
-+//#ifdef CONFIG_RTK_MTD_ROOT
-+#ifdef CONFIG_RTL_819X
-+ || offset < (rtl8196_partitions[0].size+ rtl8196_partitions[0].offset)
-+#endif
-+ )
-+ {
-+
-+ if ( (flash_write_flag & 1) && (ofs < (docptr+flash_hw_start)) )
-+ goto next_word;
-+
-+ if ( (flash_write_flag & 2) && (ofs < (docptr+flash_ds_start)) )
-+ goto next_word;
-+
-+ if ( (flash_write_flag & 4) && (ofs < (docptr+flash_ds_start+flash_ds_len)) )
-+ goto next_word;
-+ }
-+#endif // COMPACK_SETTING && NO_CHECK_REGION
-+#endif //CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ val = *(unsigned short *)buf;
-+
-+ mtd_save_flags(flags);mtd_cli(); // david
-+
-+ *(volatile unsigned short *)(0xbfc00000 + offset + 0x555 * 2)= 0xaa;
-+ *(volatile unsigned short *)(0xbfc00000 + offset + 0x2aa * 2)= 0x55;
-+ *(volatile unsigned short *)(0xbfc00000 + offset + 0x555 * 2)= 0xa0;
-+ *(volatile unsigned short *)(ofs )= val;
-+
-+ mtd_restore_flags(flags); // david
-+
-+ timeo = jiffies + (HZ * 50);
-+ do{
-+#if 0
-+ val1=*(volatile unsigned short *)(ofs);
-+ if ( val1 == val )
-+ break;
-+#endif
-+ unsigned short val2;
-+
-+ val2=*(volatile unsigned short *)(ofs);
-+ val1=*(volatile unsigned short *)(ofs);
-+
-+ if (((val1^val2) & 0x40) != 0)
-+ continue;
-+ if (((val1^val) & 0x80) != 0)
-+ continue;
-+ if ( val1 == val )
-+ break;
-+//--------------
-+ } while ( !time_after(jiffies, timeo) );
-+
-+ if ( time_after(jiffies, timeo)) {
-+ printk(KERN_WARNING "program timeout!");
-+ printk(KERN_WARNING " write: %x, read:%x, addr: %x\n", val, val1, ofs);
-+ return -1;
-+ }
-+
-+#ifndef COMPACK_SETTING
-+next_word:
-+#endif
-+
-+#endif
-+//---------------------------------------------------------
-+ ofs += 2;
-+ buf += 2;
-+
-+ }
-+
-+ ret = 0 ;
-+// printk("in doc_write_ecc ret=%08x\n", ret);
-+ return ret;
-+}
-+#endif /* #ifdef CONFIG_RTL_819X */
-+
- static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf)
- {
-+#ifdef CONFIG_RTL_819X
-+static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-+ size_t *retlen, u_char *buf, u_char *eccbuf);
-+/* Just a special case of doc_read_ecc */
-+ return doc_read_ecc(mtd, from, len, retlen, buf, NULL);
-+#else
- int i, ret;
- volatile char dummy;
- unsigned char syndrome[6], eccbuf[6];
-@@ -491,11 +773,49 @@ static int doc_read (struct mtd_info *mt
- WriteDOC(DOC_ECC_DIS, docptr , ECCConf);
-
- return ret;
-+
-+#endif /* #ifdef CONFIG_RTL_819X */
-+}
-+
-+#ifdef CONFIG_RTL_819X
-+static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
-+ size_t *retlen, u_char *buf, u_char *eccbuf)
-+{
-+ int i;
-+ unsigned short tmp;
-+ struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-+ unsigned long docptr = this->virtadr+from;
-+
-+ /* Don't allow read past end of device */
-+ if (from >= this->totlen)
-+ return -EINVAL;
-+ for(i=0; i< len; i+=2)
-+ {
-+ tmp = *(volatile unsigned short *)(docptr);
-+ *(unsigned short *)buf = tmp;
-+ buf += 2;
-+ docptr +=2;
-+ }
-+ if (len & 0x01)
-+ {
-+ tmp = *(volatile unsigned long *)(docptr);
-+ *(unsigned char *)buf = (tmp >> 8) & 0xff;
-+ }
-+
-+ /* Let the caller know we completed it */
-+ *retlen = len;
-+
-+ return 0;
- }
-+#endif /*#ifdef CONFIG_RTL_819X */
-
- static int doc_write (struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf)
- {
-+#ifdef CONFIG_RTL_819X
-+ char eccbuf[6];
-+ return doc_write_ecc(mtd, to, len, retlen, buf, eccbuf);
-+#else
- int i,ret = 0;
- char eccbuf[6];
- volatile char dummy;
-@@ -617,8 +937,12 @@ static int doc_write (struct mtd_info *m
- *retlen = len;
-
- return ret;
-+#endif /*#ifdef CONFIG_RTL_819X */
- }
-
-+#ifdef CONFIG_RTL_819X
-+/*do nothing here*/
-+#else
- static int doc_read_oob(struct mtd_info *mtd, loff_t ofs,
- struct mtd_oob_ops *ops)
- {
-@@ -753,9 +1077,229 @@ static int doc_write_oob(struct mtd_info
-
- return ret;
- }
-+#endif /*#ifdef CONFIG_RTL_819X */
-+
-+#ifdef CONFIG_RTL_819X
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+int find_section_boundary(struct mtd_info *mtd,unsigned int start, unsigned int end, unsigned int *rstart, unsigned *rend)
-+{
-+ int i = 0;
-+ int j = 0;
-+ struct mtd_erase_region_info *regions = mtd->eraseregions;
-+ while ((i < mtd->numeraseregions) &&
-+ (start >= regions[i].offset)) {
-+ i++;
-+ }
-+ i--;
-+
-+ j = 1;
-+ while((j <= regions[i].numblocks) &&
-+ (start >= (regions[i].offset+regions[i].erasesize*j))) {
-+ j++;
-+ }
-+ *rstart=(regions[i].offset+regions[i].erasesize*(j-1));
-+
-+ i=0;
-+ while ((i < mtd->numeraseregions) &&
-+ (end >= regions[i].offset)) {
-+ i++;
-+ }
-+ i--;
-+
-+ j = 1;
-+ while((j <= regions[i].numblocks) &&
-+ (end >= (regions[i].offset+regions[i].erasesize*j))) {
-+ j++;
-+ }
-+ *rend=(regions[i].offset+regions[i].erasesize*j);
-+
-+}
-+#endif
-+#endif
-
- int doc_erase (struct mtd_info *mtd, struct erase_info *instr)
- {
-+#ifdef CONFIG_RTL_819X
-+
-+struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-+ unsigned long adr, len;
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ unsigned int rstart,rend;
-+ unsigned int start,end;
-+#endif
-+ int i;
-+ int first;
-+ struct mtd_erase_region_info *regions = mtd->eraseregions;
-+
-+ DEBUG(MTD_DEBUG_LEVEL1, "going to erase sector addr=%08x,len=%08x\n",
-+ instr->addr, instr->len);
-+
-+ if (instr->addr > mtd->size) {
-+ printk(KERN_WARNING "Erase addr greater than max size (0x%x > 0x%x)\n",
-+ instr->addr, mtd->size );
-+ return -EINVAL;
-+ }
-+
-+ if ((instr->len + instr->addr) > mtd->size) {
-+ printk(KERN_WARNING "Erase size greater than max size (0x%x + 0x%x > 0x%x)\n",
-+ instr->addr, instr->len, mtd->size );
-+ return -EINVAL;
-+ }
-+
-+ /* Check that both start and end of the requested erase are
-+ * aligned with the erasesize at the appropriate addresses.
-+ */
-+
-+ i = 0;
-+
-+ /* Skip all erase regions which are ended before the start of
-+ the requested erase. Actually, to save on the calculations,
-+ we skip to the first erase region which starts after the
-+ start of the requested erase, and then go back one.
-+ */
-+
-+ while ((i < mtd->numeraseregions) &&
-+ (instr->addr >= regions[i].offset)) {
-+ i++;
-+ }
-+ i--;
-+
-+ /* OK, now i is pointing at the erase region in which this
-+ * erase request starts. Check the start of the requested
-+ * erase range is aligned with the erase size which is in
-+ * effect here.
-+ */
-+
-+ if (instr->addr & (regions[i].erasesize-1)) {
-+ return -EINVAL;
-+ }
-+
-+ /* Remember the erase region we start on. */
-+
-+ first = i;
-+
-+ /* Next, check that the end of the requested erase is aligned
-+ * with the erase region at that address.
-+ */
-+
-+ while ((i < mtd->numeraseregions) &&
-+ ((instr->addr + instr->len) >= regions[i].offset)) {
-+ i++;
-+ }
-+
-+ /* As before, drop back one to point at the region in which
-+ * the address actually falls.
-+ */
-+
-+ i--;
-+
-+ if ((instr->addr + instr->len) & (regions[i].erasesize-1)) {
-+ return -EINVAL;
-+ }
-+
-+
-+ adr = instr->addr;
-+ len = instr->len;
-+
-+ i = first;
-+ instr->state = MTD_ERASING;
-+
-+
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ start=adr;
-+ end=0xFFFFFFF;
-+ if(flash_write_flag & 1)
-+ {
-+ if(0 == start)
-+ start = CONFIG_RTL_HW_SETTING_OFFSET;
-+ else if( start > CONFIG_RTL_HW_SETTING_OFFSET )
-+ start = CONFIG_RTL_HW_SETTING_OFFSET;
-+ end = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
-+ }
-+
-+ if(flash_write_flag & 2 )
-+ {
-+ if(0 == start)
-+ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
-+ else if( start > CONFIG_RTL_DEFAULT_SETTING_OFFSET )
-+ start = CONFIG_RTL_DEFAULT_SETTING_OFFSET;
-+ end = CONFIG_RTL_CURRENT_SETTING_OFFSET;
-+ }
-+
-+ if(flash_write_flag & 4 )
-+ {
-+ if(0 == start)
-+ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
-+ else if( start > CONFIG_RTL_CURRENT_SETTING_OFFSET )
-+ start = CONFIG_RTL_CURRENT_SETTING_OFFSET;
-+
-+ end = CONFIG_RTL_WEB_PAGES_OFFSET;
-+ }
-+
-+ find_section_boundary(mtd,start,end,&rstart,&rend);
-+
-+ //printk("line[%d] rstart 0x%x rend 0x%x\n",__LINE__,rstart,rend);
-+
-+ /*don't erase bootcode*/
-+ if(rstart < RTL_BOOTCODE_END)
-+ rstart = RTL_BOOTCODE_END;
-+
-+ //printk("line[%d] rstart 0x%x rend 0x%x\n",__LINE__,rstart,rend);
-+#endif
-+
-+ while (len) {
-+// if (adr >= CONFIG_MTD_DOCPROBE_ADDRESS) {
-+
-+#if defined(COMPACK_SETTING) || defined(NO_CHECK_REGION)
-+ if ( erase_one_block(this, adr, regions[i].erasesize) )
-+ return -1;
-+
-+#else
-+
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ if(adr >= rstart)
-+#else
-+ if ( ((flash_write_flag & 1) && (adr == flash_hw_start)) ||
-+ ((flash_write_flag & 2) &&(adr >= flash_ds_start && adr < (flash_ds_start+flash_ds_len)))
-+ || ((flash_write_flag & 4) && (adr >= (flash_ds_start+flash_ds_len)))
-+//#ifdef CONFIG_RTK_MTD_ROOT
-+#ifdef CONFIG_RTL_819X
-+ || (adr >= (rtl8196_partitions[0].size+ rtl8196_partitions[0].offset))
-+#endif
-+ || (flash_write_flag == 0x8000)
-+ )
-+#endif
-+ {
-+ if ( erase_one_block(this, adr, regions[i].erasesize) )
-+ return -1;
-+ }
-+
-+#endif // COMPACK_SETTING || NO_CHECK_REGION
-+
-+ adr += regions[i].erasesize;
-+ if (len < regions[i].erasesize)
-+ len = 0;
-+ else
-+ len -= regions[i].erasesize;
-+
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ if(rend <= adr)
-+ {
-+ /*no need to erase other block*/
-+ len=0;
-+ }
-+#endif
-+ if ( adr >= (regions[i].offset + regions[i].erasesize*regions[i].numblocks))
-+ i++;
-+ }
-+
-+ instr->state = MTD_ERASE_DONE;
-+ if (instr->callback) {
-+ instr->callback(instr);
-+ }
-+
-+ return 0;
-+#else
- volatile char dummy;
- struct DiskOnChip *this = mtd->priv;
- __u32 ofs = instr->addr;
-@@ -809,7 +1353,52 @@ int doc_erase (struct mtd_info *mtd, str
- mtd_erase_callback(instr);
-
- return 0;
-+
-+#endif /*#ifdef CONFIG_RTL_819X */
-+}
-+
-+#ifdef CONFIG_RTL_819X
-+static int erase_one_block(struct DiskOnChip *this, __u32 addr, __u32 len)
-+{
-+ unsigned long timeo;
-+ unsigned long docptr = this->virtadr;
-+ __u32 ofs, offset;
-+ unsigned long flags; // david
-+
-+
-+ DEBUG(MTD_DEBUG_LEVEL1, "Erase sector, addr=0x%x, docptr=0x%x, len=0x%x\n",
-+ (int)addr, (int)docptr, (int)len);
-+
-+ // issue erase command!
-+ ofs = docptr + addr;
-+
-+ offset = (addr >> this->chipshift)*(1 << this->chipshift);
-+
-+ mtd_save_flags(flags);mtd_cli(); // david
-+ *(volatile unsigned short *)(docptr + offset + 0x555 * 2) = 0xaa;
-+ *(volatile unsigned short *)(docptr + offset + 0x2aa * 2) = 0x55;
-+ *(volatile unsigned short *)(docptr + offset + 0x555 * 2) = 0x80;
-+ *(volatile unsigned short *)(docptr + offset + 0x555 * 2) = 0xaa;
-+ *(volatile unsigned short *)(docptr + offset + 0x2aa * 2) = 0x55;
-+ *(volatile unsigned short *)(ofs ) = 0x30;
-+ mtd_restore_flags(flags); // david
-+
-+ timeo = jiffies + (HZ * 40);
-+
-+ while (1) {
-+ if ((*(volatile unsigned short *)(ofs))==0xffff) {
-+ DEBUG(MTD_DEBUG_LEVEL1, "Erase success!\n");
-+ break;
-+ }
-+ if (time_after(jiffies, timeo)) {
-+ printk(KERN_WARNING "Erase timeout!\n");
-+ return -1;
-+ }
-+ udelay(1);
-+ }
-+ return 0;
- }
-+#endif /*#ifdef CONFIG_RTL_819X */
-
- /****************************************************************************
- *
---- linux-2.6.30.9/drivers/mtd/devices/docprobe.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/mtd/devices/docprobe.c 2013-05-02 01:47:52.630227147 +0300
-@@ -36,7 +36,7 @@
- <linux-mtd@lists.infradead.org>.
- */
- #define DOC_SINGLE_DRIVER
--
-+#include <linux/config.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <asm/errno.h>
-@@ -56,10 +56,68 @@
- #define CONFIG_MTD_DOCPROBE_ADDRESS 0
- #endif
-
-+#ifdef CONFIG_RTL_819X
-+// david ----------------------
-+/* MXIC */
-+#define MANUFACTURER_MXIC 0x00C2
-+#define MX29LV800B 0x225B
-+#define MX29LV160AB 0x2249
-+#define MX29LV320AB 0x22A8
-+#define MX29LV640AB 0x22CB
-+
-+/*AMD*/
-+#define MANUFACTURER_AMD 0x0001
-+#define AM29LV800BB 0x225B
-+#define AM29LV160DB 0x2249
-+#define AM29LV320DB 0x22F9
-+
-+/*ST*/
-+#define MANUFACTURER_ST 0x0020
-+#define M29W160DB 0X2249
-+
-+/* ESMT */
-+#define MANUFACTURER_ESMT 0x008C
-+#define F49L160BA 0x2249
-+
-+/* SAMSUNG */
-+#define MANUFACTURER_SAMSUNG 0x00EC
-+#define K8D1716UBC 0x2277
-+
-+/* ESI */
-+#define MANUFACTURER_ESI 0x004A
-+#define ES29LV320D 0x22F9
-+
-+/* EON */
-+#define MANUFACTURER_EON 0x007F
-+#define EN29LV160A 0x2249
-+
-+#ifdef CONFIG_RTL8196B
-+#define FLASH_BASE 0xbd000000
-+#else
-+#define FLASH_BASE 0xbe000000
-+#endif
-+
-+struct flash_info {
-+ const __u16 mfr_id;
-+ const __u16 dev_id;
-+ const char *name;
-+ const u_long size;
-+ const int shift; // shift number of chip size
-+ const int numeraseregions;
-+ const struct mtd_erase_region_info regions[4];
-+};
-+
-+static int probeChip(struct DiskOnChip *doc, struct mtd_info *mtd);
-+//-----------------------------
-+#endif /*#ifdef CONFIG_RTL_819X*/
-+
-+//static unsigned long doc_config_location = CONFIG_MTD_DOCPROBE_ADDRESS;
-+//module_param(doc_config_location, ulong, 0);
-+//MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
-
--static unsigned long doc_config_location = CONFIG_MTD_DOCPROBE_ADDRESS;
--module_param(doc_config_location, ulong, 0);
--MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
-+#ifdef CONFIG_RTL_819X
-+ /* Do nothing here*/
-+#else
-
- static unsigned long __initdata doc_locations[] = {
- #if defined (__alpha__) || defined(__i386__) || defined(__x86_64__)
-@@ -76,6 +134,13 @@ static unsigned long __initdata doc_loca
- 0xe0000, 0xe2000, 0xe4000, 0xe6000,
- 0xe8000, 0xea000, 0xec000, 0xee000,
- #endif /* CONFIG_MTD_DOCPROBE_HIGH */
-+#elif defined(__PPC__)
-+ 0xe4000000,
-+#elif defined(CONFIG_MOMENCO_OCELOT)
-+ 0x2f000000,
-+ 0xff000000,
-+#elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C)
-+ 0xff000000,
- #else
- #warning Unknown architecture for DiskOnChip. No default probe locations defined
- #endif
-@@ -217,8 +282,9 @@ static inline int __init doccheck(void _
- #endif
- return 0;
- }
-+#endif /*#ifdef CONFIG_RTL_819X*/
-
--static int docfound;
-+//static int docfound;
-
- extern void DoC2k_init(struct mtd_info *);
- extern void DoCMil_init(struct mtd_info *);
-@@ -229,11 +295,18 @@ static void __init DoC_Probe(unsigned lo
- void __iomem *docptr;
- struct DiskOnChip *this;
- struct mtd_info *mtd;
-- int ChipID;
-+ //int ChipID;
- char namebuf[15];
- char *name = namebuf;
-+
-+
-+ char *im_funcname = NULL;
-+ char *im_modname = NULL;
-+
-+
- void (*initroutine)(struct mtd_info *) = NULL;
-
-+#ifndef CONFIG_RTL_819X
- docptr = ioremap(physadr, DOC_IOREMAP_LEN);
-
- if (!docptr)
-@@ -302,8 +375,286 @@ static void __init DoC_Probe(unsigned lo
- kfree(mtd);
- }
- iounmap(docptr);
-+#else
-+ docptr = FLASH_BASE;
-+ //-----------------------------
-+
-+
-+ mtd = kmalloc(sizeof(struct DiskOnChip) + sizeof(struct mtd_info), GFP_KERNEL);
-+
-+ if (!mtd) {
-+ printk(KERN_WARNING "Cannot allocate memory for data structures. Dropping.\n");
-+ iounmap((void *)docptr);
-+ return;
- }
-
-+ this = (struct DiskOnChip *)(&mtd[1]);
-+
-+ memset((char *)mtd,0, sizeof(struct mtd_info));
-+ memset((char *)this, 0, sizeof(struct DiskOnChip));
-+
-+ mtd->priv = this;
-+ this->virtadr = docptr;
-+ this->physadr = physadr;
-+ this->ChipID = DOC_ChipID_DocMil;
-+
-+ name="Millennium";
-+ im_funcname = "DoCMil_init";
-+ im_modname = "doc2001";
-+
-+ if ( probeChip(this, mtd) == 0) // david added,
-+ initroutine = &DoCMil_init;
-+
-+ if (initroutine) {
-+ (*initroutine)(mtd);
-+ return;
-+ }
-+ printk(KERN_NOTICE "Cannot find driver for DiskOnChip %s at 0x%lX\n", name, physadr);
-+ iounmap((void *)docptr);
-+
-+#endif /*#ifdef CONFIG_RTL_819X*/
-+}
-+
-+#ifdef CONFIG_RTL_819X
-+// david -------------------------------------------------------------------
-+static int probeChip(struct DiskOnChip *doc, struct mtd_info *mtd)
-+{
-+ /* Keep this table on the stack so that it gets deallocated after the
-+ * probe is done.
-+ */
-+ const struct flash_info table[] = {
-+ {
-+ mfr_id: MANUFACTURER_MXIC,
-+ dev_id: MX29LV800B,
-+ name: "MXIC MX29LV800B",
-+ size: 0x00100000,
-+ shift: 20,
-+ numeraseregions: 4,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
-+ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
-+ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 15 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_MXIC,
-+ dev_id: MX29LV160AB,
-+ name: "MXIC MX29LV160AB",
-+ size: 0x00200000,
-+ shift: 21,
-+ numeraseregions: 4,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
-+ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
-+ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_MXIC,
-+ dev_id: MX29LV320AB,
-+ name: "MXIC MX29LV320AB",
-+ size: 0x00400000,
-+ shift: 22,
-+ numeraseregions: 2,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 63 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_AMD,
-+ dev_id: AM29LV800BB,
-+ name: "AMD AM29LV800BB",
-+ size: 0x00100000,
-+ shift: 20,
-+ numeraseregions: 4,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
-+ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
-+ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 15 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_AMD,
-+ dev_id: AM29LV160DB,
-+ name: "AMD AM29LV160DB",
-+ size: 0x00200000,
-+ shift: 21,
-+ numeraseregions: 4,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
-+ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
-+ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_AMD,
-+ dev_id: AM29LV320DB,
-+ name: "AMD AM29LV320DB",
-+ size: 0x00400000,
-+ shift: 22,
-+ numeraseregions: 2,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 63 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_ST,
-+ dev_id: M29W160DB,
-+ name: "ST M29W160DB",
-+ size: 0x00200000,
-+ shift: 21,/*21 bit=> that is 2 MByte size*/
-+ numeraseregions: 4,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
-+ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
-+ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_MXIC,
-+ dev_id: MX29LV640AB,
-+ name: "MXIC MX29LV640AB",
-+ size: 0x00800000,
-+ shift: 23,/*22 bit=> that is 8 MByte size*/
-+ numeraseregions: 2,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 127 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_SAMSUNG,
-+ dev_id: K8D1716UBC,
-+ name: "SAMSUNG K8D1716UBC",
-+ size: 0x00200000,
-+ shift: 21,/*21 bit=> that is 2 MByte size*/
-+ numeraseregions: 2,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_ESMT,
-+ dev_id: F49L160BA,
-+ name: "ESMT F49L160BA",
-+ size: 0x00200000,
-+ shift: 21,/*21 bit=> that is 2 MByte size*/
-+ numeraseregions: 4,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
-+ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
-+ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_ESI,
-+ dev_id: ES29LV320D,
-+ name: "ESI ES29LV320D",
-+ size: 0x00400000,
-+ shift: 22,/*22 bit=> that is 4 MByte size*/
-+ numeraseregions: 2,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x02000, numblocks: 8 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 63 }
-+ }
-+ },
-+ {
-+ mfr_id: MANUFACTURER_EON,
-+ dev_id: EN29LV160A,
-+ name: "EON EN29LV160A",
-+ size: 0x00200000,
-+ shift: 21,
-+ numeraseregions: 4,
-+ regions: {
-+ { offset: 0x000000, erasesize: 0x04000, numblocks: 1 },
-+ { offset: 0x004000, erasesize: 0x02000, numblocks: 2 },
-+ { offset: 0x008000, erasesize: 0x08000, numblocks: 1 },
-+ { offset: 0x010000, erasesize: 0x10000, numblocks: 31 }
-+ }
-+ }
-+ };
-+
-+ struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
-+ unsigned long docptr = this->virtadr;
-+ __u16 mfid, devid;
-+ int i, j, k, interleave=1, chipsize;
-+
-+ // issue reset and auto-selection command
-+ *(volatile unsigned short *)(FLASH_BASE) = 0xf0;
-+
-+ *(volatile unsigned short *)(FLASH_BASE + 0x555 * 2) = 0xaa;
-+ *(volatile unsigned short *)(FLASH_BASE + 0x2aa * 2) = 0x55;
-+ *(volatile unsigned short *)(FLASH_BASE + 0x555 * 2) = 0x90;
-+
-+ mfid = *((volatile unsigned short *)docptr);
-+ devid = *((volatile unsigned short *)(docptr + 1*2));
-+
-+ *(volatile unsigned short *)(FLASH_BASE) = 0xf0;
-+
-+ for (i=0; i< sizeof(table)/sizeof(table[0]); i++) {
-+ if ( mfid==table[i].mfr_id && devid==table[i].dev_id)
-+ break;
-+ }
-+ if ( i == sizeof(table)/sizeof(table[0]) )
-+ return -1;
-+
-+ // Look for 2nd flash
-+ *(volatile unsigned short *)(FLASH_BASE + table[i].size) = 0xf0;
-+ *(volatile unsigned short *)(FLASH_BASE + table[i].size + 0x555 * 2) = 0xaa;
-+ *(volatile unsigned short *)(FLASH_BASE + table[i].size + 0x2aa * 2) = 0x55;
-+ *(volatile unsigned short *)(FLASH_BASE + table[i].size + 0x555 * 2) = 0x90;
-+
-+ mfid = *((volatile unsigned short *)(docptr + table[i].size));
-+ devid = *((volatile unsigned short *)(docptr + table[i].size + 1*2));
-+
-+ *(volatile unsigned short *)(FLASH_BASE+table[i].size) = 0xf0;
-+ if ( mfid==table[i].mfr_id && devid==table[i].dev_id) {
-+ interleave++;
-+ }
-+
-+ printk(KERN_NOTICE "Found %d x %ldM Byte %s at 0x%lx\n",
-+ interleave, (table[i].size)/(1024*1024), table[i].name, docptr);
-+
-+ mtd->size = table[i].size*interleave;
-+ mtd->numeraseregions = table[i].numeraseregions*interleave;
-+
-+ mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) *
-+ mtd->numeraseregions*interleave, GFP_KERNEL);
-+ if (!mtd->eraseregions) {
-+ printk(KERN_WARNING "Failed to allocate "
-+ "memory for MTD erase region info\n");
-+ kfree(mtd);
-+ return -1;
-+ }
-+
-+ for (k=0, chipsize=0; interleave>0; interleave--, chipsize+=table[i].size) {
-+ for (j=0; j<table[i].numeraseregions; j++, k++) {
-+ mtd->eraseregions[k].offset = table[i].regions[j].offset+chipsize;
-+ mtd->eraseregions[k].erasesize = table[i].regions[j].erasesize;
-+ mtd->eraseregions[k].numblocks = table[i].regions[j].numblocks;
-+ if (mtd->erasesize < mtd->eraseregions[k].erasesize)
-+ mtd->erasesize = mtd->eraseregions[k].erasesize;
-+ }
-+ }
-+
-+ this->totlen = mtd->size;
-+ this->numchips = interleave;
-+ this->chipshift = table[i].shift;
-+
-+ return 0;
-+}
-+//---------------------------------------------------------------------------
-+#endif /*#ifdef CONFIG_RTL_819X */
-+
-
- /****************************************************************************
- *
-@@ -313,6 +664,14 @@ static void __init DoC_Probe(unsigned lo
-
- static int __init init_doc(void)
- {
-+#ifdef CONFIG_RTL_819X
-+ printk(KERN_NOTICE "RealTek E-Flash System Driver. (C) 2002 RealTek Corp.\n");
-+ DoC_Probe(CONFIG_MTD_DOCPROBE_ADDRESS);
-+ /* So it looks like we've been used and we get unloaded */
-+// MOD_INC_USE_COUNT;
-+// MOD_DEC_USE_COUNT;
-+ return 0;
-+#else
- int i;
-
- if (doc_config_location) {
-@@ -328,6 +687,7 @@ static int __init init_doc(void)
- if (!docfound)
- printk(KERN_INFO "No recognised DiskOnChip devices found\n");
- return -EAGAIN;
-+#endif
- }
-
- module_init(init_doc);
---- linux-2.6.30.9/drivers/mtd/maps/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/mtd/maps/Makefile 2013-05-02 01:47:52.636227146 +0300
-@@ -62,3 +62,4 @@ obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_
- obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o
- obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o
- obj-$(CONFIG_MTD_VMU) += vmu-flash.o
-+obj-$(CONFIG_RTL819X_SPI_FLASH) += rtl819x_flash.o
---- linux-2.6.30.9/drivers/mtd/mtdblock.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/mtd/mtdblock.c 2013-05-02 01:47:52.649227145 +0300
-@@ -18,6 +18,26 @@
- #include <linux/mtd/blktrans.h>
- #include <linux/mutex.h>
-
-+#include <linux/config.h>
-+
-+#ifdef CONFIG_RTL_819X
-+// david ---------------
-+//#define CONFIG_MTD_DEBUG
-+#define CONFIG_MTD_DEBUG_VERBOSE 3
-+
-+
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+int flash_write_flag=0; // 1: hw setting 2: default setting, 4: current setting, 8: system image
-+#else
-+int flash_hw_start=0x6000; // hw setting start address
-+int flash_hw_len=0x2000; // hw setting length
-+int flash_ds_start=0x8000; // default & current setting start address
-+int flash_ds_len=0x8000; // default & current setting length
-+
-+int flash_write_flag=0; // 1: hw setting 2: default setting, 4: current setting, 8: system image
-+#endif
-+#endif /*#ifdef CONFIG_RTL_819X */
-+
-
- static struct mtdblk_dev {
- struct mtd_info *mtd;
-@@ -134,6 +154,58 @@ static int do_cached_write (struct mtdbl
- DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: write on \"%s\" at 0x%lx, size 0x%x\n",
- mtd->name, pos, len);
-
-+
-+#ifdef CONFIG_RTL_819X
-+#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
-+ /*since len is normal 0x200 less than every section*/
-+ if(flash_write_flag != 0x8000)
-+ {
-+ flash_write_flag = 0;
-+ if ( pos >= CONFIG_RTL_HW_SETTING_OFFSET && pos < CONFIG_RTL_DEFAULT_SETTING_OFFSET ) {
-+ flash_write_flag |= 1;
-+ if ((pos+len) > CONFIG_RTL_DEFAULT_SETTING_OFFSET ) {
-+ flash_write_flag |= 2;
-+ if ((pos+len) > CONFIG_RTL_CURRENT_SETTING_OFFSET )
-+ flash_write_flag |= 4;
-+ }
-+ }
-+ if ( pos >= CONFIG_RTL_DEFAULT_SETTING_OFFSET && pos < CONFIG_RTL_CURRENT_SETTING_OFFSET ) {
-+ flash_write_flag |= 2;
-+ if ((pos+len) > CONFIG_RTL_CURRENT_SETTING_OFFSET ) {
-+ flash_write_flag |= 4;
-+ }
-+ }
-+ else if ( pos >= CONFIG_RTL_CURRENT_SETTING_OFFSET && pos < CONFIG_RTL_WEB_PAGES_OFFSET ){
-+ flash_write_flag |= 4;
-+ }
-+ }
-+#else
-+// david --------------
-+ if ( flash_write_flag != 0x8000)
-+ {
-+ flash_write_flag = 0;
-+ if (pos >= flash_hw_start && pos < (flash_hw_start+flash_hw_len) ) {
-+ flash_write_flag |= 1;
-+ if ((len - flash_hw_len) > 0) {
-+ flash_write_flag |= 2;
-+ if ((len - flash_ds_len -flash_hw_len) > 0)
-+ flash_write_flag |= 4;
-+ }
-+ }
-+ if (pos >= flash_ds_start && pos < (flash_ds_start+flash_ds_len) ) {
-+ flash_write_flag |= 2;
-+ if ((len - flash_ds_len) > 0) {
-+ flash_write_flag |= 4;
-+ }
-+ }
-+ else if ( pos >= (flash_ds_start+flash_ds_len) ){
-+ flash_write_flag |= 4;
-+ }
-+ }
-+//---------------------
-+#endif //CONFIG_RTL_FLASH_MAPPING_ENABLE
-+#endif
-+
- if (!sect_size)
- return mtd->write(mtd, pos, len, &retlen, buf);
-
---- linux-2.6.30.9/drivers/net/Kconfig 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/net/Kconfig 2013-05-02 01:47:52.704227141 +0300
-@@ -27,7 +27,7 @@ menuconfig NETDEVICES
- if NETDEVICES
-
- config COMPAT_NET_DEV_OPS
-- default y
-+ default n
- bool "Enable older network device API compatibility"
- ---help---
- This option enables kernel compatibility with older network devices
-@@ -2146,6 +2146,22 @@ config R8169_VLAN
-
- If in doubt, say Y.
-
-+config R8168
-+ tristate "Realtek 8168 gigabit ethernet support"
-+ depends on PCI
-+ select CRC32
-+ default y
-+ ---help---
-+ Say Y here if you have a Realtek 8168 PCI Gigabit Ethernet adapter.
-+
-+ To compile this driver as a module, choose M here: the module
-+ will be called r8168. This is recommended.
-+
-+config R8168_NAPI
-+ bool "NAPI support"
-+ depends on R8168
-+ default y
-+
- config SB1250_MAC
- tristate "SB1250 Gigabit Ethernet support"
- depends on SIBYTE_SB1xxx_SOC
-@@ -2987,19 +3003,39 @@ config PPP_BSDCOMP
- module; it is called bsd_comp and will show up in the directory
- modules once you have said "make modules". If unsure, say N.
-
--config PPP_MPPE
-- tristate "PPP MPPE compression (encryption) (EXPERIMENTAL)"
-- depends on PPP && EXPERIMENTAL
-- select CRYPTO
-+config PPP_MPPE_MPPC
-+ tristate "Microsoft PPP compression/encryption (MPPC/MPPE)"
-+ depends on PPP
- select CRYPTO_SHA1
- select CRYPTO_ARC4
-- select CRYPTO_ECB
- ---help---
-- Support for the MPPE Encryption protocol, as employed by the
-- Microsoft Point-to-Point Tunneling Protocol.
-+ Support for the Microsoft Point-To-Point Compression (RFC2118) and
-+ Microsoft Point-To-Point Encryption (RFC3078). These protocols are
-+ supported by Microsoft Windows and wide range of "hardware" access
-+ servers. MPPE is common protocol in Virtual Private Networks. According
-+ to RFC3078, MPPE supports 40, 56 and 128-bit key lengths. Depending on
-+ PPP daemon configuration on both ends of the link, following scenarios
-+ are possible:
-+ - only compression (MPPC) is used,
-+ - only encryption (MPPE) is used,
-+ - compression and encryption (MPPC+MPPE) are used.
-+
-+ Please note that Hi/Fn (http://www.hifn.com) holds patent on MPPC so
-+ you should check if this patent is valid in your country in order to
-+ avoid legal problems.
-
-- See http://pptpclient.sourceforge.net/ for information on
-- configuring PPTP clients and servers to utilize this method.
-+ For more information please visit http://mppe-mppc.alphacron.de
-+
-+ To compile this driver as a module, choose M here. The module will
-+ be called ppp_mppe_mppc.ko.
-+
-+
-+config PPP_IDLE_TIMEOUT_REFINE
-+ tristate "PPP idle timeout refine"
-+ depends on PPP
-+ help
-+ skip some kinds of packets from DUT to WAN or WAN to DUT that will cause PPPoE/PPTP/L2TP idle timeout
-+ can't work well
-
- config PPPOE
- tristate "PPP over Ethernet (EXPERIMENTAL)"
-@@ -3155,4 +3191,22 @@ config VIRTIO_NET
- This is the virtual network driver for virtio. It can be used with
- lguest or QEMU based VMMs (like KVM or Xen). Say Y or M.
-
-+config R8198EP
-+ bool "Realtek 8198 slave pcie support"
-+ ---help---
-+ Say Y here if you have a Realtek 8198 slave pcie Ethernet adapter.
-+
-+config R8198EP_HOST
-+ tristate "Host site view for slave PCIe RTL8198"
-+ depends on R8198EP
-+ ---help---
-+ Say Y here if you have a Realtek 8198 slave pcie Ethernet adapter.
-+config R8198EP_DEVICE
-+ tristate "Device site view for salve PCIe RTL8198"
-+ depends on R8198EP
-+ ---help---
-+ Say Y here if you have a Realtek 8198 slave pcie Ethernet adapter.
-+
-+
-+source "drivers/net/rtl819x/Kconfig"
- endif # NETDEVICES
---- linux-2.6.30.9/drivers/net/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/net/Makefile 2013-05-02 01:47:52.705227141 +0300
-@@ -142,7 +142,7 @@ obj-$(CONFIG_PPP_ASYNC) += ppp_async.o
- obj-$(CONFIG_PPP_SYNC_TTY) += ppp_synctty.o
- obj-$(CONFIG_PPP_DEFLATE) += ppp_deflate.o
- obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o
--obj-$(CONFIG_PPP_MPPE) += ppp_mppe.o
-+obj-$(CONFIG_PPP_MPPE_MPPC) += ppp_mppe_mppc.o
- obj-$(CONFIG_PPPOE) += pppox.o pppoe.o
- obj-$(CONFIG_PPPOL2TP) += pppox.o pppol2tp.o
-
-@@ -218,6 +218,7 @@ obj-$(CONFIG_VETH) += veth.o
- obj-$(CONFIG_NET_NETX) += netx-eth.o
- obj-$(CONFIG_DL2K) += dl2k.o
- obj-$(CONFIG_R8169) += r8169.o
-+obj-$(CONFIG_R8168) += r8168/
- obj-$(CONFIG_AMD8111_ETH) += amd8111e.o
- obj-$(CONFIG_IBMVETH) += ibmveth.o
- obj-$(CONFIG_S2IO) += s2io.o
-@@ -271,3 +272,12 @@ obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
- obj-$(CONFIG_SFC) += sfc/
-
- obj-$(CONFIG_WIMAX) += wimax/
-+
-+obj-$(CONFIG_RTL_819X_SWCORE) += rtl819x/built-in.o
-+subdir-$(CONFIG_RTL_819X_SWCORE) += rtl819x
-+
-+obj-$(CONFIG_RTK_VLAN_SUPPORT) += rtk_vlan.o
-+obj-$(CONFIG_R8198EP) += r8198ep/
-+
-+#DIR_RTLASIC = $(DIR_LINUX)/drivers/net/rtl819x/
-+#EXTRA_CFLAGS += -I$(DIR_RTLASIC)
---- linux-2.6.30.9/drivers/net/ppp_generic.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/net/ppp_generic.c 2013-05-02 01:47:53.185227102 +0300
-@@ -42,6 +42,9 @@
- #include <linux/tcp.h>
- #include <linux/smp_lock.h>
- #include <linux/spinlock.h>
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+#include <linux/smp_lock.h>
-+#endif
- #include <linux/rwsem.h>
- #include <linux/stddef.h>
- #include <linux/device.h>
-@@ -52,6 +55,49 @@
- #include <linux/nsproxy.h>
- #include <net/net_namespace.h>
- #include <net/netns/generic.h>
-+#include <linux/icmp.h>
-+
-+#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
-+#include <linux/if_pppox.h>
-+#endif
-+
-+#include <net/rtl/rtl_types.h>
-+#if defined(CONFIG_RTL_819X)
-+#include <net/rtl/rtl_nic.h>
-+#endif
-+
-+#include <net/rtl/rtl865x_netif.h>
-+#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-+#include <net/rtl/rtl865x_ppp.h>
-+#endif
-+
-+#if defined (CONFIG_RTL_HW_QOS_SUPPORT) // sync from voip customer for multiple ppp
-+#include <net/rtl/rtl865x_outputQueue.h>
-+#endif
-+
-+#if defined(NAT_SPEEDUP)||defined(CONFIG_RTL_IPTABLES_FAST_PATH)
-+ #define FAST_PPTP
-+ #define FAST_L2TP
-+#endif
-+
-+#ifdef CONFIG_RTL_LAYERED_DRIVER
-+enum SE_TYPE
-+{
-+ /*1:if_ether, 2:pppoe,3:pptp,4:l2tp*/
-+ SE_ETHER = 1,
-+ SE_PPPOE = 2,
-+ SE_PPTP = 3,
-+ SE_L2TP = 4,
-+};
-+#else
-+enum SE_TYPE
-+{
-+ SE_PPPOE = 1,
-+ SE_PPTP = 2,
-+ SE_L2TP = 3,
-+};
-+#endif /*CONFIG_RTL865X_LAYERED_DRIVER*/
-+
-
- #define PPP_VERSION "2.4.2"
-
-@@ -88,10 +134,18 @@ struct ppp_file {
- int dead; /* unit/channel has been shut down */
- };
-
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+#define PF_TO_X(pf, X) ((X *)((char *)(pf) - offsetof(X, file)))
-+#else
- #define PF_TO_X(pf, X) container_of(pf, X, file)
-+#endif
-
- #define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp)
- #define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel)
-+//#if defined(CONFIG_PPP_MPPE_MPPC)
-+//#undef ROUNDUP
-+//#define ROUNDUP(n, x) (((n) + (x) - 1) / (x))
-+//#endif
-
- /*
- * Data structure describing one ppp unit.
-@@ -107,6 +161,9 @@ struct ppp {
- spinlock_t rlock; /* lock for receive side 58 */
- spinlock_t wlock; /* lock for transmit side 5c */
- int mru; /* max receive unit 60 */
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+ int mru_alloc; /* MAX(1500,MRU) for dev_alloc_skb() */
-+#endif
- unsigned int flags; /* control bits 64 */
- unsigned int xstate; /* transmit state bits 68 */
- unsigned int rstate; /* receive state bits 6c */
-@@ -130,6 +187,7 @@ struct ppp {
- u32 minseq; /* MP: min of most recent seqnos */
- struct sk_buff_head mrq; /* MP: receive reconstruction queue */
- #endif /* CONFIG_PPP_MULTILINK */
-+ struct net_device_stats stats; /* statistics */
- #ifdef CONFIG_PPP_FILTER
- struct sock_filter *pass_filter; /* filter for packets to pass */
- struct sock_filter *active_filter;/* filter for pkts to reset idle */
-@@ -138,6 +196,67 @@ struct ppp {
- struct net *ppp_net; /* the net we belong to */
- };
-
-+#ifdef FAST_PPTP
-+#define MPPE_CCOUNT(p) ((((p)[2] & 0x0f) << 8) + (p)[3])
-+typedef struct {
-+ unsigned i;
-+ unsigned j;
-+ unsigned char S[256];
-+} arcfour_context;
-+
-+
-+#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */ /* reference from ppp_mppe.h*/
-+
-+
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+typedef struct ppp_mppe_state { /* reference from ppp_mppe_mppc.c */
-+ struct crypto_tfm *arc4_tfm;
-+ u8 master_key[MPPE_MAX_KEY_LEN];
-+ u8 session_key[MPPE_MAX_KEY_LEN];
-+ u8 mppc; /* do we use compression (MPPC)? */
-+ u8 mppe; /* do we use encryption (MPPE)? */
-+ u8 keylen; /* key length in bytes */
-+ u8 bitkeylen; /* key length in bits */
-+ u16 ccount; /* coherency counter */
-+ u16 bits; /* MPPC/MPPE control bits */
-+ u8 stateless; /* do we use stateless mode? */
-+ u8 nextflushed; /* set A bit in the next outgoing packet;
-+ used only by compressor*/
-+ u8 flushexpected; /* drop packets until A bit is received;
-+ used only by decompressor*/
-+ u8 *hist; /* MPPC history */
-+ u16 *hash; /* Hash table; used only by compressor */
-+ u16 histptr; /* history "cursor" */
-+ int unit;
-+ int debug;
-+ int mru;
-+ struct compstat stats;
-+}ppp_mppe_state;
-+#else
-+typedef struct ppp_mppe_state { /* reference from ppp_mppe.c */
-+ struct crypto_blkcipher *arc4;
-+ struct crypto_hash *sha1;
-+ unsigned char *sha1_digest;
-+ unsigned char master_key[MPPE_MAX_KEY_LEN];
-+ unsigned char session_key[MPPE_MAX_KEY_LEN];
-+ unsigned keylen; /* key length in bytes */
-+ /* NB: 128-bit == 16, 40-bit == 8! */
-+ /* If we want to support 56-bit, */
-+ /* the unit has to change to bits */
-+ unsigned char bits; /* MPPE control bits */
-+ unsigned ccount; /* 12-bit coherency count (seqno) */
-+ unsigned stateful; /* stateful mode flag */
-+ int discard; /* stateful mode packet loss flag */
-+ int sanity_errors; /* take down LCP if too many */
-+ int unit;
-+ int debug;
-+ struct compstat stats;
-+} ppp_mppe_state;
-+#endif
-+
-+#endif
-+
-+
- /*
- * Bits in flags: SC_NO_TCP_CCID, SC_CCP_OPEN, SC_CCP_UP, SC_LOOP_TRAFFIC,
- * SC_MULTILINK, SC_MP_SHORTSEQ, SC_MP_XSHORTSEQ, SC_COMP_TCP, SC_REJ_COMP_TCP,
-@@ -145,9 +264,15 @@ struct ppp {
- * Bits in rstate: SC_DECOMP_RUN, SC_DC_ERROR, SC_DC_FERROR.
- * Bits in xstate: SC_COMP_RUN
- */
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+#define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \
-+ |SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
-+ |SC_COMP_TCP|SC_REJ_COMP_TCP)
-+#else
- #define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \
- |SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
- |SC_COMP_TCP|SC_REJ_COMP_TCP|SC_MUST_COMP)
-+#endif
-
- /*
- * Private data structure for each channel.
-@@ -169,6 +294,12 @@ struct channel {
- u32 lastseq; /* MP: last sequence # received */
- int speed; /* speed of the corresponding ppp channel*/
- #endif /* CONFIG_PPP_MULTILINK */
-+#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
-+ u8 pppoe;
-+ u8 rsv1;
-+ u16 rsv2;
-+#endif /* CONFIG_RTL865X_HW_TABLES */
-+
- };
-
- /*
-@@ -235,13 +366,31 @@ struct ppp_net {
- static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
- struct file *file, unsigned int cmd, unsigned long arg);
- static void ppp_xmit_process(struct ppp *ppp);
-+#ifdef FAST_PPTP
-+static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw);
-+#else
- static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
-+#endif
-+
- static void ppp_push(struct ppp *ppp);
- static void ppp_channel_push(struct channel *pch);
- static void ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb,
- struct channel *pch);
- static void ppp_receive_error(struct ppp *ppp);
-+#ifdef FAST_PPTP
-+struct sk_buff *ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw);
-+#ifdef CONFIG_FAST_PATH_MODULE
-+int (*FastPath_hook9)( void )=NULL;
-+int (*FastPath_hook10)(struct sk_buff *skb)=NULL;
-+EXPORT_SYMBOL(FastPath_hook9);
-+EXPORT_SYMBOL(FastPath_hook10);
-+EXPORT_SYMBOL(ppp_receive_nonmp_frame);
-+#endif
-+
-+#else
- static void ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb);
-+#endif
-+
- static struct sk_buff *ppp_decompress_frame(struct ppp *ppp,
- struct sk_buff *skb);
- #ifdef CONFIG_PPP_MULTILINK
-@@ -555,10 +704,25 @@ static int get_filter(void __user *arg,
- }
- #endif /* CONFIG_PPP_FILTER */
-
-+#if defined (CONFIG_RTL_FAST_PPPOE)
-+extern int set_pppoe_info(char *ppp_dev, char *wan_dev, unsigned short sid,
-+ unsigned int our_ip,unsigned int peer_ip,
-+ unsigned char * our_mac, unsigned char *peer_mac);
-+
-+extern int clear_pppoe_info(char *ppp_dev, char *wan_dev, unsigned short sid,
-+ unsigned int our_ip,unsigned int peer_ip,
-+ unsigned char * our_mac, unsigned char *peer_mac);
-+extern int get_pppoe_last_rx_tx(char * ppp_dev,char * wan_dev,unsigned short sid,
-+ unsigned int our_ip,unsigned int peer_ip,
-+ unsigned char * our_mac,unsigned char * peer_mac,
-+ unsigned long * last_rx,unsigned long * last_tx);
-+extern int fast_pppoe_fw;
-+
-+#endif
- static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
- {
- struct ppp_file *pf = file->private_data;
-- struct ppp *ppp;
-+ struct ppp *ppp = NULL;
- int err = -EFAULT, val, val2, i;
- struct ppp_idle idle;
- struct npioctl npi;
-@@ -611,11 +775,83 @@ static long ppp_ioctl(struct file *file,
- case PPPIOCCONNECT:
- if (get_user(unit, p))
- break;
-+#ifdef CONFIG_RTL_LAYERED_DRIVER_L2 // sync from voip customer for multiple ppp
-+ #if defined (CONFIG_RTL_HW_QOS_SUPPORT)
-+ rtl865x_qosRearrangeRule();
-+ #endif
-+#endif
- err = ppp_connect_channel(pch, unit);
-+
-+#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
-+ if(err == 0 && pch->pppoe==TRUE)
-+ {
-+ struct sock *sk = (struct sock *) pch->chan->private;
-+ struct pppox_sock *po = pppox_sk(sk);
-+ struct net_device *local_dev = po->pppoe_dev;
-+#ifdef CONFIG_RTL_LAYERED_DRIVER
-+#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-+ {
-+
-+
-+ rtl865x_attachMasterNetif(pch->ppp->dev->name, local_dev->name);
-+ //add the netif mapping table
-+ rtl_add_ps_drv_netif_mapping(pch->ppp->dev,pch->ppp->dev->name); // sync from voip customer for multiple ppp
-+ }
-+ rtl865x_addPpp(pch->ppp->dev->name , (ether_addr_t*)po->pppoe_pa.remote, po->pppoe_pa.sid, SE_PPPOE);
-+#endif
-+#endif
-+#if defined (CONFIG_RTL_FAST_PPPOE)
-+ set_pppoe_info(pch->ppp->dev->name, local_dev->name, po->pppoe_pa.sid,
-+ 0,0,NULL, (unsigned char *)po->pppoe_pa.remote);
-+#endif
-+ }
-+#endif
-+
-+
-+ #ifdef FAST_PPTP // sync from voip customer for multiple ppp
-+ {
-+ extern void set_pptp_device(char *ppp_device);
-+ extern int fast_pptp_fw;
-+ if (err==0 && fast_pptp_fw)
-+ set_pptp_device(pch->ppp->dev->name);
-+ }
-+ #endif
-+
-+ #ifdef FAST_L2TP // sync from voip customer for multiple ppp
-+ {
-+ extern void set_l2tp_device(char *ppp_device);
-+ if (err==0)
-+ set_l2tp_device(pch->ppp->dev->name);
-+ }
-+ #endif
-+
- break;
-
- case PPPIOCDISCONN:
- err = ppp_disconnect_channel(pch);
-+#if defined(CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
-+ if (err == 0 && pch->pppoe==TRUE)
-+ {
-+ pch->pppoe = FALSE;
-+
-+#ifdef CONFIG_RTL_LAYERED_DRIVER
-+#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-+
-+ rtl865x_detachMasterNetif(ppp->dev->name);
-+ //del the netif mapping table
-+ rtl_del_ps_drv_netif_mapping(pch->ppp->dev);
-+ rtl865x_delPppbyIfName(ppp->dev->name);
-+#endif
-+
-+#endif
-+
-+#if defined (CONFIG_RTL_FAST_PPPOE)
-+ clear_pppoe_info(pch->ppp->dev->name, NULL, 0,
-+ 0,0,NULL, NULL);
-+#endif
-+ }
-+#endif
-+
- break;
-
- default:
-@@ -642,7 +878,13 @@ static long ppp_ioctl(struct file *file,
- case PPPIOCSMRU:
- if (get_user(val, p))
- break;
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+ ppp->mru_alloc = ppp->mru = val;
-+ if (ppp->mru_alloc < PPP_MRU)
-+ ppp->mru_alloc = PPP_MRU; /* increase for broken peers */
-+#else
- ppp->mru = val;
-+#endif
- err = 0;
- break;
-
-@@ -689,6 +931,53 @@ static long ppp_ioctl(struct file *file,
- break;
-
- case PPPIOCGIDLE:
-+#ifdef FAST_L2TP
-+ {
-+ extern int fast_l2tp_fw;
-+ unsigned long get_fast_l2tp_lastxmit(void);
-+ unsigned long fastl2tp_lastxmit;
-+ if(fast_l2tp_fw)
-+ {
-+ fastl2tp_lastxmit = get_fast_l2tp_lastxmit();
-+ if(ppp->last_xmit < fastl2tp_lastxmit)
-+ ppp->last_xmit = fastl2tp_lastxmit;
-+ }
-+ }
-+#endif
-+#ifdef FAST_PPTP
-+ {
-+ extern int fast_pptp_fw;
-+ extern unsigned long get_fastpptp_lastxmit(void);
-+ unsigned long fastpptp_lastxmit;
-+ if(fast_pptp_fw)
-+ {
-+ fastpptp_lastxmit = get_fastpptp_lastxmit();
-+ if(ppp->last_xmit < fastpptp_lastxmit)
-+ ppp->last_xmit = fastpptp_lastxmit;
-+ }
-+ }
-+#endif
-+#if defined (CONFIG_RTL_FAST_PPPOE)
-+ {
-+ unsigned long fast_pppoe_last_rx=0;
-+ unsigned long fast_pppoe_last_tx=0;
-+
-+ if(fast_pppoe_fw)
-+ {
-+ if(ppp->dev!=NULL)
-+ {
-+ get_pppoe_last_rx_tx(ppp->dev->name,NULL,0,0,0,NULL,NULL,&fast_pppoe_last_rx,&fast_pppoe_last_tx);
-+
-+ if(ppp->last_xmit < fast_pppoe_last_tx)
-+ ppp->last_xmit = fast_pppoe_last_tx;
-+
-+ if(ppp->last_recv < fast_pppoe_last_rx)
-+ ppp->last_xmit = fast_pppoe_last_rx;
-+ }
-+ }
-+ }
-+#endif
-+
- idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
- idle.recv_idle = (jiffies - ppp->last_recv) / HZ;
- if (copy_to_user(argp, &idle, sizeof(idle)))
-@@ -788,6 +1077,15 @@ static long ppp_ioctl(struct file *file,
- return err;
- }
-
-+struct net_device_stats *get_ppp_stats(struct ppp *ppp)
-+{
-+ return (&ppp->stats);
-+}
-+
-+#ifdef CONFIG_FAST_PATH_MODULE
-+EXPORT_SYMBOL(get_ppp_stats);
-+#endif
-+
- static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
- struct file *file, unsigned int cmd, unsigned long arg)
- {
-@@ -951,13 +1249,114 @@ out:
- /*
- * Network interface unit routines.
- */
--static int
--ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
-+ #if defined(FAST_L2TP)
-+extern int fast_l2tp_to_wan(void *skb);
-+extern int check_for_fast_l2tp_to_wan(void *skb);
-+extern void event_ppp_dev_down(const char * name);
-+#endif
-+#if defined(FAST_PPTP) || defined(FAST_L2TP)
-+int ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
-+#else
-+static int ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
-+#endif
-+
- {
- struct ppp *ppp = netdev_priv(dev);
- int npi, proto;
- unsigned char *pp;
-
-+#ifdef FAST_PPTP
-+ int is_fast_fw=0;
-+ #if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
-+ extern int fast_pptp_fw;
-+ #ifdef CONFIG_FAST_PATH_MODULE
-+ if((FastPath_hook9!=NULL) &&(FastPath_hook10!=NULL))
-+ {
-+ if (FastPath_hook9()) {
-+ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L')
-+ {
-+ is_fast_fw=1;
-+ memset(skb->cb, '\x0', 3);
-+ }
-+ else {
-+ extern int fast_pptp_to_wan(struct sk_buff *skb);
-+ if (FastPath_hook10(skb))
-+ return 0;
-+ }
-+ }
-+ }
-+ #else
-+ if (fast_pptp_fw) {
-+ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L')
-+ {
-+ is_fast_fw=1;
-+ memset(skb->cb, '\x0', 3);
-+ }
-+ else {
-+ extern int is_pptp_device(char *ppp_device); // sync from voip customer for multiple ppp
-+ extern int fast_pptp_to_wan(void *skb);
-+ if (is_pptp_device(ppp->dev->name) && fast_pptp_to_wan((void*)skb)) // sync from voip customer for multiple ppp
-+ return 0;
-+ }
-+ }
-+ #endif
-+ #else
-+ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L')
-+ is_fast_fw=1;
-+ #endif
-+#endif
-+
-+#if 0
-+#ifdef FAST_L2TP
-+#ifndef FAST_PPTP
-+ int is_fast_fw=0;
-+#endif
-+
-+#ifdef CONFIG_RTL_IPTABLES_FAST_PATH
-+#if 0//def CONFIG_FAST_PATH_MODULE
-+ if((FastPath_hook9!=NULL) &&(FastPath_hook10!=NULL))
-+ {
-+ if (FastPath_hook9()) {
-+ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L') {
-+ is_fast_fw = 1;
-+ memset(skb->cb, '\x0', 3);
-+ }
-+ else {
-+ //extern int fast_pptp_to_wan(struct sk_buff *skb);
-+#ifdef CONFIG_RTL865X_HW_PPTPL2TP
-+ if (!accelerate && FastPath_hook10(skb))
-+ return 0;
-+#else
-+ if (FastPath_hook10(skb))
-+ return 0;
-+#endif /* CONFIG_RTL865X_HW_PPTPL2TP */
-+ }
-+ }
-+ }
-+#else
-+ extern int fast_l2tp_fw;
-+ if (fast_l2tp_fw) {
-+ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L') {
-+ is_fast_fw = 1;
-+ memset(skb->cb, '\x0', 3);
-+ }
-+ else {
-+ extern int is_l2tp_device(char *ppp_device);
-+ extern int fast_l2tp_to_wan(struct sk_buff *skb);
-+ if (is_l2tp_device(ppp->dev->name)&&fast_l2tp_to_wan(skb))
-+ return 0;
-+ }
-+ }
-+#endif
-+#else
-+ if (skb->cb[0]=='R' && skb->cb[1]=='T' && skb->cb[2]=='L') {
-+ is_fast_fw = 1;
-+ memset(skb->cb, '\x0', 3);
-+ }
-+#endif
-+#endif
-+#endif
-+
- npi = ethertype_to_npindex(ntohs(skb->protocol));
- if (npi < 0)
- goto outf;
-@@ -985,9 +1384,37 @@ ppp_start_xmit(struct sk_buff *skb, stru
- pp[0] = proto >> 8;
- pp[1] = proto;
-
-+#ifdef FAST_PPTP
-+ if (is_fast_fw)
-+ ppp_send_frame(ppp, skb, 1);
-+ else {
-+#ifdef FAST_L2TP
-+ skb_pull(skb,2);
-+ extern int is_l2tp_device(char *ppp_device); // sync from voip customer for multiple ppp
-+ if (is_l2tp_device(ppp->dev->name) && (check_for_fast_l2tp_to_wan((void*)skb)==1) && (fast_l2tp_to_wan((void*)skb) == 1)) // sync from voip customer for multiple ppp
-+ {
-+ /* Note: if pkt go here, l2tp dial-on-demand will not be triggered,
-+ so some risk exist here! -- 2010/04/25 zj */
-+ return 0;
-+ }
-+ else
-+ {
-+ pp = skb_push(skb, 2);
-+ proto = npindex_to_proto[npi];
-+ pp[0] = proto >> 8;
-+ pp[1] = proto;
-+ }
-+#endif
-+ netif_stop_queue(dev);
-+ skb_queue_tail(&ppp->file.xq, skb);
-+ ppp_xmit_process(ppp);
-+ }
-+#else
- netif_stop_queue(dev);
- skb_queue_tail(&ppp->file.xq, skb);
- ppp_xmit_process(ppp);
-+#endif
-+
- return 0;
-
- outf:
-@@ -1050,7 +1477,11 @@ static void ppp_setup(struct net_device
- dev->hard_header_len = PPP_HDRLEN;
- dev->mtu = PPP_MTU;
- dev->addr_len = 0;
-+#if defined(CONFIG_RTL_819X)
-+ dev->tx_queue_len = 64;
-+#else
- dev->tx_queue_len = 3;
-+#endif
- dev->type = ARPHRD_PPP;
- dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
- dev->features |= NETIF_F_NETNS_LOCAL;
-@@ -1074,7 +1505,12 @@ ppp_xmit_process(struct ppp *ppp)
- ppp_push(ppp);
- while (!ppp->xmit_pending
- && (skb = skb_dequeue(&ppp->file.xq)))
-+#ifdef FAST_PPTP
-+ ppp_send_frame(ppp, skb, 0);
-+#else
- ppp_send_frame(ppp, skb);
-+#endif
-+
- /* If there's no work left to do, tell the core net
- code that we can accept some more. */
- if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
-@@ -1083,6 +1519,7 @@ ppp_xmit_process(struct ppp *ppp)
- ppp_xmit_unlock(ppp);
- }
-
-+#if !defined(CONFIG_PPP_MPPE_MPPC)
- static inline struct sk_buff *
- pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
- {
-@@ -1132,19 +1569,81 @@ pad_compress_skb(struct ppp *ppp, struct
- }
- return new_skb;
- }
-+#endif
-+
-+/*
-+ * some kinds of packets from DUT to WAN will cause ppp interface active when lan==>wan traffic is off,
-+ * so we skip these packets. otherwise the ppp idletime out can't work well
-+ * return value 1 means this packet won't set the ppp to active
-+ */
-+#if defined(CONFIG_PPP_IDLE_TIMEOUT_REFINE)
-+int timeoutCheck_skipp_pkt(struct iphdr *iph)
-+{
-+
-+ if(iph == NULL)
-+ {
-+ printk("the iphdr for PPP_IDLE_TIMEOUT_REFINE is NULL, is may cause some isses\n");
-+ return 0;
-+ }
-+
-+ if(iph->protocol == IPPROTO_ICMP)
-+ {
-+ struct icmphdr *icmph= (void *)iph + iph->ihl*4;
-+ // we don't care dest unreacheable pkts(to wan) while recode last tx time
-+ if(icmph->type==ICMP_DEST_UNREACH)
-+ {
-+ printk("it is ICMP dest unreacheable packet\n");
-+ //if(net_ratelimit())printk("skip a icmp dest unreachable pkt from lan to wan\n");
-+ return 1;
-+ }
-+ }
-+ else if(iph->protocol == IPPROTO_TCP)
-+ {
-+ struct tcphdr *tcph;
-+ tcph = (void *)iph + iph->ihl*4;
-+ // we don't care tcp fin/rst pkts(to wan) while recode last tx time
-+ if(tcph->fin || tcph->rst)
-+ {
-+ //if(net_ratelimit())printk("skip a tcp fin/rst pkt fin: %d rst :%d from lan to wan\n", tcph->fin, tcph->rst);
-+ return 1;
-+ }
-+ }
-+ else if(iph->protocol == IPPROTO_IGMP)
-+ {
-+ // we don't care IGMP packets
-+ printk("it is ICMP packet\n");
-+ return 1;
-+ }
-+
-+ return 0;
-+}
-+#else //fastpath assemble code will call this function anyway.
-+int timeoutCheck_skipp_pkt(struct iphdr *iph)
-+{
-+ return 0;
-+}
-+#endif
-
- /*
- * Compress and send a frame.
- * The caller should have locked the xmit path,
- * and xmit_pending should be 0.
- */
--static void
--ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
-+#ifdef FAST_PPTP
-+static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw)
-+#else
-+static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
-+#endif
-+
- {
- int proto = PPP_PROTO(skb);
- struct sk_buff *new_skb;
- int len;
- unsigned char *cp;
-+#if defined(CONFIG_PPP_IDLE_TIMEOUT_REFINE)
-+ struct iphdr *iphp;
-+ iphp = (struct iphdr *)((unsigned char *)(skb->data+2));
-+#endif
-
- if (proto < 0x8000) {
- #ifdef CONFIG_PPP_FILTER
-@@ -1168,6 +1667,9 @@ ppp_send_frame(struct ppp *ppp, struct s
- skb_pull(skb, 2);
- #else
- /* for data packets, record the time */
-+#if defined(CONFIG_PPP_IDLE_TIMEOUT_REFINE)
-+ if(timeoutCheck_skipp_pkt(iphp)!=1)
-+#endif
- ppp->last_xmit = jiffies;
- #endif /* CONFIG_PPP_FILTER */
- }
-@@ -1175,6 +1677,13 @@ ppp_send_frame(struct ppp *ppp, struct s
- ++ppp->dev->stats.tx_packets;
- ppp->dev->stats.tx_bytes += skb->len - 2;
-
-+#if defined(FAST_PPTP) && defined(NAT_SPEEDUP)
-+{
-+ extern void update_fast_pptp_state(void);
-+ update_fast_pptp_state();
-+}
-+#endif
-+
- switch (proto) {
- case PPP_IP:
- if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0)
-@@ -1213,12 +1722,69 @@ ppp_send_frame(struct ppp *ppp, struct s
- case PPP_CCP:
- /* peek at outbound CCP frames */
- ppp_ccp_peek(ppp, skb, 0);
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+ if (CCP_CODE(skb->data+2) == CCP_RESETACK
-+ && (ppp->xcomp->compress_proto == CI_MPPE
-+ || ppp->xcomp->compress_proto == CI_LZS)) {
-+ --ppp->dev->stats.tx_packets;
-+ ppp->dev->stats.tx_bytes -= skb->len - 2;
-+ kfree_skb(skb);
-+ return;
-+ }
-+#endif
- break;
- }
-
- /* try to do packet compression */
- if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state
- && proto != PPP_LCP && proto != PPP_CCP) {
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+ int comp_ovhd = 0;
-+ /*
-+ * because of possible data expansion when MPPC or LZS
-+ * is used, allocate compressor's buffer 12.5% bigger
-+ * than MTU
-+ */
-+ if (ppp->xcomp->compress_proto == CI_MPPE)
-+ comp_ovhd = ((ppp->dev->mtu * 9) / 8) + 1 + MPPE_OVHD;
-+ else if (ppp->xcomp->compress_proto == CI_LZS)
-+ comp_ovhd = ((ppp->dev->mtu * 9) / 8) + 1 + LZS_OVHD;
-+ new_skb = alloc_skb(ppp->dev->mtu + ppp->dev->hard_header_len
-+ + comp_ovhd, GFP_ATOMIC);
-+ if (new_skb == 0) {
-+ printk(KERN_ERR "PPP: no memory (comp pkt)\n");
-+ goto drop;
-+ }
-+ if (ppp->dev->hard_header_len > PPP_HDRLEN)
-+ skb_reserve(new_skb,
-+ ppp->dev->hard_header_len - PPP_HDRLEN);
-+
-+ /* compressor still expects A/C bytes in hdr */
-+ len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
-+ new_skb->data, skb->len + 2,
-+ ppp->dev->mtu + PPP_HDRLEN);
-+ if (len > 0 && (ppp->flags & SC_CCP_UP)) {
-+ kfree_skb(skb);
-+ skb = new_skb;
-+ skb_put(skb, len);
-+ skb_pull(skb, 2); /* pull off A/C bytes */
-+ } else if (len == 0) {
-+ /* didn't compress, or CCP not up yet */
-+ kfree_skb(new_skb);
-+ } else {
-+ /*
-+ * (len < 0)
-+ * MPPE requires that we do not send unencrypted
-+ * frames. The compressor will return -1 if we
-+ * should drop the frame. We cannot simply test
-+ * the compress_proto because MPPE and MPPC share
-+ * the same number.
-+ */
-+ printk(KERN_ERR "ppp: compressor dropped pkt\n");
-+ kfree_skb(new_skb);
-+ goto drop;
-+ }
-+#else
- if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
- if (net_ratelimit())
- printk(KERN_ERR "ppp: compression required but down - pkt dropped.\n");
-@@ -1227,6 +1793,7 @@ ppp_send_frame(struct ppp *ppp, struct s
- skb = pad_compress_skb(ppp, skb);
- if (!skb)
- goto drop;
-+#endif
- }
-
- /*
-@@ -1242,6 +1809,9 @@ ppp_send_frame(struct ppp *ppp, struct s
- }
-
- ppp->xmit_pending = skb;
-+#ifdef FAST_PPTP
-+ if (!is_fast_fw)
-+#endif
- ppp_push(ppp);
- return;
-
-@@ -1637,7 +2207,11 @@ ppp_receive_frame(struct ppp *ppp, struc
- ppp_receive_mp_frame(ppp, skb, pch);
- else
- #endif /* CONFIG_PPP_MULTILINK */
-+#ifdef FAST_PPTP
-+ ppp_receive_nonmp_frame(ppp, skb, 0);
-+#else
- ppp_receive_nonmp_frame(ppp, skb);
-+#endif
- return;
- }
-
-@@ -1657,12 +2231,38 @@ ppp_receive_error(struct ppp *ppp)
- slhc_toss(ppp->vj);
- }
-
--static void
--ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
-+#ifdef FAST_PPTP
-+struct sk_buff *ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb, int is_fast_fw)
-+#else
-+static void ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
-+#endif
-+
- {
- struct sk_buff *ns;
- int proto, len, npi;
-
-+//brad add for pptp mppe rx out of order
-+#ifdef FAST_PPTP
-+ if(is_fast_fw){
-+ ppp_mppe_state *state;
-+ unsigned int curr_ccount=0;
-+ if((skb->data[2] & 0x10) == 0x10){
-+ state = (ppp_mppe_state *) ppp->rc_state;
-+ curr_ccount = MPPE_CCOUNT(skb->data);
-+ if(state->ccount < 4096 && state->ccount != 0 ){
-+ if(curr_ccount < state->ccount && curr_ccount > 0){
-+ kfree_skb(skb);
-+ return NULL;
-+ }
-+ }else if(curr_ccount == 4095 && state->ccount == 0){
-+ kfree_skb(skb);
-+ return NULL;
-+
-+ }
-+ }
-+ }
-+#endif
-+
- /*
- * Decompress the frame, if compressed.
- * Note that some decompressors need to see uncompressed frames
-@@ -1672,8 +2272,10 @@ ppp_receive_nonmp_frame(struct ppp *ppp,
- && (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0)
- skb = ppp_decompress_frame(ppp, skb);
-
-+#if !defined(CONFIG_PPP_MPPE_MPPC)
- if (ppp->flags & SC_MUST_COMP && ppp->rstate & SC_DC_FERROR)
- goto err;
-+#endif
-
- proto = PPP_PROTO(skb);
- switch (proto) {
-@@ -1737,6 +2339,12 @@ ppp_receive_nonmp_frame(struct ppp *ppp,
-
- npi = proto_to_npindex(proto);
- if (npi < 0) {
-+#ifdef FAST_PPTP
-+ if (is_fast_fw) {
-+ kfree_skb(skb);
-+ return NULL;
-+ }
-+#endif
- /* control or unknown frame - pass it to pppd */
- skb_queue_tail(&ppp->file.rq, skb);
- /* limit queue length by dropping old frames */
-@@ -1786,14 +2394,30 @@ ppp_receive_nonmp_frame(struct ppp *ppp,
- skb->dev = ppp->dev;
- skb->protocol = htons(npindex_to_ethertype[npi]);
- skb_reset_mac_header(skb);
-+#ifdef FAST_PPTP
-+ if (is_fast_fw)
-+ return skb;
-+ else
-+#endif
-+#if defined(CONFIG_RTL_819X)&&defined(RX_TASKLET)
-+ netif_receive_skb(skb);
-+#else
- netif_rx(skb);
-+#endif
- }
- }
-+#ifdef FAST_PPTP
-+ return NULL;
-+#else
- return;
-+#endif
-
- err:
- kfree_skb(skb);
- ppp_receive_error(ppp);
-+#ifdef FAST_PPTP
-+ return NULL;
-+#endif
- }
-
- static struct sk_buff *
-@@ -1814,10 +2438,18 @@ ppp_decompress_frame(struct ppp *ppp, st
-
- switch(ppp->rcomp->compress_proto) {
- case CI_MPPE:
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+ obuff_size = ppp->mru_alloc + PPP_HDRLEN + 1;
-+#else
- obuff_size = ppp->mru + PPP_HDRLEN + 1;
-+#endif
- break;
- default:
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+ obuff_size = ppp->mru_alloc + PPP_HDRLEN;
-+#else
- obuff_size = ppp->mru + PPP_HDRLEN;
-+#endif
- break;
- }
-
-@@ -1854,7 +2486,18 @@ ppp_decompress_frame(struct ppp *ppp, st
- return skb;
-
- err:
-+ #if defined(CONFIG_PPP_MPPE_MPPC)
-+ if (ppp->rcomp->compress_proto != CI_MPPE
-+ && ppp->rcomp->compress_proto != CI_LZS) {
-+ /*
-+ * If decompression protocol isn't MPPE/MPPC or LZS, we set
-+ * SC_DC_ERROR flag and wait for CCP_RESETACK
-+ */
- ppp->rstate |= SC_DC_ERROR;
-+ }
-+ #else
-+ ppp->rstate |= SC_DC_ERROR;
-+ #endif
- ppp_receive_error(ppp);
- return skb;
- }
-@@ -1943,7 +2586,11 @@ ppp_receive_mp_frame(struct ppp *ppp, st
-
- /* Pull completed packets off the queue and receive them. */
- while ((skb = ppp_mp_reconstruct(ppp)))
-+#ifdef FAST_PPTP
-+ ppp_receive_nonmp_frame(ppp, skb, 0);
-+#else
- ppp_receive_nonmp_frame(ppp, skb);
-+#endif
-
- return;
-
-@@ -2169,6 +2816,19 @@ int ppp_unit_number(struct ppp_channel *
- return unit;
- }
-
-+#if defined (CONFIG_RTL_PPPOE_HWACC) || defined (CONFIG_RTL_FAST_PPPOE)
-+/*
-+ * Mark the pppoe type for a channel
-+ */
-+void ppp_channel_pppoe(struct ppp_channel *chan)
-+{
-+ struct channel *pch = chan->ppp;
-+
-+ pch->pppoe = TRUE;
-+}
-+#endif
-+
-+
- /*
- * Disconnect a channel from the generic layer.
- * This must be called in process context.
-@@ -2541,6 +3201,9 @@ ppp_create_interface(struct net *net, in
- ppp = netdev_priv(dev);
- ppp->dev = dev;
- ppp->mru = PPP_MRU;
-+#if defined(CONFIG_PPP_MPPE_MPPC)
-+ ppp->mru_alloc = PPP_MRU;
-+#endif
- init_ppp_file(&ppp->file, INTERFACE);
- ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */
- for (i = 0; i < NUM_NP; ++i)
-@@ -2633,7 +3296,15 @@ init_ppp_file(struct ppp_file *pf, int k
- static void ppp_shutdown_interface(struct ppp *ppp)
- {
- struct ppp_net *pn;
--
-+#ifdef CONFIG_RTL_PPPOE_HWACC
-+ char dev_name[IFNAMSIZ];
-+ memcpy(dev_name, ppp->dev->name, IFNAMSIZ);
-+#endif
-+
-+#if defined (CONFIG_RTL_FAST_PPPOE)
-+ clear_pppoe_info(ppp->dev->name, NULL, 0,
-+ 0,0,NULL, NULL);
-+#endif
- pn = ppp_pernet(ppp->ppp_net);
- mutex_lock(&pn->all_ppp_mutex);
-
-@@ -2649,6 +3320,33 @@ static void ppp_shutdown_interface(struc
- unit_put(&pn->units_idr, ppp->file.index);
- ppp->file.dead = 1;
- ppp->owner = NULL;
-+
-+#if defined(FAST_L2TP)
-+ {
-+ extern int fast_l2tp_fw;
-+ if(fast_l2tp_fw)
-+ event_ppp_dev_down(dev_name);
-+ }
-+#endif
-+
-+#ifdef CONFIG_RTL_PPPOE_HWACC
-+#ifdef CONFIG_RTL_LAYERED_DRIVER
-+#ifdef CONFIG_RTL_LAYERED_DRIVER_L3
-+#if 1
-+ rtl865x_detachMasterNetif(dev_name);
-+#endif
-+#ifdef CONFIG_RTL_LAYERED_DRIVER_L2 // sync from voip customer for multiple ppp
-+ #if defined (CONFIG_RTL_HW_QOS_SUPPORT)
-+ rtl865x_qosFlushMarkRuleByDev(dev_name);
-+ #endif
-+#endif
-+ rtl865x_delPppbyIfName(dev_name);
-+#endif
-+#else
-+ rtl865x_delPppSession(dev_name, SE_PPPOE);
-+#endif
-+#endif
-+
- wake_up_interruptible(&ppp->file.rwait);
-
- mutex_unlock(&pn->all_ppp_mutex);
-@@ -2892,6 +3590,12 @@ static void *unit_find(struct idr *p, in
- module_init(ppp_init);
- module_exit(ppp_cleanup);
-
-+#if defined(CONFIG_RTL_IPTABLES_FAST_PATH)
-+ #if defined(CONFIG_FAST_PATH_MODULE)
-+ EXPORT_SYMBOL(ppp_start_xmit);
-+ #endif
-+#endif
-+
- EXPORT_SYMBOL(ppp_register_net_channel);
- EXPORT_SYMBOL(ppp_register_channel);
- EXPORT_SYMBOL(ppp_unregister_channel);
---- linux-2.6.30.9/drivers/net/pppoe.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/net/pppoe.c 2013-05-02 01:47:53.188227102 +0300
-@@ -304,6 +304,11 @@ static void pppoe_flush_dev(struct net_d
- for (i = 0; i < PPPOE_HASH_SIZE; i++) {
- struct pppox_sock *po = pn->hash_table[i];
-
-+ if(!((unsigned int)po & 0x80000000))
-+ {
-+ continue;
-+ }
-+
- while (po != NULL) {
- struct sock *sk;
- if (po->pppoe_dev != dev) {
-@@ -699,6 +704,10 @@ static int pppoe_connect(struct socket *
- if (error)
- goto err_put;
-
-+#if defined (CONFIG_RTL_PPPOE_HWACC) || defined(CONFIG_RTL_FAST_PPPOE)
-+ ppp_channel_pppoe(&po->chan);
-+#endif
-+
- sk->sk_state = PPPOX_CONNECTED;
- }
-
-@@ -908,6 +917,9 @@ end:
- * xmit function for internal use.
- *
- ***********************************************************************/
-+ #if defined(CONFIG_NET_SCHED)
-+ extern int gQosEnabled;
-+ #endif
- static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
- {
- struct pppox_sock *po = pppox_sk(sk);
-@@ -943,7 +955,17 @@ static int __pppoe_xmit(struct sock *sk,
- dev_hard_header(skb, dev, ETH_P_PPP_SES,
- po->pppoe_pa.remote, NULL, data_len);
-
-+ /*Improve pppoe wantype throughput when QoS disabled.*/
-+#if defined(CONFIG_NET_SCHED)
-+ if (gQosEnabled)
-+ {
- dev_queue_xmit(skb);
-+ }
-+ else
-+#endif
-+ {
-+ skb->dev->netdev_ops->ndo_start_xmit(skb,skb->dev);
-+ }
-
- return 1;
-
---- linux-2.6.30.9/drivers/net/tg3.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/net/tg3.c 2013-05-02 01:47:53.528227074 +0300
-@@ -6242,6 +6242,11 @@ static int tg3_chip_reset(struct tg3 *tp
- PCI_EXP_DEVSTA_URD);
- }
-
-+ /* tonywu */
-+ pci_write_config_word(tp->pdev, tp->pcie_cap + PCI_EXP_DEVCTL, 0);
-+ pcie_set_readrq(tp->pdev, 128);
-+ /* tonywu */
-+
- tg3_restore_pci_state(tp);
-
- tp->tg3_flags &= ~TG3_FLAG_CHIP_RESETTING;
---- linux-2.6.30.9/drivers/net/wireless/Kconfig 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/net/wireless/Kconfig 2013-05-02 01:47:53.615227067 +0300
-@@ -434,6 +434,12 @@ config RTL8187
-
- Thanks to Realtek for their support!
-
-+config RTL8192SE_mac80211
-+ tristate "Realtek 8192SE wireless chip support"
-+ depends on MAC80211 && WLAN_80211
-+ ---help---
-+ This is a driver for RTL8192SE that support mac80211
-+
- config ADM8211
- tristate "ADMtek ADM8211 support"
- depends on MAC80211 && PCI && WLAN_80211 && EXPERIMENTAL
-@@ -483,17 +489,9 @@ config MWL8K
- To compile this driver as a module, choose M here: the module
- will be called mwl8k. If unsure, say N.
-
--source "drivers/net/wireless/p54/Kconfig"
--source "drivers/net/wireless/ath5k/Kconfig"
--source "drivers/net/wireless/ath9k/Kconfig"
--source "drivers/net/wireless/ar9170/Kconfig"
--source "drivers/net/wireless/ipw2x00/Kconfig"
- source "drivers/net/wireless/iwlwifi/Kconfig"
- source "drivers/net/wireless/hostap/Kconfig"
--source "drivers/net/wireless/b43/Kconfig"
--source "drivers/net/wireless/b43legacy/Kconfig"
--source "drivers/net/wireless/zd1211rw/Kconfig"
--source "drivers/net/wireless/rt2x00/Kconfig"
--source "drivers/net/wireless/orinoco/Kconfig"
-+source "drivers/net/wireless/rtl8192cd/Kconfig"
-+source "drivers/net/wireless/rtl8192e/Kconfig"
-
- endmenu
---- linux-2.6.30.9/drivers/net/wireless/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/net/wireless/Makefile 2013-05-02 01:47:53.615227067 +0300
-@@ -2,8 +2,6 @@
- # Makefile for the Linux Wireless network device drivers.
- #
-
--obj-$(CONFIG_IPW2100) += ipw2x00/
--obj-$(CONFIG_IPW2200) += ipw2x00/
-
- obj-$(CONFIG_STRIP) += strip.o
- obj-$(CONFIG_ARLAN) += arlan.o
-@@ -24,16 +22,9 @@ obj-$(CONFIG_ATMEL) += atmel
- obj-$(CONFIG_PCI_ATMEL) += atmel_pci.o
- obj-$(CONFIG_PCMCIA_ATMEL) += atmel_cs.o
-
--obj-$(CONFIG_AT76C50X_USB) += at76c50x-usb.o
-
--obj-$(CONFIG_PRISM54) += prism54/
-
- obj-$(CONFIG_HOSTAP) += hostap/
--obj-$(CONFIG_B43) += b43/
--obj-$(CONFIG_B43LEGACY) += b43legacy/
--obj-$(CONFIG_ZD1211RW) += zd1211rw/
--obj-$(CONFIG_RTL8180) += rtl818x/
--obj-$(CONFIG_RTL8187) += rtl818x/
-
- # 16-bit wireless PCMCIA client drivers
- obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
-@@ -51,12 +42,8 @@ obj-$(CONFIG_ADM8211) += adm8211.o
- obj-$(CONFIG_MWL8K) += mwl8k.o
-
- obj-$(CONFIG_IWLWIFI) += iwlwifi/
--obj-$(CONFIG_RT2X00) += rt2x00/
-
--obj-$(CONFIG_P54_COMMON) += p54/
-
--obj-$(CONFIG_ATH5K) += ath5k/
--obj-$(CONFIG_ATH9K) += ath9k/
--obj-$(CONFIG_AR9170_USB) += ar9170/
-
--obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o
-+obj-$(CONFIG_RTL8192CD) += rtl8192cd/
-+obj-$(CONFIG_WLAN_HAL_8192EE) += rtl8192e/
---- linux-2.6.30.9/drivers/pci/access.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/pci/access.c 2013-05-02 01:47:54.647226984 +0300
-@@ -38,6 +38,46 @@ int pci_bus_read_config_##size \
- spin_unlock_irqrestore(&pci_lock, flags); \
- return res; \
- }
-+#ifdef CONFIG_RTL8198_REVISION_B
-+int pci_bus_read_config_word
-+ (struct pci_bus *bus, unsigned int devfn, int pos, u16 *value)
-+{
-+ int res;
-+ unsigned long flags;
-+ u32 data = 0;
-+ if (PCI_word_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;
-+ spin_lock_irqsave(&pci_lock, flags);
-+
-+ int swap[4]={0,8,16,24}; int diff = pos&0x3;
-+ res = bus->ops->read(bus, devfn, (pos&0xFFFFC), 4, &data);
-+ *value =(u16)( (data>>(swap[diff]))&0xffff);
-+
-+
-+
-+
-+ //*value = (type)data;
-+ spin_unlock_irqrestore(&pci_lock, flags);
-+ return res;
-+}
-+int pci_bus_read_config_byte
-+ (struct pci_bus *bus, unsigned int devfn, int pos, u8 *value)
-+{
-+ int res;
-+ unsigned long flags;
-+ u32 data = 0;
-+ if (PCI_word_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;
-+ spin_lock_irqsave(&pci_lock, flags);
-+
-+ int swap[4]={0,8,16,24}; int diff = pos&0x3;
-+ res = bus->ops->read(bus, devfn, (pos&0xFFFFC), 4, &data);
-+ *value =(u8)( (data>>(swap[diff]))&0xff);
-+ //*value = (type)data;
-+ spin_unlock_irqrestore(&pci_lock, flags);
-+ return res;
-+}
-+
-+#endif
-+
-
- #define PCI_OP_WRITE(size,type,len) \
- int pci_bus_write_config_##size \
-@@ -52,8 +92,11 @@ int pci_bus_write_config_##size \
- return res; \
- }
-
-+#ifndef CONFIG_RTL8198_REVISION_B
- PCI_OP_READ(byte, u8, 1)
-+
- PCI_OP_READ(word, u16, 2)
-+#endif
- PCI_OP_READ(dword, u32, 4)
- PCI_OP_WRITE(byte, u8, 1)
- PCI_OP_WRITE(word, u16, 2)
---- linux-2.6.30.9/drivers/scsi/Kconfig 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/scsi/Kconfig 2013-05-02 01:47:55.017226954 +0300
-@@ -82,6 +82,11 @@ config BLK_DEV_SD
- In this case, do not compile the driver for your SCSI host adapter
- (below) as a module either.
-
-+config 4KB_HARDDISK_SUPPORT
-+ bool "4kb sector size disk support"
-+ depends on BLK_DEV_SD
-+ default n
-+
- config CHR_DEV_ST
- tristate "SCSI tape support"
- depends on SCSI
---- linux-2.6.30.9/drivers/scsi/scsi_lib.c 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/scsi/scsi_lib.c 2013-05-02 01:47:55.252226935 +0300
-@@ -1626,7 +1626,7 @@ u64 scsi_calculate_bounce_limit(struct S
-
- host_dev = scsi_get_device(shost);
- if (host_dev && host_dev->dma_mask)
-- bounce_limit = *host_dev->dma_mask;
-+ bounce_limit = *(host_dev->dma_mask);
-
- return bounce_limit;
- }
--- linux-2.6.30.9/drivers/serial/8250.c 2009-10-05 18:38:08.000000000 +0300
+++ linux-2.6.30.9-rsdk/drivers/serial/8250.c 2013-05-02 01:47:55.684226900 +0300
@@ -44,10 +44,6 @@
@@ -6117,24 +3261,3 @@
}
return 0;
}
---- linux-2.6.30.9/drivers/staging/Kconfig 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/staging/Kconfig 2013-05-02 01:47:55.708226898 +0300
-@@ -85,6 +87,8 @@ source "drivers/staging/altpciechdma/Kco
-
- source "drivers/staging/rtl8187se/Kconfig"
-
-+source "drivers/staging/rtl8192su/Kconfig"
-+
- source "drivers/staging/rspiusb/Kconfig"
-
- source "drivers/staging/mimio/Kconfig"
---- linux-2.6.30.9/drivers/staging/Makefile 2009-10-05 18:38:08.000000000 +0300
-+++ linux-2.6.30.9-rsdk/drivers/staging/Makefile 2013-05-02 01:47:55.708226898 +0300
-@@ -25,6 +25,7 @@ obj-$(CONFIG_ASUS_OLED) += asus_oled/
- obj-$(CONFIG_PANEL) += panel/
- obj-$(CONFIG_ALTERA_PCIE_CHDMA) += altpciechdma/
- obj-$(CONFIG_RTL8187SE) += rtl8187se/
-+obj-$(CONFIG_RTL8192SU) += rtl8192su/
- obj-$(CONFIG_USB_RSPI) += rspiusb/
- obj-$(CONFIG_INPUT_MIMIO) += mimio/
- obj-$(CONFIG_TRANZPORT) += frontier/
diff --git a/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-staging.patch b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-staging.patch
new file mode 100644
index 000000000..f1ecc88a7
--- /dev/null
+++ b/target/linux/realtek/patches-2.6.30/0002-rsdk-drivers-staging.patch
@@ -0,0 +1,21 @@
+--- linux-2.6.30.9/drivers/staging/Kconfig 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/staging/Kconfig 2013-05-02 01:47:55.708226898 +0300
+@@ -85,6 +87,8 @@ source "drivers/staging/altpciechdma/Kco
+
+ source "drivers/staging/rtl8187se/Kconfig"
+
++source "drivers/staging/rtl8192su/Kconfig"
++
+ source "drivers/staging/rspiusb/Kconfig"
+
+ source "drivers/staging/mimio/Kconfig"
+--- linux-2.6.30.9/drivers/staging/Makefile 2009-10-05 18:38:08.000000000 +0300
++++ linux-2.6.30.9-rsdk/drivers/staging/Makefile 2013-05-02 01:47:55.708226898 +0300
+@@ -25,6 +25,7 @@ obj-$(CONFIG_ASUS_OLED) += asus_oled/
+ obj-$(CONFIG_PANEL) += panel/
+ obj-$(CONFIG_ALTERA_PCIE_CHDMA) += altpciechdma/
+ obj-$(CONFIG_RTL8187SE) += rtl8187se/
++obj-$(CONFIG_RTL8192SU) += rtl8192su/
+ obj-$(CONFIG_USB_RSPI) += rspiusb/
+ obj-$(CONFIG_INPUT_MIMIO) += mimio/
+ obj-$(CONFIG_TRANZPORT) += frontier/