From owner-svn-src-head@freebsd.org Tue Oct 24 05:41:50 2017 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 11ABBE40A50; Tue, 24 Oct 2017 05:41:50 +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 mx1.freebsd.org (Postfix) with ESMTPS id E0A4C711DF; Tue, 24 Oct 2017 05:41:49 +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 v9O5fnR3072418; Tue, 24 Oct 2017 05:41:49 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9O5fmmn072412; Tue, 24 Oct 2017 05:41:48 GMT (envelope-from np@FreeBSD.org) Message-Id: <201710240541.v9O5fmmn072412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 24 Oct 2017 05:41:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324945 - in head/sys/dev/cxgbe: . common X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: in head/sys/dev/cxgbe: . common X-SVN-Commit-Revision: 324945 X-SVN-Commit-Repository: base 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.23 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: Tue, 24 Oct 2017 05:41:50 -0000 Author: np Date: Tue Oct 24 05:41:48 2017 New Revision: 324945 URL: https://svnweb.freebsd.org/changeset/base/324945 Log: cxgbe(4): Read the MPS buffer group map from the firmware as it could be different from hardware defaults. The congestion channel map, which is still fixed, needs to be tracked separately now. Change the congestion setting for TOE rx queues to match the drivers on other OSes while here. MFC after: 2 weeks Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/common/common.h head/sys/dev/cxgbe/common/t4_hw.c head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/t4_sge.c Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Tue Oct 24 02:25:42 2017 (r324944) +++ head/sys/dev/cxgbe/adapter.h Tue Oct 24 05:41:48 2017 (r324945) @@ -287,7 +287,8 @@ struct port_info { uint8_t mod_type; uint8_t port_id; uint8_t tx_chan; - uint8_t rx_chan_map; /* rx MPS channel bitmap */ + uint8_t mps_bg_map; /* rx MPS buffer group bitmap */ + uint8_t rx_e_chan_map; /* rx TP e-channel bitmap */ struct link_config link_cfg; struct link_config old_link_cfg; @@ -796,7 +797,7 @@ struct adapter { struct taskqueue *tq[MAX_NCHAN]; /* General purpose taskqueues */ struct port_info *port[MAX_NPORTS]; - uint8_t chan_map[MAX_NCHAN]; + uint8_t chan_map[MAX_NCHAN]; /* channel -> port */ void *tom_softc; /* (struct tom_data *) */ struct tom_tunables tt; Modified: head/sys/dev/cxgbe/common/common.h ============================================================================== --- head/sys/dev/cxgbe/common/common.h Tue Oct 24 02:25:42 2017 (r324944) +++ head/sys/dev/cxgbe/common/common.h Tue Oct 24 05:41:48 2017 (r324945) @@ -369,6 +369,8 @@ struct adapter_params { unsigned int max_ordird_qp; unsigned int max_ird_adapter; + + uint32_t mps_bg_map; /* rx buffer group map for all ports (upto 4) */ }; #define CHELSIO_T4 0x4 Modified: head/sys/dev/cxgbe/common/t4_hw.c ============================================================================== --- head/sys/dev/cxgbe/common/t4_hw.c Tue Oct 24 02:25:42 2017 (r324944) +++ head/sys/dev/cxgbe/common/t4_hw.c Tue Oct 24 05:41:48 2017 (r324945) @@ -5895,6 +5895,24 @@ void t4_pmrx_get_stats(struct adapter *adap, u32 cnt[] */ static unsigned int t4_get_mps_bg_map(struct adapter *adap, int idx) { + u32 n; + + if (adap->params.mps_bg_map) + return ((adap->params.mps_bg_map >> (idx << 3)) & 0xff); + + n = G_NUMPORTS(t4_read_reg(adap, A_MPS_CMN_CTL)); + if (n == 0) + return idx == 0 ? 0xf : 0; + if (n == 1 && chip_id(adap) <= CHELSIO_T5) + return idx < 2 ? (3 << (2 * idx)) : 0; + return 1 << idx; +} + +/* + * TP RX e-channels associated with the port. + */ +static unsigned int t4_get_rx_e_chan_map(struct adapter *adap, int idx) +{ u32 n = G_NUMPORTS(t4_read_reg(adap, A_MPS_CMN_CTL)); if (n == 0) @@ -5972,7 +5990,7 @@ void t4_get_port_stats_offset(struct adapter *adap, in */ void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p) { - u32 bgmap = t4_get_mps_bg_map(adap, idx); + u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map; u32 stat_ctl = t4_read_reg(adap, A_MPS_STAT_CTL); #define GET_STAT(name) \ @@ -6074,7 +6092,7 @@ void t4_get_port_stats(struct adapter *adap, int idx, */ void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p) { - u32 bgmap = t4_get_mps_bg_map(adap, idx); + u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map; #define GET_STAT(name) \ t4_read_reg64(adap, \ @@ -8379,7 +8397,8 @@ int t4_port_init(struct adapter *adap, int mbox, int p else p->vi[0].smt_idx = (ret & 0x7f); p->tx_chan = j; - p->rx_chan_map = t4_get_mps_bg_map(adap, j); + p->mps_bg_map = t4_get_mps_bg_map(adap, j); + p->rx_e_chan_map = t4_get_rx_e_chan_map(adap, j); p->lport = j; p->vi[0].rss_size = rss_size; t4_os_set_hw_addr(p, addr); @@ -9374,7 +9393,7 @@ int t4_set_filter_mode(struct adapter *adap, unsigned void t4_clr_port_stats(struct adapter *adap, int idx) { unsigned int i; - u32 bgmap = t4_get_mps_bg_map(adap, idx); + u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map; u32 port_base_addr; if (is_t4(adap)) Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Tue Oct 24 02:25:42 2017 (r324944) +++ head/sys/dev/cxgbe/t4_main.c Tue Oct 24 05:41:48 2017 (r324945) @@ -3563,6 +3563,19 @@ get_params__post_init(struct adapter *sc) ("%s: L2 table size (%u) larger than expected (%u)", __func__, sc->vres.l2t.size, L2T_SIZE)); + /* + * MPSBGMAP is queried separately because only recent firmwares support + * it as a parameter and we don't want the compound query above to fail + * on older firmwares. + */ + param[0] = FW_PARAM_DEV(MPSBGMAP); + val[0] = 0; + rc = -t4_query_params(sc, sc->mbox, sc->pf, 0, 1, param, val); + if (rc == 0) + sc->params.mps_bg_map = val[0]; + else + sc->params.mps_bg_map = 0; + /* get capabilites */ bzero(&caps, sizeof(caps)); caps.op_to_write = htobe32(V_FW_CMD_OP(FW_CAPS_CONFIG_CMD) | @@ -5061,8 +5074,7 @@ vi_refresh_stats(struct adapter *sc, struct vi_info *v static void cxgbe_refresh_stats(struct adapter *sc, struct port_info *pi) { - int i; - u_int v, tnl_cong_drops; + u_int i, v, tnl_cong_drops, bg_map; struct timeval tv; const struct timeval interval = {0, 250000}; /* 250ms */ @@ -5073,14 +5085,15 @@ cxgbe_refresh_stats(struct adapter *sc, struct port_in tnl_cong_drops = 0; t4_get_port_stats(sc, pi->tx_chan, &pi->stats); - for (i = 0; i < sc->chip_params->nchan; i++) { - if (pi->rx_chan_map & (1 << i)) { - mtx_lock(&sc->reg_lock); - t4_read_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, - 1, A_TP_MIB_TNL_CNG_DROP_0 + i); - mtx_unlock(&sc->reg_lock); - tnl_cong_drops += v; - } + bg_map = pi->mps_bg_map; + while (bg_map) { + i = ffs(bg_map) - 1; + mtx_lock(&sc->reg_lock); + t4_read_indirect(sc, A_TP_MIB_INDEX, A_TP_MIB_DATA, &v, 1, + A_TP_MIB_TNL_CNG_DROP_0 + i); + mtx_unlock(&sc->reg_lock); + tnl_cong_drops += v; + bg_map &= ~(1 << i); } pi->tnl_cong_drops = tnl_cong_drops; getmicrotime(&pi->last_refreshed); @@ -5672,6 +5685,10 @@ cxgbe_sysctls(struct port_info *pi) SYSCTL_ADD_INT(ctx, children, OID_AUTO, "max_speed", CTLFLAG_RD, NULL, port_top_speed(pi), "max speed (in Gbps)"); + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "mps_bg_map", CTLFLAG_RD, NULL, + pi->mps_bg_map, "MPS buffer group map"); + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "rx_e_chan_map", CTLFLAG_RD, + NULL, pi->rx_e_chan_map, "TP rx e-channel map"); if (sc->flags & IS_VF) return; Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Tue Oct 24 02:25:42 2017 (r324944) +++ head/sys/dev/cxgbe/t4_sge.c Tue Oct 24 05:41:48 2017 (r324945) @@ -3085,7 +3085,7 @@ tnl_cong(struct port_info *pi, int drop) else if (drop == 1) return (0); else - return (pi->rx_chan_map); + return (pi->rx_e_chan_map); } static int @@ -3195,8 +3195,7 @@ alloc_ofld_rxq(struct vi_info *vi, struct sge_ofld_rxq struct sysctl_oid_list *children; char name[16]; - rc = alloc_iq_fl(vi, &ofld_rxq->iq, &ofld_rxq->fl, intr_idx, - pi->rx_chan_map); + rc = alloc_iq_fl(vi, &ofld_rxq->iq, &ofld_rxq->fl, intr_idx, 0); if (rc != 0) return (rc);