1 /******************************************************************************
3 * Copyright (c) 2020 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 *******************************************************************************/
20 * @brief This file has all definitions for the Ethernet Data Interface Layer
22 * @ingroup group_lte_source_auxlib
23 * @author Intel Corporation
26 #ifndef _XRANLIB_ETHERNET_H_
27 #define _XRANLIB_ETHERNET_H_
33 #include <rte_config.h>
34 #include <rte_ether.h>
38 #define BURST_SIZE 4096 /** IAVF_MAX_RING_DESC 4096 */
40 #define ETHER_TYPE_ETHDI RTE_ETHER_TYPE_IPV4 /* hack needed for jumbo frames */
41 #define ETHER_TYPE_ECPRI 0xAEFE
43 #define NUM_MBUFS 65535/*16383*/ /*65535*/ /** optimal is n = (2^q - 1) */
44 #define NUM_MBUFS_RING NUM_MBUFS+1 /** The size of the ring (must be a power of 2) */
46 #define NUM_MBUFS_VF 1048575
48 #define NUM_MBUFS_RING_TRX 2097152
50 #define MBUF_CACHE 256
52 #define MBUF_POOL_ELM_SMALL_INDIRECT (128 + RTE_PKTMBUF_HEADROOM ) /* indirect */
54 #define MBUF_POOL_ELM_SMALL (1500 + RTE_PKTMBUF_HEADROOM )/* regular ethernet MTU, most compatible */
55 #define MBUF_POOL_ELEMENT (MAX_RX_LEN + RTE_PKTMBUF_HEADROOM)
57 #define MBUF_POOL_PKT_GEN_ELM (256 + RTE_PKTMBUF_HEADROOM )
59 #define MAX_RX_LEN 9600
60 #define MAX_TX_LEN (MAX_RX_LEN - 14) /* headroom for rx driver */
61 #define MAX_DATA_SIZE (MAX_TX_LEN - sizeof(struct ether_hdr) - \
62 sizeof(struct ethdi_hdr) - sizeof(struct burst_hdr))
64 extern struct rte_mempool *_eth_mbuf_pool;
66 extern struct rte_mempool *_eth_mbuf_pkt_gen;
67 extern struct rte_mempool *_eth_mbuf_pool_big;
68 extern struct rte_mempool *socket_direct_pool;
69 extern struct rte_mempool *socket_indirect_pool;
71 extern struct rte_mempool *_eth_mbuf_pool_vf_rx[16][RTE_MAX_QUEUES_PER_PORT];
72 extern struct rte_mempool *_eth_mbuf_pool_vf_small[16];
80 int8_t data[]; /* original raw data starts here! */
84 void xran_init_mbuf_pool(uint32_t mtu);
85 void xran_init_port(int port, uint16_t num_rxq, uint32_t mtu);
86 void xran_init_port_mempool(int p_id, uint32_t mtu);
87 void xran_add_eth_hdr_vlan(struct rte_ether_addr *dst, uint16_t ethertype, struct rte_mbuf *mb);
89 #define PANIC_ON(x, m, ...) do { if (unlikely(x)) \
90 rte_panic("%s: " m "\n", #x, ##__VA_ARGS__); } while (0)
92 /* Add mbuf to the TX ring. */
93 static inline int xran_enqueue_mbuf(struct rte_mbuf *mb, struct rte_ring *r)
95 if (rte_ring_enqueue(r, mb) == 0) {
96 return 1; /* success */
100 //print_err("failed to enqueue packet on port %d (ring full)", mb->port);
109 #endif /* _XRANLIB_ETHERNET_H_ */