diff options
Diffstat (limited to 'lib/librte_port')
-rw-r--r-- | lib/librte_port/Makefile | 11 | ||||
-rw-r--r-- | lib/librte_port/rte_port_ethdev.c | 30 | ||||
-rw-r--r-- | lib/librte_port/rte_port_fd.c | 41 | ||||
-rw-r--r-- | lib/librte_port/rte_port_frag.c | 9 | ||||
-rw-r--r-- | lib/librte_port/rte_port_kni.c | 26 | ||||
-rw-r--r-- | lib/librte_port/rte_port_ras.c | 14 | ||||
-rw-r--r-- | lib/librte_port/rte_port_ring.c | 86 | ||||
-rw-r--r-- | lib/librte_port/rte_port_sched.c | 10 | ||||
-rw-r--r-- | lib/librte_port/rte_port_source_sink.c | 27 |
9 files changed, 120 insertions, 134 deletions
diff --git a/lib/librte_port/Makefile b/lib/librte_port/Makefile index 44fa7352..76629a13 100644 --- a/lib/librte_port/Makefile +++ b/lib/librte_port/Makefile @@ -77,15 +77,4 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_kni.h endif SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_source_sink.h -# this lib depends upon: -DEPDIRS-$(CONFIG_RTE_LIBRTE_PORT) := lib/librte_eal -DEPDIRS-$(CONFIG_RTE_LIBRTE_PORT) += lib/librte_mbuf -DEPDIRS-$(CONFIG_RTE_LIBRTE_PORT) += lib/librte_mempool -DEPDIRS-$(CONFIG_RTE_LIBRTE_PORT) += lib/librte_ether -DEPDIRS-$(CONFIG_RTE_LIBRTE_PORT) += lib/librte_ip_frag -DEPDIRS-$(CONFIG_RTE_LIBRTE_PORT) += lib/librte_sched -ifeq ($(CONFIG_RTE_LIBRTE_KNI),y) -DEPDIRS-$(CONFIG_RTE_LIBRTE_PORT) += lib/librte_kni -endif - include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_port/rte_port_ethdev.c b/lib/librte_port/rte_port_ethdev.c index 73e5f185..d5c5fba5 100644 --- a/lib/librte_port/rte_port_ethdev.c +++ b/lib/librte_port/rte_port_ethdev.c @@ -67,7 +67,7 @@ static void * rte_port_ethdev_reader_create(void *params, int socket_id) { struct rte_port_ethdev_reader_params *conf = - (struct rte_port_ethdev_reader_params *) params; + params; struct rte_port_ethdev_reader *port; /* Check input parameters */ @@ -95,7 +95,7 @@ static int rte_port_ethdev_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { struct rte_port_ethdev_reader *p = - (struct rte_port_ethdev_reader *) port; + port; uint16_t rx_pkt_cnt; rx_pkt_cnt = rte_eth_rx_burst(p->port_id, p->queue_id, pkts, n_pkts); @@ -120,7 +120,7 @@ static int rte_port_ethdev_reader_stats_read(void *port, struct rte_port_in_stats *stats, int clear) { struct rte_port_ethdev_reader *p = - (struct rte_port_ethdev_reader *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -163,7 +163,7 @@ static void * rte_port_ethdev_writer_create(void *params, int socket_id) { struct rte_port_ethdev_writer_params *conf = - (struct rte_port_ethdev_writer_params *) params; + params; struct rte_port_ethdev_writer *port; /* Check input parameters */ @@ -212,7 +212,7 @@ static int rte_port_ethdev_writer_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_ethdev_writer *p = - (struct rte_port_ethdev_writer *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, 1); @@ -228,7 +228,7 @@ rte_port_ethdev_writer_tx_bulk(void *port, uint64_t pkts_mask) { struct rte_port_ethdev_writer *p = - (struct rte_port_ethdev_writer *) port; + port; uint64_t bsz_mask = p->bsz_mask; uint32_t tx_buf_count = p->tx_buf_count; uint64_t expr = (pkts_mask & (pkts_mask + 1)) | @@ -274,7 +274,7 @@ static int rte_port_ethdev_writer_flush(void *port) { struct rte_port_ethdev_writer *p = - (struct rte_port_ethdev_writer *) port; + port; if (p->tx_buf_count > 0) send_burst(p); @@ -300,7 +300,7 @@ static int rte_port_ethdev_writer_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_ethdev_writer *p = - (struct rte_port_ethdev_writer *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -344,7 +344,7 @@ static void * rte_port_ethdev_writer_nodrop_create(void *params, int socket_id) { struct rte_port_ethdev_writer_nodrop_params *conf = - (struct rte_port_ethdev_writer_nodrop_params *) params; + params; struct rte_port_ethdev_writer_nodrop *port; /* Check input parameters */ @@ -418,7 +418,7 @@ static int rte_port_ethdev_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_ethdev_writer_nodrop *p = - (struct rte_port_ethdev_writer_nodrop *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); @@ -434,7 +434,7 @@ rte_port_ethdev_writer_nodrop_tx_bulk(void *port, uint64_t pkts_mask) { struct rte_port_ethdev_writer_nodrop *p = - (struct rte_port_ethdev_writer_nodrop *) port; + port; uint64_t bsz_mask = p->bsz_mask; uint32_t tx_buf_count = p->tx_buf_count; @@ -456,8 +456,8 @@ rte_port_ethdev_writer_nodrop_tx_bulk(void *port, return 0; /* - * If we didnt manage to send all packets in single burst, move - * remaining packets to the buffer and call send burst. + * If we did not manage to send all packets in single burst, + * move remaining packets to the buffer and call send burst. */ for (; n_pkts_ok < n_pkts; n_pkts_ok++) { struct rte_mbuf *pkt = pkts[n_pkts_ok]; @@ -487,7 +487,7 @@ static int rte_port_ethdev_writer_nodrop_flush(void *port) { struct rte_port_ethdev_writer_nodrop *p = - (struct rte_port_ethdev_writer_nodrop *) port; + port; if (p->tx_buf_count > 0) send_burst_nodrop(p); @@ -513,7 +513,7 @@ static int rte_port_ethdev_writer_nodrop_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_ethdev_writer_nodrop *p = - (struct rte_port_ethdev_writer_nodrop *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); diff --git a/lib/librte_port/rte_port_fd.c b/lib/librte_port/rte_port_fd.c index 0d640f34..b5b37291 100644 --- a/lib/librte_port/rte_port_fd.c +++ b/lib/librte_port/rte_port_fd.c @@ -67,7 +67,7 @@ static void * rte_port_fd_reader_create(void *params, int socket_id) { struct rte_port_fd_reader_params *conf = - (struct rte_port_fd_reader_params *) params; + params; struct rte_port_fd_reader *port; /* Check input parameters */ @@ -107,18 +107,13 @@ rte_port_fd_reader_create(void *params, int socket_id) static int 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; + struct rte_port_fd_reader *p = port; + 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 *); ssize_t n_bytes; @@ -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 @@ -156,7 +151,7 @@ static int rte_port_fd_reader_stats_read(void *port, struct rte_port_in_stats *stats, int clear) { struct rte_port_fd_reader *p = - (struct rte_port_fd_reader *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -197,7 +192,7 @@ static void * rte_port_fd_writer_create(void *params, int socket_id) { struct rte_port_fd_writer_params *conf = - (struct rte_port_fd_writer_params *) params; + params; struct rte_port_fd_writer *port; /* Check input parameters */ @@ -253,7 +248,7 @@ static int rte_port_fd_writer_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_fd_writer *p = - (struct rte_port_fd_writer *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(p, 1); @@ -269,7 +264,7 @@ rte_port_fd_writer_tx_bulk(void *port, uint64_t pkts_mask) { struct rte_port_fd_writer *p = - (struct rte_port_fd_writer *) port; + port; uint32_t tx_buf_count = p->tx_buf_count; if ((pkts_mask & (pkts_mask + 1)) == 0) { @@ -301,7 +296,7 @@ static int rte_port_fd_writer_flush(void *port) { struct rte_port_fd_writer *p = - (struct rte_port_fd_writer *) port; + port; if (p->tx_buf_count > 0) send_burst(p); @@ -327,7 +322,7 @@ static int rte_port_fd_writer_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_fd_writer *p = - (struct rte_port_fd_writer *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -369,7 +364,7 @@ static void * rte_port_fd_writer_nodrop_create(void *params, int socket_id) { struct rte_port_fd_writer_nodrop_params *conf = - (struct rte_port_fd_writer_nodrop_params *) params; + params; struct rte_port_fd_writer_nodrop *port; /* Check input parameters */ @@ -438,7 +433,7 @@ static int rte_port_fd_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_fd_writer_nodrop *p = - (struct rte_port_fd_writer_nodrop *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); @@ -454,7 +449,7 @@ rte_port_fd_writer_nodrop_tx_bulk(void *port, uint64_t pkts_mask) { struct rte_port_fd_writer_nodrop *p = - (struct rte_port_fd_writer_nodrop *) port; + port; uint32_t tx_buf_count = p->tx_buf_count; if ((pkts_mask & (pkts_mask + 1)) == 0) { @@ -486,7 +481,7 @@ static int rte_port_fd_writer_nodrop_flush(void *port) { struct rte_port_fd_writer_nodrop *p = - (struct rte_port_fd_writer_nodrop *) port; + port; if (p->tx_buf_count > 0) send_burst_nodrop(p); @@ -512,7 +507,7 @@ static int rte_port_fd_writer_nodrop_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_fd_writer_nodrop *p = - (struct rte_port_fd_writer_nodrop *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); diff --git a/lib/librte_port/rte_port_frag.c b/lib/librte_port/rte_port_frag.c index 0fcace99..a00c9ae1 100644 --- a/lib/librte_port/rte_port_frag.c +++ b/lib/librte_port/rte_port_frag.c @@ -88,7 +88,7 @@ static void * rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4) { struct rte_port_ring_reader_frag_params *conf = - (struct rte_port_ring_reader_frag_params *) params; + params; struct rte_port_ring_reader_frag *port; /* Check input parameters */ @@ -159,7 +159,7 @@ rte_port_ring_reader_frag_rx(void *port, uint32_t n_pkts) { struct rte_port_ring_reader_frag *p = - (struct rte_port_ring_reader_frag *) port; + port; uint32_t n_pkts_out; n_pkts_out = 0; @@ -186,7 +186,8 @@ rte_port_ring_reader_frag_rx(void *port, /* If "pkts" buffer is empty, read packet burst from ring */ if (p->n_pkts == 0) { p->n_pkts = rte_ring_sc_dequeue_burst(p->ring, - (void **) p->pkts, RTE_PORT_IN_BURST_SIZE_MAX); + (void **) p->pkts, RTE_PORT_IN_BURST_SIZE_MAX, + NULL); RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD(p, p->n_pkts); if (p->n_pkts == 0) return n_pkts_out; @@ -276,7 +277,7 @@ rte_port_frag_reader_stats_read(void *port, struct rte_port_in_stats *stats, int clear) { struct rte_port_ring_reader_frag *p = - (struct rte_port_ring_reader_frag *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); diff --git a/lib/librte_port/rte_port_kni.c b/lib/librte_port/rte_port_kni.c index 08f4ac2a..2515fb2a 100644 --- a/lib/librte_port/rte_port_kni.c +++ b/lib/librte_port/rte_port_kni.c @@ -66,7 +66,7 @@ static void * rte_port_kni_reader_create(void *params, int socket_id) { struct rte_port_kni_reader_params *conf = - (struct rte_port_kni_reader_params *) params; + params; struct rte_port_kni_reader *port; /* Check input parameters */ @@ -93,7 +93,7 @@ static int rte_port_kni_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { struct rte_port_kni_reader *p = - (struct rte_port_kni_reader *) port; + port; uint16_t rx_pkt_cnt; rx_pkt_cnt = rte_kni_rx_burst(p->kni, pkts, n_pkts); @@ -118,7 +118,7 @@ static int rte_port_kni_reader_stats_read(void *port, struct rte_port_in_stats *stats, int clear) { struct rte_port_kni_reader *p = - (struct rte_port_kni_reader *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -160,7 +160,7 @@ static void * rte_port_kni_writer_create(void *params, int socket_id) { struct rte_port_kni_writer_params *conf = - (struct rte_port_kni_writer_params *) params; + params; struct rte_port_kni_writer *port; /* Check input parameters */ @@ -207,7 +207,7 @@ static int rte_port_kni_writer_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_kni_writer *p = - (struct rte_port_kni_writer *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(p, 1); @@ -223,7 +223,7 @@ rte_port_kni_writer_tx_bulk(void *port, uint64_t pkts_mask) { struct rte_port_kni_writer *p = - (struct rte_port_kni_writer *) port; + port; uint64_t bsz_mask = p->bsz_mask; uint32_t tx_buf_count = p->tx_buf_count; uint64_t expr = (pkts_mask & (pkts_mask + 1)) | @@ -268,7 +268,7 @@ static int rte_port_kni_writer_flush(void *port) { struct rte_port_kni_writer *p = - (struct rte_port_kni_writer *) port; + port; if (p->tx_buf_count > 0) send_burst(p); @@ -294,7 +294,7 @@ static int rte_port_kni_writer_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_kni_writer *p = - (struct rte_port_kni_writer *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -337,7 +337,7 @@ static void * rte_port_kni_writer_nodrop_create(void *params, int socket_id) { struct rte_port_kni_writer_nodrop_params *conf = - (struct rte_port_kni_writer_nodrop_params *) params; + params; struct rte_port_kni_writer_nodrop *port; /* Check input parameters */ @@ -410,7 +410,7 @@ static int rte_port_kni_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_kni_writer_nodrop *p = - (struct rte_port_kni_writer_nodrop *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_KNI_WRITER_STATS_PKTS_IN_ADD(p, 1); @@ -426,7 +426,7 @@ rte_port_kni_writer_nodrop_tx_bulk(void *port, uint64_t pkts_mask) { struct rte_port_kni_writer_nodrop *p = - (struct rte_port_kni_writer_nodrop *) port; + port; uint64_t bsz_mask = p->bsz_mask; uint32_t tx_buf_count = p->tx_buf_count; @@ -478,7 +478,7 @@ static int rte_port_kni_writer_nodrop_flush(void *port) { struct rte_port_kni_writer_nodrop *p = - (struct rte_port_kni_writer_nodrop *) port; + port; if (p->tx_buf_count > 0) send_burst_nodrop(p); @@ -504,7 +504,7 @@ static int rte_port_kni_writer_nodrop_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_kni_writer_nodrop *p = - (struct rte_port_kni_writer_nodrop *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index c4bb5081..415fadd5 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -93,7 +93,7 @@ static void * rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) { struct rte_port_ring_writer_ras_params *conf = - (struct rte_port_ring_writer_ras_params *) params; + params; struct rte_port_ring_writer_ras *port; uint64_t frag_cycles; @@ -167,7 +167,7 @@ send_burst(struct rte_port_ring_writer_ras *p) uint32_t nb_tx; nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count, NULL); RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); for ( ; nb_tx < p->tx_buf_count; nb_tx++) @@ -243,7 +243,7 @@ static int rte_port_ring_writer_ras_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_ring_writer_ras *p = - (struct rte_port_ring_writer_ras *) port; + port; RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(p, 1); p->f_ras(p, pkt); @@ -259,7 +259,7 @@ rte_port_ring_writer_ras_tx_bulk(void *port, uint64_t pkts_mask) { struct rte_port_ring_writer_ras *p = - (struct rte_port_ring_writer_ras *) port; + port; if ((pkts_mask & (pkts_mask + 1)) == 0) { uint64_t n_pkts = __builtin_popcountll(pkts_mask); @@ -295,7 +295,7 @@ static int rte_port_ring_writer_ras_flush(void *port) { struct rte_port_ring_writer_ras *p = - (struct rte_port_ring_writer_ras *) port; + port; if (p->tx_buf_count > 0) send_burst(p); @@ -307,7 +307,7 @@ static int rte_port_ring_writer_ras_free(void *port) { struct rte_port_ring_writer_ras *p = - (struct rte_port_ring_writer_ras *) port; + port; if (port == NULL) { RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__); @@ -326,7 +326,7 @@ rte_port_ras_writer_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_ring_writer_ras *p = - (struct rte_port_ring_writer_ras *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c index 3b9d3d08..64bd965f 100644 --- a/lib/librte_port/rte_port_ring.c +++ b/lib/librte_port/rte_port_ring.c @@ -67,14 +67,14 @@ rte_port_ring_reader_create_internal(void *params, int socket_id, uint32_t is_multi) { struct rte_port_ring_reader_params *conf = - (struct rte_port_ring_reader_params *) params; + params; struct rte_port_ring_reader *port; /* Check input parameters */ if ((conf == NULL) || (conf->ring == NULL) || - (conf->ring->cons.sc_dequeue && is_multi) || - (!(conf->ring->cons.sc_dequeue) && !is_multi)) { + (conf->ring->cons.single && is_multi) || + (!(conf->ring->cons.single) && !is_multi)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; } @@ -108,10 +108,11 @@ rte_port_ring_multi_reader_create(void *params, int socket_id) static int rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { - struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port; + struct rte_port_ring_reader *p = port; uint32_t nb_rx; - nb_rx = rte_ring_sc_dequeue_burst(p->ring, (void **) pkts, n_pkts); + nb_rx = rte_ring_sc_dequeue_burst(p->ring, (void **) pkts, + n_pkts, NULL); RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); return nb_rx; @@ -121,10 +122,11 @@ static int rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { - struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port; + struct rte_port_ring_reader *p = port; uint32_t nb_rx; - nb_rx = rte_ring_mc_dequeue_burst(p->ring, (void **) pkts, n_pkts); + nb_rx = rte_ring_mc_dequeue_burst(p->ring, (void **) pkts, + n_pkts, NULL); RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); return nb_rx; @@ -148,7 +150,7 @@ rte_port_ring_reader_stats_read(void *port, struct rte_port_in_stats *stats, int clear) { struct rte_port_ring_reader *p = - (struct rte_port_ring_reader *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -192,14 +194,14 @@ rte_port_ring_writer_create_internal(void *params, int socket_id, uint32_t is_multi) { struct rte_port_ring_writer_params *conf = - (struct rte_port_ring_writer_params *) params; + params; struct rte_port_ring_writer *port; /* Check input parameters */ if ((conf == NULL) || (conf->ring == NULL) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; @@ -241,7 +243,7 @@ send_burst(struct rte_port_ring_writer *p) uint32_t nb_tx; nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count, NULL); RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); for ( ; nb_tx < p->tx_buf_count; nb_tx++) @@ -256,7 +258,7 @@ send_burst_mp(struct rte_port_ring_writer *p) uint32_t nb_tx; nb_tx = rte_ring_mp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count, NULL); RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); for ( ; nb_tx < p->tx_buf_count; nb_tx++) @@ -268,7 +270,7 @@ send_burst_mp(struct rte_port_ring_writer *p) static int rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) { - struct rte_port_ring_writer *p = (struct rte_port_ring_writer *) port; + struct rte_port_ring_writer *p = port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1); @@ -281,7 +283,7 @@ rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) static int rte_port_ring_multi_writer_tx(void *port, struct rte_mbuf *pkt) { - struct rte_port_ring_writer *p = (struct rte_port_ring_writer *) port; + struct rte_port_ring_writer *p = port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1); @@ -298,7 +300,7 @@ rte_port_ring_writer_tx_bulk_internal(void *port, uint32_t is_multi) { struct rte_port_ring_writer *p = - (struct rte_port_ring_writer *) port; + port; uint64_t bsz_mask = p->bsz_mask; uint32_t tx_buf_count = p->tx_buf_count; @@ -318,11 +320,11 @@ rte_port_ring_writer_tx_bulk_internal(void *port, RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, n_pkts); if (is_multi) - n_pkts_ok = rte_ring_mp_enqueue_burst(p->ring, (void **)pkts, - n_pkts); + n_pkts_ok = rte_ring_mp_enqueue_burst(p->ring, + (void **)pkts, n_pkts, NULL); else - n_pkts_ok = rte_ring_sp_enqueue_burst(p->ring, (void **)pkts, - n_pkts); + n_pkts_ok = rte_ring_sp_enqueue_burst(p->ring, + (void **)pkts, n_pkts, NULL); RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - n_pkts_ok); for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) { @@ -372,7 +374,7 @@ rte_port_ring_multi_writer_tx_bulk(void *port, static int rte_port_ring_writer_flush(void *port) { - struct rte_port_ring_writer *p = (struct rte_port_ring_writer *) port; + struct rte_port_ring_writer *p = port; if (p->tx_buf_count > 0) send_burst(p); @@ -383,7 +385,7 @@ rte_port_ring_writer_flush(void *port) static int rte_port_ring_multi_writer_flush(void *port) { - struct rte_port_ring_writer *p = (struct rte_port_ring_writer *) port; + struct rte_port_ring_writer *p = port; if (p->tx_buf_count > 0) send_burst_mp(p); @@ -394,7 +396,7 @@ rte_port_ring_multi_writer_flush(void *port) static int rte_port_ring_writer_free(void *port) { - struct rte_port_ring_writer *p = (struct rte_port_ring_writer *) port; + struct rte_port_ring_writer *p = port; if (port == NULL) { RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); @@ -416,7 +418,7 @@ rte_port_ring_writer_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_ring_writer *p = - (struct rte_port_ring_writer *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -461,14 +463,14 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id, uint32_t is_multi) { struct rte_port_ring_writer_nodrop_params *conf = - (struct rte_port_ring_writer_nodrop_params *) params; + params; struct rte_port_ring_writer_nodrop *port; /* Check input parameters */ if ((conf == NULL) || (conf->ring == NULL) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; @@ -517,7 +519,7 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p) uint32_t nb_tx = 0, i; nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count, NULL); /* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) { @@ -527,7 +529,8 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p) for (i = 0; i < p->n_retries; i++) { nb_tx += rte_ring_sp_enqueue_burst(p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx, NULL); /* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) { @@ -550,7 +553,7 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p) uint32_t nb_tx = 0, i; nb_tx = rte_ring_mp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count, NULL); /* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) { @@ -560,7 +563,8 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p) for (i = 0; i < p->n_retries; i++) { nb_tx += rte_ring_mp_enqueue_burst(p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx, NULL); /* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) { @@ -581,7 +585,7 @@ static int rte_port_ring_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_ring_writer_nodrop *p = - (struct rte_port_ring_writer_nodrop *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); @@ -595,7 +599,7 @@ static int rte_port_ring_multi_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) { struct rte_port_ring_writer_nodrop *p = - (struct rte_port_ring_writer_nodrop *) port; + port; p->tx_buf[p->tx_buf_count++] = pkt; RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); @@ -612,7 +616,7 @@ rte_port_ring_writer_nodrop_tx_bulk_internal(void *port, uint32_t is_multi) { struct rte_port_ring_writer_nodrop *p = - (struct rte_port_ring_writer_nodrop *) port; + port; uint64_t bsz_mask = p->bsz_mask; uint32_t tx_buf_count = p->tx_buf_count; @@ -633,10 +637,12 @@ rte_port_ring_writer_nodrop_tx_bulk_internal(void *port, RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts); if (is_multi) n_pkts_ok = - rte_ring_mp_enqueue_burst(p->ring, (void **)pkts, n_pkts); + rte_ring_mp_enqueue_burst(p->ring, + (void **)pkts, n_pkts, NULL); else n_pkts_ok = - rte_ring_sp_enqueue_burst(p->ring, (void **)pkts, n_pkts); + rte_ring_sp_enqueue_burst(p->ring, + (void **)pkts, n_pkts, NULL); if (n_pkts_ok >= n_pkts) return 0; @@ -699,7 +705,7 @@ static int rte_port_ring_writer_nodrop_flush(void *port) { struct rte_port_ring_writer_nodrop *p = - (struct rte_port_ring_writer_nodrop *) port; + port; if (p->tx_buf_count > 0) send_burst_nodrop(p); @@ -711,7 +717,7 @@ static int rte_port_ring_multi_writer_nodrop_flush(void *port) { struct rte_port_ring_writer_nodrop *p = - (struct rte_port_ring_writer_nodrop *) port; + port; if (p->tx_buf_count > 0) send_burst_mp_nodrop(p); @@ -723,7 +729,7 @@ static int rte_port_ring_writer_nodrop_free(void *port) { struct rte_port_ring_writer_nodrop *p = - (struct rte_port_ring_writer_nodrop *) port; + port; if (port == NULL) { RTE_LOG(ERR, PORT, "%s: Port is NULL\n", __func__); @@ -745,7 +751,7 @@ rte_port_ring_writer_nodrop_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_ring_writer_nodrop *p = - (struct rte_port_ring_writer_nodrop *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); diff --git a/lib/librte_port/rte_port_sched.c b/lib/librte_port/rte_port_sched.c index 25217d62..9100a197 100644 --- a/lib/librte_port/rte_port_sched.c +++ b/lib/librte_port/rte_port_sched.c @@ -64,7 +64,7 @@ static void * rte_port_sched_reader_create(void *params, int socket_id) { struct rte_port_sched_reader_params *conf = - (struct rte_port_sched_reader_params *) params; + params; struct rte_port_sched_reader *port; /* Check input parameters */ @@ -91,7 +91,7 @@ rte_port_sched_reader_create(void *params, int socket_id) static int rte_port_sched_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { - struct rte_port_sched_reader *p = (struct rte_port_sched_reader *) port; + struct rte_port_sched_reader *p = port; uint32_t nb_rx; nb_rx = rte_sched_port_dequeue(p->sched, pkts, n_pkts); @@ -118,7 +118,7 @@ rte_port_sched_reader_stats_read(void *port, struct rte_port_in_stats *stats, int clear) { struct rte_port_sched_reader *p = - (struct rte_port_sched_reader *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -160,7 +160,7 @@ static void * rte_port_sched_writer_create(void *params, int socket_id) { struct rte_port_sched_writer_params *conf = - (struct rte_port_sched_writer_params *) params; + params; struct rte_port_sched_writer *port; /* Check input parameters */ @@ -292,7 +292,7 @@ rte_port_sched_writer_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_sched_writer *p = - (struct rte_port_sched_writer *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); diff --git a/lib/librte_port/rte_port_source_sink.c b/lib/librte_port/rte_port_source_sink.c index 4cad7109..a79f2f64 100644 --- a/lib/librte_port/rte_port_source_sink.c +++ b/lib/librte_port/rte_port_source_sink.c @@ -228,7 +228,7 @@ static void * rte_port_source_create(void *params, int socket_id) { struct rte_port_source_params *p = - (struct rte_port_source_params *) params; + params; struct rte_port_source *port; /* Check input arguments*/ @@ -265,7 +265,7 @@ static int rte_port_source_free(void *port) { struct rte_port_source *p = - (struct rte_port_source *)port; + port; /* Check input parameters */ if (p == NULL) @@ -286,17 +286,12 @@ rte_port_source_free(void *port) static int rte_port_source_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { - struct rte_port_source *p = (struct rte_port_source *) port; + struct rte_port_source *p = 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], @@ -323,7 +318,7 @@ rte_port_source_stats_read(void *port, struct rte_port_in_stats *stats, int clear) { struct rte_port_source *p = - (struct rte_port_source *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); @@ -400,7 +395,7 @@ pcap_sink_open(struct rte_port_sink *port, static void pcap_sink_write_pkt(struct rte_port_sink *port, struct rte_mbuf *mbuf) { - uint8_t *pcap_dumper = (uint8_t *)(port->dumper); + uint8_t *pcap_dumper = (port->dumper); struct pcap_pkthdr pcap_hdr; uint8_t jumbo_pkt_buf[ETHER_MAX_JUMBO_FRAME_LEN]; uint8_t *pkt; @@ -524,7 +519,7 @@ rte_port_sink_create(void *params, int socket_id) static int rte_port_sink_tx(void *port, struct rte_mbuf *pkt) { - struct rte_port_sink *p = (struct rte_port_sink *) port; + struct rte_port_sink *p = port; RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1); if (p->dumper != NULL) @@ -539,7 +534,7 @@ static int rte_port_sink_tx_bulk(void *port, struct rte_mbuf **pkts, uint64_t pkts_mask) { - struct rte_port_sink *p = (struct rte_port_sink *) port; + struct rte_port_sink *p = port; if ((pkts_mask & (pkts_mask + 1)) == 0) { uint64_t n_pkts = __builtin_popcountll(pkts_mask); @@ -591,7 +586,7 @@ static int rte_port_sink_flush(void *port) { struct rte_port_sink *p = - (struct rte_port_sink *)port; + port; if (p == NULL) return 0; @@ -605,7 +600,7 @@ static int rte_port_sink_free(void *port) { struct rte_port_sink *p = - (struct rte_port_sink *)port; + port; if (p == NULL) return 0; @@ -622,7 +617,7 @@ rte_port_sink_stats_read(void *port, struct rte_port_out_stats *stats, int clear) { struct rte_port_sink *p = - (struct rte_port_sink *) port; + port; if (stats != NULL) memcpy(stats, &p->stats, sizeof(p->stats)); |