diff --git a/Makefile b/Makefile index 0af186b..1645390 100644 --- a/Makefile +++ b/Makefile @@ -1214,8 +1214,7 @@ EXTRA_CFLAGS += -DDM_ODM_SUPPORT_TYPE=0x04 ifeq ($(CONFIG_PLATFORM_I386_PC), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -EXTRA_CFLAGS += -mhard-float -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/) +SUBARCH := $(shell uname -m | sed -e "s/armv.*/arm/" | sed -e "s/aarch64/arm64/" | sed -e s/i.86/i386/) ARCH ?= $(SUBARCH) CROSS_COMPILE ?= KVER := $(shell uname -r) @@ -1352,7 +1351,7 @@ endif ifeq ($(CONFIG_PLATFORM_ANDROID_X86), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/) +SUBARCH := $(shell uname -m | sed -e "s/armv.*/arm/" | sed -e "s/aarch64/arm64/" | sed -e s/i.86/i386/) ARCH := $(SUBARCH) CROSS_COMPILE := /media/DATA-2/android-x86/ics-x86_20120130/prebuilt/linux-x86/toolchain/i686-unknown-linux-gnu-4.2.1/bin/i686-unknown-linux-gnu- KSRC := /media/DATA-2/android-x86/ics-x86_20120130/out/target/product/generic_x86/obj/kernel @@ -1375,7 +1374,7 @@ ifeq ($(CONFIG_PLATFORM_JB_X86), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/) +SUBARCH := $(shell uname -m | sed -e "s/armv.*/arm/" | sed -e "s/aarch64/arm64/" | sed -e s/i.86/i386/) ARCH := $(SUBARCH) CROSS_COMPILE := /home/android_sdk/android-x86_JB/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7/bin/i686-linux-android- KSRC := /home/android_sdk/android-x86_JB/out/target/product/x86/obj/kernel/ @@ -2115,10 +2114,6 @@ endif endif -ifeq ($(ARCH), arm) -EXTRA_CFLAGS += -mfloat-abi=hard -endif - ifeq ($(CONFIG_MULTIDRV), y) ifeq ($(CONFIG_SDIO_HCI), y) diff --git a/README.md b/README.md index 6264588..bb3d579 100644 --- a/README.md +++ b/README.md @@ -110,18 +110,7 @@ Make sure `8821cu.ko` file present on that directory `` sudo dkms status `` -### ARM architecture tweak for this driver (this solves compilation problem of this driver): -``` -# For AArch32 -sudo cp /lib/modules/$(uname -r)/build/arch/arm/Makefile /lib/modules/$(uname -r)/build/arch/arm/Makefile.$(date +%Y%m%d%H%M) -sudo sed -i 's/-msoft-float//' /lib/modules/$(uname -r)/build/arch/arm/Makefile -sudo ln -s /lib/modules/$(uname -r)/build/arch/arm /lib/modules/$(uname -r)/build/arch/armv7l - -# For AArch64 -sudo cp /lib/modules/$(uname -r)/build/arch/arm64/Makefile /lib/modules/$(uname -r)/build/arch/arm64/Makefile.$(date +%Y%m%d%H%M) -sudo sed -i 's/-mgeneral-regs-only//' /lib/modules/$(uname -r)/build/arch/arm64/Makefile -``` ### Monitor mode Use the tool 'iw', please don't use other tools like 'airmon-ng' ``` diff --git a/core/rtw_mp.c b/core/rtw_mp.c index d966fac..63fb39e 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -23,20 +23,10 @@ #include #endif -#ifdef CONFIG_MP_VHT_HW_TX_MODE -#define CEILING_POS(X) ((X - (int)(X)) > 0 ? (int)(X + 1) : (int)(X)) -#define CEILING_NEG(X) ((X - (int)(X)) < 0 ? (int)(X - 1) : (int)(X)) -#define ceil(X) (((X) > 0) ? CEILING_POS(X) : CEILING_NEG(X)) - -int rtfloor(float x) +static inline UINT ceil_divide(UINT a, UINT b) { - int i = x - 2; - while - (++i <= x - 1) - ; - return i; + return (a + b - 1) / b; } -#endif #ifdef CONFIG_MP_INCLUDED u32 read_macreg(_adapter *padapter, u32 addr, u32 sz) @@ -3134,11 +3124,11 @@ void CCK_generator( PRT_PMAC_PKT_INFO pPMacPktInfo ) { - double ratio = 0; + UINT ratio11 = 0; bool crc16_in[32] = {0}, crc16_out[16] = {0}; bool LengthExtBit; - double LengthExact; - double LengthPSDU; + UINT LengthExact11; + UINT LengthPSDU; UCHAR i; UINT PacketLength = pPMacTxInfo->PacketLength; @@ -3150,41 +3140,41 @@ void CCK_generator( switch (pPMacPktInfo->MCS) { case 0: pPMacTxInfo->SignalField = 0xA; - ratio = 8; + ratio11 = 88; /*CRC16_in(1,0:7)=[0 1 0 1 0 0 0 0]*/ crc16_in[1] = crc16_in[3] = 1; break; case 1: pPMacTxInfo->SignalField = 0x14; - ratio = 4; + ratio11 = 44; /*CRC16_in(1,0:7)=[0 0 1 0 1 0 0 0];*/ crc16_in[2] = crc16_in[4] = 1; break; case 2: pPMacTxInfo->SignalField = 0x37; - ratio = 8.0 / 5.5; + ratio11 = 16; /*CRC16_in(1,0:7)=[1 1 1 0 1 1 0 0];*/ crc16_in[0] = crc16_in[1] = crc16_in[2] = crc16_in[4] = crc16_in[5] = 1; break; case 3: pPMacTxInfo->SignalField = 0x6E; - ratio = 8.0 / 11.0; + ratio11 = 8; /*CRC16_in(1,0:7)=[0 1 1 1 0 1 1 0];*/ crc16_in[1] = crc16_in[2] = crc16_in[3] = crc16_in[5] = crc16_in[6] = 1; break; } - LengthExact = PacketLength * ratio; - LengthPSDU = ceil(LengthExact); + LengthExact11 = PacketLength * ratio11; + LengthPSDU = ceil_divide(LengthExact11, 11); if ((pPMacPktInfo->MCS == 3) && - ((LengthPSDU - LengthExact) >= 0.727 || (LengthPSDU - LengthExact) <= -0.727)) + (LengthPSDU * 11 >= 8 + LengthExact11 || LengthPSDU * 11 + 8 <= LengthExact11)) LengthExtBit = 1; else LengthExtBit = 0; - pPMacTxInfo->LENGTH = (UINT)LengthPSDU; + pPMacTxInfo->LENGTH = LengthPSDU; /* CRC16_in(1,16:31) = LengthPSDU[0:15]*/ for (i = 0; i < 16; i++) crc16_in[i + 16] = (pPMacTxInfo->LENGTH >> i) & 0x1; @@ -3279,75 +3269,63 @@ void PMAC_Get_Pkt_Param( UINT LDPC_parameter_generator( - UINT N_pld_int, + UINT N_pld, UINT N_CBPSS, UINT N_SS, UINT R, UINT m_STBC, - UINT N_TCB_int + UINT N_TCB ) { - double CR = 0.; - double N_pld = (double)N_pld_int; - double N_TCB = (double)N_TCB_int; - double N_CW = 0., N_shrt = 0., N_spcw = 0., N_fshrt = 0.; - double L_LDPC = 0., K_LDPC = 0., L_LDPC_info = 0.; - double N_punc = 0., N_ppcw = 0., N_fpunc = 0., N_rep = 0., N_rpcw = 0., N_frep = 0.; - double R_eff = 0.; + UINT CR12 = 0; + UINT N_CW = 0, N_shrt = 0; + UINT L_LDPC_12 = 0, K_LDPC = 0; + UINT N_punc = 0; UINT VHTSIGA2B3 = 0;/* extra symbol from VHT-SIG-A2 Bit 3*/ if (R == 0) - CR = 0.5; + CR12 = 6; else if (R == 1) - CR = 2. / 3.; + CR12 = 8; else if (R == 2) - CR = 3. / 4.; + CR12 = 9; else if (R == 3) - CR = 5. / 6.; + CR12 = 10; - if (N_TCB <= 648.) { - N_CW = 1.; - if (N_TCB >= N_pld + 912.*(1. - CR)) - L_LDPC = 1296.; + if (N_TCB <= 648) { + N_CW = 1; + if (N_TCB >= N_pld + 76 * (12 - CR12)) + L_LDPC_12 = 1296 / 12; else - L_LDPC = 648.; - } else if (N_TCB <= 1296.) { - N_CW = 1.; - if (N_TCB >= (double)N_pld + 1464.*(1. - CR)) - L_LDPC = 1944.; + L_LDPC_12 = 648 / 12; + } else if (N_TCB <= 1296) { + N_CW = 1; + if (N_TCB >= N_pld + 122 * (12 - CR12)) + L_LDPC_12 = 1944 / 12; else - L_LDPC = 1296.; - } else if (N_TCB <= 1944.) { - N_CW = 1.; - L_LDPC = 1944.; - } else if (N_TCB <= 2592.) { - N_CW = 2.; - if (N_TCB >= N_pld + 2916.*(1. - CR)) - L_LDPC = 1944.; + L_LDPC_12 = 1296 / 12; + } else if (N_TCB <= 1944) { + N_CW = 1; + L_LDPC_12 = 1944 / 12; + } else if (N_TCB <= 2592) { + N_CW = 2; + if (N_TCB >= N_pld + 243 * (12 - CR12)) + L_LDPC_12 = 1944 / 12; else - L_LDPC = 1296.; + L_LDPC_12 = 1296 / 12; } else { - N_CW = ceil(N_pld / 1944. / CR); - L_LDPC = 1944.; + N_CW = ceil_divide(N_pld, 162 * CR12); + L_LDPC_12 = 1944 / 12; } /* Number of information bits per CW*/ - K_LDPC = L_LDPC * CR; - /* Number of shortening bits max(0, (N_CW * L_LDPC * R) - N_pld)*/ - N_shrt = (N_CW * K_LDPC - N_pld) > 0. ? (N_CW * K_LDPC - N_pld) : 0.; - /* Number of shortening bits per CW N_spcw = rtfloor(N_shrt/N_CW)*/ - N_spcw = rtfloor(N_shrt / N_CW); - /* The first N_fshrt CWs shorten 1 bit more*/ - N_fshrt = (double)((int)N_shrt % (int)N_CW); - /* Number of data bits for the last N_CW-N_fshrt CWs*/ - L_LDPC_info = K_LDPC - N_spcw; + K_LDPC = L_LDPC_12 * CR12; + /* Number of shortening bits max(0, (N_CW * L_LDPC_12 * 12 * R) - N_pld)*/ + N_shrt = (N_CW * K_LDPC > N_pld) ? (N_CW * K_LDPC - N_pld) : 0; /* Number of puncturing bits*/ - N_punc = (N_CW * L_LDPC - N_TCB - N_shrt) > 0. ? (N_CW * L_LDPC - N_TCB - N_shrt) : 0.; - if (((N_punc > .1 * N_CW * L_LDPC * (1. - CR)) && (N_shrt < 1.2 * N_punc * CR / (1. - CR))) || - (N_punc > 0.3 * N_CW * L_LDPC * (1. - CR))) { - /*cout << "*** N_TCB and N_punc are Recomputed ***" << endl;*/ + N_punc = (N_CW * L_LDPC_12 * 12 > N_TCB + N_shrt) ? (N_CW * L_LDPC_12 * 12 - N_TCB - N_shrt) : 0; + if (((N_punc * 10 > N_CW * L_LDPC_12 * (12 - CR12)) && (N_shrt * 10 < 12 * N_punc * CR12 / (12 - CR12))) || + (N_punc * 10 > 3 * N_CW * L_LDPC_12 * (12 - CR12))) { VHTSIGA2B3 = 1; - N_TCB += (double)N_CBPSS * N_SS * m_STBC; - N_punc = (N_CW * L_LDPC - N_TCB - N_shrt) > 0. ? (N_CW * L_LDPC - N_TCB - N_shrt) : 0.; } else VHTSIGA2B3 = 0; @@ -3366,7 +3344,7 @@ void PMAC_Nsym_generator( UCHAR TX_RATE = pPMacTxInfo->TX_RATE; UINT R, R_list[10] = {0, 0, 2, 0, 2, 1, 2, 3, 2, 3}; - double CR = 0; + UINT CR12 = 0; UINT N_SD, N_BPSC_list[10] = {1, 2, 2, 4, 4, 6, 6, 6, 8, 8}; UINT N_BPSC = 0, N_CBPS = 0, N_DBPS = 0, N_ES = 0, N_SYM = 0, N_pld = 0, N_TCB = 0; int D_R = 0; @@ -3396,38 +3374,38 @@ void PMAC_Nsym_generator( switch (R) { case 0: - CR = .5; + CR12 = 6; break; case 1: - CR = 2. / 3.; + CR12 = 8; break; case 2: - CR = 3. / 4.; + CR12 = 9; break; case 3: - CR = 5. / 6.; + CR12 = 10; break; } N_BPSC = N_BPSC_list[MCS_temp]; N_CBPS = N_BPSC * N_SD * pPMacPktInfo->Nss; - N_DBPS = (UINT)((double)N_CBPS * CR); + N_DBPS = N_CBPS * CR12 / 12; if (pPMacTxInfo->bLDPC == FALSE) { - N_ES = (UINT)ceil((double)(N_DBPS * pPMacPktInfo->Nss) / 4. / 300.); + N_ES = ceil_divide(N_DBPS * pPMacPktInfo->Nss, 1200); RTW_INFO("N_ES = %d\n", N_ES); /* N_SYM = m_STBC* (8*length+16+6*N_ES) / (m_STBC*N_DBPS)*/ - N_SYM = pPMacTxInfo->m_STBC * (UINT)ceil((double)(pPMacTxInfo->PacketLength * 8 + 16 + N_ES * 6) / - (double)(N_DBPS * pPMacTxInfo->m_STBC)); + N_SYM = pPMacTxInfo->m_STBC * ceil_divide(pPMacTxInfo->PacketLength * 8 + 16 + N_ES * 6, + N_DBPS * pPMacTxInfo->m_STBC); } else { N_ES = 1; /* N_pld = length * 8 + 16*/ N_pld = pPMacTxInfo->PacketLength * 8 + 16; RTW_INFO("N_pld = %d\n", N_pld); - N_SYM = pPMacTxInfo->m_STBC * (UINT)ceil((double)(N_pld) / - (double)(N_DBPS * pPMacTxInfo->m_STBC)); + N_SYM = pPMacTxInfo->m_STBC * ceil_divide(N_pld, + N_DBPS * pPMacTxInfo->m_STBC); RTW_INFO("N_SYM = %d\n", N_SYM); /* N_avbits = N_CBPS *m_STBC *(N_pld/N_CBPS*R*m_STBC)*/ N_TCB = N_CBPS * N_SYM; @@ -3442,33 +3420,33 @@ void PMAC_Nsym_generator( switch (R) { case 0: - CR = .5; + CR12 = 6; break; case 1: - CR = 2. / 3.; + CR12 = 8; break; case 2: - CR = 3. / 4.; + CR12 = 9; break; case 3: - CR = 5. / 6.; + CR12 = 10; break; } N_BPSC = N_BPSC_list[pPMacPktInfo->MCS]; N_CBPS = N_BPSC * N_SD * pPMacPktInfo->Nss; - N_DBPS = (UINT)((double)N_CBPS * CR); + N_DBPS = N_CBPS * CR12 / 12; if (pPMacTxInfo->bLDPC == FALSE) { if (pPMacTxInfo->bSGI) - N_ES = (UINT)ceil((double)(N_DBPS) / 3.6 / 600.); + N_ES = ceil_divide(N_DBPS, 2160); else - N_ES = (UINT)ceil((double)(N_DBPS) / 4. / 600.); + N_ES = ceil_divide(N_DBPS, 2400); /* N_SYM = m_STBC* (8*length+16+6*N_ES) / (m_STBC*N_DBPS)*/ - N_SYM = pPMacTxInfo->m_STBC * (UINT)ceil((double)(pPMacTxInfo->PacketLength * 8 + 16 + N_ES * 6) / (double)(N_DBPS * pPMacTxInfo->m_STBC)); + N_SYM = pPMacTxInfo->m_STBC * ceil_divide(pPMacTxInfo->PacketLength * 8 + 16 + N_ES * 6, N_DBPS * pPMacTxInfo->m_STBC); SIGA2B3 = 0; } else { N_ES = 1; /* N_SYM = m_STBC* (8*length+N_service) / (m_STBC*N_DBPS)*/ - N_SYM = pPMacTxInfo->m_STBC * (UINT)ceil((double)(pPMacTxInfo->PacketLength * 8 + 16) / (double)(N_DBPS * pPMacTxInfo->m_STBC)); + N_SYM = pPMacTxInfo->m_STBC * ceil_divide(pPMacTxInfo->PacketLength * 8 + 16, N_DBPS * pPMacTxInfo->m_STBC); /* N_avbits = N_sys_init * N_CBPS*/ N_TCB = N_CBPS * N_SYM; /* N_pld = N_sys_init * N_DBPS*/ @@ -3523,7 +3501,7 @@ void L_SIG_generator( LENGTH = pPMacTxInfo->PacketLength; } else { UCHAR N_LTF; - double T_data; + UINT T_data5; UINT OFDM_symbol; mode = 0; @@ -3535,15 +3513,15 @@ void L_SIG_generator( N_LTF = 4; if (pPMacTxInfo->bSGI) - T_data = 3.6; + T_data5 = 18; else - T_data = 4.0; + T_data5 = 20; /*(L-SIG, HT-SIG, HT-STF, HT-LTF....HT-LTF, Data)*/ if (MPT_IS_VHT_RATE(pPMacTxInfo->TX_RATE)) - OFDM_symbol = (UINT)ceil((double)(8 + 4 + N_LTF * 4 + N_SYM * T_data + 4) / 4.); + OFDM_symbol = 2 + 1 + N_LTF + ceil_divide(N_SYM * T_data5, 20) + 1; else - OFDM_symbol = (UINT)ceil((double)(8 + 4 + N_LTF * 4 + N_SYM * T_data) / 4.); + OFDM_symbol = 2 + 1 + N_LTF + ceil_divide(N_SYM * T_data5, 20); RTW_INFO("%s , OFDM_symbol =%d\n", __func__, OFDM_symbol); LENGTH = OFDM_symbol * 3 - 3;