FD.io VPP  v21.01.1
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>
21 
22 static uword
25 {
26  virtio_if_t *vif;
27  f64 timeout = 3153600000.0 /* 100 years */ ;
28  uword event_type, *event_data = 0;
29  virtio_main_t *vim = &virtio_main;
30 
31  while (1)
32  {
34  event_type = vlib_process_get_events (vm, &event_data);
35  vec_reset_length (event_data);
36 
37  switch (event_type)
38  {
40  timeout = 3153600000.0;
41  break;
42 
44  timeout = 1e-3; /* 1 millisecond */
45  break;
46 
47  case ~0:
48  /* *INDENT-OFF* */
49  pool_foreach (vif, vim->interfaces) {
50  if (vif->packet_coalesce || vif->packet_buffering)
51  {
52  virtio_vring_t *vring;
53  vec_foreach (vring, vif->rxq_vrings)
54  {
55  if (vring->mode == VNET_HW_IF_RX_MODE_INTERRUPT ||
58  vnet_get_main (), vif->hw_if_index,
59  RX_QUEUE_ACCESS (vring->queue_id));
60  }
61  }
62  }
63  /* *INDENT-ON* */
64  break;
65 
66  default:
67  clib_warning ("BUG: unhandled event type %d", event_type);
68  break;
69  }
70  }
71  return 0;
72 }
73 
74 /* *INDENT-OFF* */
77  .type = VLIB_NODE_TYPE_PROCESS,
78  .name = "virtio-send-interrupt-process",
79 };
80 /* *INDENT-ON* */
81 
82 /*
83  * fd.io coding-style-patch-verification: ON
84  *
85  * Local Variables:
86  * eval: (c-set-style "gnu")
87  * End:
88  */
virtio_if_t * interfaces
Definition: virtio.h:219
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:751
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:527
#define VIRTIO_EVENT_START_TIMER
Definition: virtio.h:60
vlib_main_t * vm
Definition: in2out_ed.c:1580
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
static uword virtio_send_interrupt_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
u32 hw_if_index
Definition: virtio.h:151
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:579
vlib_node_registration_t virtio_send_interrupt_node
(constructor) VLIB_REGISTER_NODE (virtio_send_interrupt_node)
static_always_inline void vnet_device_input_set_interrupt_pending(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
Definition: devices.h:127
u16 queue_id
Definition: virtio.h:84
vnet_hw_if_rx_mode mode
Definition: virtio.h:107
int packet_coalesce
Definition: virtio.h:155
virtio_vring_t * rxq_vrings
Definition: virtio.h:135
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:170
#define clib_warning(format, args...)
Definition: error.h:59
virtio_main_t virtio_main
Definition: virtio.c:35
#define RX_QUEUE_ACCESS(X)
Definition: virtio.h:40
int packet_buffering
Definition: virtio.h:156
u64 uword
Definition: types.h:112
#define vec_foreach(var, vec)
Vector iterator.
#define VIRTIO_EVENT_STOP_TIMER
Definition: virtio.h:61