diff mbox series

[v3] wifi: wilc1000: Added back-off algorithm to balance tx queue packets.

Message ID 20230907170851.178834-1-prasurjya.rohansaikia@microchip.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series [v3] wifi: wilc1000: Added back-off algorithm to balance tx queue packets. | expand

Commit Message

Prasurjya Rohan Saikia Sept. 7, 2023, 5:08 p.m. UTC
From: Prasurjya Rohan Saikia <prasurjya.rohansaikia@microchip.com>

Added an algorithm to backoff the Tx Task when low memory scenario is
triggered at firmware. During high data transfer from host, the firmware
runs out of VMM memory, which is used to hold the frames from the host.
So added flow control to delay the transmit from host side when there is
not enough space to accomodate frames in firmware side.

Signed-off-by: Prasurjya Rohan Saikia <prasurjya.rohansaikia@microchip.com>
---
v1 -> v2: Removed the unused `timeout` variable.
v2 -> v3: Replaced schedule_timeout() by schedule_timeout_interruptible().
---
 .../net/wireless/microchip/wilc1000/netdev.c  | 21 +++++++++++++++----
 .../net/wireless/microchip/wilc1000/netdev.h  |  2 ++
 2 files changed, 19 insertions(+), 4 deletions(-)

Comments

Johannes Berg Sept. 7, 2023, 5:57 p.m. UTC | #1
On Thu, 2023-09-07 at 17:08 +0000, Prasurjya.Rohansaikia@microchip.com
wrote:
> From: Prasurjya Rohan Saikia <prasurjya.rohansaikia@microchip.com>
> 
> Added an algorithm to backoff the Tx Task when low memory scenario is
> triggered at firmware. During high data transfer from host, the firmware
> runs out of VMM memory, which is used to hold the frames from the host.
> So added flow control to delay the transmit from host side when there is
> not enough space to accomodate frames in firmware side.
> 

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#commit_messages

   Please write commit messages, like mentioned for the subject above,
   in imperative voice. 

and that says:

   Subject lines, like commit messages (see below) should be written in
   imperative voice (“fix foo and optimize bar”), not in any other way such
   as past tense (“fixed foo and optimized bar”). 

johannes
Prasurjya Rohan Saikia Sept. 15, 2023, 5:27 p.m. UTC | #2
On 9/7/23 23:27, Johannes Berg wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Thu, 2023-09-07 at 17:08 +0000, Prasurjya.Rohansaikia@microchip.com
> wrote:
>> From: Prasurjya Rohan Saikia <prasurjya.rohansaikia@microchip.com>
>>
>> Added an algorithm to backoff the Tx Task when low memory scenario is
>> triggered at firmware. During high data transfer from host, the firmware
>> runs out of VMM memory, which is used to hold the frames from the host.
>> So added flow control to delay the transmit from host side when there is
>> not enough space to accomodate frames in firmware side.
>>
> 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#commit_messages
> 
>    Please write commit messages, like mentioned for the subject above,
>    in imperative voice.
> 
> and that says:
> 
>    Subject lines, like commit messages (see below) should be written in
>    imperative voice (“fix foo and optimize bar”), not in any other way such
>    as past tense (“fixed foo and optimized bar”).
> 
> johannes

Thanks you for pointing it out. I've accordingly updated my current
outgoing patch & I'll definitely keep it in mind from the next time I
create a commit.
Prasurjya Rohan Saikia Sept. 15, 2023, 5:29 p.m. UTC | #3
On 9/7/23 23:27, Johannes Berg wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Thu, 2023-09-07 at 17:08 +0000, Prasurjya.Rohansaikia@microchip.com
> wrote:
>> From: Prasurjya Rohan Saikia <prasurjya.rohansaikia@microchip.com>
>>
>> Added an algorithm to backoff the Tx Task when low memory scenario is
>> triggered at firmware. During high data transfer from host, the firmware
>> runs out of VMM memory, which is used to hold the frames from the host.
>> So added flow control to delay the transmit from host side when there is
>> not enough space to accomodate frames in firmware side.
>>
> 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches#commit_messages
> 
>    Please write commit messages, like mentioned for the subject above,
>    in imperative voice.
> 
> and that says:
> 
>    Subject lines, like commit messages (see below) should be written in
>    imperative voice (“fix foo and optimize bar”), not in any other way such
>    as past tense (“fixed foo and optimized bar”).
> 
> johannes

Thanks you for pointing it out. I've accordingly updated my current
outgoing patch & will definitely keep this point in mind the next time I
create a commit.
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
index e9f59de31b0b..f6bec17bfd0f 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.c
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -148,8 +148,8 @@  static int wilc_txq_task(void *vp)
 
 	complete(&wl->txq_thread_started);
 	while (1) {
-		wait_for_completion(&wl->txq_event);
-
+		if (wait_for_completion_interruptible(&wl->txq_event))
+			continue;
 		if (wl->close) {
 			complete(&wl->txq_thread_started);
 
@@ -166,12 +166,25 @@  static int wilc_txq_task(void *vp)
 				srcu_idx = srcu_read_lock(&wl->srcu);
 				list_for_each_entry_rcu(ifc, &wl->vif_list,
 							list) {
-					if (ifc->mac_opened && ifc->ndev)
+					if (ifc->mac_opened &&
+					    netif_queue_stopped(ifc->ndev))
 						netif_wake_queue(ifc->ndev);
 				}
 				srcu_read_unlock(&wl->srcu, srcu_idx);
 			}
-		} while (ret == WILC_VMM_ENTRY_FULL_RETRY && !wl->close);
+			if (ret != WILC_VMM_ENTRY_FULL_RETRY)
+				break;
+			/* Back off TX task from sending packets for some time.
+			 * schedule_timeout_interruptible will allow RX task
+			 * to run and free buffers. TX task will be in
+			 * TASK_INTERRUPTIBLE state which will put the thread
+			 * back to CPU running queue when it's signaled even
+			 * if the timeout isn't elapsed. This gives faster chance
+			 * for reserved SK buffers to be freed
+			 */
+			schedule_timeout_interruptible(msecs_to_jiffies
+						       (TX_BACKOFF_WEIGHT_MS));
+		} while (!wl->close);
 	}
 	return 0;
 }
diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h
index bb1a315a7b7e..aafe3dc44ac6 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.h
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.h
@@ -27,6 +27,8 @@ 
 #define TCP_ACK_FILTER_LINK_SPEED_THRESH	54
 #define DEFAULT_LINK_SPEED			72
 
+#define TX_BACKOFF_WEIGHT_MS			1
+
 struct wilc_wfi_stats {
 	unsigned long rx_packets;
 	unsigned long tx_packets;