PERFORCE change 134460 for review
Randall R. Stewart
rrs at FreeBSD.org
Wed Jan 30 02:00:15 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=134460
Change 134460 by rrs at rrs-mips2-jnpr on 2008/01/30 09:59:44
rest of the s9 indent
Affected files ...
.. //depot/projects/mips2-jnpr/src/sys/dev/rgmii/octeon_rgmx.c#2 edit
.. //depot/projects/mips2-jnpr/src/sys/dev/rgmii/octeon_rgmx.h#2 edit
Differences ...
==== //depot/projects/mips2-jnpr/src/sys/dev/rgmii/octeon_rgmx.c#2 (text+ko) ====
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2007 Cavium Networks (support at cavium.com). All rights
+Copyright (c) 2003-2007 Cavium Networks (support at cavium.com). All rights
reserved.
Redistribution and use in source and binary forms, with or without
@@ -17,25 +17,25 @@
* Neither the name of Cavium Networks nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
- permission.
+ permission.
-This Software, including technical data, may be subject to U.S. export
-control laws, including the U.S. Export Administration Act and its
-associated regulations, and may be subject to export or import
-regulations in other countries. You warrant that You will comply
-strictly in all respects with all such regulations and acknowledge that
-you have the responsibility to obtain licenses to export, re-export or
-import the Software.
+This Software, including technical data, may be subject to U.S. export
+control laws, including the U.S. Export Administration Act and its
+associated regulations, and may be subject to export or import
+regulations in other countries. You warrant that You will comply
+strictly in all respects with all such regulations and acknowledge that
+you have the responsibility to obtain licenses to export, re-export or
+import the Software.
-TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
-AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
-OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT
-TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
-REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
-DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF
-TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
-LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
-OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
+TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
+AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
+OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT
+TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
+REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
+DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF
+TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
+LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
+OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
*/
@@ -114,7 +114,8 @@
#define OCTEON_RGMX_OQUEUE_PER_PORT 8
-#define OCTEON_RGMX_SCHEDULED_ISRS 1 /* Use Scheduled ISRs from kernel tasks */
+#define OCTEON_RGMX_SCHEDULED_ISRS 1 /* Use Scheduled ISRs from
+ * kernel tasks */
#ifndef POW_MAX_LOOP
@@ -133,31 +134,32 @@
/* Driver data */
struct rgmx_softc_dev {
- device_t sc_dev; /* Device ID */
- uint64_t link_status;
- struct ifnet *ifp;
- int sc_unit;
+ device_t sc_dev; /* Device ID */
+ uint64_t link_status;
+ struct ifnet *ifp;
+ int sc_unit;
- u_int port;
- u_int idx;
- u_char ieee[6];
+ u_int port;
+ u_int idx;
+ u_char ieee[6];
- char const * typestr; /* printable name of the interface. */
- u_short txb_size; /* size of TX buffer, in bytes */
+ char const *typestr; /* printable name of the interface. */
+ u_short txb_size; /* size of TX buffer, in bytes */
- /* Transmission buffer management. */
- u_short txb_free; /* free bytes in TX buffer */
- u_char txb_count; /* number of packets in TX buffer */
- u_char txb_sched; /* number of scheduled packets */
+ /* Transmission buffer management. */
+ u_short txb_free; /* free bytes in TX buffer */
+ u_char txb_count; /* number of packets in TX buffer */
+ u_char txb_sched; /* number of scheduled packets */
- /* Media information. */
- struct ifmedia media; /* used by if_media. */
- u_short mbitmap; /* bitmap for supported media; see bit2media */
- int defmedia; /* default media */
- struct ifqueue tx_pending_queue; /* Queue of mbuf given to PKO currently */
- octeon_pko_sw_queue_info_t *outq_ptr;
+ /* Media information. */
+ struct ifmedia media; /* used by if_media. */
+ u_short mbitmap; /* bitmap for supported media; see bit2media */
+ int defmedia; /* default media */
+ struct ifqueue tx_pending_queue; /* Queue of mbuf given to PKO
+ * currently */
+ octeon_pko_sw_queue_info_t *outq_ptr;
- struct mtx mtx;
+ struct mtx mtx;
};
@@ -199,8 +201,10 @@
static void octeon_rgmx_isr_link(void *context, int pending);
static void octeon_rgmx_isr_rxtx(void *context, int pending);
static int octeon_rgmx_intr_fast(void *arg);
+
#else
static int octeon_rgmx_intr(void *arg);
+
#endif
@@ -210,28 +214,30 @@
/* Standard driver entry points. These can be static. */
-static void octeon_rgmx_init (void *);
-//static driver_intr_t rgmx_intr;
-static int octeon_rgmx_ioctl (struct ifnet *, u_long, caddr_t);
-static void octeon_rgmx_output_start (struct ifnet *);
-static void octeon_rgmx_output_start_locked (struct ifnet *);
+static void octeon_rgmx_init(void *);
+//static driver_intr_t rgmx_intr;
+static int octeon_rgmx_ioctl(struct ifnet *, u_long, caddr_t);
+static void octeon_rgmx_output_start(struct ifnet *);
+static void octeon_rgmx_output_start_locked(struct ifnet *);
+
#if 0
-static void octeon_rgmx_watchdog (struct ifnet *);
+static void octeon_rgmx_watchdog(struct ifnet *);
+
#endif
-static int octeon_rgmx_medchange (struct ifnet *);
-static void octeon_rgmx_medstat (struct ifnet *, struct ifmediareq *);
+static int octeon_rgmx_medchange(struct ifnet *);
+static void octeon_rgmx_medstat(struct ifnet *, struct ifmediareq *);
/* Mapping between media bitmap (in fe_softc.mbitmap) and ifm_media. */
-static int const bit2media [] = {
- IFM_ETHER | IFM_AUTO,
- IFM_ETHER | IFM_MANUAL,
- IFM_ETHER | IFM_10_T,
- IFM_ETHER | IFM_10_2,
- IFM_ETHER | IFM_10_5,
- IFM_ETHER | IFM_10_FL,
- IFM_ETHER | IFM_10_T,
- /* More can be added here... */
+static int const bit2media[] = {
+ IFM_ETHER | IFM_AUTO,
+ IFM_ETHER | IFM_MANUAL,
+ IFM_ETHER | IFM_10_T,
+ IFM_ETHER | IFM_10_2,
+ IFM_ETHER | IFM_10_5,
+ IFM_ETHER | IFM_10_FL,
+ IFM_ETHER | IFM_10_T,
+ /* More can be added here... */
};
/* Mapping between media bitmap (in fe_softc.mbitmap) and ifm_media. */
@@ -250,116 +256,123 @@
static u_int port_array[OCTEON_RGMX_NUM_PORTS_MAX] = {0};
static u_int num_devices = 0;
static octeon_pko_sw_queue_info_t output_queues_array[OCTEON_RGMX_NUM_PORTS_MAX * OCTEON_RGMX_OQUEUE_PER_PORT];
-static struct resource *irq_res; /* Interrupt resource. */
-static void *int_handler_tag;
+static struct resource *irq_res;/* Interrupt resource. */
+static void *int_handler_tag;
#ifdef OCTEON_RGMX_SCHEDULED_ISRS
-struct task link_isr_task;
-struct task rxtx_isr_task;
+struct task link_isr_task;
+struct task rxtx_isr_task;
struct taskqueue *tq; /* private task queue */
#endif
-static u_int get_rgmx_port_ordinal (u_int port)
+static u_int
+get_rgmx_port_ordinal(u_int port)
{
- u_int idx;
+ u_int idx;
- for (idx = 0; idx < OCTEON_RGMX_NUM_PORTS_MAX; idx++) {
- if (port_array[idx] == port) {
- return (idx);
- }
- }
- return (-1);
+ for (idx = 0; idx < OCTEON_RGMX_NUM_PORTS_MAX; idx++) {
+ if (port_array[idx] == port) {
+ return (idx);
+ }
+ }
+ return (-1);
}
-static struct rgmx_softc_dev *get_rgmx_softc (u_int port)
+static struct rgmx_softc_dev *
+get_rgmx_softc(u_int port)
{
- u_int idx;
+ u_int idx;
- idx = get_rgmx_port_ordinal(port);
- if (idx != -1) {
- return (rgmx_scdev_array[idx]);
- }
- return (NULL);
+ idx = get_rgmx_port_ordinal(port);
+ if (idx != -1) {
+ return (rgmx_scdev_array[idx]);
+ }
+ return (NULL);
}
-static void octeon_rgmx_init_sc (struct rgmx_softc_dev *sc, device_t dev, u_int port, u_int num_devices)
+static void
+octeon_rgmx_init_sc(struct rgmx_softc_dev *sc, device_t dev, u_int port, u_int num_devices)
{
- int ii;
+ int ii;
- /* No software-controllable media selection. */
- sc->mbitmap = MB_HM;
- sc->defmedia = MB_HM;
+ /* No software-controllable media selection. */
+ sc->mbitmap = MB_HM;
+ sc->defmedia = MB_HM;
- sc->sc_dev = dev;
- sc->port = port;
- sc->idx = num_devices;
- sc->link_status = 0;
- sc->sc_unit = num_devices;
- sc->mbitmap = MB_HT;
- sc->defmedia = MB_HT;
- sc->tx_pending_queue.ifq_maxlen = NUM_TX_PACKETS;
- sc->tx_pending_queue.ifq_head = sc->tx_pending_queue.ifq_tail = NULL;
- sc->tx_pending_queue.ifq_len = sc->tx_pending_queue.ifq_drops = 0;
- mtx_init(&sc->tx_pending_queue.ifq_mtx, "if->sc->txpq.ifqmtx", NULL, MTX_DEF);
+ sc->sc_dev = dev;
+ sc->port = port;
+ sc->idx = num_devices;
+ sc->link_status = 0;
+ sc->sc_unit = num_devices;
+ sc->mbitmap = MB_HT;
+ sc->defmedia = MB_HT;
+ sc->tx_pending_queue.ifq_maxlen = NUM_TX_PACKETS;
+ sc->tx_pending_queue.ifq_head = sc->tx_pending_queue.ifq_tail = NULL;
+ sc->tx_pending_queue.ifq_len = sc->tx_pending_queue.ifq_drops = 0;
+ mtx_init(&sc->tx_pending_queue.ifq_mtx, "if->sc->txpq.ifqmtx", NULL, MTX_DEF);
- sc->outq_ptr = &(output_queues_array[num_devices * OCTEON_RGMX_OQUEUE_PER_PORT]);
+ sc->outq_ptr = &(output_queues_array[num_devices * OCTEON_RGMX_OQUEUE_PER_PORT]);
- for (ii = 0; ii < 6; ii++) {
- sc->ieee[ii] = octeon_mac_addr[ii];
- }
- sc->ieee[5] += get_rgmx_port_ordinal(port);
+ for (ii = 0; ii < 6; ii++) {
+ sc->ieee[ii] = octeon_mac_addr[ii];
+ }
+ sc->ieee[5] += get_rgmx_port_ordinal(port);
}
-static int octeon_rgmx_init_ifnet (struct rgmx_softc_dev *sc)
+static int
+octeon_rgmx_init_ifnet(struct rgmx_softc_dev *sc)
{
- struct ifnet *ifp;
+ struct ifnet *ifp;
- ifp = sc->ifp = if_alloc(IFT_ETHER);
- if (NULL == ifp) {
- device_printf(sc->sc_dev, "can not ifalloc for rgmx port\n");
- return (ENOSPC);
- }
- /*
- * Initialize ifnet structure
- */
- ifp->if_softc = sc;
- if_initname(sc->ifp, device_get_name(sc->sc_dev), device_get_unit(sc->sc_dev));
- ifp->if_start = octeon_rgmx_output_start;
- ifp->if_ioctl = octeon_rgmx_ioctl;
- /* Watchdog interface is now deprecated.
- ifp->if_watchdog = octeon_rgmx_watchdog;
- */
+ ifp = sc->ifp = if_alloc(IFT_ETHER);
+ if (NULL == ifp) {
+ device_printf(sc->sc_dev, "can not ifalloc for rgmx port\n");
+ return (ENOSPC);
+ }
+ /*
+ * Initialize ifnet structure
+ */
+ ifp->if_softc = sc;
+ if_initname(sc->ifp, device_get_name(sc->sc_dev), device_get_unit(sc->sc_dev));
+ ifp->if_start = octeon_rgmx_output_start;
+ ifp->if_ioctl = octeon_rgmx_ioctl;
+ /*
+ * Watchdog interface is now deprecated. ifp->if_watchdog =
+ * octeon_rgmx_watchdog;
+ */
ifp->if_hwassist = CSUM_TCP | CSUM_UDP;
ifp->if_capabilities = IFCAP_HWCSUM;
ifp->if_capenable = ifp->if_capabilities;
- ifp->if_init = octeon_rgmx_init;
- ifp->if_linkmib = NULL; // &sc->mibdata;
- ifp->if_linkmiblen = 0; // sizeof (sc->mibdata);
- /*
- * Set fixed interface flags.
- */
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-// | IFF_NEEDSGIANT;
- if (ifp->if_snd.ifq_maxlen == 0)
- ifp->if_snd.ifq_maxlen = ifqmaxlen;
+ ifp->if_init = octeon_rgmx_init;
+ ifp->if_linkmib = NULL;
+ //&sc->mibdata;
+ ifp->if_linkmiblen = 0;
+ //sizeof(sc->mibdata);
+ /*
+ * Set fixed interface flags.
+ */
+ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+ //|IFF_NEEDSGIANT;
+ if (ifp->if_snd.ifq_maxlen == 0)
+ ifp->if_snd.ifq_maxlen = ifqmaxlen;
- ifmedia_init(&sc->media, 0, octeon_rgmx_medchange, octeon_rgmx_medstat);
- ifmedia_add(&sc->media, bit2media[0], 0, NULL);
- ifmedia_set(&sc->media, bit2media[0]);
+ ifmedia_init(&sc->media, 0, octeon_rgmx_medchange, octeon_rgmx_medstat);
+ ifmedia_add(&sc->media, bit2media[0], 0, NULL);
+ ifmedia_set(&sc->media, bit2media[0]);
- ether_ifattach(sc->ifp, sc->ieee);
- /* Print additional info when attached. */
- device_printf(sc->sc_dev, "type %s, full duplex\n", sc->typestr);
+ ether_ifattach(sc->ifp, sc->ieee);
+ /* Print additional info when attached. */
+ device_printf(sc->sc_dev, "type %s, full duplex\n", sc->typestr);
- return (0);
+ return (0);
}
@@ -370,7 +383,8 @@
/* ------------------------------------------------------------------- *
* rgmii_identify() *
* ------------------------------------------------------------------- */
-static void rgmii_identify (driver_t *drv, device_t parent)
+static void
+rgmii_identify(driver_t * drv, device_t parent)
{
BUS_ADD_CHILD(parent, 0, "rgmii", 0);
}
@@ -379,12 +393,13 @@
/* ------------------------------------------------------------------- *
* rgmii_probe() *
* ------------------------------------------------------------------- */
-static int rgmii_probe (device_t dev)
+static int
+rgmii_probe(device_t dev)
{
if (device_get_unit(dev) != 0)
panic("can't probe/attach more rgmii devices\n");
- device_set_desc(dev, "Octeon RGMII");
+ device_set_desc(dev, "Octeon RGMII");
return (0);
}
@@ -393,19 +408,21 @@
/* ------------------------------------------------------------------- *
* rgmii_attach() *
* ------------------------------------------------------------------- */
-static int rgmii_attach (device_t dev)
+static int
+rgmii_attach(device_t dev)
{
- struct rgmx_softc_dev *sc;
- device_t child;
- int iface, port, nr_ports, error;
- void *softc;
- int irq_rid;
+ struct rgmx_softc_dev *sc;
+ device_t child;
+ int iface, port, nr_ports, error;
+ void *softc;
+ int irq_rid;
- octeon_config_hw_units_pre_ports();
+ octeon_config_hw_units_pre_ports();
- /* Count interfaces and ports*/
+ /* Count interfaces and ports */
octeon_gmxx_inf_mode_t iface_mode;
+
iface_mode.word64 = 0;
for (iface = 0; iface < 2; iface++) {
@@ -414,10 +431,10 @@
/* interface is either disabled or SPI */
if (!iface_mode.bits.en)
continue;
- if (octeon_get_chipid() == OCTEON_CN3020_CHIP) {
+ if (octeon_get_chipid() == OCTEON_CN3020_CHIP) {
nr_ports = 2;
} else {
- if (iface_mode.bits.type ) {
+ if (iface_mode.bits.type) {
continue;
}
nr_ports = (octeon_has_4ports()) ? 4 : 3;
@@ -427,42 +444,42 @@
for (port = iface * 16; port < iface * 16 + nr_ports; port++) {
- child = device_add_child(dev, OCTEON_RGMX_DEV_NAME, num_devices);
- if (child == NULL)
- panic("%s: device_add_child() failed\n", __func__);
+ child = device_add_child(dev, OCTEON_RGMX_DEV_NAME, num_devices);
+ if (child == NULL)
+ panic("%s: device_add_child() failed\n", __func__);
- softc = malloc(sizeof(struct rgmx_softc_dev), M_DEVBUF, M_NOWAIT | M_ZERO);
- if (!softc) {
- panic("%s malloc failed for softc\n", __func__);
- }
- device_set_softc(child, softc);
- device_set_desc(child, "Octeon RGMII");
- sc = device_get_softc(child);
- if (!sc) {
- printf(" No sc\n");
- num_devices++;
- continue;
- }
- port_array[num_devices] = port;
- rgmx_scdev_array[num_devices] = sc;
- RGMX_LOCK_INIT(sc, device_get_nameunit(child));
- octeon_rgmx_init_sc(sc, child, port, num_devices);
- octeon_config_hw_units_port(sc, port);
- if (octeon_rgmx_init_ifnet(sc)) {
- device_printf(dev, " ifinit failed for rgmx port %u\n", port);
- return (ENOSPC);
- }
+ softc = malloc(sizeof(struct rgmx_softc_dev), M_DEVBUF, M_NOWAIT | M_ZERO);
+ if (!softc) {
+ panic("%s malloc failed for softc\n", __func__);
+ }
+ device_set_softc(child, softc);
+ device_set_desc(child, "Octeon RGMII");
+ sc = device_get_softc(child);
+ if (!sc) {
+ printf(" No sc\n");
+ num_devices++;
+ continue;
+ }
+ port_array[num_devices] = port;
+ rgmx_scdev_array[num_devices] = sc;
+ RGMX_LOCK_INIT(sc, device_get_nameunit(child));
+ octeon_rgmx_init_sc(sc, child, port, num_devices);
+ octeon_config_hw_units_port(sc, port);
+ if (octeon_rgmx_init_ifnet(sc)) {
+ device_printf(dev, " ifinit failed for rgmx port %u\n", port);
+ return (ENOSPC);
+ }
/*
* Don't call octeon_rgmx_mark_ready()
* ifnet will call it indirectly via octeon_rgmx_init()
*
* octeon_rgmx_mark_ready(sc);
*/
- num_devices++;
- }
+ num_devices++;
+ }
}
- octeon_config_hw_units_post_ports();
+ octeon_config_hw_units_post_ports();
irq_rid = 0;
irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0, 0, 1, RF_SHAREABLE | RF_ACTIVE);
@@ -470,41 +487,37 @@
device_printf(dev, "failed to allocate irq\n");
return (ENXIO);
}
-
-
#ifdef OCTEON_RGMX_SCHEDULED_ISRS
- /*
- * Single task queues for all child devices. Since POW gives us a unified
- * interrupt based on POW groups, not based on PORTs.
- */
+ /*
+ * Single task queues for all child devices. Since POW gives us a
+ * unified interrupt based on POW groups, not based on PORTs.
+ */
TASK_INIT(&rxtx_isr_task, 0, octeon_rgmx_isr_rxtx, NULL);
TASK_INIT(&link_isr_task, 0, octeon_rgmx_isr_link, NULL);
tq = taskqueue_create_fast("octeon_rgmx_taskq", M_NOWAIT,
- taskqueue_thread_enqueue, &tq);
+ taskqueue_thread_enqueue, &tq);
taskqueue_start_threads(&tq, 1, PI_NET, "%s taskq", device_get_nameunit(dev));
error = bus_setup_intr(dev, irq_res, INTR_TYPE_NET, octeon_rgmx_intr_fast, NULL,
- NULL, &int_handler_tag);
+ NULL, &int_handler_tag);
if (error != 0) {
device_printf(dev, "bus_setup_intr returned %d\n", error);
taskqueue_free(tq);
- tq = NULL;
+ tq = NULL;
return (error);
}
-
-#else /* OCTEON_RGMX_SCHEDULED_ISRS */
+#else /* OCTEON_RGMX_SCHEDULED_ISRS */
error = bus_setup_intr(dev, irq_res, INTR_TYPE_NET, octeon_rgmx_intr, NULL,
- NULL, &int_handler_tag);
+ NULL, &int_handler_tag);
- if (error != 0) {
+ if (error != 0) {
device_printf(dev, "bus_setup_intr returned %d\n", error);
- tq = NULL;
+ tq = NULL;
return (error);
}
+#endif /* OCTEON_RGMX_SCHEDULED_ISRS */
-#endif /* OCTEON_RGMX_SCHEDULED_ISRS */
-
return (bus_generic_attach(dev));
}
@@ -539,7 +552,7 @@
#define FPA_NOPOOL 0
#define OCTEON_FPA_RX_PACKET_POOL 0
-#define OCTEON_FPA_RX_PACKET_POOL_WORDS 208 /* 2048 bytes */
+#define OCTEON_FPA_RX_PACKET_POOL_WORDS 208 /* 2048 bytes */
#define OCTEON_FPA_RX_PACKET_POOL_ELEM_SIZE (OCTEON_FPA_RX_PACKET_POOL_WORDS)
#define OCTEON_FPA_RX_PACKET_POOL_ELEMENTS (MAX_RX_BUFS)
#define OCTEON_RX_MAX_SIZE (OCTEON_FPA_RX_PACKET_POOL_WORDS * sizeof(uint64_t))
@@ -550,7 +563,7 @@
#define OCTEON_FPA_WQE_RX_POOL_ELEMENTS (NUM_RX_PACKETS_CTL)
#define OCTEON_FPA_TX_PACKET_POOL 2
-#define OCTEON_FPA_TX_PACKET_POOL_WORDS 208 /* 2048 bytes */
+#define OCTEON_FPA_TX_PACKET_POOL_WORDS 208 /* 2048 bytes */
#define OCTEON_FPA_TX_PACKET_POOL_ELEM_SIZE (OCTEON_FPA_TX_PACKET_POOL_WORDS)
#define OCTEON_FPA_TX_PACKET_POOL_ELEMENTS (MAX_TX_BUFS)
#define OCTEON_TX_MAX_SIZE (OCTEON_FPA_TX_PACKET_POOL_WORDS * sizeof(uint64_t))
@@ -569,22 +582,24 @@
#define RGMX_MAX_PAK_RECEIVE 5000000
-static void octeon_dump_pow_stats (void);
+static void octeon_dump_pow_stats(void);
#ifdef OCTEON_RGMX_SCHEDULED_ISRS
-static void octeon_rgmx_isr_link (void *context, int pending)
+static void
+octeon_rgmx_isr_link(void *context, int pending)
{
- octeon_line_status_loop(NULL);
+ octeon_line_status_loop(NULL);
}
-static void octeon_rgmx_isr_rxtx (void *context, int pending)
+static void
+octeon_rgmx_isr_rxtx(void *context, int pending)
{
- octeon_rx_loop(NULL);
+ octeon_rx_loop(NULL);
}
@@ -594,61 +609,61 @@
*
*********************************************************************/
-//#define OCTEON_RGMX_POW_TIME_THR_INTS 1
+//
+#define OCTEON_RGMX_POW_TIME_THR_INTS 1
-static int octeon_rgmx_intr_fast(void *arg)
+static int
+octeon_rgmx_intr_fast(void *arg)
{
- int handled_flag = 0;
- uint64_t ciu_summary;
+ int handled_flag = 0;
+ uint64_t ciu_summary;
- ciu_summary = ciu_get_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
- OCTEON_RGMX_CIU_ENX);
+ ciu_summary = ciu_get_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
+ OCTEON_RGMX_CIU_ENX);
- if (ciu_summary & CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1)) {
+ if (ciu_summary & CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1)) {
- /*
- * Timer Interrupt for link status checks
- * Acknowledging it will mask it for this cycle.
- */
- ciu_clear_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
- OCTEON_RGMX_CIU_ENX,
- CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1));
+ /*
+ * Timer Interrupt for link status checks Acknowledging it
+ * will mask it for this cycle.
+ */
+ ciu_clear_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
+ OCTEON_RGMX_CIU_ENX,
+ CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1));
taskqueue_enqueue(taskqueue_fast, &link_isr_task);
- handled_flag = 1;
- }
-
- if (ciu_summary & OCTEON_POW_ALL_GROUPS_MASK) {
+ handled_flag = 1;
+ }
+ if (ciu_summary & OCTEON_POW_ALL_GROUPS_MASK) {
#ifndef OCTEON_RGMX_POW_TIME_THR_INTS
/*
- * When using POW IQ/DSQ size based interrupts, then
- * ack the interrupts right away. So they don't interrupt
- * until the queue size goes to 0 again.
- */
- oct_write64(OCTEON_POW_WORKQUEUE_INT,
- 0x10001 << OCTEON_POW_RX_GROUP_NUM);
+ * When using POW IQ/DSQ size based interrupts, then ack the
+ * interrupts right away. So they don't interrupt until the
+ * queue size goes to 0 again.
+ */
+ oct_write64(OCTEON_POW_WORKQUEUE_INT,
+ 0x10001 << OCTEON_POW_RX_GROUP_NUM);
#else
- /*
- * We use POW thresholds based interrupt signalled on timer
- * countdown. Acknowledge it now so that it doesn't
- * interrupt us until next countdown to zero.
- */
- oct_write64(OCTEON_POW_WORKQUEUE_INT,
- 0x1 << OCTEON_POW_RX_GROUP_NUM);
+ /*
+ * We use POW thresholds based interrupt signalled on timer
+ * countdown. Acknowledge it now so that it doesn't
+ * interrupt us until next countdown to zero.
+ */
+ oct_write64(OCTEON_POW_WORKQUEUE_INT,
+ 0x1 << OCTEON_POW_RX_GROUP_NUM);
#endif
- taskqueue_enqueue(tq, &rxtx_isr_task);
- handled_flag = 1;
- }
-
+ taskqueue_enqueue(tq, &rxtx_isr_task);
+ handled_flag = 1;
+ }
return ((handled_flag) ? FILTER_HANDLED : FILTER_STRAY);
}
-#else /* ! OCTEON_RGMX_SCHEDULED_ISRS */
+#else /* ! OCTEON_RGMX_SCHEDULED_ISRS */
/*
@@ -659,50 +674,52 @@
* Also note that the RGMX_LOCK/UNLOCK code will have to checked/added, since that is new and
* was not supported with this model.
*/
-static int octeon_rgmx_intr (void *arg)
+static int
+octeon_rgmx_intr(void *arg)
{
- int flag = 0;
- uint64_t ciu_summary;
+ int flag = 0;
+ uint64_t ciu_summary;
- /*
- * read ciu to see if any bits are pow
- */
- while (1) {
- ciu_summary = ciu_get_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
- OCTEON_RGMX_CIU_ENX);
+ /*
+ * read ciu to see if any bits are pow
+ */
+ while (1) {
+ ciu_summary = ciu_get_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
+ OCTEON_RGMX_CIU_ENX);
- if ((ciu_summary & (OCTEON_POW_ALL_GROUPS_MASK | CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1))) == 0) {
- break;
- }
+ if ((ciu_summary & (OCTEON_POW_ALL_GROUPS_MASK | CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1))) == 0) {
+ break;
+ }
+ flag = 1;
- flag = 1;
-
- if (ciu_summary & OCTEON_POW_ALL_GROUPS_MASK) {
- octeon_rx_loop(NULL);
- /*
- * Acknowledge the interrupt after processing queues.
- */
- oct_write64(OCTEON_POW_WORKQUEUE_INT, OCTEON_POW_RX_GROUP_MASK);
- }
- if (ciu_summary & CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1)) {
- octeon_line_status_loop(NULL);
- ciu_clear_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
- OCTEON_RGMX_CIU_ENX,
- CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1));
- }
- }
+ if (ciu_summary & OCTEON_POW_ALL_GROUPS_MASK) {
+ octeon_rx_loop(NULL);
+ /*
+ * Acknowledge the interrupt after processing
+ * queues.
+ */
+ oct_write64(OCTEON_POW_WORKQUEUE_INT, OCTEON_POW_RX_GROUP_MASK);
+ }
+ if (ciu_summary & CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1)) {
+ octeon_line_status_loop(NULL);
+ ciu_clear_int_summary(CIU_THIS_CORE, OCTEON_RGMX_CIU_INTX,
+ OCTEON_RGMX_CIU_ENX,
+ CIU_GENTIMER_BITS_ENABLE(CIU_GENTIMER_NUM_1));
+ }
+ }
return ((flag) ? FILTER_HANDLED : FILTER_STRAY);
}
-#endif /* OCTEON_RGMX_SCHEDULED_ISRS */
+#endif /* OCTEON_RGMX_SCHEDULED_ISRS */
static struct mbuf *octeon_rgmx_build_new_rx_mbuf(struct ifnet *ifp, void *data_start, u_int totlen);
-static struct mbuf *octeon_rgmx_build_new_rx_mbuf (struct ifnet *ifp, void *data_start, u_int totlen)
+static struct mbuf *
+octeon_rgmx_build_new_rx_mbuf(struct ifnet *ifp, void *data_start, u_int totlen)
{
struct mbuf *m, *m0, *newm;
caddr_t newdata;
@@ -714,17 +731,15 @@
#endif
return (NULL);
}
-
MGETHDR(m0, M_DONTWAIT, MT_DATA);
if (m0 == NULL) {
return (NULL);
- }
-
- /* Initialize packet header info. */
+ }
+ /* Initialize packet header info. */
m0->m_pkthdr.rcvif = ifp;
m0->m_pkthdr.len = totlen;
- m0->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
- m0->m_pkthdr.csum_data = 0xffff;
+ m0->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID | CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
+ m0->m_pkthdr.csum_data = 0xffff;
len = MHLEN;
m = m0;
@@ -735,17 +750,15 @@
goto octeon_rgmx_build_new_rx_mbuf_bad;
len = MCLBYTES;
}
-
if (m == m0) {
- newdata = (caddr_t) ALIGN(m->m_data + ETHER_HDR_LEN) - ETHER_HDR_LEN;
+ newdata = (caddr_t)ALIGN(m->m_data + ETHER_HDR_LEN) - ETHER_HDR_LEN;
len -= newdata - m->m_data;
m->m_data = newdata;
}
-
- /* Set the length of this mbuf. */
+ /* Set the length of this mbuf. */
m->m_len = len = min(totlen, len);
- bcopy(data_start, mtod(m, caddr_t), len);
- data_start = (void *) (((u_long) (data_start)) + len);
+ bcopy(data_start, mtod(m, caddr_t), len);
+ data_start = (void *)(((u_long)(data_start)) + len);
totlen -= len;
if (totlen > 0) {
@@ -767,101 +780,126 @@
-//#define DEBUG_RX 1
+//
+#define DEBUG_RX 1
-static void octeon_rgmx_rx_process_work (octeon_wqe_t *work, u_int port)
+static void
+octeon_rgmx_rx_process_work(octeon_wqe_t * work, u_int port)
{
- struct rgmx_softc_dev *sc;
- struct ifnet *ifp;
- u_int len;
- void *data_start, *new_data_start;
- struct mbuf *mbuf;
+ struct rgmx_softc_dev *sc;
+ struct ifnet *ifp;
+ u_int len;
+ void *data_start, *new_data_start;
+ struct mbuf *mbuf;
-//#define DEBUG_RX_PKT_DUMP 1
+ //
+#define DEBUG_RX_PKT_DUMP 1
#ifdef DEBUG_RX_PKT_DUMP
- int i; u_char *dc;
+ int i;
+ u_char *dc;
+
#endif
-
- data_start = octeon_pow_pktptr_to_kbuffer(work->packet_ptr);
+
+ data_start = octeon_pow_pktptr_to_kbuffer(work->packet_ptr);
-//#define DEBUG_RX2
+ //
+#define DEBUG_RX2
#ifdef DEBUG_RX2
- printf(" WQE 0x%X: port:%u ", work, port);
- printf(" Grp: %u, %llX Tag: %u %llX type: %u 0x%llx\n",
- work->grp, work->grp, work->tag, work->tag, work->tag_type, work->tag_type);
+ printf(" WQE 0x%X: port:%u ", work, port);
+ printf(" Grp: %u, %llX Tag: %u %llX type: %u 0x%llx\n",
+ work->grp, work->grp, work->tag, work->tag, work->tag_type, work->tag_type);
#endif
- if ((port >= OCTEON_RGMX_MIN_PORT) || (port <= OCTEON_RGMX_MAX_PORT)) {
+ if ((port >= OCTEON_RGMX_MIN_PORT) || (port <= OCTEON_RGMX_MAX_PORT)) {
- sc = get_rgmx_softc(port);
+ sc = get_rgmx_softc(port);
- if (!sc || !sc->ifp) {
+ if (!sc || !sc->ifp) {
- printf(" octeon_rgmx_rx_process_work No sc or sc->ifp - port:%u", port);
- } else {
+ printf(" octeon_rgmx_rx_process_work No sc or sc->ifp - port:%u", port);
+ } else {
- ifp = sc->ifp;
+ ifp = sc->ifp;
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- if (!work->word2.bits.rcv_error) {
+ if (!work->word2.bits.rcv_error) {
- len = work->len;
+ len = work->len;
- /*
- * We cannot pass the same FPA phys-buffer higher up.
- * User space will not be able to use this phys-buffer.
- *
- * Start building a mbuf packet here using data_start & len.
- */
+ /*
+ * We cannot pass the same FPA
+ * phys-buffer higher up. User space
+ * will not be able to use this
+ * phys-buffer.
+ *
+ * Start building a mbuf packet here
+ * using data_start & len.
+ */
- new_data_start = data_start;
- if (!work->word2.bits.not_IP) {
- new_data_start = (void *) (((unsigned long) (new_data_start)) + 14);
- /* mark it as checksum checked */
- } else {
- new_data_start = (void *) (((unsigned long) (new_data_start)) + 8);
- }
+ new_data_start = data_start;
+ if (!work->word2.bits.not_IP) {
+ new_data_start = (void *)(((unsigned long)(new_data_start)) + 14);
+ /*
+ * mark it as checksum
+ * checked
+ */
+ } else {
+ new_data_start = (void *)(((unsigned long)(new_data_start)) + 8);
+ }
#ifdef DEBUG_RX_PKT_DUMP
- dc = new_data_start; printf("In:\n");
- for (i = 0; i < len; i++) { if (!(i % 16)) printf ("\n"); printf(" %02X", dc[i]); }
+ dc = new_data_start;
+ printf("In:\n");
+ for (i = 0; i < len; i++) {
+ if (!(i % 16))
+ printf("\n");
+ printf(" %02X", dc[i]);
+ }
#endif
-
- mbuf = octeon_rgmx_build_new_rx_mbuf(ifp, new_data_start, len);
- if (mbuf) {
-// printf(" Passing pkt to ifp: pkt_len: %u len: %u ", mbuf->m_pkthdr.len, mbuf->m_len);
+
+ mbuf = octeon_rgmx_build_new_rx_mbuf(ifp, new_data_start, len);
+ if (mbuf) {
+ //printf(" Passing pkt to ifp: pkt_len: %u len: %u ", mbuf->m_pkthdr.len, mbuf->m_len);
#ifdef DEBUG_RX_PKT_DUMP
- dc = mtod(mbuf, u_char *); printf("\n"); printf("In: ");
- for (i = 0; i < mbuf->m_len; i++) { if (!(i % 16)) printf ("\n"); printf(" %02X", dc[i]); }
+ dc = mtod(mbuf, u_char *);
+ printf("\n");
+ printf("In: ");
+ for (i = 0; i < mbuf->m_len; i++) {
+ if (!(i % 16))
+ printf("\n");
+ printf(" %02X", dc[i]);
+ }
#endif
- /* Feed the packet to upper layer. */
- (*ifp->if_input)(ifp, mbuf);
- ifp->if_ipackets++;
+ /*
+ * Feed the packet to upper
+ * layer.
+ */
+ (*ifp->if_input) (ifp, mbuf);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list