Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3240424pxp; Tue, 8 Mar 2022 10:11:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsrZQN+9TTG7wroeW3R5pSIemOl+VPVvoVxphgvxunY0N1L6eAXxAA+ziCOlPI2toDOYZy X-Received: by 2002:a17:907:3da0:b0:6da:8dbc:f4bc with SMTP id he32-20020a1709073da000b006da8dbcf4bcmr14262596ejc.708.1646763088792; Tue, 08 Mar 2022 10:11:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646763088; cv=none; d=google.com; s=arc-20160816; b=nJcrcooNDxyLzo/VTam2oeBUa0VtZHAlKiZPnB7gONDEwf+A86K61X5tdLBjZINuKM vaWFJtyXfs8HjQ8Ck8pScVklq8dtcUN5gJWr6PKq2VqrltmqBLx6t6moLoPVq36jgGjF FOhli0yRwFK1HPglNur5zk4qPNDJzBpNktDGfFGMpn+V0HxBXqzYcL+p+GR3AElYkcEn 8PA1xDPL8qeoG1t8HiIKXZxs/SLztLz9PuP2zkHbIMNbYXyw0uCxsx/4orbgvHMqQTlA ovCtHxE4jsOIQLvm0Mn3U5hmGGDCJH/QD4NRF3acITq7xY0CgCUmKkEpUVPhNep/ehwI Z+jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ggKiyjMqJXFqKN4cK84dHjlanN4Wy+dzFf9wKe88wWI=; b=LXobMNlb9yUYogujcNI37sq7hXRjWuGEZTZIv8R2+tKq5DEGq54B8dVLnK/jDzr7In L/1s5arVQRVpBlnR3QPBNGZibHz6v+kJmt26xy01Xz6UlaMr5jFsFuPKlVX67qMFsmGn dzuA5MZDP1kHQHC6m3gGGPhTDRNU+B+apuBW8YGlIIiamO/fLiJZN3VnWMirif0k1w4O 3US0SPUOu9cZ6XmfTuVaKsTEOpnppJr/vCo4GQfMm8fxFkgSL8PFexoAAYpT1f5Veop/ C5eSW+SIn0Cd63R9psV5UEo9GwynpKR98kFwp1YGOVzNhp65lVW+nXD0XNILusOYlXst BT+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=aTubupD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky1-20020a170907778100b006a98068f20bsi10090867ejc.420.2022.03.08.10.11.05; Tue, 08 Mar 2022 10:11:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=aTubupD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348118AbiCHQ4D (ORCPT + 99 others); Tue, 8 Mar 2022 11:56:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345576AbiCHQ4C (ORCPT ); Tue, 8 Mar 2022 11:56:02 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 190964ECF9; Tue, 8 Mar 2022 08:55:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646758505; x=1678294505; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6C2mZ4cPAPhBiwzAinOa3KOV00eNAxZd7Qi1+RwReUs=; b=aTubupD8D5HKsnE67ZLaQjaNN214lw3UGfxIuKW46Kzoldvkayl5bQPS GwlpMF5/vtbsGBQ6/zEc14f5pPDBP6n//ezAwHuBgw3rPXQjDS3mjTwYv NEA1yseutes3wTD6HsG3RWqXxKH2AMkcj2hJ1h49Rv7HxpQHcSCPo0a3G IkRXPCe8L7+2MbxcwjMXjaRBSf2dfNEKxc2faUAD43wL+MAZm6JQTcqNo LQgFXAOfYaIsGmzIu40Oz3DkH2GAO7HxXOrRMVud89VOgNxgTofoL3uke hAfNCWB0DKw+XkstiD3iPdKperjpaDlefceJ4b3JngwIZod2/mgMPn+LS w==; X-IronPort-AV: E=Sophos;i="5.90,165,1643698800"; d="scan'208";a="88232263" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 08 Mar 2022 09:55:05 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 8 Mar 2022 09:55:05 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 8 Mar 2022 09:55:03 -0700 From: Horatiu Vultur To: , CC: , , , Horatiu Vultur Subject: [PATCH net-next] net: lan966x: Improve the CPU TX bitrate. Date: Tue, 8 Mar 2022 17:57:27 +0100 Message-ID: <20220308165727.4088656-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_PERMERROR autolearn=ham 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 Replace 'readx_poll_timeout_atomic' with a simple while loop + timeout when checking if it is possible to write to the HW the next word of the frame. Doing this will improve the TX bitrate by 65%. The measurements were done using iperf3. Before: [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.03 sec 55.2 MBytes 46.2 Mbits/sec 0 sender [ 5] 0.00-10.04 sec 53.8 MBytes 45.0 Mbits/sec receiver After: [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.02 sec 91.4 MBytes 76.6 Mbits/sec 0 sender [ 5] 0.00-10.03 sec 90.2 MBytes 75.5 Mbits/sec receiver Signed-off-by: Horatiu Vultur --- .../ethernet/microchip/lan966x/lan966x_main.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 81c01665d01e..f6cef29b9d36 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -176,18 +176,20 @@ static int lan966x_port_stop(struct net_device *dev) return 0; } -static int lan966x_port_inj_status(struct lan966x *lan966x) -{ - return lan_rd(lan966x, QS_INJ_STATUS); -} - static int lan966x_port_inj_ready(struct lan966x *lan966x, u8 grp) { - u32 val; + unsigned long time = jiffies + usecs_to_jiffies(READL_TIMEOUT_US); + int ret = 0; - return readx_poll_timeout_atomic(lan966x_port_inj_status, lan966x, val, - QS_INJ_STATUS_FIFO_RDY_GET(val) & BIT(grp), - READL_SLEEP_US, READL_TIMEOUT_US); + while (!(lan_rd(lan966x, QS_INJ_STATUS) & + QS_INJ_STATUS_FIFO_RDY_SET(BIT(grp)))) { + if (time_after(jiffies, time)) { + ret = -ETIMEDOUT; + break; + } + } + + return ret; } static int lan966x_port_ifh_xmit(struct sk_buff *skb, -- 2.33.0