From patchwork Wed Oct 4 12:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 13408689 X-Patchwork-Delegate: kvalo@adurom.com 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 57B4FE7B604 for ; Wed, 4 Oct 2023 12:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242359AbjJDMbM (ORCPT ); Wed, 4 Oct 2023 08:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242351AbjJDMbL (ORCPT ); Wed, 4 Oct 2023 08:31:11 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2088.outbound.protection.outlook.com [40.107.212.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB93E6; Wed, 4 Oct 2023 05:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y6sneH6XQq3wdOSXHc273yMBV9Ua+HW3GBE6DB756RQno7lbFVWZFXXYLLyuOEMd8707Mcq/iZDROVPEXR/tB4gxSrW5aRnGnz38Gr75kvh4N0JkaEBzSP+SjKdlxumgeUIZGuFC7cNra8sJVKlFR6NbiHhLnzohJmVQ0rwTv7LQ6JuBkKy2AQc8UXr/0CzIC1HwQH4j/O6PdDMo2RblqRvLzMGAunrDh+qtsvznDY4oD/TzT4A1SEytNyPJoOEJZigZcsPsD7JRVKti+YO7gglG8m2QXGK3/OqE6aRpTX7Ei106chTURpwSISP2hsbWNahTgGtu9yGG66b7S+isMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qQt3OGMdANefwVSpXGd1rKYp7KRuhNqulpgmGB/25Fs=; b=Z9DR3NEsj2dxqWkSAvvpkMwW3iJdFJG6O2NQtOfa3FLBgnGFh1BO64zUapdIGRA5Yetw9Nm2DVwrvKbTmAvvgmLEdPiCmjbeU+ZDKLfCq8UmnWeFt5Gc2Ro7fwMbnwNeLlZeV6WONSQ9u9TYlfuo5L8UapkhqeX4Ekbut0QEqDSMXIcwb6PrJP+pCoKux5nWVddQhwj4wwQXF/ycxJhX3c3blgKUFguKx6jVuczMCPjA4eQai9LkPrHfOPYoxxFoldv3Kd3Ugw43FDtKIGCNd8xBzSg79knLy1N+3tzKgbtycpHeqveOR3v/wjJqDqIxt4WNLBvnWjNf/3ImVMfslw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qQt3OGMdANefwVSpXGd1rKYp7KRuhNqulpgmGB/25Fs=; b=d/T/d3IQ0zRKJRo2UoBpjh5bhQfoTxYmk295xKbe06feJCBi/VEUAO2bXWBTfamFUm3CWFGPF6s3aToKUF8IeDVzcSNoFYxmsLb5bgAfDJbjufKSdyhUHbZEzYjliNSxKEjzvxTdxLqttER6ax+H6F5kIkDnmBpDwEBK4pAgUM0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silabs.com; Received: from IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) by PH7PR11MB6795.namprd11.prod.outlook.com (2603:10b6:510:1b9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Wed, 4 Oct 2023 12:31:04 +0000 Received: from IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::d6c8:4cb6:2594:d8f3]) by IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::d6c8:4cb6:2594:d8f3%4]) with mapi id 15.20.6838.030; Wed, 4 Oct 2023 12:31:03 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= To: linux-wireless@vger.kernel.org, Kalle Valo Cc: linux-kernel@vger.kernel.org, Felix Fietkau , Felipe Negrelli Wolter , Olivier Souloumiac , Alexandr Suslenko , =?utf-8?b?SsOpcsO0bWUgUG91aWxs?= =?utf-8?b?ZXI=?= Subject: [PATCH v2] wifi: wfx: fix case where rates are out of order Date: Wed, 4 Oct 2023 14:30:39 +0200 Message-Id: <20231004123039.157112-1-jerome.pouiller@silabs.com> X-Mailer: git-send-email 2.39.2 X-ClientProxiedBy: PA7P264CA0533.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3db::25) To IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR11MB7773:EE_|PH7PR11MB6795:EE_ X-MS-Office365-Filtering-Correlation-Id: 8bf9a1b4-f1c5-4eb6-1f31-08dbc4d5c644 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TEXZvYr35WkZcx0Vny9kz0oqJ6IiloKEJplZ2c+eb/joop4j+BJf+pX8HbgK+4XVkCBT6ZXdyVH+af5Tx03KIF6PfuCWWwkNUGwyrqQOdB2pObediLhZvNhcHLNo77/zvLc6Vhd+d4wAYXzcldzIHovgNd+UJqz0+Nf/I7ojRhPEqYl7CLrQ2HpwfPpQOXCY43rEhM8kzCjs6Ig0hj9jScio+nVkKQjZcq77t0prTe8wQD1Hl/WwhgMd6MOn5M0TQBskLzhD5YqkZg72S8jacVUGQmcubhEZo4xkd9J0FBIEjK9D5GDq0kytu+pYqEyojZPlr4JCSjcUWDw3X6dRbvU408y0+B9FDb6XUsH9nsRT4mZQi7cCkHRfEwlGGhWRVLaXHLjNnW6wD0rKaTxbKJ3ZAjRbE3/egzANvc0Fa/PCTrxCfiM5HiV5x0dmTGBs58g556fU9g1DwwrqSxuSC+T127AlYNCo10sYQZZtGNDhoXQnHQ10RTMjBq0UAAEclYBOQ3cpW4XQ028hTTcCuYiti/ROvx00VOlFxmmz3houtarWvfUofk3eT9auOfAv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA1PR11MB7773.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39850400004)(136003)(396003)(366004)(376002)(230922051799003)(186009)(451199024)(64100799003)(1800799009)(6666004)(478600001)(66574015)(83380400001)(107886003)(2616005)(6512007)(52116002)(6486002)(6506007)(86362001)(66476007)(66556008)(316002)(2906002)(1076003)(38100700002)(54906003)(6916009)(5660300002)(36756003)(66946007)(8936002)(41300700001)(4326008)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TPucxUGphZKX2lN+9YhHSLksj9ng?= =?utf-8?q?CfJ3vrgzuEH9gOHMfYtuXIvyQy/5wXzRpO1RWOKtcvw6dNxUKcGQS8w4fKwhU5ZNs?= =?utf-8?q?bFtjI0g/exIvn5UTEbNVwSOps3CePRBSh5t0ResJC64RuYi3UBwGzbPSfaA4wBnTK?= =?utf-8?q?Ys/F62eg9lSpqa6sqkHjhAYlicMPG2Yo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Lj+D5onJ3poU/JY6op9qQfP3iTk?= =?utf-8?q?I23mDpA/zDPTcq8SJ5sv7p7gQ2I9920rx+r2OsmLZkbLdNEVDVimfwm603sNlBIN/?= =?utf-8?q?K2/GtmSDSC0xLTPspZpKlempQRQIjBsg3bhKr6UhWPeTgFACtlFmD52Lzbeav/tp0?= =?utf-8?q?LyeJDmHRxFjMT7ZH4GIKzN54rzLN26Qt3ruQbUejYEy/HT4yaVMaCTSAxRXV1I1df?= =?utf-8?q?5WbE3sy2NsJ4DKI+8X6jHsVZE4fI5xV5rO0ZLZs+KHMz1xZW8O17yNPoOfjhYqBzA?= =?utf-8?q?C4f78UY6qN34yQIy3NeEI+zOZ9w/msC1e5w8b7FjDEgv3+uI1U8A4ELOWg06CMxXw?= =?utf-8?q?XvzflldxpK1CO/+gUulEZIYydkitDaU7aSuo0JNgtpuxbaTa9PLKozjE0iyrTUsie?= =?utf-8?q?Y1jwlMpmZq8TbkINWs5l9uY/vo5HxYdJOpj7heAJEw8fJ7KTeS3LxOZIQpDctj2Gu?= =?utf-8?q?smXXHn/GbI56wFpyAjBZNuYST8JWuC5SGCgSezkNLEhGzhtW90sZjJaSSkVgVHTgN?= =?utf-8?q?LMLcAPN2rSM?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bf9a1b4-f1c5-4eb6-1f31-08dbc4d5c644 X-MS-Exchange-CrossTenant-AuthSource: IA1PR11MB7773.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 12:31:03.7668 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2tCsf8gNn96Ms0giwQwB7Acm93BykLMrA4zy9LbatySp1gpu7Gx/6mZTHl1McdYbcR1T7JZb0edmnjT/SsWphg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6795 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Felipe Negrelli Wolter When frames are sent over the air, the device always applies the data rates in descending order. The driver assumed Minstrel also provided rate in descending order. However, in some cases, Minstrel can a choose a fallback rate greater than the primary rate. In this case, the two rates was inverted, the device try highest rate first and we get many retries. Since the device always applies rates in descending order, the workaround is to drop the rate when it higher than its predecessor in the rate list. Thus [ 4, 5, 3 ] becomes [ 4, 3 ]. This patch has been tested in isolated room with a series of attenuators. Here are the Minstrel statistics with 80dBm of attenuation: Without the fix: best ____________rate__________ ____statistics___ _____last____ ______sum-of________ mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts] HT20 LGI 1 S MCS0 0 1477 5.6 5.2 82.7 3 0 0 3 4 HT20 LGI 1 MCS1 1 738 10.6 0.0 0.0 0 0 0 0 1 HT20 LGI 1 D MCS2 2 492 14.9 13.5 81.5 5 0 0 5 9 HT20 LGI 1 C MCS3 3 369 18.8 17.6 84.3 5 0 0 76 96 HT20 LGI 1 A P MCS4 4 246 25.4 22.4 79.5 5 0 0 11268 14026 HT20 LGI 1 B S MCS5 5 185 30.7 19.7 57.7 5 8 9 3918 9793 HT20 LGI 1 MCS6 6 164 33.0 0.0 0.0 5 0 0 6 102 HT20 LGI 1 MCS7 7 148 35.1 0.0 0.0 0 0 0 0 44 With the fix: best ____________rate__________ ____statistics___ _____last____ ______sum-of________ mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts] HT20 LGI 1 S MCS0 0 1477 5.6 1.8 28.6 1 0 0 1 5 HT20 LGI 1 DP MCS1 1 738 10.6 9.7 82.6 4 0 0 14 34 HT20 LGI 1 MCS2 2 492 14.9 9.2 55.4 5 0 0 52 77 HT20 LGI 1 B S MCS3 3 369 18.8 15.6 74.9 5 1 1 417 554 HT20 LGI 1 A MCS4 4 246 25.4 16.7 59.2 5 1 1 13812 17951 HT20 LGI 1 C S MCS5 5 185 30.7 14.0 41.0 5 1 5 57 640 HT20 LGI 1 MCS6 6 164 33.0 0.0 0.0 0 0 1 0 48 HT20 LGI 1 S MCS7 7 148 35.1 0.0 0.0 0 0 0 0 36 We can notice the device try now to send with lower rates (and high success rates). At the end, we measured 20-25% better throughput with this patch. Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames") Tested-by: Olivier Souloumiac Tested-by: Alexandr Suslenko Reported-by: Alexandr Suslenko Co-developed-by: Jérôme Pouiller Signed-off-by: Jérôme Pouiller Signed-off-by: Felipe Negrelli Wolter --- v2: - Fix malformed tags in commit body. (checkpatch still complains about missing Close tag, but the bug tracker is not public and I don't have the exact URL) - Slightly reword commit body drivers/net/wireless/silabs/wfx/data_tx.c | 71 +++++++++-------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/drivers/net/wireless/silabs/wfx/data_tx.c b/drivers/net/wireless/silabs/wfx/data_tx.c index 6a5e52a96d183..caa22226b01bc 100644 --- a/drivers/net/wireless/silabs/wfx/data_tx.c +++ b/drivers/net/wireless/silabs/wfx/data_tx.c @@ -226,53 +226,40 @@ static u8 wfx_tx_get_link_id(struct wfx_vif *wvif, struct ieee80211_sta *sta, static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates) { - int i; - bool finished; + bool has_rate0 = false; + int i, j; - /* Firmware is not able to mix rates with different flags */ - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { - if (rates[0].flags & IEEE80211_TX_RC_SHORT_GI) - rates[i].flags |= IEEE80211_TX_RC_SHORT_GI; - if (!(rates[0].flags & IEEE80211_TX_RC_SHORT_GI)) + for (i = 1, j = 1; j < IEEE80211_TX_MAX_RATES; j++) { + if (rates[j].idx == -1) + break; + /* The device use the rates in descending order, whatever the request from minstrel. + * We have to trade off here. Most important is to respect the primary rate + * requested by minstrel. So, we drops the entries with rate higher than the + * previous. + */ + if (rates[j].idx >= rates[i - 1].idx) { + rates[i - 1].count += rates[j].count; + rates[i - 1].count = min_t(u16, 15, rates[i - 1].count); + } else { + memcpy(rates + i, rates + j, sizeof(rates[i])); + if (rates[i].idx == 0) + has_rate0 = true; + /* The device apply Short GI only on the first rate */ rates[i].flags &= ~IEEE80211_TX_RC_SHORT_GI; - if (!(rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)) - rates[i].flags &= ~IEEE80211_TX_RC_USE_RTS_CTS; - } - - /* Sort rates and remove duplicates */ - do { - finished = true; - for (i = 0; i < IEEE80211_TX_MAX_RATES - 1; i++) { - if (rates[i + 1].idx == rates[i].idx && - rates[i].idx != -1) { - rates[i].count += rates[i + 1].count; - if (rates[i].count > 15) - rates[i].count = 15; - rates[i + 1].idx = -1; - rates[i + 1].count = 0; - - finished = false; - } - if (rates[i + 1].idx > rates[i].idx) { - swap(rates[i + 1], rates[i]); - finished = false; - } + i++; } - } while (!finished); + } /* Ensure that MCS0 or 1Mbps is present at the end of the retry list */ - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { - if (rates[i].idx == 0) - break; - if (rates[i].idx == -1) { - rates[i].idx = 0; - rates[i].count = 8; /* == hw->max_rate_tries */ - rates[i].flags = rates[i - 1].flags & IEEE80211_TX_RC_MCS; - break; - } + if (!has_rate0 && i < IEEE80211_TX_MAX_RATES) { + rates[i].idx = 0; + rates[i].count = 8; /* == hw->max_rate_tries */ + rates[i].flags = rates[0].flags & IEEE80211_TX_RC_MCS; + i++; + } + for (; i < IEEE80211_TX_MAX_RATES; i++) { + memset(rates + i, 0, sizeof(rates[i])); + rates[i].idx = -1; } - /* All retries use long GI */ - for (i = 1; i < IEEE80211_TX_MAX_RATES; i++) - rates[i].flags &= ~IEEE80211_TX_RC_SHORT_GI; } static u8 wfx_tx_get_retry_policy_id(struct wfx_vif *wvif, struct ieee80211_tx_info *tx_info)