Skip to contentSkip to conversation

b43: Add QOS support

PATCH In review Michael Buesch 2 participants 8 messages Feb 12, 2008 – Feb 13, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 b43: Add QOS support

This patch adds QOS support for b43.
Please comment on this and test this.
This patch depends on Johannes' "burst time -> txop patch" being _not_ applied. One can trivially fix that, though.

drivers/net/wireless/b43/b43.h +37 -0
Index: wireless-2.6/drivers/net/wireless/b43/b43.h
===================================================================
@@ -96,12 +96,14 @@
 #define B43_MMIO_TSF_CFP_START_HIGH	0x606
 #define B43_MMIO_TSF_0			0x632	/* core rev < 3 only */
 #define B43_MMIO_TSF_1			0x634	/* core rev < 3 only */
 #define B43_MMIO_TSF_2			0x636	/* core rev < 3 only */
 #define B43_MMIO_TSF_3			0x638	/* core rev < 3 only */
 #define B43_MMIO_RNG			0x65A
+#define B43_MMIO_IFSCTL			0x688 /* Interframe space control */
+#define  B43_MMIO_IFSCTL_USE_EDCF	0x0004
 #define B43_MMIO_POWERUP_DELAY		0x6A8
 
 /* SPROM boardflags_lo values */
 #define B43_BFL_BTCOEXIST		0x0001	/* implements Bluetooth coexistance */
 #define B43_BFL_PACTRL			0x0002	/* GPIO 9 controlling the PA */
 #define B43_BFL_AIRLINEMODE		0x0004	/* implements GPIO 13 radio disable indication */
@@ -607,12 +609,41 @@ struct b43_key {
 	 * keyconf is a cookie. Don't derefenrence it outside of the set_key
 	 * path, because b43 doesn't own it. */
 	struct ieee80211_key_conf *keyconf;
 	u8 algorithm;
 };
 
+/* SHM offsets to the QOS data structures for the 4 different queues. */
+#define B43_QOS_PARAMS(queue)	(B43_SHM_SH_EDCFQ + \
+				 (B43_NR_QOSPARAMS * sizeof(u16) * (queue)))
+#define B43_QOS_BACKGROUND	B43_QOS_PARAMS(0)
+#define B43_QOS_BESTEFFORT	B43_QOS_PARAMS(1)
+#define B43_QOS_VIDEO		B43_QOS_PARAMS(2)
+#define B43_QOS_VOICE		B43_QOS_PARAMS(3)
+
+/* QOS parameter hardware data structure offsets. */
+#define B43_NR_QOSPARAMS	22
+enum {
+	B43_QOSPARAM_TXOP = 0,
+	B43_QOSPARAM_CWMIN,
+	B43_QOSPARAM_CWMAX,
+	B43_QOSPARAM_CWCUR,
+	B43_QOSPARAM_AIFS,
+	B43_QOSPARAM_BSLOTS,
+	B43_QOSPARAM_REGGAP,
+	B43_QOSPARAM_STATUS,
+};
+
+/* QOS parameters for a queue. */
+struct b43_qos_params {
+	/* The QOS parameters */
+	struct ieee80211_tx_queue_params p;
+	/* Does this need to get uploaded to hardware? */
+	bool need_hw_update;
+};
+
 struct b43_wldev;
 
 /* Data structure for the WLAN parts (802.11 cores) of the b43 chip. */
 struct b43_wl {
 	/* Pointer to the active wireless device on this chip */
 	struct b43_wldev *current_dev;
@@ -659,12 +690,18 @@ struct b43_wl {
 
 	/* The beacon we are currently using (AP or IBSS mode).
 	 * This beacon stuff is protected by the irq_lock. */
 	struct sk_buff *current_beacon;
 	bool beacon0_uploaded;
 	bool beacon1_uploaded;
+
+	/* The current QOS parameters for the 4 queues.
+	 * This is protected by the irq_lock. */
+	struct b43_qos_params qos_params[4];
+	/* Workqueue for updating QOS parameters in hardware. */
+	struct work_struct qos_update_work;
 };
 
 /* In-memory representation of a cached microcode file. */
 struct b43_firmware_file {
 	const char *filename;
 	const struct firmware *data;
drivers/net/wireless/b43/dma.c +4 -10
Index: wireless-2.6/drivers/net/wireless/b43/dma.c
===================================================================
@@ -294,46 +294,40 @@ static inline int request_slot(struct b4
 /* Mac80211-queue to b43-ring mapping */
 static struct b43_dmaring *priority_to_txring(struct b43_wldev *dev,
 					      int queue_priority)
 {
 	struct b43_dmaring *ring;
 
-/*FIXME: For now we always run on TX-ring-1 */
-	return dev->dma.tx_ring1;
-
 	/* 0 = highest priority */
 	switch (queue_priority) {
 	default:
 		B43_WARN_ON(1);
 		/* fallthrough */
 	case 0:
-		ring = dev->dma.tx_ring3;
+		ring = dev->dma.tx_ring3; /* AC_VO */
 		break;
 	case 1:
-		ring = dev->dma.tx_ring2;
+		ring = dev->dma.tx_ring2; /* AC_VI */
 		break;
 	case 2:
-		ring = dev->dma.tx_ring1;
+		ring = dev->dma.tx_ring1; /* AC_BE */
 		break;
 	case 3:
-		ring = dev->dma.tx_ring0;
+		ring = dev->dma.tx_ring0; /* AC_BK */
 		break;
 	}
 
 	return ring;
 }
 
 /* b43-ring to mac80211-queue mapping */
 static inline int txring_to_priority(struct b43_dmaring *ring)
 {
 	static const u8 idx_to_prio[] = { 3, 2, 1, 0, };
 	unsigned int index;
 
-/*FIXME: have only one queue, for now */
-	return 0;
-
 	index = ring->index;
 	if (B43_WARN_ON(index >= ARRAY_SIZE(idx_to_prio)))
 		index = 0;
 	return idx_to_prio[index];
 }
 
drivers/net/wireless/b43/main.c +167 -2

232 lines not on this page · raw message

drivers/net/wireless/b43/xmit.c +0 -27
Index: wireless-2.6/drivers/net/wireless/b43/xmit.c
===================================================================
@@ -698,33 +698,6 @@ void b43_tx_suspend(struct b43_wldev *de
 
 /* Resume any TX operation on the device (resume the hardware queues) */
 void b43_tx_resume(struct b43_wldev *dev)
 {
 	b43_dma_tx_resume(dev);
 }
-
-#if 0
-static void upload_qos_parms(struct b43_wldev *dev,
-			     const u16 * parms, u16 offset)
-{
-	int i;
-
-	for (i = 0; i < B43_NR_QOSPARMS; i++) {
-		b43_shm_write16(dev, B43_SHM_SHARED,
-				offset + (i * 2), parms[i]);
-	}
-}
-#endif
-
-/* Initialize the QoS parameters */
-void b43_qos_init(struct b43_wldev *dev)
-{
-	/* FIXME: This function must probably be called from the mac80211
-	 * config callback. */
-	return;
-
-	b43_hf_write(dev, b43_hf_read(dev) | B43_HF_EDCF);
-	//FIXME kill magic
-	b43_write16(dev, 0x688, b43_read16(dev, 0x688) | 0x4);
-
-	/*TODO: We might need some stack support here to get the values. */
-}
drivers/net/wireless/b43/xmit.h +0 -12
Index: wireless-2.6/drivers/net/wireless/b43/xmit.h
===================================================================
@@ -299,24 +299,12 @@ void b43_handle_txstatus(struct b43_wlde
 void b43_handle_hwtxstatus(struct b43_wldev *dev,
 			   const struct b43_hwtxstatus *hw);
 
 void b43_tx_suspend(struct b43_wldev *dev);
 void b43_tx_resume(struct b43_wldev *dev);
 
-#define B43_NR_QOSPARMS		22
-enum {
-	B43_QOSPARM_TXOP = 0,
-	B43_QOSPARM_CWMIN,
-	B43_QOSPARM_CWMAX,
-	B43_QOSPARM_CWCUR,
-	B43_QOSPARM_AIFS,
-	B43_QOSPARM_BSLOTS,
-	B43_QOSPARM_REGGAP,
-	B43_QOSPARM_STATUS,
-};
-void b43_qos_init(struct b43_wldev *dev);
 
 /* Helper functions for converting the key-table index from "firmware-format"
  * to "raw-format" and back. The firmware API changed for this at some revision.
  * We need to account for that here. */
 static inline int b43_new_kidx_api(struct b43_wldev *dev)
 {
#1 lore raw

drivers/net/wireless/b43/main.c static int b43_op_tx(struct ieee80211_hw · line 2800

Quoted 10 lines · On Tuesday 12 February 2008 22:05:42 Michael Buesch wrote:

This patch adds QOS support for b43.
Please comment on this and test this.
This patch depends on Johannes' "burst time -> txop patch" being _not_ applied. One can trivially fix that, though.

drivers/net/wireless/b43/main.c +6 -0
+	for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) {
+		params = &(wl->qos_params[i]);
+		if (params->need_hw_update) {
+			b43_qos_params_upload(dev, &(params->p),
+					      qos_shm_offsets[i]);
+			params->need_hw_update = 1;

Whoopsy, needs to be:

			params->need_hw_update = 0;

drivers/net/wireless/b43/main.c static int b43_op_tx(struct ieee80211_hw · line 2825

Quoted 11 lines
drivers/net/wireless/b43/main.c +10 -0
+		}
+	}
+
+	spin_unlock_irqrestore(&wl->irq_lock, flags);
+	b43_mac_enable(dev);
+}
 
+/* Initialize the core's QOS capabilities */
+static void b43_qos_init(struct b43_wldev *dev)
+{
+	/* Upload the current QOS parameters. */

And here we need a loop setting all "need_hw_update" to 1.

Quoted 7 lines
drivers/net/wireless/b43/main.c +7 -0
+	b43_qos_update(dev);
+	/* Enable QOS support. */
+	b43_hf_write(dev, b43_hf_read(dev) | B43_HF_EDCF);
+	b43_write16(dev, B43_MMIO_IFSCTL,
+		    b43_read16(dev, B43_MMIO_IFSCTL)
+		    | B43_MMIO_IFSCTL_USE_EDCF);
+}
Signature · 1 line
Greetings Michael.
#2 lore raw
In reply to Michael Buesch
Quoted 4 lines · On Tuesday 12 February 2008 22:05:42 Michael Buesch wrote:

This patch adds QOS support for b43.
Please comment on this and test this.
This patch depends on Johannes' "burst time -> txop patch" being _not_ applied. One can trivially fix that, though.

Hm, it seems there are two other variables in SHM we should probably write:
0x000E EDCF Status Offset
0x0030 TXF Current Index

The status offset is the offset of the status field in the QOS data structure for a queue?
What is the TXF Current Index?

Signature · 1 line
Greetings Michael.
maintainer
#3 lore raw
Quoted 3 lines

Hm, it seems there are two other variables in SHM we should probably write:
0x000E EDCF Status Offset

I'll have to double-check that.

Quoted 1 line

0x0030 TXF Current Index

I don't think we need to write that, it's used internally by the ucode to manage the queues.

johannes

maintainer
#4 lore raw
In reply to Michael Buesch
Quoted 3 lines

Hm, it seems there are two other variables in SHM we should probably write:
0x000E EDCF Status Offset

Ok already mentioned this on IRC but for the record: this is set by the initial value upload.

johannes

maintainer
#5 lore raw
In reply to Michael Buesch

drivers/net/wireless/b43/main.c static int b43_op_tx(struct ieee80211_hw · line 2860

Quoted 7 lines
drivers/net/wireless/b43/main.c +6 -0
+	if (queue >= ARRAY_SIZE(wl->qos_params)) {
+		/* Queue not available or don't support setting
+		 * params on this queue. Return success to not
+		 * confuse mac80211. */
+		return 0;
+	}

Is that really necessary? If so, I'll probably remove it when doing the QoS rework, it shouldn't be, imho you should return an error if mac80211 tries to configure a queue >= hw.queues.

johannes

#6 lore raw
Quoted 11 lines · On Wednesday 13 February 2008 13:07:53 Johannes Berg wrote:

drivers/net/wireless/b43/main.c static int b43_op_tx(struct ieee80211_hw · line 2860

Quoted 7 lines
drivers/net/wireless/b43/main.c +6 -0
+	if (queue >= ARRAY_SIZE(wl->qos_params)) {
+		/* Queue not available or don't support setting
+		 * params on this queue. Return success to not
+		 * confuse mac80211. */
+		return 0;
+	}

Is that really necessary? If so, I'll probably remove it when doing the QoS rework, it shouldn't be, imho you should return an error if mac80211 tries to configure a queue >= hw.queues.

Yep, mac80211 walks the whole queue array without looking at hw->queues. I think this needs fixing in mac80211.

Signature · 1 line
Greetings Michael.
maintainer
#7 lore raw
Quoted 13 lines · Michael Buesch
Quoted 11 lines · On Wednesday 13 February 2008 13:07:53 Johannes Berg wrote:

drivers/net/wireless/b43/main.c static int b43_op_tx(struct ieee80211_hw · line 2860

Quoted 7 lines
drivers/net/wireless/b43/main.c +6 -0
+	if (queue >= ARRAY_SIZE(wl->qos_params)) {
+		/* Queue not available or don't support setting
+		 * params on this queue. Return success to not
+		 * confuse mac80211. */
+		return 0;
+	}

Is that really necessary? If so, I'll probably remove it when doing the QoS rework, it shouldn't be, imho you should return an error if mac80211 tries to configure a queue >= hw.queues.

Quoted 2 lines

Yep, mac80211 walks the whole queue array without looking at hw->queues. I think this needs fixing in mac80211.

Ah. Yeah I already fixed that in my WIP QoS patch.

johannes