[dpdk-dev] [PATCH v6] ethdev: add sanity checks in control APIs
Kevin Traynor
ktraynor at redhat.com
Fri Apr 16 12:22:02 CEST 2021
On 16/04/2021 07:52, Min Hu (Connor) wrote:
> This patch adds more sanity checks in control path APIs.
>
> Fixes: 214ed1acd125 ("ethdev: add iterator to match devargs input")
> Fixes: 3d98f921fbe9 ("ethdev: unify prefix for static functions and variables")
> Fixes: 0366137722a0 ("ethdev: check for invalid device name")
> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
> Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
> Fixes: f8244c6399d9 ("ethdev: increase port id range")
> Cc: stable at dpdk.org
>
> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
<snip>
> @@ -1298,9 +1342,15 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
> uint16_t old_mtu;
>
> RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> -
> dev = &rte_eth_devices[port_id];
>
> + if (dev_conf == NULL) {
> + RTE_ETHDEV_LOG(ERR,
> + "Cannot configure ethdev port %u to NULL dev_conf\n",
The others use a natural sounding names instead of argument name. If you
wanted to match that it could be "..to NULL conf"
> + port_id);
> + return -EINVAL;
> + }
> +
> RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
>
> if (dev->data->dev_started) {
<snip>
> @@ -2609,6 +2680,13 @@ rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
> RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> dev = &rte_eth_devices[port_id];
>
> + if (eth_link == NULL) {
> + RTE_ETHDEV_LOG(ERR,
> + "Cannot get ethdev port %u link for NULL eth_link\n",
^^^
> + port_id);
> + return -EINVAL;
> + }
> +
> if (dev->data->dev_conf.intr_conf.lsc &&
> dev->data->dev_started)
> rte_eth_linkstatus_get(dev, eth_link);
> @@ -2629,6 +2707,13 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
> RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> dev = &rte_eth_devices[port_id];
>
> + if (eth_link == NULL) {
> + RTE_ETHDEV_LOG(ERR,
> + "Cannot get nowait ethdev port %u for NULL link\n",
^^^
I would probably stick with "link" for both these functions, rather than
argument name "eth_link" in one "link" in other.
> + port_id);
> + return -EINVAL;
> + }
> +
> if (dev->data->dev_conf.intr_conf.lsc &&
> dev->data->dev_started)
> rte_eth_linkstatus_get(dev, eth_link);
Thanks Connor. There are only minor nits, so
Acked-by: Kevin Traynor <ktraynor at redhat.com>
More information about the dev
mailing list