Small patch for review

Harti Brandt brandt at fokus.fraunhofer.de
Mon Apr 28 09:08:14 PDT 2003


Hi,

attached is a simple patch that does the following:

- add a version number to net/if_atmsubr.c (just like if_ethersubr.c does)
- add module dependency information to the en(4) driver
- add a sysctl node hw.atm where the drivers will attach their hardware
  sysctl sub-trees
- create an atm_ifdetach() function
- make atm_ifattach() call if_attach (like ether_ifattach does)
- remove the call to if_attach() from the en(4) driver

The last two change the ABI, but this is not problem. The only other NATM
driver (besides en) is an old LANAI driver floating on the net, that will
anyway not work under current. So better to make the interface clean now,
than later when there are more drivers.

Is there something fundamentally wrong with this patch?

harti
-- 
harti brandt,
http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private
brandt at fokus.fraunhofer.de, harti at freebsd.org
-------------- next part --------------
Index: sys/dev/en/midway.c
===================================================================
RCS file: /export/cvs/freebsd/src/sys/dev/en/midway.c,v
retrieving revision 1.37
diff -u -r1.37 midway.c
--- sys/dev/en/midway.c	25 Apr 2003 16:14:03 -0000	1.37
+++ sys/dev/en/midway.c	28 Apr 2003 15:52:33 -0000
@@ -173,7 +173,7 @@
 #define ENOTHER_DRAIN	0x02		/* almost free (drain DRQ dma) */
 #define ENOTHER_SWSL	0x08		/* in software service list */
 
-SYSCTL_NODE(_hw, OID_AUTO, en, CTLFLAG_RW, 0, "ENI 155p");
+SYSCTL_DECL(_hw_atm);
 
 /*
  * dma tables
@@ -2767,7 +2767,7 @@
 	sysctl_ctx_init(&sc->sysctl_ctx);
 
 	if ((sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
-	    SYSCTL_STATIC_CHILDREN(_hw_en), OID_AUTO,
+	    SYSCTL_STATIC_CHILDREN(_hw_atm), OID_AUTO,
 	    device_get_nameunit(sc->dev), CTLFLAG_RD, 0, "")) == NULL)
 		goto fail;
 
@@ -2877,7 +2877,6 @@
 	/*
 	 * final commit
 	 */
-	if_attach(ifp);
 	atm_ifattach(ifp); 
 
 #ifdef ENABLE_BPF
Index: sys/net/if_atm.h
===================================================================
RCS file: /export/cvs/freebsd/src/sys/net/if_atm.h,v
retrieving revision 1.6
diff -u -r1.6 if_atm.h
--- sys/net/if_atm.h	13 Mar 2003 12:44:06 -0000	1.6
+++ sys/net/if_atm.h	28 Apr 2003 15:52:48 -0000
@@ -99,6 +99,7 @@
 
 #ifdef _KERNEL
 void	atm_ifattach(struct ifnet *);
+void	atm_ifdetach(struct ifnet *);
 void	atm_input(struct ifnet *, struct atm_pseudohdr *,
 		struct mbuf *, void *);
 int	atm_output(struct ifnet *, struct mbuf *, struct sockaddr *, 
Index: sys/net/if_atmsubr.c
===================================================================
RCS file: /export/cvs/freebsd/src/sys/net/if_atmsubr.c,v
retrieving revision 1.24
diff -u -r1.24 if_atmsubr.c
--- sys/net/if_atmsubr.c	13 Mar 2003 12:44:06 -0000	1.24
+++ sys/net/if_atmsubr.c	28 Apr 2003 15:52:48 -0000
@@ -45,11 +45,14 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
 #include <sys/mac.h>
 #include <sys/mbuf.h>
 #include <sys/socket.h>
 #include <sys/sockio.h>
 #include <sys/errno.h>
+#include <sys/sysctl.h>
 
 #include <net/if.h>
 #include <net/netisr.h>
@@ -68,6 +71,8 @@
 #include <netnatm/natm.h>
 #endif
 
+SYSCTL_NODE(_hw, OID_AUTO, atm, CTLFLAG_RW, 0, "ATM hardware");
+
 #ifndef ETHERTYPE_IPV6
 #define ETHERTYPE_IPV6	0x86dd
 #endif
@@ -283,7 +288,7 @@
 }
 
 /*
- * Perform common duties while attaching to interface list
+ * Perform common duties while attaching to interface list.
  */
 void
 atm_ifattach(ifp)
@@ -295,6 +300,7 @@
 	ifp->if_type = IFT_ATM;
 	ifp->if_addrlen = 0;
 	ifp->if_hdrlen = 0;
+	if_attach(ifp);
 	ifp->if_mtu = ATMMTU;
 	ifp->if_output = atm_output;
 #if 0
@@ -321,3 +327,21 @@
 		}
 
 }
+
+/*
+ * Common stuff for detaching an ATM interface
+ */
+void
+atm_ifdetach(struct ifnet *ifp)
+{
+	if_detach(ifp);
+}
+
+static moduledata_t atm_mod = {
+        "atm",
+        NULL,
+        0
+};
+                
+DECLARE_MODULE(atm, atm_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+MODULE_VERSION(atm, 1);
Index: sys/pci/if_en_pci.c
===================================================================
RCS file: /export/cvs/freebsd/src/sys/pci/if_en_pci.c,v
retrieving revision 1.21
diff -u -r1.21 if_en_pci.c
--- sys/pci/if_en_pci.c	25 Apr 2003 16:14:02 -0000	1.21
+++ sys/pci/if_en_pci.c	28 Apr 2003 15:52:50 -0000
@@ -66,6 +66,9 @@
 #include <dev/en/midwayreg.h>
 #include <dev/en/midwayvar.h>
 
+MODULE_DEPEND(en, pci, 1, 1, 1);
+MODULE_DEPEND(en, atm, 1, 1, 1);
+
 /*
  * local structures
  */
@@ -262,7 +265,7 @@
 	    en_intr, sc, &scp->ih);
 	if (error) {
 		en_reset(sc);
-		if_detach(&sc->enif);
+		atm_ifdetach(&sc->enif);
 		device_printf(dev, "could not setup irq\n");
 		bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq);
 		bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res);
@@ -297,7 +300,7 @@
 	 * Close down routes etc.
 	 */
 	en_reset(sc);
-	if_detach(&sc->enif);
+	atm_ifdetach(&sc->enif);
 
 	/*
 	 * Deallocate resources.


More information about the freebsd-atm mailing list