svn commit: r207090 - in user/jmallett/octeon/sys/mips/cavium: .
octe
Juli Mallett
jmallett at FreeBSD.org
Fri Apr 23 01:45:38 UTC 2010
Author: jmallett
Date: Fri Apr 23 01:45:38 2010
New Revision: 207090
URL: http://svn.freebsd.org/changeset/base/207090
Log:
Use a pseudo-bus to manage the octe interfaces and punt, for now, on giving
them each their own device_t.
Added:
user/jmallett/octeon/sys/mips/cavium/octe/octebus.c
Modified:
user/jmallett/octeon/sys/mips/cavium/files.octeon1
user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h
user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c
Modified: user/jmallett/octeon/sys/mips/cavium/files.octeon1
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/files.octeon1 Fri Apr 23 01:34:01 2010 (r207089)
+++ user/jmallett/octeon/sys/mips/cavium/files.octeon1 Fri Apr 23 01:45:38 2010 (r207090)
@@ -27,6 +27,7 @@ mips/cavium/octe/ethernet-sgmii.c optio
mips/cavium/octe/ethernet-spi.c optional octe
mips/cavium/octe/ethernet-tx.c optional octe
mips/cavium/octe/ethernet-xaui.c optional octe
+mips/cavium/octe/octebus.c optional octe
contrib/octeon-sdk/cvmx-bootmem.c optional octe
contrib/octeon-sdk/cvmx-cmd-queue.c optional octe
Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h Fri Apr 23 01:34:01 2010 (r207089)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet-common.h Fri Apr 23 01:45:38 2010 (r207090)
@@ -30,6 +30,9 @@ AND WITH ALL FAULTS AND CAVIUM NETWORKS
int cvm_oct_common_init(struct ifnet *ifp);
void cvm_oct_common_uninit(struct ifnet *ifp);
+int cvm_oct_init_module(void);
+void cvm_oct_cleanup_module(void);
+
/*
* XXX/juli
* These belong elsewhere but we can't stomach the nested extern.
Modified: user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c
==============================================================================
--- user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c Fri Apr 23 01:34:01 2010 (r207089)
+++ user/jmallett/octeon/sys/mips/cavium/octe/ethernet.c Fri Apr 23 01:45:38 2010 (r207090)
@@ -327,16 +327,14 @@ int cvm_oct_free_work(void *work_queue_e
*
* @return Zero on success
*/
-static int cvm_oct_init_module(void)
+int cvm_oct_init_module(void)
{
- device_t dev;
+ int ifnum;
int num_interfaces;
int interface;
int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
int qos;
- dev = NULL;
-
printf("cavium-ethernet: %s\n", OCTEON_SDK_VERSION_STRING);
#if 0
@@ -365,6 +363,8 @@ static int cvm_oct_init_module(void)
memset(cvm_oct_device, 0, sizeof(cvm_oct_device));
+ ifnum = 0;
+
/* Initialize the FAU used for counting packet buffers that need to be freed */
cvmx_fau_atomic_write32(FAU_NUM_PACKET_BUFFERS_TO_FREE, 0);
@@ -382,7 +382,9 @@ static int cvm_oct_init_module(void)
priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED;
priv->port = CVMX_PIP_NUM_INPUT_PORTS;
priv->queue = -1;
- device_set_desc(dev, "Cavium Octeon POW Ethernet");
+
+ if_initname(ifp, "octe", ifnum++);
+ if_printf(ifp, "Cavium Octeon POW Ethernet\n");
#if 0
for (qos = 0; qos < 16; qos++)
m_queue_head_init(&priv->tx_free_list[qos]);
@@ -438,6 +440,8 @@ static int cvm_oct_init_module(void)
for (qos = 0; qos < cvmx_pko_get_num_queues(port); qos++)
cvmx_fau_atomic_write32(priv->fau+qos*4, 0);
+ if_initname(ifp, "octe", ifnum++);
+
switch (priv->imode) {
/* These types don't support ports to IPD/PKO */
@@ -449,43 +453,43 @@ static int cvm_oct_init_module(void)
case CVMX_HELPER_INTERFACE_MODE_NPI:
priv->init = cvm_oct_common_init;
priv->uninit = cvm_oct_common_uninit;
- device_set_desc(dev, "Cavium Octeon NPI Ethernet");
+ if_printf(ifp, "Cavium Octeon NPI Ethernet\n");
break;
case CVMX_HELPER_INTERFACE_MODE_XAUI:
priv->init = cvm_oct_xaui_init;
priv->uninit = cvm_oct_xaui_uninit;
- device_set_desc(dev, "Cavium Octeon XAUI Ethernet");
+ if_printf(ifp, "Cavium Octeon XAUI Ethernet\n");
break;
case CVMX_HELPER_INTERFACE_MODE_LOOP:
priv->init = cvm_oct_common_init;
priv->uninit = cvm_oct_common_uninit;
- device_set_desc(dev, "Cavium Octeon LOOP Ethernet");
+ if_printf(ifp, "Cavium Octeon LOOP Ethernet\n");
break;
case CVMX_HELPER_INTERFACE_MODE_SGMII:
priv->init = cvm_oct_sgmii_init;
priv->uninit = cvm_oct_sgmii_uninit;
- device_set_desc(dev, "Cavium Octeon SGMII Ethernet");
+ if_printf(ifp, "Cavium Octeon SGMII Ethernet\n");
break;
case CVMX_HELPER_INTERFACE_MODE_SPI:
priv->init = cvm_oct_spi_init;
priv->uninit = cvm_oct_spi_uninit;
- device_set_desc(dev, "Cavium Octeon SPI Ethernet");
+ if_printf(ifp, "Cavium Octeon SPI Ethernet\n");
break;
case CVMX_HELPER_INTERFACE_MODE_RGMII:
priv->init = cvm_oct_rgmii_init;
priv->uninit = cvm_oct_rgmii_uninit;
- device_set_desc(dev, "Cavium Octeon RGMII Ethernet");
+ if_printf(ifp, "Cavium Octeon RGMII Ethernet\n");
break;
case CVMX_HELPER_INTERFACE_MODE_GMII:
priv->init = cvm_oct_rgmii_init;
priv->uninit = cvm_oct_rgmii_uninit;
- device_set_desc(dev, "Cavium Octeon GMII Ethernet");
+ if_printf(ifp, "Cavium Octeon GMII Ethernet\n");
break;
}
@@ -533,7 +537,7 @@ static int cvm_oct_init_module(void)
*
* @return Zero on success
*/
-static void cvm_oct_cleanup_module(void)
+void cvm_oct_cleanup_module(void)
{
int port;
@@ -580,22 +584,3 @@ static void cvm_oct_cleanup_module(void)
if (CVMX_FPA_OUTPUT_BUFFER_POOL != CVMX_FPA_PACKET_POOL)
cvm_oct_mem_empty_fpa(CVMX_FPA_OUTPUT_BUFFER_POOL, CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, 128);
}
-
-static int
-cvm_oct_modevent(module_t mod __unused, int type, void *data __unused)
-{
- switch(type) {
- case MOD_LOAD:
- cvm_oct_init_module();
- break;
- case MOD_UNLOAD:
- case MOD_SHUTDOWN:
- cvm_oct_cleanup_module();
- break;
- default:
- return (EOPNOTSUPP);
- }
- return (0);
-}
-DEV_MODULE(octe, cvm_oct_modevent, NULL);
-MODULE_VERSION(octe, 1);
Added: user/jmallett/octeon/sys/mips/cavium/octe/octebus.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/jmallett/octeon/sys/mips/cavium/octe/octebus.c Fri Apr 23 01:45:38 2010 (r207090)
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (c) 2010 Juli Mallett <jmallett at 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.
+ * 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$
+ */
+
+/*
+ * Cavium Octeon Ethernet pseudo-bus attachment.
+ *
+ * XXX Would be nice to have a device for each iface.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/kernel.h>
+#include <sys/mbuf.h>
+#include <sys/lock.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/rman.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+
+#include "ethernet-common.h"
+
+static void octebus_identify(driver_t *drv, device_t parent);
+static int octebus_probe(device_t dev);
+static int octebus_attach(device_t dev);
+static int octebus_detach(device_t dev);
+static int octebus_shutdown(device_t dev);
+
+static device_method_t octebus_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_identify, octebus_identify),
+ DEVMETHOD(device_probe, octebus_probe),
+ DEVMETHOD(device_attach, octebus_attach),
+ DEVMETHOD(device_detach, octebus_detach),
+ DEVMETHOD(device_shutdown, octebus_shutdown),
+
+ { 0, 0 }
+};
+
+static driver_t octebus_driver = {
+ "octebus",
+ octebus_methods,
+ 1,
+};
+
+static devclass_t octebus_devclass;
+
+DRIVER_MODULE(octebus, nexus, octebus_driver, octebus_devclass, 0, 0);
+
+static void
+octebus_identify(driver_t *drv, device_t parent)
+{
+ BUS_ADD_CHILD(parent, 0, "octebus", 0);
+}
+
+static int
+octebus_probe(device_t dev)
+{
+ if (device_get_unit(dev) != 0)
+ return (ENXIO);
+ device_set_desc(dev, "Cavium Octeon Ethernet pseudo-bus");
+ return (0);
+}
+
+static int
+octebus_attach(device_t dev)
+{
+ int rv;
+
+ rv = cvm_oct_init_module();
+ if (rv != 0)
+ return (ENXIO);
+ return (0);
+}
+
+static int
+octebus_detach(device_t dev)
+{
+ cvm_oct_cleanup_module();
+ return (0);
+}
+
+static int
+octebus_shutdown(device_t dev)
+{
+ return (octebus_detach(dev));
+}
More information about the svn-src-user
mailing list