Date: Fri, 17 Feb 2012 17:53:20 +0400 From: Gleb Smirnoff <glebius@FreeBSD.org> To: Marcel Moolenaar <marcel@xcllnt.net> Cc: net@FreeBSD.org Subject: Re: Abstracting struct ifnet Message-ID: <20120217135320.GJ55075@FreeBSD.org> In-Reply-To: <338757D1-6B1E-49CF-983F-5D5851066FD3@xcllnt.net> References: <338757D1-6B1E-49CF-983F-5D5851066FD3@xcllnt.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Feb 16, 2012 at 08:16:22PM -0800, Marcel Moolenaar wrote: M> All, M> M> Juniper is in the final phases of creating a clean separation M> between FreeBSD and Junos, so as to make upgrades of FreeBSD M> easier. This also allows Juniper to track -current and be more M> active FreeBSD contributors. M> M> To that end, we have a short-term and hopefully short-lived M> problem to solve, which is the ability to use FreeBSD's network M> drivers against the Junos network stack. As some may know, the M> Junos network stack has split up struct ifnet into a physical M> and logical component, called ifdev and iflogical. M> M> We've tried a few approaches to bridge the gap between ifnet M> on the one hand and ifdev and iflogical on the other and found M> that abstracting ifnet and using accessor functions is the M> best way to allow us to use FreeBSD drivers with the Junos M> network stack, while retaining the ability to use them with M> the FreeBSD stack. M> M> FreeBSD is also looking at breaking up ifnet and with that in M> mind, I was wondering if there would be any resistance to M> changing network drivers to use accessor functions or macros M> instead of direct pointer dereferences? M> M> For example, do something like: M> M> Index: if_fxp.c M> =================================================================== M> --- if_fxp.c (revision 231178) M> +++ if_fxp.c (working copy) M> @@ -823,13 +823,14 @@ M> } M> M> if_initname(ifp, device_get_name(dev), device_get_unit(dev)); M> - ifp->if_init = fxp_init; M> - ifp->if_softc = sc; M> - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; M> - ifp->if_ioctl = fxp_ioctl; M> - ifp->if_start = fxp_start; M> + if_set_init(ifp, fxp_init); M> + if_set_softc(ifp, sc); M> + if_set_flags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST, 0); M> + if_set_ioctl(ifp, fxp_ioctl); M> + if_set_start(ifp, fxp_start); M> M> - ifp->if_capabilities = ifp->if_capenable = 0; M> + if_set_capabilities(ifp, 0); M> + if_set_capenable(ifp, 0); M> M> /* Enable checksum offload/TSO for 82550 or better chips */ M> if (sc->flags & FXP_FLAG_EXT_RFA) { M> M> Such a scheme, while initially touching a lot of driver, M> would make it easier to break up ifnet *and* also make it M> easier to hide ABI/API changes from driver vendors (esp. M> when the accessor functions are non-inlined functions and M> not macros or inlines). This is particularly useful for M> Juniper, where we have worked towards network stacks as M> (pre-)loadable modules so as to help with migration and M> validation. M> M> Thoughts, feedback and suggestion are welcome, Is it possible to make the structure the driver points to opaque? Once made, that would allow us to hack on the ifnet (or on its successor - iflogical) more aggressively without breaking ABI/API. -- Totus tuus, Glebius.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120217135320.GJ55075>