Date: Thu, 18 Dec 1997 20:08:39 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: avalon@coombs.anu.edu.au (Darren Reed) Cc: gurney_j@resnet.uoregon.edu, freebsd-hackers@FreeBSD.ORG Subject: Re: converting drivers to dynamic memory... Message-ID: <199712182008.NAA13665@usr05.primenet.com> In-Reply-To: <199712181327.FAA17836@hub.freebsd.org> from "Darren Reed" at Dec 19, 97 00:23:04 am
next in thread | previous in thread | raw e-mail | index | archive | help
> Why isn't it ok to just free/allocate and the memory when it is (un)loaded ?
>
> If, I load a device like BPF and tell it I want "NBPF" to be 4, then what
> else besides the BPF driver needs to know that NBPF is 4 ? (I hope I've
> picked a very simple case :). What else cares about those buffers ?
There's a fundamental flaw here: that 4 should be anything other than
a soft limit.
The BPF is one of those devices, like pty's or the tun or vn devices,
that is best modelled with a cloning interface.
Initially, I would think you would do something like:
static void *contexts[ NBPFILTER];
fake_bpf_device_op( minor, ...)
{
return real_bpf_device_op( contexts[ minor], ...);
}
This should make the transition relatively painless.
There would probably need to be a new function for instancing in
the bpf_cdevsw entry, which would be called to instance into the
static contexts value appropriate for the device being referenced,
and a reflexive one for destroying those same contexts.
But this would let you change one device at a time fairly trivially,
and, assuming a recompile an placement of the create/delet at the
end of the struct cdevsw, the values would default to NULL for all
unconverted devices.
Terry Lambert
terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712182008.NAA13665>
