zoukankan      html  css  js  c++  java
  • 鲲鹏服务器sriov

     

     

    [root@localhost dpdk-19.11]# echo 5 >   /sys/class/net/enp5s0/device/sriov_numvfs 
    -bash: echo: write error: No such file or directory
    [root@localhost dpdk-19.11]# dmesg | tail
    [1461727.761339] arm-smmu-v3 arm-smmu-v3.0.auto:        0x0000020000000000
    [1461727.767419] arm-smmu-v3 arm-smmu-v3.0.auto:        0x0000000000000100
    [1461727.773489] arm-smmu-v3 arm-smmu-v3.0.auto:        0x0000000000000000
    [1461727.923263] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x10 received:
    [1461727.923538] hinic 0000:05:00.0: No MGMT msg handler, mod = 0
    [1461727.935237] arm-smmu-v3 arm-smmu-v3.0.auto:        0x0000050000000010
    [1461727.941314] arm-smmu-v3 arm-smmu-v3.0.auto:        0x0000020000000000
    [1461727.947391] arm-smmu-v3 arm-smmu-v3.0.auto:        0x0000000000000100
    [1461727.953459] arm-smmu-v3 arm-smmu-v3.0.auto:        0x0000000000000000
    [1461728.007889] hinic 0000:05:00.0: No MGMT msg handler, mod = 0
    [root@localhost dpdk-19.11]# dmesg | grep iommu
    [root@localhost dpdk-19.11]# 
    [root@localhost dpdk-19.11]# cat /proc/cmdline
    BOOT_IMAGE=/vmlinuz-4.14.0-115.el7a.0.1.aarch64 root=UUID=a7b34ae0-7d43-4c06-9083-cd70919acbdf ro crashkernel=auto LANG=en_US.UTF-8
    [root@localhost dpdk-19.11]# cd /boot/
    [root@localhost boot]# ls
    config-4.14.0-115.el7a.0.1.aarch64                       initramfs-4.14.0-115.el7a.0.1.aarch64kdump.img
    efi                                                      symvers-4.14.0-115.el7a.0.1.aarch64.gz
    grub                                                     System.map-4.14.0-115.el7a.0.1.aarch64
    grub2                                                    vmlinuz-0-rescue-032bfe0dcc244e15accd08109835eb9a
    initramfs-0-rescue-032bfe0dcc244e15accd08109835eb9a.img  vmlinuz-4.14.0-115.el7a.0.1.aarch64
    initramfs-4.14.0-115.el7a.0.1.aarch64.img
    [root@localhost boot]# grep 'ro crashkernel=auto LANG=en_US.UTF-8' -rn *
    efi/EFI/centos/grub.cfg:100:    linux /vmlinuz-4.14.0-115.el7a.0.1.aarch64 root=UUID=a7b34ae0-7d43-4c06-9083-cd70919acbdf ro crashkernel=auto LANG=en_US.UTF-8
    [root@localhost boot]# 

     或者

     # vim /etc/default/grub
        GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora-server/root rd.lvm.lv=fedora-server/swap rhgb quiet intel_iommu=on"
        :wq
     # grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
    [root@localhost ~]#  cat  /sys/class/net/enp5s0/device/sriov_numvfs 
    0
    [root@localhost ~]# echo 5 > /sys/class/net/enp5s0/device/sriov_numvfs 
    
    [root@localhost ~]# cat /proc/cmdline
    BOOT_IMAGE=/vmlinuz-4.14.0-115.el7a.0.1.aarch64 root=UUID=a7b34ae0-7d43-4c06-9083-cd70919acbdf ro crashkernel=auto LANG=en_US.UTF-8 iommu=pt intel_iommu=on
    [root@localhost ~]# dmesg | grep iommu
    [    0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-4.14.0-115.el7a.0.1.aarch64 root=UUID=a7b34ae0-7d43-4c06-9083-cd70919acbdf ro crashkernel=auto LANG=en_US.UTF-8 iommu=pt intel_iommu=on
    [   12.251285] iommu: Adding device 0000:74:03.0 to group 0, default domain type 3
    [   12.314181] iommu: Adding device 0000:b4:03.0 to group 1, default domain type 3
    [   12.393070] iommu: Adding device 0000:7a:01.0 to group 2, default domain type 3
    [   12.491228] iommu: Adding device 0000:ba:01.0 to group 3, default domain type 3
    [   12.601861] iommu: Adding device 0000:7a:00.0 to group 4, default domain type 3
    [   12.745140] iommu: Adding device 0000:ba:00.0 to group 5, default domain type 3
    [   12.886158] iommu: Adding device 0000:7a:02.0 to group 6, default domain type 3
    [   13.025237] iommu: Adding device 0000:ba:02.0 to group 7, default domain type 3
    [   13.416989] iommu: Adding device 0000:00:00.0 to group 8, default domain type 3
    [   13.443539] iommu: Adding device 0000:00:08.0 to group 9, default domain type 3
    [   13.463424] iommu: Adding device 0000:00:0c.0 to group 10, default domain type 3
    [   13.483488] iommu: Adding device 0000:00:10.0 to group 11, default domain type 3
    [   13.503511] iommu: Adding device 0000:00:11.0 to group 12, default domain type 3
    [   13.523537] iommu: Adding device 0000:00:12.0 to group 13, default domain type 3
    [   13.569704] iommu: Adding device 0000:03:00.0 to group 14, default domain type 3
    [   13.581710] iommu: Adding device 0000:04:00.0 to group 15, default domain type 3
    [   13.589722] iommu: Adding device 0000:04:01.0 to group 16, default domain type 3
    [   13.597732] iommu: Adding device 0000:7c:00.0 to group 17, default domain type 3
    [   13.605809] iommu: Adding device 0000:80:00.0 to group 18, default domain type 3
    [   13.626025] iommu: Adding device 0000:80:08.0 to group 19, default domain type 3
    [   13.646068] iommu: Adding device 0000:80:0c.0 to group 20, default domain type 3
    [   13.666095] iommu: Adding device 0000:80:10.0 to group 21, default domain type 3
    [   13.754557] iommu: Adding device 0000:bc:00.0 to group 22, default domain type 3
    [   14.948030] iommu: Adding device 0000:02:00.0 to group 23, default domain type 3
    [   14.954111] iommu: Adding device 0000:74:02.0 to group 24, default domain type 3
    [   14.956317] iommu: Adding device 0000:81:00.0 to group 25, default domain type 3
    [   14.956995] iommu: Adding device 0000:7d:00.0 to group 26, default domain type 3
    [   14.957730] iommu: Adding device 0000:84:00.0 to group 27, default domain type 3
    [   14.958708] iommu: Adding device 0000:05:00.0 to group 28, default domain type 3
    [   14.984595] iommu: Adding device 0000:7d:00.1 to group 29, default domain type 3
    [   14.994075] iommu: Adding device 0000:08:00.0 to group 30, default domain type 3
    [   15.016038] iommu: Adding device 0000:7d:00.2 to group 31, default domain type 3
    [   15.035414] iommu: Adding device 0000:7d:00.3 to group 32, default domain type 3
    [   15.268209] iommu: Adding device 0000:06:00.0 to group 33, default domain type 3
    [   17.177451] iommu: Adding device 0000:74:04.0 to group 34, default domain type 3
    [   19.127404] iommu: Adding device 0000:b4:02.0 to group 35, default domain type 3
    [   21.067502] iommu: Adding device 0000:b4:04.0 to group 36, default domain type 3
    [root@localhost ~]# 
    在 /etc/default/grub 裡面, 在 GRUB_CMDLINE_LINUX_DEFAULT 要增加 粗體的參數
    GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"

    GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"
    如果是高階 intel xeon cpu 碰到 iommu group 的問題, 可以增加 pcie_acs_override=downstream

    然後執行
    # update-grub
    在 /etc/modules 裡面需要啟動
    vfio
    vfio_iommu_type1
    vfio_pci
    vfio_virqfd
    我有寫一個 iommu_status.bsh 來檢查是否所有的設定都可以了, 這樣子才能做 passthrough
    echo "iommu boot kernel flag"
    cat /etc/default/grub |grep iommu
    echo " "
    echo "dmesg | grep -e DMAR -e IOMMU"
    dmesg | grep -e DMAR -e IOMMU
    echo " "
    echo "lspci -vnn|grep Ethernet"
    lspci -vnn|grep Ethernet
    echo " "
    echo "ls -al /sys/kernel/iommu_groups"
    ls -al /sys/kernel/iommu_groups
    echo " "
    echo "find /sys/kernel/iommu_groups/ -type l"
    find /sys/kernel/iommu_groups/ -type l
    注意要點
    1. 如果你的主板沒有開啟 Intel VT-D 或 AMD-VI (IOMMU) 以及可以開啟 SR-IOV 的選項時, 代表了你的"硬體平台非常有可能 (99.9%) 不支援"
    2. 所有在"同一個" iommu group 下面的 device, "需要一起 " passthrough 給 vm. 所以主板的 PCH 以及 PCI-E 設備的 firmware 一定要寫的夠好, 才能這樣子 passthrough.
    3. Intel/Mellanox/NVidia passthrough 的成功比率比較好. 伺服器主板的話, x9/x10/x11 系列都可以做到. 越舊然後便宜的主板 PCH Root 不夠使用, passthrough 機率非常低.
    4. 需要passthrough 的 pci-e device, 它們需要使用 vfio_pci 的驅動, 而不可以使用原本 igb-vf 的驅動, 那樣子硬體就被 host 拿去使用了, 而 vm guest 就無法使用.
    /etc/modprobe.d/igb.conf 的內容, 我的卡是 dual eth port, 每一個 port 開2個 VF
    options igb max_vfs=2,2 
    /etc/modprobe.d/ixgbe.conf 的內容, 我有兩張卡, 其中有兩個是光纖模組, 所以設定不同
    options ixgbe max_vfs=4,4,4,4 allow_unsupported_sfp=1,1
    我有寫一個 set_mac.bsh, 內容如下
    ip link set eth10 up
    ip link set eth11 up
    ip link set eth10 vf 0 mac 7e:ba:b6:b5:ec:11
    ip link set eth10 vf 1 mac 7e:ba:b6:b5:ec:12
    ip link set eth11 vf 0 mac 7e:ba:b6:b5:ec:13
    ip link set eth11 vf 1 mac 7e:ba:b6:b5:ec:14
    因為 sr-iov 開啟的 vf, 其 mac 是亂數產生, 但是如果要 passthrough 給 pfsense 使用, 它 interface 是認 mac address 的, 其實很多 vm 下面的 udev 也都會認 mac address, 所以我會固定 assign mac.我有寫一個 vfio_pci.bsh 來修改 vf 的 loading driver. 重點要找出 vf 的 pci id, 可以透過 iommu_status.bsh 或是 lspci -nn 來看, 但是這個 script 在 pve 4.2 不需要用到, 但是之前的版版本需要.
    DEVLIST="0000:03:00.0 0000:03:00.1 0000:08:10.0 0000:08:10.1"
    for dev in $DEVLIST
    do
    vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
    device=$(cat /sys/bus/pci/devices/$dev/device)
    if [ -e /sys/bus/pci/devices/$dev/driver ]
    then
    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
    fi
    echo $vendor $device > /sys/bus/pci/driver/vfio-pci/new_id
    done
    在我的 PFSense VM 806.conf
    boot: cdnbootdisk: scsi0
    cores: 2
    cpu: host
    hostpci0: 03:00.1,pcie=1
    hostpci1: 08:10.0,pcie=1
    hostpci2: 08:10.1,pcie=1
    ide2: none,media=cdrom
    machine: q35
    memory: 1024
    name: pfsense
    net0: virtio=32:64:62:30:39:33,bridge=vmbr1
    numa: 0
    onboot: 1
    ostype: l26
    scsi0: vm:vm-806-disk-3,size=32G
    smbios1: uuid=af59d2ac-eb3b-4170-93e5-90534255e722
    sockets: 1
    startup: order=1
    在 Web GUI 界面只有看到 net0 的設定而已
     
    在 PFSense VM 裡面可以看到我的 Interfaces
    這樣子的設定好處如下
    1. WAN 使用實體 NIC 原因是它一定實體線路連線到 Hinet 的光線機.
    2. LAN_BSI 是 VF 在 sr-iov 那邊切割 vlan, 這樣子 vtag 封包處理時, 不需要透過 cpu, 也不會增加 network latency
    3. LAN_ASRS 有點同上
    4. LAN_VM 是在這台上所有的 VM/LXC 的 LAN, 沒有任何 edge 的 traffic 影響, 所有 vm to vm 以及 vm to lxc 的 traffic 都透過 kernel 來走, 完全不走到 實體 switch. 這部分提供一個非常穩定的 Data LAN
    Passthrough 參考 PVE 官網教學
    關於 LXC 如何使用 VF, 可以參考 Intel 教學
  • 相关阅读:
    关于jpa的Specification自定义函数,实现oracle的decode;以及如何在静态方法中调用注入的service
    转载-logbock.xml
    sql学习指南--持续更新
    转载-有时间担心中年危机,还不如用忧虑的时间来提升自己——再论程序员该如何避免所谓的中年危机
    转载-缓存
    转载-SpringBoot开发案例之整合日志管理
    转载-Spring Boot应用监控实战
    乐观锁 与 悲观锁
    独占锁 和 共享锁
    自旋锁
  • 原文地址:https://www.cnblogs.com/dream397/p/13652673.html
Copyright © 2011-2022 走看看