blob: f7c8bfda85bdf54330fb6323e5d1a85410cbb999 [file] [log] [blame]
Neale Ranns43161a82017-08-12 02:12:00 -07001/*
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
16#include <vnet/dpo/interface_tx_dpo.h>
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 */
23static void
24interface_tx_dpo_lock (dpo_id_t *dpo)
25{
26}
27
28static void
29interface_tx_dpo_unlock (dpo_id_t *dpo)
30{
31}
32
33/*
34 * interface_tx_dpo_add_or_lock
35 *
36 * construct DPO object wrappers around a sw_if_index
37 */
38void
39interface_tx_dpo_add_or_lock (dpo_proto_t proto,
40 u32 sw_if_index,
41 dpo_id_t *dpo)
42{
43 dpo_set(dpo, DPO_INTERFACE_TX, proto, sw_if_index);
44}
45
46u8*
47format_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-dpo:",
54 format_vnet_sw_interface_name,
55 vnm,
56 vnet_get_sw_interface(vnm, index)));
57}
58
59static void
60interface_tx_dpo_mem_show (void)
61{
62}
63
64u32*
65interface_tx_dpo_get_next_node (const dpo_id_t *dpo)
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,
73 vnet_tx_node_index_for_sw_interface(vnet_get_main(),
74 dpo->dpoi_index));
75
76 return (node_indices);
77}
78
79const static dpo_vft_t interface_tx_dpo_vft = {
80 .dv_lock = interface_tx_dpo_lock,
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
87void
88interface_tx_dpo_module_init (void)
89{
90 dpo_register(DPO_INTERFACE_TX, &interface_tx_dpo_vft, NULL);
91}
92