From aec846d48461d38b520a89ce29161fdd486187b3 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Thu, 29 Nov 2001 23:47:47 +0000 Subject: Per jlemon request, reintroduce some printf() when an mbuf allocation fails, and fix (i hope) a couple of style bugs. I believe these printf() are extremely dangerous because now they can occur on every incoming packet and are not rate limited. They were meant to warn the sysadmin about lack of resources, but now they can become a nice way to panic your system under load. Other drivers (e.g. the fxp driver) have nothing like this. There is a pending discussion on putting this kind of warnings elsewhere, and I hope we can fix this soon. --- sys/dev/dc/if_dc.c | 11 ++++++++--- sys/pci/if_dc.c | 11 ++++++++--- sys/pci/if_sis.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index 81cb9360e84c9..4506fe8322442 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2217,7 +2217,7 @@ static int dc_list_tx_init(sc) cd = &sc->dc_cdata; ld = sc->dc_ldata; for (i = 0; i < DC_TX_LIST_CNT; i++) { - nexti = (i == (DC_TX_LIST_CNT - 1)) ? 0 : i+1 ; + nexti = (i == (DC_TX_LIST_CNT - 1)) ? 0 : i+1; ld->dc_tx_list[i].dc_next = vtophys(&ld->dc_tx_list[nexti]); cd->dc_tx_chain[i] = NULL; ld->dc_tx_list[i].dc_data = 0; @@ -2248,7 +2248,7 @@ static int dc_list_rx_init(sc) for (i = 0; i < DC_RX_LIST_CNT; i++) { if (dc_newbuf(sc, i, NULL) == ENOBUFS) return(ENOBUFS); - nexti = (i == (DC_RX_LIST_CNT - 1)) ? 0 : i+1 ; + nexti = (i == (DC_RX_LIST_CNT - 1)) ? 0 : i+1; ld->dc_rx_list[i].dc_next = vtophys(&ld->dc_rx_list[nexti]); } @@ -2272,11 +2272,16 @@ static int dc_newbuf(sc, i, m) if (m == NULL) { MGETHDR(m_new, M_DONTWAIT, MT_DATA); - if (m_new == NULL) + if (m_new == NULL) { + printf("dc%d: no memory for rx list " + "-- packet dropped!\n", sc->dc_unit); return(ENOBUFS); + } MCLGET(m_new, M_DONTWAIT); if (!(m_new->m_flags & M_EXT)) { + printf("dc%d: no memory for rx list " + "-- packet dropped!\n", sc->dc_unit); m_freem(m_new); return(ENOBUFS); } diff --git a/sys/pci/if_dc.c b/sys/pci/if_dc.c index 81cb9360e84c9..4506fe8322442 100644 --- a/sys/pci/if_dc.c +++ b/sys/pci/if_dc.c @@ -2217,7 +2217,7 @@ static int dc_list_tx_init(sc) cd = &sc->dc_cdata; ld = sc->dc_ldata; for (i = 0; i < DC_TX_LIST_CNT; i++) { - nexti = (i == (DC_TX_LIST_CNT - 1)) ? 0 : i+1 ; + nexti = (i == (DC_TX_LIST_CNT - 1)) ? 0 : i+1; ld->dc_tx_list[i].dc_next = vtophys(&ld->dc_tx_list[nexti]); cd->dc_tx_chain[i] = NULL; ld->dc_tx_list[i].dc_data = 0; @@ -2248,7 +2248,7 @@ static int dc_list_rx_init(sc) for (i = 0; i < DC_RX_LIST_CNT; i++) { if (dc_newbuf(sc, i, NULL) == ENOBUFS) return(ENOBUFS); - nexti = (i == (DC_RX_LIST_CNT - 1)) ? 0 : i+1 ; + nexti = (i == (DC_RX_LIST_CNT - 1)) ? 0 : i+1; ld->dc_rx_list[i].dc_next = vtophys(&ld->dc_rx_list[nexti]); } @@ -2272,11 +2272,16 @@ static int dc_newbuf(sc, i, m) if (m == NULL) { MGETHDR(m_new, M_DONTWAIT, MT_DATA); - if (m_new == NULL) + if (m_new == NULL) { + printf("dc%d: no memory for rx list " + "-- packet dropped!\n", sc->dc_unit); return(ENOBUFS); + } MCLGET(m_new, M_DONTWAIT); if (!(m_new->m_flags & M_EXT)) { + printf("dc%d: no memory for rx list " + "-- packet dropped!\n", sc->dc_unit); m_freem(m_new); return(ENOBUFS); } diff --git a/sys/pci/if_sis.c b/sys/pci/if_sis.c index 196e1f99c51a5..c4ac1407d7446 100644 --- a/sys/pci/if_sis.c +++ b/sys/pci/if_sis.c @@ -1146,7 +1146,7 @@ static int sis_list_tx_init(sc) ld = &sc->sis_ldata; for (i = 0; i < SIS_TX_LIST_CNT; i++) { - nexti = (i == (SIS_TX_LIST_CNT - 1)) ? 0 : i+1 ; + nexti = (i == (SIS_TX_LIST_CNT - 1)) ? 0 : i+1; ld->sis_tx_list[i].sis_nextdesc = &ld->sis_tx_list[nexti]; bus_dmamap_load(sc->sis_ldata.sis_tx_tag, @@ -1184,7 +1184,7 @@ static int sis_list_rx_init(sc) for (i = 0; i < SIS_RX_LIST_CNT; i++) { if (sis_newbuf(sc, &ld->sis_rx_list[i], NULL) == ENOBUFS) return(ENOBUFS); - nexti = (i == (SIS_RX_LIST_CNT - 1)) ? 0 : i+1 ; + nexti = (i == (SIS_RX_LIST_CNT - 1)) ? 0 : i+1; ld->sis_rx_list[i].sis_nextdesc = &ld->sis_rx_list[nexti]; bus_dmamap_load(sc->sis_ldata.sis_rx_tag, @@ -1217,11 +1217,16 @@ static int sis_newbuf(sc, c, m) if (m == NULL) { MGETHDR(m_new, M_DONTWAIT, MT_DATA); - if (m_new == NULL) + if (m_new == NULL) { + printf("sis%d: no memory for rx list " + "-- packet dropped!\n", sc->sis_unit); return(ENOBUFS); + } MCLGET(m_new, M_DONTWAIT); if (!(m_new->m_flags & M_EXT)) { + printf("sis%d: no memory for rx list " + "-- packet dropped!\n", sc->sis_unit); m_freem(m_new); return(ENOBUFS); } -- cgit v1.3