diff mbox series

[RFC,v2,1/6] mac80211: modify tx-power level annotation

Message ID 20220920104032.496697-2-jelonek.jonas@gmail.com (mailing list archive)
State RFC
Delegated to: Johannes Berg
Headers show
Series mac80211: add TPC support in control path | expand

Commit Message

Jonas Jelonek Sept. 20, 2022, 10:40 a.m. UTC
This patch modifies the annotation of supported tx-power levels for a
wifi device in ieee80211_hw. This annotation was introduced with commit
44fa75f207d8a106bc75e6230db61e961fdbf8a8 to be able to operate on power
indices instead of absolute power values, providing better support for
different hardware capabilities.

The former annotation uses a 'const s8' for each power level. The choice
made with the former commit was not the best as this kind of annotation
may require much memory if there is a high number of power levels.
Thus, it is now replaced by a new struct ieee80211_hw_txpower_range. This
struct describes a tx-power range by specifying a start index, the number
of levels, a start power value and the power step width.

A wifi driver should specify valid tx-power ranges when it registers a
device in mac80211 by providing a pointer to a list and a length in the
corresponding ieee80211_hw members.
Drivers can define multiple tx-power ranges with each different scales
depending on the hardware.

Signed-off-by: Thomas Huehn <thomas.huehn@hs-nordhausen.de>
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
---
 include/net/mac80211.h | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

Comments

Jeff Johnson Sept. 21, 2022, 2:54 p.m. UTC | #1
On 9/20/2022 3:40 AM, Jonas Jelonek wrote:
> This patch modifies the annotation of supported tx-power levels for a
> wifi device in ieee80211_hw. This annotation was introduced with commit
> 44fa75f207d8a106bc75e6230db61e961fdbf8a8 to be able to operate on power

nit: preferred way to reference a commit is 12 characters of hash + subject:
44fa75f207d8 ("mac80211: extend current rate control tx status API")
Johannes Berg Jan. 12, 2023, 10:24 a.m. UTC | #2
On Tue, 2022-09-20 at 12:40 +0200, Jonas Jelonek wrote:
>  
> +/**
> + * struct ieee80211_hw_txpower_range - Power range for transmit power
> + *
> + * This struct can be used by drivers to define multiple tx-power ranges with
> + * different scales according to the hardware capabilities. A tx-power range
> + * describe either absolute power levels or power offsets relative to a base
> + * power.
> + *
> + * @start_idx The starting idx of the range. @start_idx is always the lowest
> + * 	idx of the power range.
> + * @start_pwr The power level at idx @start_idx in 0.25 dBm units.
> + * @n_levels How many power levels this range has.
> + * @pwr_step The power step width in 0.25 dBm units.

Need colons for valid kernel-doc, I believe.

johannes
diff mbox series

Patch

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ac2bad57933f..a047fb5fc207 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2661,6 +2661,27 @@  enum ieee80211_hw_flags {
 	NUM_IEEE80211_HW_FLAGS
 };
 
+/**
+ * struct ieee80211_hw_txpower_range - Power range for transmit power
+ *
+ * This struct can be used by drivers to define multiple tx-power ranges with
+ * different scales according to the hardware capabilities. A tx-power range
+ * describe either absolute power levels or power offsets relative to a base
+ * power.
+ *
+ * @start_idx The starting idx of the range. @start_idx is always the lowest
+ * 	idx of the power range.
+ * @start_pwr The power level at idx @start_idx in 0.25 dBm units.
+ * @n_levels How many power levels this range has.
+ * @pwr_step The power step width in 0.25 dBm units.
+ */
+struct ieee80211_hw_txpower_range {
+	u8 start_idx;
+	u8 n_levels;
+	s8 start_pwr;
+	s8 pwr_step;
+};
+
 /**
  * struct ieee80211_hw - hardware information and state
  *
@@ -2783,11 +2804,10 @@  enum ieee80211_hw_flags {
  *
  * @max_mtu: the max mtu could be set.
  *
- * @tx_power_levels: a list of power levels supported by the wifi hardware.
- * 	The power levels can be specified either as integer or fractions.
- * 	The power level at idx 0 shall be the maximum positive power level.
+ * @txpower_ranges: a list of tx-power level ranges supported by the wifi
+ *  hardware. The driver can specify multiple ranges with e.g. different scales.
  *
- * @max_txpwr_levels_idx: the maximum valid idx of 'tx_power_levels' list.
+ * @n_txpower_ranges: the number of power ranges defined by the wifi driver.
  */
 struct ieee80211_hw {
 	struct ieee80211_conf conf;
@@ -2824,8 +2844,8 @@  struct ieee80211_hw {
 	u8 tx_sk_pacing_shift;
 	u8 weight_multiplier;
 	u32 max_mtu;
-	const s8 *tx_power_levels;
-	u8 max_txpwr_levels_idx;
+	struct ieee80211_hw_txpower_range *txpower_ranges;
+	u8 n_txpower_ranges;
 };
 
 static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw,