From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-7.cisco.com (rcdn-iport-7.cisco.com [173.37.86.78]) by dpdk.org (Postfix) with ESMTP id 6E17E2B98 for ; Mon, 11 Jul 2016 21:45:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2284; q=dns/txt; s=iport; t=1468266326; x=1469475926; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ATJWmBjM7dRBanI0OP4L+O7DOG65TP7zl04V0MQprdw=; b=MY1KOFS0mhY6+UURumfy+/MUKcPjSd7BOB04m2PuoZ/Pmw/IQdvzqWwx Yz2MC75cDIq6j7YcNxOHfYE4hyVCQcKTxWhLm+kTarXS3KM9r5/j58RZN MxL9Aye7gOzhYpKnaXt+FctCMpvJqMVDmbBwdJcPjXspvOAOgFT3A8O64 s=; X-IronPort-AV: E=Sophos;i="5.28,348,1464652800"; d="scan'208";a="122976266" Received: from rcdn-core-11.cisco.com ([173.37.93.147]) by rcdn-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2016 19:45:25 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-11.cisco.com (8.14.5/8.14.5) with ESMTP id u6BJjPSg023878; Mon, 11 Jul 2016 19:45:25 GMT Received: by cisco.com (Postfix, from userid 392789) id 6FFD83FAADF0; Mon, 11 Jul 2016 12:45:25 -0700 (PDT) From: John Daley To: dev@dpdk.org Cc: bruce.richardson@intel.com, olivier.matz@6wind.com, John Daley Date: Mon, 11 Jul 2016 12:45:01 -0700 Message-Id: <1468266301-2762-1-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1ca338a4-a8fe-8149-2373-d02fee3199cb@6wind.com> References: <1ca338a4-a8fe-8149-2373-d02fee3199cb@6wind.com> Subject: [dpdk-dev] [PATCH v2] net/enic: decrement Tx mbuf reference count before recycling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2016 19:45:26 -0000 In the burst Tx cleanup function, the reference count in mbufs returned to the pool should to be decremented before they are returned. Decrementing is not done by rte_mempool_put_bulk() so it must be done separately using __rte_pktmbuf_prefree_seg(). Also when returning unsent buffers when the device is stopped use rte_mbuf_free_seg() instead of rte_mempool_put() so that reference counts are properly decremented. Fixes: 36935afbc53c ("net/enic: refactor Tx mbuf recycling") Reviewed-by: Nelson Escobar Signed-off-by: John Daley --- v2: Use rte_pktmbuf_free_seg when returning mbufs when the device is stoped. Suggested by Olivier Matz . drivers/net/enic/enic_main.c | 2 +- drivers/net/enic/enic_rxtx.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index d8669cc..54aaa25 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -106,7 +106,7 @@ static void enic_free_wq_buf(struct vnic_wq_buf *buf) { struct rte_mbuf *mbuf = (struct rte_mbuf *)buf->mb; - rte_mempool_put(mbuf->pool, mbuf); + rte_pktmbuf_free_seg(mbuf); buf->mb = NULL; } diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c index 2f4a08c..845a8e6 100644 --- a/drivers/net/enic/enic_rxtx.c +++ b/drivers/net/enic/enic_rxtx.c @@ -398,7 +398,14 @@ static inline void enic_free_wq_bufs(struct vnic_wq *wq, u16 completed_index) pool = ((struct rte_mbuf *)buf->mb)->pool; for (i = 0; i < nb_to_free; i++) { buf = &wq->bufs[tail_idx]; - m = (struct rte_mbuf *)(buf->mb); + m = __rte_pktmbuf_prefree_seg((struct rte_mbuf *)(buf->mb)); + buf->mb = NULL; + + if (unlikely(m == NULL)) { + tail_idx = enic_ring_incr(desc_count, tail_idx); + continue; + } + if (likely(m->pool == pool)) { RTE_ASSERT(nb_free < ENIC_MAX_WQ_DESCS); free[nb_free++] = m; @@ -409,7 +416,6 @@ static inline void enic_free_wq_bufs(struct vnic_wq *wq, u16 completed_index) pool = m->pool; } tail_idx = enic_ring_incr(desc_count, tail_idx); - buf->mb = NULL; } rte_mempool_put_bulk(pool, (void **)free, nb_free); -- 2.7.0