sk Panic in 8.0-CURRENT
Pyun YongHyeon
pyunyh at gmail.com
Wed Feb 13 00:36:09 UTC 2008
On Mon, Feb 11, 2008 at 07:45:31PM -0800, Cy Schubert wrote:
> In message <20080212014312.GA6953 at cdnetworks.co.kr>, Pyun YongHyeon writes:
> > On Mon, Feb 11, 2008 at 04:10:40PM -0800, Cy Schubert wrote:
> > > Has anyone seen the following mutex panic in sk_jfree? The last time this
> > > system booted was Jan 31.
> > >
> >
> > [...]
> >
> > > panic: mtx_lock() of spin mutex (null) @ /dsk03/src/cvs-current/src/sys/mo
> > du
> > > les/sk/../../dev/sk/if_sk.c:2439
> > > cpuid = 0
> > > KDB: enter: panic
> > > [thread pid 12 tid 100038 ]
> > > Stopped at kdb_enter+0x34: movl $0,kdb_why
> > > db> bt
> > > Tracing pid 12 tid 100038 td 0xc3363cc0
> > > kdb_enter(c0a36183,c0a36183) at kdb_enter+0x34
> > > panic(c0a34f9b,0,c0cefb36,987,e2583cc0,...) at panic+0x111
> > > _mtx_lock_flags(e2586bbc,0,c0cefb36,987,c35d1000,...) at
> > > _mtx_lock_flags+0x70
> > > sk_jfree(c341f000,e2583cc0) at sk_jfree+0x3a
> > > mb_free_ext(c35d1000) at mb_free_ext+0x18f
> > > m_freem(c35d1000) at m_freem+0x1f
> > > arpintr(c35d1000) at arpintr+0xc0b
> > > netisr_dispatch(12,c35d1000) at netisr_dispatch+0x5d
> > > ether_demux(c33d5400,c35d1000) at ether_demux+0x1c9
> > > ether_input(c33d5400,c35d1000,c33f36e0,0,c0cefb36,...) at ether_input+0x2f
> > 9
> > > sk_jumbo_rxeof(c33f36e0,c341f000,c33d5400,0,c342d340,...) at
> > > sk_jumbo_rxeof+0x215
> > > sk_intr(c33f3680) at sk_intr+0xac
> > > ithread_loop(c342ab40,e2589d38) at ithread_loop+0x175
> > > fork_exit(c06eded0,c342ab40,e2589d38) at fork_exit+0xb0
> > > fork_trampoline() at fork_trampoline+0x8
> > > --- trap 0, eip = 0, esp = 0xe2589d70, ebp = 0 ---
> > > db>
> > >
> >
> > I'm not sure whether this panic is related with recent phk's change
> > to MEXTADD(). If this is the case, you may have to use standard MTU
> > instead of 9000.
> > Since FreeBSD now have physically contiguous jumbos I have plan to
> > take advantage of it instead of use of local allocator. That would
> > also eliminate a jlist lock required to serialize accessing jumbo
> > buffers allocated from driver. Give me a couple of days.
>
> Thanks. Reducing the MTU from 9000 to default (1500) circumvents the panic.
>
Would you try attached patch?
--
Regards,
Pyun YongHyeon
-------------- next part --------------
--- sys/dev/sk/if_sk.c.orig 2008-02-04 09:59:09.000000000 +0900
+++ sys/dev/sk/if_sk.c 2008-02-12 12:58:07.000000000 +0900
@@ -227,9 +227,9 @@
static int sk_jumbo_newbuf(struct sk_if_softc *, int);
static void sk_dmamap_cb(void *, bus_dma_segment_t *, int, int);
static int sk_dma_alloc(struct sk_if_softc *);
+static int sk_dma_jumbo_alloc(struct sk_if_softc *);
static void sk_dma_free(struct sk_if_softc *);
-static void *sk_jalloc(struct sk_if_softc *);
-static void sk_jfree(void *, void *);
+static void sk_dma_jumbo_free(struct sk_if_softc *);
static int sk_init_rx_ring(struct sk_if_softc *);
static int sk_init_jumbo_rx_ring(struct sk_if_softc *);
static void sk_init_tx_ring(struct sk_if_softc *);
@@ -263,6 +263,10 @@
static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int low, int high);
static int sysctl_hw_sk_int_mod(SYSCTL_HANDLER_ARGS);
+/* Tunables. */
+static int jumbo_disable = 0;
+TUNABLE_INT("hw.skc.jumbo_disable", &jumbo_disable);
+
/*
* It seems that SK-NET GENESIS supports very simple checksum offload
* capability for Tx and I believe it can generate 0 checksum value for
@@ -1044,24 +1048,15 @@
bus_dma_segment_t segs[1];
bus_dmamap_t map;
int nsegs;
- void *buf;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
+ m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES);
if (m == NULL)
return (ENOBUFS);
- buf = sk_jalloc(sc_if);
- if (buf == NULL) {
- m_freem(m);
- return (ENOBUFS);
- }
- /* Attach the buffer to the mbuf */
- MEXTADD(m, buf, SK_JLEN, sk_jfree, (struct sk_if_softc *)sc_if, buf, 0,
- EXT_NET_DRV);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
return (ENOBUFS);
}
- m->m_pkthdr.len = m->m_len = SK_JLEN;
+ m->m_pkthdr.len = m->m_len = MJUM9BYTES;
/*
* Adjust alignment so packet payload begins on a
* longword boundary. Mandatory for Alpha, useful on
@@ -1149,15 +1144,22 @@
error = 0;
switch(command) {
case SIOCSIFMTU:
- SK_IF_LOCK(sc_if);
- if (ifr->ifr_mtu > SK_JUMBO_MTU)
+ if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > SK_JUMBO_MTU)
error = EINVAL;
- else {
- ifp->if_mtu = ifr->ifr_mtu;
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
- sk_init_locked(sc_if);
+ else if (ifp->if_mtu != ifr->ifr_mtu) {
+ if (sc_if->sk_jumbo_disable != 0 &&
+ ifr->ifr_mtu > SK_MAX_FRAMELEN)
+ error = EINVAL;
+ else {
+ SK_IF_LOCK(sc_if);
+ ifp->if_mtu = ifr->ifr_mtu;
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ sk_init_locked(sc_if);
+ }
+ SK_IF_UNLOCK(sc_if);
+ }
}
- SK_IF_UNLOCK(sc_if);
break;
case SIOCSIFFLAGS:
SK_IF_LOCK(sc_if);
@@ -1374,6 +1376,7 @@
error = ENOMEM;
goto fail;
}
+ sk_dma_jumbo_alloc(sc_if);
ifp = sc_if->sk_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
@@ -1855,6 +1858,7 @@
device_delete_child(dev, sc_if->sk_miibus);
*/
bus_generic_detach(dev);
+ sk_dma_jumbo_free(sc_if);
sk_dma_free(sc_if);
SK_IF_UNLOCK(sc_if);
@@ -1928,15 +1932,8 @@
struct sk_dmamap_arg ctx;
struct sk_txdesc *txd;
struct sk_rxdesc *rxd;
- struct sk_rxdesc *jrxd;
- u_int8_t *ptr;
- struct sk_jpool_entry *entry;
int error, i;
- mtx_init(&sc_if->sk_jlist_mtx, "sk_jlist_mtx", NULL, MTX_DEF);
- SLIST_INIT(&sc_if->sk_jfree_listhead);
- SLIST_INIT(&sc_if->sk_jinuse_listhead);
-
/* create parent tag */
/*
* XXX
@@ -1963,6 +1960,7 @@
"failed to create parent DMA tag\n");
goto fail;
}
+
/* create tag for Tx ring */
error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */
SK_RING_ALIGN, 0, /* algnmnt, boundary */
@@ -1999,42 +1997,6 @@
goto fail;
}
- /* create tag for jumbo Rx ring */
- error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */
- SK_RING_ALIGN, 0, /* algnmnt, boundary */
- BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- SK_JUMBO_RX_RING_SZ, /* maxsize */
- 1, /* nsegments */
- SK_JUMBO_RX_RING_SZ, /* maxsegsize */
- 0, /* flags */
- NULL, NULL, /* lockfunc, lockarg */
- &sc_if->sk_cdata.sk_jumbo_rx_ring_tag);
- if (error != 0) {
- device_printf(sc_if->sk_if_dev,
- "failed to allocate jumbo Rx ring DMA tag\n");
- goto fail;
- }
-
- /* create tag for jumbo buffer blocks */
- error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */
- PAGE_SIZE, 0, /* algnmnt, boundary */
- BUS_SPACE_MAXADDR, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- SK_JMEM, /* maxsize */
- 1, /* nsegments */
- SK_JMEM, /* maxsegsize */
- 0, /* flags */
- NULL, NULL, /* lockfunc, lockarg */
- &sc_if->sk_cdata.sk_jumbo_tag);
- if (error != 0) {
- device_printf(sc_if->sk_if_dev,
- "failed to allocate jumbo Rx buffer block DMA tag\n");
- goto fail;
- }
-
/* create tag for Tx buffers */
error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */
1, 0, /* algnmnt, boundary */
@@ -2071,24 +2033,6 @@
goto fail;
}
- /* create tag for jumbo Rx buffers */
- error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */
- PAGE_SIZE, 0, /* algnmnt, boundary */
- BUS_SPACE_MAXADDR, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- MCLBYTES * SK_MAXRXSEGS, /* maxsize */
- SK_MAXRXSEGS, /* nsegments */
- SK_JLEN, /* maxsegsize */
- 0, /* flags */
- NULL, NULL, /* lockfunc, lockarg */
- &sc_if->sk_cdata.sk_jumbo_rx_tag);
- if (error != 0) {
- device_printf(sc_if->sk_if_dev,
- "failed to allocate jumbo Rx DMA tag\n");
- goto fail;
- }
-
/* allocate DMA'able memory and load the DMA map for Tx ring */
error = bus_dmamem_alloc(sc_if->sk_cdata.sk_tx_ring_tag,
(void **)&sc_if->sk_rdata.sk_tx_ring, BUS_DMA_NOWAIT | BUS_DMA_ZERO,
@@ -2131,28 +2075,6 @@
}
sc_if->sk_rdata.sk_rx_ring_paddr = ctx.sk_busaddr;
- /* allocate DMA'able memory and load the DMA map for jumbo Rx ring */
- error = bus_dmamem_alloc(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
- (void **)&sc_if->sk_rdata.sk_jumbo_rx_ring,
- BUS_DMA_NOWAIT|BUS_DMA_ZERO, &sc_if->sk_cdata.sk_jumbo_rx_ring_map);
- if (error != 0) {
- device_printf(sc_if->sk_if_dev,
- "failed to allocate DMA'able memory for jumbo Rx ring\n");
- goto fail;
- }
-
- ctx.sk_busaddr = 0;
- error = bus_dmamap_load(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
- sc_if->sk_cdata.sk_jumbo_rx_ring_map,
- sc_if->sk_rdata.sk_jumbo_rx_ring, SK_JUMBO_RX_RING_SZ, sk_dmamap_cb,
- &ctx, BUS_DMA_NOWAIT);
- if (error != 0) {
- device_printf(sc_if->sk_if_dev,
- "failed to load DMA'able memory for jumbo Rx ring\n");
- goto fail;
- }
- sc_if->sk_rdata.sk_jumbo_rx_ring_paddr = ctx.sk_busaddr;
-
/* create DMA maps for Tx buffers */
for (i = 0; i < SK_TX_RING_CNT; i++) {
txd = &sc_if->sk_cdata.sk_txdesc[i];
@@ -2166,6 +2088,7 @@
goto fail;
}
}
+
/* create DMA maps for Rx buffers */
if ((error = bus_dmamap_create(sc_if->sk_cdata.sk_rx_tag, 0,
&sc_if->sk_cdata.sk_rx_sparemap)) != 0) {
@@ -2185,12 +2108,88 @@
goto fail;
}
}
+
+fail:
+ return (error);
+}
+
+static int
+sk_dma_jumbo_alloc(sc_if)
+ struct sk_if_softc *sc_if;
+{
+ struct sk_dmamap_arg ctx;
+ struct sk_rxdesc *jrxd;
+ int error, i;
+
+ if (jumbo_disable != 0) {
+ device_printf(sc_if->sk_if_dev, "disabling jumbo frame support\n");
+ sc_if->sk_jumbo_disable = 1;
+ return (0);
+ }
+ /* create tag for jumbo Rx ring */
+ error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */
+ SK_RING_ALIGN, 0, /* algnmnt, boundary */
+ BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ SK_JUMBO_RX_RING_SZ, /* maxsize */
+ 1, /* nsegments */
+ SK_JUMBO_RX_RING_SZ, /* maxsegsize */
+ 0, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &sc_if->sk_cdata.sk_jumbo_rx_ring_tag);
+ if (error != 0) {
+ device_printf(sc_if->sk_if_dev,
+ "failed to allocate jumbo Rx ring DMA tag\n");
+ goto jumbo_fail;
+ }
+
+ /* create tag for jumbo Rx buffers */
+ error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */
+ 1, 0, /* algnmnt, boundary */
+ BUS_SPACE_MAXADDR, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ MJUM9BYTES, /* maxsize */
+ 1, /* nsegments */
+ MJUM9BYTES, /* maxsegsize */
+ 0, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &sc_if->sk_cdata.sk_jumbo_rx_tag);
+ if (error != 0) {
+ device_printf(sc_if->sk_if_dev,
+ "failed to allocate jumbo Rx DMA tag\n");
+ goto jumbo_fail;
+ }
+
+ /* allocate DMA'able memory and load the DMA map for jumbo Rx ring */
+ error = bus_dmamem_alloc(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
+ (void **)&sc_if->sk_rdata.sk_jumbo_rx_ring,
+ BUS_DMA_NOWAIT|BUS_DMA_ZERO, &sc_if->sk_cdata.sk_jumbo_rx_ring_map);
+ if (error != 0) {
+ device_printf(sc_if->sk_if_dev,
+ "failed to allocate DMA'able memory for jumbo Rx ring\n");
+ goto jumbo_fail;
+ }
+
+ ctx.sk_busaddr = 0;
+ error = bus_dmamap_load(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
+ sc_if->sk_cdata.sk_jumbo_rx_ring_map,
+ sc_if->sk_rdata.sk_jumbo_rx_ring, SK_JUMBO_RX_RING_SZ, sk_dmamap_cb,
+ &ctx, BUS_DMA_NOWAIT);
+ if (error != 0) {
+ device_printf(sc_if->sk_if_dev,
+ "failed to load DMA'able memory for jumbo Rx ring\n");
+ goto jumbo_fail;
+ }
+ sc_if->sk_rdata.sk_jumbo_rx_ring_paddr = ctx.sk_busaddr;
+
/* create DMA maps for jumbo Rx buffers */
if ((error = bus_dmamap_create(sc_if->sk_cdata.sk_jumbo_rx_tag, 0,
&sc_if->sk_cdata.sk_jumbo_rx_sparemap)) != 0) {
device_printf(sc_if->sk_if_dev,
"failed to create spare jumbo Rx dmamap\n");
- goto fail;
+ goto jumbo_fail;
}
for (i = 0; i < SK_JUMBO_RX_RING_CNT; i++) {
jrxd = &sc_if->sk_cdata.sk_jumbo_rxdesc[i];
@@ -2201,55 +2200,18 @@
if (error != 0) {
device_printf(sc_if->sk_if_dev,
"failed to create jumbo Rx dmamap\n");
- goto fail;
+ goto jumbo_fail;
}
}
- /* allocate DMA'able memory and load the DMA map for jumbo buf */
- error = bus_dmamem_alloc(sc_if->sk_cdata.sk_jumbo_tag,
- (void **)&sc_if->sk_rdata.sk_jumbo_buf,
- BUS_DMA_NOWAIT|BUS_DMA_ZERO, &sc_if->sk_cdata.sk_jumbo_map);
- if (error != 0) {
- device_printf(sc_if->sk_if_dev,
- "failed to allocate DMA'able memory for jumbo buf\n");
- goto fail;
- }
-
- ctx.sk_busaddr = 0;
- error = bus_dmamap_load(sc_if->sk_cdata.sk_jumbo_tag,
- sc_if->sk_cdata.sk_jumbo_map,
- sc_if->sk_rdata.sk_jumbo_buf, SK_JMEM, sk_dmamap_cb,
- &ctx, BUS_DMA_NOWAIT);
- if (error != 0) {
- device_printf(sc_if->sk_if_dev,
- "failed to load DMA'able memory for jumbobuf\n");
- goto fail;
- }
- sc_if->sk_rdata.sk_jumbo_buf_paddr = ctx.sk_busaddr;
-
- /*
- * Now divide it up into 9K pieces and save the addresses
- * in an array.
- */
- ptr = sc_if->sk_rdata.sk_jumbo_buf;
- for (i = 0; i < SK_JSLOTS; i++) {
- sc_if->sk_cdata.sk_jslots[i] = ptr;
- ptr += SK_JLEN;
- entry = malloc(sizeof(struct sk_jpool_entry),
- M_DEVBUF, M_NOWAIT);
- if (entry == NULL) {
- device_printf(sc_if->sk_if_dev,
- "no memory for jumbo buffers!\n");
- error = ENOMEM;
- goto fail;
- }
- entry->slot = i;
- SLIST_INSERT_HEAD(&sc_if->sk_jfree_listhead, entry,
- jpool_entries);
- }
+ return (0);
-fail:
- return (error);
+jumbo_fail:
+ sk_dma_jumbo_free(sc_if);
+ device_printf(sc_if->sk_if_dev, "disabling jumbo frame support due to "
+ "resource shortage\n");
+ sc_if->sk_jumbo_disable = 1;
+ return (0);
}
static void
@@ -2258,39 +2220,8 @@
{
struct sk_txdesc *txd;
struct sk_rxdesc *rxd;
- struct sk_rxdesc *jrxd;
- struct sk_jpool_entry *entry;
int i;
- SK_JLIST_LOCK(sc_if);
- while ((entry = SLIST_FIRST(&sc_if->sk_jinuse_listhead))) {
- device_printf(sc_if->sk_if_dev,
- "asked to free buffer that is in use!\n");
- SLIST_REMOVE_HEAD(&sc_if->sk_jinuse_listhead, jpool_entries);
- SLIST_INSERT_HEAD(&sc_if->sk_jfree_listhead, entry,
- jpool_entries);
- }
-
- while (!SLIST_EMPTY(&sc_if->sk_jfree_listhead)) {
- entry = SLIST_FIRST(&sc_if->sk_jfree_listhead);
- SLIST_REMOVE_HEAD(&sc_if->sk_jfree_listhead, jpool_entries);
- free(entry, M_DEVBUF);
- }
- SK_JLIST_UNLOCK(sc_if);
-
- /* destroy jumbo buffer block */
- if (sc_if->sk_cdata.sk_jumbo_map)
- bus_dmamap_unload(sc_if->sk_cdata.sk_jumbo_tag,
- sc_if->sk_cdata.sk_jumbo_map);
-
- if (sc_if->sk_rdata.sk_jumbo_buf) {
- bus_dmamem_free(sc_if->sk_cdata.sk_jumbo_tag,
- sc_if->sk_rdata.sk_jumbo_buf,
- sc_if->sk_cdata.sk_jumbo_map);
- sc_if->sk_rdata.sk_jumbo_buf = NULL;
- sc_if->sk_cdata.sk_jumbo_map = 0;
- }
-
/* Tx ring */
if (sc_if->sk_cdata.sk_tx_ring_tag) {
if (sc_if->sk_cdata.sk_tx_ring_map)
@@ -2321,21 +2252,6 @@
bus_dma_tag_destroy(sc_if->sk_cdata.sk_rx_ring_tag);
sc_if->sk_cdata.sk_rx_ring_tag = NULL;
}
- /* jumbo Rx ring */
- if (sc_if->sk_cdata.sk_jumbo_rx_ring_tag) {
- if (sc_if->sk_cdata.sk_jumbo_rx_ring_map)
- bus_dmamap_unload(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
- sc_if->sk_cdata.sk_jumbo_rx_ring_map);
- if (sc_if->sk_cdata.sk_jumbo_rx_ring_map &&
- sc_if->sk_rdata.sk_jumbo_rx_ring)
- bus_dmamem_free(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
- sc_if->sk_rdata.sk_jumbo_rx_ring,
- sc_if->sk_cdata.sk_jumbo_rx_ring_map);
- sc_if->sk_rdata.sk_jumbo_rx_ring = NULL;
- sc_if->sk_cdata.sk_jumbo_rx_ring_map = 0;
- bus_dma_tag_destroy(sc_if->sk_cdata.sk_jumbo_rx_ring_tag);
- sc_if->sk_cdata.sk_jumbo_rx_ring_tag = NULL;
- }
/* Tx buffers */
if (sc_if->sk_cdata.sk_tx_tag) {
for (i = 0; i < SK_TX_RING_CNT; i++) {
@@ -2367,6 +2283,36 @@
bus_dma_tag_destroy(sc_if->sk_cdata.sk_rx_tag);
sc_if->sk_cdata.sk_rx_tag = NULL;
}
+
+ if (sc_if->sk_cdata.sk_parent_tag) {
+ bus_dma_tag_destroy(sc_if->sk_cdata.sk_parent_tag);
+ sc_if->sk_cdata.sk_parent_tag = NULL;
+ }
+}
+
+static void
+sk_dma_jumbo_free(sc_if)
+ struct sk_if_softc *sc_if;
+{
+ struct sk_rxdesc *jrxd;
+ int i;
+
+ /* jumbo Rx ring */
+ if (sc_if->sk_cdata.sk_jumbo_rx_ring_tag) {
+ if (sc_if->sk_cdata.sk_jumbo_rx_ring_map)
+ bus_dmamap_unload(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
+ sc_if->sk_cdata.sk_jumbo_rx_ring_map);
+ if (sc_if->sk_cdata.sk_jumbo_rx_ring_map &&
+ sc_if->sk_rdata.sk_jumbo_rx_ring)
+ bus_dmamem_free(sc_if->sk_cdata.sk_jumbo_rx_ring_tag,
+ sc_if->sk_rdata.sk_jumbo_rx_ring,
+ sc_if->sk_cdata.sk_jumbo_rx_ring_map);
+ sc_if->sk_rdata.sk_jumbo_rx_ring = NULL;
+ sc_if->sk_cdata.sk_jumbo_rx_ring_map = 0;
+ bus_dma_tag_destroy(sc_if->sk_cdata.sk_jumbo_rx_ring_tag);
+ sc_if->sk_cdata.sk_jumbo_rx_ring_tag = NULL;
+ }
+
/* jumbo Rx buffers */
if (sc_if->sk_cdata.sk_jumbo_rx_tag) {
for (i = 0; i < SK_JUMBO_RX_RING_CNT; i++) {
@@ -2386,72 +2332,6 @@
bus_dma_tag_destroy(sc_if->sk_cdata.sk_jumbo_rx_tag);
sc_if->sk_cdata.sk_jumbo_rx_tag = NULL;
}
-
- if (sc_if->sk_cdata.sk_parent_tag) {
- bus_dma_tag_destroy(sc_if->sk_cdata.sk_parent_tag);
- sc_if->sk_cdata.sk_parent_tag = NULL;
- }
- mtx_destroy(&sc_if->sk_jlist_mtx);
-}
-
-/*
- * Allocate a jumbo buffer.
- */
-static void *
-sk_jalloc(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct sk_jpool_entry *entry;
-
- SK_JLIST_LOCK(sc_if);
-
- entry = SLIST_FIRST(&sc_if->sk_jfree_listhead);
-
- if (entry == NULL) {
- SK_JLIST_UNLOCK(sc_if);
- return (NULL);
- }
-
- SLIST_REMOVE_HEAD(&sc_if->sk_jfree_listhead, jpool_entries);
- SLIST_INSERT_HEAD(&sc_if->sk_jinuse_listhead, entry, jpool_entries);
-
- SK_JLIST_UNLOCK(sc_if);
-
- return (sc_if->sk_cdata.sk_jslots[entry->slot]);
-}
-
-/*
- * Release a jumbo buffer.
- */
-static void
-sk_jfree(buf, args)
- void *buf;
- void *args;
-{
- struct sk_if_softc *sc_if;
- struct sk_jpool_entry *entry;
- int i;
-
- /* Extract the softc struct pointer. */
- sc_if = (struct sk_if_softc *)args;
- KASSERT(sc_if != NULL, ("%s: can't find softc pointer!", __func__));
-
- SK_JLIST_LOCK(sc_if);
- /* calculate the slot this buffer belongs to */
- i = ((vm_offset_t)buf
- - (vm_offset_t)sc_if->sk_rdata.sk_jumbo_buf) / SK_JLEN;
- KASSERT(i >= 0 && i < SK_JSLOTS,
- ("%s: asked to free buffer that we don't manage!", __func__));
-
- entry = SLIST_FIRST(&sc_if->sk_jinuse_listhead);
- KASSERT(entry != NULL, ("%s: buffer not in use!", __func__));
- entry->slot = i;
- SLIST_REMOVE_HEAD(&sc_if->sk_jinuse_listhead, jpool_entries);
- SLIST_INSERT_HEAD(&sc_if->sk_jfree_listhead, entry, jpool_entries);
- if (SLIST_EMPTY(&sc_if->sk_jinuse_listhead))
- wakeup(sc_if);
-
- SK_JLIST_UNLOCK(sc_if);
}
static void
--- sys/dev/sk/if_skreg.h.orig 2007-04-02 13:43:41.000000000 +0900
+++ sys/dev/sk/if_skreg.h 2008-02-12 12:53:22.000000000 +0900
@@ -1358,34 +1358,12 @@
#define SK_RX_RING_CNT 256
#define SK_JUMBO_RX_RING_CNT 256
#define SK_MAXTXSEGS 32
-#define SK_MAXRXSEGS 32
-/*
- * Jumbo buffer stuff. Note that we must allocate more jumbo
- * buffers than there are descriptors in the receive ring. This
- * is because we don't know how long it will take for a packet
- * to be released after we hand it off to the upper protocol
- * layers. To be safe, we allocate 1.5 times the number of
- * receive descriptors.
- */
#define SK_JUMBO_FRAMELEN 9018
#define SK_JUMBO_MTU (SK_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#define SK_MAX_FRAMELEN \
(ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN - ETHER_CRC_LEN)
#define SK_MIN_FRAMELEN (ETHER_MIN_LEN - ETHER_CRC_LEN)
-#define SK_JSLOTS ((SK_RX_RING_CNT * 3) / 2)
-
-#define SK_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN)
-#define SK_JLEN (SK_JRAWLEN + (sizeof(u_int64_t) - \
- (SK_JRAWLEN % sizeof(u_int64_t))))
-#define SK_JPAGESZ PAGE_SIZE
-#define SK_RESID (SK_JPAGESZ - (SK_JLEN * SK_JSLOTS) % SK_JPAGESZ)
-#define SK_JMEM ((SK_JLEN * SK_JSLOTS) + SK_RESID)
-
-struct sk_jpool_entry {
- int slot;
- SLIST_ENTRY(sk_jpool_entry) jpool_entries;
-};
struct sk_txdesc {
struct mbuf *tx_m;
@@ -1414,10 +1392,6 @@
bus_dmamap_t sk_rx_ring_map;
bus_dmamap_t sk_rx_sparemap;
bus_dma_tag_t sk_jumbo_rx_tag;
- bus_dma_tag_t sk_jumbo_tag;
- bus_dmamap_t sk_jumbo_map;
- bus_dma_tag_t sk_jumbo_mtag;
- caddr_t sk_jslots[SK_JSLOTS];
struct sk_rxdesc sk_jumbo_rxdesc[SK_JUMBO_RX_RING_CNT];
bus_dma_tag_t sk_jumbo_rx_ring_tag;
bus_dmamap_t sk_jumbo_rx_ring_map;
@@ -1436,8 +1410,6 @@
bus_addr_t sk_rx_ring_paddr;
struct sk_rx_desc *sk_jumbo_rx_ring;
bus_addr_t sk_jumbo_rx_ring_paddr;
- void *sk_jumbo_buf;
- bus_addr_t sk_jumbo_buf_paddr;
};
#define SK_TX_RING_ADDR(sc, i) \
@@ -1518,12 +1490,7 @@
struct sk_softc *sk_softc; /* parent controller */
int sk_tx_bmu; /* TX BMU register */
int sk_if_flags;
- SLIST_HEAD(__sk_jfreehead, sk_jpool_entry) sk_jfree_listhead;
- SLIST_HEAD(__sk_jinusehead, sk_jpool_entry) sk_jinuse_listhead;
- struct mtx sk_jlist_mtx;
+ int sk_jumbo_disable;
};
-#define SK_JLIST_LOCK(_sc) mtx_lock(&(_sc)->sk_jlist_mtx)
-#define SK_JLIST_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_jlist_mtx)
-
#define SK_TIMEOUT 1000
More information about the freebsd-current
mailing list