Line data Source code
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 0 : format_af_xdp_device_name (u8 * s, va_list * args)
27 : {
28 0 : u32 i = va_arg (*args, u32);
29 0 : af_xdp_main_t *am = &af_xdp_main;
30 0 : af_xdp_device_t *ad = vec_elt_at_index (am->devices, i);
31 :
32 0 : s = format (s, "%v", ad->name);
33 0 : return s;
34 : }
35 :
36 : u8 *
37 0 : format_af_xdp_device_flags (u8 * s, va_list * args)
38 : {
39 0 : 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);
43 0 : foreach_af_xdp_device_flags
44 : #undef _
45 0 : return s;
46 : }
47 :
48 : u8 *
49 0 : format_af_xdp_device (u8 * s, va_list * args)
50 : {
51 0 : u32 i = va_arg (*args, u32);
52 0 : af_xdp_main_t *am = &af_xdp_main;
53 0 : af_xdp_device_t *ad = vec_elt_at_index (am->devices, i);
54 0 : u32 indent = format_get_indent (s);
55 :
56 0 : s = format (s, "netdev %v\n", ad->linux_ifname);
57 : s =
58 0 : format (s, "%Uflags: %U", format_white_space, indent,
59 : format_af_xdp_device_flags, ad);
60 0 : if (ad->error)
61 0 : s = format (s, "\n%Uerror %U", format_white_space, indent,
62 : format_clib_error, ad->error);
63 :
64 0 : return s;
65 : }
66 :
67 : u8 *
68 0 : format_af_xdp_input_trace (u8 * s, va_list * args)
69 : {
70 0 : vlib_main_t *vm = va_arg (*args, vlib_main_t *);
71 0 : vlib_node_t *node = va_arg (*args, vlib_node_t *);
72 0 : af_xdp_input_trace_t *t = va_arg (*args, af_xdp_input_trace_t *);
73 0 : vnet_main_t *vnm = vnet_get_main ();
74 0 : vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, t->hw_if_index);
75 :
76 0 : s = format (s, "af_xdp: %v (%d) next-node %U",
77 : hi->name, t->hw_if_index, format_vlib_next_node_name, vm,
78 : node->index, t->next_index);
79 :
80 0 : 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 : */
|