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 : 16 : #include <vlib/vlib.h> 17 : #include <vnet/vnet.h> 18 : #include <ioam/lib-e2e/ioam_seqno_lib.h> 19 : 20 : u8 * 21 0 : show_ioam_seqno_cmd_fn (u8 * s, ioam_seqno_data * seqno_data, u8 enc) 22 : { 23 : seqno_rx_info *rx; 24 : 25 0 : s = format (s, "SeqNo Data:\n"); 26 0 : if (enc) 27 : { 28 0 : s = format (s, " Current Seq. Number : %llu\n", seqno_data->seq_num); 29 : } 30 : else 31 : { 32 0 : rx = &seqno_data->seqno_rx; 33 0 : s = show_ioam_seqno_analyse_data_fn (s, rx); 34 : } 35 : 36 0 : format (s, "\n"); 37 0 : return s; 38 : } 39 : 40 : u8 * 41 0 : show_ioam_seqno_analyse_data_fn (u8 * s, seqno_rx_info * rx) 42 : { 43 0 : s = format (s, " Highest Seq. Number : %llu\n", rx->bitmap.highest); 44 0 : s = format (s, " Packets received : %llu\n", rx->rx_packets); 45 0 : s = format (s, " Lost packets : %llu\n", rx->lost_packets); 46 0 : s = format (s, " Reordered packets : %llu\n", rx->reordered_packets); 47 0 : s = format (s, " Duplicate packets : %llu\n", rx->dup_packets); 48 : 49 0 : format (s, "\n"); 50 0 : return s; 51 : } 52 : 53 : void 54 0 : ioam_seqno_init_data (ioam_seqno_data * data) 55 : { 56 0 : data->seq_num = 0; 57 0 : ioam_seqno_init_rx_info (&data->seqno_rx); 58 0 : return; 59 : } 60 : 61 : void 62 0 : ioam_seqno_init_rx_info (seqno_rx_info * data) 63 : { 64 0 : seqno_bitmap *bitmap = &data->bitmap; 65 0 : bitmap->window_size = SEQNO_WINDOW_SIZE; 66 0 : bitmap->array_size = SEQNO_WINDOW_ARRAY_SIZE; 67 0 : bitmap->mask = 32 * SEQNO_WINDOW_ARRAY_SIZE - 1; 68 0 : bitmap->array[0] = 0x00000000; /* pretend we haven seen sequence numbers 0 */ 69 0 : bitmap->highest = 0; 70 : 71 0 : data->dup_packets = 0; 72 0 : data->lost_packets = 0; 73 0 : data->reordered_packets = 0; 74 0 : data->rx_packets = 0; 75 0 : return; 76 : } 77 : 78 : /* 79 : * fd.io coding-style-patch-verification: ON 80 : * 81 : * Local Variables: 82 : * eval: (c-set-style "gnu") 83 : * End: 84 : */