* How to grab a block of binary data w/out using ioctls?
@ 2006-10-24 0:44 Ben Greear
2006-10-24 4:54 ` Randy Dunlap
2006-10-25 12:51 ` Hagen Paul Pfeifer
0 siblings, 2 replies; 13+ messages in thread
From: Ben Greear @ 2006-10-24 0:44 UTC (permalink / raw)
To: NetDev
Since IOCTLs are out of favor these days, what would be
a preferred way to get a block of binary data out of the
kernel?
I just want to grab a stats structure (well-aligned 32 and 64-bit counters
and fixed-length strings) for a pktgen interface.
Can you do this with seq-files somehow?
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-24 0:44 How to grab a block of binary data w/out using ioctls? Ben Greear
@ 2006-10-24 4:54 ` Randy Dunlap
2006-10-24 5:00 ` Jeff Garzik
2006-10-25 12:51 ` Hagen Paul Pfeifer
1 sibling, 1 reply; 13+ messages in thread
From: Randy Dunlap @ 2006-10-24 4:54 UTC (permalink / raw)
To: Ben Greear; +Cc: NetDev
On Mon, 23 Oct 2006 17:44:24 -0700 Ben Greear wrote:
> Since IOCTLs are out of favor these days, what would be
> a preferred way to get a block of binary data out of the
> kernel?
>
> I just want to grab a stats structure (well-aligned 32 and 64-bit counters
> and fixed-length strings) for a pktgen interface.
>
> Can you do this with seq-files somehow?
seq-files just use printk() for text output. Not well-suited
to binary output.
Similarly, sysfs is desirable in some circumstances, but
not for blocks of binary data.
ioctls or netlink or debugfs or relay output (see how blktrace
uses relay output) are your choices (I may have missed some. :)
ioctls can be OK for some purposes. If you want to avoid them,
try debugfs or relay. (I haven't looked at debugfs very much;
it may be more text-oriented also...)
---
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-24 4:54 ` Randy Dunlap
@ 2006-10-24 5:00 ` Jeff Garzik
2006-10-24 5:04 ` Randy.Dunlap
2006-10-25 2:25 ` Ben Greear
0 siblings, 2 replies; 13+ messages in thread
From: Jeff Garzik @ 2006-10-24 5:00 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Ben Greear, NetDev
On Mon, Oct 23, 2006 at 09:54:48PM -0700, Randy Dunlap wrote:
> Similarly, sysfs is desirable in some circumstances, but
> not for blocks of binary data.
sysfs specifically has APIs for binary data...
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-24 5:00 ` Jeff Garzik
@ 2006-10-24 5:04 ` Randy.Dunlap
2006-10-25 2:25 ` Ben Greear
1 sibling, 0 replies; 13+ messages in thread
From: Randy.Dunlap @ 2006-10-24 5:04 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Ben Greear, NetDev
Jeff Garzik wrote:
> On Mon, Oct 23, 2006 at 09:54:48PM -0700, Randy Dunlap wrote:
>> Similarly, sysfs is desirable in some circumstances, but
>> not for blocks of binary data.
>
> sysfs specifically has APIs for binary data...
Ack that, sorry about that.
--
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-24 5:00 ` Jeff Garzik
2006-10-24 5:04 ` Randy.Dunlap
@ 2006-10-25 2:25 ` Ben Greear
2006-10-25 2:47 ` Jeff Garzik
1 sibling, 1 reply; 13+ messages in thread
From: Ben Greear @ 2006-10-25 2:25 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Randy Dunlap, NetDev
Jeff Garzik wrote:
> On Mon, Oct 23, 2006 at 09:54:48PM -0700, Randy Dunlap wrote:
>
>> Similarly, sysfs is desirable in some circumstances, but
>> not for blocks of binary data.
>>
>
> sysfs specifically has APIs for binary data...
>
From reading the Documentation/filesystems/sysfs.txt, it seems like
it is not recommended that one use sysfs for anything other than
very simple (and single) attributes.
If you know of a piece of code that actually passes back a struct or
other binary blob of data, please point me to it so I can learn from it.
Thanks,
Ben
> Jeff
>
>
>
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-25 2:25 ` Ben Greear
@ 2006-10-25 2:47 ` Jeff Garzik
2006-10-25 4:35 ` Randy Dunlap
0 siblings, 1 reply; 13+ messages in thread
From: Jeff Garzik @ 2006-10-25 2:47 UTC (permalink / raw)
To: Ben Greear; +Cc: Randy Dunlap, NetDev
On Tue, Oct 24, 2006 at 07:25:48PM -0700, Ben Greear wrote:
> From reading the Documentation/filesystems/sysfs.txt, it seems like
> it is not recommended that one use sysfs for anything other than
> very simple (and single) attributes.
>
> If you know of a piece of code that actually passes back a struct or
> other binary blob of data, please point me to it so I can learn from it.
Please grep for sysfs_create_bin_file, you will find plenty of examples.
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-25 2:47 ` Jeff Garzik
@ 2006-10-25 4:35 ` Randy Dunlap
2006-10-25 4:46 ` Jeff Garzik
0 siblings, 1 reply; 13+ messages in thread
From: Randy Dunlap @ 2006-10-25 4:35 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Ben Greear, NetDev
On Tue, 24 Oct 2006 22:47:18 -0400 Jeff Garzik wrote:
> On Tue, Oct 24, 2006 at 07:25:48PM -0700, Ben Greear wrote:
> > From reading the Documentation/filesystems/sysfs.txt, it seems like
> > it is not recommended that one use sysfs for anything other than
> > very simple (and single) attributes.
> >
> > If you know of a piece of code that actually passes back a struct or
> > other binary blob of data, please point me to it so I can learn from it.
>
> Please grep for sysfs_create_bin_file, you will find plenty of examples.
Hm, I thought that sysfs binary files were supposed to be
for "transparent" blobs of data, not for structured data.
E.g., a "firmware" blob would be OK.
And I'm looking at current users. ISTM that this one:
arch/ppc/syslib/mv64x60.c:2443: sysfs_create_bin_file(&mv64xxx_device.dev.kobj, &mv64xxx_hs_reg_attr);
in its sysfs read function returns a string (binary data converted
to a string) instead of returning binary data. Or did I misread it?
or misunderstand sysfs binary data?
---
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-25 4:35 ` Randy Dunlap
@ 2006-10-25 4:46 ` Jeff Garzik
2006-10-25 4:52 ` Randy.Dunlap
2006-10-25 16:30 ` Ben Greear
0 siblings, 2 replies; 13+ messages in thread
From: Jeff Garzik @ 2006-10-25 4:46 UTC (permalink / raw)
To: Randy Dunlap; +Cc: Ben Greear, NetDev
On Tue, Oct 24, 2006 at 09:35:49PM -0700, Randy Dunlap wrote:
> >
> > Please grep for sysfs_create_bin_file, you will find plenty of examples.
>
> Hm, I thought that sysfs binary files were supposed to be
> for "transparent" blobs of data, not for structured data.
> E.g., a "firmware" blob would be OK.
Depends. Normally ASCII is greatly preferred, but passing in/out big
data structures can be a huge pain, thunking to/from ASCII.
> And I'm looking at current users. ISTM that this one:
>
> arch/ppc/syslib/mv64x60.c:2443: sysfs_create_bin_file(&mv64xxx_device.dev.kobj, &mv64xxx_hs_reg_attr);
>
> in its sysfs read function returns a string (binary data converted
> to a string) instead of returning binary data. Or did I misread it?
> or misunderstand sysfs binary data?
Yeah, that one shouldn't be using _bin_
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-25 4:46 ` Jeff Garzik
@ 2006-10-25 4:52 ` Randy.Dunlap
2006-10-25 5:01 ` Jeff Garzik
2006-10-25 16:30 ` Ben Greear
1 sibling, 1 reply; 13+ messages in thread
From: Randy.Dunlap @ 2006-10-25 4:52 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Ben Greear, NetDev
Jeff Garzik wrote:
> On Tue, Oct 24, 2006 at 09:35:49PM -0700, Randy Dunlap wrote:
>>> Please grep for sysfs_create_bin_file, you will find plenty of examples.
>> Hm, I thought that sysfs binary files were supposed to be
>> for "transparent" blobs of data, not for structured data.
>> E.g., a "firmware" blob would be OK.
>
> Depends. Normally ASCII is greatly preferred, but passing in/out big
> data structures can be a huge pain, thunking to/from ASCII.
>
>
>> And I'm looking at current users. ISTM that this one:
>>
>> arch/ppc/syslib/mv64x60.c:2443: sysfs_create_bin_file(&mv64xxx_device.dev.kobj, &mv64xxx_hs_reg_attr);
>>
>> in its sysfs read function returns a string (binary data converted
>> to a string) instead of returning binary data. Or did I misread it?
>> or misunderstand sysfs binary data?
>
> Yeah, that one shouldn't be using _bin_
Thanks. It's not the only one like that. Also these 3 uses are incorrect AFAICT:
./drivers/firmware/dell_rbu.c:721: rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
./drivers/firmware/dell_rbu.c:724: rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
./drivers/firmware/dell_rbu.c:727: rc = sysfs_create_bin_file(&rbu_device->dev.kobj,
--
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-25 4:52 ` Randy.Dunlap
@ 2006-10-25 5:01 ` Jeff Garzik
2006-10-25 5:07 ` Randy.Dunlap
0 siblings, 1 reply; 13+ messages in thread
From: Jeff Garzik @ 2006-10-25 5:01 UTC (permalink / raw)
To: Randy.Dunlap; +Cc: Ben Greear, NetDev
On Tue, Oct 24, 2006 at 09:52:15PM -0700, Randy.Dunlap wrote:
> Thanks. It's not the only one like that. Also these 3 uses are incorrect
> AFAICT:
>
> ./drivers/firmware/dell_rbu.c:721: rc =
> sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
this is ok
> ./drivers/firmware/dell_rbu.c:724: rc =
> sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
> ./drivers/firmware/dell_rbu.c:727: rc =
> sysfs_create_bin_file(&rbu_device->dev.kobj,
these appear to be incorrect
Jeff
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-25 5:01 ` Jeff Garzik
@ 2006-10-25 5:07 ` Randy.Dunlap
0 siblings, 0 replies; 13+ messages in thread
From: Randy.Dunlap @ 2006-10-25 5:07 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Ben Greear, NetDev
Jeff Garzik wrote:
> On Tue, Oct 24, 2006 at 09:52:15PM -0700, Randy.Dunlap wrote:
>> Thanks. It's not the only one like that. Also these 3 uses are incorrect
>> AFAICT:
>>
>> ./drivers/firmware/dell_rbu.c:721: rc =
>> sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
>
> this is ok
ack, thanks for looking.
>> ./drivers/firmware/dell_rbu.c:724: rc =
>> sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
>> ./drivers/firmware/dell_rbu.c:727: rc =
>> sysfs_create_bin_file(&rbu_device->dev.kobj,
>
> these appear to be incorrect
--
~Randy
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-24 0:44 How to grab a block of binary data w/out using ioctls? Ben Greear
2006-10-24 4:54 ` Randy Dunlap
@ 2006-10-25 12:51 ` Hagen Paul Pfeifer
1 sibling, 0 replies; 13+ messages in thread
From: Hagen Paul Pfeifer @ 2006-10-25 12:51 UTC (permalink / raw)
To: Ben Greear; +Cc: NetDev
* Ben Greear | 2006-10-23 17:44:24 [-0700]:
>Since IOCTLs are out of favor these days, what would be
>a preferred way to get a block of binary data out of the
>kernel?
I suggest netlink socket for that purpose! Netlink scales also well if the
amount of data "surprisedly" rise.
>Thanks,
>Ben
HGN
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to grab a block of binary data w/out using ioctls?
2006-10-25 4:46 ` Jeff Garzik
2006-10-25 4:52 ` Randy.Dunlap
@ 2006-10-25 16:30 ` Ben Greear
1 sibling, 0 replies; 13+ messages in thread
From: Ben Greear @ 2006-10-25 16:30 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Randy Dunlap, NetDev
Jeff Garzik wrote:
> On Tue, Oct 24, 2006 at 09:35:49PM -0700, Randy Dunlap wrote:
>
>>> Please grep for sysfs_create_bin_file, you will find plenty of examples.
>>>
>> Hm, I thought that sysfs binary files were supposed to be
>> for "transparent" blobs of data, not for structured data.
>> E.g., a "firmware" blob would be OK.
>>
>
> Depends. Normally ASCII is greatly preferred, but passing in/out big
> data structures can be a huge pain, thunking to/from ASCII.
>
This is my scenario exactly. It is also much easier to make sure the
data is
coherent if I can grab it all at once.
In my case, I'm wanting to add this to the pktgen module, for reporting
stats. But,
it seems sysfs is designed mostly for drivers with some sort of 'object'
behind it.
Would I need to create some faked out dummy object in order to use sysfs
with
pktgen?
I also notice there is already a /sys/modules/pktgen node in sysfs..is
there any easy way to
stick my binary file interface in that directory?
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2006-10-25 16:33 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-24 0:44 How to grab a block of binary data w/out using ioctls? Ben Greear
2006-10-24 4:54 ` Randy Dunlap
2006-10-24 5:00 ` Jeff Garzik
2006-10-24 5:04 ` Randy.Dunlap
2006-10-25 2:25 ` Ben Greear
2006-10-25 2:47 ` Jeff Garzik
2006-10-25 4:35 ` Randy Dunlap
2006-10-25 4:46 ` Jeff Garzik
2006-10-25 4:52 ` Randy.Dunlap
2006-10-25 5:01 ` Jeff Garzik
2006-10-25 5:07 ` Randy.Dunlap
2006-10-25 16:30 ` Ben Greear
2006-10-25 12:51 ` Hagen Paul Pfeifer
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).