Orin NX, socket zero copy based on AF_PACKET + TPACKET_V3 / PACKET_MMAP

I’m developing a zero-copy solution for several LiDAR systems on Orin NX, based on AF_PACKET + TPACKET_V3 / PACKET_MMAP. However, I’m encountering a problem: under heavy load, the kernel stops filling the ring buffer. All buffers in the ring are in the USER state, preventing the kernel from filling them, and it won’t fill them again. Even if user space recovers, the LiDAR stops receiving data. Furthermore, I can’t close the stall ring, as this will cause a crash.

Any suggestions for fixing this issue?

Hello @songqiangqiang1!

Based on the title and content of your topic, it looks like it may receive better visibility and feedback in a different category. We took the liberty of moving it for you.

If this was an incorrect assessment, please send me a direct message.

Disclaimer: this moderation suggestion and message were generated with AI assistance.

What’s the LiDAR interface? USB? MIPI?

USB network port, data packets are UDP packets.

Are you writing the kernel driver for the LiDAR directly?

No, I’m using your Tegra 5.15 kernel driver. I’m using a socket to create a ring shared memory to achieve zero-copy lidar UDP packets.

What is the application code you are running on your side for such test? Do you have any sample?

I’m running the Hesai JT128 LiDAR driver, and we have our own samples.

We may not be able to debug with such info. You need to provide a method that could reproduce this issue on NV devkit.

The Tegra 5.15 kernel driver creates a ring via a socket:

socket(AF_PACKET, SOCK_RAW | SOCK_NONBLOCK, htons(ETH_P_ALL));
int ver = TPACKET_V3;
setsockopt(zc_fd_, SOL_PACKET, PACKET_VERSION, &ver, sizeof(ver)) < 0)
setsockopt(zc_fd_, SOL_PACKET, PACKET_RX_RING, &req, sizeof(req))

If the ring is filled by the kernel and no user consumes any data, will there be any problems? Are you aware of this?

sorry that we are not aware of such issue.

Maybe you could try jetpack7.2 and see if upstream fixed this or not.

What is Jetpack 7.2? Could you explain it in detail? Or are there any resources available? Thank you.

kernel5.15 you are using is Jetpack6.x. There are Jetpack7.2 that supports Orin NX too. And it is using kernel 6.8.

Okay, I’ll try it. Thanks for your support.