From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 17A7EA0568; Mon, 2 Mar 2020 10:01:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 71FA01C0B0; Mon, 2 Mar 2020 10:00:27 +0100 (CET) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id C21F01C038 for ; Mon, 2 Mar 2020 10:00:20 +0100 (CET) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id A7FBB1A0FDF; Mon, 2 Mar 2020 10:00:20 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 291391A0FA6; Mon, 2 Mar 2020 10:00:18 +0100 (CET) Received: from bf-netperf1.ap.com (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id DAE5C402ED; Mon, 2 Mar 2020 17:00:14 +0800 (SGT) From: Hemant Agrawal To: ferruh.yigit@intel.com Cc: dev@dpdk.org, g.singh@nxp.com, Alex Marginean Date: Mon, 2 Mar 2020 20:02:07 +0530 Message-Id: <20200302143209.11854-9-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200302143209.11854-1-hemant.agrawal@nxp.com> References: <20200302143209.11854-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 08/10] net/enetc: use bulk free in Tx clean 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: Alex Marginean Use rte_pktmbuf_free_bulk to release all mbufs at once. This is flagged as obsolete/not yet stable in DPDK but seems to be functional. Don't count the released frames, it's no longer needed in the caller. Signed-off-by: Alex Marginean --- drivers/net/enetc/Makefile | 1 + drivers/net/enetc/enetc_rxtx.c | 32 ++++++++++++++++++++++++-------- drivers/net/enetc/meson.build | 1 + 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/net/enetc/Makefile b/drivers/net/enetc/Makefile index 7276026e3..7f7a85f64 100644 --- a/drivers/net/enetc/Makefile +++ b/drivers/net/enetc/Makefile @@ -11,6 +11,7 @@ LIB = librte_pmd_enetc.a CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) CFLAGS += -I$(RTE_SDK)/drivers/common/dpaax +CFLAGS += -DALLOW_EXPERIMENTAL_API EXPORT_MAP := rte_pmd_enetc_version.map SRCS-$(CONFIG_RTE_LIBRTE_ENETC_PMD) += enetc_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_ENETC_PMD) += enetc_rxtx.c diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.c index 8b85c5371..1acc43a08 100644 --- a/drivers/net/enetc/enetc_rxtx.c +++ b/drivers/net/enetc/enetc_rxtx.c @@ -20,8 +20,9 @@ static int enetc_clean_tx_ring(struct enetc_bdr *tx_ring) { int tx_frm_cnt = 0; - struct enetc_swbd *tx_swbd; - int i, hwci; + struct enetc_swbd *tx_swbd, *tx_swbd_base; + int i, hwci, bd_count; + struct rte_mbuf *m[ENETC_RXBD_BUNDLE]; /* we don't need barriers here, we just want a relatively current value * from HW. @@ -29,8 +30,10 @@ enetc_clean_tx_ring(struct enetc_bdr *tx_ring) hwci = (int)(rte_read32_relaxed(tx_ring->tcisr) & ENETC_TBCISR_IDX_MASK); + tx_swbd_base = tx_ring->q_swbd; + bd_count = tx_ring->bd_count; i = tx_ring->next_to_clean; - tx_swbd = &tx_ring->q_swbd[i]; + tx_swbd = &tx_swbd_base[i]; /* we're only reading the CI index once here, which means HW may update * it while we're doing clean-up. We could read the register in a loop @@ -42,20 +45,33 @@ enetc_clean_tx_ring(struct enetc_bdr *tx_ring) * meantime. */ while (i != hwci) { - rte_pktmbuf_free(tx_swbd->buffer_addr); + /* It seems calling rte_pktmbuf_free is wasting a lot of cycles, + * make a list and call _free when it's done. + */ + if (tx_frm_cnt == ENETC_RXBD_BUNDLE) { + rte_pktmbuf_free_bulk(m, tx_frm_cnt); + tx_frm_cnt = 0; + } + + m[tx_frm_cnt] = tx_swbd->buffer_addr; tx_swbd->buffer_addr = NULL; - tx_swbd++; + i++; - if (unlikely(i == tx_ring->bd_count)) { + tx_swbd++; + if (unlikely(i == bd_count)) { i = 0; - tx_swbd = &tx_ring->q_swbd[0]; + tx_swbd = tx_swbd_base; } tx_frm_cnt++; } + if (tx_frm_cnt) + rte_pktmbuf_free_bulk(m, tx_frm_cnt); + tx_ring->next_to_clean = i; - return tx_frm_cnt++; + + return 0; } uint16_t diff --git a/drivers/net/enetc/meson.build b/drivers/net/enetc/meson.build index bea54bea8..af11c0960 100644 --- a/drivers/net/enetc/meson.build +++ b/drivers/net/enetc/meson.build @@ -11,3 +11,4 @@ sources = files('enetc_ethdev.c', 'enetc_rxtx.c') includes += include_directories('base') +allow_experimental_apis = true -- 2.17.1