Skip to contentSkip to conversation

d80211: Split antenna selection into TX and RX antenna

PATCH Applied Ivo van Doorn 2 participants 9 messages Feb 21, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

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

Let broadcom use the antenna_tx field for hardware configuration. I did not check if the device is also capable of RX antenna selection, but current implementation only suggested support for the TX antenna.

---

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +1 -1
index cdce227..580ea33 100644
@@ -2609,7 +2609,7 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	int antenna = -1;
 	int err = 0;
 
-	switch (conf->antenna_sel) {
+	switch (conf->antenna_sel_tx) {
 	case 0: /* default/diversity */
 		antenna = BCM43xx_ANTENNA_DEFAULT;
 		break;
drivers/net/wireless/d80211/bcm43xx/bcm43xx_xmit.c +1 -1
index 71cba92..cfc84cd 100644
@@ -281,7 +281,7 @@ static void generate_txhdr_fw4(struct bcm43xx_wldev *dev,
 		phy_ctl |= BCM43xx_TX4_PHY_OFDM;
 	if (dev->short_preamble)
 		phy_ctl |= BCM43xx_TX4_PHY_SHORTPRMBL;
-	switch (txctl->antenna_sel) {
+	switch (txctl->antenna_sel_tx) {
 	case 0:
 		phy_ctl |= BCM43xx_TX4_PHY_ANTLAST;
 		break;
#1 lore raw
Quoted 13 lines · Ivo van Doorn

Let broadcom use the antenna_tx field for hardware configuration. I did not check if the device is also capable of RX antenna selection, but current implementation only suggested support for the TX antenna.

---

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +0 -0
index cdce227..580ea33 100644

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c static int bcm43xx_dev_config(struct ieee80211_hw *hw, · line 2612

Quoted 5 lines
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +1 -1
@@ -2609,7 +2609,7 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	int antenna = -1;
 	int err = 0;
 
-	switch (conf->antenna_sel) {
+	switch (conf->antenna_sel_tx) {

Nope, this is conf->antenna_sel_rx
;)

Signature · 1 line
Greetings Michael.
#2 lore raw
Quoted 17 lines · Michael Buesch
Quoted 16 lines · Ivo van Doorn

Let broadcom use the antenna_tx field for hardware configuration. I did not check if the device is also capable of RX antenna selection, but current implementation only suggested support for the TX antenna.

---

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +0 -0
index cdce227..580ea33 100644
@@ -2609,7 +2609,7 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	int antenna = -1;
 	int err = 0;
 
Quoted 5 lines

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c static int bcm43xx_dev_config(struct ieee80211_hw *hw, · line 2612

Quoted 2 lines
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +1 -1
-	switch (conf->antenna_sel) {
+	switch (conf->antenna_sel_tx) {

Nope, this is conf->antenna_sel_rx
;)

On further inspection not even that. :P
The outcome of that switch is stored in the antenna variable, which is used with

	bcm43xx_mgmtframe_txantenna(dev, antenna);
	bcm43xx_set_rx_antenna(dev, antenna);

So I guess that needs to be fixed to create a switch statement for the RX antenna and one for the TX antenna?

Ivo

#3 lore raw
Quoted 24 lines · Ivo van Doorn
Quoted 17 lines · Michael Buesch
Quoted 16 lines · Ivo van Doorn

Let broadcom use the antenna_tx field for hardware configuration. I did not check if the device is also capable of RX antenna selection, but current implementation only suggested support for the TX antenna.

---

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +0 -0
index cdce227..580ea33 100644
@@ -2609,7 +2609,7 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	int antenna = -1;
 	int err = 0;
 
Quoted 5 lines

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c static int bcm43xx_dev_config(struct ieee80211_hw *hw, · line 2612

Quoted 2 lines
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +1 -1
-	switch (conf->antenna_sel) {
+	switch (conf->antenna_sel_tx) {

Nope, this is conf->antenna_sel_rx
;)

Quoted 8 lines

On further inspection not even that. :P
The outcome of that switch is stored in the antenna variable, which is used with

	bcm43xx_mgmtframe_txantenna(dev, antenna);
	bcm43xx_set_rx_antenna(dev, antenna);

So I guess that needs to be fixed to create a switch statement for the RX antenna and one for the TX antenna?

Ah, yeah. I didn't have the complete code for this in my head. :)

I'd rather like to have a helper function
int bcm43xx_antenna_from_ieee80211(u8 antenna) which includes the switch statement and use it twice in the config callback. Wanna do that?

Signature · 1 line
Greetings Michael.
#4 lore raw
Quoted 9 lines
Quoted 8 lines

On further inspection not even that. :P
The outcome of that switch is stored in the antenna variable, which is used with

	bcm43xx_mgmtframe_txantenna(dev, antenna);
	bcm43xx_set_rx_antenna(dev, antenna);

So I guess that needs to be fixed to create a switch statement for the RX antenna and one for the TX antenna?

Quoted 6 lines

Ah, yeah. I didn't have the complete code for this in my head. :)

I'd rather like to have a helper function
int bcm43xx_antenna_from_ieee80211(u8 antenna) which includes the switch statement and use it twice in the config callback. Wanna do that?

No problem, I will resend this patch with that helper function added.

Ivo

#5 lore raw
In reply to Michael Buesch
Quoted 12 lines
Quoted 11 lines
Quoted 2 lines

Nope, this is conf->antenna_sel_rx
;)

On further inspection not even that. :P
The outcome of that switch is stored in the antenna variable, which is used with

	bcm43xx_mgmtframe_txantenna(dev, antenna);
	bcm43xx_set_rx_antenna(dev, antenna);

So I guess that needs to be fixed to create a switch statement for the RX antenna and one for the TX antenna?

Quoted 6 lines

Ah, yeah. I didn't have the complete code for this in my head. :)

I'd rather like to have a helper function
int bcm43xx_antenna_from_ieee80211(u8 antenna) which includes the switch statement and use it twice in the config callback. Wanna do that?

Fixed. This will make the bcm43xx driver make use of both RX and TX antenna selection capabilities.

---

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +6 -16
index cdce227..1256549 100644
@@ -2606,22 +2606,12 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	struct bcm43xx_phy *phy;
 	unsigned long flags;
 	unsigned int new_phymode = 0xFFFF;
-	int antenna = -1;
+	int antenna_tx;
+	int antenna_rx;
 	int err = 0;
 
-	switch (conf->antenna_sel) {
-	case 0: /* default/diversity */
-		antenna = BCM43xx_ANTENNA_DEFAULT;
-		break;
-	case 1: /* Antenna 0 */
-		antenna = BCM43xx_ANTENNA0;
-		break;
-	case 2: /* Antenna 1 */
-		antenna = BCM43xx_ANTENNA1;
-		break;
-	default:
-		assert(0);
-	}
+	antenna_tx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_tx);
+	antenna_rx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_rx);
 
 	mutex_lock(&wl->mutex);
 
@@ -2682,8 +2672,8 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	}
 
 	/* Antennas for RX and management frame TX. */
-	bcm43xx_mgmtframe_txantenna(dev, antenna);
-	bcm43xx_set_rx_antenna(dev, antenna);
+	bcm43xx_mgmtframe_txantenna(dev, antenna_tx);
+	bcm43xx_set_rx_antenna(dev, antenna_rx);
 
 	/* Update templates for AP mode. */
 	if (bcm43xx_is_mode(wl, IEEE80211_IF_TYPE_AP))
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.h +16 -0
index e56efc1..bba6606 100644
@@ -110,6 +110,22 @@ int bcm43xx_is_ofdm_rate(int rate)
 }
 
 static inline
+int bcm43xx_antenna_from_ieee80211(u8 antenna)
+{
+	switch (antenna) {
+	case 0: /* default/diversity */
+		return BCM43xx_ANTENNA_DEFAULT;
+	case 1: /* Antenna 0 */
+		return BCM43xx_ANTENNA0;
+	case 2: /* Antenna 1 */
+		return BCM43xx_ANTENNA1;
+	default:
+		assert(0);
+		return -EINVAL;
+	}
+}
+
+static inline
 int bcm43xx_is_hw_radio_enabled(struct bcm43xx_wldev *dev)
 {
 	/* function to return state of hardware enable of radio
drivers/net/wireless/d80211/bcm43xx/bcm43xx_xmit.c +1 -1
index 71cba92..cfc84cd 100644
@@ -281,7 +281,7 @@ static void generate_txhdr_fw4(struct bcm43xx_wldev *dev,
 		phy_ctl |= BCM43xx_TX4_PHY_OFDM;
 	if (dev->short_preamble)
 		phy_ctl |= BCM43xx_TX4_PHY_SHORTPRMBL;
-	switch (txctl->antenna_sel) {
+	switch (txctl->antenna_sel_tx) {
 	case 0:
 		phy_ctl |= BCM43xx_TX4_PHY_ANTLAST;
 		break;
#6 lore raw
Quoted 54 lines · Ivo van Doorn
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +6 -16
index cdce227..1256549 100644
@@ -2606,22 +2606,12 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	struct bcm43xx_phy *phy;
 	unsigned long flags;
 	unsigned int new_phymode = 0xFFFF;
-	int antenna = -1;
+	int antenna_tx;
+	int antenna_rx;
 	int err = 0;
 
-	switch (conf->antenna_sel) {
-	case 0: /* default/diversity */
-		antenna = BCM43xx_ANTENNA_DEFAULT;
-		break;
-	case 1: /* Antenna 0 */
-		antenna = BCM43xx_ANTENNA0;
-		break;
-	case 2: /* Antenna 1 */
-		antenna = BCM43xx_ANTENNA1;
-		break;
-	default:
-		assert(0);
-	}
+	antenna_tx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_tx);
+	antenna_rx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_rx);
 
 	mutex_lock(&wl->mutex);
 
@@ -2682,8 +2672,8 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	}
 
 	/* Antennas for RX and management frame TX. */
-	bcm43xx_mgmtframe_txantenna(dev, antenna);
-	bcm43xx_set_rx_antenna(dev, antenna);
+	bcm43xx_mgmtframe_txantenna(dev, antenna_tx);
+	bcm43xx_set_rx_antenna(dev, antenna_rx);
 
 	/* Update templates for AP mode. */
 	if (bcm43xx_is_mode(wl, IEEE80211_IF_TYPE_AP))
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.h +4 -0
index e56efc1..bba6606 100644
@@ -110,6 +110,22 @@ int bcm43xx_is_ofdm_rate(int rate)
 }
 
 static inline
+int bcm43xx_antenna_from_ieee80211(u8 antenna)
+{
+	switch (antenna) {
+	case 0: /* default/diversity */

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.h int bcm43xx_is_ofdm_rate(int rate) · line 126

Quoted 10 lines
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.h +10 -0
+		return BCM43xx_ANTENNA_DEFAULT;
+	case 1: /* Antenna 0 */
+		return BCM43xx_ANTENNA0;
+	case 2: /* Antenna 1 */
+		return BCM43xx_ANTENNA1;
+	default:
+		assert(0);
+		return -EINVAL;
+	}
+}

No, there is no need to inline. Simple static in main.c above the config callback, please. :)
And simply return BCM43xx_ANTENNA_DEFAULT for the default:
case, so it doesn't break immediately, if someone decides to add something to d80211.

...But we've almost got it :D
After that you'll get my sign-off.

Signature · 1 line
Greetings Michael.
#7 lore raw
Quoted 8 lines

No, there is no need to inline. Simple static in main.c above the config callback, please. :)
And simply return BCM43xx_ANTENNA_DEFAULT for the default:
case, so it doesn't break immediately, if someone decides to add something to d80211.

...But we've almost got it :D
After that you'll get my sign-off.

bcm43xx_antenna_from_ieee80211 is no longer inlined, and it returns BCM43xx_ANTENNA_DEFAULT by default.

Hopefully I got it this time. :)

---

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +20 -16
index cdce227..798427f 100644
@@ -2598,6 +2598,20 @@ static int bcm43xx_switch_phymode(struct bcm43xx_wl *wl,
 	return 0;
 }
 
+static int bcm43xx_antenna_from_ieee80211(u8 antenna)
+{
+	switch (antenna) {
+	case 0: /* default/diversity */
+		return BCM43xx_ANTENNA_DEFAULT;
+	case 1: /* Antenna 0 */
+		return BCM43xx_ANTENNA0;
+	case 2: /* Antenna 1 */
+		return BCM43xx_ANTENNA1;
+	default:
+		return BCM43xx_ANTENNA_DEFAULT;
+	}
+}
+
 static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 			      struct ieee80211_conf *conf)
 {
@@ -2606,22 +2620,12 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	struct bcm43xx_phy *phy;
 	unsigned long flags;
 	unsigned int new_phymode = 0xFFFF;
-	int antenna = -1;
+	int antenna_tx;
+	int antenna_rx;
 	int err = 0;
 
-	switch (conf->antenna_sel) {
-	case 0: /* default/diversity */
-		antenna = BCM43xx_ANTENNA_DEFAULT;
-		break;
-	case 1: /* Antenna 0 */
-		antenna = BCM43xx_ANTENNA0;
-		break;
-	case 2: /* Antenna 1 */
-		antenna = BCM43xx_ANTENNA1;
-		break;
-	default:
-		assert(0);
-	}
+	antenna_tx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_tx);
+	antenna_rx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_rx);
 
 	mutex_lock(&wl->mutex);
 
@@ -2682,8 +2686,8 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	}
 
 	/* Antennas for RX and management frame TX. */
-	bcm43xx_mgmtframe_txantenna(dev, antenna);
-	bcm43xx_set_rx_antenna(dev, antenna);
+	bcm43xx_mgmtframe_txantenna(dev, antenna_tx);
+	bcm43xx_set_rx_antenna(dev, antenna_rx);
 
 	/* Update templates for AP mode. */
 	if (bcm43xx_is_mode(wl, IEEE80211_IF_TYPE_AP))
drivers/net/wireless/d80211/bcm43xx/bcm43xx_xmit.c +1 -1
index 71cba92..cfc84cd 100644
@@ -281,7 +281,7 @@ static void generate_txhdr_fw4(struct bcm43xx_wldev *dev,
 		phy_ctl |= BCM43xx_TX4_PHY_OFDM;
 	if (dev->short_preamble)
 		phy_ctl |= BCM43xx_TX4_PHY_SHORTPRMBL;
-	switch (txctl->antenna_sel) {
+	switch (txctl->antenna_sel_tx) {
 	case 0:
 		phy_ctl |= BCM43xx_TX4_PHY_ANTLAST;
 		break;
#8 lore raw
Quoted 6 lines · Ivo van Doorn
Quoted 6 lines

No, there is no need to inline. Simple static in main.c above the config callback, please. :)
And simply return BCM43xx_ANTENNA_DEFAULT for the default:
case, so it doesn't break immediately, if someone decides to add something to d80211.

Quoted 7 lines
Quoted 2 lines

...But we've almost got it :D
After that you'll get my sign-off.

bcm43xx_antenna_from_ieee80211 is no longer inlined, and it returns BCM43xx_ANTENNA_DEFAULT by default.

Hopefully I got it this time. :)

Yeah, *clap clap clap* :D

Quoted 1 line
Quoted 80 lines

---

drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +20 -16
index cdce227..798427f 100644
@@ -2598,6 +2598,20 @@ static int bcm43xx_switch_phymode(struct bcm43xx_wl *wl,
 	return 0;
 }
 
+static int bcm43xx_antenna_from_ieee80211(u8 antenna)
+{
+	switch (antenna) {
+	case 0: /* default/diversity */
+		return BCM43xx_ANTENNA_DEFAULT;
+	case 1: /* Antenna 0 */
+		return BCM43xx_ANTENNA0;
+	case 2: /* Antenna 1 */
+		return BCM43xx_ANTENNA1;
+	default:
+		return BCM43xx_ANTENNA_DEFAULT;
+	}
+}
+
 static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 			      struct ieee80211_conf *conf)
 {
@@ -2606,22 +2620,12 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	struct bcm43xx_phy *phy;
 	unsigned long flags;
 	unsigned int new_phymode = 0xFFFF;
-	int antenna = -1;
+	int antenna_tx;
+	int antenna_rx;
 	int err = 0;
 
-	switch (conf->antenna_sel) {
-	case 0: /* default/diversity */
-		antenna = BCM43xx_ANTENNA_DEFAULT;
-		break;
-	case 1: /* Antenna 0 */
-		antenna = BCM43xx_ANTENNA0;
-		break;
-	case 2: /* Antenna 1 */
-		antenna = BCM43xx_ANTENNA1;
-		break;
-	default:
-		assert(0);
-	}
+	antenna_tx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_tx);
+	antenna_rx = bcm43xx_antenna_from_ieee80211(conf->antenna_sel_rx);
 
 	mutex_lock(&wl->mutex);
 
@@ -2682,8 +2686,8 @@ static int bcm43xx_dev_config(struct ieee80211_hw *hw,
 	}
 
 	/* Antennas for RX and management frame TX. */
-	bcm43xx_mgmtframe_txantenna(dev, antenna);
-	bcm43xx_set_rx_antenna(dev, antenna);
+	bcm43xx_mgmtframe_txantenna(dev, antenna_tx);
+	bcm43xx_set_rx_antenna(dev, antenna_rx);
 
 	/* Update templates for AP mode. */
 	if (bcm43xx_is_mode(wl, IEEE80211_IF_TYPE_AP))
drivers/net/wireless/d80211/bcm43xx/bcm43xx_xmit.c +1 -1
index 71cba92..cfc84cd 100644
@@ -281,7 +281,7 @@ static void generate_txhdr_fw4(struct bcm43xx_wldev *dev,
 		phy_ctl |= BCM43xx_TX4_PHY_OFDM;
 	if (dev->short_preamble)
 		phy_ctl |= BCM43xx_TX4_PHY_SHORTPRMBL;
-	switch (txctl->antenna_sel) {
+	switch (txctl->antenna_sel_tx) {
 	case 0:
 		phy_ctl |= BCM43xx_TX4_PHY_ANTLAST;
 		break;
Signature · 1 line
Greetings Michael.