[dpdk-dev] [PATCH 06/11] ethdev: allow ownership operations on unused port

Stephen Hemminger stephen at networkplumber.org
Thu May 10 22:26:46 CEST 2018


On Wed,  9 May 2018 11:43:32 +0200
Thomas Monjalon <thomas at monjalon.net> wrote:

> -	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> +	if (port_id >= RTE_MAX_ETHPORTS || ethdev->data->name[0] == '\0') {

Since name being empty now has significance, why not introduce an macro or inline function
to make the test. Also, static checkers don't like pointers which maybe outside valid
range (sometimes).

static inline bool rte_ethdev_is_unused(const struct rte_ethdev *ethdev)
{
	return ethdev->data->name[0] == '\0';
}

#define RTE_ETH_UNUSED_OR_ERR_RET(ethdev, retval)  do { \
	if (!rte_ethdev_is_unused(ethdev)) { \
		RTE_PMD_DEBUG_TRACE("Port already in use=%d\n", ethdev->port_id); \
		return retval; \
	} } while(0)


	


More information about the dev mailing list