Date: Sun, 5 Jun 2016 23:53:54 -0400 From: Warner Losh <wlosh@bsdimp.com> To: KILOREUX Emperex <kiloreux@gmail.com> Cc: Poul-Henning Kamp <phk@phk.freebsd.dk>, Koop Mast <kwm@freebsd.org>, eadler@freebsd.org, =?utf-8?Q?Jean-S=C3=A9bastien_P=C3=A9dron?= <dumbbell@freebsd.org>, freebsd-arch@freebsd.org Subject: Re: API to link sysctl nodes to devices Message-ID: <070D3C32-9631-49AD-85FB-53A4865AFA08@bsdimp.com> In-Reply-To: <CAN1JrQ1eSr3%2BrPuF5d6USX=V_cTjzuAG=VXd7pFphO%2BEk2gE%2BQ@mail.gmail.com> References: <CAN1JrQ2dd0WZi0_aaNdqH9xdy292tP2DYLxvKV9bfK93vYFLXw@mail.gmail.com> <13621.1465030369@critter.freebsd.dk> <CAN1JrQ1eSr3%2BrPuF5d6USX=V_cTjzuAG=VXd7pFphO%2BEk2gE%2BQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Jun 5, 2016, at 11:07 PM, KILOREUX Emperex <kiloreux@gmail.com> = wrote: >=20 > Hey, >=20 > Thanks for your feedback, but we have been over this and what you are > proposing seems pretty interesting, can you please elaborate on how = that > could be implemented inside the kernel, or give more details about it, = also > it seems a bit cool if we could do both of them together, so what do = you > think about sysctl nodes, is there any disadvantages for the = implementation > of such API ? >=20 > On Sat, Jun 4, 2016 at 9:52 AM, Poul-Henning Kamp <phk@phk.freebsd.dk> > wrote: >=20 >> -------- >> In message < >> CAN1JrQ2dd0WZi0_aaNdqH9xdy292tP2DYLxvKV9bfK93vYFLXw@mail.gmail.com> >> , KILOREUX Emperex writes: >>=20 >>> As part of my participation GSOC, I have been working on an API spec = to >>> link sysctl nodes to devices. >>=20 >> It's not really the sysctl nodes as such you should focus on, but >> rather on the gap between (the increasingly inaccurately named) >> newbus and devfs. >>=20 >> The poster-boy example is how you get from USB bus coordinates to >> /dev/da* or /dev/{tty|cua}U* devices. >>=20 >> devd(8) seems to know the linkage and usually I resort to /etc/devd >> entries like this to make it liveable: >>=20 >> attach 1000 { >> match "device-name" "uftdi[0-9]*"; >> match "vendor" "0x0403"; >> match "product" "0x6001"; >> match "sernum" "FTHAV9UU"; >> action "ln -s /dev/cua$ttyname /dev/bbb1"; >> }; >>=20 >> notify 1000 { >> match "system" "USB"; >> match "subsystem" "DEVICE"; >> match "type" "DETACH"; >> match "vendor" "0x0403"; >> match "product" "0x6001"; >> match "sernum" "FTHAV9UU"; >> action "rm -f /dev/bbb1"; >> }; For /dev/da* we created a geom creation event that should be used = instead of a USB insertion event, which removed the strain we had. For = uftdi vs ttyUx thing, though, there=E2=80=99s a problem. We could do a = device creation event as well (there may already be one), but there=E2=80=99= s no way to connect the /dev/ttyUx back to the newbus device_t node, = which can be used look up info about the device to do interesting things = with. One way to do this would be dev.uftdi.0.%devnodes: ttyU2 ttyU3, = which would require some new APIs for adding a dev_t to a device_t. But = that might be backwards. I=E2=80=99d like something more like = devnode.ttyU2.device: uftdi0 would do the trick (or uftdi.0, since = device names can have numbers in them, which is why the sysctl nodes = under dev are the way they are). Note =E2=80=98devnode=E2=80=99 is just = a name, I=E2=80=99m agnostic, but given that dev is already taken (and = its an API for many device drivers, so changing it would be difficult) = =E2=80=98devnode=E2=80=99 seems the next best thing, but I=E2=80=99m = open to other names. Of course, having a stronger coupling between device_t and dev_t would = allow us to detect when /dev/foo isn=E2=80=99t destroyed when the = device_t created it gets detached. As for sysctl, there=E2=80=99s already a sysctl tree that=E2=80=99s = tightly coupled to a device instance that any device can take advantage = of. I=E2=80=99m not sure what you need here, unless it=E2=80=99s what I = described in the last paragraph. Warner=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?070D3C32-9631-49AD-85FB-53A4865AFA08>