2009-11-25 08:41:23

by Holger Schurig

[permalink] [raw]
Subject: PROPOSAL: cfg80211 antenna selection

Hi,

I just wondered how we can do the antenna and diversity
selection.

Assumption: 32 antennas are enought



My current idea is this:

struct cfg80211_ops {
+int (*set_antennas)(struct wiphy *wiphy, struct net_device *dev,
+ u32 rx_antenna_mask, u32 tx_antenna_mask);
+int (*get_antennas)(struct wiphy *wiphy, struct net_device *dev,
+ u32 *rx_antenna_mask, u32 tx_antenna_mask);
}

struct wiphy {
+u8 max_antennas;
}

wiphy->max_antennas will just be used by user-space to query the
driver capability, e.g. in "iw list".


A driver must have wiphy->max_antennas && ops->set/get_antennas
set in order to have antenna-selection. xx_antenna_mask is a
bitfield, where the active bits denote which antenna to use.

When more than one bits are set in tx_antenna_mask, the driver
may use diversity. This means that my proposal doesn't support
diffentiating between diversity and sending the same frame
throught several anteannas at the same time. Not sure if this is
a short-coming, e.g. if there's a use-case behind this or not.

Another thing I'm not sure is if we really need rx_antenna_mask.
it would allow us to receive with one antenna, but send with
another one. Is this over-design or a real use-case?


If a driver doesn't support diversity, the driver simply returns
an error if more than one bit is set in the mask.


For iw, I'd then be able to do:

iw wlan0 get antennas
iw wlan0 set antenna 0 1 (set both tx/rx antenna mask)
iw wlan0 set antenna tx 0 rx 1


--
http://www.holgerschurig.de


2009-11-26 07:51:07

by Holger Schurig

[permalink] [raw]
Subject: Re: PROPOSAL: cfg80211 antenna selection

> While at it might as well make this some configurable struct
> which the drivers can add to the wiphy just as with the
> subbands.

Something like this?


struct ieee80211_antenna lbs_antennas {
u32 hwvalue;
u32 flags;
u32 capability;
int max_gain;
}

static struct ieee80211_antenna lbs_antennas[] = {
{
.hwvalue = 0,
.capability = IEEE80211_ANTENNA_RXTX,
}
};

wiphy->antennas = lbs_antennas;
wiphy->n_anteanns = ARRAY_SIZE(lbs_antennas);

Or should the antennas be added to "struct
ieee80211_supported_band" instead of wiphy?


Capabilities could be

#define IEEE80211_ANTENNA_RX BIT(0)
#define IEEE80211_ANTENNA_TX BIT(1)
#define IEEE80211_ANTENNA_OMNI BIT(2)
#define IEEE80211_ANTENNA_SECTIONAL BIT(3)
#define IEEE80211_ANTENNA_RXTX
(IEEE80211_ANTENNA_RX | IEEE80211_ANTENNA_TX)

An unknown gain would be set to 0.



> Not sure how to get this from other cards. Anyone know how
> about on b43, iwlwifi, rallink?

Libertas doesn't give this to you, AFAIK you can just get the
number of antennas.


> Not sure if allowing for ops for chainmask setting would also
> be helpeful here, that would need some review.

What is "chainmask setting", I don't even know the concept.



You didn't give any comment on my mask idea for the user-space
API.

--
http://www.holgerschurig.de

2009-11-26 23:40:21

by Nick Kossifidis

[permalink] [raw]
Subject: Re: PROPOSAL: cfg80211 antenna selection

2009/11/26 Holger Schurig <[email protected]>:
>> While at it might as well make this some configurable struct
>> which the drivers can add to the wiphy just as with the
>> subbands.
>
> Something like this?
>
>
> struct ieee80211_antenna lbs_antennas {
>        u32 hwvalue;
>        u32 flags;
>        u32 capability;
>        int max_gain;
> }
>
> static struct ieee80211_antenna lbs_antennas[] = {
>        {
>                .hwvalue = 0,
>                .capability = IEEE80211_ANTENNA_RXTX,
>        }
> };
>
> wiphy->antennas = lbs_antennas;
> wiphy->n_anteanns = ARRAY_SIZE(lbs_antennas);
>
> Or should the antennas be added to "struct
> ieee80211_supported_band" instead of wiphy?
>
>
> Capabilities could be
>
> #define IEEE80211_ANTENNA_RX         BIT(0)
> #define IEEE80211_ANTENNA_TX         BIT(1)
> #define IEEE80211_ANTENNA_OMNI       BIT(2)
> #define IEEE80211_ANTENNA_SECTIONAL  BIT(3)
> #define IEEE80211_ANTENNA_RXTX
>   (IEEE80211_ANTENNA_RX | IEEE80211_ANTENNA_TX)
>
> An unknown gain would be set to 0.
>
>
>
>> Not sure how to get this from other cards. Anyone know how
>> about on b43, iwlwifi, rallink?
>
> Libertas doesn't give this to you, AFAIK you can just get the
> number of antennas.
>
>
>> Not sure if allowing for ops for chainmask setting would also
>> be helpeful here, that would need some review.
>
> What is "chainmask setting", I don't even know the concept.
>
>
>
> You didn't give any comment on my mask idea for the user-space
> API.
>


This is what we have on ath5k right now...

enum ath5k_ant_mode {
AR5K_ANTMODE_DEFAULT = 0, /* default antenna setup */
AR5K_ANTMODE_FIXED_A = 1, /* only antenna A is present */
AR5K_ANTMODE_FIXED_B = 2, /* only antenna B is present */
AR5K_ANTMODE_SINGLE_AP = 3, /* sta locked on a single ap */
AR5K_ANTMODE_SECTOR_AP = 4, /* AP with tx antenna set on tx desc */
AR5K_ANTMODE_SECTOR_STA = 5, /* STA with tx antenna set on tx desc */
AR5K_ANTMODE_DEBUG = 6, /* Debug mode -A -> Rx, B-> Tx- */
AR5K_ANTMODE_MAX,
};

...think more like antenna setups or scenarios.

#define IEEE80211_ANTENNA_RX BIT(0)

Also i suggest that we don't use IEEE80211_* for non 80211 related stuff...

--
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick

2009-11-26 07:35:18

by Holger Schurig

[permalink] [raw]
Subject: Re: PROPOSAL: cfg80211 antenna selection

> So what does a mask of 0 mean? No antennas, or use default?

Good question, default would be best.


But I actually like the rate idea from Luis, so we probably won't
use a bitmask then.

--
http://www.holgerschurig.de

2009-11-25 15:37:04

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: PROPOSAL: cfg80211 antenna selection

On Wed, Nov 25, 2009 at 12:41 AM, Holger Schurig
<[email protected]> wrote:
> Hi,
>
> I just wondered how we can do the antenna and diversity
> selection.
>
> Assumption: 32 antennas are enought
>
>
>
> My current idea is this:
>
>  struct cfg80211_ops {
> +int (*set_antennas)(struct wiphy *wiphy, struct net_device *dev,
> +                    u32 rx_antenna_mask, u32 tx_antenna_mask);
> +int (*get_antennas)(struct wiphy *wiphy, struct net_device *dev,
> +                    u32 *rx_antenna_mask, u32 tx_antenna_mask);
>  }
>
>  struct wiphy {
> +u8 max_antennas;
>  }

While at it might as well make this some configurable struct which the
drivers can add to the wiphy just as with the subbands. Also please
add the max antenna gain in mbi and start seeing if we can collect
this. On laptops with Atheros devices this would come from the EEPROM
so the driver should be able to set this upon initialization (probably
on hw init) and then cfg80211 can do more of the final computation to
the max eirp used.

Not sure how to get this from other cards. Anyone know how about on
b43, iwlwifi, rallink (I guess I can read the docs now :)) ?

Not sure if allowing for ops for chainmask setting would also be
helpeful here, that would need some review.

There is still one missing part to do a real final max eirp
computation on cfg80211 would be that of evaluation the CTL indexes if
there could be a common ground found amongst devices but last I tried
it seemed this was a pipe dream since other drivers do not expose any
of this, people working on certain drivers may not be aware of how
this is implemented on their devices yet or they may just use a
relatively conservative value for all edges.

Although a user should likely not be allowed to decrease the
configured eirp we *should* be able to allow user to increase it
through userspace as well to help with compliance to help adjust the
max eirp as well.

Finally, I theorize that if the antenna gain *was* indeed properly set
and this information was available even at some other level (say BIOS
and somehow we can extract that) it should technically then be
possible to put in the right code to technically allow swapping
wireless cards on laptops and perhaps then a solid argument can be
made against the silly BIOS locks put in place out there. The only
consideration which probably may not allow for this is calibration,
unless of course legislation would be OK with users doing calibration
themselves and if tools were available to the user.

Luis

2009-11-25 14:37:07

by Bob Copeland

[permalink] [raw]
Subject: Re: PROPOSAL: cfg80211 antenna selection

On Wed, Nov 25, 2009 at 3:41 AM, Holger Schurig <[email protected]> wrote:
> Hi,
>
> I just wondered how we can do the antenna and diversity
> selection.
>
> Assumption: 32 antennas are enought

So what does a mask of 0 mean? No antennas, or use default?

FWIW, ath5k has been set up such that you can specify 'default'
mode, or you can pick between one of two antennas for RX. In the
latter case, we transmit on the same antenna that the user selects.
My main interest is supporting at least this because some people
have devices with two antennas and the disconnected one is default.
For that, the masks should work fine. The aforementioned people are
used to using iwpriv to fix it in madwifi.

On the tx side, we can specify a different antenna on each transmit,
basically one omni and a sector number (1-14) for a directional antenna.
We don't really have full support for this in the driver but some people
may want it for APs.

--
Bob Copeland %% http://www.bobcopeland.com