Skip to contentSkip to conversation

d80211: Split antenna selection into TX and RX antenna

PATCH Applied Ivo van Doorn 3 participants 5 messages Feb 21, 2007 – Feb 26, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 d80211: Split antenna selection into TX and RX antenna

With the split antenna selection rt2x00 can now read the default value for both selections from the EEPROM and can now configure the card correctly based on the individual RX and TX antenna selections.

---

drivers/net/wireless/d80211/rt2x00/rt2400pci.c +23 -23
index 2e3a514..a64a5a9 100644
@@ -460,7 +460,8 @@ static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower)
 	rt2x00dev->tx_power = txpower;
 }
 
-static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
+static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
+	int antenna_tx, int antenna_rx)
 {
 	u8 reg_rx;
 	u8 reg_tx;
@@ -468,7 +469,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	/*
 	 * Only continue when there is something to be done.
 	 */
-	if (rt2x00dev->rx_params.antenna == antenna)
+	if (rt2x00dev->rx_status.antenna == antenna_rx)
 		return;
 
 	rt2x00_bbp_read(rt2x00dev, 4, &reg_rx);
@@ -481,25 +482,24 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	reg_tx &= ~0x03;
 
 	/*
-	 * Ralink devices have have antenna options for both TX as RX.
-	 * The ieee80211 stack currently only provide the user to set
-	 * 1 antenna, by default this is considered to be the TX antenna.
+	 * Configure the TX antenna.
 	 */
-	if (antenna == 0) {
-		/* Diversity. */
-		reg_rx |= 0x02;
+	if (antenna_tx == 0)		/* Diversity. */
 		reg_tx |= 0x01;
-	} else if (antenna == 1) {
-		/* RX: Antenna B */
-		reg_rx |= 0x04;
-		/* TX: Antenna A */
+	else if (antenna_tx == 1)	/* TX: Antenna A */
 		reg_tx |= 0x00;
-	} else if (antenna == 2) {
-		/* RX: Antenna A */
-		reg_rx |= 0x00;
-		/* TX: Antenna B */
+	else if (antenna_tx == 2)	/* TX: Antenna B */
 		reg_tx |= 0x02;
-	}
+
+	/*
+	 * Configure the RX antenna.
+	 */
+	if (antenna_rx == 0)		/* Diversity. */
+		reg_rx |= 0x02;
+	else if (antenna_rx == 1)	/* RX: Antenna A */
+		reg_rx |= 0x00;
+	else if (antenna_rx == 2)	/* RX: Antenna B */
+		reg_rx |= 0x04;
 
 	rt2x00_bbp_write(rt2x00dev, 4, reg_rx);
 	rt2x00_bbp_write(rt2x00dev, 1, reg_tx);
@@ -507,7 +507,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	/*
 	 * Update active info for RX.
 	 */
-	rt2x00dev->rx_params.antenna = antenna;
+	rt2x00dev->rx_status.antenna = antenna_rx;
 }
 
 static void rt2400pci_config_cw(struct rt2x00_dev *rt2x00dev,
@@ -1972,7 +1972,8 @@ static int rt2400pci_config(struct ieee80211_hw *hw,
 	rt2400pci_config_channel(rt2x00dev,
 		conf->channel_val, conf->channel, conf->freq);
 	rt2400pci_config_txpower(rt2x00dev, conf->power_level);
-	rt2400pci_config_antenna(rt2x00dev, conf->antenna_sel);
+	rt2400pci_config_antenna(rt2x00dev,
+		conf->antenna_sel_tx, conf->antenna_sel_rx);
 	rt2400pci_config_duration(rt2x00dev,
 		(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME));
 	rt2400pci_config_phymode(rt2x00dev, conf->phymode);
@@ -2444,12 +2445,11 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 
 	/*
 	 * Identify default antenna configuration.
-	 * Ralink devices have have antenna options for both TX as RX.
-	 * The ieee80211 stack currently only provide the user to set
-	 * 1 antenna, by default this is considered to be the TX antenna.
 	 */
-	rt2x00dev->hw->conf.antenna_sel = rt2x00_get_field16(eeprom,
+	rt2x00dev->hw->conf.antenna_sel_tx = rt2x00_get_field16(eeprom,
 		EEPROM_ANTENNA_TX_DEFAULT);
+	rt2x00dev->hw->conf.antenna_sel_rx = rt2x00_get_field16(eeprom,
+		EEPROM_ANTENNA_RX_DEFAULT);
 
 	/*
 	 * Store led mode, for correct led behaviour.
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +23 -22

96 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt2500usb.c +23 -22

96 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt61pci.c +20 -30

110 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt73usb.c +20 -30

112 lines not on this page · raw message

#1 lore raw

drivers/net/wireless/d80211/rt2x00/rt2400pci.c static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna) · line 472

Quoted 11 lines · Ivo van Doorn

With the split antenna selection rt2x00 can now read the default value for both selections from the EEPROM and can now configure the card correctly based on the individual RX and TX antenna selections.

[...]

drivers/net/wireless/d80211/rt2x00/rt2400pci.c +1 -1
@@ -468,7 +469,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	/*
 	 * Only continue when there is something to be done.
 	 */
-	if (rt2x00dev->rx_params.antenna == antenna)
+	if (rt2x00dev->rx_status.antenna == antenna_rx)

drivers/net/wireless/d80211/rt2x00/rt2400pci.c:472: error: 'struct rt2x00_dev' has no member named 'rx_status'

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
#2 lore raw
Quoted 5 lines · Jiri Benc
Quoted 4 lines · Ivo van Doorn

With the split antenna selection rt2x00 can now read the default value for both selections from the EEPROM and can now configure the card correctly based on the individual RX and TX antenna selections.

Quoted 9 lines

Review static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna) · line 472

Quoted 7 lines

[...]

(quoted diff) +1 -1
@@ -468,7 +469,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	/*
 	 * Only continue when there is something to be done.
 	 */
-	if (rt2x00dev->rx_params.antenna == antenna)
+	if (rt2x00dev->rx_status.antenna == antenna_rx)

drivers/net/wireless/d80211/rt2x00/rt2400pci.c:472: error: 'struct rt2x00_dev' has no member named 'rx_status'

Sorry about that, I had renamed rx_params to rx_status in my cvs tree and hadn't set that correctly to the git tree yet. I'll try to update rt2x00 inside wireless-dev as soon as possible, but in the mean time here is the correct patch.

---

drivers/net/wireless/d80211/rt2x00/rt2400pci.c +23 -23
index 2e3a514..a64a5a9 100644
@@ -460,7 +460,8 @@ static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower)
 	rt2x00dev->tx_power = txpower;
 }
 
-static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
+static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
+	int antenna_tx, int antenna_rx)
 {
 	u8 reg_rx;
 	u8 reg_tx;
@@ -468,7 +469,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	/*
 	 * Only continue when there is something to be done.
 	 */
-	if (rt2x00dev->rx_params.antenna == antenna)
+	if (rt2x00dev->rx_params.antenna == antenna_rx)
 		return;
 
 	rt2x00_bbp_read(rt2x00dev, 4, &reg_rx);
@@ -481,25 +482,24 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	reg_tx &= ~0x03;
 
 	/*
-	 * Ralink devices have have antenna options for both TX as RX.
-	 * The ieee80211 stack currently only provide the user to set
-	 * 1 antenna, by default this is considered to be the TX antenna.
+	 * Configure the TX antenna.
 	 */
-	if (antenna == 0) {
-		/* Diversity. */
-		reg_rx |= 0x02;
+	if (antenna_tx == 0)		/* Diversity. */
 		reg_tx |= 0x01;
-	} else if (antenna == 1) {
-		/* RX: Antenna B */
-		reg_rx |= 0x04;
-		/* TX: Antenna A */
+	else if (antenna_tx == 1)	/* TX: Antenna A */
 		reg_tx |= 0x00;
-	} else if (antenna == 2) {
-		/* RX: Antenna A */
-		reg_rx |= 0x00;
-		/* TX: Antenna B */
+	else if (antenna_tx == 2)	/* TX: Antenna B */
 		reg_tx |= 0x02;
-	}
+
+	/*
+	 * Configure the RX antenna.
+	 */
+	if (antenna_rx == 0)		/* Diversity. */
+		reg_rx |= 0x02;
+	else if (antenna_rx == 1)	/* RX: Antenna A */
+		reg_rx |= 0x00;
+	else if (antenna_rx == 2)	/* RX: Antenna B */
+		reg_rx |= 0x04;
 
 	rt2x00_bbp_write(rt2x00dev, 4, reg_rx);
 	rt2x00_bbp_write(rt2x00dev, 1, reg_tx);
@@ -507,7 +507,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, int antenna)
 	/*
 	 * Update active info for RX.
 	 */
-	rt2x00dev->rx_params.antenna = antenna;
+	rt2x00dev->rx_params.antenna = antenna_rx;
 }
 
 static void rt2400pci_config_cw(struct rt2x00_dev *rt2x00dev,
@@ -1972,7 +1972,8 @@ static int rt2400pci_config(struct ieee80211_hw *hw,
 	rt2400pci_config_channel(rt2x00dev,
 		conf->channel_val, conf->channel, conf->freq);
 	rt2400pci_config_txpower(rt2x00dev, conf->power_level);
-	rt2400pci_config_antenna(rt2x00dev, conf->antenna_sel);
+	rt2400pci_config_antenna(rt2x00dev,
+		conf->antenna_sel_tx, conf->antenna_sel_rx);
 	rt2400pci_config_duration(rt2x00dev,
 		(conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME));
 	rt2400pci_config_phymode(rt2x00dev, conf->phymode);
@@ -2444,12 +2445,11 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 
 	/*
 	 * Identify default antenna configuration.
-	 * Ralink devices have have antenna options for both TX as RX.
-	 * The ieee80211 stack currently only provide the user to set
-	 * 1 antenna, by default this is considered to be the TX antenna.
 	 */
-	rt2x00dev->hw->conf.antenna_sel = rt2x00_get_field16(eeprom,
+	rt2x00dev->hw->conf.antenna_sel_tx = rt2x00_get_field16(eeprom,
 		EEPROM_ANTENNA_TX_DEFAULT);
+	rt2x00dev->hw->conf.antenna_sel_rx = rt2x00_get_field16(eeprom,
+		EEPROM_ANTENNA_RX_DEFAULT);
 
 	/*
 	 * Store led mode, for correct led behaviour.
drivers/net/wireless/d80211/rt2x00/rt2500pci.c +23 -22

96 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt2500usb.c +23 -22

96 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt61pci.c +20 -30

110 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt73usb.c +20 -30

112 lines not on this page · raw message

#3 lore raw
Quoted 3 lines · Ivo van Doorn

Sorry about that, I had renamed rx_params to rx_status in my cvs tree and hadn't set that correctly to the git tree yet. I'll try to update rt2x00 inside wireless-dev as soon as possible, but in the mean time here is the correct patch.

Since you brought it up... :-)

It would be a big help if rt2x00 could keep upstream in-sync with your current developments. FWIW, I expect wireless-dev to get picked-up in -mm soon, and Fedora has it in rawhide already. So, it is in your own best interest to make sure that we have the latest fixes here, unless you want to support two different versions... :-)

Thanks!

John

Signature · 2 lines
John W. Linville
[email protected]
#4 lore raw

Hi,

Quoted 11 lines
Quoted 3 lines

Sorry about that, I had renamed rx_params to rx_status in my cvs tree and hadn't set that correctly to the git tree yet. I'll try to update rt2x00 inside wireless-dev as soon as possible, but in the mean time here is the correct patch.

Since you brought it up... :-)

It would be a big help if rt2x00 could keep upstream in-sync with your current developments. FWIW, I expect wireless-dev to get picked-up in -mm soon, and Fedora has it in rawhide already. So, it is in your own best interest to make sure that we have the latest fixes here, unless you want to support two different versions... :-)

True true, I am terribly late with updating rt2x00 in the wireless-dev tree. :( I'll try to send several patches this week, I am not sure if that will be entire update because some changes are quite big.
Although I should note that rt2x00 still isn't stable, rt61pci and rt73usb seem to be problematic in the sense that they still fail to associate or manage to associate
only for a second before being disassociated again. The other drivers in rt2x00 also
show various problematic behavior with suspend/resume, running ifconfig down followed
by ifconfig up, monitor mode that isn't picking up everything, scanning that only picks
up the strongest signals (Even APs that are a few meters away are sometimes not detected.) etc. etc.

Ivo