-/******************************************************************************
-*
-* Copyright (c) 2019 Intel.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-*******************************************************************************/
-
-
-/**
- * @brief This file has all definitions for the Ethernet Data Interface Layer
- * @file ethernet.h
- * @ingroup group_lte_source_auxlib
- * @author Intel Corporation
- **/
-
-#ifndef AUXLIB_ETHERNET_H
-#define AUXLIB_ETHERNET_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rte_config.h>
-#include <rte_ether.h>
-#include <rte_mbuf.h>
-
-#define BURST_SIZE 64
-
-//#define VLAN_SUPPORT
-#define FLEXRAN_UP_VLAN_TAG 2
-#define ETHER_TYPE_ETHDI ETHER_TYPE_IPv4 /* hack needed for jumbo frames */
-#define ETHER_TYPE_ECPRI 0xAEFE
-#define ETHER_TYPE_SYNC 0xBEFE
-#define ETHER_TYPE_START_TX 0xCEFE
-
-#define NUM_MBUFS 262144
-#define MBUF_CACHE 256
-
-#define MBUF_POOL_ELM_SMALL 1500 /* regular ethernet MTU, most compatible */
-#define MBUF_POOL_ELEMENT MAX_RX_LEN
-
-#define MAX_RX_LEN 9600
-#define MAX_TX_LEN (MAX_RX_LEN - 14) /* headroom for rx driver */
-#define MAX_DATA_SIZE (MAX_TX_LEN - sizeof(struct ether_hdr) - \
- sizeof(struct ethdi_hdr) - sizeof(struct burst_hdr))
-
-/* Looks like mbuf size is limited to 16 bits - see the buf_len field. */
-#define MBUF_POOL_ELM_BIG USHRT_MAX
-#define NUM_MBUFS_BIG 64
-
-#define DEFAULT_DUMP_LENGTH 96
-
-extern struct rte_mempool *_eth_mbuf_pool;
-extern struct rte_mempool *_eth_mbuf_pool_small;
-extern struct rte_mempool *_eth_mbuf_pool_big;
-
-/* Do NOT change the order of this enum and below
- * - need to be in sync with the table of handlers in testue.c */
-enum pkt_type
-{
- PKT_ZERO,
- PKT_EMPTY,
- PKT_DISCOVER_REQUEST,
- PKT_PING,
- PKT_PONG,
- PKT_DISCOVER_REPLY,
- PKT_LTE_DATA,
- PKT_LTE_CONTROL,
- PKT_BURST,
- PKT_DATATEST,
- PKT_ADD_ETHDEV,
- PKT_SYNC_START,
- PKT_LAST,
-};
-
-/* Do NOT change the order. */
-static char * const xran_pkt_descriptions[PKT_LAST + 1] = {
- "ZERO",
- "empty packet",
- "discovery request packet",
- "ping packet",
- "pong packet",
- "discovery reply packet",
- "LTE data packet",
- "LTE control packet",
- "BURST packet",
- "DATATEST packet",
- "Add ethernet port command packet",
- "SYNC-START packet",
- "LAST packet",
-};
-
-struct burst_hdr {
- int8_t pkt_idx;
- int8_t total_pkts;
- int8_t original_type;
- int8_t data[];
-};
-
-struct ethdi_hdr {
- uint8_t pkt_type;
- uint8_t source_id;
- uint8_t dest_id;
- int8_t data[]; /* original raw data starts here! */
-};
-
-
-void xran_init_mbuf_pool(void);
-
-void xran_init_port(int port, struct ether_addr *p_lls_cu_addr);
-
-void xran_add_eth_hdr_vlan(struct ether_addr *dst, uint16_t ethertype, struct rte_mbuf *mb, uint16_t vlan_tci);
-int xran_send_mbuf(struct ether_addr *dst, struct rte_mbuf *mb);
-
-int xran_send_message_burst(int dst_id, int pkt_type, void *body, int len);
-
-void xran_memdump(void *addr, int len);
-
-/*
- * Print a message after all critical processing done.
- * Mt-safe. 4 variants - normal, warning, error and debug log.
- */
-
-#define nlog(m, ...)
-#define delayed_message /* this is the old alias for this function */
-#define wlog(m, ...)
-#define elog(m, ...)
-#ifdef DEBUG
-# define dlog(m, ...)
-#else
-# define dlog(m, ...)
-#endif
-
-#define PANIC_ON(x, m, ...) do { if (unlikely(x)) \
- rte_panic("%s: " m "\n", #x, ##__VA_ARGS__); } while (0)
-
-/* Add mbuf to the TX ring. */
-static inline int xran_enqueue_mbuf(struct rte_mbuf *mb, struct rte_ring *r)
-{
- if (rte_ring_enqueue(r, mb) == 0) {
- return 1; /* success */
- }
-
- rte_pktmbuf_free(mb);
- wlog("failed to enqueue packet on port %d (ring full)", mb->port);
-
- return 0; /* fail */
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AUXLIB_ETHERNET_H */
+/******************************************************************************\r
+*\r
+* Copyright (c) 2019 Intel.\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+*******************************************************************************/\r
+\r
+/**\r
+ * @brief This file has all definitions for the Ethernet Data Interface Layer\r
+ * @file ethernet.h\r
+ * @ingroup group_lte_source_auxlib\r
+ * @author Intel Corporation\r
+ **/\r
+\r
+#ifndef AUXLIB_ETHERNET_H\r
+#define AUXLIB_ETHERNET_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include <rte_config.h>\r
+#include <rte_ether.h>\r
+#include <rte_mbuf.h>\r
+\r
+#define BURST_SIZE 4096\r
+\r
+//#define VLAN_SUPPORT\r
+#define FLEXRAN_UP_VLAN_TAG 2\r
+#define ETHER_TYPE_ETHDI ETHER_TYPE_IPv4 /* hack needed for jumbo frames */\r
+#define ETHER_TYPE_ECPRI 0xAEFE\r
+#define ETHER_TYPE_SYNC 0xBEFE\r
+#define ETHER_TYPE_START_TX 0xCEFE\r
+\r
+#define NUM_MBUFS 65536\r
+#define MBUF_CACHE 256\r
+\r
+#define MBUF_POOL_ELM_SMALL 1500 /* regular ethernet MTU, most compatible */\r
+#define MBUF_POOL_ELEMENT MAX_RX_LEN\r
+\r
+#define MAX_RX_LEN 9600\r
+#define MAX_TX_LEN (MAX_RX_LEN - 14) /* headroom for rx driver */\r
+#define MAX_DATA_SIZE (MAX_TX_LEN - sizeof(struct ether_hdr) - \\r
+ sizeof(struct ethdi_hdr) - sizeof(struct burst_hdr))\r
+\r
+/* Looks like mbuf size is limited to 16 bits - see the buf_len field. */\r
+#define MBUF_POOL_ELM_BIG USHRT_MAX\r
+#define NUM_MBUFS_BIG 64\r
+\r
+#define DEFAULT_DUMP_LENGTH 96\r
+\r
+extern struct rte_mempool *_eth_mbuf_pool;\r
+extern struct rte_mempool *_eth_mbuf_pool_small;\r
+extern struct rte_mempool *_eth_mbuf_pool_big;\r
+extern struct rte_mempool *socket_direct_pool;\r
+extern struct rte_mempool *socket_indirect_pool;\r
+\r
+/* Do NOT change the order of this enum and below\r
+ * - need to be in sync with the table of handlers in testue.c */\r
+enum pkt_type\r
+{\r
+ PKT_ZERO,\r
+ PKT_EMPTY,\r
+ PKT_DISCOVER_REQUEST,\r
+ PKT_PING,\r
+ PKT_PONG,\r
+ PKT_DISCOVER_REPLY,\r
+ PKT_LTE_DATA,\r
+ PKT_LTE_CONTROL,\r
+ PKT_BURST,\r
+ PKT_DATATEST,\r
+ PKT_ADD_ETHDEV,\r
+ PKT_SYNC_START,\r
+ PKT_LAST,\r
+};\r
+\r
+/* Do NOT change the order. */\r
+static char * const xran_pkt_descriptions[PKT_LAST + 1] = {\r
+ "ZERO",\r
+ "empty packet",\r
+ "discovery request packet",\r
+ "ping packet",\r
+ "pong packet",\r
+ "discovery reply packet",\r
+ "LTE data packet",\r
+ "LTE control packet",\r
+ "BURST packet",\r
+ "DATATEST packet",\r
+ "Add ethernet port command packet",\r
+ "SYNC-START packet",\r
+ "LAST packet",\r
+};\r
+\r
+struct burst_hdr {\r
+ int8_t pkt_idx;\r
+ int8_t total_pkts;\r
+ int8_t original_type;\r
+ int8_t data[];\r
+};\r
+\r
+struct ethdi_hdr {\r
+ uint8_t pkt_type;\r
+ uint8_t source_id;\r
+ uint8_t dest_id;\r
+ int8_t data[]; /* original raw data starts here! */\r
+};\r
+\r
+\r
+void xran_init_mbuf_pool(void);\r
+\r
+void xran_init_port(int port, struct ether_addr *p_lls_cu_addr);\r
+\r
+void xran_add_eth_hdr_vlan(struct ether_addr *dst, uint16_t ethertype, struct rte_mbuf *mb, uint16_t vlan_tci);\r
+\r
+#if 0\r
+void xran_memdump(void *addr, int len);\r
+void xran_add_eth_hdr(struct ether_addr *dst, uint16_t ethertype, struct rte_mbuf *);\r
+int xran_send_mbuf(struct ether_addr *dst, struct rte_mbuf *mb);\r
+int xran_send_message_burst(int dst_id, int pkt_type, void *body, int len);\r
+int xran_show_delayed_message(void);\r
+#endif\r
+/*\r
+ * Print a message after all critical processing done.\r
+ * Mt-safe. 4 variants - normal, warning, error and debug log.\r
+ */\r
+int __xran_delayed_msg(const char *fmt, ...);\r
+#define nlog(m, ...) __xran_delayed_msg("%s(): " m "\n", __FUNCTION__, ##__VA_ARGS__)\r
+#define delayed_message nlog /* this is the old alias for this function */\r
+#define wlog(m, ...) nlog("WARNING: " m, ##__VA_ARGS__)\r
+#define elog(m, ...) nlog("ERROR: " m, ##__VA_ARGS__)\r
+#ifdef DEBUG\r
+# define dlog(m, ...) nlog("DEBUG: " m, ##__VA_ARGS__)\r
+#else\r
+# define dlog(m, ...)\r
+#endif\r
+\r
+#define PANIC_ON(x, m, ...) do { if (unlikely(x)) \\r
+ rte_panic("%s: " m "\n", #x, ##__VA_ARGS__); } while (0)\r
+\r
+/* Add mbuf to the TX ring. */\r
+static inline int xran_enqueue_mbuf(struct rte_mbuf *mb, struct rte_ring *r)\r
+{\r
+ if (rte_ring_enqueue(r, mb) == 0) {\r
+ return 1; /* success */\r
+ }\r
+\r
+ rte_pktmbuf_free(mb);\r
+ wlog("failed to enqueue packet on port %d (ring full)", mb->port);\r
+\r
+ return 0; /* fail */\r
+}\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* AUXLIB_ETHERNET_H */\r