31 #include <sys/queue.h> 34 #include <linux/limits.h> 35 #include <sys/types.h> 41 #include <rte_config.h> 42 #include <rte_common.h> 44 #include <rte_memory.h> 45 #include <rte_memcpy.h> 46 #include <rte_memzone.h> 48 #include <rte_per_lcore.h> 49 #include <rte_launch.h> 50 #include <rte_atomic.h> 51 #include <rte_cycles.h> 52 #include <rte_prefetch.h> 53 #include <rte_lcore.h> 54 #include <rte_per_lcore.h> 55 #include <rte_branch_prediction.h> 56 #include <rte_interrupts.h> 58 #include <rte_debug.h> 59 #include <rte_ethdev.h> 62 #include <rte_timer.h> 70 #include "../src/xran_lib_mlog_tasks_id.h" 72 #define BURST_RX_IO_SIZE 48 106 void xran_ethdi_stop_tx()
109 rte_timer_stop_sync(&ctx->
timer_tx);
135 elog(
"support for ethertype %u not found", ethertype);
149 wlog(
"Packet with unrecognized ethertype '%.4X' dropped", ethertype);
161 if (rte_vlan_strip(pkt) == 0) {
162 if (pkt->vlan_tci == ctx->
cp_vtag) {
163 dlog(
"VLAN tci matches %d", pkt->vlan_tci);
165 wlog(
"packet with wrong VLAN tag %d, dropping",
170 dlog(
"Packet not vlan tagged");
173 const struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(pkt,
void *);
175 #if defined(DPDKIO_DEBUG) && DPDKIO_DEBUG > 1 176 nlog(
"*** processing RX'ed packet of size %d ***",
177 rte_pktmbuf_data_len(pkt));
181 #if defined(DPDKIO_DEBUG) && DPDKIO_DEBUG > 1 183 char dst[ETHER_ADDR_FMT_SIZE] =
"(empty)";
184 char src[ETHER_ADDR_FMT_SIZE] =
"(empty)";
186 ether_format_addr(dst,
sizeof(dst), ð_hdr->d_addr);
187 ether_format_addr(src,
sizeof(src), ð_hdr->s_addr);
188 nlog(
"src: %s dst: %s ethertype: %.4X", dst, src,
189 rte_be_to_cpu_16(eth_hdr->ether_type));
194 if (rte_pktmbuf_adj(pkt,
sizeof(*eth_hdr)) == NULL) {
195 wlog(
"Packet too short, dropping");
216 void xran_ethdi_ports_stats(
void)
218 struct rte_eth_stats stats;
224 rte_eth_stats_get(ctx->
io_cfg.
port[i], &stats);
225 printf(
"DPDK stats:\n");
226 printf(
"** Port %hhu **\n", ctx->
io_cfg.
port[i]);
227 printf(
"ierrors:\t%lu\n", stats.ierrors);
228 printf(
"oerrors:\t%lu\n", stats.oerrors);
229 printf(
"ipackets:\t%lu\n", stats.ipackets);
230 printf(
"opackets:\t%lu\n", stats.opackets);
231 printf(
"imissed:\t%lu\n", stats.imissed);
232 printf(
"rx_nombuf:\t%lu\n", stats.rx_nombuf);
238 static void check_port_link_status(uint8_t portid)
240 #define CHECK_INTERVAL 100 241 #define MAX_CHECK_TIME 90 242 uint8_t count, all_ports_up, print_flag = 0;
243 struct rte_eth_link link;
245 printf(
"\nChecking link status");
249 memset(&link, 0,
sizeof(link));
250 rte_eth_link_get_nowait(portid, &link);
253 if (print_flag == 1) {
254 if (link.link_status)
255 printf(
"Port %d Link Up - speed %u " 256 "Mbps - %s\n", (uint8_t)portid,
257 (
unsigned)link.link_speed,
258 (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
259 (
"full-duplex") : (
"half-duplex\n"));
261 printf(
"Port %d Link Down\n",
265 if (link.link_status == ETH_LINK_DOWN) {
273 if (all_ports_up == 0) {
282 printf(
" ... done\n");
289 int *lcore_id,
struct ether_addr *p_lls_cu_addr,
struct ether_addr *p_ru_addr,
290 uint16_t cp_vlan, uint16_t up_vlan)
292 uint16_t port[2] = {0xffff, 0xffff};
297 char bbdev_wdev[32] =
"";
298 char bbdev_vdev[32] =
"";
300 char *argv[] = { name, core_mask,
"-n2",
"--socket-mem=8192",
"--proc-type=auto",
301 "--file-prefix", name,
"-w",
"0000:00:00.0", bbdev_wdev, bbdev_vdev};
306 printf(
"BBDEV_FEC_ACCL_NR5G\n");
309 printf(
"hw-accelerated bbdev %s\n", io_cfg->
bbdev_dev[0]);
310 sprintf(bbdev_wdev,
"-w %s", io_cfg->
bbdev_dev[0]);
314 printf(
"hw-accelerated bbdev disable %s\n", io_cfg->
bbdev_dev[0]);
315 sprintf(bbdev_wdev,
"-b %s", io_cfg->
bbdev_dev[0]);
317 sprintf(bbdev_wdev,
"%s",
"--vdev=baseband_turbo_sw");
319 rte_panic(
"Cannot init DPDK incorrect [bbdev_mode %d]\n", io_cfg->
bbdev_mode);
323 c_mask = (long)(1L << io_cfg->
core) |
329 printf(
"c_mask 0x%lx core %d system_core %d pkt_proc_core %d pkt_aux_core %d timing_core %d\n",
332 snprintf(core_mask,
sizeof(core_mask),
"-c 0x%lx", c_mask);
344 printf(
"%s: Calling rte_eal_init:", __FUNCTION__);
345 for (i = 0; i < RTE_DIM(argv); i++)
347 printf(
"%s ", argv[i]);
354 if (rte_eal_init(RTE_DIM(argv), argv) < 0)
355 rte_panic(
"Cannot init EAL: %s\n", rte_strerror(rte_errno));
359 #ifdef RTE_LIBRTE_PDUMP 361 rte_pdump_init(NULL);
365 rte_timer_subsystem_init();
370 *lcore_id = rte_get_next_lcore(rte_lcore_id(), 0, 0);
372 PANIC_ON(*lcore_id == RTE_MAX_LCORE,
"out of lcores for io_loop()");
374 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
377 if (rte_eth_dev_attach(io_cfg->
dpdk_dev[i], &port[i]) != 0 ||
378 rte_eth_dev_count_avail() == 0)
379 errx(1,
"Network port doesn't exist.");
382 printf(
"no DPDK port provided\n");
386 rte_lcore_to_socket_id(*lcore_id), RING_F_SC_DEQ);
388 rte_lcore_to_socket_id(*lcore_id), RING_F_SC_DEQ);
390 rte_lcore_to_socket_id(*lcore_id), RING_F_SC_DEQ);
393 rte_lcore_to_socket_id(*lcore_id), RING_F_SC_DEQ);
395 rte_lcore_to_socket_id(*lcore_id), RING_F_SC_DEQ);
397 rte_lcore_to_socket_id(*lcore_id), RING_F_SC_DEQ);
400 check_port_link_status(port[i]);
403 rte_panic(
"ethdi_dpdk_io_loop() failed to start with RTE_PROC_SECONDARY\n");
421 static inline uint16_t xran_tx_from_ring(
int port,
struct rte_ring *r)
424 uint16_t dequeued, sent = 0;
429 dequeued = rte_ring_dequeue_burst(r, (
void **)mbufs,
BURST_SIZE,
436 sent += rte_eth_tx_burst(port, 0, &mbufs[sent], dequeued - sent);
440 if (sent == dequeued)
454 if(port[port_id] == 0xFF)
457 const uint16_t rxed = rte_eth_rx_burst(port[port_id], 0, mbufs,
BURST_RX_IO_SIZE);
461 enq_n = rte_ring_enqueue_burst(ctx->
rx_ring[port_id], (
void*)mbufs, rxed, NULL);
463 rte_panic(
"error enq\n");
468 const uint16_t sent = xran_tx_from_ring(port[port_id], ctx->
tx_ring[port_id]);
481 static inline void xran_process_rx_burst(
struct rte_mbuf *mbufs[], uint16_t n_mbufs,
489 for (i = 0; i < n_mbufs; ++i)
492 rte_pktmbuf_free(mbufs[i]);
495 #ifdef DPDKIO_LATENCY_DEBUG 496 struct timeval tv_now, tv_diff;
498 gettimeofday(&tv_now, NULL);
500 nlog(
"Warning - received %d mbufs in a row", n_mbufs);
502 timersub(&tv_now, &rx_time, &tv_diff);
503 nlog(
"rx processing took %d usec", tv_diff.tv_usec);
512 int xran_ethdi_dpdk_io_loop(
void *io_loop_cfg)
514 struct sched_param sched_param;
520 printf(
"%s [PORT: %d %d] [CPU %2d] [PID: %6d]\n", __FUNCTION__, port[
ETHDI_UP_VF], port[
ETHDI_CP_VF] , rte_lcore_id(), getpid());
522 printf(
"%s [CPU %2d] [PID: %6d]\n", __FUNCTION__, rte_lcore_id(), getpid());
524 if ((res = pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched_param))) {
525 printf(
"priority is not changed: coreId = %d, result1 = %d\n",rte_lcore_id(), res);
535 puts(
"IO loop finished");
+
#define PID_RADIO_ETH_TX_BURST
+
+
struct rte_mbuf * xran_ethdi_mbuf_alloc(void)
+
+
#define PANIC_ON(x, m,...)
+
+
#define print_dbg(fmt, args...)
+
struct rte_timer timer_ping
+
+
char * dpdk_dev[ETHDI_VF_MAX]
+
+
enum xran_if_state xran_if_current_state
+
struct xran_io_loop_cfg io_cfg
+
#define ETHER_TYPE_START_TX
+
int xran_ethdi_mbuf_send(struct rte_mbuf *mb, uint16_t ethertype)
+
struct rte_ring * tx_ring[ETHDI_VF_MAX]
+
int xran_ethdi_mbuf_send_cp(struct rte_mbuf *mb, uint16_t ethertype)
+
int(* ethertype_handler)(struct rte_mbuf *, uint64_t rx_time)
+
+
struct ether_addr entities[ID_BROADCAST+1]
+
void xran_init_port(int p_id, struct ether_addr *p_lls_cu_addr)
+
struct @21 xran_ethertype_handlers[]
+
+
+
int xran_ethdi_filter_packet(struct rte_mbuf *pkt, uint64_t rx_time)
+
struct rte_timer timer_sync
+
struct xran_ethdi_ctx g_ethdi_ctx
+
+
+
+
struct rte_ring * rx_ring[ETHDI_VF_MAX]
+
This file has all definitions for the Ethernet Data Interface Layer.
+
void xran_add_eth_hdr_vlan(struct ether_addr *dst, uint16_t ethertype, struct rte_mbuf *mb, uint16_t vlan_tci)
+
+
+
+
struct rte_ring * pkt_dump_ring[ETHDI_VF_MAX]
+
+
+
int xran_handle_ether(uint16_t ethertype, struct rte_mbuf *pkt, uint64_t rx_time)
+
+
+
int32_t process_dpdk_io(void)
+
+
+
+
struct rte_mempool * _eth_mbuf_pool
+
+
int xran_ethdi_init_dpdk_io(char *name, const struct xran_io_loop_cfg *io_cfg, int *lcore_id, struct ether_addr *p_lls_cu_addr, struct ether_addr *p_ru_addr, uint16_t cp_vlan, uint16_t up_vlan)
+
+
This file has all definitions for the Ethernet Data Interface Layer.
+
#define PID_RADIO_RX_VALIDATE
+
Modules provide debug prints and utility functions.
+
+
+
+
+
+
+
+
+
This file provides public interface to xRAN Front Haul layer implementation as defined in the ORAN-WG...
+
+
+
+
+
+
+
+
+
#define MLogTask(w, x, y)
+
+
+
+
void xran_init_mbuf_pool(void)
+
struct rte_timer timer_tx
+
#define XRAN_THREAD_DEFAULT_PRIO
+
+
int xran_register_ethertype_handler(uint16_t ethertype, ethertype_handler callback)
+