From patchwork Mon Aug 29 14:41:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Jelonek X-Patchwork-Id: 12957997 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64A57ECAAD2 for ; Mon, 29 Aug 2022 14:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbiH2OmE (ORCPT ); Mon, 29 Aug 2022 10:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbiH2OmD (ORCPT ); Mon, 29 Aug 2022 10:42:03 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6546E90815 for ; Mon, 29 Aug 2022 07:42:02 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id e13so9558128wrm.1 for ; Mon, 29 Aug 2022 07:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=6NWu/Ly1g+WIRpG9O2aLNsUaVepWWRiAR79qGrRwoK4=; b=Ejkd48vds+obWrnOewXqR7ewC9ijc2S5+IoWfqr6ras/wDshuJnKjIAhSUaJ3Q0oCh R9VXcp3f3vcWhL8jLK1UvLig83zns5AAs5OkSjih33d5MqYUxNmWLwIhWoIph+4NKiY2 KhfNPkXT52WnQ2bCONXzzIDZZ5GBWnq+j34IUOwQV04oCIkP/liHgm1qrCTiFMMu7a+z PxbqJkPgB9mt/sAEEMGwE59ah4PYfKgb4i6ESLOHIvbDEOTtXvDY8Z+HxjEwP3DalNg8 XhNOwWKEJjaWfwzrcqpw/pjO7jotmFRJP6Ol/67SYtHxNAg1A6/FmB+ZX1+yCDrOVKDE ErPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=6NWu/Ly1g+WIRpG9O2aLNsUaVepWWRiAR79qGrRwoK4=; b=XHmWHBENAf13HuVH5E7tUbg4vqvf463w2eNBhvmEpC71BrdW6Rj0w6PmeDJM7EuHal JRvTar8vz9lA5tSJFgvExSeyoXC0Q6ZmAtu8qLdLk2tLyNheErcBUooXVRWFj7UEtgNm oK9b8vWYmPFEan4+J/QDuMXqQ4QYJ/uhIp2wEiJ2mlGSRrINv7ggr+jgzbmUG7NBClY2 FsRhTsKA7MspgwT3+V3HM7KovSCzGOCl8YgC5XwAW+AMDfv3D6ENS506bEnTUvU2sDNh IlwmbvLYEy6MsnVnPg+YXRHXNuYx2pYPy+atnJE1xTwjcVV8hTu7rvedQyxhMVG+/XcN xW1g== X-Gm-Message-State: ACgBeo2n/pJcFOpEyZwdW9QUE2FkZCcdRVhkQiRReLLvAAFa4t/11EF2 5Lz0rjLimy/jR/jQ/oSsRSsnJbgXMZE= X-Google-Smtp-Source: AA6agR7vX5IUfcH4kaJmKhdYogJSUrTNwNErVxWjMLMYqDQ94fG38orXorDKKvhAqhvWHi5Ie/6VZQ== X-Received: by 2002:adf:f085:0:b0:226:d6e4:58f5 with SMTP id n5-20020adff085000000b00226d6e458f5mr4294059wro.50.1661784120933; Mon, 29 Aug 2022 07:42:00 -0700 (PDT) Received: from build-server.fritz.box (p200300c56f18a600880d3dfffedefb04.dip0.t-ipconnect.de. [2003:c5:6f18:a600:880d:3dff:fede:fb04]) by smtp.googlemail.com with ESMTPSA id q3-20020a1ce903000000b003a61306d79dsm9398431wmc.41.2022.08.29.07.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 07:42:00 -0700 (PDT) From: Jonas Jelonek To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, nbd@nbd.name, Jonas Jelonek , Thomas Huehn Subject: [RFC 1/4] mac80211: modify tx-power level annotation Date: Mon, 29 Aug 2022 16:41:44 +0200 Message-Id: <20220829144147.484787-2-jelonek.jonas@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220829144147.484787-1-jelonek.jonas@gmail.com> References: <20220829144147.484787-1-jelonek.jonas@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 Signed-off-by: Jonas Jelonek --- include/net/mac80211.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index ffd0ebbff294..9612714d715f 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -2619,6 +2619,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. + * @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 * @@ -2741,11 +2762,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; @@ -2782,8 +2802,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, From patchwork Mon Aug 29 14:41:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Jelonek X-Patchwork-Id: 12957998 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E8C5ECAAD5 for ; Mon, 29 Aug 2022 14:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230391AbiH2OmF (ORCPT ); Mon, 29 Aug 2022 10:42:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbiH2OmE (ORCPT ); Mon, 29 Aug 2022 10:42:04 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E98901A3 for ; Mon, 29 Aug 2022 07:42:03 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id c7so3798149wrp.11 for ; Mon, 29 Aug 2022 07:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=sZGs/SfDvoLovLDUPhVU9clLBjBIoiuwVlanjNAHV70=; b=jS/sBBSBd0Uq55Ol6jyus2WmwLPRRLqvjj+lHg9FxQMbvHo6xdQ6y+s3E2GlRgOs61 jOICgTqsGIhcqIsGT5rM7xNyTJEg2Bm/z5gJ14+CoQAVLuyZuhY8MtuOo2zbNWd6pHMG bXHAvByaT9T1U+9eCLaDUHr/uvoN6Pb3qq7DgsjlMZzkVftfPPZiSt1MoP8qpWcVRPwg vfl8CXEH7VTbSJpUBRsXotSNeHd/7QCeWzVVOfON99kUt813azW5KIHgoUjAHfc/6HUs AULz2xJ03IjYlQrjkzG5VZLihaJCgjknCzJWtWFS17O5/KlPbMx4xMu0c1AAvy+012Cs AS4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=sZGs/SfDvoLovLDUPhVU9clLBjBIoiuwVlanjNAHV70=; b=069tvaIhvN3IXP8UCOOcrEAfUlQHAdxeF3OSsZgZldxw7t12uMot53HoRsHAMYzoXK 6ampQgzwsnKy87QfYeZnIvJ4gH0VF9AOC/AQuBk3YfEPE5TBSysD/Dq8ROGU4lOqpFhv xoCw1pVZqBhdVE7rY7UX3OgIr6P4IBMPX1ebonH4aicDoEDsJYZmZBB4DW6Jv2y+EQ4f 4JLAB7JiY2ohbWNl8OnPJ5n1z65cjqcOkwIcHtLkLEuJiiXFGNqzpA1sS+r2GarBpnAt zPTmhGhjcwCxJSGTczHTuVVX9pw8c7LshwSvEifTMMcvWPbXn2tHAs22uKbTw7jdTN80 DY7Q== X-Gm-Message-State: ACgBeo1JUixHvOKzRZylrRVugQWj9QdtReNQXFRYg69VHHLIQuTr2Ljc GqMhVyNWP/bk2A+5m7n7Q/KQBGH6ewg= X-Google-Smtp-Source: AA6agR6RdhK8cxkTwTuW8evCREcq5Ztb6JCB3jcxnXG2lSeiYkUC7X6dY3mcYCq1ndTN2cG3nNbE+A== X-Received: by 2002:a5d:6c6b:0:b0:225:dde:ab40 with SMTP id r11-20020a5d6c6b000000b002250ddeab40mr6573289wrz.690.1661784121831; Mon, 29 Aug 2022 07:42:01 -0700 (PDT) Received: from build-server.fritz.box (p200300c56f18a600880d3dfffedefb04.dip0.t-ipconnect.de. [2003:c5:6f18:a600:880d:3dff:fede:fb04]) by smtp.googlemail.com with ESMTPSA id q3-20020a1ce903000000b003a61306d79dsm9398431wmc.41.2022.08.29.07.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 07:42:01 -0700 (PDT) From: Jonas Jelonek To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, nbd@nbd.name, Jonas Jelonek , Thomas Huehn Subject: [RFC 2/4] mac80211: add tx-power annotation in control path Date: Mon, 29 Aug 2022 16:41:45 +0200 Message-Id: <20220829144147.484787-3-jelonek.jonas@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220829144147.484787-1-jelonek.jonas@gmail.com> References: <20220829144147.484787-1-jelonek.jonas@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This patch adds members to ieee80211_tx_info and ieee80211_sta_rates structures to allow tx-power annotation per packet/per mrr stage. The added members are always tx-power indices referring to the tx-power set described by ieee80211_hw->txpower_ranges. The annotation in ieee80211_tx_info is for probing and compatibility reasons only, e.g. drivers that only support RC/TPC per packet and do not yet use ieee80211_sta_rates. Signed-off-by: Thomas Huehn Signed-off-by: Jonas Jelonek --- include/net/mac80211.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 9612714d715f..659662f8b5dd 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1072,6 +1072,8 @@ ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate) * @control.use_cts_prot: use RTS/CTS * @control.short_preamble: use short preamble (CCK only) * @control.skip_table: skip externally configured rate table + * @control.txpower_idx: Tx-power level index for whole packet, + * referring to an idx described by ieee80211_hw->txpower_ranges * @control.jiffies: timestamp for expiry on powersave clients * @control.vif: virtual interface (may be NULL) * @control.hw_key: key to encrypt with (may be NULL) @@ -1120,7 +1122,8 @@ struct ieee80211_tx_info { u8 use_cts_prot:1; u8 short_preamble:1; u8 skip_table:1; - /* 2 bytes free */ + u8 txpower_idx; + /* 1 byte free */ }; /* only needed before rate control */ unsigned long jiffies; @@ -1181,9 +1184,10 @@ ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info) * * @rate_idx The actual used rate. * @try_count How often the rate was tried. - * @tx_power_idx An idx into the ieee80211_hw->tx_power_levels list of the - * corresponding wifi hardware. The idx shall point to the power level - * that was used when sending the packet. + * @tx_power_idx An idx into the the tx-power set described by + * ieee80211_hw->txpower_ranges for the corresponding wifi hardware. + * The idx shall point to the tx-power level that was used when sending + * the packet. */ struct ieee80211_rate_status { struct rate_info rate_idx; @@ -2097,6 +2101,8 @@ enum ieee80211_sta_rx_bandwidth { * @rcu_head: RCU head used for freeing the table on update * @rate: transmit rates/flags to be used by default. * Overriding entries per-packet is possible by using cb tx control. + * @rate.txpower_idx: An idx pointing to a tx-power level described by + * ieee80211_hw->txpower_ranges that should be used for the mrr stage. */ struct ieee80211_sta_rates { struct rcu_head rcu_head; @@ -2106,6 +2112,7 @@ struct ieee80211_sta_rates { u8 count_cts; u8 count_rts; u16 flags; + u8 txpower_idx; } rate[IEEE80211_TX_RATE_TABLE_SIZE]; }; From patchwork Mon Aug 29 14:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Jelonek X-Patchwork-Id: 12957999 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE5EDECAAD2 for ; Mon, 29 Aug 2022 14:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbiH2OmG (ORCPT ); Mon, 29 Aug 2022 10:42:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbiH2OmF (ORCPT ); Mon, 29 Aug 2022 10:42:05 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C774192F62 for ; Mon, 29 Aug 2022 07:42:04 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id bq11so10461279wrb.12 for ; Mon, 29 Aug 2022 07:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=fm7qEMv+xUI/3r1l2+5+ZPC82d9Mfm+oNWCnOPxaifI=; b=RZUII4V41Sj5NMQ8xYO9vnAGhXUy2ZXF+wpCvQ3BAIhgeufcZZmxp5cOSylR5K1zGs Ln/CJMtDTGYvQpxW6PL17WWNfKycLsxjZAwfkUdGpkGAWZ5X8JREyelQzoL4VT0ioliC mOm/BKuv/ph4tz91bP6DXGJ/9Sdvmqh4GUXWH9c3ZAdXebZNTSyiJu733hKZ+DQRBHpg R9KMeRDju8SNJ7okWBdQdmo7wJ2QuSoYlqH8jLCL5Y0HNUgeW3kwRvK4CUNP17u8fEKv MHbK0Bc0fZrg4+VbMBTgXcLLJIlIiwvDyP3qJ+Ol8pUyDsmKGuqwWP7cUJTAvBmw+0gg crlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=fm7qEMv+xUI/3r1l2+5+ZPC82d9Mfm+oNWCnOPxaifI=; b=2Hyf83zBJH3WhMYbsupQhaABjynHmWQP37LHFdWugMPAAEiuMApN2oaTf7LE8XgNLB 0Lf7j+DmTrKrCekSEGU2qr0X8qTwbRT5Guk9TFVOwxAfmEhrtk71BKrVdUD0pAlOyLMD P7tSM8vk8o1ZSJxrD0v/FxbFSaAd0VuSho4c5iCjdMy38KYg8VD+lYsI+GJYY9cNoba6 rgrKJRNRl9WCbtwhYaEoVXN0Ww0KTGkMN43/yuJ3k6ZDDxchJDdtEmr8B/ldPieJ9afY h0D3AIG2hEvI9sCXOCTN0Zsh6ERtrm0vbQe2X48iyPsEtdLBVS78awAN8U5Z9z8uQBmN pH6g== X-Gm-Message-State: ACgBeo2aUNkXYHCHOQf1jAFPWBI8fRzynZJ7KPgNOwvJ/OdrbX3lDLAg 9zi0GACyx5lWGnDYV6MuZ7ikypbwz/w= X-Google-Smtp-Source: AA6agR5BUeLckLLdSQZsed6IdrBbFgCbaRJrDSzkT/XSCrxgivv9+1D6+3W9XNzFnn0NCynzU93E9Q== X-Received: by 2002:a05:6000:1b92:b0:220:7d86:2e30 with SMTP id r18-20020a0560001b9200b002207d862e30mr6769817wru.530.1661784123298; Mon, 29 Aug 2022 07:42:03 -0700 (PDT) Received: from build-server.fritz.box (p200300c56f18a600880d3dfffedefb04.dip0.t-ipconnect.de. [2003:c5:6f18:a600:880d:3dff:fede:fb04]) by smtp.googlemail.com with ESMTPSA id q3-20020a1ce903000000b003a61306d79dsm9398431wmc.41.2022.08.29.07.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 07:42:02 -0700 (PDT) From: Jonas Jelonek To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, nbd@nbd.name, Jonas Jelonek , Thomas Huehn Subject: [RFC 3/4] mac80211: add hardware flags for TPC support Date: Mon, 29 Aug 2022 16:41:46 +0200 Message-Id: <20220829144147.484787-4-jelonek.jonas@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220829144147.484787-1-jelonek.jonas@gmail.com> References: <20220829144147.484787-1-jelonek.jonas@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This patch adds two hardware flags for drivers to indicate their transmit power control (TPC) capabilities: TPC per packet or TPC per mrr stage of each data packet. The driver has to register with its TPC capabilities when it is registering at the mac80211. Signed-off-by: Thomas Huehn Signed-off-by: Jonas Jelonek --- include/net/mac80211.h | 9 +++++++++ net/mac80211/debugfs.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 659662f8b5dd..ce3241313e06 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -2564,6 +2564,13 @@ struct ieee80211_txq { * @IEEE80211_HW_MLO_MCAST_MULTI_LINK_TX: Hardware/driver handles transmitting * multicast frames on all links, mac80211 should not do that. * + * @IEEE80211_HW_SUPPORTS_TPC_PER_PACKET: The hardware/driver supports transmit + * power control (TPC) with one power level per data packet. + * + * @IEEE80211_HW_SUPPORTS_TPC_PER_MRR: The hardware/driver supports transmit + * power control (TPC) with individual power levels for each + * multi-rate-retry (mrr) stage per packet. + * * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays */ enum ieee80211_hw_flags { @@ -2621,6 +2628,8 @@ enum ieee80211_hw_flags { IEEE80211_HW_SUPPORTS_CONC_MON_RX_DECAP, IEEE80211_HW_DETECTS_COLOR_COLLISION, IEEE80211_HW_MLO_MCAST_MULTI_LINK_TX, + IEEE80211_HW_SUPPORTS_TPC_PER_PACKET, + IEEE80211_HW_SUPPORTS_TPC_PER_MRR, /* keep last, obviously */ NUM_IEEE80211_HW_FLAGS diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 78c7d60e8667..daeef1e04cb5 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -496,6 +496,8 @@ static const char *hw_flag_names[] = { FLAG(SUPPORTS_CONC_MON_RX_DECAP), FLAG(DETECTS_COLOR_COLLISION), FLAG(MLO_MCAST_MULTI_LINK_TX), + FLAG(SUPPORTS_TPC_PER_PACKET), + FLAG(SUPPORTS_TPC_PER_MRR), #undef FLAG }; From patchwork Mon Aug 29 14:41:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Jelonek X-Patchwork-Id: 12958000 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22968ECAAD2 for ; Mon, 29 Aug 2022 14:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230396AbiH2OmL (ORCPT ); Mon, 29 Aug 2022 10:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbiH2OmK (ORCPT ); Mon, 29 Aug 2022 10:42:10 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46B7E979CB for ; Mon, 29 Aug 2022 07:42:06 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id e20so10440064wri.13 for ; Mon, 29 Aug 2022 07:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=QKJYCZBZ7zF/rLnjuEFP7T+ofEp0leg9es3w94vqizY=; b=awE/RH/UqWjtxXVINq2YBt9UbMhX8jW6WyCPYzZRoVzXCAI5yRrFLnHsptST33nC/O fm/PWJFAEAjE3PM/e+6PwPx6pURxEvY3AXCJeqUitziOEEFJ+mmRxobdw18KRvVA0J5H 2S8QxLEJMT99xMyYu4Vow3GtJD50dLvmfp2fcHDHEnk8jHTkiMoN2N3Gu/buRKoJfKEE TKVHLuEin3z+a8ytG09a09YnAdZx381VDRGkyebg33ax0/OG71SEGV5+KWSpFb1LRLiA gUU85WHeaabmzvZVFCU3T8XH5Hd12BlNa8h/Ya6l570g4MqmaKQizP9VO8Vp7kr0k3DF HmyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=QKJYCZBZ7zF/rLnjuEFP7T+ofEp0leg9es3w94vqizY=; b=24MaNTs+y4E2rFiS5lPG1P47ZCvP1xW2mflvyWbX7Q4lZ+PaRQyTLF/rpAsUyCv7D6 ISlSl/PWF3LYVBFAF7xLyMU205y6He11ZYvdUhBLUmic3Swucd1uEuojKw+iXf/u2kV/ 4u+UhFlbFPoZtuOaJtp60SCMW6E9G1OnBJ7HudyACVP1A/DFcG+xXLgnATI6VAe61ZsL TmQhds+vppLKcagSBXmE4bJRT8aLVtHvB9efZ4e4T0we5qeHMEO2inPDXcP9hMBsC8f0 wVDGq1/be0RZhmhUfF6A8MepwEtfbgzX6KIkMvl+5LO4aSYFKvko5PVtJrptcGScYJ/g mSGA== X-Gm-Message-State: ACgBeo2UoOwi2LOGKW9p+kQS5hSVXCRlxceS0dzZeEc0yMsQX0t6Ul15 uGz9gc1XaPR2XKSU0nA8hT4Qx71IH1k= X-Google-Smtp-Source: AA6agR5iled6ZlalhYFm7u7/W3BCRmsfgZaO4QiPKkro3ufU/pO6nuCSkYKcHGDbMOxzqF3EcUXBAw== X-Received: by 2002:a5d:6d46:0:b0:21f:8b7:4c1d with SMTP id k6-20020a5d6d46000000b0021f08b74c1dmr6650059wri.455.1661784124549; Mon, 29 Aug 2022 07:42:04 -0700 (PDT) Received: from build-server.fritz.box (p200300c56f18a600880d3dfffedefb04.dip0.t-ipconnect.de. [2003:c5:6f18:a600:880d:3dff:fede:fb04]) by smtp.googlemail.com with ESMTPSA id q3-20020a1ce903000000b003a61306d79dsm9398431wmc.41.2022.08.29.07.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 07:42:03 -0700 (PDT) From: Jonas Jelonek To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, nbd@nbd.name, Jonas Jelonek Subject: [RFC 4/4] mac80211: add utility function for tx_rate - rate_info conversion Date: Mon, 29 Aug 2022 16:41:47 +0200 Message-Id: <20220829144147.484787-5-jelonek.jonas@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220829144147.484787-1-jelonek.jonas@gmail.com> References: <20220829144147.484787-1-jelonek.jonas@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This patch adds an utility function to mac80211 for conversion between ieee80211_tx_rate (mac80211.h) and rate_info (cfg80211.h). struct ieee80211_tx_rate is space limited to annotate rates up to IEEE 802.11ac. The new struct rate_info is able to annotate IEEE 802.11ax rates and beyond. Several drivers internally still use ieee80211_tx_rate but mac80211 expects rate_info in struct ieee80211_rate_status. This struct is in turn required to allow, e.g., tx-power status report or dynamic number of mrr stages. Signed-off-by: Jonas Jelonek --- include/net/mac80211.h | 4 ++++ net/mac80211/util.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index ce3241313e06..cecba460a518 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1050,6 +1050,10 @@ ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate) return (rate->idx >> 4) + 1; } +void ieee80211_rate_get_rate_info(const struct ieee80211_tx_rate *rate, + struct wiphy *wiphy, u8 band, + struct rate_info *rate_info); + /** * struct ieee80211_tx_info - skb transmit information * diff --git a/net/mac80211/util.c b/net/mac80211/util.c index a292e63377c3..466d49ff8dcf 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -4870,3 +4870,38 @@ void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos) *len_pos = elem_len; } + + +void ieee80211_rate_get_rate_info(const struct ieee80211_tx_rate *rate, + struct wiphy *wiphy, u8 band, + struct rate_info *rate_info) +{ + memset(rate_info, 0, sizeof(struct rate_info)); + + if (rate->flags & IEEE80211_TX_RC_MCS) { /* 802.11n */ + rate_info->flags |= RATE_INFO_FLAGS_MCS; + rate_info->mcs = rate->idx; + } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { /* 802.11ac */ + rate_info->flags |= RATE_INFO_FLAGS_VHT_MCS; + rate_info->mcs = ieee80211_rate_get_vht_mcs(rate); + rate_info->nss = ieee80211_rate_get_vht_nss(rate); + } else { /* 802.11a/b/g */ + rate_info->legacy = wiphy->bands[band]->bitrates[rate->idx].bitrate; + rate_info->bw = RATE_INFO_BW_20; + return; + } + + if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + rate_info->bw = RATE_INFO_BW_40; + else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) + rate_info->bw = RATE_INFO_BW_80; + else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) + rate_info->bw = RATE_INFO_BW_160; + else + rate_info->bw = RATE_INFO_BW_20; + + if (rate->flags & IEEE80211_TX_RC_SHORT_GI) + rate_info->flags |= RATE_INFO_FLAGS_SHORT_GI; + +} +EXPORT_SYMBOL(ieee80211_rate_get_rate_info);