2023-10-26 05:43:46

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 00/10] staging: rtl8192e: Convert array rx_ring[] to rx_ring

Remove some functions that always return false or zero.
Remove a loop that is always executed one time and convert arrays to variables.
Remove some unused constants.

Tested with rtl8192e (WLL6130-D99) in Mode n (12.5 MB/s)
Transferred this patch over wlan connection of rtl8192e.

Philipp Hortmann (10):
staging: rtl8192e: Remove HTIOTActIsDisableMCS14()
staging: rtl8192e: Remove HTIOTActIsDisableMCS15()
staging: rtl8192e: Remove HTIOTActIsDisableMCSTwoSpatialStream()
staging: rtl8192e: Remove HTIOTActIsDisableEDCATurbo()
staging: rtl8192e: Remove loops with constant MAX_RX_QUEUE
staging: rtl8192e: Convert array rx_ring[] to variable rx_ring
staging: rtl8192e: Convert array rx_buf[][] to array rx_buf[]
staging: rtl8192e: Convert array rx_ring_dma[] to variable rx_ring_dma
staging: rtl8192e: Convert array rx_idx[] to variable rx_idx
staging: rtl8192e: Remove unused constants starting with MAX_RX_QUEUE

.../staging/rtl8192e/rtl8192e/r8190P_def.h | 2 -
.../staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +-
.../staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 62 +--------
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 131 ++++++++----------
drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 10 +-
drivers/staging/rtl8192e/rtl819x_HTProc.c | 37 -----
drivers/staging/rtl8192e/rtl819x_Qos.h | 1 -
drivers/staging/rtl8192e/rtl819x_TS.h | 1 -
drivers/staging/rtl8192e/rtllib.h | 1 -
9 files changed, 67 insertions(+), 180 deletions(-)

--
2.42.0


2023-10-26 05:44:03

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 01/10] staging: rtl8192e: Remove HTIOTActIsDisableMCS14()

Remove HTIOTActIsDisableMCS14() as it always returns zero which leads to
one evaluation that is always false. Remove dead code.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl819x_HTProc.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 00b21542ddc3..18659408bb69 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -207,11 +207,6 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee)
netdev_dbg(ieee->dev, "IOTPEER: %x\n", ht_info->IOTPeer);
}

-static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr)
-{
- return 0;
-}
-
static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee)
{
return false;
@@ -696,10 +691,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
HTIOTPeerDetermine(ieee);

ht_info->iot_action = 0;
- bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
- if (bIOTAction)
- ht_info->iot_action |= HT_IOT_ACT_DISABLE_MCS14;
-
bIOTAction = HTIOTActIsDisableMCS15(ieee);
if (bIOTAction)
ht_info->iot_action |= HT_IOT_ACT_DISABLE_MCS15;
--
2.42.0

2023-10-26 05:44:08

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 02/10] staging: rtl8192e: Remove HTIOTActIsDisableMCS15()

Remove HTIOTActIsDisableMCS15() as it always returns false which leads to
one evaluation that is always false. Remove dead code.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl819x_HTProc.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 18659408bb69..ea01cfce77d8 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -207,11 +207,6 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee)
netdev_dbg(ieee->dev, "IOTPEER: %x\n", ht_info->IOTPeer);
}

-static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee)
-{
- return false;
-}
-
static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee)
{
return false;
@@ -691,10 +686,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
HTIOTPeerDetermine(ieee);

ht_info->iot_action = 0;
- bIOTAction = HTIOTActIsDisableMCS15(ieee);
- if (bIOTAction)
- ht_info->iot_action |= HT_IOT_ACT_DISABLE_MCS15;
-
bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee);
if (bIOTAction)
ht_info->iot_action |= HT_IOT_ACT_DISABLE_ALL_2SS;
--
2.42.0

2023-10-26 05:44:13

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 03/10] staging: rtl8192e: Remove HTIOTActIsDisableMCSTwoSpatialStream()

Remove HTIOTActIsDisableMCSTwoSpatialStream() as it always returns false
which leads to one evaluation that is always false. Remove dead code.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl819x_HTProc.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index ea01cfce77d8..3cbadd6a0aef 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -207,11 +207,6 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee)
netdev_dbg(ieee->dev, "IOTPEER: %x\n", ht_info->IOTPeer);
}

-static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee)
-{
- return false;
-}
-
static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee,
u8 *PeerMacAddr)
{
@@ -686,10 +681,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
HTIOTPeerDetermine(ieee);

ht_info->iot_action = 0;
- bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee);
- if (bIOTAction)
- ht_info->iot_action |= HT_IOT_ACT_DISABLE_ALL_2SS;
-
bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
if (bIOTAction)
ht_info->iot_action |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
--
2.42.0

2023-10-26 05:44:22

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 04/10] staging: rtl8192e: Remove HTIOTActIsDisableEDCATurbo()

Remove HTIOTActIsDisableEDCATurbo() as it always returns false which
leads to one evaluation that is always false. Remove dead code.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl819x_HTProc.c | 10 ----------
1 file changed, 10 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 3cbadd6a0aef..e607bccc079a 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -207,12 +207,6 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee)
netdev_dbg(ieee->dev, "IOTPEER: %x\n", ht_info->IOTPeer);
}

-static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee,
- u8 *PeerMacAddr)
-{
- return false;
-}
-
static u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee,
struct rtllib_network *network)
{
@@ -681,10 +675,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
HTIOTPeerDetermine(ieee);

ht_info->iot_action = 0;
- bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
- if (bIOTAction)
- ht_info->iot_action |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
-
bIOTAction = HTIOTActIsMgntUseCCK6M(ieee, pNetwork);
if (bIOTAction)
ht_info->iot_action |= HT_IOT_ACT_MGNT_USE_CCK_6M;
--
2.42.0

2023-10-26 05:44:42

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 07/10] staging: rtl8192e: Convert array rx_buf[][] to array rx_buf[]

Convert array rx_buf[][] to array rx_buf[] as index is always 0. This
increases readability.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 8 ++++----
drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index d0d5b1dfff48..573d548e44d8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1145,7 +1145,7 @@ static void _rtl92e_free_rx_ring(struct net_device *dev)
int rx_queue_idx = 0;

for (i = 0; i < priv->rxringcount; i++) {
- struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
+ struct sk_buff *skb = priv->rx_buf[i];

if (!skb)
continue;
@@ -1373,7 +1373,7 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
if (!skb)
return 0;
skb->dev = dev;
- priv->rx_buf[rx_queue_idx][i] = skb;
+ priv->rx_buf[i] = skb;
mapping = (dma_addr_t *)skb->cb;
*mapping = dma_map_single(&priv->pdev->dev,
skb_tail_pointer(skb),
@@ -1575,7 +1575,7 @@ static void _rtl92e_rx_normal(struct net_device *dev)
while (count--) {
struct rx_desc *pdesc = &priv->rx_ring
[priv->rx_idx[rx_queue_idx]];
- struct sk_buff *skb = priv->rx_buf[rx_queue_idx]
+ struct sk_buff *skb = priv->rx_buf
[priv->rx_idx[rx_queue_idx]];
struct sk_buff *new_skb;

@@ -1614,7 +1614,7 @@ static void _rtl92e_rx_normal(struct net_device *dev)
skb = new_skb;
skb->dev = dev;

- priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] =
+ priv->rx_buf[priv->rx_idx[rx_queue_idx]] =
skb;
*((dma_addr_t *)skb->cb) = dma_map_single(&priv->pdev->dev,
skb_tail_pointer(skb),
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index caa8a00cc922..2a99873fbe90 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -233,7 +233,7 @@ struct r8192_priv {
u8 (*rf_set_chan)(struct net_device *dev, u8 ch);

struct rx_desc *rx_ring;
- struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT];
+ struct sk_buff *rx_buf[MAX_RX_COUNT];
dma_addr_t rx_ring_dma[MAX_RX_QUEUE];
unsigned int rx_idx[MAX_RX_QUEUE];
int rxringcount;
--
2.42.0

2023-10-26 05:45:01

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 05/10] staging: rtl8192e: Remove loops with constant MAX_RX_QUEUE

MAX_RX_QUEUE is set to 1. All loops with MAX_RX_QUEUE run only one cycle.
Remove loops.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 120 +++++++++----------
1 file changed, 58 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index ba35ae4a21fa..2f0fc7c0f216 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1141,28 +1141,26 @@ void rtl92e_tx_enable(struct net_device *dev)
static void _rtl92e_free_rx_ring(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
- int i, rx_queue_idx;
-
- for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE;
- rx_queue_idx++) {
- for (i = 0; i < priv->rxringcount; i++) {
- struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
+ int i;
+ int rx_queue_idx = 0;

- if (!skb)
- continue;
+ for (i = 0; i < priv->rxringcount; i++) {
+ struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];

- dma_unmap_single(&priv->pdev->dev,
- *((dma_addr_t *)skb->cb),
- priv->rxbuffersize, DMA_FROM_DEVICE);
- kfree_skb(skb);
- }
+ if (!skb)
+ continue;

- dma_free_coherent(&priv->pdev->dev,
- sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
- priv->rx_ring[rx_queue_idx],
- priv->rx_ring_dma[rx_queue_idx]);
- priv->rx_ring[rx_queue_idx] = NULL;
+ dma_unmap_single(&priv->pdev->dev,
+ *((dma_addr_t *)skb->cb),
+ priv->rxbuffersize, DMA_FROM_DEVICE);
+ kfree_skb(skb);
}
+
+ dma_free_coherent(&priv->pdev->dev,
+ sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
+ priv->rx_ring[rx_queue_idx],
+ priv->rx_ring_dma[rx_queue_idx]);
+ priv->rx_ring[rx_queue_idx] = NULL;
}

static void _rtl92e_free_tx_ring(struct net_device *dev, unsigned int prio)
@@ -1353,47 +1351,46 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
struct rx_desc *entry = NULL;
- int i, rx_queue_idx;
-
- for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
- priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev,
- sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
- &priv->rx_ring_dma[rx_queue_idx],
- GFP_ATOMIC);
- if (!priv->rx_ring[rx_queue_idx] ||
- (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
- netdev_warn(dev, "Cannot allocate RX ring\n");
- return -ENOMEM;
- }
-
- priv->rx_idx[rx_queue_idx] = 0;
+ int i;
+ int rx_queue_idx = 0;
+
+ priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev,
+ sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
+ &priv->rx_ring_dma[rx_queue_idx],
+ GFP_ATOMIC);
+ if (!priv->rx_ring[rx_queue_idx] ||
+ (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
+ netdev_warn(dev, "Cannot allocate RX ring\n");
+ return -ENOMEM;
+ }

- for (i = 0; i < priv->rxringcount; i++) {
- struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
- dma_addr_t *mapping;
+ priv->rx_idx[rx_queue_idx] = 0;

- entry = &priv->rx_ring[rx_queue_idx][i];
- if (!skb)
- return 0;
- skb->dev = dev;
- priv->rx_buf[rx_queue_idx][i] = skb;
- mapping = (dma_addr_t *)skb->cb;
- *mapping = dma_map_single(&priv->pdev->dev,
- skb_tail_pointer(skb),
- priv->rxbuffersize, DMA_FROM_DEVICE);
- if (dma_mapping_error(&priv->pdev->dev, *mapping)) {
- dev_kfree_skb_any(skb);
- return -1;
- }
- entry->BufferAddress = *mapping;
+ for (i = 0; i < priv->rxringcount; i++) {
+ struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
+ dma_addr_t *mapping;

- entry->Length = priv->rxbuffersize;
- entry->OWN = 1;
+ entry = &priv->rx_ring[rx_queue_idx][i];
+ if (!skb)
+ return 0;
+ skb->dev = dev;
+ priv->rx_buf[rx_queue_idx][i] = skb;
+ mapping = (dma_addr_t *)skb->cb;
+ *mapping = dma_map_single(&priv->pdev->dev,
+ skb_tail_pointer(skb),
+ priv->rxbuffersize, DMA_FROM_DEVICE);
+ if (dma_mapping_error(&priv->pdev->dev, *mapping)) {
+ dev_kfree_skb_any(skb);
+ return -1;
}
+ entry->BufferAddress = *mapping;

- if (entry)
- entry->EOR = 1;
+ entry->Length = priv->rxbuffersize;
+ entry->OWN = 1;
}
+
+ if (entry)
+ entry->EOR = 1;
return 0;
}

@@ -1455,19 +1452,18 @@ static short _rtl92e_pci_initdescring(struct net_device *dev)
void rtl92e_reset_desc_ring(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
- int i, rx_queue_idx;
+ int i;
+ int rx_queue_idx = 0;
unsigned long flags = 0;

- for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
- if (priv->rx_ring[rx_queue_idx]) {
- struct rx_desc *entry = NULL;
+ if (priv->rx_ring[rx_queue_idx]) {
+ struct rx_desc *entry = NULL;

- for (i = 0; i < priv->rxringcount; i++) {
- entry = &priv->rx_ring[rx_queue_idx][i];
- entry->OWN = 1;
- }
- priv->rx_idx[rx_queue_idx] = 0;
+ for (i = 0; i < priv->rxringcount; i++) {
+ entry = &priv->rx_ring[rx_queue_idx][i];
+ entry->OWN = 1;
}
+ priv->rx_idx[rx_queue_idx] = 0;
}

spin_lock_irqsave(&priv->irq_th_lock, flags);
--
2.42.0

2023-10-26 05:45:01

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 06/10] staging: rtl8192e: Convert array rx_ring[] to variable rx_ring

Convert array rx_ring[] to variable rx_ring as index is always 0. This
increases readability.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 25 ++++++++++----------
drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 +-
2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 2f0fc7c0f216..d0d5b1dfff48 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1157,10 +1157,10 @@ static void _rtl92e_free_rx_ring(struct net_device *dev)
}

dma_free_coherent(&priv->pdev->dev,
- sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
- priv->rx_ring[rx_queue_idx],
+ sizeof(*priv->rx_ring) * priv->rxringcount,
+ priv->rx_ring,
priv->rx_ring_dma[rx_queue_idx]);
- priv->rx_ring[rx_queue_idx] = NULL;
+ priv->rx_ring = NULL;
}

static void _rtl92e_free_tx_ring(struct net_device *dev, unsigned int prio)
@@ -1354,12 +1354,11 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
int i;
int rx_queue_idx = 0;

- priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev,
- sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
- &priv->rx_ring_dma[rx_queue_idx],
- GFP_ATOMIC);
- if (!priv->rx_ring[rx_queue_idx] ||
- (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
+ priv->rx_ring = dma_alloc_coherent(&priv->pdev->dev,
+ sizeof(*priv->rx_ring) * priv->rxringcount,
+ &priv->rx_ring_dma[rx_queue_idx],
+ GFP_ATOMIC);
+ if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) {
netdev_warn(dev, "Cannot allocate RX ring\n");
return -ENOMEM;
}
@@ -1370,7 +1369,7 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
dma_addr_t *mapping;

- entry = &priv->rx_ring[rx_queue_idx][i];
+ entry = &priv->rx_ring[i];
if (!skb)
return 0;
skb->dev = dev;
@@ -1456,11 +1455,11 @@ void rtl92e_reset_desc_ring(struct net_device *dev)
int rx_queue_idx = 0;
unsigned long flags = 0;

- if (priv->rx_ring[rx_queue_idx]) {
+ if (priv->rx_ring) {
struct rx_desc *entry = NULL;

for (i = 0; i < priv->rxringcount; i++) {
- entry = &priv->rx_ring[rx_queue_idx][i];
+ entry = &priv->rx_ring[i];
entry->OWN = 1;
}
priv->rx_idx[rx_queue_idx] = 0;
@@ -1574,7 +1573,7 @@ static void _rtl92e_rx_normal(struct net_device *dev)
stats.nic_type = NIC_8192E;

while (count--) {
- struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx]
+ struct rx_desc *pdesc = &priv->rx_ring
[priv->rx_idx[rx_queue_idx]];
struct sk_buff *skb = priv->rx_buf[rx_queue_idx]
[priv->rx_idx[rx_queue_idx]];
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index d4e998cfbefc..caa8a00cc922 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -232,7 +232,7 @@ struct r8192_priv {

u8 (*rf_set_chan)(struct net_device *dev, u8 ch);

- struct rx_desc *rx_ring[MAX_RX_QUEUE];
+ struct rx_desc *rx_ring;
struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT];
dma_addr_t rx_ring_dma[MAX_RX_QUEUE];
unsigned int rx_idx[MAX_RX_QUEUE];
--
2.42.0

2023-10-26 05:45:24

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 09/10] staging: rtl8192e: Convert array rx_idx[] to variable rx_idx

Convert array rx_idx[] to variable rx_idx as index is always 0. Remove
unused rx_queue_idx as well. This increases readability.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 18 +++++++-----------
drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 +-
2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 8af732870ddf..d2a8a9543579 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1142,7 +1142,6 @@ static void _rtl92e_free_rx_ring(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
int i;
- int rx_queue_idx = 0;

for (i = 0; i < priv->rxringcount; i++) {
struct sk_buff *skb = priv->rx_buf[i];
@@ -1352,7 +1351,6 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
struct r8192_priv *priv = rtllib_priv(dev);
struct rx_desc *entry = NULL;
int i;
- int rx_queue_idx = 0;

priv->rx_ring = dma_alloc_coherent(&priv->pdev->dev,
sizeof(*priv->rx_ring) * priv->rxringcount,
@@ -1363,7 +1361,7 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
return -ENOMEM;
}

- priv->rx_idx[rx_queue_idx] = 0;
+ priv->rx_idx = 0;

for (i = 0; i < priv->rxringcount; i++) {
struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
@@ -1452,7 +1450,6 @@ void rtl92e_reset_desc_ring(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
int i;
- int rx_queue_idx = 0;
unsigned long flags = 0;

if (priv->rx_ring) {
@@ -1462,7 +1459,7 @@ void rtl92e_reset_desc_ring(struct net_device *dev)
entry = &priv->rx_ring[i];
entry->OWN = 1;
}
- priv->rx_idx[rx_queue_idx] = 0;
+ priv->rx_idx = 0;
}

spin_lock_irqsave(&priv->irq_th_lock, flags);
@@ -1561,7 +1558,6 @@ static void _rtl92e_rx_normal(struct net_device *dev)
struct ieee80211_hdr *rtllib_hdr = NULL;
bool unicast_packet = false;
u32 skb_len = 0;
- int rx_queue_idx = RX_MPDU_QUEUE;

struct rtllib_rx_stats stats = {
.signal = 0,
@@ -1574,9 +1570,9 @@ static void _rtl92e_rx_normal(struct net_device *dev)

while (count--) {
struct rx_desc *pdesc = &priv->rx_ring
- [priv->rx_idx[rx_queue_idx]];
+ [priv->rx_idx];
struct sk_buff *skb = priv->rx_buf
- [priv->rx_idx[rx_queue_idx]];
+ [priv->rx_idx];
struct sk_buff *new_skb;

if (pdesc->OWN)
@@ -1614,7 +1610,7 @@ static void _rtl92e_rx_normal(struct net_device *dev)
skb = new_skb;
skb->dev = dev;

- priv->rx_buf[priv->rx_idx[rx_queue_idx]] =
+ priv->rx_buf[priv->rx_idx] =
skb;
*((dma_addr_t *)skb->cb) = dma_map_single(&priv->pdev->dev,
skb_tail_pointer(skb),
@@ -1627,9 +1623,9 @@ static void _rtl92e_rx_normal(struct net_device *dev)
pdesc->BufferAddress = *((dma_addr_t *)skb->cb);
pdesc->OWN = 1;
pdesc->Length = priv->rxbuffersize;
- if (priv->rx_idx[rx_queue_idx] == priv->rxringcount - 1)
+ if (priv->rx_idx == priv->rxringcount - 1)
pdesc->EOR = 1;
- priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) %
+ priv->rx_idx = (priv->rx_idx + 1) %
priv->rxringcount;
}
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index b3ebff2df62a..a6c47388d72c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -235,7 +235,7 @@ struct r8192_priv {
struct rx_desc *rx_ring;
struct sk_buff *rx_buf[MAX_RX_COUNT];
dma_addr_t rx_ring_dma;
- unsigned int rx_idx[MAX_RX_QUEUE];
+ unsigned int rx_idx;
int rxringcount;
u16 rxbuffersize;

--
2.42.0

2023-10-26 05:45:24

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 10/10] staging: rtl8192e: Remove unused constants starting with MAX_RX_QUEUE

Remove unused constants.

Signed-off-by: Philipp Hortmann <[email protected]>
---
.../staging/rtl8192e/rtl8192e/r8190P_def.h | 2 -
.../staging/rtl8192e/rtl8192e/r8192E_phyreg.h | 62 +------------------
drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 -
drivers/staging/rtl8192e/rtl819x_Qos.h | 1 -
drivers/staging/rtl8192e/rtl819x_TS.h | 1 -
drivers/staging/rtl8192e/rtllib.h | 1 -
6 files changed, 1 insertion(+), 68 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
index c229fd244a48..8c85f1c866d3 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
@@ -11,8 +11,6 @@

#define MAX_SILENT_RESET_RX_SLOT_NUM 10

-#define RX_MPDU_QUEUE 0
-
enum rtl819x_loopback {
RTL819X_NO_LOOPBACK = 0,
RTL819X_MAC_LOOPBACK = 1,
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
index 24fb0ca539ea..c48c56869c19 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
@@ -248,75 +248,15 @@
#define bPAEnd 0xf
#define bTREnd 0x0f000000
#define bRFEnd 0x000f0000
-/* T2R */
-#define bCCAMask 0x000000f0
-#define bR2RCCAMask 0x00000f00
-#define bHSSI_R2TDelay 0xf8000000
-#define bHSSI_T2RDelay 0xf80000
/* Channel gain at continue TX. */
-#define bContTxHSSI 0x400
-#define bIGFromCCK 0x200
-#define bAGCAddress 0x3f
-#define bRxHPTx 0x7000
-#define bRxHPT2R 0x38000
-#define bRxHPCCKIni 0xc0000
-#define bAGCTxCode 0xc00000
-#define bAGCRxCode 0x300000
#define b3WireDataLength 0x800
#define b3WireAddressLength 0x400
-#define b3WireRFPowerDown 0x1
-/*#define bHWSISelect 0x8 */
-#define b2GPAPEPolarity 0x80000000
-#define bRFSW_TxDefaultAnt 0x3
-#define bRFSW_TxOptionAnt 0x30
-#define bRFSW_RxDefaultAnt 0x300
-#define bRFSW_RxOptionAnt 0x3000
-#define bRFSI_3WireData 0x1
-#define bRFSI_3WireClock 0x2
-#define bRFSI_3WireLoad 0x4
-#define bRFSI_3WireRW 0x8
/* 3-wire total control */
-#define bRFSI_3Wire 0xf
#define bRFSI_RFENV 0x10
-#define bRFSI_TRSW 0x20
-#define bRFSI_TRSWB 0x40
-#define bRFSI_ANTSW 0x100
-#define bRFSI_ANTSWB 0x200
-#define bRFSI_PAPE 0x400
-#define bBandSelect 0x1
-#define bHTSIG2_GI 0x80
-#define bHTSIG2_Smoothing 0x01
-#define bHTSIG2_Sounding 0x02
-#define bHTSIG2_Aggreaton 0x08
-#define bHTSIG2_STBC 0x30
-#define bHTSIG2_AdvCoding 0x40
-#define bHTSIG2_NumOfHTLTF 0x300
-#define bHTSIG2_CRC8 0x3fc
-#define bHTSIG1_MCS 0x7f
-#define bHTSIG1_BandWidth 0x80
-#define bHTSIG1_HTLength 0xffff
-#define bLSIG_Rate 0xf
-#define bLSIG_Reserved 0x10
-#define bLSIG_Length 0x1fffe
-#define bLSIG_Parity 0x20
-#define bCCKRxPhase 0x4
#define bLSSIReadAddress 0x3f000000 /* LSSI "read" address */
#define bLSSIReadEdge 0x80000000 /* LSSI "read" edge signal */
#define bLSSIReadBackData 0xfff
-#define bLSSIReadOKFlag 0x1000
-#define bCCKSampleRate 0x8 /* 0: 44 MHz, 1: 88MHz */
-
-#define bRegulator0Standby 0x1
-#define bRegulatorPLLStandby 0x2
-#define bRegulator1Standby 0x4
-#define bPLLPowerUp 0x8
-#define bDPLLPowerUp 0x10
-#define bDA10PowerUp 0x20
-#define bAD7PowerUp 0x200
-#define bDA6PowerUp 0x2000
-#define bXtalPowerUp 0x4000
-#define b40MDClkPowerUP 0x8000
-#define bDA6DebugMode 0x20000
+
#define bDA6Swing 0x380000
#define bADClkPhase 0x4000000
#define b80MClkDelay 0x18000000
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index a6c47388d72c..a4afbf3e934d 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -91,8 +91,6 @@

#define MAX_TX_QUEUE 9

-#define MAX_RX_QUEUE 1
-
#define MAX_RX_COUNT 64
#define MAX_TX_QUEUE_COUNT 9

diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h
index f547de4c1da3..1c00092ea3a5 100644
--- a/drivers/staging/rtl8192e/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192e/rtl819x_Qos.h
@@ -21,7 +21,6 @@ struct octet_string {
#define AC1_BK 1
#define AC2_VI 2
#define AC3_VO 3
-#define AC_MAX 4

enum direction_value {
DIR_UP = 0,
diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h
index ab737428d4a7..fff36315f174 100644
--- a/drivers/staging/rtl8192e/rtl819x_TS.h
+++ b/drivers/staging/rtl8192e/rtl819x_TS.h
@@ -10,7 +10,6 @@
#define TS_ADDBA_DELAY 60

#define TOTAL_TS_NUM 16
-#define TCLAS_NUM 4

enum tr_select {
TX_DIR = 0,
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index dc3488d9693f..d2cf3cfaaaba 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -911,7 +911,6 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
((up) < 6) ? WME_AC_VI : \
WME_AC_VO)

-#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
* plus ether type
*/
--
2.42.0

2023-10-26 05:45:37

by Philipp Hortmann

[permalink] [raw]
Subject: [PATCH 08/10] staging: rtl8192e: Convert array rx_ring_dma[] to variable rx_ring_dma

Convert array rx_ring_dma[] to variable rx_ring_dma as index is always 0.
This increases readability.

Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +-
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++--
drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index e343e10e011a..e93394c51264 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -1841,7 +1841,7 @@ void rtl92e_enable_rx(struct net_device *dev)
{
struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);

- rtl92e_writel(dev, RDQDA, priv->rx_ring_dma[RX_MPDU_QUEUE]);
+ rtl92e_writel(dev, RDQDA, priv->rx_ring_dma);
}

static const u32 TX_DESC_BASE[] = {
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 573d548e44d8..8af732870ddf 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1159,7 +1159,7 @@ static void _rtl92e_free_rx_ring(struct net_device *dev)
dma_free_coherent(&priv->pdev->dev,
sizeof(*priv->rx_ring) * priv->rxringcount,
priv->rx_ring,
- priv->rx_ring_dma[rx_queue_idx]);
+ priv->rx_ring_dma);
priv->rx_ring = NULL;
}

@@ -1356,7 +1356,7 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)

priv->rx_ring = dma_alloc_coherent(&priv->pdev->dev,
sizeof(*priv->rx_ring) * priv->rxringcount,
- &priv->rx_ring_dma[rx_queue_idx],
+ &priv->rx_ring_dma,
GFP_ATOMIC);
if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) {
netdev_warn(dev, "Cannot allocate RX ring\n");
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index 2a99873fbe90..b3ebff2df62a 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -234,7 +234,7 @@ struct r8192_priv {

struct rx_desc *rx_ring;
struct sk_buff *rx_buf[MAX_RX_COUNT];
- dma_addr_t rx_ring_dma[MAX_RX_QUEUE];
+ dma_addr_t rx_ring_dma;
unsigned int rx_idx[MAX_RX_QUEUE];
int rxringcount;
u16 rxbuffersize;
--
2.42.0

2023-10-26 07:09:44

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 09/10] staging: rtl8192e: Convert array rx_idx[] to variable rx_idx

On Thu, Oct 26, 2023 at 07:44:24AM +0200, Philipp Hortmann wrote:
> @@ -1614,7 +1610,7 @@ static void _rtl92e_rx_normal(struct net_device *dev)
> skb = new_skb;
> skb->dev = dev;
>
> - priv->rx_buf[priv->rx_idx[rx_queue_idx]] =
> + priv->rx_buf[priv->rx_idx] =
> skb;

I really like how you split these patches up. Like there was a bunch
of different ways to do that and you chose one which made it so easy to
review. You made the right choice to avoid touching unrelated white
space issues.

But could you send a follow on patch to move this lonely skb back with
his friends?

regards,
dan carpenter

2023-10-26 07:11:14

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 00/10] staging: rtl8192e: Convert array rx_ring[] to rx_ring

On Thu, Oct 26, 2023 at 07:43:26AM +0200, Philipp Hortmann wrote:
> Remove some functions that always return false or zero.
> Remove a loop that is always executed one time and convert arrays to variables.
> Remove some unused constants.
>
> Tested with rtl8192e (WLL6130-D99) in Mode n (12.5 MB/s)
> Transferred this patch over wlan connection of rtl8192e.
>
> Philipp Hortmann (10):
> staging: rtl8192e: Remove HTIOTActIsDisableMCS14()
> staging: rtl8192e: Remove HTIOTActIsDisableMCS15()
> staging: rtl8192e: Remove HTIOTActIsDisableMCSTwoSpatialStream()
> staging: rtl8192e: Remove HTIOTActIsDisableEDCATurbo()
> staging: rtl8192e: Remove loops with constant MAX_RX_QUEUE
> staging: rtl8192e: Convert array rx_ring[] to variable rx_ring
> staging: rtl8192e: Convert array rx_buf[][] to array rx_buf[]
> staging: rtl8192e: Convert array rx_ring_dma[] to variable rx_ring_dma
> staging: rtl8192e: Convert array rx_idx[] to variable rx_idx
> staging: rtl8192e: Remove unused constants starting with MAX_RX_QUEUE
>

Looks good to me.

Reviewed-by: Dan Carpenter <[email protected]>

regards,
dan carpenter