New upstream version 18.02
[deb_dpdk.git] / examples / ip_pipeline / pipeline / pipeline_routing_be.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4
5 #ifndef __INCLUDE_PIPELINE_ROUTING_BE_H__
6 #define __INCLUDE_PIPELINE_ROUTING_BE_H__
7
8 #include <rte_ether.h>
9
10 #include "pipeline_common_be.h"
11
12 /*
13  * Pipeline argument parsing
14  */
15 #ifndef PIPELINE_ROUTING_N_ROUTES_DEFAULT
16 #define PIPELINE_ROUTING_N_ROUTES_DEFAULT                  4096
17 #endif
18
19 enum pipeline_routing_encap {
20         PIPELINE_ROUTING_ENCAP_ETHERNET = 0,
21         PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ,
22         PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS,
23 };
24
25 struct pipeline_routing_params {
26         /* routing */
27         uint32_t n_routes;
28         uint32_t port_local_dest;
29
30         /* routing packet encapsulation */
31         enum pipeline_routing_encap encap;
32         uint32_t qinq_sched;
33         uint32_t mpls_color_mark;
34
35         /* arp */
36         uint32_t n_arp_entries;
37
38         /* packet buffer offsets */
39         uint32_t ip_hdr_offset;
40         uint32_t arp_key_offset;
41         uint32_t color_offset;
42
43         /* debug */
44         uint32_t dbg_ah_disable;
45 };
46
47 int
48 pipeline_routing_parse_args(struct pipeline_routing_params *p,
49         struct pipeline_params *params);
50
51 /*
52  * Route
53  */
54 enum pipeline_routing_route_key_type {
55         PIPELINE_ROUTING_ROUTE_IPV4,
56 };
57
58 struct pipeline_routing_route_key_ipv4 {
59         uint32_t ip;
60         uint32_t depth;
61 };
62
63 struct pipeline_routing_route_key {
64         enum pipeline_routing_route_key_type type;
65         union {
66                 struct pipeline_routing_route_key_ipv4 ipv4;
67         } key;
68 };
69
70 enum pipeline_routing_route_flags {
71         PIPELINE_ROUTING_ROUTE_LOCAL = 1 << 0, /* 0 = remote; 1 = local */
72         PIPELINE_ROUTING_ROUTE_ARP = 1 << 1, /* 0 = ARP OFF; 1 = ARP ON */
73         PIPELINE_ROUTING_ROUTE_QINQ = 1 << 2, /* 0 = QINQ OFF; 1 = QINQ ON */
74         PIPELINE_ROUTING_ROUTE_MPLS = 1 << 3, /* 0 = MPLS OFF; 1 = MPLS ON */
75 };
76
77 #define PIPELINE_ROUTING_MPLS_LABELS_MAX         4
78
79 struct pipeline_routing_route_data {
80         uint32_t flags;
81         uint32_t port_id; /* Output port ID */
82
83         union {
84                 /* Next hop IP (valid only when ARP is enabled) */
85                 uint32_t ip;
86
87                 /* Next hop MAC address (valid only when ARP disabled */
88                 struct ether_addr macaddr;
89         } ethernet;
90
91         union {
92                 struct {
93                         uint16_t svlan;
94                         uint16_t cvlan;
95                 } qinq;
96
97                 struct {
98                         uint32_t labels[PIPELINE_ROUTING_MPLS_LABELS_MAX];
99                         uint32_t n_labels;
100                 } mpls;
101         } l2;
102 };
103
104 /*
105  * ARP
106  */
107 enum pipeline_routing_arp_key_type {
108         PIPELINE_ROUTING_ARP_IPV4,
109 };
110
111 struct pipeline_routing_arp_key_ipv4 {
112         uint32_t port_id;
113         uint32_t ip;
114 };
115
116 struct pipeline_routing_arp_key {
117         enum pipeline_routing_arp_key_type type;
118         union {
119                 struct pipeline_routing_arp_key_ipv4 ipv4;
120         } key;
121 };
122
123 /*
124  * Messages
125  */
126 enum pipeline_routing_msg_req_type {
127         PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD,
128         PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL,
129         PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD_DEFAULT,
130         PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL_DEFAULT,
131         PIPELINE_ROUTING_MSG_REQ_ARP_ADD,
132         PIPELINE_ROUTING_MSG_REQ_ARP_DEL,
133         PIPELINE_ROUTING_MSG_REQ_ARP_ADD_DEFAULT,
134         PIPELINE_ROUTING_MSG_REQ_ARP_DEL_DEFAULT,
135         PIPELINE_ROUTING_MSG_REQ_SET_MACADDR,
136         PIPELINE_ROUTING_MSG_REQS
137 };
138
139 /*
140  * MSG ROUTE ADD
141  */
142 struct pipeline_routing_route_add_msg_req {
143         enum pipeline_msg_req_type type;
144         enum pipeline_routing_msg_req_type subtype;
145
146         /* key */
147         struct pipeline_routing_route_key key;
148
149         /* data */
150         struct pipeline_routing_route_data data;
151 };
152
153 struct pipeline_routing_route_add_msg_rsp {
154         int status;
155         int key_found;
156         void *entry_ptr;
157 };
158
159 /*
160  * MSG ROUTE DELETE
161  */
162 struct pipeline_routing_route_delete_msg_req {
163         enum pipeline_msg_req_type type;
164         enum pipeline_routing_msg_req_type subtype;
165
166         /* key */
167         struct pipeline_routing_route_key key;
168 };
169
170 struct pipeline_routing_route_delete_msg_rsp {
171         int status;
172         int key_found;
173 };
174
175 /*
176  * MSG ROUTE ADD DEFAULT
177  */
178 struct pipeline_routing_route_add_default_msg_req {
179         enum pipeline_msg_req_type type;
180         enum pipeline_routing_msg_req_type subtype;
181
182         /* data */
183         uint32_t port_id;
184 };
185
186 struct pipeline_routing_route_add_default_msg_rsp {
187         int status;
188         void *entry_ptr;
189 };
190
191 /*
192  * MSG ROUTE DELETE DEFAULT
193  */
194 struct pipeline_routing_route_delete_default_msg_req {
195         enum pipeline_msg_req_type type;
196         enum pipeline_routing_msg_req_type subtype;
197 };
198
199 struct pipeline_routing_route_delete_default_msg_rsp {
200         int status;
201 };
202
203 /*
204  * MSG ARP ADD
205  */
206 struct pipeline_routing_arp_add_msg_req {
207         enum pipeline_msg_req_type type;
208         enum pipeline_routing_msg_req_type subtype;
209
210         /* key */
211         struct pipeline_routing_arp_key key;
212
213         /* data */
214         struct ether_addr macaddr;
215 };
216
217 struct pipeline_routing_arp_add_msg_rsp {
218         int status;
219         int key_found;
220         void *entry_ptr;
221 };
222
223 /*
224  * MSG ARP DELETE
225  */
226 struct pipeline_routing_arp_delete_msg_req {
227         enum pipeline_msg_req_type type;
228         enum pipeline_routing_msg_req_type subtype;
229
230         /* key */
231         struct pipeline_routing_arp_key key;
232 };
233
234 struct pipeline_routing_arp_delete_msg_rsp {
235         int status;
236         int key_found;
237 };
238
239 /*
240  * MSG ARP ADD DEFAULT
241  */
242 struct pipeline_routing_arp_add_default_msg_req {
243         enum pipeline_msg_req_type type;
244         enum pipeline_routing_msg_req_type subtype;
245
246         /* data */
247         uint32_t port_id;
248 };
249
250 struct pipeline_routing_arp_add_default_msg_rsp {
251         int status;
252         void *entry_ptr;
253 };
254
255 /*
256  * MSG ARP DELETE DEFAULT
257  */
258 struct pipeline_routing_arp_delete_default_msg_req {
259         enum pipeline_msg_req_type type;
260         enum pipeline_routing_msg_req_type subtype;
261 };
262
263 struct pipeline_routing_arp_delete_default_msg_rsp {
264         int status;
265 };
266
267 /*
268  * MSG SET MACADDR
269  */
270 struct pipeline_routing_set_macaddr_msg_req {
271         enum pipeline_msg_req_type type;
272         enum pipeline_routing_msg_req_type subtype;
273
274         uint64_t macaddr[PIPELINE_MAX_PORT_OUT];
275 };
276
277 struct pipeline_routing_set_macaddr_msg_rsp {
278         int status;
279 };
280
281 extern struct pipeline_be_ops pipeline_routing_be_ops;
282
283 #endif