From 43f4e3932afaa3dbca40255d6e8d5dce517434a1 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Thu, 22 Aug 2019 21:44:02 +0200 Subject: [PATCH] env_dpdk/memory: implement contiguity check for vtophys map We'll be now able to check contiguity for more than 2MB regions. Change-Id: I738ff451d534075c944972918d08e5e0cadea4f5 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466073 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- lib/env_dpdk/memory.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/env_dpdk/memory.c b/lib/env_dpdk/memory.c index 706471ef8..4a7839543 100644 --- a/lib/env_dpdk/memory.c +++ b/lib/env_dpdk/memory.c @@ -1086,6 +1086,17 @@ spdk_vtophys_notify(void *cb_ctx, struct spdk_mem_map *map, return rc; } +static int +vtophys_check_contiguous_entries(uint64_t paddr1, uint64_t paddr2) +{ + /* This function is always called with paddrs for two subsequent + * 2MB chunks in virtual address space, so those chunks will be only + * physically contiguous if the physical addresses are 2MB apart + * from each other as well. + */ + return (paddr2 - paddr1 == VALUE_2MB); +} + #if SPDK_VFIO_ENABLED static bool @@ -1274,7 +1285,7 @@ spdk_vtophys_init(void) { const struct spdk_mem_map_ops vtophys_map_ops = { .notify_cb = spdk_vtophys_notify, - .are_contiguous = NULL + .are_contiguous = vtophys_check_contiguous_entries, }; #if SPDK_VFIO_ENABLED