From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 042599974; Sat, 29 Jul 2017 00:59:58 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 28 Jul 2017 15:59:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,427,1496127600"; d="scan'208";a="998468321" Received: from dpdk06.sh.intel.com ([10.67.111.82]) by orsmga003.jf.intel.com with ESMTP; 28 Jul 2017 15:59:56 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: Jianfeng Tan , stable@dpdk.org, Zhihong Wang , Yuanhan Liu , Maxime Coquelin Date: Fri, 28 Jul 2017 23:01:14 +0000 Message-Id: <1501282874-127700-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-stable] [PATCH] net/virtio: fix MAC addr not correct read X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jul 2017 22:59:59 -0000 When virtio-net devices are bound to uio_pci_generic, we get the wrong mac addr by virtio PMD. The wrong mac addr is a addr that is 4-byte left shift of the correct addr. It's a regression bug introduced by the cleanup patch below. The condition of if we set use_msix should be if msix is actually enabled. Only to check if there is a capability list is not enough. For example, binding a transitional device to uio_pci_device would trigger the wrong assignment of use_msix. To correct that, we also check the flags of msix capability to make sure it's enabled. Fixes: ee1843bd8907 ("net/virtio: remove redundant MSI-X detection") Cc: stable@dpdk.org Cc: Zhihong Wang Cc: Yuanhan Liu Cc: Maxime Coquelin Reported-by: Vipin Varghese Signed-off-by: Jianfeng Tan --- drivers/net/virtio/virtio_pci.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index e6eda75..e6da680 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -580,6 +580,8 @@ get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap) return base + offset; } +#define PCI_MSIX_ENABLE 0x8000 + static int virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) { @@ -606,8 +608,17 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) break; } - if (cap.cap_vndr == PCI_CAP_ID_MSIX) - hw->use_msix = 1; + if (cap.cap_vndr == PCI_CAP_ID_MSIX) { + /* Transitional devices would also have this capability, + * that's why we also check if msix is enabled. + * 1st byte is cap ID; 2nd byte is the position of next + * cap; next two bytes are the flags. + */ + uint16_t flags = ((uint16_t *)&cap)[1]; + + if (flags & PCI_MSIX_ENABLE) + hw->use_msix = 1; + } if (cap.cap_vndr != PCI_CAP_ID_VNDR) { PMD_INIT_LOG(DEBUG, -- 2.7.4