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 1D667A04A3; Fri, 17 Dec 2021 16:00:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9D8F40143; Fri, 17 Dec 2021 16:00:44 +0100 (CET) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mails.dpdk.org (Postfix) with ESMTP id B2D6C40040 for ; Fri, 17 Dec 2021 16:00:43 +0100 (CET) Received: by mail-wm1-f52.google.com with SMTP id z4-20020a1c7e04000000b0032fb900951eso4224375wmc.4 for ; Fri, 17 Dec 2021 07:00:43 -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=T7UuoLcpfOKtK9xYzmTNe2cKXnLSkxkg8ladpRcmJt0=; b=Kzed9eutzXo8ajnD9xxOjSFgpsnhRkY2bxwWR5TBIcNhKHxXq6J/NpdCi0AjOCaxyw stpNuoFPwwRo+d/74GD/ZLvsmfw3gXyHRVlJ/J4SZ7ire6JwzAtJsmrj3XZDR/zblBSo P8px88N3A+FJA1Gzh81Buf32p5y5cWYCrIN6KqoJIU6oZ+H9GHpYBvFM417WzyEOzjeA VBrtG95RRJAwQTWFxeevCdPx6NnnLq9rbGtGvYTABfG7mkt2dhPrkek0CcVxbdKG+lAx xIgiPxRPqWanXBEIWTMNBjdiiO2xh8SqgZ8454/42fuHIaBv+y4i1D5PpvG4lslTQlov 727w== 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=T7UuoLcpfOKtK9xYzmTNe2cKXnLSkxkg8ladpRcmJt0=; b=VHCTLj3SWCoRRoiCsGQkcD+si3OMJJMFn5cJL/kvFDqe0088icnnTg+lOgacZ7BmTB VXLY3W6nGjBe1JJvOahAhx8/89ABP/eQUgqH+y6FLWheXpttEq9m99WSt4MFysgpFeyn M6Pw4EOdPqcjaeavjoY7PJ2hLyf+WZXwqXI7UVloA/4Og5KD80YTOmLI4/Z96N5N1qCB bxowPLLSYDm0+7emXeL2DV4QJVRwwJD8q/CC/86NpURh2OpiTkWrYJX/0PnsGUjQHXNu WGt79VQtsyEcLHBq5a8kaqkSXzwYHylsQXtwbX5xxriFiXQNYHzyxDR1/3FYe2Vjkxsd x93w== X-Gm-Message-State: AOAM533xa9n2RQbb4BIzEPGZbxDHLd2CrQfJ0oizl5mO0tXQsBMKuQyh P4VGwe7Onu57hBLp1WjCg7c= X-Google-Smtp-Source: ABdhPJx2GXmAra/2b3rHd0HKFw28rKjCE3VOY1ybY5WhpwrekBvs76Pc7LdlNc2rOau6d4QtOK/kQg== X-Received: by 2002:a7b:cd02:: with SMTP id f2mr3018683wmj.115.1639753243451; Fri, 17 Dec 2021 07:00:43 -0800 (PST) Received: from tucornea-dev-machine.localdomain ([193.226.172.43]) by smtp.gmail.com with ESMTPSA id v15sm7603464wro.35.2021.12.17.07.00.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Dec 2021 07:00:42 -0800 (PST) From: Tudor Cornea To: ferruh.yigit@intel.com Cc: thomas@monjalon.net, stephen@networkplumber.org, dev@dpdk.org, Tudor Cornea Subject: [PATCH] kernel/kni: retry the xmit in case ring is full Date: Fri, 17 Dec 2021 17:00:32 +0200 Message-Id: <1639753232-115930-1-git-send-email-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.7.4 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 This patch attempts to avoid dropping packets that are to be transmitted, in case there is no space in the KNI ring. We have a use case in which we leverage the Linux TCP / IP stack for control plane, and some protocols might be sensitive to packet drops. This might mean that the sender (Kernel) might be moving at a faster pace than the receiver end (DPDK application), or it might have some brief moments of bursty traffic patterns. Requeuing the packets could add a kind of backpressure until a transmit window is available to us. The burden of retransmitting is shifted to the caller of ndo_start_xmit, which in our case is the configured queuing discipline. This way, the user should be able to influence the behavior w.r.t dropping packets, by picking the desired queuing discipline. Although it should technically be a good approach, from what I have tested, stopping the queue prior to returning NETDEV_TX_BUSY seems to add some extra overhead, and degrade the control-plane performance a bit. Signed-off-by: Tudor Cornea --- kernel/linux/kni/kni_net.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c index 29e5b9e..db0330f 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -321,10 +321,9 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev) if (kni_fifo_free_count(kni->tx_q) == 0 || kni_fifo_count(kni->alloc_q) == 0) { /** - * If no free entry in tx_q or no entry in alloc_q, - * drops skb and goes out. + * Tell the caller to requeue, and retry at a later time. */ - goto drop; + goto requeue; } /* dequeue a mbuf from alloc_q */ @@ -371,6 +370,10 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev) dev->stats.tx_dropped++; return NETDEV_TX_OK; + +requeue: + /* Signal the caller to re-transmit at a later time */ + return NETDEV_TX_BUSY; } /* -- 2.7.4