linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aritz Bastida <aritzbastida@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Right way to configure a driver? (sysfs, ioctl, proc, configfs,....)
Date: Thu, 26 Jan 2006 21:06:28 +0100	[thread overview]
Message-ID: <7d40d7190601261206wdb22ccck@mail.gmail.com> (raw)

Hello everybody.

I'm quite a newbie in the kernel development, but I'm writing a kernel
module and would like to do the things right. What I'm trying to do
is, more or less, a kind of "virtual" network device (not really that
but it will suffice).

This network device can be configured from userspace. I have read the
books "Linux Device Drivers 3" (LDD3) and "Linux Kernel Development"
and after that I didn't find the answer to the question I was making
myself: What should be the right way to configure it?

In LDD3 it says that ioctls fall out of favor among kernel developers,
but there is not a  strong _advise_ to use another method. It says
that instead of that sysfs _could_ be used. Of course, that was almost
a year ago. I'm sure things have changed since then.

So, well, I did all this configuration using ioctls and proc, which
was the fastest for me, but may be not the best solution. So I'm
asking for advise here.

The configuration I need to do is actually quite simple. Most of the
commands are just set or get a variable defined in my module (for
example, write to a flags variable, just like in real network devices
-- i.e. IF_UP). The most difficult "config" I need to do is write a
struct to the module (just write two variables in the same command).

What way do you suggest for all this? Is sysfs correct for this? What
about the new filesystem "configfs"? I've just heard about it, but I
don't even have it mounted on my system. Would it be what I need?

On the other hand, I also need to export some statistics to userspace.
These are similar to the ones in a network device: packets received,
dropped,... but I would like to export not just the number of packets
received, but the number received by _each_ cpu, as well as the total.
Would you recommend me /proc or sysfs?

In case of using sysfs, would this be the correct approach or you
would recommend  one value per file?
$ cat rx_packets
     10     15     25
where the first value is packets received in CPU0, the second in CPU1
and the last the total.


Thank you for your time
Regards
Aritz

             reply	other threads:[~2006-01-26 20:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-26 20:06 Aritz Bastida [this message]
2006-01-27  5:01 ` Right way to configure a driver? (sysfs, ioctl, proc, configfs,....) Greg KH
2006-01-27 10:30   ` Aritz Bastida
     [not found]     ` <69304d110601270834q5fa8a078m63a7168aa7e288d1@mail.gmail.com>
2006-01-30 11:23       ` Aritz Bastida
2006-01-30 21:39         ` Greg KH
2006-02-01 14:54           ` Jan Engelhardt
2006-02-01 15:11             ` Greg KH
2006-02-01 15:44               ` Aritz Bastida
2006-02-01 16:17                 ` Jan Engelhardt
2006-02-02  6:31               ` Neil Brown
2006-01-30 21:41     ` Greg KH
2006-02-01 13:37       ` Aritz Bastida
2006-02-01 13:53         ` linux-os (Dick Johnson)
2006-02-01 14:19           ` Aritz Bastida
2006-02-01 15:11             ` linux-os (Dick Johnson)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d40d7190601261206wdb22ccck@mail.gmail.com \
    --to=aritzbastida@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).