Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ioctl

47 views
Skip to first unread message

cfk

unread,
Oct 17, 2003, 4:34:21 PM10/17/03
to
I'm working on a project developing a ethernet driver and I have a need to
read/write some private ioctls like SIOCDEVPRIVATE. What I am puzzling over
is how to go about obtaining a pointer to the net_device structure of eth0,
1 or 2 so I can get to where I can call into the driver and read/write those
ioctls.

Would anyone have any hints, kinks or URL's they might be willing to share.

Charles


wb

unread,
Oct 18, 2003, 11:24:44 AM10/18/03
to
cfk wrote:

There are plenty of examples in existing drivers.

See: /usr/src/linux/Documentation/networking/netdevices.txt ,
net_modules.txt ....

Do you use a source viewer like cscope ? or tags in vi ?
It helps to be able to peruse other drivers.

cfk

unread,
Oct 18, 2003, 12:58:18 PM10/18/03
to
Dear wb:
Thank you for replying. I have read net_modules.txt and some of its
cousins. Its not the examples of how the driver works that puzzles me, but
how to communicate with the do_ioctl in the driver that do puzzle me.Let me
tell you a bit more about where I am in hopes you can tell me where to go.

I have a prototype driver based on Mr. Becker's eepro100.c. It does
insmod/rmmod. I can also call ifconfig and iwconfig while it is loaded and
see some of the elements of net_device that I have set in my driver. I can
see how to change the source to add ioctl support to the driver and
communicate easily with the underlying custom chip and I am working on that.

There are some parameters that I need to set and query that are above
and beyond iwconfig/ifconfig. For that, I need to create a custom userspace
program to read/write hardware registers as we flesh out this wireless
design.

Towards that end, I am trying to understand how to communicate with my
prototype driver from userspace and a private IOCTL seems the most
straighforward. I can see some hints of that in ifconfig.c and its cousin
interface.c, but I suspect it will be a while before I can come to a grok.
What I am really looking for is a way to accelerate that effort with another
reference that will let me avoid a week inside the ifconfig sources
answering the all-important questions "why" and "how".

With that said, I leave myself open to a suggestion of where to go.

With highest respects for this group, Charles Krinke

p.s. I did read Rubini's "Linux Device Drivers" second edition and Beck's
"Linux Kernel Internals" before I made the first post yesterday.


"wb" <dead_...@nospam.com> wrote in message
news:3F915DF1...@nospam.com...

wb

unread,
Oct 20, 2003, 3:09:27 PM10/20/03
to
For one thing, SIOCDEVPRIVATE is simply a starting integer
number that means any thing you want it to be
within the context of you driver.

If you want to see what ioctls's are being sent down
to the eeproc100, use strace :

strace ifconfig eth0

Basically, ifconfig does a

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4 to eth0, then

ioctl(4, 0x8913, 0xbffff730) = 0

You can also comminicate to your driver via a
private /proc/ name too :

register a unique file within /proc

/proc/my_special_device_nic

open("/proc/my_device_nic")
ioctl ( fd, 0xABCD, & my_data_structure) ;

You can avoid the PRIVATE crap altogether.

Sometimes you just have to bite the bullet and kill
a week learning it. "Open Source" doesn't always mean
completely free as management assumes .

//

cfk

unread,
Oct 20, 2003, 8:51:54 PM10/20/03
to
Dear WB:
Thank you for the pointers. I was not intending to mean that I dont
welcome learning. It is one of my greatest pleasures. Its just that I got a
little stuck in ifconfig.c. I am certainly jumping into it and others with
both feet as I figure out how to talk with this hardware. I have gotten a
modified eepro100.c to insmod/rmmod with our unique chip. Now, I need to get
access to some of the other registers. Its basically a wireless networking
chip so it has power output and signal strength registers also. It will be
interesting to get into iwconfig.c after I analyze more of ifconfig.

Again, I thank you for your help, and I'll be back sometime later after
I do some studying.

Charles Krinke http://home.pacbell.net/cfk

0 new messages