LCOV - code coverage report
Current view: top level - vnet/dpo - interface_tx_dpo.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 19 21 90.5 %
Date: 2023-07-05 22:20:52 Functions: 6 7 85.7 %

          Line data    Source code
       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             : 
      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             :  */
      23             : static void
      24          24 : interface_tx_dpo_lock (dpo_id_t *dpo)
      25             : {
      26          24 : }
      27             : 
      28             : static void
      29          24 : interface_tx_dpo_unlock (dpo_id_t *dpo)
      30             : {
      31          24 : }
      32             : 
      33             : /*
      34             :  * interface_tx_dpo_add_or_lock
      35             :  *
      36             :  * construct DPO object wrappers around a sw_if_index
      37             :  */
      38             : void
      39           8 : interface_tx_dpo_add_or_lock (dpo_proto_t proto,
      40             :                               u32 sw_if_index,
      41             :                               dpo_id_t *dpo)
      42             : {
      43           8 :     dpo_set(dpo, DPO_INTERFACE_TX, proto, sw_if_index);
      44           8 : }
      45             : 
      46             : u8*
      47           7 : format_interface_tx_dpo (u8* s, va_list *ap)
      48             : {
      49           7 :     index_t index = va_arg(*ap, index_t);
      50           7 :     CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
      51           7 :     vnet_main_t * vnm = vnet_get_main();
      52             : 
      53           7 :     return (format(s, "%U-tx-dpo:",
      54             :                    format_vnet_sw_interface_name,
      55             :                    vnm,
      56             :                    vnet_get_sw_interface(vnm, index)));
      57             : }
      58             : 
      59             : static void
      60           0 : interface_tx_dpo_mem_show (void)
      61             : {
      62           0 : }
      63             : 
      64             : u32*
      65           8 : interface_tx_dpo_get_next_node (const dpo_id_t *dpo)
      66             : {
      67           8 :     u32 *node_indices = NULL;
      68             : 
      69             :     /*
      70             :      * return the interface's TX node for the wrapped sw_if_index
      71             :      */
      72           8 :     vec_add1(node_indices,
      73             :              vnet_tx_node_index_for_sw_interface(vnet_get_main(),
      74             :                                                  dpo->dpoi_index));
      75             : 
      76           8 :     return (node_indices);
      77             : }
      78             : 
      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,
      85             : };
      86             : 
      87             : void
      88         559 : interface_tx_dpo_module_init (void)
      89             : {
      90         559 :     dpo_register(DPO_INTERFACE_TX, &interface_tx_dpo_vft, NULL);
      91         559 : }
      92             : 

Generated by: LCOV version 1.14