FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
format.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2018 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <rdma/rdma.h>
21 
22 u8 *
23 format_rdma_device_name (u8 * s, va_list * args)
24 {
25  u32 i = va_arg (*args, u32);
26  rdma_main_t *rm = &rdma_main;
27  rdma_device_t *rd = vec_elt_at_index (rm->devices, i);
28 
29  if (rd->name)
30  return format (s, "%v", rd->name);
31 
32  s = format (s, "rdma-%u", rd->dev_instance);
33  return s;
34 }
35 
36 u8 *
37 format_rdma_device_flags (u8 * s, va_list * args)
38 {
39  rdma_device_t *rd = va_arg (*args, rdma_device_t *);
40  u8 *t = 0;
41 
42 #define _(a, b, c) if (rd->flags & (1 << a)) \
43 t = format (t, "%s%s", t ? " ":"", c);
45 #undef _
46  s = format (s, "%v", t);
47  vec_free (t);
48  return s;
49 }
50 
51 u8 *
52 format_rdma_device (u8 * s, va_list * args)
53 {
54  u32 i = va_arg (*args, u32);
55  rdma_main_t *rm = &rdma_main;
56  rdma_device_t *rd = vec_elt_at_index (rm->devices, i);
57  u32 indent = format_get_indent (s);
58 
59  s = format (s, "netdev: %v\n", rd->linux_ifname);
60  s = format (s, "%Uflags: %U", format_white_space, indent,
62  if (rd->error)
63  s = format (s, "\n%Uerror %U", format_white_space, indent,
65 
66  return s;
67 }
68 
69 u8 *
70 format_rdma_input_trace (u8 * s, va_list * args)
71 {
72  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
73  vlib_node_t *node = va_arg (*args, vlib_node_t *);
74  rdma_input_trace_t *t = va_arg (*args, rdma_input_trace_t *);
75  vnet_main_t *vnm = vnet_get_main ();
77 
78  s = format (s, "rdma: %v (%d) next-node %U",
80  node->index, t->next_index);
81 
82  return s;
83 }
84 
85 /*
86  * fd.io coding-style-patch-verification: ON
87  *
88  * Local Variables:
89  * eval: (c-set-style "gnu")
90  * End:
91  */
u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
u8 * linux_ifname
Definition: rdma.h:80
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
u32 index
Definition: node.h:280
u32 dev_instance
Definition: rdma.h:83
u8 * format_rdma_input_trace(u8 *s, va_list *args)
Definition: format.c:70
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u8 * format_rdma_device(u8 *s, va_list *args)
Definition: format.c:52
int i
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
u8 * format_rdma_device_flags(u8 *s, va_list *args)
Definition: format.c:37
unsigned char u8
Definition: types.h:56
rdma_device_t * devices
Definition: rdma.h:98
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
format_function_t format_vlib_next_node_name
Definition: node_funcs.h:1142
unsigned int u32
Definition: types.h:88
vlib_main_t * vm
Definition: in2out_ed.c:1810
clib_error_t * error
Definition: rdma.h:93
rdma_main_t rdma_main
Definition: device.c:46
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:342
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1810
u8 * name
Definition: rdma.h:79
vl_api_ip4_address_t hi
Definition: arp.api:37
u8 * format_rdma_device_name(u8 *s, va_list *args)
Definition: format.c:23