当前位置: 首页 > 工具软件 > DPDK-ANS > 使用案例 >

dpdk加速网络协议栈ANS用户手册

齐浩淼
2023-12-01

文章介绍了如何编译,配置,使用加速网络协议栈ANS。详情参见 https://github.com/ansyun/dpdk-ans

  

 

ANS User Guide

 

   

LIST

1.     Compile ANS.2

1.1.      Compile DPDK.2

1.2.      Generate ANS static libs.3

1.3.      Compile ANS.3

2.     ANS Startup.4

3.     ANS Configuration.6

3.1.      Configure IP.8

3.2.      Configure route.8

3.3.      Configure neigh.9

3.4.      Configure link.9

3.5.      Show IP statistics.9

3.6.      Configure ACL.10

3.7.      Configure log.11

 

   

1.   Compile ANS

1.1.  Compile DPDK

Ø  Create work directory

# mkdir work

 

Ø  Download DPDK package to work directory

# wget http://dpdk.org/rel/dpdk-17.05.2.tar.xz

 

Ø  Uncompressing DPDK package

# xz -d dpdk-17.05.2.tar.xz

# tar xvf dpdk-17.05.2.tar

 

Ø  Compile all DPDK libs

# make config T=x86_64-native-linuxapp-gcc

# make install T=x86_64-native-linuxapp-gcc

All DPDK libs are copied to x86_64-native-linuxapp-gcc/lib/directory.

For detail steps, please refer to DPDK website.

(http://dpdk.org/doc/guides/linux_gsg/index.html).

 

Notes: should choice DPDK version based on ANS version.

1.2.  Generate ANS static libs

Ø  Set DPDK environment

# export RTE_SDK=/home/work/dpdk-17.05

# export RTE_TARGET=x86_64-native-linuxapp-gcc

 

Ø  Set ANS environment

# export RTE_ANS=/home/work/dpdk-ans

 

Ø  Clone ANS from github

# git clone https://github.com/ansyun/dpdk-ans.git

 

Ø  Generate librte_ans/librte_anssock/librte_anscli

# ./ install_deps.sh

librte_ans is generated in librte_ans directory.

librte_anssock is generated in librte_anssock directory.

librte_anscli is generated in librte_anscli directory.

 

1.3.  Compile ANS

# cd dpdk-ans/ans

# make

 

Notes: If compile ans failed,shall upgrade your gcc and binutils version.

2.   ANS Startup

Ø  Run dpdk-setup.sh script to set DPDK environment. Need choice [16],[18], [19], [22].

 

root@ubuntu:~/dpdk-17.02# ./usertools/dpdk-setup.sh

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

 RTE_SDK exportedas /root/dpdk-17.02

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

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

 Step 2: Setuplinuxapp environment

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

[16] Insert IGB UIO module

[17] Insert VFIO module

[18] Insert KNI module

[19] Setup hugepage mappings for non-NUMA systems

[20] Setup hugepage mappings for NUMA systems

[21] Display current Ethernet/Crypto device settings

[22] Bind Ethernet/Crypto device to IGB UIO module

[23] Bind Ethernet/Crypto device to VFIO module

[24] Setup VFIO permissions

 

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

[27] List hugepage info from /proc/meminfo

 

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

 Step 5: Uninstalland system cleanup

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

[28] Unbind devices from IGB UIO or VFIO driver

[29] Remove IGB UIO module

[30] Remove VFIO module

[31] Remove KNI module

[32] Remove hugepage mappings

 

[33] Exit Script

 

Ø  ANS startup parameters

 

root@ubuntu:~/dpdk-ans/ans# ./build/ans --help

EAL: Detected 12 lcore(s)

 

Usage: ./build/ans [options]

 

EAL common options:

  -c COREMASK         Hexadecimal bitmask of cores to run on

  -l CORELIST         List of cores to run on

                     The argument format is <c1>[-c2][,c3[-c4],...]

                     where c1, c2, etc are core indexes between 0 and 128

  --lcoresCOREMAP    Map lcore set to physical cpuset

                      The argument format is

                           '<lcores[@cpus]>[<,lcores[@cpus]>...]'

                     lcores and cpus list are grouped by '(' and ')'

                     Within the group, '-' is used for range separator,

                      ',' is used for single numberseparator.

                     '( )' can be omitted for single element group,

                     '@' can be omitted if cpus and lcores have the same value

  --master-lcoreID   Core ID that is used as master

  -n CHANNELS         Number of memory channels

  -m MB               Memory to allocate (see also--socket-mem)

  -r RANKS            Force number of memory ranks (don'tdetect)

  -b,--pci-blacklist Add a PCI device in black list.

                     Prevent EAL from using this PCI device. The argument

                     format is <domain:bus:devid.func>.

  -w,--pci-whitelist Add a PCI device in white list.

                     Only use the specified PCI devices. The argument format

                     is <[domain:]bus:devid.func>. This option can be present

                     several times (once per device).

                     [NOTE: PCI whitelist cannot be used with -b option]

  --vdev              Add a virtual device.

                      The argument format is<driver><id>[,key=val,...]

                     (ex: --vdev=net_pcap0,iface=eth2).

  -dLIB.so|DIR       Add a driver or driverdirectory

                     (can be used multiple times)

 --vmware-tsc-map    Use VMware TSCmap instead of native RDTSC

  --proc-type         Type of this process(primary|secondary|auto)

  --syslog            Set syslog facility

  --log-level         Set default log level

  -v                  Display version informationon startup

  -h, --help          This help

 

EAL options for DEBUG use only:

 --huge-unlink       Unlinkhugepage files after init

  --no-huge           Use malloc instead of hugetlbfs

  --no-pci            Disable PCI

  --no-hpet           Disable HPET

  --no-shconf         No shared config (mmap'd files)

 

EAL Linux options:

  --socket-mem        Memory to allocate on sockets (commaseparated values)

  --huge-dir          Directory where hugetlbfs is mounted

 --file-prefix       Prefix forhugepage filenames

  --base-virtaddr     Base virtual address

 --create-uio-dev    Create/dev/uioX (usually done by hotplug)

  --vfio-intr         Interrupt mode for VFIO(legacy|msi|msix)

  --xen-dom0          Support running on Xen dom0 withouthugetlbfs

 

  -p PORTMASK:hexadecimal bitmask of ports to configure

  -P : enablepromiscuous mode

  --config(port,queue,lcore): rx queues configuration

  --no-numa:optional, disable numa awareness

  --enable-kni:optional, disable kni awareness

  --enable-jumbo: enablejumbo frame which max packet len is PKTLEN in decimal (64-9600)

 

Ø  ANS startup example

 

# ./build/ans -c 0x4 -n 1 --base-virtaddr=0x2aaa2aa0000-- -p 0x1 --config="(0,0,2)"

EAL: Detected 12 lcore(s)

EAL: 128 hugepages of size 2097152 reserved, but nomounted hugetlbfs found for that size

EAL: Probing VFIO support...

EAL: PCI device 0000:06:00.0 on NUMA socket -1

EAL:   probedriver: 8086:10fb net_ixgbe

EAL: PCI device 0000:06:00.1 on NUMA socket -1

EAL:   probedriver: 8086:10fb net_ixgbe

EAL: PCI device 0000:07:00.0 on NUMA socket -1

EAL:   probedriver: 8086:10fb net_ixgbe

EAL: PCI device 0000:07:00.1 on NUMA socket -1

EAL:   probedriver: 8086:10fb net_ixgbe

param nb 1 ports 1

port id 0

3.   ANS Configuration

Ø  Compile anscli

# make

 

Ø  Run anscli

# ./build/anscli

EAL: Detected 12 lcore(s)

EAL: WARNING: Address Space Layout Randomization (ASLR)is enabled in the kernel.

EAL:    This maycause issues with mapping memory into secondary processes

ans>

Notes:should run ans processbefore run anscli

 

Ø  anscli help

ans> help

ip addr add IFADDR dev STRING

ip addr del IFADDR dev STRING

ip addr show

ip route add DESTIP via NEXTHOP

ip route del DESTIP

ip route show

ip link show

ip neigh show

ip stats show

acl add index NUMBER srcaddr IPADDR dstaddr IPADDRsrcportstart NUMBER srcportend NUMBER dstportstart NUMBER dstportend NUMBERprotocol NUMBER dev IFACE

   index - ACL ruleindex [1 - 2048], large index has high priority.

   srcaddr - sourceIP subnet address, 0.0.0.0/0 match all IP, [ip-address/mask]

   dstaddr -destination IP subnet address, 0.0.0.0/0 match all IP, [ip-address/mask]

   srcportstart -source port start [0...65535]

   srcportend -source port end [0...65535]

   dstportstart -destination port start [0...65535]

   dstportend -destination port start [0...65535]

   protocol - IPprotocol, 0 match all protocol, [0...255]

   iface - inputinterface name, 'any' match all iface

  drop|accept|bypass - drops or accepts or bypass all packets that matchthe rule

 note: match ACLrule at PREROUTING.

         bypass:forward packets to kernel.

acl del index NUMBER

   index - ACL ruleindex [1 - 2048]

acl show

log level set [emerg | alert | crit | err | warning |notice | info | debug]

help

quit

3.1.  Configure IP

Ø  Add IP

ans> ip addr add 10.10.10.10/24 dev eth0

Add IP address successfully

ans>

 

Ø  Delete IP

ans> ip addr del 10.10.10.10/24 dev eth0

Del IP address successfully

ans>

 

Ø  Show IP

ans> ip addr show

 

 eth0: mtu 1500

   link/ether08:00:27:de:5d:8e

   inet addr:10.0.0.2/24

ans>

3.2.  Configure route

Ø  Add route

ans> ip route add 20.0.0.0/24 via 10.0.0.20

Add routing successfully

ans>

 

Ø  Delete route

ans> ip route del 20.0.0.0/24

Del routing successfully

ans>

 

Ø  Show route

ans> ip route show

 

ANS IP routing table

 10.0.0.0/24 viadev eth0 src 10.0.0.2

 10.10.0.0/24 via10.0.0.5 dev eth0

ans>

 

3.3.  Configure neigh

Ø  Show arp table

ans> ip neigh show

 

ANS IP neigh table

   10.0.0.11 deveth0 lladdr 08:00:27:82:ca:ad REACHABLE

ans>

 

3.4.  Configure link

Ø  Show link status

ans> ip link show

 

 eth0: port 0 state UP speed 1000Mbpsfull-duplex mtu 1500

  link/ether 08:00:27:de:5d:8e

   RXpackets:29 errors:0 dropped:0

   TXpackets:4 errors:0 dropped:0

   RXbytes:5433 TX bytes:312

ans>

3.5.  Show IP statistics

ans> ip stats show

 Total packets received               :33

 Checksum bad                         :0

 Packet too short                     :0

 Notenough data                      :0

 IPheader length < data size         :0

 IPlength < ip header length         :0

 Fragments received                   :0

 Frags dropped (dups, out of space)   :0

 Fragments timed out                  :0

 Packets forwarded                    :0

 Packets fast forwarded               :0

 Packets rcvd for unreachable dest    :0

 Packets forwarded on same net        :0

 Unknown or unsupported protocol      :0

 Datagrams delivered to upper level   :31

 Total ip packets generated here      :3

 Lostpackets due to nobufs, etc.     :0

 Total packets reassembled ok         :0

 Datagrams successfully fragmented    :0

 Output fragments created             :0

 Don't fragment flag was set, etc.    :0

 Error in option processing           :0

 Packets discarded due to no route    :0

 IPversion != 4                      :0

 Total raw ip packets generated       :0

 IPlength > max ip packet size       :0

 Multicasts for unregistered grps     :0

 Nomatch gif found                   :0

 Invalid address on header            :0

 Packets filtered                     :0

ans>

 

3.6.  Configure ACL

Ø  Add acl rule

ans> acl add index 100 srcaddr10.10.10.0/24 dstaddr 20.20.20.0/24 srcportstart 0 srcportend 65535dstportstart 0 dstportend 65535 protocol 0 iface any drop

Add ACL rule successfully

ans>

 

Ø  Delete acl rule

ans> acl del index 100

Delete ACL rule successfully

ans>

 

Ø  Show acl rule

 

ans> acl show

 

ACL rule 100:

 Source subnet address      :10.10.10.0/24

 Destination subnet address : 20.20.20.0/24

 Source port range          : 0 -65535

 Destination port range     : 0 -65535

  IPprotocol                : 0

  Interfacename             : any

 Action                     : drop

ans>

3.7.   Configurelog

Ø  Enable debug log

 

ans> log level set debug

Set log level successfully

ans>

 

Ø  Disable debug log

ans> log level set info

Set log level successfully

ans>

 


 类似资料: