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: 148253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp95081vqb; Wed, 4 Oct 2023 05:31:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCxq6CnYTyqid9yveuz50clRCQha3USmChn7OrGetJsZ6rNCWxBc8EXerHTZroolKyoJZK X-Received: by 2002:a05:6a20:3206:b0:161:20dc:1a15 with SMTP id hl6-20020a056a20320600b0016120dc1a15mr1925376pzc.57.1696422688324; Wed, 04 Oct 2023 05:31:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696422688; cv=pass; d=google.com; s=arc-20160816; b=eOcGG3ccYykKAjo7F3GgfqJt9L5IwP7HtA25OBThTGcw5sxrbXtBrTtEyOge2o4S+i tm1DezTCU+zpvR4ndjyaAK3d6EJ7rYY75xHd2IbiTiYQ+YmV4qR4t0cJSz+RQrU72EAD 91idhUxQTrfVx/ePxJp+g0TH3aelGFrB6b6Gho4a/+hyh7OgG1XUDUV2L/7PnotVMKZK 1smWcE9o3Xs+ZNqNVn++RrGc2WDiuYOqmfTr9AskG3xt9QGrnkbfXIz8Gv8VJ1NGvnp7 9rPiuvvPoBYDfU6pjo0A8+JnpnNucL9hFqzE9geRg0ij4dHl2Q7XM1Y58fFGt6uHHcii 4Wpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=qQt3OGMdANefwVSpXGd1rKYp7KRuhNqulpgmGB/25Fs=; fh=0f95jaFBz0QakYqORlWE6DJMdLXDSQ0BqK1r1/7eEjc=; b=zLUvxV71Qc3Qe3/hsADAELlvbW6mLWKGAHqRvbB3wSlMHEbIjUyAzneN+WybJaZvfl 9m2aCR55L0qR5JT/hAGcmSHyRtugzqIVTxlJkweIgg201qKWzwrklfQe2EpUiOK0EY4x VpvhMXbecgRRnvWocRbGmLBv20Uozfs+IRRgmK2G34cOtXxfiyjnRR6acPCXJ1HUKMvP FCjwQVhxTyhhjV/atVjbc2+EzDAB9sBZMevm3E/wzZGgpvic24zWOst0BfLgvZtqDYoN uJqOCZntMRzFqXfHR43l8xXM8CRUDktI5GK2mIwREy7KABIY0NJjh+LHoo6h+4wT2G8S 84Bg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@silabs.onmicrosoft.com header.s=selector2-silabs-onmicrosoft-com header.b="d/T/d3IQ"; arc=pass (i=1 spf=pass spfdomain=silabs.com dkim=pass dkdomain=silabs.com dmarc=pass fromdomain=silabs.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=silabs.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x7-20020a170902a38700b001c611f285aasi3519461pla.541.2023.10.04.05.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:31:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@silabs.onmicrosoft.com header.s=selector2-silabs-onmicrosoft-com header.b="d/T/d3IQ"; arc=pass (i=1 spf=pass spfdomain=silabs.com dkim=pass dkdomain=silabs.com dmarc=pass fromdomain=silabs.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=silabs.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5372A8031F28; Wed, 4 Oct 2023 05:31:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242348AbjJDMbM (ORCPT + 18 others); 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/F62eg9lSpqa6sqkHjhAYlicMPG2YoZldqLJ+ca4bvrUDBEi79h+FZcCNISpNwq?= =?utf-8?q?f45n5XqiOamS6bBBkzUWyEIZVZQsjhySZI7nOxqsnUKy3vO/hJAiRvr8BU5a8L2tn?= =?utf-8?q?C9R2bTtNyhN06meBAs1gy9AvS5Jv5mJ+6XyurxRMCHiGoH8W2DycaJHlpQLckq1pt?= =?utf-8?q?0v6FnqZ4H4e1hbH7nh9mI8Jt9oTpP14StjcHFB89tAZpxH3namVcvQXKO+jXa+Llh?= =?utf-8?q?cssu2+IBwr8op/evg/4SL8Z+jUEZ0hd5F8s0sL/YWpsnuguaDj5pHCHuWGq4cvVIg?= =?utf-8?q?PXpvA68DuSC+YIkT7sGv1dJ+2ntWPNujslWZT7/21r4w437WtbuHFhqB7id0vigdb?= =?utf-8?q?Okz5sgfLJ/+Lg+K+6T6iYxHQ40njhjTQNR4249mq+kGebasmR5hQn9VaytxwqLHk1?= =?utf-8?q?6wv7JIpIiYBHmJuJgrSMcxjwT0gdt2f+73SIA3cDLz5cQDYEqXf3jDd9j3MQr0FOq?= =?utf-8?q?n6nU31vjXEuW8VcViGvuT4K41J+mGN0DM/z+NzhKU4ZjJezc7zZno7es6Vv6dKB7q?= =?utf-8?q?6IuWThK0laqc9EJKMJjAf4ldI22Bj6d7w9CImz7hIhjg2C6AwMZOfr3UL2ZYDlbv6?= =?utf-8?q?PTkXL5Ih7uWyaGcwZwK52hFae6SdVSYSF/agdOhanfI6iJTca/QgR7Ng0qvCGSq5p?= =?utf-8?q?NGIhH00+Y3Sx1KZiJy4m2T4cLQq1kKRH+NXDPRdnzcLbauTSi3gygxzJ+KS3wtEcy?= =?utf-8?q?ZUOEujcBH2FNhjLUJ0scSpYVfKn1bq6Xg51lluHK6WHm104UlO02KfHQCVYAkhufN?= =?utf-8?q?IWwiJ88y6OraXe971/ZGV82ensK0EOeQlt2jwzLls3fSjW8bI0Ku/M4RcWCe2tcHn?= =?utf-8?q?P7YUnC21xerbtaAHlhe0pWmMxTAhUmiDooM+/aLj+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 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 05:31:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828117131128787 X-GMAIL-MSGID: 1778828117131128787 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)