2 * Copyright (c) 2017 Intel Corporation.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #ifndef __NGX_TLDK_H__
28 #define __NGX_TLDK_H__
34 #include <ngx_config.h>
37 #include <rte_config.h>
39 #include <rte_common.h>
40 #include <rte_ether.h>
43 #include <tle_event.h>
45 #define MAX_PKT_BURST 0x20
47 #define MAX_PORT_QUEUE \
48 (sizeof(((struct tldk_port_conf *)NULL)->queue_map) * CHAR_BIT)
50 #define MAX_CTX_PER_LOCRE 32
52 struct tldk_port_conf {
61 struct ether_addr mac;
64 struct tldk_dev_conf {
70 struct tldk_dest_conf {
79 struct ether_addr mac;
82 #define TLDK_MAX_DEST 0x10
84 struct tldk_ctx_conf {
97 uint32_t be_in_worker;
98 uint32_t tcp_timewait; /* TCP TIME_WAIT value in milliseconds */
99 struct tldk_dev_conf dev[RTE_MAX_ETHPORTS];
100 struct tldk_dest_conf dest[TLDK_MAX_DEST];
103 typedef struct tldk_conf tldk_conf_t;
107 char *eal_argv[NGX_CONF_MAX_ARGS];
108 char eal_cmd[PATH_MAX];
110 struct tldk_port_conf port[RTE_MAX_ETHPORTS];
112 struct tldk_ctx_conf ctx[RTE_MAX_LCORE];
115 extern char *tldk_block_parse(ngx_conf_t *, ngx_command_t *, void *);
116 extern char *tldk_ctx_parse(ngx_conf_t *, ngx_command_t *, void *);
120 struct rte_mbuf *pkt[2 * MAX_PKT_BURST];
125 struct tldk_dev_conf cf;
136 struct pkt_buf tx_buf;
139 #define LCORE_MAX_DST (UINT8_MAX + 1)
142 const struct tldk_ctx_conf *cf;
143 struct rte_lpm *lpm4;
144 struct rte_lpm6 *lpm6;
146 struct rte_mempool *mpool;
147 struct rte_mempool *frag_mpool;
149 struct tldk_dev dev[RTE_MAX_ETHPORTS];
152 struct tle_dest dst4[LCORE_MAX_DST];
153 struct tle_dest dst6[LCORE_MAX_DST];
155 uint64_t flags[UINT8_MAX + 1];
157 } __rte_cache_aligned;
159 extern struct tldk_ctx wrk2ctx[RTE_MAX_LCORE];
161 struct lcore_ctxs_list {
163 struct tldk_ctx *ctxs[MAX_CTX_PER_LOCRE];
167 #define DUMMY_MACRO do {} while (0)
170 #define BE_TRACE(fmt, arg...) printf(fmt, ##arg)
171 #define BE_PKT_DUMP(p) rte_pktmbuf_dump(stdout, (p), 74)
173 #define BE_TRACE(fmt, arg...) DUMMY_MACRO
174 #define BE_PKT_DUMP(p) DUMMY_MACRO
178 #define FE_TRACE(fmt, arg...) printf(fmt, ##arg)
179 #define FE_PKT_DUMP(p) rte_pktmbuf_dump(stdout, (p), 74)
181 #define FE_TRACE(fmt, arg...) DUMMY_MACRO
182 #define FE_PKT_DUMP(p) DUMMY_MACRO
186 #endif /* __NGX_TLDK_H__ */