cxgbe(4): Replace T4_PKT_TIMESTAMP with something slightly less hackish.

This commit is contained in:
Navdeep Parhar 2018-08-18 04:23:51 +00:00
parent 7920ad944b
commit e7e0844422
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=337996
4 changed files with 41 additions and 21 deletions

View File

@ -349,7 +349,7 @@ enum {
/* iq flags */
IQ_ALLOCATED = (1 << 0), /* firmware resources allocated */
IQ_HAS_FL = (1 << 1), /* iq associated with a freelist */
/* 1 << 2 Used to be IQ_INTR */
IQ_RX_TIMESTAMP = (1 << 2), /* provide the SGE rx timestamp */
IQ_LRO_ENABLED = (1 << 3), /* iq is an eth rxq with LRO enabled */
IQ_ADJ_CREDIT = (1 << 4), /* hw is off by 1 credit for this iq */

View File

@ -1464,7 +1464,8 @@ cxgbe_probe(device_t dev)
#define T4_CAP (IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | \
IFCAP_VLAN_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU | IFCAP_LRO | \
IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6 | IFCAP_HWSTATS)
IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWCSUM_IPV6 | IFCAP_HWSTATS | \
IFCAP_HWRXTSTMP)
#define T4_CAP_ENABLE (T4_CAP)
static int
@ -1813,6 +1814,18 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data)
if (mask & IFCAP_TXRTLMT)
ifp->if_capenable ^= IFCAP_TXRTLMT;
#endif
if (mask & IFCAP_HWRXTSTMP) {
int i;
struct sge_rxq *rxq;
ifp->if_capenable ^= IFCAP_HWRXTSTMP;
for_each_rxq(vi, i, rxq) {
if (ifp->if_capenable & IFCAP_HWRXTSTMP)
rxq->iq.flags |= IQ_RX_TIMESTAMP;
else
rxq->iq.flags &= ~IQ_RX_TIMESTAMP;
}
}
#ifdef VLAN_CAPABILITIES
VLAN_CAPABILITIES(ifp);

View File

@ -1564,6 +1564,17 @@ sort_before_lro(struct lro_ctrl *lro)
return (lro->lro_mbuf_max != 0);
}
static inline uint64_t
last_flit_to_ns(struct adapter *sc, uint64_t lf)
{
uint64_t n = be64toh(lf) & 0xfffffffffffffff; /* 60b, not 64b. */
if (n > UINT64_MAX / 1000000)
return (n / sc->params.vpd.cclk * 1000000);
else
return (n * 1000000 / sc->params.vpd.cclk);
}
/*
* Deals with interrupts on an iq+fl queue.
*/
@ -1624,19 +1635,21 @@ service_iq_fl(struct sge_iq *iq, int budget)
if (__predict_false(m0 == NULL))
goto out;
refill = IDXDIFF(fl->hw_cidx, fl_hw_cidx, fl->sidx) > 2;
#ifdef T4_PKT_TIMESTAMP
/*
* 60 bit timestamp for the payload is
* *(uint64_t *)m0->m_pktdat. Note that it is
* in the leading free-space in the mbuf. The
* kernel can clobber it during a pullup,
* m_copymdata, etc. You need to make sure that
* the mbuf reaches you unmolested if you care
* about the timestamp.
*/
*(uint64_t *)m0->m_pktdat =
be64toh(ctrl->u.last_flit) & 0xfffffffffffffff;
if (iq->flags & IQ_RX_TIMESTAMP) {
/*
* Fill up rcv_tstmp but do not set M_TSTMP.
* rcv_tstmp is not in the format that the
* kernel expects and we don't want to mislead
* it. For now this is only for custom code
* that knows how to interpret cxgbe's stamp.
*/
m0->m_pkthdr.rcv_tstmp =
last_flit_to_ns(sc, d->rsp.u.last_flit);
#ifdef notyet
m0->m_flags |= M_TSTMP;
#endif
}
/* fall through */
@ -1814,10 +1827,7 @@ get_scatter_segment(struct adapter *sc, struct sge_fl *fl, int fr_offset,
if (m == NULL)
return (NULL);
fl->mbuf_allocated++;
#ifdef T4_PKT_TIMESTAMP
/* Leave room for a timestamp */
m->m_data += 8;
#endif
/* copy data to mbuf */
bcopy(payload, mtod(m, caddr_t), len);

View File

@ -34,9 +34,6 @@ SRCS+= cudbg_wtp.c
SRCS+= fastlz_api.c
SRCS+= fastlz.c
# Provide the timestamp of a packet in its header mbuf.
#CFLAGS+= -DT4_PKT_TIMESTAMP
CFLAGS+= -I${CXGBE}
.include <bsd.kmod.mk>