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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
18 #include <vlib/vlib.h>
19 #include <vnet/devices/virtio/virtio.h>
20 #include <vnet/gso/gro_func.h>
21 #include <vnet/interface/rx_queue_funcs.h>
24 virtio_send_interrupt_process (vlib_main_t * vm,
25 vlib_node_runtime_t * rt, vlib_frame_t * f)
28 f64 timeout = 3153600000.0 /* 100 years */ ;
29 uword event_type, *event_data = 0;
30 virtio_main_t *vim = &virtio_main;
34 vlib_process_wait_for_event_or_clock (vm, timeout);
35 event_type = vlib_process_get_events (vm, &event_data);
36 vec_reset_length (event_data);
40 case VIRTIO_EVENT_STOP_TIMER:
41 timeout = 3153600000.0;
44 case VIRTIO_EVENT_START_TIMER:
45 timeout = 1e-3; /* 1 millisecond */
49 pool_foreach (vif, vim->interfaces)
51 if (vif->packet_coalesce || vif->packet_buffering)
53 vnet_virtio_vring_t *vring;
54 vec_foreach (vring, vif->rxq_vrings)
56 if (vring->mode == VNET_HW_IF_RX_MODE_INTERRUPT ||
57 vring->mode == VNET_HW_IF_RX_MODE_ADAPTIVE)
58 vnet_hw_if_rx_queue_set_int_pending (
59 vnet_get_main (), vring->queue_index);
66 clib_warning ("BUG: unhandled event type %d", event_type);
73 VLIB_REGISTER_NODE (virtio_send_interrupt_node) = {
74 .function = virtio_send_interrupt_process,
75 .type = VLIB_NODE_TYPE_PROCESS,
76 .name = "virtio-send-interrupt-process",
80 * fd.io coding-style-patch-verification: ON
83 * eval: (c-set-style "gnu")