Giter VIP home page Giter VIP logo

afxdp-rs's Introduction

AFXDP-rs

This module provides a Rust interface for AF_XDP built on libbpf-sys (https://github.com/alexforster/libbpf-sys).

Author: Dan Siemon <[email protected]>

docs.rs

AF_XDP:

The goals of this crate, in order, are:

  1. Correctness
  2. Performance
  3. Ease of use

Current Status

The API works for my current use cases but I expect it will change to achieve higher performance and better usability.

If you have knowledge of Rust FFI and general Rust unsafe things I would greatly appreciate some help auditing this crate as my experience in this area is limited.

Sample Programs

There are two sample programs in src/bin/:

l2fwd-1link: Receives frames on a single link/queue, swaps the MAC and writes back to the same link/queue. This is roughly like the kernel xdpsock_user.c sample program in l2fwd mode.

l2fwd-2link: Receives frames from two link/queue pairs (separate devices) and forwards the frames to the opposite link.

Performance

Test System:

  • Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz
  • Single X710 (4 physical 10G ports) (i40e)
  • Kernel: 5.4.2-300.fc31.x86_64
  • Kernel boot args: skew_tick=1 mitigations=off selinux=0 isolcpus=4-27 nohz_full=4-27 rcu_nobcs=4-27 default_hugepagesz=1G hugepagesz=1G hugepages=4

Traffic Generator:

  • Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
  • Single X710 (4 physical 10G ports) (i40e)
  • Traffic goes from one port, through test system and to second port on the same X710
  • T-Rex traffic generator (https://trex-tgn.cisco.com/) (DPDK)
  • 64-byte UDP packets

Scenario 1: l2fwd-2link on a single core running userspace and NAPI

Small amounts of packet loss starts at about 6.5M PPS unidirectional and 6.0M PPS bi-directionally (3M each direction).

Little effort has been put into optimizing this so I expect there are some easy performance wins.

AF_XDP Features

  • HUGE TLB flag: Optional (command line arg in the sample programs)
  • ZEROCOPY flag: Optional (command line arg in the sample programs)
  • Only the chunked memory mode is supported
  • Need wakeup flag is required which implies Linux >= 5.4

To Do

  • Currently this module is not 'safe' because Bufs can outlive the memory pool they are associated with. I believe fixing this will require adding an Arc to each Buf. I have not had the time yet to determine the performance impact of this and would appreciate any other ideas.
  • Allow more configurability of AF XDP features
  • All interactions with the Tx, Rx, fill and completion queues are done with C functions that wrap the inline functions in libbpf. I believe this means that these hot functions cannot be inlined in Rust. In the medium term we should build pure Rust functions so they can be inlined.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.