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: 0ddc9b815b
("net/mrvl: add net PMD skeleton")
Cc: stable@dpdk.org
Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
This commit is contained in:
parent
3588aaa68e
commit
a9bd1322b8
@ -165,6 +165,8 @@ static int mrvl_lcore_first;
|
|||||||
static int mrvl_lcore_last;
|
static int mrvl_lcore_last;
|
||||||
static int mrvl_dev_num;
|
static int mrvl_dev_num;
|
||||||
|
|
||||||
|
static int mrvl_fill_bpool(struct mrvl_rxq *rxq, int num);
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
mrvl_get_bpool_size(int pp2_id, int pool_id)
|
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;
|
struct mrvl_priv *priv = dev->data->dev_private;
|
||||||
char match[MRVL_MATCH_LEN];
|
char match[MRVL_MATCH_LEN];
|
||||||
int ret;
|
int ret = 0, def_init_size;
|
||||||
|
|
||||||
snprintf(match, sizeof(match), "ppio-%d:%d",
|
snprintf(match, sizeof(match), "ppio-%d:%d",
|
||||||
priv->pp_id, priv->ppio_id);
|
priv->pp_id, priv->ppio_id);
|
||||||
priv->ppio_params.match = match;
|
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:
|
* Calculate the minimum bpool size for refill feature as follows:
|
||||||
* 2 default burst sizes multiply by number of rx queues.
|
* 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;
|
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);
|
ret = pp2_ppio_init(&priv->ppio_params, &priv->ppio);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
RTE_LOG(ERR, PMD, "Failed to init ppio\n");
|
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);
|
q->priv->bpool_init_size);
|
||||||
|
|
||||||
for (i = 0; i < pkt_to_remove; i++) {
|
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 *)
|
mbuf = (struct rte_mbuf *)
|
||||||
(cookie_addr_high | buff.cookie);
|
(cookie_addr_high | buff.cookie);
|
||||||
rte_pktmbuf_free(mbuf);
|
rte_pktmbuf_free(mbuf);
|
||||||
}
|
}
|
||||||
mrvl_port_bpool_size
|
mrvl_port_bpool_size
|
||||||
[bpool->pp2_id][bpool->id][core_id] -=
|
[bpool->pp2_id][bpool->id][core_id] -= i;
|
||||||
pkt_to_remove;
|
|
||||||
}
|
}
|
||||||
rte_spinlock_unlock(&q->priv->lock);
|
rte_spinlock_unlock(&q->priv->lock);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user