1 /******************************************************************************
3 * Copyright (c) 2019 Intel.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 *******************************************************************************/
21 * @brief This file has all definitions for the Ethernet Data Interface Layer
23 * @ingroup group_lte_source_auxlib
24 * @author Intel Corporation
27 #ifndef AUXLIB_ETHERNET_H
28 #define AUXLIB_ETHERNET_H
34 #include <rte_config.h>
35 #include <rte_ether.h>
40 //#define VLAN_SUPPORT
41 #define FLEXRAN_UP_VLAN_TAG 2
42 #define ETHER_TYPE_ETHDI ETHER_TYPE_IPv4 /* hack needed for jumbo frames */
43 #define ETHER_TYPE_ECPRI 0xAEFE
44 #define ETHER_TYPE_SYNC 0xBEFE
45 #define ETHER_TYPE_START_TX 0xCEFE
47 #define NUM_MBUFS 262144
48 #define MBUF_CACHE 256
50 #define MBUF_POOL_ELM_SMALL 1500 /* regular ethernet MTU, most compatible */
51 #define MBUF_POOL_ELEMENT MAX_RX_LEN
53 #define MAX_RX_LEN 9600
54 #define MAX_TX_LEN (MAX_RX_LEN - 14) /* headroom for rx driver */
55 #define MAX_DATA_SIZE (MAX_TX_LEN - sizeof(struct ether_hdr) - \
56 sizeof(struct ethdi_hdr) - sizeof(struct burst_hdr))
58 /* Looks like mbuf size is limited to 16 bits - see the buf_len field. */
59 #define MBUF_POOL_ELM_BIG USHRT_MAX
60 #define NUM_MBUFS_BIG 64
62 #define DEFAULT_DUMP_LENGTH 96
64 extern struct rte_mempool *_eth_mbuf_pool;
65 extern struct rte_mempool *_eth_mbuf_pool_small;
66 extern struct rte_mempool *_eth_mbuf_pool_big;
68 /* Do NOT change the order of this enum and below
69 * - need to be in sync with the table of handlers in testue.c */
87 /* Do NOT change the order. */
88 static char * const xran_pkt_descriptions[PKT_LAST + 1] = {
91 "discovery request packet",
94 "discovery reply packet",
99 "Add ethernet port command packet",
107 int8_t original_type;
115 int8_t data[]; /* original raw data starts here! */
119 void xran_init_mbuf_pool(void);
121 void xran_init_port(int port, struct ether_addr *p_lls_cu_addr);
123 void xran_add_eth_hdr_vlan(struct ether_addr *dst, uint16_t ethertype, struct rte_mbuf *mb, uint16_t vlan_tci);
124 int xran_send_mbuf(struct ether_addr *dst, struct rte_mbuf *mb);
126 int xran_send_message_burst(int dst_id, int pkt_type, void *body, int len);
128 void xran_memdump(void *addr, int len);
131 * Print a message after all critical processing done.
132 * Mt-safe. 4 variants - normal, warning, error and debug log.
136 #define delayed_message /* this is the old alias for this function */
140 # define dlog(m, ...)
142 # define dlog(m, ...)
145 #define PANIC_ON(x, m, ...) do { if (unlikely(x)) \
146 rte_panic("%s: " m "\n", #x, ##__VA_ARGS__); } while (0)
148 /* Add mbuf to the TX ring. */
149 static inline int xran_enqueue_mbuf(struct rte_mbuf *mb, struct rte_ring *r)
151 if (rte_ring_enqueue(r, mb) == 0) {
152 return 1; /* success */
155 rte_pktmbuf_free(mb);
156 wlog("failed to enqueue packet on port %d (ring full)", mb->port);
165 #endif /* AUXLIB_ETHERNET_H */