From: Anatoly Burakov Date: Wed, 11 Apr 2018 12:30:18 +0000 (+0100) Subject: net/mlx4: use virt2memseg instead of iteration X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c2fe5823224a;p=dpdk.git net/mlx4: use virt2memseg instead of iteration Reduce dependency on internal details of EAL memory subsystem, and simplify code. Signed-off-by: Anatoly Burakov Tested-by: Santosh Shukla Tested-by: Hemant Agrawal Tested-by: Gowrishankar Muthukrishnan --- diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile index b76d4f3363..8a6287f189 100644 --- a/drivers/net/mlx4/Makefile +++ b/drivers/net/mlx4/Makefile @@ -37,6 +37,7 @@ CFLAGS += -D_BSD_SOURCE CFLAGS += -D_DEFAULT_SOURCE CFLAGS += -D_XOPEN_SOURCE=600 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y) CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"' CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"' diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c index 410d7a7df5..b7e910d8f0 100644 --- a/drivers/net/mlx4/mlx4_mr.c +++ b/drivers/net/mlx4/mlx4_mr.c @@ -126,10 +126,9 @@ mlx4_check_mempool(struct rte_mempool *mp, uintptr_t *start, uintptr_t *end) struct mlx4_mr * mlx4_mr_get(struct priv *priv, struct rte_mempool *mp) { - const struct rte_memseg *ms = rte_eal_get_physmem_layout(); + const struct rte_memseg *ms; uintptr_t start; uintptr_t end; - unsigned int i; struct mlx4_mr *mr; if (mlx4_check_mempool(mp, &start, &end) != 0) { @@ -142,16 +141,13 @@ mlx4_mr_get(struct priv *priv, struct rte_mempool *mp) (void *)mp, (void *)start, (void *)end, (size_t)(end - start)); /* Round start and end to page boundary if found in memory segments. */ - for (i = 0; (i < RTE_MAX_MEMSEG) && (ms[i].addr != NULL); ++i) { - uintptr_t addr = (uintptr_t)ms[i].addr; - size_t len = ms[i].len; - unsigned int align = ms[i].hugepage_sz; + ms = rte_mem_virt2memseg((void *)start); + if (ms != NULL) + start = RTE_ALIGN_FLOOR(start, ms->hugepage_sz); + ms = rte_mem_virt2memseg((void *)end); + if (ms != NULL) + end = RTE_ALIGN_CEIL(end, ms->hugepage_sz); - if ((start > addr) && (start < addr + len)) - start = RTE_ALIGN_FLOOR(start, align); - if ((end > addr) && (end < addr + len)) - end = RTE_ALIGN_CEIL(end, align); - } DEBUG("mempool %p using start=%p end=%p size=%zu for MR", (void *)mp, (void *)start, (void *)end, (size_t)(end - start));