FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
lcp_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 #ifndef __LCP_ITF_PAIR_H__
16 #define __LCP_ITF_PAIR_H__
17 
18 #include <vnet/dpo/dpo.h>
19 #include <vnet/adj/adj.h>
20 #include <vnet/ip/ip_types.h>
21 
22 #include <plugins/linux-cp/lcp.h>
23 
24 #define foreach_lcp_itf_pair_flag _ (STALE, 0, "stale")
25 
26 typedef enum lip_flag_t_
27 {
28 #define _(a, b, c) LIP_FLAG_##a = (1 << b),
30 #undef _
31 } lip_flag_t;
32 
33 typedef enum
34 {
38 
39 #define N_LCP_ITF_HOST (LCP_ITF_HOST_TUN + 1)
40 
41 typedef struct lcp_itf_phy_adj
42 {
45 
46 /**
47  * A pair of interfaces
48  */
49 typedef struct lcp_itf_pair_t_
50 {
51  u32 lip_host_sw_if_index; /* VPP's sw_if_index for the host tap */
52  u32 lip_phy_sw_if_index; /* VPP's sw_if_index for the phy */
53  u8 *lip_host_name; /* linux's name for the tap */
54  u32 lip_vif_index; /* linux's index for the tap */
55  u8 *lip_namespace; /* namespace in which the tap lives */
56  lip_host_type_t lip_host_type; /* type of host interface */
57  lcp_itf_phy_adj_t lip_phy_adjs; /* adjacencies for phy l3 interface */
58  lip_flag_t lip_flags; /* Flags */
59  u8 lip_rewrite_len; /* The length of an L2 MAC rewrite */
60  f64 lip_create_ts; /* Timestamp of creation */
63 
65 
66 u8 *format_lcp_itf_pair (u8 *s, va_list *args);
67 void lcp_itf_pair_show (u32 phy_sw_if_index);
68 u32 lcp_itf_num_pairs (void);
69 
70 /**
71  * Get an interface-pair object from its VPP index
72  */
74 
75 /**
76  * Find a interface-pair object from the host interface
77  *
78  * @param host_sw_if_index host interface
79  * @return VPP's object index
80  */
81 extern index_t lcp_itf_pair_find_by_vif (u32 vif_index);
82 
83 /**
84  * Create an interface-pair
85  *
86  * @return error code
87  */
88 extern int lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index,
89  u8 *host_name, u32 host_index,
90  lip_host_type_t host_type, u8 *ns);
91 extern int lcp_itf_pair_add_sub (u32 vif, u8 *host_name, u32 sub_sw_if_index,
92  u32 phy_sw_if_index, u8 *ns);
93 extern int lcp_itf_pair_del (u32 phy_sw_if_index);
94 
95 /**
96  * Create an interface-pair from PHY sw_if_index and tap name.
97  *
98  * @return error code
99  */
100 extern int lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
101  lip_host_type_t host_if_type, u8 *ns,
102  u32 *host_sw_if_indexp);
103 
104 /**
105  * Delete a LCP_ITF_PAIR
106  */
107 extern int lcp_itf_pair_delete (u32 phy_sw_if_index);
108 
109 /**
110  * Callback function invoked during a walk of all interface-pairs
111  */
113 
114 /**
115  * Walk/visit each of the interface pairs
116  */
117 extern void lcp_itf_pair_walk (lcp_itf_pair_walk_cb_t cb, void *ctx);
118 
119 /**
120  * Begin and End the replace process
121  */
122 extern int lcp_itf_pair_replace_begin (void);
123 extern int lcp_itf_pair_replace_end (void);
124 
125 /**
126  * Retreive the pair in the DP
127  */
128 extern index_t *lip_db_by_phy;
129 extern u32 *lip_db_by_host;
130 
132 lcp_itf_pair_find_by_phy (u32 phy_sw_if_index)
133 {
134  if (phy_sw_if_index >= vec_len (lip_db_by_phy))
135  return INDEX_INVALID;
136  return (lip_db_by_phy[phy_sw_if_index]);
137 }
138 
140 lcp_itf_pair_find_by_host (u32 host_sw_if_index)
141 {
142  if (host_sw_if_index >= vec_len (lip_db_by_host))
143  return INDEX_INVALID;
144  return (lip_db_by_host[host_sw_if_index]);
145 }
146 
147 /**
148  * manage interface auto creation
149  */
150 void lcp_set_auto_intf (u8 is_auto);
151 int lcp_auto_intf (void);
152 
153 /*
154  * fd.io coding-style-patch-verification: ON
155  *
156  * Local Variables:
157  * eval: (c-set-style "gnu")
158  * End:
159  */
160 
161 #endif
adj.h
lcp_itf_pair_t_::lip_namespace
u8 * lip_namespace
Definition: lcp_interface.h:55
lcp_itf_pair_find_by_host
static index_t lcp_itf_pair_find_by_host(u32 host_sw_if_index)
Definition: lcp_interface.h:140
lcp_itf_pair_t_
A pair of interfaces.
Definition: lcp_interface.h:49
lcp_set_auto_intf
void lcp_set_auto_intf(u8 is_auto)
manage interface auto creation
Definition: lcp_api.c:45
lcp_auto_intf
int lcp_auto_intf(void)
Definition: lcp_api.c:53
lcp_itf_pair_t
struct lcp_itf_pair_t_ lcp_itf_pair_t
A pair of interfaces.
lcp_itf_pair_show
void lcp_itf_pair_show(u32 phy_sw_if_index)
Definition: lcp_interface.c:117
lcp_itf_pair_t_::lip_phy_sw_if_index
u32 lip_phy_sw_if_index
Definition: lcp_interface.h:52
lcp_itf_pair_t_::lip_phy_adjs
lcp_itf_phy_adj_t lip_phy_adjs
Definition: lcp_interface.h:57
lip_db_by_phy
index_t * lip_db_by_phy
Retreive the pair in the DP.
Definition: lcp_interface.c:60
lcp_itf_phy_adj::adj_index
adj_index_t adj_index[N_AF]
Definition: lcp_interface.h:43
lip_flag_t
enum lip_flag_t_ lip_flag_t
lcp.h
lcp_itf_pair_walk
void lcp_itf_pair_walk(lcp_itf_pair_walk_cb_t cb, void *ctx)
Walk/visit each of the interface pairs.
Definition: lcp_interface.c:475
lcp_itf_pair_walk_cb_t
walk_rc_t(* lcp_itf_pair_walk_cb_t)(index_t index, void *ctx)
Callback function invoked during a walk of all interface-pairs.
Definition: lcp_interface.h:112
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
lcp_itf_pair_replace_begin
int lcp_itf_pair_replace_begin(void)
Begin and End the replace process.
Definition: lcp_interface.c:846
dpo.h
lcp_itf_pair_replace_end
int lcp_itf_pair_replace_end(void)
Definition: lcp_interface.c:873
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
lcp_itf_pair_t_::lip_host_name
u8 * lip_host_name
Definition: lcp_interface.h:53
f64
double f64
Definition: types.h:142
lip_host_type_t
lip_host_type_t
Definition: lcp_interface.h:33
lcp_itf_pair_t_::lip_vif_index
u32 lip_vif_index
Definition: lcp_interface.h:54
ip_types.h
lcp_itf_pair_t_::lip_host_sw_if_index
u32 lip_host_sw_if_index
Definition: lcp_interface.h:51
LCP_ITF_HOST_TUN
@ LCP_ITF_HOST_TUN
Definition: lcp_interface.h:36
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
N_AF
#define N_AF
Definition: ip_types.h:27
lcp_itf_pair_del
int lcp_itf_pair_del(u32 phy_sw_if_index)
Definition: lcp_interface.c:380
lcp_itf_pair_find_by_vif
index_t lcp_itf_pair_find_by_vif(u32 vif_index)
Find a interface-pair object from the host interface.
Definition: lcp_interface.c:147
lcp_itf_pair_t_::lip_host_type
lip_host_type_t lip_host_type
Definition: lcp_interface.h:56
index
u32 index
Definition: flow_types.api:221
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
lcp_itf_phy_adj_t
struct lcp_itf_phy_adj lcp_itf_phy_adj_t
lcp_itf_num_pairs
u32 lcp_itf_num_pairs(void)
Definition: lcp_interface.c:48
foreach_lcp_itf_pair_flag
#define foreach_lcp_itf_pair_flag
Definition: lcp_interface.h:24
u32
unsigned int u32
Definition: types.h:88
lip_flag_t_
lip_flag_t_
Definition: lcp_interface.h:26
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
lcp_itf_phy_adj
Definition: lcp_interface.h:41
lcp_itf_pair_add_sub
int lcp_itf_pair_add_sub(u32 vif, u8 *host_name, u32 sub_sw_if_index, u32 phy_sw_if_index, u8 *ns)
Definition: lcp_interface.c:160
lcp_itf_pair_t_::lip_flags
lip_flag_t lip_flags
Definition: lcp_interface.h:58
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
u8
unsigned char u8
Definition: types.h:56
lcp_itf_pair_pool
lcp_itf_pair_t * lcp_itf_pair_pool
Pool of LIP objects.
Definition: lcp_interface.c:45
lip_db_by_host
u32 * lip_db_by_host
Definition: lcp_interface.c:61
lcp_itf_pair_find_by_phy
static index_t lcp_itf_pair_find_by_phy(u32 phy_sw_if_index)
Definition: lcp_interface.h:132
lcp_itf_pair_get
lcp_itf_pair_t * lcp_itf_pair_get(index_t index)
Get an interface-pair object from its VPP index.
Definition: lcp_interface.c:141
lcp_itf_pair_create
int lcp_itf_pair_create(u32 phy_sw_if_index, u8 *host_if_name, lip_host_type_t host_if_type, u8 *ns, u32 *host_sw_if_indexp)
Create an interface-pair from PHY sw_if_index and tap name.
Definition: lcp_interface.c:642
lcp_itf_pair_t_::lip_create_ts
f64 lip_create_ts
Definition: lcp_interface.h:60
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
format_lcp_itf_pair
u8 * format_lcp_itf_pair(u8 *s, va_list *args)
Definition: lcp_interface.c:70
LCP_ITF_HOST_TAP
@ LCP_ITF_HOST_TAP
Definition: lcp_interface.h:35
lcp_ethernet_node
vlib_node_registration_t lcp_ethernet_node
lcp_itf_pair_delete
int lcp_itf_pair_delete(u32 phy_sw_if_index)
Delete a LCP_ITF_PAIR.
Definition: lcp_interface.c:460
lcp_itf_pair_add
int lcp_itf_pair_add(u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name, u32 host_index, lip_host_type_t host_type, u8 *ns)
Create an interface-pair.
Definition: lcp_interface.c:226
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
lcp_itf_pair_t_::lip_rewrite_len
u8 lip_rewrite_len
Definition: lcp_interface.h:59