[dpdk-dev] [PATCH v3 1/6] mem: add function for checking memsegs IOVAs addresses

Thomas Monjalon thomas at monjalon.net
Sun Oct 28 22:03:48 CET 2018


05/10/2018 14:45, Alejandro Lucero:
> A device can suffer addressing limitations. This function checks
> memsegs have iovas within the supported range based on dma mask.
> 
> PMDs should use this function during initialization if device
> suffers addressing limitations, returning an error if this function
> returns memsegs out of range.
> 
> Another usage is for emulated IOMMU hardware with addressing
> limitations.
> 
> It is necessary to save the most restricted dma mask for checking out
> memory allocated dynamically after initialization.
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero at netronome.com>
> Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.com>

I am really disappointed that no more people looked at this patch,
even after asking in several maintainers meeting:
	http://mails.dpdk.org/archives/dev/2018-October/116337.html
	http://mails.dpdk.org/archives/dev/2018-October/117092.html

This series will enter in 18.11-rc1 because no strong objection
(only 1 issue raised without any followup).

I had no time to review it recently, but after a quick look, I see
some details which can be improved. Please, Alejandro,
consider comments below for a separate patch in -rc2. Thanks

[...]
> +static int
> +check_iova(const struct rte_memseg_list *msl __rte_unused,
> +		const struct rte_memseg *ms, void *arg)
> +{
> +	uint64_t *mask = arg;
> +	rte_iova_t iova;
> +
> +	/* higher address within segment */
> +	iova = (ms->iova + ms->len) - 1;

This black magic needs to be better commented.

> +	if (!(iova & *mask))
> +		return 0;
> +
> +	RTE_LOG(DEBUG, EAL, "memseg iova %"PRIx64", len %zx, out of range\n",
> +			    ms->iova, ms->len);
> +
> +	RTE_LOG(DEBUG, EAL, "\tusing dma mask %"PRIx64"\n", *mask);
> +	return 1;
> +}
[...]
> --- a/lib/librte_eal/common/include/rte_memory.h
> +++ b/lib/librte_eal/common/include/rte_memory.h
> +/* check memsegs iovas are within a range based on dma mask */
> +int rte_eal_check_dma_mask(uint8_t maskbits);

You need to insert a doxygen comment, explaining the format
of the maskbits parameter, and the behaviour of the function.
The doxygen comment must also state the function is experimental.

About the name of the function, the trend is to use rte_mem_ prefix
instead of rte_eal_ in this case.

__rte_experimental tag must be added to the function prototype, I will do
when applying the patch.




More information about the dev mailing list