dpdk_18_05 的例程使用


dpdk_18_05 的 helloworld 例程

编译

方法1: 编译并安装到 ./build/ (使用,后续都是以这个为例子)

	cd ${RTE_SDK}/examples/helloworld
	make

方法2: 编译并安装到 ${dpdk_example} 路径 (暂不使用)

	cd ${RTE_SDK}/examples/helloworld
	make O=${dpdk_example}

运行

	cd ${RTE_SDK}/examples/helloworld
	./build/helloworld

l2fwd 的 例程

编译

情况1. 编译的时候没有网卡的驱动。(使用,后续都是以这个为例子)

	EXTRA_CFLAGS="-O0 -g3" make

情况1. 编译的时候加上网卡的驱动。(暂不使用)

	EXTRA_CFLAGS="-O0 -g3 -lrte_pmd_ixgbe" make

查看应用程序是否有使用PMD驱动

	ldd build/l2fwd | grep pmd

如果为空。则表示应用程序没有使用PMD驱动。后续启动的时候需用-d指定驱动。

查询网卡驱动驱动库文件

通过网卡的 pci地址,查看网卡的 device id的值。

	# show the nic device id
	cat /sys/bus/pci/devices/0000:08:00.0/device
	>	0x10fb

在 dpdk 的源码中,通过 device id的值,查找到 device id 的宏。

	#define IXGBE_DEV_ID_82599_SFP			0x10FB

在 dpdk 的源码中,通过 device id的宏,查找到网卡所在的 id table

	pci_id_ixgbe_map = {
   
		{
    RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
	};

在 dpdk 的源码中,通过 id table,查找到网卡的驱动 rte_pci_driver

	static struct rte_pci_driver rte_ixgbe_pmd = {
   
		.id_table = pci_id_ixgbe_map,
		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
				 RTE_PCI_DRV_IOVA_AS_VA,
		.probe = eth_ixgbe_pci_probe,
		.remove = eth_ixgbe_pci_remove,
	};

在 dpdk 的源码中,查找到网卡的驱动 rte_pci_driver 的注册函数。
得到注册函数所在的文件路径。

	RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
	
	所在的文件路径为:
	 ${
   RTE_SDK}/drivers/net/ixgbe/ixgbe_ethdev.c

查看 Makefile,找到驱动库的名字。

	cd ${
   RTE_SDK}/drivers/net/ixgbe
	
	grep LIB Makefile | head -n 1
	>	LIB = librte_pmd_ixgbe.a

${RTE_SDK}/${RTE_TARGET}/lib 里,查看是否有驱动库。

	ls ${RTE_SDK}/${RTE_TARGET}/lib | grep librte_pmd_ixgbe
	>	librte_pmd_ixgbe.so
	>	librte_pmd_ixgbe.so.2.1

运行

情况1. 编译的时候没有网卡的驱动

需要在运行的时候指定驱动。
函数eal_plugins_init()会使用 dlopen()来打开so库文件。

	./build/l2fwd -d librte_pmd_ixgbe.so -w 08:00.0 -w 08:00.1 -c 0xf0 -n 4 -- -q 8 -p 0x3 -T 1 --no-mac-updating

情况2. 编译的时候加上网卡的驱动

不需要在运行的时候指定驱动。

	./build/l2fwd  -w 08:00.0 -w 08:00.1 -
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值