All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aditya Shankar <aditya.shankar@microchip.com>
To: <gregkh@linuxfoundation.org>, <linux-wireless@vger.kernel.org>
Cc: <devel@driverdev.osuosl.org>, <Ganesh.Krishna@microchip.com>,
	Aditya Shankar <aditya.shankar@microchip.com>
Subject: [PATCH v2 2/8] staging: wilc1000: Add function to calculate ac queue limit
Date: Mon, 26 Jun 2017 17:13:24 +0530	[thread overview]
Message-ID: <1498477410-19518-3-git-send-email-aditya.shankar@microchip.com> (raw)
In-Reply-To: <1498477410-19518-1-git-send-email-aditya.shankar@microchip.com>

This patch adds a function which calculates the queue limit
for a given access category queue.

Signed-off-by: Aditya Shankar <aditya.shankar@microchip.com>
---
 drivers/staging/wilc1000/wilc_wlan.c | 42 ++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 9addef1..8c997ba 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -333,6 +333,48 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer,
 	return 1;
 }
 
+static inline void ac_q_limit(u8 ac, u16 *q_limit)
+{
+	static bool initialized;
+	static u8 buffer[AC_BUFFER_SIZE];
+	static u16 cnt[NQUEUES];
+	u8 factors[NQUEUES] = {1, 1, 1, 1};
+	static u16 sum;
+	u16 i;
+	static u16 end_index;
+
+	if (!initialized) {
+		for (i = 0; i < AC_BUFFER_SIZE; i++)
+			buffer[i] = i % NQUEUES;
+
+		for (i = 0; i < NQUEUES; i++) {
+			cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES;
+			sum += cnt[i];
+		}
+		end_index = AC_BUFFER_SIZE - 1;
+		initialized = 1;
+	}
+	if (end_index > AC_BUFFER_SIZE - 1)
+		end_index = AC_BUFFER_SIZE - 1;
+
+	cnt[buffer[end_index]] -= factors[buffer[end_index]];
+	cnt[ac] += factors[ac];
+	sum += (factors[ac] - factors[buffer[end_index]]);
+
+	buffer[end_index] = ac;
+	if (end_index > 0)
+		end_index--;
+	else
+		end_index = AC_BUFFER_SIZE - 1;
+
+	for (i = 0; i < NQUEUES; i++)
+		if (!sum)
+			q_limit[i] = 1;
+		else
+			q_limit[i] = (cnt[i] * FLOW_CONTROL_UPPER_THRESHOLD /
+				      sum) + 1;
+}
+
 int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
 			      u32 buffer_size, wilc_tx_complete_func_t func)
 {
-- 
2.7.4

  parent reply	other threads:[~2017-06-26 11:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26 11:43 [PATCH v2 0/8] Enable access category classification on Tx path Aditya Shankar
2017-06-26 11:43 ` [PATCH v2 1/8] staging: wilc1000: Add support for AC classification Aditya Shankar
2017-06-26 11:43 ` Aditya Shankar [this message]
2017-06-26 11:43 ` [PATCH v2 3/8] staging: wilc1000: WMM classification of data Aditya Shankar
2017-06-26 11:43 ` [PATCH v2 4/8] staging: wilc1000: Add function to balance packet count Aditya Shankar
2017-06-26 11:43 ` [PATCH v2 5/8] staging: wilc1000: Add new variable for ac queue management Aditya Shankar
2017-06-29 14:38   ` Greg KH
2017-06-26 11:43 ` [PATCH v2 6/8] staging: wilc1000: Get packet count from firmware Aditya Shankar
2017-06-26 11:43 ` [PATCH v2 7/8] staging: wilc1000: Change ac based on acm status Aditya Shankar
2017-06-26 11:43 ` [PATCH v2 8/8] staging: wilc1000: Update ACM bit status Aditya Shankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498477410-19518-3-git-send-email-aditya.shankar@microchip.com \
    --to=aditya.shankar@microchip.com \
    --cc=Ganesh.Krishna@microchip.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.