Intel? DPDK is a set of libraries and drivers for fast packet processing on x86 platforms. It runs mostly in Linux userland.
This project tracks the Intel? DPDK and includes all major public contributions. The most recent patches and enhancements, provided by the community, are available in master branch.
dpdk是intel开发的X86芯片上用于高性能网络处理的基础库,业内比较常用的模式是linux-app模式,即利用该基础库,在用户层空间做数据包处理,有了这个基础库,可以方便地写应用层的网络包处理高性能程序,目前该库已经开源。
(1)multicore framework:多核框架,dpdk库面向intel i3/i5/i7/ep等多核架构芯片,内置了对多核的支持。
(2)huge page memory:内存管理,dpdk库基于linux hugepage实现了一套内存管理基础库,为应用层包处理做了很多优化。
(3)ring buffers:共享队列,dpdk库提供的无锁多生产者-多消费者队列,是应用宝处理程序的基础组件。
(4)poll-mode drivers:轮询驱动,dpdk库基于linux uio实现的用户态网卡驱动。
These libraries can be used to:
(1)receive and send packets within the minimum number of CPU cycles (usually less than 80 cycles)
(2)develop fast packet capture algorithms (tcpdump-like)
(3)run third-party fast path stacks
For example, some packet processing functions have been benchmarked up to 160 Mfps (million frames per second, using 64-byte packets) with a PCIe Gen-2 NIC.
Intel? DPDK is not a networking stack and does not provide functions such as Layer-3 forwarding, IPsec, firewalling, etc. Within the tree, however, various application examples are included to help with the development of such features.
If you need some specific drivers or networking stacks, you should contact a company that provides such extensions.
Intel? DPDK: (Data Plane Development Kit)
DPDK driver for paravirtualized NIC based on memory copy
http://dpdk.org/browse/memnic/refs/
DPDK driver for paravirtualized NIC based on Virtio
http://dpdk.org/browse/virtio-net-pmd/refs/
http://dpdk.org/doc/virtio-net-pmd
DPDK driver for paravirtualized NIC in VMware ESXi
http://dpdk.org/browse/vmxnet3-usermap/refs/
http://dpdk.org/doc/vmxnet3-usermap
#source tools/setup.sh
(1)6
(2)8
(3)10
(4)11或12(最好选择NUMA系统,因为hugepages)
(5)14
(6)26
Option:
(1)3
(2)5、6、7或8
(3)10
(4)19(退出)
(1)下载解压缩
#wget http://dpdk.org/browse/dpdk/snapshot/dpdk-1.7.0.tar.gz
#tar xf dpdk-1.7.0.tar.gz
#cd dpdk-1.7.0
(2)Build libraries and kernel module (Linux headers are needed)
#make config T=x86_64-native-linuxapp-gcc
#make
备注:对应上面的第1步(6)。
(3)加载内核模块
#modprobe uio
#insmod build/kmod/igb_uio.ko
备注:对应上面的第2步(8)。
(4)绑定intel设备到igb_uio
#tools/dpdk_nic_bind.py --bind=igb_uio $(tools/dpdk_nic_bind.py --status | sed -rn 's,.* if=([^ ]*).*igb_uio *$,\1,p')
备注:对应上面的第3步(10)(14)。
(5)Reserve huge pages memory.
#mkdir -p /mnt/huge
#mount -t hugetlbfs nodev /mnt/huge
#echo 64 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
备注:对应上面的第4步(11~12)。
static int
lcore_hello(__attribute__((unused)) void *arg)
{
unsigned lcore_id;
lcore_id = rte_lcore_id();
printf("hello from core %u\n", lcore_id);
return 0;
}
int
MAIN(int argc, char **argv)
{
int ret;
unsigned lcore_id;
ret = rte_eal_init(argc, argv);
if (ret < 0)
rte_panic("Cannot init EAL\n");
/* call lcore_hello() on every slave lcore */
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
}
/* call it on master lcore too */
lcore_hello(NULL);
rte_eal_mp_wait_lcore();
return 0;
}
(1)rte_eal_init(argc, argv):dpdk内部初始化函数,参数是-c f -n 4;
(2)rte_eal_remote_launch(lcore_hello, NULL, lcore_id):让子线程去调用 lcore_hello()函数;
(3)rte_eal_mp_wait_lcore():回收各个子线程;
#source /root/.bash_profile
#. /root/.bash_profile
备注:安装成功后,会有一个build目录。
#./build/helloworld -c f -n 4
备注:可能是网络不稳定,没有下载完成,再下载一次就可以解决这个问题。
备注:sudo bash -c bash升级到root权限即可。
备注:主要原因是没有设置环境变量。
example:
http://dpdk.org/browse/dpdk/tree/examples/
API:
NICs:
邮件列表:
http://dpdk.org/ml/archives/dev/
快速部署: