From: Ben Hutchings <bhutchings@solarflare•com>
To: Jiri Pirko <jpirko@redhat•com>
Cc: netdev@vger•kernel.org, davem@davemloft•net,
eric.dumazet@gmail•com, jeffrey.t.kirsher@intel•com,
jesse.brandeburg@intel•com, bruce.w.allan@intel•com,
peter.p.waskiewicz.jr@intel•com, john.ronciak@intel•com,
e1000-devel@lists•sourceforge.net, mchehab@infradead•org,
linux-media@vger•kernel.org
Subject: Re: [PATCH net-next-2.6 1/4] net: introduce mc list helpers
Date: Thu, 22 Oct 2009 15:18:32 +0100 [thread overview]
Message-ID: <1256221112.2785.13.camel@achroite> (raw)
In-Reply-To: <20091022135220.GD2868@psychotron.lab.eng.brq.redhat.com>
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.
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.
next prev parent reply other threads:[~2009-10-22 14:18 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 [this message]
2009-10-22 14:28 ` Jiri Pirko
2009-10-29 15:19 ` Jiri Pirko
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=1256221112.2785.13.camel@achroite \
--to=bhutchings@solarflare$(echo .)com \
--cc=bruce.w.allan@intel$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=e1000-devel@lists$(echo .)sourceforge.net \
--cc=eric.dumazet@gmail$(echo .)com \
--cc=jeffrey.t.kirsher@intel$(echo .)com \
--cc=jesse.brandeburg@intel$(echo .)com \
--cc=john.ronciak@intel$(echo .)com \
--cc=jpirko@redhat$(echo .)com \
--cc=linux-media@vger$(echo .)kernel.org \
--cc=mchehab@infradead$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=peter.p.waskiewicz.jr@intel$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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