M7350v7_en_gpl

This commit is contained in:
T 2024-09-09 08:59:52 +00:00
parent f75098198c
commit 46ba6f09ec
1372 changed files with 1231198 additions and 1184 deletions

View File

@ -71,15 +71,17 @@ static struct flash_id supported_flash[] = {
/* Flash ID Flash ID2 ID Mask ID Mask2 Density(MB) Wid Pgsz Blksz oobsz 8-bit ECCf */
{0x1590AC2C, 0x56, 0xFFFFFFFF, 0xFF, 0x20000000, 0, 2048, 0x00020000, 0x40, 0},
{0x1590AC2C, 0x57, 0xFFFFFFFF, 0xFF, 0x20000000, 0, 2048, 0x00020000, 0x40, 1},
{0x1590AA2C, 0x06, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0xE0, 0},
{0x1590AA2C, 0x06, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0x80, 1}, // wuchao modify, 20.12.29, for ESMT FM6BD2G1GXA(2A)
{0x2690AC2C, 0x54, 0xFFFFFFFF, 0x0, 0x20000000, 0, 4096, 0x00040000, 0xE0, 1},
{0x1590ACAD, 0, 0xFFFFFFFF, 0x0, 0x20000000, 0, 2048, 0x00020000, 0x80, 0},
{0x9590DC2C, 0x56, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0x40, 0},
{0x1590aa98, 0x76, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0x80, 1},
{0x1590aa98, 0x76, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0x80, 1}, /* NM1281KSLAXAJ-3B */
{0x2690A32C, 0x64, 0xFFFFFFFF, 0x0, 0x20000000, 0, 4096, 0x00040000, 0xE0, 1},
{0x2690AC98, 0x81676, 0xFFFFFFFF, 0x0, 0x20000000, 0, 4096, 0x00040000, 0xE0, 1},
{0x1590AAEF, 0, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0x40, 0}, /* Add by yangjihong for W20GF3FW*/
{0x1590AAC8, 0, 0xFFFFFFFF, 0X0, 0x10000000, 0, 2048, 0x00020000, 0x40, 0}, /* Add by wuchao, 16.08.30, for ESMT(FM6BD2G1GA) */
{0x1590AAEF, 0, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0x40, 0}, /* Add by yangjihong for W71NW20GF3FW*/
{0x1590AAC8, 0, 0xFFFFFFFF, 0x0, 0x10000000, 0, 2048, 0x00020000, 0x40, 0}, /* Add by wuchao, 16.08.30, for ESMT(FM6BD2G1GA) */
{0x1590AAAD, 0x46, 0xFFFFFFFF, 0X0, 0x10000000, 0, 2048, 0x00020000, 0x80, 0}, /* Add by wuchao, 17.12.29, for JSFBAB3YHABBG-425 */
{0x1590AA01, 0x46, 0xFFFFFFFF, 0X0, 0x10000000, 0, 2048, 0x00020000, 0x80, 0}, /* JSFBAB3YHABBG-425 */
/* Note: Width flag is 0 for 8 bit Flash and 1 for 16 bit flash */
};

7
bootable/recovery/install.c Normal file → Executable file
View File

@ -38,7 +38,7 @@
// Flash dsp*.mbn files included in the zip
/* [yangjihong] Update dsp image */
#define MAX_DSP_MBN_IMAGES 4
#define MAX_DSP_MBN_IMAGES 5
#define WLAN_MODEM_ZIP_PATH "firmware"
#define WLAN_MODEM_DEST_PATH "/firmware"
#define WLAN_MODEM_INFO_FILE "firmware/image/update_info"
@ -140,10 +140,11 @@ static bool install_mbns(const ZipArchive *zip)
"sbl1.mbn",
"appsboot.mbn",
"NON-HLOS.ubi",
"boot.img"
"boot.img",
"rpm.mbn"
};
const char *mbn_partitions[MAX_DSP_MBN_IMAGES] =
{"sbl", "aboot", "modem", "boot"};
{"sbl", "aboot", "modem", "boot", "rpm"};
const ZipEntry *mbn_entry;
const MtdPartition *part;

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,9 @@ ORIGIN_UPDATE_ZIP=../../../../oe-core/build/tmp-glibc/deploy/images/mdm9607/mdm9
OTA_TEST_ZIP=mdm9607-ota-target-image-ubi.zip
OUTPUT_ZIP=ota_test_tmp.zip
MODIFY_PRODUCT_FILE=SYSTEM/etc/default_config/product
#MODIFY_PRODUCT_FILE=SYSTEM/etc/default_config/product
CURRENT_PATH=`pwd`
MODIFY_PRODUCT_FILE=${CURRENT_PATH}/../../../../tp-product/product
RM_DATA_BIN=SYSTEM/usr/bin/smbd
# copy mdm9607-ota-target-image-ubi.zip
@ -21,6 +23,7 @@ pushd ${OTA_TEST_TMP_DIR}
FIRMWARE_VER=`cat ${MODIFY_PRODUCT_FILE} | grep -oP '(?<=option firmware_ver ")[\d\.]+'`
TEST_FIRMWARE_VER=`echo ${FIRMWARE_VER} | awk -F"." '{print $1 "." $2 "." expr $3 + 1}'`
PRODUCT_ID=`cat ${MODIFY_PRODUCT_FILE} | grep -oP '(?<=option product_id ")[\d\.]+'`
UPDATE_VER=`cat ${MODIFY_PRODUCT_FILE} | grep -oP '(?<=option update_ver ")[\d\.]+'`
# modify product (firmware_ver + 1)
sed -i "s/option firmware_ver \"${FIRMWARE_VER}\"/option firmware_ver \"${TEST_FIRMWARE_VER}\"/g" ${MODIFY_PRODUCT_FILE}
@ -35,7 +38,7 @@ zip ${OTA_TEST_ZIP} ${RM_DATA_BIN} -d
# produce compatibility.txt
COMPA_TXT=compatibility.txt
echo ${PRODUCT_ID}:${FIRMWARE_VER} > ${COMPA_TXT}
echo ${PRODUCT_ID}:${FIRMWARE_VER}:${UPDATE_VER} > ${COMPA_TXT}
./make_ota_package.sh ${OTA_TEST_ZIP} ${OUTPUT_ZIP} n n
OTE_TEST_ZIP=${FIRMWARE_VER}_${TEST_FIRMWARE_VER}.zip
@ -43,7 +46,7 @@ mv update.zip ${OTE_TEST_ZIP}
# produce compatibility.txt
COMPA_TXT=compatibility.txt
echo ${PRODUCT_ID}:0 > ${COMPA_TXT}
echo ${PRODUCT_ID}:0:${UPDATE_VER} > ${COMPA_TXT}
cp -f ${ORIGIN_UPDATE_ZIP} ./${OTA_TEST_ZIP}
./make_ota_package.sh origin_update.zip ${OTA_TEST_ZIP} n n

View File

@ -328,8 +328,8 @@
regulator-min-microvolt = <1>;
regulator-max-microvolt = <7>;
qcom,cpr-voltage-ceiling = <1350000 1350000 1350000>;
qcom,cpr-voltage-floor = <1350000 1350000 1350000>;
qcom,cpr-voltage-ceiling = <1050000 1225000 1350000>;
qcom,cpr-voltage-floor = <1050000 1050000 1350000>;
vdd-apc-supply = <&mdm9607_s1>;
vdd-mx-supply = <&mdm9607_l12_level_ao>;

2
kernel/drivers/i2c/busses/i2c-msm-v2.c Normal file → Executable file
View File

@ -2965,7 +2965,7 @@ static int i2c_msm_init(void)
{
return platform_driver_register(&i2c_msm_driver);
}
arch_initcall(i2c_msm_init);
subsys_initcall(i2c_msm_init);
static void i2c_msm_exit(void)
{

View File

@ -69,14 +69,20 @@ struct nand_flash_dev nand_flash_ids[] = {
{ .id = {0x98, 0xac, 0x90, 0x26, 0x76, 0x00, 0x00, 0x00} },
SZ_4K, SZ_512, SZ_256K, 0, 5, 128, NAND_ECC_INFO(8, SZ_512) },
{"MT29RZ2B1DZZHGSP 2G 1.8V 4-bit",
{ .id = {0x2c, 0xaa, 0x90, 0x15, 0x00, 0x00, 0x00, 0x00} },
SZ_2K, SZ_256, SZ_128K, 0, 4, 64, NAND_ECC_INFO(4, SZ_512) },
// Add by wuchao, 20.12.29, for ESMT FM6BD2G1GXA, this flash support ONFI, info here will not be used
{"FM6BD2G1GXA 2G 1.8V 8-bit",
{ .id = {0x2c, 0xaa, 0x90, 0x15, 0x06, 0x00, 0x00, 0x00} },
SZ_2K, SZ_256, SZ_128K, 0, 5, 128, NAND_ECC_INFO(8, SZ_512) },
{"KSLCMAL2TA0M2A 2G 1.8V 8-bit",
{ .id = {0x98, 0xaa, 0x90, 0x15, 0x00, 0x00, 0x00, 0x00} },
SZ_2K, SZ_256, SZ_128K, 0, 4, 128, NAND_ECC_INFO(8, SZ_512)},
// Add by wuchao, 20.12.29, for ESMT FM6BD2G1GA, this flash does not support ONFI
{"FM6BD2G1GA 2G 1.8V 8-bit",
{ .id = {0xc8, 0xaa, 0x90, 0x15, 0x00, 0x00, 0x00, 0x00} },
SZ_2K, SZ_256, SZ_128K, 0, 4, 64, NAND_ECC_INFO(4, SZ_512)},
LEGACY_ID_NAND("NAND 4MiB 5V 8-bit", 0x6B, 4, SZ_8K, SP_OPTIONS),
LEGACY_ID_NAND("NAND 4MiB 3,3V 8-bit", 0xE3, 4, SZ_8K, SP_OPTIONS),
LEGACY_ID_NAND("NAND 4MiB 3,3V 8-bit", 0xE5, 4, SZ_8K, SP_OPTIONS),
@ -206,6 +212,7 @@ struct nand_manufacturers nand_manuf_ids[] = {
{NAND_MFR_INTEL, "Intel"},
{NAND_MFR_WINBOND, "Winbond"},
{NAND_MFR_ESMT, "ESMT"},
{NAND_MFR_ESMT2, "ESMT"},
{0x0, "Unknown"}
};

View File

@ -52,12 +52,16 @@ typedef unsigned int boolean;
#define FALSE 0
#endif
#define ID_GC9106 0x9106
#define ID_GC9104 0x9104
// reset
static int lcd_s90319_rsx;
static int lcd_s90319_cs;
static int lcd_s90319_boost_en;
static unsigned int lcd_id = 0;
enum GPIO_LCD_S90319 {
GPIO_LCD_CS = 0,
GPIO_LCD_RESET,
@ -65,6 +69,8 @@ enum GPIO_LCD_S90319 {
GPIO_LCD_RSX,
GPIO_LCD_VDD0,
GPIO_LCD_VDD1,
GPIO_LCD_MOSI,
GPIO_LCD_CLK,
GPIO_LCD_END,
};
@ -76,7 +82,8 @@ static const char *dts_gpio_name[] = {
[GPIO_LCD_RSX] = "qcom,oled-rsx-gpio",
[GPIO_LCD_VDD0] = "qcom,oled-vdd0-gpio",
[GPIO_LCD_VDD1] = "qcom,oled-vdd1-gpio",
[GPIO_LCD_MOSI] = "qcom,oled-mosi-gpio",
[GPIO_LCD_CLK] = "qcom,oled-clk-gpio",
[GPIO_LCD_END] = "",
};
@ -98,8 +105,6 @@ static struct spi_device *s90319_spi;
static uint8_t frame_data[COLUMN_NUM * ROW_NUM * 2] ={0};
static uint8_t frame_data_buf[COLUMN_NUM * ROW_NUM * 2] ={0};
static int lcd_s90319_rsx;
static struct mutex flush_mutex;
static struct mutex oled_panel_mutex;
@ -304,7 +309,6 @@ static int s90319_spi_txdata(uint8_t *txdata, const uint16_t length)
return spi_sync(s90319_spi, &spi_msg);
}
/************************************************************
Function : s90319_spi_write_cmd
Description: transfer cmd by spi
@ -393,7 +397,6 @@ void wr_dat(uint8_t data)
s90319_spi_write_data(&data, 1);
}
/************************************************************
Function : oled_s90319_fill_with_pic
Description: write pic data on location assign
@ -415,8 +418,17 @@ static int oled_s90319_fill_with_pic(const uint8_t *pic, const uint8_t x,
oled_s90319_set_col_addr[1] = x + X_OFFSET;
oled_s90319_set_col_addr[3] = x + width - 1 + X_OFFSET;
if (lcd_id == ID_GC9106 || lcd_id == ID_GC9104)
{
oled_s90319_set_row_addr[1] = y + Y_OFFSET_GC9106;
oled_s90319_set_row_addr[3] = y + height - 1 + Y_OFFSET_GC9106;
}
else
{
oled_s90319_set_row_addr[1] = y + Y_OFFSET;
oled_s90319_set_row_addr[3] = y + height - 1 + Y_OFFSET;
}
for (i = 0; i < height; i++){
for (j = 0; j < width * 2; j++)
@ -468,31 +480,240 @@ static void s90319fb_fillrect(struct fb_info *info, const struct fb_fillrect *re
oled_s90319_fill_with_pic(info->screen_base, x, y, width, height);
}
static void lcd_s90319_panel_init(void)
/*******************************************************************************
Function : spi_start
Description : Start or restart spi communication
Input : None
Output : None
Return : None
Others : None
*******************************************************************************/
void spi_start(void)
{
/* End Reset Sequence */
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_CS], 0);
//oled_udelay(SPI_SPEED_DURATION);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CS], 0);/* start condition */
//oled_udelay(SPI_SPEED_DURATION);
}
/*******************************************************************************
Function : spi_stop
Description : stop spi communication
Input : None
Output : None
Return : None
Others : None
*******************************************************************************/
void spi_stop(void)
{
//gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CS], 1); /* stop condition */
//oled_udelay(SPI_SPEED_DURATION);
}
/*******************************************************************************
Function : s90319_spi_txdata_byte
Description : Transfer data, from baseband chip to spi device.
Input : data: Data to transfer
Output : None
Return : None
Others : None
*******************************************************************************/
void s90319_spi_txdata_byte(uint8_t data)
{
int i = 0;
for(i = 7; (i >= 0)&&(i <= 7); i--) {
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CLK], 0);
//oled_udelay(SPI_SPEED_DURATION);
if(i == 7) {
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_MOSI], 0);
}
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_MOSI], (data >> i) & 0x01);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CLK], 1);
}
return;
}
int spi_txdata_by_gpio(uint8_t *txdata, const uint16_t length, int compress)
{
uint8_t j;
signed char m;
uint8_t data;
uint8_t data_first;
uint8_t data_second;
spi_start();
if (compress){
for(j = 0; j < length; j++, txdata++) {
data = *txdata;
for(m = 7; (m >= 0)&&(m <= 7); m--)
{
if((data >> m) & 0x01)
{
data_first = 0x00;
data_second = 0x00;
}
else
{
data_first = 0xFF;
data_second = 0xFF;
}
s90319_spi_txdata_byte(data_first);
s90319_spi_txdata_byte(data_second);
}
}
}
else
{
for(j = 0; j < length; j++, txdata++) {
s90319_spi_txdata_byte(*txdata);
}
}
spi_stop();
return 0;
}
/*******************************************************************************
Function : spi_write_cmd_by_gpio
Description : Transfer cmd.
Input : data: cmd to transfer
len: length of cmd
Output : None
Return : None
Others : None
*******************************************************************************/
int spi_write_cmd_by_gpio(const uint8_t *data, const uint16_t len)
{
int rc = 0;
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 0);
mdelay(1);
memcpy(frame_data, data, len);
rc = spi_txdata_by_gpio(frame_data, len, FALSE);
return rc;
}
/*******************************************************************************
Function : wr_comm
Description : write init cmd.
Input :
Output : None
Return : None
Others : None
*******************************************************************************/
void wr_comm_by_gpio(uint8_t cmd)
{
spi_write_cmd_by_gpio(&cmd, 1);
}
void oled_gpio_spi_config(void)
{
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_MOSI], 0);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_CS], 0);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_BOOST_EN], 0);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_RESET], 0);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_CLK], 0);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_VDD0], 0);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_VDD1], 0);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_RSX], 0);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_VDD0], 1);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_VDD1], 1);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CS], 0);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 0);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RESET], 1);
mdelay(120);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RESET], 0);
mdelay(100);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RESET], 1);
mdelay(120);
}
unsigned int oled_read_data(int num)
{
unsigned int i=0, dat=0;
for(i=0;i<num;i++)
{
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CLK], 0);
gpio_direction_input(lcd_s90319_gpio[GPIO_LCD_MOSI]);
dat=(dat<<1)|gpio_get_value(lcd_s90319_gpio[GPIO_LCD_MOSI]);
gpio_direction_output(lcd_s90319_gpio[GPIO_LCD_MOSI], 1);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CLK], 1);
}
//printk("dat:%x\n", dat);
return dat;
}
unsigned int get_lcd_id(void)
{
unsigned int id=0, id1=0, id2=0, id3=0;
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CS], 0);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 0);
wr_comm_by_gpio(0xda);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 1);
id1=oled_read_data(8);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 0);
wr_comm_by_gpio(0xdb);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 1);
id2=oled_read_data(8);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 0);
wr_comm_by_gpio(0xdc);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_RSX], 1);
id3=oled_read_data(8);
gpio_set_value(lcd_s90319_gpio[GPIO_LCD_CS], 1);
id = id1<<16|id2<<8|id3;
printk("id:%x\n", id);
return id;
}
/*******************************************************************************
Function : oled_st7735t_init
Description : init oled panel.
Input :
Output : None
Return : None
Others : None
*******************************************************************************/
static void oled_st7735t_init(void)
{
/* End ST7735T Reset Sequence */
wr_comm(0x11); //Sleep out
mdelay (120); //Delay 120ms
/* Frame Rate */
/* ST7735T Frame Rate */
wr_comm(0xB1);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
wr_dat(0x01);
wr_dat(0x24);
wr_dat(0x24);
wr_comm(0xB2);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
wr_dat(0x01);
wr_dat(0x24);
wr_dat(0x24);
wr_comm(0xB3);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
/* End Frame Rate */
wr_dat(0x01);
wr_dat(0x24);
wr_dat(0x24);
wr_dat(0x01);
wr_dat(0x24);
wr_dat(0x24);
/* End ST7735T Frame Rate */
wr_comm(0xB4); //Column inversion
wr_dat(0x07);
/* Power Sequence */
wr_dat(0x01);
/* ST7735T Power Sequence */
wr_comm(0xC0);
wr_dat(0xC8);
wr_dat(0x08);
@ -508,12 +729,12 @@ static void lcd_s90319_panel_init(void)
wr_comm(0xC4);
wr_dat(0x8A);
wr_dat(0xEE);
/* End Power Sequence*/
/* End ST7735T Power Sequence */
wr_comm(0xC5); //VCOM
wr_dat(0x0C);
wr_dat(0x22);
wr_comm(0x36); //MX, MY, RGB mode
wr_dat(0xc8);
/* Gamma Sequence */
/* ST7735T Gamma Sequence */
wr_comm(0xE0);
wr_dat(0x05);
wr_dat(0x1A);
@ -548,7 +769,7 @@ static void lcd_s90319_panel_init(void)
wr_dat(0x00);
wr_dat(0x03);
wr_dat(0x12);
/* End Gamma Sequence */
/* End ST7735T Gamma Sequence */
wr_comm(0x3A); //65k mode
wr_dat(0x05);
@ -563,11 +784,213 @@ static void lcd_s90319_panel_init(void)
wr_dat(0x03);
wr_dat(0x00);
wr_dat(0x82);
wr_comm(0x29); //Display on
wr_comm(0x2C);
}
/*******************************************************************************
Function : oled_st7735s_init
Description : init oled panel.
Input :
Output : None
Return : None
Others : None
*******************************************************************************/
static void oled_st7735s_init(void)
{
/* End ST7735S Reset Sequence */
wr_comm(0x11); //Sleep out
mdelay (120); //Delay 120ms
/* ST7735S Frame Rate */
wr_comm(0xB1);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
wr_comm(0xB2);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
wr_comm(0xB3);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
wr_dat(0x05);
wr_dat(0x3A);
wr_dat(0x3A);
/* End ST7735S Frame Rate */
wr_comm(0xB4); //Column inversion
wr_dat(0x07);
/* ST7735S Power Sequence */
wr_comm(0xC0);
wr_dat(0xC8);
wr_dat(0x08);
wr_dat(0x84);
wr_comm(0xC1);
wr_dat(0XC5);
wr_comm(0xC2);
wr_dat(0x0A);
wr_dat(0x00);
wr_comm(0xC3);
wr_dat(0x8A);
wr_dat(0x2A);
wr_comm(0xC4);
wr_dat(0x8A);
wr_dat(0xEE);
/* End ST7735S Power Sequence */
wr_comm(0xC5); //VCOM
wr_dat(0x0C);
wr_comm(0x36); //MX, MY, RGB mode
wr_dat(0xc8);
/* ST7735S Gamma Sequence */
wr_comm(0xE0);
wr_dat(0x05);
wr_dat(0x1A);
wr_dat(0x0C);
wr_dat(0x0E);
wr_dat(0x3A);
wr_dat(0x34);
wr_dat(0x2D);
wr_dat(0x2F);
wr_dat(0x2D);
wr_dat(0x2A);
wr_dat(0x2F);
wr_dat(0x3C);
wr_dat(0x00);
wr_dat(0x01);
wr_dat(0x02);
wr_dat(0x10);
wr_comm(0xE1);
wr_dat(0x04);
wr_dat(0x1B);
wr_dat(0x0D);
wr_dat(0x0E);
wr_dat(0x2D);
wr_dat(0x29);
wr_dat(0x24);
wr_dat(0x29);
wr_dat(0x28);
wr_dat(0x26);
wr_dat(0x31);
wr_dat(0x3B);
wr_dat(0x00);
wr_dat(0x00);
wr_dat(0x03);
wr_dat(0x12);
/* End ST7735S Gamma Sequence */
wr_comm(0x3A); //65k mode
wr_dat(0x05);
wr_comm(0x2a);
wr_dat(0x00);
wr_dat(0x02);
wr_dat(0x00);
wr_dat(0x81);
wr_comm(0x2b);
wr_dat(0x00);
wr_dat(0x03);
wr_dat(0x00);
wr_dat(0x82);
wr_comm(0x29); //Display on
wr_comm(0x2C);
}
#if 0
static void oled_gc9106_init(void)
{
wr_comm(0xfe);
wr_comm(0xfe);
wr_comm(0xef);
wr_comm(0xb3);
wr_dat(0x03);
wr_comm(0x21);
wr_comm(0x36);
wr_dat(0xd8);///
wr_comm(0x3a);
wr_dat(0x05);
wr_comm(0xb4);
wr_dat(0x21);
//====================
wr_comm(0xb1);
wr_dat(0xc0);//e6_en e7_en
wr_comm(0xe6);
wr_dat(0x50);//50
wr_dat(0x43);
wr_comm(0xe7);
wr_dat(0x56);//38 62
wr_dat(0x43);
//=================
wr_comm(0xF0);
wr_dat(0x0B);
wr_dat(0x4D);
wr_dat(0x1B);
wr_dat(0x5E);
wr_dat(0x8C);
wr_dat(0x2C);
wr_dat(0x2D);
wr_dat(0x00);
wr_dat(0x00);
wr_dat(0x10);
wr_dat(0x12);
wr_dat(0x15);
wr_dat(0x14);
wr_dat(0x0F);
wr_comm(0xF1);
wr_dat(0x01);
wr_dat(0x28);
wr_dat(0x2D);
wr_dat(0x3A);
wr_dat(0xB8);
wr_dat(0x0D);
wr_dat(0x0E);
wr_dat(0x00);
wr_dat(0x00);
wr_dat(0x08);
wr_dat(0x08);
wr_dat(0x18);
wr_dat(0x16);
wr_dat(0x0F);
wr_comm(0xfe);
wr_comm(0xff);
wr_comm(0x2a);
wr_dat(0x00);
wr_dat(0x02);
wr_dat(0x00);
wr_dat(0x81);
wr_comm(0x2b);
wr_dat(0x00);
wr_dat(0x01);
wr_dat(0x00);
wr_dat(0x80);
wr_comm(0x11);
wr_comm(0x29);
mdelay(120);
wr_comm(0x2c);
}
#endif
static void lcd_s90319_panel_init(void)
{
if (lcd_id == 0x7C89F0)
{
oled_st7735s_init();
}
else
{
oled_st7735t_init();
}
}
/************************************************************
Function : s90319_disp_on
@ -637,13 +1060,15 @@ static void s90319_disp_powerup(void)
s90319_state.disp_powered_up = TRUE;
oled_s90319_power_save(1);
oled_gpio_spi_config();
lcd_id = get_lcd_id();
gpio_direction_output(lcd_s90319_cs, 0);
/* 1 data, 0 command*/
gpio_direction_output(lcd_s90319_rsx, 0);
mdelay(5);
gpio_set_value_cansleep(lcd_s90319_cs, 0);
mdelay(3);
}
}
@ -714,8 +1139,17 @@ static void s90319fb_clear_screen (const struct fb_fillrect *rect)
oled_s90319_set_col_addr[1] = x + X_OFFSET;
oled_s90319_set_col_addr[3] = x + width - 1 + X_OFFSET;
if (lcd_id == ID_GC9106 || lcd_id == ID_GC9104)
{
oled_s90319_set_row_addr[1] = y + Y_OFFSET_GC9106;
oled_s90319_set_row_addr[3] = y + height - 1 + Y_OFFSET_GC9106;
}
else
{
oled_s90319_set_row_addr[1] = y + Y_OFFSET;
oled_s90319_set_row_addr[3] = y + height - 1 + Y_OFFSET;
}
for (i = 0; i < height; i++){
for (j = 0; j < width * 2; j++)
@ -786,7 +1220,7 @@ static int __init s90319fb_map_fb_memory(struct fb_info *info)
}
/*******************************************************************************
Function : s90319fb_unmap_video_memory
Function : s90319fb_unmap_vdeo_memory
Description : Free the DRAM memory of the frame buffer.
Input : info: Frame buffer structure.
Output : None

View File

@ -48,6 +48,7 @@ struct s90319fb_display {
#define X_OFFSET 2
#define Y_OFFSET 3
#define Y_OFFSET_GC9106 1
uint8_t oled_s90319_set_col_addr[] = {
0x00, 0x00, 0x00, 0x00

View File

@ -243,6 +243,15 @@ config MP2617_CHARGER
The MP2617 charger chip is a charging solution. This driver supports
enabling and disabling charging, setting the input current limit.
config BQ25601_CHARGER
tristate "TI BQ25601 Battery Charger"
help
The BQ25601 device is a highly-integrated 3-A switch-mode battery charge
management and system power path management device for single cell Li-Ion
and Li-polymer battery. The low impedance power path optimizes switch-mode
operation efficiency, reduces battery charging time and extends battery
life during discharging phase.
config CHARGER_PCF50633
tristate "NXP PCF50633 MBC"
depends on MFD_PCF50633

View File

@ -38,6 +38,7 @@ obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o
obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
obj-$(CONFIG_MP2617_CHARGER) += mp2617-charger.o
obj-$(CONFIG_BQ25601_CHARGER) += bq25601-charger.o
obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o
obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o

File diff suppressed because it is too large Load Diff

View File

@ -725,6 +725,7 @@ struct nand_chip {
#define NAND_MFR_INTEL 0x89
#define NAND_MFR_WINBOND 0xef
#define NAND_MFR_ESMT 0xc8
#define NAND_MFR_ESMT2 0x2c
/* The maximum expected count of bytes in the NAND ID sequence */
#define NAND_MAX_ID_LEN 8

2
kernel/include/linux/netdevice.h Normal file → Executable file
View File

@ -1220,6 +1220,7 @@ enum netdev_priv_flags {
IFF_LIVE_ADDR_CHANGE = 1<<20,
IFF_MACVLAN = 1<<21,
IFF_XMIT_DST_RELEASE_PERM = 1<<22,
IFF_WAN_DEV = 1<<23,
};
#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@ -1245,6 +1246,7 @@ enum netdev_priv_flags {
#define IFF_LIVE_ADDR_CHANGE IFF_LIVE_ADDR_CHANGE
#define IFF_MACVLAN IFF_MACVLAN
#define IFF_XMIT_DST_RELEASE_PERM IFF_XMIT_DST_RELEASE_PERM
#define IFF_WAN_DEV IFF_WAN_DEV
/**
* struct net_device - The DEVICE structure.

16
kernel/net/core/dev.c Normal file → Executable file
View File

@ -175,6 +175,13 @@ static int call_netdevice_notifiers_info(unsigned long val,
DEFINE_RWLOCK(dev_base_lock);
EXPORT_SYMBOL(dev_base_lock);
//[zhangguosong start] 2018-05-07
/*
*brief WAN的流量均设置数据包的mark字段
*/
#define MASK_FOR_WAN2LAN (0x00008000)
//[zhangguosong end]
/* protects napi_hash addition/deletion and napi_gen_id */
static DEFINE_SPINLOCK(napi_hash_lock);
@ -3412,6 +3419,14 @@ static int netif_rx_internal(struct sk_buff *skb)
net_timestamp_check(netdev_tstamp_prequeue, skb);
trace_netif_rx(skb);
//[zhangguosong start] 2018-05-07 for mark downstream (traffic from wan interface)
if (skb->dev && (skb->dev->priv_flags & IFF_WAN_DEV))
{
skb->mark |= MASK_FOR_WAN2LAN;
}
//[zhangguosong end]
#ifdef CONFIG_RPS
WARN_ONCE(skb_cloned(skb), "Cloned packet from dev %s\n",
skb->dev->name);
@ -5621,6 +5636,7 @@ void dev_set_rx_mode(struct net_device *dev)
netif_addr_unlock_bh(dev);
}
/**
* dev_get_flags - get flags reported to userspace
* @dev: device

44
kernel/net/core/dev_ioctl.c Normal file → Executable file
View File

@ -17,6 +17,35 @@
* match. --pb
*/
#define SIOCSIFPRIVFLAGS 0x89ba //set device priv_flags
#define SIOCGIFPRIVFLAGS 0x89bb //get device priv_flags
//[zhangguosong start] 2018-06-20
static unsigned int dev_get_privflags(const struct net_device *dev)
{
return dev->priv_flags;
}
static unsigned int dev_change_privflags(struct net_device *dev, unsigned int flags)
{
int old_flags = dev->priv_flags;
if ((old_flags ^ flags) & IFF_WAN_DEV)
{
if (old_flags & IFF_WAN_DEV)
{
dev->priv_flags &= ~IFF_WAN_DEV;
}
else
{
dev->priv_flags |= IFF_WAN_DEV;
}
}
return 0;
}
//[zhangguosong end]
static int dev_ifname(struct net *net, struct ifreq __user *arg)
{
struct ifreq ifr;
@ -115,6 +144,7 @@ static int dev_ifconf(struct net *net, char __user *arg)
return copy_to_user(arg, &ifc, sizeof(struct ifconf)) ? -EFAULT : 0;
}
#define ifr_iflags ifr_ifru.ifru_ivalue /* add by zhangguosong, for traffic control module */
/*
* Perform the SIOCxIFxxx calls, inside rcu_read_lock()
*/
@ -127,6 +157,10 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm
return -ENODEV;
switch (cmd) {
//[zhangguosong start]
case SIOCGIFPRIVFLAGS: /* Get interface priv_flags */
ifr->ifr_iflags = dev_get_privflags(dev);
//[zhangguosng end]
case SIOCGIFFLAGS: /* Get interface flags */
ifr->ifr_flags = (short) dev_get_flags(dev);
return 0;
@ -248,6 +282,10 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
ops = dev->netdev_ops;
switch (cmd) {
//[zhangguosong start] 2018-06-20
case SIOCSIFPRIVFLAGS:
return dev_change_privflags(dev, ifr->ifr_iflags);
//[zhangguosong end]
case SIOCSIFFLAGS: /* Set interface flags */
return dev_change_flags(dev, ifr->ifr_flags);
@ -427,6 +465,9 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
* - atomic and do not require locking.
* - return a value
*/
//[zhangguosong start]
case SIOCGIFPRIVFLAGS:
//[zhangguosong end]
case SIOCGIFFLAGS:
case SIOCGIFMETRIC:
case SIOCGIFMTU:
@ -503,6 +544,9 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
* - require strict serialization.
* - do not return a value
*/
//[zhangguosong start] 2018-06-20
case SIOCSIFPRIVFLAGS:
//[zhangguosong end]
case SIOCSIFFLAGS:
case SIOCSIFMETRIC:
case SIOCSIFMTU:

2
oe-core/build/conf/bblayers.conf Normal file → Executable file
View File

@ -7,4 +7,4 @@ export WORKSPACE := "${@os.path.abspath(os.path.join(os.path.dirname(bb.data.get
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS = "/home/mobile/Work/mifi/M7350v5_en_gpl/M7350v5_en_gpl/oe-core/meta-tp /home/mobile/Work/mifi/M7350v5_en_gpl/M7350v5_en_gpl/oe-core/meta-msm /home/mobile/Work/mifi/M7350v5_en_gpl/M7350v5_en_gpl/oe-core/meta"
BBLAYERS = "/home/bba/projects/dev/M7350v7/M7350v7_en_gpl/oe-core/meta-tp /home/bba/projects/dev/M7350v7/M7350v7_en_gpl/oe-core/meta-msm /home/bba/projects/dev/M7350v7/M7350v7_en_gpl/oe-core/meta"

3
oe-core/build/conf/sanity_info Executable file
View File

@ -0,0 +1,3 @@
SANITY_VERSION 1
TMPDIR /home/bba/projects/dev/M7350v7/M7350v7_en_gpl/oe-core/build/tmp-glibc
SSTATE_DIR /home/bba/projects/dev/M7350v7/M7350v7_en_gpl/oe-core/build/sstate-cache

0
oe-core/build/conf/templateconf.cfg Normal file → Executable file
View File

22
oe-core/build/conf/tp_set_bb_env.sh Normal file → Executable file
View File

@ -1,4 +1,4 @@
PRODUCT_CHOICES=(m7350v5)
PRODUCT_CHOICES=(m7350v6)
BUILD_TYPE_CHOICES=(release debug)
export TARGET_BOARD=mdm9607
@ -200,6 +200,8 @@ function copy_kernel_dts_and_defconfig()
local PRODUCT_KERNEL_DEFCONFIG_FILE=tp-product/${TARGET_PRODUCT}/kernel/mdm9607_defconfig
local PRODUCT_KERNEL_PATCH_FILE=tp-product/${TARGET_PRODUCT}/kernel/kernel_diff.patch
local DEBUG_DEFCONFIG_FILE=${WS}/kernel/arch/arm/configs/mdm9607_debug_defconfig
local PRODUCT_QCN_FILE=${WS}/tp-proprietary/qcn/factory.xqcn
local PRODUCT_QCN_DIR=${WS}/tp-proprietary/qcn/${TARGET_PRODUCT}
:<<mark
if [ -d ${WS}/${PRODUCT_KERNEL_DTS_DIR} ] ; then
@ -221,6 +223,22 @@ mark
if [ "${TARGET_BUILD_TYPE}" = "debug" ] ; then
cat ${DEBUG_DEFCONFIG_FILE} >> ${WS}/kernel/arch/arm/configs/mdm9607_defconfig
fi
cp ${PRODUCT_QCN_DIR}/*.xqcn ${PRODUCT_QCN_FILE}
cp ${WS}/tp-product/${TARGET_PRODUCT}/config/product ${WS}/tp-product/product
}
function create_firmware_id()
{
local PRODUCT_FILE=${WS}/tp-product/${TARGET_PRODUCT}/config/product
local PRODUCT_FILE_TMP=${WS}/tp-product/product_tmp
echo "---------------------------------------------------------"
echo " generate firmware_id"
echo "---------------------------------------------------------"
${WS}/oe-core/build/conf/gen_firmware_id.sh ${PRODUCT_FILE} ${PRODUCT_FILE_TMP}
cat ${PRODUCT_FILE}
}
function choosecombo()
@ -270,6 +288,8 @@ function rpp () {
function build()
{
create_firmware_id
if check_config
then
echo "Your environment is set, please check if it is right."

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -12,6 +12,7 @@
# - saves some time
# - saves memory
server.modules = (
"mod_expire",
# "mod_rewrite",
"mod_redirect",
# "mod_alias",
@ -20,7 +21,7 @@ server.modules = (
# "mod_trigger_b4_dl",
# "mod_auth",
# "mod_status",
# "mod_setenv",
"mod_setenv",
# "mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
@ -30,7 +31,6 @@ server.modules = (
# "mod_compress",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_secdownload",
# "mod_rrdtool",
# "mod_webdav",
@ -119,6 +119,9 @@ mimetype.assign = (
#accesslog.filename = "/www/access.log"
#debug.log-request-handling = "enable"
###[pudongfang] add ipv6 support
$SERVER["socket"] == "[::]:80" {}
$HTTP["url"] =~ "/" {
server.document-root = "/WEBSERVER/www/"
#server.errorlog = "/www/lighttpd.error.log"
@ -154,6 +157,16 @@ $HTTP["url"] == "/" {
}
}
}
$HTTP["url"] =~ "/*.html" {
setenv.add-response-header = ( "Cache-Control" => "no-cache" )
}
$HTTP["url"] =~ "/*.css" {
expire.url = ( "" => "access 1 hours")
}
$HTTP["url"] =~ "/*.js" {
setenv.add-response-header = ( "Cache-Control" => "no-cache" )
}
expire.url = ( "/images/" => "access 1 hours")
##
# which extensions should not be handle via static-file transfer

View File

@ -15,6 +15,8 @@ RDEPENDS_${PN} += " \
lighttpd-module-auth \
lighttpd-module-redirect \
lighttpd-module-evasive \
lighttpd-module-expire \
lighttpd-module-setenv \
"
EXTRA_OECONF += " \
--with-openssl \

0
oe-core/meta-msm/recipes/linux-quic/linux-quic_git.bb Normal file → Executable file
View File

View File

@ -11,6 +11,8 @@ S = "${WORKDIR}/shortcut-fe/shortcut-fe"
FILES_${PN}="/etc/init.d/start_shortcut_fe_le"
EXTRA_OEMAKE += "${@base_conditional('TP_FEATURE_CLOUD', 'y', 'EXTRA_CFLAGS+=-DTP_FEATURE_CLOUD', '', d)}"
do_install() {
module_do_install
install -d ${D}${sysconfdir}/init.d

View File

@ -1,16 +0,0 @@
inherit autotools qcommon
DESCRIPTION = "WFA certification testing tool for QCA devices"
HOMEPAGE = "https://github.com/qca/sigma-dut"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/${LICENSE};md5=550794465ba0ec5312d6919e203a55f9"
PR = "r0"
SRC_DIR = "${WORKSPACE}/wlan/utils/sigma-dut/"
S = "${WORKDIR}/wlan/utils/sigma-dut"
do_install() {
make install DESTDIR=${D} BINDIR=${sbindir}/
}

View File

@ -10,8 +10,8 @@ FILESPATH =+ "${WORKSPACE}:"
SRC_URI = "file://${@d.getVar('SRC_DIR', True).replace('${WORKSPACE}/', '')}"
PV = "git-${GITSHA}"
LICENSE = "TPLink-Technologies-Inc.-Proprietary"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta-tp/files/tp-licenses/${LICENSE};md5=abd123e5a2e897447f2c177f6053913c"
LICENSE = "TPLink-Corporation-Limited.-Proprietary"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta-tp/files/tp-licenses/${LICENSE};md5=414f2f16c6966d51db8a805b26f9a907"
TP-PROPRIETARY = "${WORKSPACE}/tp-proprietary"
TP-OPENSOURCE = "${WORKSPACE}/tp-opensource"

View File

@ -5,4 +5,4 @@ BBFILE_PRIORITY_tp = "20"
BBFILE_PATTERN_tp := "^${LAYERDIR}/"
#LICENSE_PATH += "${LAYERDIR}/files/tp-licenses"
LICENSE_DIR .= "${LAYERDIR}/files/tp-licenses"
SPDXLICENSEMAP[TPLink-Technologies-Inc.-Proprietary] = "TPLink-Technologies-Inc.-Proprietary"
SPDXLICENSEMAP[TPLink-Corporation-Limited.-Proprietary] = "TPLink-Corporation-Limited.-Proprietary"

View File

@ -0,0 +1,2 @@
Copyright (c) 2020 TPLINK CORPORATION LIMITED. All Rights Reserved.
TP-Link Corporation Limited Proprietary and Confidential.

View File

@ -1,2 +0,0 @@
Copyright (c) 2015 TPLINK TECHNOLOGIES CO., LTD. All Rights Reserved.
TP-Link Technologies Proprietary and Confidential.

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,8 @@ SRCREV="393bc2b908ef44cb8b417126a35d4915c4cdfbc9"
SRC_URI = "git://nbd.name/uci.git;protocol=git \
file://hack_uci_save.patch \
file://unspport_lua.patch \
file://change_default_confdir.patch"
file://change_default_confdir.patch\
file://gdpr.patch"
S="${WORKDIR}/git"
@ -17,6 +18,13 @@ INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
PACKAGES = "${PN}"
DEPENDS = "libubox"
DEPENDS += "${@base_conditional('TP_FEATURE_GDPR', 'y', 'openssl', '', d)}"
DEPENDS += "${@base_conditional('TP_FEATURE_GDPR', 'y', 'system-core', '', d)}"
#RDEPENDS += "libubox"
inherit cmake
OECMAKE_C_FLAGS += "${@base_conditional('TP_FEATURE_GDPR', 'y', '-DTP_FEATURE_GDPR', '', d)}"

View File

@ -0,0 +1,2 @@
Copyright (c) 2020 TPLINK CORPORATION LIMITED. All Rights Reserved.
TP-Link Corporation Limited Proprietary and Confidential.

View File

@ -1,2 +0,0 @@
Copyright (c) 2015 TPLINK TECHNOLOGIES CO., LTD. All Rights Reserved.
TP-Link Technologies Proprietary and Confidential.

View File

@ -1,5 +1,3 @@
Upstream-Status: Pending
--- a/configure.ac
+++ b/configure.ac
@@ -281,7 +281,7 @@ dnl ************************************

View File

@ -0,0 +1,62 @@
DESCRIPTION = "Command line tool and library for client-side URL transfers."
HOMEPAGE = "http://curl.haxx.se/"
BUGTRACKER = "http://curl.haxx.se/mail/list.cgi?list=curl-tracker"
SECTION = "console/network"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;beginline=7;md5=3a34942f4ae3fbf1a303160714e664ac"
DEPENDS = "zlib gnutls"
DEPENDS_class-native = "zlib-native openssl-native"
DEPENDS_class-nativesdk = "nativesdk-zlib"
PR = "r0"
SRC_URI = "http://curl.haxx.se/download/curl-${PV}.tar.bz2 \
file://pkgconfig_fix.patch \
"
# curl likes to set -g0 in CFLAGS, so we stop it
# from mucking around with debug options
#
SRC_URI += " file://configure_ac.patch"
SRC_URI[md5sum] = "0db5ec03a5001b42a2edc03bf63b5ceb"
SRC_URI[sha256sum] = "6b1c410387bea82601baec85d6aa61955794672e36766407e99ade8d55aaaf11"
inherit autotools pkgconfig binconfig
EXTRA_OECONF = "--with-zlib=${STAGING_LIBDIR}/../ \
--without-libssh2 \
--with-random=/dev/urandom \
--without-libidn \
--enable-crypto-auth \
--disable-ldap \
--disable-ldaps \
${CURLGNUTLS} \
"
CURLGNUTLS = " --with-gnutls=${STAGING_LIBDIR}/../ --without-ssl"
CURLGNUTLS_class-native = "--without-gnutls --with-ssl"
CURLGNUTLS_class-nativesdk = "--without-gnutls --without-ssl"
do_configure_prepend() {
sed -i s:OPT_GNUTLS/bin:OPT_GNUTLS:g ${S}/configure.ac
}
PACKAGES =+ "${PN}-certs libcurl libcurl-dev libcurl-staticdev libcurl-doc"
FILES_${PN}-certs = "${datadir}/curl/curl-*"
PACKAGE_ARCH_${PN}-certs = "all"
FILES_lib${BPN} = "${libdir}/lib*.so.*"
RRECOMMENDS_lib${BPN} += "${PN}-certs"
FILES_lib${BPN}-dev = "${includedir} \
${libdir}/lib*.so \
${libdir}/lib*.la \
${libdir}/pkgconfig \
${datadir}/aclocal \
${bindir}/*-config"
FILES_lib${BPN}-staticdev = "${libdir}/lib*.a"
FILES_lib${BPN}-doc = "${mandir}/man3 \
${mandir}/man1/curl-config.1"
BBCLASSEXTEND = "native nativesdk"

View File

@ -1,59 +0,0 @@
SUMMARY = "Command line tool and library for client-side URL transfers"
HOMEPAGE = "http://curl.haxx.se/"
BUGTRACKER = "http://curl.haxx.se/mail/list.cgi?list=curl-tracker"
SECTION = "console/network"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;beginline=7;md5=3a34942f4ae3fbf1a303160714e664ac"
SRC_URI = "http://curl.haxx.se/download/curl-${PV}.tar.bz2 \
file://pkgconfig_fix.patch \
"
# curl likes to set -g0 in CFLAGS, so we stop it
# from mucking around with debug options
#
SRC_URI += " file://configure_ac.patch"
SRC_URI[md5sum] = "8d30594212e65657a5c32030f0998fa9"
SRC_URI[sha256sum] = "899109eb3900fa6b8a2f995df7f449964292776a04763e94fae640700f883fba"
inherit autotools pkgconfig binconfig multilib_header
PACKAGECONFIG ??= "${@bb.utils.contains("DISTRO_FEATURES", "ipv6", "ipv6", "", d)} gnutls zlib"
PACKAGECONFIG_class-native = "ipv6 ssl zlib"
PACKAGECONFIG_class-nativesdk = "ipv6 ssl zlib"
PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
PACKAGECONFIG[ssl] = "--with-ssl --with-random=/dev/urandom,--without-ssl,openssl"
PACKAGECONFIG[gnutls] = "--with-gnutls,--without-gnutls,gnutls"
PACKAGECONFIG[zlib] = "--with-zlib=${STAGING_LIBDIR}/../,--without-zlib,zlib"
PACKAGECONFIG[rtmpdump] = "--with-librtmp,--without-librtmp,rtmpdump"
PACKAGECONFIG[libssh2] = "--with-libssh2,--without-libssh2,libssh2"
PACKAGECONFIG[smb] = "--enable-smb,--disable-smb,samba"
EXTRA_OECONF = "--without-libidn \
--enable-crypto-auth \
--disable-ldap \
--disable-ldaps \
--with-ca-bundle=${sysconfdir}/ssl/certs/ca-certificates.crt \
"
do_install_append() {
oe_multilib_header curl/curlbuild.h
}
PACKAGES =+ "lib${BPN} lib${BPN}-dev lib${BPN}-staticdev lib${BPN}-doc"
FILES_lib${BPN} = "${libdir}/lib*.so.*"
RRECOMMENDS_lib${BPN} += "ca-certificates"
FILES_lib${BPN}-dev = "${includedir} \
${libdir}/lib*.so \
${libdir}/lib*.la \
${libdir}/pkgconfig \
${datadir}/aclocal \
${bindir}/*-config"
FILES_lib${BPN}-staticdev = "${libdir}/lib*.a"
FILES_lib${BPN}-doc = "${mandir}/man3 \
${mandir}/man1/curl-config.1"
BBCLASSEXTEND = "native nativesdk"

1
shortcut-fe/fast-classifier/fast-classifier.c Normal file → Executable file
View File

@ -1353,6 +1353,7 @@ static const struct device_attribute fast_classifier_debug_info_attr =
static const struct device_attribute fast_classifier_skip_bridge_ingress =
__ATTR(skip_to_bridge_ingress, S_IWUGO | S_IRUGO, fast_classifier_get_skip_bridge_ingress, fast_classifier_set_skip_bridge_ingress);
/*
* fast_classifier_init()
*/

1
shortcut-fe/shortcut-fe/Makefile Normal file → Executable file
View File

@ -35,6 +35,7 @@ shortcut-fe-cm-objs := \
sfe_cm.o
ccflags-y += -D__CHECK_ENDIAN__
ccflags-y += -DSFE_CONFIG_MARK
CDEFINES += -D__CHECK_ENDIAN__

0
shortcut-fe/shortcut-fe/sfe.h Normal file → Executable file
View File

98
shortcut-fe/shortcut-fe/sfe_cm.c Normal file → Executable file
View File

@ -30,6 +30,12 @@
#include <net/netfilter/nf_conntrack_core.h>
#include <linux/if_bridge.h>
//[zhangguosong start]
#ifdef TP_FEATURE_WLANTC
#include <linux/netfilter_ipv4.h>
#endif
//[zhangguosong end]
#include "sfe.h"
#include "sfe_cm.h"
#include "sfe_backport.h"
@ -551,6 +557,20 @@ static unsigned int sfe_cm_post_routing(struct sk_buff *skb, int is_v4)
sic.dest_port = orig_tuple.dst.u.udp.port;
sic.src_port_xlate = reply_tuple.dst.u.udp.port;
sic.dest_port_xlate = reply_tuple.src.u.udp.port;
//[zhangguosong start] 2018-06-21
/* Do not use package from reply to build sfe connection */
if (likely(is_v4))
{
struct iphdr* iph = ip_hdr(skb);
if (iph && ntohl(iph->saddr) != ntohl(sic.src_ip_xlate.ip)
&& ntohl(iph->saddr) != ntohl(sic.src_ip.ip))
{
DEBUG_TRACE("%s: Ignore reply package\n", __FUNCTION__);
return NF_ACCEPT;
}
}
//[zhangguosong end]
break;
default:
@ -665,9 +685,34 @@ static unsigned int sfe_cm_post_routing(struct sk_buff *skb, int is_v4)
sic.src_dev = src_dev_use;
sic.dest_dev = dest_dev_use;
//[zhangguosong start] 2018-07-30
/* Fix#241362
* : DMZ主机时,,
* : ,conntrack中origin_tuple的src_ip为外部客户端,ip地址
* ,,SFE依然
* 使SFE快速转发规则,Mark标记,.
* : 1. SpeedTest的修改;
* 2. SFE转发规则之前对skb中的mark标记进行判断,wan2lan标记(0x00008000),
* ,;
*/
DEBUG_TRACE("%s: sic.src_dev->name = %s\n", __FUNCTION__, sic.src_dev->name);
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
if (skb->mark & MASK_FOR_WAN2LAN)
{
DEBUG_TRACE("%s: Download link package, ignore it.\n", __FUNCTION__);
return NF_ACCEPT;
}
//[zhangguosong end]
sic.src_mtu = src_dev_use->mtu;
sic.dest_mtu = dest_dev_use->mtu;
//[zhangguosong start] 2018-05-08 get mark
sic.mark = ct->mark;
sic.mark |= (skb->mark & 0x8FFF);
//sic.mark |= skb->mark;
//[zhangguosong end]
if (likely(is_v4)) {
if (sfe_ipv4_create_rule(&sic) == 0) {
ct->sfe_entry = (void *)(&sic);
@ -1008,6 +1053,50 @@ static ssize_t sfe_cm_get_exceptions(struct device *dev,
*/
static const struct device_attribute sfe_cm_exceptions_attr =
__ATTR(exceptions, S_IRUGO, sfe_cm_get_exceptions, NULL);
#ifdef TP_FEATURE_CLOUD
int do_sfe_cloud_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
{
int ret = 0;
int status = 1;
printk("%s: hande msg: %d\n", __FUNCTION__, cmd);
switch(cmd)
{
case SFE_ENABLE_CLOUD_BLCOK:
if (NULL == user || len != 4)
{
printk("%s: invalid params.", __FUNCTION__);
ret = -1;
break;
}
copy_from_user(&status, user, len);
printk("%s: sfe change cloud block status to %d.", __FUNCTION__, status);
sfe_update_enable_block_status(status);
break;
default:
DEBUG_ERROR("Receive an unknown set ctl command. cmd = %d\n", cmd);
ret = -1;
break;
}
return ret;
}
int do_sfe_cloud_get_ctl(struct sock* sk, int cmd, void __user *user, int *len)
{
return 0;
}
static struct nf_sockopt_ops cloud_sockopts = {
.pf = PF_INET,
.set_optmin = SFE_CLOUD_BASE_CTL,
.set_optmax = SFE_CLOUD_SET_MAX+1,
.set = do_sfe_cloud_set_ctl,
.get_optmin = SFE_CLOUD_BASE_CTL,
.get_optmax = SFE_CLOUD_GET_MAX+1,
.get = do_sfe_cloud_get_ctl,
};
#endif
/*
* sfe_cm_init()
@ -1056,7 +1145,16 @@ static int __init sfe_cm_init(void)
DEBUG_ERROR("can't register nf post routing hook: %d\n", result);
goto exit3;
}
#ifdef TP_FEATURE_CLOUD
result = nf_register_sockopt(&cloud_sockopts);
if (result < 0)
{
DEBUG_ERROR("can't register nf sockopts for cloud: %d\n", result);
goto exit3;
}
#endif
printk("%s: sfe register sockopt success.", __FUNCTION__);
spin_lock_init(&sc->lock);
/*

36
shortcut-fe/shortcut-fe/sfe_cm.h Normal file → Executable file
View File

@ -15,6 +15,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <linux/spinlock.h>
/*
* connection flags.
*/
@ -27,6 +29,13 @@
#define SFE_SUPPORT_IPV6
#endif
//for test
#ifndef TP_FEATURE_WLANTC
#define TP_FEATURE_WLANTC
#endif
/*
* IPv6 address structure
*/
@ -165,6 +174,29 @@ struct sfe_connection_mark {
uint32_t mark;
};
#ifdef TP_FEATURE_CLOUD
#define SFE_CLOUD_BASE_CTL 512
#define SFE_ENABLE_CLOUD_BLCOK (SFE_CLOUD_BASE_CTL)
#define SFE_CLOUD_SET_MAX (SFE_ENABLE_CLOUD_BLCOK)
#define SFE_CLOUD_GET_MAX (SFE_CLOUD_BASE_CTL)
#endif
//[zhangguosong start]
#ifdef TP_FEATURE_WLANTC
#define MAX_TC_RULES_NUM 20
/*
* brief: this marco is used to mark the download packet(from WAN to LAN)
*/
#define MASK_FOR_WAN2LAN 0X00008000
static DEFINE_SPINLOCK(tc_lock);
#endif
//[zhangguosong end]
/*
* Type used for a sync rule callback.
*/
@ -181,6 +213,10 @@ extern void sfe_ipv4_register_sync_rule_callback(sfe_sync_rule_callback_t callba
extern void sfe_ipv4_update_rule(struct sfe_connection_create *sic);
extern void sfe_ipv4_mark_rule(struct sfe_connection_mark *mark);
#ifdef TP_FEATURE_CLOUD
extern void sfe_update_enable_block_status(int status);
#endif
#ifdef SFE_SUPPORT_IPV6
/*
* IPv6 APIs used by connection manager

133
shortcut-fe/shortcut-fe/sfe_ipv4.c Normal file → Executable file
View File

@ -35,7 +35,7 @@ int var_thresh = PKT_THRESHOLD;
int skip_mtu_check = 1;
int threshold_count;
int timeout_count;
int enable_cloud_block = 0;
#define XDBG_ADD_PROC_ENTRY(it, name, xdata) \
{ \
.procname = (name), \
@ -543,6 +543,7 @@ typedef bool (*sfe_ipv4_debug_xml_write_method_t)(struct sfe_ipv4 *si, char *buf
struct sfe_ipv4 __si;
/* When the timer expires this callback function is called*/
void sfe_timer_callback(unsigned long data)
{
@ -1250,6 +1251,12 @@ static void sfe_ipv4_flush_sfe_ipv4_connection(struct sfe_ipv4 *si, struct sfe_i
kfree(c);
}
//[zhangguosong start] 2018-05-10 Export sfe_stat_cb function to ipt-stat to record stat
int (*sfe_stat_cb)(struct sk_buff *skb) __rcu __read_mostly;
EXPORT_SYMBOL_GPL(sfe_stat_cb);
//[zhangguosong end]
/*
* sfe_ipv4_recv_udp()
* Handle UDP packet receives and forwarding.
@ -1265,11 +1272,21 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
struct sfe_ipv4_connection_match *cm;
uint8_t ttl;
struct net_device *xmit_dev;
int (*stat_cb)(struct sk_buff *skb);
struct sk_buff *new_skb ;
int k;
const struct net_device_ops *ops;
int queue_index = 0;
struct sfe_ipv4_connection *c;
//[zhangguosong start]
#ifdef TP_FEATURE_WLANTC
struct sfe_ipv4_connection_match *counter_cm;
int idx = 0;
#endif
//[zhangguosong end]
/*
* Is our packet too short to contain a valid UDP header?
*/
@ -1397,6 +1414,15 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
if (unlikely(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_SRC)) {
uint16_t udp_csum;
//[zhangguosong start] 2018-05-10 update stats in ipt-stat
stat_cb = rcu_dereference(sfe_stat_cb);
if (stat_cb) {
if (NF_DROP == stat_cb(skb)) { /* if ipt-stat return NF_DROP, it means reach limit data-usaged */
return 0;
}
}
//[zhangguosong end]
iph->saddr = cm->xlate_src_ip;
udph->source = cm->xlate_src_port;
@ -1445,7 +1471,34 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
sum = (sum & 0xffff) + (sum >> 16);
udph->check = (uint16_t)sum;
}
//[zhangguosong start] 2018-05-10 update stats in ipt-stat
stat_cb = rcu_dereference(sfe_stat_cb);
if (stat_cb) {
if (NF_DROP == stat_cb(skb)) {
return 0;
}
}
//[zhangguosong end]
}
//[zhangguosong start] 2018-05-10 Move from MR6400V3
/**
* add by wuchao, 18.03.21, fix bug#215239.
* topology: lan pc - vpn server on dut - vpn client on wan pc
* no need to do SNAT & DNAT
*/
if (unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_DEST)))
{
stat_cb = rcu_dereference(sfe_stat_cb);
if (stat_cb) {
if (NF_DROP == stat_cb(skb)) {
return 0;
}
}
}
//[zhangguosong end]
/*
* Replace the IP checksum.
@ -1509,7 +1562,13 @@ static int sfe_ipv4_recv_udp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
/*
* Mark outgoing packet.
*/
skb->mark = cm->connection->mark;
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
if (cm->connection->mark != 0) {
skb->mark = skb->mark | cm->connection->mark /*| MASK_FOR_WAN2LAN*/;
DEBUG_TRACE("%s: skb-mark = 0x%x", __FUNCTION__, skb->mark);
}
//skb->mark = cm->connection->mark;
if (skb->mark) {
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
}
@ -1680,7 +1739,15 @@ static bool sfe_ipv4_process_tcp_option_sack(const struct sfe_ipv4_tcp_hdr *th,
return true;
}
#ifdef TP_FEATURE_CLOUD
void sfe_update_enable_block_status(int status)
{
struct sfe_ipv4 *si = &__si;
spin_lock_bh(&si->lock);
enable_cloud_block = status;
spin_unlock_bh(&si->lock);
}
#endif
/*
* sfe_ipv4_recv_tcp()
* Handle TCP packet receives and forwarding.
@ -1698,11 +1765,15 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
uint8_t ttl;
uint32_t flags;
struct net_device *xmit_dev;
int (*stat_cb)(struct sk_buff *skb);
struct sk_buff *new_skb ;
int k;
const struct net_device_ops *ops;
int queue_index = 0;
struct sfe_ipv4_connection *c;
int idx = 0; //[zhangguosong add]
/*
* Is our packet too short to contain a valid UDP header?
@ -1732,6 +1803,21 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
spin_lock_bh(&si->lock);
// [ lxw start]
#ifdef TP_FEATURE_CLOUD
if (enable_cloud_block == 1)
{
if (ntohs(src_port) == 80 || ntohs(dest_port) == 80)
{
si->exception_events[SFE_IPV4_EXCEPTION_EVENT_UNHANDLED_PROTOCOL]++;
si->packets_not_forwarded++;
spin_unlock_bh(&si->lock);
DEBUG_TRACE("Enable to tip cloud upgrade, not forward http packet\n");
return 0;
}
}
#endif
// [lxw end]
/*
* Look for a connection match.
*/
@ -2022,6 +2108,15 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
uint16_t tcp_csum;
uint32_t sum;
//[zhangguosong start] 2018-05-10 Update stats in ipt-stat
stat_cb = rcu_dereference(sfe_stat_cb);
if (stat_cb) {
if (NF_DROP == stat_cb(skb)) {
return 0;
}
}
//[zhangguosong end]
iph->saddr = cm->xlate_src_ip;
tcph->source = cm->xlate_src_port;
@ -2063,7 +2158,29 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
sum = (sum & 0xffff) + (sum >> 16);
tcph->check = (uint16_t)sum;
//[zhangguosong start] 2018-05-10 Update stats in ipt-stat
stat_cb = rcu_dereference(sfe_stat_cb);
if (stat_cb) {
if (NF_DROP == stat_cb(skb)) {
return 0;
}
}
//[zhangguosong end]
}
//[zhangguosong start] 2018-05-10 Move from MR6400V3
if (unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
unlikely(!(cm->flags & SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_DEST)))
{
stat_cb = rcu_dereference(sfe_stat_cb);
if (stat_cb) {
if (NF_DROP == stat_cb(skb)) {
return 0;
}
}
}
//[zhangguosong end]
/*
* Replace the IP checksum.
@ -2127,7 +2244,12 @@ static int sfe_ipv4_recv_tcp(struct sfe_ipv4 *si, struct sk_buff *skb, struct ne
/*
* Mark outgoing packet
*/
skb->mark = cm->connection->mark;
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
if (cm->connection->mark != 0) {
skb->mark = skb->mark | cm->connection->mark/* | MASK_FOR_WAN2LAN*/;
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
}
// skb->mark = cm->connection->mark;
if (skb->mark) {
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
}
@ -3850,6 +3972,9 @@ EXPORT_SYMBOL(sfe_ipv4_update_rule);
EXPORT_SYMBOL(sfe_register_flow_cookie_cb);
EXPORT_SYMBOL(sfe_unregister_flow_cookie_cb);
#endif
#ifdef TP_FEATURE_CLOUD
EXPORT_SYMBOL(sfe_update_enable_block_status);
#endif
MODULE_AUTHOR("Qualcomm Atheros Inc.");
MODULE_DESCRIPTION("Shortcut Forwarding Engine - IPv4 edition");

113
shortcut-fe/shortcut-fe/sfe_ipv6.c Normal file → Executable file
View File

@ -29,6 +29,8 @@
#define PKT_THRESHOLD 10
#define TIMEOUT 100
#define __OPEN_SUPPORT__IPV6__ 1
struct sfe_wlan_aggr_params aggr_params[MAX_WLAN_INDEX];
int var_timeout = TIMEOUT;
@ -1315,6 +1317,9 @@ static void sfe_ipv6_flush_connection(struct sfe_ipv6 *si, struct sfe_ipv6_conne
kfree(c);
}
int (*sfe_ipv6_stat_cb)(struct sk_buff *skb) __rcu __read_mostly;
EXPORT_SYMBOL_GPL(sfe_ipv6_stat_cb);
/*
* sfe_ipv6_recv_udp()
* Handle UDP packet receives and forwarding.
@ -1334,6 +1339,8 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
int queue_index = 0;
struct sfe_ipv6_connection *c;
int (*stat_cb)(struct skb_buff *skb);
/*
* Is our packet too short to contain a valid UDP header?
*/
@ -1456,6 +1463,19 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_SRC)) {
uint16_t udp_csum;
//[zhangguosong add] 2018-06-26
#if __OPEN_SUPPORT__IPV6__
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
if (stat_cb)
{
if (NF_DROP == stat_cb(skb))
{
return 0;
}
}
#endif
//[zhangguosong end]
iph->saddr = cm->xlate_src_ip[0];
udph->source = cm->xlate_src_port;
@ -1490,7 +1510,35 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
sum = (sum & 0xffff) + (sum >> 16);
udph->check = (uint16_t)sum;
}
//[zhangguosong add] 2016-06-26
#if __OPEN_SUPPORT__IPV6__
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
if (stat_cb)
{
if (NF_DROP == stat_cb(skb))
{
return 0;
}
}
#endif
//[zhangguosong end]
}
#if __OPEN_SUPPORT_IPV6__
if (unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_DEST)))
{
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
if (stat_cb)
{
if (NF_DROP == stat_cb(skb))
{
return 0;
}
}
}
#endif
/*
* Update traffic stats.
@ -1548,9 +1596,15 @@ static int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
/*
* Mark outgoing packet.
*/
skb->mark = cm->connection->mark;
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
if (0 != cm->connection->mark)
{
skb->mark = skb->mark | cm->connection->mark;
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
}
if (skb->mark) {
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
DEBUG_TRACE("%s: SKB MARK is NON ZERO %x\n", __FUNCTION__, skb->mark);
}
#endif
@ -1741,6 +1795,8 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
int queue_index = 0;
struct sfe_ipv6_connection *c;
int (*stat_cb)(struct skb_buff *skb);
/*
* Is our packet too short to contain a valid UDP header?
*/
@ -2055,6 +2111,19 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
uint16_t tcp_csum;
uint32_t sum;
//[zhangguosong start] 2018-06-26
#if __OPEN_SUPPORT__IPV6__
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
if (stat_cb)
{
if (NF_DROP == stat_cb(skb))
{
return 0;
}
}
#endif
//[zhangguosong end]
iph->saddr = cm->xlate_src_ip[0];
tcph->source = cm->xlate_src_port;
@ -2086,7 +2155,37 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
sum = tcp_csum + cm->xlate_dest_csum_adjustment;
sum = (sum & 0xffff) + (sum >> 16);
tcph->check = (uint16_t)sum;
//[zhangguosong start] 2018-06-27
#if __OPEN_SUPPORT__IPV6__
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
if (stat_cb)
{
if (NF_DROP == stat_cb(skb))
{
return 0;
}
}
#endif
//[zhangguosong end]
}
//[zhangguosong start] 2018-06-26
#if __OPEN_SUPPORT__IPV6__
if (unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_SRC)) &&
unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_DEST)))
{
stat_cb = rcu_dereference(sfe_ipv6_stat_cb);
if (stat_cb)
{
if (NF_DROP == stat_cb(skb))
{
return 0;
}
}
}
#endif
//[zhangguosong end]
/*
* Update traffic stats.
@ -2144,9 +2243,15 @@ static int sfe_ipv6_recv_tcp(struct sfe_ipv6 *si, struct sk_buff *skb, struct ne
/*
* Mark outgoing packet
*/
skb->mark = cm->connection->mark;
DEBUG_TRACE("%s: cm->connection->mark = 0x%x\n", __FUNCTION__, cm->connection->mark);
if (0 != cm->connection->mark)
{
skb->mark = skb->mark | cm->connection->mark;
DEBUG_TRACE("%s: skb->mark = 0x%x\n", __FUNCTION__, skb->mark);
}
if (skb->mark) {
DEBUG_TRACE("SKB MARK is NON ZERO %x\n", skb->mark);
DEBUG_TRACE("%s: SKB MARK is NON ZERO %x\n", __FUNCTION__, skb->mark);
}
#endif

5
system/core/liblog/logprint.c Normal file → Executable file
View File

@ -359,6 +359,11 @@ int android_log_processLogBuffer(struct logger_entry *buf,
entry->tid = buf->tid;
entry->tag = buf->msg + 1;
tag_len = strlen(entry->tag);
if(buf->len < (tag_len + 3))
{
return -1;
}
entry->messageLen = buf->len - tag_len - 3;
entry->message = entry->tag + tag_len + 1;

View File

@ -1,21 +1,25 @@
# Packages installed to the root file system
IMAGE_INSTALL += "tp-domain"
IMAGE_INSTALL += "uci"
IMAGE_INSTALL += "data-manager"
IMAGE_INSTALL += "npd6"
IMAGE_INSTALL += "radvd"
IMAGE_INSTALL += "wide-dhcpv6"
IMAGE_INSTALL += "libcjson"
IMAGE_INSTALL += "cgic"
IMAGE_INSTALL += "libghttp"
IMAGE_INSTALL += "uci"
IMAGE_INSTALL += "npd6"
IMAGE_INSTALL += "radvd"
IMAGE_INSTALL += "wide-dhcpv6"
IMAGE_INSTALL += "samba"
IMAGE_INSTALL += "bftpd"
IMAGE_INSTALL += "ntfs-3g"
IMAGE_INSTALL += "lighttpd"
IMAGE_INSTALL += "tp-domain"
IMAGE_INSTALL += "cgic"
IMAGE_INSTALL += "libghttp"

View File

@ -2,13 +2,13 @@
# Product configuration for TP-Link
################################################################################
BOARD_TYPE="mdm9207"
PRODUCT_TYPE="m7350-eu-v5"
PRODUCT_ID="73500005"
PRODUCT_NAME="M7350(EU) 5.0"
PRODUCT_TYPE="m7350-eu-v6"
PRODUCT_ID="73502006"
PRODUCT_NAME="M7350(EU) 6.2"
PRODUCT_SERIES="M7350"
PRODUCT_VER="5.0.0"
PRODUCT_VER="6.2.0"
PRODUCT_REGION="EU"
PRODUCT_TPNAME="m7350v5"
PRODUCT_TPNAME="m7350v6"
################################################################################
@ -54,7 +54,7 @@ WIRELESS_WPS_DISABLE="n"
WIRELESS_5G_DISABLE="y"
WIRELESS_ADAPTIVITY_ENABLE="n"
TP_WIRELESS_PASSPHRASE_ON_OLED="y"
TP_FEATURE_RTL8192ES="n"
TP_FEATURE_RTL8192ES="y"
TP_FEATURE_QCACLD="n"
#-------------------------------------------------------------------------------

View File

@ -3,17 +3,18 @@
################################################################################
config product info
option board_type "mdm9207"
option product_type "m7350-eu-v5"
option product_id "73500005"
option product_type "m7350-eu-v6"
option product_id "73502006"
option product_name "M7350"
option hardware_ver "5.0"
option firmware_ver "1.0.5"
option hardware_ver "7.0"
option firmware_ver "7.0.4"
option firmware_ver_build "Build 000000 Rel.0000n"
option product_region "EU"
option product_series "M7350"
option vendor_name "TP-Link Technologies Co., Ltd."
option vendor_name "TP-Link Corporation Limited."
option ssid_prefix "TP-Link_"
################################################################################
# Feature configuration
#-------------------------------------------------------------------------------

View File

@ -38,10 +38,10 @@ index 6674491..4deed09 100644
+ status = "ok";
+};
diff --git a/arch/arm/boot/dts/qcom/mdm9607-mtp.dtsi b/arch/arm/boot/dts/qcom/mdm9607-mtp.dtsi
index 5e6d2f2..0301f63 100644
index 5e6d2f2..9498828 100644
--- a/arch/arm/boot/dts/qcom/mdm9607-mtp.dtsi
+++ b/arch/arm/boot/dts/qcom/mdm9607-mtp.dtsi
@@ -27,6 +27,17 @@
@@ -27,6 +27,18 @@
};
&soc {
@ -55,11 +55,12 @@ index 5e6d2f2..0301f63 100644
+ mps,chg-m0-gpio = <&tlmm_pinmux 26 0>;
+ mps,ac-ok-gpio = <&tlmm_pinmux 4 0>;
+ qcom,client-vadc = <&pm8019_vadc>;
+ status = "disabled";
+ };
};
&blsp1_uart5 {
@@ -36,10 +47,14 @@
@@ -36,10 +48,14 @@
};
&i2c_4 {
@ -75,7 +76,7 @@ index 5e6d2f2..0301f63 100644
status = "ok";
};
@@ -55,14 +70,15 @@
@@ -55,14 +71,15 @@
status = "ok";
};
@ -97,7 +98,7 @@ index 5e6d2f2..0301f63 100644
};
};
@@ -141,21 +157,21 @@
@@ -141,21 +158,21 @@
};
};
@ -123,7 +124,7 @@ index 5e6d2f2..0301f63 100644
&sdhc_2 {
vdd-supply = <&sdcard_ext_vreg>;
@@ -175,7 +191,7 @@
@@ -175,7 +192,7 @@
1 &intc 0 221 0
2 &tlmm_pinmux 26 0>;
interrupt-names = "hc_irq", "pwr_irq", "status_irq";
@ -133,7 +134,7 @@ index 5e6d2f2..0301f63 100644
pinctrl-names = "active", "sleep";
pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
diff --git a/arch/arm/boot/dts/qcom/mdm9607-pinctrl.dtsi b/arch/arm/boot/dts/qcom/mdm9607-pinctrl.dtsi
index 6d4344b..7fce96d 100644
index 6d4344b..285c284 100644
--- a/arch/arm/boot/dts/qcom/mdm9607-pinctrl.dtsi
+++ b/arch/arm/boot/dts/qcom/mdm9607-pinctrl.dtsi
@@ -123,6 +123,68 @@
@ -256,7 +257,7 @@ index 6d4344b..7fce96d 100644
drive-strength = <2>;
bias-disable;
};
@@ -224,11 +286,11 @@
@@ -224,17 +286,43 @@
i2c_4_sleep: i2c_4_sleep {
/* suspended state */
mux {
@ -270,7 +271,39 @@ index 6d4344b..7fce96d 100644
drive-strength = <2>;
bias-pull-down;
};
@@ -1013,5 +1075,32 @@
};
};
+ i2c_2 {
+ i2c_2_active: i2c_2_active {
+ mux {
+ pins = "gpio6", "gpio7";
+ function = "blsp_i2c2";
+ };
+ config {
+ pins = "gpio6", "gpio7";
+ drive-strength = <2>;
+ bias-pull-up;
+ };
+ };
+
+ i2c_2_sleep: i2c_2_sleep {
+ mux {
+ pins = "gpio6", "gpio7";
+ function = "blsp_i2c2";
+ };
+ config {
+ pins = "gpio6", "gpio7";
+ drive-strength = <2>;
+ bias-pull-up;
+ };
+ };
+ };
+
codec_reset {
codec_reset_active: codec_reset_active {
mux {
@@ -1013,5 +1101,32 @@
output-low;
};
};
@ -304,7 +337,7 @@ index 6d4344b..7fce96d 100644
};
};
diff --git a/arch/arm/boot/dts/qcom/mdm9607.dtsi b/arch/arm/boot/dts/qcom/mdm9607.dtsi
index 1a9e273..ab5fdd1 100644
index 1a9e273..ac96a27 100644
--- a/arch/arm/boot/dts/qcom/mdm9607.dtsi
+++ b/arch/arm/boot/dts/qcom/mdm9607.dtsi
@@ -36,13 +36,14 @@
@ -331,15 +364,86 @@ index 1a9e273..ab5fdd1 100644
};
};
@@ -68,6 +70,7 @@
@@ -68,7 +70,9 @@
smd36 = &smdtty_loopback;
/* spi device */
spi1 = &spi_1;
+ spi5 = &spi_5;
i2c4 = &i2c_4;
+ i2c2 = &i2c_2; // new charge IC: BQ25601
sdhc2 = &sdhc_2; /* SDC2 SD card slot */
};
@@ -586,7 +589,7 @@
@@ -355,7 +359,7 @@
dma_blsp1: qcom,sps-dma@7884000 { /* BLSP1 */
#dma-cells = <4>;
compatible = "qcom,sps-dma";
- reg = <0x7884000 0x2b000>;
+ reg = <0x7884000 0x23000>;
interrupts = <0 238 0>;
qcom,summing-threshold = <10>;
};
@@ -519,6 +523,59 @@
};
};
+ /* refer to doc: 80-nu767-1 (qcom) & Documentation/devicetree/bindings/i2c/i2c-msm-v2.txt (kernel) */
+ i2c_2: i2c@78b6000 { /* BLSP1 QUP1 */
+ compatible = "qcom,i2c-msm-v2";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg-names = "qup_phys_addr";
+ reg = <0x78b6000 0x1000>;
+
+ interrupt-names = "qup_irq";
+ interrupts = <0 96 0>;
+
+ dmas = <&dma_blsp1 14 32 0x20000020 0x20>,
+ <&dma_blsp1 15 64 0x20000020 0x20>;
+ dma-names = "tx", "rx";
+
+ qcom,clk-freq-out = <100000>; // 100 KHz
+ qcom,clk-freq-in = <19200000>;
+
+ clock-names = "iface_clk", "core_clk";
+ clocks = <&clock_gcc clk_gcc_blsp1_ahb_clk>,
+ <&clock_gcc clk_gcc_blsp1_qup2_i2c_apps_clk>;
+
+ pinctrl-names = "i2c_active", "i2c_sleep";
+ pinctrl-0 = <&i2c_2_active>;
+ pinctrl-1 = <&i2c_2_sleep>;
+
+ qcom,noise-rjct-scl = <0>;
+ qcom,noise-rjct-sda = <0>;
+ qcom,fs-clk-div = <96>;
+ qcom,high-time-clk-div = <90>;
+ qcom,master-id = <86>;
+
+ bq25601: bq25601-charger@6b {
+ compatible = "ti,bq25601-charger";
+ reg = <0x6b>;
+
+ ti,irq-gpio = <&tlmm_pinmux 28 0>;
+ ti,chg-en-gpio = <&tlmm_pinmux 27 0>;
+ ti,chg-vbat-div = <3>;
+ qcom,chg-vadc = <&pm8019_vadc>;
+ };
+
+ sgm41513-charger@1a {
+ compatible = "ti,sgm41513-charger";
+ reg = <0x1a>;
+
+ ti,irq-gpio = <&tlmm_pinmux 28 0>;
+ ti,chg-en-gpio = <&tlmm_pinmux 27 0>;
+ ti,chg-vbat-div = <3>;
+ qcom,chg-vadc = <&pm8019_vadc>;
+ };
+ };
+
blsp1_uart3: uart@78b1000 {
compatible = "qcom,msm-hsuart-v14";
reg = <0x78b1000 0x200>,
@@ -586,7 +643,7 @@
<0x44 0x80 0x38 0x81 0x24 0x82 0x13 0x83 0xffffffff>;
qcom,hsusb-otg-phy-type = <3>; /* SNPS Femto PHY */
@ -348,7 +452,7 @@ index 1a9e273..ab5fdd1 100644
qcom,hsusb-otg-otg-control = <2>; /* PMIC control */
qcom,usbid-gpio = <&pm8019_mpps 1 0>;
qcom,hsusb-log2-itc = <4>;
@@ -829,6 +832,7 @@
@@ -829,6 +886,7 @@
sound-9330 {
compatible = "qcom,mdm9607-audio-tomtom";
qcom,model = "mdm9607-tomtom-i2s-snd-card";
@ -356,7 +460,7 @@ index 1a9e273..ab5fdd1 100644
qcom,audio-routing =
"RX_BIAS", "MCLK",
@@ -1202,6 +1206,12 @@
@@ -1202,6 +1260,12 @@
qcom,sensor-type = "adc";
qcom,sensor-name = "xo_therm_amux";
};
@ -369,7 +473,7 @@ index 1a9e273..ab5fdd1 100644
};
mitigation_profile0: qcom,limit_info-0 {
@@ -1346,7 +1356,7 @@
@@ -1346,7 +1410,7 @@
reg = <0x4044000 0x19000>;
interrupts = <0 29 1>;
qcom,rx-ring-size = <32>;
@ -378,7 +482,7 @@ index 1a9e273..ab5fdd1 100644
qcom,fast-shutdown;
};
@@ -1396,6 +1406,49 @@
@@ -1396,6 +1460,51 @@
status = "disabled";
};
@ -422,13 +526,15 @@ index 1a9e273..ab5fdd1 100644
+ qcom,oled-reset-gpio = <&tlmm_pinmux 24 0>;
+ qcom,oled-vdd0-gpio = <&tlmm_pinmux 18 0>;
+ qcom,oled-vdd1-gpio = <&tlmm_pinmux 19 0>;
+ qcom,oled-boost-en-gpio = <&tlmm_pinmux 6 0>;
+ qcom,oled-mosi-gpio = <&tlmm_pinmux 20 0>;
+ qcom,oled-clk-gpio = <&tlmm_pinmux 23 0>;
+ qcom,oled-boost-en-gpio = <&tlmm_pinmux 4 0>;
+ };
+
qcom,mss@4080000 {
compatible = "qcom,pil-q6v55-mss";
reg = <0x04080000 0x100>,
@@ -1525,6 +1578,35 @@
@@ -1525,6 +1634,35 @@
phy-addr = <0>;
status = "disable";
};
@ -464,7 +570,7 @@ index 1a9e273..ab5fdd1 100644
};
#include "mdm9607-rpm-regulator.dtsi"
@@ -1543,9 +1625,9 @@
@@ -1543,9 +1681,9 @@
};
};
@ -476,7 +582,7 @@ index 1a9e273..ab5fdd1 100644
&pm8019_vadc {
chan@6 {
@@ -1570,6 +1652,17 @@
@@ -1570,6 +1708,17 @@
qcom,fast-avg-setup = <0>;
};
@ -520,7 +626,7 @@ index d385ae6..e87ef38 100644
+CONFIG_TIMER_STATS=y
+CONFIG_SUPPORT_RTL_SDIO3=y
diff --git a/arch/arm/configs/mdm9607_defconfig b/arch/arm/configs/mdm9607_defconfig
index 1e33537..267a303 100644
index 1e33537..2cbd806 100644
--- a/arch/arm/configs/mdm9607_defconfig
+++ b/arch/arm/configs/mdm9607_defconfig
@@ -1,21 +1,23 @@
@ -582,10 +688,10 @@ index 1e33537..267a303 100644
CONFIG_NF_CONNTRACK_NETBIOS_NS=y
CONFIG_NF_CONNTRACK_SNMP=y
-CONFIG_NF_CONNTRACK_PPTP=y
+CONFIG_NF_CONNTRACK_PPTP=m
-CONFIG_NF_CONNTRACK_SIP=y
+CONFIG_NF_CONNTRACK_SIP=m
-CONFIG_NF_CONNTRACK_TFTP=y
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
CONFIG_NF_CT_NETLINK=y
CONFIG_NF_CT_NETLINK_TIMEOUT=y
@ -679,17 +785,20 @@ index 1e33537..267a303 100644
CONFIG_SERIAL_MSM_SMD=y
CONFIG_DIAG_CHAR=y
CONFIG_HW_RANDOM=y
@@ -225,7 +229,8 @@ CONFIG_GPIO_SYSFS=y
@@ -224,8 +228,10 @@ CONFIG_DEBUG_GPIO=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_QPNP_PIN=y
CONFIG_POWER_SUPPLY=y
CONFIG_SMB1351_USB_CHARGER=y
-CONFIG_SMB1351_USB_CHARGER=y
-CONFIG_SMB358_CHARGER=y
+CONFIG_SMB1351_USB_CHARGER=n
+CONFIG_SMB358_CHARGER=n
+CONFIG_MP2617_CHARGER=y
+CONFIG_MP2617_CHARGER=n
+CONFIG_BQ25601_CHARGER=y
CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_MSM=y
CONFIG_MSM_DLOAD_MODE=y
@@ -234,37 +239,37 @@ CONFIG_THERMAL=y
@@ -234,37 +240,37 @@ CONFIG_THERMAL=y
CONFIG_THERMAL_TSENS8974=y
CONFIG_THERMAL_MONITOR=y
CONFIG_THERMAL_QPNP_ADC_TM=y
@ -753,7 +862,7 @@ index 1e33537..267a303 100644
CONFIG_USB_EHSET_TEST_FIXTURE=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DEBUG_FILES=y
@@ -274,7 +279,6 @@ CONFIG_USB_CI13XXX_MSM=y
@@ -274,7 +280,6 @@ CONFIG_USB_CI13XXX_MSM=y
CONFIG_USB_CI13XXX_MSM_HSIC=y
CONFIG_USB_G_ANDROID=y
CONFIG_MMC=y
@ -761,7 +870,7 @@ index 1e33537..267a303 100644
CONFIG_MMC_CLKGATE=y
CONFIG_MMC_PARANOID_SD_INIT=y
CONFIG_MMC_BLOCK_MINORS=32
@@ -299,16 +303,15 @@ CONFIG_QPNP_REVID=y
@@ -299,16 +304,15 @@ CONFIG_QPNP_REVID=y
CONFIG_SPS=y
CONFIG_USB_BAM=y
CONFIG_SPS_SUPPORT_NDP_BAM=y
@ -782,7 +891,7 @@ index 1e33537..267a303 100644
CONFIG_MSM_WATCHDOG_V2=y
CONFIG_MSM_RPM_RBCPR_STATS_V2_LOG=y
CONFIG_MSM_RPM_LOG=y
@@ -332,20 +335,20 @@ CONFIG_MSM_PIL_MSS_QDSP6V5=y
@@ -332,20 +336,20 @@ CONFIG_MSM_PIL_MSS_QDSP6V5=y
CONFIG_TRACER_PKT=y
CONFIG_MSM_BAM_DMUX=y
CONFIG_REMOTE_SPINLOCK_MSM=y
@ -817,7 +926,7 @@ index 1e33537..267a303 100644
CONFIG_VFAT_FS=y
CONFIG_TMPFS=y
CONFIG_UBIFS_FS=y
@@ -354,27 +357,37 @@ CONFIG_NLS_CODEPAGE_437=y
@@ -354,27 +358,52 @@ CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ASCII=y
CONFIG_NLS_ISO8859_1=y
CONFIG_PRINTK_TIME=y
@ -875,3 +984,18 @@ index 1e33537..267a303 100644
+CONFIG_SUPPORT_RTL_SDIO3=y
+#[wuchao add] modify pkt_threshold for rtl wifi
+CONFIG_TP_FEATURE_RTL8192ES=y
+#[zhangguosong add start]
+CONFIG_NET_SCH_HTB=y
+CONFIG_NET_SCH_SFQ=y
+CONFIG_NET_SCH_FIFO=y
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_FW=y
+CONFIG_NET_CLS_U32=y
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_MIRRED=y
+CONFIG_BRIDGE_EBT_MARK=y
+CONFIG_BRIDGE_EBT_VLAN=y
+CONFIG_BRIDGE_EBT_FTOS=y
+CONFIG_BRIDGE_EBT_MARK_T=y
+CONFIG_IFB=y
+#[zhangguosong add end]

View File

@ -0,0 +1,16 @@
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
obj-m += tp_domain.o
PWD := $(shell pwd)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install
.PHONY:clean
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,158 @@
/******************************************************************************
*
* Copyright (c) 2009 TP-LINK Technologies CO.,LTD.
* All rights reserved.
*
* FILE NAME : tp_domain.h
* VERSION : 1.0
* DESCRIPTION: web管理页面.
*
* AUTHOR : huangwenzhong <huangwenzhong@tp-link.net>
* CREATE DATE: 11/30/2010
*
* HISTORY :
* 01 11/30/2010 huangwenzhong Create.
*
******************************************************************************/
#ifndef _TP_DOMAIN_H
#define _TP_DOMAIN_H
#define DOMAIN_PORT 53
#define ETH_HEADER_LEN ( 2 + 14 )
#define IP_PACKET_TTL 128
#define IP6_PACKET_HOPLIMIT 64
#define BR_STATE_DISABLED 0
#define BR_STATE_LISTENING 1
#define BR_STATE_LEARNING 2
#define BR_STATE_FORWARDING 3
#define BR_STATE_BLOCKING 4
#define BR_HASH_BITS 8
#define BR_HASH_SIZE (1 << BR_HASH_BITS)
typedef __u16 port_id;
typedef struct bridge_id bridge_id;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
struct bridge_id
{
unsigned char prio[2];
unsigned char addr[6];
};
struct net_bridge_port
{
struct net_bridge *br;
struct net_device *dev;
struct list_head list;
/* STP */
u8 priority;
u8 state;
u16 port_no;
unsigned char topology_change_ack;
unsigned char config_pending;
port_id port_id;
port_id designated_port;
bridge_id designated_root;
bridge_id designated_bridge;
u32 path_cost;
u32 designated_cost;
struct timer_list forward_delay_timer;
struct timer_list hold_timer;
struct timer_list message_age_timer;
struct kobject kobj;
struct rcu_head rcu;
};
struct net_bridge
{
spinlock_t lock;
struct list_head port_list;
struct net_device *dev;
spinlock_t hash_lock;
struct hlist_head hash[BR_HASH_SIZE];
struct list_head age_list;
unsigned long feature_mask;
#ifdef CONFIG_BRIDGE_NETFILTER
struct rtable fake_rtable;
#endif
unsigned long flags;
#define BR_SET_MAC_ADDR 0x00000001
/* STP */
bridge_id designated_root;
bridge_id bridge_id;
u32 root_path_cost;
unsigned long max_age;
unsigned long hello_time;
unsigned long forward_delay;
unsigned long bridge_max_age;
unsigned long ageing_time;
unsigned long bridge_hello_time;
unsigned long bridge_forward_delay;
u8 group_addr[ETH_ALEN];
u16 root_port;
enum {
BR_NO_STP, /* no spanning tree */
BR_KERNEL_STP, /* old STP in kernel */
BR_USER_STP, /* new RSTP in userspace */
} stp_enabled;
unsigned char topology_change;
unsigned char topology_change_detected;
struct timer_list hello_timer;
struct timer_list tcn_timer;
struct timer_list topology_change_timer;
struct timer_list gc_timer;
struct kobject *ifobj;
};
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
#if 0
#define DNS_ANSWER_TTL 0
#else
#define DNS_ANSWER_TTL ( 2 * 24 * 60 *60 )
#endif
#define IP_ADDR_LEN sizeof( __u32 )
#define IP6_ADDR_LEN 16
#define PORT_LEN sizeof( __u16 )
#define UDP_HEADER_LEN sizeof( struct udphdr )
#define DNS_HEADER_LEN sizeof( DNS_HEADER )
#define DNS_RESPONSE_PACKET ( 0x8000 ) /* response packet flag */
#define DNS_QUERY_TYPE_A ( 0x0001 ) /* query type,type A */
#define DNS_QUERY_TYPE_AAAA ( 0x001c ) /* query type,type AAAA */
#define DNS_QUERY_CLASS ( 0x0001 ) /* query class,clase internet */
#define DNS_RESPONSE_FLAG ( 0x8080 ) /* response flag value */
#define DNS_RESPONSE_POINTER ( 0xc00c )/* response field pointer */
#define DNS_RESOURCE_LEN_A ( 0x0004 ) /* response field IPv4 length */
#define DNS_RESOURCE_LEN_AAAA ( 0x0010 ) /* response field IPv6 length */
/* DNS报文头部结构.added by huangwenzhong. 11/30/2010. */
#define br_port_get_rcu(dev) \
((struct net_bridge_port *) rcu_dereference(dev->rx_handler_data))
#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
typedef struct
{
__u16 transaction_id;
__u16 flag;
__u16 questions;
__u16 answers_rrs;
__u16 authority_rrs;
__u16 additional_rrs;
}__attribute__ ((__packed__))DNS_HEADER;
#endif /* #ifndef _TP_DOMAIN_H */

View File

@ -0,0 +1,6 @@
How to build ?
1. Modify the "platform.mk" to select you platform or add an configuration for your platform.
2. Modify the "config.mk" to configure the driver option(select the chip, features, ...).
3. Overwirte "Makefile" by "Makefile_nrs" if your platform is not realtek system.
4. Run "make".

View File

@ -0,0 +1,743 @@
/* This is an independent implementation of the encryption algorithm: */
/* */
/* RIJNDAEL by Joan Daemen and Vincent Rijmen */
/* */
/* which is a candidate algorithm in the Advanced Encryption Standard */
/* programme of the US National Institute of Standards and Technology. */
/* */
/* Copyright in this implementation is held by Dr B R Gladman but I */
/* hereby give permission for its free direct or derivative use subject */
/* to acknowledgment of its origin and compliance with any conditions */
/* that the originators of the algorithm place on its exploitation. */
/* */
/* Dr Brian Gladman (gladman@seven77.demon.co.uk) 14th January 1999 */
#if 0
#include "stdafx.h"
#include <time.h>
#include <string.h>
#include <assert.h>
#endif
#ifdef __KERNEL__
#include <linux/time.h>
#include <linux/string.h>
#include <linux/slab.h>
#elif defined(__ECOS)
#include <cyg/hal/plf_intr.h>
#include <cyg/io/eth/rltk/819x/wrapper/sys_support.h>
#include <cyg/io/eth/rltk/819x/wrapper/skbuff.h>
#include <cyg/io/eth/rltk/819x/wrapper/timer.h>
#include <cyg/io/eth/rltk/819x/wrapper/wrapper.h>
#endif
#include "./8192cd_cfg.h"
#if defined(INCLUDE_WPA_PSK) || (defined(RTK_NL80211) && defined(CONFIG_IEEE80211W))
#ifdef RTL_WPA2
//#define MODULE_TEST
/*#include "aes_defs.h" */
#ifdef _SHOW_
#define _VERBOSE_ 1
#elif !defined(_VERBOSE_)
#define _VERBOSE_ 0
#endif
// david, move define to Makefile
// kenny
//#define BIG_ENDIAN 1
#if defined(__BORLANDC__) /* show what compiler we used */
#define COMPILER_ID "Borland"
//#define LITTLE_ENDIAN 1
// modified by chilong
#define AUTH_LITTLE_ENDIAN 1
#elif defined(_MSC_VER)
#define COMPILER_ID "Microsoft"
//#define LITTLE_ENDIAN 1
// modified by chilong
#define AUTH_LITTLE_ENDIAN 1
#elif defined(__GNUC__)
#define COMPILER_ID "GNU"
/* marked by chilong
#ifndef BIG_ENDIAN // assume gcc = little-endian, unless told otherwise
#define LITTLE_ENDIAN 1
#endif
*/
// modified by chilong
#ifndef _BIG_ENDIAN_ // assume gcc = little-endian, unless told otherwise
#define AUTH_LITTLE_ENDIAN 1
#endif
// modified by chilong
#else /* assume big endian, if compiler is unknown */
#define COMPILER_ID "Unknown"
#endif
/* 1. Standard types for AES cryptography source code */
typedef unsigned char u08b; /* an 8 bit unsigned character type */
typedef unsigned short u16b; /* a 16 bit unsigned integer type */
typedef unsigned int u32b; /* a 32 bit unsigned integer type */
#ifndef _RTL_WPA_WINDOW
#ifndef __LINUX_2_6__
#ifndef __ECOS
typedef int bool;
#endif
#endif
#endif
/* 2. Standard interface for AES cryptographic routines */
/* These are all based on 32-bit unsigned values and will therefore */
/* require endian conversions for big-endian architectures */
#ifdef __cplusplus
extern "C"
{
#endif
u32b * AES_SetKey (const u32b in_key[ ], const u32b key_len);
void AES_Encrypt(const u32b in_blk[4], u32b out_blk[4]);
void AES_Decrypt(const u32b in_blk[4], u32b out_blk[4]);
#ifdef __cplusplus
};
#endif
/* 3. Basic macros for speeding up generic operations */
/* Circular rotate of 32 bit values */
#ifdef _MSC_VER
#include <stdlib.h>
#pragma intrinsic(_lrotr,_lrotl)
#define rotr(x,n) _lrotr(x,n)
#define rotl(x,n) _lrotl(x,n)
#else
#define rotr(x,n) (((x) >> ((int)(n))) | ((x) << (32 - (int)(n))))
#define rotl(x,n) (((x) << ((int)(n))) | ((x) >> (32 - (int)(n))))
#endif
/* Extract byte from a 32 bit quantity (little endian notation) */
#define byte(x,n) ((u08b)((x) >> (8 * n)))
/* For inverting byte order in input/output 32 bit words, if needed */
// #ifdef LITTLE_ENDIAN
// modified by chilong
#ifdef AUTH_LITTLE_ENDIAN
#define bswap(x) (x)
#else
#define bswap(x) ((rotl((x), 8) & 0x00ff00ff) | (rotr((x), 8) & 0xff00ff00))
#endif
//end of aes_def.h
/*------------------ DLW debug code */
#if _VERBOSE_
#include <stdio.h>
int rNum;
void ShowBlk(const u32b *b,int final)
{
int i,j;
u32b x;
u08b a;
printf("%s %2d: ",(final) ? "Final" : "Round",rNum++);
for (i=0;i<4;i++)
{
printf(" ");
x = b[i]; /* always used internally as "little-endian" */
for (j=0;j<4;j++)
{
a = byte(x,j);
printf(" %02X",a);
}
}
printf("\n");
}
void ShowKeySched(const u32b *key,int cnt,const char *hdrMsg)
{
int i,j;
u32b x;
u08b a;
printf("%s\n",hdrMsg);
for (i=0;i<4*cnt;i++)
{
x = key[i]; /* key always used as "little-endian" */
printf(" ");
for (j=0;j<4;j++)
{
a = byte(x,j);
printf(" %02X",a);
}
if ((i%4) == 3) printf("\n");
}
}
#define SetR(r) { rNum = r; }
#else
#define ShowBlk(b,f)
#define SetR(r)
#define ShowKeySched(key,cnt,hdrMsg)
#endif
/*---------------- end of DLW debug */
#define LARGE_TABLES
u08b pow_tab[256];
u08b log_tab[256];
u08b sbx_tab[256];
u08b isb_tab[256];
u32b rco_tab[ 10];
u32b ft_tab[4][256];
u32b it_tab[4][256];
#ifdef LARGE_TABLES
u32b fl_tab[4][256];
u32b il_tab[4][256];
#endif
u32b tab_gen = 0;
u32b k_len;
u32b e_key[64];
u32b d_key[64];
#define ff_mult(a,b) (a && b ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0)
#define f_rn(bo, bi, n, k) \
bo[n] = ft_tab[0][byte(bi[n],0)] ^ \
ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
#define i_rn(bo, bi, n, k) \
bo[n] = it_tab[0][byte(bi[n],0)] ^ \
it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
#ifdef LARGE_TABLES
#define ls_box(x) \
( fl_tab[0][byte(x, 0)] ^ \
fl_tab[1][byte(x, 1)] ^ \
fl_tab[2][byte(x, 2)] ^ \
fl_tab[3][byte(x, 3)] )
#define f_rl(bo, bi, n, k) \
bo[n] = fl_tab[0][byte(bi[n],0)] ^ \
fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)
#define i_rl(bo, bi, n, k) \
bo[n] = il_tab[0][byte(bi[n],0)] ^ \
il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)
#else
#define ls_box(x) \
((u32b)sbx_tab[byte(x, 0)] << 0) ^ \
((u32b)sbx_tab[byte(x, 1)] << 8) ^ \
((u32b)sbx_tab[byte(x, 2)] << 16) ^ \
((u32b)sbx_tab[byte(x, 3)] << 24)
#define f_rl(bo, bi, n, k) \
bo[n] = (u32b)sbx_tab[byte(bi[n],0)] ^ \
rotl(((u32b)sbx_tab[byte(bi[(n + 1) & 3],1)]), 8) ^ \
rotl(((u32b)sbx_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \
rotl(((u32b)sbx_tab[byte(bi[(n + 3) & 3],3)]), 24) ^ *(k + n)
#define i_rl(bo, bi, n, k) \
bo[n] = (u32b)isb_tab[byte(bi[n],0)] ^ \
rotl(((u32b)isb_tab[byte(bi[(n + 3) & 3],1)]), 8) ^ \
rotl(((u32b)isb_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \
rotl(((u32b)isb_tab[byte(bi[(n + 1) & 3],3)]), 24) ^ *(k + n)
#endif
void gen_tabs(void)
{ u32b i, t;
u08b p, q;
/* log and power tables for GF(2**8) finite field with */
/* 0x11b as modular polynomial - the simplest prmitive */
/* root is 0x11, used here to generate the tables */
for(i = 0,p = 1; i < 256; ++i)
{
pow_tab[i] = (u08b)p; log_tab[p] = (u08b)i;
p = p ^ (p << 1) ^ (p & 0x80 ? 0x01b : 0);
}
log_tab[1] = 0; p = 1;
for(i = 0; i < 10; ++i)
{
rco_tab[i] = p;
p = (p << 1) ^ (p & 0x80 ? 0x1b : 0);
}
/* note that the affine byte transformation matrix in */
/* rijndael specification is in big endian format with */
/* bit 0 as the most significant bit. In the remainder */
/* of the specification the bits are numbered from the */
/* least significant end of a byte. */
for(i = 0; i < 256; ++i)
{
p = (i ? pow_tab[255 - log_tab[i]] : 0); q = p;
q = (q >> 7) | (q << 1); p ^= q;
q = (q >> 7) | (q << 1); p ^= q;
q = (q >> 7) | (q << 1); p ^= q;
q = (q >> 7) | (q << 1); p ^= q ^ 0x63;
sbx_tab[i] = (u08b)p; isb_tab[p] = (u08b)i;
}
for(i = 0; i < 256; ++i)
{
p = sbx_tab[i];
#ifdef LARGE_TABLES
t = p; fl_tab[0][i] = t;
fl_tab[1][i] = rotl(t, 8);
fl_tab[2][i] = rotl(t, 16);
fl_tab[3][i] = rotl(t, 24);
#endif
t = ((u32b)ff_mult(2, p)) |
((u32b)p << 8) |
((u32b)p << 16) |
((u32b)ff_mult(3, p) << 24);
ft_tab[0][i] = t;
ft_tab[1][i] = rotl(t, 8);
ft_tab[2][i] = rotl(t, 16);
ft_tab[3][i] = rotl(t, 24);
p = isb_tab[i];
#ifdef LARGE_TABLES
t = p; il_tab[0][i] = t;
il_tab[1][i] = rotl(t, 8);
il_tab[2][i] = rotl(t, 16);
il_tab[3][i] = rotl(t, 24);
#endif
t = ((u32b)ff_mult(14, p)) |
((u32b)ff_mult( 9, p) << 8) |
((u32b)ff_mult(13, p) << 16) |
((u32b)ff_mult(11, p) << 24);
it_tab[0][i] = t;
it_tab[1][i] = rotl(t, 8);
it_tab[2][i] = rotl(t, 16);
it_tab[3][i] = rotl(t, 24);
#if _VERBOSE_
if (i<4) /* helpful for debugging on new platform */
{ /* (compare with results from known platform) */
if (i==0)
printf("%8s : %08X %08X %08X %08X\n","rco_tab",
rco_tab[0],rco_tab[1],rco_tab[2],rco_tab[3]);
#define _ShowTab(tName) printf("%8s[%d]: %08X %08X %08X %08X\n",#tName,i, \
tName[0][i],tName[1][i],tName[2][i],tName[3][i]);
_ShowTab(it_tab);
_ShowTab(ft_tab);
#ifdef LARGE_TABLES
_ShowTab(il_tab);
_ShowTab(fl_tab);
#endif
}
#endif
}
tab_gen = 1;
};
#define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
#define imix_col(y,x) \
u = star_x(x); \
v = star_x(u); \
w = star_x(v); \
t = w ^ (x); \
(y) = u ^ v ^ w; \
(y) ^= rotr(u ^ t, 8) ^ \
rotr(v ^ t, 16) ^ \
rotr(t,24)
/* initialise the key schedule from the user supplied key */
#define loop4(i) \
{ t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
t ^= e_key[4 * i]; e_key[4 * i + 4] = t; \
t ^= e_key[4 * i + 1]; e_key[4 * i + 5] = t; \
t ^= e_key[4 * i + 2]; e_key[4 * i + 6] = t; \
t ^= e_key[4 * i + 3]; e_key[4 * i + 7] = t; \
}
#define loop6(i) \
{ t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
t ^= e_key[6 * i]; e_key[6 * i + 6] = t; \
t ^= e_key[6 * i + 1]; e_key[6 * i + 7] = t; \
t ^= e_key[6 * i + 2]; e_key[6 * i + 8] = t; \
t ^= e_key[6 * i + 3]; e_key[6 * i + 9] = t; \
t ^= e_key[6 * i + 4]; e_key[6 * i + 10] = t; \
t ^= e_key[6 * i + 5]; e_key[6 * i + 11] = t; \
}
#define loop8(i) \
{ t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \
t ^= e_key[8 * i]; e_key[8 * i + 8] = t; \
t ^= e_key[8 * i + 1]; e_key[8 * i + 9] = t; \
t ^= e_key[8 * i + 2]; e_key[8 * i + 10] = t; \
t ^= e_key[8 * i + 3]; e_key[8 * i + 11] = t; \
t = e_key[8 * i + 4] ^ ls_box(t); \
e_key[8 * i + 12] = t; \
t ^= e_key[8 * i + 5]; e_key[8 * i + 13] = t; \
t ^= e_key[8 * i + 6]; e_key[8 * i + 14] = t; \
t ^= e_key[8 * i + 7]; e_key[8 * i + 15] = t; \
}
u32b *AES_SetKey(const u32b in_key[], const u32b key_len)
{ u32b i, t, u, v, w;
if(!tab_gen)
gen_tabs();
k_len = (key_len + 31) / 32;
for (i=0;i<k_len;i++)
e_key[i] = bswap(in_key[i]);
t = e_key[k_len-1];
switch(k_len)
{
case 4: for(i = 0; i < 10; ++i)
loop4(i);
break;
case 6: for(i = 0; i < 8; ++i)
loop6(i);
break;
case 8: for(i = 0; i < 7; ++i)
loop8(i);
break;
}
d_key[0] = e_key[0]; d_key[1] = e_key[1];
d_key[2] = e_key[2]; d_key[3] = e_key[3];
for(i = 4; i < 4 * k_len + 24; ++i)
{
imix_col(d_key[i], e_key[i]);
}
ShowKeySched(e_key,4,"Encryption key schedule:");
ShowKeySched(d_key,4,"Decryption key schedule:");
return e_key;
};
/* encrypt a block of text */
#define f_nround(bo, bi, k) \
f_rn(bo, bi, 0, k); \
f_rn(bo, bi, 1, k); \
f_rn(bo, bi, 2, k); \
f_rn(bo, bi, 3, k); \
ShowBlk(bo,0); \
k += 4
#define f_lround(bo, bi, k) \
f_rl(bo, bi, 0, k); \
f_rl(bo, bi, 1, k); \
f_rl(bo, bi, 2, k); \
f_rl(bo, bi, 3, k); \
ShowBlk(bo,1);
void AES_Encrypt(const u32b in_blk[4], u32b out_blk[4])
{ u32b b0[4], b1[4], *kp;
b0[0] = bswap(in_blk[0]) ^ e_key[0];
b0[1] = bswap(in_blk[1]) ^ e_key[1];
b0[2] = bswap(in_blk[2]) ^ e_key[2];
b0[3] = bswap(in_blk[3]) ^ e_key[3];
SetR(1); ShowBlk(b0,0);
kp = e_key + 4;
if(k_len > 6)
{
f_nround(b1, b0, kp); f_nround(b0, b1, kp);
}
if(k_len > 4)
{
f_nround(b1, b0, kp); f_nround(b0, b1, kp);
}
f_nround(b1, b0, kp); f_nround(b0, b1, kp);
f_nround(b1, b0, kp); f_nround(b0, b1, kp);
f_nround(b1, b0, kp); f_nround(b0, b1, kp);
f_nround(b1, b0, kp); f_nround(b0, b1, kp);
f_nround(b1, b0, kp); f_lround(b0, b1, kp);
out_blk[0] = bswap(b0[0]);
out_blk[1] = bswap(b0[1]);
out_blk[2] = bswap(b0[2]);
out_blk[3] = bswap(b0[3]);
};
/* decrypt a block of text */
#define i_nround(bo, bi, k) \
i_rn(bo, bi, 0, k); \
i_rn(bo, bi, 1, k); \
i_rn(bo, bi, 2, k); \
i_rn(bo, bi, 3, k); \
k -= 4
#define i_lround(bo, bi, k) \
i_rl(bo, bi, 0, k); \
i_rl(bo, bi, 1, k); \
i_rl(bo, bi, 2, k); \
i_rl(bo, bi, 3, k)
void AES_Decrypt(const u32b in_blk[4], u32b out_blk[4])
{ u32b b0[4], b1[4], *kp;
b0[0] = bswap(in_blk[0]) ^ e_key[4 * k_len + 24];
b0[1] = bswap(in_blk[1]) ^ e_key[4 * k_len + 25];
b0[2] = bswap(in_blk[2]) ^ e_key[4 * k_len + 26];
b0[3] = bswap(in_blk[3]) ^ e_key[4 * k_len + 27];
kp = d_key + 4 * (k_len + 5);
if(k_len > 6)
{
i_nround(b1, b0, kp); i_nround(b0, b1, kp);
}
if(k_len > 4)
{
i_nround(b1, b0, kp); i_nround(b0, b1, kp);
}
i_nround(b1, b0, kp); i_nround(b0, b1, kp);
i_nround(b1, b0, kp); i_nround(b0, b1, kp);
i_nround(b1, b0, kp); i_nround(b0, b1, kp);
i_nround(b1, b0, kp); i_nround(b0, b1, kp);
i_nround(b1, b0, kp); i_lround(b0, b1, kp);
out_blk[0] = bswap(b0[0]);
out_blk[1] = bswap(b0[1]);
out_blk[2] = bswap(b0[2]);
out_blk[3] = bswap(b0[3]);
};
enum
{
BLK_SIZE = 16, // # octets in an AES block
MAX_PACKET = 3*512, // largest packet size
N_RESERVED = 0, // reserved nonce octet value
A_DATA = 0x40, // the Adata bit in the flags
M_SHIFT = 3, // how much to shift the 3-bit M field
L_SHIFT = 0, // how much to shift the 3-bit L field
L_SIZE = 2 // size of the l(m) length field (in octets)
};
typedef union _block // AES cipher block
{
u32b x[BLK_SIZE/4]; // access as 8-bit octets or 32-bit words
u08b b[BLK_SIZE];
}block;
typedef struct _packet
{
BOOLEAN encrypted; // TRUE if encrypted
u08b TA[6]; // xmit address
int micLength; // # octets of MIC appended to plaintext (M)
int clrCount; // # cleartext octets covered by MIC
u32b pktNum[2]; // unique packet sequence number (like WEP IV)
block key; // the encryption key (K)
int length; // # octets in data[]
u08b data[MAX_PACKET+2*BLK_SIZE]; // packet contents
}packet;
/*
input : 256 bits, 32 bytes, 4 block for TKIP
128 bits, 16 bytes, 2 block for CCMP, WRAP, and WEP
up to 32 block for WPA2
output: 8 bytes MIC | Wraped key data
*/
#define BLOCKSIZE8 8
void AES_WRAP(u08b * plain, int plain_len,
u08b * iv, int iv_len,
u08b * kek, int kek_len,
u08b *cipher, u16b *cipher_len)
{
int i, j, k, nblock = plain_len/BLOCKSIZE8;
#ifdef RTL_WPA2
static u08b R[32][BLOCKSIZE8], A[BLOCKSIZE8], xor[BLOCKSIZE8];
#else
u08b R[4][BLOCKSIZE8], A[BLOCKSIZE8], xor[BLOCKSIZE8];
#endif
static packet p;
static block m,x;
memcpy(&p.key.b , kek, kek_len);
AES_SetKey(p.key.x, BLK_SIZE*8); // run the key schedule
//Initialize Variable
memcpy(A, iv, BLOCKSIZE8);
for(i = 0; i < nblock ; i++)
memcpy(&R[i], plain + i*BLOCKSIZE8, BLOCKSIZE8);
//Caalculate Intermediate Values
for(j = 0 ; j < 6 ; j++ )
for (i = 0 ; i < nblock ; i++)
{
memcpy(&m.b, A, BLOCKSIZE8);
memcpy((&m.b[0]) + BLOCKSIZE8, &(R[i]), BLOCKSIZE8);
// => B = AES(K, A|R[i])
AES_Encrypt(m.x,x.x);
// => A = MSB(64,B) ^t where t = (n*j) + i
memset(xor, 0, sizeof xor);
xor[7] |= ((nblock * j) + i + 1);
for(k = 0 ; k < 8 ; k++)
A[k] = x.b[k] ^ xor[k];
// => R[i] = LSB(64,B)
for(k = 0 ; k < 8 ; k++)
R[i][k] = x.b[k + BLOCKSIZE8];
}
//Output the result
memcpy(cipher, A, BLOCKSIZE8);
for(i = 0; i<nblock ; i++)
memcpy(cipher + (i+1)*BLOCKSIZE8, &R[i], BLOCKSIZE8);
*cipher_len = plain_len + BLOCKSIZE8;
}
void AES_UnWRAP(u08b * cipher, int cipher_len,
u08b * kek, int kek_len,
u08b * plain, int plain_len)
{
int i, j, k, nblock = (cipher_len/BLOCKSIZE8) - 1;
#ifdef RTL_WPA2
if (nblock > 32) {
printk("AES_UnWRAP Error: cipher len exceeds!\n");
return;
}
u08b R[32][BLOCKSIZE8], A[BLOCKSIZE8], xor[BLOCKSIZE8];
#else
if (nblock > 4) {
printk("AES_UnWRAP Error: cipher len exceeds!\n");
return;
}
u08b R[4][BLOCKSIZE8], A[BLOCKSIZE8], xor[BLOCKSIZE8];
#endif
packet *p;
block m,x;
if ((plain_len < BLOCKSIZE8) || (plain_len < cipher_len)) {
printk("AES_UnWRAP Error: cipher len exceeds plain len!\n");
return;
}
p = (packet *)kmalloc(sizeof(packet), GFP_ATOMIC);
if (p == NULL)
return;
memcpy(p->key.b , kek, kek_len);
AES_SetKey(p->key.x, BLK_SIZE*8); // run the key schedule
//Initialize Variable
memcpy(A, cipher, BLOCKSIZE8);
for(i = 0; i < nblock ; i++)
memcpy(&R[i], cipher + (i+1)*BLOCKSIZE8, BLOCKSIZE8);
//Compute internediate Value
for(j=5 ; j>=0 ; j--)
for(i= nblock-1 ; i>=0 ; i--)
{
// => B = AES-1((A^t) |R[i])
memset(xor, 0, sizeof xor);
xor[7] |= ((nblock * j) + i + 1);
for(k = 0 ; k < 8 ; k++)
x.b[k] = A[k] ^ xor[k];
memcpy((&x.b[0]) + BLOCKSIZE8, &(R[i]), BLOCKSIZE8);
AES_Decrypt(x.x,m.x);
memcpy(A, &m.b[0], BLOCKSIZE8);
//for(k=0 ; k<BLOCKSIZE8 ; k++)
// A[k] = m.b[k];
for(k=0 ; k<BLOCKSIZE8 ; k++)
R[i][k] = m.b[k + BLOCKSIZE8];
}
memcpy(plain, A, BLOCKSIZE8);
for(i = 0; i < nblock ; i++)
memcpy(plain + (i+1)*BLOCKSIZE8, &R[i], BLOCKSIZE8);
kfree(p);
}
#ifdef MODULE_TEST
void TestAESWRAP()
{
unsigned char kek[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
unsigned char plaintext[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char cipher[16+ 8];
/*
unsigned char iv[] = {0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6};
unsigned char plaintext1[] ={0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
AES_WRAP(plaintext, 16,
iv, 8,
kek, 16,
cipher);
*/
AES_UnWRAP(cipher, 24,
kek, 16,
plaintext, 24);
}
#endif
#endif // RTL_WPA2
#endif // INCLUDE_WPA_PSK

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,418 @@
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
//#include "8021x.h"
#include "./8192cd_cfg.h"
#if defined(INCLUDE_WPA_PSK) || defined(WIFI_HAPD) || defined(RTK_NL80211)
#include "1x_md5c.h"
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
static void MD5Transform(UINT4 [4], UINT8 [64]);
static void Encode(UINT8 *, UINT4 *, UINT32);
static void Decode(UINT4 *, UINT8 *, UINT32);
static void MD5_memcpy(POINTER, POINTER, UINT32);
static void MD5_memset(POINTER, int, UINT32);
static UINT8 PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
void wlan_MD5_Init (context)
MD5_CTX *context; /* context */
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.
*/
void wlan_MD5_Update (context, input, inputLen)
MD5_CTX *context; /* context */
UINT8 *input; /* input block */
UINT32 inputLen; /* length of input block */
{
UINT32 i, index, partLen;
/* Compute number of bytes mod 64 */
index = (UINT32)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible.
*/
if (inputLen >= partLen) {
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform (context->state, &input[i]);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)&input[i],
inputLen-i);
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void wlan_MD5_Final (digest, context)
UINT8 digest[16]; /* message digest */
MD5_CTX *context; /* context */
{
UINT8 bits[8];
UINT32 index, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.
*/
index = (UINT32)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
wlan_MD5_Update (context, PADDING, padLen);
/* Append length (before padding) */
wlan_MD5_Update (context, bits, 8);
/* Store state in digest */
Encode (digest, context->state, 16);
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)context, 0, sizeof (*context));
}
/* MD5 basic transformation. Transforms state based on block.
*/
static void MD5Transform (state, block)
UINT4 state[4];
UINT8 block[64];
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)x, 0, sizeof (x));
}
/* Encodes input (UINT4) into output (UINT8). Assumes len is
a multiple of 4.
*/
static void Encode (output, input, len)
UINT8 *output;
UINT4 *input;
UINT32 len;
{
UINT32 i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (UINT8)(input[i] & 0xff);
output[j+1] = (UINT8)((input[i] >> 8) & 0xff);
output[j+2] = (UINT8)((input[i] >> 16) & 0xff);
output[j+3] = (UINT8)((input[i] >> 24) & 0xff);
}
}
/* Decodes input (UINT8) into output (UINT4). Assumes len is
a multiple of 4.
*/
static void Decode (output, input, len)
UINT4 *output;
UINT8 *input;
UINT32 len;
{
UINT32 i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible.
*/
static void MD5_memcpy (output, input, len)
POINTER output;
POINTER input;
UINT32 len;
{
UINT32 i;
for (i = 0; i < len; i++)
output[i] = input[i];
}
/* Note: Replace "for loop" with standard memset if possible.
*/
static void MD5_memset (output, value, len)
POINTER output;
int value;
UINT32 len;
{
UINT32 i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
}
#if 0
/*
UINT8* text; pointer to data stream
int text_len; length of data stream
UINT8* key; pointer to authentication key
int key_len; length of authentication key
UINT8* digest; caller digest to be filled in
*/
void hmac_md5(UINT8 *text, INT32 text_len, UINT8 *key, INT32 key_len,UINT8 *digest)
{
MD5_CTX context;
UINT8 k_ipad[65]; /* inner padding -
* key XORd with ipad
*/
UINT8 k_opad[65]; /* outer padding -
* key XORd with opad
*/
UINT8 tk[16];
int i;
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) {
MD5_CTX tctx;
MD5Init(&tctx);
MD5Update(&tctx, key, key_len);
MD5Final(tk, &tctx);
key = tk;
key_len = 16;
}
/*
* the HMAC_MD5 transform looks like:
*
* MD5(K XOR opad, MD5(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
/* start out by storing key in pads */
memset(k_ipad, 0x0, sizeof(k_ipad));
memset(k_opad, 0x0, sizeof(k_opad));
memcpy(k_ipad, key, key_len);
memcpy(k_opad, key, key_len);
//bzero( k_ipad, sizeof k_ipad);
//bzero( k_opad, sizeof k_opad);
//bcopy( key, k_ipad, key_len);
//bcopy( key, k_opad, key_len);
/* XOR key with ipad and opad values */
for (i=0; i<64; i++) {
k_ipad[i] ^= 0x36;
k_opad[i] ^= 0x5c;
}
/*
* perform inner MD5
*/
MD5Init(&context); /* init context for 1st
* pass */
MD5Update(&context, k_ipad, 64); /* start with inner pad */
MD5Update(&context, text, text_len); /* then text of datagram */
MD5Final(digest, &context); /* finish up 1st pass */
/*
* perform outer MD5
*/
MD5Init(&context); /* init context for 2nd
* pass */
MD5Update(&context, k_opad, 64); /* start with outer pad */
MD5Update(&context, digest, 16); /* then results of 1st
* hash */
MD5Final(digest, &context); /* finish up 2nd pass */
}
#endif
#endif // INCLUDE_WPA_PSK

View File

@ -0,0 +1,63 @@
/*
* 8021x_md5c.h - header file for MD5C.C
*/
#ifndef P8021X_MD5C_H
#define P8021X_MD5C_H
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
/* MD5_TYPE.H - RSAREF types and constants */
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT2 defines a two byte word */
typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */
typedef unsigned int UINT4;
#if 0
typedef unsigned char UINT8;
typedef unsigned long UINT32;
typedef int INT32;
#endif
/* MD5 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
void wlan_MD5_Init(MD5_CTX *);
void wlan_MD5_Update(MD5_CTX *, UINT8 *, UINT32);
void wlan_MD5_Final(unsigned char [16], MD5_CTX *);
//void hmac_md5(UINT8 *, INT32, UINT8 * , INT32, UINT8 * );
#endif

View File

@ -0,0 +1,371 @@
/* crypto/rc4/rc4_enc.c */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#include "./8192cd_cfg.h"
#ifdef INCLUDE_WPA_PSK
#include "1x_rc4.h"
/* RC4 as implemented from a posting from
* Newsgroups: sci.crypt
* From: sterndark@netcom.com (David Sterndark)
* Subject: RC4 Algorithm revealed.
* Message-ID: <sternCvKL4B.Hyy@netcom.com>
* Date: Wed, 14 Sep 1994 06:35:31 GMT
*/
void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
unsigned char *outdata)
{
register RC4_INT *d;
register RC4_INT x,y,tx,ty;
int i;
x=key->x;
y=key->y;
d=key->data;
#if defined(RC4_CHUNK)
/*
* The original reason for implementing this(*) was the fact that
* pre-21164a Alpha CPUs don't have byte load/store instructions
* and e.g. a byte store has to be done with 64-bit load, shift,
* and, or and finally 64-bit store. Peaking data and operating
* at natural word size made it possible to reduce amount of
* instructions as well as to perform early read-ahead without
* suffering from RAW (read-after-write) hazard. This resulted
* in ~40%(**) performance improvement on 21064 box with gcc.
* But it's not only Alpha users who win here:-) Thanks to the
* early-n-wide read-ahead this implementation also exhibits
* >40% speed-up on SPARC and 20-30% on 64-bit MIPS (depending
* on sizeof(RC4_INT)).
*
* (*) "this" means code which recognizes the case when input
* and output pointers appear to be aligned at natural CPU
* word boundary
* (**) i.e. according to 'apps/openssl speed rc4' benchmark,
* crypto/rc4/rc4speed.c exhibits almost 70% speed-up...
*
* Cavets.
*
* - RC4_CHUNK="unsigned long long" should be a #1 choice for
* UltraSPARC. Unfortunately gcc generates very slow code
* (2.5-3 times slower than one generated by Sun's WorkShop
* C) and therefore gcc (at least 2.95 and earlier) should
* always be told that RC4_CHUNK="unsigned long".
*
* <appro@fy.chalmers.se>
*/
# define RC4_STEP ( \
x=(x+1) &0xff, \
tx=d[x], \
y=(tx+y)&0xff, \
ty=d[y], \
d[y]=tx, \
d[x]=ty, \
(RC4_CHUNK)d[(tx+ty)&0xff]\
)
if ( ( ((unsigned long)indata & (sizeof(RC4_CHUNK)-1)) |
((unsigned long)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 )
{
RC4_CHUNK ichunk,otp;
const union { long one; char little; } is_endian = {1};
/*
* I reckon we can afford to implement both endian
* cases and to decide which way to take at run-time
* because the machine code appears to be very compact
* and redundant 1-2KB is perfectly tolerable (i.e.
* in case the compiler fails to eliminate it:-). By
* suggestion from Terrel Larson <terr@terralogic.net>
* who also stands for the is_endian union:-)
*
* Special notes.
*
* - is_endian is declared automatic as doing otherwise
* (declaring static) prevents gcc from eliminating
* the redundant code;
* - compilers (those I've tried) don't seem to have
* problems eliminating either the operators guarded
* by "if (sizeof(RC4_CHUNK)==8)" or the condition
* expressions themselves so I've got 'em to replace
* corresponding #ifdefs from the previous version;
* - I chose to let the redundant switch cases when
* sizeof(RC4_CHUNK)!=8 be (were also #ifdefed
* before);
* - in case you wonder "&(sizeof(RC4_CHUNK)*8-1)" in
* [LB]ESHFT guards against "shift is out of range"
* warnings when sizeof(RC4_CHUNK)!=8
*
* <appro@fy.chalmers.se>
*/
if (!is_endian.little)
{ /* BIG-ENDIAN CASE */
# define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1))
for (;len&-sizeof(RC4_CHUNK);len-=sizeof(RC4_CHUNK))
{
ichunk = *(RC4_CHUNK *)indata;
otp = RC4_STEP<<BESHFT(0);
otp |= RC4_STEP<<BESHFT(1);
otp |= RC4_STEP<<BESHFT(2);
otp |= RC4_STEP<<BESHFT(3);
if (sizeof(RC4_CHUNK)==8)
{
otp |= RC4_STEP<<BESHFT(4);
otp |= RC4_STEP<<BESHFT(5);
otp |= RC4_STEP<<BESHFT(6);
otp |= RC4_STEP<<BESHFT(7);
}
*(RC4_CHUNK *)outdata = otp^ichunk;
indata += sizeof(RC4_CHUNK);
outdata += sizeof(RC4_CHUNK);
}
if (len)
{
RC4_CHUNK mask=(RC4_CHUNK)-1, ochunk;
ichunk = *(RC4_CHUNK *)indata;
ochunk = *(RC4_CHUNK *)outdata;
otp = 0;
i = BESHFT(0);
mask <<= (sizeof(RC4_CHUNK)-len)<<3;
switch (len&(sizeof(RC4_CHUNK)-1))
{
case 7: otp = RC4_STEP<<i, i-=8;
case 6: otp |= RC4_STEP<<i, i-=8;
case 5: otp |= RC4_STEP<<i, i-=8;
case 4: otp |= RC4_STEP<<i, i-=8;
case 3: otp |= RC4_STEP<<i, i-=8;
case 2: otp |= RC4_STEP<<i, i-=8;
case 1: otp |= RC4_STEP<<i, i-=8;
case 0: ; /*
* it's never the case,
* but it has to be here
* for ultrix?
*/
}
ochunk &= ~mask;
ochunk |= (otp^ichunk) & mask;
*(RC4_CHUNK *)outdata = ochunk;
}
key->x=x;
key->y=y;
return;
}
else
{ /* LITTLE-ENDIAN CASE */
# define LESHFT(c) (((c)*8)&(sizeof(RC4_CHUNK)*8-1))
for (;len&-sizeof(RC4_CHUNK);len-=sizeof(RC4_CHUNK))
{
ichunk = *(RC4_CHUNK *)indata;
otp = RC4_STEP;
otp |= RC4_STEP<<8;
otp |= RC4_STEP<<16;
otp |= RC4_STEP<<24;
if (sizeof(RC4_CHUNK)==8)
{
otp |= RC4_STEP<<LESHFT(4);
otp |= RC4_STEP<<LESHFT(5);
otp |= RC4_STEP<<LESHFT(6);
otp |= RC4_STEP<<LESHFT(7);
}
*(RC4_CHUNK *)outdata = otp^ichunk;
indata += sizeof(RC4_CHUNK);
outdata += sizeof(RC4_CHUNK);
}
if (len)
{
RC4_CHUNK mask=(RC4_CHUNK)-1, ochunk;
ichunk = *(RC4_CHUNK *)indata;
ochunk = *(RC4_CHUNK *)outdata;
otp = 0;
i = 0;
mask >>= (sizeof(RC4_CHUNK)-len)<<3;
switch (len&(sizeof(RC4_CHUNK)-1))
{
case 7: otp = RC4_STEP, i+=8;
case 6: otp |= RC4_STEP<<i, i+=8;
case 5: otp |= RC4_STEP<<i, i+=8;
case 4: otp |= RC4_STEP<<i, i+=8;
case 3: otp |= RC4_STEP<<i, i+=8;
case 2: otp |= RC4_STEP<<i, i+=8;
case 1: otp |= RC4_STEP<<i, i+=8;
case 0: ; /*
* it's never the case,
* but it has to be here
* for ultrix?
*/
}
ochunk &= ~mask;
ochunk |= (otp^ichunk) & mask;
*(RC4_CHUNK *)outdata = ochunk;
}
key->x=x;
key->y=y;
return;
}
}
#endif
#define LOOP(in,out) \
x=((x+1)&0xff); \
tx=d[x]; \
y=(tx+y)&0xff; \
d[x]=ty=d[y]; \
d[y]=tx; \
(out) = d[(tx+ty)&0xff]^ (in);
#ifndef RC4_INDEX
#define RC4_LOOP(a,b,i) LOOP(*((a)++),*((b)++))
#else
#define RC4_LOOP(a,b,i) LOOP(a[i],b[i])
#endif
i=(int)(len>>3L);
if (i)
{
for (;;)
{
RC4_LOOP(indata,outdata,0);
RC4_LOOP(indata,outdata,1);
RC4_LOOP(indata,outdata,2);
RC4_LOOP(indata,outdata,3);
RC4_LOOP(indata,outdata,4);
RC4_LOOP(indata,outdata,5);
RC4_LOOP(indata,outdata,6);
RC4_LOOP(indata,outdata,7);
#ifdef RC4_INDEX
indata+=8;
outdata+=8;
#endif
if (--i == 0) break;
}
}
i=(int)len&0x07;
if (i)
{
for (;;)
{
RC4_LOOP(indata,outdata,0); if (--i == 0) break;
RC4_LOOP(indata,outdata,1); if (--i == 0) break;
RC4_LOOP(indata,outdata,2); if (--i == 0) break;
RC4_LOOP(indata,outdata,3); if (--i == 0) break;
RC4_LOOP(indata,outdata,4); if (--i == 0) break;
RC4_LOOP(indata,outdata,5); if (--i == 0) break;
RC4_LOOP(indata,outdata,6); if (--i == 0) break;
}
}
key->x=x;
key->y=y;
}
#ifndef COMPACK_SIZE
const char *RC4_options(void)
{
#ifdef RC4_INDEX
if (sizeof(RC4_INT) == 1)
return("rc4(idx,char)");
else
return("rc4(idx,int)");
#else
if (sizeof(RC4_INT) == 1)
return("rc4(ptr,char)");
else
return("rc4(ptr,int)");
#endif
}
#endif
/* RC4 as implemented from a posting from
* Newsgroups: sci.crypt
* From: sterndark@netcom.com (David Sterndark)
* Subject: RC4 Algorithm revealed.
* Message-ID: <sternCvKL4B.Hyy@netcom.com>
* Date: Wed, 14 Sep 1994 06:35:31 GMT
*/
void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
{
register RC4_INT tmp;
register int id1,id2;
register RC4_INT *d;
unsigned int i;
d= &(key->data[0]);
for (i=0; i<256; i++)
d[i]=i;
key->x = 0;
key->y = 0;
id1=id2=0;
#define SK_LOOP(n) { \
tmp=d[(n)]; \
id2 = (data[id1] + tmp + id2) & 0xff; \
if (++id1 == len) id1=0; \
d[(n)]=d[id2]; \
d[id2]=tmp; }
for (i=0; i < 256; i+=4)
{
SK_LOOP(i+0);
SK_LOOP(i+1);
SK_LOOP(i+2);
SK_LOOP(i+3);
}
}
#endif // INCLUDE_WPA_PSK

View File

@ -0,0 +1,89 @@
/* crypto/rc4/rc4.h */
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#ifndef HEADER_RC4_H
#define HEADER_RC4_H
#ifdef OPENSSL_NO_RC4
#error RC4 is disabled.
#endif
//#include <openssl/opensslconf.h> /* RC4_INT */
#define RC4_INT unsigned int
#ifdef __cplusplus
extern "C" {
#endif
typedef struct rc4_key_st
{
RC4_INT x,y;
RC4_INT data[256];
} RC4_KEY;
const char *RC4_options(void);
void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
unsigned char *outdata);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,438 @@
/*
* Software TKIP encryption/descryption routines
*
* $Id: 8192cd_tkip.c,v 1.4.4.2 2010/09/30 05:27:28 button Exp $
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#define _8192CD_11H_C_
#ifdef __KERNEL__
#include <linux/module.h>
#include <asm/byteorder.h>
#elif defined(__ECOS)
#include <cyg/io/eth/rltk/819x/wrapper/sys_support.h>
#include <cyg/io/eth/rltk/819x/wrapper/skbuff.h>
#include <cyg/io/eth/rltk/819x/wrapper/timer.h>
#include <cyg/io/eth/rltk/819x/wrapper/wrapper.h>
#endif
#include "./8192cd_cfg.h"
#if !defined(__KERNEL__) && !defined(__ECOS)
#include "./sys-support.h"
#endif
#include "./8192cd.h"
#ifdef __KERNEL__
#include "./ieee802_mib.h"
#elif defined(__ECOS)
#include <cyg/io/eth/rltk/819x/wlan/ieee802_mib.h>
#endif
#include "./8192cd_util.h"
#include "./8192cd_headers.h"
#include "./8192cd_debug.h"
#if (defined(DOT11D) || defined(DOT11H))
#define MAX_CHANNEL_SET_NUMBER 20
typedef struct _PER_CHANNEL_ENTRY_ {
unsigned char firstChannel;
unsigned char numberOfChannel;
unsigned char maxTxDbm;
} PER_CHANNEL_ENTRY;
typedef struct _BAND_TABLE_ELEMENT_ {
unsigned char channel_set_number;
PER_CHANNEL_ENTRY channel_set[MAX_CHANNEL_SET_NUMBER];
} BAND_TABLE_ELEMENT;
typedef struct _COUNTRY_IE_ELEMENT_ {
unsigned int countryNumber;
unsigned char countryA2[3];
unsigned char A_Band_Region; //if support 5G A band? ; 0 == no support ; aBandRegion == real region domain
unsigned char G_Band_Region; //if support 2.4G G band? ; 0 == no support ; bBandRegion == real region domain
} COUNTRY_IE_ELEMENT;
static const COUNTRY_IE_ELEMENT countryIEArray[] =
{
/*
format: countryNumber | CountryCode(A2)
*/
{8,"AL ", 3, 3}, /*ALBANIA*/
{12,"DZ ", 3, 3}, /*ALGERIA*/
{32,"AR ", 3, 3}, /*ARGENTINA*/
{51,"AM ", 3, 3}, /*ARMENIA*/
{36,"AU ", 3, 3}, /*AUSTRALIA*/
{40,"AT ", 3, 3}, /*AUSTRIA*/
{31,"AZ ", 3, 3}, /*AZERBAIJAN*/
{48,"BH ", 3, 3}, /*BAHRAIN*/
{112,"BY", 3, 3}, /*BELARUS*/
{56,"BE ", 3, 3}, /*BELGIUM*/
{84,"BZ ", 3, 3}, /*BELIZE*/
{68,"BO ", 3, 3}, /*BOLIVIA*/
{76,"BR ", 3, 3}, /*BRAZIL*/
{96,"BN ", 3, 3}, /*BRUNEI*/
{100,"BG ", 3, 3}, /*BULGARIA*/
{124,"CA ", 1, 1}, /*CANADA*/
{152,"CL ", 3, 3}, /*CHILE*/
{156,"CN ",13,13}, /*CHINA*/
{170,"CO ", 1, 1}, /*COLOMBIA*/
{188,"CR ", 3, 3}, /*COSTA RICA*/
{191,"HR ", 3, 3}, /*CROATIA*/
{196,"CY ", 3, 3}, /*CYPRUS*/
{203,"CZ ", 3, 3}, /*CZECH REPUBLIC*/
{208,"DK ", 3, 3}, /*DENMARK*/
{214,"DO ", 1, 1}, /*DOMINICAN REPUBLIC*/
{218,"EC ", 3, 3}, /*ECUADOR*/
{818,"EG ", 3, 3}, /*EGYPT*/
{222,"SV ", 3, 3}, /*EL SALVADOR*/
{233,"EE ", 3, 3}, /*ESTONIA*/
{246,"FI ", 3, 3}, /*FINLAND*/
{250,"FR ", 3, 3}, /*FRANCE*/
{268,"GE ", 3, 3}, /*GEORGIA*/
{276,"DE ", 3, 3}, /*GERMANY*/
{300,"GR ", 3, 3}, /*GREECE*/
{320,"GT ", 1, 1}, /*GUATEMALA*/
{340,"HN ", 3, 3}, /*HONDURAS*/
{344,"HK ", 3, 3}, /*HONG KONG*/
{348,"HU ", 3, 3}, /*HUNGARY*/
{352,"IS ", 3, 3}, /*ICELAND*/
{356,"IN ", 3, 3}, /*INDIA*/
{360,"ID ", 3, 3}, /*INDONESIA*/
{364,"IR ", 3, 3}, /*IRAN*/
{372,"IE ", 3, 3}, /*IRELAND*/
{376,"IL ", 7, 7}, /*ISRAEL*/
{380,"IT ", 3, 3}, /*ITALY*/
{392,"JP ", 6, 6}, /*JAPAN*/
{400,"JO ", 3, 3}, /*JORDAN*/
{398,"KZ ", 3, 3}, /*KAZAKHSTAN*/
{410,"KR ", 3, 3}, /*NORTH KOREA*/
{408,"KP ", 3, 3}, /*KOREA REPUBLIC*/
{414,"KW ", 3, 3}, /*KUWAIT*/
{428,"LV ", 3, 3}, /*LATVIA*/
{422,"LB ", 3, 3}, /*LEBANON*/
{438,"LI ", 3, 3}, /*LIECHTENSTEIN*/
{440,"LT ", 3, 3}, /*LITHUANIA*/
{442,"LU ", 3, 3}, /*LUXEMBOURG*/
{446,"MO ", 3, 3}, /*CHINA MACAU*/
{807,"MK ", 3, 3}, /*MACEDONIA*/
{458,"MY ", 3, 3}, /*MALAYSIA*/
{484,"MX ", 1, 1}, /*MEXICO*/
{492,"MC ", 3, 3}, /*MONACO*/
{504,"MA ", 3, 3}, /*MOROCCO*/
{528,"NL ", 3, 3}, /*NETHERLANDS*/
{554,"NZ ", 3, 3}, /*NEW ZEALAND*/
{578,"NO ", 3, 3}, /*NORWAY*/
{512,"OM ", 3, 3}, /*OMAN*/
{586,"PK ", 3, 3}, /*PAKISTAN*/
{591,"PA ", 1, 1}, /*PANAMA*/
{604,"PE ", 3, 3}, /*PERU*/
{608,"PH ", 3, 3}, /*PHILIPPINES*/
{616,"PL ", 3, 3}, /*POLAND*/
{620,"PT ", 3, 3}, /*PORTUGAL*/
{630,"PR ", 1, 1}, /*PUERTO RICO*/
{634,"QA ", 3, 3}, /*QATAR*/
{642,"RO ", 3, 3}, /*ROMANIA*/
{643,"RU ",12,12}, /*RUSSIAN*/
{682,"SA ", 3, 3}, /*SAUDI ARABIA*/
{702,"SG ", 3, 3}, /*SINGAPORE*/
{703,"SK ", 3, 3}, /*SLOVAKIA*/
{705,"SI ", 3, 3}, /*SLOVENIA*/
{710,"ZA ", 3, 3}, /*SOUTH AFRICA*/
{724,"ES ", 3, 3}, /*SPAIN*/
{752,"SE ", 3, 3}, /*SWEDEN*/
{756,"CH ", 3, 3}, /*SWITZERLAND*/
{760,"SY ", 3, 3}, /*SYRIAN ARAB REPUBLIC*/
{158,"TW ",11,11}, /*TAIWAN*/
{764,"TH ", 3, 3}, /*THAILAND*/
{780,"TT ", 3, 3}, /*TRINIDAD AND TOBAGO*/
{788,"TN ", 3, 3}, /*TUNISIA*/
{792,"TR ", 3, 3}, /*TURKEY*/
{804,"UA ", 3, 3}, /*UKRAINE*/
{784,"AE ", 3, 3}, /*UNITED ARAB EMIRATES*/
{826,"GB ", 3, 3}, /*UNITED KINGDOM*/
{840,"US ", 1, 1}, /*UNITED STATES*/
{858,"UY ", 3, 3}, /*URUGUAY*/
{860,"UZ ", 1, 1}, /*UZBEKISTAN*/
{862,"VE ", 3, 3}, /*VENEZUELA*/
{704,"VN ", 3, 3}, /*VIET NAM*/
{887,"YE ", 3, 3}, /*YEMEN*/
{716,"ZW ", 3, 3}, /*ZIMBABWE*/
};
static const BAND_TABLE_ELEMENT country_ie_channel_2_4g[] = {
/* number of channel set | array of channel sets{first channel, num of channel, tx power}
transmit tx power is copy from CAMEO
*/
/* (1) FCC */ {1, {{1, 11, 30}}},
/* (2) IC */ {1, {{1, 11, 30}}},
/* (3) ETSI */ {1, {{1, 13, 30}}},
/* (4) SPAIN */ {1, {{1, 13, 30}}},
/* (5) FRANCE */ {1, {{10, 4, 30}}},
/* (6) MKK */ {1, {{1, 14, 30}}},
/* (7) ISRAEL */ {1, {{3, 11, 30}}},
/* (8) MKK1 */ {1, {{1, 14, 30}}},
/* (9) MKK2 */ {1, {{1, 14, 30}}},
/* (10) MKK3 */ {1, {{1, 14, 30}}},
/* (11) NCC (Taiwan) */ {1, {{1, 11, 30}}},
/* (12) RUSSIAN */ {1, {{1, 13, 30}}},
/* (13) CN */ {1, {{1, 13, 30}}},
/* (14) Global */ {1, {{1, 14, 30}}},
/* (15) World_wide */ {1, {{1, 13, 30}}},
/* (16) Test */ {1, {{1, 14, 30}}},
};
static const BAND_TABLE_ELEMENT country_ie_channel_5g[] = {
/* number of channel set | array of channel sets {first channel, num of channel, tx power},
transmit tx power is copy from CAMEO
*/
/*(1) FCC */ {20, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{100,1,20},{104,1,20},{108,1,20},{112,1,20},{116,1,20},{136,1,20},{140,1,20},
{149,1,30},{153,1,30},{157,1,30},{161,1,30},{165,1,30} }
},
/* (2) IC */ {12, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{149,1,30},{153,1,30},{157,1,30},{161,1,30} }
},
/* (3) ETSI */ {19, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{100,1,20},{104,1,20},{108,1,20},{112,1,20},{116,1,20},{120,1,20},{124,1,20},{128,1,20},{132,1,20},{136,1,20},{140,1,20} }
},
/* (4) SPAIN */ {3, {{36,4,30}, //36, 40, 44, 48
{52,4,30}, //52, 56, 60, 64
{100,11,20} } //100, 104, 108, 112, 116,120,124,128,132,136,140
},
/* (5) FRANCE */ {3, {{36,4,30}, //36, 40, 44, 48
{52,4,30}, //52, 56, 60, 64
{100,11,20} } //100, 104, 108, 112, 116,120,124,128,132,136,140
},
/* (6) MKK */ {19, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{100,1,20},{104,1,20},{108,1,20},{112,1,20},{116,1,20},{120,1,20},{124,1,20},{128,1,20},{132,1,20},{136,1,20},{140,1,20} }
},
/* (7) ISRAEL */ {19, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{100,1,30},{104,1,30},{108,1,30},{112,1,30},{116,1,30},{120,1,30},{124,1,30},{128,1,30},{132,1,30},{136,1,30},{140,1,30} }
},
/* (8) MKK1 */ {1, {{34,4,30} } // 34, 38, 42, 46
},
/* (9) MKK2 */ {1, {{36,4,30} } //36, 40, 44, 48
},
/* (10) MKK3 */ {2, {{36,4,30}, //36, 40, 44, 48
{52,4,30} } //52, 56, 60, 64
},
/* (11) NCC (Taiwan) */
{15, {{56,1,30}, {60,1,30}, {64,1,30},
{100,1,20},{104,1,20},{108,1,20},{112,1,20},{116,1,20},{136,1,20},{140,1,20},
{149,1,30},{153,1,30},{157,1,30},{161,1,30},{165,1,30} }
},
/* (12) RUSSIAN */{16, {{36,1,20}, {40,1,20}, {44,1,20}, {48,1,20},
{52,1,20}, {56,1,20}, {60,1,20}, {64,1,20},
{132,1,30},{136,1,30},{140,1,30},
{149,1,30},{153,1,30},{157,1,30},{161,1,30},{165,1,30}}
},
/* (13) CN */ {13, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{149,1,30},{153,1,30},{157,1,30},{161,1,30},{165,1,30} }
},
/* (14) Global */ {20, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{100,1,30},{104,1,30},{108,1,30},{112,1,30},{116,1,30},{136,1,30},{140,1,30},
{149,1,30},{153,1,30},{157,1,30},{161,1,30},{165,1,30} }
},
/* (15) World_wide */
{20, {{36,1,30}, {40,1,30}, {44,1,30}, {48,1,30},
{52,1,30}, {56,1,30}, {60,1,30}, {64,1,30},
{100,1,30},{104,1,30},{108,1,30},{112,1,30},{116,1,30},{136,1,30},{140,1,30},
{149,1,30},{153,1,30},{157,1,30},{161,1,30},{165,1,30} }
},
/* (16) Test */ {4, {{36,4,30}, //36, 40, 44, 48
{52,4,30}, //52, 56, 60, 64
{100,12,30}, //100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144
{149,8,30} } //149, 153, 157, 161, 165, 169, 173, 177
},
/* (17) 5M10M */ {1, {{146,25,30} } // 146 ~ 170
},
};
void check_country_channel_table(struct rtl8192cd_priv *priv) {
unsigned char i = 0, country_num;
priv->countryTableIdx = 0;
if(COUNTRY_CODE_ENABLED || priv->pmib->dot11hTPCEntry.tpc_enable)
{
country_num = sizeof(countryIEArray)/sizeof(COUNTRY_IE_ELEMENT);
for (i=0; i<country_num; i++) {
if (!memcmp(priv->pmib->dot11dCountry.dot11CountryString, countryIEArray[i].countryA2, 2)) {
priv->countryTableIdx = i + 1;
break;
}
}
if (priv->countryTableIdx == 0) {
printk("can't found country code(%s)\n", priv->pmib->dot11dCountry.dot11CountryString);
}
}
}
unsigned char * construct_country_ie(struct rtl8192cd_priv *priv, unsigned char *pbuf, unsigned int *frlen) {
const COUNTRY_IE_ELEMENT * country_ie;
const BAND_TABLE_ELEMENT * band_table = NULL;
unsigned char temp[MAX_CHANNEL_SET_NUMBER*3 + 3 + 1];/*channel sets + country code + 1 possible padding*/
unsigned int len = 0;
country_ie = &(countryIEArray[priv->countryTableIdx-1]);
if ( priv->pmib->dot11RFEntry.phyBandSelect & PHY_BAND_2G) {
if(country_ie->G_Band_Region) {
band_table = &(country_ie_channel_2_4g[country_ie->G_Band_Region-1]);
}
}
else {
if(country_ie->A_Band_Region) {
band_table = &(country_ie_channel_5g[country_ie->A_Band_Region-1]);
}
}
if(band_table) {
memcpy(temp + len, country_ie->countryA2, 3);
len += 3;
memcpy(temp + len, (unsigned char *)band_table->channel_set, band_table->channel_set_number*3);
len += band_table->channel_set_number*3;
/*add padding, the length of country ie must divided by two*/
if(len%2) {
temp[len] = 0;
len++;
}
pbuf = set_ie(pbuf, _COUNTRY_IE_, len, temp, frlen);
}
return pbuf;
}
#endif
#ifdef DOT11H
#if defined(CLIENT_MODE) || defined(CONFIG_RTK_MESH)
unsigned char * construct_power_capability_ie(struct rtl8192cd_priv *priv, unsigned char *pbuf, unsigned int *frlen) {
unsigned char temp[2];
temp[0] = priv->pmib->dot11hTPCEntry.min_tx_power;
temp[1] = priv->pmib->dot11hTPCEntry.max_tx_power;
pbuf = set_ie(pbuf, _PWR_CAPABILITY_IE_, 2, temp, frlen);
return pbuf;
}
unsigned char * construct_supported_channel_ie(struct rtl8192cd_priv *priv, unsigned char *pbuf, unsigned int *frlen) {
const COUNTRY_IE_ELEMENT * country_ie;
const BAND_TABLE_ELEMENT * band_table = NULL;
unsigned char temp[MAX_CHANNEL_SET_NUMBER*2];/*channel sets*/
unsigned int i,j = 0;
if(priv->countryTableIdx) {
country_ie = &(countryIEArray[priv->countryTableIdx-1]);
if ( priv->pmib->dot11RFEntry.phyBandSelect & PHY_BAND_2G) {
if(country_ie->G_Band_Region) {
band_table = &(country_ie_channel_2_4g[country_ie->G_Band_Region-1]);
}
}
else {
if(country_ie->A_Band_Region) {
band_table = &(country_ie_channel_5g[country_ie->A_Band_Region-1]);
}
}
if(band_table) {
for(i = 0; i < band_table->channel_set_number; i++) {
temp[j++] = band_table->channel_set[i].firstChannel;
temp[j++] = band_table->channel_set[i].numberOfChannel;
}
pbuf = set_ie(pbuf, _SUPPORTED_CHANNEL_IE_, j, temp, frlen);
}
}
return pbuf;
}
#endif
unsigned char * construct_TPC_report_ie(struct rtl8192cd_priv *priv, unsigned char *pbuf, unsigned int *frlen) {
unsigned char temp[2];
temp[0] = priv->pmib->dot11hTPCEntry.tpc_tx_power;
temp[1] = priv->pmib->dot11hTPCEntry.tpc_link_margin;
pbuf = set_ie(pbuf, _TPC_REPORT_IE_, 2, temp, frlen);
return pbuf;
}
void issue_TPC_report(struct rtl8192cd_priv *priv, unsigned char *da, unsigned char dialog_token) {
unsigned char *pbuf;
unsigned int frlen;
DECLARE_TXINSN(txinsn);
txinsn.q_num = MANAGE_QUE_NUM;
txinsn.fr_type = _PRE_ALLOCMEM_;
#ifdef P2P_SUPPORT // 2013
if(OPMODE&WIFI_P2P_SUPPORT){
txinsn.tx_rate = _6M_RATE_;
}else
#endif
txinsn.tx_rate = find_rate(priv, NULL, 0, 1);
txinsn.lowest_tx_rate = txinsn.tx_rate;
txinsn.fixed_rate = 1;
pbuf = txinsn.pframe = get_mgtbuf_from_poll(priv);
if (pbuf == NULL)
goto issue_TPC_report_fail;
txinsn.phdr = get_wlanhdr_from_poll(priv);
if (txinsn.phdr == NULL)
goto issue_TPC_report_fail;
memset((void *)(txinsn.phdr), 0, sizeof(struct wlan_hdr));
pbuf[0] = _SPECTRUM_MANAGEMENT_CATEGORY_ID_;
pbuf[1] = _TPC_REPORT_ACTION_ID_;
pbuf[2] = dialog_token;
frlen = 3;
construct_TPC_report_ie(priv, pbuf + frlen, &frlen);
txinsn.fr_len += frlen;
SetFrameSubType((txinsn.phdr), WIFI_WMM_ACTION);
memcpy((void *)GetAddr1Ptr((txinsn.phdr)), da, MACADDRLEN);
memcpy((void *)GetAddr2Ptr((txinsn.phdr)), GET_MY_HWADDR, MACADDRLEN);
memcpy((void *)GetAddr3Ptr((txinsn.phdr)), BSSID, MACADDRLEN);
if ((rtl8192cd_firetx(priv, &txinsn)) == SUCCESS)
return;
issue_TPC_report_fail:
if (txinsn.phdr)
release_wlanhdr_to_poll(priv, txinsn.phdr);
if (txinsn.pframe)
release_mgtbuf_to_poll(priv, txinsn.pframe);
return;
}
#endif

View File

@ -0,0 +1,242 @@
/*
* a4 sta functions
*
* $Id: 8192cd_a4_sta.c,v 1.1 2010/10/13 06:38:58 davidhsu Exp $
*
* Copyright (c) 2010 Realtek Semiconductor Corp.
*
* 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.
*/
#define _8192CD_A4_STA_C_
#ifdef __KERNEL__
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/timer.h>
#endif
#include "./8192cd_cfg.h"
#ifdef A4_STA
#include "./8192cd.h"
#include "./8192cd_headers.h"
#include "./8192cd_debug.h"
//#define A4_STA_DEBUG
static struct a4_sta_db_entry *alloc_entry(struct rtl8192cd_priv *priv)
{
int i;
for (i=0; i<MAX_A4_TBL_NUM; i++) {
if (!priv->a4_ent[i].used) {
priv->a4_ent[i].used = 1;
return &priv->a4_ent[i].entry;
}
}
return NULL;
}
static void free_entry(struct rtl8192cd_priv *priv, struct a4_sta_db_entry *entry)
{
int i;
for (i=0; i<MAX_A4_TBL_NUM; i++) {
if (priv->a4_ent[i].used && (entry == &priv->a4_ent[i].entry)) {
priv->a4_ent[i].used = 0;
break;
}
}
}
static int mac_hash(unsigned char *networkAddr)
{
unsigned long x;
x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5];
return x & (A4_STA_HASH_SIZE - 1);
}
static void mac_hash_link(struct rtl8192cd_priv *priv, struct a4_sta_db_entry *ent, int hash)
{
ent->next_hash = priv->machash[hash];
if (ent->next_hash != NULL)
ent->next_hash->pprev_hash = &ent->next_hash;
priv->machash[hash] = ent;
ent->pprev_hash = &priv->machash[hash];
}
static void mac_hash_unlink(struct a4_sta_db_entry *ent)
{
*(ent->pprev_hash) = ent->next_hash;
if (ent->next_hash != NULL)
ent->next_hash->pprev_hash = ent->pprev_hash;
ent->next_hash = NULL;
ent->pprev_hash = NULL;
}
static unsigned long _timeout(struct rtl8192cd_priv *priv)
{
unsigned long timeout;
timeout = jiffies - A4_STA_AGEING_TIME*HZ;
return timeout;
}
static int has_expired(struct rtl8192cd_priv *priv, struct a4_sta_db_entry *fdb)
{
if (time_before_eq(fdb->ageing_timer, _timeout(priv)))
return 1;
return 0;
}
void a4_sta_cleanup(struct rtl8192cd_priv *priv)
{
int i;
if (priv->pshare->rf_ft_var.a4_enable) {
for (i=0; i<A4_STA_HASH_SIZE; i++) {
struct a4_sta_db_entry *f;
f = priv->machash[i];
while (f != NULL) {
struct a4_sta_db_entry *g;
g = f->next_hash;
mac_hash_unlink(f);
free_entry(priv, f);
f = g;
}
}
}
}
void a4_sta_expire(struct rtl8192cd_priv *priv)
{
int i;
if (priv->pshare->rf_ft_var.a4_enable) {
for (i=0; i<A4_STA_HASH_SIZE; i++) {
struct a4_sta_db_entry *f;
f = priv->machash[i];
while (f != NULL) {
struct a4_sta_db_entry *g;
g = f->next_hash;
if (has_expired(priv, f)) {
#ifdef A4_STA_DEBUG
panic_printk("A4 STA Expire (%02d) emac:%02x%02x%02x%02x%02x%02x, wmac:%02x%02x%02x%02x%02x%02x\n",
i,
f->mac[0],
f->mac[1],
f->mac[2],
f->mac[3],
f->mac[4],
f->mac[5],
f->stat->hwaddr[0],
f->stat->hwaddr[1],
f->stat->hwaddr[2],
f->stat->hwaddr[3],
f->stat->hwaddr[4],
f->stat->hwaddr[5]);
#endif
mac_hash_unlink(f);
free_entry(priv, f);
}
f = g;
}
}
}
}
void a4_sta_add(struct rtl8192cd_priv *priv, struct stat_info *pstat, unsigned char *mac)
{
struct a4_sta_db_entry *db;
int hash;
ASSERT(mac);
hash = mac_hash(mac);
db = priv->machash[hash];
while (db != NULL) {
if (!memcmp(db->mac, mac, ETH_ALEN)) {
db->stat = pstat;
db->ageing_timer = jiffies;
return;
}
db = db->next_hash;
}
db = alloc_entry(priv);
if (db == NULL) {
DEBUG_ERR("alloc_entry() failed for a4_sta_db_entry!\n");
return;
}
memcpy(db->mac, mac, ETH_ALEN);
db->stat = pstat;
db->ageing_timer = jiffies;
#ifdef A4_STA_DEBUG
panic_printk("A4 STA Add emac:%02x%02x%02x%02x%02x%02x, wmac:%02x%02x%02x%02x%02x%02x\n",
db->mac[0],
db->mac[1],
db->mac[2],
db->mac[3],
db->mac[4],
db->mac[5],
db->stat->hwaddr[0],
db->stat->hwaddr[1],
db->stat->hwaddr[2],
db->stat->hwaddr[3],
db->stat->hwaddr[4],
db->stat->hwaddr[5]);
#endif
mac_hash_link(priv, db, hash);
}
struct stat_info *a4_sta_lookup(struct rtl8192cd_priv *priv, unsigned char *mac)
{
struct a4_sta_db_entry *db;
ASSERT(mac);
db = priv->machash[mac_hash(mac)];
while (db != NULL) {
if (!memcmp(db->mac, mac, ETH_ALEN)) {
#ifdef A4_STA_DEBUG
panic_printk("A4 STA LOOKUP emac:%02x%02x%02x%02x%02x%02x, wmac:%02x%02x%02x%02x%02x%02x\n",
db->mac[0],
db->mac[1],
db->mac[2],
db->mac[3],
db->mac[4],
db->mac[5],
db->stat->hwaddr[0],
db->stat->hwaddr[1],
db->stat->hwaddr[2],
db->stat->hwaddr[3],
db->stat->hwaddr[4],
db->stat->hwaddr[5]);
#endif
return db->stat;
}
db = db->next_hash;
}
return NULL;
}
#endif /* A4_STA */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
/*
* Headler file defines some data structure and macro of bridge extention
*
* $Id: 8192cd_br_ext.h,v 1.1.4.1 2010/07/28 13:15:27 davidhsu Exp $
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#ifndef _8192CD_BR_EXT_H_
#define _8192CD_BR_EXT_H_
#define NAT25_HASH_BITS 4
#define NAT25_HASH_SIZE (1 << NAT25_HASH_BITS)
#define NAT25_AGEING_TIME 300
#ifdef CL_IPV6_PASS
#define MAX_NETWORK_ADDR_LEN 17
#else
#define MAX_NETWORK_ADDR_LEN 11
#endif
struct nat25_network_db_entry
{
struct nat25_network_db_entry *next_hash;
struct nat25_network_db_entry **pprev_hash;
atomic_t use_count;
unsigned char macAddr[6];
unsigned long ageing_timer;
#ifdef __ECOS
unsigned int used;
#endif
unsigned char networkAddr[MAX_NETWORK_ADDR_LEN];
};
enum NAT25_METHOD {
NAT25_MIN,
NAT25_CHECK,
NAT25_INSERT,
NAT25_LOOKUP,
NAT25_PARSE,
NAT25_MAX
};
#endif // _8192CD_BR_EXT_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,381 @@
/*
* Copyright (c) 2011 Atheros Communications Inc.
* Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef RTK_NL80211
#define RTK_NL80211
#endif
#ifdef RTK_NL80211
#include "./wifi.h"/*cfg p2p cfg p2p*/
#include "osdep_service.h"
#define DSSET_IE_LEN 1
#define HTCAP_IE_LEN 26
#define HTINFO_IE_LEN 22
#define MAX_PROBED_SSIDS 32
#define VIF_NUM RTL8192CD_NUM_VWLAN //eric-vap
#define IF_NUM (VIF_NUM+2) //#vap + root + vxd
#define VIF_NAME_SIZE 10
/*cfg p2p cfg p2p*/
#define MAX_IE_LEN 768
#define MAX_ASSOC_REQ_LEN 512
#define MAX_ASSOC_RSP_LEN 512
// cliWW
extern void notify_cfg_evt(struct rtl8192cd_priv *priv, unsigned char *mac, int event, unsigned char *extra);
#define RATETAB_ENT(_rate, _rateid, _flags) { \
.bitrate = (_rate), \
.flags = (_flags), \
.hw_value = (_rateid), \
}
static struct ieee80211_rate realtek_rates[] = {
RATETAB_ENT(10, 0x1, 0),
RATETAB_ENT(20, 0x2, 0),
RATETAB_ENT(55, 0x4, 0),
RATETAB_ENT(110, 0x8, 0),
RATETAB_ENT(60, 0x10, 0),
RATETAB_ENT(90, 0x20, 0),
RATETAB_ENT(120, 0x40, 0),
RATETAB_ENT(180, 0x80, 0),
RATETAB_ENT(240, 0x100, 0),
RATETAB_ENT(360, 0x200, 0),
RATETAB_ENT(480, 0x400, 0),
RATETAB_ENT(540, 0x800, 0),
};
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
enum nl80211_chan_width {
NL80211_CHAN_WIDTH_20_NOHT,
NL80211_CHAN_WIDTH_20,
NL80211_CHAN_WIDTH_40,
NL80211_CHAN_WIDTH_80,
NL80211_CHAN_WIDTH_80p80,
NL80211_CHAN_WIDTH_160,
};
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
#define WLAN_CIPHER_SUITE_GCMP 0x000FAC08
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
#endif
#define realtek_g_rates (realtek_rates + 0)
#define realtek_g_rates_size 12
#define realtek_a_rates (realtek_rates + 4)
#define realtek_a_rates_size 8
#define realtek_g_htcap (IEEE80211_HT_CAP_SUP_WIDTH_20_40 | \
IEEE80211_HT_CAP_SGI_20 | \
IEEE80211_HT_CAP_SGI_40)
#define realtek_a_htcap (IEEE80211_HT_CAP_SUP_WIDTH_20_40 | \
IEEE80211_HT_CAP_SGI_20 | \
IEEE80211_HT_CAP_SGI_40)
#define realtek_a_vhtcap (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_80MHZ)
/* WMI_CONNECT_CMDID */
enum network_type {
INFRA_NETWORK = 0x01,
ADHOC_NETWORK = 0x02,
ADHOC_CREATOR = 0x04,
AP_NETWORK = 0x10,
};
enum scan_abort_case {
SCAN_ABORT_DEL_IFACE = 0,
SCAN_ABORT_START_AP,
};
#if 0/*cfg p2p cfg p2p*/
enum mgmt_type {
MGMT_BEACON = 0,
MGMT_PROBERSP = 1,
MGMT_ASSOCRSP = 2,
MGMT_ASSOCREQ = 3,
MGMT_PROBEREQ = 4,
};
#endif
static const u32 cipher_suites[] = {
WLAN_CIPHER_SUITE_WEP40,
WLAN_CIPHER_SUITE_WEP104,
WLAN_CIPHER_SUITE_TKIP,
WLAN_CIPHER_SUITE_CCMP,
WLAN_CIPHER_SUITE_AES_CMAC,
WLAN_CIPHER_SUITE_GCMP,
//CCKM_KRK_CIPHER_SUITE,
//WLAN_CIPHER_SUITE_SMS4,
};
#define CHAN2G(_channel, _freq, _flags) { \
.band = IEEE80211_BAND_2GHZ, \
.hw_value = (_channel), \
.center_freq = (_freq), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
#define CHAN5G(_channel, _flags) { \
.band = IEEE80211_BAND_5GHZ, \
.hw_value = (_channel), \
.center_freq = 5000 + (5 * (_channel)), \
.flags = (_flags), \
.max_antenna_gain = 0, \
.max_power = 30, \
}
static struct ieee80211_channel realtek_2ghz_channels[] = {
CHAN2G(1, 2412, IEEE80211_CHAN_NO_HT40MINUS),
CHAN2G(2, 2417, IEEE80211_CHAN_NO_HT40MINUS),
CHAN2G(3, 2422, IEEE80211_CHAN_NO_HT40MINUS),
CHAN2G(4, 2427, IEEE80211_CHAN_NO_HT40MINUS),
CHAN2G(5, 2432, 0),
CHAN2G(6, 2437, 0),
CHAN2G(7, 2442, 0),
CHAN2G(8, 2447, IEEE80211_CHAN_NO_HT40PLUS),
CHAN2G(9, 2452, IEEE80211_CHAN_NO_HT40PLUS),
CHAN2G(10, 2457, IEEE80211_CHAN_NO_HT40PLUS),
CHAN2G(11, 2462, IEEE80211_CHAN_NO_HT40PLUS),
CHAN2G(12, 2467, IEEE80211_CHAN_NO_HT40PLUS),
CHAN2G(13, 2472, IEEE80211_CHAN_NO_HT40PLUS),
CHAN2G(14, 2484, IEEE80211_CHAN_NO_HT40PLUS |
IEEE80211_CHAN_NO_HT40MINUS
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
| IEEE80211_CHAN_NO_OFDM
#endif
)
};
static struct ieee80211_channel realtek_5ghz_a_channels[] = {
/* UNII-1 */
CHAN5G(36, IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(40, IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(44, IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(48, IEEE80211_CHAN_NO_HT40PLUS),
/* UNII-2 */
CHAN5G(52,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(56,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(60,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(64,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS),
/* MID */
CHAN5G(100,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(104,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(108,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(112,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(116,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(120,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(124,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(128,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(132,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(136,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(140,
IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_HT40PLUS |
IEEE80211_CHAN_NO_HT40MINUS),
/* UNII-3 */
CHAN5G(149, IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(153, IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(157, IEEE80211_CHAN_NO_HT40MINUS),
CHAN5G(161, IEEE80211_CHAN_NO_HT40PLUS),
CHAN5G(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
};
static struct ieee80211_supported_band realtek_band_2ghz = {
.band = NL80211_BAND_2GHZ,
.n_channels = ARRAY_SIZE(realtek_2ghz_channels),
.channels = realtek_2ghz_channels,
.n_bitrates = realtek_g_rates_size,
.bitrates = realtek_g_rates,
.ht_cap = {
.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40,
.ht_supported = true,
.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
.ampdu_density = 7,
.mcs = {
.rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
.rx_highest = cpu_to_le16(300),
.tx_params = IEEE80211_HT_MCS_TX_DEFINED
}
}
};
static struct ieee80211_supported_band realtek_band_5ghz = {
.band = NL80211_BAND_5GHZ,
.n_channels = ARRAY_SIZE(realtek_5ghz_a_channels),
.channels = realtek_5ghz_a_channels,
.n_bitrates = realtek_a_rates_size,
.bitrates = realtek_a_rates,
.ht_cap = {
.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_RX_STBC,
.ht_supported = true,
.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
.ampdu_density = 7,
.mcs = {
.rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
.rx_highest = cpu_to_le16(300),
.tx_params = IEEE80211_HT_MCS_TX_DEFINED
}
},
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
.vht_cap = {
.vht_supported = true,
.cap = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | IEEE80211_VHT_CAP_SHORT_GI_80 |
IEEE80211_VHT_CAP_TXSTBC | IEEE80211_VHT_CAP_RXSTBC_1 |
#ifdef BEAMFORMING_SUPPORT
IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
(1 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT) | (1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT) |
#endif
IEEE80211_VHT_CAP_HTC_VHT | (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT),
.vht_mcs = {
.rx_mcs_map = cpu_to_le16(0xfffa),
.tx_mcs_map = cpu_to_le16(0xfffa),
.rx_highest = cpu_to_le16(780),
.tx_highest = cpu_to_le16(780),
}
}
#endif
};
struct rtk_clnt_info {
struct wpa_ie_info wpa_ie;
struct rsn_ie_info rsn_ie;
unsigned char assoc_req[MAX_ASSOC_REQ_LEN];
unsigned short assoc_req_len;
unsigned char assoc_rsp[MAX_ASSOC_RSP_LEN];
unsigned short assoc_rsp_len;
};
struct rtk_iface_info {
unsigned char used;
unsigned char ndev_name[32];
struct rtl8192cd_priv *priv;
};
struct survey_info_t {
unsigned int channel;
unsigned int chbusytime;
unsigned int rx_time;
unsigned int tx_time;
s8 noise;
};
struct rtknl {
struct class *cl;
struct device *dev;
struct wiphy *wiphy;
struct rtl8192cd_priv *priv;
struct net_device *ndev_add;
struct rtk_clnt_info clnt_info;
unsigned char num_vif;
int idx_vif;
unsigned char num_vap;
unsigned char num_vxd;
unsigned int vif_flag;
unsigned char wiphy_registered;
unsigned int cipher;
unsigned int wpa;
unsigned int psk;
unsigned int sha256;
unsigned char ndev_name[VIF_NUM][VIF_NAME_SIZE];
unsigned char ndev_name_vxd[VIF_NAME_SIZE];
unsigned char root_ifname[VIF_NAME_SIZE];
unsigned char root_mac[ETH_ALEN];
unsigned char vap_mac[VIF_NUM][ETH_ALEN];
struct rtl8192cd_priv *priv_root;
struct rtl8192cd_priv *priv_vxd;
struct rtk_iface_info rtk_iface[VIF_NUM+2];
//for survey_dump
struct survey_info_t survey_info[ARRAY_SIZE(realtek_5ghz_a_channels)];
/* By brian, to support per channel statistic
unsigned int chbusytime;
unsigned int rx_time;
unsigned int tx_time;
*/
//openwrt_psd
unsigned int psd_chnl;
unsigned int psd_bw;
unsigned int psd_pts;
unsigned int psd_fft_info[1040];
//openwrt_tx_power_use
unsigned int pwr_rate;
int pwr_cur;
int pwr_set_dbm;
unsigned char keep_legacy;
};
/* HT Capabilities Info field within HT Capabilities element */
#define HT_CAP_INFO_SHORT_GI20MHZ ((u16) BIT(5))
#define HT_CAP_INFO_SHORT_GI40MHZ ((u16) BIT(6))
/* VHT Defines */
#define VHT_CAP_SHORT_GI_80 ((u32) BIT(5))
#if defined(VAP_MAC_DRV_READ_FLASH)
int read_flash_hw_mac_vap( unsigned char *mac, int vap_idx);
#endif
unsigned char is_WRT_scan_iface(const char* if_name); //eric-vap
void realtek_cfg80211_inform_ss_result(struct rtl8192cd_priv *priv);
struct rtknl *realtek_cfg80211_create(void);
int realtek_rtknl_init(struct rtknl *rtk);
int realtek_cfg80211_init(struct rtknl *rtk,struct rtl8192cd_priv *priv);
int realtek_interface_add(struct rtl8192cd_priv *priv, struct rtknl *rtk, const char *name,
enum nl80211_iftype type, u8 fw_vif_idx, u8 nw_type);
int realtek_cfg80211_deinit(struct rtl8192cd_priv *priv, struct rtknl *rtk);
int realtek_interface_del(struct rtl8192cd_priv *priv, struct rtknl *rtk, struct net_device *ndev);
int realtek_cfg80211_destroy(struct rtknl *rtk);
int event_indicate_cfg80211(struct rtl8192cd_priv *priv, unsigned char *mac, int event, void *extra);
void close_vxd_vap(struct rtl8192cd_priv *priv_root);
int check_5M10M_config(struct rtl8192cd_priv *priv);
void realtek_change_iftype(struct rtl8192cd_priv *priv ,enum nl80211_iftype type);
void rtk_cfg80211_rx_mgmt(struct rtl8192cd_priv *priv , struct rx_frinfo *pfrinfo, unsigned char channel);
#ifdef RTK_NL80211_HS_CLI
void realtek_cfg80211_RemainOnChExpire(unsigned long task_priv);
#endif
#endif /* RTK_NL80211 */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,113 @@
/*
* Header file for API-compatible handling routines
*
*
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#ifndef _8192CD_COMAPI_H_
#define _8192CD_COMAPI_H_
#include "./8192cd.h"
typedef struct rtl8192cd_priv RTL_PRIV;
#define MAX_CONFIG_FILE_SIZE (64*1024) // for 8192, added to 64k
#define MAX_PARAM_BUF_SIZE (1024) // for 8192, added to 20k
#ifdef CONFIG_RTL_COMAPI_CFGFILE
/* Following is a example for PARAMETERs completely compatible to other vendors'
* configure file - chris 2010/02/01 */
#undef VENDOR_PARAM_COMPATIBLE
#ifdef VENDOR_PARAM_COMPATIBLE
int Set_CountryRegion_Proc (RTL_PRIV *priv, char *arg);
int Set_CountryRegionABand_Proc (RTL_PRIV *priv, char *arg);
int Set_SSID_Proc (RTL_PRIV *priv, char *arg);
struct mib_cfg_func{
char name[20]; /*mib name*/
int (*set_proc)(RTL_PRIV *priv, char *arg);
};
static struct mib_cfg_func *TMP_MIBCFG, RTL_SUPPORT_MIBCFG[] = {
{"CountryRegion", Set_CountryRegion_Proc},
{"CountryRegionABand", Set_CountryRegionABand_Proc},
{"SSID", Set_SSID_Proc}
};
int Set_CountryRegion_Proc(RTL_PRIV *priv, char *arg)
{
int val = simple_strtol(arg, 0 ,10);
if (DOMAIN_FCC <= val && val <= DOMAIN_MAX ) {
priv->pmib->dot11StationConfigEntry.dot11RegDomain = val;
return TRUE;
} else {
printk("contry region out of range [%d-%d]\n", DOMAIN_FCC, DOMAIN_MAX);
return FALSE;
}
}
int Set_CountryRegionABand_Proc(RTL_PRIV *priv, char *arg)
{
int val = simple_strtol(arg, 0 ,10);
priv->pmib->dot11StationConfigEntry.dot11RegDomainABand = val;
return TRUE;
}
int Set_SSID_Proc(RTL_PRIV *priv, char *arg)
{
strcpy(priv->pmib->dot11StationConfigEntry.dot11DesiredSSID, arg);
return TRUE;
}
#else
extern int set_mib(struct rtl8192cd_priv *priv, unsigned char *data);
#endif //VENDOR_PARAM_COMPATIBLE
#endif //CONFIG_RTL_COMAPI_CFGFILE
#ifdef WIFI_WPAS_CLI
#define WPA_IE_ID 0xdd
#define WPA2_IE_ID 0x30
#define RSN_HEADER_LEN 4
#define WPA_SELECTOR_LEN 4
#define RSN_SELECTOR_LEN 4
#define VENDOR_SPECIFIC_IE 221
#ifdef CONFIG_RTL_WAPI_SUPPORT
#ifndef IW_AUTH_WAPI_VERSION_1
#define IW_AUTH_WAPI_VERSION_1 0x00000008
#endif
#ifndef IW_AUTH_KEY_MGMT_WAPI_PSK
#define IW_AUTH_KEY_MGMT_WAPI_PSK 0x04
#endif
#ifndef IW_AUTH_KEY_MGMT_WAPI_CERT
#define IW_AUTH_KEY_MGMT_WAPI_CERT 0x08
#endif
#ifndef IW_AUTH_WAPI_ENABLED
#define IW_AUTH_WAPI_ENABLED 0x20
#endif
#ifndef IW_ENCODE_ALG_SM4
#define IW_ENCODE_ALG_SM4 0x20
#endif
#endif // CONFIG_RTL_WAPI_SUPPORT
#endif // WIFI_WPAS_CLI
#endif // _8192CD_COMAPI_H_

View File

@ -0,0 +1,386 @@
/*
* Debug headler file. It defines various print out method
*
* $Id: 8192cd_debug.h,v 1.2.4.2 2010/12/01 13:38:00 button Exp $
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#ifndef _8192CD_DEBUG_H_
#define _8192CD_DEBUG_H_
#if 1
//#define _MESH_MOD_
#define printMac(da) printk("%02X:%02X:%02X:%02X:%02X:%02X\n", 0xff&*(da), 0xff&*(da+1), 0xff&*(da+2), 0xff&*(da+3), 0xff&*(da+4), 0xff&*(da+5));
#define printMac4(pframe) {\
printMac(GetAddr1Ptr(pframe));\
printMac(GetAddr2Ptr(pframe));\
printMac(GetAddr3Ptr(pframe));\
printMac(GetAddr4Ptr(pframe));\
}
#define printHex(d,n) {int i; \
for(i=0; i<n; i++) { printk("%02X:", *(d+i)); \
if( i%40==39) printk("\n "); \
} }
#endif
#ifndef MAC2STR
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
/*
* Compact form for string representation of MAC address
* To be used, e.g., for constructing dbus paths for P2P Devices
*/
#define COMPACT_MACSTR "%02x%02x%02x%02x%02x%02x"
#endif
#ifdef _DEBUG_RTL8192CD_
extern unsigned long rtl8192cd_debug_err; /* err flag */
extern unsigned long rtl8192cd_debug_info; /* info flag */
extern unsigned long rtl8192cd_debug_trace; /* trace flag */
extern unsigned long rtl8192cd_debug_warn; /* warn flag */
/* Bit definition for bit31-bit8 of rtl8190_debug */
enum _module_define_ {
_OSDEP_ = 0x00000001,
_SME_ = 0x00000002,
_IOCTL_ = 0x00000004,
_TX_ = 0x00000008,
_RX_ = 0x00000010,
_HW_ = 0x00000020,
_SECURITY_ = 0x00000040,
_UTIL_ = 0x00000080,
_TKIP_ = 0x00000100,
_AES_ = 0x00000200,
_HOST_ = 0x00000400,
_BR_EXT_ = 0x00000800,
_EEPROM_ = 0x00001000,
_PSK_ = 0x00002000,
_MP_ = 0x00004000,
_MIB_ = 0x00008000,
_LED_ = 0x00010000,
_WPS_ = 0x00020000,
_DHW_ = 0x00040000,
_HAL_ = 0x00080000,
_DM_ = 0x00100000,
_88E_HW_ = 0x00200000,
_DFS_ = 0x00400000,
_OTHER_ = 0x00800000,
_MESH_SME_ = 0x02000000,
_MESH_SECURITY_ = 0x04000000,
_MESH_TX_ = 0x08000000,
_MESH_RX_ = 0x10000000,
_MESH_UTIL_ = 0x20000000,
#ifdef CONFIG_POWER_SAVE
_PWR_CTRL_ = 0x40000000,
#else
_MESH_ROUTE_ = 0x40000000,
#endif
_DM_COM_ = 0x80000000,
};
#if defined(_8192CD_OSDEP_C_)
#define _MODULE_DEFINE _OSDEP_
#define _MODULE_NAME "osdep"
#elif defined(_8192CD_SME_C_)
#define _MODULE_DEFINE _SME_
#define _MODULE_NAME "sme"
#elif defined(_8192CD_IOCTL_C_)
#define _MODULE_DEFINE _IOCTL_
#define _MODULE_NAME "ioctl"
#elif defined(_8192CD_PROC_C_)
#define _MODULE_DEFINE _PROC_
#define _MODULE_NAME "proc"
#elif defined(_8192CD_TX_C_)
#define _MODULE_DEFINE _TX_
#define _MODULE_NAME "tx"
#elif defined(_8192CD_RX_C_)
#define _MODULE_DEFINE _RX_
#define _MODULE_NAME "rx"
#elif defined(_8192CD_HW_C_)
#define _MODULE_DEFINE _HW_
#define _MODULE_NAME "hw"
#elif defined(_8192D_HW_C_)
#define _MODULE_DEFINE _DHW_
#define _MODULE_NAME "dhw"
#elif defined(_8192CD_SECURITY_C_)
#define _MODULE_DEFINE _SECURITY_
#define _MODULE_NAME "security"
#elif defined(_8192CD_UTILS_C_)
#define _MODULE_DEFINE _UTIL_
#define _MODULE_NAME "util"
#elif defined(_8192CD_TKIP_C_)
#define _MODULE_DEFINE _TKIP_
#define _MODULE_NAME "tkip"
#elif defined(_8192CD_AES_C_)
#define _MODULE_DEFINE _AES_
#define _MODULE_NAME "aes"
#elif defined(_8192CD_BR_EXT_C_)
#define _MODULE_DEFINE _BR_EXT_
#define _MODULE_NAME "br_ext"
#elif defined(_8192CD_EEPROM_C_)
#define _MODULE_DEFINE _EEPROM_
#define _MODULE_NAME "eeprom"
#elif defined(_8192CD_PSK_C_)
#define _MODULE_DEFINE _PSK_
#define _MODULE_NAME "psk"
#elif defined(_8192CD_MP_C_)
#define _MODULE_DEFINE _MP_
#define _MODULE_NAME "mp"
#elif defined(_8192CD_MIB_C_)
#define _MODULE_DEFINE _MIB_
#define _MODULE_NAME "mib"
#elif defined(_8192CD_DMEM_C_)
//not yet
#elif defined(_HAL8192CDM_C_)
#define _MODULE_DEFINE _HAL_
#define _MODULE_NAME "hal"
#elif defined(_8192CD_A4_STA_C_)
#define _MODULE_DEFINE _A4STA_
#define _MODULE_NAME "a4_sta"
#elif defined(_8192CD_WSCD_C_)
#define _MODULE_DEFINE _WPS_
#define _MODULE_NAME "wps"
#elif defined(_MESH_SME_C_)
#define _MODULE_DEFINE _MESH_SME_
#define _MODULE_NAME "mesh_sme"
#elif defined(_MESH_TX_C_)
#define _MODULE_DEFINE _MESH_TX_
#define _MODULE_NAME "mesh_tx"
#elif defined(_MESH_RX_C_)
#define _MODULE_DEFINE _MESH_RX_
#define _MODULE_NAME "mehs_rx"
#elif defined(_MESH_SECURITY_C_)
#define _MODULE_DEFINE _MESH_SECURITY_
#define _MODULE_NAME "mesh_secutiry"
#elif defined(_MESH_UTILS_C_)
#define _MODULE_DEFINE _MESH_UTIL_
#define _MODULE_NAME "mesh_util"
#elif defined(_MESH_ROUTE_C_)
#define _MODULE_DEFINE _MESH_ROUTE_
#define _MODULE_NAME "mesh_route"
#elif defined(_8192CD_PWRCTRL_C_)
#define _MODULE_DEFINE _PWR_CTRL_
#define _MODULE_NAME "pwr_ctrl"
#elif defined(_MESH_PROC_C_)
#define _MODULE_DEFINE _MESH_PROC_
#define _MODULE_NAME "mesh_proc"
#elif defined(_MESH_11KV_C_)
//not yet
#elif defined(_HAL8192CDM_C_)
#define _MODULE_DEFINE _DM_
#define _MODULE_NAME "DM"
#elif defined(_8188E_HW_C_)
#define _MODULE_DEFINE _88E_HW_
#define _MODULE_NAME "88E_hw"
#elif defined(_HALDM_COMMON_C_)
#define _MODULE_DEFINE _DM_COM_
#define _MODULE_NAME "DM_COM"
#elif defined(_8812_HW_C_)
#define _MODULE_DEFINE _OTHER_
#define _MODULE_NAME "8812_hw"
#elif defined(_8192CD_HOST_C_)
#define _MODULE_DEFINE _HOST_
#define _MODULE_NAME "host"
#elif defined(_8192CD_LED_C_)
#define _MODULE_DEFINE _LED_
#define _MODULE_NAME "led"
#elif defined(_8192CD_DFS_C_)
#define _MODULE_DEFINE _DFS_
#define _MODULE_NAME "dfs"
#else
#define _MODULE_DEFINE _OTHER_
#define _MODULE_NAME "other"
#endif
/* Macro for DEBUG_ERR(), DEBUG_TRACE(), DEBUG_WARN(), DEBUG_INFO() */
#ifdef __GNUC__
#ifdef CONFIG_RTL8671
#define DEBUG_ERR printk
#define DEBUG_TRACE printk
#define DEBUG_INFO printk
#define DEBUG_WARN printk
#define _DEBUG_ERR printk
#define _DEBUG_INFO printk
#define DBFENTER
#define DBFEXIT
#define PRINT_INFO printk
#else
#define __DEBUG_ERR(name, fmt, args...) \
if (rtl8192cd_debug_err&_MODULE_DEFINE) \
printk("%s-"_MODULE_NAME"-err: " fmt, name, ## args);
#define __DEBUG_TRACE(name) \
if (rtl8192cd_debug_trace&_MODULE_DEFINE) \
printk("%s-"_MODULE_NAME"-trace: %s----->\n", name, (char *)__FUNCTION__);
#define __DEBUG_INFO(name, fmt, args...) \
if (rtl8192cd_debug_info&_MODULE_DEFINE) \
printk("%s-"_MODULE_NAME"-info: " fmt, name, ## args);
#define __DEBUG_WARN(name, fmt, args...) \
if (rtl8192cd_debug_warn&_MODULE_DEFINE) \
printk("%s-"_MODULE_NAME"-warn: " fmt, name, ## args);
#define DEBUG_ERR(fmt, args...) __DEBUG_ERR(priv->dev->name, fmt, ## args)
#define DEBUG_INFO(fmt, args...) __DEBUG_INFO(priv->dev->name, fmt, ## args)
#define DEBUG_TRACE __DEBUG_TRACE(priv->dev->name)
#define DEBUG_WARN(fmt, args...) __DEBUG_WARN(priv->dev->name, fmt, ## args)
#define _DEBUG_ERR(fmt, args...) __DEBUG_ERR("wlan", fmt, ## args)
#define _DEBUG_INFO(fmt, args...) __DEBUG_INFO("wlan", fmt, ## args)
#define _DEBUG_TRACE __DEBUG_TRACE("wlan")
#define _DEBUG_WARN(fmt, args...) __DEBUG_WARN("wlan", fmt, ## args)
#define DBFENTER printk("----->%s\n", (char *)__FUNCTION__)
#define DBFEXIT printk("%s----->\n", (char *)__FUNCTION__)
#define PRINT_INFO(fmt, args...) printk(fmt, ## args)
#endif
#endif // __GNUC__
/*
#ifdef __DRAYTEK_OS__
#define __FUNCTION__ ""
#define DEBUG_ERR Print
#define DEBUG_INFO Print
#define DEBUG_TRACE
#define DEBUG_WARN Print
#define _DEBUG_ERR DEBUG_ERR
#define _DEBUG_INFO DEBUG_INFO
#define _DEBUG_TRACE DEBUG_TRACE
#define _DEBUG_WARN DEBUG_WARN
#define DBFENTER
#define DBFEXIT
#define PRINT_INFO Print
#endif // __DRAYTEK_OS__
#ifdef GREEN_HILL
#define DEBUG_ERR printk
#define DEBUG_INFO printk
#define DEBUG_TRACE printk
#define DEBUG_WARN printk
#define _DEBUG_ERR printk
#define _DEBUG_INFO printk
#define _DEBUG_TRACE printk
#define _DEBUG_WARN printk
#define DBFENTER printk
#define DBFEXIT printk
#define PRINT_INFO printk
#endif // GREEN_HILL
*/
#else // not _DEBUG_RTL8192CD_
#ifdef __GNUC__
#define DEBUG_ERR(fmt, args...) {}
#define DEBUG_INFO(fmt, args...) {}
#define DEBUG_TRACE {}
#define DEBUG_WARN(fmt, args...) {}
#define _DEBUG_ERR(fmt, args...) {}
#define _DEBUG_INFO(fmt, args...) {}
#define _DEBUG_TRACE {}
#define _DEBUG_WARN(fmt, args...) {}
#define DBFENTER {}
#define DBFEXIT {}
#define PRINT_INFO(fmt, args...) {}
#endif // __GNUC__
/*
#ifdef __DRAYTEK_OS__
#define __FUNCTION__ ""
#define DEBUG_ERR
#define DEBUG_INFO
#define DEBUG_TRACE
#define DEBUG_WARN
#define _DEBUG_ERR
#define _DEBUG_INFO
#define _DEBUG_TRACE
#define _DEBUG_WARN
#define DBFENTER
#define DBFEXIT
#define PRINT_INFO
#endif // __DRAYTEK_OS__
#ifdef GREEN_HILL
#define DEBUG_ERR(fmt, args...) {}
#define DEBUG_INFO(fmt, args...) {}
#define DEBUG_TRACE {}
#define DEBUG_WARN(fmt, args...) {}
#define _DEBUG_ERR(fmt, args...) {}
#define _DEBUG_INFO(fmt, args...) {}
#define _DEBUG_TRACE {}
#define _DEBUG_WARN(fmt, args...) {}
#define DBFENTER {}
#define DBFEXIT {}
#define PRINT_INFO(fmt, args...) {}
#endif // GREEN_HILL
*/
#endif // _DEBUG_RTL8192CD_
#endif // _8192CD_DEBUG_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,286 @@
/*
* D-MEM supporting module for RTL8190 802.11N wireless NIC on RTL865x platform
*
* $Id: 8192cd_dmem.c,v 1.2 2010/01/19 06:04:03 jimmylin Exp $
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#ifdef __ECOS
#include <cyg/io/eth/rltk/819x/wrapper/sys_support.h>
#include <cyg/io/eth/rltk/819x/wrapper/skbuff.h>
#include <cyg/io/eth/rltk/819x/wrapper/timer.h>
#include <cyg/io/eth/rltk/819x/wrapper/wrapper.h>
#endif
#ifndef _8192CD_DMEM_C_
#define _8192CD_DMEM_C_
#include "./8192cd.h"
//#include "./8190n_fastExtDev.h"
#include "./8192cd_cfg.h"
#ifdef RTL8192CD_VARIABLE_USED_DMEM
#include "./8192cd_dmem.h"
#define RTL8192CD_MAX_SPEEDUP_STA 2
#define RTL8192CD_SPEEDUP_PRIV_COUNT 1
/* ========================== All variables using D-MEM ========================== */
static void rtl8192cd_dmem_AID_OBJ_init(void);
static void *rtl8192cd_dmem_AID_OBJ_alloc(void *miscInfo);
static void rtl8192cd_dmem_AID_OBJ_free(void *miscInfo);
static void rtl8192cd_dmem_pmib_init(void);
static void *rtl8192cd_dmem_pmib_alloc(void *miscInfo);
static void rtl8192cd_dmem_pmib_free(void *miscInfo);
#ifdef PRIV_STA_BUF
extern struct aid_obj *alloc_sta_obj(struct rtl8192cd_priv*);
extern void free_sta_obj(struct rtl8192cd_priv *priv, struct aid_obj *obj);
#endif
static _rtl8192cd_dmem_callBack_t _8192cd_dmem_callBack_list[] =
{
/* ID Init CallBack Allocate CallBack Free CallBack */
{ AID_OBJ, rtl8192cd_dmem_AID_OBJ_init, rtl8192cd_dmem_AID_OBJ_alloc, rtl8192cd_dmem_AID_OBJ_free},
{ PMIB, rtl8192cd_dmem_pmib_init, rtl8192cd_dmem_pmib_alloc, rtl8192cd_dmem_pmib_free},
/* ==================================================================== */
{ _RTL8192CD_DMEM_ITEM_MAX, NULL, NULL},
};
/* ========================== External APIs of D-MEM module ========================== */
/*
Initiation function for DMEM library
*/
void rtl8192cd_dmem_init( void )
{
_rtl8192cd_dmem_callBack_t *ptr;
ptr = &_8192cd_dmem_callBack_list[0];
while ( (ptr->id > _RTL8192CD_DMEM_ITEM_MIN) &&
(ptr->id < _RTL8192CD_DMEM_ITEM_MAX))
{
/* Call the Callback function to decide the memory of allocated */
if (ptr->initCallBackFunc)
{
((_dummyFunc_void_void)(ptr->initCallBackFunc))();
}
/* Next Entry */
ptr ++;
}
}
void *rtl8192cd_dmem_alloc( enum _RTL8192CD_DMEM_ITEM_ID id, void *miscInfo )
{
void *retval;
_rtl8192cd_dmem_callBack_t *ptr;
retval = NULL;
if ( (id <= _RTL8192CD_DMEM_ITEM_MIN) ||
(id >= _RTL8192CD_DMEM_ITEM_MAX))
{
printk("%s %d : ERROR (%d)\n", __FUNCTION__, __LINE__, id);
goto out;
}
ptr = &_8192cd_dmem_callBack_list[0];
while ( ptr->allcateCallBackFunc )
{
if ( ptr->id == id )
{
/* Call the Callback function to decide the memory of allocated */
retval = ((_dummyFunc_voidStar_voidStar)(ptr->allcateCallBackFunc))(miscInfo);
goto out;
}
/* Next Entry */
ptr ++;
}
out:
return retval;
}
void rtl8192cd_dmem_free( enum _RTL8192CD_DMEM_ITEM_ID id, void *miscInfo )
{
_rtl8192cd_dmem_callBack_t *ptr;
if ( (id <= _RTL8192CD_DMEM_ITEM_MIN) ||
(id >= _RTL8192CD_DMEM_ITEM_MAX))
{
printk("%s %d : ERROR (%d)\n", __FUNCTION__, __LINE__, id);
goto out;
}
ptr = &_8192cd_dmem_callBack_list[0];
while ( ptr->freeCallBackFunc )
{
if ( ptr->id == id )
{
/* Call the Callback function to decide the memory of allocated */
((_dummyFunc_void_voidStar)(ptr->freeCallBackFunc))(miscInfo);
goto out;
}
/* Next Entry */
ptr ++;
}
out:
return;
}
/* ========================== Internal APIs for per-variable of D-MEM module ========================== */
/* ==============================================
*
* AID_OBJ
*
*
* ============================================== */
__DRAM_IN_865X struct aid_obj _rtl8192cd_aid_Array[RTL8192CD_MAX_SPEEDUP_STA];
void *_rtl8192cd_aid_externalMem_Array[NUM_STAT];
static void rtl8192cd_dmem_AID_OBJ_init(void)
{
memset(_rtl8192cd_aid_Array, 0, sizeof(struct aid_obj) * RTL8192CD_MAX_SPEEDUP_STA);
memset(_rtl8192cd_aid_externalMem_Array, 0, sizeof(_rtl8192cd_aid_externalMem_Array));
}
static void *rtl8192cd_dmem_AID_OBJ_alloc(void *miscInfo)
{
/* For AID_OBJ : miscInfo would be [unsigned int *] to decision the index of aidarray to allocate */
unsigned int index = *((unsigned int*)miscInfo);
if ( (index < 0) ||
(index >= NUM_STAT))
{
printk("%s %d : ERROR ( Index : %d )\n", __FUNCTION__, __LINE__, index);
return NULL;
}
/* Allocate from external memory */
if ( index >= RTL8192CD_MAX_SPEEDUP_STA )
{
#ifdef PRIV_STA_BUF
_rtl8192cd_aid_externalMem_Array[index] = alloc_sta_obj(NULL);
#else
_rtl8192cd_aid_externalMem_Array[index] = kmalloc(sizeof(struct aid_obj), GFP_ATOMIC);
#endif
if (_rtl8192cd_aid_externalMem_Array[index] == NULL)
{
printk("%s %d : Error : Allocation FAILED!\n", __FUNCTION__, __LINE__);
return NULL;
}
return _rtl8192cd_aid_externalMem_Array[index];
}
memset(&(_rtl8192cd_aid_Array[index]), 0, sizeof(struct aid_obj));
return (void*)(&(_rtl8192cd_aid_Array[index]));
}
static void rtl8192cd_dmem_AID_OBJ_free(void *miscInfo)
{
/* For AID_OBJ : miscInfo would be [unsigned int *] to decision the index of aidarray to free */
unsigned int index = *((unsigned int*)miscInfo);
if ( (index < 0) ||
(index >= NUM_STAT))
{
printk("%s %d : ERROR ( Index : %d )\n", __FUNCTION__, __LINE__, index);
return;
}
/* Free memory to external memory module */
if ( index >= RTL8192CD_MAX_SPEEDUP_STA )
{
if ( _rtl8192cd_aid_externalMem_Array[index] )
{
#ifdef PRIV_STA_BUF
free_sta_obj(NULL, _rtl8192cd_aid_externalMem_Array[index]);
#else
kfree(_rtl8192cd_aid_externalMem_Array[index]);
#endif
_rtl8192cd_aid_externalMem_Array[index] = NULL;
}
return;
}
memset(&(_rtl8192cd_aid_Array[index]), 0, sizeof(struct aid_obj));
}
/* =================== The following variable are mapped to PRIV =================== */
/* ==============================================
*
* PMIB
*
*
* ============================================== */
__DRAM_IN_865X struct wifi_mib _rtl8192cd_pmib[RTL8192CD_SPEEDUP_PRIV_COUNT];
int _rtl8192cd_pmib_usageMap[RTL8192CD_SPEEDUP_PRIV_COUNT];
static void rtl8192cd_dmem_pmib_init(void)
{
memset(_rtl8192cd_pmib_usageMap, 0, sizeof(int) * RTL8192CD_SPEEDUP_PRIV_COUNT);
memset(_rtl8192cd_pmib, 0, sizeof(struct wifi_mib) * RTL8192CD_SPEEDUP_PRIV_COUNT);
}
static void *rtl8192cd_dmem_pmib_alloc(void *miscInfo)
{
int idx ;
/* miscInfo is useless */
for ( idx = 0 ; idx < RTL8192CD_SPEEDUP_PRIV_COUNT ; idx ++ )
{
if ( _rtl8192cd_pmib_usageMap[idx] == 0 )
{ /* Unused entry : use it */
_rtl8192cd_pmib_usageMap[idx] = 1;
memset(&(_rtl8192cd_pmib[idx]), 0, sizeof(struct wifi_mib));
return &(_rtl8192cd_pmib[idx]);
}
}
/* Allocate from externel memory if speedup PMIB is exhausted */
return kmalloc(sizeof(struct wifi_mib), GFP_ATOMIC);
}
static void rtl8192cd_dmem_pmib_free(void *miscInfo)
{
int idx;
/* miscInfo is pointed to the address of PMIB to free */
/* Free PMIB if it is speeded up by DMEM */
for ( idx = 0 ; idx < RTL8192CD_SPEEDUP_PRIV_COUNT ; idx ++ )
{
if ( (unsigned long)(&(_rtl8192cd_pmib[idx])) == (unsigned long)miscInfo )
{ /* Entry is found : free it */
memset(&(_rtl8192cd_pmib[idx]), 0, sizeof(struct wifi_mib));
_rtl8192cd_pmib_usageMap[idx] = 0;
return;
}
}
/* It would be allocated from external memory: kfree it */
kfree(miscInfo);
}
#endif // RTL8192CD_VARIABLE_USED_DMEM
#endif

View File

@ -0,0 +1,44 @@
/*
* Header of D-MEM supporting module for RTL8190 802.11N wireless NIC on RTL865x platform
*
* $Id: 8192cd_dmem.h,v 1.1 2009/11/06 12:26:48 victoryman Exp $
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#ifndef _8192CD_DMEM_H
#define _8192CD_DMEM_H
/* ========================= External ========================= */
enum _RTL8192CD_DMEM_ITEM_ID {
_RTL8192CD_DMEM_ITEM_MIN,
/* ============================== Add here ============================== */
AID_OBJ,
PMIB,
/* =================================================================== */
_RTL8192CD_DMEM_ITEM_MAX,
};
void rtl8192cd_dmem_init( void );
void *rtl8192cd_dmem_alloc( enum _RTL8192CD_DMEM_ITEM_ID id, void *miscInfo );
void rtl8192cd_dmem_free( enum _RTL8192CD_DMEM_ITEM_ID id, void *miscInfo );
/* ========================= Internal ========================= */
typedef void* (*_dummyFunc_voidStar_voidStar)(void*);
typedef void (*_dummyFunc_void_voidStar)(void*);
typedef void (*_dummyFunc_void_void)(void);
typedef struct _rtl8192cd_dmem_list_s
{
int id;
void * initCallBackFunc;
void * allcateCallBackFunc;
void * freeCallBackFunc;
} _rtl8192cd_dmem_callBack_t;
#endif /* _8192CD_DMEM_H */

View File

@ -0,0 +1,579 @@
/*
* Routines to read and write eeprom
*
* $Id: 8192cd_eeprom.c,v 1.1 2009/11/06 12:26:48 victoryman Exp $
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#define _8192CD_EEPROM_C_
#if 0
#ifdef __KERNEL__
#include <linux/config.h>
#include <linux/module.h>
#endif
#include "./8192cd_cfg.h"
#include "./8192cd.h"
#include "./8192cd_hw.h"
#include "./8192cd_util.h"
#include "./8192cd_debug.h"
#define VOID void
#define EEPROM_MAX_SIZE 256
#define CSR_EEPROM_CONTROL_REG _9346CR_
#define CLOCK_RATE 50 //100us
static VOID ShiftOutBits(struct rtl8192cd_priv *priv, USHORT data, USHORT count);
static USHORT ShiftInBits(struct rtl8192cd_priv *priv);
static VOID RaiseClock(struct rtl8192cd_priv *priv, USHORT *x);
static VOID LowerClock(struct rtl8192cd_priv *priv, USHORT *x);
static VOID EEpromCleanup(struct rtl8192cd_priv *priv);
static USHORT WaitEEPROMCmdDone(struct rtl8192cd_priv *priv);
static VOID StandBy(struct rtl8192cd_priv *priv);
//*****************************************************************************
//
// I/O based Read EEPROM Routines
//
//*****************************************************************************
//-----------------------------------------------------------------------------
// Procedure: ReadEEprom
//
// Description: This routine serially reads one word out of the EEPROM.
//
// Arguments:
// Reg - EEPROM word to read.
//
// Returns:
// Contents of EEPROM word (Reg).
//-----------------------------------------------------------------------------
static USHORT
ReadEEprom(
struct rtl8192cd_priv *priv,
UCHAR AddressSize,
USHORT Reg)
{
USHORT x;
USHORT data;
// select EEPROM, reset bits, set EECS
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
x &= ~(EEDI | EEDO | EESK | CR9346_EEM0);
x |= CR9346_EEM1 | EECS;
RTL_W8(CSR_EEPROM_CONTROL_REG, (UCHAR)x);
// write the read opcode and register number in that order
// The opcode is 3bits in length, reg is 6 bits long
ShiftOutBits(priv, EEPROM_READ_OPCODE, 3);
ShiftOutBits(priv, Reg, AddressSize);
// Now read the data (16 bits) in from the selected EEPROM word
data = ShiftInBits(priv);
EEpromCleanup(priv);
return data;
}
//-----------------------------------------------------------------------------
// Procedure: ShiftOutBits
//
// Description: This routine shifts data bits out to the EEPROM.
//
// Arguments:
// data - data to send to the EEPROM.
// count - number of data bits to shift out.
//
// Returns: (none)
//-----------------------------------------------------------------------------
static VOID
ShiftOutBits(
struct rtl8192cd_priv *priv,
USHORT data,
USHORT count)
{
USHORT x,mask;
mask = 0x01 << (count - 1);
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
x &= ~(EEDO | EEDI);
do
{
x &= ~EEDI;
if(data & mask)
x |= EEDI;
RTL_W8(CSR_EEPROM_CONTROL_REG, (UCHAR)x);
delay_us(CLOCK_RATE);
RaiseClock(priv, &x);
LowerClock(priv, &x);
mask = mask >> 1;
} while(mask);
x &= ~EEDI;
RTL_W8(CSR_EEPROM_CONTROL_REG, (UCHAR)x);
}
//-----------------------------------------------------------------------------
// Procedure: ShiftInBits
//
// Description: This routine shifts data bits in from the EEPROM.
//
// Arguments:
//
// Returns:
// The contents of that particular EEPROM word
//-----------------------------------------------------------------------------
static USHORT
ShiftInBits(
struct rtl8192cd_priv *priv)
{
USHORT x,d,i;
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
x &= ~( EEDO | EEDI);
d = 0;
for(i=0; i<16; i++)
{
d = d << 1;
RaiseClock(priv, &x);
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
x &= ~(EEDI);
if(x & EEDO)
d |= 1;
LowerClock(priv, &x);
}
return d;
}
//-----------------------------------------------------------------------------
// Procedure: RaiseClock
//
// Description: This routine raises the EEPOM's clock input (EESK)
//
// Arguments:
// x - Ptr to the EEPROM control register's current value
//
// Returns: (none)
//-----------------------------------------------------------------------------
static VOID
RaiseClock(
struct rtl8192cd_priv *priv,
USHORT *x)
{
*x = *x | EESK;
RTL_W8(CSR_EEPROM_CONTROL_REG, (UCHAR)(*x));
delay_us(CLOCK_RATE);
}
//-----------------------------------------------------------------------------
// Procedure: LowerClock
//
// Description: This routine lower's the EEPOM's clock input (EESK)
//
// Arguments:
// x - Ptr to the EEPROM control register's current value
//
// Returns: (none)
//-----------------------------------------------------------------------------
static VOID
LowerClock(
struct rtl8192cd_priv *priv,
USHORT *x)
{
*x = *x & ~EESK;
RTL_W8(CSR_EEPROM_CONTROL_REG, (UCHAR)(*x));
delay_us(CLOCK_RATE);
}
//-----------------------------------------------------------------------------
// Procedure: EEpromCleanup
//
// Description: This routine returns the EEPROM to an idle state
//
// Arguments:
//
// Returns: (none)
//-----------------------------------------------------------------------------
static VOID
EEpromCleanup(
struct rtl8192cd_priv *priv)
{
USHORT x;
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
x &= ~(EECS | EEDI);
RTL_W8(CSR_EEPROM_CONTROL_REG, (UCHAR)x);
RaiseClock(priv, &x);
LowerClock(priv, &x);
}
//*****************************************************************************
//
// EEPROM Write Routines
//
//*****************************************************************************
//-----------------------------------------------------------------------------
// Procedure: D100UpdateChecksum
//
// Description: Calculates the checksum and writes it to the EEProm. This
// routine assumes that the checksum word is the last word in
// a 64 word EEPROM. It calculates the checksum accroding to
// the formula: Checksum = 0xBABA - (sum of first 63 words).
//
// Arguments:
// Adapter - Ptr to this card's adapter data structure
//
// Returns: (none)
//-----------------------------------------------------------------------------
/*static VOID
UpdateChecksum(
struct rtl8192cd_priv *priv)
{
USHORT Checksum=0;
// USHORT Iter;
// for (Iter = 0; Iter < 0x3F; Iter++)
// Checksum += ReadEEprom( CSRBaseIoAddress, Iter );
Checksum = (USHORT)0xBABA - Checksum;
// WriteEEprom( CSRBaseIoAddress, 0x3F, Checksum );
}*/
//-----------------------------------------------------------------------------
// Procedure: WriteEEprom
//
// Description: This routine writes a word to a specific EEPROM location.
//
// Arguments:
// Adapter - Ptr to this card's adapter data structure.
// reg - The EEPROM word that we are going to write to.
// data - The data (word) that we are going to write to the EEPROM.
//
// Returns: (none)
//-----------------------------------------------------------------------------
static VOID
WriteEEprom(
struct rtl8192cd_priv *priv,
UCHAR AddressSize,
USHORT reg,
USHORT data)
{
UCHAR x;
// select EEPROM, mask off ASIC and reset bits, set EECS
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
x &= ~(EEDI | EEDO | EESK | CR9346_EEM0);
x |= CR9346_EEM1 | EECS;
RTL_W8(CSR_EEPROM_CONTROL_REG, x);
ShiftOutBits(priv, EEPROM_EWEN_OPCODE, 5);
/////ShiftOutBits(CSRBaseIoAddress, reg, 4);
ShiftOutBits(priv, 0, 6);
StandBy(priv);
// Erase this particular word. Write the erase opcode and register
// number in that order. The opcode is 3bits in length; reg is 6 bits long.
ShiftOutBits(priv, EEPROM_ERASE_OPCODE, 3);
ShiftOutBits(priv, reg, AddressSize);
if (WaitEEPROMCmdDone(priv) == FALSE)
{
return;
}
StandBy(priv);
// write the new word to the EEPROM
// send the write opcode the EEPORM
ShiftOutBits(priv, EEPROM_WRITE_OPCODE, 3);
// select which word in the EEPROM that we are writing to.
ShiftOutBits(priv, reg, AddressSize);
// write the data to the selected EEPROM word.
ShiftOutBits(priv, data, 16);
if (WaitEEPROMCmdDone(priv) == FALSE)
{
// DbgPrint("D100: Failed EEPROM Write");
return;
}
StandBy(priv);
ShiftOutBits(priv, EEPROM_EWDS_OPCODE, 5);
ShiftOutBits(priv, reg, 4);
EEpromCleanup(priv);
return;
}
//-----------------------------------------------------------------------------
// Procedure: WaitEEPROMCmdDone
//
// Description: This routine waits for the the EEPROM to finish its command.
// Specifically, it waits for EEDO (data out) to go high.
//
// Arguments:
// Adapter - Ptr to this card's adapter data structure.
//
// Returns:
// TRUE - If the command finished
// FALSE - If the command never finished (EEDO stayed low)
//-----------------------------------------------------------------------------
static USHORT
WaitEEPROMCmdDone(
struct rtl8192cd_priv *priv)
{
UCHAR x;
USHORT i;
StandBy(priv);
for (i=0; i<200; i++)
{
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
if (x & EEDO)
return (TRUE);
delay_us(CLOCK_RATE);
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Procedure: StandBy
//
// Description: This routine lowers the EEPROM chip select (EECS) for a few
// microseconds.
//
// Arguments:
// Adapter - Ptr to this card's adapter data structure.
//
// Returns: (none)
//-----------------------------------------------------------------------------
static VOID
StandBy(
struct rtl8192cd_priv *priv)
{
UCHAR x;
x = RTL_R8(CSR_EEPROM_CONTROL_REG);
x &= ~(EECS | EESK);
RTL_W8(CSR_EEPROM_CONTROL_REG, x);
delay_us(CLOCK_RATE);
x |= EECS;
RTL_W8(CSR_EEPROM_CONTROL_REG, x);
delay_us(CLOCK_RATE);
}
//*****************************************************************************
//
// Main routines to read and write EEPROM
//
//*****************************************************************************
#define NUM_11A_CHANNEL 46
const UCHAR ChannelNumberListOf11a[] = {
26, 28, 30, 32,
34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64,
66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86,
100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
149, 153, 157, 161
};
#define READ_EEPROM(addr) ReadEEprom(priv, EepromAddressSize, addr)
#define WRITE_EEPROM(a,d) WriteEEprom(priv, EepromAddressSize, a, d)
int ReadAdapterInfo(struct rtl8192cd_priv *priv, int entry_id, void *data)
{
USHORT Index;
USHORT usValue;
ULONG curRCR;
UCHAR EepromAddressSize;
UCHAR TxPowerLevel[64];
if (!priv->EE_Cached)
{
curRCR = RTL_R32(_RCR_);
EepromAddressSize = (curRCR & _9356SEL_)? 8 : 6;
// ID
priv->EE_ID = (unsigned int)READ_EEPROM(EEPROM_ID);
DEBUG_INFO("ID 0x%04X\n", (USHORT)priv->EE_ID);
if (priv->EE_ID != RTL8180_EEPROM_ID) {
DEBUG_INFO("ID is invalid\n");
priv->EE_AutoloadFail = TRUE;
}
else
priv->EE_AutoloadFail = FALSE;
// Version
// priv->EE_Version = (unsigned int)READ_EEPROM((USHORT)(EEPROM_VERSION >> 1));
usValue = READ_EEPROM(0x7C >> 1);
priv->EE_Version = ((usValue&0xff00)>>8);
DEBUG_INFO("Version 0x%x\n", (USHORT)priv->EE_Version);
// MAC address
for (Index = 0; Index < 6; Index += 2) {
usValue = READ_EEPROM((USHORT)((EEPROM_NODE_ADDRESS_BYTE_0 + Index)>>1));
priv->EE_Mac[Index] = usValue & 0xff;
priv->EE_Mac[Index+1] = ((usValue&0xff00) >> 8);
}
DEBUG_INFO("Mac %02X-%02X-%02X-%02X-%02X-%02X\n",
priv->EE_Mac[0], priv->EE_Mac[1], priv->EE_Mac[2], priv->EE_Mac[3],
priv->EE_Mac[4], priv->EE_Mac[5]);
// for identifying empty EEPROM
if (!priv->EE_AutoloadFail)
{
// Tx Power Level
memset(priv->EE_TxPower_CCK, 0, sizeof(priv->EE_TxPower_CCK));
for (Index = 0; Index < MAX_CCK_CHANNEL_NUM; Index += 2) {
usValue = READ_EEPROM((USHORT)((EEPROM_TX_POWER_LEVEL_0 + Index) >> 1));
*((USHORT *)(&priv->EE_TxPower_CCK[Index])) = usValue;
}
memset(priv->EE_TxPower_OFDM, 0, sizeof(priv->EE_TxPower_OFDM));
for (Index = 0; Index < NUM_11A_CHANNEL; Index += 2) {
usValue = READ_EEPROM((USHORT)((EEPROM_11A_CHANNEL_TX_POWER_LEVEL_OFFSET + Index) >> 1));
*((USHORT *)(&TxPowerLevel[Index])) = usValue;
}
for (Index = 0; Index < NUM_11A_CHANNEL; Index++)
priv->EE_TxPower_OFDM[ChannelNumberListOf11a[Index] - 1] = TxPowerLevel[Index];
for (Index = 0; Index < MAX_CCK_CHANNEL_NUM; Index += 2) {
usValue = READ_EEPROM((USHORT)((EEPROM_11G_CHANNEL_OFDM_TX_POWER_LEVEL_OFFSET + Index) >> 1));
*((USHORT *)(&TxPowerLevel[Index])) = usValue;
}
for (Index = 0; Index < MAX_CCK_CHANNEL_NUM; Index++)
priv->EE_TxPower_OFDM[Index] = TxPowerLevel[Index];
#ifdef _DEBUG_RTL8192CD_
if (rtl8192cd_debug_info & _MODULE_DEFINE) {
extern void debug_out(char *label, unsigned char *data, int data_length);
debug_out("EEProm CCK TxPower", priv->EE_TxPower_CCK, MAX_CCK_CHANNEL_NUM);
debug_out("EEProm OFDM TxPower", priv->EE_TxPower_OFDM, MAX_OFDM_CHANNEL_NUM);
}
#endif
// RF chip id
// priv->EE_RFTypeID = (unsigned int)(READ_EEPROM((USHORT)(EEPROM_RF_CHIP_ID >> 1)) & 0x00f);
priv->EE_RFTypeID = (unsigned int)(READ_EEPROM((USHORT)(0x28 >> 1)) & 0x80 ) >> 7;
DEBUG_INFO("RF ID 0x%02X\n", (UCHAR)priv->EE_RFTypeID);
// AnaParm
usValue = READ_EEPROM((USHORT)((EEPROM_ANA_PARM + 2) >> 1));
priv->EE_AnaParm = (unsigned int)(usValue << 16);
usValue = READ_EEPROM((USHORT)(EEPROM_ANA_PARM >> 1));
priv->EE_AnaParm |= usValue;
DEBUG_INFO("AnaParm 0x%08X\n", priv->EE_AnaParm);
usValue = READ_EEPROM((USHORT)((EEPROM_ANA_PARM2 + 2) >> 1));
priv->EE_AnaParm2 = (unsigned int)(usValue << 16);
usValue = READ_EEPROM((USHORT)(EEPROM_ANA_PARM2 >> 1));
priv->EE_AnaParm2 |= usValue;
DEBUG_INFO("AnaParm2 0x%08X\n", priv->EE_AnaParm2);
//add CrystalCap, joshua 20080502
priv->EE_CrystalCap = (((unsigned int) READ_EEPROM( 0x2A >> 1)) & 0xf000) >> 12;
priv->pmib->dot11RFEntry.crystalCap = priv->EE_CrystalCap;
DEBUG_INFO("CrystalCap 0x%08X\n", priv->EE_CrystalCap);
}
priv->EE_Cached = 1;
}
if ((data != NULL) && (!priv->EE_AutoloadFail))
{
switch(entry_id)
{
case EEPROM_RF_CHIP_ID:
*((UCHAR *)data) = (UCHAR)priv->EE_RFTypeID;
break;
case EEPROM_NODE_ADDRESS_BYTE_0:
memcpy(data, priv->EE_Mac, MACADDRLEN);
break;
case EEPROM_TX_POWER_LEVEL_0:
memcpy(data, priv->EE_TxPower_CCK, MAX_CCK_CHANNEL_NUM);
break;
case EEPROM_11G_CHANNEL_OFDM_TX_POWER_LEVEL_OFFSET:
memcpy(data, priv->EE_TxPower_OFDM, MAX_OFDM_CHANNEL_NUM);
break;
default:
DEBUG_INFO("not support this id yet\n");
return 0;
}
return 1;
}
else
return 0;
}
int WriteAdapterInfo(struct rtl8192cd_priv *priv, int entry_id, void *data)
{
USHORT Index;
USHORT usValue;
ULONG curRCR;
UCHAR EepromAddressSize;
priv->EE_Cached = 0;
curRCR = RTL_R32(_RCR_);
EepromAddressSize = (curRCR & _9356SEL_)? 8 : 6;
switch(entry_id)
{
case EEPROM_TX_POWER_LEVEL_0:
Index = ((USHORT)((int)data)) & 0xfffe;
usValue = *((USHORT *)(&priv->EE_TxPower_CCK[Index]));
WRITE_EEPROM((USHORT)((EEPROM_TX_POWER_LEVEL_0 + Index) >> 1), usValue);
break;
case EEPROM_11G_CHANNEL_OFDM_TX_POWER_LEVEL_OFFSET:
Index = ((USHORT)((int)data)) & 0xfffe;
usValue = *((USHORT *)(&priv->EE_TxPower_OFDM[Index]));
WRITE_EEPROM((USHORT)((EEPROM_11G_CHANNEL_OFDM_TX_POWER_LEVEL_OFFSET + Index) >> 1), usValue);
break;
default:
return 0;
}
return 1;
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,646 @@
/*
* Handling routines for LED lightening functions
*
* $Id: 8192cd_led.c,v 1.1 2012/05/04 12:49:07 jimmylin Exp $
*
* Copyright (c) 2012 Realtek Semiconductor Corp.
*
* 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.
*/
#define _8192CD_LED_C_
#include "./8192cd_cfg.h"
#include "./8192cd.h"
#include "./8192cd_headers.h"
#include "./8192cd_debug.h"
// for SW LED ----------------------------------------------------
#ifdef RTL8190_SWGPIO_LED
static void set_swGpio_LED(struct rtl8192cd_priv *priv, unsigned int ledNum, int flag)
{
unsigned int ledItem; /* parameter to decode GPIO item */
if (ledNum >= SWLED_GPIORT_CNT)
return;
ledItem = SWLED_GPIORT_ITEM(LED_ROUTE, ledNum);
if (ledItem & SWLED_GPIORT_ENABLEMSK)
{
/* get the corresponding information (GPIO number/Active high or low) of LED */
int gpio;
int activeMode; /* !=0 : Active High, ==0 : Active Low */
gpio = ledItem & SWLED_GPIORT_RTBITMSK;
activeMode = ledItem & SWLED_GPIORT_HLMSK;
if (flag) { /* Turn ON LED */
if (activeMode) /* Active High */
RTL_W8(0x90, RTL_R8(0x90) | BIT(gpio));
else /* Active Low */
RTL_W8(0x90, RTL_R8(0x90) &~ BIT(gpio));
}
else { /* Turn OFF LED */
if (activeMode) /* Active High */
RTL_W8(0x90, RTL_R8(0x90) &~ BIT(gpio));
else /* Active Low */
RTL_W8(0x90, RTL_R8(0x90) | BIT(gpio));
}
}
}
#endif // RTL8190_SWGPIO_LED
static void set_sw_LED0(struct rtl8192cd_priv *priv, int flag)
{
#ifdef RTL8190_SWGPIO_LED
if (LED_ROUTE)
set_swGpio_LED(priv, 0, flag);
#elif defined(CONFIG_RTL8672) || defined(NOT_RTK_BSP)
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfffffff0) | LED0SV);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfffffff0);
#else
if ((GET_CHIP_VER(priv) == VERSION_8188E)||(GET_CHIP_VER(priv) == VERSION_8192E)) {
#ifdef RTLWIFINIC_GPIO_CONTROL
if (flag)
RTLWIFINIC_GPIO_write(5, 0);
else
RTLWIFINIC_GPIO_write(5, 1);
#endif
}
else if ((GET_CHIP_VER(priv) == VERSION_8812E)) {
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfffff0ff) | LED1SV);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfffff0ff);
}
else if (GET_CHIP_VER(priv) == VERSION_8881A) {
if (flag)
writel(readl(IO_TYPE_CAST(0xb800350c)) | BIT(24), IO_TYPE_CAST(0xb800350c));
else
writel(readl(IO_TYPE_CAST(0xb800350c)) & ~BIT(24), IO_TYPE_CAST(0xb800350c));
}
else {
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfffffff0) | LED0SV);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfffffff0);
}
#endif
}
static void set_sw_LED1(struct rtl8192cd_priv *priv, int flag)
{
#ifdef RTL8190_SWGPIO_LED
if (LED_ROUTE)
set_swGpio_LED(priv, 1, flag);
#elif defined(CONFIG_RTL8672) || defined(NOT_RTK_BSP)
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfffff0ff) | LED1SV);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfffff0ff);
#else
if ((GET_CHIP_VER(priv) == VERSION_8188E)||(GET_CHIP_VER(priv) == VERSION_8192E)) {
#ifdef RTLWIFINIC_GPIO_CONTROL
if (flag)
RTLWIFINIC_GPIO_write(5, 0);
else
RTLWIFINIC_GPIO_write(5, 1);
#endif
}
#if defined(CONFIG_RTL_92D_SUPPORT)
else if (GET_CHIP_VER(priv) == VERSION_8192D) {
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfffff0ff) | LED1SV_92D);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfffff0ff);
}
#endif
else if (GET_CHIP_VER(priv) == VERSION_8192C){
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfffff0ff) | LED1SV);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfffff0ff);
}
#endif
}
static void set_sw_LED2(struct rtl8192cd_priv *priv, int flag)
{
#ifdef RTL8190_SWGPIO_LED
if (LED_ROUTE)
set_swGpio_LED(priv, 2, flag);
#elif defined(CONFIG_RTL8672) || defined(NOT_RTK_BSP)
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfff0ffff) | LED2SV);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfff0ffff);
#else
if ((GET_CHIP_VER(priv) == VERSION_8188E)||(GET_CHIP_VER(priv) == VERSION_8192E)) {
#ifdef RTLWIFINIC_GPIO_CONTROL
if (flag)
RTLWIFINIC_GPIO_write(5, 0);
else
RTLWIFINIC_GPIO_write(5, 1);
#endif
}
#if defined(CONFIG_RTL_92D_SUPPORT)
else if (GET_CHIP_VER(priv) == VERSION_8192D) {
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfff0ffff) | LED2SV_92D);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfff0ffff);
}
#endif
else if (GET_CHIP_VER(priv) == VERSION_8192C){
if (flag)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG) & 0xfff0ffff) | LED2SV);
else
RTL_W32(LEDCFG, RTL_R32(LEDCFG) & 0xfff0ffff);
}
#endif
}
static void LED_Interval_timeout(unsigned long task_priv)
{
struct rtl8192cd_priv *priv = (struct rtl8192cd_priv *)task_priv;
int led_on_time= LED_ON_TIME;
if (!(priv->drv_state & DRV_STATE_OPEN))
return;
#ifdef PCIE_POWER_SAVING
if ((priv->pwr_state != L1) && (priv->pwr_state != L2))
#endif
{
if (!priv->pshare->set_led_in_progress) {
#if defined(CONFIG_RTL8672) || defined(NOT_RTK_BSP)
#ifdef CONFIG_RTL_88E_SUPPORT
if (GET_CHIP_VER(priv) == VERSION_8188E)
set_sw_LED2(priv, priv->pshare->LED_Toggle);
else
#endif
#ifdef CONFIG_WLAN_HAL_8192EE
if (GET_CHIP_VER(priv) == VERSION_8192E)
set_sw_LED0(priv, priv->pshare->LED_Toggle);
else
#endif
#ifdef CONFIG_RTL_8812_SUPPORT
if (GET_CHIP_VER(priv) == VERSION_8812E)
set_sw_LED1(priv, priv->pshare->LED_Toggle);
else
#endif
#endif // CONFIG_RTL8672 || NOT_RTK_BSP
if ((LED_TYPE == LEDTYPE_SW_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LINKTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_ENABLETXRXDATA) ||
((LED_TYPE == LEDTYPE_SW_ADATA_GDATA) && (priv->pshare->curr_band == BAND_5G)) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA_92D) ||
(LED_TYPE == LEDTYPE_SW_LED1_GPIO9_LINKTXRX_92D) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX_92D))
{
if ((LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA_92D) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX_92D))
set_sw_LED2(priv, priv->pshare->LED_Toggle);
else if (LED_TYPE == LEDTYPE_SW_LED1_GPIO9_LINKTXRX_92D)
set_sw_LED1(priv, priv->pshare->LED_Toggle);
else
set_sw_LED0(priv, priv->pshare->LED_Toggle);
} else {
set_sw_LED1(priv, priv->pshare->LED_Toggle);
}
}
}
if( (LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA) &&
(!(OPMODE & WIFI_ASOC_STATE))) //client not assco , mark_led
{
led_on_time = LED_NOBLINK_TIME;
}
if ( priv->pshare->LED_Toggle == priv->pshare->LED_ToggleStart) {
mod_timer(&priv->pshare->LED_Timer, jiffies + priv->pshare->LED_Interval);
} else {
if (LED_TYPE == LEDTYPE_SW_CUSTOM1)
mod_timer(&priv->pshare->LED_Timer, jiffies + priv->pshare->LED_Interval);
else
mod_timer(&priv->pshare->LED_Timer, jiffies + led_on_time);
}
priv->pshare->LED_Toggle = (priv->pshare->LED_Toggle + 1) % 2;
}
void enable_sw_LED(struct rtl8192cd_priv *priv, int init)
{
#if (defined(HW_ANT_SWITCH) || defined(SW_ANT_SWITCH))&&( defined(CONFIG_RTL_92C_SUPPORT) || defined(CONFIG_RTL_92D_SUPPORT))
int b23 = RTL_R32(LEDCFG) & BIT(23);
#endif
if (LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA)
if (!(OPMODE & WIFI_STATION_STATE)) // if it is not Client mode , then run orignal 12 type
LED_TYPE = LEDTYPE_SW_LED2_GPIO8_ENABLETXRXDATA ;
// configure mac to use SW LED
#if defined(CONFIG_RTL8672) || defined(NOT_RTK_BSP)
#ifdef CONFIG_RTL_88E_SUPPORT
if (GET_CHIP_VER(priv) == VERSION_8188E)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG)&0xFF00FFFF) | LED2EN | LED2SV);
else
#endif
#ifdef CONFIG_WLAN_HAL_8192EE
if (GET_CHIP_VER(priv) == VERSION_8192E)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG)&0xFFFFFF00) | LED0SV);
else
#endif
#else // !CONFIG_RTL8672 && !NOT_RTK_BSP
#if defined(CONFIG_RTL_88E_SUPPORT) || defined(CONFIG_WLAN_HAL_8192EE) //mark_ecos
if ((GET_CHIP_VER(priv) == VERSION_8188E)||(GET_CHIP_VER(priv) == VERSION_8192E))
{
#ifdef RTLWIFINIC_GPIO_CONTROL
RTLWIFINIC_GPIO_config(5, 0x10);
#endif
}
else
#endif
#endif // CONFIG_RTL8672 || NOT_RTK_BSP
if (GET_CHIP_VER(priv) == VERSION_8812E)
RTL_W32(LEDCFG, BIT(13) | LED1SV);
else
#ifdef CONFIG_WLAN_HAL_8881A
if (GET_CHIP_VER(priv) == VERSION_8881A) {
writel(readl(IO_TYPE_CAST(0xb8000044)) | BIT(15) | BIT(16), IO_TYPE_CAST(0xb8000044));
writel(readl(IO_TYPE_CAST(0xb8003500)) & ~BIT(24), IO_TYPE_CAST(0xb8003500));
writel(readl(IO_TYPE_CAST(0xb8003508)) | BIT(24), IO_TYPE_CAST(0xb8003508));
writel(readl(IO_TYPE_CAST(0xb800350c)) | BIT(24), IO_TYPE_CAST(0xb800350c));
} else
#endif
{
if (LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG)&0xFF00FFFF) | LED2EN | LED2SV);
else if (LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG)&0xFF00FFFF) | LED2EN | LED2SV);
#ifdef CONFIG_RTL_92D_SUPPORT
else if ((LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX_92D) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA_92D))
RTL_W32(LEDCFG,(RTL_R32(LEDCFG)&0xFF00FFFF)| LED2DIS_92D | LED2SV_92D);
else if (LED_TYPE == LEDTYPE_SW_LED1_GPIO9_LINKTXRX_92D)
RTL_W32(LEDCFG, (RTL_R32(LEDCFG)&0xFFFF00FF)|LED1DIS_92D | LED1SV_92D);
#endif
else if ((LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRXDATA))
RTL_W32(LEDCFG, (RTL_R32(LEDCFG)&0xFF00FFFF) | GP8_LED | LED2EN | LED2SV);
else
RTL_W32(LEDCFG, LED2SV | LED1SV | LED0SV);
}
priv->pshare->LED_Interval = LED_INTERVAL_TIME;
priv->pshare->LED_Toggle = 0;
priv->pshare->LED_ToggleStart = LED_OFF;
priv->pshare->LED_tx_cnt_log = 0;
priv->pshare->LED_rx_cnt_log = 0;
priv->pshare->LED_tx_cnt = 0;
priv->pshare->LED_rx_cnt = 0;
if ((LED_TYPE == LEDTYPE_SW_ENABLE_TXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_ENABLETXRXDATA)) {
set_sw_LED0(priv, LED_ON);
set_sw_LED1(priv, LED_OFF);
if (LED_TYPE == LEDTYPE_SW_ENABLETXRXDATA)
priv->pshare->LED_ToggleStart = LED_ON;
} else if ((LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_ENABLETXRXDATA_92D)) {
set_sw_LED2(priv, LED_ON);
priv->pshare->LED_ToggleStart = LED_ON;
} else if (LED_TYPE == LEDTYPE_SW_ADATA_GDATA) {
priv->pshare->LED_ToggleStart = LED_ON;
if (priv->pshare->curr_band == BAND_5G) {
set_sw_LED0(priv, LED_ON);
set_sw_LED1(priv, LED_OFF);
}
else { // 11G
set_sw_LED0(priv, LED_OFF);
set_sw_LED1(priv, LED_ON);
}
}
else if (LED_TYPE == LEDTYPE_SW_ENABLETXRXDATA_1) {
set_sw_LED0(priv, LED_OFF);
set_sw_LED1(priv, LED_ON);
priv->pshare->LED_ToggleStart = LED_ON;
}
else if ((LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA) ) {
set_sw_LED2(priv, LED_ON);
priv->pshare->LED_ToggleStart = LED_ON;
}
else if ((LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRXDATA)) {
set_sw_LED2(priv, LED_OFF);
}
else {
set_sw_LED0(priv, LED_OFF);
set_sw_LED1(priv, LED_OFF);
set_sw_LED2(priv, LED_OFF);
}
#if (defined(HW_ANT_SWITCH) || defined(SW_ANT_SWITCH))&&( defined(CONFIG_RTL_92C_SUPPORT) || defined(CONFIG_RTL_92D_SUPPORT))
RTL_W32(LEDCFG, b23 | RTL_R32(LEDCFG));
#endif
if (init) {
init_timer(&priv->pshare->LED_Timer);
#if defined(CONFIG_PCI_HCI)
priv->pshare->LED_Timer.data = (unsigned long) priv;
priv->pshare->LED_Timer.function = &LED_Interval_timeout;
#elif defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI)
priv->pshare->LED_Timer.data = (unsigned long) &priv->pshare->LED_Timer_event;
priv->pshare->LED_Timer.function = timer_event_timer_fn;
INIT_TIMER_EVENT_ENTRY(&priv->pshare->LED_Timer_event,
LED_Interval_timeout, (unsigned long)priv);
#endif
mod_timer(&priv->pshare->LED_Timer, jiffies + priv->pshare->LED_Interval);
}
}
void disable_sw_LED(struct rtl8192cd_priv *priv)
{
if (timer_pending(&priv->pshare->LED_Timer))
del_timer_sync(&priv->pshare->LED_Timer);
if ((LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ENABLETXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA)) {
set_sw_LED2(priv, LED_OFF);
} else {
set_sw_LED0(priv, LED_OFF);
set_sw_LED1(priv, LED_OFF);
set_sw_LED2(priv, LED_OFF);
}
}
void calculate_sw_LED_interval(struct rtl8192cd_priv *priv)
{
unsigned int delta = 0;
int i, scale_num=0;
if (priv->pshare->set_led_in_progress)
return;
if( (LED_TYPE == LEDTYPE_SW_LED2_GPIO8_ASOCTXRXDATA) &&
(!(OPMODE & WIFI_ASOC_STATE))) //client not assco , mark_led
{
priv->pshare->LED_Interval = LED_NOBLINK_TIME; // force one second
priv->pshare->LED_tx_cnt_log = priv->pshare->LED_tx_cnt; // sync tx/rx cnt
priv->pshare->LED_rx_cnt_log = priv->pshare->LED_rx_cnt;
return ;
}
// calculate counter delta
delta += UINT32_DIFF(priv->pshare->LED_tx_cnt, priv->pshare->LED_tx_cnt_log);
delta += UINT32_DIFF(priv->pshare->LED_rx_cnt, priv->pshare->LED_rx_cnt_log);
priv->pshare->LED_tx_cnt_log = priv->pshare->LED_tx_cnt;
priv->pshare->LED_rx_cnt_log = priv->pshare->LED_rx_cnt;
// update interval according to delta
if (delta == 0) {
if (LED_TYPE == LEDTYPE_SW_CUSTOM1) {
if (priv->pshare->LED_Interval != RTL_SECONDS_TO_JIFFIES(1)) {
priv->pshare->LED_Interval = RTL_SECONDS_TO_JIFFIES(1);
mod_timer(&priv->pshare->LED_Timer, jiffies + priv->pshare->LED_Interval);
}
} else {
if (priv->pshare->LED_Interval == LED_NOBLINK_TIME)
mod_timer(&priv->pshare->LED_Timer, jiffies + priv->pshare->LED_Interval);
else {
priv->pshare->LED_Interval = LED_NOBLINK_TIME;
if (LED_TYPE == LEDTYPE_SW_ENABLETXRXDATA)
priv->pshare->LED_Toggle = LED_ON;
}
}
} else {
if ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11G) ||
(priv->pmib->dot11BssType.net_work_type & WIRELESS_11A))
scale_num = LED_MAX_PACKET_CNT_AG / LED_MAX_SCALE;
else
scale_num = LED_MAX_PACKET_CNT_B / LED_MAX_SCALE;
if ((LED_TYPE == LEDTYPE_SW_LINK_TXRX) ||
(LED_TYPE == LEDTYPE_SW_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED1_GPIO9_LINKTXRX_92D) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX_92D) ||
(LED_TYPE == LEDTYPE_SW_CUSTOM1))
scale_num = scale_num*2;
for (i=1; i<=LED_MAX_SCALE; i++) {
if (delta < i*scale_num)
break;
}
if (priv->pshare->rf_ft_var.ledBlinkingFreq > 1) {
i = i*priv->pshare->rf_ft_var.ledBlinkingFreq;
if (i > LED_MAX_SCALE)
i = LED_MAX_SCALE;
}
priv->pshare->LED_Interval = ((LED_MAX_SCALE-i+1)*LED_INTERVAL_TIME)/LED_MAX_SCALE;
if (priv->pshare->LED_Interval < LED_ON_TIME)
priv->pshare->LED_Interval = LED_ON_TIME;
}
if ((LED_TYPE == LEDTYPE_SW_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LINKTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO8_LINKTXRXDATA) ||
(LED_TYPE == LEDTYPE_SW_LED1_GPIO9_LINKTXRX_92D) ||
(LED_TYPE == LEDTYPE_SW_LED2_GPIO10_LINKTXRX_92D)) {
if (priv->link_status)
priv->pshare->LED_ToggleStart = LED_ON;
else
priv->pshare->LED_ToggleStart = LED_OFF;
} else {
if (priv->pshare->set_led_in_progress)
return;
if ((LED_TYPE == LEDTYPE_SW_LINK_TXRX) ||
(LED_TYPE == LEDTYPE_SW_LINK_TXRXDATA)) {
if (priv->link_status)
set_sw_LED0(priv, LED_ON);
else
set_sw_LED0(priv, LED_OFF);
} else if (LED_TYPE == LEDTYPE_SW_ADATA_GDATA) {
if (priv->pshare->curr_band == BAND_5G) {
set_sw_LED0(priv, LED_ON);
set_sw_LED1(priv, LED_OFF);
} else { // 11A
set_sw_LED0(priv, LED_OFF);
set_sw_LED1(priv, LED_ON);
}
}
}
}
#if 0
void set_wireless_LED_steady_on(int led_num, struct net_device *dev)
{
struct rtl8192cd_priv *priv;
if (led_num != LED_0 && led_num != LED_1 && led_num != LED_2)
return;
#ifdef NETDEV_NO_PRIV
if (dev == NULL || netdev_priv(dev) == NULL)
return;
priv = ((struct rtl8192cd_priv *)netdev_priv(dev))->wlan_priv;
#else
if (dev == NULL || dev->priv == NULL)
return;
priv = (struct rtl8192cd_priv *)dev->priv;
#endif
if (priv->pshare == NULL)
return;
priv->pshare->set_led_in_progress = 1;
if ((LED_TYPE >= LEDTYPE_HW_TX_RX) && (LED_TYPE <= LEDTYPE_HW_LINKACT_INFRA)) {
enable_sw_LED(priv, 0);
}
else if ((LED_TYPE >= LEDTYPE_SW_LINK_TXRX) && (LED_TYPE < LEDTYPE_SW_MAX)) {
if (timer_pending(&priv->pshare->LED_Timer))
del_timer_sync(&priv->pshare->LED_Timer);
}
if (led_num == LED_0)
set_sw_LED0(priv, LED_ON);
else if (led_num == LED_1)
set_sw_LED1(priv, LED_ON);
else
set_sw_LED2(priv, LED_ON);
}
void recover_wireless_LED(struct net_device *dev)
{
struct rtl8192cd_priv *priv;
#ifdef NETDEV_NO_PRIV
if (dev == NULL || netdev_priv(dev) == NULL)
return;
priv = ((struct rtl8192cd_priv *)netdev_priv(dev))->wlan_priv;
#else
if (dev == NULL || dev->priv == NULL)
return;
priv = (struct rtl8192cd_priv *)dev->priv;
#endif
if (!priv->pshare->set_led_in_progress)
return;
// for HW/SW LED
if ((LED_TYPE >= LEDTYPE_HW_TX_RX) && (LED_TYPE <= LEDTYPE_HW_LINKACT_INFRA)) {
set_sw_LED0(priv, LED_OFF);
set_sw_LED1(priv, LED_OFF);
set_sw_LED2(priv, LED_OFF);
enable_hw_LED(priv, LED_TYPE);
}
else if ((LED_TYPE >= LEDTYPE_SW_LINK_TXRX) && (LED_TYPE < LEDTYPE_SW_MAX)) {
enable_sw_LED(priv, 0);
mod_timer(&priv->pshare->LED_Timer, jiffies + priv->pshare->LED_Interval);
}
priv->pshare->set_led_in_progress = 0;
}
#endif
void control_wireless_led(struct rtl8192cd_priv *priv, int enable)
{
if (enable == 0) {
priv->pshare->set_led_in_progress = 1;
set_sw_LED0(priv, LED_OFF);
set_sw_LED1(priv, LED_OFF);
set_sw_LED2(priv, LED_OFF);
}
else if (enable == 1) {
priv->pshare->set_led_in_progress = 1;
set_sw_LED0(priv, LED_ON);
set_sw_LED1(priv, LED_ON);
set_sw_LED2(priv, LED_ON);
}
else if (enable == 2) {
set_sw_LED0(priv, priv->pshare->LED_ToggleStart);
set_sw_LED1(priv, priv->pshare->LED_ToggleStart);
set_sw_LED2(priv, priv->pshare->LED_ToggleStart);
priv->pshare->set_led_in_progress = 0;
}
}
#ifdef CONFIG_RTL_ULINKER
static struct rtl8192cd_priv *root_priv = NULL;
void enable_sys_LED(struct rtl8192cd_priv *priv)
{
#ifdef RTLWIFINIC_GPIO_CONTROL
RTLWIFINIC_GPIO_config(4, 0x10);
#endif
root_priv = priv;
}
void renable_sw_LED(void)
{
struct rtl8192cd_priv *priv = root_priv;
if ((LED_TYPE >= LEDTYPE_SW_LINK_TXRX) && (LED_TYPE < LEDTYPE_SW_MAX)) {
priv->pshare->set_led_in_progress = 1;
disable_sw_LED(priv);
priv->pshare->set_led_in_progress = 0;
enable_sw_LED(priv, 1);
}
}
#endif /* #ifdef CONFIG_RTL_ULINKER */

View File

@ -0,0 +1,45 @@
#ifndef 8192CD_LOG_H
#define 8192CD_LOG_H
#if defined(CONFIG_RTL_LOG_DEBUG)
#if defined(LOG_ERROR)
#undef LOG_ERROR
#define LOG_ERROR(fmt, args...) do{ \
if(RTL_LogTypeMask.ERROR&&RTL_LogModuleMask.WIRELESS&&LOG_LIMIT)scrlog_printk("WLS-ERROR:"fmt, ## args); \
}while(0)
#endif
#if defined(LOG_MEM_ERROR)
#undef LOG_MEM_ERROR
#define LOG_MEM_ERROR(fmt, args...) do{ \
if(RTL_LogTypeMask.ERROR&&RTL_LogErrorMask.MEM&&RTL_LogModuleMask.WIRELESS&&LOG_LIMIT)scrlog_printk("WLS-MEM-ERROR:"fmt, ## args); \
}while(0)
#endif
#if defined(LOG_SKB_ERROR)
#undef LOG_SKB_ERROR
#define LOG_SKB_ERROR(fmt, args...) do{ \
if(RTL_LogTypeMask.ERROR&&RTL_LogErrorMask.SKB&&RTL_LogModuleMask.WIRELESS&&LOG_LIMIT)scrlog_printk("WLS-SKB-ERROR:"fmt, ## args); \
}while(0)
#endif
#if defined(LOG_WARN)
#undef LOG_WARN
#define LOG_WARN(fmt, args...) do{ \
if(RTL_LogTypeMask.WARN&&RTL_LogModuleMask.WIRELESS&&LOG_LIMIT)scrlog_printk("WLS-WARN:"fmt, ## args); \
}while(0)
#endif
#if defined(LOG_INFO)
#undef LOG_INFO
#define LOG_INFO(fmt, args...) do{ \
if(RTL_LogTypeMask.INFO&&RTL_LogModuleMask.WIRELESS&&LOG_LIMIT)scrlog_printk("WLS-INFO:"fmt, ## args); \
}while(0)
#endif
#endif
#endif

View File

@ -0,0 +1,555 @@
/*
* SNMP MIB module
*
* $Id: 8192cd_mib.c,v 1.1 2009/11/06 12:26:48 victoryman Exp $
*
* Copyright (c) 2009 Realtek Semiconductor Corp.
*
* 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.
*/
#define _8192CD_MIB_C_
#ifdef __KERNEL__
#include <linux/module.h>
#elif defined(__ECOS)
#include <cyg/io/eth/rltk/819x/wrapper/sys_support.h>
#include <cyg/io/eth/rltk/819x/wrapper/skbuff.h>
#include <cyg/io/eth/rltk/819x/wrapper/timer.h>
#include <cyg/io/eth/rltk/819x/wrapper/wrapper.h>
#endif
#include "./8192cd_cfg.h"
#ifdef SUPPORT_SNMP_MIB
#ifdef __KERNEL__
#include "./ieee802_mib.h"
#elif defined(__ECOS)
#include <cyg/io/eth/rltk/819x/wlan/ieee802_mib.h>
#endif
#include "./8192cd_headers.h"
#include "./8192cd_debug.h"
#include "./8192cd_mib.h"
extern int _convert_2_pwr_dot(char *s, int base);
extern int _atoi(char *s, int base);
struct mib_val dot11_mib_table[]={
//dot11StationConfigTable
{ {1, 1, 1, 1, 1, -1}, "dot11StationID", MIB_TYPE_PRIV, PRIV_OFFSET(dot11OperationEntry.hwaddr), PRIV_SIZE(dot11OperationEntry.hwaddr)},
{ {1, 1, 1, 2, 1, -1}, "dot11MediumOccupancyLimit ", MIB_TYPE_VAL, 100, 1},
{ {1, 1, 1, 3, 1, -1}, "dot11CFPollable", MIB_TYPE_VAL, 0, 1},
{ {1, 1, 1, 4, 1, -1}, "dot11CFPPeriod", MIB_TYPE_VAL, 0, 1},
{ {1, 1, 1, 5, 1, -1}, "dot11CFPMaxDuration", MIB_TYPE_VAL, 0, 1},
{ {1, 1, 1, 6, 1, -1}, "dot11AuthenticationResponseTimeOut", MIB_TYPE_VAL, REAUTH_TO*10, 4},
{ {1, 1, 1, 7, 1, -1}, "dot11PrivacyOptionImplemented", MIB_TYPE_VAL, 1, 1},
{ {1, 1, 1, 8, 1, -1}, "dot11PowerManagementMode", MIB_TYPE_VAL, 1, 1},
{ {1, 1, 1, 9, 1, -1}, "dot11DesiredSSID", MIB_TYPE_PRIV, PRIV_OFFSET(dot11StationConfigEntry.dot11DesiredSSID), 0},
{ {1, 1, 1, 10, 1, -1}, "dot11DesiredBSSType", MIB_TYPE_SNMP, SNMP_OFFSET(dot11DesiredBSSType), SNMP_SIZE(dot11DesiredBSSType)},
{ {1, 1, 1, 11, 1, -1}, "dot11OperationalRateSet", MIB_TYPE_SNMP1, SNMP_OFFSET(dot11OperationalRateSet), SNMP_OFFSET(dot11SupportedDataRatesNum)},
{ {1, 1, 1, 12, 1, -1}, "dot11BeaconPeriod", MIB_TYPE_PRIV, PRIV_OFFSET(dot11StationConfigEntry.dot11BeaconPeriod), PRIV_SIZE(dot11StationConfigEntry.dot11BeaconPeriod)},
{ {1, 1, 1, 13, 1, -1}, "dot11DTIMPeriod", MIB_TYPE_PRIV, PRIV_OFFSET(dot11StationConfigEntry.dot11DTIMPeriod), PRIV_SIZE(dot11StationConfigEntry.dot11DTIMPeriod)},
{ {1, 1, 1, 14, 1, -1}, "dot11AssociationResponseTimeOut", MIB_TYPE_VAL, REASSOC_TO*10, 4},
{ {1, 1, 1, 15, 1, -1}, "dot11DisassociateReason", MIB_TYPE_SNMP, SNMP_OFFSET(dot11DisassociateReason), SNMP_SIZE(dot11DisassociateReason)},
{ {1, 1, 1, 16, 1, -1}, "dot11DisassociateStation", MIB_TYPE_SNMP, SNMP_OFFSET(dot11DisassociateStation), SNMP_SIZE(dot11DisassociateStation)},
{ {1, 1, 1, 17, 1, -1}, "dot11DeauthenticateReason", MIB_TYPE_SNMP, SNMP_OFFSET(dot11DeauthenticateReason), SNMP_SIZE(dot11DeauthenticateReason)},
{ {1, 1, 1, 18, 1, -1}, "dot11DeauthenticateStation", MIB_TYPE_SNMP, SNMP_OFFSET(dot11DeauthenticateStation), SNMP_SIZE(dot11DeauthenticateStation)},
{ {1, 1, 1, 19, 1, -1}, "dot11AuthenticateFailStatus", MIB_TYPE_SNMP, SNMP_OFFSET(dot11AuthenticateFailStatus), SNMP_SIZE(dot11AuthenticateFailStatus)},
{ {1, 1, 1, 20, 1, -1}, "dot11AuthenticateFailStation", MIB_TYPE_SNMP, SNMP_OFFSET(dot11AuthenticateFailStation), SNMP_SIZE(dot11AuthenticateFailStation)},
{ {1, 1, 1, 24, 1, -1}, "dot11RegDomain", MIB_TYPE_PRIV, PRIV_OFFSET(dot11StationConfigEntry.dot11RegDomain), PRIV_SIZE(dot11StationConfigEntry.dot11RegDomain)},
{ {1, 1, 1, 25, 1, -1}, "dot11DataRate", MIB_TYPE_SNMP, SNMP_OFFSET(dot11DataRate), SNMP_SIZE(dot11DataRate)},
{ {1, 1, 1, 26, 1, -1}, "dot11ProtectionDisabled", MIB_TYPE_PRIV, PRIV_OFFSET(dot11StationConfigEntry.protectionDisabled), PRIV_SIZE(dot11StationConfigEntry.protectionDisabled)},
{ {1, 1, 1, 27, 1, -1}, "dot11nSTBC", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nSTBC), PRIV_SIZE(dot11nConfigEntry.dot11nSTBC)},
{ {1, 1, 1, 28, 1, -1}, "dot11nCoexist", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nCoexist), PRIV_SIZE(dot11nConfigEntry.dot11nCoexist)},
{ {1, 1, 1, 29, 1, -1}, "dot11nUse40M", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nUse40M), PRIV_SIZE(dot11nConfigEntry.dot11nUse40M)},
{ {1, 1, 1, 30, 1, -1}, "dot11n2ndChOffset", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11n2ndChOffset), PRIV_SIZE(dot11nConfigEntry.dot11n2ndChOffset)},
{ {1, 1, 1, 31, 1, -1}, "dot11nShortGIfor20M", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nShortGIfor20M), PRIV_SIZE(dot11nConfigEntry.dot11nShortGIfor20M)},
{ {1, 1, 1, 32, 1, -1}, "dot11nShortGIfor40M", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nShortGIfor40M), PRIV_SIZE(dot11nConfigEntry.dot11nShortGIfor40M)},
{ {1, 1, 1, 33, 1, -1}, "dot11nAMPDU", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nAMPDU), PRIV_SIZE(dot11nConfigEntry.dot11nAMPDU)},
{ {1, 1, 1, 34, 1, -1}, "dot11nAMSDU", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nAMSDU), PRIV_SIZE(dot11nConfigEntry.dot11nAMSDU)},
{ {1, 1, 1, 35, 1, -1}, "dot11nLDPC", MIB_TYPE_PRIV, PRIV_OFFSET(dot11nConfigEntry.dot11nLDPC), PRIV_SIZE(dot11nConfigEntry.dot11nLDPC)},
//dot11AuthenticationAlgorithmsTable
{ {1, 2, 1, 1, 1, -1}, "dot11AuthenticationAlgorithmsIndex", MIB_TYPE_VAL, 1, 1},
{ {1, 2, 1, 2, 1, -1}, "dot11AuthenticationAlgorithm", MIB_TYPE_VAL, 1, 1},
{ {1, 2, 1, 3, 1, -1}, "dot11AuthenticationAlgorithmsEnable", MIB_TYPE_SNMP, SNMP_OFFSET(dot11AuthenticationAlgorithmsEnableOpen), SNMP_SIZE(dot11AuthenticationAlgorithmsEnableOpen)},
{ {1, 2, 1, 1, 2, -1}, "dot11AuthenticationAlgorithmsIndex", MIB_TYPE_VAL, 2, 1},
{ {1, 2, 1, 2, 2, -1}, "dot11AuthenticationAlgorithm", MIB_TYPE_VAL, 2, 1},
{ {1, 2, 1, 3, 2, -1}, "dot11AuthenticationAlgorithmsEnable", MIB_TYPE_SNMP, SNMP_OFFSET(dot11AuthenticationAlgorithmsEnableShared), SNMP_SIZE(dot11AuthenticationAlgorithmsEnableShared)},
//dot11WEPDefaultKeysTable
{ {1, 3, 1, 1, 1, -1}, "dot11WEPDefaultKeyIndex", MIB_TYPE_VAL, 1, 1},
{ {1, 3, 1, 2, 1, -1}, "dot11WEPDefaultKeyValue", MIB_TYPE_SNMP1, SNMP_OFFSET(dot11WEPDefaultKey1), SNMP_SIZE(dot11WEPDefaultKeyLen)},
{ {1, 3, 1, 1, 2, -1}, "dot11WEPDefaultKeyIndex", MIB_TYPE_VAL, 2, 1},
{ {1, 3, 1, 2, 2, -1}, "dot11WEPDefaultKeyValue", MIB_TYPE_SNMP1, SNMP_OFFSET(dot11WEPDefaultKey2), SNMP_SIZE(dot11WEPDefaultKeyLen)},
{ {1, 3, 1, 1, 3, -1}, "dot11WEPDefaultKeyIndex", MIB_TYPE_VAL, 3, 1},
{ {1, 3, 1, 2, 3, -1}, "dot11WEPDefaultKeyValue", MIB_TYPE_SNMP1, SNMP_OFFSET(dot11WEPDefaultKey3), SNMP_SIZE(dot11WEPDefaultKeyLen)},
{ {1, 3, 1, 1, 4, -1}, "dot11WEPDefaultKeyIndex", MIB_TYPE_VAL, 4, 1},
{ {1, 3, 1, 2, 4, -1}, "dot11WEPDefaultKeyValue", MIB_TYPE_SNMP1, SNMP_OFFSET(dot11WEPDefaultKey4), SNMP_SIZE(dot11WEPDefaultKeyLen)},
//dot11WEPKeyMappingsTable
{ {1, 4, 1, 1, 1, -1}, "dot11WEPKeyMappingIndex", MIB_TYPE_VAL, 1, 1},
{ {1, 4, 1, 2, 1, -1}, "dot11WEPKeyMappingAddress", 0},
{ {1, 4, 1, 3, 1, -1}, "dot11WEPKeyMappingWEPOn", 0},
{ {1, 4, 1, 4, 1, -1}, "dot11WEPKeyMappingValue", 0},
{ {1, 4, 1, 5, 1, -1}, "dot11WEPKeyMappingStatus", 0},
//dot11PrivacyTable
{ {1, 5, 1, 1, 1, -1}, "dot11PrivacyInvoked", MIB_TYPE_SNMP, SNMP_OFFSET(dot11PrivacyInvoked), SNMP_SIZE(dot11PrivacyInvoked)},
{ {1, 5, 1, 2, 1, -1}, "dot11WEPDefaultKeyID", MIB_TYPE_PRIV, PRIV_OFFSET(dot1180211AuthEntry.dot11PrivacyKeyIndex), PRIV_SIZE(dot1180211AuthEntry.dot11PrivacyKeyIndex)},
{ {1, 5, 1, 3, 1, -1}, "dot11WEPKeyMappingLength", MIB_TYPE_VAL, 10, 1},
{ {1, 5, 1, 4, 1, -1}, "dot11ExcludeUnencrypted", MIB_TYPE_SNMP, SNMP_OFFSET(dot11PrivacyInvoked), SNMP_SIZE(dot11PrivacyInvoked)},
{ {1, 5, 1, 5, 1, -1}, "dot11WEPICVErrorCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11WEPICVErrorCount), SNMP_SIZE(dot11WEPICVErrorCount)},
{ {1, 5, 1, 6, 1, -1}, "dot11WEPExcludedCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11WEPExcludedCount), SNMP_SIZE(dot11WEPExcludedCount)},
{ {1, 8, 1, 1, 1, -1}, "dot11WPAKeyIndex", MIB_TYPE_VAL, 1, 1},
{ {1, 8, 1, 2, 1, -1}, "dot11WPAKeyFormat", MIB_TYPE_VAL, 1, 1},
{ {1, 8, 1, 3, 1, -1}, "dot11WPAKeyValue", MIB_TYPE_VAL, 1, 1},
{ {1, 9, 1, 1, 1, -1}, "dot11WPA2KeyIndex", MIB_TYPE_VAL, 1, 1},
{ {1, 9, 1, 2, 1, -1}, "dot11WPA2KeyFormat", MIB_TYPE_VAL, 1, 1},
{ {1, 9, 1, 3, 1, -1}, "dot11WPA2KeyValue", MIB_TYPE_VAL, 1, 1},
{ {1, 10, 1, 1, 1, -1}, "dot11RadiusServerIPAddress", MIB_TYPE_VAL, 1, 1},
{ {1, 10, 1, 2, 1, -1}, "dot11RadiusServerPort", MIB_TYPE_VAL, 1, 1},
{ {1, 10, 1, 3, 1, -1}, "dot11RadiusServerPassword", MIB_TYPE_VAL, 1, 1},
{ {1, 10, 1, 4, 1, -1}, "dot11RadiusServerEnable", MIB_TYPE_VAL, 1, 1},
//dot11OperationTable
{ {2, 1, 1, 1, 1, -1}, "dot11MACAddress", MIB_TYPE_PRIV, PRIV_OFFSET(dot11OperationEntry.hwaddr), PRIV_SIZE(dot11OperationEntry.hwaddr)},
{ {2, 1, 1, 2, 1, -1}, "dot11RTSThreshold", MIB_TYPE_PRIV, PRIV_OFFSET(dot11OperationEntry.dot11RTSThreshold), PRIV_SIZE(dot11OperationEntry.dot11RTSThreshold)},
{ {2, 1, 1, 3, 1, -1}, "dot11ShortRetryLimit", MIB_TYPE_PRIV, PRIV_OFFSET(dot11OperationEntry.dot11ShortRetryLimit), PRIV_SIZE(dot11OperationEntry.dot11ShortRetryLimit)},
{ {2, 1, 1, 4, 1, -1}, "dot11LongRetryLimit", MIB_TYPE_PRIV, PRIV_OFFSET(dot11OperationEntry.dot11LongRetryLimit), PRIV_SIZE(dot11OperationEntry.dot11LongRetryLimit)},
{ {2, 1, 1, 5, 1, -1}, "dot11FragmentationThreshold", MIB_TYPE_PRIV, PRIV_OFFSET(dot11OperationEntry.dot11FragmentationThreshold), PRIV_SIZE(dot11OperationEntry.dot11FragmentationThreshold)},
{ {2, 1, 1, 6, 1, -1}, "dot11MaxTransmitMSDULifetime", MIB_TYPE_VAL, 512, 1},
{ {2, 1, 1, 7, 1, -1}, "dot11MaxReceiveLifetime", MIB_TYPE_VAL, FRAG_TO*10, 4},
{ {2, 1, 1, 8, 1, -1}, "dot11ManufacturerID", MIB_TYPE_VAL, (int)"Realtek", 0},
{ {2, 1, 1, 9, 1, -1}, "dot11ProductID", MIB_TYPE_VAL, (int)"RTL8185/RTL8186", 0},
{ {2, 1, 1, 10, 1, -1}, "dot11IappEnable", MIB_TYPE_PRIV,PRIV_OFFSET(dot11OperationEntry.iapp_enable), PRIV_SIZE(dot11OperationEntry.iapp_enable)},
{ {2, 1, 1, 11, 1, -1}, "dot11BlockRelay", MIB_TYPE_PRIV,PRIV_OFFSET(dot11OperationEntry.block_relay), PRIV_SIZE(dot11OperationEntry.block_relay)},
{ {2, 1, 1, 12, 1, -1}, "dot11WIFISpecific", MIB_TYPE_PRIV,PRIV_OFFSET(dot11OperationEntry.wifi_specific), PRIV_SIZE(dot11OperationEntry.wifi_specific)},
{ {2, 1, 1, 13, 1, -1}, "dot11QosEnable", MIB_TYPE_PRIV,PRIV_OFFSET(dot11QosEntry.dot11QosEnable), PRIV_SIZE(dot11QosEntry.dot11QosEnable)},
{ {2, 1, 1, 14, 1, -1}, "dot11NetworkType", MIB_TYPE_PRIV,PRIV_OFFSET(dot11BssType.net_work_type), PRIV_SIZE(dot11BssType.net_work_type)},
{ {2, 1, 1, 15, 1, -1}, "dot11LedType", MIB_TYPE_PRIV,PRIV_OFFSET(dot11OperationEntry.ledtype), PRIV_SIZE(dot11OperationEntry.ledtype)},
{ {2, 1, 1, 16, 1, -1}, "dot11OperationMode", MIB_TYPE_PRIV,PRIV_OFFSET(dot11OperationEntry.opmode), PRIV_SIZE(dot11OperationEntry.opmode)},
{ {2, 1, 1, 17, 1, -1}, "dot11BroadCastSSID", MIB_TYPE_PRIV,PRIV_OFFSET(miscEntry.show_hidden_bss), PRIV_SIZE(miscEntry.show_hidden_bss)},
{ {2, 1, 1, 18, 1, -1}, "dot11GuestAccess", MIB_TYPE_PRIV,PRIV_OFFSET(dot11OperationEntry.guest_access), PRIV_SIZE(dot11OperationEntry.guest_access)},
//dot11CountersTable
{ {2, 2, 1, 1, 1, -1}, "dot11TransmittedFragmentCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11TransmittedFragmentCount), SNMP_SIZE(dot11TransmittedFragmentCount)},
{ {2, 2, 1, 2, 1, -1}, "dot11MulticastTransmittedFrameCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11MulticastTransmittedFrameCount), SNMP_SIZE(dot11MulticastTransmittedFrameCount)},
{ {2, 2, 1, 3, 1, -1}, "dot11FailedCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11FailedCount), SNMP_SIZE(dot11FailedCount)},
{ {2, 2, 1, 4, 1, -1}, "dot11RetryCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11RetryCount), SNMP_SIZE(dot11RetryCount)},
{ {2, 2, 1, 5, 1, -1}, "dot11MultipleRetryCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11MultipleRetryCount), SNMP_SIZE(dot11MultipleRetryCount)},
{ {2, 2, 1, 6, 1, -1}, "dot11FrameDuplicateCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11FrameDuplicateCount), SNMP_SIZE(dot11FrameDuplicateCount)},
{ {2, 2, 1, 7, 1, -1}, "dot11RTSSuccessCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11RTSSuccessCount), SNMP_SIZE(dot11RTSSuccessCount)},
{ {2, 2, 1, 8, 1, -1}, "dot11RTSFailureCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11RTSFailureCount), SNMP_SIZE(dot11RTSFailureCount)},
{ {2, 2, 1, 9, 1, -1}, "dot11ACKFailureCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11ACKFailureCount), SNMP_SIZE(dot11ACKFailureCount)},
{ {2, 2, 1, 10, 1, -1}, "dot11ReceivedFragmentCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11ReceivedFragmentCount), SNMP_SIZE(dot11ReceivedFragmentCount)},
{ {2, 2, 1, 11, 1, -1}, "dot11MulticastReceivedFrameCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11MulticastReceivedFrameCount), SNMP_SIZE(dot11MulticastReceivedFrameCount)},
{ {2, 2, 1, 12, 1, -1}, "dot11FCSErrorCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11FCSErrorCount), SNMP_SIZE(dot11FCSErrorCount)},
{ {2, 2, 1, 13, 1, -1}, "dot11TransmittedFrameCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11TransmittedFrameCount), SNMP_SIZE(dot11TransmittedFrameCount)},
{ {2, 2, 1, 14, 1, -1}, "dot11WEPUndecryptableCount", MIB_TYPE_SNMP, SNMP_OFFSET(dot11WEPUndecryptableCount), SNMP_SIZE(dot11WEPUndecryptableCount)},
//dot11GroupAddressesTable
{ {2, 3, 1, 1, 1, -1}, "dot11GroupAddressesIndex", MIB_TYPE_VAL, 1, 1},
{ {2, 3, 1, 2, 1, -1}, "dot11Address", 0},
{ {2, 3, 1, 3, 1, -1}, "dot11GroupAddressesStatus", 0},
{ {3, 1, 1, 0, -1}, "dot11ResourceTypeIDName", MIB_TYPE_VAL, (int)"8185", 0},
//dot11ResourceInfoTable
{ {3, 1, 2, 1, 1, 1, -1}, "dot11manufacturerOUI", MIB_TYPE_VAL, (int)"\x00\xE0\x4C", 3},
{ {3, 1, 2, 1, 2, 1, -1}, "dot11manufacturerName", MIB_TYPE_VAL, (int)"Realtek", 0},
{ {3, 1, 2, 1, 3, 1, -1}, "dot11manufacturerProductName", MIB_TYPE_VAL, (int)"Wireless 802.11 b/g", 0},
{ {3, 1, 2, 1, 4, 1, -1}, "dot11manufacturerProductVersion", MIB_TYPE_VAL, (int)"v1.00", 0},
//dot11PhyOperationTable
{ {4, 1, 1, 1, 1, -1}, "dot11PHYType", MIB_TYPE_VAL, 2, 1},
{ {4, 1, 1, 2, 1, -1}, "dot11CurrentRegDomain", MIB_TYPE_SNMP, SNMP_OFFSET(dot11CurrentRegDomain), SNMP_SIZE(dot11CurrentRegDomain)},
{ {4, 1, 1, 3, 1, -1}, "dot11TempType", MIB_TYPE_VAL, 1, 1},
{ {4, 1, 1, 4, 1, -1}, "dot11ShortPreamble",MIB_TYPE_PRIV, PRIV_OFFSET(dot11RFEntry.shortpreamble), PRIV_SIZE(dot11RFEntry.shortpreamble)},
{ {4, 1, 1, 5, 1, -1}, "dot11PhyBandSelect",MIB_TYPE_PRIV, PRIV_OFFSET(dot11RFEntry.phyBandSelect), PRIV_SIZE(dot11RFEntry.phyBandSelect)},
{ {4, 1, 1, 6, 1, -1}, "dot11TrSwitch",MIB_TYPE_PRIV, PRIV_OFFSET(dot11RFEntry.trswitch), PRIV_SIZE(dot11RFEntry.trswitch)},
{ {4, 1, 1, 7, 1, -1}, "dot11PowerScale", MIB_TYPE_SNMP, SNMP_OFFSET(dot11PowerScale), SNMP_SIZE(dot11PowerScale)},
//dot11PhyAntennaTable
{ {4, 2, 1, 1, 1, -1}, "dot11CurrentTxAntenna", MIB_TYPE_SNMP, SNMP_OFFSET(dot11CurrentTxAntenna), SNMP_SIZE(dot11CurrentTxAntenna)},
{ {4, 2, 1, 2, 1, -1}, "dot11DiversitySupport", MIB_TYPE_VAL, 2, 1},
{ {4, 2, 1, 3, 1, -1}, "dot11CurrentRxAntenna", MIB_TYPE_SNMP, SNMP_OFFSET(dot11CurrentTxAntenna), SNMP_SIZE(dot11CurrentTxAntenna)},
//dot11PhyTxPowerTable
{ {4, 3, 1, 1, 1, -1}, "dot11NumberSupportedPowerLevels", MIB_TYPE_VAL, 4, 1},
{ {4, 3, 1, 2, 1, -1}, "dot11TxPowerLevel1", MIB_TYPE_VAL, 25, 1},
{ {4, 3, 1, 3, 1, -1}, "dot11TxPowerLevel2", MIB_TYPE_VAL, 12, 1},
{ {4, 3, 1, 4, 1, -1}, "dot11TxPowerLevel3", MIB_TYPE_VAL, 6, 1},
{ {4, 3, 1, 5, 1, -1}, "dot11TxPowerLevel4", MIB_TYPE_VAL, 3, 1},
{ {4, 3, 1, 6, 1, -1}, "dot11TxPowerLevel5", MIB_TYPE_VAL, 0, 1},
{ {4, 3, 1, 7, 1, -1}, "dot11TxPowerLevel6", MIB_TYPE_VAL, 0, 1},
{ {4, 3, 1, 8, 1, -1}, "dot11TxPowerLevel7", MIB_TYPE_VAL, 0, 1},
{ {4, 3, 1, 9, 1, -1}, "dot11TxPowerLevel8", MIB_TYPE_VAL, 0, 1},
{ {4, 3, 1, 10, 1, -1}, "dot11CurrentTxPowerLevel", 0}, // NCTU
//dot11PhyDSSSTable
{ {4, 5, 1, 1, 1, -1}, "dot11CurrentChannel", MIB_TYPE_PRIV, PRIV_OFFSET(dot11RFEntry.dot11channel), PRIV_SIZE(dot11RFEntry.dot11channel)},
{ {4, 5, 1, 2, 1, -1}, "dot11CCAModeSupported", MIB_TYPE_VAL, 4, 1},
{ {4, 5, 1, 3, 1, -1}, "dot11CurrentCCAMode", MIB_TYPE_VAL, 4, 1},
{ {4, 5, 1, 4, 1, -1}, "dot11EDThreshold", MIB_TYPE_VAL, 0, 1},
//dot11RegDomainsSupportedTable
{ {4, 7, 1, 1, 1, -1}, "dot11RegDomainsSupportIndex", MIB_TYPE_VAL, 1, 1},
{ {4, 7, 1, 2, 1, -1}, "dot11RegDomainsSupportValue", MIB_TYPE_VAL, 16, 1},
{ {4, 7, 1, 1, 2, -1}, "dot11RegDomainsSupportIndex", MIB_TYPE_VAL, 2, 1},
{ {4, 7, 1, 2, 2, -1}, "dot11RegDomainsSupportValue", MIB_TYPE_VAL, 32, 1},
{ {4, 7, 1, 1, 3, -1}, "dot11RegDomainsSupportIndex", MIB_TYPE_VAL, 3, 1},
{ {4, 7, 1, 2, 3, -1}, "dot11RegDomainsSupportValue", MIB_TYPE_VAL, 48, 1},
{ {4, 7, 1, 1, 4, -1}, "dot11RegDomainsSupportIndex", MIB_TYPE_VAL, 4, 1},
{ {4, 7, 1, 2, 4, -1}, "dot11RegDomainsSupportValue", MIB_TYPE_VAL, 49, 1},
{ {4, 7, 1, 1, 5, -1}, "dot11RegDomainsSupportIndex", MIB_TYPE_VAL, 5, 1},
{ {4, 7, 1, 2, 5, -1}, "dot11RegDomainsSupportValue", MIB_TYPE_VAL, 50, 1},
{ {4, 7, 1, 1, 6, -1}, "dot11RegDomainsSupportIndex", MIB_TYPE_VAL, 6, 1},
{ {4, 7, 1, 2, 6, -1}, "dot11RegDomainsSupportValue", MIB_TYPE_VAL, 64, 1},
//dot11AntennasListTable
{ {4, 8, 1, 1, 1, -1}, "dot11AntennaListIndex", MIB_TYPE_VAL, 1, 1},
{ {4, 8, 1, 2, 1, -1}, "dot11SupportedTxAntenna", MIB_TYPE_VAL, 1, 1},
{ {4, 8, 1, 3, 1, -1}, "dot11SupportedRxAntenna", MIB_TYPE_VAL, 1, 1},
{ {4, 8, 1, 4, 1, -1}, "dot11DiversitySelectionRx", MIB_TYPE_VAL, 1, 1},
//dot11SupportedDataRatesTxTable
{ {4, 9, 1, 1, 1, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 1, 1},
{ {4, 9, 1, 2, 1, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[0]), 4},
{ {4, 9, 1, 1, 2, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 2, 1},
{ {4, 9, 1, 2, 2, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[1]), 4},
{ {4, 9, 1, 1, 3, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 3, 1},
{ {4, 9, 1, 2, 3, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[2]), 4},
{ {4, 9, 1, 1, 4, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 4, 1},
{ {4, 9, 1, 2, 4, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[3]), 4},
{ {4, 9, 1, 1, 5, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 5, 1},
{ {4, 9, 1, 2, 5, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[4]), 4},
{ {4, 9, 1, 1, 6, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 6, 1},
{ {4, 9, 1, 2, 6, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[5]), 4},
{ {4, 9, 1, 1, 7, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 7, 1},
{ {4, 9, 1, 2, 7, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[6]), 4},
{ {4, 9, 1, 1, 8, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 8, 1},
{ {4, 9, 1, 2, 8, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[7]), 4},
{ {4, 9, 1, 1, 9, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 9, 1},
{ {4, 9, 1, 2, 9, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[8]), 4},
{ {4, 9, 1, 1, 10, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 10, 1},
{ {4, 9, 1, 2, 10, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[9]), 4},
{ {4, 9, 1, 1, 11, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 11, 1},
{ {4, 9, 1, 2, 11, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[10]), 4},
{ {4, 9, 1, 1, 12, -1}, "dot11SupportedDataRatesTxIndex", MIB_TYPE_VAL, 12, 1},
{ {4, 9, 1, 2, 12, -1}, "dot11SupportedDataRatesTxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[11]), 4},
//dot11SupportedDataRatesRxTable
{ {4, 10, 1, 1, 1, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 1, 1},
{ {4, 10, 1, 2, 1, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[0]), 4},
{ {4, 10, 1, 1, 2, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 2, 1},
{ {4, 10, 1, 2, 2, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[1]), 4},
{ {4, 10, 1, 1, 3, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 3, 1},
{ {4, 10, 1, 2, 3, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[2]), 4},
{ {4, 10, 1, 1, 4, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 4, 1},
{ {4, 10, 1, 2, 4, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[3]), 4},
{ {4, 10, 1, 1, 5, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 5, 1},
{ {4, 10, 1, 2, 5, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[4]), 4},
{ {4, 10, 1, 1, 6, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 6, 1},
{ {4, 10, 1, 2, 6, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[5]), 4},
{ {4, 10, 1, 1, 7, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 7, 1},
{ {4, 10, 1, 2, 7, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[6]), 4},
{ {4, 10, 1, 1, 8, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 8, 1},
{ {4, 10, 1, 2, 8, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[7]), 4},
{ {4, 10, 1, 1, 9, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 9, 1},
{ {4, 10, 1, 2, 9, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[8]), 4},
{ {4, 10, 1, 1, 10, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 10, 1},
{ {4, 10, 1, 2, 10, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[9]), 4},
{ {4, 10, 1, 1, 11, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 11, 1},
{ {4, 10, 1, 2, 11, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[10]), 4},
{ {4, 10, 1, 1, 12, -1}, "dot11SupportedDataRatesRxIndex", MIB_TYPE_VAL, 12, 1},
{ {4, 10, 1, 2, 12, -1}, "dot11SupportedDataRatesRxValue", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesSet[11]), 4},
// Number of table entry, Realtek proprietary
{ {6, 1, -1}, "dot11StationConfigEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 2, -1}, "dot11AuthenticationAlgorithmsEntryNum", MIB_TYPE_VAL, 2, 1},
{ {6, 3, -1}, "dot11WEPDefaultKeysEntryNum", MIB_TYPE_VAL, 4, 1},
{ {6, 4, -1}, "dot11WEPKeyMappingsEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 5, -1}, "dot11PrivacyEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 6, -1}, "dot11OperationEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 7, -1}, "dot11CountersEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 8, -1}, "dot11GroupAddressesEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 9, -1}, "dot11ResourceInfoTableNum", MIB_TYPE_VAL, 1, 1},
{ {6, 10, -1}, "dot11PhyOperationEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 11, -1}, "dot11PhyAntennaEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 12, -1}, "dot11PhyTxPowerEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 13, -1}, "dot11PhyDSSSEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 14, -1}, "dot11RegDomainsSupportEntryNum", MIB_TYPE_VAL, 6, 1},
{ {6, 15, -1}, "dot11AntennasListEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 16, -1}, "dot11AntennasListEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 17, -1}, "dot11SupportedDataRatesTxEntryNum", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesNum), SNMP_SIZE(dot11SupportedDataRatesNum)},
{ {6, 18, -1}, "dot11SupportedDataRatesRxEntryNum", MIB_TYPE_SNMP, SNMP_OFFSET(dot11SupportedDataRatesNum), SNMP_SIZE(dot11SupportedDataRatesNum)},
{ {6, 19, -1}, "dot11MultiDomainCapabilityEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 20, -1}, "dot11WPAKeysEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 21, -1}, "dot11WPA2KeysEntryNum", MIB_TYPE_VAL, 1, 1},
{ {6, 22, -1}, "dot11RadiusServerNum", MIB_TYPE_VAL, 1, 1},
{ {-1}, NULL, 0}
};
static int add_mib_entry(struct rtl8192cd_priv *priv, struct mib_val *ent)
{
int i=0;
struct mib_entry **mib=&priv->snmp_mib.mib_tree, *pre_mib=NULL;
while(1) {
if (ent->oid[i] == -1)
break;
if (*mib == NULL) {
if (priv->snmp_mib.tree_used_index == MAX_MIB_TREE_NUM) {
printk("Exceed max mib tree number\n");
return -1;
}
*mib = &priv->snmp_mib.mib_list[priv->snmp_mib.tree_used_index++];
}
if ((*mib)->id == -1 || ent->oid[i] == (*mib)->id) {
if ((*mib)->id == -1)
(*mib)->id = ent->oid[i];
i++;
pre_mib = *mib;
mib = &((*mib)->next_level);
}
else
mib = &((*mib)->next_node);
}
if (pre_mib == NULL) {
printk("build mib tree error, no parent mib found!\n");
return -1;
}
if (pre_mib->val) {
printk("build mib tree error, mib value has been assigned!\n");
return -1;
}
pre_mib->val = ent;
return 0;
}
static void name2oid(char *name, int *oid)
{
int i=0;
char *src=name, *ptr;
while (*src) {
ptr = strstr(src, ".");
if (ptr)
*ptr = '\0';
oid[i++] = _atoi(src, 10);
if (ptr==NULL)
break;
src = ++ptr;
}
oid[i] = -1;
}
static struct mib_val *search_mib(struct rtl8192cd_priv *priv, char *id)
{
int i=0;
struct mib_entry *mib=priv->snmp_mib.mib_tree, *pre_mib=NULL;
int oid[100];
name2oid(id, oid);
while (oid[i] != -1) {
if (mib == NULL || mib->id == -1)
return NULL;
if (mib->id == oid[i]) {
pre_mib = mib;
mib = mib->next_level;
i++;
}
else {
pre_mib = NULL;
mib = mib->next_node;
}
}
if (pre_mib && pre_mib->val)
return pre_mib->val;
else
return NULL;
}
static void build_tree(struct rtl8192cd_priv *priv)
{
int i=0;
struct mib_val *tbl = dot11_mib_table;
for (i=0; i<MAX_MIB_TREE_NUM; i++)
priv->snmp_mib.mib_list[i].id = -1;
i=0;
while (tbl[i].name) {
if (add_mib_entry(priv, &tbl[i]) < 0) {
printk("Add mib entry failed [%s]!\n", tbl[i].name);
return;
}
i++;
}
// printk("used mib num = %d\n", priv->snmp_mib.tree_used_index);
}
int mib_get(struct rtl8192cd_priv *priv, char *oid, unsigned char *data, int *pLen)
{
int iVal;
unsigned char bVal, *pVal, *pVal_type=data++;
struct mib_val *mib;
mib = search_mib(priv, oid);
if (mib == NULL) {
printk("search mib failed [oid=%s]!\n", oid);
return 0;
}
*pVal_type = VAL_OCTET;
switch (mib->type) {
case MIB_TYPE_PRIV:
if (mib->size)
*pLen = mib->size;
else {
*pLen = strlen(((unsigned char *)priv->pmib)+mib->offset)+1;
*pVal_type = VAL_STR;
}
memcpy(data, ((unsigned char *)priv->pmib)+mib->offset, *pLen);
break;
case MIB_TYPE_SNMP:
case MIB_TYPE_SNMP1:
if (mib->type == MIB_TYPE_SNMP1) {
bVal = *(((unsigned char *)&priv->snmp_mib)+mib->size);
*pLen = (int)bVal;
}
else if (mib->size > 0)
*pLen = mib->size;
else if (mib->size == 0) {
*pLen = strlen(((unsigned char *)&priv->snmp_mib)+mib->offset) + 1;
*pVal_type = VAL_STR;
}
memcpy(data, ((unsigned char *)&priv->snmp_mib)+mib->offset, *pLen);
break;
case MIB_TYPE_VAL:
if (mib->size == 0) {
pVal = (unsigned char *)mib->offset;
*pLen = strlen(pVal) + 1;
memcpy(data, pVal, *pLen);
*pVal_type = VAL_STR;
} else if (mib->size == 1) {
bVal = (unsigned char)mib->offset;
pVal = &bVal;
*pLen = sizeof(bVal);
}
else {
iVal = mib->offset;
pVal = (unsigned char *)&iVal;
*pLen = sizeof(iVal);
}
memcpy(data, pVal, *pLen);
break;
default:
// printk("Invalid mib type [%d, %s]\n", mib->type, mib->name);
*pVal_type = VAL_NULL;
*pLen = 0;
break;
}
#if 0
{
int i;
printk("name=%s, val_type=%d, len=%d", mib->name, *pVal_type, *pLen);
if (*pVal_type == VAL_STR)
printk(", val=%s\n", data);
else {
printk(", val=");
for (i=0; i<*pLen; i++) {
printk("%02x ", data[i]);
}
printk("\n");
}
}
#endif
*pLen += 1;
return 1;
}
// build tree and mapping mib value from priv to dot11
void mib_init(struct rtl8192cd_priv *priv)
{
int val;
memset(&priv->snmp_mib, '\0', sizeof(struct mib_snmp));
build_tree(priv);
if ((OPMODE & WIFI_AP_STATE) || (OPMODE & WIFI_STATION_STATE))
SNMP_MIB_ASSIGN(dot11DesiredBSSType, 1); // infra
else
SNMP_MIB_ASSIGN(dot11DesiredBSSType, 2); // ad-hoc
if (priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm > 0)
SNMP_MIB_ASSIGN(dot11PrivacyInvoked, 1);
if (priv->pmib->dot1180211AuthEntry.dot11AuthAlgrthm == 1) // shared key
SNMP_MIB_ASSIGN(dot11AuthenticationAlgorithmsEnableShared, 1);
else
SNMP_MIB_ASSIGN(dot11AuthenticationAlgorithmsEnableOpen, 1);
if (priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm == _WEP_40_PRIVACY_) {
SNMP_MIB_COPY(dot11WEPDefaultKey1, &priv->pmib->dot11DefaultKeysTable.keytype[0].skey[0], 5);
SNMP_MIB_COPY(dot11WEPDefaultKey2, &priv->pmib->dot11DefaultKeysTable.keytype[1].skey[0], 5);
SNMP_MIB_COPY(dot11WEPDefaultKey3, &priv->pmib->dot11DefaultKeysTable.keytype[2].skey[0], 5);
SNMP_MIB_COPY(dot11WEPDefaultKey4, &priv->pmib->dot11DefaultKeysTable.keytype[3].skey[0], 5);
SNMP_MIB_ASSIGN(dot11WEPDefaultKeyLen, 5);
}
else if (priv->pmib->dot1180211AuthEntry.dot11PrivacyAlgrthm == _WEP_104_PRIVACY_) {
SNMP_MIB_COPY(dot11WEPDefaultKey1, &priv->pmib->dot11DefaultKeysTable.keytype[0].skey[0], 13);
SNMP_MIB_COPY(dot11WEPDefaultKey2, &priv->pmib->dot11DefaultKeysTable.keytype[1].skey[0], 13);
SNMP_MIB_COPY(dot11WEPDefaultKey3, &priv->pmib->dot11DefaultKeysTable.keytype[2].skey[0], 13);
SNMP_MIB_COPY(dot11WEPDefaultKey4, &priv->pmib->dot11DefaultKeysTable.keytype[3].skey[0], 13);
SNMP_MIB_ASSIGN(dot11WEPDefaultKeyLen, 13);
}
get_oper_rate(priv);
switch(priv->pmib->dot11StationConfigEntry.dot11RegDomain) {
case DOMAIN_FCC:
val = 16;
break;
case DOMAIN_IC:
val = 32;
break;
case DOMAIN_ETSI:
val = 48;
break;
case DOMAIN_SPAIN:
val = 49;
break;
case DOMAIN_FRANCE:
val = 50;
break;
case DOMAIN_MKK:
case DOMAIN_MKK1:
case DOMAIN_MKK2:
case DOMAIN_MKK3:
val = 64;
break;
default:
printk("Invalid dot11RegDomain [%d]!\n", priv->pmib->dot11StationConfigEntry.dot11RegDomain);
val = 16;
break;
}
SNMP_MIB_ASSIGN(dot11CurrentRegDomain, val);
SNMP_MIB_ASSIGN(dot11CurrentTxAntenna, priv->pmib->dot11RFEntry.defaultAntennaB+1);
}
#endif // SUPPORT_SNMP_MIB

Some files were not shown because too many files have changed in this diff Show More