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:
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.
16 #include <vnet/dpo/interface_tx_dpo.h>
17 #include <vnet/adj/rewrite.h>
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
24 interface_tx_dpo_lock (dpo_id_t *dpo)
29 interface_tx_dpo_unlock (dpo_id_t *dpo)
34 * interface_tx_dpo_add_or_lock
36 * construct DPO object wrappers around a sw_if_index
39 interface_tx_dpo_add_or_lock (dpo_proto_t proto,
43 dpo_set(dpo, DPO_INTERFACE_TX, proto, sw_if_index);
47 format_interface_tx_dpo (u8* s, va_list *ap)
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();
53 return (format(s, "%U-tx-dpo:",
54 format_vnet_sw_interface_name,
56 vnet_get_sw_interface(vnm, index)));
60 interface_tx_dpo_mem_show (void)
65 interface_tx_dpo_get_next_node (const dpo_id_t *dpo)
67 u32 *node_indices = NULL;
70 * return the interface's TX node for the wrapped sw_if_index
72 vec_add1(node_indices,
73 vnet_tx_node_index_for_sw_interface(vnet_get_main(),
76 return (node_indices);
79 const 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,
88 interface_tx_dpo_module_init (void)
90 dpo_register(DPO_INTERFACE_TX, &interface_tx_dpo_vft, NULL);