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
#include <
vlib/vlib.h
>
18
#include <
vlib/unix/unix.h
>
19
#include <
vlib/pci/pci.h
>
20
#include <
vnet/ethernet/ethernet.h
>
21
#include <
vnet/ip/ip4_packet.h
>
22
#include <
vnet/ip/ip6_packet.h
>
23
#include <
vnet/devices/virtio/virtio.h
>
24
#include <
vnet/devices/virtio/pci.h
>
25
26
u8
*
27
format_virtio_device_name
(
u8
* s, va_list * args)
28
{
29
u32
dev_instance = va_arg (*args,
u32
);
30
virtio_main_t
*mm = &
virtio_main
;
31
virtio_if_t
*vif =
pool_elt_at_index
(mm->
interfaces
, dev_instance);
32
33
if
(vif->
type
== VIRTIO_IF_TYPE_TAP)
34
s =
format
(s,
"tap%u"
, vif->
id
);
35
else
if
(vif->
type
== VIRTIO_IF_TYPE_PCI)
36
s =
format
(s,
"virtio-%x/%x/%x/%x"
, vif->
pci_addr
.
domain
,
37
vif->
pci_addr
.
bus
, vif->
pci_addr
.
slot
,
38
vif->
pci_addr
.
function
);
39
else
if
(vif->
type
== VIRTIO_IF_TYPE_TUN)
40
s =
format
(s,
"tun%u"
, vif->
id
);
41
else
42
s =
format
(s,
"virtio-%lu"
, vif->
dev_instance
);
43
44
return
s;
45
}
46
47
u8
*
48
format_virtio_log_name
(
u8
* s, va_list * args)
49
{
50
virtio_if_t
*vif = va_arg (*args,
virtio_if_t
*);
51
52
if
(vif->
type
== VIRTIO_IF_TYPE_TAP)
53
s =
format
(s,
"tap%u"
, vif->
id
);
54
else
if
(vif->
type
== VIRTIO_IF_TYPE_TUN)
55
s =
format
(s,
"tun%u"
, vif->
id
);
56
else
if
(vif->
type
== VIRTIO_IF_TYPE_PCI)
57
s =
format
(s,
"%U"
,
format_vlib_pci_addr
, &vif->
pci_addr
);
58
else
59
s =
format
(s,
"virtio-%lu"
, vif->
dev_instance
);
60
61
return
s;
62
}
63
64
/*
65
* fd.io coding-style-patch-verification: ON
66
*
67
* Local Variables:
68
* eval: (c-set-style "gnu")
69
* End:
70
*/
vlib.h
pci.h
virtio.h
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition:
pool.h:553
pci_addr_t::bus
u8 bus
Definition:
virtio.h:118
pci_addr_t::function
u8 function
Definition:
virtio.h:120
ethernet.h
ip6_packet.h
virtio_main
virtio_main_t virtio_main
Definition:
virtio.c:37
virtio_if_t::pci_addr
pci_addr_t pci_addr
Definition:
virtio.h:196
pci_addr_t::domain
u16 domain
Definition:
virtio.h:117
format_virtio_device_name
u8 * format_virtio_device_name(u8 *s, va_list *args)
Definition:
format.c:27
format
__clib_export u8 * format(u8 *s, const char *fmt,...)
Definition:
format.c:428
ip4_packet.h
virtio_main_t
Definition:
virtio.h:214
format_virtio_log_name
u8 * format_virtio_log_name(u8 *s, va_list *args)
Definition:
format.c:48
virtio_if_t::dev_instance
u32 dev_instance
Definition:
virtio.h:158
format_vlib_pci_addr
format_function_t format_vlib_pci_addr
Definition:
pci.h:326
u32
unsigned int u32
Definition:
types.h:88
pci.h
virtio_if_t::type
virtio_if_type_t type
Definition:
virtio.h:150
virtio_if_t
Definition:
virtio.h:128
virtio_main_t::interfaces
virtio_if_t * interfaces
Definition:
virtio.h:220
u8
unsigned char u8
Definition:
types.h:56
unix.h
virtio_if_t::id
u32 id
Definition:
virtio.h:183
pci_addr_t::slot
u8 slot
Definition:
virtio.h:119
src
vnet
devices
virtio
format.c
Generated on Sat Jan 8 2022 10:03:36 for FD.io VPP by
1.8.17