Switch to 64 bit features, which virtio 1.0 supports.
While legacy virtio only supports 32 bit features, it complains aloud
and quit when trying to setting > 32 bit features.
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Qian Xu <qian.q.xu@intel.com>
Reviewed-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Tested-by: Tetsuya Mukawa <mukawa@igel.co.jp>
Acked-by: Huawei Xie <huawei.xie@intel.com>
static void
virtio_negotiate_features(struct virtio_hw *hw)
{
static void
virtio_negotiate_features(struct virtio_hw *hw)
{
- uint32_t host_features;
+ uint64_t host_features;
/* Prepare guest_features: feature that driver wants to support */
hw->guest_features = VIRTIO_PMD_GUEST_FEATURES;
/* Prepare guest_features: feature that driver wants to support */
hw->guest_features = VIRTIO_PMD_GUEST_FEATURES;
- PMD_INIT_LOG(DEBUG, "guest_features before negotiate = %x",
+ PMD_INIT_LOG(DEBUG, "guest_features before negotiate = %" PRIx64,
hw->guest_features);
/* Read device(host) feature bits */
host_features = hw->vtpci_ops->get_features(hw);
hw->guest_features);
/* Read device(host) feature bits */
host_features = hw->vtpci_ops->get_features(hw);
- PMD_INIT_LOG(DEBUG, "host_features before negotiate = %x",
+ PMD_INIT_LOG(DEBUG, "host_features before negotiate = %" PRIx64,
* guest feature bits.
*/
hw->guest_features = vtpci_negotiate_features(hw, host_features);
* guest feature bits.
*/
hw->guest_features = vtpci_negotiate_features(hw, host_features);
- PMD_INIT_LOG(DEBUG, "features after negotiate = %x",
+ PMD_INIT_LOG(DEBUG, "features after negotiate = %" PRIx64,
legacy_get_features(struct virtio_hw *hw)
{
return VIRTIO_READ_REG_4(hw, VIRTIO_PCI_HOST_FEATURES);
}
static void
legacy_get_features(struct virtio_hw *hw)
{
return VIRTIO_READ_REG_4(hw, VIRTIO_PCI_HOST_FEATURES);
}
static void
-legacy_set_features(struct virtio_hw *hw, uint32_t features)
+legacy_set_features(struct virtio_hw *hw, uint64_t features)
+ if ((features >> 32) != 0) {
+ PMD_DRV_LOG(ERR,
+ "only 32 bit features are allowed for legacy virtio!");
+ return;
+ }
VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_GUEST_FEATURES, features);
}
VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_GUEST_FEATURES, features);
}
hw->vtpci_ops->write_dev_cfg(hw, offset, src, length);
}
hw->vtpci_ops->write_dev_cfg(hw, offset, src, length);
}
-uint32_t
-vtpci_negotiate_features(struct virtio_hw *hw, uint32_t host_features)
+uint64_t
+vtpci_negotiate_features(struct virtio_hw *hw, uint64_t host_features)
/*
* Limit negotiated features to what the driver, virtqueue, and
/*
* Limit negotiated features to what the driver, virtqueue, and
uint8_t (*get_status)(struct virtio_hw *hw);
void (*set_status)(struct virtio_hw *hw, uint8_t status);
uint8_t (*get_status)(struct virtio_hw *hw);
void (*set_status)(struct virtio_hw *hw, uint8_t status);
- uint32_t (*get_features)(struct virtio_hw *hw);
- void (*set_features)(struct virtio_hw *hw, uint32_t features);
+ uint64_t (*get_features)(struct virtio_hw *hw);
+ void (*set_features)(struct virtio_hw *hw, uint64_t features);
uint8_t (*get_isr)(struct virtio_hw *hw);
uint8_t (*get_isr)(struct virtio_hw *hw);
struct virtio_hw {
struct virtqueue *cvq;
uint32_t io_base;
struct virtio_hw {
struct virtqueue *cvq;
uint32_t io_base;
- uint32_t guest_features;
+ uint64_t guest_features;
uint32_t max_tx_queues;
uint32_t max_rx_queues;
uint16_t vtnet_hdr_size;
uint32_t max_tx_queues;
uint32_t max_rx_queues;
uint16_t vtnet_hdr_size;
outl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))
static inline int
outl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))
static inline int
-vtpci_with_feature(struct virtio_hw *hw, uint32_t bit)
+vtpci_with_feature(struct virtio_hw *hw, uint64_t bit)
- return (hw->guest_features & (1u << bit)) != 0;
+ return (hw->guest_features & (1ULL << bit)) != 0;
void vtpci_set_status(struct virtio_hw *, uint8_t);
void vtpci_set_status(struct virtio_hw *, uint8_t);
-uint32_t vtpci_negotiate_features(struct virtio_hw *, uint32_t);
+uint64_t vtpci_negotiate_features(struct virtio_hw *, uint64_t);
void vtpci_write_dev_config(struct virtio_hw *, size_t, const void *, int);
void vtpci_write_dev_config(struct virtio_hw *, size_t, const void *, int);