Date: Tue, 24 Apr 2007 04:08:40 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 118699 for review Message-ID: <200704240408.l3O48eHT041797@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=118699 Change 118699 by kmacy@kmacy_vt-x:opentoe_init on 2007/04/24 04:08:19 enable rx descriptor recycling for packets < 128 bytes fix mbuf leak in single descriptor case Affected files ... .. //depot/projects/opentoe/sys/dev/cxgb/cxgb_sge.c#11 edit Differences ... ==== //depot/projects/opentoe/sys/dev/cxgb/cxgb_sge.c#11 (text+ko) ==== @@ -73,6 +73,7 @@ uint32_t collapse_free = 0; uint32_t mb_free_vec_free = 0; int collapse_mbufs = 0; +static int recycle_enable = 1; /* @@ -85,6 +86,7 @@ #define SGE_RX_SM_BUF_SIZE 1536 #define SGE_RX_DROP_THRES 16 +#define SGE_RX_COPY_THRES 128 /* * Period of the Tx buffer reclaim timer. This timer does not need to run @@ -208,7 +210,6 @@ int n = 0; mtx_assert(&q->lock, MA_OWNED); - if (reclaim > 0) { n = free_tx_desc(adapter, q, min(reclaim, nbufs), mvec); reclaimed = min(reclaim, nbufs); @@ -584,8 +585,8 @@ * Recycles the specified buffer on the given free list by adding it at * the next available slot on the list. */ -#ifdef notyet -static void recycle_rx_buf(adapter_t *adap, struct sge_fl *q, unsigned int idx) +static void +recycle_rx_buf(adapter_t *adap, struct sge_fl *q, unsigned int idx) { struct rx_desc *from = &q->desc[idx]; struct rx_desc *to = &q->desc[q->pidx]; @@ -604,7 +605,6 @@ } t3_write_reg(adap, A_SG_KDOORBELL, V_EGRCNTX(q->cntxt_id)); } -#endif static void alloc_ring_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error) @@ -766,7 +766,7 @@ mtx_lock(&txq->lock); n = reclaim_completed_tx(sc, txq, TX_CLEAN_MAX_DESC, m_vec); mtx_unlock(&txq->lock); - + for (i = 0; i < n; i++) { m_freem_vec(m_vec[i]); } @@ -1090,6 +1090,7 @@ if (mlen <= WR_LEN - sizeof(*cpl)) { txq_prod(txq, 1, &txqs); txq->sdesc[txqs.pidx].m = m0; + m0->m_priority = txqs.pidx; if (m0->m_len == m0->m_pkthdr.len) memcpy(&txd->flit[2], m0->m_data, mlen); @@ -1734,6 +1735,8 @@ m_vec[nbufs] = d->m; d->m = NULL; nbufs++; + } else { + printf("pri=%d cidx=%d\n", d->m->m_priority, cidx); } } ++d; @@ -2142,7 +2145,6 @@ * threshold and the packet is too big to copy, or (b) the packet should * be copied but there is no memory for the copy. */ - static int get_packet(adapter_t *adap, unsigned int drop_thres, struct sge_qset *qs, struct mbuf *m, struct rsp_desc *r) @@ -2154,22 +2156,27 @@ uint32_t len = G_RSPD_LEN(len_cq); uint32_t flags = ntohl(r->flags); uint8_t sopeop = G_RSPD_SOP_EOP(flags); + void *cl; int ret = 0; prefetch(sd->cl); fl->credits--; bus_dmamap_sync(fl->entry_tag, sd->map, BUS_DMASYNC_POSTREAD); - bus_dmamap_unload(fl->entry_tag, sd->map); - /* - * XXX Recycle small packets - * - */ + if (recycle_enable && len <= SGE_RX_COPY_THRES && sopeop == RSPQ_SOP_EOP) { + cl = mtod(m, void *); + memcpy(cl, sd->cl, len); + recycle_rx_buf(adap, fl, fl->cidx); + } else { + cl = sd->cl; + bus_dmamap_unload(fl->entry_tag, sd->map); + } switch(sopeop) { case RSPQ_SOP_EOP: DBG(DBG_RX, ("get_packet: SOP-EOP m %p\n", m)); - m_cljset(m, sd->cl, fl->type); + if (cl == sd->cl) + m_cljset(m, cl, fl->type); m->m_len = m->m_pkthdr.len = len; ret = 1; goto done; @@ -2188,7 +2195,7 @@ ret = 1; break; } - m_iovappend(m, sd->cl, fl->buf_size, len, 0); + m_iovappend(m, cl, fl->buf_size, len, 0); done: if (++fl->cidx == fl->size)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704240408.l3O48eHT041797>