aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Wojtas <mw@FreeBSD.org>2021-04-27 09:00:15 +0000
committerMarcin Wojtas <mw@FreeBSD.org>2021-04-30 10:46:17 +0000
commitcd945dc08a86a0cfd1637335de04e4c4c5bf70d9 (patch)
tree548509b904bd188bb649f31d7bc30d7d9013182c
parenteb79855920ffa33d6c096221eac9cc9a6d7a484b (diff)
downloadsrc-cd945dc08a86a0cfd1637335de04e4c4c5bf70d9.tar.gz
src-cd945dc08a86a0cfd1637335de04e4c4c5bf70d9.zip
iflib: Take iri_pad into account when processing small frames
Drivers can specify padding of received frames with iri_pad field. This can be used to enforce ip alignment by hardware. Iflib ignored that padding when processing small frames, which rendered this feature inoperable. I found it while writing a driver for a NIC that can ip align received packets. Note that this doesn't change behavior of existing drivers as they all set iri_pad to 0. Submitted by: Kornel Duleba <mindal@semihalf.com> Reviewed by: gallatin Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30009
-rw-r--r--sys/net/iflib.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index faf58917c96b..01da882f0d12 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -2827,11 +2827,13 @@ iflib_rxd_pkt_get(iflib_rxq_t rxq, if_rxd_info_t ri)
if (pf_rv == PFIL_PASS) {
m_init(m, M_NOWAIT, MT_DATA, M_PKTHDR);
#ifndef __NO_STRICT_ALIGNMENT
- if (!IP_ALIGNED(m))
+ if (!IP_ALIGNED(m) && ri->iri_pad == 0)
m->m_data += 2;
#endif
memcpy(m->m_data, *sd.ifsd_cl, ri->iri_len);
m->m_len = ri->iri_frags[0].irf_len;
+ m->m_data += ri->iri_pad;
+ ri->iri_len -= ri->iri_pad;
}
} else {
m = assemble_segments(rxq, ri, &sd, &pf_rv);