Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 225234
b: refs/heads/master
c: a7ffac9
h: refs/heads/master
v: v3
  • Loading branch information
Bruno Randolf authored and John W. Linville committed Dec 13, 2010
1 parent 8437481 commit cf3a7d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a08e7ade9ddf4fe79576f953cc5c1725e944d26c
refs/heads/master: a7ffac9591a2a0ee74c431396ae475a8d0caa51e
5 changes: 5 additions & 0 deletions trunk/include/net/cfg80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,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 */
Expand Down Expand Up @@ -1507,6 +1510,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
Expand Down
15 changes: 13 additions & 2 deletions trunk/net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,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);
Expand Down Expand Up @@ -1046,14 +1046,25 @@ 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;
}

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;
}

tx_ant = tx_ant & rdev->wiphy.available_antennas;
rx_ant = rx_ant & rdev->wiphy.available_antennas;

result = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant);
if (result)
goto bad_res;
Expand Down

0 comments on commit cf3a7d5

Please sign in to comment.