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.)
This commit is contained in:
parent
9adbae037d
commit
ebe15a7b25
@ -821,6 +821,28 @@ ieee80211_htchanflags(const struct ieee80211_channel *c)
|
||||
IEEE80211_IS_CHAN_HT(c) ? IEEE80211_FHT_HT : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user