回复: af_packet can't send packet more than framecnt

Message ID 1CCF1B14C9842CED+002501d95b20$272f1b60$758d5220$@netitest.com (mailing list archive)
State Not Applicable, archived
Delegated to: Ferruh Yigit
Headers
Series 回复: af_packet can't send packet more than framecnt |

Checks

Context Check Description
ci/loongarch-compilation warning apply patch failure
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure

Commit Message

hfli@netitest.com March 20, 2023, 11:36 a.m. UTC
  Hi,

The issue has been resolved when I patched new code from dpdk 22.12, my dpdk
version is 19.11

 static uint16_t
@@ -213,7 +236,7 @@
                }
 
                /* point at the next incoming frame */
-               if (ppd->tp_status != TP_STATUS_AVAILABLE) {
+               if (!tx_ring_status_available(ppd->tp_status)) {
                        if (poll(&pfd, 1, -1) < 0)
                                break;
 
@@ -236,7 +259,7 @@
                 *
                 * This results in poll() returning POLLOUT.
                 */
-               if (ppd->tp_status != TP_STATUS_AVAILABLE)
+               if (!tx_ring_status_available(ppd->tp_status))
                        break;
 
                /* copy the tx frame data */


Thanks,
Haifeng

-----邮件原件-----
发件人: hfli@netitest.com <hfli@netitest.com> 
发送时间: 2023年3月20日 11:32
收件人: 'dev@dpdk.org' <dev@dpdk.org>
主题: af_packet can't send packet more than framecnt

Hi,

I used af_packet interface, but found only can send packets successfully
less than framecnt argument. 

E.g. if I pass “--vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,
framecnt=512,qpairs=1,qdisc_bypass=0” to DPDK, the rte_eth_tx_burst only
return 1 for 512 times, after that it always return 0.
If I pass
“--vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=1024,q
pairs=1,qdisc_bypass=0” to DPDK, the rte_eth_tx_burst only return 1 for
1024 times, after that it always return 0.

BTW, I use busy loop mode in project, Is there any help for this?



Thanks so much
Haifeng
  

Comments

Stephen Hemminger March 20, 2023, 4:53 p.m. UTC | #1
On Mon, 20 Mar 2023 19:36:02 +0800
<hfli@netitest.com> wrote:

> Hi,
> 
> The issue has been resolved when I patched new code from dpdk 22.12, my dpdk
> version is 19.11
> 
> Index: rte_eth_af_packet.c
> ===================================================================
> --- rte_eth_af_packet.c (版本 44115)
> +++ rte_eth_af_packet.c (版本 44128)
> @@ -169,6 +169,29 @@
>  }
>  
>  /*
> + * Check if there is an available frame in the ring
> + */
> +static inline int
> +tx_ring_status_available(uint32_t tp_status)
> +{
> +       /*
> +        * We eliminate the timestamp status from the packet status.
> +        * This should only matter if timestamping is enabled on the socket,
> +        * but there is a bug in the kernel which is fixed in newer
> releases.
> +        *
> +        * See the following kernel commit for reference:
> +        *     commit 171c3b151118a2fe0fc1e2a9d1b5a1570cfe82d2
> +        *     net: packetmmap: fix only tx timestamp on request


Thanks for investigating, what kernel are you using?
That bug was fixed in 5.13 kernel (in 2021-05-11) almost 2 years ago.
It looks like it was also fixed in the LTS stable kernels.

DPDK probably should not be modified to handle kernel bugs that are
ready fixed in the current kernel LTS versions.
  
hfli@netitest.com March 21, 2023, 1 a.m. UTC | #2
Hi Stephen,

Thanks for your response, my OS is CentOS7.9, so the kernel is 3.10. However, the issue has been resolved depend on new DPDK code.


Regards,
Haifeng

-----邮件原件-----
发件人: Stephen Hemminger <stephen@networkplumber.org> 
发送时间: 2023年3月21日 0:54
收件人: hfli@netitest.com
抄送: dev@dpdk.org
主题: Re: 回复: af_packet can't send packet more than framecnt

On Mon, 20 Mar 2023 19:36:02 +0800
<hfli@netitest.com> wrote:

> Hi,
> 
> The issue has been resolved when I patched new code from dpdk 22.12, 
> my dpdk version is 19.11
> 
> Index: rte_eth_af_packet.c
> ===================================================================
> --- rte_eth_af_packet.c (版本 44115)
> +++ rte_eth_af_packet.c (版本 44128)
> @@ -169,6 +169,29 @@
>  }
>  
>  /*
> + * Check if there is an available frame in the ring  */ static inline 
> +int tx_ring_status_available(uint32_t tp_status) {
> +       /*
> +        * We eliminate the timestamp status from the packet status.
> +        * This should only matter if timestamping is enabled on the socket,
> +        * but there is a bug in the kernel which is fixed in newer
> releases.
> +        *
> +        * See the following kernel commit for reference:
> +        *     commit 171c3b151118a2fe0fc1e2a9d1b5a1570cfe82d2
> +        *     net: packetmmap: fix only tx timestamp on request


Thanks for investigating, what kernel are you using?
That bug was fixed in 5.13 kernel (in 2021-05-11) almost 2 years ago.
It looks like it was also fixed in the LTS stable kernels.

DPDK probably should not be modified to handle kernel bugs that are ready fixed in the current kernel LTS versions.
  

Patch

Index: rte_eth_af_packet.c
===================================================================
--- rte_eth_af_packet.c (版本 44115)
+++ rte_eth_af_packet.c (版本 44128)
@@ -169,6 +169,29 @@ 
 }
 
 /*
+ * Check if there is an available frame in the ring
+ */
+static inline int
+tx_ring_status_available(uint32_t tp_status)
+{
+       /*
+        * We eliminate the timestamp status from the packet status.
+        * This should only matter if timestamping is enabled on the socket,
+        * but there is a bug in the kernel which is fixed in newer
releases.
+        *
+        * See the following kernel commit for reference:
+        *     commit 171c3b151118a2fe0fc1e2a9d1b5a1570cfe82d2
+        *     net: packetmmap: fix only tx timestamp on request
+        */
+       tp_status &= ~(TP_STATUS_TS_SOFTWARE | TP_STATUS_TS_RAW_HARDWARE);
+
+       if (tp_status == TP_STATUS_AVAILABLE)
+        return 1;
+
+    return 0;
+}
+
+/*
  * Callback to handle sending packets through a real NIC.
  */