From patchwork Wed Jun 24 01:11:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 72047 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4FFDBA0350; Wed, 24 Jun 2020 03:12:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9850A1D705; Wed, 24 Jun 2020 03:12:07 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by dpdk.org (Postfix) with ESMTP id 0CD841D703 for ; Wed, 24 Jun 2020 03:12:06 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 58ECA20B7192; Tue, 23 Jun 2020 18:12:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 58ECA20B7192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1592961125; bh=n73Z0Ad4ZUntvjqaGraG5Y63nQJkCV07Oo/cXut0ako=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GLl0TKkObWMg7CX7Y4rOlLUSfOC/e1WLladTmxK5E+smrQfotp2lRC4N7aqwG7hVT 2p2sT+A8imJuvSGKgGeGjukrh0MJbVYPKgLhYPyW59MuOTvuSJvrID31auikqUl6BX YLqGMzxQp5SxL6ssLq5FYb679bjWdUyZeN0a4isg= From: longli@linuxonhyperv.com To: Stephen Hemminger Cc: dev@dpdk.org, Long Li Date: Tue, 23 Jun 2020 18:11:46 -0700 Message-Id: <1592961106-82820-2-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1592961106-82820-1-git-send-email-longli@linuxonhyperv.com> References: <1592961106-82820-1-git-send-email-longli@linuxonhyperv.com> Subject: [dpdk-dev] [PATCH 2/2] net/netvsc: detach external buffer on failure 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Long Li When external buffer is used, driver should detach it if it doesn't make it successfully to the queue. Signed-off-by: Long Li Acked-by: Stephen Hemminger --- drivers/net/netvsc/hn_rxtx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index aece38e2d..52f5c0191 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -550,6 +550,7 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb, { struct hn_data *hv = rxq->hv; struct rte_mbuf *m; + bool use_extbuf = false; m = rte_pktmbuf_alloc(rxq->mb_pool); if (unlikely(!m)) { @@ -587,6 +588,7 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb, rte_pktmbuf_attach_extbuf(m, data, iova, dlen + headroom, shinfo); m->data_off = headroom; + use_extbuf = true; } else { /* Mbuf's in pool must be large enough to hold small packets */ if (unlikely(rte_pktmbuf_tailroom(m) < dlen)) { @@ -614,6 +616,8 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb, if (!hv->vlan_strip && rte_vlan_insert(&m)) { PMD_DRV_LOG(DEBUG, "vlan insert failed"); ++rxq->stats.errors; + if (use_extbuf) + rte_pktmbuf_detach_extbuf(m); rte_pktmbuf_free(m); return; } @@ -648,6 +652,8 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb, if (unlikely(rte_ring_sp_enqueue(rxq->rx_ring, m) != 0)) { ++rxq->stats.ring_full; PMD_RX_LOG(DEBUG, "rx ring full"); + if (use_extbuf) + rte_pktmbuf_detach_extbuf(m); rte_pktmbuf_free(m); } }