linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] cfg80211: Add antenna availability information
@ 2010-12-08  3:44 Bruno Randolf
  2010-12-08  4:49 ` Bruno Randolf
  2010-12-08 14:31 ` John W. Linville
  0 siblings, 2 replies; 4+ messages in thread
From: Bruno Randolf @ 2010-12-08  3:44 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.

The antenna configuration is now also checked against the availabe antennas and
rejected if it does not match.

Signed-off-by: Bruno Randolf <br1@einfach.org>

v2:	reject antenna configurations which don't match the available antennas
---
 include/net/cfg80211.h |    5 +++++
 net/wireless/nl80211.c |   12 ++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8764c9a..ef6f15d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1465,6 +1465,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 */
@@ -1504,6 +1507,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 2cf0333..4f6ff31 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);
@@ -1045,7 +1045,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;
 		}
@@ -1053,6 +1053,14 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 		tx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX]);
 		rx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);
 
+		/* reject antenna configurations which don't match the
+		 * available antenna mask, except for the "all" mask */
+		if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas)) ||
+		    (~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas))) {
+			result = -EINVAL;
+			goto bad_res;
+		}
+
 		result = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant);
 		if (result)
 			goto bad_res;


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] cfg80211: Add antenna availability information
  2010-12-08  3:44 [PATCH v2] cfg80211: Add antenna availability information Bruno Randolf
@ 2010-12-08  4:49 ` Bruno Randolf
  2010-12-08 14:31 ` John W. Linville
  1 sibling, 0 replies; 4+ messages in thread
From: Bruno Randolf @ 2010-12-08  4:49 UTC (permalink / raw)
  To: johannes; +Cc: linville, linux-wireless

Ah, please ignore this one and wait for v3...

bruno

On Wed December 8 2010 12:44:29 Bruno Randolf wrote:
> 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.
> 
> The antenna configuration is now also checked against the availabe antennas
> and rejected if it does not match.
> 
> Signed-off-by: Bruno Randolf <br1@einfach.org>
> 
> v2:	reject antenna configurations which don't match the available antennas
> ---
>  include/net/cfg80211.h |    5 +++++
>  net/wireless/nl80211.c |   12 ++++++++++--
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 8764c9a..ef6f15d 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -1465,6 +1465,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 */
> @@ -1504,6 +1507,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 2cf0333..4f6ff31 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);
> @@ -1045,7 +1045,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;
>  		}
> @@ -1053,6 +1053,14 @@ static int nl80211_set_wiphy(struct sk_buff *skb,
> struct genl_info *info) tx_ant =
> nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX]); rx_ant =
> nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);
> 
> +		/* reject antenna configurations which don't match the
> +		 * available antenna mask, except for the "all" mask */
> +		if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas)) ||
> +		    (~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas))) {
> +			result = -EINVAL;
> +			goto bad_res;
> +		}
> +
>  		result = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant);
>  		if (result)
>  			goto bad_res;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] cfg80211: Add antenna availability information
  2010-12-08  3:44 [PATCH v2] cfg80211: Add antenna availability information Bruno Randolf
  2010-12-08  4:49 ` Bruno Randolf
@ 2010-12-08 14:31 ` John W. Linville
  2010-12-10 12:47   ` Bruno Randolf
  1 sibling, 1 reply; 4+ messages in thread
From: John W. Linville @ 2010-12-08 14:31 UTC (permalink / raw)
  To: Bruno Randolf; +Cc: johannes, linux-wireless

On Wed, Dec 08, 2010 at 12:44:29PM +0900, Bruno Randolf wrote:
> 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.
> 
> The antenna configuration is now also checked against the availabe antennas and
> rejected if it does not match.
> 
> Signed-off-by: Bruno Randolf <br1@einfach.org>
> 
> v2:	reject antenna configurations which don't match the available antennas
> ---

Please either put the "v2" part before the "Signed-off-by" or
(preferably) after the "---" line.  Also, make sure to use 3 "-"
characters -- often you use only 2 of them and the results from
applying with "git am" are messy.

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] cfg80211: Add antenna availability information
  2010-12-08 14:31 ` John W. Linville
@ 2010-12-10 12:47   ` Bruno Randolf
  0 siblings, 0 replies; 4+ messages in thread
From: Bruno Randolf @ 2010-12-10 12:47 UTC (permalink / raw)
  To: John W. Linville; +Cc: johannes, linux-wireless

On Wednesday 08 December 2010 23:31:01 John W. Linville wrote:
> On Wed, Dec 08, 2010 at 12:44:29PM +0900, Bruno Randolf wrote:
> > 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.
> > 
> > The antenna configuration is now also checked against the availabe
> > antennas and rejected if it does not match.
> > 
> > Signed-off-by: Bruno Randolf <br1@einfach.org>
> > 
> > v2:	reject antenna configurations which don't match the available
> > antennas ---
> 
> Please either put the "v2" part before the "Signed-off-by" or
> (preferably) after the "---" line.  Also, make sure to use 3 "-"
> characters -- often you use only 2 of them and the results from
> applying with "git am" are messy.

Oh, I'm sorry for that. For some reason I thought 2 -- are ok. Will be careful 
to have three from now on.

bruno

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-10 12:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08  3:44 [PATCH v2] cfg80211: Add antenna availability information Bruno Randolf
2010-12-08  4:49 ` Bruno Randolf
2010-12-08 14:31 ` John W. Linville
2010-12-10 12:47   ` 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).