From 238ecfedf5eb81ff8e786e9cec23c9f422951a3a Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 9 Aug 2009 11:40:59 +0000 Subject: MCLGETI() will now allocate a mbuf header if it is not provided, thus reducing the amount of splnet/splx dancing required.. especially in the worst case (of m_cldrop) ok dlg kettenis damien --- sys/dev/pci/if_bge.c | 22 +++++----------------- sys/dev/pci/if_bnx.c | 13 +++---------- sys/dev/pci/if_em.c | 12 +++--------- sys/dev/pci/if_iwn.c | 24 +++++------------------- sys/dev/pci/if_ix.c | 12 +++--------- sys/dev/pci/if_msk.c | 12 +++--------- sys/dev/pci/if_sis.c | 12 +++--------- sys/dev/pci/if_vic.c | 12 +++--------- sys/dev/pci/if_vr.c | 12 +++--------- sys/dev/pci/if_wpi.c | 24 +++++------------------- 10 files changed, 36 insertions(+), 119 deletions(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index f03f1415002..8f8986974f1 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.279 2009/08/08 15:58:14 naddy Exp $ */ +/* $OpenBSD: if_bge.c,v 1.280 2009/08/09 11:40:56 deraadt Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -719,15 +719,9 @@ bge_newbuf(struct bge_softc *sc, int i) struct mbuf *m; int error; - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) + m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); + if (!m) return (ENOBUFS); - - MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); - if (!(m->m_flags & M_EXT)) { - m_freem(m); - return (ENOBUFS); - } m->m_len = m->m_pkthdr.len = MCLBYTES; if (!(sc->bge_flags & BGE_RX_ALIGNBUG)) m_adj(m, ETHER_ALIGN); @@ -776,15 +770,9 @@ bge_newbuf_jumbo(struct bge_softc *sc, int i) struct mbuf *m; int error; - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) + m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, BGE_JLEN); + if (!m) return (ENOBUFS); - - MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, BGE_JLEN); - if (!(m->m_flags & M_EXT)) { - m_freem(m); - return (ENOBUFS); - } m->m_len = m->m_pkthdr.len = BGE_JUMBO_FRAMELEN; if (!(sc->bge_flags & BGE_RX_ALIGNBUG)) m_adj(m, ETHER_ALIGN); diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c index e0f0de5c17a..3bf0151bdf1 100644 --- a/sys/dev/pci/if_bnx.c +++ b/sys/dev/pci/if_bnx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnx.c,v 1.82 2009/08/06 19:53:13 sthen Exp $ */ +/* $OpenBSD: if_bnx.c,v 1.83 2009/08/09 11:40:56 deraadt Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -3591,16 +3591,9 @@ bnx_get_buf(struct bnx_softc *sc, u_int16_t *prod, *prod_bseq); /* This is a new mbuf allocation. */ - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) + m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); + if (!m) return (ENOBUFS); - - /* Attach a cluster to the mbuf. */ - MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); - if (!(m->m_flags & M_EXT)) { - m_freem(m); - return (ENOBUFS); - } m->m_len = m->m_pkthdr.len = MCLBYTES; /* the chip aligns the ip header for us, no need to m_adj */ diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c index 7dbec34a729..9a7155f2ab6 100644 --- a/sys/dev/pci/if_em.c +++ b/sys/dev/pci/if_em.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_em.c,v 1.215 2009/07/27 16:37:52 claudio Exp $ */ +/* $OpenBSD: if_em.c,v 1.216 2009/08/09 11:40:56 deraadt Exp $ */ /* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */ #include @@ -2307,14 +2307,8 @@ em_get_buf(struct em_softc *sc, int i) return (ENOBUFS); } - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) { - sc->mbuf_alloc_failed++; - return (ENOBUFS); - } - MCLGETI(m, M_DONTWAIT, &sc->interface_data.ac_if, MCLBYTES); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); + m = MCLGETI(NULL, M_DONTWAIT, &sc->interface_data.ac_if, MCLBYTES); + if (!m) { sc->mbuf_cluster_failed++; return (ENOBUFS); } diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index bc6c2d431ee..76883231278 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.60 2009/07/10 07:44:04 blambert Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.61 2009/08/09 11:40:56 deraadt Exp $ */ /*- * Copyright (c) 2007-2009 Damien Bergamini @@ -1010,15 +1010,8 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring) goto fail; } - MGETHDR(data->m, M_DONTWAIT, MT_DATA); - if (data->m == NULL) { - printf("%s: could not allocate RX mbuf\n", - sc->sc_dev.dv_xname); - error = ENOMEM; - goto fail; - } - MCLGETI(data->m, M_DONTWAIT, NULL, IWN_RBUF_SIZE); - if (!(data->m->m_flags & M_EXT)) { + data->m = MCLGETI(NULL, M_DONTWAIT, NULL, IWN_RBUF_SIZE); + if (!data->m) { printf("%s: could not allocate RX mbuf cluster\n", sc->sc_dev.dv_xname); error = ENOBUFS; @@ -1704,15 +1697,8 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, return; } - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { - ic->ic_stats.is_rx_nombuf++; - ifp->if_ierrors++; - return; - } - MCLGETI(m1, M_DONTWAIT, NULL, IWN_RBUF_SIZE); - if (!(m1->m_flags & M_EXT)) { - m_freem(m1); + m1 = MCLGETI(NULL, M_DONTWAIT, NULL, IWN_RBUF_SIZE); + if (!m1) { ic->ic_stats.is_rx_nombuf++; ifp->if_ierrors++; return; diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c index e4a03ef8e93..067efcc2b69 100644 --- a/sys/dev/pci/if_ix.c +++ b/sys/dev/pci/if_ix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ix.c,v 1.24 2009/07/10 12:00:52 dlg Exp $ */ +/* $OpenBSD: if_ix.c,v 1.25 2009/08/09 11:40:56 deraadt Exp $ */ /****************************************************************************** @@ -2217,14 +2217,8 @@ ixgbe_get_buf(struct rx_ring *rxr, int i) return (ENOBUFS); } - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) { - sc->mbuf_alloc_failed++; - return (ENOBUFS); - } - MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, size); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); + m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, size); + if (!m) { sc->mbuf_cluster_failed++; return (ENOBUFS); } diff --git a/sys/dev/pci/if_msk.c b/sys/dev/pci/if_msk.c index 9cc0ef3dad6..387837302e0 100644 --- a/sys/dev/pci/if_msk.c +++ b/sys/dev/pci/if_msk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_msk.c,v 1.75 2009/03/29 14:36:34 jsg Exp $ */ +/* $OpenBSD: if_msk.c,v 1.76 2009/08/09 11:40:56 deraadt Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -503,15 +503,9 @@ msk_newbuf(struct sk_if_softc *sc_if) int error; int opcode, i; - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) + m = MCLGETI(NULL, M_DONTWAIT, &sc_if->arpcom.ac_if, sc_if->sk_pktlen); + if (!m) return (ENOBUFS); - - MCLGETI(m, M_DONTWAIT, &sc_if->arpcom.ac_if, sc_if->sk_pktlen); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); - return (ENOBUFS); - } m->m_len = m->m_pkthdr.len = sc_if->sk_pktlen; m_adj(m, ETHER_ALIGN); diff --git a/sys/dev/pci/if_sis.c b/sys/dev/pci/if_sis.c index bc8a6d9cfa6..3fb8be5af3b 100644 --- a/sys/dev/pci/if_sis.c +++ b/sys/dev/pci/if_sis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sis.c,v 1.94 2009/07/22 21:32:50 miod Exp $ */ +/* $OpenBSD: if_sis.c,v 1.95 2009/08/09 11:40:56 deraadt Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul . All rights reserved. @@ -1232,16 +1232,10 @@ sis_newbuf(struct sis_softc *sc, struct sis_desc *c) if (c == NULL) return (EINVAL); - MGETHDR(m_new, M_DONTWAIT, MT_DATA); - if (m_new == NULL) + m_new = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); + if (!m_new) return (ENOBUFS); - MCLGETI(m_new, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); - if (!(m_new->m_flags & M_EXT)) { - m_free(m_new); - return (ENOBUFS); - } - m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; if (bus_dmamap_load_mbuf(sc->sc_dmat, c->map, m_new, diff --git a/sys/dev/pci/if_vic.c b/sys/dev/pci/if_vic.c index cbe5345796f..3a5e9c1f0de 100644 --- a/sys/dev/pci/if_vic.c +++ b/sys/dev/pci/if_vic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vic.c,v 1.71 2009/06/02 12:32:06 deraadt Exp $ */ +/* $OpenBSD: if_vic.c,v 1.72 2009/08/09 11:40:56 deraadt Exp $ */ /* * Copyright (c) 2006 Reyk Floeter @@ -1340,15 +1340,9 @@ vic_alloc_mbuf(struct vic_softc *sc, bus_dmamap_t map, u_int pktlen) { struct mbuf *m = NULL; - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) + m = MCLGETI(NULL, M_DONTWAIT, &sc->sc_ac.ac_if, pktlen); + if (!m) return (NULL); - - MCLGETI(m, M_DONTWAIT, &sc->sc_ac.ac_if, pktlen); - if ((m->m_flags & M_EXT) == 0) { - m_freem(m); - return (NULL); - } m->m_data += ETHER_ALIGN; m->m_len = m->m_pkthdr.len = pktlen - ETHER_ALIGN; diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index 1dbe51a569e..4c961ebe1c2 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.97 2009/06/18 18:53:02 claudio Exp $ */ +/* $OpenBSD: if_vr.c,v 1.98 2009/08/09 11:40:56 deraadt Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1568,16 +1568,10 @@ vr_alloc_mbuf(struct vr_softc *sc, struct vr_chain_onefrag *r) if (r == NULL) return (EINVAL); - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) + m = MCLGETI(NULL, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); + if (!m) return (ENOBUFS); - MCLGETI(m, M_DONTWAIT, &sc->arpcom.ac_if, MCLBYTES); - if (!(m->m_flags & M_EXT)) { - m_free(m); - return (ENOBUFS); - } - m->m_len = m->m_pkthdr.len = MCLBYTES; m_adj(m, sizeof(u_int64_t)); diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index d52562647fe..ccd1cd72728 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.89 2009/07/11 13:28:36 blambert Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.90 2009/08/09 11:40:56 deraadt Exp $ */ /*- * Copyright (c) 2006-2008 @@ -641,15 +641,8 @@ wpi_alloc_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring) goto fail; } - MGETHDR(data->m, M_DONTWAIT, MT_DATA); - if (data->m == NULL) { - printf("%s: could not allocate RX mbuf\n", - sc->sc_dev.dv_xname); - error = ENOBUFS; - goto fail; - } - MCLGETI(data->m, M_DONTWAIT, NULL, WPI_RBUF_SIZE); - if (!(data->m->m_flags & M_EXT)) { + data->m = MCLGETI(NULL, M_DONTWAIT, NULL, WPI_RBUF_SIZE); + if (!data->m) { printf("%s: could not allocate RX mbuf cluster\n", sc->sc_dev.dv_xname); error = ENOBUFS; @@ -1192,15 +1185,8 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc, return; } - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { - ic->ic_stats.is_rx_nombuf++; - ifp->if_ierrors++; - return; - } - MCLGETI(m1, M_DONTWAIT, NULL, WPI_RBUF_SIZE); - if (!(m1->m_flags & M_EXT)) { - m_freem(m1); + m1 = MCLGETI(NULL, M_DONTWAIT, NULL, WPI_RBUF_SIZE); + if (!m1) { ic->ic_stats.is_rx_nombuf++; ifp->if_ierrors++; return; -- cgit v1.2.3