From patchwork Thu Sep 28 10:10:48 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: 727586 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 1AE73CE7B17 for ; Thu, 28 Sep 2023 10:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjI1KLp (ORCPT ); Thu, 28 Sep 2023 06:11:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230358AbjI1KLo (ORCPT ); Thu, 28 Sep 2023 06:11:44 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2071.outbound.protection.outlook.com [40.107.95.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F137A122; Thu, 28 Sep 2023 03:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GwK5Jkl6TzDzG6w3gGeLGpDCUbRpu4xIgEHV0bsnyZ3oZ8lZMT5RmbcPSZLs1MuK+gWeZ3dFUtzHAh2tm0avFPcc2ft+ILnkXlE9Xs5ujDs/XuMtzEfA4GPhzEh0D2iCieHbi6aUUynJWNOALhxcu351dhEkhEFhs9t/mcP+5sAixgflt4WlzUsc5UcpcXjP1vcDQgMr3BAwjxANPvZ0lkSI6yMEroakA/+aM38/hF8ov7czGk3V5ldZEx5sDyC4CWSH1IwUmImICStd/b1UOlE4Guxqn5G4PnlFv6xiqB2UK5TDP+qJrAhDlKGreG7/n1T3w1N3axAx8nue8SZ3+Q== 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=wTqtp10S8n8sRWwgeXyvqrvNYdS12+M7dnIPKdSrsI4=; b=CBrMa/FRxG9Oh6Rto0gnmDLhgTNqJXxWR8H3QzSCxJErx/QEfPmdzBE5JCLpDMXsZUhM8KH5cpqCZ7h6XGZBHvxxHkpKTWiUsPcSbpZs7MEUPZOyDOy9umHlFnUzQQV1WXDdWbuqXogNkkwZhLOQtCeLlLucQpwmEtGcKPNFv8CQu8FNIQYIBIkeAUsVh2f7/VJ42EU1tYVHP9wdgE0cfZ9blK+1GfxUQu40atbSxnlqm7rzBfpErRwTTE2qCmlIwLgOMF8Vl2BFmF02AEZARz98Pzq67AwtFFuw69p7dsdGWySFLNbsi8NFxS9i9PJ12VCEYFpSDP8ssMlyrBwC4A== 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=wTqtp10S8n8sRWwgeXyvqrvNYdS12+M7dnIPKdSrsI4=; b=gFgMMekYT5WFewXw/WZ5/Q4uq9qsHuWRz+6XejoRyKnFF96whPK9ij6hgNyllVgZUkMmuuypsPTRrpoK5/pO2asRNT7qAPSWtK3ZCVUqOUJhLsTh/eBrFSmu/aAQpkdkB3wMzB1gqCdGInaF/3DddXw6UZsx8lvL3dggnPI+G4Q= 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 SA0PR11MB4557.namprd11.prod.outlook.com (2603:10b6:806:96::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Thu, 28 Sep 2023 10:11:39 +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.6813.027; Thu, 28 Sep 2023 10:11:39 +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] wifi: wfx: fix case where rates are out of order Date: Thu, 28 Sep 2023 12:10:48 +0200 Message-Id: <20230928101048.5543-1-jerome.pouiller@silabs.com> X-Mailer: git-send-email 2.39.2 X-ClientProxiedBy: GVAP278CA0001.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:20::11) To IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR11MB7773:EE_|SA0PR11MB4557:EE_ X-MS-Office365-Filtering-Correlation-Id: 36ef0e84-769c-4698-d7e8-08dbc00b4e38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CSp+NV01aevQUMWw75RQPz2yqfR42faWHkkkbiATWqLsdduvLx+uujBQlVSicMyX5t8/PIn+TsDw9/PCtMJbCoq9VM9MlIn3fYZ9NCF1SSpklwcbey0IRbhE5ltD6IXtRgIw9llCrven9jla3JIsHfyA8SfqKkzTP4PX5wW6O+8bm8xPitXwMGIVdbhJtUf58Grkyq93tey3XSkzoaxhjSsfV4w4IM4yw01NZ4Hc1iWS0S1diJc5VdUG8e5UBABP7gQRIMxhdvLeX899Gfx/6FP1DDAll/b9R2iFlQXqpvbYOkczf8se1OHgA/6WncKOdlWbhngY/UHa55kjKtejzXh3xhhKrDAtOCui3IE7JzWmbQSfU8lVMVe7Ph1qeNkFH/fUaMoYBOCXrvP28GzB2db9Mz/Nv9ef8OFW8IFg51B+TpReDIwCB+d45o49LHw6hivXve09WnIu5R8i1LWNuqVqNfvvkiZDD7osMHqzn7lC46GB1tNkbddH2mxaiofktfnmr+k8sXX1HMS4NhUrjemm8emJviJMQb0nBNmLgcg042+w9s1GPQbgng+Cps56Eb5BvJOc76C58msR9ncTiWW4jRnf0VoYz6bMZC8/0QlnQ7YccJ7urHftuymZuRM4 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)(396003)(346002)(136003)(39850400004)(376002)(366004)(230922051799003)(1800799009)(186009)(64100799003)(451199024)(6512007)(66946007)(316002)(6916009)(2906002)(66476007)(66556008)(54906003)(41300700001)(8936002)(8676002)(4326008)(478600001)(1076003)(6666004)(5660300002)(52116002)(38100700002)(38350700002)(6506007)(2616005)(86362001)(26005)(66574015)(36756003)(107886003)(6486002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?iBJnk9SxCA5XaGj9Dj9JrHkrCi3D?= =?utf-8?q?WKD/VLWLW9f3WcUzXFaoqOxOzTrawFvmctr8Tp/qm6dIPO9D9u4ae4b/Fdo1DA7mn?= =?utf-8?q?CD49P4y/N9/oMeEoOcNH4g9AdLgZC5NxPoZQkyOPPEOki3gNrzp1Oeg1KOOaUCScF?= =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EAMc3pCIdS8T0ZuJgpHJxgUSUDKtSHVBoWDJ7P9w2mR/d17ZKRwNUhc9+ag9O?= =?utf-8?q?xUURAjsy/QfYPjbjp3jB7Jc5wq5VLkH+tsKciiYUWxk5YebSR1rUQHYzq38FQlBQs?= =?utf-8?q?3rlnh6AVk3k71ye3XA/3KhSTFvVyxVa3WEWQhJpcrYsvVs1KQ25C5y1oQWXmFE/AJ?= =?utf-8?q?8YWrDlX57drf4xkqzdobEtpfT5J5dTqrY6izJ3zCw3niQ5C9hNeVdHjYargalIhJj?= =?utf-8?q?yH9szAaJUPED+b+CNHIYbQ7mvarQ6wfWrU1u/TX7l7NeQMg0h84ucfRLs6Z9bbjzS?= =?utf-8?q?zK50KyNh/+OiNSp5j47hbIIjia876Z/XK2GWD9UPXp3308Qy/sc9SLAl6RU/YGuC5?= =?utf-8?q?050jRlx9CdophsGX4EkiHiiYSfBHf6gJ399t9liIpUDE/fym3yFGcc7RbbQI3PMDQ?= =?utf-8?q?Ts3ymI3JAd0XBDlc2a9iGAEU7hb8cBZ+YSs1C2iKm3UhxradRhSc5xCtQl5pFsHY8?= =?utf-8?q?jd8QDjTZEwUM?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36ef0e84-769c-4698-d7e8-08dbc00b4e38 X-MS-Exchange-CrossTenant-AuthSource: IA1PR11MB7773.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2023 10:11:39.3819 (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: fBXaGPU3brfB8ohF92LZZUbjAyWQT0Wy0r7QZgdu6c3ohfv2AZEDrWAcXrKDTboxXBnuKVSE9rYkFekfJqDE9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4557 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 apply rates in descending order. The workaround is to drop rate when it higher than its predecessor in the rate list. Thus [ 4, 5, 3 ] become [ 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: 9bca45f3d6924 "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 --- 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)