From owner-svn-src-all@freebsd.org Sun Apr 28 18:30:21 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B34115860C9; Sun, 28 Apr 2019 18:30:21 +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 B29967012B; Sun, 28 Apr 2019 18:30: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 8C291E793; Sun, 28 Apr 2019 18:30:20 +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 x3SIUKs4081575; Sun, 28 Apr 2019 18:30:20 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3SIUJYp081571; Sun, 28 Apr 2019 18:30:19 GMT (envelope-from np@FreeBSD.org) Message-Id: <201904281830.x3SIUJYp081571@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Sun, 28 Apr 2019 18:30:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r346848 - in stable/11/sys/dev/cxgbe: . common tom X-SVN-Group: stable-11 X-SVN-Commit-Author: np X-SVN-Commit-Paths: in stable/11/sys/dev/cxgbe: . common tom X-SVN-Commit-Revision: 346848 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B29967012B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Apr 2019 18:30:21 -0000 Author: np Date: Sun Apr 28 18:30:19 2019 New Revision: 346848 URL: https://svnweb.freebsd.org/changeset/base/346848 Log: MFC r331902: r331902: cxgbe: Implement tcp_info handler for connections handled by t4_tom. Modified: stable/11/sys/dev/cxgbe/adapter.h stable/11/sys/dev/cxgbe/common/common.h stable/11/sys/dev/cxgbe/t4_main.c stable/11/sys/dev/cxgbe/tom/t4_tom.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/11/sys/dev/cxgbe/adapter.h Sun Apr 28 17:27:06 2019 (r346847) +++ stable/11/sys/dev/cxgbe/adapter.h Sun Apr 28 18:30:19 2019 (r346848) @@ -1118,6 +1118,7 @@ int vi_full_init(struct vi_info *); int vi_full_uninit(struct vi_info *); void vi_sysctls(struct vi_info *); void vi_tick(void *); +int rw_via_memwin(struct adapter *, int, uint32_t, uint32_t *, int, int); #ifdef DEV_NETMAP /* t4_netmap.c */ @@ -1210,4 +1211,19 @@ t4_wrq_tx(struct adapter *sc, struct wrqe *wr) TXQ_UNLOCK(wrq); } +static inline int +read_via_memwin(struct adapter *sc, int idx, uint32_t addr, uint32_t *val, + int len) +{ + + return (rw_via_memwin(sc, idx, addr, val, len, 0)); +} + +static inline int +write_via_memwin(struct adapter *sc, int idx, uint32_t addr, + const uint32_t *val, int len) +{ + + return (rw_via_memwin(sc, idx, addr, (void *)(uintptr_t)val, len, 1)); +} #endif Modified: stable/11/sys/dev/cxgbe/common/common.h ============================================================================== --- stable/11/sys/dev/cxgbe/common/common.h Sun Apr 28 17:27:06 2019 (r346847) +++ stable/11/sys/dev/cxgbe/common/common.h Sun Apr 28 18:30:19 2019 (r346848) @@ -520,6 +520,12 @@ static inline u_int us_to_tcp_ticks(const struct adapt return (us * adap->params.vpd.cclk / 1000 >> adap->params.tp.tre); } +static inline u_int tcp_ticks_to_us(const struct adapter *adap, u_int ticks) +{ + return ((uint64_t)ticks << adap->params.tp.tre) / + core_ticks_per_usec(adap); +} + 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: stable/11/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/11/sys/dev/cxgbe/t4_main.c Sun Apr 28 17:27:06 2019 (r346847) +++ stable/11/sys/dev/cxgbe/t4_main.c Sun Apr 28 18:30:19 2019 (r346848) @@ -592,11 +592,6 @@ struct filter_entry { static void setup_memwin(struct adapter *); static void position_memwin(struct adapter *, int, uint32_t); -static int rw_via_memwin(struct adapter *, int, uint32_t, uint32_t *, int, int); -static inline int read_via_memwin(struct adapter *, int, uint32_t, uint32_t *, - int); -static inline int write_via_memwin(struct adapter *, int, uint32_t, - const uint32_t *, int); static int validate_mem_range(struct adapter *, uint32_t, uint32_t); static int fwmtype_to_hwmtype(int); static int validate_mt_off_len(struct adapter *, int, uint32_t, uint32_t, @@ -2712,7 +2707,7 @@ position_memwin(struct adapter *sc, int idx, uint32_t t4_read_reg(sc, reg); /* flush */ } -static int +int rw_via_memwin(struct adapter *sc, int idx, uint32_t addr, uint32_t *val, int len, int rw) { @@ -2758,22 +2753,6 @@ rw_via_memwin(struct adapter *sc, int idx, uint32_t ad } return (0); -} - -static inline int -read_via_memwin(struct adapter *sc, int idx, uint32_t addr, uint32_t *val, - int len) -{ - - return (rw_via_memwin(sc, idx, addr, val, len, 0)); -} - -static inline int -write_via_memwin(struct adapter *sc, int idx, uint32_t addr, - const uint32_t *val, int len) -{ - - return (rw_via_memwin(sc, idx, addr, (void *)(uintptr_t)val, len, 1)); } static int Modified: stable/11/sys/dev/cxgbe/tom/t4_tom.c ============================================================================== --- stable/11/sys/dev/cxgbe/tom/t4_tom.c Sun Apr 28 17:27:06 2019 (r346847) +++ stable/11/sys/dev/cxgbe/tom/t4_tom.c Sun Apr 28 18:30:19 2019 (r346848) @@ -396,7 +396,85 @@ t4_ctloutput(struct toedev *tod, struct tcpcb *tp, int } } +static inline int +get_tcb_bit(u_char *tcb, int bit) +{ + int ix, shift; + + ix = 127 - (bit >> 3); + shift = bit & 0x7; + + return ((tcb[ix] >> shift) & 1); +} + +static inline uint64_t +get_tcb_bits(u_char *tcb, int hi, int lo) +{ + uint64_t rc = 0; + + while (hi >= lo) { + rc = (rc << 1) | get_tcb_bit(tcb, hi); + --hi; + } + + return (rc); +} + /* + * Called by the kernel to allow the TOE driver to "refine" values filled up in + * the tcp_info for an offloaded connection. + */ +static void +t4_tcp_info(struct toedev *tod, struct tcpcb *tp, struct tcp_info *ti) +{ + int i, j, k, rc; + struct adapter *sc = tod->tod_softc; + struct toepcb *toep = tp->t_toe; + uint32_t addr, v; + uint32_t buf[TCB_SIZE / sizeof(uint32_t)]; + u_char *tcb, tmp; + + INP_WLOCK_ASSERT(tp->t_inpcb); + MPASS(ti != NULL); + + addr = t4_read_reg(sc, A_TP_CMM_TCB_BASE) + toep->tid * TCB_SIZE; + rc = read_via_memwin(sc, 2, addr, &buf[0], TCB_SIZE); + if (rc != 0) + return; + + tcb = (u_char *)&buf[0]; + for (i = 0, j = TCB_SIZE - 16; i < j; i += 16, j -= 16) { + for (k = 0; k < 16; k++) { + tmp = tcb[i + k]; + tcb[i + k] = tcb[j + k]; + tcb[j + k] = tmp; + } + } + + ti->tcpi_state = get_tcb_bits(tcb, 115, 112); + + v = get_tcb_bits(tcb, 271, 256); + ti->tcpi_rtt = tcp_ticks_to_us(sc, v); + + v = get_tcb_bits(tcb, 287, 272); + ti->tcpi_rttvar = tcp_ticks_to_us(sc, v); + + ti->tcpi_snd_ssthresh = get_tcb_bits(tcb, 487, 460); + ti->tcpi_snd_cwnd = get_tcb_bits(tcb, 459, 432); + ti->tcpi_rcv_nxt = get_tcb_bits(tcb, 553, 522); + + ti->tcpi_snd_nxt = get_tcb_bits(tcb, 319, 288) - + get_tcb_bits(tcb, 375, 348); + + /* Receive window being advertised by us. */ + ti->tcpi_rcv_space = get_tcb_bits(tcb, 581, 554); + + /* Send window ceiling. */ + v = get_tcb_bits(tcb, 159, 144) << get_tcb_bits(tcb, 131, 128); + ti->tcpi_snd_wnd = min(v, ti->tcpi_snd_cwnd); +} + +/* * The TOE driver will not receive any more CPLs for the tid associated with the * toepcb; release the hold on the inpcb. */ @@ -1292,6 +1370,11 @@ t4_tom_activate(struct adapter *sc) tod->tod_syncache_respond = t4_syncache_respond; tod->tod_offload_socket = t4_offload_socket; tod->tod_ctloutput = t4_ctloutput; +#if 0 + tod->tod_tcp_info = t4_tcp_info; +#else + (void)&t4_tcp_info; +#endif for_each_port(sc, i) { for_each_vi(sc->port[i], v, vi) {