• dpdk kni二


    [root@localhost dpdk-19.11]# ./usertools/dpdk-devbind.py -b igb_uio 0000:05:00.0
    [root@localhost dpdk-19.11]#  ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x01 --config="(0,0,1)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: API CMD poll status timeout
    net_hinic: chain type: 0x7
    net_hinic: chain hw cpld error: 0x1
    net_hinic: chain hw check error: 0x0
    net_hinic: chain hw current fsm: 0x0
    net_hinic: chain hw current ci: 0x0
    net_hinic: Chain hw current pi: 0x1
    net_hinic: Send msg to mgmt failed
    net_hinic: Failed to get board info, err: -110, status: 0x0, out size: 0x0
    net_hinic: Check card workmode failed, dev_name: 0000:05:00.0
    net_hinic: Create nic device failed, dev_name: 0000:05:00.0
    net_hinic: Initialize 0000:05:00.0 in primary failed
    EAL: Requested device 0000:05:00.0 cannot be used
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: Error - exiting with code: 1
      Cause: No supported Ethernet device found
    [root@localhost dpdk-19.11]# ./usertools/dpdk-devbind.py -u  0000:05:00.0
    [root@localhost dpdk-19.11]# modprobe vfio
    [root@localhost dpdk-19.11]# modprobe vfio-pci
    [root@localhost dpdk-19.11]# ./usertools/dpdk-devbind.py -b vfio-pci  0000:05:00.0 -------换成vfio
    [root@localhost dpdk-19.11]#  ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x01 --config="(0,0,1)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'VA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    KNI: Can not open /dev/kni
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    KNI: KNI subsystem has not been initialized. Invoke rte_kni_init() first
    EAL: Error - exiting with code: 1
      Cause: Fail to create kni for port: 0
    [root@localhost dpdk-19.11]# ls /dev/kni
    ls: cannot access /dev/kni: No such file or directory
    [root@localhost dpdk-19.11]# gcc -V
     

    dpdk 创建kni

    DPDK创建kni设备

    https://blog.csdn.net/sinat_20184565/article/details/92700223

    [root@localhost dpdk-19.11]# ls -l /dev | awk /10,/
    crw-r--r--. 1 root root     10, 235 Aug 25 06:44 autofs
    crw-------. 1 root root     10,  62 Aug 25 06:44 cpu_dma_latency
    crw-------. 1 root root     10, 203 Aug 25 06:44 cuse
    crw-rw-rw-. 1 root root     10, 229 Aug 25 06:44 fuse
    crw-------. 1 root root     10, 183 Aug 25 06:44 hwrng
    crw-------. 1 root root     10, 232 Aug 25 06:44 kvm
    crw-rw----. 1 root disk     10, 237 Aug 25 06:44 loop-control
    crw-------. 1 root root     10,  59 Aug 25 06:44 memory_bandwidth
    crw-------. 1 root root     10,  61 Aug 25 06:44 network_latency
    crw-------. 1 root root     10,  60 Aug 25 06:44 network_throughput
    crw-------. 1 root root     10, 231 Aug 25 06:44 snapshot
    crw-------. 1 root root     10, 239 Aug 25 06:44 uhid
    crw-------. 1 root root     10,  63 Aug 25 06:44 vga_arbiter
    crw-------. 1 root root     10, 238 Aug 25 06:44 vhost-net
    crw-------. 1 root root     10, 241 Aug 25 06:44 vhost-vsock
    crw-------. 1 root root     10, 130 Aug 25 06:44 watchdog
    [root@localhost dpdk-19.11]# cat /proc/misc
    196 vfio
    130 watchdog
     59 memory_bandwidth
     60 network_throughput
     61 network_latency
     62 cpu_dma_latency
    183 hw_random
    235 autofs
    231 snapshot
    232 kvm
     63 vga_arbiter
    [root@localhost dpdk-19.11]# cat /proc/misc
     58 kni
    196 vfio
    130 watchdog
     59 memory_bandwidth
     60 network_throughput
     61 network_latency
     62 cpu_dma_latency
    183 hw_random
    235 autofs
    231 snapshot
    232 kvm
     63 vga_arbiter
    [root@localhost dpdk-19.11]# ls -l /dev | awk /10,/
    crw-r--r--. 1 root root     10, 235 Aug 25 06:44 autofs
    crw-------. 1 root root     10,  62 Aug 25 06:44 cpu_dma_latency
    crw-------. 1 root root     10, 203 Aug 25 06:44 cuse
    crw-rw-rw-. 1 root root     10, 229 Aug 25 06:44 fuse
    crw-------. 1 root root     10, 183 Aug 25 06:44 hwrng
    crw-------. 1 root root     10, 232 Aug 25 06:44 kvm
    crw-rw----. 1 root disk     10, 237 Aug 25 06:44 loop-control
    crw-------. 1 root root     10,  59 Aug 25 06:44 memory_bandwidth
    crw-------. 1 root root     10,  61 Aug 25 06:44 network_latency
    crw-------. 1 root root     10,  60 Aug 25 06:44 network_throughput
    crw-------. 1 root root     10, 231 Aug 25 06:44 snapshot
    crw-------. 1 root root     10, 239 Aug 25 06:44 uhid
    crw-------. 1 root root     10,  63 Aug 25 06:44 vga_arbiter
    crw-------. 1 root root     10, 238 Aug 25 06:44 vhost-net
    crw-------. 1 root root     10, 241 Aug 25 06:44 vhost-vsock
    crw-------. 1 root root     10, 130 Aug 25 06:44 watchdog
    [root@localhost dpdk-19.11]#  mknod /dev/kni c 10 58
    [root@localhost dpdk-19.11]# ls -l /dev | awk /10,/
    crw-r--r--. 1 root root     10, 235 Aug 25 06:44 autofs
    crw-------. 1 root root     10,  62 Aug 25 06:44 cpu_dma_latency
    crw-------. 1 root root     10, 203 Aug 25 06:44 cuse
    crw-rw-rw-. 1 root root     10, 229 Aug 25 06:44 fuse
    crw-------. 1 root root     10, 183 Aug 25 06:44 hwrng
    crw-r--r--. 1 root root     10,  58 Aug 26 23:59 kni
    crw-------. 1 root root     10, 232 Aug 25 06:44 kvm
    crw-rw----. 1 root disk     10, 237 Aug 25 06:44 loop-control
    crw-------. 1 root root     10,  59 Aug 25 06:44 memory_bandwidth
    crw-------. 1 root root     10,  61 Aug 25 06:44 network_latency
    crw-------. 1 root root     10,  60 Aug 25 06:44 network_throughput
    crw-------. 1 root root     10, 231 Aug 25 06:44 snapshot
    crw-------. 1 root root     10, 239 Aug 25 06:44 uhid
    crw-------. 1 root root     10,  63 Aug 25 06:44 vga_arbiter
    crw-------. 1 root root     10, 238 Aug 25 06:44 vhost-net
    crw-------. 1 root root     10, 241 Aug 25 06:44 vhost-vsock
    crw-------. 1 root root     10, 130 Aug 25 06:44 watchdog
         /* Check FD and open */
            if (kni_fd < 0) {
                    kni_fd = open("/dev/" KNI_DEVICE, O_RDWR);
                    if (kni_fd < 0) {
                            RTE_LOG(ERR, KNI,
                                    "Can not open /dev/%s
    ", KNI_DEVICE);
                            return -1;
                    }
            }
    [root@localhost dpdk-19.11]# ls /dev/kni -al
    crw-r--r--. 1 root root 10, 57 Aug 26 23:32 /dev/kni
    [root@localhost dpdk-19.11]# chmod 666 /dev/kni
    [root@localhost dpdk-19.11]# ls /dev/kni -al
    crw-rw-rw-. 1 root root 10, 57 Aug 26 23:32 /dev/kni
    

      

    [root@localhost dpdk-19.11]#  ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x01 --config="(0,0,1)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    
    Checking link status
    done
    Port0 Link Up - speed 40000Mbps - full-duplex
    APP: ========================
    APP: KNI Running
    APP: kill -SIGUSR1 29347
    APP:     Show KNI Statistics.
    APP: kill -SIGUSR2 29347
    APP:     Zero KNI Statistics.
    APP: ========================
    APP: Lcore 1 is writing to port 0
    APP: Lcore 2 has nothing to do
    APP: Lcore 4 has nothing to do
    APP: Lcore 6 has nothing to do
    APP: Lcore 8 has nothing to do
    APP: Lcore 10 has nothing to do
    APP: Lcore 12 has nothing to do
    APP: Lcore 14 has nothing to do
    APP: Lcore 16 has nothing to do
    APP: Lcore 18 has nothing to do
    APP: Lcore 0 is reading from port 0
    APP: Lcore 5 has nothing to do
    APP: Lcore 9 has nothing to do
    APP: Lcore 13 has nothing to do
    APP: Lcore 17 has nothing to do
    APP: Lcore 3 has nothing to do
    APP: Lcore 11 has nothing to do
    APP: Lcore 19 has nothing to do
    APP: Lcore 15 has nothing to do
    APP: Lcore 7 has nothing to do
    APP: Configure network interface of 0 up
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb

    [root@localhost kni]# ps  -elf | grep kni
    4 R root      29597  27964 99  80   0 - 8410281 -    01:55 pts/0    00:12:50 ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x01 --config=(0,1,1,1)
    1 S root      29619      2  0  80   0 -     0 kni_th 01:55 ?        00:00:00 [kni_single]
    0 S root      29686  28139  0  80   0 -  1729 pipe_w 02:04 pts/1    00:00:00 grep --color=auto kni
    [root@localhost kni]# kill -9 29597
    [root@localhost kni]# ps  -elf | grep kni
    0 S root      29710  28139  0  80   0 -  1729 pipe_w 02:04 pts/1    00:00:00 grep --color=auto kni
    [root@localhost kni]#

    carrier=on  否则无法从remote访问

    [root@localhost dpdk-19.11]# rmmod rte_kni.ko
    [root@localhost dpdk-19.11]# lsmod | grep rte_kni
    [root@localhost dpdk-19.11]# insmod ./build/kmod/rte_kni.ko carrier=on

    [root@localhost dpdk-19.11]# ifconfig vEth0_0 10.10.103.229/24 up
     
    [root@localhost dpdk-19.11]# ethtool vEth0_0
    Settings for vEth0_0:
            Link detected: yes
    [root@localhost dpdk-19.11]# ethtool -d  vEth0_0
    Cannot get register dump: Operation not supported
    [root@localhost dpdk-19.11]# 
    
    [root@localhost dpdk-19.11]# ifconfig vEth0_0
    vEth0_0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet6 fe80::7f0e:5c1c:93c8:c97  prefixlen 64  scopeid 0x20<link>
            ether 44:a1:91:a4:9b:eb  txqueuelen 1000  (Ethernet)
            RX packets 7436  bytes 874584 (854.0 KiB)
            RX errors 0  dropped 78  overruns 0  frame 0
            TX packets 62  bytes 9936 (9.7 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    配置成"(0,1,2,1)",kni eth不会发送

    [root@localhost dpdk-19.11]#  ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x01 --config="(0,1,1,1)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    Checking link status
    done
    Port0 Link Up - speed 40000Mbps - full-duplex
    APP: ========================
    APP: KNI Running
    APP: kill -SIGUSR1 30138
    APP:     Show KNI Statistics.
    APP: kill -SIGUSR2 30138
    APP:     Zero KNI Statistics.
    APP: ========================
    APP: Lcore 1 is reading from port 0
    APP: Lcore 2 has nothing to do   -----------------nothing
    APP: Lcore 3 has nothing to do
    APP: Lcore 4 has nothing to do
    APP: Lcore 8 has nothing to do
    APP: Lcore 13 has nothing to do
    APP: Lcore 19 has nothing to do
    APP: Lcore 7 has nothing to do
    APP: Lcore 5 has nothing to do
    APP: Lcore 12 has nothing to do
    APP: Lcore 14 has nothing to do
    APP: Lcore 16 has nothing to do
    APP: Lcore 18 has nothing to do
    APP: Lcore 9 has nothing to do
    APP: Lcore 10 has nothing to do
    APP: Lcore 6 has nothing to do
    APP: Lcore 17 has nothing to do
    APP: Lcore 11 has nothing to do
    APP: Lcore 0 has nothing to do
    APP: Lcore 15 has nothing to do
    APP: Configure network interface of 0 up
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    [root@localhost dpdk-19.11]#  ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x01 --config="(0,1,2,1,2)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    
    Checking link status
    done
    Port0 Link Up - speed 40000Mbps - full-duplex
    APP: ========================
    APP: KNI Running
    APP: kill -SIGUSR1 30206
    APP:     Show KNI Statistics.
    APP: kill -SIGUSR2 30206
    APP:     Zero KNI Statistics.
    APP: ========================
    APP: Lcore 1 is reading from port 0   -----------承担接收
    APP: Lcore 2 is writing to port 0   -------------承担发送
    APP: Lcore 7 has nothing to do
    APP: Lcore 9 has nothing to do
    APP: Lcore 6 has nothing to do
    APP: Lcore 14 has nothing to do
    APP: Lcore 5 has nothing to do
    APP: Lcore 11 has nothing to do
    APP: Lcore 12 has nothing to do
    APP: Lcore 8 has nothing to do
    APP: Lcore 15 has nothing to do
    APP: Lcore 17 has nothing to do
    APP: Lcore 19 has nothing to do
    APP: Lcore 10 has nothing to do
    APP: Lcore 13 has nothing to do
    APP: Lcore 16 has nothing to do
    APP: Lcore 0 has nothing to do
    APP: Lcore 3 has nothing to do
    APP: Lcore 4 has nothing to do
    APP: Lcore 18 has nothing to do
    APP: Configure network interface of 0 up
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 1
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    [root@localhost dpdk-19.11]# ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x01 --config="(0,1,2,3)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    
    Checking link status
    done
    Port0 Link Up - speed 40000Mbps - full-duplex
    APP: ========================
    APP: KNI Running
    APP: kill -SIGUSR1 31491
    APP:     Show KNI Statistics.
    APP: kill -SIGUSR2 31491
    APP:     Zero KNI Statistics.
    APP: ========================
    APP: Lcore 1 is reading from port 0
    APP: Lcore 2 is writing to port 0
    APP: Lcore 4 has nothing to do
    APP: Lcore 6 has nothing to do
    APP: Lcore 19 has nothing to do
    APP: Lcore 9 has nothing to do
    APP: Lcore 10 has nothing to do
    APP: Lcore 12 has nothing to do
    APP: Lcore 13 has nothing to do
    APP: Lcore 15 has nothing to do
    APP: Lcore 17 has nothing to do
    APP: Lcore 18 has nothing to do
    APP: Lcore 8 has nothing to do
    APP: Lcore 11 has nothing to do
    APP: Lcore 14 has nothing to do
    APP: Lcore 7 has nothing to do
    APP: Lcore 3 has nothing to do
    APP: Lcore 16 has nothing to do
    APP: Lcore 5 has nothing to do
    APP: Lcore 0 has nothing to do
    APP: Configure network interface of 0 up
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb

    从remote ping

    [root@localhost dpdk-19.11]# ifconfig vEth0_0 10.10.103.229/24 up
    [root@localhost dpdk-19.11]# ifconfig vEth0_0 
    vEth0_0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.10.103.229  netmask 255.255.255.0  broadcast 10.10.103.255
            inet6 fe80::7f0e:5c1c:93c8:c97  prefixlen 64  scopeid 0x20<link>
            ether 44:a1:91:a4:9b:eb  txqueuelen 1000  (Ethernet)
            RX packets 22053  bytes 2573366 (2.4 MiB)
            RX errors 0  dropped 314  overruns 0  frame 0
            TX packets 80  bytes 12692 (12.3 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    [root@localhost dpdk-19.11]# 
    [root@bogon ~]# ping 10.10.103.229 -i 3
    PING 10.10.103.229 (10.10.103.229) 56(84) bytes of data.
    64 bytes from 10.10.103.229: icmp_seq=1 ttl=64 time=38.0 ms
    64 bytes from 10.10.103.229: icmp_seq=3 ttl=64 time=24.2 ms
    64 bytes from 10.10.103.229: icmp_seq=5 ttl=64 time=34.2 ms
    64 bytes from 10.10.103.229: icmp_seq=6 ttl=64 time=0.953 ms

    配置示例


    以下命令首先以多线程模式加载rte_kni内核模块。其次,kni应用指定两个接口(-p 0x3)启动;根据--config参数可知,接口0(0,4,6,8)使用核心4运行接收任务,核心6运行发送任务,并且创建一个KNI虚拟接口vEth0_0,启动一个内核处理线程绑定在核心8上。类似的接口1(0,5,7,9)使用核心5运行接收任务,核心7运行发送任务,并且创建一个KNI虚拟接口vEth1_0,启动一个内核处理线程绑定在核心9上。

    # rmmod rte_kni
    # insmod kmod/rte_kni.ko kthread_mode=multiple
    # ./build/kni -l 4-7 -n 4 -- -P -p 0x3 -m --config="(0,4,6,8),(1,5,7,9)"

    一张网卡配置多个kni网卡

    [root@localhost dpdk-19.11]# insmod ./build/kmod/rte_kni.ko carrier=on  thread_mode=multiple
    [root@localhost dpdk-19.11]# ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x1 --config="(0,1,2,3,4)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    
    Checking link status
    done
    Port0 Link Up - speed 40000Mbps - full-duplex
    APP: ========================
    APP: KNI Running
    APP: kill -SIGUSR1 32130
    APP:     Show KNI Statistics.
    APP: kill -SIGUSR2 32130
    APP:     Zero KNI Statistics.
    APP: ========================
    APP: Lcore 1 is reading from port 0 ---------------
    APP: Lcore 15 has nothing to do
    APP: Lcore 2 is writing to port 0      --------------------------
    APP: Lcore 5 has nothing to do
    APP: Lcore 7 has nothing to do
    APP: Lcore 9 has nothing to do
    APP: Lcore 11 has nothing to do
    APP: Lcore 13 has nothing to do
    APP: Lcore 14 has nothing to do
    APP: Lcore 3 has nothing to do
    APP: Lcore 16 has nothing to do
    APP: Lcore 18 has nothing to do
    APP: Lcore 0 has nothing to do
    APP: Lcore 8 has nothing to do
    APP: Lcore 12 has nothing to do
    APP: Lcore 4 has nothing to do
    APP: Lcore 19 has nothing to do
    APP: Lcore 10 has nothing to do
    APP: Lcore 17 has nothing to do
    APP: Lcore 6 has nothing to do
    APP: Configure network interface of 0 up
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 1
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Link status event report, dev_name: 0000:05:00.0, port_id: 0, link_status: DOWN
    net_hinic: Hilink info report after link down
    net_hinic: Cable information: Vendor: LUXSHARE-ICT, QSFP, Direct Attach Copper, length: 5m, max_speed: 100Gbps
    net_hinic: Link information: antoneg: on
    net_hinic: TX_FFE: PRE2=-4; PRE1=0; MAIN=61; POST1=-1; POST1X=0
    net_hinic: RX_CTLE: Gain1~3=3 7 7; Boost1~3=4 2 2; Zero1~3=5 1 0; Squelch1~3=2 2 2
    net_hinic: PMA ctrl: on, MAC tx enable, MAC rx enable, PMA debug inforeg: 0x0, PMA signal ok reg: 0x1, RF/LF status reg: 0x1
    net_hinic: alos: 0, rx_los: 0, PCS block counter reg: 0x1001,PCS link: 0x2, MAC link: 0x2 PCS_err_cnt: 0x0
    net_hinic: Link status event report, dev_name: 0000:05:00.0, port_id: 0, link_status: UP
    net_hinic: Hilink info report after link up
    net_hinic: Cable information: Vendor: LUXSHARE-ICT, QSFP, Direct Attach Copper, length: 5m, max_speed: 100Gbps
    net_hinic: Link information: speed 40Gbps, BASE-FEC, autoneg on
    net_hinic: TX_FFE: PRE2=-4; PRE1=0; MAIN=61; POST1=-1; POST1X=0
    net_hinic: RX_CTLE: Gain1~3=3 7 7; Boost1~3=6 2 2; Zero1~3=5 1 0; Squelch1~3=2 2 2
    23: vEth0_0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 44:a1:91:a4:9b:eb brd ff:ff:ff:ff:ff:ff
    24: vEth0_1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 6a:8b:0f:84:84:f2 brd ff:ff:ff:ff:ff:ff
    [root@localhost dpdk-19.11]# 
    [root@localhost dpdk-19.11]# ps -elf | grep kni
    4 R root      32130  27964 99  80   0 - 8411305 -    04:12 pts/0    00:16:13 ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x1 --config=(0,1,2,3,4)
    1 S root      32152      2  0  80   0 -     0 kni_th 04:12 ?        00:00:00 [kni_single]  --------------还是single
    0 S root      32269  28177  0  80   0 -  1729 pipe_w 04:18 pts/2    00:00:00 grep --color=auto kni
    ifconfig  vEth0_0  del 10.10.104.229
    [root@localhost dpdk-19.11]# ifconfig vEth0_0 10.10.103.229/24 up
    [root@localhost dpdk-19.11]# ifconfig vEth0_1 10.10.104.229/24 up
    [root@localhost dpdk-19.11]#
    
    
    
    [root@bogon ~]# ping 10.10.104.229 -i 3
    PING 10.10.104.229 (10.10.104.229) 56(84) bytes of data.
    64 bytes from 10.10.104.229: icmp_seq=1 ttl=64 time=43.3 ms
    64 bytes from 10.10.104.229: icmp_seq=2 ttl=64 time=9.99 ms
    64 bytes from 10.10.104.229: icmp_seq=3 ttl=64 time=16.9 ms
    ^C
    --- 10.10.104.229 ping statistics ---
    4 packets transmitted, 3 received, 25% packet loss, time 9010ms
    rtt min/avg/max/mdev = 9.990/23.430/43.362/14.377 ms
    [root@bogon ~]# ping 10.10.103.229 -i 3
    PING 10.10.103.229 (10.10.103.229) 56(84) bytes of data.
    64 bytes from 10.10.103.229: icmp_seq=3 ttl=64 time=13.9 ms
    64 bytes from 10.10.103.229: icmp_seq=5 ttl=64 time=13.9 ms
    64 bytes from 10.10.103.229: icmp_seq=6 ttl=64 time=9.96 ms
    64 bytes from 10.10.103.229: icmp_seq=7 ttl=64 time=26.9 ms
    64 bytes from 10.10.103.229: icmp_seq=9 ttl=64 time=23.9 ms

    绑定多张网卡

    ./usertools/dpdk-devbind.py  --bind=vfio-pci  0000:06:00.0
    
    [root@localhost dpdk-19.11]# ./usertools/dpdk-devbind.py  -s
    
    Network devices using DPDK-compatible driver
    ============================================
    0000:05:00.0 'Hi1822 Family (2*25GE) 0200' drv=vfio-pci unused=hinic,igb_uio
    0000:06:00.0 'Hi1822 Family (2*25GE) 0200' drv=vfio-pci unused=hinic,igb_uio
    
    ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x3 --config="(0,1,2,3),(1,7,8,9)"
    [root@localhost dpdk-19.11]# ps -elf | grep kni
    4 R root      32512  27964 99  80   0 - 8410299 -    04:33 pts/0    00:02:58 ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x3 --config=(0,1,2,3),(1,7,8,9)
    1 S root      32534      2  1  80   0 -     0 kni_th 04:33 ?        00:00:00 [kni_single]  ----还是single
    0 S root      32564  28177  0  80   0 -  1729 pipe_w 04:34 pts/2    00:00:00 grep --color=auto kni
    [root@localhost dpdk-19.11]# ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x3 --config="(0,1,2,3),(1,7,8,9)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    net_hinic: Initializing pf hinic-0000:06:00.0 in primary process
    net_hinic: Device 0000:06:00.0 hwif attribute:
    net_hinic: func_idx:1, p2p_idx:1, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:135, func_type:0
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x1, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x1, port_id: 0x1
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:06:00.0 in primary successfully
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    APP: Initialising port 1 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:06:00.0, port_id: 1
    net_hinic: Disable vlan strip succeed, device: hinic-0000:06:00.0, port_id: 1
    net_hinic: Set new mac address 44:a1:91:a4:9b:ec
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:06:00.0, port_id: 1, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:06:00.0, port_id: 1
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:06:00.0, port_id: 1, promisc: 0
    Checking link status
    done
    Port0 Link Up - speed 40000Mbps - full-duplex
    Port1 Link Up - speed 40000Mbps - full-duplex
    APP: ========================
    APP: KNI Running
    APP: kill -SIGUSR1 32512
    APP:     Show KNI Statistics.
    APP: kill -SIGUSR2 32512
    APP:     Zero KNI Statistics.
    APP: ========================
    APP: Lcore 1 is reading from port 0
    APP: Lcore 2 is writing to port 0
    APP: Configure network interface of 0 up
    APP: Lcore 3 has nothing to do
    APP: Lcore 4 has nothing to do
    APP: Lcore 8 is writing to port 1
    APP: Lcore 6 has nothing to do
    APP: Lcore 13 has nothing to do
    APP: Lcore 7 is reading from port 1
    APP: Lcore 9 has nothing to do
    APP: Lcore 11 has nothing to do
    APP: Lcore 5 has nothing to do
    APP: Lcore 15 has nothing to do
    APP: Lcore 17 has nothing to do
    APP: Lcore 10 has nothing to do
    APP: Lcore 0 has nothing to do
    APP: Lcore 14 has nothing to do
    APP: Lcore 18 has nothing to do
    APP: Lcore 12 has nothing to do
    APP: Lcore 19 has nothing to do
    APP: Lcore 16 has nothing to do
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb

    44:a1:91:a4:9b:eb是物理网卡的mac
    25: vEth0_0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether 44:a1:91:a4:9b:eb brd ff:ff:ff:ff:ff:ff
    26: vEth1_0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 44:a1:91:a4:9b:ec brd ff:ff:ff:ff:ff:ff
        inet6 fe80::9cfd:3d1f:690e:f670/64 scope link noprefixroute 
           valid_lft forever preferred_lft forever
    [root@localhost dpdk-19.11]# ifconfig vEth0_0 10.10.103.229/24  up
    [root@localhost dpdk-19.11]# ifconfig vEth1_0 10.10.104.229/24  up
    [root@localhost dpdk-19.11]#
    [root@bogon ~]# ping 10.10.103.229 -i 3
    PING 10.10.103.229 (10.10.103.229) 56(84) bytes of data.
    64 bytes from 10.10.103.229: icmp_seq=1 ttl=64 time=16.5 ms
    64 bytes from 10.10.103.229: icmp_seq=2 ttl=64 time=12.8 ms
    ^C
    --- 10.10.103.229 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 3003ms
    rtt min/avg/max/mdev = 12.843/14.709/16.575/1.866 ms
    [root@bogon ~]# ping 10.10.104.229 -i 3
    PING 10.10.104.229 (10.10.104.229) 56(84) bytes of data.
    64 bytes from 10.10.104.229: icmp_seq=1 ttl=64 time=23.0 ms
    64 bytes from 10.10.104.229: icmp_seq=2 ttl=64 time=9.84 ms
    ^C
    --- 10.10.104.229 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 3003ms
    rtt min/avg/max/mdev = 9.848/16.465/23.083/6.618 ms
    [root@bogon ~]# 
     kni_alloc(uint16_t port_id)
    {
        uint8_t i;
        struct rte_kni *kni;
        struct rte_kni_conf conf;
        struct kni_port_params **params = kni_port_params_array;
        int ret;
    
        if (port_id >= RTE_MAX_ETHPORTS || !params[port_id])
            return -1;
    
        params[port_id]->nb_kni = params[port_id]->nb_lcore_k ?
                    params[port_id]->nb_lcore_k : 1;
    
        for (i = 0; i < params[port_id]->nb_kni; i++) {
            /* Clear conf at first */
            memset(&conf, 0, sizeof(conf));
            if (params[port_id]->nb_lcore_k) {  // 多个kni
                snprintf(conf.name, RTE_KNI_NAMESIZE,
                        "vEth%u_%u", port_id, i);
                conf.core_id = params[port_id]->lcore_k[i];
                conf.force_bind = 1;
            } else
                snprintf(conf.name, RTE_KNI_NAMESIZE,
                            "vEth%u", port_id);
            conf.group_id = port_id;  --------------设置group_id
            conf.mbuf_size = MAX_PACKET_SZ;
            /*
             * The first KNI device associated to a port
             * is the master, for multiple kernel thread
             * environment.
             */
            if (i == 0) {
                struct rte_kni_ops ops;
                struct rte_eth_dev_info dev_info;
    
                ret = rte_eth_dev_info_get(port_id, &dev_info);
                if (ret != 0)
                    rte_exit(EXIT_FAILURE,
                        "Error during getting device (port %u) info: %s
    ",
                        port_id, strerror(-ret));
    
                /* Get the interface default mac address */
                ret = rte_eth_macaddr_get(port_id,
                    (struct rte_ether_addr *)&conf.mac_addr);
                if (ret != 0)
                    rte_exit(EXIT_FAILURE,
                        "Failed to get MAC address (port %u): %s
    ",
                        port_id, rte_strerror(-ret));
    
                rte_eth_dev_get_mtu(port_id, &conf.mtu);
    
                conf.min_mtu = dev_info.min_mtu;
                conf.max_mtu = dev_info.max_mtu;
    
                memset(&ops, 0, sizeof(ops));
                ops.port_id = port_id;
                ops.change_mtu = kni_change_mtu;   ------------应用程序实现
                ops.config_network_if = kni_config_network_interface;  -------------应用程序实现
                ops.config_mac_address = kni_config_mac_address;----------------应用程序实现
    
                kni = rte_kni_alloc(pktmbuf_pool, &conf, &ops);
            } else
                kni = rte_kni_alloc(pktmbuf_pool, &conf, NULL); --------没ops
    
            if (!kni)
                rte_exit(EXIT_FAILURE, "Fail to create kni for "
                            "port: %d
    ", port_id);
            params[port_id]->kni[i] = kni;
        }
    
        return 0;
    }
    [root@localhost dpdk-19.11]# cat  /sys/module/rte_kni/parameters/
    cat: /sys/module/rte_kni/parameters/: No such file or directory
     
    [root@localhost dpdk-19.11]# insmod ./build/kmod/rte_kni.ko "carrier=on kthread_mode=multiple"
    [root@localhost dpdk-19.11]# cat  /sys/module/rte_kni/parameters/*
    on
    multiple
    (null)
    [root@localhost dpdk-19.11]# 
    [root@localhost dpdk-19.11]# ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x1 --config="(0,1,2,3,4)"
    EAL: Detected 128 lcore(s)
    EAL: Detected 4 NUMA nodes
    EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
    EAL: Selected IOVA mode 'PA'
    EAL: Probing VFIO support...
    EAL: VFIO support initialized
    EAL: PCI device 0000:05:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    EAL:   using IOMMU type 1 (Type 1)
    net_hinic: Initializing pf hinic-0000:05:00.0 in primary process
    net_hinic: Device 0000:05:00.0 hwif attribute:
    net_hinic: func_idx:0, p2p_idx:0, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:15, func_type:2
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x0, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x0, port_id: 0x0
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get share resource capability:
    net_hinic: host_pctxs: 0x0, host_cctxs: 0x0, host_scqs: 0x0, host_srqs: 0x0, host_mpts: 0x0
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:05:00.0 in primary successfully
    EAL: PCI device 0000:06:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:200 net_hinic
    net_hinic: Initializing pf hinic-0000:06:00.0 in primary process
    net_hinic: Device 0000:06:00.0 hwif attribute:
    net_hinic: func_idx:1, p2p_idx:1, pciintf_idx:0, vf_in_pf:0, ppf_idx:0, global_vf_id:135, func_type:0
    net_hinic: num_aeqs:4, num_ceqs:4, num_irqs:32, dma_attr:2
    net_hinic: Get public resource capability:
    net_hinic: host_id: 0x0, ep_id: 0x1, intr_type: 0x0, max_cos_id: 0x7, er_id: 0x1, port_id: 0x1
    net_hinic: host_total_function: 0xf2, host_oq_id_mask_val: 0x8, max_vf: 0x78
    net_hinic: pf_num: 0x2, pf_id_start: 0x0, vf_num: 0xf0, vf_id_start: 0x10
    net_hinic: Get l2nic resource capability:
    net_hinic: max_sqs: 0x10, max_rqs: 0x10, vf_max_sqs: 0x4, vf_max_rqs: 0x4
    net_hinic: Initialize 0000:06:00.0 in primary successfully
    EAL: PCI device 0000:7d:00.0 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.1 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    EAL: PCI device 0000:7d:00.2 on NUMA socket 0
    EAL:   probe driver: 19e5:a222 net_hns3
    EAL: PCI device 0000:7d:00.3 on NUMA socket 0
    EAL:   probe driver: 19e5:a221 net_hns3
    APP: Initialising port 0 ...
    net_hinic: Disable vlan filter succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Disable vlan strip succeed, device: hinic-0000:05:00.0, port_id: 0
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    
    net_hinic: Disable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    net_hinic: Disable allmulticast succeed, nic_dev: hinic-0000:05:00.0, port_id: 0
    net_hinic: Enable promiscuous, nic_dev: hinic-0000:05:00.0, port_id: 0, promisc: 0
    
    Checking link status
    done
    Port0 Link Up - speed 40000Mbps - full-duplex
    APP: ========================
    APP: KNI Running
    APP: kill -SIGUSR1 32791
    APP:     Show KNI Statistics.
    APP: kill -SIGUSR2 32791
    APP:     Zero KNI Statistics.
    APP: ========================
    APP: Lcore 1 is reading from port 0
    APP: Lcore 2 is writing to port 0
    APP: Lcore 4 has nothing to do  ------还是空闲
    APP: Lcore 10 has nothing to do
    APP: Lcore 3 has nothing to do  ---------还是空闲
    APP: Lcore 19 has nothing to do
    APP: Lcore 0 has nothing to do
    APP: Lcore 5 has nothing to do
    APP: Lcore 6 has nothing to do
    APP: Lcore 12 has nothing to do
    APP: Lcore 14 has nothing to do
    APP: Lcore 15 has nothing to do
    APP: Lcore 17 has nothing to do
    APP: Lcore 8 has nothing to do
    APP: Lcore 9 has nothing to do
    APP: Lcore 11 has nothing to do
    APP: Lcore 7 has nothing to do
    APP: Lcore 18 has nothing to do
    APP: Lcore 13 has nothing to do
    APP: Lcore 16 has nothing to do
    APP: Configure network interface of 0 up
    net_hinic: Set new mac address 44:a1:91:a4:9b:eb
    [root@localhost kni]# ps -elf | grep kni
    4 R root      32791  27964 99  80   0 - 8410299 -    05:12 pts/0    00:00:14 ./examples/kni/build/app/kni -c 0xFFFFF -n 4 -- -P -p 0x1 --config=(0,1,2,3,4)
    1 S root      32813      2  0  80   0 -     0 kni_th 05:12 ?        00:00:00 [kni_vEth0_0]
    1 S root      32817      2  0  80   0 -     0 kni_th 05:12 ?        00:00:00 [kni_vEth0_1]
    0 S root      32850  28139  0  80   0 -  1729 pipe_w 05:12 pts/1    00:00:00 grep --color=auto kni
    [root@localhost kni]# 
    [root@localhost kni]# ps -mo pid,tid,%cpu,psr -p  32813
       PID    TID %CPU PSR
     32813      -  0.1   -
         -  32813  0.1   3
    [root@localhost kni]# ps -mo pid,tid,%cpu,psr -p  32817
       PID    TID %CPU PSR
     32817      -  0.4   -
         -  32817  0.4   4
     
    [root@localhost kni]# ps -mo pid,tid,%cpu,psr -p  32791
       PID    TID %CPU PSR
     32791      -  298   -
         -  32791 99.6   0
         -  32792  0.0  60
         -  32793  0.0  20
         -  32794 99.3   1
         -  32795 99.4   2
         -  32796  0.0   3
         -  32797  0.0   4
         -  32798  0.0   5
         -  32799  0.0   6
         -  32800  0.0   7
         -  32801  0.0   8
         -  32802  0.0   9
         -  32803  0.0  10
         -  32804  0.0  11
         -  32805  0.0  12
         -  32806  0.0  13
         -  32807  0.0  14
         -  32808  0.0  15
         -  32809  0.0  16
         -  32810  0.0  17
         -  32811  0.0  18
         -  32812  0.0  19
    [root@localhost kni]# 
    [root@localhost kni]# ps -T -p  32791
       PID   SPID TTY          TIME CMD
     32791  32791 pts/0    00:05:29 kni
     32791  32792 pts/0    00:00:00 eal-intr-thread
     32791  32793 pts/0    00:00:00 rte_mp_handle
     32791  32794 pts/0    00:05:28 lcore-slave-1
     32791  32795 pts/0    00:05:29 lcore-slave-2
     32791  32796 pts/0    00:00:00 lcore-slave-3
     32791  32797 pts/0    00:00:00 lcore-slave-4
     32791  32798 pts/0    00:00:00 lcore-slave-5
     32791  32799 pts/0    00:00:00 lcore-slave-6
     32791  32800 pts/0    00:00:00 lcore-slave-7
     32791  32801 pts/0    00:00:00 lcore-slave-8
     32791  32802 pts/0    00:00:00 lcore-slave-9
     32791  32803 pts/0    00:00:00 lcore-slave-10
     32791  32804 pts/0    00:00:00 lcore-slave-11
     32791  32805 pts/0    00:00:00 lcore-slave-12
     32791  32806 pts/0    00:00:00 lcore-slave-13
     32791  32807 pts/0    00:00:00 lcore-slave-14
     32791  32808 pts/0    00:00:00 lcore-slave-15
     32791  32809 pts/0    00:00:00 lcore-slave-16
     32791  32810 pts/0    00:00:00 lcore-slave-17
     32791  32811 pts/0    00:00:00 lcore-slave-18
     32791  32812 pts/0    00:00:00 lcore-slave-19
  • 相关阅读:
    Ubuntu:Failed to restart network.service: Unit network.service not found.
    解决 yarn或pnpm : 无法加载文件 C:\Users\hp\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本
    MSSQL表名、列名转大写SQL语句
    js 控制打开网页窗口的大小位置 sk
    js实现公历(阳历)和农历(阴历)的换算 sk
    一个怂女婿的成长笔记【二十四】
    牛顿迭代法(大白话)
    Source Generator实战
    i=i++
    记录下三种排序,冒泡,选择,和快速。
  • 原文地址:https://www.cnblogs.com/dream397/p/13570607.html
Copyright © 2020-2023  润新知