aboutsummaryrefslogtreecommitdiffstats
path: root/examples/ip_pipeline/pipeline/pipeline_routing_be.h
blob: 1276342757c148c1f29733c3481d212a8909be03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/*-
 *   BSD LICENSE
 *
 *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
 *   All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *     * Neither the name of Intel Corporation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __INCLUDE_PIPELINE_ROUTING_BE_H__
#define __INCLUDE_PIPELINE_ROUTING_BE_H__

#include <rte_ether.h>

#include "pipeline_common_be.h"

/*
 * Pipeline argument parsing
 */
#ifndef PIPELINE_ROUTING_N_ROUTES_DEFAULT
#define PIPELINE_ROUTING_N_ROUTES_DEFAULT                  4096
#endif

enum pipeline_routing_encap {
	PIPELINE_ROUTING_ENCAP_ETHERNET = 0,
	PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ,
	PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS,
};

struct pipeline_routing_params {
	/* routing */
	uint32_t n_routes;
	uint32_t port_local_dest;

	/* routing packet encapsulation */
	enum pipeline_routing_encap encap;
	uint32_t qinq_sched;
	uint32_t mpls_color_mark;

	/* arp */
	uint32_t n_arp_entries;

	/* packet buffer offsets */
	uint32_t ip_hdr_offset;
	uint32_t arp_key_offset;
	uint32_t color_offset;

	/* debug */
	uint32_t dbg_ah_disable;
};

int
pipeline_routing_parse_args(struct pipeline_routing_params *p,
	struct pipeline_params *params);

/*
 * Route
 */
enum pipeline_routing_route_key_type {
	PIPELINE_ROUTING_ROUTE_IPV4,
};

struct pipeline_routing_route_key_ipv4 {
	uint32_t ip;
	uint32_t depth;
};

struct pipeline_routing_route_key {
	enum pipeline_routing_route_key_type type;
	union {
		struct pipeline_routing_route_key_ipv4 ipv4;
	} key;
};

enum pipeline_routing_route_flags {
	PIPELINE_ROUTING_ROUTE_LOCAL = 1 << 0, /* 0 = remote; 1 = local */
	PIPELINE_ROUTING_ROUTE_ARP = 1 << 1, /* 0 = ARP OFF; 1 = ARP ON */
	PIPELINE_ROUTING_ROUTE_QINQ = 1 << 2, /* 0 = QINQ OFF; 1 = QINQ ON */
	PIPELINE_ROUTING_ROUTE_MPLS = 1 << 3, /* 0 = MPLS OFF; 1 = MPLS ON */
};

#define PIPELINE_ROUTING_MPLS_LABELS_MAX         4

struct pipeline_routing_route_data {
	uint32_t flags;
	uint32_t port_id; /* Output port ID */

	union {
		/* Next hop IP (valid only when ARP is enabled) */
		uint32_t ip;

		/* Next hop MAC address (valid only when ARP disabled */
		struct ether_addr macaddr;
	} ethernet;

	union {
		struct {
			uint16_t svlan;
			uint16_t cvlan;
		} qinq;

		struct {
			uint32_t labels[PIPELINE_ROUTING_MPLS_LABELS_MAX];
			uint32_t n_labels;
		} mpls;
	} l2;
};

/*
 * ARP
 */
enum pipeline_routing_arp_key_type {
	PIPELINE_ROUTING_ARP_IPV4,
};

struct pipeline_routing_arp_key_ipv4 {
	uint32_t port_id;
	uint32_t ip;
};

struct pipeline_routing_arp_key {
	enum pipeline_routing_arp_key_type type;
	union {
		struct pipeline_routing_arp_key_ipv4 ipv4;
	} key;
};

/*
 * Messages
 */
enum pipeline_routing_msg_req_type {
	PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD,
	PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL,
	PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD_DEFAULT,
	PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL_DEFAULT,
	PIPELINE_ROUTING_MSG_REQ_ARP_ADD,
	PIPELINE_ROUTING_MSG_REQ_ARP_DEL,
	PIPELINE_ROUTING_MSG_REQ_ARP_ADD_DEFAULT,
	PIPELINE_ROUTING_MSG_REQ_ARP_DEL_DEFAULT,
	PIPELINE_ROUTING_MSG_REQ_SET_MACADDR,
	PIPELINE_ROUTING_MSG_REQS
};

/*
 * MSG ROUTE ADD
 */
struct pipeline_routing_route_add_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;

	/* key */
	struct pipeline_routing_route_key key;

	/* data */
	struct pipeline_routing_route_data data;
};

struct pipeline_routing_route_add_msg_rsp {
	int status;
	int key_found;
	void *entry_ptr;
};

/*
 * MSG ROUTE DELETE
 */
struct pipeline_routing_route_delete_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;

	/* key */
	struct pipeline_routing_route_key key;
};

struct pipeline_routing_route_delete_msg_rsp {
	int status;
	int key_found;
};

/*
 * MSG ROUTE ADD DEFAULT
 */
struct pipeline_routing_route_add_default_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;

	/* data */
	uint32_t port_id;
};

struct pipeline_routing_route_add_default_msg_rsp {
	int status;
	void *entry_ptr;
};

/*
 * MSG ROUTE DELETE DEFAULT
 */
struct pipeline_routing_route_delete_default_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;
};

struct pipeline_routing_route_delete_default_msg_rsp {
	int status;
};

/*
 * MSG ARP ADD
 */
struct pipeline_routing_arp_add_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;

	/* key */
	struct pipeline_routing_arp_key key;

	/* data */
	struct ether_addr macaddr;
};

struct pipeline_routing_arp_add_msg_rsp {
	int status;
	int key_found;
	void *entry_ptr;
};

/*
 * MSG ARP DELETE
 */
struct pipeline_routing_arp_delete_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;

	/* key */
	struct pipeline_routing_arp_key key;
};

struct pipeline_routing_arp_delete_msg_rsp {
	int status;
	int key_found;
};

/*
 * MSG ARP ADD DEFAULT
 */
struct pipeline_routing_arp_add_default_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;

	/* data */
	uint32_t port_id;
};

struct pipeline_routing_arp_add_default_msg_rsp {
	int status;
	void *entry_ptr;
};

/*
 * MSG ARP DELETE DEFAULT
 */
struct pipeline_routing_arp_delete_default_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;
};

struct pipeline_routing_arp_delete_default_msg_rsp {
	int status;
};

/*
 * MSG SET MACADDR
 */
struct pipeline_routing_set_macaddr_msg_req {
	enum pipeline_msg_req_type type;
	enum pipeline_routing_msg_req_type subtype;

	uint64_t macaddr[PIPELINE_MAX_PORT_OUT];
};

struct pipeline_routing_set_macaddr_msg_rsp {
	int status;
};

extern struct pipeline_be_ops pipeline_routing_be_ops;

#endif