45f37a1fb6e91df3fbcef3e7efec0143d928517d
[dpdk.git] / examples / ip_pipeline / pipeline / pipeline_routing_be.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef __INCLUDE_PIPELINE_ROUTING_BE_H__
35 #define __INCLUDE_PIPELINE_ROUTING_BE_H__
36
37 #include <rte_ether.h>
38
39 #include "pipeline_common_be.h"
40
41 /*
42  * Route
43  */
44 enum pipeline_routing_route_key_type {
45         PIPELINE_ROUTING_ROUTE_IPV4,
46 };
47
48 struct pipeline_routing_route_key_ipv4 {
49         uint32_t ip;
50         uint32_t depth;
51 };
52
53 struct pipeline_routing_route_key {
54         enum pipeline_routing_route_key_type type;
55         union {
56                 struct pipeline_routing_route_key_ipv4 ipv4;
57         } key;
58 };
59
60 enum pipeline_routing_route_flags {
61         PIPELINE_ROUTING_ROUTE_LOCAL = 1 << 0, /* 0 = remote; 1 = local */
62 };
63
64 /*
65  * ARP
66  */
67 enum pipeline_routing_arp_key_type {
68         PIPELINE_ROUTING_ARP_IPV4,
69 };
70
71 struct pipeline_routing_arp_key_ipv4 {
72         uint32_t port_id;
73         uint32_t ip;
74 };
75
76 struct pipeline_routing_arp_key {
77         enum pipeline_routing_arp_key_type type;
78         union {
79                 struct pipeline_routing_arp_key_ipv4 ipv4;
80         } key;
81 };
82
83 /*
84  * Messages
85  */
86 enum pipeline_routing_msg_req_type {
87         PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD,
88         PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL,
89         PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD_DEFAULT,
90         PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL_DEFAULT,
91         PIPELINE_ROUTING_MSG_REQ_ARP_ADD,
92         PIPELINE_ROUTING_MSG_REQ_ARP_DEL,
93         PIPELINE_ROUTING_MSG_REQ_ARP_ADD_DEFAULT,
94         PIPELINE_ROUTING_MSG_REQ_ARP_DEL_DEFAULT,
95         PIPELINE_ROUTING_MSG_REQS
96 };
97
98 /*
99  * MSG ROUTE ADD
100  */
101 struct pipeline_routing_route_add_msg_req {
102         enum pipeline_msg_req_type type;
103         enum pipeline_routing_msg_req_type subtype;
104
105         /* key */
106         struct pipeline_routing_route_key key;
107
108         /* data */
109         uint32_t flags;
110         uint32_t port_id; /* Output port ID */
111         uint32_t ip; /* Next hop IP address (only valid for remote routes) */
112 };
113
114 struct pipeline_routing_route_add_msg_rsp {
115         int status;
116         int key_found;
117         void *entry_ptr;
118 };
119
120 /*
121  * MSG ROUTE DELETE
122  */
123 struct pipeline_routing_route_delete_msg_req {
124         enum pipeline_msg_req_type type;
125         enum pipeline_routing_msg_req_type subtype;
126
127         /* key */
128         struct pipeline_routing_route_key key;
129 };
130
131 struct pipeline_routing_route_delete_msg_rsp {
132         int status;
133         int key_found;
134 };
135
136 /*
137  * MSG ROUTE ADD DEFAULT
138  */
139 struct pipeline_routing_route_add_default_msg_req {
140         enum pipeline_msg_req_type type;
141         enum pipeline_routing_msg_req_type subtype;
142
143         /* data */
144         uint32_t port_id;
145 };
146
147 struct pipeline_routing_route_add_default_msg_rsp {
148         int status;
149         void *entry_ptr;
150 };
151
152 /*
153  * MSG ROUTE DELETE DEFAULT
154  */
155 struct pipeline_routing_route_delete_default_msg_req {
156         enum pipeline_msg_req_type type;
157         enum pipeline_routing_msg_req_type subtype;
158 };
159
160 struct pipeline_routing_route_delete_default_msg_rsp {
161         int status;
162 };
163
164 /*
165  * MSG ARP ADD
166  */
167 struct pipeline_routing_arp_add_msg_req {
168         enum pipeline_msg_req_type type;
169         enum pipeline_routing_msg_req_type subtype;
170
171         /* key */
172         struct pipeline_routing_arp_key key;
173
174         /* data */
175         struct ether_addr macaddr;
176 };
177
178 struct pipeline_routing_arp_add_msg_rsp {
179         int status;
180         int key_found;
181         void *entry_ptr;
182 };
183
184 /*
185  * MSG ARP DELETE
186  */
187 struct pipeline_routing_arp_delete_msg_req {
188         enum pipeline_msg_req_type type;
189         enum pipeline_routing_msg_req_type subtype;
190
191         /* key */
192         struct pipeline_routing_arp_key key;
193 };
194
195 struct pipeline_routing_arp_delete_msg_rsp {
196         int status;
197         int key_found;
198 };
199
200 /*
201  * MSG ARP ADD DEFAULT
202  */
203 struct pipeline_routing_arp_add_default_msg_req {
204         enum pipeline_msg_req_type type;
205         enum pipeline_routing_msg_req_type subtype;
206
207         /* data */
208         uint32_t port_id;
209 };
210
211 struct pipeline_routing_arp_add_default_msg_rsp {
212         int status;
213         void *entry_ptr;
214 };
215
216 /*
217  * MSG ARP DELETE DEFAULT
218  */
219 struct pipeline_routing_arp_delete_default_msg_req {
220         enum pipeline_msg_req_type type;
221         enum pipeline_routing_msg_req_type subtype;
222 };
223
224 struct pipeline_routing_arp_delete_default_msg_rsp {
225         int status;
226 };
227
228 extern struct pipeline_be_ops pipeline_routing_be_ops;
229
230 #endif