Well,

it looks like the patch did the trick :) thanks a lot :)

shouldn't it get to Tag OpenBSD_4_8, so everyone can benefit ?

correct me if I'm wrong, but re(4) seems to be a popular interface

best regards
M.K.


W dniu 2010-11-12 22:32, Stuart Henderson pisze:
[moving from misc to tech@, reply-to set]
On 2010-11-12, Stuart Henderson<s...@spacehopper.org>  wrote:
On 2010-11-11, Micha?? Koc<m...@prime.pl>  wrote:
Yes, it does.

regards
M.K.

W dniu 2010-11-11 10:53, Stuart Henderson pisze:
On 2010-11-10, Micha?? Koc<m...@prime.pl>   wrote:
Hi All,

migrating from re to em solved the network problem
With the re(4), does the system recover if you leave it for a couple of minutes?

Interesting... I've seen similar symptoms on my netbook a few times
recently (during p2k10) which haven't happened before, and I haven't
seen it since I got back, the only difference being that I'm mostly
using ral(4) at home and was using re(4) there.

In my case: system just appears to freeze, no response to numlock
etc, cannot enter DDB (typing blind as I'm generally in X and
the machine has no serial port, but no response to ctrl-alt-esc
followed by boot r).

When I get time to look at it I'll try and reproduce it with GENERIC
rather than GENERIC.MP (this is my main machine though and I haven't
had much chance to use it to investigate this yet..) and dig through
my old kernel archive..

IIRC, netblast (in the netrate package) was good at triggering this
(it's the fastest packet source I know of that runs on OpenBSD; about
270Kpps UDP from an opteron 146 + bge running one instance of it).

okay... at first I was having problems reproducing this, until
I hit the machine with a large bunch of *incoming* packets by
running netblast on a faster box.

to repeat this I am doing:

- boot the re(4) box, configure IP addresses, systat mbuf .1
- on a faster machine, pkg_add netrate, netblast $netbook_ip_addr 5 10
(5=packet size, 10=run for 10 seconds)

the following diff reverts MCLGETI for re(4) which stops the
freezes for me. unless there are serious objections or a fix,
I would like to commit this tomorrow as it's better than what
is in-tree.

with MCLGETI and 250Kpps the freeze is almost instant; machine
recovers some time (usually<1min) when traffic is removed.

without MCLGETI at 250Kpps it is obvious that there is starvation
almost instantly (especially with the fast systat updates), but the
machine keeps running normally.

(at first I forgot to disable IPsec - the IPsec gateway for my
netbook is an alix, so I was also able to discover that netblast
is rather good at triggering the vr(4) hangs there which require
ifconfig down+up to recover from - I guess I will be building a
non-MCLGETI vr(4) sometime soon too).


Index: re.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/re.c,v
retrieving revision 1.129
diff -u -p -r1.129 re.c
--- re.c        5 Oct 2010 08:57:34 -0000       1.129
+++ re.c        12 Nov 2010 18:39:50 -0000
@@ -1,4 +1,4 @@
-/*     $OpenBSD: re.c,v 1.129 2010/10/05 08:57:34 mikeb Exp $  */
+/*     $OpenBSD: re.c,v 1.112 2009/07/18 13:21:32 sthen Exp $  */
  /*    $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $   */
  /*
   * Copyright (c) 1997, 1998-2003
@@ -162,9 +162,8 @@ static inline void re_set_bufaddr(struct

  int   re_encap(struct rl_softc *, struct mbuf *, int *);

-int    re_newbuf(struct rl_softc *);
+int    re_newbuf(struct rl_softc *, int, struct mbuf *);
  int   re_rx_list_init(struct rl_softc *);
-void   re_rx_list_fill(struct rl_softc *);
  int   re_tx_list_init(struct rl_softc *);
  int   re_rxeof(struct rl_softc *);
  int   re_txeof(struct rl_softc *);
@@ -1109,8 +1108,6 @@ re_attach(struct rl_softc *sc, const cha
        IFQ_SET_MAXLEN(&ifp->if_snd, RL_TX_QLEN);
        IFQ_SET_READY(&ifp->if_snd);

-       m_clsetwms(ifp, MCLBYTES, 2, RL_RX_DESC_CNT);
-
        ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_IPv4 |
                               IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4;

@@ -1215,18 +1212,28 @@ fail_0:


  int
-re_newbuf(struct rl_softc *sc)
+re_newbuf(struct rl_softc *sc, int idx, struct mbuf *m)
  {
-       struct mbuf     *m;
+       struct mbuf     *n = NULL;
        bus_dmamap_t    map;
        struct rl_desc  *d;
        struct rl_rxsoft *rxs;
        u_int32_t       cmdstat;
-       int             error, idx;
+       int             error;

-       m = MCLGETI(NULL, M_DONTWAIT,&sc->sc_arpcom.ac_if, MCLBYTES);
-       if (!m)
-               return (ENOBUFS);
+       if (m == NULL) {
+               MGETHDR(n, M_DONTWAIT, MT_DATA);
+               if (n == NULL)
+                       return (ENOBUFS);
+
+               MCLGET(n, M_DONTWAIT);
+               if (!(n->m_flags&  M_EXT)) {
+                       m_freem(n);
+                       return (ENOBUFS);
+               }
+               m = n;
+       } else
+               m->m_data = m->m_ext.ext_buf;

        /*
         * Initialize mbuf length fields and fixup
@@ -1236,15 +1243,13 @@ re_newbuf(struct rl_softc *sc)
        m->m_len = m->m_pkthdr.len = RE_RX_DESC_BUFLEN;
        m->m_data += RE_ETHER_ALIGN;

-       idx = sc->rl_ldata.rl_rx_prodidx;
        rxs =&sc->rl_ldata.rl_rxsoft[idx];
        map = rxs->rxs_dmamap;
        error = bus_dmamap_load_mbuf(sc->sc_dmat, map, m,
            BUS_DMA_READ|BUS_DMA_NOWAIT);
-       if (error) {
-               m_freem(m);
-               return (ENOBUFS);
-       }
+
+       if (error)
+               goto out;

        bus_dmamap_sync(sc->sc_dmat, map, 0, map->dm_mapsize,
            BUS_DMASYNC_PREREAD);
@@ -1256,8 +1261,7 @@ re_newbuf(struct rl_softc *sc)
        if (cmdstat&  RL_RDESC_STAT_OWN) {
                printf("%s: tried to map busy RX descriptor\n",
                    sc->sc_dev.dv_xname);
-               m_freem(m);
-               return (ENOBUFS);
+               goto out;
        }

        rxs->rxs_mbuf = m;
@@ -1273,10 +1277,11 @@ re_newbuf(struct rl_softc *sc)
        d->rl_cmdstat = htole32(cmdstat);
        RL_RXDESCSYNC(sc, idx, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);

-       sc->rl_ldata.rl_rx_prodidx = RL_NEXT_RX_DESC(sc, idx);
-       sc->rl_ldata.rl_rx_cnt++;
-
        return (0);
+ out:
+       if (n != NULL)
+               m_freem(n);
+       return (ENOMEM);
  }


@@ -1305,27 +1310,21 @@ re_tx_list_init(struct rl_softc *sc)
  int
  re_rx_list_init(struct rl_softc *sc)
  {
-       bzero(sc->rl_ldata.rl_rx_list, RL_RX_LIST_SZ);
+       int     i;
+
+       memset((char *)sc->rl_ldata.rl_rx_list, 0, RL_RX_LIST_SZ);
+
+       for (i = 0; i<  RL_RX_DESC_CNT; i++) {
+               if (re_newbuf(sc, i, NULL) == ENOBUFS)
+                       return (ENOBUFS);
+       }

        sc->rl_ldata.rl_rx_prodidx = 0;
-       sc->rl_ldata.rl_rx_considx = 0;
-       sc->rl_ldata.rl_rx_cnt = 0;
        sc->rl_head = sc->rl_tail = NULL;

-       re_rx_list_fill(sc);
-
        return (0);
  }

-void
-re_rx_list_fill(struct rl_softc *sc)
-{
-       while (sc->rl_ldata.rl_rx_cnt<  RL_RX_DESC_CNT) {
-               if (re_newbuf(sc) == ENOBUFS)
-                       break;
-       }
-}
-
  /*
   * RX handler for C+ and 8169. For the gigE chips, we support
   * the reception of jumbo frames that have been fragmented
@@ -1343,8 +1342,7 @@ re_rxeof(struct rl_softc *sc)

        ifp =&sc->sc_arpcom.ac_if;

-       for (i = sc->rl_ldata.rl_rx_considx; sc->rl_ldata.rl_rx_cnt>  0;
-            i = RL_NEXT_RX_DESC(sc, i)) {
+       for (i = sc->rl_ldata.rl_rx_prodidx;; i = RL_NEXT_RX_DESC(sc, i)) {
                cur_rx =&sc->rl_ldata.rl_rx_list[i];
                RL_RXDESCSYNC(sc, i,
                    BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
@@ -1356,8 +1354,6 @@ re_rxeof(struct rl_softc *sc)
                total_len = rxstat&  sc->rl_rxlenmask;
                rxs =&sc->rl_ldata.rl_rxsoft[i];
                m = rxs->rxs_mbuf;
-               rxs->rxs_mbuf = NULL;
-               sc->rl_ldata.rl_rx_cnt--;
                rx = 1;

                /* Invalidate the RX mbuf and unload its map */
@@ -1376,6 +1372,7 @@ re_rxeof(struct rl_softc *sc)
                                sc->rl_tail->m_next = m;
                                sc->rl_tail = m;
                        }
+                       re_newbuf(sc, i, NULL);
                        continue;
                }

@@ -1413,6 +1410,22 @@ re_rxeof(struct rl_softc *sc)
                                m_freem(sc->rl_head);
                                sc->rl_head = sc->rl_tail = NULL;
                        }
+                       re_newbuf(sc, i, m);
+                       continue;
+               }
+
+               /*
+                * If allocating a replacement mbuf fails,
+                * reload the current one.
+                */
+
+               if (re_newbuf(sc, i, NULL)) {
+                       ifp->if_ierrors++;
+                       if (sc->rl_head != NULL) {
+                               m_freem(sc->rl_head);
+                               sc->rl_head = sc->rl_tail = NULL;
+                       }
+                       re_newbuf(sc, i, m);
                        continue;
                }

@@ -1490,8 +1503,7 @@ re_rxeof(struct rl_softc *sc)
                ether_input_mbuf(ifp, m);
        }

-       sc->rl_ldata.rl_rx_considx = i;
-       re_rx_list_fill(sc);
+       sc->rl_ldata.rl_rx_prodidx = i;

        return (rx);
  }
Index: rtl81x9reg.h
===================================================================
RCS file: /cvs/src/sys/dev/ic/rtl81x9reg.h,v
retrieving revision 1.70
diff -u -p -r1.70 rtl81x9reg.h
--- rtl81x9reg.h        7 Sep 2010 16:21:43 -0000       1.70
+++ rtl81x9reg.h        12 Nov 2010 18:32:10 -0000
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rtl81x9reg.h,v 1.70 2010/09/07 16:21:43 deraadt Exp $ */
+/*     $OpenBSD: rtl81x9reg.h,v 1.65 2009/07/11 16:51:58 sthen Exp $   */

  /*
   * Copyright (c) 1997, 1998
@@ -787,9 +787,7 @@ struct rl_list_data {
        struct rl_rxsoft        rl_rxsoft[RL_RX_DESC_CNT];
        bus_dmamap_t            rl_rx_list_map;
        struct rl_desc          *rl_rx_list;
-       int                     rl_rx_considx;
        int                     rl_rx_prodidx;
-       int                     rl_rx_cnt;
        bus_dma_segment_t       rl_rx_listseg;
        int                     rl_rx_listnseg;
  };

Reply via email to