qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <weil@mail.berlios.de>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] eepro100: Add support for multiple individual addresses (multiple IA)
Date: Sun, 03 Oct 2010 12:11:39 +0200	[thread overview]
Message-ID: <4CA856DB.2070805@mail.berlios.de> (raw)
In-Reply-To: <20101003095653.GA16313@redhat.com>

Am 03.10.2010 11:56, schrieb Michael S. Tsirkin:
> On Wed, Sep 29, 2010 at 10:30:10PM +0200, Edgar E. Iglesias wrote:
>> On Wed, Sep 29, 2010 at 09:59:55PM +0200, Stefan Weil wrote:
>>> I reviewed the latest sources of Linux, FreeBSD and NetBSD.
>>> They all reset the multiple IA bit (multi_ia in BSD) to zero,
>>> but I did not find code which sets this bit to one
>>> (like it is done by some routers).
>>>
>>> Running Windows guests also did not set this bit.
>>>
>>> Intel's Open Source Software Developer Manual does not
>>> give much information on the semantics related to this bit,
>>> so I had to guess how it works. The guess was good enough
>>> to make the router emulation work.
>>>
>>>
>>> Related changes in this patch:
>>> * Update naming and documentation of the internal hash register.
>>> It is not limited to multicast, but also used for multiple IA.
>>> * Dump complete configuration register when debug traces are enabled.
>>> * Debug output when multiple IA bit is set during CmdConfigure.
>>> * Debug output when frames are received because multiple IA bit is set,
>>> or when they are ignored although it is set.
>>>
>>> Cc: Michael S. Tsirkin <mst@redhat.com>
>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>> ---
>>> hw/eepro100.c | 30 +++++++++++++++++++++---------
>>> 1 files changed, 21 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/hw/eepro100.c b/hw/eepro100.c
>>> index 2b75c8f..5f6dcb6 100644
>>> --- a/hw/eepro100.c
>>> +++ b/hw/eepro100.c
>>> @@ -219,7 +219,8 @@ typedef enum {
>>>
>>> typedef struct {
>>> PCIDevice dev;
>>> - uint8_t mult[8]; /* multicast mask array */
>>> + /* Hash register (multicast mask array, multiple individual 
>>> addresses). */
>>> + uint8_t mult[8];
>>
>>
>> Nitpick:
>> It seems to me like if mult is only used internally. If so, why not
>> represent the hash filter with an uint64_t?
>>
>> Then you can replace the current memsets with ->mult = 0 and simplify
>> the match logic.
>>
>>
>>> int mmio_index;
>>> NICState *nic;
>>> NICConf conf;
>>> @@ -599,7 +600,7 @@ static void nic_reset(void *opaque)
>>> {
>>> EEPRO100State *s = opaque;
>>> TRACE(OTHER, logout("%p\n", s));
>>> - /* TODO: Clearing of multicast table for selective reset, too? */
>>> + /* TODO: Clearing of hash register for selective reset, too? */
>>> memset(&s->mult[0], 0, sizeof(s->mult));
>>
>> e.g:
>>
>> s->mult = 0;
>>
>>> nic_selective_reset(s);
>>> }
>>> @@ -851,7 +852,14 @@ static void action_command(EEPRO100State *s)
>>> case CmdConfigure:
>>> cpu_physical_memory_read(s->cb_address + 8, &s->configuration[0],
>>> sizeof(s->configuration));
>>> - TRACE(OTHER, logout("configuration: %s\n", 
>>> nic_dump(&s->configuration[0], 16)));
>>> + TRACE(OTHER, logout("configuration: %s\n",
>>> + nic_dump(&s->configuration[0], 16)));
>>> + TRACE(OTHER, logout("configuration: %s\n",
>>> + nic_dump(&s->configuration[16],
>>> + ARRAY_SIZE(s->configuration) - 16)));
>>> + if (s->configuration[20] & BIT(6)) {
>>> + TRACE(OTHER, logout("Multiple IA bit\n"));
>>> + }
>>> break;
>>> case CmdMulticastList:
>>> set_multicast_list(s);
>>> @@ -1647,12 +1655,6 @@ static ssize_t nic_receive(VLANClientState 
>>> *nc, const uint8_t * buf, size_t size
>>> static const uint8_t broadcast_macaddr[6] =
>>> { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
>>>
>>> - /* TODO: check multiple IA bit. */
>>> - if (s->configuration[20] & BIT(6)) {
>>> - missing("Multiple IA bit");
>>> - return -1;
>>> - }
>>> -
>>> if (s->configuration[8] & 0x80) {
>>> /* CSMA is disabled. */
>>> logout("%p received while CSMA is disabled\n", s);
>>> @@ -1702,6 +1704,16 @@ static ssize_t nic_receive(VLANClientState 
>>> *nc, const uint8_t * buf, size_t size
>>> /* Promiscuous: receive all. */
>>> TRACE(RXTX, logout("%p received frame in promiscuous mode, 
>>> len=%zu\n", s, size));
>>> rfd_status |= 0x0004;
>>> + } else if (s->configuration[20] & BIT(6)) {
>>> + /* Multiple IA bit set. */
>>> + unsigned mcast_idx = compute_mcast_idx(buf);
>>> + assert(mcast_idx < 64);
>>> + if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) {
>>
>> e.g:
>> if (s->mult & (1 << (mcast_idx & 63))) {
>>
>> Cheers
>
> This 1 must really be 1ULL, otherwise we get an int shifted by a value 
> > 31,
> which triggers undefined behaviour.


Hello Michael,

that's correct. But there is no urgent need to switch to Edgar's code,
and the current code is ok.

Could you please add my patch to your pci patch queue?
It might be applied to the stable branches, too.

Thanks,
Stefan

  reply	other threads:[~2010-10-03 10:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-25 19:11 [Qemu-devel] eepro100 multicast Dunc
2010-09-29 19:03 ` Stefan Weil
2010-09-29 19:59   ` [Qemu-devel] [PATCH] eepro100: Add support for multiple individual addresses (multiple IA) Stefan Weil
2010-09-29 20:30     ` Edgar E. Iglesias
2010-09-30 16:45       ` Stefan Weil
2010-09-30 17:04         ` Edgar E. Iglesias
2010-10-03  9:56       ` Michael S. Tsirkin
2010-10-03 10:11         ` Stefan Weil [this message]
2010-10-03 11:16           ` Michael S. Tsirkin
2010-10-03 11:47             ` Stefan Weil
2010-10-03 13:20               ` Michael S. Tsirkin
2010-10-04 12:57                 ` Stefan Weil
2010-10-04 12:53                   ` Michael S. Tsirkin

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=4CA856DB.2070805@mail.berlios.de \
    --to=weil@mail.berlios.de \
    --cc=edgar.iglesias@gmail.com \
    --cc=mst@redhat.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).