From patchwork Tue Jan 23 20:09:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Engleder X-Patchwork-Id: 13528116 X-Patchwork-Delegate: kuba@kernel.org Received: from mx15lb.world4you.com (mx15lb.world4you.com [81.19.149.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7401C82D8D; Tue, 23 Jan 2024 20:09:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.19.149.125 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706040567; cv=none; b=TV/oHGdIGid6chQoWfzUaZmewicRReXIfBRsAJZDjNPs8bSd6f+0IMJYqiGdlHZcMKXz4/FxtjGiQu0EQ88kD6D1+gPQ91vxv4xhizZbjVMbscy2NdwqGyTdoo7juw6zQCREvACQlkYXWZvJldkGjj7Mzp13Gfby3M+DOVEsoUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706040567; c=relaxed/simple; bh=Eahtt7sp9NJ+VqKi4mXtvkxGACKZUdR8h1dFdG71Mf0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LGpQx8Zl3QeqX3UjGCLp3uTRFMEZ251SdsI9HiaT+s02QQaBmWK6mVUI3hXmPnZghIOfzcHNEaAPJn78F84NHBo2upMATYdCF+R5IhDxH1EloyvXwcR6uIDhsrsglWfRCCpoqA+AqzY0n+tL7sPU+ooPI9EX5bujl4li+SHFrms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=engleder-embedded.com; spf=pass smtp.mailfrom=engleder-embedded.com; dkim=pass (1024-bit key) header.d=engleder-embedded.com header.i=@engleder-embedded.com header.b=Tc8n6Pt+; arc=none smtp.client-ip=81.19.149.125 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=engleder-embedded.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=engleder-embedded.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=engleder-embedded.com header.i=@engleder-embedded.com header.b="Tc8n6Pt+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=engleder-embedded.com; s=dkim11; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=l+aWBgTvWf+NUADLxxLeRzHBIAi5CDIxHTcun2ROO7c=; b=Tc8n6Pt+KxjzPmnt8vV0luJSvi /Uff9U4T65TA3v5LbOh5sXhRjrmTKk+Uel406vBK0GxRMa8kc6upUlSuEN21W1jfdajeEHu9OI0lL V3dTCT3bGvaftCXcCKdjb3AaDbjG73qglKTG06RqtO5SHE62bVkJcOyD6MZjeDMe4c1U=; Received: from 88-117-59-234.adsl.highway.telekom.at ([88.117.59.234] helo=hornet.engleder.at) by mx15lb.world4you.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rSN5H-0006xu-2V; Tue, 23 Jan 2024 21:09:23 +0100 From: Gerhard Engleder To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, Gerhard Engleder Subject: [PATCH net 1/2] tsnep: Remove FCS for XDP data path Date: Tue, 23 Jan 2024 21:09:17 +0100 Message-Id: <20240123200918.61219-2-gerhard@engleder-embedded.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123200918.61219-1-gerhard@engleder-embedded.com> References: <20240123200918.61219-1-gerhard@engleder-embedded.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-AV-Do-Run: Yes X-ACL-Warn: X-W4Y-Internal X-Patchwork-Delegate: kuba@kernel.org The RX data buffer includes the FCS. The FCS is already stripped for the normal data path. But for the XDP data path the FCS is included and acts like additional/useless data. Remove the FCS from the RX data buffer also for XDP. Fixes: 65b28c810035 ("tsnep: Add XDP RX support") Fixes: 3fc2333933fd ("tsnep: Add XDP socket zero-copy RX support") Signed-off-by: Gerhard Engleder --- drivers/net/ethernet/engleder/tsnep_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c index 0462834cf6e1..d380a407e175 100644 --- a/drivers/net/ethernet/engleder/tsnep_main.c +++ b/drivers/net/ethernet/engleder/tsnep_main.c @@ -1487,7 +1487,7 @@ static int tsnep_rx_poll(struct tsnep_rx *rx, struct napi_struct *napi, xdp_prepare_buff(&xdp, page_address(entry->page), XDP_PACKET_HEADROOM + TSNEP_RX_INLINE_METADATA_SIZE, - length, false); + length - ETH_FCS_LEN, false); consume = tsnep_xdp_run_prog(rx, prog, &xdp, &xdp_status, tx_nq, tx); @@ -1570,7 +1570,7 @@ static int tsnep_rx_poll_zc(struct tsnep_rx *rx, struct napi_struct *napi, prefetch(entry->xdp->data); length = __le32_to_cpu(entry->desc_wb->properties) & TSNEP_DESC_LENGTH_MASK; - xsk_buff_set_size(entry->xdp, length); + xsk_buff_set_size(entry->xdp, length - ETH_FCS_LEN); xsk_buff_dma_sync_for_cpu(entry->xdp, rx->xsk_pool); /* RX metadata with timestamps is in front of actual data, From patchwork Tue Jan 23 20:09:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Engleder X-Patchwork-Id: 13528117 X-Patchwork-Delegate: kuba@kernel.org Received: from mx15lb.world4you.com (mx15lb.world4you.com [81.19.149.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55DF485C47; Tue, 23 Jan 2024 20:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.19.149.125 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706040567; cv=none; b=bR/8wWaFvL0XoJm40jqh+/Q37H7/OlBzP4VMtG73uf65oebxRv7Aocoy4gdiktf/tzV1R9xglo/MONHfIglaP/1+FoTzY9LW/lnrLmb/T9UqQJKwrRg4DuYw4HfpP0QEBdPDhEDY7OinRRHLqyVDQ7FCj7SR7AjWASn14gezpoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706040567; c=relaxed/simple; bh=OnF2NS8E5Rgd8oS5vEXS5MCrFLcOWVVF9f2KxhbA5gs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fA5XZ1ODjBScjftklNU4dOtjkPadErkqS9MTYLl/meuIHqOCi0Jv7u1VvxWYDtw0nE7ZIBFJ9xjeaz0iWfvAme6VkKFfjYvfQ4KNZzlnfrwUKNRsn4y1IqUU0Kacy0JwvKM97rB3U9VG0HmSlFFp8DSRUFef02N80ZwDh2o0NEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=engleder-embedded.com; spf=pass smtp.mailfrom=engleder-embedded.com; dkim=pass (1024-bit key) header.d=engleder-embedded.com header.i=@engleder-embedded.com header.b=U+ifQrZR; arc=none smtp.client-ip=81.19.149.125 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=engleder-embedded.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=engleder-embedded.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=engleder-embedded.com header.i=@engleder-embedded.com header.b="U+ifQrZR" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=engleder-embedded.com; s=dkim11; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2j/QEu67spPks8eR09A9FtkHTZs1MTEwycM7n70OG4k=; b=U+ifQrZRGm4N9PihiovK87B5MO hxn1eS/eSqsOXKF7uI50nOU1Yf04Lo6aIMYhIx0Nnf9Z5akPgjlDkT2AFv/6godKRjKTu82IXr/wa WbxZ77m5guK2gWQQThjQGIDWcGRvuw5PO39wIg/Wvt/fj7s4ASikxFP1/3G8P0x86C8k=; Received: from 88-117-59-234.adsl.highway.telekom.at ([88.117.59.234] helo=hornet.engleder.at) by mx15lb.world4you.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rSN5I-0006xu-26; Tue, 23 Jan 2024 21:09:24 +0100 From: Gerhard Engleder To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, Gerhard Engleder Subject: [PATCH net 2/2] tsnep: Fix XDP_RING_NEED_WAKEUP for empty fill ring Date: Tue, 23 Jan 2024 21:09:18 +0100 Message-Id: <20240123200918.61219-3-gerhard@engleder-embedded.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123200918.61219-1-gerhard@engleder-embedded.com> References: <20240123200918.61219-1-gerhard@engleder-embedded.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-AV-Do-Run: Yes X-ACL-Warn: X-W4Y-Internal X-Patchwork-Delegate: kuba@kernel.org The fill ring of the XDP socket may contain not enough buffers to completey fill the RX queue during socket creation. In this case the flag XDP_RING_NEED_WAKEUP is not set as this flag is only set if the RX queue is not completely filled during polling. Set XDP_RING_NEED_WAKEUP flag also if RX queue is not completely filled during XDP socket creation. Fixes: 3fc2333933fd ("tsnep: Add XDP socket zero-copy RX support") Signed-off-by: Gerhard Engleder --- drivers/net/ethernet/engleder/tsnep_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c index d380a407e175..ae0b8b37b9bf 100644 --- a/drivers/net/ethernet/engleder/tsnep_main.c +++ b/drivers/net/ethernet/engleder/tsnep_main.c @@ -1764,6 +1764,19 @@ static void tsnep_rx_reopen_xsk(struct tsnep_rx *rx) allocated--; } } + + /* set need wakeup flag immediately if ring is not filled completely, + * first polling would be too late as need wakeup signalisation would + * be delayed for an indefinite time + */ + if (xsk_uses_need_wakeup(rx->xsk_pool)) { + int desc_available = tsnep_rx_desc_available(rx); + + if (desc_available) + xsk_set_rx_need_wakeup(rx->xsk_pool); + else + xsk_clear_rx_need_wakeup(rx->xsk_pool); + } } static bool tsnep_pending(struct tsnep_queue *queue)