From: Ben Hutchings <bhutchings@solarflare.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [RFC 1/7] netdev: add standardized irq naming function
Date: Tue, 21 Jun 2011 19:07:41 +0100 [thread overview]
Message-ID: <1308679661.2743.42.camel@bwh-desktop> (raw)
In-Reply-To: <20110621170658.395370414@vyatta.com>
On Tue, 2011-06-21 at 10:05 -0700, Stephen Hemminger wrote:
> To force driver developers to use a standard convention for naming
> network device IRQ's, provide a standardized method for creating
> the name.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
>
> --- a/include/linux/netdevice.h 2011-06-21 08:58:32.207953328 -0700
> +++ b/include/linux/netdevice.h 2011-06-21 09:12:12.155952869 -0700
> @@ -2631,6 +2631,46 @@ static inline const char *netdev_name(co
> return dev->name;
> }
>
> +/* function bits for netdev_irqname */
> +#define NETIF_IRQ_TX 1
> +#define NETIF_IRQ_RX 2
> +#define NETIF_IRQ_TXRX 3
> +#define NETIF_IRQ_OTHER 0 /* none of the above */
There can be multiple 'other' IRQs in which case they will need their
own suffixes.
Also: 'netdev' and 'NETIF'? We are terribly inconsistent about this but
we could at least make this single change self-consistent. :-)
> +/**
> + * netdev_irqname - generate name for irq
> + * @buf: space to store result
> + * @buflen: sizeof buf
> + * @dev: network device
> + * @queue: assoctiated network queue
Queue index.
> + * @function: function of irq
> + *
> + * Format a IRQ name according to standard convention to be passed
> + * to request_irq().
> + */
> +static inline const char *netdev_irqname(char *buf, size_t buflen,
> + const struct net_device *dev,
> + unsigned queue,
> + unsigned function)
Might be worth making this a little more generic as storage devices are
also going multiqueue in a similar way.
> +{
> + switch (function) {
> + case NETIF_IRQ_TX:
> + snprintf(buf, buflen, "%s-tx-%u", dev->name, queue);
> + break;
> + case NETIF_IRQ_RX:
> + snprintf(buf, buflen, "%s-rx-%u", dev->name, queue);
> + break;
> + case NETIF_IRQ_TXRX:
> + snprintf(buf, buflen, "%s-%u", dev->name, queue);
> + break;
> + default:
> + snprintf(buf, buflen, "%s", dev->name);
> + }
> +
> + return buf;
> +}
So perhaps something like:
/* kernel/irq/manage.c */
const char *irq_name(char *buf, size_t buflen, const char *base_name,
int index, const char *type)
{
if (type) {
if (index >= 0)
snprintf(buf, buflen, "%s-%s-%d", base_name, type, index);
else
snprintf(buf, buflen, "%s-%s", base_name, type);
} else {
if (index >= 0)
snprintf(buf, buflen, "%s-%d", base_name, index);
else
strlcpy(buf, base_name, buflen);
}
return buf;
}
/* include/linux/interrupt.h */
#define IRQ_NAME_NO_INDEX (-1)
/* include/linux/netdevice.h */
/* IRQ type name for netdev_irqname */
#define NETDEV_IRQ_TYPE_TX "tx"
#define NETDEV_IRQ_TYPE_RX "rx"
#define NETDEV_IRQ_TYPE_TXRX NULL
/**
* netdev_irqname - generate name for irq
* @buf: space to store result
* @buflen: sizeof buf
* @dev: network device
* @index: network queue index
* @type: type of IRQ
*
* Format a IRQ name according to standard convention to be passed
* to request_irq().
*/
static inline const char *netdev_irqname(char *buf, size_t buflen,
const struct net_device *dev,
int index, const char *type)
{
return irq_name(buf, buflen, dev->name, index, type);
}
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
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:[~2011-06-21 18:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-21 17:05 [RFC 0/7] network device irq naming Stephen Hemminger
2011-06-21 17:05 ` [RFC 1/7] netdev: add standardized irq naming function Stephen Hemminger
2011-06-21 17:30 ` Michał Mirosław
2011-06-21 17:48 ` Ben Hutchings
2011-06-21 17:56 ` Stephen Hemminger
2011-06-21 18:07 ` Ben Hutchings [this message]
2011-06-21 17:05 ` [RFC 2/7] igb: use netdev_irqname Stephen Hemminger
2011-06-21 17:05 ` [RFC 3/7] ixgbe: " Stephen Hemminger
2011-06-21 17:05 ` [RFC 4/7] benet: use irq naming standard Stephen Hemminger
2011-06-21 17:05 ` [RFC 5/7] bnx2: use netdev_irqname Stephen Hemminger
2011-06-21 18:11 ` Ben Hutchings
2011-06-21 18:17 ` Stephen Hemminger
2011-06-21 18:42 ` Ben Hutchings
2011-06-21 17:05 ` [RFC 6/7] niu: " Stephen Hemminger
2011-06-21 17:05 ` [RFC 7/7] netxen: " Stephen Hemminger
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=1308679661.2743.42.camel@bwh-desktop \
--to=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.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 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).