From 0128a675f303358380d3d86995d0db27ec7a53cf Mon Sep 17 00:00:00 2001 From: adrian Date: Tue, 16 Apr 2013 20:36:32 +0000 Subject: 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.) --- sys/net80211/ieee80211_var.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sys/net80211') 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 -- cgit v1.1