[dpdk-dev] [PATCH v4 3/5] ethdev: add API to get hairpin peer ports list
Thomas Monjalon
thomas at monjalon.net
Wed Oct 14 17:02:08 CEST 2020
13/10/2020 18:19, Bing Zhao:
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -2208,6 +2208,30 @@ struct rte_eth_dev *
> return ret;
> }
>
> +int
> +rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports,
> + size_t len, uint32_t direction)
> +{
> + struct rte_eth_dev *dev;
> + int ret;
> +
> + if (!peer_ports || !len)
> + return -EINVAL;
> +
> + RTE_ETH_VALID_PORTID_OR_ERR_RET(cur_port, -EINVAL);
should be -ENODEV
> + dev = &rte_eth_devices[cur_port];
> + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->hairpin_get_peer_ports,
> + -ENOTSUP);
> +
> + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports,
> + len, direction);
> + if (ret < 0)
> + RTE_ETHDEV_LOG(ERR, "Failed to get %d hairpin peer %s ports",
> + cur_port, direction ? "RX" : "TX");
Missing \n
> +
> + return ret;
> +}
> --- a/lib/librte_ethdev/rte_ethdev.h
> +++ b/lib/librte_ethdev/rte_ethdev.h
> * @warning
> * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
> *
> + * Get all the hairpin peer RX / TX ports of the current port.
> + * The caller should ensure that the array is large enough to save the ports
> + * list.
> + *
> + * @param cur_port
> + * The current port identifier of the Ethernet device.
Why current? In general we use "port_id".
> + * @param peer_ports
> + * Pointer to the array to store the peer ports list.
> + * @param len
> + * Length of the array to store the port identifiers.
> + * @param direction
> + * Current port to peer port direction
> + * positive - current used as TX to get all peer RX ports.
> + * zero - current used as RX to get all peer TX ports.
> + *
> + * @return
> + * - (0 or positive) actual peer ports number.
> + * - (-EINVAL) if bad parameter.
> + * - (-ENOTSUP) if hardware doesn't support.
> + * - Others detailed errors from PMD drivers.
Please add ENODEV
> + */
> +__rte_experimental
> +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports,
> + size_t len, uint32_t direction);
More information about the dev
mailing list