From owner-svn-src-stable-7@FreeBSD.ORG Mon Feb 9 03:23:00 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79DEF1065670; Mon, 9 Feb 2009 03:23:00 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D37A8FC16; Mon, 9 Feb 2009 03:23:00 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193N0AV043387; Mon, 9 Feb 2009 03:23:00 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193N0nL043386; Mon, 9 Feb 2009 03:23:00 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090323.n193N0nL043386@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:23:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188365 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:23:01 -0000 Author: yongari Date: Mon Feb 9 03:23:00 2009 New Revision: 188365 URL: http://svn.freebsd.org/changeset/base/188365 Log: MFC r177507(cvs if_fxp.c, 1.267): Reuse the mbuf that was just retrieved from the receive ring if mbuf exhaustion is encountered. There was a fix made previously for this problem but the solution (breaking out of the receive loop) does not seem to work. mbuf reuse strategy is already adopted by other drivers such as if_bge. The problem was recreated and the patch is also verified in the same test environment. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 02:15:25 2009 (r188364) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:23:00 2009 (r188365) @@ -231,7 +231,7 @@ static int fxp_ioctl(struct ifnet *ifp, caddr_t data); static void fxp_watchdog(struct fxp_softc *sc); static int fxp_add_rfabuf(struct fxp_softc *sc, - struct fxp_rx *rxp); + struct fxp_rx *rxp, struct mbuf *oldm); static int fxp_mc_addrs(struct fxp_softc *sc); static void fxp_mc_setup(struct fxp_softc *sc); static uint16_t fxp_eeprom_getword(struct fxp_softc *sc, int offset, @@ -715,7 +715,7 @@ fxp_attach(device_t dev) device_printf(dev, "can't create DMA map for RX\n"); goto fail; } - if (fxp_add_rfabuf(sc, rxp) != 0) { + if (fxp_add_rfabuf(sc, rxp, NULL) != 0) { error = ENOMEM; goto fail; } @@ -1652,7 +1652,7 @@ fxp_intr_body(struct fxp_softc *sc, stru * If this fails, the old buffer is recycled * instead. */ - fxp_rc = fxp_add_rfabuf(sc, rxp); + fxp_rc = fxp_add_rfabuf(sc, rxp, m); if (fxp_rc == 0) { int total_len; @@ -2245,17 +2245,26 @@ fxp_ifmedia_sts(struct ifnet *ifp, struc * data pointer is fixed up to point just past it. */ static int -fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp) +fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp, struct mbuf *oldm) { struct mbuf *m; struct fxp_rfa *rfa, *p_rfa; struct fxp_rx *p_rx; bus_dmamap_t tmp_map; - int error; + int error, reused_mbuf=0; m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m == NULL) - return (ENOBUFS); + if (m == NULL) { + if (oldm == NULL) + return ENOBUFS; + m = oldm; + m->m_data = m->m_ext.ext_buf; + /* + * return error so the receive loop will + * not pass the packet to upper layer + */ + reused_mbuf = EAGAIN; + } /* * Move the data pointer up so that the incoming data packet @@ -2320,7 +2329,7 @@ fxp_add_rfabuf(struct fxp_softc *sc, str sc->fxp_desc.rx_head = rxp; } sc->fxp_desc.rx_tail = rxp; - return (0); + return (reused_mbuf); } static int