From owner-svn-src-stable@freebsd.org Tue Jul 23 22:00:20 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5D29AB5238; Tue, 23 Jul 2019 22:00:20 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E9C98030B; Tue, 23 Jul 2019 22:00:20 +0000 (UTC) (envelope-from np@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F1C6345EF; Tue, 23 Jul 2019 22:00:19 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6NM0JHV044735; Tue, 23 Jul 2019 22:00:19 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6NM0JaO044734; Tue, 23 Jul 2019 22:00:19 GMT (envelope-from np@FreeBSD.org) Message-Id: <201907232200.x6NM0JaO044734@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 23 Jul 2019 22:00:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r350266 - stable/12/sys/dev/cxgbe X-SVN-Group: stable-12 X-SVN-Commit-Author: np X-SVN-Commit-Paths: stable/12/sys/dev/cxgbe X-SVN-Commit-Revision: 350266 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3E9C98030B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.949,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jul 2019 22:00:20 -0000 Author: np Date: Tue Jul 23 22:00:19 2019 New Revision: 350266 URL: https://svnweb.freebsd.org/changeset/base/350266 Log: MFC r349870: cxgbe(4): Clear the freelist statistics in the clearstats ioctl. Move all clearstats code into its own function while here. Sponsored by: Chelsio Communications Modified: stable/12/sys/dev/cxgbe/t4_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/12/sys/dev/cxgbe/t4_main.c Tue Jul 23 21:28:20 2019 (r350265) +++ stable/12/sys/dev/cxgbe/t4_main.c Tue Jul 23 22:00:19 2019 (r350266) @@ -694,6 +694,7 @@ static void free_offload_policy(struct t4_offload_poli static int set_offload_policy(struct adapter *, struct t4_offload_policy *); static int read_card_mem(struct adapter *, int, struct t4_mem_range *); static int read_i2c(struct adapter *, struct t4_i2c_data *); +static int clear_stats(struct adapter *, u_int); #ifdef TCP_OFFLOAD static int toe_capability(struct vi_info *, int); #endif @@ -9837,6 +9838,107 @@ read_i2c(struct adapter *sc, struct t4_i2c_data *i2cd) return (rc); } +static int +clear_stats(struct adapter *sc, u_int port_id) +{ + int i, v, bg_map; + struct port_info *pi; + struct vi_info *vi; + struct sge_rxq *rxq; + struct sge_txq *txq; + struct sge_wrq *wrq; +#ifdef TCP_OFFLOAD + struct sge_ofld_rxq *ofld_rxq; +#endif + + if (port_id >= sc->params.nports) + return (EINVAL); + pi = sc->port[port_id]; + if (pi == NULL) + return (EIO); + + /* MAC stats */ + t4_clr_port_stats(sc, pi->tx_chan); + pi->tx_parse_error = 0; + pi->tnl_cong_drops = 0; + mtx_lock(&sc->reg_lock); + for_each_vi(pi, v, vi) { + if (vi->flags & VI_INIT_DONE) + t4_clr_vi_stats(sc, vi->vin); + } + bg_map = pi->mps_bg_map; + v = 0; /* reuse */ + while (bg_map) { + i = ffs(bg_map) - 1; + t4_write_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, + 1, A_TP_MIB_TNL_CNG_DROP_0 + i); + bg_map &= ~(1 << i); + } + mtx_unlock(&sc->reg_lock); + + /* + * Since this command accepts a port, clear stats for + * all VIs on this port. + */ + for_each_vi(pi, v, vi) { + if (vi->flags & VI_INIT_DONE) { + + for_each_rxq(vi, i, rxq) { +#if defined(INET) || defined(INET6) + rxq->lro.lro_queued = 0; + rxq->lro.lro_flushed = 0; +#endif + rxq->rxcsum = 0; + rxq->vlan_extraction = 0; + + rxq->fl.mbuf_allocated = 0; + rxq->fl.mbuf_inlined = 0; + rxq->fl.cl_allocated = 0; + rxq->fl.cl_recycled = 0; + rxq->fl.cl_fast_recycled = 0; + } + + for_each_txq(vi, i, txq) { + txq->txcsum = 0; + txq->tso_wrs = 0; + txq->vlan_insertion = 0; + txq->imm_wrs = 0; + txq->sgl_wrs = 0; + txq->txpkt_wrs = 0; + txq->txpkts0_wrs = 0; + txq->txpkts1_wrs = 0; + txq->txpkts0_pkts = 0; + txq->txpkts1_pkts = 0; + mp_ring_reset_stats(txq->r); + } + +#if defined(TCP_OFFLOAD) || defined(RATELIMIT) + for_each_ofld_txq(vi, i, wrq) { + wrq->tx_wrs_direct = 0; + wrq->tx_wrs_copied = 0; + } +#endif +#ifdef TCP_OFFLOAD + for_each_ofld_rxq(vi, i, ofld_rxq) { + ofld_rxq->fl.mbuf_allocated = 0; + ofld_rxq->fl.mbuf_inlined = 0; + ofld_rxq->fl.cl_allocated = 0; + ofld_rxq->fl.cl_recycled = 0; + ofld_rxq->fl.cl_fast_recycled = 0; + } +#endif + + if (IS_MAIN_VI(vi)) { + wrq = &sc->sge.ctrlq[pi->port_id]; + wrq->tx_wrs_direct = 0; + wrq->tx_wrs_copied = 0; + } + } + } + + return (0); +} + int t4_os_find_pci_capability(struct adapter *sc, int cap) { @@ -10040,88 +10142,9 @@ t4_ioctl(struct cdev *dev, unsigned long cmd, caddr_t case CHELSIO_T4_GET_I2C: rc = read_i2c(sc, (struct t4_i2c_data *)data); break; - case CHELSIO_T4_CLEAR_STATS: { - int i, v, bg_map; - u_int port_id = *(uint32_t *)data; - struct port_info *pi; - struct vi_info *vi; - - if (port_id >= sc->params.nports) - return (EINVAL); - pi = sc->port[port_id]; - if (pi == NULL) - return (EIO); - - /* MAC stats */ - t4_clr_port_stats(sc, pi->tx_chan); - pi->tx_parse_error = 0; - pi->tnl_cong_drops = 0; - mtx_lock(&sc->reg_lock); - for_each_vi(pi, v, vi) { - if (vi->flags & VI_INIT_DONE) - t4_clr_vi_stats(sc, vi->vin); - } - bg_map = pi->mps_bg_map; - v = 0; /* reuse */ - while (bg_map) { - i = ffs(bg_map) - 1; - t4_write_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, - 1, A_TP_MIB_TNL_CNG_DROP_0 + i); - bg_map &= ~(1 << i); - } - mtx_unlock(&sc->reg_lock); - - /* - * Since this command accepts a port, clear stats for - * all VIs on this port. - */ - for_each_vi(pi, v, vi) { - if (vi->flags & VI_INIT_DONE) { - struct sge_rxq *rxq; - struct sge_txq *txq; - struct sge_wrq *wrq; - - for_each_rxq(vi, i, rxq) { -#if defined(INET) || defined(INET6) - rxq->lro.lro_queued = 0; - rxq->lro.lro_flushed = 0; -#endif - rxq->rxcsum = 0; - rxq->vlan_extraction = 0; - } - - for_each_txq(vi, i, txq) { - txq->txcsum = 0; - txq->tso_wrs = 0; - txq->vlan_insertion = 0; - txq->imm_wrs = 0; - txq->sgl_wrs = 0; - txq->txpkt_wrs = 0; - txq->txpkts0_wrs = 0; - txq->txpkts1_wrs = 0; - txq->txpkts0_pkts = 0; - txq->txpkts1_pkts = 0; - mp_ring_reset_stats(txq->r); - } - -#if defined(TCP_OFFLOAD) || defined(RATELIMIT) - /* nothing to clear for each ofld_rxq */ - - for_each_ofld_txq(vi, i, wrq) { - wrq->tx_wrs_direct = 0; - wrq->tx_wrs_copied = 0; - } -#endif - - if (IS_MAIN_VI(vi)) { - wrq = &sc->sge.ctrlq[pi->port_id]; - wrq->tx_wrs_direct = 0; - wrq->tx_wrs_copied = 0; - } - } - } + case CHELSIO_T4_CLEAR_STATS: + rc = clear_stats(sc, *(uint32_t *)data); break; - } case CHELSIO_T4_SCHED_CLASS: rc = t4_set_sched_class(sc, (struct t4_sched_params *)data); break;