Add mbuf_tstmp2timeval()

Reviewed by:	hselasky, jkim, rscheff
Sponsored by:	NVIDIA networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36870
This commit is contained in:
Konstantin Belousov 2022-10-04 01:49:45 +03:00
parent 2c9dc2384f
commit 2220b66fe0
3 changed files with 16 additions and 7 deletions

View File

@ -2261,8 +2261,7 @@ bbr_log_ack_event(struct tcp_bbr *bbr, struct tcphdr *th, struct tcpopt *to, uin
log.u_bbr.lt_epoch = 0;
}
if (m->m_flags & M_TSTMP_LRO) {
tv.tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;
tv.tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000;
mbuf_tstmp2timeval(m, &tv);
log.u_bbr.flex5 = tcp_tv_to_usectick(&tv);
} else {
/* No arrival timestamp */
@ -11691,8 +11690,7 @@ bbr_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
}
}
if (m->m_flags & M_TSTMP_LRO) {
tv.tv_sec = m->m_pkthdr.rcv_tstmp /1000000000;
tv.tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000)/1000;
mbuf_tstmp2timeval(m, &tv);
} else {
/* Should not be should we kassert instead? */
tcp_get_usecs(&tv);

View File

@ -14631,8 +14631,7 @@ rack_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
}
}
if (m->m_flags & M_TSTMP_LRO) {
tv.tv_sec = m->m_pkthdr.rcv_tstmp /1000000000;
tv.tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000)/1000;
mbuf_tstmp2timeval(m, &tv);
} else {
/* Should not be should we kassert instead? */
tcp_get_usecs(&tv);

View File

@ -1675,12 +1675,24 @@ mbuf_tstmp2timespec(struct mbuf *m, struct timespec *ts)
{
KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m));
KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0, ("mbuf %p no M_TSTMP or M_TSTMP_LRO", m));
KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0,
("mbuf %p no M_TSTMP or M_TSTMP_LRO", m));
ts->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;
ts->tv_nsec = m->m_pkthdr.rcv_tstmp % 1000000000;
}
#endif
static inline void
mbuf_tstmp2timeval(struct mbuf *m, struct timeval *tv)
{
KASSERT((m->m_flags & M_PKTHDR) != 0, ("mbuf %p no M_PKTHDR", m));
KASSERT((m->m_flags & (M_TSTMP|M_TSTMP_LRO)) != 0,
("mbuf %p no M_TSTMP or M_TSTMP_LRO", m));
tv->tv_sec = m->m_pkthdr.rcv_tstmp / 1000000000;
tv->tv_usec = (m->m_pkthdr.rcv_tstmp % 1000000000) / 1000;
}
#ifdef DEBUGNET
/* Invoked from the debugnet client code. */
void debugnet_mbuf_drain(void);