From owner-svn-src-head@freebsd.org Mon Jul 24 19:17:15 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 4392AD7DF53; Mon, 24 Jul 2017 19:17:15 +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 1ACB2754B6; Mon, 24 Jul 2017 19:17:15 +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 v6OJHEJL050538; Mon, 24 Jul 2017 19:17:14 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6OJHDRj050536; Mon, 24 Jul 2017 19:17:13 GMT (envelope-from np@FreeBSD.org) Message-Id: <201707241917.v6OJHDRj050536@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Mon, 24 Jul 2017 19:17:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321435 - 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: 321435 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: Mon, 24 Jul 2017 19:17:15 -0000 Author: np Date: Mon Jul 24 19:17:13 2017 New Revision: 321435 URL: https://svnweb.freebsd.org/changeset/base/321435 Log: cxgbe(4): Display some more TOE parameters related to retransmission and keepalive in the sysctl MIB. Provide tunables to change some of these parameters. These are supposed to be setup by the firmware so these tunables are for experimentation only. MFC after: 2 weeks Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/common/common.h head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/common/common.h ============================================================================== --- head/sys/dev/cxgbe/common/common.h Mon Jul 24 18:54:56 2017 (r321434) +++ head/sys/dev/cxgbe/common/common.h Mon Jul 24 19:17:13 2017 (r321435) @@ -501,6 +501,15 @@ static inline unsigned int dack_ticks_to_usec(const st return (ticks << adap->params.tp.dack_re) / core_ticks_per_usec(adap); } +static inline u_int ms_to_tcp_ticks(const struct adapter *adap, u_int ms) +{ + u_long l; + + l = (u_long)ms * adap->params.vpd.cclk >> adap->params.tp.tre; + + return (l); +} + void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask, u32 val); int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd, Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Mon Jul 24 18:54:56 2017 (r321434) +++ head/sys/dev/cxgbe/t4_main.c Mon Jul 24 19:17:13 2017 (r321435) @@ -551,6 +551,8 @@ static int sysctl_tc_params(SYSCTL_HANDLER_ARGS); static int sysctl_tp_tick(SYSCTL_HANDLER_ARGS); static int sysctl_tp_dack_timer(SYSCTL_HANDLER_ARGS); static int sysctl_tp_timer(SYSCTL_HANDLER_ARGS); +static int sysctl_tp_shift_cnt(SYSCTL_HANDLER_ARGS); +static int sysctl_tp_backoff(SYSCTL_HANDLER_ARGS); #endif static uint32_t fconf_iconf_to_mode(uint32_t, uint32_t); static uint32_t mode_to_fconf(uint32_t); @@ -3607,12 +3609,62 @@ static int set_params__post_init(struct adapter *sc) { uint32_t param, val; + int i, v, shift; + char s[32]; /* ask for encapsulated CPLs */ param = FW_PARAM_PFVF(CPLFW4MSG_ENCAP); val = 1; (void)t4_set_params(sc, sc->mbox, sc->pf, 0, 1, ¶m, &val); + /* + * Override the TOE timers with user provided tunables. This is not the + * recommended way to change the timers (the firmware config file is) so + * these tunables are not documented. + * + * All the timer tunables are in milliseconds. + */ + if (TUNABLE_INT_FETCH("hw.cxgbe.toe.keepalive_idle", &v)) { + t4_set_reg_field(sc, A_TP_KEEP_IDLE, + V_KEEPALIVEIDLE(M_KEEPALIVEIDLE), + V_KEEPALIVEIDLE(ms_to_tcp_ticks(sc, v))); + } + if (TUNABLE_INT_FETCH("hw.cxgbe.toe.keepalive_interval", &v)) { + t4_set_reg_field(sc, A_TP_KEEP_INTVL, + V_KEEPALIVEINTVL(M_KEEPALIVEINTVL), + V_KEEPALIVEINTVL(ms_to_tcp_ticks(sc, v))); + } + if (TUNABLE_INT_FETCH("hw.cxgbe.toe.keepalive_count", &v)) { + v &= M_KEEPALIVEMAXR1; + t4_set_reg_field(sc, A_TP_SHIFT_CNT, + V_KEEPALIVEMAXR1(M_KEEPALIVEMAXR1) | + V_KEEPALIVEMAXR2(M_KEEPALIVEMAXR2), + V_KEEPALIVEMAXR1(1) | V_KEEPALIVEMAXR2(v)); + } + if (TUNABLE_INT_FETCH("hw.cxgbe.toe.rexmt_min", &v)) { + t4_set_reg_field(sc, A_TP_RXT_MIN, + V_RXTMIN(M_RXTMIN), V_RXTMIN(ms_to_tcp_ticks(sc, v))); + } + if (TUNABLE_INT_FETCH("hw.cxgbe.toe.rexmt_max", &v)) { + t4_set_reg_field(sc, A_TP_RXT_MAX, + V_RXTMAX(M_RXTMAX), V_RXTMAX(ms_to_tcp_ticks(sc, v))); + } + if (TUNABLE_INT_FETCH("hw.cxgbe.toe.rexmt_count", &v)) { + v &= M_RXTSHIFTMAXR1; + t4_set_reg_field(sc, A_TP_SHIFT_CNT, + V_RXTSHIFTMAXR1(M_RXTSHIFTMAXR1) | + V_RXTSHIFTMAXR2(M_RXTSHIFTMAXR2), + V_RXTSHIFTMAXR1(1) | V_RXTSHIFTMAXR2(v)); + } + for (i = 0; i < 16; i++) { + snprintf(s, sizeof(s), "hw.cxgbe.toe.rexmt_backoff.%d", i); + if (TUNABLE_INT_FETCH(s, &v)) { + v &= M_TIMERBACKOFFINDEX0; + shift = (i & 3) << 3; + t4_set_reg_field(sc, A_TP_TCP_BACKOFF_REG0 + (i & ~3), + M_TIMERBACKOFFINDEX0 << shift, v << shift); + } + } return (0); } @@ -5255,6 +5307,9 @@ t4_sysctls(struct adapter *sc) #ifdef TCP_OFFLOAD if (is_offload(sc)) { + int i; + char s[4]; + /* * dev.t4nex.X.toe. */ @@ -5301,11 +5356,11 @@ t4_sysctls(struct adapter *sc) SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rexmt_min", CTLTYPE_ULONG | CTLFLAG_RD, sc, A_TP_RXT_MIN, - sysctl_tp_timer, "LU", "Retransmit min (us)"); + sysctl_tp_timer, "LU", "Minimum retransmit interval (us)"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rexmt_max", CTLTYPE_ULONG | CTLFLAG_RD, sc, A_TP_RXT_MAX, - sysctl_tp_timer, "LU", "Retransmit max (us)"); + sysctl_tp_timer, "LU", "Maximum retransmit interval (us)"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "persist_min", CTLTYPE_ULONG | CTLFLAG_RD, sc, A_TP_PERS_MIN, @@ -5317,11 +5372,11 @@ t4_sysctls(struct adapter *sc) SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "keepalive_idle", CTLTYPE_ULONG | CTLFLAG_RD, sc, A_TP_KEEP_IDLE, - sysctl_tp_timer, "LU", "Keepidle idle timer (us)"); + sysctl_tp_timer, "LU", "Keepalive idle timer (us)"); - SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "keepalive_intvl", + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "keepalive_interval", CTLTYPE_ULONG | CTLFLAG_RD, sc, A_TP_KEEP_INTVL, - sysctl_tp_timer, "LU", "Keepidle interval (us)"); + sysctl_tp_timer, "LU", "Keepalive interval timer (us)"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "initial_srtt", CTLTYPE_ULONG | CTLFLAG_RD, sc, A_TP_INIT_SRTT, @@ -5330,6 +5385,31 @@ t4_sysctls(struct adapter *sc) SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "finwait2_timer", CTLTYPE_ULONG | CTLFLAG_RD, sc, A_TP_FINWAIT2_TIMER, sysctl_tp_timer, "LU", "FINWAIT2 timer (us)"); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "syn_rexmt_count", + CTLTYPE_UINT | CTLFLAG_RD, sc, S_SYNSHIFTMAX, + sysctl_tp_shift_cnt, "IU", + "Number of SYN retransmissions before abort"); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rexmt_count", + CTLTYPE_UINT | CTLFLAG_RD, sc, S_RXTSHIFTMAXR2, + sysctl_tp_shift_cnt, "IU", + "Number of retransmissions before abort"); + + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "keepalive_count", + CTLTYPE_UINT | CTLFLAG_RD, sc, S_KEEPALIVEMAXR2, + sysctl_tp_shift_cnt, "IU", + "Number of keepalive probes before abort"); + + oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "rexmt_backoff", + CTLFLAG_RD, NULL, "TOE retransmit backoffs"); + children = SYSCTL_CHILDREN(oid); + for (i = 0; i < 16; i++) { + snprintf(s, sizeof(s), "%u", i); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, s, + CTLTYPE_UINT | CTLFLAG_RD, sc, i, sysctl_tp_backoff, + "IU", "TOE retransmit backoff"); + } } #endif } @@ -8148,6 +8228,40 @@ sysctl_tp_timer(SYSCTL_HANDLER_ARGS) v = tp_tick_us * t4_read_reg(sc, reg); return (sysctl_handle_long(oidp, &v, 0, req)); +} + +/* + * All fields in TP_SHIFT_CNT are 4b and the starting location of the field is + * passed to this function. + */ +static int +sysctl_tp_shift_cnt(SYSCTL_HANDLER_ARGS) +{ + struct adapter *sc = arg1; + int idx = arg2; + u_int v; + + MPASS(idx >= 0 && idx <= 24); + + v = (t4_read_reg(sc, A_TP_SHIFT_CNT) >> idx) & 0xf; + + return (sysctl_handle_int(oidp, &v, 0, req)); +} + +static int +sysctl_tp_backoff(SYSCTL_HANDLER_ARGS) +{ + struct adapter *sc = arg1; + int idx = arg2; + u_int shift, v, r; + + MPASS(idx >= 0 && idx < 16); + + r = A_TP_TCP_BACKOFF_REG0 + (idx & ~3); + shift = (idx & 3) << 3; + v = (t4_read_reg(sc, r) >> shift) & M_TIMERBACKOFFINDEX0; + + return (sysctl_handle_int(oidp, &v, 0, req)); } #endif