Message ID | 20110621170658.395370414@vyatta.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
2011/6/21 Stephen Hemminger <shemminger@vyatta.com>: > To force driver developers to use a standard convention for naming > network device IRQ's, provide a standardized method for creating > the name. Can this be modified to track netdev renames? Best Regards, Michał Mirosław -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, 2011-06-21 at 19:30 +0200, Michał Mirosław wrote: > 2011/6/21 Stephen Hemminger <shemminger@vyatta.com>: > > To force driver developers to use a standard convention for naming > > network device IRQ's, provide a standardized method for creating > > the name. > > Can this be modified to track netdev renames? We should handle renames somehow. sfc currently uses a netdev notifier to update the names of its IRQs (and MTDs) but it might make more sense to add something to net_device_ops rather than having every driver receive notification for every device. Ben.
On Tue, 21 Jun 2011 18:48:55 +0100 Ben Hutchings <bhutchings@solarflare.com> wrote: > On Tue, 2011-06-21 at 19:30 +0200, Michał Mirosław wrote: > > 2011/6/21 Stephen Hemminger <shemminger@vyatta.com>: > > > To force driver developers to use a standard convention for naming > > > network device IRQ's, provide a standardized method for creating > > > the name. > > > > Can this be modified to track netdev renames? > > We should handle renames somehow. > > sfc currently uses a netdev notifier to update the names of its IRQs > (and MTDs) but it might make more sense to add something to > net_device_ops rather than having every driver receive notification for > every device. > > Ben. > Since renames are only allowed when netdevice is down. Renames do not need to be tracked if device registers irq in open handler. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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.
--- 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 */ + +/** + * netdev_irqname - generate name for irq + * @buf: space to store result + * @buflen: sizeof buf + * @dev: network device + * @queue: assoctiated network queue + * @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) +{ + 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; +} + + extern int netdev_printk(const char *level, const struct net_device *dev, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
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> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html