Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 May 2017 04:18:46 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r318856 - in head/sys: dev/ath dev/ath/ath_dfs/null dev/ath/ath_hal dev/ath/ath_rate/sample modules modules/ath modules/ath_dfs modules/ath_hal modules/ath_hal_ar5210 modules/ath_hal_ar...
Message-ID:  <201705250418.v4P4IkbT004230@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Thu May 25 04:18:46 2017
New Revision: 318856
URL: https://svnweb.freebsd.org/changeset/base/318856

Log:
  [ath] [ath_hal] (etc, etc) - begin the task of re-modularising the HAL.
  
  In the deep past, when this code compiled as a binary module, ath_hal
  built as a module.  This allowed custom, smaller HAL modules to be built.
  This was especially beneficial for small embedded platforms where you
  didn't require /everything/ just to run.
  
  However, sometime around the HAL opening fanfare, the HAL landed here
  as one big driver+HAL thing, and a lot of the (dirty) infrastructure
  (ie, #ifdef AH_SUPPORT_XXX) to build specific subsets of the HAL went away.
  This was retained in sys/conf/files as "ath_hal_XXX" but it wasn't
  really floated up to the modules themselves.
  
  I'm now in a position where for the reaaaaaly embedded boards (both the
  really old and the last couple generation of QCA MIPS boards) having a
  cut down HAL module and driver loaded at runtime is /actually/ beneficial.
  
  This reduces the kernel size down by quite a bit.  The MIPS modules look
  like this:
  
  adrian@gertrude:~/work/freebsd/head-embedded/src % ls -l ../root/mips_ap/boot/kernel.CARAMBOLA2/ath*ko
  -r-xr-xr-x  1 adrian  adrian    5076 May 23 23:45 ../root/mips_ap/boot/kernel.CARAMBOLA2/ath_dfs.ko
  -r-xr-xr-x  1 adrian  adrian  100588 May 23 23:45 ../root/mips_ap/boot/kernel.CARAMBOLA2/ath_hal.ko
  -r-xr-xr-x  1 adrian  adrian  627324 May 23 23:45 ../root/mips_ap/boot/kernel.CARAMBOLA2/ath_hal_ar9300.ko
  -r-xr-xr-x  1 adrian  adrian  314588 May 23 23:45 ../root/mips_ap/boot/kernel.CARAMBOLA2/ath_main.ko
  -r-xr-xr-x  1 adrian  adrian   23472 May 23 23:45 ../root/mips_ap/boot/kernel.CARAMBOLA2/ath_rate.ko
  
  And the x86 versions, like this:
  
  root@gertrude:/home/adrian # ls -l /boot/kernel/ath*ko
  -r-xr-xr-x  1 root  wheel   36632 May 24 18:32 /boot/kernel/ath_dfs.ko
  -r-xr-xr-x  1 root  wheel  134440 May 24 18:32 /boot/kernel/ath_hal.ko
  -r-xr-xr-x  1 root  wheel   82320 May 24 18:32 /boot/kernel/ath_hal_ar5210.ko
  -r-xr-xr-x  1 root  wheel  104976 May 24 18:32 /boot/kernel/ath_hal_ar5211.ko
  -r-xr-xr-x  1 root  wheel  236144 May 24 18:32 /boot/kernel/ath_hal_ar5212.ko
  -r-xr-xr-x  1 root  wheel  336104 May 24 18:32 /boot/kernel/ath_hal_ar5416.ko
  -r-xr-xr-x  1 root  wheel  598336 May 24 18:32 /boot/kernel/ath_hal_ar9300.ko
  -r-xr-xr-x  1 root  wheel  406144 May 24 18:32 /boot/kernel/ath_main.ko
  -r-xr-xr-x  1 root  wheel   55352 May 24 18:32 /boot/kernel/ath_rate.ko
  
  .. so you can see, not building the whole HAL can save quite a bit.
  For example, if you don't need AR9300 support, you can actually avoid
  wasting half a megabyte of RAM.  On embedded routers this is quite a
  big deal.
  
  The AR9300 HAL can be later further shrunk because, hilariously,
  it indeed supports AH_SUPPORT_<xxx> for optionally adding chipset support.
  (I'll chase that down later as it's quite a big savings if you're only
  building for a single embedded target.)
  
  So:
  
  * Create a very hackish way to load/unload HAL modules
  * Create module metadata for each HAL subtype - ah_osdep_arXXXX.c
  * Create module metadata for ath_rate and ath_dfs (bluetooth is
    currently just built as part of it)
  * .. yes, this means we could actually build multiple rate control
    modules and pick one at load time, but I'd rather just glue this
    into net80211's rate control code.  Oh well, baby steps.
  * Main driver is now "ath_main"
  * Create an "if_ath" module that does what the ye olde one did -
    load PCI glue, main driver, HAL and all child modules.
    In this way, if you have "if_ath_load=YES" in /boot/modules.conf
    it will load everything the old way and stuff should still work.
  * For module autoloading purposes, I actually /did/ fix up
    the name of the modules in if_ath_pci and if_ath_ahb.
  
  If you want to selectively load things (eg on ye cheape ARM/MIPS platforms
  where RAM is at a premium) you should:
  
  * load ath_hal
  * load the chip modules in question
  * load ath_rate, ath_dfs
  * load ath_main
  * load if_ath_pci and/or if_ath_ahb depending upon your particular
    bus bind type - this is where probe/attach is done.
  
  TODO:
  
  * AR5312 module and associated pieces - yes, we have the SoC side support
    now so the wifi support would be good to "round things out";
  * Just nuke AH_SUPPORT_AR5416 for now and always bloat the packet
    structures; this'll simplify other things.
  * Should add a simple refcnt thing to the HAL RF/chip modules so you
    can't unload them whilst you're using them.
  * Manpage updates, UPDATING if appropriate, etc.

Added:
  head/sys/dev/ath/ah_osdep_ar5210.c   (contents, props changed)
  head/sys/dev/ath/ah_osdep_ar5211.c   (contents, props changed)
  head/sys/dev/ath/ah_osdep_ar5212.c   (contents, props changed)
  head/sys/dev/ath/ah_osdep_ar5416.c   (contents, props changed)
  head/sys/dev/ath/ah_osdep_ar9300.c   (contents, props changed)
  head/sys/dev/ath/if_ath_dfs.c   (contents, props changed)
  head/sys/dev/ath/if_ath_drv.c   (contents, props changed)
  head/sys/dev/ath/if_ath_rate.c   (contents, props changed)
  head/sys/modules/ath_dfs/
  head/sys/modules/ath_dfs/Makefile   (contents, props changed)
  head/sys/modules/ath_hal/
  head/sys/modules/ath_hal/Makefile   (contents, props changed)
  head/sys/modules/ath_hal_ar5210/
  head/sys/modules/ath_hal_ar5210/Makefile   (contents, props changed)
  head/sys/modules/ath_hal_ar5211/
  head/sys/modules/ath_hal_ar5211/Makefile   (contents, props changed)
  head/sys/modules/ath_hal_ar5212/
  head/sys/modules/ath_hal_ar5212/Makefile   (contents, props changed)
  head/sys/modules/ath_hal_ar5416/
  head/sys/modules/ath_hal_ar5416/Makefile   (contents, props changed)
  head/sys/modules/ath_hal_ar9300/
  head/sys/modules/ath_hal_ar9300/Makefile   (contents, props changed)
  head/sys/modules/ath_main/
  head/sys/modules/ath_main/Makefile   (contents, props changed)
  head/sys/modules/ath_rate/
  head/sys/modules/ath_rate/Makefile   (contents, props changed)
Modified:
  head/sys/dev/ath/ah_osdep.c
  head/sys/dev/ath/ath_dfs/null/dfs_null.c
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah_internal.h
  head/sys/dev/ath/ath_rate/sample/sample.c
  head/sys/dev/ath/if_ath.c
  head/sys/dev/ath/if_ath_ahb.c
  head/sys/dev/ath/if_ath_pci.c
  head/sys/modules/Makefile
  head/sys/modules/ath/Makefile

Modified: head/sys/dev/ath/ah_osdep.c
==============================================================================
--- head/sys/dev/ath/ah_osdep.c	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/ah_osdep.c	Thu May 25 04:18:46 2017	(r318856)
@@ -41,6 +41,7 @@
 #include <sys/pcpu.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
+#include <sys/conf.h>
 
 #include <machine/stdarg.h>
 
@@ -420,3 +421,31 @@ ath_hal_assert_failed(const char* filena
 	panic("ath_hal_assert");
 }
 #endif /* AH_ASSERT */
+
+static int
+ath_hal_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		printf("[ath_hal] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		printf("[ath_hal] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(ath_hal, ath_hal_modevent, NULL);
+MODULE_VERSION(ath_hal, 1);

Added: head/sys/dev/ath/ah_osdep_ar5210.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ah_osdep_ar5210.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,74 @@
+/*-
+ * Copyright 2017 Adrian Chadd <adrian@FreeBSD.org>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#include "opt_ah.h"
+#include "opt_wlan.h"
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <dev/ath/ath_hal/ah.h>
+#include <dev/ath/ath_hal/ah_internal.h>
+
+extern struct ath_hal_chip AR5210_chip;
+
+static int
+ath_hal_ar5210_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		ath_hal_add_chip(&AR5210_chip);
+		printf("[ar5210] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		ath_hal_remove_chip(&AR5210_chip);
+		printf("[ar5210] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(ath_hal_ar5210, ath_hal_ar5210_modevent, NULL);
+MODULE_VERSION(ath_hal_ar5210, 1);
+MODULE_DEPEND(ath_hal_ar5210, ath_hal, 1, 1, 1);

Added: head/sys/dev/ath/ah_osdep_ar5211.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ah_osdep_ar5211.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,74 @@
+/*-
+ * Copyright 2017 Adrian Chadd <adrian@FreeBSD.org>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#include "opt_ah.h"
+#include "opt_wlan.h"
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <dev/ath/ath_hal/ah.h>
+#include <dev/ath/ath_hal/ah_internal.h>
+
+extern struct ath_hal_chip AR5211_chip;
+
+static int
+ath_hal_ar5211_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		ath_hal_add_chip(&AR5211_chip);
+		printf("[ar5211] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		ath_hal_remove_chip(&AR5211_chip);
+		printf("[ar5211] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(ath_hal_ar5211, ath_hal_ar5211_modevent, NULL);
+MODULE_VERSION(ath_hal_ar5211, 1);
+MODULE_DEPEND(ath_hal_ar5211, ath_hal, 1, 1, 1);

Added: head/sys/dev/ath/ah_osdep_ar5212.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ah_osdep_ar5212.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,95 @@
+/*-
+ * Copyright 2017 Adrian Chadd <adrian@FreeBSD.org>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#include "opt_ah.h"
+#include "opt_wlan.h"
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <dev/ath/ath_hal/ah.h>
+#include <dev/ath/ath_hal/ah_internal.h>
+
+extern struct ath_hal_chip AR5212_chip;
+//extern struct ath_hal_rf RF2316_rf;
+//extern struct ath_hal_rf RF2317_rf;
+extern struct ath_hal_rf RF2413_rf;
+extern struct ath_hal_rf RF2425_rf;
+extern struct ath_hal_rf RF5111_rf;
+extern struct ath_hal_rf RF5112_rf;
+extern struct ath_hal_rf RF5413_rf;
+
+static int
+ath_hal_ar5212_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		ath_hal_add_chip(&AR5212_chip);
+//		ath_hal_add_rf(&RF2316_rf);
+//		ath_hal_add_rf(&RF2317_rf);
+		ath_hal_add_rf(&RF2413_rf);
+		ath_hal_add_rf(&RF2425_rf);
+		ath_hal_add_rf(&RF5111_rf);
+		ath_hal_add_rf(&RF5112_rf);
+		ath_hal_add_rf(&RF5413_rf);
+		printf("[ar5212] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		ath_hal_remove_chip(&AR5212_chip);
+//		ath_hal_remove_rf(&RF2316_rf);
+//		ath_hal_remove_rf(&RF2317_rf);
+		ath_hal_remove_rf(&RF2413_rf);
+		ath_hal_remove_rf(&RF2425_rf);
+		ath_hal_remove_rf(&RF5111_rf);
+		ath_hal_remove_rf(&RF5112_rf);
+		ath_hal_remove_rf(&RF5413_rf);
+		printf("[ar5212] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(ath_hal_ar5212, ath_hal_ar5212_modevent, NULL);
+MODULE_VERSION(ath_hal_ar5212, 1);
+MODULE_DEPEND(ath_hal_ar5212, ath_hal, 1, 1, 1);

Added: head/sys/dev/ath/ah_osdep_ar5416.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ah_osdep_ar5416.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,103 @@
+/*-
+ * Copyright 2017 Adrian Chadd <adrian@FreeBSD.org>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#include "opt_ah.h"
+#include "opt_wlan.h"
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <dev/ath/ath_hal/ah.h>
+#include <dev/ath/ath_hal/ah_internal.h>
+
+extern struct ath_hal_chip AR5416_chip;
+extern struct ath_hal_chip AR9130_chip;
+extern struct ath_hal_chip AR9160_chip;
+extern struct ath_hal_chip AR9280_chip;
+extern struct ath_hal_chip AR9285_chip;
+extern struct ath_hal_chip AR9287_chip;
+
+extern struct ath_hal_rf RF2133_rf;
+extern struct ath_hal_rf RF9280_rf;
+extern struct ath_hal_rf RF9285_rf;
+extern struct ath_hal_rf RF9287_rf;
+
+static int
+ath_hal_ar5416_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		ath_hal_add_chip(&AR5416_chip);
+		ath_hal_add_chip(&AR9130_chip);
+		ath_hal_add_chip(&AR9160_chip);
+		ath_hal_add_chip(&AR9280_chip);
+		ath_hal_add_chip(&AR9285_chip);
+		ath_hal_add_chip(&AR9287_chip);
+		ath_hal_add_rf(&RF2133_rf);
+		ath_hal_add_rf(&RF9280_rf);
+		ath_hal_add_rf(&RF9285_rf);
+		ath_hal_add_rf(&RF9287_rf);
+		printf("[ar5416] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		ath_hal_remove_chip(&AR5416_chip);
+		ath_hal_remove_chip(&AR9130_chip);
+		ath_hal_remove_chip(&AR9160_chip);
+		ath_hal_remove_chip(&AR9280_chip);
+		ath_hal_remove_chip(&AR9285_chip);
+		ath_hal_remove_chip(&AR9287_chip);
+		ath_hal_remove_rf(&RF2133_rf);
+		ath_hal_remove_rf(&RF9280_rf);
+		ath_hal_remove_rf(&RF9285_rf);
+		ath_hal_remove_rf(&RF9287_rf);
+		printf("[ar5416] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(ath_hal_ar5416, ath_hal_ar5416_modevent, NULL);
+MODULE_VERSION(ath_hal_ar5416, 1);
+MODULE_DEPEND(ath_hal_ar5416, ath_hal, 1, 1, 1);
+MODULE_DEPEND(ath_hal_ar5416, ath_hal_ar5212, 1, 1, 1);

Added: head/sys/dev/ath/ah_osdep_ar9300.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ah_osdep_ar9300.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,74 @@
+/*-
+ * Copyright 2017 Adrian Chadd <adrian@FreeBSD.org>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#include "opt_ah.h"
+#include "opt_wlan.h"
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <dev/ath/ath_hal/ah.h>
+#include <dev/ath/ath_hal/ah_internal.h>
+
+extern struct ath_hal_chip AR9300_chip;
+
+static int
+ath_hal_ar9300_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		ath_hal_add_chip(&AR9300_chip);
+		printf("[ar9300] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		ath_hal_remove_chip(&AR9300_chip);
+		printf("[ar9300] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(ath_hal_ar9300, ath_hal_ar9300_modevent, NULL);
+MODULE_VERSION(ath_hal_ar9300, 1);
+MODULE_DEPEND(ath_hal_ar9300, ath_hal, 1, 1, 1);

Modified: head/sys/dev/ath/ath_dfs/null/dfs_null.c
==============================================================================
--- head/sys/dev/ath/ath_dfs/null/dfs_null.c	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/ath_dfs/null/dfs_null.c	Thu May 25 04:18:46 2017	(r318856)
@@ -102,7 +102,7 @@ ath_dfs_detach(struct ath_softc *sc)
 int
 ath_dfs_radar_enable(struct ath_softc *sc, struct ieee80211_channel *chan)
 {
-#if 0
+#if 1
 	HAL_PHYERR_PARAM pe;
 
 	/* Check if the hardware supports radar reporting */
@@ -155,7 +155,7 @@ ath_dfs_radar_enable(struct ath_softc *s
 int
 ath_dfs_radar_disable(struct ath_softc *sc)
 {
-#if 0
+#if 1
 	HAL_PHYERR_PARAM pe;
 
 	(void) ath_hal_getdfsthresh(sc->sc_ah, &pe);

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/ath_hal/ah.c	Thu May 25 04:18:46 2017	(r318856)
@@ -28,6 +28,23 @@
 
 /* linker set of registered chips */
 OS_SET_DECLARE(ah_chips, struct ath_hal_chip);
+TAILQ_HEAD(, ath_hal_chip) ah_chip_list = TAILQ_HEAD_INITIALIZER(ah_chip_list);
+
+int
+ath_hal_add_chip(struct ath_hal_chip *ahc)
+{
+
+	TAILQ_INSERT_TAIL(&ah_chip_list, ahc, node);
+	return (0);
+}
+
+int
+ath_hal_remove_chip(struct ath_hal_chip *ahc)
+{
+
+	TAILQ_REMOVE(&ah_chip_list, ahc, node);
+	return (0);
+}
 
 /*
  * Check the set of registered chips to see if any recognize
@@ -37,12 +54,22 @@ const char*
 ath_hal_probe(uint16_t vendorid, uint16_t devid)
 {
 	struct ath_hal_chip * const *pchip;
+	struct ath_hal_chip *pc;
 
+	/* Linker set */
 	OS_SET_FOREACH(pchip, ah_chips) {
 		const char *name = (*pchip)->probe(vendorid, devid);
 		if (name != AH_NULL)
 			return name;
 	}
+
+	/* List */
+	TAILQ_FOREACH(pc, &ah_chip_list, node) {
+		const char *name = pc->probe(vendorid, devid);
+		if (name != AH_NULL)
+			return name;
+	}
+
 	return AH_NULL;
 }
 
@@ -60,6 +87,7 @@ ath_hal_attach(uint16_t devid, HAL_SOFTC
 	HAL_STATUS *error)
 {
 	struct ath_hal_chip * const *pchip;
+	struct ath_hal_chip *pc;
 
 	OS_SET_FOREACH(pchip, ah_chips) {
 		struct ath_hal_chip *chip = *pchip;
@@ -82,6 +110,30 @@ ath_hal_attach(uint16_t devid, HAL_SOFTC
 			return ah;
 		}
 	}
+
+	/* List */
+	TAILQ_FOREACH(pc, &ah_chip_list, node) {
+		struct ath_hal_chip *chip = pc;
+		struct ath_hal *ah;
+
+		/* XXX don't have vendorid, assume atheros one works */
+		if (chip->probe(ATHEROS_VENDOR_ID, devid) == AH_NULL)
+			continue;
+		ah = chip->attach(devid, sc, st, sh, eepromdata, ah_config,
+		    error);
+		if (ah != AH_NULL) {
+			/* copy back private state to public area */
+			ah->ah_devid = AH_PRIVATE(ah)->ah_devid;
+			ah->ah_subvendorid = AH_PRIVATE(ah)->ah_subvendorid;
+			ah->ah_macVersion = AH_PRIVATE(ah)->ah_macVersion;
+			ah->ah_macRev = AH_PRIVATE(ah)->ah_macRev;
+			ah->ah_phyRev = AH_PRIVATE(ah)->ah_phyRev;
+			ah->ah_analog5GhzRev = AH_PRIVATE(ah)->ah_analog5GhzRev;
+			ah->ah_analog2GhzRev = AH_PRIVATE(ah)->ah_analog2GhzRev;
+			return ah;
+		}
+	}
+
 	return AH_NULL;
 }
 
@@ -160,6 +212,23 @@ ath_hal_getwirelessmodes(struct ath_hal*
 
 /* linker set of registered RF backends */
 OS_SET_DECLARE(ah_rfs, struct ath_hal_rf);
+TAILQ_HEAD(, ath_hal_rf) ah_rf_list = TAILQ_HEAD_INITIALIZER(ah_rf_list);
+
+int
+ath_hal_add_rf(struct ath_hal_rf *arf)
+{
+
+	TAILQ_INSERT_TAIL(&ah_rf_list, arf, node);
+	return (0);
+}
+
+int
+ath_hal_remove_rf(struct ath_hal_rf *arf)
+{
+
+	TAILQ_REMOVE(&ah_rf_list, arf, node);
+	return (0);
+}
 
 /*
  * Check the set of registered RF backends to see if
@@ -169,12 +238,18 @@ struct ath_hal_rf *
 ath_hal_rfprobe(struct ath_hal *ah, HAL_STATUS *ecode)
 {
 	struct ath_hal_rf * const *prf;
+	struct ath_hal_rf * rf;
 
 	OS_SET_FOREACH(prf, ah_rfs) {
 		struct ath_hal_rf *rf = *prf;
 		if (rf->probe(ah))
 			return rf;
 	}
+
+	TAILQ_FOREACH(rf, &ah_rf_list, node) {
+		if (rf->probe(ah))
+			return rf;
+	}
 	*ecode = HAL_ENOTSUPP;
 	return AH_NULL;
 }

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Thu May 25 04:18:46 2017	(r318856)
@@ -28,6 +28,7 @@
 #define	AH_MAX(a,b)	((a)>(b)?(a):(b))
 
 #include <net80211/_ieee80211.h>
+#include <sys/queue.h>			/* XXX for reasons */
 #include "opt_ah.h"			/* needed for AH_SUPPORT_AR5416 */
 
 #ifndef	AH_SUPPORT_AR5416
@@ -85,6 +86,11 @@ typedef enum {
 
 /*
  * Each chip or class of chips registers to offer support.
+ *
+ * Compiled-in versions will include a linker set to iterate through the
+ * linked in code.
+ *
+ * Modules will have to register HAL backends separately.
  */
 struct ath_hal_chip {
 	const char	*name;
@@ -93,13 +99,14 @@ struct ath_hal_chip {
 			    HAL_BUS_TAG, HAL_BUS_HANDLE, uint16_t *eepromdata,
 			    HAL_OPS_CONFIG *ah,
 			    HAL_STATUS *error);
+	TAILQ_ENTRY(ath_hal_chip) node;
 };
 #ifndef AH_CHIP
 #define	AH_CHIP(_name, _probe, _attach)				\
-static struct ath_hal_chip _name##_chip = {			\
+struct ath_hal_chip _name##_chip = {				\
 	.name		= #_name,				\
 	.probe		= _probe,				\
-	.attach		= _attach				\
+	.attach		= _attach,				\
 };								\
 OS_DATA_SET(ah_chips, _name##_chip)
 #endif
@@ -108,18 +115,24 @@ OS_DATA_SET(ah_chips, _name##_chip)
  * Each RF backend registers to offer support; this is mostly
  * used by multi-chip 5212 solutions.  Single-chip solutions
  * have a fixed idea about which RF to use.
+ *
+ * Compiled in versions will include this linker set to iterate through
+ * the linked in code.
+ *
+ * Modules will have to register RF backends separately.
  */
 struct ath_hal_rf {
 	const char	*name;
 	HAL_BOOL	(*probe)(struct ath_hal *ah);
 	HAL_BOOL	(*attach)(struct ath_hal *ah, HAL_STATUS *ecode);
+	TAILQ_ENTRY(ath_hal_rf) node;
 };
 #ifndef AH_RF
 #define	AH_RF(_name, _probe, _attach)				\
-static struct ath_hal_rf _name##_rf = {				\
+struct ath_hal_rf _name##_rf = {				\
 	.name		= __STRING(_name),			\
 	.probe		= _probe,				\
-	.attach		= _attach				\
+	.attach		= _attach,				\
 };								\
 OS_DATA_SET(ah_rfs, _name##_rf)
 #endif
@@ -1038,4 +1051,12 @@ extern	void ath_hal_survey_clear(struct 
 extern	void ath_hal_survey_add_sample(struct ath_hal *ah,
 	    HAL_SURVEY_SAMPLE *hs);
 
+/*
+ * Chip registration - for modules.
+ */
+extern	int ath_hal_add_chip(struct ath_hal_chip *ahc);
+extern	int ath_hal_remove_chip(struct ath_hal_chip *ahc);
+extern	int ath_hal_add_rf(struct ath_hal_rf *arf);
+extern	int ath_hal_remove_rf(struct ath_hal_rf *arf);
+
 #endif /* _ATH_AH_INTERAL_H_ */

Modified: head/sys/dev/ath/ath_rate/sample/sample.c
==============================================================================
--- head/sys/dev/ath/ath_rate/sample/sample.c	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/ath_rate/sample/sample.c	Thu May 25 04:18:46 2017	(r318856)
@@ -775,6 +775,10 @@ update_stats(struct ath_softc *sc, struc
 	 * XXX Don't mark the higher bit rates as also having failed; as this
 	 * unfortunately stops those rates from being tasted when trying to
 	 * TX. This happens with 11n aggregation.
+	 *
+	 * This is valid for higher CCK rates, higher OFDM rates, and higher
+	 * HT rates within the current number of streams (eg MCS0..7, 8..15,
+	 * etc.)
 	 */
 	if (nframes == nbad) {
 #if 0

Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/if_ath.c	Thu May 25 04:18:46 2017	(r318856)
@@ -6989,8 +6989,11 @@ ath_node_recv_pspoll(struct ieee80211_no
 #endif	/* ATH_SW_PSQ */
 }
 
-MODULE_VERSION(if_ath, 1);
-MODULE_DEPEND(if_ath, wlan, 1, 1, 1);          /* 802.11 media layer */
+MODULE_VERSION(ath_main, 1);
+MODULE_DEPEND(ath_main, wlan, 1, 1, 1);          /* 802.11 media layer */
+MODULE_DEPEND(ath_main, ath_rate, 1, 1, 1);
+MODULE_DEPEND(ath_main, ath_dfs, 1, 1, 1);
+MODULE_DEPEND(ath_main, ath_hal, 1, 1, 1);
 #if	defined(IEEE80211_ALQ) || defined(AH_DEBUG_ALQ) || defined(ATH_DEBUG_ALQ)
-MODULE_DEPEND(if_ath, alq, 1, 1, 1);
+MODULE_DEPEND(ath_main, alq, 1, 1, 1);
 #endif

Modified: head/sys/dev/ath/if_ath_ahb.c
==============================================================================
--- head/sys/dev/ath/if_ath_ahb.c	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/if_ath_ahb.c	Thu May 25 04:18:46 2017	(r318856)
@@ -343,8 +343,9 @@ static driver_t ath_ahb_driver = {
 	sizeof (struct ath_ahb_softc)
 };
 static	devclass_t ath_devclass;
-DRIVER_MODULE(ath, nexus, ath_ahb_driver, ath_devclass, 0, 0);
-DRIVER_MODULE(ath, apb, ath_ahb_driver, ath_devclass, 0, 0);
-MODULE_VERSION(ath, 1);
-MODULE_DEPEND(ath, wlan, 1, 1, 1);		/* 802.11 media layer */
-MODULE_DEPEND(ath, if_ath, 1, 1, 1);		/* if_ath driver */
+DRIVER_MODULE(if_ath_ahb, nexus, ath_ahb_driver, ath_devclass, 0, 0);
+DRIVER_MODULE(if_ath_ahb, apb, ath_ahb_driver, ath_devclass, 0, 0);
+MODULE_VERSION(if_ath_ahb, 1);
+MODULE_DEPEND(if_ath_ahb, wlan, 1, 1, 1);		/* 802.11 media layer */
+MODULE_DEPEND(if_ath_ahb, ath_main, 1, 1, 1);		/* if_ath driver */
+MODULE_DEPEND(if_ath_ahb, ath_hal, 1, 1, 1);		/* ath HAL */

Added: head/sys/dev/ath/if_ath_dfs.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/if_ath_dfs.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2017 Adrian Chadd <adrian@FreeBSD.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *    redistribution must be conditioned upon including a substantially
+ *    similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#include "opt_ah.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+#include <sys/proc.h>
+#include <sys/pcpu.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/conf.h>
+
+static int
+ath_dfs_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		printf("[ath_dfs] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		printf("[ath_dfs] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(ath_dfs, ath_dfs_modevent, NULL);
+MODULE_VERSION(ath_dfs, 1);
+MODULE_DEPEND(ath_dfs, ath_hal, 1, 1, 1);
+MODULE_DEPEND(ath_dfs, wlan, 1, 1, 1);

Added: head/sys/dev/ath/if_ath_drv.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/if_ath_drv.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2017 Adrian Chadd <adrian@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *    redistribution must be conditioned upon including a substantially
+ *    similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#include "opt_ah.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+#include <sys/proc.h>
+#include <sys/pcpu.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/conf.h>
+
+/*
+ * This implements the "old" style ath(4) module behaviour, which loaded the
+ * driver, HAL and PCI glue.
+ */
+
+static int
+ath_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		printf("[ath] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		printf("[ath] unloaded\n");
+		break;
+
+	case MOD_SHUTDOWN:
+		break;
+
+	default:
+		error = EOPNOTSUPP;
+		break;
+
+	}
+	return (error);
+}
+
+DEV_MODULE(if_ath, ath_modevent, NULL);
+
+MODULE_VERSION(if_ath, 1);
+MODULE_DEPEND(if_ath, ath_hal, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_hal_ar5210, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_hal_ar5211, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_hal_ar5212, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_hal_ar5416, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_hal_ar9300, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_rate, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_dfs, 1, 1, 1);
+MODULE_DEPEND(if_ath, wlan, 1, 1, 1);
+MODULE_DEPEND(if_ath, ath_main, 1, 1, 1);
+MODULE_DEPEND(if_ath, if_ath_pci, 1, 1, 1);

Modified: head/sys/dev/ath/if_ath_pci.c
==============================================================================
--- head/sys/dev/ath/if_ath_pci.c	Thu May 25 02:00:37 2017	(r318855)
+++ head/sys/dev/ath/if_ath_pci.c	Thu May 25 04:18:46 2017	(r318856)
@@ -463,7 +463,8 @@ static driver_t ath_pci_driver = {
 	sizeof (struct ath_pci_softc)
 };
 static	devclass_t ath_devclass;
-DRIVER_MODULE(ath_pci, pci, ath_pci_driver, ath_devclass, 0, 0);
-MODULE_VERSION(ath_pci, 1);
-MODULE_DEPEND(ath_pci, wlan, 1, 1, 1);		/* 802.11 media layer */
-MODULE_DEPEND(ath_pci, if_ath, 1, 1, 1);	/* if_ath driver */
+DRIVER_MODULE(if_ath_pci, pci, ath_pci_driver, ath_devclass, 0, 0);
+MODULE_VERSION(if_ath_pci, 1);
+MODULE_DEPEND(if_ath_pci, wlan, 1, 1, 1);		/* 802.11 media layer */
+MODULE_DEPEND(if_ath_pci, ath_main, 1, 1, 1);	/* if_ath driver */
+MODULE_DEPEND(if_ath_pci, ath_hal, 1, 1, 1);	/* ath HAL */

Added: head/sys/dev/ath/if_ath_rate.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/if_ath_rate.c	Thu May 25 04:18:46 2017	(r318856)
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2017 Adrian Chadd <adrian@FreeBSD.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *    redistribution must be conditioned upon including a substantially
+ *    similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * $FreeBSD$
+ */
+#include "opt_ah.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/sysctl.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+#include <sys/proc.h>
+#include <sys/pcpu.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/conf.h>
+
+static int
+ath_rate_modevent(module_t mod __unused, int type, void *data __unused)
+{
+	int error = 0;
+
+	switch (type) {
+	case MOD_LOAD:
+		printf("[ath_rate] loaded\n");
+		break;
+
+	case MOD_UNLOAD:
+		printf("[ath_rate] unloaded\n");
+		break;
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705250418.v4P4IkbT004230>