Chinaunix首页 | 论坛 | 博客
  • 博客访问: 127775
  • 博文数量: 40
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 236
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-04 09:56
个人简介

小小博客,不足为外人道

文章分类

全部博文(40)

分类: 嵌入式

2016-03-16 11:58:44

环境搭建:

手头没有intel的板子,暂时只能用虚拟机代替;



虚拟机的CPU数量不能超过真实的机器,因此暂时无法模拟出NUMA的环境;

dpdk需要至少两块网卡,eth0和eth1用于dpdk使用,eth2用于跟主机通信;

 

打开虚拟机的配置文件, xxx.vmx,把所有网卡都设置成e1000


点击(此处)折叠或打开

  1. ethernet0.present = "TRUE"
  2. ethernet0.connectionType = "hostonly"
  3. ethernet0.wakeOnPcktRcv = "FALSE"
  4. ethernet0.addressType = "static"
  5. ethernet0.virtualDev = "e1000"
  6. ethernet1.present = "TRUE"
  7. ethernet1.connectionType = "hostonly"
  8. ethernet1.wakeOnPcktRcv = "FALSE"
  9. ethernet1.addressType = "static"
  10. ethernet1.virtualDev = "e1000"
  11. ethernet2.present = "TRUE"
  12. ethernet2.connectionType = "nat"
  13. ethernet2.wakeOnPcktRcv = "FALSE"
  14. ethernet2.addressType = "static"
  15. ethernet2.virtualDev = "e1000"

下载dpdk源码

git clone git://dpdk.org/dpdk

设置环境变量

点击(此处)折叠或打开

  1. export RTE_SDK=/root/dpdk
  2. export RTE_TARGET=i686-default-linuxapp-gcc
  3. export EXTRA_CFLAGS="-O0 -g"

由于是32位机器,设置target为i686;更多target可以参考intel-dpdk-getting-started-guide

其中EXTRA_CFLAGS把编译优化去掉,并加上调试信息;

 

编译代码


点击(此处)折叠或打开

  1. make config T=i686-default-linuxapp-gcc
  2. make install T=i686-default-linuxapp-gcc
  3. make -C i686-default-linuxapp-gcc
  4. make -C examples/helloworld

预留hugepage个数,并挂载

点击(此处)折叠或打开

  1. echo 128 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages

  2. mount -t hugetlbfs nodev /mnt/huge
加载uio和igb_uio

点击(此处)折叠或打开

  1. modprobe uio
  2. insmod ./build/kmod/igb_uio.ko


绑定设备

点击(此处)折叠或打开

  1. ./tools/igb_uio_bind.py --bind=igb_uio eth0
  2. ./tools/igb_uio_bind.py --bind=igb_uio eth1

如果需要解绑定,后面的bus:slot.func各种设备不一样

点击(此处)折叠或打开

  1. ./tools/igb_uio_bind.py --unbind 02:01.0
  2. ./tools/igb_uio_bind.py --unbind 02:02.0

  3. ./tools/igb_uio_bind.py --bind=e1000 02:01.0
  4. ./tools/igb_uio_bind.py --bind=e1000 02:02.0


最后就可以运行helloworld

点击(此处)折叠或打开

  1. root@bogon:~/dpdk# ./examples/helloworld/build/helloworld -c 0xf -n 2
  2. EAL: Cannot read numa node link for lcore 0 - using physical package id instead
  3. EAL: Detected lcore 0 as core 0 on socket 0
  4. EAL: Cannot read numa node link for lcore 1 - using physical package id instead
  5. EAL: Detected lcore 1 as core 1 on socket 0
  6. EAL: Cannot read numa node link for lcore 2 - using physical package id instead
  7. EAL: Detected lcore 2 as core 0 on socket 1
  8. EAL: Cannot read numa node link for lcore 3 - using physical package id instead
  9. EAL: Detected lcore 3 as core 1 on socket 1
  10. EAL: Skip lcore 4 (not detected)
  11. EAL: Skip lcore 5 (not detected)
  12. EAL: Skip lcore 6 (not detected)
  13. EAL: Skip lcore 7 (not detected)
  14. EAL: Skip lcore 8 (not detected)
  15. EAL: Skip lcore 9 (not detected)
  16. EAL: Skip lcore 10 (not detected)
  17. EAL: Skip lcore 11 (not detected)
  18. EAL: Skip lcore 12 (not detected)
  19. EAL: Skip lcore 13 (not detected)
  20. EAL: Skip lcore 14 (not detected)
  21. EAL: Skip lcore 15 (not detected)
  22. EAL: Skip lcore 16 (not detected)
  23. EAL: Skip lcore 17 (not detected)
  24. EAL: Skip lcore 18 (not detected)
  25. EAL: Skip lcore 19 (not detected)
  26. EAL: Skip lcore 20 (not detected)
  27. EAL: Skip lcore 21 (not detected)
  28. EAL: Skip lcore 22 (not detected)
  29. EAL: Skip lcore 23 (not detected)
  30. EAL: Skip lcore 24 (not detected)
  31. EAL: Skip lcore 25 (not detected)
  32. EAL: Skip lcore 26 (not detected)
  33. EAL: Skip lcore 27 (not detected)
  34. EAL: Skip lcore 28 (not detected)
  35. EAL: Skip lcore 29 (not detected)
  36. EAL: Skip lcore 30 (not detected)
  37. EAL: Skip lcore 31 (not detected)
  38. EAL: Skip lcore 32 (not detected)
  39. EAL: Skip lcore 33 (not detected)
  40. EAL: Skip lcore 34 (not detected)
  41. EAL: Skip lcore 35 (not detected)
  42. EAL: Skip lcore 36 (not detected)
  43. EAL: Skip lcore 37 (not detected)
  44. EAL: Skip lcore 38 (not detected)
  45. EAL: Skip lcore 39 (not detected)
  46. EAL: Skip lcore 40 (not detected)
  47. EAL: Skip lcore 41 (not detected)
  48. EAL: Skip lcore 42 (not detected)
  49. EAL: Skip lcore 43 (not detected)
  50. EAL: Skip lcore 44 (not detected)
  51. EAL: Skip lcore 45 (not detected)
  52. EAL: Skip lcore 46 (not detected)
  53. EAL: Skip lcore 47 (not detected)
  54. EAL: Skip lcore 48 (not detected)
  55. EAL: Skip lcore 49 (not detected)
  56. EAL: Skip lcore 50 (not detected)
  57. EAL: Skip lcore 51 (not detected)
  58. EAL: Skip lcore 52 (not detected)
  59. EAL: Skip lcore 53 (not detected)
  60. EAL: Skip lcore 54 (not detected)
  61. EAL: Skip lcore 55 (not detected)
  62. EAL: Skip lcore 56 (not detected)
  63. EAL: Skip lcore 57 (not detected)
  64. EAL: Skip lcore 58 (not detected)
  65. EAL: Skip lcore 59 (not detected)
  66. EAL: Skip lcore 60 (not detected)
  67. EAL: Skip lcore 61 (not detected)
  68. EAL: Skip lcore 62 (not detected)
  69. EAL: Skip lcore 63 (not detected)
  70. EAL: Setting up memory...
  71. EAL: cannot open /proc/self/numa_maps, consider that all memory is in socket_id 0
  72. EAL: Ask a virtual area of 0xe800000 bytes
  73. EAL: Virtual area found at 0xa8400000 (size = 0xe800000)
  74. EAL: Ask a virtual area of 0x200000 bytes
  75. EAL: Virtual area found at 0xa8000000 (size = 0x200000)
  76. EAL: Ask a virtual area of 0x400000 bytes
  77. EAL: Virtual area found at 0xa7a00000 (size = 0x400000)
  78. EAL: Ask a virtual area of 0x200000 bytes
  79. EAL: Virtual area found at 0xa7600000 (size = 0x200000)
  80. EAL: Ask a virtual area of 0xc00000 bytes
  81. EAL: Virtual area found at 0xa6800000 (size = 0xc00000)
  82. EAL: Ask a virtual area of 0x200000 bytes
  83. EAL: Virtual area found at 0xa6400000 (size = 0x200000)
  84. EAL: Ask a virtual area of 0x200000 bytes
  85. EAL: Virtual area found at 0xa6000000 (size = 0x200000)
  86. EAL: Requesting 128 pages of size 2MB from socket 0
  87. EAL: TSC frequency is ~2660068 KHz
  88. EAL: Master core 0 is ready (tid=b7599800)
  89. EAL: Core 1 is ready (tid=a5fffb40)
  90. EAL: Core 2 is ready (tid=a57feb40)
  91. EAL: Core 3 is ready (tid=a4ffdb40)
  92. hello from core 1
  93. hello from core 3
  94. hello from core 2
  95. hello from core 0
后面就可以用gdb调试了



阅读(1444) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~