diff options
author | adrian <adrian@FreeBSD.org> | 2013-04-16 20:36:32 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2013-04-16 20:36:32 +0000 |
commit | 0128a675f303358380d3d86995d0db27ec7a53cf (patch) | |
tree | e4c6d9d546770934d08fdff0b49f5773de998421 | |
parent | 1061eb0aaeeccdbe9be462d17eb5dd09b43c4d4e (diff) | |
download | FreeBSD-src-0128a675f303358380d3d86995d0db27ec7a53cf.zip FreeBSD-src-0128a675f303358380d3d86995d0db27ec7a53cf.tar.gz |
Implement a utility function to return the current TX power cap for
the given node.
This takes into account the per-node cap, the ic cap and the
per-channel regulatory caps.
This is designed to replace references to ni_txpower in various net80211
drivers - ni_txpower doesn't necessarily reflect the actual cap for
the given node (eg if the node has the default value of 50dBm (100) and
the administrator has manually configured a lower TX power.)
-rw-r--r-- | sys/net80211/ieee80211_var.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 2e8f58b..9593ffe 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -822,6 +822,28 @@ ieee80211_htchanflags(const struct ieee80211_channel *c) } /* + * Fetch the current TX power (cap) for the given node. + * + * This includes the node and ic/vap TX power limit as needed, + * but it doesn't take into account any per-rate limit. + */ +static __inline uint16_t +ieee80211_get_node_txpower(struct ieee80211_node *ni) +{ + struct ieee80211com *ic = ni->ni_ic; + uint16_t txpower; + + txpower = ni->ni_txpower; + txpower = MIN(txpower, ic->ic_txpowlimit); + if (ic->ic_curchan != NULL) { + txpower = MIN(txpower, 2 * ic->ic_curchan->ic_maxregpower); + txpower = MIN(txpower, ic->ic_curchan->ic_maxpower); + } + + return (txpower); +} + +/* * Debugging facilities compiled in when IEEE80211_DEBUG is defined. * * The intent is that any problem in the net80211 layer can be |