All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Dmitry Fleytman <dmitry@daynix.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel@nongnu.org, Yan Vugenfirer <yan@daynix.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	Gerhard Wiesinger <lists@wiesinger.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v13 5/5] VMXNET3 device implementation
Date: Thu, 07 Mar 2013 13:59:19 +0100	[thread overview]
Message-ID: <51388F27.7000201@suse.de> (raw)
In-Reply-To: <1362554502-15248-6-git-send-email-dmitry@daynix.com>

Am 06.03.2013 08:21, schrieb Dmitry Fleytman:
> Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
> Signed-off-by: Yan Vugenfirer <yan@daynix.com>
> ---
>  default-configs/pci.mak |    1 +
>  hw/Makefile.objs        |    1 +
>  hw/pci/pci.h            |    1 +
>  hw/vmxnet3.c            | 2460 +++++++++++++++++++++++++++++++++++++++++++++++
>  hw/vmxnet3.h            |  760 +++++++++++++++
>  5 files changed, 3223 insertions(+)
>  create mode 100644 hw/vmxnet3.c
>  create mode 100644 hw/vmxnet3.h
> 
> diff --git a/default-configs/pci.mak b/default-configs/pci.mak
> index ee2d18d..ce56d58 100644
> --- a/default-configs/pci.mak
> +++ b/default-configs/pci.mak
> @@ -13,6 +13,7 @@ CONFIG_LSI_SCSI_PCI=y
>  CONFIG_MEGASAS_SCSI_PCI=y
>  CONFIG_RTL8139_PCI=y
>  CONFIG_E1000_PCI=y
> +CONFIG_VMXNET3_PCI=y
>  CONFIG_IDE_CORE=y
>  CONFIG_IDE_QDEV=y
>  CONFIG_IDE_PCI=y
> diff --git a/hw/Makefile.objs b/hw/Makefile.objs
> index 14922cb..026aff6 100644
> --- a/hw/Makefile.objs
> +++ b/hw/Makefile.objs
> @@ -120,6 +120,7 @@ common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o
>  common-obj-$(CONFIG_E1000_PCI) += e1000.o
>  common-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o
>  common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet_tx_pkt.o vmxnet_rx_pkt.o
> +common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet3.o
>  
>  common-obj-$(CONFIG_SMC91C111) += smc91c111.o
>  common-obj-$(CONFIG_LAN9118) += lan9118.o
> diff --git a/hw/pci/pci.h b/hw/pci/pci.h
> index f340fe5..3beb70b 100644
> --- a/hw/pci/pci.h
> +++ b/hw/pci/pci.h
> @@ -60,6 +60,7 @@
>  #define PCI_DEVICE_ID_VMWARE_NET         0x0720
>  #define PCI_DEVICE_ID_VMWARE_SCSI        0x0730
>  #define PCI_DEVICE_ID_VMWARE_IDE         0x1729
> +#define PCI_DEVICE_ID_VMWARE_VMXNET3     0x07B0
>  
>  /* Intel (0x8086) */
>  #define PCI_DEVICE_ID_INTEL_82551IT      0x1209
> diff --git a/hw/vmxnet3.c b/hw/vmxnet3.c
> new file mode 100644
> index 0000000..75b7181
> --- /dev/null
> +++ b/hw/vmxnet3.c
> @@ -0,0 +1,2460 @@
> +/*
> + * QEMU VMWARE VMXNET3 paravirtual NIC
> + *
> + * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
> + *
> + * Developed by Daynix Computing LTD (http://www.daynix.com)
> + *
> + * Authors:
> + * Dmitry Fleytman <dmitry@daynix.com>
> + * Tamir Shomer <tamirs@daynix.com>
> + * Yan Vugenfirer <yan@daynix.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include "hw.h"
> +#include "pci/pci.h"
> +#include "net/net.h"
> +#include "virtio-net.h"
> +#include "net/tap.h"
> +#include "net/checksum.h"
> +#include "sysemu/sysemu.h"
> +#include "qemu-common.h"
> +#include "qemu/bswap.h"
> +#include "pci/msix.h"
> +#include "pci/msi.h"
> +
> +#include "vmxnet3.h"
> +#include "vmxnet_debug.h"
> +#include "vmware_utils.h"
> +#include "vmxnet_tx_pkt.h"
> +#include "vmxnet_rx_pkt.h"
> +
> +#define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1
> +#define VMXNET3_MSIX_BAR_SIZE 0x2000
> +
> +#define VMXNET3_BAR0_IDX      (0)
> +#define VMXNET3_BAR1_IDX      (1)
> +#define VMXNET3_MSIX_BAR_IDX  (2)
> +
> +#define VMXNET3_OFF_MSIX_TABLE (0x000)
> +#define VMXNET3_OFF_MSIX_PBA   (0x800)
> +
> +/* Link speed in Mbps should be shifted by 16 */
> +#define VMXNET3_LINK_SPEED      (1000 << 16)
> +
> +/* Link status: 1 - up, 0 - down. */
> +#define VMXNET3_LINK_STATUS_UP  0x1
> +
> +/* Least significant bit should be set for revision and version */
> +#define VMXNET3_DEVICE_VERSION    0x1
> +#define VMXNET3_DEVICE_REVISION   0x1
> +
> +/* Macros for rings descriptors access */
> +#define VMXNET3_READ_TX_QUEUE_DESCR8(dpa, field) \
> +    (vmw_shmem_ld8(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field)))
> +
> +#define VMXNET3_WRITE_TX_QUEUE_DESCR8(dpa, field, value) \
> +    (vmw_shmem_st8(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field, value)))
> +
> +#define VMXNET3_READ_TX_QUEUE_DESCR32(dpa, field) \
> +    (vmw_shmem_ld32(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field)))
> +
> +#define VMXNET3_WRITE_TX_QUEUE_DESCR32(dpa, field, value) \
> +    (vmw_shmem_st32(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field), value))
> +
> +#define VMXNET3_READ_TX_QUEUE_DESCR64(dpa, field) \
> +    (vmw_shmem_ld64(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field)))
> +
> +#define VMXNET3_WRITE_TX_QUEUE_DESCR64(dpa, field, value) \
> +    (vmw_shmem_st64(dpa + offsetof(struct Vmxnet3_TxQueueDesc, field), value))
> +
> +#define VMXNET3_READ_RX_QUEUE_DESCR64(dpa, field) \
> +    (vmw_shmem_ld64(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field)))
> +
> +#define VMXNET3_READ_RX_QUEUE_DESCR32(dpa, field) \
> +    (vmw_shmem_ld32(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field)))
> +
> +#define VMXNET3_WRITE_RX_QUEUE_DESCR64(dpa, field, value) \
> +    (vmw_shmem_st64(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field), value))
> +
> +#define VMXNET3_WRITE_RX_QUEUE_DESCR8(dpa, field, value) \
> +    (vmw_shmem_st8(dpa + offsetof(struct Vmxnet3_RxQueueDesc, field), value))
> +
> +/* Macros for guest driver shared area access */
> +#define VMXNET3_READ_DRV_SHARED64(shpa, field) \
> +    (vmw_shmem_ld64(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
> +
> +#define VMXNET3_READ_DRV_SHARED32(shpa, field) \
> +    (vmw_shmem_ld32(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
> +
> +#define VMXNET3_WRITE_DRV_SHARED32(shpa, field, val) \
> +    (vmw_shmem_st32(shpa + offsetof(struct Vmxnet3_DriverShared, field), val))
> +
> +#define VMXNET3_READ_DRV_SHARED16(shpa, field) \
> +    (vmw_shmem_ld16(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
> +
> +#define VMXNET3_READ_DRV_SHARED8(shpa, field) \
> +    (vmw_shmem_ld8(shpa + offsetof(struct Vmxnet3_DriverShared, field)))
> +
> +#define VMXNET3_READ_DRV_SHARED(shpa, field, b, l) \
> +    (vmw_shmem_read(shpa + offsetof(struct Vmxnet3_DriverShared, field), b, l))
> +
> +#define VMXNET_FLAG_IS_SET(field, flag) (((field) & (flag)) == (flag))
> +
> +#define VMXNET3(pci_dev) container_of((pci_dev), VMXNET3State, parent_obj)

This still accessing parent_obj field and wrongly makes type assumptions
about the argument. It should be:

#define TYPE_VMXNET3 "vmxnet3"
#define VMXNET3(obj) OBJECT_CHECK(VMXNET3State, (obj), TYPE_VMXNET3)

[...]
> +static const TypeInfo vmxnet3_info = {
> +    .name          = "vmxnet3",

.name = TYPE_VMXNET3,

> +    .parent        = TYPE_PCI_DEVICE,
> +    .instance_size = sizeof(VMXNET3State),
> +    .class_init    = vmxnet3_class_init,
> +};
[snip]

Cf. include/qom/object.h

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-03-07 12:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06  7:21 [Qemu-devel] [PATCH V13 0/5] VMXNET3 paravirtual NIC device implementation Dmitry Fleytman
2013-03-06  7:21 ` [Qemu-devel] [PATCH v13 1/5] Checksum-related utility functions Dmitry Fleytman
2013-03-06  7:21 ` [Qemu-devel] [PATCH v13 2/5] net: iovec checksum calculator Dmitry Fleytman
2013-03-06  7:21 ` [Qemu-devel] [PATCH v13 3/5] Common definitions for VMWARE devices Dmitry Fleytman
2013-03-06  7:21 ` [Qemu-devel] [PATCH v13 4/5] Packet abstraction for VMWARE network devices Dmitry Fleytman
2013-03-06  7:21 ` [Qemu-devel] [PATCH v13 5/5] VMXNET3 device implementation Dmitry Fleytman
2013-03-07 12:59   ` Andreas Färber [this message]
2013-03-07 13:43     ` Dmitry Fleytman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51388F27.7000201@suse.de \
    --to=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=dmitry@daynix.com \
    --cc=lists@wiesinger.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=yan@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.