svn commit: r249568 - head/sys/net80211

Adrian Chadd adrian at FreeBSD.org
Tue Apr 16 20:36:32 UTC 2013


Author: adrian
Date: Tue Apr 16 20:36:32 2013
New Revision: 249568
URL: http://svnweb.freebsd.org/changeset/base/249568

Log:
  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.)

Modified:
  head/sys/net80211/ieee80211_var.h

Modified: head/sys/net80211/ieee80211_var.h
==============================================================================
--- head/sys/net80211/ieee80211_var.h	Tue Apr 16 20:31:15 2013	(r249567)
+++ head/sys/net80211/ieee80211_var.h	Tue Apr 16 20:36:32 2013	(r249568)
@@ -822,6 +822,28 @@ ieee80211_htchanflags(const struct ieee8
 }
 
 /*
+ * 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


More information about the svn-src-all mailing list