Module Name:    src
Committed By:   bad
Date:           Sun Nov 17 22:52:14 UTC 2013

Modified Files:
        src/sys/dev/pci: ubsec.c

Log Message:
Create the sysctl variables on module initialization.
Create them under hw.ubsec as is hip these days.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/ubsec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ubsec.c
diff -u src/sys/dev/pci/ubsec.c:1.32 src/sys/dev/pci/ubsec.c:1.33
--- src/sys/dev/pci/ubsec.c:1.32	Sun Nov 17 17:16:25 2013
+++ src/sys/dev/pci/ubsec.c	Sun Nov 17 22:52:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsec.c,v 1.32 2013/11/17 17:16:25 bad Exp $	*/
+/*	$NetBSD: ubsec.c,v 1.33 2013/11/17 22:52:14 bad Exp $	*/
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*	$OpenBSD: ubsec.c,v 1.127 2003/06/04 14:04:58 jason Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.32 2013/11/17 17:16:25 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.33 2013/11/17 22:52:14 bad Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.
 #include <sys/device.h>
 #include <sys/module.h>
 #include <sys/queue.h>
+#include <sys/sysctl.h>
 
 #include <opencrypto/cryptodev.h>
 #include <opencrypto/xform.h>
@@ -84,6 +85,7 @@ __KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.
 static	int ubsec_probe(device_t, cfdata_t, void *);
 static	void ubsec_attach(device_t, device_t, void *);
 static	int  ubsec_detach(device_t, int);
+static	int  ubsec_sysctl_init(void);
 static	void ubsec_reset_board(struct ubsec_softc *);
 static	void ubsec_init_board(struct ubsec_softc *);
 static	void ubsec_init_pciregs(struct pci_attach_args *pa);
@@ -161,6 +163,8 @@ static	void	ubsec_dump_ctx2(volatile str
 
 struct ubsec_stats ubsecstats;
 
+static struct sysctllog *ubsec_sysctllog;
+
 /*
  * ubsec_maxbatch controls the number of crypto ops to voluntarily
  * collect into one submission to the hardware.  This batching happens
@@ -169,10 +173,6 @@ struct ubsec_stats ubsecstats;
  * with a ``no delay'' flag.
  */
 static	int ubsec_maxbatch = 1;
-#ifdef SYSCTL_INT
-SYSCTL_INT(_kern, OID_AUTO, ubsec_maxbatch, CTLFLAG_RW, &ubsec_maxbatch,
-	    0, "Broadcom driver: max ops to batch w/o interrupt");
-#endif
 
 /*
  * ubsec_maxaggr controls the number of crypto ops to submit to the
@@ -182,10 +182,6 @@ SYSCTL_INT(_kern, OID_AUTO, ubsec_maxbat
  * performance but at the expense of more interrupt processing.
  */
 static	int ubsec_maxaggr = 1;
-#ifdef SYSCTL_INT
-SYSCTL_INT(_kern, OID_AUTO, ubsec_maxaggr, CTLFLAG_RW, &ubsec_maxaggr,
-	    0, "Broadcom driver: max ops to aggregate under one interrupt");
-#endif
 
 static const struct ubsec_product {
 	pci_vendor_id_t		ubsec_vendor;
@@ -540,8 +536,12 @@ ubsec_modcmd(modcmd_t cmd, void *data)
 		error = config_init_component(cfdriver_ioconf_ubsec,
 		    cfattach_ioconf_ubsec, cfdata_ioconf_ubsec);
 #endif
+		if (error == 0)
+			error = ubsec_sysctl_init();
 		return error;
 	case MODULE_CMD_FINI:
+		if (ubsec_sysctllog != NULL)
+			sysctl_teardown(&ubsec_sysctllog);
 #ifdef _MODULE
 		error = config_fini_component(cfdriver_ioconf_ubsec,
 		    cfattach_ioconf_ubsec, cfdata_ioconf_ubsec);
@@ -552,6 +552,40 @@ ubsec_modcmd(modcmd_t cmd, void *data)
 	}
 }
 
+static int
+ubsec_sysctl_init(void)
+{
+	const struct sysctlnode *node = NULL;
+
+	ubsec_sysctllog = NULL;
+
+	sysctl_createv(&ubsec_sysctllog, 0, NULL, NULL,
+		CTLFLAG_PERMANENT,
+		CTLTYPE_NODE, "hw", NULL,
+		NULL, 0, NULL, 0,
+		CTL_HW, CTL_EOL);
+	sysctl_createv(&ubsec_sysctllog, 0, NULL, &node,
+		CTLFLAG_PERMANENT,
+		CTLTYPE_NODE, "ubsec", 
+		SYSCTL_DESCR("ubsec opetions"),
+		NULL, 0, NULL, 0,
+		CTL_HW, CTL_CREATE, CTL_EOL);
+	sysctl_createv(&ubsec_sysctllog, 0, &node, NULL,
+		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+		CTLTYPE_INT, "maxbatch",
+		SYSCTL_DESCR("max ops to batch w/o interrupt"),
+		NULL, 0, &ubsec_maxbatch, 0,
+		CTL_CREATE, CTL_EOL);
+	sysctl_createv(&ubsec_sysctllog, 0, &node, NULL,
+		CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+		CTLTYPE_INT, "maxaggr",
+		SYSCTL_DESCR("max ops to aggregate under one interrupt"),
+		NULL, 0, &ubsec_maxaggr, 0,
+		CTL_CREATE, CTL_EOL);
+
+	return 0;
+}
+
 /*
  * UBSEC Interrupt routine
  */

Reply via email to