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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章