Re: [dpdk-dev] [PATCH 16/40] net/virtio: introduce generic virtio header
From: Maxime Coquelin <hidden>
Date: 2021-01-15 09:40:04
On 1/6/21 11:08 AM, David Marchand wrote:
On Sun, Dec 20, 2020 at 10:15 PM Maxime Coquelin [off-list ref] wrote:quoted
diff --git a/drivers/net/virtio/virtio.h b/drivers/net/virtio/virtio.h new file mode 100644 index 0000000000..eb078bc227 --- /dev/null +++ b/drivers/net/virtio/virtio.h@@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + * Copyright(c) 2020 Red Hat, Inc.2021?
Well, it was still 2020 when I submitted the patch :) I'll change it when fixing comment below
quoted
+ */ + +#ifndef _VIRTIO_H_ +#define _VIRTIO_H_ + +#include <rte_ether.h> + +struct virtio_hw { + struct virtqueue **vqs; + uint64_t guest_features; + uint16_t vtnet_hdr_size; + uint8_t started; + uint8_t weak_barriers; + uint8_t vlan_strip; + uint8_t has_tx_offload; + uint8_t has_rx_offload; + uint8_t use_vec_rx; + uint8_t use_vec_tx; + uint8_t use_inorder_rx; + uint8_t use_inorder_tx; + uint8_t opened; + uint16_t port_id; + uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; + uint32_t speed; /* link speed in MB */ + uint8_t duplex; + uint8_t use_msix; + uint16_t max_mtu; + /* + * App management thread and virtio interrupt handler thread + * both can change device state, this lock is meant to avoid + * such a contention. + */ + rte_spinlock_t state_lock; + struct rte_mbuf **inject_pkts; + uint16_t max_queue_pairs; + uint64_t req_guest_features; + struct virtnet_ctl *cvq; +}; + +struct virtio_ops { + void (*read_dev_cfg)(struct virtio_hw *hw, size_t offset, void *dst, int len); + void (*write_dev_cfg)(struct virtio_hw *hw, size_t offset, const void *src, int len); + uint8_t (*get_status)(struct virtio_hw *hw); + void (*set_status)(struct virtio_hw *hw, uint8_t status); + uint64_t (*get_features)(struct virtio_hw *hw); + void (*set_features)(struct virtio_hw *hw, uint64_t features); + int (*features_ok)(struct virtio_hw *hw); + uint8_t (*get_isr)(struct virtio_hw *hw); + uint16_t (*set_config_irq)(struct virtio_hw *hw, uint16_t vec); + uint16_t (*set_queue_irq)(struct virtio_hw *hw, struct virtqueue *vq, uint16_t vec); + uint16_t (*get_queue_num)(struct virtio_hw *hw, uint16_t queue_id); + int (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq); + void (*del_queue)(struct virtio_hw *hw, struct virtqueue *vq); + void (*notify_queue)(struct virtio_hw *hw, struct virtqueue *vq); + int (*dev_close)(struct virtio_hw *hw); +}; + +/* + * While virtio_hw is stored in shared memory, this structure stores + * some infos that may vary in the multiple process model locally. + * For example, the vtpci_ops pointer.You can remove this comment on vtpci_ops.
I think the comment is still valid, just that it now applied to virtio_ops instead of vtpci_ops. I'll fix it. Thanks, Maxime