netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jpirko@redhat.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: eric.dumazet@gmail.com, e1000-devel@lists.sourceforge.net,
	netdev@vger.kernel.org, bruce.w.allan@intel.com,
	jesse.brandeburg@intel.com, mchehab@infradead.org,
	john.ronciak@intel.com, jeffrey.t.kirsher@intel.com,
	davem@davemloft.net, linux-media@vger.kernel.org
Subject: Re: [PATCH net-next-2.6 1/4] net: introduce mc list helpers
Date: Thu, 29 Oct 2009 16:19:49 +0100	[thread overview]
Message-ID: <20091029151949.GH2877@psychotron.lab.eng.brq.redhat.com> (raw)
In-Reply-To: <1256221112.2785.13.camel@achroite>

Thu, Oct 22, 2009 at 04:18:32PM CEST, bhutchings@solarflare.com wrote:
>On Thu, 2009-10-22 at 15:52 +0200, Jiri Pirko wrote:
>> This helpers should be used by network drivers to access to netdev
>> multicast lists.
>[...]
>> +static inline void netdev_mc_walk(struct net_device *dev,
>> +				  void (*func)(void *, unsigned char *),
>> +				  void *data)
>> +{
>> +	struct dev_addr_list *mclist;
>> +	int i;
>> +
>> +	for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
>> +	     i++, mclist = mclist->next)
>> +		func(data, mclist->dmi_addr);
>> +}
>[...]
>
>We usually implement iteration as macros so that any context doesn't
>have to be squeezed through a single untyped (void *) variable.  A macro
>for this would look something like:
>
>#define netdev_for_each_mc_addr(dev, addr)						\
>	for (addr = (dev)->mc_list ? (dev)->mc_list->dmi_addr : NULL;			\
>	     addr;									\
>	     addr = (container_of(addr, struct dev_addr_list, dmi_addr)->next ?		\
>		     container_of(addr, struct dev_addr_list, dmi_addr)->next->dmi_addr : \
>		     NULL))
>
>Once you change the list type this can presumably be made less ugly.

Looking at this, I'm not sure how to deal with this macro once we need to
convert it to work with list_head. I see two options:

1) traverse through the list by hand in this macro (ugly)
2) introduce something like "list_for_each_struct_entry" which takes pointer of
   the structure member as a cursor. Then netdev_for_each_mc_addr would be just
   wrap-up of this.

What do you think?

Thanks

Jirka
>
>Ben.
>
>-- 
>Ben Hutchings, Senior Software Engineer, Solarflare Communications
>Not speaking for my employer; that's the marketing department's job.
>They asked us to note that Solarflare product names are trademarked.
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel

  parent reply	other threads:[~2009-10-29 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22 13:51 [PATCH net-next-2.6 0/4] net: change the way mc_list is accessed Jiri Pirko
2009-10-22 13:52 ` [PATCH net-next-2.6 1/4] net: introduce mc list helpers Jiri Pirko
2009-10-22 14:18   ` Ben Hutchings
2009-10-22 14:28     ` Jiri Pirko
2009-10-29 15:19     ` Jiri Pirko [this message]
2009-10-22 13:53 ` [PATCH net-next-2.6 2/4] 8139too: use mc helpers to access multicast list Jiri Pirko
2009-10-22 13:54 ` [PATCH net-next-2.6 3/4] e1000e: " Jiri Pirko
2009-10-22 13:54 ` [PATCH net-next-2.6 0/4] net: change the way mc_list is accessed Jiri Pirko
2009-10-22 13:56   ` Jiri Pirko
2009-10-22 13:57 ` [PATCH net-next-2.6 4/4] dvb: dvb_net: use mc helpers to access multicast list Jiri Pirko

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=20091029151949.GH2877@psychotron.lab.eng.brq.redhat.com \
    --to=jpirko@redhat.com \
    --cc=bhutchings@solarflare.com \
    --cc=bruce.w.allan@intel.com \
    --cc=davem@davemloft.net \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=eric.dumazet@gmail.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=john.ronciak@intel.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=netdev@vger.kernel.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).