LCOV - code coverage report
Current view: top level - plugins/nsh/nsh-md2-ioam/export-nsh-md2-ioam - nsh_md2_ioam_node.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 1 40 2.5 %
Date: 2023-10-26 01:39:38 Functions: 2 6 33.3 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 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             : #include <vlib/vlib.h>
      16             : #include <vnet/vnet.h>
      17             : #include <vppinfra/error.h>
      18             : #include <vnet/ethernet/ethernet.h>
      19             : #include <vnet/ip/ip.h>
      20             : #include <nsh/nsh.h>
      21             : #include <nsh/nsh_packet.h>
      22             : #include <ioam/export-common/ioam_export.h>
      23             : 
      24             : typedef struct
      25             : {
      26             :   u32 next_index;
      27             :   u32 flow_label;
      28             : } export_trace_t;
      29             : 
      30             : extern ioam_export_main_t nsh_md2_ioam_export_main;
      31             : vlib_node_registration_t export_node;
      32             : /* packet trace format function */
      33             : static u8 *
      34           0 : format_export_trace (u8 * s, va_list * args)
      35             : {
      36           0 :   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
      37           0 :   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
      38           0 :   export_trace_t *t = va_arg (*args, export_trace_t *);
      39             : 
      40           0 :   s = format (s, "EXPORT: flow_label %d, next index %d",
      41             :               t->flow_label, t->next_index);
      42           0 :   return s;
      43             : }
      44             : 
      45             : vlib_node_registration_t nsh_md2_ioam_export_node;
      46             : 
      47             : #define foreach_export_error \
      48             : _(RECORDED, "Packets recorded for export")
      49             : 
      50             : typedef enum
      51             : {
      52             : #define _(sym,str) EXPORT_ERROR_##sym,
      53             :   foreach_export_error
      54             : #undef _
      55             :     EXPORT_N_ERROR,
      56             : } export_error_t;
      57             : 
      58             : static char *export_error_strings[] = {
      59             : #define _(sym,string) string,
      60             :   foreach_export_error
      61             : #undef _
      62             : };
      63             : 
      64             : typedef enum
      65             : {
      66             :   EXPORT_NEXT_NSH_MD2_IOAM_INPUT,
      67             :   EXPORT_N_NEXT,
      68             : } export_next_t;
      69             : 
      70             : always_inline void
      71           0 : copy3cachelines (void *dst, const void *src, size_t n)
      72             : {
      73             : 
      74             :   u64 *copy_dst, *copy_src;
      75             :   int i;
      76           0 :   copy_dst = (u64 *) dst;
      77           0 :   copy_src = (u64 *) src;
      78           0 :   if (PREDICT_FALSE (n < DEFAULT_EXPORT_SIZE))
      79             :     {
      80           0 :       for (i = 0; i < n / 64; i++)
      81             :         {
      82           0 :           copy_dst[0] = copy_src[0];
      83           0 :           copy_dst[1] = copy_src[1];
      84           0 :           copy_dst[2] = copy_src[2];
      85           0 :           copy_dst[3] = copy_src[3];
      86           0 :           copy_dst[4] = copy_src[4];
      87           0 :           copy_dst[5] = copy_src[5];
      88           0 :           copy_dst[6] = copy_src[6];
      89           0 :           copy_dst[7] = copy_src[7];
      90           0 :           copy_dst += 8;
      91           0 :           copy_src += 8;
      92             :         }
      93           0 :       return;
      94             :     }
      95           0 :   for (i = 0; i < 3; i++)
      96             :     {
      97           0 :       copy_dst[0] = copy_src[0];
      98           0 :       copy_dst[1] = copy_src[1];
      99           0 :       copy_dst[2] = copy_src[2];
     100           0 :       copy_dst[3] = copy_src[3];
     101           0 :       copy_dst[4] = copy_src[4];
     102           0 :       copy_dst[5] = copy_src[5];
     103           0 :       copy_dst[6] = copy_src[6];
     104           0 :       copy_dst[7] = copy_src[7];
     105           0 :       copy_dst += 8;
     106           0 :       copy_src += 8;
     107             :     }
     108             : }
     109             : 
     110             : static void
     111           0 : nsh_md2_ioam_export_fixup_func (vlib_buffer_t * export_buf,
     112             :                                 vlib_buffer_t * pak_buf)
     113             : {
     114             :   /* Todo: on implementing analyse */
     115           0 : }
     116             : 
     117             : static uword
     118           0 : nsh_md2_ioam_export_node_fn (vlib_main_t * vm,
     119             :                              vlib_node_runtime_t * node, vlib_frame_t * frame)
     120             : {
     121           0 :   ioam_export_main_t *em = &nsh_md2_ioam_export_main;
     122           0 :   ioam_export_node_common (em, vm, node, frame, ip4_header_t, length,
     123             :                            ip_version_and_header_length,
     124             :                            EXPORT_NEXT_NSH_MD2_IOAM_INPUT,
     125             :                            nsh_md2_ioam_export_fixup_func);
     126           0 :   return frame->n_vectors;
     127             : }
     128             : 
     129             : /*
     130             :  * Node for iOAM export
     131             :  */
     132             : /* *INDENT-OFF* */
     133       51864 : VLIB_REGISTER_NODE (nsh_md2_ioam_export_node) =
     134             : {
     135             :   .function = nsh_md2_ioam_export_node_fn,
     136             :   .name = "nsh-md2-ioam-export",
     137             :   .vector_size = sizeof (u32),
     138             :   .format_trace = format_export_trace,
     139             :   .type = VLIB_NODE_TYPE_INTERNAL,
     140             :   .n_errors = ARRAY_LEN (export_error_strings),
     141             :   .error_strings = export_error_strings,
     142             :   .n_next_nodes = EXPORT_N_NEXT,
     143             :     /* edit / add dispositions here */
     144             :     .next_nodes =
     145             :   {[EXPORT_NEXT_NSH_MD2_IOAM_INPUT] = "nsh-pop"},
     146             : };
     147             : /* *INDENT-ON* */
     148             : 
     149             : /*
     150             :  * fd.io coding-style-patch-verification: ON
     151             :  *
     152             :  * Local Variables:
     153             :  * eval: (c-set-style "gnu")
     154             :  * End:
     155             :  */

Generated by: LCOV version 1.14