From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id A3CDB1BE3E; Tue, 26 Jun 2018 19:38:04 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QHbbv9028354; Tue, 26 Jun 2018 18:37:37 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QHbbk8028353; Tue, 26 Jun 2018 18:37:37 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com Date: Tue, 26 Jun 2018 18:37:29 +0100 Message-Id: <1530034653-28299-3-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> References: <1530034653-28299-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH 2/6] mem: add hugepages check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2018 17:38:05 -0000 Devices can have addressing limitations and a driver can set a dma mask. This patch adds a function for checking hugepages iovas are within the range supported by the dma mask. Signed-off-by: Alejandro Lucero --- lib/librte_eal/linuxapp/eal/eal_memory.c | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 17c20d4..4c196a6 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1334,6 +1334,42 @@ void numa_error(char *where) return -1; } +int +rte_eal_memory_dma_mask_check(void) +{ + struct rte_mem_config *mcfg; + int i; + int total_segs_checked = 0; + uint64_t mask; + + if (!internal_config.dma_mask) + return 0; + + mask = 1ULL << internal_config.dma_mask; + mask -= 1; + + /* get pointer to global configuration */ + mcfg = rte_eal_get_configuration()->mem_config; + + for (i = 0; i < RTE_MAX_MEMSEG; i++) { + RTE_LOG(DEBUG, EAL, "Memseg %d with iova %"PRIx64" and mask %"PRIx64"\n", i, + mcfg->memseg[i].iova, mask); + + if (!mcfg->memseg[i].iova) + break; + + if (mcfg->memseg[i].iova & ~mask) { + return -1; + } + total_segs_checked++; + } + + RTE_LOG(DEBUG, EAL, "ALEJ: %d segments successfully checked with dma mask\n", + total_segs_checked); + + return 0; +} + /* * uses fstat to report the size of a file on disk */ -- 1.9.1