From patchwork Fri Jan 29 19:52:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 12056461 X-Patchwork-Delegate: kuba@kernel.org 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=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 D22A2C433E0 for ; Fri, 29 Jan 2021 20:10:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74F7264E04 for ; Fri, 29 Jan 2021 20:10:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233058AbhA2UKf (ORCPT ); Fri, 29 Jan 2021 15:10:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233117AbhA2Tx1 (ORCPT ); Fri, 29 Jan 2021 14:53:27 -0500 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70E0CC061574; Fri, 29 Jan 2021 11:52:47 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id c1so7609112qtc.1; Fri, 29 Jan 2021 11:52:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NJl5nz8B/w9PQNydomJXvK6cYumU20h6AeRMSE4OuRY=; b=Z4hRnb2+wLp/gRainOiF00YxS3+yTjNJd4EKhPaqLliRLKU+sJYqDhF1XbTE7EcHLf GP9EiyQkG8/2difzGDPC/RfnN4t1nRv2Bi57IJv9cI1kFwLtY6/RzU//2fusE89xSZqN V2UaKUErnK6e1b/KutXG/F3ZWIJiiPFaJ4db9mF009X5zt6OAW2h1c5OcbH/UG4gksfG e3mm/ZNQGBMUq2a/ejFcxPItT7szMDRIvF4aPc6u4B/KOjSrQZwqry5y0aDAMCrlLBA2 pWia7OqwqIQKTa36Q26W38VmzG914xkXYkEUlaH6x9u5FXUZXmjLRo9+sK9LYqF79HLn IWuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NJl5nz8B/w9PQNydomJXvK6cYumU20h6AeRMSE4OuRY=; b=Wk7vprXKDc3Y9d3a2/22bFwix0mMCzwwgwPMKbZdNgRwaG2S4CBrgWOnNCmlQGTkGO QqMrfYdo+xvKgeWzdq5B1/B00xE+gyyUk7vNtIgTcApibwpMguxMRKzNBcmxSW4vKx+r n6ti+SpiWH79acPDWP24Y80oEBmkmBh9wwd21PvIEFa+V+fUUHJ/6t1ht1xfLyvfZ+JH 0KPmTyArXZM+11acfEmJUpLPFyRu6F/VBC3IFiDIKm8OOz6vi0/Bxl8khNHLlgUooLac WmI1Cx0zHpE//q9wORvTcAkI3AZQ7615p4OxiFkAfuzBI9lMt2rxsEOvnV0h4G3A8DQM jz8w== X-Gm-Message-State: AOAM530aiC4TcxMhvwNzwigqwSWfD13LOS998IXYOqOvtSevMkp/jHvn AEvGUlB4Xd2qmG1DeQ6WQVg= X-Google-Smtp-Source: ABdhPJwZcm0Fzs4yHPrOetfFJ86vdEXNFDDTJL6A1CHzbqQk+515R57/ojaHBAT2hDPbEwtT79296Q== X-Received: by 2002:ac8:370b:: with SMTP id o11mr6014792qtb.314.1611949966450; Fri, 29 Jan 2021 11:52:46 -0800 (PST) Received: from localhost.localdomain ([198.52.185.246]) by smtp.gmail.com with ESMTPSA id s136sm6558994qka.106.2021.01.29.11.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 11:52:46 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Bryan Whitehead , UNGLinuxDriver@microchip.com, David S Miller , Jakub Kicinski Cc: Sven Van Asbroeck , Andrew Lunn , Alexey Denisov , Sergej Bauer , Tim Harvey , =?utf-8?q?Anders_R=C3=B8nningen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v1 1/6] lan743x: boost performance on cpu archs w/o dma cache snooping Date: Fri, 29 Jan 2021 14:52:35 -0500 Message-Id: <20210129195240.31871-2-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210129195240.31871-1-TheSven73@gmail.com> References: <20210129195240.31871-1-TheSven73@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sven Van Asbroeck The buffers in the lan743x driver's receive ring are always 9K, even when the largest packet that can be received (the mtu) is much smaller. This performs particularly badly on cpu archs without dma cache snooping (such as ARM): each received packet results in a 9K dma_{map|unmap} operation, which is very expensive because cpu caches need to be invalidated. Careful measurement of the driver rx path on armv7 reveals that the cpu spends the majority of its time waiting for cache invalidation. Optimize as follows: 1. set rx ring buffer size equal to the mtu. this limits the amount of cache that needs to be invalidated per dma_map(). 2. when dma_unmap()ping, skip cpu sync. Sync only the packet data actually received, the size of which the chip will indicate in its rx ring descriptors. this limits the amount of cache that needs to be invalidated per dma_unmap(). These optimizations double the rx performance on armv7. Third parties report 3x rx speedup on armv8. Performance on dma cache snooping architectures (such as x86) is expected to stay the same. Tested with iperf3 on a freescale imx6qp + lan7430, both sides set to mtu 1500 bytes, measure rx performance: Before: [ ID] Interval Transfer Bandwidth Retr [ 4] 0.00-20.00 sec 550 MBytes 231 Mbits/sec 0 After: [ ID] Interval Transfer Bandwidth Retr [ 4] 0.00-20.00 sec 1.33 GBytes 570 Mbits/sec 0 Test by Anders Roenningen (anders@ronningen.priv.no) on armv8, rx iperf3: Before 102 Mbits/sec After 279 Mbits/sec Signed-off-by: Sven Van Asbroeck --- Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git # 46eb3c108fe1 To: Bryan Whitehead To: UNGLinuxDriver@microchip.com To: "David S. Miller" To: Jakub Kicinski Cc: Andrew Lunn Cc: Alexey Denisov Cc: Sergej Bauer Cc: Tim Harvey Cc: Anders Rønningen Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) drivers/net/ethernet/microchip/lan743x_main.c | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index f1f6eba4ace4..f485320e5784 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1957,11 +1957,11 @@ static int lan743x_rx_next_index(struct lan743x_rx *rx, int index) static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx) { - int length = 0; + struct net_device *netdev = rx->adapter->netdev; - length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING); - return __netdev_alloc_skb(rx->adapter->netdev, - length, GFP_ATOMIC | GFP_DMA); + return __netdev_alloc_skb(netdev, + netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING, + GFP_ATOMIC | GFP_DMA); } static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) @@ -1977,9 +1977,10 @@ static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, { struct lan743x_rx_buffer_info *buffer_info; struct lan743x_rx_descriptor *descriptor; - int length = 0; + struct net_device *netdev = rx->adapter->netdev; + int length; - length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING); + length = netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING; descriptor = &rx->ring_cpu_ptr[index]; buffer_info = &rx->buffer_info[index]; buffer_info->skb = skb; @@ -2148,11 +2149,18 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx) descriptor = &rx->ring_cpu_ptr[first_index]; /* unmap from dma */ + packet_length = RX_DESC_DATA0_FRAME_LENGTH_GET_ + (descriptor->data0); if (buffer_info->dma_ptr) { - dma_unmap_single(&rx->adapter->pdev->dev, - buffer_info->dma_ptr, - buffer_info->buffer_length, - DMA_FROM_DEVICE); + dma_sync_single_for_cpu(&rx->adapter->pdev->dev, + buffer_info->dma_ptr, + packet_length, + DMA_FROM_DEVICE); + dma_unmap_single_attrs(&rx->adapter->pdev->dev, + buffer_info->dma_ptr, + buffer_info->buffer_length, + DMA_FROM_DEVICE, + DMA_ATTR_SKIP_CPU_SYNC); buffer_info->dma_ptr = 0; buffer_info->buffer_length = 0; } @@ -2167,8 +2175,8 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx) int index = first_index; /* multi buffer packet not supported */ - /* this should not happen since - * buffers are allocated to be at least jumbo size + /* this should not happen since buffers are allocated + * to be at least the mtu size configured in the mac. */ /* clean up buffers */ @@ -2628,6 +2636,9 @@ static int lan743x_netdev_change_mtu(struct net_device *netdev, int new_mtu) struct lan743x_adapter *adapter = netdev_priv(netdev); int ret = 0; + if (netif_running(netdev)) + return -EBUSY; + ret = lan743x_mac_set_mtu(adapter, new_mtu); if (!ret) netdev->mtu = new_mtu; From patchwork Fri Jan 29 19:52:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 12056443 X-Patchwork-Delegate: kuba@kernel.org 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=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 6AD5EC433DB for ; Fri, 29 Jan 2021 19:55:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1601264DE1 for ; Fri, 29 Jan 2021 19:55:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233066AbhA2TzX (ORCPT ); Fri, 29 Jan 2021 14:55:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233120AbhA2Tx3 (ORCPT ); Fri, 29 Jan 2021 14:53:29 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C37ADC06174A; Fri, 29 Jan 2021 11:52:48 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id t17so7598620qtq.2; Fri, 29 Jan 2021 11:52:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wZUDEcYeUWqVsTyaSGiJjQzVWLFvK2gANMka41D/0Kc=; b=PDlkGC5vsd8xZoycvu/npOr/3CygFdULWtje7Xe8pRoeGHUQP4QTLYvX1HNIq48MiM 2P3VZ83UPwtrMdEJpsptoXvsrc0H8rBzGloh2BejRDKk3EALRlSxDE4ri7Ii+ZPAnOr8 f3+4M8LR6ltvVAyMtnuFrgAmi51/zSN2cLVQoa1JWlK2+bJ3YOfl+QRp+DCnCBThSIaG KIvKjxOEAdYBYiU6ElmUjC7012LDP0Tdn7f90UXlnVfYwFTm1XHMuXVE9usZ25wk5wLt bTdTtW6YKteEHHDjGvll+r+fM4bjeiqX48oM1bJ0a7hVWW7C+07tKm3SJyCerrsRcDps iphw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wZUDEcYeUWqVsTyaSGiJjQzVWLFvK2gANMka41D/0Kc=; b=qFM+Yp1b01ndaH69CKBiQfjpef9tVxGFcLMPzNP3LDOhVw0/+QbOS9qjnPVuV67sid 9cVpWUtgLlH5ky1en0tiT9obh6mimOsZwdIcun1Ny63J6mXhedmkqBxvU9mbcJ0GxTuo IMELfCY4Rbpdr6lQ4EfpwdRNdn1/60bv+m9ZN3O7DLrfzULpRMnmqQG2BBozTarhbwam gj6/1ceIgJ8eyZ2asoF/AyLhFMtIZdeEVC+eh/ptngSxWXQ/J5H8vCOzEwSRWdJV2KO3 2rTnDLiDA+wiDLd0xzsltOBuRLixzaRDp9d/bxOpHVvLpU/irKcXjSIvHbfg5BYxoZTv ozPg== X-Gm-Message-State: AOAM531VkS4rvoyDoIwx4SNua2JX4DiZlQEwwlOP+mi8A5aOmPxvYVq4 cbK1KjiPgqVNZgyfPFBs0C6SfNhazXvGMg== X-Google-Smtp-Source: ABdhPJxiSr7iZVRJcvI2Nn1D6+z3fZENSDse9Jtbi+5pc3Gw7QWeA8bsQUZf0Lr+gqIFpH7SyKfsaA== X-Received: by 2002:ac8:5985:: with SMTP id e5mr5866684qte.160.1611949967762; Fri, 29 Jan 2021 11:52:47 -0800 (PST) Received: from localhost.localdomain ([198.52.185.246]) by smtp.gmail.com with ESMTPSA id s136sm6558994qka.106.2021.01.29.11.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 11:52:47 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Bryan Whitehead , UNGLinuxDriver@microchip.com, David S Miller , Jakub Kicinski Cc: Sven Van Asbroeck , Andrew Lunn , Alexey Denisov , Sergej Bauer , Tim Harvey , =?utf-8?q?Anders_R=C3=B8nningen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v1 2/6] lan743x: support rx multi-buffer packets Date: Fri, 29 Jan 2021 14:52:36 -0500 Message-Id: <20210129195240.31871-3-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210129195240.31871-1-TheSven73@gmail.com> References: <20210129195240.31871-1-TheSven73@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sven Van Asbroeck Multi-buffer packets enable us to use rx ring buffers smaller than the mtu. This will allow us to change the mtu on-the-fly, without having to stop the network interface in order to re-size the rx ring buffers. This is a big change touching a key driver function (process_packet), so care has been taken to test this extensively: Tests with debug logging enabled (add #define DEBUG). 1. Limit rx buffer size to 500, so mtu (1500) takes 3 buffers. Ping to chip, verify correct packet size is sent to OS. Ping large packets to chip (ping -s 1400), verify correct packet size is sent to OS. Ping using packets around the buffer size, verify number of buffers is changing, verify correct packet size is sent to OS: $ ping -s 472 $ ping -s 473 $ ping -s 992 $ ping -s 993 Verify that each packet is followed by extension processing. 2. Limit rx buffer size to 500, so mtu (1500) takes 3 buffers. Run iperf3 -s on chip, verify that packets come in 3 buffers at a time. Verify that packet size is equal to mtu. Verify that each packet is followed by extension processing. 3. Set chip and host mtu to 2000. Limit rx buffer size to 500, so mtu (2000) takes 4 buffers. Run iperf3 -s on chip, verify that packets come in 4 buffers at a time. Verify that packet size is equal to mtu. Verify that each packet is followed by extension processing. Tests with debug logging DISabled (remove #define DEBUG). 4. Limit rx buffer size to 500, so mtu (1500) takes 3 buffers. Run iperf3 -s on chip, note sustained rx speed. Set chip and host mtu to 2000, so mtu takes 4 buffers. Run iperf3 -s on chip, note sustained rx speed. Verify no packets are dropped in both cases. Tests with DEBUG_KMEMLEAK on: $ mount -t debugfs nodev /sys/kernel/debug/ $ echo scan > /sys/kernel/debug/kmemleak 5. Limit rx buffer size to 500, so mtu (1500) takes 3 buffers. Run the following tests concurrently for at least one hour: - iperf3 -s on chip - ping -> chip Monitor reported memory leaks. 6. Set chip and host mtu to 2000. Limit rx buffer size to 500, so mtu (2000) takes 4 buffers. Run the following tests concurrently for at least one hour: - iperf3 -s on chip - ping -> chip Monitor reported memory leaks. 7. Simulate low-memory in lan743x_rx_allocate_skb(): fail every 100 allocations. Repeat (5) and (6). Monitor reported memory leaks. 8. Simulate low-memory in lan743x_rx_allocate_skb(): fail 10 allocations in a row in every 100. Repeat (5) and (6). Monitor reported memory leaks. 9. Simulate low-memory in lan743x_rx_trim_skb(): fail 1 allocation in every 100. Repeat (5) and (6). Monitor reported memory leaks. Signed-off-by: Sven Van Asbroeck --- Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git # 46eb3c108fe1 To: Bryan Whitehead To: UNGLinuxDriver@microchip.com To: "David S. Miller" To: Jakub Kicinski Cc: Andrew Lunn Cc: Alexey Denisov Cc: Sergej Bauer Cc: Tim Harvey Cc: Anders Rønningen Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) drivers/net/ethernet/microchip/lan743x_main.c | 321 ++++++++---------- drivers/net/ethernet/microchip/lan743x_main.h | 2 + 2 files changed, 143 insertions(+), 180 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index f485320e5784..b784e9feadac 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1955,15 +1955,6 @@ static int lan743x_rx_next_index(struct lan743x_rx *rx, int index) return ((++index) % rx->ring_size); } -static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx) -{ - struct net_device *netdev = rx->adapter->netdev; - - return __netdev_alloc_skb(netdev, - netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING, - GFP_ATOMIC | GFP_DMA); -} - static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) { /* update the tail once per 8 descriptors */ @@ -1972,37 +1963,37 @@ static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) index); } -static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, - struct sk_buff *skb) +static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index) { + struct net_device *netdev = rx->adapter->netdev; + struct device *dev = &rx->adapter->pdev->dev; struct lan743x_rx_buffer_info *buffer_info; struct lan743x_rx_descriptor *descriptor; - struct net_device *netdev = rx->adapter->netdev; + struct sk_buff *skb; + dma_addr_t dma_ptr; int length; length = netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING; + descriptor = &rx->ring_cpu_ptr[index]; buffer_info = &rx->buffer_info[index]; - buffer_info->skb = skb; - if (!(buffer_info->skb)) + skb = __netdev_alloc_skb(netdev, length, GFP_ATOMIC | GFP_DMA); + if (!skb) return -ENOMEM; - buffer_info->dma_ptr = dma_map_single(&rx->adapter->pdev->dev, - buffer_info->skb->data, - length, - DMA_FROM_DEVICE); - if (dma_mapping_error(&rx->adapter->pdev->dev, - buffer_info->dma_ptr)) { - buffer_info->dma_ptr = 0; + dma_ptr = dma_map_single(dev, skb->data, length, DMA_FROM_DEVICE); + if (dma_mapping_error(dev, dma_ptr)) { + dev_kfree_skb_any(skb); return -ENOMEM; } + buffer_info->skb = skb; + buffer_info->dma_ptr = dma_ptr; buffer_info->buffer_length = length; descriptor->data1 = cpu_to_le32(DMA_ADDR_LOW32(buffer_info->dma_ptr)); descriptor->data2 = cpu_to_le32(DMA_ADDR_HIGH32(buffer_info->dma_ptr)); descriptor->data3 = 0; descriptor->data0 = cpu_to_le32((RX_DESC_DATA0_OWN_ | (length & RX_DESC_DATA0_BUF_LENGTH_MASK_))); - skb_reserve(buffer_info->skb, RX_HEAD_PADDING); lan743x_rx_update_tail(rx, index); return 0; @@ -2051,16 +2042,32 @@ static void lan743x_rx_release_ring_element(struct lan743x_rx *rx, int index) memset(buffer_info, 0, sizeof(*buffer_info)); } +static struct sk_buff * +lan743x_rx_trim_skb(struct sk_buff *skb, int frame_length) +{ + if (skb_linearize(skb)) { + dev_kfree_skb_irq(skb); + return NULL; + } + frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2); + if (skb->len > frame_length) { + skb->tail -= skb->len - frame_length; + skb->len = frame_length; + } + return skb; +} + static int lan743x_rx_process_packet(struct lan743x_rx *rx) { - struct skb_shared_hwtstamps *hwtstamps = NULL; + struct lan743x_rx_descriptor *descriptor, *desc_ext; int result = RX_PROCESS_RESULT_NOTHING_TO_DO; int current_head_index = le32_to_cpu(*rx->head_cpu_ptr); struct lan743x_rx_buffer_info *buffer_info; - struct lan743x_rx_descriptor *descriptor; + struct skb_shared_hwtstamps *hwtstamps; + int frame_length, buffer_length; + struct sk_buff *skb; int extension_index = -1; - int first_index = -1; - int last_index = -1; + bool is_last, is_first; if (current_head_index < 0 || current_head_index >= rx->ring_size) goto done; @@ -2068,170 +2075,126 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx) if (rx->last_head < 0 || rx->last_head >= rx->ring_size) goto done; - if (rx->last_head != current_head_index) { - descriptor = &rx->ring_cpu_ptr[rx->last_head]; - if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_OWN_) - goto done; + if (rx->last_head == current_head_index) + goto done; - if (!(le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_FS_)) - goto done; + descriptor = &rx->ring_cpu_ptr[rx->last_head]; + if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_OWN_) + goto done; + buffer_info = &rx->buffer_info[rx->last_head]; - first_index = rx->last_head; - if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_LS_) { - last_index = rx->last_head; - } else { - int index; - - index = lan743x_rx_next_index(rx, first_index); - while (index != current_head_index) { - descriptor = &rx->ring_cpu_ptr[index]; - if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_OWN_) - goto done; - - if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_LS_) { - last_index = index; - break; - } - index = lan743x_rx_next_index(rx, index); - } - } - if (last_index >= 0) { - descriptor = &rx->ring_cpu_ptr[last_index]; - if (le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_EXT_) { - /* extension is expected to follow */ - int index = lan743x_rx_next_index(rx, - last_index); - if (index != current_head_index) { - descriptor = &rx->ring_cpu_ptr[index]; - if (le32_to_cpu(descriptor->data0) & - RX_DESC_DATA0_OWN_) { - goto done; - } - if (le32_to_cpu(descriptor->data0) & - RX_DESC_DATA0_EXT_) { - extension_index = index; - } else { - goto done; - } - } else { - /* extension is not yet available */ - /* prevent processing of this packet */ - first_index = -1; - last_index = -1; - } - } - } + is_last = le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_LS_; + is_first = le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_FS_; + + if (is_last && le32_to_cpu(descriptor->data0) & RX_DESC_DATA0_EXT_) { + /* extension is expected to follow */ + int index = lan743x_rx_next_index(rx, rx->last_head); + + if (index == current_head_index) + /* extension not yet available */ + goto done; + desc_ext = &rx->ring_cpu_ptr[index]; + if (le32_to_cpu(desc_ext->data0) & RX_DESC_DATA0_OWN_) + /* extension not yet available */ + goto done; + if (!(le32_to_cpu(desc_ext->data0) & RX_DESC_DATA0_EXT_)) + goto move_forward; + extension_index = index; } - if (first_index >= 0 && last_index >= 0) { - int real_last_index = last_index; - struct sk_buff *skb = NULL; - u32 ts_sec = 0; - u32 ts_nsec = 0; - - /* packet is available */ - if (first_index == last_index) { - /* single buffer packet */ - struct sk_buff *new_skb = NULL; - int packet_length; - - new_skb = lan743x_rx_allocate_skb(rx); - if (!new_skb) { - /* failed to allocate next skb. - * Memory is very low. - * Drop this packet and reuse buffer. - */ - lan743x_rx_reuse_ring_element(rx, first_index); - goto process_extension; - } - buffer_info = &rx->buffer_info[first_index]; - skb = buffer_info->skb; - descriptor = &rx->ring_cpu_ptr[first_index]; - - /* unmap from dma */ - packet_length = RX_DESC_DATA0_FRAME_LENGTH_GET_ - (descriptor->data0); - if (buffer_info->dma_ptr) { - dma_sync_single_for_cpu(&rx->adapter->pdev->dev, - buffer_info->dma_ptr, - packet_length, - DMA_FROM_DEVICE); - dma_unmap_single_attrs(&rx->adapter->pdev->dev, - buffer_info->dma_ptr, - buffer_info->buffer_length, - DMA_FROM_DEVICE, - DMA_ATTR_SKIP_CPU_SYNC); - buffer_info->dma_ptr = 0; - buffer_info->buffer_length = 0; - } - buffer_info->skb = NULL; - packet_length = RX_DESC_DATA0_FRAME_LENGTH_GET_ - (le32_to_cpu(descriptor->data0)); - skb_put(skb, packet_length - 4); - skb->protocol = eth_type_trans(skb, - rx->adapter->netdev); - lan743x_rx_init_ring_element(rx, first_index, new_skb); - } else { - int index = first_index; + /* Only the last buffer in a multi-buffer frame contains the total frame + * length. All other buffers have a zero frame length. The chip + * occasionally sends more buffers than strictly required to reach the + * total frame length. + * Handle this by adding all buffers to the skb in their entirety. + * Once the real frame length is known, trim the skb. + */ + frame_length = + RX_DESC_DATA0_FRAME_LENGTH_GET_(le32_to_cpu(descriptor->data0)); + buffer_length = buffer_info->buffer_length; - /* multi buffer packet not supported */ - /* this should not happen since buffers are allocated - * to be at least the mtu size configured in the mac. - */ + netdev_dbg(rx->adapter->netdev, "%s%schunk: %d/%d", + is_first ? "first " : " ", + is_last ? "last " : " ", + frame_length, buffer_length); - /* clean up buffers */ - if (first_index <= last_index) { - while ((index >= first_index) && - (index <= last_index)) { - lan743x_rx_reuse_ring_element(rx, - index); - index = lan743x_rx_next_index(rx, - index); - } - } else { - while ((index >= first_index) || - (index <= last_index)) { - lan743x_rx_reuse_ring_element(rx, - index); - index = lan743x_rx_next_index(rx, - index); - } - } - } + /* unmap from dma */ + if (buffer_info->dma_ptr) { + dma_unmap_single(&rx->adapter->pdev->dev, + buffer_info->dma_ptr, + buffer_info->buffer_length, + DMA_FROM_DEVICE); + buffer_info->dma_ptr = 0; + buffer_info->buffer_length = 0; + } + skb = buffer_info->skb; -process_extension: - if (extension_index >= 0) { - descriptor = &rx->ring_cpu_ptr[extension_index]; - buffer_info = &rx->buffer_info[extension_index]; - - ts_sec = le32_to_cpu(descriptor->data1); - ts_nsec = (le32_to_cpu(descriptor->data2) & - RX_DESC_DATA2_TS_NS_MASK_); - lan743x_rx_reuse_ring_element(rx, extension_index); - real_last_index = extension_index; - } + /* allocate new skb and map to dma */ + if (lan743x_rx_init_ring_element(rx, rx->last_head)) { + /* failed to allocate next skb. + * Memory is very low. + * Drop this packet and reuse buffer. + */ + lan743x_rx_reuse_ring_element(rx, rx->last_head); + goto process_extension; + } + + /* add buffers to skb via skb->frag_list */ + if (is_first) { + skb_reserve(skb, RX_HEAD_PADDING); + skb_put(skb, buffer_length - RX_HEAD_PADDING); + if (rx->skb_head) + dev_kfree_skb_irq(rx->skb_head); + rx->skb_head = skb; + } else if (rx->skb_head) { + skb_put(skb, buffer_length); + if (skb_shinfo(rx->skb_head)->frag_list) + rx->skb_tail->next = skb; + else + skb_shinfo(rx->skb_head)->frag_list = skb; + rx->skb_tail = skb; + rx->skb_head->len += skb->len; + rx->skb_head->data_len += skb->len; + rx->skb_head->truesize += skb->truesize; + } else { + rx->skb_head = skb; + } - if (!skb) { - result = RX_PROCESS_RESULT_PACKET_DROPPED; - goto move_forward; +process_extension: + if (extension_index >= 0) { + u32 ts_sec; + u32 ts_nsec; + + ts_sec = le32_to_cpu(desc_ext->data1); + ts_nsec = (le32_to_cpu(desc_ext->data2) & + RX_DESC_DATA2_TS_NS_MASK_); + if (rx->skb_head) { + hwtstamps = skb_hwtstamps(rx->skb_head); + if (hwtstamps) + hwtstamps->hwtstamp = ktime_set(ts_sec, ts_nsec); } + lan743x_rx_reuse_ring_element(rx, extension_index); + rx->last_head = extension_index; + netdev_dbg(rx->adapter->netdev, "process extension"); + } - if (extension_index < 0) - goto pass_packet_to_os; - hwtstamps = skb_hwtstamps(skb); - if (hwtstamps) - hwtstamps->hwtstamp = ktime_set(ts_sec, ts_nsec); + if (is_last && rx->skb_head) + rx->skb_head = lan743x_rx_trim_skb(rx->skb_head, frame_length); -pass_packet_to_os: - /* pass packet to OS */ - napi_gro_receive(&rx->napi, skb); - result = RX_PROCESS_RESULT_PACKET_RECEIVED; + if (is_last && rx->skb_head) { + rx->skb_head->protocol = eth_type_trans(rx->skb_head, + rx->adapter->netdev); + netdev_dbg(rx->adapter->netdev, "sending %d byte frame to OS", + rx->skb_head->len); + napi_gro_receive(&rx->napi, rx->skb_head); + rx->skb_head = NULL; + } move_forward: - /* push tail and head forward */ - rx->last_tail = real_last_index; - rx->last_head = lan743x_rx_next_index(rx, real_last_index); - } + /* push tail and head forward */ + rx->last_tail = rx->last_head; + rx->last_head = lan743x_rx_next_index(rx, rx->last_head); + result = RX_PROCESS_RESULT_PACKET_RECEIVED; done: return result; } @@ -2367,9 +2330,7 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx) rx->last_head = 0; for (index = 0; index < rx->ring_size; index++) { - struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx); - - ret = lan743x_rx_init_ring_element(rx, index, new_skb); + ret = lan743x_rx_init_ring_element(rx, index); if (ret) goto cleanup; } diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h index 751f2bc9ce84..17e31a6210c6 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.h +++ b/drivers/net/ethernet/microchip/lan743x_main.h @@ -698,6 +698,8 @@ struct lan743x_rx { struct napi_struct napi; u32 frame_count; + + struct sk_buff *skb_head, *skb_tail; }; struct lan743x_adapter { From patchwork Fri Jan 29 19:52:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 12056457 X-Patchwork-Delegate: kuba@kernel.org 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=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 12917C433E0 for ; Fri, 29 Jan 2021 20:08:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB6CA64E04 for ; Fri, 29 Jan 2021 20:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233219AbhA2UIK (ORCPT ); Fri, 29 Jan 2021 15:08:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233125AbhA2Txa (ORCPT ); Fri, 29 Jan 2021 14:53:30 -0500 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1B92C061756; Fri, 29 Jan 2021 11:52:49 -0800 (PST) Received: by mail-qt1-x835.google.com with SMTP id c12so7586211qtv.5; Fri, 29 Jan 2021 11:52:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ut9QqJ8Bb2FrztE7bn3aXbtZ5BLxMG2sx0NSSH/xwUI=; b=aBMO+pWmEC7z/EWnOcanV6rSfEWJC7TZQLc/1Nqaz73cldyCBvuHpJ3S/fCGuSyBAH jR2SiKDWY8jF2Etdz8O/Q1ePhaTxIxewlyVF/3y/1taDyC0O031wNSbfDet9IUJfDxaW 3/BoyyJoLLxBhNkbmdrkDQeGwM4rRyzS7Jffg3AVV986EZpesGzmto9WEoxivkn2x4ZS w7DBEon6sXZlRWXI+Q12Ownrjjat15+ebKFKKH3avwvuOx6cOcFuagTAajMCssmpcXW8 ww1rdtSnMJyTt6b/n+2YDMiZbknJ/X+1rQgbQQkTgrQQq8aP/WaXGiX4uhOiTMf9pJol FVsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ut9QqJ8Bb2FrztE7bn3aXbtZ5BLxMG2sx0NSSH/xwUI=; b=gp6xPOLI+/Mh41S+B7vBmF9MQRUTgeY7Wn7ZvE3xOsQ3UWjxi3t8wECoT311Lr1qHj VNXx5RK6tjP0o1kdhur6n+4VGqF6t3EXjtbUp5jz55V/jZYjlqT+nr4FvfYikzKGbOF7 iQ34OiMrISRm5XX3uSJuZBW9vis54Xw/2htxP3TZHSFHpAJ1d1qjC90ddCw/hrIHL7e1 LoGGwKwnSEOrsa/PnI7e1g/YYlolnImGElUKuCWVrYQ4lJj/g+LB33SZvWKfiC6KYyjJ 42UKt4eA45MVo33jeD2Fj2upR87a0QSW8inr0UXPgtRk9otoSZBokBmJi/N7jMQC9fQI /yHQ== X-Gm-Message-State: AOAM532BQiL2EYWjFquvbk75IUhg1VNhOKH+7XRjWf6LVsKhRMor97K5 QpSxC5E+hF0W54WipIFMVdA= X-Google-Smtp-Source: ABdhPJyCh48VoqMVC68j0pVhLy16N2ITDMDSP87kz509b1sCqaiQTT9AwAOCG9KU/bGMG/hMp7i9hg== X-Received: by 2002:ac8:7119:: with SMTP id z25mr5628642qto.16.1611949969079; Fri, 29 Jan 2021 11:52:49 -0800 (PST) Received: from localhost.localdomain ([198.52.185.246]) by smtp.gmail.com with ESMTPSA id s136sm6558994qka.106.2021.01.29.11.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 11:52:48 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Bryan Whitehead , UNGLinuxDriver@microchip.com, David S Miller , Jakub Kicinski Cc: Sven Van Asbroeck , Andrew Lunn , Alexey Denisov , Sergej Bauer , Tim Harvey , =?utf-8?q?Anders_R=C3=B8nningen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v1 3/6] lan743x: allow mtu change while network interface is up Date: Fri, 29 Jan 2021 14:52:37 -0500 Message-Id: <20210129195240.31871-4-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210129195240.31871-1-TheSven73@gmail.com> References: <20210129195240.31871-1-TheSven73@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sven Van Asbroeck Now that we can use rx ring buffers smaller than the mtu, we allow users to change the mtu on the fly. Tested as follows: Tests with debug logging enabled (add #define DEBUG). 1. Set the chip mtu to 1500, generate lots of network traffic. Stop all network traffic. Set the chip and remote mtus to 8000. Ping remote -> chip: $ ping -s 7000 Verify that the first few received packets are multi-buffer. Verify no pings are dropped. Tests with DEBUG_KMEMLEAK on: $ mount -t debugfs nodev /sys/kernel/debug/ $ echo scan > /sys/kernel/debug/kmemleak 2. Start with chip mtu at 1500, host mtu at 8000. Run concurrently: - iperf3 -s on chip - ping -> chip Cycle the chip mtu between 1500 and 8000 every 10 seconds. Scan kmemleak periodically to watch for memory leaks. Verify that the mtu changeover happens smoothly, i.e. the iperf3 test does not report periods where speed drops and recovers suddenly. Note: iperf3 occasionally reports dropped packets on changeover. This behaviour also occurs on the original driver, it's not a regression. Possibly related to the chip's mac rx being disabled when the mtu is changed. Signed-off-by: Sven Van Asbroeck --- Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git # 46eb3c108fe1 To: Bryan Whitehead To: UNGLinuxDriver@microchip.com To: "David S. Miller" To: Jakub Kicinski Cc: Andrew Lunn Cc: Alexey Denisov Cc: Sergej Bauer Cc: Tim Harvey Cc: Anders Rønningen Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) drivers/net/ethernet/microchip/lan743x_main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index b784e9feadac..618f0714a2cf 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -2597,9 +2597,6 @@ static int lan743x_netdev_change_mtu(struct net_device *netdev, int new_mtu) struct lan743x_adapter *adapter = netdev_priv(netdev); int ret = 0; - if (netif_running(netdev)) - return -EBUSY; - ret = lan743x_mac_set_mtu(adapter, new_mtu); if (!ret) netdev->mtu = new_mtu; From patchwork Fri Jan 29 19:52:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 12056459 X-Patchwork-Delegate: kuba@kernel.org 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=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,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 30409C433DB for ; Fri, 29 Jan 2021 20:08:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D44CB64E0E for ; Fri, 29 Jan 2021 20:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233054AbhA2UH4 (ORCPT ); Fri, 29 Jan 2021 15:07:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233033AbhA2Txb (ORCPT ); Fri, 29 Jan 2021 14:53:31 -0500 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4301BC0613D6; Fri, 29 Jan 2021 11:52:51 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id d15so7551210qtw.12; Fri, 29 Jan 2021 11:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7fVbGNql8fbM24WicwqR5l8k2H47U7DaRICOGVwNnLU=; b=hdhcZw3olGLsEdGhZ3gow6JOKe3PKQFMZyJGfWdUVOxSPj58arRfqyjqbCztYJfZTn 9Sn/JGUlxamGsQzhELEOxYxVBuuVsoZtjSnX7t9NXO/GxxhoIoJCkbmkh4ZVbID4Ho4m f2L0/UYmZBXMofxR+SeCco/Jl+VeoFNQ4T0AoCyofM0IuBYhFbweGQEP1CjhHmtV0D++ 06fNhbWbcp7AkVi36LnhSGjdUV8E3YPqX+0BNx6g3R8rWiME0wjRhBulxU6WQw4SlZKd IED3LMHsOW+BBGylFp7C6jYYTeZG8xCq8zTCr/EyAOv3eFv52JNjWtoqu/iaTOZnpxmi Psbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7fVbGNql8fbM24WicwqR5l8k2H47U7DaRICOGVwNnLU=; b=FV89ywzXTDkTvSxmqRyhzSMnWDAekub6H8LYJPkBDQDUP/JKCSNnbIS4PdyoZ4m2NA BinrUZVfMXpCsCFFPFJAYil5J+CtvWb1/fWGEqsyj+xB4X79yCZYKoPDj2+z2V45yIzM 6XlQ9w7P/9a0F32hIUE8aPP5WwB6TFHEuD48Fi1YuP1ZMDEVGBlAO9oBnpTnntfIuYug gl8fWQrc5fzsMgMSMImWmT70FlIJ4PyXHGEVRW788bf4xohxQchOUhl3V4/2F7XkFisK lJwqKRrRjaq2eOEkbPsmwKN32MGvNfC9ClbMuxu/GQsz/k1QRLNr6nC3MKZBMK7B9CAM 3AoA== X-Gm-Message-State: AOAM532LaoE8SmvmHu8Kf7nHxbk2wa2I+E0m97ODXBlDKqOcbkpnuefz 9jIZBIrAgqmMpKWlQF5RFZw= X-Google-Smtp-Source: ABdhPJxMTIt4opqGB3q1wi+2z3hDi555Ieo1PrBfa6K0Eb7wXb61S0UGk7brTaTRUeRUXzCeatXOiQ== X-Received: by 2002:ac8:ecc:: with SMTP id w12mr5698078qti.371.1611949970337; Fri, 29 Jan 2021 11:52:50 -0800 (PST) Received: from localhost.localdomain ([198.52.185.246]) by smtp.gmail.com with ESMTPSA id s136sm6558994qka.106.2021.01.29.11.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 11:52:50 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Bryan Whitehead , UNGLinuxDriver@microchip.com, David S Miller , Jakub Kicinski Cc: Sven Van Asbroeck , Andrew Lunn , Alexey Denisov , Sergej Bauer , Tim Harvey , =?utf-8?q?Anders_R=C3=B8nningen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v1 4/6] TEST ONLY: lan743x: limit rx ring buffer size to 500 bytes Date: Fri, 29 Jan 2021 14:52:38 -0500 Message-Id: <20210129195240.31871-5-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210129195240.31871-1-TheSven73@gmail.com> References: <20210129195240.31871-1-TheSven73@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sven Van Asbroeck Signed-off-by: Sven Van Asbroeck --- Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git # 46eb3c108fe1 To: Bryan Whitehead To: UNGLinuxDriver@microchip.com To: "David S. Miller" To: Jakub Kicinski Cc: Andrew Lunn Cc: Alexey Denisov Cc: Sergej Bauer Cc: Tim Harvey Cc: Anders Rønningen Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) drivers/net/ethernet/microchip/lan743x_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index 618f0714a2cf..ed4959ad9237 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1973,7 +1973,7 @@ static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index) dma_addr_t dma_ptr; int length; - length = netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING; + length = 500 + ETH_HLEN + 4 + RX_HEAD_PADDING; descriptor = &rx->ring_cpu_ptr[index]; buffer_info = &rx->buffer_info[index]; From patchwork Fri Jan 29 19:52:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 12056447 X-Patchwork-Delegate: kuba@kernel.org 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=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 57813C433E6 for ; Fri, 29 Jan 2021 19:56:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EAA764DE1 for ; Fri, 29 Jan 2021 19:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233204AbhA2T4x (ORCPT ); Fri, 29 Jan 2021 14:56:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233024AbhA2Tyd (ORCPT ); Fri, 29 Jan 2021 14:54:33 -0500 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91463C0613ED; Fri, 29 Jan 2021 11:52:52 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id k193so9917087qke.6; Fri, 29 Jan 2021 11:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FUZQHmSz8v3ZgZ4ETLTlu70PtPovT39hOXxs/7uV0ak=; b=KMWjVfcFin1+Di60Wpv6w/JJgM5adDrEgxFWsbt4urmWktq9qtXvWk6IWQ6/y/fATr VCgGxgtFL52vUhzdvWLMGXU3pn2XYdEeGjvDo6GW4fAcqMsTyVttwaqNChsdMLB+5LGp q3QuFOaOBqX+h69kCDMpnNA1/bgBV+Kx81JEY/5mwNfBH8U9wZd6ApDxCthIxZtInDOA 8FMuVL/sPbE3bcII6OoFV/VvU9DtRBWm+R1ygiYTRNNtGd4JkQnj4E1vAO+LVYkIUc6g blL+vHQ9jK1qFvHp3Lcy5BFBN/GLDStYIq6uV0glfOMbYtqHVMVqfJXX+AkhsJ4vNCYY SKwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FUZQHmSz8v3ZgZ4ETLTlu70PtPovT39hOXxs/7uV0ak=; b=DCm/vZRWT8hikh18Mjxp6mCCW1p+5T0Enjoue4qM/kmdcribg1qSobQZbFgxfFr+9s QmzrhO79YtGstNX15J9FoHAjZ02IcP1EWagdio+M+KiZWnWCTnAVqAzPydlyJ6or16GJ rf6hV8rMDQGWJ8s23Wae985pUpfJDxrCqYg9A46fuUp3T7QT6SbzVXccKuaW1/nsm1lb 51VVc6IaTZfZuzSqHN5hNatdssL8go8zb9o6CQy8Mr8DKPVBD0vrtywjkfopPJ/NhfPC wB3PUX5K6aneomiMo4XMQdBMgHaOu1K6cJ2lRwbG1ec3o4gJDJ0sq/MQuNBtBHDPWcw7 DQ5Q== X-Gm-Message-State: AOAM532Rmljpmt0HDhW/w7zq2U7IgToteDypBCEpi9DsygNOKAWmvAM2 JyQ8ocEmaxJ9jrYmSripOXSQyBy1aOIxDA== X-Google-Smtp-Source: ABdhPJyGnyx8VFJmsUtjCYdaCcfwmo6W/kWastkQEQBD2SJ/a/yef0mx/nCvKnB1GjKgswWmdfRKZw== X-Received: by 2002:a37:a156:: with SMTP id k83mr5862461qke.471.1611949971669; Fri, 29 Jan 2021 11:52:51 -0800 (PST) Received: from localhost.localdomain ([198.52.185.246]) by smtp.gmail.com with ESMTPSA id s136sm6558994qka.106.2021.01.29.11.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 11:52:51 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Bryan Whitehead , UNGLinuxDriver@microchip.com, David S Miller , Jakub Kicinski Cc: Sven Van Asbroeck , Andrew Lunn , Alexey Denisov , Sergej Bauer , Tim Harvey , =?utf-8?q?Anders_R=C3=B8nningen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v1 5/6] TEST ONLY: lan743x: skb_alloc failure test Date: Fri, 29 Jan 2021 14:52:39 -0500 Message-Id: <20210129195240.31871-6-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210129195240.31871-1-TheSven73@gmail.com> References: <20210129195240.31871-1-TheSven73@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sven Van Asbroeck Simulate low-memory in lan743x_rx_allocate_skb(): fail 10 allocations in a row in every 100. Signed-off-by: Sven Van Asbroeck --- Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git # 46eb3c108fe1 To: Bryan Whitehead To: UNGLinuxDriver@microchip.com To: "David S. Miller" To: Jakub Kicinski Cc: Andrew Lunn Cc: Alexey Denisov Cc: Sergej Bauer Cc: Tim Harvey Cc: Anders Rønningen Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) drivers/net/ethernet/microchip/lan743x_main.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index ed4959ad9237..149b482fd984 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1963,7 +1963,20 @@ static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) index); } -static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index) +static struct sk_buff * +lan743x_alloc_skb(struct net_device *netdev, int length, bool can_fail) +{ + static int rx_alloc; + int counter = rx_alloc++ % 100; + + if (can_fail && counter >= 20 && counter < 30) + return NULL; + + return __netdev_alloc_skb(netdev, length, GFP_ATOMIC | GFP_DMA); +} + +static int +lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, bool can_fail) { struct net_device *netdev = rx->adapter->netdev; struct device *dev = &rx->adapter->pdev->dev; @@ -1977,7 +1990,7 @@ static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index) descriptor = &rx->ring_cpu_ptr[index]; buffer_info = &rx->buffer_info[index]; - skb = __netdev_alloc_skb(netdev, length, GFP_ATOMIC | GFP_DMA); + skb = lan743x_alloc_skb(netdev, length, can_fail); if (!skb) return -ENOMEM; dma_ptr = dma_map_single(dev, skb->data, length, DMA_FROM_DEVICE); @@ -2130,7 +2143,7 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx) skb = buffer_info->skb; /* allocate new skb and map to dma */ - if (lan743x_rx_init_ring_element(rx, rx->last_head)) { + if (lan743x_rx_init_ring_element(rx, rx->last_head, true)) { /* failed to allocate next skb. * Memory is very low. * Drop this packet and reuse buffer. @@ -2330,7 +2343,7 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx) rx->last_head = 0; for (index = 0; index < rx->ring_size; index++) { - ret = lan743x_rx_init_ring_element(rx, index); + ret = lan743x_rx_init_ring_element(rx, index, false); if (ret) goto cleanup; } From patchwork Fri Jan 29 19:52:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 12056455 X-Patchwork-Delegate: kuba@kernel.org 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=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 164F7C433E0 for ; Fri, 29 Jan 2021 20:07:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFF5764E00 for ; Fri, 29 Jan 2021 20:07:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232808AbhA2UHu (ORCPT ); Fri, 29 Jan 2021 15:07:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233054AbhA2Tyd (ORCPT ); Fri, 29 Jan 2021 14:54:33 -0500 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D09EAC061786; Fri, 29 Jan 2021 11:52:53 -0800 (PST) Received: by mail-qk1-x72a.google.com with SMTP id l27so9916293qki.9; Fri, 29 Jan 2021 11:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vyq09P2oaw4x3jWLZrbHOYVErJkNHGPbbt0QMfukTA8=; b=EWpHtNoDMUUeXcnysJV8JAIvqMx4R+wgEvPgCKBI8VToZ/Me6fxwUVz9OepKufoXDf YzkrknxHNvcl8lHQyeSsaLgJ1w5D+O74Vls3lhjLYwoMzGIQtuPhtCjKavyoB7hUe2Ix rW/MUgQx1aO/jfCE5+Uoco7PEk+d/wpATgefQK7a5qUpU08rbykwbAEHZW/4F4uFblD+ AWDuqItYTezIRGGHgRuJE+5hJCblqrg/3Of3WUhb+TNEsLI1EQx77o3w/FBd536wArtY wdPkLZMGHZGHFHEvNnAdY52GU+/VaAU1Hku8dRej0K/JbHlgJuUVlaECpGy9cqffSj7E s7Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vyq09P2oaw4x3jWLZrbHOYVErJkNHGPbbt0QMfukTA8=; b=mTY5j/+U9Bs/oz1PqaVr3U7xAGPGm6BMcgnn0+yeHbfyxlqNTJvT35ZKGJtthNQ8rF WN5mf/WfPJDPY2uef9fNwffPiWsJYfIEkRQTlJUdlq6jtSA6Gk93Doj77qhClGX/OVNX VnW1uwc7bXkkcFYRgOozu74cLQGIqya24WG6FWEHR0QseLjbcURynBeIXn3gUk7KiisH WAysJONpNlqBlUzGXiT4sLNl6VXLTEgiM/0+R5TPYGzmXVKrgqODB72wSDS/M2RLhkbV jPN+WRwp+C0vEbChkh8sjvx1RnL1f+29mm7IhKJNkE+yB4kfnZKgzQ7denVS/6sOS+wp Qkrw== X-Gm-Message-State: AOAM532jxa2X4gMhD5unHOPLm28yiMRO1zqVN+IfV+v+423SCQPb4d8x UGBnje5yCjX5pGbeY4Rm9Zk= X-Google-Smtp-Source: ABdhPJwB6AJX7wUheibDZ4Eqpb8ln/ktwLaAwBbuBGORYTS4/5y1Qj2eLGUfr3NGOOr0TmwTRK1r0A== X-Received: by 2002:a37:b07:: with SMTP id 7mr5904648qkl.164.1611949972942; Fri, 29 Jan 2021 11:52:52 -0800 (PST) Received: from localhost.localdomain ([198.52.185.246]) by smtp.gmail.com with ESMTPSA id s136sm6558994qka.106.2021.01.29.11.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 11:52:52 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Bryan Whitehead , UNGLinuxDriver@microchip.com, David S Miller , Jakub Kicinski Cc: Sven Van Asbroeck , Andrew Lunn , Alexey Denisov , Sergej Bauer , Tim Harvey , =?utf-8?q?Anders_R=C3=B8nningen?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v1 6/6] TEST ONLY: lan743x: skb_trim failure test Date: Fri, 29 Jan 2021 14:52:40 -0500 Message-Id: <20210129195240.31871-7-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210129195240.31871-1-TheSven73@gmail.com> References: <20210129195240.31871-1-TheSven73@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sven Van Asbroeck Simulate low-memory in lan743x_rx_trim_skb(): fail one allocation in every 100. Signed-off-by: Sven Van Asbroeck --- Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git # 46eb3c108fe1 To: Bryan Whitehead To: UNGLinuxDriver@microchip.com To: "David S. Miller" To: Jakub Kicinski Cc: Andrew Lunn Cc: Alexey Denisov Cc: Sergej Bauer Cc: Tim Harvey Cc: Anders Rønningen Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org (open list) drivers/net/ethernet/microchip/lan743x_main.c | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c index 149b482fd984..dfae7745094b 100644 --- a/drivers/net/ethernet/microchip/lan743x_main.c +++ b/drivers/net/ethernet/microchip/lan743x_main.c @@ -1963,20 +1963,7 @@ static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index) index); } -static struct sk_buff * -lan743x_alloc_skb(struct net_device *netdev, int length, bool can_fail) -{ - static int rx_alloc; - int counter = rx_alloc++ % 100; - - if (can_fail && counter >= 20 && counter < 30) - return NULL; - - return __netdev_alloc_skb(netdev, length, GFP_ATOMIC | GFP_DMA); -} - -static int -lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, bool can_fail) +static int lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index) { struct net_device *netdev = rx->adapter->netdev; struct device *dev = &rx->adapter->pdev->dev; @@ -1990,7 +1977,7 @@ lan743x_rx_init_ring_element(struct lan743x_rx *rx, int index, bool can_fail) descriptor = &rx->ring_cpu_ptr[index]; buffer_info = &rx->buffer_info[index]; - skb = lan743x_alloc_skb(netdev, length, can_fail); + skb = __netdev_alloc_skb(netdev, length, GFP_ATOMIC | GFP_DMA); if (!skb) return -ENOMEM; dma_ptr = dma_map_single(dev, skb->data, length, DMA_FROM_DEVICE); @@ -2058,6 +2045,13 @@ static void lan743x_rx_release_ring_element(struct lan743x_rx *rx, int index) static struct sk_buff * lan743x_rx_trim_skb(struct sk_buff *skb, int frame_length) { + static int trim_cnt; + + if ((trim_cnt++ % 100) == 77) { + dev_kfree_skb_irq(skb); + return NULL; + } + if (skb_linearize(skb)) { dev_kfree_skb_irq(skb); return NULL; @@ -2143,7 +2137,7 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx) skb = buffer_info->skb; /* allocate new skb and map to dma */ - if (lan743x_rx_init_ring_element(rx, rx->last_head, true)) { + if (lan743x_rx_init_ring_element(rx, rx->last_head)) { /* failed to allocate next skb. * Memory is very low. * Drop this packet and reuse buffer. @@ -2343,7 +2337,7 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx) rx->last_head = 0; for (index = 0; index < rx->ring_size; index++) { - ret = lan743x_rx_init_ring_element(rx, index, false); + ret = lan743x_rx_init_ring_element(rx, index); if (ret) goto cleanup; }