SPDK 新增 DPDK 提供的 Transport

SPDK添加新的Transport

  1. 添加源文件
lib/nvmf/xdma.c
  1. 修改 lib/nvmf/Makefile 增加 xdma.c
diff --git a/lib/nvmf/Makefile b/lib/nvmf/Makefile
index bc2e18606..c2f4d1d64 100644
--- a/lib/nvmf/Makefile
+++ b/lib/nvmf/Makefile
@@ -10,7 +10,7 @@ SO_VER := 15
 SO_MINOR := 0
 
 C_SRCS = ctrlr.c ctrlr_discovery.c ctrlr_bdev.c \
-        subsystem.c nvmf.c nvmf_rpc.c transport.c tcp.c
+        subsystem.c nvmf.c nvmf_rpc.c transport.c tcp.c xdma.c
 
 C_SRCS-$(CONFIG_RDMA) += rdma.c
 LIBNAME = nvmf
  1. 添加独立的 lib/xdma 文件夹用于包装 librte_net_xdma(DPDK提供的动态链接库) 的接口
0 directories, 36 files
➜  spdk git:(xdma) ✗ tree -L 2 ./lib/     
./lib/
└── xdma
    ├── Makefile
    └── xdma.c
  1. lib/xdma 添加 Makefile 和接口声明头文件;
# lib/xdma/Makefile
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 1
SO_MINOR := 0

C_SRCS = xdma.c
LIBNAME = xdma

SPDK_MAP_FILE = $(abspath $(CURDIR)/xdma.map)

include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
// include/spdk/xdma.h
*********
*********
*********
  1. lib/Makefile 中加入 xdma 编译子目录。
diff --git a/lib/Makefile b/lib/Makefile
index 5cf00b869..c149da8e0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -9,7 +9,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.lib_deps.mk
 
 DIRS-y += bdev blob blobfs conf dma accel event json jsonrpc \
           log lvol rpc sock thread trace util nvme vmd nvmf scsi \
-          ioat ut_mock iscsi notify init trace_parser
+          ioat ut_mock iscsi notify init trace_parser xdma
 ifeq ($(OS),Linux)
 DIRS-y += nbd ftl vfio_user
 ifeq ($(CONFIG_UBLK),y)

将 DPDK 中的 rte_net_xdma 驱动库集成到 SPDK 构建系统中

  1. lib/env_dpdk 中添加包裹文件 xdma.c,封装 rte_net_xdma 驱动相关接口,供 SPDK 调用
// lib/env_dpdk/xdma.c
*********
*********
*********
  1. 修改 lib/env_dpdk/Makefileenv.mk,将 xdma.c 加入编译源文件,并将 rte_net_xdma 加入 DPDK 库列表中,以确保构建时能够链接到 xdma 驱动
diff --git a/lib/env_dpdk/Makefile b/lib/env_dpdk/Makefile
index 7a53d1cde..6bd7892ec 100644
--- a/lib/env_dpdk/Makefile
+++ b/lib/env_dpdk/Makefile
@@ -13,7 +13,7 @@ CFLAGS += $(ENV_CFLAGS)
 C_SRCS = env.c memory.c pci.c init.c threads.c
 C_SRCS += pci_ioat.c pci_virtio.c pci_vmd.c pci_idxd.c
 C_SRCS += pci_event.c sigbus_handler.c pci_dpdk.c
-C_SRCS += pci_dpdk_2207.c pci_dpdk_2211.c
+C_SRCS += pci_dpdk_2207.c pci_dpdk_2211.c xdma.c
 LIBNAME = env_dpdk
 
 SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_env_dpdk.map)
diff --git a/lib/env_dpdk/env.mk b/lib/env_dpdk/env.mk
index d4fa958da..f38684078 100644
--- a/lib/env_dpdk/env.mk
+++ b/lib/env_dpdk/env.mk
@@ -32,7 +32,7 @@ endif
 
 DPDK_INC := -I$(DPDK_INC_DIR)
 
-DPDK_LIB_LIST = rte_eal rte_mempool rte_ring rte_mbuf rte_bus_pci rte_pci rte_mempool_ring
+DPDK_LIB_LIST = rte_eal rte_mempool rte_ring rte_mbuf rte_bus_pci rte_pci rte_mempool_ring rte_net_xdma
 DPDK_LIB_LIST += rte_telemetry rte_kvargs rte_rcu
 
 DPDK_POWER=n
  1. 修改 dpdkbuild/Makefile,将 net/xdma 加入 DPDK_DRIVERS,以便在构建 DPDK 时启用该驱动
diff --git a/dpdkbuild/Makefile b/dpdkbuild/Makefile
index 62b789119..f1431ba25 100644
--- a/dpdkbuild/Makefile
+++ b/dpdkbuild/Makefile
@@ -32,6 +32,7 @@ endif
 
 # the drivers we use
 DPDK_DRIVERS = bus bus/pci bus/vdev mempool/ring
+DPDK_DRIVERS += net net/xdma
 
 # Core DPDK libs
 DPDK_LIBS = eal ring mempool pci
posted @ 2025-05-12 20:39  Groot_Liu  阅读(19)  评论(0)    收藏  举报