From 5b7b2de9579c4d938e515693adf9e4e2f562dcdf Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 08:40:11 -0400 Subject: [PATCH 01/14] Remove unused floating point variables --- core/rtw_mp.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index d966fac..2568fb0 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3290,10 +3290,9 @@ UINT LDPC_parameter_generator( 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.; + double N_CW = 0., N_shrt = 0.; + double L_LDPC = 0., K_LDPC = 0.; + double N_punc = 0.; UINT VHTSIGA2B3 = 0;/* extra symbol from VHT-SIG-A2 Bit 3*/ if (R == 0) @@ -3334,20 +3333,11 @@ UINT LDPC_parameter_generator( 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; /* 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;*/ 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; From e4073adb7942d45cd6fecd581c8fcefea0ef5406 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 08:41:10 -0400 Subject: [PATCH 02/14] Remove unnecessary floating point conversion --- core/rtw_mp.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 2568fb0..7d216ff 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3279,17 +3279,15 @@ 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.; double L_LDPC = 0., K_LDPC = 0.; double N_punc = 0.; @@ -3304,22 +3302,22 @@ UINT LDPC_parameter_generator( else if (R == 3) CR = 5. / 6.; - if (N_TCB <= 648.) { + if (N_TCB <= 648) { N_CW = 1.; if (N_TCB >= N_pld + 912.*(1. - CR)) L_LDPC = 1296.; else L_LDPC = 648.; - } else if (N_TCB <= 1296.) { + } else if (N_TCB <= 1296) { N_CW = 1.; - if (N_TCB >= (double)N_pld + 1464.*(1. - CR)) + if (N_TCB >= N_pld + 1464.*(1. - CR)) L_LDPC = 1944.; else L_LDPC = 1296.; - } else if (N_TCB <= 1944.) { + } else if (N_TCB <= 1944) { N_CW = 1.; L_LDPC = 1944.; - } else if (N_TCB <= 2592.) { + } else if (N_TCB <= 2592) { N_CW = 2.; if (N_TCB >= N_pld + 2916.*(1. - CR)) L_LDPC = 1944.; From c54dc801bb7c533f765181e5d160dee56f978b5f Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 08:46:16 -0400 Subject: [PATCH 03/14] Scale LDPC and CR to make them both integer --- core/rtw_mp.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 7d216ff..f35d7b9 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3287,54 +3287,54 @@ UINT LDPC_parameter_generator( UINT N_TCB ) { - double CR = 0.; + UINT CR12 = 0; double N_CW = 0., N_shrt = 0.; - double L_LDPC = 0., K_LDPC = 0.; + UINT L_LDPC_12 = 0, K_LDPC = 0; double 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 >= N_pld + 76 * (12 - CR12)) + L_LDPC_12 = 1296 / 12; else - L_LDPC = 648.; + L_LDPC_12 = 648 / 12; } else if (N_TCB <= 1296) { N_CW = 1.; - if (N_TCB >= N_pld + 1464.*(1. - CR)) - L_LDPC = 1944.; + if (N_TCB >= N_pld + 122 * (12 - CR12)) + L_LDPC_12 = 1944 / 12; else - L_LDPC = 1296.; + L_LDPC_12 = 1296 / 12; } else if (N_TCB <= 1944) { N_CW = 1.; - L_LDPC = 1944.; + L_LDPC_12 = 1944 / 12; } else if (N_TCB <= 2592) { N_CW = 2.; - if (N_TCB >= N_pld + 2916.*(1. - CR)) - L_LDPC = 1944.; + 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(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)*/ + 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) > 0. ? (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))) { + N_punc = (N_CW * L_LDPC_12 * 12 - N_TCB - N_shrt) > 0. ? (N_CW * L_LDPC_12 * 12 - N_TCB - N_shrt) : 0.; + if (((N_punc > .1 * N_CW * L_LDPC_12 * (12 - CR12)) && (N_shrt < 1.2 * N_punc * CR12 / (12 - CR12))) || + (N_punc > 0.3 * N_CW * L_LDPC_12 * (12 - CR12))) { VHTSIGA2B3 = 1; } else VHTSIGA2B3 = 0; From 24276282e1dca10a5552a3582e5dc18c47d37525 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 08:47:55 -0400 Subject: [PATCH 04/14] Compare numbers to be subtracted first --- core/rtw_mp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index f35d7b9..90effa7 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3330,9 +3330,9 @@ UINT LDPC_parameter_generator( /* Number of information bits per CW*/ 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) > 0. ? (N_CW * K_LDPC - N_pld) : 0.; + 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_12 * 12 - N_TCB - N_shrt) > 0. ? (N_CW * L_LDPC_12 * 12 - N_TCB - N_shrt) : 0.; + 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 > .1 * N_CW * L_LDPC_12 * (12 - CR12)) && (N_shrt < 1.2 * N_punc * CR12 / (12 - CR12))) || (N_punc > 0.3 * N_CW * L_LDPC_12 * (12 - CR12))) { VHTSIGA2B3 = 1; From f9117491b7b2df046a1b1be04f6cfcdc04c09fe0 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 08:48:52 -0400 Subject: [PATCH 05/14] Add ceiling division helper function --- core/rtw_mp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 90effa7..f4763f7 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -23,6 +23,11 @@ #include #endif +static inline UINT ceil_divide(UINT a, UINT b) +{ + return (a + b - 1) / b; +} + #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)) From 0f5815b6f2397436705ed92b1b88ace9099cb488 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 08:49:34 -0400 Subject: [PATCH 06/14] Get rid of the remaining floating point values from LDPC_parameter_generator --- core/rtw_mp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index f4763f7..8b7c873 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3293,9 +3293,9 @@ UINT LDPC_parameter_generator( ) { UINT CR12 = 0; - double N_CW = 0., N_shrt = 0.; + UINT N_CW = 0, N_shrt = 0; UINT L_LDPC_12 = 0, K_LDPC = 0; - double N_punc = 0.; + UINT N_punc = 0; UINT VHTSIGA2B3 = 0;/* extra symbol from VHT-SIG-A2 Bit 3*/ if (R == 0) @@ -3308,36 +3308,36 @@ UINT LDPC_parameter_generator( CR12 = 10; if (N_TCB <= 648) { - N_CW = 1.; + N_CW = 1; if (N_TCB >= N_pld + 76 * (12 - CR12)) L_LDPC_12 = 1296 / 12; else L_LDPC_12 = 648 / 12; } else if (N_TCB <= 1296) { - N_CW = 1.; + N_CW = 1; if (N_TCB >= N_pld + 122 * (12 - CR12)) L_LDPC_12 = 1944 / 12; else L_LDPC_12 = 1296 / 12; } else if (N_TCB <= 1944) { - N_CW = 1.; + N_CW = 1; L_LDPC_12 = 1944 / 12; } else if (N_TCB <= 2592) { - N_CW = 2.; + N_CW = 2; if (N_TCB >= N_pld + 243 * (12 - CR12)) L_LDPC_12 = 1944 / 12; else L_LDPC_12 = 1296 / 12; } else { - N_CW = ceil(N_pld / (162 * CR12)); + N_CW = ceil_divide(N_pld, 162 * CR12); L_LDPC_12 = 1944 / 12; } /* Number of information bits per CW*/ 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.; + 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_12 * 12 > N_TCB + N_shrt) ? (N_CW * L_LDPC_12 * 12 - N_TCB - N_shrt) : 0.; + 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 > .1 * N_CW * L_LDPC_12 * (12 - CR12)) && (N_shrt < 1.2 * N_punc * CR12 / (12 - CR12))) || (N_punc > 0.3 * N_CW * L_LDPC_12 * (12 - CR12))) { VHTSIGA2B3 = 1; From 407ee96e89d99a93251607bd0d53367e3fd62221 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 08:53:46 -0400 Subject: [PATCH 07/14] Scale comparisons to use integer arithmetics --- core/rtw_mp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 8b7c873..2217132 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3338,8 +3338,8 @@ UINT LDPC_parameter_generator( 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_12 * 12 > N_TCB + N_shrt) ? (N_CW * L_LDPC_12 * 12 - N_TCB - N_shrt) : 0; - if (((N_punc > .1 * N_CW * L_LDPC_12 * (12 - CR12)) && (N_shrt < 1.2 * N_punc * CR12 / (12 - CR12))) || - (N_punc > 0.3 * N_CW * L_LDPC_12 * (12 - CR12))) { + 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; } else VHTSIGA2B3 = 0; From 2f637770040ab1f03ece8c16f4844b619c97b25b Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 09:04:05 -0400 Subject: [PATCH 08/14] Replace floating point divisions with interger ones --- core/rtw_mp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 2217132..351f4fd 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3407,20 +3407,20 @@ void PMAC_Nsym_generator( N_DBPS = (UINT)((double)N_CBPS * CR); 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; @@ -3452,16 +3452,16 @@ void PMAC_Nsym_generator( N_DBPS = (UINT)((double)N_CBPS * CR); 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*/ @@ -3516,7 +3516,7 @@ void L_SIG_generator( LENGTH = pPMacTxInfo->PacketLength; } else { UCHAR N_LTF; - double T_data; + UINT T_data5; UINT OFDM_symbol; mode = 0; @@ -3528,15 +3528,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; From 92827948f123c7466cd070ac9fac9816bc80eafd Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 09:07:18 -0400 Subject: [PATCH 09/14] Remove use of floating point math in PMAC_Nsym_generator --- core/rtw_mp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 351f4fd..7137dae 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3359,7 +3359,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; @@ -3389,22 +3389,22 @@ 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 = ceil_divide(N_DBPS * pPMacPktInfo->Nss, 1200); @@ -3435,21 +3435,21 @@ 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 = ceil_divide(N_DBPS, 2160); From 7c797ecf35e5f3e8c41acabc42a0f352622d36bb Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 09:13:06 -0400 Subject: [PATCH 10/14] Scale ratio by 11 to get rid of floating point math in CCK_generator --- core/rtw_mp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 7137dae..dc3cf26 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -3139,11 +3139,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; @@ -3155,41 +3155,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; From 0290929963482619cbae1c52db16e8655aa9c362 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 09:13:40 -0400 Subject: [PATCH 11/14] Clean up unused floating point macros and functions --- core/rtw_mp.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/core/rtw_mp.c b/core/rtw_mp.c index dc3cf26..63fb39e 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -28,21 +28,6 @@ static inline UINT ceil_divide(UINT a, UINT b) return (a + b - 1) / b; } -#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) -{ - int i = x - 2; - while - (++i <= x - 1) - ; - return i; -} -#endif - #ifdef CONFIG_MP_INCLUDED u32 read_macreg(_adapter *padapter, u32 addr, u32 sz) { From a6e7045bf38be98fceb1b16e7f1af8d84bf3e5ed Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 09:16:04 -0400 Subject: [PATCH 12/14] Do not request hard floating point from compiler --- Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Makefile b/Makefile index a5fc133..c648d07 100644 --- a/Makefile +++ b/Makefile @@ -1213,7 +1213,6 @@ 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/) ARCH ?= $(SUBARCH) CROSS_COMPILE ?= @@ -2100,10 +2099,6 @@ endif endif -ifeq ($(ARCH), arm) -EXTRA_CFLAGS += -mfloat-abi=hard -endif - ifeq ($(CONFIG_MULTIDRV), y) ifeq ($(CONFIG_SDIO_HCI), y) From c4e78f8dd1e4b06adf8429c67f26857b7ab2b507 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 09:17:42 -0400 Subject: [PATCH 13/14] Fix SUBARCH autodetection on arm and aarch64 --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c648d07..a60c71e 100644 --- a/Makefile +++ b/Makefile @@ -1213,7 +1213,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 -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) @@ -1350,7 +1350,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 @@ -1373,7 +1373,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/ From e41d4afc3762fb6994aaffdac8455bd29decdf78 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 27 Oct 2021 09:19:10 -0400 Subject: [PATCH 14/14] Remove wrong notes about building on ARM --- README.md | 11 ----------- 1 file changed, 11 deletions(-) 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' ```