Message ID | 1449069991-6109-2-git-send-email-shmulik.ladkani@ravellosystems.com |
---|---|
State | New |
Headers | show |
On 12/02/2015 11:26 PM, Shmulik Ladkani wrote: > Place device reported PCI capabilities at the same offsets as placed by > the VMware virtual hardware: MSI at [84], MSI-X at [9c]. > > For compatability, preserve old offsets using 'x-old-msi-offsets' toggle. > > Signed-off-by: Shmulik Ladkani <shmulik.ladkani@ravellosystems.com> > --- > hw/net/vmxnet3.c | 20 +++++++++++++++++--- > include/hw/compat.h | 4 ++++ > 2 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c > index 5e3a233..1985dcf 100644 > --- a/hw/net/vmxnet3.c > +++ b/hw/net/vmxnet3.c > @@ -36,6 +36,16 @@ > #define VMXNET3_MSIX_BAR_SIZE 0x2000 > #define MIN_BUF_SIZE 60 > > +/* Compatability flags for migration */ > +#define VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS_BIT 0 > +#define VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS \ > + (1 << VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS_BIT) > + > +#define VMXNET3_MSI_OFFSET(s) \ > + ((s)->compat_flags & VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS ? 0x50 : 0x84) > +#define VMXNET3_MSIX_OFFSET(s) \ > + ((s)->compat_flags & VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS ? 0 : 0x9c) > + > #define VMXNET3_BAR0_IDX (0) > #define VMXNET3_BAR1_IDX (1) > #define VMXNET3_MSIX_BAR_IDX (2) > @@ -313,6 +323,9 @@ typedef struct { > MACAddr *mcast_list; > uint32_t mcast_list_len; > uint32_t mcast_list_buff_size; /* needed for live migration. */ > + > + /* Compatability flags for migration */ > + uint32_t compat_flags; > } VMXNET3State; > > /* Interrupt management */ > @@ -2103,7 +2116,7 @@ vmxnet3_init_msix(VMXNET3State *s) > VMXNET3_MSIX_BAR_IDX, VMXNET3_OFF_MSIX_TABLE, > &s->msix_bar, > VMXNET3_MSIX_BAR_IDX, VMXNET3_OFF_MSIX_PBA, > - 0); > + VMXNET3_MSIX_OFFSET(s)); > > if (0 > res) { > VMW_WRPRN("Failed to initialize MSI-X, error %d", res); > @@ -2131,7 +2144,6 @@ vmxnet3_cleanup_msix(VMXNET3State *s) > } > } > > -#define VMXNET3_MSI_OFFSET (0x50) > #define VMXNET3_USE_64BIT (true) > #define VMXNET3_PER_VECTOR_MASK (false) > > @@ -2141,7 +2153,7 @@ vmxnet3_init_msi(VMXNET3State *s) > PCIDevice *d = PCI_DEVICE(s); > int res; > > - res = msi_init(d, VMXNET3_MSI_OFFSET, VMXNET3_MAX_NMSIX_INTRS, > + res = msi_init(d, VMXNET3_MSI_OFFSET(s), VMXNET3_MAX_NMSIX_INTRS, > VMXNET3_USE_64BIT, VMXNET3_PER_VECTOR_MASK); > if (0 > res) { > VMW_WRPRN("Failed to initialize MSI, error %d", res); > @@ -2552,6 +2564,8 @@ static const VMStateDescription vmstate_vmxnet3 = { > > static Property vmxnet3_properties[] = { > DEFINE_NIC_PROPERTIES(VMXNET3State, conf), > + DEFINE_PROP_BIT("x-old-msi-offsets", VMXNET3State, compat_flags, > + VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS_BIT, false), > DEFINE_PROP_END_OF_LIST(), > }; > > diff --git a/include/hw/compat.h b/include/hw/compat.h > index d0b1c4f..01e326d 100644 > --- a/include/hw/compat.h > +++ b/include/hw/compat.h > @@ -18,6 +18,10 @@ > .driver = "virtio-pci",\ > .property = "migrate-extra",\ > .value = "off",\ > + },{\ > + .driver = "vmxnet3",\ > + .property = "x-old-msi-offsets",\ > + .value = "on",\ > }, To have a better bisection behavior, we'd better enable this and compat it in patch 2. > > #define HW_COMPAT_2_3 \
Thanks Jason, On Fri, 4 Dec 2015 16:49:23 +0800 Jason Wang <jasowang@redhat.com> wrote: > > @@ -18,6 +18,10 @@ > > .driver = "virtio-pci",\ > > .property = "migrate-extra",\ > > .value = "off",\ > > + },{\ > > + .driver = "vmxnet3",\ > > + .property = "x-old-msi-offsets",\ > > + .value = "on",\ > > }, > > To have a better bisection behavior, we'd better enable this and compat > it in patch 2. Did you mean the following: #1 Introduce the new functionality with its 'x-old-msi-offsets' property, with the property set to true by default #2 Change 'x-old-msi-offsets' default value to false, and introduce the above compat Regards, Shmulik
On 12/05/2015 03:38 AM, Shmulik Ladkani wrote: > Thanks Jason, > > On Fri, 4 Dec 2015 16:49:23 +0800 Jason Wang <jasowang@redhat.com> wrote: >>> @@ -18,6 +18,10 @@ >>> .driver = "virtio-pci",\ >>> .property = "migrate-extra",\ >>> .value = "off",\ >>> + },{\ >>> + .driver = "vmxnet3",\ >>> + .property = "x-old-msi-offsets",\ >>> + .value = "on",\ >>> }, >> To have a better bisection behavior, we'd better enable this and compat >> it in patch 2. > Did you mean the following: > > #1 Introduce the new functionality with its 'x-old-msi-offsets' > property, with the property set to true by default > > #2 Change 'x-old-msi-offsets' default value to false, and introduce the > above compat > > Regards, > Shmulik Sorry for being unclear, I mean we'd better, keep the compat flag like what has been done in the patch but introduce the property bit and compat it in next patch.
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 5e3a233..1985dcf 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -36,6 +36,16 @@ #define VMXNET3_MSIX_BAR_SIZE 0x2000 #define MIN_BUF_SIZE 60 +/* Compatability flags for migration */ +#define VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS_BIT 0 +#define VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS \ + (1 << VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS_BIT) + +#define VMXNET3_MSI_OFFSET(s) \ + ((s)->compat_flags & VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS ? 0x50 : 0x84) +#define VMXNET3_MSIX_OFFSET(s) \ + ((s)->compat_flags & VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS ? 0 : 0x9c) + #define VMXNET3_BAR0_IDX (0) #define VMXNET3_BAR1_IDX (1) #define VMXNET3_MSIX_BAR_IDX (2) @@ -313,6 +323,9 @@ typedef struct { MACAddr *mcast_list; uint32_t mcast_list_len; uint32_t mcast_list_buff_size; /* needed for live migration. */ + + /* Compatability flags for migration */ + uint32_t compat_flags; } VMXNET3State; /* Interrupt management */ @@ -2103,7 +2116,7 @@ vmxnet3_init_msix(VMXNET3State *s) VMXNET3_MSIX_BAR_IDX, VMXNET3_OFF_MSIX_TABLE, &s->msix_bar, VMXNET3_MSIX_BAR_IDX, VMXNET3_OFF_MSIX_PBA, - 0); + VMXNET3_MSIX_OFFSET(s)); if (0 > res) { VMW_WRPRN("Failed to initialize MSI-X, error %d", res); @@ -2131,7 +2144,6 @@ vmxnet3_cleanup_msix(VMXNET3State *s) } } -#define VMXNET3_MSI_OFFSET (0x50) #define VMXNET3_USE_64BIT (true) #define VMXNET3_PER_VECTOR_MASK (false) @@ -2141,7 +2153,7 @@ vmxnet3_init_msi(VMXNET3State *s) PCIDevice *d = PCI_DEVICE(s); int res; - res = msi_init(d, VMXNET3_MSI_OFFSET, VMXNET3_MAX_NMSIX_INTRS, + res = msi_init(d, VMXNET3_MSI_OFFSET(s), VMXNET3_MAX_NMSIX_INTRS, VMXNET3_USE_64BIT, VMXNET3_PER_VECTOR_MASK); if (0 > res) { VMW_WRPRN("Failed to initialize MSI, error %d", res); @@ -2552,6 +2564,8 @@ static const VMStateDescription vmstate_vmxnet3 = { static Property vmxnet3_properties[] = { DEFINE_NIC_PROPERTIES(VMXNET3State, conf), + DEFINE_PROP_BIT("x-old-msi-offsets", VMXNET3State, compat_flags, + VMXNET3_COMPAT_FLAG_OLD_MSI_OFFSETS_BIT, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/compat.h b/include/hw/compat.h index d0b1c4f..01e326d 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -18,6 +18,10 @@ .driver = "virtio-pci",\ .property = "migrate-extra",\ .value = "off",\ + },{\ + .driver = "vmxnet3",\ + .property = "x-old-msi-offsets",\ + .value = "on",\ }, #define HW_COMPAT_2_3 \
Place device reported PCI capabilities at the same offsets as placed by the VMware virtual hardware: MSI at [84], MSI-X at [9c]. For compatability, preserve old offsets using 'x-old-msi-offsets' toggle. Signed-off-by: Shmulik Ladkani <shmulik.ladkani@ravellosystems.com> --- hw/net/vmxnet3.c | 20 +++++++++++++++++--- include/hw/compat.h | 4 ++++ 2 files changed, 21 insertions(+), 3 deletions(-)