Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9309849rwb; Thu, 24 Nov 2022 10:48:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf671eZ9udFkP08aXEWSdmHSPvke47dtmFcD39ZPAyVAYqgozsEuP5P30czL5RijcFzNFUKa X-Received: by 2002:a05:6402:5405:b0:468:4cd4:f133 with SMTP id ev5-20020a056402540500b004684cd4f133mr16540015edb.18.1669315737131; Thu, 24 Nov 2022 10:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669315737; cv=none; d=google.com; s=arc-20160816; b=XBaEDfE5YmZxMqeq42NYGxPQP+qRpFqip+SjD2XYRPvd7n3oBY+OQTsf5NLJwqAu2w c4/auu04YJQu72PW688S2nm0drZ8+kg3MIFK3o1tzfn+ekm5GfHjLQkiLc2G5y3QEhFp oacSUqH3qLxjnbnseRUgchsApLl3/f5QU1IKBGnKfD8+4m71XMjZdIQt/yZdFs9RQ83/ NrBLMOLXehruAUL3T3/shyXnXtFjTwj7v73jylu0mNzOXer5j2DWasWSYtNQYJOY2xTz ZMHqoO77j+ett4PofLLyrQJWmn6xJFsmKf72htEf+bpx4ZHnyOCUAb1g7ZQje7zph1pp Yw+g== 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=AD9TuOVK/RsIOyoGJ4bbDI6mCdsGtnGFWw/FzzS5oYo=; b=q94pEKrzypkiVAXbu3qT45BYJPR0bG/ZWAFhmzc2lUCr80SnLDRg2YqzGd/GEoRLjW pE8tMFMimfiRxVY8bLk7wgcTTKM0EsuECf3WczXmAGgCmwIK9BFlr1muqeIEJyf6HAP1 6yrl6gVu8O0c+UHRTybcUCxKLWMdvbej+5rZ99GM3Lb5KEmL/IuxCQdSnT41eDnX8Ys6 8LxSvnbm5c13LnpRDMf0C0Vyw3QnnVbBoyz+XDztT1TsTXx3EAZChf8FnT6QPtpcbydN Y6g0twWwZa652t72+5wJbS/lRwhabxy5NQNHiY4Memd7xTTTBIxmpGOTS8CLjK83qtoO rlag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YwyNlSxm; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a50ea88000000b0046751a6076bsi1427393edo.318.2022.11.24.10.48.33; Thu, 24 Nov 2022 10:48:57 -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=pass header.i=@intel.com header.s=Intel header.b=YwyNlSxm; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229790AbiKXRzK (ORCPT + 86 others); Thu, 24 Nov 2022 12:55:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbiKXRyz (ORCPT ); Thu, 24 Nov 2022 12:54:55 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89A5C12D39; Thu, 24 Nov 2022 09:54:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669312458; x=1700848458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sXnKN/YXOdlrt4gQi4aLdKbmQKzlc0Sj2MoBA1aMjMg=; b=YwyNlSxmNLWmFxuwYCI9dVUAwwQwoe+yLi8a6K4Aqr6kuLg7ur+LjaCv YphQQFd3YbRcTjGlW9zN9Iv6+2UTBIXUHQZTS0/xCNX9L3mJf9uR8p2j2 BauOe3r6wFgBCmGppi8amxLyPOkRux0dcUTsLnKtorqrrowfpOyAt7wI1 yYp+8Ukf000l2VWu9ZAcEj/2mauXwNZdYze7FR3i7/rMFlgfhhT8VWEeA l9C592lYpPjxvBKIYX65C3YbDmfEuoGloqUP9FhD0uKOL3wmxYg1+pjOs OgDhNTcU+51HRWhPQUMVzb0Xl+CqDrH2v7rBXqtJrDaLmD5oFFlCEJmbx g==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="316166681" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="316166681" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 09:54:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="767146960" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="767146960" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga004.jf.intel.com with ESMTP; 24 Nov 2022 09:54:15 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 2AOHsDbM003592; Thu, 24 Nov 2022 17:54:13 GMT From: Alexander Lobakin To: Felix Fietkau Cc: Alexander Lobakin , netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] net: ethernet: mtk_eth_soc: work around issue with sending small fragments Date: Thu, 24 Nov 2022 18:54:10 +0100 Message-Id: <20221124175410.5684-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123095754.36821-3-nbd@nbd.name> References: <20221123095754.36821-1-nbd@nbd.name> <20221123095754.36821-3-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE,SPF_NONE 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 From: Felix Fietkau Date: Wed, 23 Nov 2022 10:57:52 +0100 > When frames are sent with very small fragments, the DMA engine appears to > lock up and transmit attempts time out. Fix this by detecting the presence > of small fragments and use skb_gso_segment + skb_linearize to deal with > them Nit: all of your commit messages don't have a trailing dot (.), not sure if it's important, but my eye is missing it definitely :D skb_gso_segment() and skb_linearize() are slow as hell. I think you can do it differently. I guess only the first (head) and the last frag can be so small, right? So, if a frag from shinfo->frags is less than 16, get a new frag of the minimum acceptable size via netdev_alloc_frag(), copy the data to it and pad the rest with zeroes. Then increase skb->len and skb->data_len, skb_frag_unref() the current, "invalid" frag and replace the pointer to the new frag. I didn't miss anything I believe... Zero padding the tail is usual thing for NICs. skb frag substitution is less common, but should be legit. If skb_headlen() is less than 16, try doing pskb_may_pull() + __skb_pull() at first. The argument would be `16 - headlen`. If pskb_may_pull() returns false, then yeah, you have no choice other than segmenting and linearizing ._. > > Signed-off-by: Felix Fietkau > --- > drivers/net/ethernet/mediatek/mtk_eth_soc.c | 36 +++++++++++++++++++-- > 1 file changed, 34 insertions(+), 2 deletions(-) [...] > if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) > netif_tx_stop_all_queues(dev); > -- > 2.38.1 Thanks, Olek