svn commit: r346848 - in stable/11/sys/dev/cxgbe: . common tom
Navdeep Parhar
np at FreeBSD.org
Sun Apr 28 18:30:21 UTC 2019
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) {
More information about the svn-src-all
mailing list