Skip to content

Commit d89ecf7

Browse files
MeghanaMalladiTIcshilwant
authored andcommitted
feat(linux): Add XDP zero copy support documentation for ICSSG
Update existing XDP documentation and add documentation support for AF_XDP and zero copy for PRU_ICSS driver. Signed-off-by: Meghana Malladi <m-malladi@ti.com>
1 parent 7aa6bbd commit d89ecf7

File tree

3 files changed

+161
-11
lines changed

3 files changed

+161
-11
lines changed
167 KB
Loading
-13.7 KB
Binary file not shown.
Lines changed: 161 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,185 @@
11
.. _pru_icssg_xdp:
22

3-
*************
3+
#############
44
PRU_ICSSG XDP
5-
*************
5+
#############
66

77
.. contents:: :local:
88
:depth: 3
99

10+
************
1011
Introduction
11-
############
12+
************
1213

13-
XDP stands for eXpress Data Path and provides a framework for BPF that enables high-performance programmable packet processing in the Linux kernel. It runs the BPF program at the earliest possible point in software, namely at the moment the network driver receives the packet.
14+
XDP (eXpress Data Path) provides a framework for BPF that enables high-performance programmable packet processing in the Linux kernel. It runs the BPF program at the earliest possible point in software, namely at the moment the network driver receives the packet.
1415

1516
XDP allows running a BPF program just before the skbs are allocated in the driver, the BPF program can look at the packet and return the following things.
1617

1718
- XDP_DROP :- The packet is dropped right away, without wasting any resources. Useful for firewall etc.
1819
- XDP_ABORTED :- Similar to drop, an exception is generated.
1920
- XDP_PASS :- Pass the packet to kernel stack, i.e. the skbs are allocated and it works normally.
2021
- XDP_TX :- Send the packet back to same NIC with modification(if done by the program).
21-
- XDP_REDIRECT :- Send the packet to another NIC or to the userspace through AF_XDP Socket(discussed below).
22+
- XDP_REDIRECT :- Send the packet to another NIC or to the user space through AF_XDP Socket(discussed below).
2223

23-
.. Image:: /images/xdp-packet-processing.png
24+
.. Image:: /images/XDP-packet-processing.png
2425

25-
As explained above, the XDP_REDIRECT can be used to send a packet directly to the userspace.
26+
As explained before, the XDP_REDIRECT sends packets directly to the user space.
2627
This works by using the AF_XDP socket type which was introduced specifically for this usecase.
2728

28-
In this process, the packet is directly sent to the userspace without going through the kernel network stack.
29+
In this process, the packet is directly sent to the user space without going through the kernel network stack.
2930

3031
.. Image:: /images/xdp-packet.png
3132

32-
Running XDP on EVM
33-
##################
33+
Use cases for XDP
34+
=================
3435

35-
The ICSSG driver supports XDP. Any application based on XDP can use ICSSG XDP Capablities. By default CONFIG_XDP_SOCKETS is enabled in .config of ti-linux-kernel.
36+
XDP is particularly useful for these common networking scenarios:
37+
38+
1. **DDoS Mitigation**: High-speed packet filtering and dropping malicious traffic
39+
2. **Load Balancing**: Efficient traffic distribution across multiple servers
40+
3. **Packet Capture**: High-performance network monitoring without performance penalties
41+
4. **Firewalls**: Wire-speed packet filtering based on flexible rule sets
42+
5. **Network Analytics**: Real-time traffic analysis and monitoring
43+
6. **Custom Network Functions**: Specialized packet handling for unique requirements
44+
45+
How to run XDP with PRU_ICSSG
46+
=============================
47+
48+
The kernel configuration requires the following changes to use XDP with PRU_ICSSG:
49+
50+
.. code-block:: console
51+
52+
CONFIG_DEBUG_INFO_BTF=y
53+
CONFIG_BPF_PRELOAD=y
54+
CONFIG_BPF_PRELOAD_UMD=y
55+
CONFIG_BPF_EVENTS=y
56+
CONFIG_BPF_LSM=y
57+
CONFIG_DEBUG_INFO_REDUCED=n
58+
CONFIG_FTRACE=y
59+
CONFIG_XDP_SOCKETS=y
60+
61+
Tools for debugging XDP Applications
62+
====================================
63+
64+
Debugging tools for XDP development:
65+
66+
- bpftool - For loading and managing BPF programs
67+
- xdpdump - For capturing XDP packet data
68+
- perf - For performance monitoring and analysis
69+
- bpftrace - For tracing BPF program execution
70+
71+
**************
72+
AF_XDP Sockets
73+
**************
74+
75+
AF_XDP is a socket address family specifically designed to work with the XDP framework.
76+
These sockets provide a high-performance interface for user space applications to receive
77+
and transmit network packets directly from the XDP layer, bypassing the traditional kernel networking stack.
78+
79+
Key characteristics of AF_XDP sockets include:
80+
81+
- Direct path from network driver to user space applications
82+
- Shared memory rings for efficient packet transfer
83+
- Minimal overhead compared to traditional socket interfaces
84+
- Optimized for high-throughput, low-latency applications
85+
86+
How AF_XDP Works
87+
================
88+
89+
AF_XDP sockets operate through a shared memory mechanism:
90+
91+
1. XDP program intercepts packets at driver level
92+
2. XDP_REDIRECT action sends packets to the socket
93+
3. Shared memory rings (RX/TX/FILL/COMPLETION) manage packet data
94+
4. Userspace application directly accesses the packet data
95+
5. Zero or minimal copying depending on the mode used
96+
97+
The AF_XDP architecture uses several ring buffers:
98+
99+
- **RX Ring**: Received packets ready for consumption
100+
- **TX Ring**: Packets to be transmitted
101+
- **FILL Ring**: Pre-allocated buffers for incoming packets
102+
- **COMPLETION Ring**: Tracks completed TX operations
103+
104+
For more details on AF_XDP please refer to the official documentation: `AF_XDP <https://www.kernel.org/doc/html/latest/networking/af_xdp.html>`_.
105+
106+
Current Support Status in PRU_ICSSG
107+
===================================
108+
109+
The PRU_ICSSG Ethernet driver currently supports:
110+
111+
- Native XDP mode
112+
- Generic XDP mode (SKB-based)
113+
- Zero-copy mode
114+
115+
**************************
116+
XDP Zero-Copy in PRU_ICSSG
117+
**************************
118+
119+
Introduction to Zero-Copy Mode
120+
==============================
121+
122+
Zero-copy mode is an optimization in AF_XDP that eliminates packet data copying between the kernel and user space. This results in significantly improved performance for high-throughput network applications.
123+
124+
How Zero-Copy Works
125+
===================
126+
127+
In standard XDP operation (copy mode), packet data is copied from kernel memory to user space memory when processed. Zero-copy mode eliminates this copy operation by:
128+
129+
1. Using memory-mapped regions shared between the kernel and user space
130+
2. Allowing direct DMA from network hardware into memory accessible by user space applications
131+
3. Managing memory ownership through descriptor rings rather than data movement
132+
133+
This approach provides several benefits:
134+
- Reduced CPU utilization
135+
- Lower memory bandwidth consumption
136+
- Decreased latency for packet processing
137+
- Improved overall throughput
138+
139+
Requirements for Zero-Copy
140+
==========================
141+
142+
For zero-copy to function properly with PRU_ICSSG, ensure:
143+
144+
1. **Driver Support**: Verify the PRU_ICSSG driver is loaded with zero-copy support enabled
145+
2. **Memory Alignment**: Buffer addresses must be properly aligned to page boundaries
146+
3. **UMEM Configuration**: The UMEM area must be correctly configured:
147+
- Properly aligned memory allocation
148+
- Sufficient number of packet buffers
149+
- Appropriate buffer sizes
150+
4. **Hugepages**: Using hugepages for UMEM allocation is recommended for optimal performance
151+
152+
Performance Comparison
153+
======================
154+
155+
Performance testing shows that zero-copy mode can provide substantial throughput improvements compared to copy mode:
156+
157+
`xdpsock <https://github.com/xdp-project/bpf-examples/tree/main/AF_XDP-example>`_ opensource tool was used for testing XDP zero copy.
158+
AF_XDP performance while using 64 byte packets in Kpps:
159+
160+
.. list-table::
161+
:header-rows: 1
162+
163+
* - Benchmark
164+
- XDP-SKB
165+
- XDP-Native
166+
- XDP-Native(ZeroCopy)
167+
* - rxdrop
168+
- 253
169+
- 473
170+
- 656
171+
* - txonly
172+
- 350
173+
- 354
174+
- 855
175+
176+
Performance Considerations
177+
==========================
178+
179+
When implementing XDP applications, consider these performance factors:
180+
181+
1. **Memory Alignment**: Buffers should be aligned to page boundaries for optimal performance
182+
2. **Batch Processing**: Process multiple packets in batches when possible
183+
3. **Poll Mode**: Use poll() or similar mechanisms to avoid blocking on socket operations
184+
4. **Core Affinity**: Bind application threads to specific CPU cores to reduce cache contention
185+
5. **NUMA Awareness**: Consider NUMA topology when allocating memory for packet buffers

0 commit comments

Comments
 (0)