summaryrefslogtreecommitdiffstats
path: root/sys/dev/bce
diff options
context:
space:
mode:
authordavidch <davidch@FreeBSD.org>2009-02-27 19:25:06 +0000
committerdavidch <davidch@FreeBSD.org>2009-02-27 19:25:06 +0000
commite039f0dcb5d4c4dbe5e93bbb4151c305de646d65 (patch)
tree231a5fa3985a856023bc17b61478c56ae65be69e /sys/dev/bce
parent8499a8b51c06ba71d27e6cb02b43e86459ab17e4 (diff)
downloadFreeBSD-src-e039f0dcb5d4c4dbe5e93bbb4151c305de646d65.zip
FreeBSD-src-e039f0dcb5d4c4dbe5e93bbb4151c305de646d65.tar.gz
- Update copyright to 2009.
- Only enable split header operation when ZERO_COPY_SOCKETS is enabled in the kernel. Submitted by: davidch MFC after: 1 week
Diffstat (limited to 'sys/dev/bce')
-rw-r--r--sys/dev/bce/if_bce.c77
-rw-r--r--sys/dev/bce/if_bcefw.h2
-rw-r--r--sys/dev/bce/if_bcereg.h28
3 files changed, 65 insertions, 42 deletions
diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c
index 8385b6e..6638e5a 100644
--- a/sys/dev/bce/if_bce.c
+++ b/sys/dev/bce/if_bce.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2006-2008 Broadcom Corporation
+ * Copyright (c) 2006-2009 Broadcom Corporation
* David Christensen <davidch@broadcom.com>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -89,7 +89,6 @@ __FBSDID("$FreeBSD$");
/****************************************************************************/
/* BCE Build Time Options */
/****************************************************************************/
-#define BCE_USE_SPLIT_HEADER 1
/* #define BCE_NVRAM_WRITE_SUPPORT 1 */
@@ -294,12 +293,12 @@ static void bce_dump_enet (struct bce_softc *, struct mbuf *);
static void bce_dump_mbuf (struct bce_softc *, struct mbuf *);
static void bce_dump_tx_mbuf_chain (struct bce_softc *, u16, int);
static void bce_dump_rx_mbuf_chain (struct bce_softc *, u16, int);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
static void bce_dump_pg_mbuf_chain (struct bce_softc *, u16, int);
#endif
static void bce_dump_txbd (struct bce_softc *, int, struct tx_bd *);
static void bce_dump_rxbd (struct bce_softc *, int, struct rx_bd *);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
static void bce_dump_pgbd (struct bce_softc *, int, struct rx_bd *);
#endif
static void bce_dump_l2fhdr (struct bce_softc *, int, struct l2_fhdr *);
@@ -307,7 +306,7 @@ static void bce_dump_ctx (struct bce_softc *, u16);
static void bce_dump_ftqs (struct bce_softc *);
static void bce_dump_tx_chain (struct bce_softc *, u16, int);
static void bce_dump_rx_chain (struct bce_softc *, u16, int);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
static void bce_dump_pg_chain (struct bce_softc *, u16, int);
#endif
static void bce_dump_status_block (struct bce_softc *);
@@ -392,7 +391,7 @@ static int bce_init_rx_chain (struct bce_softc *);
static void bce_fill_rx_chain (struct bce_softc *);
static void bce_free_rx_chain (struct bce_softc *);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
static int bce_get_pg_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *);
static int bce_init_pg_chain (struct bce_softc *);
static void bce_fill_pg_chain (struct bce_softc *);
@@ -597,7 +596,7 @@ bce_print_adapter_info(struct bce_softc *sc)
/* Firmware version and device features. */
printf("F/W (0x%08X); Flags( ", sc->bce_fw_ver);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
printf("SPLT ");
#endif
if (sc->bce_flags & BCE_MFW_ENABLE_FLAG)
@@ -1013,7 +1012,7 @@ bce_attach(device_t dev)
* This may change later if the MTU size is set to
* something other than 1500.
*/
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
sc->rx_bd_mbuf_alloc_size = MHLEN;
/* Make sure offset is 16 byte aligned for hardware. */
sc->rx_bd_mbuf_align_pad = roundup2((MSIZE - MHLEN), 16) -
@@ -2753,7 +2752,7 @@ bce_dma_free(struct bce_softc *sc)
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/* Free, unmap and destroy all page buffer descriptor chain pages. */
for (i = 0; i < PG_PAGES; i++ ) {
if (sc->pg_bd_chain[i] != NULL) {
@@ -2817,7 +2816,7 @@ bce_dma_free(struct bce_softc *sc)
sc->rx_mbuf_tag = NULL;
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/* Unload and destroy the page mbuf maps. */
for (i = 0; i < TOTAL_PG_BD; i++) {
if (sc->pg_mbuf_map[i] != NULL) {
@@ -3267,7 +3266,7 @@ bce_dma_alloc(device_t dev)
/*
* Create a DMA tag for RX mbufs.
*/
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
max_size = max_seg_size = ((sc->rx_bd_mbuf_alloc_size < MCLBYTES) ?
MCLBYTES : sc->rx_bd_mbuf_alloc_size);
#else
@@ -3303,7 +3302,7 @@ bce_dma_alloc(device_t dev)
}
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/*
* Create a DMA tag for the page buffer descriptor chain,
* allocate and clear the memory, and fetch the physical
@@ -4384,7 +4383,7 @@ bce_stop(struct bce_softc *sc)
bce_disable_intr(sc);
/* Free RX buffers. */
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
bce_free_pg_chain(sc);
#endif
bce_free_rx_chain(sc);
@@ -4822,7 +4821,7 @@ bce_get_rx_buf(struct bce_softc *sc, struct mbuf *m, u16 *prod,
goto bce_get_rx_buf_exit);
/* This is a new mbuf allocation. */
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
MGETHDR(m_new, M_DONTWAIT, MT_DATA);
#else
if (sc->rx_bd_mbuf_alloc_size <= MCLBYTES)
@@ -4901,7 +4900,7 @@ bce_get_rx_buf_exit:
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/****************************************************************************/
/* Encapsulate an mbuf cluster into the page chain. */
/* */
@@ -5010,7 +5009,7 @@ bce_get_pg_buf_exit:
return(rc);
}
-#endif /* BCE_USE_SPLIT_HEADER */
+#endif /* ZERO_COPY_SOCKETS */
/****************************************************************************/
/* Initialize the TX context memory. */
@@ -5368,7 +5367,7 @@ bce_free_rx_chain(struct bce_softc *sc)
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/****************************************************************************/
/* Allocate memory and initialize the page data structures. */
/* Assumes that bce_init_rx_chain() has not already been called. */
@@ -5534,7 +5533,7 @@ bce_free_pg_chain(struct bce_softc *sc)
DBEXIT(BCE_VERBOSE_RESET | BCE_VERBOSE_RECV | BCE_VERBOSE_UNLOAD);
}
-#endif /* BCE_USE_SPLIT_HEADER */
+#endif /* ZERO_COPY_SOCKETS */
/****************************************************************************/
@@ -5707,7 +5706,7 @@ bce_rx_intr(struct bce_softc *sc)
unsigned int pkt_len;
u16 sw_rx_cons, sw_rx_cons_idx, hw_rx_cons;
u32 status;
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
unsigned int rem_len;
u16 sw_pg_cons, sw_pg_cons_idx;
#endif
@@ -5723,7 +5722,7 @@ bce_rx_intr(struct bce_softc *sc)
bus_dmamap_sync(sc->rx_bd_chain_tag,
sc->rx_bd_chain_map[i], BUS_DMASYNC_POSTWRITE);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/* Prepare the page chain pages to be accessed by the host CPU. */
for (int i = 0; i < PG_PAGES; i++)
bus_dmamap_sync(sc->pg_bd_chain_tag,
@@ -5735,7 +5734,7 @@ bce_rx_intr(struct bce_softc *sc)
/* Get working copies of the driver's view of the consumer indices. */
sw_rx_cons = sc->rx_cons;
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
sw_pg_cons = sc->pg_cons;
#endif
@@ -5797,7 +5796,7 @@ bce_rx_intr(struct bce_softc *sc)
*/
m_adj(m0, sizeof(struct l2_fhdr) + ETHER_ALIGN);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/*
* Check whether the received frame fits in a single
* mbuf or not (i.e. packet data + FCS <=
@@ -5970,7 +5969,7 @@ bce_rx_int_next_rx:
if (m0) {
/* Make sure we don't lose our place when we release the lock. */
sc->rx_cons = sw_rx_cons;
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
sc->pg_cons = sw_pg_cons;
#endif
@@ -5980,7 +5979,7 @@ bce_rx_int_next_rx:
/* Recover our place. */
sw_rx_cons = sc->rx_cons;
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
sw_pg_cons = sc->pg_cons;
#endif
}
@@ -5991,7 +5990,7 @@ bce_rx_int_next_rx:
}
/* No new packets to process. Refill the RX and page chains and exit. */
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
sc->pg_cons = sw_pg_cons;
bce_fill_pg_chain(sc);
#endif
@@ -6003,7 +6002,7 @@ bce_rx_int_next_rx:
bus_dmamap_sync(sc->rx_bd_chain_tag,
sc->rx_bd_chain_map[i], BUS_DMASYNC_PREWRITE);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
for (int i = 0; i < PG_PAGES; i++)
bus_dmamap_sync(sc->pg_bd_chain_tag,
sc->pg_bd_chain_map[i], BUS_DMASYNC_PREWRITE);
@@ -6249,7 +6248,7 @@ bce_init_locked(struct bce_softc *sc)
* Calculate and program the hardware Ethernet MTU
* size. Be generous on the receive if we have room.
*/
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
if (ifp->if_mtu <= (sc->rx_bd_mbuf_data_len + sc->pg_bd_mbuf_alloc_size))
ether_mtu = sc->rx_bd_mbuf_data_len + sc->pg_bd_mbuf_alloc_size;
#else
@@ -6281,7 +6280,7 @@ bce_init_locked(struct bce_softc *sc)
/* Program appropriate promiscuous/multicast filtering. */
bce_set_rx_mode(sc);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/* Init page buffer descriptor chain. */
bce_init_pg_chain(sc);
#endif
@@ -6794,7 +6793,7 @@ bce_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
BCE_LOCK(sc);
ifp->if_mtu = ifr->ifr_mtu;
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/* No buffer allocation size changes are necessary. */
#else
/* Recalculate our buffer allocation sizes. */
@@ -7495,7 +7494,7 @@ bce_tick(void *xsc)
bce_stats_update(sc);
/* Top off the receive and page chains. */
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
bce_fill_pg_chain(sc);
#endif
bce_fill_rx_chain(sc);
@@ -7675,7 +7674,7 @@ bce_sysctl_dump_tx_chain(SYSCTL_HANDLER_ARGS)
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/****************************************************************************/
/* Provides a sysctl interface to allow dumping the page chain. */
/* */
@@ -8248,7 +8247,7 @@ bce_add_sysctls(struct bce_softc *sc)
(void *)sc, 0,
bce_sysctl_dump_tx_chain, "I", "Dump tx_bd chain");
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
SYSCTL_ADD_PROC(ctx, children, OID_AUTO,
"dump_pg_chain", CTLTYPE_INT | CTLFLAG_RW,
(void *)sc, 0,
@@ -8543,7 +8542,7 @@ bce_dump_rx_mbuf_chain(struct bce_softc *sc, u16 chain_prod, int count)
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/****************************************************************************/
/* Prints out the mbufs in the mbuf page chain. */
/* */
@@ -8667,7 +8666,7 @@ bce_dump_rxbd(struct bce_softc *sc, int idx, struct rx_bd *rxbd)
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/****************************************************************************/
/* Prints out a rx_bd structure in the page chain. */
/* */
@@ -9154,7 +9153,7 @@ bce_dump_rx_chain(struct bce_softc *sc, u16 rx_prod, int count)
}
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
/****************************************************************************/
/* Prints out the page chain. */
/* */
@@ -9635,7 +9634,7 @@ bce_dump_driver_state(struct bce_softc *sc)
"0x%08X:%08X - (sc->rx_bd_chain) rx_bd chain virtual address\n",
val_hi, val_lo);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
val_hi = BCE_ADDR_HI(sc->pg_bd_chain);
val_lo = BCE_ADDR_LO(sc->pg_bd_chain);
BCE_PRINTF(
@@ -9655,7 +9654,7 @@ bce_dump_driver_state(struct bce_softc *sc)
"0x%08X:%08X - (sc->rx_mbuf_ptr) rx mbuf chain virtual address\n",
val_hi, val_lo);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
val_hi = BCE_ADDR_HI(sc->pg_mbuf_ptr);
val_lo = BCE_ADDR_LO(sc->pg_mbuf_ptr);
BCE_PRINTF(
@@ -9708,7 +9707,7 @@ bce_dump_driver_state(struct bce_softc *sc)
BCE_PRINTF(" 0x%08X - (sc->free_rx_bd) free rx_bd's\n",
sc->free_rx_bd);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
BCE_PRINTF(" 0x%04X(0x%04X) - (sc->pg_prod) page producer index\n",
sc->pg_prod, (u16) PG_CHAIN_IDX(sc->pg_prod));
@@ -10218,7 +10217,7 @@ bce_breakpoint(struct bce_softc *sc)
bce_dump_tpat_state(sc, 0);
bce_dump_cp_state(sc, 0);
bce_dump_com_state(sc, 0);
-#ifdef BCE_USE_SPLIT_HEADER
+#ifdef ZERO_COPY_SOCKETS
bce_dump_pgbd(sc, 0, NULL);
bce_dump_pg_mbuf_chain(sc, 0, USABLE_PG_BD);
bce_dump_pg_chain(sc, 0, USABLE_PG_BD);
diff --git a/sys/dev/bce/if_bcefw.h b/sys/dev/bce/if_bcefw.h
index 8205aaf..76a0fda 100644
--- a/sys/dev/bce/if_bcefw.h
+++ b/sys/dev/bce/if_bcefw.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2006-2008 Broadcom Corporation
+ * Copyright (c) 2006-2009 Broadcom Corporation
* David Christensen <davidch@broadcom.com>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/bce/if_bcereg.h b/sys/dev/bce/if_bcereg.h
index 001d341..83d4e80 100644
--- a/sys/dev/bce/if_bcereg.h
+++ b/sys/dev/bce/if_bcereg.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2006-2008 Broadcom Corporation
+ * Copyright (c) 2006-2009 Broadcom Corporation
* David Christensen <davidch@broadcom.com>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -6206,6 +6206,7 @@ struct l2_fhdr {
#define RX_PAGE(x) (((x) & ~USABLE_RX_BD_PER_PAGE) >> (BCM_PAGE_BITS - 4))
#define RX_IDX(x) ((x) & USABLE_RX_BD_PER_PAGE)
+#ifdef ZERO_COPY_SOCKETS
/*
* To accomodate jumbo frames, the page chain should
* be 4 times larger than the receive chain.
@@ -6226,6 +6227,8 @@ struct l2_fhdr {
#define PG_PAGE(x) (((x) & ~USABLE_PG_BD_PER_PAGE) >> (BCM_PAGE_BITS - 4))
#define PG_IDX(x) ((x) & USABLE_PG_BD_PER_PAGE)
+#endif /* ZERO_COPY_SOCKETS */
+
/* Context size. */
#define CTX_SHIFT 7
#define CTX_SIZE (1 << CTX_SHIFT)
@@ -6499,8 +6502,11 @@ struct bce_softc
u16 tx_prod;
u16 tx_cons;
u32 tx_prod_bseq; /* Counts the bytes used. */
+
+#ifdef ZERO_COPY_SOCKETS
u16 pg_prod;
u16 pg_cons;
+#endif
int bce_link;
struct callout bce_tick_callout;
@@ -6513,7 +6519,10 @@ struct bce_softc
int rx_bd_mbuf_alloc_size;
int rx_bd_mbuf_data_len;
int rx_bd_mbuf_align_pad;
+
+#ifdef ZERO_COPY_SOCKETS
int pg_bd_mbuf_alloc_size;
+#endif
/* Receive mode settings (i.e promiscuous, multicast, etc.). */
u32 rx_mode;
@@ -6533,11 +6542,13 @@ struct bce_softc
struct rx_bd *rx_bd_chain[RX_PAGES];
bus_addr_t rx_bd_chain_paddr[RX_PAGES];
+#ifdef ZERO_COPY_SOCKETS
/* H/W maintained page buffer descriptor chain structure. */
bus_dma_tag_t pg_bd_chain_tag;
bus_dmamap_t pg_bd_chain_map[PG_PAGES];
struct rx_bd *pg_bd_chain[PG_PAGES];
bus_addr_t pg_bd_chain_paddr[PG_PAGES];
+#endif
/* H/W maintained status block. */
bus_dma_tag_t status_tag;
@@ -6567,7 +6578,10 @@ struct bce_softc
/* Bus tag for RX/TX mbufs. */
bus_dma_tag_t rx_mbuf_tag;
bus_dma_tag_t tx_mbuf_tag;
+
+#ifdef ZERO_COPY_SOCKETS
bus_dma_tag_t pg_mbuf_tag;
+#endif
/* S/W maintained mbuf TX chain structure. */
bus_dmamap_t tx_mbuf_map[TOTAL_TX_BD];
@@ -6577,17 +6591,22 @@ struct bce_softc
bus_dmamap_t rx_mbuf_map[TOTAL_RX_BD];
struct mbuf *rx_mbuf_ptr[TOTAL_RX_BD];
+#ifdef ZERO_COPY_SOCKETS
/* S/W maintained mbuf page chain structure. */
bus_dmamap_t pg_mbuf_map[TOTAL_PG_BD];
struct mbuf *pg_mbuf_ptr[TOTAL_PG_BD];
+#endif
/* Track the number of buffer descriptors in use. */
u16 free_rx_bd;
u16 max_rx_bd;
u16 used_tx_bd;
u16 max_tx_bd;
+
+#ifdef ZERO_COPY_SOCKETS
u16 free_pg_bd;
u16 max_pg_bd;
+#endif
/* Provides access to hardware statistics through sysctl. */
u64 stat_IfHCInOctets;
@@ -6661,7 +6680,10 @@ struct bce_softc
/* Track the number of enqueued mbufs. */
int debug_tx_mbuf_alloc;
int debug_rx_mbuf_alloc;
+
+#ifdef ZERO_COPY_SOCKETS
int debug_pg_mbuf_alloc;
+#endif
/* Track how many and what type of interrupts are generated. */
u32 interrupts_generated;
@@ -6676,8 +6698,10 @@ struct bce_softc
u32 rx_low_watermark; /* Lowest number of rx_bd's free. */
u32 rx_empty_count; /* Number of times the RX chain was empty. */
+#ifdef ZERO_COPY_SOCKETS
u32 pg_low_watermark; /* Lowest number of pages free. */
u32 pg_empty_count; /* Number of times the page chain was empty. */
+#endif
u32 tx_hi_watermark; /* Greatest number of tx_bd's used. */
u32 tx_full_count; /* Number of times the TX chain was full. */
@@ -6693,5 +6717,5 @@ struct bce_softc
#endif
};
-#endif /* #ifndef _BCE_H_DEFINED */
+#endif /* __BCEREG_H_DEFINED */
OpenPOWER on IntegriCloud