Encap & Decap by Yilong Geng
- NetFPGA-10G Specific cores
- Xilinx AXI Peripheral
- Microblaze Subsystem
This is a testing project for the nf10_encap module and the nf10_decap module. This project added the nf10_encap module and the nf10_decap module into the NIC data path. It can add an IP header to the packet according to its output port, or remove the additional IP header of an packet if it's using the encapsulation protocol.
In the following sections, we will show how to test the nf10_encap module and the nf10_decap module on the NetFPGA.
To run the test, you need two machines, A and B. Let's say Machine A is equipped with NetFPGA and Machine B is equipped with a third-party 10G NIC.
Download the encap_decap bitfile from contrib-projects/encap_decap/bitfiles/encap_decap.bit. (Refer to Production Test Manual if you don't know how to download the bitfile and/or not setup JTAG cable yet.)
Connect Machine A and Machine B using a 10G cable. Assume we use nf0 (the port nearest to the PCI Express) and nf1 on Machine A and eth1 on Machine B.
Build and Install the NIC Driver
Make the driver in the sw/host/driver directory and insert it as a module.
cd sw/host/driver make sudo insmod nf10.ko dmesg
If everything went smoothly dmesg will output that nf10 device is ready.
Setup IP address
On Machine A
sudo ifconfig nf0 192.168.1.1 sudo ifconfig nf1 192.168.1.2
On Machine B
sudo ifconfig eth1 192.168.1.3
Test 1: Reading the configuration registers
The base address of the nf10_encap module in this project is 0x79c00000.
The base address of the nf10_decap module in this project is 0x79c20000.
On Machine A, under folder encap_decap/sw/host/apps
[gengyl08@machine_A apps]$ sudo ./rdaxi 0x79c00040 AXI reg 0x79c00040=0x100ffb2
Encap_base_address + 0x40 is the configuration register of nf10_encap. This example says the "protocol" field we use for tunneling encapsulation is 0xb2, the "ttl" is 255, the "type of service" in the new IP header is 0x00. This also means we only encapsulate traffic going out of port nf0.
[gengyl08@machine_A apps]$ sudo ./rdaxi 0x79c00000 AXI reg 0x79c00000=0x6401a8c0 [gengyl08@machine_A apps]$ sudo ./rdaxi 0x79c00001 AXI reg 0x79c00001=0x6501a8c0 [gengyl08@machine_A apps]$ sudo ./rdaxi 0x79c00002 AXI reg 0x79c00002=0x33445566 [gengyl08@machine_A apps]$ sudo ./rdaxi 0x79c00003 AXI reg 0x79c00003=0x66771122 [gengyl08@machine_A apps]$ sudo ./rdaxi 0x79c00004 AXI reg 0x79c00004=0x22334455
These four registers store the source/destination IP/MAC addresses for the new header added to the traffic going out of port nf0. In this example, the source IP address is 192.168.1.100, the destination IP address is 192.168.1.101, the source MAC address is 66:55:44:33:22:11, the destination MAC address is 77:66:55:44:33:22.
[gengyl08@machine_A apps]$ sudo ./rdaxi 0x79c20000 AXI reg 0x79c20000=0xb20501
The above is the configuration register of the nf10_decap module. In this example, the decap module is enabled, traffic coming in from ports nf0 and nf1 are checked to be decapsulated, the "encapsulation protocol" is set to be 0xb2 which is the same as in the encap module.
Test 2: Encapsulation
Ping machine B from machine A through nf0.
[gengyl08@hunan ~]$ ping -I nf0 192.168.1.3 PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data. From 192.168.1.1 icmp_seq=2 Destination Host Unreachable From 192.168.1.1 icmp_seq=3 Destination Host Unreachable From 192.168.1.1 icmp_seq=4 Destination Host Unreachable --- 192.168.1.3 ping statistics --- 5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4001ms pipe 3
On machine B, we can see that