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 29A3DA0C45; Mon, 13 Sep 2021 15:46:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C9AA40151; Mon, 13 Sep 2021 15:46:03 +0200 (CEST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mails.dpdk.org (Postfix) with ESMTP id 9B8AC4014F for ; Mon, 13 Sep 2021 15:46:02 +0200 (CEST) Received: by mail-wm1-f49.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so10476wml.3 for ; Mon, 13 Sep 2021 06:46:02 -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=pIsVcnvf1+R/qhu/fPDV2aqqoei3MUqleYk/65sN1wA=; b=dgKli7CohTBqldAvBVi0F/FAccOe6hYziGPYblFtNC44OzOxD21yO9yXisvH132fev FBl3TW9T4caw1ciDgpoyksem6vM0A3iqJMKc/s/NvDcEImS5jse7/NsdcvXz112CmU3R Wq+x3HkLvLoTFtdcG3rjmsjxT0MLWcKhZTyCubraf4dX//jNv3Ecx7mcpktapSfrY4mR pXC5619a2jlLkmnLbyWZMxL00S1KuJ6TOtzxE2JG7KKcdE96tt0QRG+B+bRnQ2/JdNxI IDWJFcKlKz01D5qcHRxgplNjAuGLbYjJFLa+p0GRZvSU+37B/1zg1LWQPbfCjUDxbKSF Jtkg== 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=pIsVcnvf1+R/qhu/fPDV2aqqoei3MUqleYk/65sN1wA=; b=DMX66FbPCQg7Fw9omeqnM5EAPIyf3GPbtWNEKJhNehjpnx0jSPYXloV0phiWgxemz7 shFEeUWB7Od13ud9z7sVdFVuffCwUCu/tZDkEcBRDZSbHk7emkNU1o+C2gGqhqsj7gG7 PzhghdWr3v6HoPJmMEldcULkyuipz79S/b+NDUnWtYTGYl40N8bpBWv8l92cJWdehItR 9zaGaOrjpNgHqrazectfj48v7+QyUP1I1yY88VVyHbL2oqxvdLVsRZDMKN0b+WadWc6w oEAK+mGv6rSkaIVmKPblcTRzQsZgXHsvVJp3lgS/nLM495KJhobe4KByVaNXP7RAGZ8x 0MfA== X-Gm-Message-State: AOAM533V7DCtIuUxCASk5euY+Yqu4/WeuLQWuiFBLFoi7Jij05irPCar pQnzKT6aWImGVG+VJGvBcFw= X-Google-Smtp-Source: ABdhPJzBoI7/v3Izi9RUyTqlyLEaUWtjZWzaIH6eHPfh3PW1sA9QK7WeKId/N8Qvzk1GsZVmeXQLOA== X-Received: by 2002:a1c:3881:: with SMTP id f123mr10547174wma.185.1631540762300; Mon, 13 Sep 2021 06:46:02 -0700 (PDT) Received: from tucornea-dev-machine.localdomain ([193.226.172.44]) by smtp.gmail.com with ESMTPSA id l124sm6890875wml.8.2021.09.13.06.46.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Sep 2021 06:46:01 -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: Mon, 13 Sep 2021 16:45:46 +0300 Message-Id: <1631540746-38443-1-git-send-email-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629466761-127333-1-git-send-email-tudor.cornea@gmail.com> References: <1629466761-127333-1-git-send-email-tudor.cornea@gmail.com> Subject: [dpdk-dev] [PATCH v2] 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. Signed-off-by: Mihai Pogonaru Signed-off-by: Tudor Cornea --- drivers/net/af_packet/rte_eth_af_packet.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index b73b211..087c196 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -216,6 +216,25 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) (poll(&pfd, 1, -1) < 0)) 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 (ppd->tp_status != TP_STATUS_AVAILABLE) + break; + /* copy the tx frame data */ pbuf = (uint8_t *) ppd + TPACKET2_HDRLEN - sizeof(struct sockaddr_ll); -- 2.7.4