patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/virtio: fix MAC addr not correct read
@ 2017-07-28 23:01 Jianfeng Tan
  2017-07-31  2:31 ` Yuanhan Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Jianfeng Tan @ 2017-07-28 23:01 UTC (permalink / raw)
  To: dev; +Cc: Jianfeng Tan, stable, Zhihong Wang, Yuanhan Liu, Maxime Coquelin

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 <zhihong.wang@intel.com>
Cc: Yuanhan Liu <yliu@fridaylinux.org>
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>

Reported-by: Vipin Varghese <vipin.varghese@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH] net/virtio: fix MAC addr not correct read
  2017-07-28 23:01 [dpdk-stable] [PATCH] net/virtio: fix MAC addr not correct read Jianfeng Tan
@ 2017-07-31  2:31 ` Yuanhan Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Yuanhan Liu @ 2017-07-31  2:31 UTC (permalink / raw)
  To: Jianfeng Tan; +Cc: dev, stable, Zhihong Wang, Maxime Coquelin

On Fri, Jul 28, 2017 at 11:01:14PM +0000, Jianfeng Tan wrote:
> 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 <zhihong.wang@intel.com>
> Cc: Yuanhan Liu <yliu@fridaylinux.org>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Reported-by: Vipin Varghese <vipin.varghese@intel.com>
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>

Applied to dpdk-next-virtio.

Thanks.

	--yliu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-31  2:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 23:01 [dpdk-stable] [PATCH] net/virtio: fix MAC addr not correct read Jianfeng Tan
2017-07-31  2:31 ` Yuanhan Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).