All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <sgruszka@redhat.com>
To: linux-wireless@vger.kernel.org
Cc: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>,
	Felix Fietkau <nbd@nbd.name>,
	linux-mediatek@lists.infradead.org
Subject: [PATCH 08/22] mt76: unify AC to hw queue mapping
Date: Tue,  4 Sep 2018 16:41:01 +0200	[thread overview]
Message-ID: <1536072075-6990-9-git-send-email-sgruszka@redhat.com> (raw)
In-Reply-To: <1536072075-6990-1-git-send-email-sgruszka@redhat.com>

Use the same AC to hardware queue mappings for all subdrivers.
Note: this change BK and BE mappings for USB drivers.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76.h       |  8 +-------
 drivers/net/wireless/mediatek/mt76/mt76x0/tx.c  |  4 ++--
 drivers/net/wireless/mediatek/mt76/mt76x2_dma.c | 10 ++--------
 drivers/net/wireless/mediatek/mt76/tx.c         | 16 ++++++++++++++++
 drivers/net/wireless/mediatek/mt76/usb.c        |  2 +-
 5 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index cb9b9852f32f..7a7d13b16508 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -519,13 +519,7 @@ static inline int mt76_decr(int val, int size)
 	return (val - 1) & (size - 1);
 }
 
-/* Hardware uses mirrored order of queues with Q3
- * having the highest priority
- */
-static inline u8 q2hwq(u8 q)
-{
-	return q ^ 0x3;
-}
+u8 mt76_ac_to_hwq(u8 ac);
 
 static inline struct ieee80211_txq *
 mtxq_to_txq(struct mt76_txq *mtxq)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
index 73ea6d3097f2..acf830bc9b4e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
@@ -25,7 +25,7 @@ static u8 skb2q(struct sk_buff *skb)
 		skb_set_queue_mapping(skb, qid);
 	}
 
-	return q2hwq(qid);
+	return mt76_ac_to_hwq(qid);
 }
 
 static void mt76x0_tx_skb_remove_dma_overhead(struct sk_buff *skb,
@@ -216,7 +216,7 @@ int mt76x0_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		    u16 queue, const struct ieee80211_tx_queue_params *params)
 {
 	struct mt76x0_dev *dev = hw->priv;
-	u8 cw_min = 5, cw_max = 10, hw_q = q2hwq(queue);
+	u8 cw_min = 5, cw_max = 10, hw_q = mt76_ac_to_hwq(queue);
 	u32 val;
 
 	/* TODO: should we do funny things with the parameters?
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c b/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c
index 6720a6a1313f..1c8e5d7be425 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c
@@ -102,12 +102,6 @@ mt76x2_tx_tasklet(unsigned long data)
 
 int mt76x2_dma_init(struct mt76x2_dev *dev)
 {
-	static const u8 wmm_queue_map[] = {
-		[IEEE80211_AC_BE] = 0,
-		[IEEE80211_AC_BK] = 1,
-		[IEEE80211_AC_VI] = 2,
-		[IEEE80211_AC_VO] = 3,
-	};
 	int ret;
 	int i;
 	struct mt76_txwi_cache __maybe_unused *t;
@@ -125,9 +119,9 @@ int mt76x2_dma_init(struct mt76x2_dev *dev)
 
 	mt76_wr(dev, MT_WPDMA_RST_IDX, ~0);
 
-	for (i = 0; i < ARRAY_SIZE(wmm_queue_map); i++) {
+	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
 		ret = mt76x2_init_tx_queue(dev, &dev->mt76.q_tx[i],
-					   wmm_queue_map[i], MT_TX_RING_SIZE);
+					   mt76_ac_to_hwq(i), MT_TX_RING_SIZE);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
index af48d43bb7dc..cf79b8c67b52 100644
--- a/drivers/net/wireless/mediatek/mt76/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/tx.c
@@ -442,3 +442,19 @@ void mt76_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq)
 	mtxq->hwq = &dev->q_tx[mt76_txq_get_qid(txq)];
 }
 EXPORT_SYMBOL_GPL(mt76_txq_init);
+
+u8 mt76_ac_to_hwq(u8 ac)
+{
+	static const u8 wmm_queue_map[] = {
+		[IEEE80211_AC_BE] = 0,
+		[IEEE80211_AC_BK] = 1,
+		[IEEE80211_AC_VI] = 2,
+		[IEEE80211_AC_VO] = 3,
+	};
+
+	if (WARN_ON(ac >= IEEE80211_NUM_ACS))
+		return 0;
+
+	return wmm_queue_map[ac];
+}
+EXPORT_SYMBOL_GPL(mt76_ac_to_hwq);
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 7780b07543bb..333b2c8ca7a4 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -715,7 +715,7 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
 		q = &dev->q_tx[i];
 		spin_lock_init(&q->lock);
 		INIT_LIST_HEAD(&q->swq);
-		q->hw_idx = q2hwq(i);
+		q->hw_idx = mt76_ac_to_hwq(i);
 
 		q->entry = devm_kzalloc(dev->dev,
 					MT_NUM_TX_ENTRIES * sizeof(*q->entry),
-- 
2.7.5

WARNING: multiple messages have this Message-ID (diff)
From: Stanislaw Gruszka <sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Lorenzo Bianconi
	<lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Felix Fietkau <nbd-Vt+b4OUoWG0@public.gmane.org>,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 08/22] mt76: unify AC to hw queue mapping
Date: Tue,  4 Sep 2018 16:41:01 +0200	[thread overview]
Message-ID: <1536072075-6990-9-git-send-email-sgruszka@redhat.com> (raw)
In-Reply-To: <1536072075-6990-1-git-send-email-sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Use the same AC to hardware queue mappings for all subdrivers.
Note: this change BK and BE mappings for USB drivers.

Signed-off-by: Stanislaw Gruszka <sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 drivers/net/wireless/mediatek/mt76/mt76.h       |  8 +-------
 drivers/net/wireless/mediatek/mt76/mt76x0/tx.c  |  4 ++--
 drivers/net/wireless/mediatek/mt76/mt76x2_dma.c | 10 ++--------
 drivers/net/wireless/mediatek/mt76/tx.c         | 16 ++++++++++++++++
 drivers/net/wireless/mediatek/mt76/usb.c        |  2 +-
 5 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index cb9b9852f32f..7a7d13b16508 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -519,13 +519,7 @@ static inline int mt76_decr(int val, int size)
 	return (val - 1) & (size - 1);
 }
 
-/* Hardware uses mirrored order of queues with Q3
- * having the highest priority
- */
-static inline u8 q2hwq(u8 q)
-{
-	return q ^ 0x3;
-}
+u8 mt76_ac_to_hwq(u8 ac);
 
 static inline struct ieee80211_txq *
 mtxq_to_txq(struct mt76_txq *mtxq)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
index 73ea6d3097f2..acf830bc9b4e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
@@ -25,7 +25,7 @@ static u8 skb2q(struct sk_buff *skb)
 		skb_set_queue_mapping(skb, qid);
 	}
 
-	return q2hwq(qid);
+	return mt76_ac_to_hwq(qid);
 }
 
 static void mt76x0_tx_skb_remove_dma_overhead(struct sk_buff *skb,
@@ -216,7 +216,7 @@ int mt76x0_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		    u16 queue, const struct ieee80211_tx_queue_params *params)
 {
 	struct mt76x0_dev *dev = hw->priv;
-	u8 cw_min = 5, cw_max = 10, hw_q = q2hwq(queue);
+	u8 cw_min = 5, cw_max = 10, hw_q = mt76_ac_to_hwq(queue);
 	u32 val;
 
 	/* TODO: should we do funny things with the parameters?
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c b/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c
index 6720a6a1313f..1c8e5d7be425 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2_dma.c
@@ -102,12 +102,6 @@ mt76x2_tx_tasklet(unsigned long data)
 
 int mt76x2_dma_init(struct mt76x2_dev *dev)
 {
-	static const u8 wmm_queue_map[] = {
-		[IEEE80211_AC_BE] = 0,
-		[IEEE80211_AC_BK] = 1,
-		[IEEE80211_AC_VI] = 2,
-		[IEEE80211_AC_VO] = 3,
-	};
 	int ret;
 	int i;
 	struct mt76_txwi_cache __maybe_unused *t;
@@ -125,9 +119,9 @@ int mt76x2_dma_init(struct mt76x2_dev *dev)
 
 	mt76_wr(dev, MT_WPDMA_RST_IDX, ~0);
 
-	for (i = 0; i < ARRAY_SIZE(wmm_queue_map); i++) {
+	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
 		ret = mt76x2_init_tx_queue(dev, &dev->mt76.q_tx[i],
-					   wmm_queue_map[i], MT_TX_RING_SIZE);
+					   mt76_ac_to_hwq(i), MT_TX_RING_SIZE);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
index af48d43bb7dc..cf79b8c67b52 100644
--- a/drivers/net/wireless/mediatek/mt76/tx.c
+++ b/drivers/net/wireless/mediatek/mt76/tx.c
@@ -442,3 +442,19 @@ void mt76_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq)
 	mtxq->hwq = &dev->q_tx[mt76_txq_get_qid(txq)];
 }
 EXPORT_SYMBOL_GPL(mt76_txq_init);
+
+u8 mt76_ac_to_hwq(u8 ac)
+{
+	static const u8 wmm_queue_map[] = {
+		[IEEE80211_AC_BE] = 0,
+		[IEEE80211_AC_BK] = 1,
+		[IEEE80211_AC_VI] = 2,
+		[IEEE80211_AC_VO] = 3,
+	};
+
+	if (WARN_ON(ac >= IEEE80211_NUM_ACS))
+		return 0;
+
+	return wmm_queue_map[ac];
+}
+EXPORT_SYMBOL_GPL(mt76_ac_to_hwq);
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 7780b07543bb..333b2c8ca7a4 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -715,7 +715,7 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
 		q = &dev->q_tx[i];
 		spin_lock_init(&q->lock);
 		INIT_LIST_HEAD(&q->swq);
-		q->hw_idx = q2hwq(i);
+		q->hw_idx = mt76_ac_to_hwq(i);
 
 		q->entry = devm_kzalloc(dev->dev,
 					MT_NUM_TX_ENTRIES * sizeof(*q->entry),
-- 
2.7.5

  parent reply	other threads:[~2018-09-04 19:07 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 14:40 [PATCH 00/22] mt76 patches 2018-09-04 Stanislaw Gruszka
2018-09-04 14:40 ` Stanislaw Gruszka
2018-09-04 14:40 ` [PATCH 01/22] mt76: move wcid fields to common mt76_dev struct Stanislaw Gruszka
2018-09-04 14:40   ` Stanislaw Gruszka
2018-09-04 14:40 ` [PATCH 02/22] mt76: unify sta_add / sta_remove Stanislaw Gruszka
2018-09-04 14:40   ` Stanislaw Gruszka
2018-09-04 14:40 ` [PATCH 03/22] mt76: pratially unify add_interface Stanislaw Gruszka
2018-09-04 14:40   ` Stanislaw Gruszka
2018-09-04 14:40 ` [PATCH 04/22] mt76x0: fix wrong usage of wcid_mask in remove_interface Stanislaw Gruszka
2018-09-04 14:40   ` Stanislaw Gruszka
2018-09-04 14:40 ` [PATCH 05/22] mt76: unify ampdu_action Stanislaw Gruszka
2018-09-04 14:40   ` Stanislaw Gruszka
2018-09-04 14:40 ` [PATCH 06/22] mt76: unify set_key Stanislaw Gruszka
2018-09-04 14:40   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 07/22] mt76x0: remove empty sta_notify Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` Stanislaw Gruszka [this message]
2018-09-04 14:41   ` [PATCH 08/22] mt76: unify AC to hw queue mapping Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 09/22] mt76: remove q->hw_idx Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-10  9:19   ` Felix Fietkau
2018-09-10  9:19     ` Felix Fietkau
2018-09-04 14:41 ` [PATCH 10/22] mt76: unify conf_tx Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 11/22] mt76x0: remove vif_mask Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 12/22] mt76: unify remove_interface Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 13/22] mt76: unify add_interface Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 14/22] mt76: unify sta_rate_tbl_update and related helpers Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 15/22] mt76: unify txwi and rxwi structures Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 16/22] mt76: unify load_tx_status Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 17/22] mt76: unify send_tx_status and related helpers Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 18/22] mt76: use mt76_rx_status in mt76x0 Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 19/22] mt76: unify mac_process_rate Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 20/22] mt76x0: reserve enough space in mac80211 Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 21/22] mt76: unify {insert/remove}_hdr_pad Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-04 14:41 ` [PATCH 22/22] mt76: partially unify filling txwi fields Stanislaw Gruszka
2018-09-04 14:41   ` Stanislaw Gruszka
2018-09-11 14:19 ` [PATCH 00/22] mt76 patches 2018-09-04 Kalle Valo
2018-09-11 14:19   ` Kalle Valo

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=1536072075-6990-9-git-send-email-sgruszka@redhat.com \
    --to=sgruszka@redhat.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    /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.