2018-06-04 05:29:15

by Ajay Singh

[permalink] [raw]
Subject: [PATCH 0/4] staging: wilc1000: modification to use list_head data structure

Instead of having own linked list implementation to maintain buffer queue change
to use list_head. Also removed the few elements from 'wilc' struct as it's not
required to be part of 'wilc' struct.

Ajay Singh (4):
staging: wilc1000: use list_head to maintain 'txq_entry_t' elements of
tx queue
staging: wilc1000: use list_head to maintain 'rxq_entry_t elements in
rx queue
staging: wilc1000: remove 'rxq_entries' from 'wilc' struct
staging: wilc1000: move 'txq_spinlock_flags' from 'wilc' structure to
local variable

drivers/staging/wilc1000/linux_wlan.c | 2 +
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 9 +--
drivers/staging/wilc1000/wilc_wlan.c | 101 ++++++++------------------
drivers/staging/wilc1000/wilc_wlan.h | 5 +-
4 files changed, 37 insertions(+), 80 deletions(-)

--
2.7.4


2018-06-04 05:29:22

by Ajay Singh

[permalink] [raw]
Subject: [PATCH 2/4] staging: wilc1000: use list_head to maintain 'rxq_entry_t elements in rx queue

Make use of 'list_head' data structure to maintain the rx buffer queue.
Modified wilc_wlan_rxq_add() to add the element at the tail by using
list_head API and wilc_wlan_rxq_remove() to remove the element from
head.

Signed-off-by: Ajay Singh <[email protected]>
---
drivers/staging/wilc1000/linux_wlan.c | 1 +
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +--
drivers/staging/wilc1000/wilc_wlan.c | 26 +++++++++-----------------
drivers/staging/wilc1000/wilc_wlan.h | 2 +-
4 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index eac719b..0019bb8 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1119,6 +1119,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
wl->gpio = gpio;
wl->hif_func = ops;
INIT_LIST_HEAD(&wl->txq_head.list);
+ INIT_LIST_HEAD(&wl->rxq_head.list);

register_inetaddr_notifier(&g_dev_notifier);

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index e1fab73..ba57f42 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -161,8 +161,7 @@ struct wilc {
int txq_entries;
int txq_exit;

- struct rxq_entry_t *rxq_head;
- struct rxq_entry_t *rxq_tail;
+ struct rxq_entry_t rxq_head;
int rxq_entries;
int rxq_exit;

diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 857cc38..059c5c7 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -404,15 +404,7 @@ static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
return 0;

mutex_lock(&wilc->rxq_cs);
- if (!wilc->rxq_head) {
- rqe->next = NULL;
- wilc->rxq_head = rqe;
- wilc->rxq_tail = rqe;
- } else {
- wilc->rxq_tail->next = rqe;
- rqe->next = NULL;
- wilc->rxq_tail = rqe;
- }
+ list_add_tail(&rqe->list, &wilc->rxq_head.list);
wilc->rxq_entries += 1;
mutex_unlock(&wilc->rxq_cs);
return wilc->rxq_entries;
@@ -420,17 +412,17 @@ static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)

static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
{
- if (wilc->rxq_head) {
- struct rxq_entry_t *rqe;
+ struct rxq_entry_t *rqe = NULL;

- mutex_lock(&wilc->rxq_cs);
- rqe = wilc->rxq_head;
- wilc->rxq_head = wilc->rxq_head->next;
+ mutex_lock(&wilc->rxq_cs);
+ if (!list_empty(&wilc->rxq_head.list)) {
+ rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t,
+ list);
+ list_del(&rqe->list);
wilc->rxq_entries -= 1;
- mutex_unlock(&wilc->rxq_cs);
- return rqe;
}
- return NULL;
+ mutex_unlock(&wilc->rxq_cs);
+ return rqe;
}

void chip_allow_sleep(struct wilc *wilc)
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index e0ff3e8..dbdebf0 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -218,7 +218,7 @@ struct txq_entry_t {
};

struct rxq_entry_t {
- struct rxq_entry_t *next;
+ struct list_head list;
u8 *buffer;
int buffer_size;
};
--
2.7.4

2018-06-04 05:29:28

by Ajay Singh

[permalink] [raw]
Subject: [PATCH 4/4] staging: wilc1000: move 'txq_spinlock_flags' from 'wilc' structure to local variable

Cleanup patch to remove 'txq_spinlock_flags' element in 'wilc' and used
local variable 'flag' in wilc_wlan_txq_filter_dup_tcp_ack().

Signed-off-by: Ajay Singh <[email protected]>
---
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 --
drivers/staging/wilc1000/wilc_wlan.c | 5 +++--
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index afba372..fe18ae9 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -155,8 +155,6 @@ struct wilc {
u32 rx_buffer_offset;
u8 *tx_buffer;

- unsigned long txq_spinlock_flags;
-
struct txq_entry_t txq_head;
int txq_entries;
int txq_exit;
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 26252d1..55755d7 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -219,11 +219,12 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev)
struct wilc *wilc;
u32 i = 0;
u32 dropped = 0;
+ unsigned long flags;

vif = netdev_priv(dev);
wilc = vif->wilc;

- spin_lock_irqsave(&wilc->txq_spinlock, wilc->txq_spinlock_flags);
+ spin_lock_irqsave(&wilc->txq_spinlock, flags);
for (i = pending_base; i < (pending_base + pending_acks); i++) {
u32 session_index;
u32 bigger_ack_num;
@@ -261,7 +262,7 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev)
else
pending_base = 0;

- spin_unlock_irqrestore(&wilc->txq_spinlock, wilc->txq_spinlock_flags);
+ spin_unlock_irqrestore(&wilc->txq_spinlock, flags);

while (dropped > 0) {
wait_for_completion_timeout(&wilc->txq_event,
--
2.7.4

2018-06-04 05:29:25

by Ajay Singh

[permalink] [raw]
Subject: [PATCH 3/4] staging: wilc1000: remove 'rxq_entries' from 'wilc' struct

Removed unnecessary 'rxq_entries' element from 'wilc' struct, as its
value is not used.

Signed-off-by: Ajay Singh <[email protected]>
---
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 -
drivers/staging/wilc1000/wilc_wlan.c | 7 ++-----
2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index ba57f42..afba372 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -162,7 +162,6 @@ struct wilc {
int txq_exit;

struct rxq_entry_t rxq_head;
- int rxq_entries;
int rxq_exit;

unsigned char eth_src_address[NUM_CONCURRENT_IFC][6];
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 059c5c7..26252d1 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -398,16 +398,14 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc,
return tqe;
}

-static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
+static void wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
{
if (wilc->quit)
- return 0;
+ return;

mutex_lock(&wilc->rxq_cs);
list_add_tail(&rqe->list, &wilc->rxq_head.list);
- wilc->rxq_entries += 1;
mutex_unlock(&wilc->rxq_cs);
- return wilc->rxq_entries;
}

static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
@@ -419,7 +417,6 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t,
list);
list_del(&rqe->list);
- wilc->rxq_entries -= 1;
}
mutex_unlock(&wilc->rxq_cs);
return rqe;
--
2.7.4

2018-06-04 09:42:29

by Claudiu Beznea

[permalink] [raw]
Subject: Re: [PATCH 0/4] staging: wilc1000: modification to use list_head data structure

Reviewed-by: Claudiu Beznea <[email protected]>

On 04.06.2018 08:29, Ajay Singh wrote:
> Instead of having own linked list implementation to maintain buffer queue change
> to use list_head. Also removed the few elements from 'wilc' struct as it's not
> required to be part of 'wilc' struct.
>
> Ajay Singh (4):
> staging: wilc1000: use list_head to maintain 'txq_entry_t' elements of
> tx queue
> staging: wilc1000: use list_head to maintain 'rxq_entry_t elements in
> rx queue
> staging: wilc1000: remove 'rxq_entries' from 'wilc' struct
> staging: wilc1000: move 'txq_spinlock_flags' from 'wilc' structure to
> local variable
>
> drivers/staging/wilc1000/linux_wlan.c | 2 +
> drivers/staging/wilc1000/wilc_wfi_netdevice.h | 9 +--
> drivers/staging/wilc1000/wilc_wlan.c | 101 ++++++++------------------
> drivers/staging/wilc1000/wilc_wlan.h | 5 +-
> 4 files changed, 37 insertions(+), 80 deletions(-)
>

2018-06-04 05:29:19

by Ajay Singh

[permalink] [raw]
Subject: [PATCH 1/4] staging: wilc1000: use list_head to maintain 'txq_entry_t' elements of tx queue

Use list_head data structure for the doubly linked list instead of own
implementation.
Only 'txq_head' is required, so removed the txq_tail pointer from
'wilc' structure.

Following functions are modified to provide data using list_head API's
wilc_wlan_txq_remove()
wilc_wlan_txq_remove_from_head()
wilc_wlan_txq_add_to_tail()
wilc_wlan_txq_add_to_head()
wilc_wlan_txq_get_first()
wilc_wlan_txq_get_next()

Signed-off-by: Ajay Singh <[email protected]>
---
drivers/staging/wilc1000/linux_wlan.c | 1 +
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +-
drivers/staging/wilc1000/wilc_wlan.c | 61 +++++++--------------------
drivers/staging/wilc1000/wilc_wlan.h | 3 +-
4 files changed, 19 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 02e6b13..eac719b 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1118,6 +1118,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
wl->io_type = io_type;
wl->gpio = gpio;
wl->hif_func = ops;
+ INIT_LIST_HEAD(&wl->txq_head.list);

register_inetaddr_notifier(&g_dev_notifier);

diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index f2b07e8..e1fab73 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -157,8 +157,7 @@ struct wilc {

unsigned long txq_spinlock_flags;

- struct txq_entry_t *txq_head;
- struct txq_entry_t *txq_tail;
+ struct txq_entry_t txq_head;
int txq_entries;
int txq_exit;

diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index d4ebbf6..857cc38 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -20,25 +20,14 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release)

static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
{
- if (tqe == wilc->txq_head) {
- wilc->txq_head = tqe->next;
- if (wilc->txq_head)
- wilc->txq_head->prev = NULL;
- } else if (tqe == wilc->txq_tail) {
- wilc->txq_tail = (tqe->prev);
- if (wilc->txq_tail)
- wilc->txq_tail->next = NULL;
- } else {
- tqe->prev->next = tqe->next;
- tqe->next->prev = tqe->prev;
- }
+ list_del(&tqe->list);
wilc->txq_entries -= 1;
}

static struct txq_entry_t *
wilc_wlan_txq_remove_from_head(struct net_device *dev)
{
- struct txq_entry_t *tqe;
+ struct txq_entry_t *tqe = NULL;
unsigned long flags;
struct wilc_vif *vif;
struct wilc *wilc;
@@ -47,15 +36,12 @@ wilc_wlan_txq_remove_from_head(struct net_device *dev)
wilc = vif->wilc;

spin_lock_irqsave(&wilc->txq_spinlock, flags);
- if (wilc->txq_head) {
- tqe = wilc->txq_head;
- wilc->txq_head = tqe->next;
- if (wilc->txq_head)
- wilc->txq_head->prev = NULL;

+ if (!list_empty(&wilc->txq_head.list)) {
+ tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t,
+ list);
+ list_del(&tqe->list);
wilc->txq_entries -= 1;
- } else {
- tqe = NULL;
}
spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
return tqe;
@@ -73,17 +59,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev,

spin_lock_irqsave(&wilc->txq_spinlock, flags);

- if (!wilc->txq_head) {
- tqe->next = NULL;
- tqe->prev = NULL;
- wilc->txq_head = tqe;
- wilc->txq_tail = tqe;
- } else {
- tqe->next = NULL;
- tqe->prev = wilc->txq_tail;
- wilc->txq_tail->next = tqe;
- wilc->txq_tail = tqe;
- }
+ list_add_tail(&tqe->list, &wilc->txq_head.list);
wilc->txq_entries += 1;

spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
@@ -101,17 +77,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif,

spin_lock_irqsave(&wilc->txq_spinlock, flags);

- if (!wilc->txq_head) {
- tqe->next = NULL;
- tqe->prev = NULL;
- wilc->txq_head = tqe;
- wilc->txq_tail = tqe;
- } else {
- tqe->next = wilc->txq_head;
- tqe->prev = NULL;
- wilc->txq_head->prev = tqe;
- wilc->txq_head = tqe;
- }
+ list_add(&tqe->list, &wilc->txq_head.list);
wilc->txq_entries += 1;

spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
@@ -402,12 +368,14 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,

static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc)
{
- struct txq_entry_t *tqe;
+ struct txq_entry_t *tqe = NULL;
unsigned long flags;

spin_lock_irqsave(&wilc->txq_spinlock, flags);

- tqe = wilc->txq_head;
+ if (!list_empty(&wilc->txq_head.list))
+ tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t,
+ list);

spin_unlock_irqrestore(&wilc->txq_spinlock, flags);

@@ -421,7 +389,10 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc,

spin_lock_irqsave(&wilc->txq_spinlock, flags);

- tqe = tqe->next;
+ if (!list_is_last(&tqe->list, &wilc->txq_head.list))
+ tqe = list_next_entry(tqe, list);
+ else
+ tqe = NULL;
spin_unlock_irqrestore(&wilc->txq_spinlock, flags);

return tqe;
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index a5b9c68..e0ff3e8 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -207,8 +207,7 @@
********************************************/

struct txq_entry_t {
- struct txq_entry_t *next;
- struct txq_entry_t *prev;
+ struct list_head list;
int type;
int tcp_pending_ack_idx;
u8 *buffer;
--
2.7.4