2 * Copyright (c) 2015 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.
15 #ifndef __included_srv6_ad_flow_h__
16 #define __included_srv6_ad_flow_h__
18 #include <vnet/vnet.h>
19 #include <vnet/ip/ip.h>
20 #include <vnet/srv6/sr.h>
21 #include <vnet/srv6/sr_packet.h>
23 #include <vppinfra/error.h>
24 #include <vppinfra/elog.h>
26 #include <vppinfra/dlist.h>
27 #include <vppinfra/bihash_40_8.h>
29 #define AD_TYPE_IP4 IP_PROTOCOL_IP_IN_IP
30 #define AD_TYPE_IP6 IP_PROTOCOL_IPV6
32 #define SRV6_AD_FLOW_DEFAULT_CACHE_SIZE 100
33 #define SRV6_AD_CACHE_TIMEOUT 300
40 /* Cache key (5-tuple) */
43 ip46_address_t s_addr;
44 ip46_address_t d_addr;
50 /* Cached encapsulation headers */
54 /* Index in global LRU list */
57 /* Last update timestamp */
60 /* Last heard timestamp */
62 } srv6_ad_flow_entry_t;
65 * This is the memory that will be stored per each localsid
66 * the user instantiates
70 ip46_address_t nh_addr; /**< Proxied device address */
71 u32 sw_if_index_out; /**< Outgoing iface to proxied dev. */
72 u32 nh_adj; /**< Adjacency index for out. iface */
75 u32 sw_if_index_in; /**< Incoming iface from proxied dev. */
79 uword cache_memory_size;
81 clib_bihash_40_8_t ftable; /**< Flow table */
82 srv6_ad_flow_entry_t *cache; /**< Cache table */
83 dlist_elt_t *lru_pool;
87 } srv6_ad_flow_localsid_t;
91 u16 msg_id_base; /**< API message ID base */
93 vlib_main_t *vlib_main; /**< [convenience] vlib main */
94 vnet_main_t *vnet_main; /**< [convenience] vnet main */
96 dpo_type_t srv6_ad_flow_dpo_type; /**< DPO type */
98 u32 srv6_localsid_behavior_id; /**< SRv6 LocalSID behavior number */
100 u32 *sw_iface_localsid2; /**< Retrieve local SID from iface */
101 u32 *sw_iface_localsid4; /**< Retrieve local SID from iface */
102 u32 *sw_iface_localsid6; /**< Retrieve local SID from iface */
104 srv6_ad_flow_localsid_t **sids; /**< Pool of AD SID pointers */
106 vlib_combined_counter_main_t
107 sid_bypass_counters; /**< Packets/bytes bypassing NF */
108 vlib_combined_counter_main_t sid_punt_counters; /**< Packets/bytes punted */
109 vlib_combined_counter_main_t sid_cache_full_counters;
111 vlib_combined_counter_main_t
112 rw_valid_counters; /**< Valid rewrite counters */
113 vlib_combined_counter_main_t
114 rw_invalid_counters; /**< Invalid rewrite counters */
115 } srv6_ad_flow_main_t;
119 srv6_ad_flow_localsid_t *ls;
121 } srv6_ad_is_idle_entry_ctx_t;
123 extern srv6_ad_flow_main_t srv6_ad_flow_main;
125 format_function_t format_srv6_ad_flow_localsid;
126 unformat_function_t unformat_srv6_ad_flow_localsid;
128 void srv6_ad_flow_dpo_lock (dpo_id_t *dpo);
129 void srv6_ad_flow_dpo_unlock (dpo_id_t *dpo);
131 extern vlib_node_registration_t srv6_ad_flow_localsid_node;
133 #endif /* __included_srv6_ad_flow_h__ */
136 * fd.io coding-style-patch-verification: ON
139 * eval: (c-set-style "gnu")