From patchwork Wed Oct 7 10:19:40 2020 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: 287948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A65C4727F for ; Wed, 7 Oct 2020 10:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64EF120870 for ; Wed, 7 Oct 2020 10:21:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="cTQXabH+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbgJGKUi (ORCPT ); Wed, 7 Oct 2020 06:20:38 -0400 Received: from mail-bn8nam12on2066.outbound.protection.outlook.com ([40.107.237.66]:19424 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727527AbgJGKUU (ORCPT ); Wed, 7 Oct 2020 06:20:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fFP2rKdAfIwLyYCsScja1LCh4QiQGDFRw5H+ijKaD2LS890MfsJw8y5lbvpLIQCJ9/lwDDG/5G3qTChhSxS2AJwTCV8hByMTF5cRJCOCRrZtPZN9V/SzfUrmGLl8oAu0OB2aToOR88b2sB4cgb8OnijOUUXZaLq6LVMGcf5P8sgTjctjvXRhbt8haHtomR9w/GJdSLAt2HpwAmAZeTJkS9j2h2iYWuyKBuuFRgL7VDvFdOA1BgEIXHQ4PteJFJpkBbGwdTEC9Tuwq1pmep1vqaUUNpBNj3LiXRdSVvlvceC7o1xEfjYeBKtgwHO7VcM/GGGF8S2QnT7AGhxwiRXsAQ== 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-SenderADCheck; bh=6o3ILcCIWqLfEBgzOO4npMJ9j0rWoU4kQ/wh+Dukeok=; b=h9hf5++hGML8GOIXEY6L2g4hLkI7U+JvYXKm2z4GOToT5asJjwCTaCxXNh/zdEuLKf15PbgDwowP8IxCdk5Y6g7MigNAVa2P4gqtiSRuLEL3Pjiqk8CMCS1fKNbF3H1HOFcBar5zvomrIDsKBLbwP1mWddagu6aqMSZRGc6VakCYIu0+QCfQgjAacHpi2dXusRvWTNCZO3nwSr88qm5oCbSKATRAMK/p/VPSKT6oT7OIe4VmdGjaVBGTfv9Et6pqIXis2z5m3OTHdkWPKewGPwnRzonhuzwVJdW1ASVwH7S8Rpsp2kvb7Syu3ex18Qt60lAAEj9KnHcbuqOSBGNtRg== 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=6o3ILcCIWqLfEBgzOO4npMJ9j0rWoU4kQ/wh+Dukeok=; b=cTQXabH+//47H9mcLmImUUzcQ2MHinxItUAyZFOb8Zw4k8mhWTFnzwoTQxeyb5Q0BkJ1IjN9v7+KhDHqDHM/tq2y7yzWOABUQy1UhzbZVaiAjrNSp7owpSgtlNgLJZ2a22WWSvW6acpO1U5ZTuHKBF6Xtw4zOkcL4xboqLMkX40= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none; driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SA0PR11MB4670.namprd11.prod.outlook.com (2603:10b6:806:9a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.23; Wed, 7 Oct 2020 10:20:10 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3433.044; Wed, 7 Oct 2020 10:20:10 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 4/7] staging: wfx: fix QoS priority for slow buses Date: Wed, 7 Oct 2020 12:19:40 +0200 Message-Id: <20201007101943.749898-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007101943.749898-1-Jerome.Pouiller@silabs.com> References: <20201007101943.749898-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: PR0P264CA0111.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::27) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.home (82.67.86.106) by PR0P264CA0111.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:19::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.23 via Frontend Transport; Wed, 7 Oct 2020 10:20:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 541e8a23-ee36-4005-7ac6-08d86aaa920b X-MS-TrafficTypeDiagnostic: SA0PR11MB4670: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IfN3WIrzhrVztlpYB4BYy59gQaGBEsbEM/Obn6K3NH4CKqFbPqKgW3ooUCI90PO8PPjdGPqnwDW+iMMAs0MShQ/RmD8KVoaaUJz0RBScffiLMF6ukQT3B/Xd8rvjkHjIgbdlzz1qIMj5Eb3E7qZAEDVQ8LLp6H1BVKkIokkqAx0I0ZJU0TeDTJQAUo6nONE1a9p9vPqxSSOa2iAFa7Rh7zvhkjl3JI3qchkfvK6U/7rQkHz2ZBQvHRfy/pJGWEPep3KnUR+pjXb7wYI+Ree0wYlEOA1StYlDa7ZBikhJw3rhkAdjbzNoE3EWc2JvFaa/ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB2718.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(39850400004)(346002)(136003)(376002)(366004)(396003)(66556008)(66476007)(6486002)(66946007)(316002)(54906003)(4326008)(478600001)(2906002)(1076003)(5660300002)(186003)(8936002)(8676002)(16526019)(52116002)(83380400001)(26005)(6506007)(66574015)(2616005)(86362001)(956004)(107886003)(8886007)(36756003)(6666004)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: VHGdQmD4bqjOXMlqXomi/u8plX5pn+ranfggQLYCNhk8mHyi7MT8B873vZA7q3+PLOAdK5e+Ru/e7BUxxzTJrvdwWNB0eYVjP8gDu/PCjxN6C+Hh26I1ZBKgTb9YmgJTZVHAC0VyFuLdVZZIGCKEinaHlNpZZrAxdwtxADG1oug2VysigSb0G9ps0iodEUAAnMMwyxLcSoILaAtWq4SWss9jTBo3gDghtElSW4qWAyL1uIcjvh/Exe3Hx5atDHn4PdPIyb/D9wHR6oUg7k7b/7LIwBXGhDnPaqUpJRjaVgabBZnNbIjSXexFUtLV9Vqt+nCe+KhLdQUECNBXHXqEDsgJTmgOrDiTOM3G+8hglVYg5pa8n5FhOHEkaI3qFb2kO2UlkJJzH9RXCoYjkfm9tDLLQhS+oHF+P5QGBcYU4Tmo5LelyVquyrJwYUV2bATyXtfPNCePiZpoPRF7K0g38gBRQnqMpH0dh+o8F3lCoNnGRjg3b4YpRcOBg9Rnq6SJdaLFeu+vPlw8DGPEskHyNjLWFb+OAYhujCKzuMVQRmMZovjenHMFE7BSWTOcA7q/yKMX1s6e+1d0De+fslk2rtZi3GBzPigS88KrzLwPMc2/118UVsjc1QZ0C3n0yUy/pE6B6HqemBa6JdOdG0GTuw== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 541e8a23-ee36-4005-7ac6-08d86aaa920b X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2020 10:20:10.2394 (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: 9LM2wDyWEsqmGBt00V7eRrOvn01XevOISUGRd7m0tXd1D/7N8P89G8hT+QP4JDM2PFcT3p+Q9cg4i7u55X6/bQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4670 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller The device is in charge of respecting the QoS constraints. The driver have to ensure that all the queues contain data and the device choose the right queue to send. The things starts to be more difficult when the bandwidth of the bus is lower than the bandwidth of the WiFi. The device quickly sends the frames of the highest priority queue. Then, it starts to send frames from a lower priority queue. Though, there are still some high priority frames waiting in the driver. To work around this problem, this patch add some priorities to each queue. The weigh of the queue was (roughly) calculated experimentally by checking the speed ratio of each queue when the bus does not limit the traffic: - Be/Bk -> 20Mbps/10Mbps - Vi/Be -> 36Mbps/180Kbps - Vo/Be -> 35Mbps/600Kbps - Vi/Vo -> 24Mbps/12Mbps So, if we fix the weigh of the Background to 1, the weight of Best Effort should be 2. The weight of Video should be 116. However, since there is only 32 queues, it make no sense to use a value greater than 64[1]. And finally, the weight of the Voice is set to 128. [1] Because of this approximation, with very slow bus, we can still observe frame starvation when we measure the speed ratio of Vi/Be. It is around 35Mbps/1Mbps (instead of 36Mbps/180Kbps). However, it is still in accepted error range. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/queue.c | 14 ++++++++++++-- drivers/staging/wfx/queue.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 6e3159165143..55b801a02959 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -60,11 +60,16 @@ void wfx_tx_lock_flush(struct wfx_dev *wdev) void wfx_tx_queues_init(struct wfx_vif *wvif) { + // The device is in charge to respect the details of the QoS parameters. + // The driver just ensure that it roughtly respect the priorities to + // avoid any shortage. + const int priorities[IEEE80211_NUM_ACS] = { 1, 2, 64, 128 }; int i; for (i = 0; i < IEEE80211_NUM_ACS; ++i) { skb_queue_head_init(&wvif->tx_queue[i].normal); skb_queue_head_init(&wvif->tx_queue[i].cab); + wvif->tx_queue[i].priority = priorities[i]; } } @@ -219,6 +224,11 @@ bool wfx_tx_queues_has_cab(struct wfx_vif *wvif) return false; } +static int wfx_tx_queue_get_weight(struct wfx_queue *queue) +{ + return atomic_read(&queue->pending_frames) * queue->priority; +} + static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) { struct wfx_queue *queues[IEEE80211_NUM_ACS * ARRAY_SIZE(wdev->vif)]; @@ -234,8 +244,8 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) WARN_ON(num_queues >= ARRAY_SIZE(queues)); queues[num_queues] = &wvif->tx_queue[i]; for (j = num_queues; j > 0; j--) - if (atomic_read(&queues[j]->pending_frames) < - atomic_read(&queues[j - 1]->pending_frames)) + if (wfx_tx_queue_get_weight(queues[j]) < + wfx_tx_queue_get_weight(queues[j - 1])) swap(queues[j - 1], queues[j]); num_queues++; } diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index 22d7c936907f..2695c10d6a22 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -18,6 +18,7 @@ struct wfx_queue { struct sk_buff_head normal; struct sk_buff_head cab; // Content After (DTIM) Beacon atomic_t pending_frames; + int priority; }; void wfx_tx_lock(struct wfx_dev *wdev);