o-du/phy
Intel O-RAN/X-RAN Generated Doxygen Documentation
ethdi.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright (c) 2019 Intel.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *******************************************************************************/
18 
27 #ifndef _ETHDI_H_
28 #define _ETHDI_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <rte_config.h>
35 #include <rte_mbuf.h>
36 #include <rte_timer.h>
37 
38 /* comment this to enable PDUMP
39  * DPDK has to be compiled with
40  * CONFIG_RTE_LIBRTE_PMD_PCAP=y
41  * CONFIG_RTE_LIBRTE_PDUMP=y
42  */
43 #undef RTE_LIBRTE_PDUMP
44 
45 #ifdef RTE_LIBRTE_PDUMP
46 #include <rte_pdump.h>
47 #endif
48 
49 #include "ethernet.h"
50 #include "xran_fh_o_du.h"
51 
52 #define XRAN_THREAD_DEFAULT_PRIO (98)
53 
54 /* How often to ping? */
55 #define PING_INTERVAL 300 /* (us) */
56 #define PING_BUSY_POLL 50 /* (us) how long to actively wait for response */
57 
58 /* If we're not receiving packets for more then this threshold... */
59 //#define SLEEP_THRESHOLD (rte_get_tsc_hz() / 30) /* = 33.3(3)ms */
60 /* we go to sleep for this long (usleep). Undef SLEEP_TRESHOLD to disable. */
61 #define SLEEP_TIME 200 /* (us) */
62 #define BCAST {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
63 
64 #define TX_TIMER_INTERVAL ((rte_get_timer_hz() / 1000000000L)*interval_us*1000) /* nanosec */
65 #define TX_RX_LOOP_TIME rte_get_timer_hz() / 1
66 
68 {
72 };
73 
75 {
79 };
80 
82 {
83  uint8_t id;
85  char *bbdev_dev[1];
87  int core;
88  int system_core; /* Needed as DPDK will change your starting core. */
89  int pkt_proc_core; /* Needed for packet processing thread. */
90  int pkt_aux_core; /* Needed for packet dumping for debug purposes. */
91  int timing_core; /* Needed for getting precise time */
92  int port[ETHDI_VF_MAX]; /* This is auto-detected, no need to set. */
93 };
94 
95 /* CAUTION: Keep in sync with the string table below. */
97 {
102 };
103 
104 static char *const entity_names[] = {
105  "xRAN lls-CU sim app",
106  "xRAN RU sim app",
107 };
108 
109 typedef int (*PROCESS_CB)(void * arg);
110 
112 {
113  struct xran_io_loop_cfg io_cfg;
114  struct ether_addr entities[ID_BROADCAST + 1];
115  uint8_t ping_state;
118 
119  struct rte_ring *tx_ring[ETHDI_VF_MAX];
120  struct rte_ring *rx_ring[ETHDI_VF_MAX];
121  struct rte_ring *pkt_dump_ring[ETHDI_VF_MAX];
122  struct rte_timer timer_autodetect;
123  struct rte_timer timer_ping;
124  struct rte_timer timer_sync;
125  struct rte_timer timer_tx;
126 
127  uint64_t busy_poll_till;
128 
129  unsigned pkt_stats[PKT_LAST + 1];
130 
131  uint16_t cp_vtag;
132  uint16_t up_vtag;
133 };
134 
135 enum {
138 };
139 
141 extern uint8_t ping_dst_id;
142 extern struct ether_addr entities_addrs[];
143 
144 static inline struct xran_ethdi_ctx *xran_ethdi_get_ctx(void)
145 {
146  extern struct xran_ethdi_ctx g_ethdi_ctx;
147 
148  return &g_ethdi_ctx;
149 }
150 typedef int (*xran_ethdi_handler)(struct rte_mbuf *, int sender, uint64_t rx_time);
151 
152 typedef int (*ethertype_handler)(struct rte_mbuf *, uint64_t rx_time);
153 typedef int (*xran_ethdi_handler)(struct rte_mbuf *, int sender, uint64_t rx_time);
154 typedef void (xran_ethdi_tx_callback)(struct rte_timer *tim, void *arg);
155 
156 
158 
159 
160 int xran_ethdi_init_dpdk_io(char *name, const struct xran_io_loop_cfg *io_cfg,
161  int *lcore_id, struct ether_addr *p_lls_cu_addr, struct ether_addr *p_ru_addr,
162  uint16_t cp_vlan, uint16_t up_vlan);
163 struct rte_mbuf *xran_ethdi_mbuf_alloc(void);
164 int xran_ethdi_mbuf_send(struct rte_mbuf *mb, uint16_t ethertype);
165 int xran_ethdi_mbuf_send_cp(struct rte_mbuf *mb, uint16_t ethertype);
166 #if 0
167 void xran_ethdi_stop_tx(void);
168 void xran_ethdi_ports_stats(void);
169 int xran_ethdi_dpdk_io_loop(void *);
170 #endif
171 int xran_ethdi_filter_packet(struct rte_mbuf *pkt, uint64_t rx_time);
172 int32_t process_dpdk_io(void);
173 
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* #ifndef _ETHDI_H_ */
int(* PROCESS_CB)(void *arg)
Definition: ethdi.h:109
Definition: ethdi.h:101
int32_t process_dpdk_io(void)
Definition: ethdi.c:445
struct ether_addr entities_addrs[]
Definition: ethdi.h:99
char * dpdk_dev[ETHDI_VF_MAX]
Definition: ethdi.h:84
int(* ethertype_handler)(struct rte_mbuf *, uint64_t rx_time)
Definition: ethdi.h:152
uint8_t id
Definition: ethdi.h:83
int ping_times
Definition: ethdi.h:116
xran_entities_id
Definition: ethdi.h:96
int xran_ethdi_filter_packet(struct rte_mbuf *pkt, uint64_t rx_time)
Definition: ethdi.c:156
int xran_ethdi_mbuf_send(struct rte_mbuf *mb, uint16_t ethertype)
Definition: ethdi.c:82
struct xran_ethdi_ctx g_ethdi_ctx
Definition: ethdi.c:74
int pkt_proc_core
Definition: ethdi.h:89
struct rte_mbuf * xran_ethdi_mbuf_alloc(void)
Definition: ethdi.c:77
This file has all definitions for the Ethernet Data Interface Layer.
int known_peers
Definition: ethdi.h:117
void() xran_ethdi_tx_callback(struct rte_timer *tim, void *arg)
Definition: ethdi.h:154
uint8_t ping_state
Definition: ethdi.h:115
int timing_core
Definition: ethdi.h:91
uint64_t busy_poll_till
Definition: ethdi.h:127
int port[ETHDI_VF_MAX]
Definition: ethdi.h:92
xran_if_state
Definition: xran_fh_o_du.h:189
uint16_t cp_vtag
Definition: ethdi.h:131
uint8_t ping_dst_id
int pkt_aux_core
Definition: ethdi.h:90
enum xran_if_state xran_if_current_state
Definition: ethdi.c:75
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)
Definition: ethdi.c:288
int xran_ethdi_mbuf_send_cp(struct rte_mbuf *mb, uint16_t ethertype)
Definition: ethdi.c:94
uint16_t up_vtag
Definition: ethdi.h:132
This file provides public interface to xRAN Front Haul layer implementation as defined in the ORAN-WG...
uint16_t ethertype
Definition: ethdi.c:114
int system_core
Definition: ethdi.h:88
xran_ethdi_vf_ports
Definition: ethdi.h:74
char * bbdev_dev[1]
Definition: ethdi.h:85
int(* xran_ethdi_handler)(struct rte_mbuf *, int sender, uint64_t rx_time)
Definition: ethdi.h:150
int bbdev_mode
Definition: ethdi.h:86
xran_ping_states
Definition: ethdi.h:67
int xran_register_ethertype_handler(uint16_t ethertype, ethertype_handler callback)
Definition: ethdi.c:124