Skip to contentSkip to conversation

rt2x00: Tune link depending on link quality

PATCH In review Ivo van Doorn 1 participant 1 message Apr 27, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 13/32 rt2x00: Tune link depending on link quality

From: Ivo van Doorn <[email protected]>

Add link tuning capabilities, and call this function every time the rxdone handler has finished.

drivers/net/wireless/d80211/rt2x00/rt2400pci.c +43 -0
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c
@@ -618,6 +618,41 @@ rt2400pci_config_rate(struct rt2x00_pci 
 }
 
 /*
+ * Link tuning
+ */
+static void
+rt2400pci_link_tuner(struct rt2x00_pci *rt2x00pci)
+{
+	u8			reg;
+	char			false_cca_delta;
+
+	/*
+	 * Read false CCA counter.
+	 */
+	rt2x00_bbp_read(rt2x00pci, 39, &reg);
+
+	/*
+	 * Determine difference with previous CCA counter.
+	 */
+	false_cca_delta = reg - rt2x00pci->false_cca;
+	rt2x00pci->false_cca = reg;
+
+	/*
+	 * Check if the difference is higher than the
+	 * threshold and if so, tune the link.
+	 */
+	if (false_cca_delta >= 8) {
+		/*
+		 * Read and update RX AGC VGC.
+		 */
+		rt2x00_bbp_read(rt2x00pci, 13, &reg);
+		reg += 2;
+		if (reg < 0x20)
+			rt2x00_bbp_write(rt2x00pci, 13, reg);
+	}
+}
+
+/*
  * TX descriptor initialization
  */
 static void
@@ -779,6 +814,9 @@ rt2400pci_rxdone(void *data)
 
 			memcpy(skb_put(skb, size), entry->data_addr, size);
 
+			ring->params.rx.ssi =
+				rt2x00_get_field32(rxd->word2, RXD_W2_RSSI);
+
 			__ieee80211_rx(net_dev, skb, &ring->params.rx);
 		}
 
@@ -786,6 +824,11 @@ rt2400pci_rxdone(void *data)
 
 		rt2x00_ring_index_inc(&rt2x00pci->rx);
 	}
+
+	/*
+	 * Tune link for optimal performance.
+	 */
+	rt2400pci_link_tuner(rt2x00pci);
 }
 
 static void
drivers/net/wireless/d80211/rt2x00/rt2400pci.h +5 -0
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.h wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.h
@@ -926,6 +926,11 @@ struct rt2x00_pci{
 	struct workqueue_struct		*workqueue;
 
 	/*
+	 * False CCA count.
+	 */
+	int					false_cca;
+
+	/*
 	 * EEPROM bus width.
 	 */
 	u8					eeprom_width;
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +65 -0

89 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt2500usb.c +82 -0

107 lines not on this page · raw message