This fixes antenna selection in b43. It adds a sanity check
for the antenna numbers we get from mac80211.
This patch depends on
[PATCH] ssb: Fix extraction of values from SPROM
Signed-off-by: Michael Buesch <[email protected]>
Index: wireless-2.6/drivers/net/wireless/b43/main.c
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/b43/main.c 2007-12-12 19:55:48.000000000 +0100
+++ wireless-2.6/drivers/net/wireless/b43/main.c 2007-12-12 19:55:53.000000000 +0100
@@ -2692,8 +2692,36 @@ static int b43_switch_phymode(struct b43
return err;
}
-static int b43_antenna_from_ieee80211(u8 antenna)
+/* Check if the use of the antenna that ieee80211 told us to
+ * use is possible. This will fall back to DEFAULT.
+ * "antenna_nr" is the antenna identifier we got from ieee80211. */
+u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
+ u8 antenna_nr)
+{
+ u8 antenna_mask;
+
+ if (antenna_nr == 0) {
+ /* Zero means "use default antenna". That's always OK. */
+ return 0;
+ }
+
+ /* Get the mask of available antennas. */
+ if (dev->phy.gmode)
+ antenna_mask = dev->dev->bus->sprom.ant_available_bg;
+ else
+ antenna_mask = dev->dev->bus->sprom.ant_available_a;
+
+ if (!(antenna_mask & (1 << (antenna_nr - 1)))) {
+ /* This antenna is not available. Fall back to default. */
+ return 0;
+ }
+
+ return antenna_nr;
+}
+
+static int b43_antenna_from_ieee80211(struct b43_wldev *dev, u8 antenna)
{
+ antenna = b43_ieee80211_antenna_sanitize(dev, antenna);
switch (antenna) {
case 0: /* default/diversity */
return B43_ANTENNA_DEFAULT;
@@ -2713,14 +2741,10 @@ static int b43_op_config(struct ieee8021
struct b43_phy *phy;
unsigned long flags;
unsigned int new_phymode = 0xFFFF;
- int antenna_tx;
- int antenna_rx;
+ int antenna;
int err = 0;
u32 savedirqs;
- antenna_tx = b43_antenna_from_ieee80211(conf->antenna_sel_tx);
- antenna_rx = b43_antenna_from_ieee80211(conf->antenna_sel_rx);
-
mutex_lock(&wl->mutex);
/* Switch the PHY mode (if necessary). */
@@ -2781,8 +2805,10 @@ static int b43_op_config(struct ieee8021
}
/* Antennas for RX and management frame TX. */
- b43_mgmtframe_txantenna(dev, antenna_tx);
- b43_set_rx_antenna(dev, antenna_rx);
+ antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_tx);
+ b43_mgmtframe_txantenna(dev, antenna);
+ antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_rx);
+ b43_set_rx_antenna(dev, antenna);
/* Update templates for AP mode. */
if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP))
Index: wireless-2.6/drivers/net/wireless/b43/main.h
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/b43/main.h 2007-12-12 18:29:32.000000000 +0100
+++ wireless-2.6/drivers/net/wireless/b43/main.h 2007-12-12 19:55:53.000000000 +0100
@@ -96,6 +96,9 @@ static inline int b43_is_ofdm_rate(int r
return !b43_is_cck_rate(rate);
}
+u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
+ u8 antenna_nr);
+
void b43_tsf_read(struct b43_wldev *dev, u64 * tsf);
void b43_tsf_write(struct b43_wldev *dev, u64 tsf);
Index: wireless-2.6/drivers/net/wireless/b43/xmit.c
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/b43/xmit.c 2007-12-12 18:29:32.000000000 +0100
+++ wireless-2.6/drivers/net/wireless/b43/xmit.c 2007-12-12 19:55:53.000000000 +0100
@@ -270,14 +270,15 @@ static void generate_txhdr_fw4(struct b4
phy_ctl |= B43_TX4_PHY_OFDM;
if (dev->short_preamble)
phy_ctl |= B43_TX4_PHY_SHORTPRMBL;
- switch (txctl->antenna_sel_tx) {
- case 0:
+
+ switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) {
+ case 0: /* Default */
phy_ctl |= B43_TX4_PHY_ANTLAST;
break;
- case 1:
+ case 1: /* Antenna 0 */
phy_ctl |= B43_TX4_PHY_ANT0;
break;
- case 2:
+ case 2: /* Antenna 1 */
phy_ctl |= B43_TX4_PHY_ANT1;
break;
default:
On Sat, 22 Dec 2007 21:54:20 +0100
Michael Buesch <[email protected]> wrote:
> This fixes antenna selection in b43. It adds a sanity check
> for the antenna numbers we get from mac80211.
Just FYI. I'm going to port this patch to b43legacy, as soon as I figure
out exactly the differences between v3 and v4 firmware devices here.
--
Ciao
Stefano
Michael Buesch wrote:
> This fixes antenna selection in b43. It adds a sanity check
> for the antenna numbers we get from mac80211.
>=20
> This patch depends on
> [PATCH] ssb: Fix extraction of values from SPROM
>=20
> Signed-off-by: Michael Buesch <[email protected]>
After applying the 4 patches you sent earlier, the compilation fails wi=
th
CC [M] drivers/ssb/main.o
drivers/net/wireless/b43/main.c: In function =E2=80=98b43_ieee80211_ant=
enna_sanitize=E2=80=99:
drivers/net/wireless/b43/main.c:2720: error: =E2=80=98struct ssb_sprom=E2=
=80=99 has no member named =E2=80=98ant_available_bg=E2=80=99
drivers/net/wireless/b43/main.c:2722: error: =E2=80=98struct ssb_sprom=E2=
=80=99 has no member named =E2=80=98ant_available_a=E2=80=99
These members of ssb_sprom are defined in the patch you sent to Felix F=
ietkau on Dec. 10, but not in
this patch set.
Larry
Larry Finger wrote:
> Michael Buesch wrote:
>> This fixes antenna selection in b43. It adds a sanity check
>> for the antenna numbers we get from mac80211.
>>
>> This patch depends on
>> [PATCH] ssb: Fix extraction of values from SPROM
>>
>> Signed-off-by: Michael Buesch <[email protected]>
>=20
> After applying the 4 patches you sent earlier, the compilation fails =
with
>=20
> CC [M] drivers/ssb/main.o
> drivers/net/wireless/b43/main.c: In function =E2=80=98b43_ieee80211_a=
ntenna_sanitize=E2=80=99:
> drivers/net/wireless/b43/main.c:2720: error: =E2=80=98struct ssb_spro=
m=E2=80=99 has no member named =E2=80=98ant_available_bg=E2=80=99
> drivers/net/wireless/b43/main.c:2722: error: =E2=80=98struct ssb_spro=
m=E2=80=99 has no member named =E2=80=98ant_available_a=E2=80=99
>=20
> These members of ssb_sprom are defined in the patch you sent to Felix=
Fietkau on Dec. 10, but not in
> this patch set.
>=20
> Larry
Please ignore the noise in this message. I had mangled the first patch =
in the series of four. It now
compiles and I am about to start testing.
Larry
On Saturday 22 December 2007 22:55:38 Larry Finger wrote:
> Michael Buesch wrote:
> > This fixes antenna selection in b43. It adds a sanity check
> > for the antenna numbers we get from mac80211.
> >=20
> > This patch depends on
> > [PATCH] ssb: Fix extraction of values from SPROM
> >=20
> > Signed-off-by: Michael Buesch <[email protected]>
>=20
> After applying the 4 patches you sent earlier, the compilation fails =
with
>=20
> CC [M] drivers/ssb/main.o
> drivers/net/wireless/b43/main.c: In function =E2=80=98b43_ieee80211_a=
ntenna_sanitize=E2=80=99:
> drivers/net/wireless/b43/main.c:2720: error: =E2=80=98struct ssb_spro=
m=E2=80=99 has no member named =E2=80=98ant_available_bg=E2=80=99
> drivers/net/wireless/b43/main.c:2722: error: =E2=80=98struct ssb_spro=
m=E2=80=99 has no member named =E2=80=98ant_available_a=E2=80=99
>=20
> These members of ssb_sprom are defined in the patch you sent to Felix=
Fietkau on Dec. 10, but not in
> this patch set.
This patch was included in the series I just sent.
[PATCH] ssb: Fix extraction of values from SPROM
> Index: wireless-2.6/include/linux/ssb/ssb.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- wireless-2.6.orig/include/linux/ssb/ssb.h 2007-12-14
> 13:15:42.000000000 +0100 +++ wireless-2.6/include/linux/ssb/ssb.h =
=20
> 2007-12-20 18:58:49.000000000 +0100 @@ -22,7 +22,12 @@ struct ssb_spr=
om {
> u8 et1mac[6]; /* MAC address for 802.11a */
> u8 et0phyaddr; /* MII address for enet0 */
> u8 et1phyaddr; /* MII address for enet1 */
> + u8 et0mdcport; /* MDIO for enet0 */
> + u8 et1mdcport; /* MDIO for enet1 */
> + u8 board_rev; /* Board revision number from SPROM. =
*/
> u8 country_code; /* Country Code */
> + u8 ant_available_a; /* A-PHY antenna available bits (up t=
o 4)
> + u8 ant_available_bg; /* B/G-PHY antenna available bits (up=
to
--=20
Greetings Michael.