Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp337450rwn; Thu, 8 Sep 2022 02:20:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR7UrBT+ciIfIDJUps2pmI/PJt4C5shFp3i2dRXCpHiAx4xonlyqxuGBsvCu4LlnR46m4FYF X-Received: by 2002:a63:8ac9:0:b0:435:783:ee5d with SMTP id y192-20020a638ac9000000b004350783ee5dmr4807911pgd.77.1662628859172; Thu, 08 Sep 2022 02:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662628859; cv=none; d=google.com; s=arc-20160816; b=C/O5wR0QdeHrt9CUZYPl34oAD0MxUOfywLjmUSAMPVf7t8ajALF4SzOCvU7z0zX+lm PMoTR+K22+Audi3UWKWadfkzJLifbPVm9sTts9+H3/sGkMr7zM7roc26nvHCb5bPh+ls QgTuSlx/6IbC1zhtyF2WooH0kqG5sNBV840BRlsf5tj0f9hwuljXP6Xe2urgEwumOf2X xj9bngWMiw1bVNZxGSO5EQ92DiUQxTpA/6LvwaIPFVNRI/uiLsjATijEy/4Ej0+y7/xD dMbIyaIoHmhDGPQtzJNCzAi+JTRvXHvnW+gJEgQNUtlfg9hbRuTZ8sYOLtv41iy4lWpj tIUw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZzgYwYTaKLuQbK5J8DyLAbM1g9ZBL7Rd6oqxsETGimw=; b=UoPCSeTkixO817RAFQRHy3smZ/prYiDhbHNQKf8GxK3EccYWlphO1Qasz4Xvym0+DW FythDZTHpaQQ+5yUFnDU3kg2DMWQJUhD9vjtOj9gE6cZ4nAFu5lWp6TzqVQ/5ZtdGYhE d8yHn52A6t9++2en1AAyDoGqa5qSaB9ayWPYF1lGSMMBlSRPXK9vTgrm7QdCqOguknSQ l9dgBOL/rHdLDXUSmFiLbrR3FtUkBR1IpCInBweH/WXJJV/yfkkJlx4ZUROvveMYXsMg 48E0AEKsvezpZcowtYHZTo0qF16TRIVHCgDbPn3ZcD/DchFGAnhx/+uH19thawyi3zR3 LDHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=UhJ02Hcf; 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=pass (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 o24-20020a63e358000000b0041a518712fbsi19371816pgj.542.2022.09.08.02.20.48; Thu, 08 Sep 2022 02:20:59 -0700 (PDT) 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=pass header.i=@microchip.com header.s=mchp header.b=UhJ02Hcf; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230280AbiIHI26 (ORCPT + 99 others); Thu, 8 Sep 2022 04:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbiIHI2x (ORCPT ); Thu, 8 Sep 2022 04:28:53 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50A2065261; Thu, 8 Sep 2022 01:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1662625733; x=1694161733; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vrAqCn0jfykHzJwc/hiNhKrO7efAl9Cz/8tuUkxVNys=; b=UhJ02HcfLeugZ/2w4FOg58+its7nPUhffPSyR2C8GDxJWoT/Ym2ROJzl HtKRYh940y4irquppLlBu1uF02zwozxWYwmBlE7PJO3EDiWstU44/ocOO aBLP3h6raJLEAw65QIaB5xjRv+hP8TtxzSMUdU1+aBoCfWPK+LK2Cq0lH vlFd2Tu/RrguquO5E/+X+vwfogqMdpgPq2vSby9umblIJrLBuvufVptJC S1vADQM+ZY1juygGIm4ZO8skMjH3zgHwVOwKpWtRz6ZDJLbMqN2cQz0ec joPbPb4KMmpPTjWxJ0G3/NaRtiMNTTSOKYGo1MKNweHQv1WqEjXtQ4L/u Q==; X-IronPort-AV: E=Sophos;i="5.93,299,1654585200"; d="scan'208";a="172912879" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 08 Sep 2022 01:28:52 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Thu, 8 Sep 2022 01:28:51 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Thu, 8 Sep 2022 01:28:48 -0700 From: Raju Lakkaraju To: CC: , , , , , Subject: [PATCH net-next V2 1/2] net: lan743x: Fix to use multiqueue start/stop APIs Date: Thu, 8 Sep 2022 13:58:33 +0530 Message-ID: <20220908082834.5070-2-Raju.Lakkaraju@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220908082834.5070-1-Raju.Lakkaraju@microchip.com> References: <20220908082834.5070-1-Raju.Lakkaraju@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 - Fix to use multiqueue start/stop APIs - Change to return NETDEV_TX_BUSY instead of holding the TX skb when busy - Increase Tx ring size to 128 to address performance issues in some platforms - Use NAPI_POLL_WEIGHT for Tx Napi handler instead of ring dependent value - Use multiqueue to register 4 Rx channels Signed-off-by: Raju Lakkaraju --- drivers/net/ethernet/microchip/lan743x_main.c | 50 +++++++++---------- drivers/net/ethernet/microchip/lan743x_main.h | 5 +- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index a9a1dea6d731..3f4e1ab63f8a 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -2066,11 +2066,13 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx, { int required_number_of_descriptors = 0; unsigned int start_frame_length = 0; + netdev_tx_t retval = NETDEV_TX_OK; unsigned int frame_length = 0; unsigned int head_length = 0; unsigned long irq_flags = 0; bool do_timestamp = false; bool ignore_sync = false; + struct netdev_queue *txq; int nr_frags = 0; bool gso = false; int j; @@ -2083,9 +2085,12 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx, if (required_number_of_descriptors > (tx->ring_size - 1)) { dev_kfree_skb_irq(skb); } else { - /* save to overflow buffer */ - tx->overflow_skb = skb; - netif_stop_queue(tx->adapter->netdev); + /* save how many descriptors we needed to restart the queue */ + tx->rqd_descriptors = required_number_of_descriptors; + retval = NETDEV_TX_BUSY; + txq = netdev_get_tx_queue(tx->adapter->netdev, + tx->channel_number); + netif_tx_stop_queue(txq); } goto unlock; } @@ -2144,15 +2149,15 @@ static netdev_tx_t lan743x_tx_xmit_frame(struct lan743x_tx *tx, unlock: spin_unlock_irqrestore(&tx->ring_lock, irq_flags); - return NETDEV_TX_OK; + return retval; } static int lan743x_tx_napi_poll(struct napi_struct *napi, int weight) { struct lan743x_tx *tx = container_of(napi, struct lan743x_tx, napi); struct lan743x_adapter *adapter = tx->adapter; - bool start_transmitter = false; unsigned long irq_flags = 0; + struct netdev_queue *txq; u32 ioc_bit = 0; ioc_bit = DMAC_INT_BIT_TX_IOC_(tx->channel_number); @@ -2163,24 +2168,20 @@ static int lan743x_tx_napi_poll(struct napi_struct *napi, int weight) /* clean up tx ring */ lan743x_tx_release_completed_descriptors(tx); - if (netif_queue_stopped(adapter->netdev)) { - if (tx->overflow_skb) { - if (lan743x_tx_get_desc_cnt(tx, tx->overflow_skb) <= - lan743x_tx_get_avail_desc(tx)) - start_transmitter = true; + txq = netdev_get_tx_queue(adapter->netdev, tx->channel_number); + if (netif_tx_queue_stopped(txq)) { + if (tx->rqd_descriptors) { + if (tx->rqd_descriptors <= + lan743x_tx_get_avail_desc(tx)) { + tx->rqd_descriptors = 0; + netif_tx_wake_queue(txq); + } } else { - netif_wake_queue(adapter->netdev); + netif_tx_wake_queue(txq); } } spin_unlock_irqrestore(&tx->ring_lock, irq_flags); - if (start_transmitter) { - /* space is now available, transmit overflow skb */ - lan743x_tx_xmit_frame(tx, tx->overflow_skb); - tx->overflow_skb = NULL; - netif_wake_queue(adapter->netdev); - } - if (!napi_complete(napi)) goto done; @@ -2304,10 +2305,7 @@ static void lan743x_tx_close(struct lan743x_tx *tx) lan743x_tx_release_all_descriptors(tx); - if (tx->overflow_skb) { - dev_kfree_skb(tx->overflow_skb); - tx->overflow_skb = NULL; - } + tx->rqd_descriptors = 0; lan743x_tx_ring_cleanup(tx); } @@ -2387,7 +2385,7 @@ static int lan743x_tx_open(struct lan743x_tx *tx) (tx->channel_number)); netif_napi_add_tx_weight(adapter->netdev, &tx->napi, lan743x_tx_napi_poll, - tx->ring_size - 1); + NAPI_POLL_WEIGHT); napi_enable(&tx->napi); data = 0; @@ -3347,8 +3345,10 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev, PCI11X1X_USED_TX_CHANNELS, LAN743X_USED_RX_CHANNELS); } else { - netdev = devm_alloc_etherdev(&pdev->dev, - sizeof(struct lan743x_adapter)); + netdev = devm_alloc_etherdev_mqs(&pdev->dev, + sizeof(struct lan743x_adapter), + LAN743X_USED_TX_CHANNELS, + LAN743X_USED_RX_CHANNELS); } if (!netdev) diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h index 72adae4f2aa0..58eb7abf976b 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.h +++ b/drivers/net/ethernet/microchip/lan743x_main.h @@ -954,8 +954,7 @@ struct lan743x_tx { struct napi_struct napi; u32 frame_count; - - struct sk_buff *overflow_skb; + u32 rqd_descriptors; }; void lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx, @@ -1110,7 +1109,7 @@ struct lan743x_tx_buffer_info { unsigned int buffer_length; }; -#define LAN743X_TX_RING_SIZE (50) +#define LAN743X_TX_RING_SIZE (128) /* OWN bit is set. ie, Descs are owned by RX DMAC */ #define RX_DESC_DATA0_OWN_ (0x00008000) -- 2.25.1