From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by dpdk.org (Postfix) with ESMTP id C1FE4728A for ; Thu, 11 Jan 2018 16:36:00 +0100 (CET) Received: by mail-lf0-f66.google.com with SMTP id f3so3256825lfe.4 for ; Thu, 11 Jan 2018 07:36:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pWmnKKY0oMNINDw2mwrNGDRfffxZEs5t7DW5UAGrZxE=; b=sKhD3FUA0N96ONUPN5Ew1tG/4i93iJDIKiFQDYhm/ZSBrhSigCcB9zNFq/N/R1sBnm 6ExwnW0PIVdwMBsSD/IreWnXQQp6jBb0Bb+K2c+rf2+Qkb1q5gl+7xs8snNvsXNunOxf j6IvKzxPTr0effo7HMAmuuys4SGBy6tkHwb9dX9jlW/XN4p64BLu7GlnWl/NOx0Ulz+2 9+H1hlt6UzXDMqEavoOxuf7svoTY6y7luwgMsyu8FhvAQzrTJ5k+Mxv6O1W11AUK1zQt 9WnVEIVIoHOP4cqSfU3lLli72xaIQZ3UAMc4hpFXYoJ8lrOBseCDpfaISaFjPOMVFZiu bHBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pWmnKKY0oMNINDw2mwrNGDRfffxZEs5t7DW5UAGrZxE=; b=Y0FsKftPEWvLtudzJaN2wSHMIDSanb2c67zMpQ4QdPaHcWnA9syxDdS9xb2KoN0/HL WTmjs5zEomya+LA+WKu73zw3rOAyG7rbTDLZ5aZoEdCGub2g2vqfsenlqXPbETzxOsmj Ur4+58l6NQAfwArbUHhy/PnNel+0rFNRSeGlCRiCqrSM93WuX/06aZlCp2E1b563KcGx 49az1sE0vKHNIgFe+hEFnJsMRMysg/9ogOi63i8mMBpAV5+8nKcLdass+B2AlSG1iO3e o3RNMF4A0yEwvYJSd9EUfcQtKY59BORyzrCAM01ABs5U5BkM/q2KXGhbeu2+nsfTcvJp uDuw== X-Gm-Message-State: AKGB3mJ21NfnZiyC/lyAu/28PKRoQmnechol4iHx/uHZklo17F8hrKvs wmhhUmswjaqouWl+glkoZZ5qYqNgFCE= X-Google-Smtp-Source: ACJfBoupaS1rCHq/OiQ2daXw8EgoBqfKfK5X0TKxT+l1/7UUjVTLH9gdVu769yQIdgiFcuwUeLq6kQ== X-Received: by 10.46.41.68 with SMTP id u65mr15388179lje.115.1515684960149; Thu, 11 Jan 2018 07:36:00 -0800 (PST) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id y15sm3923018lje.10.2018.01.11.07.35.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jan 2018 07:35:59 -0800 (PST) From: Tomasz Duszynski To: dev@dpdk.org Cc: jck@semihalf.com, mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com, Jianbo.liu@arm.com Date: Thu, 11 Jan 2018 16:35:41 +0100 Message-Id: <1515684943-32506-4-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515684943-32506-1-git-send-email-tdu@semihalf.com> References: <1515684943-32506-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 3/5] net/mrvl: fix oversize bpool handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2018 15:36:00 -0000 From: Natalie Samsonov 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: 0ddc9b8 ("net/mrvl: add net PMD skeleton") Signed-off-by: Natalie Samsonov --- drivers/net/mrvl/mrvl_ethdev.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index 5c3b700..e650bf8 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,20 +463,13 @@ 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. * If the bpool size will be below this value, new buffers will @@ -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); } -- 2.7.4