[2/2] net/bonding: inherit descriptor limits from slaves
Checks
Commit Message
From: Ivan Malov <ivan.malov@oktetlabs.ru>
Descriptor limits are used by applications to take
optimal decisions on queue sizing.
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/bonding/rte_eth_bond_api.c | 54 ++++++++++++++++++++++
drivers/net/bonding/rte_eth_bond_pmd.c | 8 ++++
drivers/net/bonding/rte_eth_bond_private.h | 2 +
3 files changed, 64 insertions(+)
Comments
On Wed, Sep 5, 2018 at 5:14 AM Andrew Rybchenko
<arybchenko@solarflare.com> wrote:
>
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>
> Descriptor limits are used by applications to take
> optimal decisions on queue sizing.
>
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Chas Williams <chas3@att.com>
> ---
> drivers/net/bonding/rte_eth_bond_api.c | 54 ++++++++++++++++++++++
> drivers/net/bonding/rte_eth_bond_pmd.c | 8 ++++
> drivers/net/bonding/rte_eth_bond_private.h | 2 +
> 3 files changed, 64 insertions(+)
>
> diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
> index 206a5c797..9e039e73b 100644
> --- a/drivers/net/bonding/rte_eth_bond_api.c
> +++ b/drivers/net/bonding/rte_eth_bond_api.c
> @@ -399,6 +399,43 @@ eth_bond_slave_inherit_dev_info_tx_next(struct bond_dev_private *internals,
> internals->tx_queue_offload_capa;
> }
>
> +static void
> +eth_bond_slave_inherit_desc_lim_first(struct rte_eth_desc_lim *bond_desc_lim,
> + const struct rte_eth_desc_lim *slave_desc_lim)
> +{
> + memcpy(bond_desc_lim, slave_desc_lim, sizeof(*bond_desc_lim));
> +}
> +
> +static int
> +eth_bond_slave_inherit_desc_lim_next(struct rte_eth_desc_lim *bond_desc_lim,
> + const struct rte_eth_desc_lim *slave_desc_lim)
> +{
> + bond_desc_lim->nb_max = RTE_MIN(bond_desc_lim->nb_max,
> + slave_desc_lim->nb_max);
> + bond_desc_lim->nb_min = RTE_MAX(bond_desc_lim->nb_min,
> + slave_desc_lim->nb_min);
> + bond_desc_lim->nb_align = RTE_MAX(bond_desc_lim->nb_align,
> + slave_desc_lim->nb_align);
> +
> + if (bond_desc_lim->nb_min > bond_desc_lim->nb_max ||
> + bond_desc_lim->nb_align > bond_desc_lim->nb_max) {
> + RTE_BOND_LOG(ERR, "Failed to inherit descriptor limits");
> + return -EINVAL;
> + }
> +
> + /* Treat maximum number of segments equal to 0 as unspecified */
> + if (slave_desc_lim->nb_seg_max != 0 &&
> + (bond_desc_lim->nb_seg_max == 0 ||
> + slave_desc_lim->nb_seg_max < bond_desc_lim->nb_seg_max))
> + bond_desc_lim->nb_seg_max = slave_desc_lim->nb_seg_max;
> + if (slave_desc_lim->nb_mtu_seg_max != 0 &&
> + (bond_desc_lim->nb_mtu_seg_max == 0 ||
> + slave_desc_lim->nb_mtu_seg_max < bond_desc_lim->nb_mtu_seg_max))
> + bond_desc_lim->nb_mtu_seg_max = slave_desc_lim->nb_mtu_seg_max;
> +
> + return 0;
> +}
> +
> static int
> __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
> {
> @@ -458,9 +495,26 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
>
> eth_bond_slave_inherit_dev_info_rx_first(internals, &dev_info);
> eth_bond_slave_inherit_dev_info_tx_first(internals, &dev_info);
> +
> + eth_bond_slave_inherit_desc_lim_first(&internals->rx_desc_lim,
> + &dev_info.rx_desc_lim);
> + eth_bond_slave_inherit_desc_lim_first(&internals->tx_desc_lim,
> + &dev_info.tx_desc_lim);
> } else {
> + int ret;
> +
> eth_bond_slave_inherit_dev_info_rx_next(internals, &dev_info);
> eth_bond_slave_inherit_dev_info_tx_next(internals, &dev_info);
> +
> + ret = eth_bond_slave_inherit_desc_lim_next(
> + &internals->rx_desc_lim, &dev_info.rx_desc_lim);
> + if (ret != 0)
> + return ret;
> +
> + ret = eth_bond_slave_inherit_desc_lim_next(
> + &internals->tx_desc_lim, &dev_info.tx_desc_lim);
> + if (ret != 0)
> + return ret;
> }
>
> bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &=
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index ee24e9658..46b660396 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -2239,6 +2239,11 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
> memcpy(&dev_info->default_txconf, &internals->default_txconf,
> sizeof(dev_info->default_txconf));
>
> + memcpy(&dev_info->rx_desc_lim, &internals->rx_desc_lim,
> + sizeof(dev_info->rx_desc_lim));
> + memcpy(&dev_info->tx_desc_lim, &internals->tx_desc_lim,
> + sizeof(dev_info->tx_desc_lim));
> +
> /**
> * If dedicated hw queues enabled for link bonding device in LACP mode
> * then we need to reduce the maximum number of data path queues by 1.
> @@ -3064,6 +3069,9 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
> memset(&internals->default_txconf, 0,
> sizeof(internals->default_txconf));
>
> + memset(&internals->rx_desc_lim, 0, sizeof(internals->rx_desc_lim));
> + memset(&internals->tx_desc_lim, 0, sizeof(internals->tx_desc_lim));
> +
> memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
> memset(internals->slaves, 0, sizeof(internals->slaves));
>
> diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
> index d12a0ebbe..c81baa094 100644
> --- a/drivers/net/bonding/rte_eth_bond_private.h
> +++ b/drivers/net/bonding/rte_eth_bond_private.h
> @@ -162,6 +162,8 @@ struct bond_dev_private {
>
> struct rte_eth_rxconf default_rxconf; /**< Default RxQ conf. */
> struct rte_eth_txconf default_txconf; /**< Default TxQ conf. */
> + struct rte_eth_desc_lim rx_desc_lim; /**< Rx descriptor limits */
> + struct rte_eth_desc_lim tx_desc_lim; /**< Tx descriptor limits */
>
> uint16_t reta_size;
> struct rte_eth_rss_reta_entry64 reta_conf[ETH_RSS_RETA_SIZE_512 /
> --
> 2.17.1
>
@@ -399,6 +399,43 @@ eth_bond_slave_inherit_dev_info_tx_next(struct bond_dev_private *internals,
internals->tx_queue_offload_capa;
}
+static void
+eth_bond_slave_inherit_desc_lim_first(struct rte_eth_desc_lim *bond_desc_lim,
+ const struct rte_eth_desc_lim *slave_desc_lim)
+{
+ memcpy(bond_desc_lim, slave_desc_lim, sizeof(*bond_desc_lim));
+}
+
+static int
+eth_bond_slave_inherit_desc_lim_next(struct rte_eth_desc_lim *bond_desc_lim,
+ const struct rte_eth_desc_lim *slave_desc_lim)
+{
+ bond_desc_lim->nb_max = RTE_MIN(bond_desc_lim->nb_max,
+ slave_desc_lim->nb_max);
+ bond_desc_lim->nb_min = RTE_MAX(bond_desc_lim->nb_min,
+ slave_desc_lim->nb_min);
+ bond_desc_lim->nb_align = RTE_MAX(bond_desc_lim->nb_align,
+ slave_desc_lim->nb_align);
+
+ if (bond_desc_lim->nb_min > bond_desc_lim->nb_max ||
+ bond_desc_lim->nb_align > bond_desc_lim->nb_max) {
+ RTE_BOND_LOG(ERR, "Failed to inherit descriptor limits");
+ return -EINVAL;
+ }
+
+ /* Treat maximum number of segments equal to 0 as unspecified */
+ if (slave_desc_lim->nb_seg_max != 0 &&
+ (bond_desc_lim->nb_seg_max == 0 ||
+ slave_desc_lim->nb_seg_max < bond_desc_lim->nb_seg_max))
+ bond_desc_lim->nb_seg_max = slave_desc_lim->nb_seg_max;
+ if (slave_desc_lim->nb_mtu_seg_max != 0 &&
+ (bond_desc_lim->nb_mtu_seg_max == 0 ||
+ slave_desc_lim->nb_mtu_seg_max < bond_desc_lim->nb_mtu_seg_max))
+ bond_desc_lim->nb_mtu_seg_max = slave_desc_lim->nb_mtu_seg_max;
+
+ return 0;
+}
+
static int
__eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
{
@@ -458,9 +495,26 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)
eth_bond_slave_inherit_dev_info_rx_first(internals, &dev_info);
eth_bond_slave_inherit_dev_info_tx_first(internals, &dev_info);
+
+ eth_bond_slave_inherit_desc_lim_first(&internals->rx_desc_lim,
+ &dev_info.rx_desc_lim);
+ eth_bond_slave_inherit_desc_lim_first(&internals->tx_desc_lim,
+ &dev_info.tx_desc_lim);
} else {
+ int ret;
+
eth_bond_slave_inherit_dev_info_rx_next(internals, &dev_info);
eth_bond_slave_inherit_dev_info_tx_next(internals, &dev_info);
+
+ ret = eth_bond_slave_inherit_desc_lim_next(
+ &internals->rx_desc_lim, &dev_info.rx_desc_lim);
+ if (ret != 0)
+ return ret;
+
+ ret = eth_bond_slave_inherit_desc_lim_next(
+ &internals->tx_desc_lim, &dev_info.tx_desc_lim);
+ if (ret != 0)
+ return ret;
}
bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &=
@@ -2239,6 +2239,11 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
memcpy(&dev_info->default_txconf, &internals->default_txconf,
sizeof(dev_info->default_txconf));
+ memcpy(&dev_info->rx_desc_lim, &internals->rx_desc_lim,
+ sizeof(dev_info->rx_desc_lim));
+ memcpy(&dev_info->tx_desc_lim, &internals->tx_desc_lim,
+ sizeof(dev_info->tx_desc_lim));
+
/**
* If dedicated hw queues enabled for link bonding device in LACP mode
* then we need to reduce the maximum number of data path queues by 1.
@@ -3064,6 +3069,9 @@ bond_alloc(struct rte_vdev_device *dev, uint8_t mode)
memset(&internals->default_txconf, 0,
sizeof(internals->default_txconf));
+ memset(&internals->rx_desc_lim, 0, sizeof(internals->rx_desc_lim));
+ memset(&internals->tx_desc_lim, 0, sizeof(internals->tx_desc_lim));
+
memset(internals->active_slaves, 0, sizeof(internals->active_slaves));
memset(internals->slaves, 0, sizeof(internals->slaves));
@@ -162,6 +162,8 @@ struct bond_dev_private {
struct rte_eth_rxconf default_rxconf; /**< Default RxQ conf. */
struct rte_eth_txconf default_txconf; /**< Default TxQ conf. */
+ struct rte_eth_desc_lim rx_desc_lim; /**< Rx descriptor limits */
+ struct rte_eth_desc_lim tx_desc_lim; /**< Tx descriptor limits */
uint16_t reta_size;
struct rte_eth_rss_reta_entry64 reta_conf[ETH_RSS_RETA_SIZE_512 /