RE: Kernel module <-> user communication

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



steve_lustbader@hsgmed.com wrote:

 > I'd like to tie the user and kernel parts together more tightly than 
 >using ioctls if possible.  If I have to use ioctl, though, I will.  
 >How do I get a file descriptor to my device?  It's a network driver, 
 >not a char driver, so there's no /dev/foo entry.
 >
 > -Steve
 >
 > -----Original Message-----
 > From: Felipe W Damasio [mailto:felipewd@terra.com.br]
 > Sent: Friday, August 23, 2002 9:43 AM
 > To: LUSTBADER,STEVE (Non-A-hsgAndover,ex1)
 > Cc: kernelnewbies@nl.linux.org
 > Subject: Re: Kernel module <-> user communication
 >
 >
 > On Fri, 23 Aug 2002 10:21:15 -0600
 > "LUSTBADER,STEVE (Non-A-hsgAndover,ex1)" <steve_lustbader@hsgmed.com>
 > wrote:
 >
 > L> I'm trying to write a kernel network driver but I don't know how to
 > L> access it from a kernel space program.  I'd like to "export" a
 > L> function
 > L> from the driver that a user space program could call, but I'm not
 > L> sure
 > L> if that's possible.  For example, I'd like to be able to call
 > L> "do_something(args)" from a user space program that would make the
 > L> driver perform an action (writing to a device register, etc). 
 > L> This>  is
 > L> a very specialized device, so the user space program could/will be 
 > L> tied
 > L> very tightly to the driver.

Hello.
I have a book, i've read it completely. But didn't write any net_drv.
The book is [wehrle et al.] linux networkarchitecture (german version).
I also have a german copy of [Rubini/Corbet] & a german [Beck et al.]
linux kernelprogramming, but my [Rubini/Corbet] isn't even 1 month old.
So what i write now, isn't tested. Readers please correct me too, if i'm
wrong.


To write network drivers generally,
i'll now bring in a few things to mention.

generally:
register_chrdev(),
unregister_chrdev()
(or _blkdev() or filesystem)
struct file_operations (!)
task_structure and task_queue
spinlock_t and spin_lock(),
read/write-spinlocks and also
semaphore.
everything about the scheduler.
plus a little more i didn't remember or find :-).
+
kmalloc(), kfree(), kmem_..()
jiffies, struct timer_list
+
for your info-output to write netstats somewhere to:
struct proc_dir_entry
proc_register(), proc_unregister()
proc_mkdir(), create* & remove_proc..entry()
create_proc_info_entry() with function-argument.
a few functions for your systeminformations in the module.

for network packets specially, the socket buffer:
struct sk_buff (very essentially)
alloc_skb(), dev_alloc_skb(), skb_..()

for network devices, the net_device Interface:
struct net_device (very essentially)
(includes attributes and replaceable operationpointers)
use the functions *tata*
dev_open(dev) and dev_close(dev) !
dev_alloc(), dev_get...(), dev_load()
struct notifier_block
(un)register_netdevice_notifier()


to find or initialize networkadapters (hardware, not the device):
struct net_local
net_init(), net_probe() like
int __init netcard_probe*() or so, don't really know.

to USE network adapters, i think:
struct netdevice_stats
net_start_xmit(),
net_interrupt(),
net_tx(), net_rx(),
net_timeout(),
net_do_ioctl()

MORE:
allocation of systemressources:
request_,release_,check_region()
request_irq(), free_irq()
request_dma(),free_dma()

NOW WE WOULD CONTINUE with the TCP/IP ISO/OSI implementation.
There are A LOT OF structs and ops following in the next 20 chapters.
It's about the tcp/ip-protocolstack. I'll write them down, if you
request :-)

means,
There are a lot more structures and operations to implement into a
normal network driver. and the tcp/ip in linux is too much for me.
(to write down now*) but i think this may help somehow. Remember,
*the above was not a list of the tcp/ip implementation in the kernel*.
this can be called "the basics of the basics". hope it will help you.

I'm not a kernel coder. I'm an interested book reader about it. a fan.
i wasn't able to sort the code until now. i use linux since 14 months.
and of course, i didn't write english messages for about 4 years. oops.
hope the above helps. looks qwite like a mess.

The [rubini/corbet] has BIG REFERENCE-PARTS at the end of each chapter.
linux networkarchitecture (addison-wesley) is a *BIG* tcp/ip-reference.

bye,
Edward

last: i think you searched for the net_device interface :-)

--- and now how to implement the drivers correct:

 >     You can do the same thing: Adding a bunch of ioctls to communicate
 > between user-space and you driver functions.
 >

 > Felipe

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux