0
0

More than 5 years have passed since last update.

Crystal で DPDK 動くのか

Last updated at Posted at 2018-01-27

サンプルコード、lib_dpdkは現時点で未公開です。

require "./lib_dpdk"

def hello_thread(arg : Void*) : LibC::Int
  LibC.printf("Hello from lcore: %d\n", LibDpdk.per_lcore__lcore_id)
  0
end

fun main(argc : Int32, argv : UInt8**) : Int32
  Crystal.main do
    LibDpdk.rte_eal_init(argc, argv)
    LibDpdk.rte_eal_mp_remote_launch(->hello_thread, nil, LibDpdk::RteRmtCallMasterT::CallMaster)
    LibDpdk.rte_eal_mp_wait_lcore
  end
end

実行結果

% sudo crystal run src/hello.cr 
EAL: Detected 4 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: 2
Hello from lcore: 3
Hello from lcore: 0

Crystal、実はThread対応していないので実用になれる気がしません。
Thread内でputsするだけでsegfaultします。

DPDK自体も#defineとinlineばっかりなのでbindingに苦労しますね。 rust-dpdk見ればわかります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0