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 04104A0C4C for ; Wed, 1 Dec 2021 12:02:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0E5340140; Wed, 1 Dec 2021 12:02:30 +0100 (CET) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mails.dpdk.org (Postfix) with ESMTP id 6A0C140140 for ; Wed, 1 Dec 2021 12:02:29 +0100 (CET) Received: by mail-wr1-f45.google.com with SMTP id o13so51169928wrs.12 for ; Wed, 01 Dec 2021 03:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=PHJQZ2cTblWUCpox3+l+/BbgXr7kSkdmyg9GgRUtN9M=; b=ogqrAKeLM9woeQP8wUOIvzbzkUXr8N+A37oF6wscDIAcG1MG6w43lRurgQWhb6LAN4 r7RiTgcUvXEgH9R6AEsP5figo8fLvUh0dOLWaBG1c2+XCWNbgRxeT5Z6JBXVB4kRmegl Uf639r44mVmo7HD18zxAXefQ7VlzaTARNxKOY7udfRCfjgffZ93DtZhU+aZiV7foFHkq UwS9SSxafV30Ah2EfpRPi6nRXr1GcdLOVyAr17iIGoEaOQOtAy1Y/5XGeaCAfVlrbr5H OWaFDoXtjrUKcm9xtQvXsvq9/hLM/sDXjtz/mgAfcwq6sza9DTeP6lUvlWmcTP83LJ+p WoIw== 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; bh=PHJQZ2cTblWUCpox3+l+/BbgXr7kSkdmyg9GgRUtN9M=; b=ZIIlGB//HxCILFVvBUsvvgxb9eh/5Ej+fZRPOlm7dK4drJP7AgU02L7JTgSZMIrIkk 5zihpiTyImpazic/jof8BL4oUY82ojzFFl9gcr32N25rkuKtbG55yMvXDehDOHnmpLUR /JbMcwliGFVEtda80QeQOgpLAfuaoeF4Ek3FG9nhACyzk1RNTH2FEGgmDmAY3IUvTOIw ht61IONGtJv7X+g/qMZiwP1SKiuHz0IQkQNcPj2eJN6DzHLPxPCBO6nVwYrC6q8RfGp9 BFe30h8B85NX+ZL/9lDDbeIjdU1qseTqiHV02znURg5RoV2VwUhS8cVswK7rd2eZ8jtU KJ7w== X-Gm-Message-State: AOAM531RrpN5QUoCn+Ic/NmGhITE4HtZ1bCEkcegc/gqbXnmPT5CkTB4 eNXGoViL+yEKxR9+BQW66tyI+4ereQI= X-Google-Smtp-Source: ABdhPJyQwEY9UiY6KOdX94K3QOIYVbGnfwO0EedisZ3t0KV+Y+mgz3OwZW4Oaacow9XaAROig/d7zQ== X-Received: by 2002:adf:f489:: with SMTP id l9mr6037231wro.268.1638356548939; Wed, 01 Dec 2021 03:02:28 -0800 (PST) Received: from tucornea-dev-machine.localdomain ([193.226.172.44]) by smtp.gmail.com with ESMTPSA id k187sm1273101wme.0.2021.12.01.03.02.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Dec 2021 03:02:28 -0800 (PST) From: Tudor Cornea To: stable@dpdk.org Cc: christian.ehrhardt@canonical.com, Tudor Cornea , Mihai Pogonaru Subject: [PATCH 19.11] net/af_packet: fix ignoring full ring on Tx Date: Wed, 1 Dec 2021 12:32:05 +0200 Message-Id: <1638354725-116692-1-git-send-email-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit f86d553cc180f9a65e115edb5641a49bbf2cf2f0 ] 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 Fixes: 364e08f2bbc0 ("af_packet: add PMD for AF_PACKET-based virtual devices") Signed-off-by: Mihai Pogonaru Signed-off-by: Tudor Cornea Reviewed-by: Ferruh Yigit --- 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 00387ed..dbbe8e5 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -213,8 +213,30 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } /* point at the next incoming frame */ - if ((ppd->tp_status != TP_STATUS_AVAILABLE) && - (poll(&pfd, 1, -1) < 0)) + if (ppd->tp_status != TP_STATUS_AVAILABLE) { + if (poll(&pfd, 1, -1) < 0) + break; + + /* poll() can return POLLERR if the interface is down */ + if (pfd.revents & POLLERR) + break; + } + + /* + * poll() 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 (ppd->tp_status != TP_STATUS_AVAILABLE) break; /* copy the tx frame data */ -- 2.7.4