Getting Started Guide for Linux(9)快速启动设置脚本

官方文档查看地址:
http://doc.dpdk.org/guides/linux_gsg/quick_start.html
PDF下载地址:
https://www.intel.com/content/www/us/en/embedded/technology/packet-processing/dpdk/dpdk-getting-started-guide.html

本篇难度系数:
翻译:★☆☆☆☆
理解:★☆☆☆☆

9.快速启动设置脚本
在usertools子目录中找到的dpdk-setup.sh脚本允许用户执行以下任务:

  • 构建DPDK库
  • 插入并删除DPDK IGB_UIO内核模块
  • 插入和删除VFIO内核模块
  • 插入并删除DPDK KNI内核模块
  • 为NUMA和非NUMA情况创建和删除大页
  • 查看网络端口状态并为DPDK应用程序使用预留端口
  • 设置将VFIO用作非特权用户的权限运行
  • 运行test和testpmd应用程序
  • 查看meminfo中的大页
  • 在/mnt/huge中列出大页
  • 删除已构建的DPDK库

完成这些步骤后,用户可以编译自己的应用程序,这些应用程序链接到EAL库中,以创建DPDK映像。

9.1脚本组织
sh脚本逻辑上组织为用户按顺序执行的一系列步骤。每个步骤都提供许多选项来指导用户完成所需的任务。下面是每个步骤的简要概述。

  • 步骤1:构建DPDK库
    首先,用户必须选择一个DPDK目标,以选择构建库时使用的正确目标类型和编译器选项。在此之前,用户必须在系统中安装所有库、模块、更新和编译器,如本入门指南前面几章所述。
  • 步骤2:设置环境
    用户配置Linux*环境以支持运行DPDK应用程序。可以为NUMA或非NUMA系统设置大页。任何现有的大型页面都将被删除。还可以在此步骤中插入所需的DPDK内核模块,并且可以将网络端口绑定到此模块以供DPDK应用程序使用。
  • 步骤3:运行应用程序
    在执行了其他步骤之后,用户可以运行测试应用程序。测试应用程序允许用户为DPDK运行一系列功能测试。testpmd应用程序也可以运行,它支持接收和发送数据包。
  • 步骤4:检查系统
    此步骤提供了一些工具,用于检查hugepage映射的状态。
  • 步骤5:系统清理最后一步是将系统恢复到原始状态的选项。

9.2用例
下面是如何使用dpdk-setup.sh脚本的一些示例。脚本应该使用source命令运行。脚本中的一些选项提示用户在继续之前输入更多的数据。

警告
应该使用root特权运行dpdk-setup.sh脚本。

source usertools/dpdk-setup.sh

------------------------------------------------------------------------

RTE_SDK exported as /home/user/rte

------------------------------------------------------------------------

Step 1: Select the DPDK environment to build

------------------------------------------------------------------------

[1] i686-native-linux-gcc

[2] i686-native-linux-icc

[3] ppc_64-power8-linux-gcc

[4] x86_64-native-freebsd-clang

[5] x86_64-native-freebsd-gcc

[6] x86_64-native-linux-clang

[7] x86_64-native-linux-gcc

[8] x86_64-native-linux-icc

------------------------------------------------------------------------

Step 2: Setup linux environment

------------------------------------------------------------------------

[11] Insert IGB UIO module

[12] Insert VFIO module

[13] Insert KNI module

[14] Setup hugepage mappings for non-NUMA systems

[15] Setup hugepage mappings for NUMA systems

[16] Display current Ethernet device settings

[17] Bind Ethernet device to IGB UIO module

[18] Bind Ethernet device to VFIO module

[19] Setup VFIO permissions

------------------------------------------------------------------------

Step 3: Run test application for linux environment

------------------------------------------------------------------------

[20] Run test application ($RTE_TARGET/app/test)

[21] Run testpmd application in interactive mode ($RTE_TARGET/app/testpmd)

------------------------------------------------------------------------

Step 4: Other tools

------------------------------------------------------------------------

[22] List hugepage info from /proc/meminfo

------------------------------------------------------------------------

Step 5: Uninstall and system cleanup

------------------------------------------------------------------------

[23] Uninstall all targets

[24] Unbind NICs from IGB UIO driver

[25] Remove IGB UIO module

[26] Remove VFIO module

[27] Remove KNI module

[28] Remove hugepage mappings

[29] Exit Script

选项:
下面的选择演示了x86_64-native-linux-gcc DPDK库的创建。

Option: 9

================== Installing x86_64-native-linux-gcc

Configuration done
== Build lib
...
Build complete
RTE_TARGET exported as x86_64-native-linux-gcc

下面的选择演示了DPDK UIO驱动程序的启动。

Option: 25

Unloading any existing DPDK UIO module
Loading DPDK UIO module

下面的选择演示了如何在NUMA系统中创建大型页面。每个节点分配1024个2 MByte的页面。结果是,应用程序应该使用-m 4096来启动应用程序,以访问这两个内存区域(如果没有提供-m选项,则自动执行)。

请注意
如果显示删除临时文件的提示,请键入“y”。

Option: 15

Removing currently reserved hugepages
mounting /mnt/huge and removing directory
Input the number of 2MB pages for each node
Example: to have 128MB of hugepages available per node,
enter '64' to reserve 64 * 2MB pages on each node
Number of pages for node0: 1024
Number of pages for node1: 1024
Reserving hugepages
Creating /mnt/huge and mounting as hugetlbfs

下面的选择演示了在单个核心上运行测试应用程序的启动。

Option: 20

Enter hex bitmask of cores to execute test app on
Example: to execute app on cores 0 to 7, enter 0xff
bitmask: 0x01
Launching app
EAL: coremask set to 1
EAL: Detected lcore 0 on socket 0
...
EAL: Master core 0 is ready (tid=1b2ad720)
RTE>>

9.3应用程序
一旦用户运行了dpdk-setup.sh脚本,构建了一个EAL目标并设置了大页(如果使用Linux EAL目标之一),用户就可以继续构建和运行他们的应用程序或提供的示例之一。

/examples目录中的示例为理解DPDK的操作提供了一个很好的起点。下面的命令序列显示了如何构建和运行helloworld示例应用程序。正如4.2.1节“应用程序使用逻辑核心”所建议的,在为应用程序选择要使用的核心掩码时,应该确定平台的逻辑核心布局。

cd helloworld/
make
  CC main.o
  LD helloworld
  INSTALL-APP helloworld
  INSTALL-MAP helloworld.map

sudo ./build/app/helloworld -l 0-3 -n 3
[sudo] password for rte:

EAL: coremask set to f
EAL: Detected lcore 0 as core 0 on socket 0
EAL: Detected lcore 1 as core 0 on socket 1
EAL: Detected lcore 2 as core 1 on socket 0
EAL: Detected lcore 3 as core 1 on socket 1
EAL: Setting up hugepage memory...
EAL: Ask a virtual area of 0x200000 bytes
EAL: Virtual area found at 0x7f0add800000 (size = 0x200000)
EAL: Ask a virtual area of 0x3d400000 bytes
EAL: Virtual area found at 0x7f0aa0200000 (size = 0x3d400000)
EAL: Ask a virtual area of 0x400000 bytes
EAL: Virtual area found at 0x7f0a9fc00000 (size = 0x400000)
EAL: Ask a virtual area of 0x400000 bytes
EAL: Virtual area found at 0x7f0a9f600000 (size = 0x400000)
EAL: Ask a virtual area of 0x400000 bytes
EAL: Virtual area found at 0x7f0a9f000000 (size = 0x400000)
EAL: Ask a virtual area of 0x800000 bytes
EAL: Virtual area found at 0x7f0a9e600000 (size = 0x800000)
EAL: Ask a virtual area of 0x800000 bytes
EAL: Virtual area found at 0x7f0a9dc00000 (size = 0x800000)
EAL: Ask a virtual area of 0x400000 bytes
EAL: Virtual area found at 0x7f0a9d600000 (size = 0x400000)
EAL: Ask a virtual area of 0x400000 bytes
EAL: Virtual area found at 0x7f0a9d000000 (size = 0x400000)
EAL: Ask a virtual area of 0x400000 bytes
EAL: Virtual area found at 0x7f0a9ca00000 (size = 0x400000)
EAL: Ask a virtual area of 0x200000 bytes
EAL: Virtual area found at 0x7f0a9c600000 (size = 0x200000)
EAL: Ask a virtual area of 0x200000 bytes
EAL: Virtual area found at 0x7f0a9c200000 (size = 0x200000)
EAL: Ask a virtual area of 0x3fc00000 bytes
EAL: Virtual area found at 0x7f0a5c400000 (size = 0x3fc00000)
EAL: Ask a virtual area of 0x200000 bytes
EAL: Virtual area found at 0x7f0a5c000000 (size = 0x200000)
EAL: Requesting 1024 pages of size 2MB from socket 0
EAL: Requesting 1024 pages of size 2MB from socket 1
EAL: Master core 0 is ready (tid=de25b700)
EAL: Core 1 is ready (tid=5b7fe700)
EAL: Core 3 is ready (tid=5a7fc700)
EAL: Core 2 is ready (tid=5affd700)
hello from core 1
hello from core 2
hello from core 3
hello from core 0
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章