FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
interface_tx_dpo.c
Go to the documentation of this file.
1 /*
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:
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 
17 #include <vnet/adj/rewrite.h>
18 
19 /*
20  * We do not lock nor unlock these DPOs since there is nothing to lock
21  * all we do is construct DPO object wrappers around a sw_if_index
22  */
23 static void
25 {
26 }
27 
28 static void
30 {
31 }
32 
33 /*
34  * interface_tx_dpo_add_or_lock
35  *
36  * construct DPO object wrappers around a sw_if_index
37  */
38 void
40  u32 sw_if_index,
41  dpo_id_t *dpo)
42 {
43  dpo_set(dpo, DPO_INTERFACE_TX, proto, sw_if_index);
44 }
45 
46 u8*
47 format_interface_tx_dpo (u8* s, va_list *ap)
48 {
49  index_t index = va_arg(*ap, index_t);
50  CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
51  vnet_main_t * vnm = vnet_get_main();
52 
53  return (format(s, "%U-tx-dpo:",
55  vnm,
56  vnet_get_sw_interface(vnm, index)));
57 }
58 
59 static void
61 {
62 }
63 
64 u32*
66 {
67  u32 *node_indices = NULL;
68 
69  /*
70  * return the interface's TX node for the wrapped sw_if_index
71  */
72  vec_add1(node_indices,
74  dpo->dpoi_index));
75 
76  return (node_indices);
77 }
78 
79 const static dpo_vft_t interface_tx_dpo_vft = {
81  .dv_unlock = interface_tx_dpo_unlock,
82  .dv_format = format_interface_tx_dpo,
83  .dv_mem_show = interface_tx_dpo_mem_show,
84  .dv_get_next_node = interface_tx_dpo_get_next_node,
85 };
86 
87 void
89 {
90  dpo_register(DPO_INTERFACE_TX, &interface_tx_dpo_vft, NULL);
91 }
92 
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:382
#define CLIB_UNUSED(x)
Definition: clib.h:79
A virtual function table regisitered for a DPO type.
Definition: dpo.h:377
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
#define NULL
Definition: clib.h:55
u8 * format_interface_tx_dpo(u8 *s, va_list *ap)
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:41
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
static void interface_tx_dpo_lock(dpo_id_t *dpo)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
Definition: dpo.c:306
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:166
format_function_t format_vnet_sw_interface_name
u32 * interface_tx_dpo_get_next_node(const dpo_id_t *dpo)
void interface_tx_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, dpo_id_t *dpo)
The data-path object representing transmitting the packet on a n interface.
u32 vnet_tx_node_index_for_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: rewrite.c:96
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:182
static void interface_tx_dpo_unlock(dpo_id_t *dpo)
unsigned int u32
Definition: types.h:88
void interface_tx_dpo_module_init(void)
static void interface_tx_dpo_mem_show(void)
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:182
unsigned char u8
Definition: types.h:56