* [PATCH 1/3] cfg80211: Add antenna availability information
@ 2010-12-06 3:45 Bruno Randolf
2010-12-06 3:45 ` [PATCH 2/3] nl80211: Export available antennas Bruno Randolf
2010-12-06 3:45 ` [PATCH 3/3] ath5k: Set available antenna information for cfg80211 Bruno Randolf
0 siblings, 2 replies; 10+ messages in thread
From: Bruno Randolf @ 2010-12-06 3:45 UTC (permalink / raw)
To: johannes, linville; +Cc: linux-wireless
Add a field to wiphy for the hardware to report the availble antennas for
configuration. Only if this is set to something bigger than zero, will the
anntenna configuration ops be executed.
Allthough this could be a simple number of antennas, I defined it as a bitmap
of antennas which are available for configuration, since it's more consistent
with the rest of the antenna API and there could be cases where the
hardware allows only configuration of certain antennas. As it does not make
much of a difference in size or normal usage, I think it's better to be able to
support this, in case the need arises.
Signed-off-by: Bruno Randolf <br1@einfach.org>
---
include/net/cfg80211.h | 5 +++++
net/wireless/nl80211.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 589c4b1..d0d4af8 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1442,6 +1442,9 @@ struct ieee80211_txrx_stypes {
* @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
* transmitted through nl80211, points to an array indexed by interface
* type
+ *
+ * @available_antennas: bitmap of antennas which are available to configure.
+ * antenna configuration commands will be rejected unless this is set.
*/
struct wiphy {
/* assign these fields before you register the wiphy */
@@ -1481,6 +1484,8 @@ struct wiphy {
u8 max_num_pmkids;
+ u32 available_antennas;
+
/* If multiple wiphys are registered and you're handed e.g.
* a regular netdev with assigned ieee80211_ptr, you won't
* know whether it points to a wiphy your driver has registered
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 45fe06d..4854df9 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -547,7 +547,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
if (dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL)
NLA_PUT_FLAG(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE);
- if (dev->ops->get_antenna) {
+ if (dev->wiphy.available_antennas && dev->ops->get_antenna) {
u32 tx_ant = 0, rx_ant = 0;
int res;
res = dev->ops->get_antenna(&dev->wiphy, &tx_ant, &rx_ant);
@@ -1044,7 +1044,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
u32 tx_ant, rx_ant;
- if (!rdev->ops->set_antenna) {
+ if (!rdev->wiphy.available_antennas || !rdev->ops->set_antenna) {
result = -EOPNOTSUPP;
goto bad_res;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] nl80211: Export available antennas
2010-12-06 3:45 [PATCH 1/3] cfg80211: Add antenna availability information Bruno Randolf
@ 2010-12-06 3:45 ` Bruno Randolf
2010-12-06 8:17 ` Johannes Berg
2010-12-06 3:45 ` [PATCH 3/3] ath5k: Set available antenna information for cfg80211 Bruno Randolf
1 sibling, 1 reply; 10+ messages in thread
From: Bruno Randolf @ 2010-12-06 3:45 UTC (permalink / raw)
To: johannes, linville; +Cc: linux-wireless
Signed-off-by: Bruno Randolf <br1@einfach.org>
---
include/linux/nl80211.h | 5 +++++
net/wireless/nl80211.c | 2 ++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 68fc25f..5f64fd6 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -833,6 +833,9 @@ enum nl80211_commands {
* the hardware should not be configured to receive on this antenna.
* For a more detailed descripton see @NL80211_ATTR_WIPHY_ANTENNA_TX.
*
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL: Bitmap of antennas which are available for
+ * configuration via the above parameters.
+ *
* @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
*
* @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
@@ -1017,6 +1020,8 @@ enum nl80211_attrs {
NL80211_ATTR_OFFCHANNEL_TX_OK,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4854df9..1d49d75 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -555,6 +555,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, tx_ant);
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, rx_ant);
}
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL,
+ dev->wiphy.available_antennas);
}
nl_modes = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_IFTYPES);
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] ath5k: Set available antenna information for cfg80211
2010-12-06 3:45 [PATCH 1/3] cfg80211: Add antenna availability information Bruno Randolf
2010-12-06 3:45 ` [PATCH 2/3] nl80211: Export available antennas Bruno Randolf
@ 2010-12-06 3:45 ` Bruno Randolf
1 sibling, 0 replies; 10+ messages in thread
From: Bruno Randolf @ 2010-12-06 3:45 UTC (permalink / raw)
To: johannes, linville; +Cc: linux-wireless
Signed-off-by: Bruno Randolf <br1@einfach.org>
---
drivers/net/wireless/ath/ath5k/base.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index d74ee0d..e648467 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -2350,6 +2350,8 @@ ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops)
BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_MESH_POINT);
+ hw->wiphy->available_antennas = 0x3; /* both can be configured */
+
hw->extra_tx_headroom = 2;
hw->channel_change_time = 5000;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] nl80211: Export available antennas
2010-12-06 3:45 ` [PATCH 2/3] nl80211: Export available antennas Bruno Randolf
@ 2010-12-06 8:17 ` Johannes Berg
2010-12-06 8:30 ` Bruno Randolf
0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2010-12-06 8:17 UTC (permalink / raw)
To: Bruno Randolf; +Cc: linville, linux-wireless
On Mon, 2010-12-06 at 12:45 +0900, Bruno Randolf wrote:
> + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL,
> + dev->wiphy.available_antennas);
I think you should not advertise this unless it's non-zero, and unless
also the set/get callbacks are available.
Similarly, I think you shouldn't advertise the set/get CMDs when the
available antennas aren't set.
Finally, you should check for nl80211 that the given tx/rx masks fall
into the available antennas mask.
johannes
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] nl80211: Export available antennas
2010-12-06 8:17 ` Johannes Berg
@ 2010-12-06 8:30 ` Bruno Randolf
2010-12-06 8:33 ` Johannes Berg
0 siblings, 1 reply; 10+ messages in thread
From: Bruno Randolf @ 2010-12-06 8:30 UTC (permalink / raw)
To: Johannes Berg; +Cc: linville, linux-wireless
On Mon December 6 2010 17:17:33 Johannes Berg wrote:
> On Mon, 2010-12-06 at 12:45 +0900, Bruno Randolf wrote:
> > + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL,
> > + dev->wiphy.available_antennas);
>
> I think you should not advertise this unless it's non-zero, and unless
> also the set/get callbacks are available.
I don't. Please check the context of this patch, esp patch 1. of this series.
> Similarly, I think you shouldn't advertise the set/get CMDs when the
> available antennas aren't set.
There are no set/get commands for antennas since you preferred putting it into
wiphy info.
> Finally, you should check for nl80211 that the given tx/rx masks fall
> into the available antennas mask.
Allright, I can do that. Would you prefer to reject the command in this case
or just apply the available mask?
bruno
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] nl80211: Export available antennas
2010-12-06 8:30 ` Bruno Randolf
@ 2010-12-06 8:33 ` Johannes Berg
2010-12-07 2:17 ` Bruno Randolf
0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2010-12-06 8:33 UTC (permalink / raw)
To: Bruno Randolf; +Cc: linville, linux-wireless
On Mon, 2010-12-06 at 17:30 +0900, Bruno Randolf wrote:
> On Mon December 6 2010 17:17:33 Johannes Berg wrote:
> > On Mon, 2010-12-06 at 12:45 +0900, Bruno Randolf wrote:
> > > + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL,
> > > + dev->wiphy.available_antennas);
> >
> > I think you should not advertise this unless it's non-zero, and unless
> > also the set/get callbacks are available.
>
> I don't. Please check the context of this patch, esp patch 1. of this series.
Ah, indeed, the context overlap was lost on me.
> > Similarly, I think you shouldn't advertise the set/get CMDs when the
> > available antennas aren't set.
>
> There are no set/get commands for antennas since you preferred putting it into
> wiphy info.
Oops. Forgot all about that, sorry!
> > Finally, you should check for nl80211 that the given tx/rx masks fall
> > into the available antennas mask.
>
> Allright, I can do that. Would you prefer to reject the command in this case
> or just apply the available mask?
I'd reject it, since userspace could have checked whether it was valid.
johannes
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] nl80211: Export available antennas
2010-12-06 8:33 ` Johannes Berg
@ 2010-12-07 2:17 ` Bruno Randolf
2010-12-07 9:35 ` Johannes Berg
0 siblings, 1 reply; 10+ messages in thread
From: Bruno Randolf @ 2010-12-07 2:17 UTC (permalink / raw)
To: Johannes Berg; +Cc: linville, linux-wireless
On Mon December 6 2010 17:33:20 Johannes Berg wrote:
> > > Finally, you should check for nl80211 that the given tx/rx masks fall
> > > into the available antennas mask.
> >
> > Allright, I can do that. Would you prefer to reject the command in this
> > case or just apply the available mask?
>
> I'd reject it, since userspace could have checked whether it was valid.
Hmm, been thinking about it: the "iw phyX set antenna all" will not work in
that case. Unless we get the available antennas before setting "all" in iw,
which seems like a lot of overhead...
Alternatively we can either apply the mask in mac80211 or just hand the
antenna masks as they are to the driver, which is what we do now.
I think either way it's not a big deal.
bruno
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] nl80211: Export available antennas
2010-12-07 2:17 ` Bruno Randolf
@ 2010-12-07 9:35 ` Johannes Berg
2010-12-08 3:45 ` Bruno Randolf
0 siblings, 1 reply; 10+ messages in thread
From: Johannes Berg @ 2010-12-07 9:35 UTC (permalink / raw)
To: Bruno Randolf; +Cc: linville, linux-wireless
On Tue, 2010-12-07 at 11:17 +0900, Bruno Randolf wrote:
> On Mon December 6 2010 17:33:20 Johannes Berg wrote:
> > > > Finally, you should check for nl80211 that the given tx/rx masks fall
> > > > into the available antennas mask.
> > >
> > > Allright, I can do that. Would you prefer to reject the command in this
> > > case or just apply the available mask?
> >
> > I'd reject it, since userspace could have checked whether it was valid.
>
> Hmm, been thinking about it: the "iw phyX set antenna all" will not work in
> that case. Unless we get the available antennas before setting "all" in iw,
> which seems like a lot of overhead...
>
> Alternatively we can either apply the mask in mac80211 or just hand the
> antenna masks as they are to the driver, which is what we do now.
I think I'd be more happy with treating ~0 as special (which it is
anyway, apply the mask to it) and allowing that to not match the mask.
That way, the most common errors still don't have to be handled in the
driver.
johannes
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] nl80211: Export available antennas
2010-12-07 9:35 ` Johannes Berg
@ 2010-12-08 3:45 ` Bruno Randolf
0 siblings, 0 replies; 10+ messages in thread
From: Bruno Randolf @ 2010-12-08 3:45 UTC (permalink / raw)
To: Johannes Berg; +Cc: linville, linux-wireless
On Tue December 7 2010 18:35:40 Johannes Berg wrote:
> On Tue, 2010-12-07 at 11:17 +0900, Bruno Randolf wrote:
> > On Mon December 6 2010 17:33:20 Johannes Berg wrote:
> > > > > Finally, you should check for nl80211 that the given tx/rx masks
> > > > > fall into the available antennas mask.
> > > >
> > > > Allright, I can do that. Would you prefer to reject the command in
> > > > this case or just apply the available mask?
> > >
> > > I'd reject it, since userspace could have checked whether it was valid.
> >
> > Hmm, been thinking about it: the "iw phyX set antenna all" will not work
> > in that case. Unless we get the available antennas before setting "all"
> > in iw, which seems like a lot of overhead...
> >
> > Alternatively we can either apply the mask in mac80211 or just hand the
> > antenna masks as they are to the driver, which is what we do now.
>
> I think I'd be more happy with treating ~0 as special (which it is
> anyway, apply the mask to it) and allowing that to not match the mask.
> That way, the most common errors still don't have to be handled in the
> driver.
Allright. Sent a patch for this.
bruno
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/3] nl80211: Export available antennas
2010-12-16 2:30 [PATCH 1/3] cfg80211: Separate available antennas for RX and TX Bruno Randolf
@ 2010-12-16 2:30 ` Bruno Randolf
0 siblings, 0 replies; 10+ messages in thread
From: Bruno Randolf @ 2010-12-16 2:30 UTC (permalink / raw)
To: johannes, linville; +Cc: dhalperi, linux-wireless
Export the information which antennas are available for configuration as TX or
RX antennas via nl80211.
Signed-off-by: Bruno Randolf <br1@einfach.org>
---
v3: rebased and updated for separate RX and TX availablility
v2: rebased
---
include/linux/nl80211.h | 9 +++++++++
net/wireless/nl80211.c | 5 +++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 1cee56b..a6e1ec5 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -844,6 +844,12 @@ enum nl80211_commands {
* the hardware should not be configured to receive on this antenna.
* For a more detailed descripton see @NL80211_ATTR_WIPHY_ANTENNA_TX.
*
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX: Bitmap of antennas which are available
+ * for configuration as TX antennas via the above parameters.
+ *
+ * @NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX: Bitmap of antennas which are available
+ * for configuration as RX antennas via the above parameters.
+ *
* @NL80211_ATTR_MCAST_RATE: Multicast tx rate (in 100 kbps) for IBSS
*
* @NL80211_ATTR_OFFCHANNEL_TX_OK: For management frame TX, the frame may be
@@ -1040,6 +1046,9 @@ enum nl80211_attrs {
NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
+ NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 087397b..ad3ca7d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -605,6 +605,11 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
if (dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL)
NLA_PUT_FLAG(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE);
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
+ dev->wiphy.available_antennas_tx);
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
+ dev->wiphy.available_antennas_rx);
+
if ((dev->wiphy.available_antennas_tx ||
dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) {
u32 tx_ant = 0, rx_ant = 0;
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-12-16 2:29 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-06 3:45 [PATCH 1/3] cfg80211: Add antenna availability information Bruno Randolf
2010-12-06 3:45 ` [PATCH 2/3] nl80211: Export available antennas Bruno Randolf
2010-12-06 8:17 ` Johannes Berg
2010-12-06 8:30 ` Bruno Randolf
2010-12-06 8:33 ` Johannes Berg
2010-12-07 2:17 ` Bruno Randolf
2010-12-07 9:35 ` Johannes Berg
2010-12-08 3:45 ` Bruno Randolf
2010-12-06 3:45 ` [PATCH 3/3] ath5k: Set available antenna information for cfg80211 Bruno Randolf
-- strict thread matches above, loose matches on Subject: below --
2010-12-16 2:30 [PATCH 1/3] cfg80211: Separate available antennas for RX and TX Bruno Randolf
2010-12-16 2:30 ` [PATCH 2/3] nl80211: Export available antennas Bruno Randolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).