Giter VIP home page Giter VIP logo

dpdk.cr's Introduction

dpdk.cr

Crystal bindings to DPDK, development in progress.

Hello World (examples/hello.cr)

require "../src/dpdk"

class Hello < Dpdk
  def hello_thread
    printf("Hello from lcore: %d\n", rte_lcore_id)
  end

  def main(argc, argv)
    rte_eal_init(argc, argv)
    rte_eal_mp_remote_launch(hello_thread)
    rte_eal_mp_wait_lcore
  end
end

Hello.run

Requirements

  • Crystal (0.24.2)
  • Recent Clang (5.0) or GCC, make and coreutils
  • Working DPDK (18.02, 17.11(branch), 17.08(branch)), with RTE_SDK environment variable is set (Works with or without shared library enabled)

Documentation

https://s-you.github.io/dpdk.cr/docs/index.html

Building

% make help

targets:
  all             Build all files (currently dpdk only) [default]
  clean           Clean up built directories and files
  clean_examples  Clean up examples
  docs            Generate standard library documentation
  dpdk            Build the library
  help            Show this help
  spec            Run all specs

optional variables:
  debug           Add symbolic debug info (not full)
  progress        Enable progress output [default]
  release         Compile in release mode [default]
  stats           Enable statistics output
  threads         Maximum number of threads to use
  verbose         Run specs in verbose mode

recipes:
  Build an example from examples/ directory and output in build/ directory
    % make hello
  Enable stats output of example
    % make l2fwd stats=1
  Build an example in non release mode
    % make hello release=
  Clean up built files then the library
    % make clean

Compiling an example

% make hello

Running an example

  • Output depends on number of CPU and NICs available on your machine.
 % sudo build/hello
EAL: Detected 10 lcore(s)
EAL: Probing VFIO support...
EAL: PCI device 0000:00:03.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:08.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:09.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:0a.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:10.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:11.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:12.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
EAL: PCI device 0000:00:13.0 on NUMA socket -1
EAL:   Invalid NUMA socket, default to 0
EAL:   probe driver: 8086:100e net_e1000_em
Hello from lcore: 1
Hello from lcore: 3
Hello from lcore: 2
Hello from lcore: 4
Hello from lcore: 5
Hello from lcore: 6
Hello from lcore: 7
Hello from lcore: 8
Hello from lcore: 9
Hello from lcore: 0

Examples (Tested only on VirtualBox)

Performance

  • rxtx_callbacks sample on one end, as fast as C

rxtx_callbacks

  • pktgen on the other end, 14Mpps with 64 byte packets (Wirerate at 10G)

2018-02-26 20 07 57 |

TODO

  • Supports all possible examples provided by DPDK

Limitations

  • All static inlines in the dpdk headers either need to write it in Crystal or extern from C.
  • GC is disabled for now (It can turn on, but GC cannot collect dpdk threads anyway)
  • Following funtions are compiled as C library currently -
    • rte_pktmbuf_free
    • rte_pktmbuf_alloc
    • rte_pktmbuf_append
    • rte_pktmbuf_prepend
    • rte_pktmbuf_adj
    • rte_pktmbuf_trim
    • rte_eth_rx_burst
    • rte_eth_tx_burst
    • rte_ring_dequeue_burst
    • rte_ring_enqueue_burst
    • rte_ring_sp_enqueue_bulk
    • rte_ring_sc_dequeue_bulk
    • rte_lpm_lookup
    • rte_lcore_to_socket_id
    • rte_socket_id (because per_lcore__socket_id not avaialable in some build)
    • rte_memcpy (optional)
  • Branches other than master is not actively maintained.

dpdk.cr's People

Contributors

s-you avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.