xref: /dpdk/drivers/net/octeontx/octeontx_rxtx.c (revision e3866e73555091d56b33b4d8916e0e484ccae114)
1aaf4363eSJerin Jacob /* SPDX-License-Identifier: BSD-3-Clause
2aaf4363eSJerin Jacob  * Copyright(c) 2017 Cavium, Inc
39e747589SJerin Jacob  */
49e747589SJerin Jacob 
59e747589SJerin Jacob #include <stdint.h>
69e747589SJerin Jacob #include <stdio.h>
79e747589SJerin Jacob #include <stdlib.h>
89e747589SJerin Jacob #include <unistd.h>
99e747589SJerin Jacob 
109e747589SJerin Jacob #include <rte_atomic.h>
119e747589SJerin Jacob #include <rte_common.h>
12ffc905f3SFerruh Yigit #include <rte_ethdev_driver.h>
139e747589SJerin Jacob #include <rte_ether.h>
149e747589SJerin Jacob #include <rte_log.h>
159e747589SJerin Jacob #include <rte_mbuf.h>
169e747589SJerin Jacob #include <rte_prefetch.h>
179e747589SJerin Jacob 
189e747589SJerin Jacob #include "octeontx_ethdev.h"
199e747589SJerin Jacob #include "octeontx_rxtx.h"
209e747589SJerin Jacob #include "octeontx_logs.h"
219e747589SJerin Jacob 
22*e3866e73SThomas Monjalon uint16_t __rte_hot
239e747589SJerin Jacob octeontx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
249e747589SJerin Jacob {
259e747589SJerin Jacob 	int count;
269e747589SJerin Jacob 	struct octeontx_txq *txq = tx_queue;
279e747589SJerin Jacob 	octeontx_dq_t *dq = &txq->dq;
289e747589SJerin Jacob 	int res;
299e747589SJerin Jacob 
309e747589SJerin Jacob 	count = 0;
319e747589SJerin Jacob 
329f92552eSJerin Jacob 	rte_cio_wmb();
339e747589SJerin Jacob 	while (count < nb_pkts) {
349e747589SJerin Jacob 		res = __octeontx_xmit_pkts(dq->lmtline_va, dq->ioreg_va,
359e747589SJerin Jacob 					   dq->fc_status_va,
369e747589SJerin Jacob 					   tx_pkts[count]);
379e747589SJerin Jacob 		if (res < 0)
389e747589SJerin Jacob 			break;
399e747589SJerin Jacob 
409e747589SJerin Jacob 		count++;
419e747589SJerin Jacob 	}
429e747589SJerin Jacob 
439e747589SJerin Jacob 	return count; /* return number of pkts transmitted */
449e747589SJerin Jacob }
452d2c7918SJerin Jacob 
46*e3866e73SThomas Monjalon uint16_t __rte_hot
472d2c7918SJerin Jacob octeontx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
482d2c7918SJerin Jacob {
492d2c7918SJerin Jacob 	struct octeontx_rxq *rxq;
502d2c7918SJerin Jacob 	struct rte_event ev;
512d2c7918SJerin Jacob 	size_t count;
522d2c7918SJerin Jacob 	uint16_t valid_event;
532d2c7918SJerin Jacob 
542d2c7918SJerin Jacob 	rxq = rx_queue;
552d2c7918SJerin Jacob 	count = 0;
562d2c7918SJerin Jacob 	while (count < nb_pkts) {
572d2c7918SJerin Jacob 		valid_event = rte_event_dequeue_burst(rxq->evdev,
582d2c7918SJerin Jacob 							rxq->ev_ports, &ev,
592d2c7918SJerin Jacob 							1, 0);
602d2c7918SJerin Jacob 		if (!valid_event)
612d2c7918SJerin Jacob 			break;
62d0d65498SPavan Nikhilesh 		rx_pkts[count++] = ev.mbuf;
632d2c7918SJerin Jacob 	}
642d2c7918SJerin Jacob 
652d2c7918SJerin Jacob 	return count; /* return number of pkts received */
662d2c7918SJerin Jacob }
67