qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Williamson <alex.williamson@hp.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 6/7] virtio-net: Add new RX filter controls
Date: Sat, 6 Jun 2009 23:48:45 +0300	[thread overview]
Message-ID: <20090606204845.GC26877@redhat.com> (raw)
In-Reply-To: <20090605204718.3355.28647.stgit@kvm.aw>

On Fri, Jun 05, 2009 at 02:47:18PM -0600, Alex Williamson wrote:
> Add a few new RX modes to better control the receive_filter.  These
> are all fairly obvious features that hardware could provide.

Could you add a bit more detail on motivation for these
features please?


> 
> Signed-off-by: Alex Williamson <alex.williamson@hp.com>
> ---
> 
>  hw/virtio-net.c |   40 ++++++++++++++++++++++++++++++++++++----
>  hw/virtio-net.h |   14 ++++++++++----
>  2 files changed, 46 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 5239cc0..ecb58de 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -16,7 +16,7 @@
>  #include "qemu-timer.h"
>  #include "virtio-net.h"
>  
> -#define VIRTIO_NET_VM_VERSION    9
> +#define VIRTIO_NET_VM_VERSION    10
>  
>  #define MAC_TABLE_ENTRIES    32
>  #define MAX_VLAN    (1 << 12)   /* Per 802.1Q definition */
> @@ -35,6 +35,10 @@ typedef struct VirtIONet
>      int mergeable_rx_bufs;
>      uint8_t promisc;
>      uint8_t allmulti;
> +    uint8_t alluni;
> +    uint8_t nomulti;
> +    uint8_t nouni;
> +    uint8_t nobcast;
>      struct {
>          int in_use;
>          int first_multi;
> @@ -98,6 +102,10 @@ static void virtio_net_reset(VirtIODevice *vdev)
>      /* Reset back to compatibility mode */
>      n->promisc = 1;
>      n->allmulti = 0;
> +    n->alluni = 0;
> +    n->nomulti = 0;
> +    n->nouni = 0;
> +    n->nobcast = 0;
>  
>      /* Flush any MAC and VLAN filter table state */
>      n->mac_table.in_use = 0;
> @@ -114,7 +122,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
>                          (1 << VIRTIO_NET_F_STATUS) |
>                          (1 << VIRTIO_NET_F_CTRL_VQ) |
>                          (1 << VIRTIO_NET_F_CTRL_RX) |
> -                        (1 << VIRTIO_NET_F_CTRL_VLAN);
> +                        (1 << VIRTIO_NET_F_CTRL_VLAN) |
> +                        (1 << VIRTIO_NET_F_CTRL_RX_EXTRA);
>  
>      return features;
>  }
> @@ -157,6 +166,14 @@ static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
>          n->promisc = on;
>      else if (cmd == VIRTIO_NET_CTRL_RX_MODE_ALLMULTI)
>          n->allmulti = on;
> +    else if (cmd == VIRTIO_NET_CTRL_RX_MODE_ALLUNI)
> +        n->alluni = on;
> +    else if (cmd == VIRTIO_NET_CTRL_RX_MODE_NOMULTI)
> +        n->nomulti = on;
> +    else if (cmd == VIRTIO_NET_CTRL_RX_MODE_NOUNI)
> +        n->nouni = on;
> +    else if (cmd == VIRTIO_NET_CTRL_RX_MODE_NOBCAST)
> +        n->nobcast = on;
>      else
>          return VIRTIO_NET_ERR;
>  
> @@ -357,7 +374,9 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
>  
>      if (ptr[0] & 1) { // multicast
>          if (!memcmp(ptr, bcast, sizeof(bcast))) {
> -            return 1;
> +            return !n->nobcast;
> +        } else if (n->nomulti) {
> +            return 0;
>          } else if (n->allmulti || n->mac_table.multi_overflow) {
>              return 1;
>          }
> @@ -368,7 +387,9 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
>              }
>          }
>      } else { // unicast
> -        if (n->mac_table.uni_overflow) {
> +        if (n->nouni) {
> +            return 0;
> +        } else if (n->alluni || n->mac_table.uni_overflow) {
>              return 1;
>          } else if (!memcmp(ptr, n->mac, ETH_ALEN)) {
>              return 1;
> @@ -549,6 +570,10 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
>      qemu_put_be32(f, 0); /* vnet-hdr placeholder */
>      qemu_put_byte(f, n->mac_table.multi_overflow);
>      qemu_put_byte(f, n->mac_table.uni_overflow);
> +    qemu_put_byte(f, n->alluni);
> +    qemu_put_byte(f, n->nomulti);
> +    qemu_put_byte(f, n->nouni);
> +    qemu_put_byte(f, n->nobcast);
>  }
>  
>  static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
> @@ -605,6 +630,13 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
>          n->mac_table.uni_overflow = qemu_get_byte(f);
>      }
>  
> +    if (version_id >= 10) {
> +        n->alluni = qemu_get_byte(f);
> +        n->nomulti = qemu_get_byte(f);
> +        n->nouni = qemu_get_byte(f);
> +        n->nobcast = qemu_get_byte(f);
> +    }
> +
>      /* Find the first multicast entry in the saved MAC filter */
>      for (i = 0; i < n->mac_table.in_use; i++) {
>          if (n->mac_table.macs[i * ETH_ALEN] & 1) {
> diff --git a/hw/virtio-net.h b/hw/virtio-net.h
> index 390fe10..2085181 100644
> --- a/hw/virtio-net.h
> +++ b/hw/virtio-net.h
> @@ -43,6 +43,7 @@
>  #define VIRTIO_NET_F_CTRL_VQ    17      /* Control channel available */
>  #define VIRTIO_NET_F_CTRL_RX    18      /* Control channel RX mode support */
>  #define VIRTIO_NET_F_CTRL_VLAN  19      /* Control channel VLAN filtering */
> +#define VIRTIO_NET_F_CTRL_RX_EXTRA 20   /* Extra RX mode control support */
>  
>  #define VIRTIO_NET_S_LINK_UP    1       /* Link is up */
>  
> @@ -103,14 +104,19 @@ typedef uint8_t virtio_net_ctrl_ack;
>  #define VIRTIO_NET_ERR    1
>  
>  /*
> - * Control the RX mode, ie. promisucous and allmulti.  PROMISC and
> - * ALLMULTI commands require an "out" sg entry containing a 1 byte
> - * state value, zero = disable, non-zero = enable.  These commands
> - * are supported with the VIRTIO_NET_F_CTRL_RX feature.
> + * Control the RX mode, ie. promisucous, allmulti, etc...
> + * All commands require an "out" sg entry containing a 1 byte
> + * state value, zero = disable, non-zero = enable.  Commands
> + * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature.
> + * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA.
>   */
>  #define VIRTIO_NET_CTRL_RX_MODE    0
>   #define VIRTIO_NET_CTRL_RX_MODE_PROMISC      0
>   #define VIRTIO_NET_CTRL_RX_MODE_ALLMULTI     1
> + #define VIRTIO_NET_CTRL_RX_MODE_ALLUNI       2
> + #define VIRTIO_NET_CTRL_RX_MODE_NOMULTI      3
> + #define VIRTIO_NET_CTRL_RX_MODE_NOUNI        4
> + #define VIRTIO_NET_CTRL_RX_MODE_NOBCAST      5
>  
>  /*
>   * Control the MAC filter table.
> 
> 

-- 
MST

  reply	other threads:[~2009-06-06 20:49 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-05 20:46 [Qemu-devel] [PATCH 0/7] virtio-net: Filter cleanup/improvements Alex Williamson
2009-06-05 20:46 ` [Qemu-devel] [PATCH 1/7] virtio-net: Add version_id 7 placeholder for vnet header support Alex Williamson
2009-06-05 20:46 ` [Qemu-devel] [PATCH 2/7] virtio-net: Use a byte to store RX mode flags Alex Williamson
2009-06-05 20:47 ` [Qemu-devel] [PATCH 3/7] virtio-net: reorganize receive_filter() Alex Williamson
2009-06-05 20:47 ` [Qemu-devel] [PATCH 4/7] virtio-net: Fix MAC filter overflow handling Alex Williamson
2009-06-05 20:47 ` [Qemu-devel] [PATCH 5/7] virtio-net: MAC filter optimization Alex Williamson
2009-06-05 20:47 ` [Qemu-devel] [PATCH 6/7] virtio-net: Add new RX filter controls Alex Williamson
2009-06-06 20:48   ` Michael S. Tsirkin [this message]
2009-06-08 19:01     ` Alex Williamson
2009-06-08 19:18       ` Anthony Liguori
2009-06-08 19:29         ` Daniel P. Berrange
2009-06-08 21:03           ` Anthony Liguori
2009-06-09  9:57             ` Daniel P. Berrange
2009-06-09 15:00               ` Jamie Lokier
2009-06-09 15:42                 ` [Qemu-devel] " Jan Kiszka
2009-06-09 23:50                   ` Jamie Lokier
2009-06-10  8:46                   ` Michael S. Tsirkin
2009-06-10  8:58                     ` Jan Kiszka
2009-06-10  9:07                       ` Michael S. Tsirkin
2009-06-10  9:13                         ` Gleb Natapov
2009-06-10  9:17                           ` Michael S. Tsirkin
2009-06-10  9:22                             ` Gleb Natapov
2009-06-10  9:35                               ` Michael S. Tsirkin
2009-06-08 20:18         ` [Qemu-devel] " Alex Williamson
2009-06-05 20:47 ` [Qemu-devel] [PATCH 7/7] virtio-net: Increase filter and control limits Alex Williamson
2009-06-06 20:44   ` Michael S. Tsirkin
2009-06-08 18:49     ` Alex Williamson
2009-06-09 19:25 ` [Qemu-devel] [PATCH 0/7] virtio-net: Filter cleanup/improvements Mark McLoughlin
2009-06-09 21:08   ` Alex Williamson
2009-06-10  6:51   ` Rusty Russell
2009-06-10 20:43     ` Alex Williamson
2009-06-12 17:07     ` Mark McLoughlin
2009-06-12 19:19       ` Alex Williamson

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=20090606204845.GC26877@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.williamson@hp.com \
    --cc=qemu-devel@nongnu.org \
    /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 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).