[dpdk-dev] [PATCH 06/11] ethdev: allow ownership operations on unused port
Thomas Monjalon
thomas at monjalon.net
Thu May 10 23:53:41 CEST 2018
10/05/2018 22:26, Stephen Hemminger:
> 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)
Yes we can have a static function for this check.
The name should be "ethdev_is_allocated".
More information about the dev
mailing list