net/sfc/base: fix error code usage in common code
[dpdk.git] / lib / librte_port / rte_port_fd.c
index ae9f31c..b5b3729 100644 (file)
@@ -108,16 +108,11 @@ static int
 rte_port_fd_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
 {
        struct rte_port_fd_reader *p = port;
-       uint32_t i;
+       uint32_t i, j;
 
-       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 *);
@@ -131,12 +126,12 @@ rte_port_fd_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
                pkt->pkt_len = n_bytes;
        }
 
-       for ( ; i < n_pkts; i++)
-               rte_pktmbuf_free(pkts[i]);
+       for (j = i; j < n_pkts; j++)
+               rte_pktmbuf_free(pkts[j]);
 
        RTE_PORT_FD_READER_STATS_PKTS_IN_ADD(p, i);
 
-       return n_pkts;
+       return i;
 }
 
 static int