All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] rfc: print mac addr
@ 2005-12-06 10:49 walter harms
  2005-12-06 11:11 ` Paolo Teti
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: walter harms @ 2005-12-06 10:49 UTC (permalink / raw)
  To: kernel-janitors

hi list,

must (if not all) net drivers contain something like this to print a mac 
addr:

for (i = 0; i < 6; i++)
   printk("%2.2x%c", dev->dev_addr[i],i = 5 ? '\n' : ':');

I think it would be usefull to add a helper function.
simple question:
1. is there such a function ?
2. where to add ? each driver ? or is there a common place i do not know 
about ?

re,
  walter

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] rfc: print mac addr
  2005-12-06 10:49 [KJ] rfc: print mac addr walter harms
@ 2005-12-06 11:11 ` Paolo Teti
  2005-12-06 17:03 ` Randy.Dunlap
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Teti @ 2005-12-06 11:11 UTC (permalink / raw)
  To: kernel-janitors

Hi walter

>
> for (i = 0; i < 6; i++)
>    printk("%2.2x%c", dev->dev_addr[i],i = 5 ? '\n' : ':');
>

1. Please post an example or the file name!

2. Are you sure that this portion of code isn't into a DEBUG block
(something like #ifdef DEBUG_xx)?

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] rfc: print mac addr
  2005-12-06 10:49 [KJ] rfc: print mac addr walter harms
  2005-12-06 11:11 ` Paolo Teti
@ 2005-12-06 17:03 ` Randy.Dunlap
  2005-12-06 17:11 ` walter harms
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Randy.Dunlap @ 2005-12-06 17:03 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: TEXT/PLAIN, Size: 989 bytes --]

On Tue, 6 Dec 2005, walter harms wrote:

> hi list,
>
> must (if not all) net drivers contain something like this to print a mac
> addr:

If that's so, then yes, a helper function is a good idea IMO.

> for (i = 0; i < 6; i++)
>    printk("%2.2x%c", dev->dev_addr[i],i == 5 ? '\n' : ':');
>
> I think it would be usefull to add a helper function.
> simple question:
> 1. is there such a function ?

If your claim that most drivers do it on their own, then I hope/guess
that there is not already such a helper function...
I don't see one in include/linux/*.h.

> 2. where to add ? each driver ? or is there a common place i do not know
> about ?

Either
(1) inline in include/linux/{if_ether.h or etherdevice.h or netdevice.h}
although I prefer one of the first two since this looks ethernet-specific
(due to the "i < 6").
And change the 6 to ETH_ALEN if this is for ethernet MAC addresses.
And put a space between comma and i:  ",i" should be ", i".

or
(2) in net/core/dev.c.

-- 
~Randy

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] rfc: print mac addr
  2005-12-06 10:49 [KJ] rfc: print mac addr walter harms
  2005-12-06 11:11 ` Paolo Teti
  2005-12-06 17:03 ` Randy.Dunlap
@ 2005-12-06 17:11 ` walter harms
  2005-12-06 17:15 ` Roland Dreier
  2005-12-07  1:07 ` Randy.Dunlap
  4 siblings, 0 replies; 6+ messages in thread
From: walter harms @ 2005-12-06 17:11 UTC (permalink / raw)
  To: kernel-janitors



Paolo Teti wrote:
> Hi walter
> 
>> for (i = 0; i < 6; i++)
>>    printk("%2.2x%c", dev->dev_addr[i],i = 5 ? '\n' : ':');
>>
> 
> 1. Please post an example or the file name!

cd linux/drivers/net
grep dev_addr *.c | grep printk


> 
> 2. Are you sure that this portion of code isn't into a DEBUG block
> (something like #ifdef DEBUG_xx)?

i did not check every file but looked into a few and the pattern is all 
the same. maybe some of them are inside a #ifdef debug the few i looked 
are not.

i know gregKH added a few dev helper macros but i can not find them 
anymore. The idea is to provide a function like:

void print_mac(struct net_device *dev)
{
    int i;
    printk(KERN_INFO);
    for (i = 0; i < MAX_ADDR_LEN; i++)
         printk("%2.2x%c", dev->dev_addr[i],i = (MAX_ADDR_LEN-1) ? '\n' 
: ':');

}
may you like to return a string ?

re,
  walter



_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] rfc: print mac addr
  2005-12-06 10:49 [KJ] rfc: print mac addr walter harms
                   ` (2 preceding siblings ...)
  2005-12-06 17:11 ` walter harms
@ 2005-12-06 17:15 ` Roland Dreier
  2005-12-07  1:07 ` Randy.Dunlap
  4 siblings, 0 replies; 6+ messages in thread
From: Roland Dreier @ 2005-12-06 17:15 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

 > (1) inline in include/linux/{if_ether.h or etherdevice.h or netdevice.h}
 > although I prefer one of the first two since this looks ethernet-specific
 > (due to the "i < 6").
 > And change the 6 to ETH_ALEN if this is for ethernet MAC addresses.
 > And put a space between comma and i:  ",i" should be ", i".

 > or
 > (2) in net/core/dev.c.

I would definitely pick the second option.  There's no reason like
performance for such a helper to be an inline function, so we should
save .text by moving it out of line.

 - R.


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] rfc: print mac addr
  2005-12-06 10:49 [KJ] rfc: print mac addr walter harms
                   ` (3 preceding siblings ...)
  2005-12-06 17:15 ` Roland Dreier
@ 2005-12-07  1:07 ` Randy.Dunlap
  4 siblings, 0 replies; 6+ messages in thread
From: Randy.Dunlap @ 2005-12-07  1:07 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

On Tue, 06 Dec 2005 18:11:48 +0100 walter harms wrote:

> Paolo Teti wrote:
> > Hi walter
> > 
> >> for (i = 0; i < 6; i++)
> >>    printk("%2.2x%c", dev->dev_addr[i],i == 5 ? '\n' : ':');
> >>
> > 
> > 1. Please post an example or the file name!
> 
> cd linux/drivers/net
> grep dev_addr *.c | grep printk
> 
> > 
> > 2. Are you sure that this portion of code isn't into a DEBUG block
> > (something like #ifdef DEBUG_xx)?
> 
> i did not check every file but looked into a few and the pattern is all 
> the same. maybe some of them are inside a #ifdef debug the few i looked 
> are not.
> 
> i know gregKH added a few dev helper macros but i can not find them 
> anymore. The idea is to provide a function like:

see include/linux/device.h: dev_printk() and friends.

> void print_mac(struct net_device *dev)
> {
>     int i;
>     printk(KERN_INFO);
>     for (i = 0; i < MAX_ADDR_LEN; i++)
>          printk("%2.2x%c", dev->dev_addr[i],i == (MAX_ADDR_LEN-1) ? '\n' 
> : ':');
> 
> }
> may you like to return a string ?

I would just print it (like you did) instead of return a string
(I think).

MAX_ADDR_LEN may want to be a variable in this function so that
differing MAC address lengths can be supported.
And put a space between ",i".

Thanks.
---
~Randy

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-12-07  1:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-06 10:49 [KJ] rfc: print mac addr walter harms
2005-12-06 11:11 ` Paolo Teti
2005-12-06 17:03 ` Randy.Dunlap
2005-12-06 17:11 ` walter harms
2005-12-06 17:15 ` Roland Dreier
2005-12-07  1:07 ` Randy.Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.