[dpdk-dev,3/5] port: use mbuf alloc bulk instead of mempool

Message ID 1490967396-2240-3-git-send-email-Andriy.Berestovskyy@caviumnetworks.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andriy Berestovskyy March 31, 2017, 1:36 p.m. UTC
  Makes code a bit cleaner and type-aware.

Signed-off-by: Andriy Berestovskyy <Andriy.Berestovskyy@caviumnetworks.com>
---
 lib/librte_port/rte_port_fd.c          | 7 +------
 lib/librte_port/rte_port_source_sink.c | 7 +------
 2 files changed, 2 insertions(+), 12 deletions(-)
  

Comments

Cristian Dumitrescu March 31, 2017, 2:18 p.m. UTC | #1
> -----Original Message-----
> From: Andriy Berestovskyy
> [mailto:Andriy.Berestovskyy@caviumnetworks.com]
> Sent: Friday, March 31, 2017 2:37 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH 3/5] port: use mbuf alloc bulk instead of mempool
> 
> Makes code a bit cleaner and type-aware.
> 
> Signed-off-by: Andriy Berestovskyy
> <Andriy.Berestovskyy@caviumnetworks.com>
> ---

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  

Patch

diff --git a/lib/librte_port/rte_port_fd.c b/lib/librte_port/rte_port_fd.c
index 0d640f3..03e69f5 100644
--- a/lib/librte_port/rte_port_fd.c
+++ b/lib/librte_port/rte_port_fd.c
@@ -110,15 +110,10 @@  rte_port_fd_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 	struct rte_port_fd_reader *p = (struct rte_port_fd_reader *) port;
 	uint32_t i;
 
-	if (rte_mempool_get_bulk(p->mempool, (void **) pkts, n_pkts) != 0)
+	if (rte_pktmbuf_alloc_bulk(p->mempool, pkts, n_pkts) != 0)
 		return 0;
 
 	for (i = 0; i < n_pkts; i++) {
-		rte_mbuf_refcnt_set(pkts[i], 1);
-		rte_pktmbuf_reset(pkts[i]);
-	}
-
-	for (i = 0; i < n_pkts; i++) {
 		struct rte_mbuf *pkt = pkts[i];
 		void *pkt_data = rte_pktmbuf_mtod(pkt, void *);
 		ssize_t n_bytes;
diff --git a/lib/librte_port/rte_port_source_sink.c b/lib/librte_port/rte_port_source_sink.c
index 4cad710..796418a 100644
--- a/lib/librte_port/rte_port_source_sink.c
+++ b/lib/librte_port/rte_port_source_sink.c
@@ -289,14 +289,9 @@  rte_port_source_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 	struct rte_port_source *p = (struct rte_port_source *) port;
 	uint32_t i;
 
-	if (rte_mempool_get_bulk(p->mempool, (void **) pkts, n_pkts) != 0)
+	if (rte_pktmbuf_alloc_bulk(p->mempool, pkts, n_pkts) != 0)
 		return 0;
 
-	for (i = 0; i < n_pkts; i++) {
-		rte_mbuf_refcnt_set(pkts[i], 1);
-		rte_pktmbuf_reset(pkts[i]);
-	}
-
 	if (p->pkt_buff != NULL) {
 		for (i = 0; i < n_pkts; i++) {
 			uint8_t *pkt_data = rte_pktmbuf_mtod(pkts[i],