searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

DPDK使用踩坑小记

2023-11-28 01:16:03
59
0

1. 编译DPDK 带上debuginfo调试信息, 修改顶层的meson.build

project('DPDK', 'C',
    # Get version number from file.
    # Fallback to "more" for Windows compatibility.
    version: run_command(find_program('cat', 'more'),
        files('VERSION')).stdout().strip(),
    license: 'BSD',
    default_options: ['buildtype=debugoptimized', 'default_library=static'],
    meson_version: '>= 0.47.1'
)

2. 15年以前机器的不支持RDSEED指令

在config/x86/meson.build 看到如下配置:

optional_flags = [
        'AES',
        'AVX',
        'AVX2',
        'AVX512BW',
        'AVX512CD',
        'AVX512DQ',
        'AVX512F',
        'AVX512VL',
        'PCLMUL',
        'RDRND',

        'RDSEED',
        'VPCLMULQDQ',
]

删除这个flag,不需要CPU指令支持后即可。

3. 编译bpf 出现报错xsk 相关错误

In file included from ../drivers/net/af_xdp/rte_eth_af_xdp.c:19:0:
/usr/include/bpf/xsk.h: In function ‘xsk_ring_prod__needs_wakeup’:
/usr/include/bpf/xsk.h:82:21: error: ‘XDP_RING_NEED_WAKEUP’ undeclared (first use in this function)
  return *r->flags & XDP_RING_NEED_WAKEUP;
                     ^~~~~~~~~~~~~~~~~~~~
/usr/include/bpf/xsk.h:82:21: note: each undeclared identifier is reported only once for each function it appears in
/usr/include/bpf/xsk.h: In function ‘xsk_umem__extract_addr’:
/usr/include/bpf/xsk.h:173:16: error: ‘XSK_UNALIGNED_BUF_ADDR_MASK’ undeclared (first use in this function)
  return addr & XSK_UNALIGNED_BUF_ADDR_MASK;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bpf/xsk.h: In function ‘xsk_umem__extract_offset’:
/usr/include/bpf/xsk.h:178:17: error: ‘XSK_UNALIGNED_BUF_OFFSET_SHIFT’ undeclared (first use in this function)
  return addr >> XSK_UNALIGNED_BUF_OFFSET_SHIFT;
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[14/857] Generating pipeline.sym_chk with a meson_exe.py custom command

修复patch 如下:

diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
index 584f6820a639..954d66e85208 100644
--- a/tools/lib/bpf/xsk.h
+++ b/tools/lib/bpf/xsk.h
@@ -79,7 +79,11 @@ xsk_ring_cons__rx_desc(const struct xsk_ring_cons *rx, __u32 idx)
 
 static inline int xsk_ring_prod__needs_wakeup(const struct xsk_ring_prod *r)
 {
+#ifdef XDP_RING_NEED_WAKEUP
        return *r->flags & XDP_RING_NEED_WAKEUP;
+#else
+       return 0;
+#endif
 }
 
 static inline __u32 xsk_prod_nb_free(struct xsk_ring_prod *r, __u32 nb)
@@ -170,12 +174,20 @@ static inline void *xsk_umem__get_data(void *umem_area, __u64 addr)
 
 static inline __u64 xsk_umem__extract_addr(__u64 addr)
 {
+#ifdef XSK_UNALIGNED_BUF_ADDR_MASK
        return addr & XSK_UNALIGNED_BUF_ADDR_MASK;
+#else
+       return addr;
+#endif
 }
 
 static inline __u64 xsk_umem__extract_offset(__u64 addr)
 {
+#ifdef XSK_UNALIGNED_BUF_OFFSET_SHIFT
        return addr >> XSK_UNALIGNED_BUF_OFFSET_SHIFT;
+#else
+       return 0;
+#endif
 }
 
 static inline __u64 xsk_umem__add_offset_to_addr(__u64 addr)
0条评论
0 / 1000
l****n
6文章数
0粉丝数
l****n
6 文章 | 0 粉丝
原创

DPDK使用踩坑小记

2023-11-28 01:16:03
59
0

1. 编译DPDK 带上debuginfo调试信息, 修改顶层的meson.build

project('DPDK', 'C',
    # Get version number from file.
    # Fallback to "more" for Windows compatibility.
    version: run_command(find_program('cat', 'more'),
        files('VERSION')).stdout().strip(),
    license: 'BSD',
    default_options: ['buildtype=debugoptimized', 'default_library=static'],
    meson_version: '>= 0.47.1'
)

2. 15年以前机器的不支持RDSEED指令

在config/x86/meson.build 看到如下配置:

optional_flags = [
        'AES',
        'AVX',
        'AVX2',
        'AVX512BW',
        'AVX512CD',
        'AVX512DQ',
        'AVX512F',
        'AVX512VL',
        'PCLMUL',
        'RDRND',

        'RDSEED',
        'VPCLMULQDQ',
]

删除这个flag,不需要CPU指令支持后即可。

3. 编译bpf 出现报错xsk 相关错误

In file included from ../drivers/net/af_xdp/rte_eth_af_xdp.c:19:0:
/usr/include/bpf/xsk.h: In function ‘xsk_ring_prod__needs_wakeup’:
/usr/include/bpf/xsk.h:82:21: error: ‘XDP_RING_NEED_WAKEUP’ undeclared (first use in this function)
  return *r->flags & XDP_RING_NEED_WAKEUP;
                     ^~~~~~~~~~~~~~~~~~~~
/usr/include/bpf/xsk.h:82:21: note: each undeclared identifier is reported only once for each function it appears in
/usr/include/bpf/xsk.h: In function ‘xsk_umem__extract_addr’:
/usr/include/bpf/xsk.h:173:16: error: ‘XSK_UNALIGNED_BUF_ADDR_MASK’ undeclared (first use in this function)
  return addr & XSK_UNALIGNED_BUF_ADDR_MASK;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/bpf/xsk.h: In function ‘xsk_umem__extract_offset’:
/usr/include/bpf/xsk.h:178:17: error: ‘XSK_UNALIGNED_BUF_OFFSET_SHIFT’ undeclared (first use in this function)
  return addr >> XSK_UNALIGNED_BUF_OFFSET_SHIFT;
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[14/857] Generating pipeline.sym_chk with a meson_exe.py custom command

修复patch 如下:

diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
index 584f6820a639..954d66e85208 100644
--- a/tools/lib/bpf/xsk.h
+++ b/tools/lib/bpf/xsk.h
@@ -79,7 +79,11 @@ xsk_ring_cons__rx_desc(const struct xsk_ring_cons *rx, __u32 idx)
 
 static inline int xsk_ring_prod__needs_wakeup(const struct xsk_ring_prod *r)
 {
+#ifdef XDP_RING_NEED_WAKEUP
        return *r->flags & XDP_RING_NEED_WAKEUP;
+#else
+       return 0;
+#endif
 }
 
 static inline __u32 xsk_prod_nb_free(struct xsk_ring_prod *r, __u32 nb)
@@ -170,12 +174,20 @@ static inline void *xsk_umem__get_data(void *umem_area, __u64 addr)
 
 static inline __u64 xsk_umem__extract_addr(__u64 addr)
 {
+#ifdef XSK_UNALIGNED_BUF_ADDR_MASK
        return addr & XSK_UNALIGNED_BUF_ADDR_MASK;
+#else
+       return addr;
+#endif
 }
 
 static inline __u64 xsk_umem__extract_offset(__u64 addr)
 {
+#ifdef XSK_UNALIGNED_BUF_OFFSET_SHIFT
        return addr >> XSK_UNALIGNED_BUF_OFFSET_SHIFT;
+#else
+       return 0;
+#endif
 }
 
 static inline __u64 xsk_umem__add_offset_to_addr(__u64 addr)
文章来自个人专栏
云上网络
2 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0