src/dpdk/lib/librte_eal/common/eal_common_memory.c
static int
check_dma_mask(uint8_t maskbits, bool thread_unsafe)
{
	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
	uint64_t mask;
	int ret;

	/* Sanity check. We only check width can be managed with 64 bits
	 * variables. Indeed any higher value is likely wrong. */
	if (maskbits > MAX_DMA_MASK_BITS) {
		RTE_LOG(ERR, EAL, "wrong dma mask size %u (Max: %u)\n",
				   maskbits, MAX_DMA_MASK_BITS);
		return -1;
	}

	/* create dma mask */
	mask = ~((1ULL << maskbits) - 1);

	if (thread_unsafe)
		ret = rte_memseg_walk_thread_unsafe(check_iova, &mask);
	else
		ret = rte_memseg_walk(check_iova, &mask);

	if (ret)
		/*
		 * Dma mask precludes hugepage usage.
		 * This device can not be used and we do not need to keep
		 * the dma mask.
		 */
		return 1;

	/*
	 * we need to keep the more restricted maskbit for checking
	 * potential dynamic memory allocation in the future.
	 */
	mcfg->dma_maskbits = mcfg->dma_maskbits == 0 ? maskbits :
			     RTE_MIN(mcfg->dma_maskbits, maskbits);

	return 0;
}
/* check memseg iovas are within the required range based on dma mask */
check memseg iovas are within the required range based on dma mask
check memseg iovas are within the required range based on dma mask
static int
check_dma_mask(uint8_t maskbits, bool thread_unsafe)
{
	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
	uint64_t mask;
	int ret;
	if (maskbits > MAX_DMA_MASK_BITS) {
		RTE_LOG(ERR, EAL, "wrong dma mask size %u (Max: %u)\n",
				   maskbits, MAX_DMA_MASK_BITS);
		return -1;
	}
	mask = ~((1ULL << maskbits) - 1);
	if (thread_unsafe)
		ret = rte_memseg_walk_thread_unsafe(check_iova, &mask);
	else
		ret = rte_memseg_walk(check_iova, &mask);
	if (ret)
		return 1;
	mcfg->dma_maskbits = mcfg->dma_maskbits == 0 ? maskbits :
			     RTE_MIN(mcfg->dma_maskbits, maskbits);
	return 0;
}
static int check_dma_mask ( uint8_t maskbits , bool thread_unsafe ) { struct rte_mem_config * mcfg = rte_eal_get_configuration ( ) -> mem_config ; uint64_t mask ; int ret ; if ( maskbits > MAX_DMA_MASK_BITS ) { RTE_LOG ( ERR , EAL , " \n " , maskbits , MAX_DMA_MASK_BITS ) ; return -1 ; } mask = ~ ( ( 1ULL << maskbits ) - 1 ) ; if ( thread_unsafe ) ret = rte_memseg_walk_thread_unsafe ( check_iova , & mask ) ; else ret = rte_memseg_walk ( check_iova , & mask ) ; if ( ret ) return 1 ; mcfg -> dma_maskbits = mcfg -> dma_maskbits == 0 ? maskbits : RTE_MIN ( mcfg -> dma_maskbits , maskbits ) ; return 0 ; }
check memseg iovas are within the required range based on dma mask
check memseg iovas are within the required range based on dma mask
/* Sanity check. We only check width can be managed with 64 bits
	 * variables. Indeed any higher value is likely wrong. */ /* create dma mask */ /*
		 * Dma mask precludes hugepage usage.
		 * This device can not be used and we do not need to keep
		 * the dma mask.
		 */ /*
	 * we need to keep the more restricted maskbit for checking
	 * potential dynamic memory allocation in the future.
	 */