Skip to content

Commit 74f366e

Browse files
fix(linux): Consolidate XDP documentation to a unified location for ICSSG and CPSW
- Add new centralized XDP documentation at Kernel/Kernel_Drivers/Network/XDP.rst - Add kernel_xdp reference label that can be used throughout the docs - Update PRU_ICSSG_XDP.rst to redirect to the consolidated XDP docs - Update features supported in PRU_ICSSG_Ethernet.rst - Update CPSW-Ethernet.rst to reference kernel_xdp instead of pru_icssg_xdp - Add XDP.rst to AM64X device-specific table of contents - Add XDP.rst to main Kernel Drivers toctree The new XDP documentation covers: - XDP introduction and concepts - Use cases and kernel configuration - AF_XDP sockets and zero-copy mode - Testing with xdp-tools (xdp-bench, xdp-trafficgen) - Performance comparison for CPSW and ICSSG drivers Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Meghana Malladi <m-malladi@ti.com>
1 parent 6448b30 commit 74f366e

File tree

6 files changed

+248
-184
lines changed

6 files changed

+248
-184
lines changed

configs/AM64X/AM64X_linux_toc.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ linux/Foundational_Components/Kernel/Kernel_Drivers/Network/NETCONF-YANG
6666
linux/Foundational_Components/Kernel/Kernel_Drivers/Network/HSR_PRP_Non_Offload
6767
linux/Foundational_Components/Kernel/Kernel_Drivers/Network/HSR_Offload
6868
linux/Foundational_Components/Kernel/Kernel_Drivers/Network/PRP_Offload
69+
linux/Foundational_Components/Kernel/Kernel_Drivers/Network/XDP
6970
linux/Foundational_Components/Kernel/Kernel_Drivers/SPI
7071
linux/Foundational_Components/Kernel/Kernel_Drivers/PCIe/PCIe_End_Point
7172
linux/Foundational_Components/Kernel/Kernel_Drivers/PCIe/PCIe_Root_Complex

source/linux/Foundational_Components/Kernel/Kernel_Drivers/Network/CPSW-Ethernet.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ For further details regarding the TSN features and testing, refer :ref:`tsn_with
9090

9191
XDP and zero copy
9292
"""""""""""""""""
93-
The CPSW Ethernet Subsystem supports XDP and zero copy features similar to PRU-ICSS Ethernet Subsystem.
94-
For more details refer :ref:`pru_icssg_xdp`.
93+
The CPSW Ethernet Subsystem supports XDP Native Mode, XDP Generic Mode, and Zero-copy mode.
94+
For detailed setup and testing information, refer to :ref:`kernel_xdp`.
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
.. _kernel_xdp:
2+
3+
===
4+
XDP
5+
===
6+
7+
.. contents:: :local:
8+
:depth: 3
9+
10+
Introduction
11+
============
12+
13+
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.
14+
15+
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.
16+
17+
- XDP_DROP :- The packet is dropped right away, without wasting any resources. Useful for firewall etc.
18+
- XDP_ABORTED :- Similar to drop, an exception is generated.
19+
- XDP_PASS :- Pass the packet to kernel stack, i.e. the skbs are allocated and it works normally.
20+
- 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 user space through AF_XDP Socket(discussed below).
22+
23+
.. Image:: /images/XDP-packet-processing.png
24+
25+
As explained before, the XDP_REDIRECT sends packets directly to the user space.
26+
This works by using the AF_XDP socket type which was introduced specifically for this usecase.
27+
28+
In this process, the packet is directly sent to the user space without going through the kernel network stack.
29+
30+
.. Image:: /images/xdp-packet.png
31+
32+
Use cases for XDP
33+
-----------------
34+
35+
XDP is particularly useful for these common networking scenarios:
36+
37+
1. **DDoS Mitigation**: High-speed packet filtering and dropping malicious traffic
38+
2. **Load Balancing**: Efficient traffic distribution across multiple servers
39+
3. **Packet Capture**: High-performance network monitoring without performance penalties
40+
4. **Firewalls**: Wire-speed packet filtering based on flexible rule sets
41+
5. **Network Analytics**: Real-time traffic analysis and monitoring
42+
6. **Custom Network Functions**: Specialized packet handling for unique requirements
43+
44+
How to run XDP on EVM
45+
---------------------
46+
47+
The kernel configuration requires the following changes to use XDP:
48+
49+
.. code-block:: console
50+
51+
CONFIG_DEBUG_INFO_BTF=y
52+
CONFIG_BPF_PRELOAD=y
53+
CONFIG_BPF_PRELOAD_UMD=y
54+
CONFIG_BPF_EVENTS=y
55+
CONFIG_BPF_LSM=y
56+
CONFIG_DEBUG_INFO_REDUCED=n
57+
CONFIG_FTRACE=y
58+
CONFIG_XDP_SOCKETS=y
59+
60+
Tools for debugging XDP Applications
61+
-------------------------------------
62+
63+
Debugging tools for XDP development:
64+
65+
- bpftool - For loading and managing BPF programs
66+
- xdpdump - For capturing XDP packet data
67+
- perf - For performance monitoring and analysis
68+
- bpftrace - For tracing BPF program execution
69+
70+
AF_XDP Sockets
71+
==============
72+
73+
AF_XDP is a socket address family specifically designed to work with the XDP framework.
74+
These sockets provide a high-performance interface for user space applications to receive
75+
and transmit network packets directly from the XDP layer, bypassing the traditional kernel networking stack.
76+
77+
Key characteristics of AF_XDP sockets include:
78+
79+
- Direct path from network driver to user space applications
80+
- Shared memory rings for efficient packet transfer
81+
- Minimal overhead compared to traditional socket interfaces
82+
- Optimized for high-throughput, low-latency applications
83+
84+
How AF_XDP Works
85+
----------------
86+
87+
AF_XDP sockets operate through a shared memory mechanism:
88+
89+
1. XDP program intercepts packets at driver level
90+
2. XDP_REDIRECT action sends packets to the socket
91+
3. Shared memory rings (RX/TX/FILL/COMPLETION) manage packet data
92+
4. Userspace application directly accesses the packet data
93+
5. Zero or minimal copying depending on the mode used
94+
95+
The AF_XDP architecture uses several ring buffers:
96+
97+
- **RX Ring**: Received packets ready for consumption
98+
- **TX Ring**: Packets to be transmitted
99+
- **FILL Ring**: Pre-allocated buffers for incoming packets
100+
- **COMPLETION Ring**: Tracks completed TX operations
101+
102+
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>`_.
103+
104+
XDP Zero-Copy
105+
=============
106+
107+
Introduction to Zero-Copy Mode
108+
-------------------------------
109+
110+
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.
111+
112+
How Zero-Copy Works
113+
-------------------
114+
115+
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:
116+
117+
1. Using memory-mapped regions shared between the kernel and user space
118+
2. Allowing direct DMA from network hardware into memory accessible by user space applications
119+
3. Managing memory ownership through descriptor rings rather than data movement
120+
121+
This approach provides several benefits:
122+
123+
- Reduced CPU utilization
124+
- Lower memory bandwidth consumption
125+
- Decreased latency for packet processing
126+
- Improved overall throughput
127+
128+
Performance Considerations
129+
--------------------------
130+
131+
When implementing XDP applications, consider these performance factors:
132+
133+
1. **Memory Alignment**: Buffers should be aligned to page boundaries for optimal performance
134+
2. **Batch Processing**: Process multiple packets in batches when possible
135+
3. **Poll Mode**: Use poll() or similar mechanisms to avoid blocking on socket operations
136+
4. **Core Affinity**: Bind application threads to specific CPU cores to reduce cache contention
137+
5. **NUMA Awareness**: Consider NUMA topology when allocating memory for packet buffers
138+
139+
Testing XDP on EVM
140+
==================
141+
142+
The `xdp-tools <https://github.com/xdp-project/xdp-tools>`__ package provides
143+
utility tools for testing XDP and AF_XDP such as `xdp-bench`, `xdp-trafficgen` etc.
144+
145+
TI SDK packages the latest version of ``xdp-tools`` utilities and provides it as part of the SDK.
146+
This allows users to easily test XDP functionality on EVM using these tools.
147+
148+
Both CPSW and ICSSG Ethernet drivers supports Native XDP, Generic XDP, and Zero-copy mode.
149+
150+
.. note::
151+
152+
In case of testing with CPSW please note that when running XDP in Zero-copy mode, non-XDP traffic will be dropped.
153+
154+
**XDP Transmit test** — generate traffic using XDP (copy mode):
155+
156+
.. code-block:: console
157+
158+
xdp-trafficgen udp -m ff:ff:ff:ff:ff:ff <interface>
159+
160+
**XDP Drop test** — receive and drop packets using XDP (copy mode):
161+
162+
.. code-block:: console
163+
164+
xdp-bench xdp-bench drop <interface>
165+
166+
**XDP Pass test** — receive and pass packets through XDP allowing normal network stack processing (copy mode):
167+
168+
.. code-block:: console
169+
170+
xdp-bench xdp-bench pass <interface>
171+
172+
**XDP TX test** — Hairpins (bounces back) received packets on the same interface (copy mode):
173+
174+
.. code-block:: console
175+
176+
xdp-bench xdp-bench tx <interface>
177+
178+
**XDP Redirect test** — Redirects received packets on the from one interface to another (copy mode):
179+
180+
.. code-block:: console
181+
182+
xdp-bench xdp-bench redirect <interface1> <interface2>
183+
184+
**XSK Drop test** — receive and drop packets using AF_XDP socket in zero-copy mode:
185+
186+
.. code-block:: console
187+
188+
xdp-bench xsk-drop -q 0 -C zero-copy <interface>
189+
190+
**XSK Transmit test** — generate traffic using AF_XDP socket in zero-copy mode:
191+
192+
.. code-block:: console
193+
194+
xdp-trafficgen xsk-udp -m ff:ff:ff:ff:ff:ff -q 0 -C zero-copy <interface>`
195+
196+
``xdpsock`` is deprecated and replaced by `xsk-trafficgen` and `xsk-bench` in `xdp-tools` package.
197+
For more details on zero copy testing refer to `xdpsock <https://github.com/xdp-project/bpf-examples/tree/main/AF_XDP-example>`_
198+
199+
Performance Comparison
200+
----------------------
201+
202+
Performance testing shows that zero-copy mode can provide substantial throughput improvements compared to copy mode:
203+
204+
AF_XDP performance while using 64 byte packets for ICSSG (in Kpps):
205+
206+
.. list-table::
207+
:header-rows: 1
208+
209+
* - Benchmark
210+
- XDP-SKB
211+
- XDP-Native
212+
- XDP-Native(ZeroCopy)
213+
* - rxdrop
214+
- 253
215+
- 473
216+
- 656
217+
* - txonly
218+
- 350
219+
- 354
220+
- 855
221+
222+
AF_XDP performance while using 64 byte packets for CPSW (in Kpps):
223+
224+
.. list-table::
225+
:header-rows: 1
226+
227+
* - Benchmark
228+
- XDP-SKB
229+
- XDP-Native
230+
- XDP-Native(ZeroCopy)
231+
* - rxdrop
232+
- 322
233+
- 491
234+
- 845
235+
* - txonly
236+
- 390
237+
- 394
238+
- 723

source/linux/Foundational_Components/PRU-ICSS/Linux_Drivers/PRU_ICSSG_Ethernet.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Features supported
4444
- Different MII modes for Real-Time Ethernet ports (MII_G_RT1 and MII_G_RT2) on different PRU_ICSSG instances. For example, MII on a PRU_ICSSG1 port, and RGMII on a PRU_ICSSG2 port, is supported.
4545
- IRQ Coalescing also known as interrupt pacing.
4646
- Multi-cast HW filtering
47-
- XDP Native Mode and XDP Generic Mode
47+
- XDP Native Mode, XDP Generic Mode and Zero-copy mode
4848
- Cut Through forwarding
4949
- PHY Interrupt mode for ICSSG2
5050
- Multicast filtering support for VLAN interfaces
@@ -54,7 +54,6 @@ Features supported
5454
- VLAN HW filtering
5555
- All-multi mode is always enabled
5656
- Different MII modes for Real-Time Ethernet ports (MII_G_RT1 and MII_G_RT2) on a single PRU_ICSSG instance. For example, MII_G_RT1=MII and MII_G_RT2=RGMII.
57-
- XDP with Zero-copy mode
5857

5958
Driver Configuration
6059
####################
@@ -713,8 +712,8 @@ To turn off PPS,
713712
XDP
714713
###
715714

716-
The PRU_ICSSG Ethernet driver supports Native XDP as well as Generic XDP. XDP with Zero-copy mode is not supported yet.
717-
For detailed setup and how to test XDP please refer to :ref:`pru_icssg_xdp`.
715+
The PRU_ICSSG Ethernet driver supports Native XDP, Generic XDP, and Zero-copy mode.
716+
Refer to :ref:`kernel_xdp` for more details.
718717

719718

720719
Tips

0 commit comments

Comments
 (0)