2022-08-06 19:57:27

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 00/13] staging: r8188eu: simplify endpoint configuration

This series contains cleanups for rtl8188eu_interface_configure and the
functions that it calls. I tried to fix the error handling and to
summarize small functions and common code.

Martin Kaiser (13):
staging: r8188eu: Hal_MappingOutPipe should return an int
staging: r8188eu: process HalUsbSetQueuePipeMapping8188EUsb's return
value
staging: r8188eu: merge two small functions
staging: r8188eu: move endpoint init functions to usb_halinit.c
staging: r8188eu: summarize endpoint-related settings
staging: r8188eu: remove OutEpNumber
staging: r8188eu: remove comments about endpoint mapping
staging: r8188eu: summarize common Queue2Pipe settings
staging: r8188eu: simplify three_out_pipe
staging: r8188eu: simplify two_out_pipe
staging: r8188eu: remove _InitNormalChipOneOutEpPriority
staging: r8188eu: we always use HQ and NQ for two endpoints
staging: r8188eu: simplify _InitNormalChipTwoOutEpPriority

drivers/staging/r8188eu/hal/hal_com.c | 110 -------------
drivers/staging/r8188eu/hal/usb_halinit.c | 152 ++++++++----------
drivers/staging/r8188eu/include/hal_com.h | 2 -
drivers/staging/r8188eu/include/hal_intf.h | 2 +-
.../staging/r8188eu/include/rtl8188e_hal.h | 1 -
drivers/staging/r8188eu/os_dep/usb_intf.c | 4 +-
6 files changed, 75 insertions(+), 196 deletions(-)

--
2.30.2


2022-08-06 19:57:27

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 02/13] staging: r8188eu: process HalUsbSetQueuePipeMapping8188EUsb's return value

At the moment, HalUsbSetQueuePipeMapping8188EUsb returns an error status
to rtl8188eu_interface_configure, where this status is discarded.

Pass the error status from rtl8188eu_interface_configure to
rtw_usb_if1_init and handle it there.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 4 ++--
drivers/staging/r8188eu/include/hal_intf.h | 2 +-
drivers/staging/r8188eu/os_dep/usb_intf.c | 4 +++-
3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index ba068e6fd9fb..839841f90d29 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -42,11 +42,11 @@ static int HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumOutPip
return Hal_MappingOutPipe(adapt, NumOutPipe);
}

-void rtl8188eu_interface_configure(struct adapter *adapt)
+int rtl8188eu_interface_configure(struct adapter *adapt)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt);

- HalUsbSetQueuePipeMapping8188EUsb(adapt, pdvobjpriv->RtNumOutPipes);
+ return HalUsbSetQueuePipeMapping8188EUsb(adapt, pdvobjpriv->RtNumOutPipes);
}

u32 rtl8188eu_InitPowerOn(struct adapter *adapt)
diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h
index 3ed5b7e031cd..fd8e792958ce 100644
--- a/drivers/staging/r8188eu/include/hal_intf.h
+++ b/drivers/staging/r8188eu/include/hal_intf.h
@@ -10,7 +10,7 @@

typedef s32 (*c2h_id_filter)(u8 id);

-void rtl8188eu_interface_configure(struct adapter *adapt);
+int rtl8188eu_interface_configure(struct adapter *adapt);
int ReadAdapterInfo8188EU(struct adapter *Adapter);
void rtl8188eu_init_default_value(struct adapter *adapt);
void rtl8188e_SetHalODMVar(struct adapter *Adapter, void *pValue1, bool bSet);
diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
index db91f72dd40f..2b330104a55d 100644
--- a/drivers/staging/r8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
@@ -330,7 +330,9 @@ static int rtw_usb_if1_init(struct dvobj_priv *dvobj, struct usb_interface *pusb
rtl8188e_read_chip_version(padapter);

/* step usb endpoint mapping */
- rtl8188eu_interface_configure(padapter);
+ ret = rtl8188eu_interface_configure(padapter);
+ if (ret)
+ goto handle_dualmac;

/* step read efuse/eeprom data and get mac_addr */
ret = ReadAdapterInfo8188EU(padapter);
--
2.30.2

2022-08-06 19:57:29

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 01/13] staging: r8188eu: Hal_MappingOutPipe should return an int

Update the Hal_MappingOutPipe function to return 0 for success or -EXNIO
if the caller requested more than the number of available endpoints.
This error code is also used by usb_find_common_endpoints if a requested
endpoint was not found.

Unlike a boolean return value, a negative error code can be returned to
external functions that call the r8188eu driver, e.g. to the caller of our
probe function.

HalUsbSetQueuePipeMapping8188EUsb passes the return value of
Hal_MappingOutPipe on to its caller. We have to change its return type
from bool to int as well.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/hal_com.c | 8 +++-----
drivers/staging/r8188eu/hal/usb_halinit.c | 2 +-
drivers/staging/r8188eu/include/hal_com.h | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
index 6a1cdc67335b..d24e0e5924eb 100644
--- a/drivers/staging/r8188eu/hal/hal_com.c
+++ b/drivers/staging/r8188eu/hal/hal_com.c
@@ -225,11 +225,10 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
}
}

-bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
+int Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
{
struct registry_priv *pregistrypriv = &adapter->registrypriv;
bool wifi_cfg = pregistrypriv->wifi_spec;
- bool result = true;

switch (numoutpipe) {
case 2:
@@ -242,10 +241,9 @@ bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
one_out_pipe(adapter);
break;
default:
- result = false;
- break;
+ return -ENXIO;
}
- return result;
+ return 0;
}

/*
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 8b36fb56076e..ba068e6fd9fb 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -35,7 +35,7 @@ static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe)
}
}

-static bool HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumOutPipe)
+static int HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumOutPipe)
{

_ConfigNormalChipOutEP_8188E(adapt, NumOutPipe);
diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h
index d7e333f6ce39..3dfb61e64ee0 100644
--- a/drivers/staging/r8188eu/include/hal_com.h
+++ b/drivers/staging/r8188eu/include/hal_com.h
@@ -143,7 +143,7 @@ u8 MRateToHwRate(u8 rate);

void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg);

-bool Hal_MappingOutPipe(struct adapter *pAdapter, u8 NumOutPipe);
+int Hal_MappingOutPipe(struct adapter *pAdapter, u8 NumOutPipe);

s32 c2h_evt_read(struct adapter *adapter, u8 *buf);

--
2.30.2

2022-08-06 19:57:29

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 04/13] staging: r8188eu: move endpoint init functions to usb_halinit.c

Move the Hal_MappingOutPipe function and the functions
one_/two_/three_out_pipe from hal_com.c to usb_halinit.c.

After this move, all the functions that rtl8188eu_interface_configure
calls are in one file and we can continue to summarize and merge them.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/hal_com.c | 108 ----------------------
drivers/staging/r8188eu/hal/usb_halinit.c | 108 ++++++++++++++++++++++
drivers/staging/r8188eu/include/hal_com.h | 2 -
3 files changed, 108 insertions(+), 110 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
index d24e0e5924eb..8416a65ba47b 100644
--- a/drivers/staging/r8188eu/hal/hal_com.c
+++ b/drivers/staging/r8188eu/hal/hal_com.c
@@ -138,114 +138,6 @@ void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg)
}
}

-static void one_out_pipe(struct adapter *adapter)
-{
- struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
-
- pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */
- pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
-}
-
-static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
-{
- struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
-
- if (wifi_cfg) { /* WMM */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:L */
-
- pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
- pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
-
- } else {/* typical setting */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:L */
-
- pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
- pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
- }
-}
-
-static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
-{
- struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
-
- if (wifi_cfg) {/* for WMM */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:N, 2:L */
-
- pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
- pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
-
- } else {/* typical setting */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:N, 2:L */
-
- pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
- pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
- }
-}
-
-int Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
-{
- struct registry_priv *pregistrypriv = &adapter->registrypriv;
- bool wifi_cfg = pregistrypriv->wifi_spec;
-
- switch (numoutpipe) {
- case 2:
- two_out_pipe(adapter, wifi_cfg);
- break;
- case 3:
- three_out_pipe(adapter, wifi_cfg);
- break;
- case 1:
- one_out_pipe(adapter);
- break;
- default:
- return -ENXIO;
- }
- return 0;
-}
-
/*
* C2H event format:
* Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index ed0faf4fd51d..8be93c44c903 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -35,6 +35,114 @@ static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe)
}
}

+static void one_out_pipe(struct adapter *adapter)
+{
+ struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
+
+ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
+ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
+ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */
+ pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
+
+ pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
+ pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
+ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
+ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
+}
+
+static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
+{
+ struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
+
+ if (wifi_cfg) { /* WMM */
+ /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
+ /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */
+ /* 0:H, 1:L */
+
+ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */
+ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
+ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
+ pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
+
+ pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
+ pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
+ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
+ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
+
+ } else {/* typical setting */
+ /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
+ /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */
+ /* 0:H, 1:L */
+
+ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
+ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
+ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
+ pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
+
+ pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
+ pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
+ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
+ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
+ }
+}
+
+static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
+{
+ struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
+
+ if (wifi_cfg) {/* for WMM */
+ /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
+ /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */
+ /* 0:H, 1:N, 2:L */
+
+ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
+ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
+ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
+ pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
+
+ pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
+ pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
+ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
+ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
+
+ } else {/* typical setting */
+ /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
+ /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */
+ /* 0:H, 1:N, 2:L */
+
+ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
+ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
+ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
+ pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */
+
+ pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
+ pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
+ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
+ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
+ }
+}
+
+static int Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
+{
+ struct registry_priv *pregistrypriv = &adapter->registrypriv;
+ bool wifi_cfg = pregistrypriv->wifi_spec;
+
+ switch (numoutpipe) {
+ case 2:
+ two_out_pipe(adapter, wifi_cfg);
+ break;
+ case 3:
+ three_out_pipe(adapter, wifi_cfg);
+ break;
+ case 1:
+ one_out_pipe(adapter);
+ break;
+ default:
+ return -ENXIO;
+ }
+ return 0;
+}
+
int rtl8188eu_interface_configure(struct adapter *adapt)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt);
diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h
index 3dfb61e64ee0..e8007295cd79 100644
--- a/drivers/staging/r8188eu/include/hal_com.h
+++ b/drivers/staging/r8188eu/include/hal_com.h
@@ -143,8 +143,6 @@ u8 MRateToHwRate(u8 rate);

void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg);

-int Hal_MappingOutPipe(struct adapter *pAdapter, u8 NumOutPipe);
-
s32 c2h_evt_read(struct adapter *adapter, u8 *buf);

#endif /* __HAL_COMMON_H__ */
--
2.30.2

2022-08-06 19:57:33

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 05/13] staging: r8188eu: summarize endpoint-related settings

rtl8188eu_interface_configure calls _ConfigNormalChipOutEP_8188E and
Hal_MappingOutPipe.

Both of these functions make some settings based on the number of
out endpoints on the 8188eu chip. We can merge both of them into
rtl8188eu_interface_configure and summarize the common code.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 55 +++++++----------------
1 file changed, 17 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 8be93c44c903..603108a5d794 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -13,28 +13,6 @@
#include "../include/usb_osintf.h"
#include "../include/HalPwrSeqCmd.h"

-static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe)
-{
- struct hal_data_8188e *haldata = &adapt->haldata;
-
- switch (NumOutPipe) {
- case 3:
- haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ;
- haldata->OutEpNumber = 3;
- break;
- case 2:
- haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ;
- haldata->OutEpNumber = 2;
- break;
- case 1:
- haldata->OutEpQueueSel = TX_SELE_HQ;
- haldata->OutEpNumber = 1;
- break;
- default:
- break;
- }
-}
-
static void one_out_pipe(struct adapter *adapter)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);
@@ -122,33 +100,34 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
}
}

-static int Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe)
+int rtl8188eu_interface_configure(struct adapter *adapt)
{
- struct registry_priv *pregistrypriv = &adapter->registrypriv;
+ struct registry_priv *pregistrypriv = &adapt->registrypriv;
+ struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt);
+ struct hal_data_8188e *haldata = &adapt->haldata;
bool wifi_cfg = pregistrypriv->wifi_spec;

- switch (numoutpipe) {
- case 2:
- two_out_pipe(adapter, wifi_cfg);
- break;
+ switch (pdvobjpriv->RtNumOutPipes) {
case 3:
- three_out_pipe(adapter, wifi_cfg);
+ haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ;
+ haldata->OutEpNumber = 3;
+ three_out_pipe(adapt, wifi_cfg);
+ break;
+ case 2:
+ haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ;
+ haldata->OutEpNumber = 2;
+ two_out_pipe(adapt, wifi_cfg);
break;
case 1:
- one_out_pipe(adapter);
+ haldata->OutEpQueueSel = TX_SELE_HQ;
+ haldata->OutEpNumber = 1;
+ one_out_pipe(adapt);
break;
default:
return -ENXIO;
}
- return 0;
-}

-int rtl8188eu_interface_configure(struct adapter *adapt)
-{
- struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt);
-
- _ConfigNormalChipOutEP_8188E(adapt, pdvobjpriv->RtNumOutPipes);
- return Hal_MappingOutPipe(adapt, pdvobjpriv->RtNumOutPipes);
+ return 0;
}

u32 rtl8188eu_InitPowerOn(struct adapter *adapt)
--
2.30.2

2022-08-06 19:59:38

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 12/13] staging: r8188eu: we always use HQ and NQ for two endpoints

When _InitNormalChipTwoOutEpPriority is called, pdvobjpriv->RtNumOutPipes
and haldata->OutEpQueueSel have already been initialized.

_InitNormalChipTwoOutEpPriority is called only if
pdvobjpriv->RtNumOutPipes == 2. In this case, haldata->OutEpQueueSel is
always TX_SELE_HQ | TX_SELE_NQ.

Remove the switch-case statement and set valueHi and valueLow directly.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index a89db93840f3..fc4d25b835d3 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -227,28 +227,10 @@ static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ,

static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter)
{
- struct hal_data_8188e *haldata = &Adapter->haldata;
struct registry_priv *pregistrypriv = &Adapter->registrypriv;
u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ;
- u16 valueHi = 0;
- u16 valueLow = 0;
-
- switch (haldata->OutEpQueueSel) {
- case (TX_SELE_HQ | TX_SELE_LQ):
- valueHi = QUEUE_HIGH;
- valueLow = QUEUE_LOW;
- break;
- case (TX_SELE_NQ | TX_SELE_LQ):
- valueHi = QUEUE_NORMAL;
- valueLow = QUEUE_LOW;
- break;
- case (TX_SELE_HQ | TX_SELE_NQ):
- valueHi = QUEUE_HIGH;
- valueLow = QUEUE_NORMAL;
- break;
- default:
- break;
- }
+ u16 valueHi = QUEUE_HIGH;
+ u16 valueLow = QUEUE_NORMAL;

if (!pregistrypriv->wifi_spec) {
beQ = valueLow;
--
2.30.2

2022-08-06 19:59:39

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 13/13] staging: r8188eu: simplify _InitNormalChipTwoOutEpPriority

Simplify the _InitNormalChipTwoOutEpPriority function, now that we have
only one configuration for the queues.

Remove the variables which are constant. Keep only those settings that
depend on wifi_spec.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index fc4d25b835d3..e1d56370a471 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -228,26 +228,17 @@ static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ,
static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter)
{
struct registry_priv *pregistrypriv = &Adapter->registrypriv;
- u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ;
- u16 valueHi = QUEUE_HIGH;
- u16 valueLow = QUEUE_NORMAL;
+ u16 bkQ, voQ;

if (!pregistrypriv->wifi_spec) {
- beQ = valueLow;
- bkQ = valueLow;
- viQ = valueHi;
- voQ = valueHi;
- mgtQ = valueHi;
- hiQ = valueHi;
+ bkQ = QUEUE_NORMAL;
+ voQ = QUEUE_HIGH;
} else {/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */
- beQ = valueLow;
- bkQ = valueHi;
- viQ = valueHi;
- voQ = valueLow;
- mgtQ = valueHi;
- hiQ = valueHi;
+ bkQ = QUEUE_HIGH;
+ voQ = QUEUE_NORMAL;
}
- _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ);
+ _InitNormalChipRegPriority(Adapter, QUEUE_NORMAL, bkQ, QUEUE_HIGH,
+ voQ, QUEUE_HIGH, QUEUE_HIGH);
}

static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter)
--
2.30.2

2022-08-06 20:10:47

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 10/13] staging: r8188eu: simplify two_out_pipe

Simplify the two_out_pipe function. Move common settings out of the
if clause.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 044e608bf6e2..f3314bed9285 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -29,15 +29,14 @@ static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)

/* 0:H, 1:L */

+ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
+ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
+
if (wifi_cfg) {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
} else {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
}
}
--
2.30.2

2022-08-06 20:12:02

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 06/13] staging: r8188eu: remove OutEpNumber

Remove the OutEpNumber component of struct hal_data_8188e.
RtNumOutPipes in struct dvobj_priv stores the same info.

Update the only place where OutEpNumber is read.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 7 ++-----
drivers/staging/r8188eu/include/rtl8188e_hal.h | 1 -
2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 603108a5d794..664028c14141 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -110,17 +110,14 @@ int rtl8188eu_interface_configure(struct adapter *adapt)
switch (pdvobjpriv->RtNumOutPipes) {
case 3:
haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ;
- haldata->OutEpNumber = 3;
three_out_pipe(adapt, wifi_cfg);
break;
case 2:
haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ;
- haldata->OutEpNumber = 2;
two_out_pipe(adapt, wifi_cfg);
break;
case 1:
haldata->OutEpQueueSel = TX_SELE_HQ;
- haldata->OutEpNumber = 1;
one_out_pipe(adapt);
break;
default:
@@ -358,9 +355,9 @@ static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter)

static void _InitQueuePriority(struct adapter *Adapter)
{
- struct hal_data_8188e *haldata = &Adapter->haldata;
+ struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter);

- switch (haldata->OutEpNumber) {
+ switch (pdvobjpriv->RtNumOutPipes) {
case 1:
_InitNormalChipOneOutEpPriority(Adapter);
break;
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
index fdc187f4deaa..ff0a4ce19dde 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h
@@ -150,7 +150,6 @@ struct hal_data_8188e {
u8 TRxAntDivType;

u8 OutEpQueueSel;
- u8 OutEpNumber;

struct P2P_PS_Offload_t p2p_ps_offload;

--
2.30.2

2022-08-06 20:13:33

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 08/13] staging: r8188eu: summarize common Queue2Pipe settings

Regardless of the number of endpoints, queues 4 to 7 are mapped to pipe 0.
Move these mappings to rtl8188eu_interface_configure to make the code
simpler.

It's ok to make these settings even if we exit with error later. In this
case, the driver will not be loaded and pdvobjpriv->Queue2Pipe[] will be
freed.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 32 ++++-------------------
1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index e561c92f1dc9..431661be95e0 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -21,11 +21,6 @@ static void one_out_pipe(struct adapter *adapter)
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */
pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
}

static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
@@ -39,22 +34,11 @@ static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
-
} else {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
}
}

@@ -69,22 +53,11 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
-
} else {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */
-
- pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
- pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
- pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
- pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
}
}

@@ -95,6 +68,11 @@ int rtl8188eu_interface_configure(struct adapter *adapt)
struct hal_data_8188e *haldata = &adapt->haldata;
bool wifi_cfg = pregistrypriv->wifi_spec;

+ pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */
+ pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */
+ pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
+ pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */
+
switch (pdvobjpriv->RtNumOutPipes) {
case 3:
haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ;
--
2.30.2

2022-08-06 20:14:04

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 03/13] staging: r8188eu: merge two small functions

All that rtl8188eu_interface_configure does is call
HalUsbSetQueuePipeMapping8188EUsb. We can merge the two functions.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 839841f90d29..ed0faf4fd51d 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -35,18 +35,12 @@ static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe)
}
}

-static int HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumOutPipe)
-{
-
- _ConfigNormalChipOutEP_8188E(adapt, NumOutPipe);
- return Hal_MappingOutPipe(adapt, NumOutPipe);
-}
-
int rtl8188eu_interface_configure(struct adapter *adapt)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt);

- return HalUsbSetQueuePipeMapping8188EUsb(adapt, pdvobjpriv->RtNumOutPipes);
+ _ConfigNormalChipOutEP_8188E(adapt, pdvobjpriv->RtNumOutPipes);
+ return Hal_MappingOutPipe(adapt, pdvobjpriv->RtNumOutPipes);
}

u32 rtl8188eu_InitPowerOn(struct adapter *adapt)
--
2.30.2

2022-08-06 20:15:19

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 11/13] staging: r8188eu: remove _InitNormalChipOneOutEpPriority

When _InitNormalChipOneOutEpPriority is called, pdvobjpriv->RtNumOutPipes
and haldata->OutEpQueueSel have already been initialized.

_InitNormalChipOneOutEpPriority is called only if
pdvobjpriv->RtNumOutPipes == 1. In this case, haldata->OutEpQueueSel is
always TX_SELE_HQ.

We can then simplify _InitNormalChipOneOutEpPriority to a single
_InitNormalChipRegPriority call, i.e. we can remove
_InitNormalChipOneOutEpPriority and call _InitNormalChipRegPriority
directly.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 25 ++---------------------
1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index f3314bed9285..a89db93840f3 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -225,28 +225,6 @@ static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ,
rtw_write16(Adapter, REG_TRXDMA_CTRL, value16);
}

-static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter)
-{
- struct hal_data_8188e *haldata = &Adapter->haldata;
-
- u16 value = 0;
- switch (haldata->OutEpQueueSel) {
- case TX_SELE_HQ:
- value = QUEUE_HIGH;
- break;
- case TX_SELE_LQ:
- value = QUEUE_LOW;
- break;
- case TX_SELE_NQ:
- value = QUEUE_NORMAL;
- break;
- default:
- break;
- }
- _InitNormalChipRegPriority(Adapter, value, value, value, value,
- value, value);
-}
-
static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter)
{
struct hal_data_8188e *haldata = &Adapter->haldata;
@@ -319,7 +297,8 @@ static void _InitQueuePriority(struct adapter *Adapter)

switch (pdvobjpriv->RtNumOutPipes) {
case 1:
- _InitNormalChipOneOutEpPriority(Adapter);
+ _InitNormalChipRegPriority(Adapter, QUEUE_HIGH, QUEUE_HIGH, QUEUE_HIGH,
+ QUEUE_HIGH, QUEUE_HIGH, QUEUE_HIGH);
break;
case 2:
_InitNormalChipTwoOutEpPriority(Adapter);
--
2.30.2

2022-08-06 20:21:28

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 07/13] staging: r8188eu: remove comments about endpoint mapping

Remove the comments in two_out_pipe and three_out_pipe that show the
mappings. They simply repeat the settings in the code and provide no
additional information. Keep the info which RtOutPipe is high, normal
or low.

Without the removed comments, it'll be easier to summarize and reorganize
the code.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 24 ++++++-----------------
1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 664028c14141..e561c92f1dc9 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -32,11 +32,9 @@ static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);

- if (wifi_cfg) { /* WMM */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:L */
+ /* 0:H, 1:L */

+ if (wifi_cfg) {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
@@ -47,11 +45,7 @@ static void two_out_pipe(struct adapter *adapter, bool wifi_cfg)
pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */

- } else {/* typical setting */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:L */
-
+ } else {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */
@@ -68,11 +62,9 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
{
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter);

- if (wifi_cfg) {/* for WMM */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:N, 2:L */
+ /* 0:H, 1:N, 2:L */

+ if (wifi_cfg) {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
@@ -83,11 +75,7 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)
pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */
pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */

- } else {/* typical setting */
- /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */
- /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */
- /* 0:H, 1:N, 2:L */
-
+ } else {
pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
--
2.30.2

2022-08-06 20:25:58

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 09/13] staging: r8188eu: simplify three_out_pipe

Only one of the mappings in three_out_pipe depends on the wifi_cfg flag.
Simplify the code accordingly.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/hal/usb_halinit.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 431661be95e0..044e608bf6e2 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -48,17 +48,12 @@ static void three_out_pipe(struct adapter *adapter, bool wifi_cfg)

/* 0:H, 1:N, 2:L */

- if (wifi_cfg) {
- pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
- pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */
- } else {
- pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
- pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
- pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
- pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */
- }
+ pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */
+ pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */
+ pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */
+
+ pdvobjpriv->Queue2Pipe[3] = wifi_cfg ?
+ pdvobjpriv->RtOutPipe[1] : pdvobjpriv->RtOutPipe[2];/* BK */
}

int rtl8188eu_interface_configure(struct adapter *adapt)
--
2.30.2

2022-08-07 06:47:27

by Philipp Hortmann

[permalink] [raw]
Subject: Re: [PATCH 00/13] staging: r8188eu: simplify endpoint configuration

On 8/6/22 21:55, Martin Kaiser wrote:
> This series contains cleanups for rtl8188eu_interface_configure and the
> functions that it calls. I tried to fix the error handling and to
> summarize small functions and common code.
>
> Martin Kaiser (13):
> staging: r8188eu: Hal_MappingOutPipe should return an int
> staging: r8188eu: process HalUsbSetQueuePipeMapping8188EUsb's return
> value
> staging: r8188eu: merge two small functions
> staging: r8188eu: move endpoint init functions to usb_halinit.c
> staging: r8188eu: summarize endpoint-related settings
> staging: r8188eu: remove OutEpNumber
> staging: r8188eu: remove comments about endpoint mapping
> staging: r8188eu: summarize common Queue2Pipe settings
> staging: r8188eu: simplify three_out_pipe
> staging: r8188eu: simplify two_out_pipe
> staging: r8188eu: remove _InitNormalChipOneOutEpPriority
> staging: r8188eu: we always use HQ and NQ for two endpoints
> staging: r8188eu: simplify _InitNormalChipTwoOutEpPriority
>
> drivers/staging/r8188eu/hal/hal_com.c | 110 -------------
> drivers/staging/r8188eu/hal/usb_halinit.c | 152 ++++++++----------
> drivers/staging/r8188eu/include/hal_com.h | 2 -
> drivers/staging/r8188eu/include/hal_intf.h | 2 +-
> .../staging/r8188eu/include/rtl8188e_hal.h | 1 -
> drivers/staging/r8188eu/os_dep/usb_intf.c | 4 +-
> 6 files changed, 75 insertions(+), 196 deletions(-)
>
Tested-by: Philipp Hortmann <[email protected]> # Edimax N150