当前位置: 首页 > news >正文

Ubuntu 22.04 编译 DPDK 19.11 igb_uio 和 kni 报错解决办法

由于 Ubuntu22.04 内核版本和gcc版本比较高,在编译dpdk时会报错。
我使用的编译命令是:

make install T=x86_64-native-linuxapp-gcc

主要有以下几个错误:

1.error: this statement may fall through

== Build kernel/linux/igb_uioCC [M]  /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.o
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c: In function ‘igbuio_pci_enable_interrupts’:
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:230:20: error: this statement may fall through [-Werror=implicit-fallthrough=]230 |                 if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSIX) == 1) {|                    ^
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:240:9: note: here240 |         case RTE_INTR_MODE_MSI:|         ^~~~
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:250:20: error: this statement may fall through [-Werror=implicit-fallthrough=]250 |                 if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSI) == 1) {|                    ^
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:259:9: note: here259 |         case RTE_INTR_MODE_LEGACY:|         ^~~~
In file included from ./include/linux/device.h:15,from /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:8:
./include/linux/dev_printk.h:148:31: error: this statement may fall through [-Werror=implicit-fallthrough=]148 |         dev_printk_index_wrap(_dev_notice, KERN_NOTICE, dev, dev_fmt(fmt), ##__VA_ARGS__)|                               ^
./include/linux/dev_printk.h:110:17: note: in definition of macro ‘dev_printk_index_wrap’110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \|                 ^~~~~~~
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:267:17: note: in expansion of macro ‘dev_notice’267 |                 dev_notice(&udev->pdev->dev, "PCI INTX mask not supported\n");|                 ^~~~~~~~~~
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:269:9: note: here269 |         case RTE_INTR_MODE_NONE:|         ^~~~
cc1: all warnings being treated as errors

解决办法:

修改 x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/Makefile 文件,去掉“MODULE_CFLAGS += -Winline -Wall -Werror” -行的 -Werror 编译选项。

2. error: passing argument 1 of ‘get_user_pages_remote’ from incompatible pointer type

== Build kernel/linux/kniCC [M]  /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.o
In file included from /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.c:22:
/root/dpdk-19.11/kernel/linux/kni/kni_dev.h: In function ‘iova_to_phys’:
/root/dpdk-19.11/kernel/linux/kni/kni_dev.h:104:37: error: passing argument 1 of ‘get_user_pages_remote’ from incompatible pointer type [-Werror=incompatible-pointer-types]104 |         ret = get_user_pages_remote(tsk, tsk->mm, iova, 1,|                                     ^~~|                                     ||                                     struct task_struct *
In file included from ./arch/x86/include/asm/cacheflush.h:5,from ./include/linux/cacheflush.h:5,from ./include/linux/highmem.h:8,from ./include/linux/bvec.h:10,from ./include/linux/skbuff.h:17,from ./include/net/net_namespace.h:39,from ./include/linux/netdevice.h:37,from /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.c:9:
./include/linux/mm.h:1943:46: note: expected ‘struct mm_struct *’ but argument is of type ‘struct task_struct *’1943 | long get_user_pages_remote(struct mm_struct *mm,|                            ~~~~~~~~~~~~~~~~~~^~

解决办法:
修改 kernel/linux/kni/kni_dev.h 文件104行,改成:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)ret = get_user_pages_remote(tsk->mm, iova, 1,FOLL_TOUCH, &page, NULL, NULL);
#elseret = get_user_pages_remote(tsk, tsk->mm, iova, 1,FOLL_TOUCH, &page, NULL, NULL);
#endif /* >= 5.9.0 */
  1. error: implicit declaration of function ‘random_ether_addr’
== Build kernel/linux/kniCC [M]  /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.o
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.c: In function ‘kni_ioctl_create’:
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.c:406:17: error: implicit declaration of function ‘random_ether_addr’ [-Werror=implicit-function-declaration]406 |                 random_ether_addr(net_dev->dev_addr);|                 ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

解决办法:
修改 x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.c 文件 406行,
将 random_ether_addr 函数修改为 eth_random_addr。

  1. error: initialization of ‘void (*)(struct net_device , unsigned int)’ from incompatible pointer type ‘void ()(struct net_device *)
== Build kernel/linux/kniCC [M]  /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_misc.oCC [M]  /root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_net.o
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_net.c:786:27: error: initialization of ‘void (*)(struct net_device *, unsigned int)’ from incompatible pointer type ‘void (*)(struct net_device *)’ [-Werror=incompatible-pointer-types]786 |         .ndo_tx_timeout = kni_net_tx_timeout,|                           ^~~~~~~~~~~~~~~~~~
/root/dpdk-19.11/x86_64-native-linuxapp-gcc/build/kernel/linux/kni/kni_net.c:786:27: note: (near initialization for ‘kni_net_netdev_ops.ndo_tx_timeout’)
cc1: all warnings being treated as errors

解决办法:

修改 x86_64-native-linuxapp-gcc/build/kernel/linux/kni/Makefile 文件,MODULE_CFLAGS += -Wall -Werror 这一行追加 -Wno-error=incompatible-pointer-types 编译选项

http://www.lryc.cn/news/163175.html

相关文章:

  • Android Studio.exe 下载 2023 最新更新,网盘下载
  • element的el-select给下拉框添加背景
  • 正确理解党籍和党龄;入党和转正时间
  • C语言基础:printf 函数介绍;以及常用四种常用的数据类型
  • 【LeetCode-中等题】209. 长度最小的子数组
  • 比较聚合模型实战文本匹配
  • LA@二次型@标准化相关原理和方法
  • Git与IDEA: 解决`dev`分支切换问题及其背后原因 为何在IDEA中无法切换到`dev`分支?全面解析!
  • 什么是JavaScript中的严格模式(strict mode)?应用场景是什么?
  • 红外特征吸收峰特征总结(主要基团的红外特征吸收峰)
  • ChatGPT AIGC 完成关联分析散点图的应用
  • CentOS7.6上实现Spring Boot(JAR包)开机自启
  • Java开发之框架(spring、springmvc、springboot、mybatis)【面试篇 完结版】
  • QT人脸识别知识
  • 熟悉Redis6
  • ip地址会随网络变化而变化吗
  • QT连接服务器通信,客户端以及服务器端
  • Vuex仓库的创建
  • C++中的红黑树
  • SQL语法知识回顾
  • Java基础二十七(泛型)
  • Python入门教程36:urllib网页请求模块的用法
  • LeetCode 每日一题 2023/9/4-2023/9/10
  • C# Onnx Yolov8 Seg 分割
  • Postman接口测试流程
  • 探索GreatADM:如何快速定义监控
  • C# 参数名加冒号,可以打乱参数顺序
  • AVL树 模拟实现(插入)
  • Java面试整理(三)《JavaSE》
  • LeetCode 1282. Group the People Given the Group Size They Belong To【哈希表】1267