1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
3 * Copyright(c) 2020 Red Hat, Inc.
9 #include "virtio_logs.h"
12 virtio_negotiate_features(struct virtio_hw *hw, uint64_t host_features)
17 * Limit negotiated features to what the driver, virtqueue, and
20 features = host_features & hw->guest_features;
21 VIRTIO_OPS(hw)->set_features(hw, features);
28 virtio_read_dev_config(struct virtio_hw *hw, size_t offset,
29 void *dst, int length)
31 VIRTIO_OPS(hw)->read_dev_cfg(hw, offset, dst, length);
35 virtio_write_dev_config(struct virtio_hw *hw, size_t offset,
36 const void *src, int length)
38 VIRTIO_OPS(hw)->write_dev_cfg(hw, offset, src, length);
42 virtio_reset(struct virtio_hw *hw)
46 VIRTIO_OPS(hw)->set_status(hw, VIRTIO_CONFIG_STATUS_RESET);
47 /* Flush status write and wait device ready max 3 seconds. */
48 while (VIRTIO_OPS(hw)->get_status(hw) != VIRTIO_CONFIG_STATUS_RESET) {
50 PMD_INIT_LOG(WARNING, "port %u device reset timeout", hw->port_id);
58 virtio_reinit_complete(struct virtio_hw *hw)
60 virtio_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER_OK);
64 virtio_set_status(struct virtio_hw *hw, uint8_t status)
66 if (status != VIRTIO_CONFIG_STATUS_RESET)
67 status |= VIRTIO_OPS(hw)->get_status(hw);
69 VIRTIO_OPS(hw)->set_status(hw, status);
73 virtio_get_status(struct virtio_hw *hw)
75 return VIRTIO_OPS(hw)->get_status(hw);
79 virtio_get_isr(struct virtio_hw *hw)
81 return VIRTIO_OPS(hw)->get_isr(hw);