Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Apr 2021 10:46:31 GMT
From:      Marcin Wojtas <mw@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: cd945dc08a86 - main - iflib: Take iri_pad into account when processing small frames
Message-ID:  <202104301046.13UAkVt0046077@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mw:

URL: https://cgit.FreeBSD.org/src/commit/?id=cd945dc08a86a0cfd1637335de04e4c4c5bf70d9

commit cd945dc08a86a0cfd1637335de04e4c4c5bf70d9
Author:     Marcin Wojtas <mw@FreeBSD.org>
AuthorDate: 2021-04-27 09:00:15 +0000
Commit:     Marcin Wojtas <mw@FreeBSD.org>
CommitDate: 2021-04-30 10:46:17 +0000

    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
---
 sys/net/iflib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104301046.13UAkVt0046077>