2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __LOOKUP_DPO_H__
17 #define __LOOKUP_DPO_H__
19 #include <vnet/vnet.h>
20 #include <vnet/fib/fib_types.h>
21 #include <vnet/dpo/dpo.h>
24 * Switch to use the packet's source or destination address for lookup
26 typedef enum lookup_input_t_ {
27 LOOKUP_INPUT_SRC_ADDR,
28 LOOKUP_INPUT_DST_ADDR,
29 } __attribute__ ((packed)) lookup_input_t;
31 #define LOOKUP_INPUTS { \
32 [LOOKUP_INPUT_SRC_ADDR] = "src-address", \
33 [LOOKUP_INPUT_DST_ADDR] = "dst-address", \
37 * Switch to use the packet's source or destination address for lookup
39 typedef enum lookup_table_t_ {
40 LOOKUP_TABLE_FROM_INPUT_INTERFACE,
41 LOOKUP_TABLE_FROM_CONFIG,
42 } __attribute__ ((packed)) lookup_table_t;
44 #define LOOKUP_TABLES { \
45 [LOOKUP_INPUT_SRC_ADDR] = "table-input-interface", \
46 [LOOKUP_INPUT_DST_ADDR] = "table-configured", \
50 * Switch to use the packet's source or destination address for lookup
52 typedef enum lookup_cast_t_ {
55 } __attribute__ ((packed)) lookup_cast_t;
57 #define LOOKUP_CASTS { \
58 [LOOKUP_UNICAST] = "unicast", \
59 [LOOKUP_MULTICAST] = "multicast", \
63 * A representation of an MPLS label for imposition in the data-path
65 typedef struct lookup_dpo_t
68 * The FIB, or interface from which to get a FIB, in which to perform
71 fib_node_index_t lkd_fib_index;
74 * The protocol of the FIB for the lookup, and hence
75 * the protocol of the packet
77 dpo_proto_t lkd_proto;
80 * Switch to use src or dst address
82 lookup_input_t lkd_input;
85 * Switch to use the table index passed, or the table of the input interface
87 lookup_table_t lkd_table;
90 * Unicast of rmulticast FIB lookup
92 lookup_cast_t lkd_cast;
100 extern void lookup_dpo_add_or_lock_w_fib_index(fib_node_index_t fib_index,
103 lookup_input_t input,
104 lookup_table_t table,
106 extern void lookup_dpo_add_or_lock_w_table_id(u32 table_id,
109 lookup_input_t input,
110 lookup_table_t table,
113 extern u8* format_lookup_dpo(u8 *s, va_list *args);
116 * Encapsulation violation for fast data-path access
118 extern lookup_dpo_t *lookup_dpo_pool;
120 static inline lookup_dpo_t *
121 lookup_dpo_get (index_t index)
123 return (pool_elt_at_index(lookup_dpo_pool, index));
126 extern void lookup_dpo_module_init(void);