qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3
@ 2015-12-23  6:06 Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 1/5] net/vmxnet3: return 1 on device activation failure Miao Yan
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Miao Yan @ 2015-12-23  6:06 UTC (permalink / raw)
  To: jasowang, dmitry, qemu-devel

Qemu vmxnet3 emulation doesn't recognize VMXNET3_CMD_GET_DID_LO,
VMXNET3_CMD_GET_DID_HI and VMXNET3_CMD_GET_DEV_EXTRA_INFO command and
returns -1 on all of them.

This patchset makes them return correct values.

Changes in v2:
 - return 0 on unknown command
Changes in v3:
 - rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION

Miao Yan (5):
  net/vmxnet3: return 1 on device activation failure
  net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command
  net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO
  net/vmxnet3: return 0 on unknown command
  net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION

 hw/net/vmxnet3.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

-- 
1.9.1

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

* [Qemu-devel] [PATCH v3 1/5] net/vmxnet3: return 1 on device activation failure
  2015-12-23  6:06 [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Miao Yan
@ 2015-12-23  6:06 ` Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 2/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command Miao Yan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Miao Yan @ 2015-12-23  6:06 UTC (permalink / raw)
  To: jasowang, dmitry, qemu-devel

When reading device status, 0 means device is successfully
activated and 1 means error.

This behavior can be observed by the following steps:

1) run a Linux distro on esxi server (5.5+)
2) modify vmxnet3 Linux driver to give it an invalid
   address to 'adapter->shared_pa' which is the
   shared memory for guest/host communication

This will trigger device activation failure and kernel
log will have the following message:

   [ 7138.403256] vmxnet3 0000:03:00.0 eth1: Failed to activate dev: error 1

So return 1 on device activation failure instead of -1;

Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
---
Changes in v3:
 - mention esxi version in commit message

 hw/net/vmxnet3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index e168285..9185408 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1652,7 +1652,7 @@ static uint64_t vmxnet3_get_command_status(VMXNET3State *s)
 
     switch (s->last_command) {
     case VMXNET3_CMD_ACTIVATE_DEV:
-        ret = (s->device_active) ? 0 : -1;
+        ret = (s->device_active) ? 0 : 1;
         VMW_CFPRN("Device active: %" PRIx64, ret);
         break;
 
-- 
1.9.1

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

* [Qemu-devel] [PATCH v3 2/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command
  2015-12-23  6:06 [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 1/5] net/vmxnet3: return 1 on device activation failure Miao Yan
@ 2015-12-23  6:06 ` Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 3/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO Miao Yan
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Miao Yan @ 2015-12-23  6:06 UTC (permalink / raw)
  To: jasowang, dmitry, qemu-devel

VMXNET3_CMD_GET_DID_LO should return PCI ID of the device
and VMXNET3_CMD_GET_DID_HI should return vmxnet3 revision ID.

This behavior can be observed by the following steps:

1) run a Linux distro on esxi server (5.x+)
2) modify vmxnet3 Linux driver to read DID_HI and DID_LO:

  VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_DID_LO);
  lo =  VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);

  VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_DID_HI);
  high =  VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
  pr_info("vmxnet3 DID lo: 0x%x, high: 0x%x\n", lo, high);

The kernel log will have something like the following message:

  [ 7005.111170] vmxnet3 DID lo: 0x7b0, high: 0x1

Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
---
Changes in v3:
 - mention esxi version in commit message

 hw/net/vmxnet3.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 9185408..cddbf6d 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1640,6 +1640,14 @@ static void vmxnet3_handle_command(VMXNET3State *s, uint64_t cmd)
                   "adaptive ring info flags");
         break;
 
+    case VMXNET3_CMD_GET_DID_LO:
+        VMW_CBPRN("Set: Get lower part of device ID");
+        break;
+
+    case VMXNET3_CMD_GET_DID_HI:
+        VMW_CBPRN("Set: Get upper part of device ID");
+        break;
+
     default:
         VMW_CBPRN("Received unknown command: %" PRIx64, cmd);
         break;
@@ -1683,6 +1691,14 @@ static uint64_t vmxnet3_get_command_status(VMXNET3State *s)
         ret = VMXNET3_DISABLE_ADAPTIVE_RING;
         break;
 
+    case VMXNET3_CMD_GET_DID_LO:
+        ret = PCI_DEVICE_ID_VMWARE_VMXNET3;
+        break;
+
+    case VMXNET3_CMD_GET_DID_HI:
+        ret = VMXNET3_DEVICE_REVISION;
+        break;
+
     default:
         VMW_WRPRN("Received request for unknown command: %x", s->last_command);
         ret = -1;
-- 
1.9.1

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

* [Qemu-devel] [PATCH v3 3/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO
  2015-12-23  6:06 [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 1/5] net/vmxnet3: return 1 on device activation failure Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 2/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command Miao Yan
@ 2015-12-23  6:06 ` Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 4/5] net/vmxnet3: return 0 on unknown command Miao Yan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Miao Yan @ 2015-12-23  6:06 UTC (permalink / raw)
  To: jasowang, dmitry, qemu-devel

VMXNET3_CMD_GET_DEV_EXTRA_INFO should return 0 for emulation
mode

This behavior can be observed by the following steps:

1) run a Linux distro on esxi server (5.x+)
2) modify vmxnet3 Linux driver to read the register:

  VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_DEV_EXTRA_INFO);
  ret =  VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
  pr_info("vmxnet3 dev_info: 0x%x\n", ret);

The kernel log will have some like the following message:

  [ 7005.111170] vmxnet3 dev_info: 0x0

Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
---
Changes in v3:
 - mention esxi version in commit message

 hw/net/vmxnet3.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index cddbf6d..b8bc360 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1648,6 +1648,10 @@ static void vmxnet3_handle_command(VMXNET3State *s, uint64_t cmd)
         VMW_CBPRN("Set: Get upper part of device ID");
         break;
 
+    case VMXNET3_CMD_GET_DEV_EXTRA_INFO:
+        VMW_CBPRN("Set: Get device extra info");
+        break;
+
     default:
         VMW_CBPRN("Received unknown command: %" PRIx64, cmd);
         break;
@@ -1667,6 +1671,7 @@ static uint64_t vmxnet3_get_command_status(VMXNET3State *s)
     case VMXNET3_CMD_RESET_DEV:
     case VMXNET3_CMD_QUIESCE_DEV:
     case VMXNET3_CMD_GET_QUEUE_STATUS:
+    case VMXNET3_CMD_GET_DEV_EXTRA_INFO:
         ret = 0;
         break;
 
-- 
1.9.1

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

* [Qemu-devel] [PATCH v3 4/5] net/vmxnet3: return 0 on unknown command
  2015-12-23  6:06 [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Miao Yan
                   ` (2 preceding siblings ...)
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 3/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO Miao Yan
@ 2015-12-23  6:06 ` Miao Yan
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 5/5] net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION Miao Yan
  2015-12-23  6:29 ` [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Dmitry Fleytman
  5 siblings, 0 replies; 8+ messages in thread
From: Miao Yan @ 2015-12-23  6:06 UTC (permalink / raw)
  To: jasowang, dmitry, qemu-devel

Return 0 on unknown command, this is what esxi (5.x+) behaves.

Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
---
Changes in v3:
 - mention esxi version in commit message

 hw/net/vmxnet3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index b8bc360..a429405 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1706,7 +1706,7 @@ static uint64_t vmxnet3_get_command_status(VMXNET3State *s)
 
     default:
         VMW_WRPRN("Received request for unknown command: %x", s->last_command);
-        ret = -1;
+        ret = 0;
         break;
     }
 
-- 
1.9.1

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

* [Qemu-devel] [PATCH v3 5/5] net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION
  2015-12-23  6:06 [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Miao Yan
                   ` (3 preceding siblings ...)
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 4/5] net/vmxnet3: return 0 on unknown command Miao Yan
@ 2015-12-23  6:06 ` Miao Yan
  2015-12-23  6:29 ` [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Dmitry Fleytman
  5 siblings, 0 replies; 8+ messages in thread
From: Miao Yan @ 2015-12-23  6:06 UTC (permalink / raw)
  To: jasowang, dmitry, qemu-devel; +Cc: Miao Yan

VMXNET3_DEVICE_VERSION is used as return value for accessing
UPT Revision Report and Selection register. So rename it
to VMXNET3_UPT_REVISION.

Signed-off-by: Miao Yan <yanmiaoebest@gmail.com>
---
 hw/net/vmxnet3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index a429405..fba1d73 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -50,7 +50,7 @@
 #define VMXNET3_LINK_STATUS_UP  0x1
 
 /* Least significant bit should be set for revision and version */
-#define VMXNET3_DEVICE_VERSION    0x1
+#define VMXNET3_UPT_REVISION      0x1
 #define VMXNET3_DEVICE_REVISION   0x1
 
 /* Number of interrupt vectors for non-MSIx modes */
@@ -1837,7 +1837,7 @@ vmxnet3_io_bar1_read(void *opaque, hwaddr addr, unsigned size)
         /* UPT Version Report Selection */
         case VMXNET3_REG_UVRS:
             VMW_CBPRN("Read BAR1 [VMXNET3_REG_UVRS], size %d", size);
-            ret = VMXNET3_DEVICE_VERSION;
+            ret = VMXNET3_UPT_REVISION;
             break;
 
         /* Command */
-- 
1.9.1

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

* Re: [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3
  2015-12-23  6:06 [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Miao Yan
                   ` (4 preceding siblings ...)
  2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 5/5] net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION Miao Yan
@ 2015-12-23  6:29 ` Dmitry Fleytman
  2015-12-24  2:53   ` Jason Wang
  5 siblings, 1 reply; 8+ messages in thread
From: Dmitry Fleytman @ 2015-12-23  6:29 UTC (permalink / raw)
  To: Miao Yan; +Cc: Jason Wang, qemu-devel

Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>

> On 23 Dec 2015, at 08:06 AM, Miao Yan <yanmiaobest@gmail.com> wrote:
> 
> Qemu vmxnet3 emulation doesn't recognize VMXNET3_CMD_GET_DID_LO,
> VMXNET3_CMD_GET_DID_HI and VMXNET3_CMD_GET_DEV_EXTRA_INFO command and
> returns -1 on all of them.
> 
> This patchset makes them return correct values.
> 
> Changes in v2:
> - return 0 on unknown command
> Changes in v3:
> - rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION
> 
> Miao Yan (5):
>  net/vmxnet3: return 1 on device activation failure
>  net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command
>  net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO
>  net/vmxnet3: return 0 on unknown command
>  net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION
> 
> hw/net/vmxnet3.c | 29 +++++++++++++++++++++++++----
> 1 file changed, 25 insertions(+), 4 deletions(-)
> 
> -- 
> 1.9.1
> 

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

* Re: [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3
  2015-12-23  6:29 ` [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Dmitry Fleytman
@ 2015-12-24  2:53   ` Jason Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Jason Wang @ 2015-12-24  2:53 UTC (permalink / raw)
  To: Dmitry Fleytman, Miao Yan; +Cc: qemu-devel



On 12/23/2015 02:29 PM, Dmitry Fleytman wrote:
> Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
>
>> On 23 Dec 2015, at 08:06 AM, Miao Yan <yanmiaobest@gmail.com> wrote:
>>
>> Qemu vmxnet3 emulation doesn't recognize VMXNET3_CMD_GET_DID_LO,
>> VMXNET3_CMD_GET_DID_HI and VMXNET3_CMD_GET_DEV_EXTRA_INFO command and
>> returns -1 on all of them.
>>
>> This patchset makes them return correct values.
>>
>> Changes in v2:
>> - return 0 on unknown command
>> Changes in v3:
>> - rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION
>>
>> Miao Yan (5):
>>  net/vmxnet3: return 1 on device activation failure
>>  net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command
>>  net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO
>>  net/vmxnet3: return 0 on unknown command
>>  net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION
>>
>> hw/net/vmxnet3.c | 29 +++++++++++++++++++++++++----
>> 1 file changed, 25 insertions(+), 4 deletions(-)
>>
>> -- 
>> 1.9.1
>>

Applied in my -net.

Thanks

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

end of thread, other threads:[~2015-12-24  2:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-23  6:06 [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Miao Yan
2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 1/5] net/vmxnet3: return 1 on device activation failure Miao Yan
2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 2/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command Miao Yan
2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 3/5] net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO Miao Yan
2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 4/5] net/vmxnet3: return 0 on unknown command Miao Yan
2015-12-23  6:06 ` [Qemu-devel] [PATCH v3 5/5] net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION Miao Yan
2015-12-23  6:29 ` [Qemu-devel] [PATCH v3 0/5] correct some register return values for vxmnet3 Dmitry Fleytman
2015-12-24  2:53   ` Jason Wang

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).