2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2010 Juli Mallett <jmallett@FreeBSD.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * Cavium Octeon Ethernet pseudo-bus attachment.
35 #include <sys/param.h>
36 #include <sys/systm.h>
38 #include <sys/endian.h>
39 #include <sys/kernel.h>
42 #include <sys/module.h>
43 #include <sys/mutex.h>
45 #include <sys/socket.h>
46 #include <sys/sockio.h>
47 #include <sys/sysctl.h>
49 #include "ethernet-common.h"
51 #include "octebusvar.h"
53 static void octebus_identify(driver_t *drv, device_t parent);
54 static int octebus_probe(device_t dev);
55 static int octebus_attach(device_t dev);
56 static int octebus_detach(device_t dev);
57 static int octebus_shutdown(device_t dev);
59 static device_method_t octebus_methods[] = {
60 /* Device interface */
61 DEVMETHOD(device_identify, octebus_identify),
62 DEVMETHOD(device_probe, octebus_probe),
63 DEVMETHOD(device_attach, octebus_attach),
64 DEVMETHOD(device_detach, octebus_detach),
65 DEVMETHOD(device_shutdown, octebus_shutdown),
68 DEVMETHOD(bus_add_child, bus_generic_add_child),
73 static driver_t octebus_driver = {
76 sizeof (struct octebus_softc),
79 static devclass_t octebus_devclass;
81 DRIVER_MODULE(octebus, ciu, octebus_driver, octebus_devclass, 0, 0);
84 octebus_identify(driver_t *drv, device_t parent)
86 BUS_ADD_CHILD(parent, 0, "octebus", 0);
90 octebus_probe(device_t dev)
92 if (device_get_unit(dev) != 0)
94 device_set_desc(dev, "Cavium Octeon Ethernet pseudo-bus");
99 octebus_attach(device_t dev)
101 struct octebus_softc *sc;
104 sc = device_get_softc(dev);
107 rv = cvm_oct_init_module(dev);
115 octebus_detach(device_t dev)
117 cvm_oct_cleanup_module(dev);
122 octebus_shutdown(device_t dev)
124 return (octebus_detach(dev));