From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6FF2DA0C4E; Tue, 2 Nov 2021 16:47:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CF924113F; Tue, 2 Nov 2021 16:47:56 +0100 (CET) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mails.dpdk.org (Postfix) with ESMTP id 969D241139 for ; Tue, 2 Nov 2021 16:47:55 +0100 (CET) Received: by mail-wr1-f43.google.com with SMTP id u18so34035638wrg.5 for ; Tue, 02 Nov 2021 08:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KOcJ9MXNwxoAbMLyrSYVAy/uUJzmoPl38k1DjN7xxT0=; b=SWFcF4ChOvh0k75MYtIx58TNt1l3eWoYGMzRMqjRMKoPux3wqr4THLLf/QC8RWvzCk VPwL1SV02TYm2J1I/fGfXDhM2g9amFhim+w4SgCyO42ZQpeiKXJh7pRilec5dBUfdoh4 9C0iK3pvLjsxQqeY5eiaVxymwoW7XD9G+MwqFy3iNofFl4RaN1sfWYY6tZzVG6869v+B KuBmxup5TNHZmTc1ReqER7/6c2z8qz+Qoa78dncHZsGSX5ba4PHyFbUGNuQaccUaTdqR c/VgGO+dkaPN1/6IsSjMeM9F2xb1Z/V3/GLupy9HQYFP0edGsY5SqxU8CcyQY8XBeV6e mk4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KOcJ9MXNwxoAbMLyrSYVAy/uUJzmoPl38k1DjN7xxT0=; b=N12qpcS4XJpPNUr9EY+MTM6GqC2JABMXd9tpLCxaxvDLZgVi7WswUUY6aNtcTson3T ske883W6fdvRTnuj4mU/Gg6n4DkaIVXbm35Bgmf233tkbsLQ1mmZ0wqykAmz+97nI1bZ dt9qOAuuVY0LWZM6Gl87J9Ar0u+hhWYOPzA0Mq64Ybp8139m7gMJTxYLZ/b6vsF3ffhj fhz2oX6STDReJ/O97wf3QqzYn6dRxOt88Rh/KxbXwV9kQ6PG1tYDTdBF6rkut8cutuWK /HjGgPqCLA3xdGHkVVQIt9c/ZWj+ctHsvpouc/DMeOwq4dqE2LTMPPHsqTit3VYUepmS K50Q== X-Gm-Message-State: AOAM532JJ8L7oM7tL3h5DBDHFl3eVAuiyaqJKp1+KmAlb9kwyjICsa7Y dSX6yEFaHNSzaYGjl1l+tLk= X-Google-Smtp-Source: ABdhPJzLWCiwAWBhvHxF8KGmphYB4Ea6Fji0FjPBvzvVljQdcx1sP/vBhQkD7qTiDT5i4oJ1sK4N+A== X-Received: by 2002:a5d:64ed:: with SMTP id g13mr22094588wri.222.1635868075373; Tue, 02 Nov 2021 08:47:55 -0700 (PDT) Received: from tucornea-dev-machine.localdomain ([193.226.172.44]) by smtp.gmail.com with ESMTPSA id y6sm18706202wrh.18.2021.11.02.08.47.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Nov 2021 08:47:54 -0700 (PDT) From: Tudor Cornea To: ferruh.yigit@intel.com Cc: linville@tuxdriver.com, thomas@monjalon.net, pogonarumihai@gmail.com, dev@dpdk.org, Tudor Cornea Date: Tue, 2 Nov 2021 17:47:24 +0200 Message-Id: <1635868044-69456-1-git-send-email-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631540746-38443-1-git-send-email-tudor.cornea@gmail.com> References: <1631540746-38443-1-git-send-email-tudor.cornea@gmail.com> Subject: [dpdk-dev] [PATCH v3] net/af_packet: fix ignoring full ring on tx X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The poll call can return POLLERR which is ignored, or it can return POLLOUT, even if there are no free frames in the mmap-ed area. We can account for both of these cases by re-checking if the next frame is empty before writing into it. We have attempted to reproduce this issue with pktgen-dpdk, using the following configuration. pktgen -l 1-4 -n 4 --proc-type=primary --no-pci --no-telemetry \ --no-huge -m 512 \ --vdev=net_af_packet0,iface=eth1,blocksz=16384,framesz=8192, \ framecnt=2048,qpairs=1,qdisc_bypass=0 \ -- \ -P \ -T \ -m "3.0" \ -f themes/black-yellow.theme We configure a low tx rate (~ 335 packets / second) and a small packet size, of about 300 Bytes from the pktgen CLI. set 0 size 300 set 0 rate 0.008 set 0 burst 1 start 0 After bringing the interface down, and up again, we seem to arrive in a state in which the tx rate is inconsistent, and does not recover. ifconfig eth1 down; sleep 7; ifconfig eth1 up [1] http://code.dpdk.org/pktgen-dpdk/pktgen-20.11.2/source/INSTALL.md Signed-off-by: Mihai Pogonaru Signed-off-by: Tudor Cornea --- v2: * Added check for POLLERR * Used tx_ring_status_available() for checking TP_STATUS_AVAILABLE --- drivers/net/af_packet/rte_eth_af_packet.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 559f5a0..d3d3104 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -237,8 +237,30 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } /* point at the next incoming frame */ - if (!tx_ring_status_available(ppd->tp_status) && - poll(&pfd, 1, -1) < 0) + if (!tx_ring_status_available(ppd->tp_status)) { + if (poll(&pfd, 1, -1) < 0) + break; + if (pfd.revents & POLLERR) + break; + } + + /* + * Poll can return POLLERR if the interface is down + * + * It will almost always return POLLOUT, even if there + * are no extra buffers available + * + * This happens, because packet_poll() calls datagram_poll() + * which checks the space left in the socket buffer and, + * in the case of packet_mmap, the default socket buffer length + * doesn't match the requested size for the tx_ring. + * As such, there is almost always space left in socket buffer, + * which doesn't seem to be correlated to the requested size + * for the tx_ring in packet_mmap. + * + * This results in poll() returning POLLOUT. + */ + if (!tx_ring_status_available(ppd->tp_status)) break; /* copy the tx frame data */ -- 2.7.4