FD.io VPP  v21.06-3-gbb25fbf28
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 <vlib/unix/unix.h>
20 #include <vlib/pci/pci.h>
21 #include <vnet/ethernet/ethernet.h>
22 
23 #include <af_xdp/af_xdp.h>
24 
25 u8 *
26 format_af_xdp_device_name (u8 * s, va_list * args)
27 {
28  u32 i = va_arg (*args, u32);
30  af_xdp_device_t *ad = vec_elt_at_index (am->devices, i);
31 
32  s = format (s, "%v", ad->name);
33  return s;
34 }
35 
36 u8 *
37 format_af_xdp_device_flags (u8 * s, va_list * args)
38 {
39  af_xdp_device_t *ad = va_arg (*args, af_xdp_device_t *);
40 #define _(a, b, c) \
41  if (ad->flags & (1 << a)) \
42  s = format (s, "%s ", c);
44 #undef _
45  return s;
46 }
47 
48 u8 *
49 format_af_xdp_device (u8 * s, va_list * args)
50 {
51  u32 i = va_arg (*args, u32);
53  af_xdp_device_t *ad = vec_elt_at_index (am->devices, i);
54  u32 indent = format_get_indent (s);
55 
56  s = format (s, "netdev %v\n", ad->linux_ifname);
57  s =
58  format (s, "%Uflags: %U", format_white_space, indent,
60  if (ad->error)
61  s = format (s, "\n%Uerror %U", format_white_space, indent,
63 
64  return s;
65 }
66 
67 u8 *
68 format_af_xdp_input_trace (u8 * s, va_list * args)
69 {
70  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
71  vlib_node_t *node = va_arg (*args, vlib_node_t *);
72  af_xdp_input_trace_t *t = va_arg (*args, af_xdp_input_trace_t *);
73  vnet_main_t *vnm = vnet_get_main ();
75 
76  s = format (s, "af_xdp: %v (%d) next-node %U",
78  node->index, t->next_index);
79 
80  return s;
81 }
82 
83 /*
84  * fd.io coding-style-patch-verification: ON
85  *
86  * Local Variables:
87  * eval: (c-set-style "gnu")
88  * End:
89  */
vlib.h
format_af_xdp_input_trace
u8 * format_af_xdp_input_trace(u8 *s, va_list *args)
Definition: format.c:68
af_xdp_main_t
Definition: af_xdp.h:126
af_xdp.h
af_xdp_input_trace_t
Definition: af_xdp.h:180
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
am
app_main_t * am
Definition: application.c:489
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
format_af_xdp_device
u8 * format_af_xdp_device(u8 *s, va_list *args)
Definition: format.c:49
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
ethernet.h
format_clib_error
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
af_xdp_input_trace_t::hw_if_index
u32 hw_if_index
Definition: af_xdp.h:183
af_xdp_main
af_xdp_main_t af_xdp_main
Definition: device.c:31
foreach_af_xdp_device_flags
@ foreach_af_xdp_device_flags
Definition: af_xdp.h:41
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
af_xdp_device_t
Definition: af_xdp.h:91
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
format_vlib_next_node_name
format_function_t format_vlib_next_node_name
Definition: node_funcs.h:1236
format
__clib_export u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:428
format_af_xdp_device_name
u8 * format_af_xdp_device_name(u8 *s, va_list *args)
Definition: format.c:26
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
af_xdp_device_t::linux_ifname
char * linux_ifname
Definition: af_xdp.h:110
format_get_indent
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u32
unsigned int u32
Definition: types.h:88
pci.h
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
u8
unsigned char u8
Definition: types.h:56
unix.h
af_xdp_input_trace_t::next_index
u32 next_index
Definition: af_xdp.h:182
format_white_space
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
format_af_xdp_device_flags
u8 * format_af_xdp_device_flags(u8 *s, va_list *args)
Definition: format.c:37
af_xdp_device_t::name
char * name
Definition: af_xdp.h:109
af_xdp_device_t::error
clib_error_t * error
Definition: af_xdp.h:123