[bwn] [bhnd] initial support for using bhnd for if_bwn devices.

This is an initial work in progress to use the replacement bhnd
bus code for devices which support it.

* Add manpage updates for bhnd, bhndb, siba
* Add kernel options for bhnd, bhndbus, etc
* Add initial support in if_bwn_pci / if_bwn_mac for using bhnd
  as the bus transport for suppoted NICs
* if_bwn_pci will eventually be the PCI bus glue to interface to bwn,
  which will use the right backend bus to attach to, versus direct
  nexus/bhnd attachments (as found in embedded broadcom devices.)

The PCI glue defaults to probing at a lower level than the bwn glue,
so bwn should still attach as per normal without a boot time tunable set.

It's also not fully fleshed out - the bwn probe/attach code needs to be
broken out into platform and bus specific things (just like ath, ath_pci,
ath_ahb) before we can shift the driver over to using this.

Tested:

* BCM4311, STA mode
* BCM4312, STA mode

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6191
This commit is contained in:
Adrian Chadd 2016-05-04 23:38:27 +00:00
parent 1b34262b0b
commit 148ed57165
17 changed files with 7714 additions and 27 deletions

View File

@ -71,9 +71,12 @@ MAN= aac.4 \
axe.4 \
axge.4 \
bce.4 \
bcma.4 \
bfe.4 \
bge.4 \
${_bhyve.4} \
bhnd.4 \
bhndb.4 \
bktr.4 \
blackhole.4 \
bpf.4 \

78
share/man/man4/bcma.4 Normal file
View File

@ -0,0 +1,78 @@
.\" Copyright (c) 2015 Landon Fuller
.\" Copyright (c) 2010 Weongyo Jeong
.\" 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.
.\" 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 THE 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 THE 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$
.\"
.Dd December 8, 2015
.Dt BCMA 4
.Os
.Sh NAME
.Nm bcma
.Nd Broadcom AMBA Backplane driver
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your kernel configuration file:
.Bd -ragged -offset indent
.Cd "device bhnd"
.Cd "device bcma"
.Ed
.Pp
Alternatively, to load the driver as a module at boot time,
place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
bcma_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver provides
.Xr bhnd 4
support for devices using the ARM AMBA-based backplane architecture found
in later Broadcom Home Networking Division's (HND) wireless chipsets and
embedded systems.
.Pp
A common interconnect connects all of the backplane's functional
blocks. These functional blocks, known as cores, use the ARM AMBA AXI or
APB interface to communicate with devices attached to the interconnect.
.Pp
The IP cores used in
.Xr siba 4
devices were adapted by Broadcom for compatibility with the new
interconnect.
.Sh SEE ALSO
.Xr bcma 4 ,
.Xr bhnd 4
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 11.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Landon Fuller Aq Mt landon@landonf.org .

83
share/man/man4/bhnd.4 Normal file
View File

@ -0,0 +1,83 @@
.\" Copyright (c) 2015 Landon Fuller
.\" 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.
.\" 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 THE 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 THE 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$
.\"
.Dd December 8, 2015
.Dt BHND 4
.Os
.Sh NAME
.Nm bhnd
.Nd Broadcom Home Networking Division interconnect bus
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your kernel configuration file:
.Bd -ragged -offset indent
.Cd "device bhnd"
.Ed
.Pp
Alternatively, to load the driver as a module at boot time,
place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
bhnd_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver provides a unified kernel bus interface to the on-chip
interconnects used in Broadcom Home Networking Division (HND)
devices.
.Pp
The Broadcom HND device family consists of SoCs (System On a Chip)
and host-connected chipsets based on a common library of Broadcom IP
cores connected via an internal hardware bus architecture. Drivers
for these cores are implemented against the unified
.Nm
interface.
.Pp
The Sonic Inc. Silicon Backplane used in earlier HND devices is supported
by the
.Xr siba 4
BHND driver.
.Pp
The ARM AMBA-based interconnect used in later HND devices is supported by
the
.Xr bcma 4
BHND driver.
.Sh SEE ALSO
.Xr bhndb 4 ,
.Xr bcma 4 ,
.Xr siba 4
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 11.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Landon Fuller Aq Mt landon@landonf.org .

72
share/man/man4/bhndb.4 Normal file
View File

@ -0,0 +1,72 @@
.\" Copyright (c) 2015 Landon Fuller
.\" 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.
.\" 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 THE 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 THE 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$
.\"
.Dd December 8, 2015
.Dt BHNDB 4
.Os
.Sh NAME
.Nm bhndb
.Nd Broadcom Home Networking Division interconnect bridge driver
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your kernel configuration file:
.Bd -ragged -offset indent
.Cd "device bhnd"
.Cd "device bhndb"
.Ed
.Pp
Alternatively, to load the driver as a module at boot time,
place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
bhndb_load="YES"
bhndb_pci_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver supports
.Xr bhnd 4
host bridge cores such as those used by Broadcom HND PCI,
PCMCIA, and SDIO network adapters.
.Sh SEE ALSO
.Xr bhnd 4
.Xr bwn 4
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 11.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Landon Fuller Aq Mt landon@landonf.org .
.Sh CAVEATS
The
.Nm
driver does not currently support PCMCIA or SDIO devices.

View File

@ -34,6 +34,7 @@
To compile this driver into the kernel,
place the following lines in your kernel configuration file:
.Bd -ragged -offset indent
.Cd "device bhnd"
.Cd "device siba"
.Ed
.Pp
@ -46,20 +47,17 @@ siba_load="YES"
.Sh DESCRIPTION
The
.Nm
driver supports the Sonic Inc. Silicon Backplane, the interblock
communications architecture that can be found in most Broadcom
wireless NICs.
driver provides
.Xr bhnd 4
support for devices based on the Sonic Inc. Silicon Backplane, an
interblock communications architecture found in earlier Broadcom Home
Networking Division wireless chipsets and embedded systems.
.Pp
A bus connects all of the Silicon Backplane's functional blocks.
These functional blocks, known as cores, use the Open Core Protocol
A common interconnect connects all of the Silicon Backplane's functional
blocks. These functional blocks, known as cores, use the Open Core Protocol
(OCP) interface to communicate with agents attached to the Silicon
Backplane.
.Pp
Each NIC uses a chip from the same chip family.
Each member of the family contains a different set of cores, but
shares basic architectural features such as address space definition,
interrupt and error architecture, and backplane register definitions.
.Pp
Each core can have an initiator agent that passes read and write
requests onto the system backplane and a target agent that returns
responses to those requests.
@ -67,22 +65,29 @@ Not all cores contain both an initiator and a target agent.
Initiator agents are present in cores that contain
host interfaces (PCI, PCMCIA), embedded processors (MIPS),
or DMA processors associated with communications cores.
.Pp
All cores other than PCMCIA have a target agent.
.Sh SEE ALSO
.Xr bwn 4
.Xr bcma 4 ,
.Xr bhnd 4
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 8.0 .
The driver was rewritten for
.Fx 11.0 .
to support the common Broadcom
.Xr bhnd 4
bus interface.
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
driver was originally written by
.An Bruce M. Simpson Aq Mt bms@FreeBSD.org
and
.An Weongyo Jeong Aq Mt weongyo@FreeBSD.org .
.Sh CAVEATS
Host mode is not supported at this moment.
The driver was rewritten for
.Fx 11.0 .
by
.An Landon Fuller Aq Mt landon@landonf.org .

View File

@ -1109,9 +1109,34 @@ dev/ath/ath_rate/sample/sample.c optional ath_rate_sample \
dev/ath/ath_dfs/null/dfs_null.c optional ath \
compile-with "${NORMAL_C} -I$S/dev/ath"
#
dev/bce/if_bce.c optional bce
dev/bfe/if_bfe.c optional bfe
dev/bge/if_bge.c optional bge
dev/bce/if_bce.c optional bce
dev/bfe/if_bfe.c optional bfe
dev/bge/if_bge.c optional bge
dev/bhnd/bhnd.c optional bhndbus | bhnd
dev/bhnd/bhnd_subr.c optional bhndbus | bhnd
dev/bhnd/bhnd_bus_if.m optional bhndbus | bhnd
dev/bhnd/bhndb/bhndb.c optional bhndbus | bhndb
dev/bhnd/bhndb/bhndb_bus_if.m optional bhndbus | bhndb
dev/bhnd/bhndb/bhndb_hwdata.c optional bhndbus | bhndb
dev/bhnd/bhndb/bhndb_if.m optional bhndbus | bhndb
dev/bhnd/bhndb/bhndb_pci.c optional bhndbus pci | bhndb pci
dev/bhnd/bhndb/bhndb_pci_hwdata.c optional bhndbus pci | bhndb pci
dev/bhnd/bhndb/bhndb_subr.c optional bhndbus pci | bhndb
dev/bhnd/bcma/bcma.c optional bhndbus | bcma
dev/bhnd/bcma/bcma_bhndb.c optional bhndbus | bcma bhndb
dev/bhnd/bcma/bcma_erom.c optional bhndbus | bcma
dev/bhnd/bcma/bcma_subr.c optional bhndbus | bcma
dev/bhnd/cores/chipc/chipc.c optional bhndbus | bhnd
dev/bhnd/cores/chipc/bhnd_chipc_if.m optional bhndbus | bhnd
dev/bhnd/cores/pci/bhnd_pci.c optional bhndbus pci | bhnd pci
dev/bhnd/cores/pci/bhnd_pci_hostb.c optional bhndbus pci | bhndb pci
dev/bhnd/cores/pci/bhnd_pcib.c optional bhnd_pcib bhnd pci
dev/bhnd/nvram/bhnd_nvram_if.m optional bhndbus | bhnd
dev/bhnd/siba/siba.c optional bhndbus | siba
dev/bhnd/siba/siba_bhndb.c optional bhndbus | siba bhndb
dev/bhnd/siba/siba_nexus.c optional siba_nexus siba
dev/bhnd/siba/siba_subr.c optional bhndbus | siba
#
dev/bktr/bktr_audio.c optional bktr pci
dev/bktr/bktr_card.c optional bktr pci
dev/bktr/bktr_core.c optional bktr pci
@ -1132,10 +1157,12 @@ dev/bwi/if_bwi_pci.c optional bwi pci
# XXX Work around clang warning, until maintainer approves fix.
dev/bwn/if_bwn.c optional bwn siba_bwn \
compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
dev/bwn/if_bwn_pci.c optional bwn pci bhnd | bwn pci bhndbus
dev/bwn/if_bwn_phy_g.c optional bwn siba_bwn \
compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
dev/bwn/if_bwn_phy_lp.c optional bwn siba_bwn \
compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
dev/bwn/bwn_mac.c optional bwn bhnd | bwn bhndbus
dev/cardbus/cardbus.c optional cardbus
dev/cardbus/cardbus_cis.c optional cardbus
dev/cardbus/cardbus_device.c optional cardbus
@ -2400,11 +2427,11 @@ dev/si/si3_t225.c optional si
dev/si/si_eisa.c optional si eisa
dev/si/si_isa.c optional si isa
dev/si/si_pci.c optional si pci
dev/siba/siba.c optional siba
dev/siba/siba.c optional siba !bhnd !bhndbus
dev/siba/siba_bwn.c optional siba_bwn pci
dev/siba/siba_cc.c optional siba
dev/siba/siba_cc.c optional siba !bhnd !bhndbus
dev/siba/siba_core.c optional siba | siba_bwn pci
dev/siba/siba_pcib.c optional siba pci
dev/siba/siba_pcib.c optional siba pci !bhnd !bhndbus
dev/siis/siis.c optional siis pci
dev/sis/if_sis.c optional sis pci
dev/sk/if_sk.c optional sk pci

View File

@ -536,8 +536,7 @@ bhndb_attach(device_t dev, bhnd_devclass_t bridge_devclass)
}
/* Attach our bridged bus device */
sc->bus_dev = BUS_ADD_CHILD(dev, 0, devclass_get_name(bhnd_devclass),
-1);
sc->bus_dev = BUS_ADD_CHILD(dev, 0, "bhnd", -1);
if (sc->bus_dev == NULL) {
error = ENXIO;
goto failed;

View File

@ -464,6 +464,7 @@ DEFINE_CLASS_1(bhndb, bhndb_pci_driver, bhndb_pci_methods,
sizeof(struct bhndb_pci_softc), bhndb_driver);
MODULE_VERSION(bhndb_pci, 1);
MODULE_DEPEND(bhndb_pci, bhnd_pci, 1, 1, 1);
MODULE_DEPEND(bhndb_pci, bhnd_pci_hostb, 1, 1, 1);
MODULE_DEPEND(bhndb_pci, pci, 1, 1, 1);
MODULE_DEPEND(bhndb_pci, bhndb, 1, 1, 1);
MODULE_DEPEND(bhndb_pci, bhnd, 1, 1, 1);

View File

@ -52,8 +52,7 @@ bhndb_attach_bridge(device_t parent, device_t *bhndb, int unit)
{
int error;
*bhndb = device_add_child(parent, devclass_get_name(bhndb_devclass),
unit);
*bhndb = device_add_child(parent, "bhndb", unit);
if (*bhndb == NULL)
return (ENXIO);

141
sys/dev/bwn/bwn_mac.c Normal file
View File

@ -0,0 +1,141 @@
/*-
* Copyright (c) 2015 Landon Fuller <landon@landonf.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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <dev/bhnd/bhnd.h>
#include <dev/bhnd/bhnd_ids.h>
static const struct resource_spec bwn_rspec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ -1, -1, 0 }
};
#define RSPEC_LEN (sizeof(bwn_rspec)/sizeof(bwn_rspec[0]))
struct bwn_softc {
struct resource_spec rspec[RSPEC_LEN];
struct bhnd_resource *res[RSPEC_LEN-1];
};
static const struct bwn_device {
uint16_t vendor;
uint16_t device;
} bwn_devices[] = {
{ BHND_MFGID_BCM, BHND_COREID_D11 },
{ BHND_MFGID_INVALID, BHND_COREID_INVALID }
};
static int
bwn_probe(device_t dev)
{
const struct bwn_device *id;
for (id = bwn_devices; id->device != BHND_COREID_INVALID; id++)
{
if (bhnd_get_vendor(dev) == id->vendor &&
bhnd_get_device(dev) == id->device)
{
device_set_desc(dev, bhnd_get_device_name(dev));
return (BUS_PROBE_DEFAULT);
}
}
return (ENXIO);
}
static int
bwn_attach(device_t dev)
{
struct bwn_softc *sc;
struct bhnd_resource *r;
int error;
sc = device_get_softc(dev);
memcpy(sc->rspec, bwn_rspec, sizeof(bwn_rspec));
if ((error = bhnd_alloc_resources(dev, sc->rspec, sc->res)))
return (error);
// XXX TODO
r = sc->res[0];
device_printf(dev, "got rid=%d res=%p\n", sc->rspec[0].rid, r);
return (0);
}
static int
bwn_detach(device_t dev)
{
struct bwn_softc *sc;
sc = device_get_softc(dev);
bhnd_release_resources(dev, sc->rspec, sc->res);
return (0);
}
static int
bwn_suspend(device_t dev)
{
return (0);
}
static int
bwn_resume(device_t dev)
{
return (0);
}
static device_method_t bwn_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, bwn_probe),
DEVMETHOD(device_attach, bwn_attach),
DEVMETHOD(device_detach, bwn_detach),
DEVMETHOD(device_suspend, bwn_suspend),
DEVMETHOD(device_resume, bwn_resume),
DEVMETHOD_END
};
static devclass_t bwn_devclass;
DEFINE_CLASS_0(bwn, bwn_driver, bwn_methods, sizeof(struct bwn_softc));
DRIVER_MODULE(bwn_mac, bhnd, bwn_driver, bwn_devclass, 0, 0);
MODULE_DEPEND(bwn_mac, bhnd, 1, 1, 1);
MODULE_VERSION(bwn_mac, 1);

View File

@ -6879,3 +6879,4 @@ MODULE_DEPEND(bwn, siba_bwn, 1, 1, 1);
MODULE_DEPEND(bwn, wlan, 1, 1, 1); /* 802.11 media layer */
MODULE_DEPEND(bwn, firmware, 1, 1, 1); /* firmware support */
MODULE_DEPEND(bwn, wlan_amrr, 1, 1, 1);
MODULE_VERSION(bwn, 1);

6881
sys/dev/bwn/if_bwn.c.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,8 @@
#ifndef __IF_BWN_DEBUG_H__
#define __IF_BWN_DEBUG_H__
#define BWN_DEBUG
enum {
BWN_DEBUG_XMIT = 0x00000001, /* basic xmit operation */
BWN_DEBUG_RECV = 0x00000002, /* basic recv operation */

288
sys/dev/bwn/if_bwn_pci.c Normal file
View File

@ -0,0 +1,288 @@
/*-
* Copyright (c) 2015 Landon Fuller <landon@landonf.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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/bhnd/bhndb/bhndb_pcivar.h>
#include <dev/bhnd/bhndb/bhndb_pci_hwdata.h>
#include <dev/bhnd/bhnd_ids.h>
#include "bhndb_bus_if.h"
#include "if_bwn_pcivar.h"
/* If non-zero, enable attachment of BWN_QUIRK_UNTESTED devices */
static int attach_untested = 0;
TUNABLE_INT("hw.bwn_pci.attach_untested", &attach_untested);
/* If non-zero, probe at a higher priority than the stable if_bwn driver. */
static int prefer_new_driver = 0;
TUNABLE_INT("hw.bwn_pci.preferred", &prefer_new_driver);
/* SIBA Devices */
static const struct bwn_pci_device siba_devices[] = {
BWN_BCM_DEV(BCM4301, "BCM4301 802.11b",
BWN_QUIRK_ENET_HW_UNPOPULATED),
BWN_BCM_DEV(BCM4306, "BCM4306 802.11b/g", 0),
BWN_BCM_DEV(BCM4306_D11G, "BCM4306 802.11g", 0),
BWN_BCM_DEV(BCM4306_D11A, "BCM4306 802.11a",
BWN_QUIRK_WLAN_DUALCORE),
BWN_BCM_DEV(BCM4306_D11DUAL, "BCM4306 802.11a/b",
BWN_QUIRK_WLAN_DUALCORE),
BWN_BCM_DEV(BCM4306_D11G_ID2, "BCM4306 802.11g", 0),
BWN_BCM_DEV(BCM4307, "BCM4307 802.11b", 0),
BWN_BCM_DEV(BCM4311_D11G, "BCM4311 802.11b/g", 0),
BWN_BCM_DEV(BCM4311_D11DUAL, "BCM4311 802.11a/b/g", 0),
BWN_BCM_DEV(BCM4311_D11A, "BCM4311 802.11a",
BWN_QUIRK_UNTESTED|BWN_QUIRK_WLAN_DUALCORE),
BWN_BCM_DEV(BCM4318_D11G, "BCM4318 802.11b/g", 0),
BWN_BCM_DEV(BCM4318_D11DUAL, "BCM4318 802.11a/b/g", 0),
BWN_BCM_DEV(BCM4318_D11A, "BCM4318 802.11a",
BWN_QUIRK_UNTESTED|BWN_QUIRK_WLAN_DUALCORE),
BWN_BCM_DEV(BCM4321_D11N, "BCM4321 802.11n Dual-Band", 0),
BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 2GHz", 0),
BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 5GHz",
BWN_QUIRK_UNTESTED),
BWN_BCM_DEV(BCM4322_D11N, "BCM4322 802.11n Dual-Band", 0),
BWN_BCM_DEV(BCM4322_D11N2G, "BCM4322 802.11n 2GHz",
BWN_QUIRK_UNTESTED),
BWN_BCM_DEV(BCM4322_D11N5G, "BCM4322 802.11n 5GHz",
BWN_QUIRK_UNTESTED),
BWN_BCM_DEV(BCM4328_D11G, "BCM4328/4312 802.11g", 0),
{ 0, 0, NULL, 0 }
};
/** BCMA Devices */
static const struct bwn_pci_device bcma_devices[] = {
BWN_BCM_DEV(BCM4331_D11N, "BCM4331 802.11n Dual-Band", 0),
BWN_BCM_DEV(BCM4331_D11N2G, "BCM4331 802.11n 2GHz", 0),
BWN_BCM_DEV(BCM4331_D11N5G, "BCM4331 802.11n 5GHz", 0),
{ 0, 0, NULL, 0}
};
/** Device configuration table */
static const struct bwn_pci_devcfg bwn_pci_devcfgs[] = {
/* SIBA devices */
{
.bridge_hwcfg = &bhndb_pci_siba_generic_hwcfg,
.bridge_hwtable = bhndb_pci_generic_hw_table,
.devices = siba_devices
},
/* BCMA devices */
{
.bridge_hwcfg = &bhndb_pci_bcma_generic_hwcfg,
.bridge_hwtable = bhndb_pci_generic_hw_table,
.devices = bcma_devices
},
{ NULL, NULL, NULL }
};
/** Search the device configuration table for an entry matching @p dev. */
static int
bwn_pci_find_devcfg(device_t dev, const struct bwn_pci_devcfg **cfg,
const struct bwn_pci_device **device)
{
const struct bwn_pci_devcfg *dvc;
const struct bwn_pci_device *dv;
for (dvc = bwn_pci_devcfgs; dvc->devices != NULL; dvc++) {
for (dv = dvc->devices; dv->device != 0; dv++) {
if (pci_get_vendor(dev) == dv->vendor &&
pci_get_device(dev) == dv->device)
{
if (cfg != NULL)
*cfg = dvc;
if (device != NULL)
*device = dv;
return (0);
}
}
}
return (ENOENT);
}
static int
bwn_pci_probe(device_t dev)
{
const struct bwn_pci_device *ident;
if (bwn_pci_find_devcfg(dev, NULL, &ident))
return (ENXIO);
/* Skip untested devices */
if (ident->quirks & BWN_QUIRK_UNTESTED && !attach_untested)
return (ENXIO);
device_set_desc(dev, ident->desc);
/* Until this driver is complete, require explicit opt-in before
* superceding if_bwn/siba_bwn. */
if (prefer_new_driver)
return (BUS_PROBE_DEFAULT+1);
else
return (BUS_PROBE_LOW_PRIORITY);
// return (BUS_PROBE_DEFAULT);
}
static int
bwn_pci_attach(device_t dev)
{
struct bwn_pci_softc *sc;
const struct bwn_pci_device *ident;
int error;
sc = device_get_softc(dev);
sc->dev = dev;
/* Find our hardware config */
if (bwn_pci_find_devcfg(dev, &sc->devcfg, &ident))
return (ENXIO);
/* Save quirk flags */
sc->quirks = ident->quirks;
/* Attach bridge device */
if ((error = bhndb_attach_bridge(dev, &sc->bhndb_dev, -1)))
return (ENXIO);
/* Success */
return (0);
}
static int
bwn_pci_detach(device_t dev)
{
return (bus_generic_detach(dev));
}
static void
bwn_pci_probe_nomatch(device_t dev, device_t child)
{
const char *name;
name = device_get_name(child);
if (name == NULL)
name = "unknown device";
device_printf(dev, "<%s> (no driver attached)\n", name);
}
static const struct bhndb_hwcfg *
bwn_pci_get_generic_hwcfg(device_t dev, device_t child)
{
struct bwn_pci_softc *sc = device_get_softc(dev);
return (sc->devcfg->bridge_hwcfg);
}
static const struct bhndb_hw *
bwn_pci_get_bhndb_hwtable(device_t dev, device_t child)
{
struct bwn_pci_softc *sc = device_get_softc(dev);
return (sc->devcfg->bridge_hwtable);
}
static bool
bwn_pci_is_core_disabled(device_t dev, device_t child,
struct bhnd_core_info *core)
{
struct bwn_pci_softc *sc;
sc = device_get_softc(dev);
switch (bhnd_core_class(core)) {
case BHND_DEVCLASS_WLAN:
if (core->unit > 0 && !(sc->quirks & BWN_QUIRK_WLAN_DUALCORE))
return (true);
return (false);
case BHND_DEVCLASS_ENET:
case BHND_DEVCLASS_ENET_MAC:
case BHND_DEVCLASS_ENET_PHY:
return ((sc->quirks & BWN_QUIRK_ENET_HW_UNPOPULATED) != 0);
default:
return (false);
}
}
static device_method_t bwn_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, bwn_pci_probe),
DEVMETHOD(device_attach, bwn_pci_attach),
DEVMETHOD(device_detach, bwn_pci_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
/* Bus interface */
DEVMETHOD(bus_probe_nomatch, bwn_pci_probe_nomatch),
/* BHNDB_BUS Interface */
DEVMETHOD(bhndb_bus_get_generic_hwcfg, bwn_pci_get_generic_hwcfg),
DEVMETHOD(bhndb_bus_get_hardware_table, bwn_pci_get_bhndb_hwtable),
DEVMETHOD(bhndb_bus_is_core_disabled, bwn_pci_is_core_disabled),
DEVMETHOD_END
};
static devclass_t bwn_pci_devclass;
DEFINE_CLASS_0(bwn_pci, bwn_pci_driver, bwn_pci_methods, sizeof(struct bwn_pci_softc));
DRIVER_MODULE(bwn_pci, pci, bwn_pci_driver, bwn_pci_devclass, NULL, NULL);
DRIVER_MODULE(bhndb, bwn_pci, bhndb_pci_driver, bhndb_devclass, NULL, NULL);
MODULE_DEPEND(bwn_pci, bwn, 1, 1, 1);
MODULE_DEPEND(bwn_pci, bhndb, 1, 1, 1);
MODULE_DEPEND(bwn_pci, bhndb_pci, 1, 1, 1);
MODULE_DEPEND(bwn_pci, bcma_bhndb, 1, 1, 1);
MODULE_DEPEND(bwn_pci, siba_bhndb, 1, 1, 1);

View File

@ -0,0 +1,93 @@
/*-
* Copyright (c) 2015 Landon Fuller <landon@landonf.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$
*/
#ifndef _IF_BWN_PCIVAR_H_
#define _IF_BWN_PCIVAR_H_
struct bwn_pci_devcfg;
/** bwn_pci per-instance state. */
struct bwn_pci_softc {
device_t dev; /**< device */
device_t bhndb_dev; /**< bhnd bridge device */
const struct bwn_pci_devcfg *devcfg; /**< bwn device config */
uint32_t quirks; /**< quirk flags */
};
/* bwn device quirks */
enum {
/** No quirks */
BWN_QUIRK_NONE = 0,
/**
* This model/revision has not been tested and may not work.
*/
BWN_QUIRK_UNTESTED = 1<<0,
/**
* Early dual-band devices did not support accessing multiple PHYs
* from a single WLAN core, and instead used separate 2GHz and 5GHz
* WLAN cores.
*
* However, not all cards with two WLAN cores are fully populated;
* we must whitelist the boards on which a second WLAN core is actually
* usable.
*/
BWN_QUIRK_WLAN_DUALCORE = 1<<1,
/**
* Some early devices shipped with unconnected ethernet cores; set
* this quirk to treat these cores as unpopulated.
*/
BWN_QUIRK_ENET_HW_UNPOPULATED = 1<<2,
};
/* PCI device descriptor */
struct bwn_pci_device {
uint16_t vendor;
uint16_t device;
const char *desc;
uint32_t quirks;
};
#define BWN_BCM_DEV(_devid, _desc, _quirks) \
{ PCI_VENDOR_BROADCOM, PCI_DEVID_ ## _devid, \
"Broadcom " _desc " Wireless", _quirks }
/* Supported device table */
struct bwn_pci_devcfg {
const struct bhndb_hwcfg *bridge_hwcfg;
const struct bhndb_hw *bridge_hwtable;
const struct bwn_pci_device *devices;
};
#endif /* _IF_BWN_PCIVAR_H_ */

View File

@ -50,7 +50,9 @@ SUBDIR= \
${_auxio} \
${_bce} \
bfe \
bhnd \
bge \
bhnd \
${_bxe} \
${_bios} \
${_bktr} \
@ -58,6 +60,7 @@ SUBDIR= \
bridgestp \
bwi \
bwn \
bwn_pci \
cam \
${_canbepm} \
${_canbus} \

View File

@ -0,0 +1,11 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../dev/bwn
KMOD= if_bwn_pci
SRCS= if_bwn_pci.c bwn_mac.c
SRCS+= device_if.h bus_if.h pci_if.h \
bhnd_bus_if.h bhndb_bus_if.h \
bhndb_if.h
.include <bsd.kmod.mk>