当前位置: 首页 > 文档资料 > SDN 网络指南 >

5. DPDK - Ring和共享内存

优质
小牛编辑
133浏览
2023-12-01

DPDK Ring

DPDK Ring提供了一个FIFO无锁队列,支持丰富的队列操作,比如

  • Multi-consumer or single-consumer dequeue
  • Multi-producer or single-producer enqueue
  • Bulk dequeue - Dequeues the specified count of objects if successful; otherwise fails
  • Bulk enqueue - Enqueues the specified count of objects if successful; otherwise fails
  • Burst dequeue - Dequeue the maximum available objects if the specified count cannot be fulfilled
  • Burst enqueue - Enqueue the maximum available objects if the specified count cannot be fulfilled

Ring和共享内存 - 图1

ivshmem

ivshmem则通过把内存映射成虚拟机PCI设备提供了虚拟机间(host-to-guest or guest-to-guest)共享内存的机制。

Ring和共享内存 - 图2

DPDK ivshmem:

Ring和共享内存 - 图3

ivshmem使用示例

  1. # on the host
  2. mount tmpfs /dev/shm -t tmpfs -osize=32m
  3. ivshmem_server -m 64 -p/tmp/nahanni &
  4. # start VM
  5. qemu-system-x86_64 -hda mg -L /pc-bios/ --smp 4 –chardev socket,path=/tmp/nahanni,id=nahanni-device ivshmem,chardev=nahanni,size=32m,msi=off -serial telnet:0.0.0.0:4000,server,nowait,nodelay-enable-kvm&
  6. # inside VM
  7. modprobe kvm_ivshmem
  8. cat/proc/devices | grep kvm_ivshmem
  9. mknod-mode=666 /dev/ivshmem c 245 0

参考文档

  • DPDK Ring Library
  • DPDK IVSHMEM Library