From owner-freebsd-net@FreeBSD.ORG Fri Feb 17 07:13:07 2012 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3A15A106566B for ; Fri, 17 Feb 2012 07:13:07 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id C5DAF8FC12 for ; Fri, 17 Feb 2012 07:13:06 +0000 (UTC) Received: by werm13 with SMTP id m13so2617264wer.13 for ; Thu, 16 Feb 2012 23:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=OqwjNbAR9ONZDd8HK83ekOGogyHUvxWLd9XnjTqi2Rs=; b=ufH9Fq+rI7TVlFZEz7ud0eVD42E5rQYuxX2tIAmzLa/sMvqqaN+rsOW1AHo8FAzlxG aj2VSCg5ZE8dhjKXaTNFTc8L0O9292OFKlWaC6AzWKjqX5p1JFV1GqqC06eT2j2bXeAO Wc8+KjnmEqyy11pegN4jO4hqXZjTCX4dJkMbY= MIME-Version: 1.0 Received: by 10.180.95.1 with SMTP id dg1mr1412662wib.21.1329460978109; Thu, 16 Feb 2012 22:42:58 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.154.199 with HTTP; Thu, 16 Feb 2012 22:42:58 -0800 (PST) In-Reply-To: <338757D1-6B1E-49CF-983F-5D5851066FD3@xcllnt.net> References: <338757D1-6B1E-49CF-983F-5D5851066FD3@xcllnt.net> Date: Thu, 16 Feb 2012 22:42:58 -0800 X-Google-Sender-Auth: kaxHMakUyYQ8wqUmkBLd9t8fYnY Message-ID: From: Adrian Chadd To: Marcel Moolenaar Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: net@freebsd.org Subject: Re: Abstracting struct ifnet X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Feb 2012 07:13:07 -0000 Hi, I honestly quite like this idea. Adrian On 16 February 2012 20:16, Marcel Moolenaar wrote: > All, > > Juniper is in the final phases of creating a clean separation > between FreeBSD and Junos, so as to make upgrades of FreeBSD > easier. This also allows Juniper to track -current and be more > active FreeBSD contributors. > > To that end, we have a short-term and hopefully short-lived > problem to solve, which is the ability to use FreeBSD's network > drivers against the Junos network stack. As some may know, the > Junos network stack has split up struct ifnet into a physical > and logical component, called ifdev and iflogical. > > We've tried a few approaches to bridge the gap between ifnet > on the one hand and ifdev and iflogical on the other and found > that abstracting ifnet and using accessor functions is the > best way to allow us to use FreeBSD drivers with the Junos > network stack, while retaining the ability to use them with > the FreeBSD stack. > > FreeBSD is also looking at breaking up ifnet and with that in > mind, I was wondering if there would be any resistance to > changing network drivers to use accessor functions or macros > instead of direct pointer dereferences? > > For example, do something like: > > Index: if_fxp.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- if_fxp.c =A0 =A0(revision 231178) > +++ if_fxp.c =A0 =A0(working copy) > @@ -823,13 +823,14 @@ > =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0if_initname(ifp, device_get_name(dev), device_get_unit(dev= )); > - =A0 =A0 =A0 ifp->if_init =3D fxp_init; > - =A0 =A0 =A0 ifp->if_softc =3D sc; > - =A0 =A0 =A0 ifp->if_flags =3D IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICA= ST; > - =A0 =A0 =A0 ifp->if_ioctl =3D fxp_ioctl; > - =A0 =A0 =A0 ifp->if_start =3D fxp_start; > + =A0 =A0 =A0 if_set_init(ifp, fxp_init); > + =A0 =A0 =A0 if_set_softc(ifp, sc); > + =A0 =A0 =A0 if_set_flags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICA= ST, 0); > + =A0 =A0 =A0 if_set_ioctl(ifp, fxp_ioctl); > + =A0 =A0 =A0 if_set_start(ifp, fxp_start); > > - =A0 =A0 =A0 ifp->if_capabilities =3D ifp->if_capenable =3D 0; > + =A0 =A0 =A0 if_set_capabilities(ifp, 0); > + =A0 =A0 =A0 if_set_capenable(ifp, 0); > > =A0 =A0 =A0 =A0/* Enable checksum offload/TSO for 82550 or better chips *= / > =A0 =A0 =A0 =A0if (sc->flags & FXP_FLAG_EXT_RFA) { > > Such a scheme, while initially touching a lot of driver, > would make it easier to break up ifnet *and* also make it > easier to hide ABI/API changes from driver vendors (esp. > when the accessor functions are non-inlined functions and > not macros or inlines). This is particularly useful for > Juniper, where we have worked towards network stacks as > (pre-)loadable modules so as to help with migration and > validation. > > Thoughts, feedback and suggestion are welcome, > > -- > Marcel Moolenaar > marcel@xcllnt.net > > > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"