blob: 73f4e906268d12bffdd68ba52b520baa775913ed [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
Vladislav Grishenkofb9d1ac2022-08-04 20:36:45 +050053 return format (s, "%U-tx-dpo:", format_vnet_sw_if_index_name, vnm, index);
Neale Ranns43161a82017-08-12 02:12:00 -070054}
55
56static void
57interface_tx_dpo_mem_show (void)
58{
59}
60
61u32*
62interface_tx_dpo_get_next_node (const dpo_id_t *dpo)
63{
64 u32 *node_indices = NULL;
65
66 /*
67 * return the interface's TX node for the wrapped sw_if_index
68 */
69 vec_add1(node_indices,
70 vnet_tx_node_index_for_sw_interface(vnet_get_main(),
71 dpo->dpoi_index));
72
73 return (node_indices);
74}
75
76const static dpo_vft_t interface_tx_dpo_vft = {
77 .dv_lock = interface_tx_dpo_lock,
78 .dv_unlock = interface_tx_dpo_unlock,
79 .dv_format = format_interface_tx_dpo,
80 .dv_mem_show = interface_tx_dpo_mem_show,
81 .dv_get_next_node = interface_tx_dpo_get_next_node,
82};
83
84void
85interface_tx_dpo_module_init (void)
86{
87 dpo_register(DPO_INTERFACE_TX, &interface_tx_dpo_vft, NULL);
88}
89