FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
virtio_process.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2020 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>
20 #include <vnet/gso/gro_func.h>
22 
23 static uword
26 {
27  virtio_if_t *vif;
28  f64 timeout = 3153600000.0 /* 100 years */ ;
29  uword event_type, *event_data = 0;
30  virtio_main_t *vim = &virtio_main;
31 
32  while (1)
33  {
35  event_type = vlib_process_get_events (vm, &event_data);
36  vec_reset_length (event_data);
37 
38  switch (event_type)
39  {
41  timeout = 3153600000.0;
42  break;
43 
45  timeout = 1e-3; /* 1 millisecond */
46  break;
47 
48  case ~0:
49  pool_foreach (vif, vim->interfaces)
50  {
51  if (vif->packet_coalesce || vif->packet_buffering)
52  {
53  virtio_vring_t *vring;
54  vec_foreach (vring, vif->rxq_vrings)
55  {
56  if (vring->mode == VNET_HW_IF_RX_MODE_INTERRUPT ||
59  vnet_get_main (), vring->queue_index);
60  }
61  }
62  }
63  break;
64 
65  default:
66  clib_warning ("BUG: unhandled event type %d", event_type);
67  break;
68  }
69  }
70  return 0;
71 }
72 
73 /* *INDENT-OFF* */
76  .type = VLIB_NODE_TYPE_PROCESS,
77  .name = "virtio-send-interrupt-process",
78 };
79 /* *INDENT-ON* */
80 
81 /*
82  * fd.io coding-style-patch-verification: ON
83  *
84  * Local Variables:
85  * eval: (c-set-style "gnu")
86  * End:
87  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
vlib.h
VNET_HW_IF_RX_MODE_ADAPTIVE
@ VNET_HW_IF_RX_MODE_ADAPTIVE
Definition: interface.h:58
virtio_vring_t
Definition: virtio.h:63
virtio.h
f
vlib_frame_t * f
Definition: interface_output.c:1080
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
virtio_if_t::packet_coalesce
int packet_coalesce
Definition: virtio.h:156
vlib_frame_t
Definition: node.h:372
virtio_if_t::packet_buffering
int packet_buffering
Definition: virtio.h:157
virtio_main
virtio_main_t virtio_main
Definition: virtio.c:37
vlib_process_get_events
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
Definition: node_funcs.h:583
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
virtio_send_interrupt_process
static uword virtio_send_interrupt_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: virtio_process.c:24
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
VIRTIO_EVENT_STOP_TIMER
#define VIRTIO_EVENT_STOP_TIMER
Definition: virtio.h:61
rx_queue_funcs.h
uword
u64 uword
Definition: types.h:112
VNET_HW_IF_RX_MODE_INTERRUPT
@ VNET_HW_IF_RX_MODE_INTERRUPT
Definition: interface.h:57
f64
double f64
Definition: types.h:142
virtio_vring_t::mode
vnet_hw_if_rx_mode mode
Definition: virtio.h:108
vnet_hw_if_rx_queue_set_int_pending
static_always_inline void vnet_hw_if_rx_queue_set_int_pending(vnet_main_t *vnm, u32 queue_index)
Definition: rx_queue_funcs.h:51
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
virtio_vring_t::queue_index
u32 queue_index
Definition: virtio.h:85
virtio_main_t
Definition: virtio.h:214
vlib_process_wait_for_event_or_clock
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:755
virtio_send_interrupt_node
vlib_node_registration_t virtio_send_interrupt_node
(constructor) VLIB_REGISTER_NODE (virtio_send_interrupt_node)
Definition: virtio_process.c:74
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
VIRTIO_EVENT_START_TIMER
#define VIRTIO_EVENT_START_TIMER
Definition: virtio.h:60
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
virtio_if_t
Definition: virtio.h:128
virtio_if_t::rxq_vrings
virtio_vring_t * rxq_vrings
Definition: virtio.h:136
virtio_main_t::interfaces
virtio_if_t * interfaces
Definition: virtio.h:220
vlib_main_t
Definition: main.h:102
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:399
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
vlib_node_runtime_t
Definition: node.h:454
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
gro_func.h