From owner-svn-src-head@freebsd.org Fri Apr 1 06:28:36 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C09ABAE9DB6; Fri, 1 Apr 2016 06:28:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8469F1201; Fri, 1 Apr 2016 06:28:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u316SZPL016558; Fri, 1 Apr 2016 06:28:35 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u316SYxi016541; Fri, 1 Apr 2016 06:28:34 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201604010628.u316SYxi016541@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 1 Apr 2016 06:28:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297482 - in head/sys: dev/cxgb dev/cxgbe dev/e1000 dev/hyperv/netvsc dev/ixgbe dev/ixl dev/mlx5/mlx5_en dev/mxge dev/oce dev/qlxgb dev/qlxge dev/vnic dev/vxge dev/xen/netfront netinet ... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2016 06:28:36 -0000 Author: sephe Date: Fri Apr 1 06:28:33 2016 New Revision: 297482 URL: https://svnweb.freebsd.org/changeset/base/297482 Log: tcp/lro: Use tcp_lro_flush_all in device drivers to avoid code duplication And factor out tcp_lro_rx_done, which deduplicates the same logic with netinet/tcp_lro.c Reviewed by: gallatin (1st version), hps, zbb, np, Dexuan Cui Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D5725 Modified: head/sys/dev/cxgb/cxgb_sge.c head/sys/dev/cxgbe/t4_sge.c head/sys/dev/e1000/if_igb.c head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/ixgbe/ix_txrx.c head/sys/dev/ixl/ixl_txrx.c head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c head/sys/dev/mxge/if_mxge.c head/sys/dev/oce/oce_if.c head/sys/dev/qlxgb/qla_isr.c head/sys/dev/qlxge/qls_isr.c head/sys/dev/vnic/nicvf_queues.c head/sys/dev/vxge/vxge.c head/sys/dev/xen/netfront/netfront.c head/sys/netinet/tcp_lro.c head/sys/ofed/drivers/net/mlx4/en_rx.c Modified: head/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- head/sys/dev/cxgb/cxgb_sge.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/cxgb/cxgb_sge.c Fri Apr 1 06:28:33 2016 (r297482) @@ -2976,11 +2976,7 @@ process_responses(adapter_t *adap, struc #if defined(INET6) || defined(INET) /* Flush LRO */ - while (!SLIST_EMPTY(&lro_ctrl->lro_active)) { - struct lro_entry *queued = SLIST_FIRST(&lro_ctrl->lro_active); - SLIST_REMOVE_HEAD(&lro_ctrl->lro_active, next); - tcp_lro_flush(lro_ctrl, queued); - } + tcp_lro_flush_all(lro_ctrl); #endif if (sleeping) Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/cxgbe/t4_sge.c Fri Apr 1 06:28:33 2016 (r297482) @@ -1397,13 +1397,8 @@ process_iql: #if defined(INET) || defined(INET6) if (iq->flags & IQ_LRO_ENABLED) { struct lro_ctrl *lro = &rxq->lro; - struct lro_entry *l; - while (!SLIST_EMPTY(&lro->lro_active)) { - l = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, l); - } + tcp_lro_flush_all(lro); } #endif Modified: head/sys/dev/e1000/if_igb.c ============================================================================== --- head/sys/dev/e1000/if_igb.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/e1000/if_igb.c Fri Apr 1 06:28:33 2016 (r297482) @@ -4974,7 +4974,6 @@ igb_rxeof(struct igb_queue *que, int cou struct rx_ring *rxr = que->rxr; struct ifnet *ifp = adapter->ifp; struct lro_ctrl *lro = &rxr->lro; - struct lro_entry *queued; int i, processed = 0, rxdone = 0; u32 ptype, staterr = 0; union e1000_adv_rx_desc *cur; @@ -5202,10 +5201,7 @@ next_desc: /* * Flush any outstanding LRO work */ - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); if (done != NULL) *done += rxdone; Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Apr 1 06:28:33 2016 (r297482) @@ -778,13 +778,8 @@ netvsc_channel_rollup(struct hv_vmbus_ch struct hn_tx_ring *txr = chan->hv_chan_txr; #if defined(INET) || defined(INET6) struct hn_rx_ring *rxr = chan->hv_chan_rxr; - struct lro_ctrl *lro = &rxr->hn_lro; - struct lro_entry *queued; - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(&rxr->hn_lro); #endif /* Modified: head/sys/dev/ixgbe/ix_txrx.c ============================================================================== --- head/sys/dev/ixgbe/ix_txrx.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/ixgbe/ix_txrx.c Fri Apr 1 06:28:33 2016 (r297482) @@ -1753,7 +1753,6 @@ ixgbe_rxeof(struct ix_queue *que) struct rx_ring *rxr = que->rxr; struct ifnet *ifp = adapter->ifp; struct lro_ctrl *lro = &rxr->lro; - struct lro_entry *queued; int i, nextp, processed = 0; u32 staterr = 0; u32 count = adapter->rx_process_limit; @@ -2003,10 +2002,7 @@ next_desc: /* * Flush any outstanding LRO work */ - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); IXGBE_RX_UNLOCK(rxr); Modified: head/sys/dev/ixl/ixl_txrx.c ============================================================================== --- head/sys/dev/ixl/ixl_txrx.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/ixl/ixl_txrx.c Fri Apr 1 06:28:33 2016 (r297482) @@ -1511,7 +1511,6 @@ ixl_rxeof(struct ixl_queue *que, int cou struct ifnet *ifp = vsi->ifp; #if defined(INET6) || defined(INET) struct lro_ctrl *lro = &rxr->lro; - struct lro_entry *queued; #endif int i, nextp, processed = 0; union i40e_rx_desc *cur; @@ -1735,10 +1734,7 @@ next_desc: /* * Flush any outstanding LRO work */ - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); #endif IXL_RX_UNLOCK(rxr); Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c Fri Apr 1 06:28:33 2016 (r297482) @@ -322,9 +322,6 @@ mlx5e_decompress_cqes(struct mlx5e_cq *c static int mlx5e_poll_rx_cq(struct mlx5e_rq *rq, int budget) { -#ifndef HAVE_TURBO_LRO - struct lro_entry *queued; -#endif int i; for (i = 0; i < budget; i++) { @@ -399,10 +396,7 @@ wq_ll_pop: /* ensure cq space is freed before enabling more cqes */ wmb(); #ifndef HAVE_TURBO_LRO - while ((queued = SLIST_FIRST(&rq->lro.lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&rq->lro.lro_active, next); - tcp_lro_flush(&rq->lro, queued); - } + tcp_lro_flush_all(&rq->lro); #endif return (i); } Modified: head/sys/dev/mxge/if_mxge.c ============================================================================== --- head/sys/dev/mxge/if_mxge.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/mxge/if_mxge.c Fri Apr 1 06:28:33 2016 (r297482) @@ -2819,11 +2819,7 @@ mxge_clean_rx_done(struct mxge_slice_sta break; } #if defined(INET) || defined (INET6) - while (!SLIST_EMPTY(&ss->lc.lro_active)) { - struct lro_entry *lro = SLIST_FIRST(&ss->lc.lro_active); - SLIST_REMOVE_HEAD(&ss->lc.lro_active, next); - tcp_lro_flush(&ss->lc, lro); - } + tcp_lro_flush_all(&ss->lc); #endif } Modified: head/sys/dev/oce/oce_if.c ============================================================================== --- head/sys/dev/oce/oce_if.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/oce/oce_if.c Fri Apr 1 06:28:33 2016 (r297482) @@ -1497,16 +1497,12 @@ static void oce_rx_flush_lro(struct oce_rq *rq) { struct lro_ctrl *lro = &rq->lro; - struct lro_entry *queued; POCE_SOFTC sc = (POCE_SOFTC) rq->parent; if (!IF_LRO_ENABLED(sc)) return; - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); rq->lro_pkts_queued = 0; return; Modified: head/sys/dev/qlxgb/qla_isr.c ============================================================================== --- head/sys/dev/qlxgb/qla_isr.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/qlxgb/qla_isr.c Fri Apr 1 06:28:33 2016 (r297482) @@ -267,7 +267,6 @@ qla_rcv_isr(qla_host_t *ha, uint32_t sds uint32_t comp_idx, desc_count; q80_stat_desc_t *sdesc; struct lro_ctrl *lro; - struct lro_entry *queued; uint32_t ret = 0; dev = ha->pci_dev; @@ -324,11 +323,7 @@ qla_rcv_isr(qla_host_t *ha, uint32_t sds } } - while((!SLIST_EMPTY(&lro->lro_active))) { - queued = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); if (hw->sds[sds_idx].sdsr_next != comp_idx) { QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx, comp_idx); Modified: head/sys/dev/qlxge/qls_isr.c ============================================================================== --- head/sys/dev/qlxge/qls_isr.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/qlxge/qls_isr.c Fri Apr 1 06:28:33 2016 (r297482) @@ -232,7 +232,6 @@ qls_cq_isr(qla_host_t *ha, uint32_t cq_i uint32_t i, cq_comp_idx; int ret = 0, tx_comp_done = 0; struct lro_ctrl *lro; - struct lro_entry *queued; cq_b = ha->rx_ring[cq_idx].cq_base_vaddr; lro = &ha->rx_ring[cq_idx].lro; @@ -287,11 +286,7 @@ qls_cq_isr(qla_host_t *ha, uint32_t cq_i } } - while((!SLIST_EMPTY(&lro->lro_active))) { - queued = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); ha->rx_ring[cq_idx].cq_next = cq_comp_idx; Modified: head/sys/dev/vnic/nicvf_queues.c ============================================================================== --- head/sys/dev/vnic/nicvf_queues.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/vnic/nicvf_queues.c Fri Apr 1 06:28:33 2016 (r297482) @@ -746,7 +746,6 @@ nicvf_cq_intr_handler(struct nicvf *nic, struct rcv_queue *rq; struct cqe_rx_t *cq_desc; struct lro_ctrl *lro; - struct lro_entry *queued; int rq_idx; int cmp_err; @@ -831,10 +830,7 @@ out: rq_idx = cq_idx; rq = &nic->qs->rq[rq_idx]; lro = &rq->lro; - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); NICVF_CMP_UNLOCK(cq); Modified: head/sys/dev/vxge/vxge.c ============================================================================== --- head/sys/dev/vxge/vxge.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/vxge/vxge.c Fri Apr 1 06:28:33 2016 (r297482) @@ -996,7 +996,6 @@ vxge_rx_compl(vxge_hal_vpath_h vpath_han vxge_vpath_t *vpath = (vxge_vpath_t *) userdata; vxge_dev_t *vdev = vpath->vdev; - struct lro_entry *queued = NULL; struct lro_ctrl *lro = &vpath->lro; /* get the interface pointer */ @@ -1083,12 +1082,8 @@ vxge_rx_compl(vxge_hal_vpath_h vpath_han &dtr_priv, &t_code) == VXGE_HAL_OK); /* Flush any outstanding LRO work */ - if (vpath->lro_enable && vpath->lro.lro_cnt) { - while ((queued = SLIST_FIRST(&lro->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } - } + if (vpath->lro_enable && vpath->lro.lro_cnt) + tcp_lro_flush_all(lro); return (status); } Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/dev/xen/netfront/netfront.c Fri Apr 1 06:28:33 2016 (r297482) @@ -1202,7 +1202,6 @@ xn_rxeof(struct netfront_rxq *rxq) struct netfront_info *np = rxq->info; #if (defined(INET) || defined(INET6)) struct lro_ctrl *lro = &rxq->lro; - struct lro_entry *queued; #endif struct netfront_rx_info rinfo; struct netif_rx_response *rx = &rinfo.rx; @@ -1296,11 +1295,7 @@ xn_rxeof(struct netfront_rxq *rxq) /* * Flush any outstanding LRO work */ - while (!SLIST_EMPTY(&lro->lro_active)) { - queued = SLIST_FIRST(&lro->lro_active); - SLIST_REMOVE_HEAD(&lro->lro_active, next); - tcp_lro_flush(lro, queued); - } + tcp_lro_flush_all(lro); #endif xn_alloc_rx_buffers(rxq); Modified: head/sys/netinet/tcp_lro.c ============================================================================== --- head/sys/netinet/tcp_lro.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/netinet/tcp_lro.c Fri Apr 1 06:28:33 2016 (r297482) @@ -67,6 +67,8 @@ static MALLOC_DEFINE(M_LRO, "LRO", "LRO #define TCP_LRO_INVALID_CSUM 0x0000 #endif +static void tcp_lro_rx_done(struct lro_ctrl *lc); + int tcp_lro_init(struct lro_ctrl *lc) { @@ -226,6 +228,17 @@ tcp_lro_rx_csum_fixup(struct lro_entry * } #endif +static void +tcp_lro_rx_done(struct lro_ctrl *lc) +{ + struct lro_entry *le; + + while ((le = SLIST_FIRST(&lc->lro_active)) != NULL) { + SLIST_REMOVE_HEAD(&lc->lro_active, next); + tcp_lro_flush(lc, le); + } +} + void tcp_lro_flush_inactive(struct lro_ctrl *lc, const struct timeval *timeout) { @@ -362,13 +375,12 @@ done: void tcp_lro_flush_all(struct lro_ctrl *lc) { - struct lro_entry *le; uint32_t hashtype; uint32_t flowid; unsigned x; /* check if no mbufs to flush */ - if (__predict_false(lc->lro_mbuf_count == 0)) + if (lc->lro_mbuf_count == 0) goto done; /* sort all mbufs according to stream */ @@ -390,10 +402,7 @@ tcp_lro_flush_all(struct lro_ctrl *lc) hashtype = M_HASHTYPE_GET(mb); /* flush active streams */ - while ((le = SLIST_FIRST(&lc->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lc->lro_active, next); - tcp_lro_flush(lc, le); - } + tcp_lro_rx_done(lc); } #ifdef TCP_LRO_RESET_SEQUENCE /* reset sequence number */ @@ -409,10 +418,8 @@ tcp_lro_flush_all(struct lro_ctrl *lc) } done: /* flush active streams */ - while ((le = SLIST_FIRST(&lc->lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&lc->lro_active, next); - tcp_lro_flush(lc, le); - } + tcp_lro_rx_done(lc); + lc->lro_mbuf_count = 0; } Modified: head/sys/ofed/drivers/net/mlx4/en_rx.c ============================================================================== --- head/sys/ofed/drivers/net/mlx4/en_rx.c Fri Apr 1 06:17:57 2016 (r297481) +++ head/sys/ofed/drivers/net/mlx4/en_rx.c Fri Apr 1 06:28:33 2016 (r297482) @@ -561,9 +561,6 @@ int mlx4_en_process_rx_cq(struct net_dev struct mbuf *mb; struct mlx4_cq *mcq = &cq->mcq; struct mlx4_cqe *buf = cq->buf; -#ifdef INET - struct lro_entry *queued; -#endif int index; unsigned int length; int polled = 0; @@ -669,10 +666,7 @@ next: /* Flush all pending IP reassembly sessions */ out: #ifdef INET - while ((queued = SLIST_FIRST(&ring->lro.lro_active)) != NULL) { - SLIST_REMOVE_HEAD(&ring->lro.lro_active, next); - tcp_lro_flush(&ring->lro, queued); - } + tcp_lro_flush_all(&ring->lro); #endif AVG_PERF_COUNTER(priv->pstats.rx_coal_avg, polled); mcq->cons_index = cons_index;