Date: Mon, 06 Jun 2016 11:19:51 -0700 From: John Baldwin <jhb@freebsd.org> To: freebsd-arch@freebsd.org Cc: KILOREUX Emperex <kiloreux@gmail.com>, Koop Mast <kwm@freebsd.org>, eadler@freebsd.org, =?ISO-8859-1?Q?Jean=2DS=E9bastien_P=E9dron?= <dumbbell@freebsd.org> Subject: Re: API to link sysctl nodes to devices Message-ID: <10046161.dJvFbDNaVq@ralph.baldwin.cx> In-Reply-To: <CAN1JrQ2dd0WZi0_aaNdqH9xdy292tP2DYLxvKV9bfK93vYFLXw@mail.gmail.com> References: <CAN1JrQ2dd0WZi0_aaNdqH9xdy292tP2DYLxvKV9bfK93vYFLXw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, June 03, 2016 06:14:45 PM KILOREUX Emperex wrote: > Hey, > > As part of my participation GSOC, I have been working on an API spec to > link sysctl nodes to devices. > > And I cam up with few ideas that I need some feedback on before proceeding > to the implementation on the kernel. > > - We need devices to have their propoer sysctl trees, and thus every device > linked will have its own id as the head of its syctl tree. > > For example a device with id 0x94, would have it's sysctl root look like > dev.fs.0x94 where the below parameters can be accessed after that. > > - We want to give device drivers the ability to create and delete sysctl > nodes as they want, thus proposing a proper interface for it. > > > So I have been thinking so far to enable the creation of the root for those > sysctl nodes on the system initialization, to allow existing device drivers > to link their device on the tree. > > Also we want to propose a new function similar to make_dev, supposed we > name it make_dev_sys, that gets the device id and links it on the tree of > existing sysctl nodes, and for the purpose of keeping track of the > available sysctl nodes for each device, I thought of proposing a change to > the device switching table "cdevsw" to keep systcl context tracked for the > device. > > Would any modification to cdevsw break backward compatibility ? > Please provide us with any feedback you have on this proposition and any > defects you seeing in the logic. > > Your help is much appreciated. More detail on what you actually want is needed I think. We already have sysctl device nodes for newbus devices (dev.X.y). The drm2 code insists on using its own private tree instead of dev.drmn.0.y though which might be the source of some confusion. If the goal is to know which device_t a given cdev is associated with, I think having a way to ask that and then use nodes for the device_t is more straightforward than having an indirection with a separate sysctl tree with opaque cookies for names. (That is, if you had a 'QUERY_DEVICET_NAME' ioctl that character device drivers could optionally implement. Note that only the device driver really knows the mapping from cdev to device_t. We could perhaps provide a wrapper where you could add the device_t as an arg via make_dev_s() and have the devfs ioctl handler handle QUERY_DEVICET_NAME in that layer using the arg passed to make_dev_s(). I would perhaps have the ioctl return the name and unit broken out so it is easier to generate the sysctl path.) -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?10046161.dJvFbDNaVq>