From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id BF36FC374 for ; Thu, 28 Jan 2016 08:54:29 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 27 Jan 2016 23:54:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,357,1449561600"; d="scan'208";a="37565618" Received: from yliu-dev.sh.intel.com ([10.239.66.49]) by fmsmga004.fm.intel.com with ESMTP; 27 Jan 2016 23:54:28 -0800 From: Yuanhan Liu To: dev@dpdk.org Date: Thu, 28 Jan 2016 15:54:53 +0800 Message-Id: <1453967697-3757-6-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1453967697-3757-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1453191125-26335-1-git-send-email-yuanhan.liu@linux.intel.com> <1453967697-3757-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH v6 5/9] viritio: switch to 64 bit features X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2016 07:54:30 -0000 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 Tested-by: Qian Xu Reviewed-by: Tetsuya Mukawa Tested-by: Tetsuya Mukawa Acked-by: Huawei Xie --- drivers/net/virtio/virtio_ethdev.c | 8 ++++---- drivers/net/virtio/virtio_pci.c | 15 ++++++++++----- drivers/net/virtio/virtio_pci.h | 12 ++++++------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index b57224d..94e0c4a 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -930,16 +930,16 @@ virtio_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) 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; - 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); - PMD_INIT_LOG(DEBUG, "host_features before negotiate = %x", + PMD_INIT_LOG(DEBUG, "host_features before negotiate = %"PRIx64, host_features); /* @@ -947,7 +947,7 @@ virtio_negotiate_features(struct virtio_hw *hw) * 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, hw->guest_features); } diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 16485fa..5e1c55f 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -87,15 +87,20 @@ legacy_write_dev_config(struct virtio_hw *hw, size_t offset, } } -static uint32_t +static uint64_t 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); } @@ -451,10 +456,10 @@ vtpci_write_dev_config(struct virtio_hw *hw, size_t offset, 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) { - uint32_t features; + uint64_t features; /* * Limit negotiated features to what the driver, virtqueue, and diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index e8e7509..d7bc6bb 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -175,8 +175,8 @@ struct virtio_pci_ops { 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); @@ -191,7 +191,7 @@ struct virtio_pci_ops { 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; @@ -271,9 +271,9 @@ outl_p(unsigned int data, unsigned int port) 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; } /* @@ -286,7 +286,7 @@ void vtpci_reinit_complete(struct virtio_hw *); 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); -- 1.9.0