From: Natalie Samsonov Date: Thu, 11 Jan 2018 15:35:41 +0000 (+0100) Subject: net/mrvl: fix oversize bpool handling X-Git-Tag: spdx-start~332 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a9bd1322b8cfe277e3ba2b81423e99ae14cd5d57;p=dpdk.git net/mrvl: fix oversize bpool handling Don't return mbuf to dpdk pool if failed to get buffer from the bpool. Fix maximum bpool size calculation to prevent unnecessary bpool oversize cases when working with small rx queues. Fixes: 0ddc9b815b11 ("net/mrvl: add net PMD skeleton") Cc: stable@dpdk.org Signed-off-by: Natalie Samsonov --- diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index 5c3b700090..e650bf8157 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -165,6 +165,8 @@ static int mrvl_lcore_first; static int mrvl_lcore_last; static int mrvl_dev_num; +static int mrvl_fill_bpool(struct mrvl_rxq *rxq, int num); + static inline int mrvl_get_bpool_size(int pp2_id, int pool_id) { @@ -461,19 +463,12 @@ mrvl_dev_start(struct rte_eth_dev *dev) { struct mrvl_priv *priv = dev->data->dev_private; char match[MRVL_MATCH_LEN]; - int ret; + int ret = 0, def_init_size; snprintf(match, sizeof(match), "ppio-%d:%d", priv->pp_id, priv->ppio_id); priv->ppio_params.match = match; - /* - * Calculate the maximum bpool size for refill feature to 1.5 of the - * configured size. In case the bpool size will exceed this value, - * superfluous buffers will be removed - */ - priv->bpool_max_size = priv->bpool_init_size + - (priv->bpool_init_size >> 1); /* * Calculate the minimum bpool size for refill feature as follows: * 2 default burst sizes multiply by number of rx queues. @@ -482,6 +477,29 @@ mrvl_dev_start(struct rte_eth_dev *dev) */ priv->bpool_min_size = priv->nb_rx_queues * MRVL_BURST_SIZE * 2; + /* In case initial bpool size configured in queues setup is + * smaller than minimum size add more buffers + */ + def_init_size = priv->bpool_min_size + MRVL_BURST_SIZE * 2; + if (priv->bpool_init_size < def_init_size) { + int buffs_to_add = def_init_size - priv->bpool_init_size; + + priv->bpool_init_size += buffs_to_add; + ret = mrvl_fill_bpool(dev->data->rx_queues[0], buffs_to_add); + if (ret) + RTE_LOG(ERR, PMD, "Failed to add buffers to bpool\n"); + } + + /* + * Calculate the maximum bpool size for refill feature as follows: + * maximum number of descriptors in rx queue multiply by number + * of rx queues plus minimum bpool size. + * In case the bpool size will exceed this value, superfluous buffers + * will be removed + */ + priv->bpool_max_size = (priv->nb_rx_queues * MRVL_PP2_RXD_MAX) + + priv->bpool_min_size; + ret = pp2_ppio_init(&priv->ppio_params, &priv->ppio); if (ret) { RTE_LOG(ERR, PMD, "Failed to init ppio\n"); @@ -1769,14 +1787,15 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) q->priv->bpool_init_size); for (i = 0; i < pkt_to_remove; i++) { - pp2_bpool_get_buff(hif, bpool, &buff); + ret = pp2_bpool_get_buff(hif, bpool, &buff); + if (ret) + break; mbuf = (struct rte_mbuf *) (cookie_addr_high | buff.cookie); rte_pktmbuf_free(mbuf); } mrvl_port_bpool_size - [bpool->pp2_id][bpool->id][core_id] -= - pkt_to_remove; + [bpool->pp2_id][bpool->id][core_id] -= i; } rte_spinlock_unlock(&q->priv->lock); }