Skip to contentSkip to conversation

correct some register return values for vxmnet3

PATCH Applied Miao Yan 3 participants 8 messages Dec 23, 2015 – Dec 24, 2015

lore
Share & tools
lore

Miao Yan

author
#0 lore raw

v3 cover correct some register return values for vxmnet3

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(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v3 1/5 net/vmxnet3: return 1 on device activation failure

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;

---
Changes in v3:
- mention esxi version in commit message

 hw/net/vmxnet3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/vmxnet3.c +1 -1
index e168285..9185408 100644
@@ -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;
 
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v3 2/5 net/vmxnet3: return correct value for VMXNET3_CMD_GET_DID_* command

In reply to Miao Yan

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

---
Changes in v3:
- mention esxi version in commit message

 hw/net/vmxnet3.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
hw/net/vmxnet3.c +16 -0
index 9185408..cddbf6d 100644
@@ -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;
Signature · 1 line
1.9.1
author
#3 lore raw

PATCH v3 3/5 net/vmxnet3: return correct value for VMXNET3_CMD_GET_DEV_EXTRA_INFO

In reply to Miao Yan

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

---
Changes in v3:
- mention esxi version in commit message

 hw/net/vmxnet3.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/net/vmxnet3.c +5 -0
index cddbf6d..b8bc360 100644
@@ -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;
 
Signature · 1 line
1.9.1
author
#4 lore raw

PATCH v3 4/5 net/vmxnet3: return 0 on unknown command

In reply to Miao Yan

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

---
Changes in v3:
- mention esxi version in commit message

 hw/net/vmxnet3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/vmxnet3.c +1 -1
index b8bc360..a429405 100644
@@ -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;
     }
 
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH v3 5/5 net/vmxnet3: rename VMXNET3_DEVICE_VERSION to VMXNET3_UPT_REVISION

In reply to 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.

---
 hw/net/vmxnet3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/vmxnet3.c +2 -2
index a429405..fba1d73 100644
@@ -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 */
Signature · 1 line
1.9.1
Reviewed-by on the v3 series
#6 lore raw
In reply to Miao Yan
Quoted 26 lines · Miao Yan

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(-)
Signature · 1 line
1.9.1
Applied
#7 lore raw
Quoted 28 lines · Dmitry Fleytman
Quoted 26 lines · Miao Yan

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(-)
Signature · 1 line
1.9.1

Applied in my -net.

Thanks