From nobody Thu Dec 28 06:25:57 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T0z6F4P4Lz557gq; Thu, 28 Dec 2023 06:25:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T0z6F3W6Cz4ZRk; Thu, 28 Dec 2023 06:25:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703744757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=u60h7ff9F6GlPoUds07zJFSVgUQTEgx8WfnDND24YBg=; b=bMFznHdYoHBJrqU8Dk8nmISKg03b1La6Co4df8nKi7GNGW8UvgNN95ThkrtvQYJPLO7HCu OQMHsjU+UmrWWylZAFx7V9JfHgXp2+uJC0Cyu1GGUNDBx5+FwOOHy+KMnusH5FBBkgdSFH tbdE3z3y6qaI/1f/f0CE76Kw+mgI55SpUQz0rCCHhfdF2izTZyhZYUNa1EQj6ZGUrLmmq5 kilkA0zD+T/U9RQIDS89d6dUpvIZL6V7+RYmRIw6YCmBSsqh5jxYZteWmvq8IqNKr1M8dp n7/jn+VEDWeQWaubwdPP5mPKJ8fyTx1Wc4zJsho00V63J8GDKCMzsdRg5v3bTg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703744757; a=rsa-sha256; cv=none; b=JhVm13GFuD+RtH75f67mQSd6ec10IU8e8zoPfL+GUnUTMYw739IktEOLdO88TFh4EPgEpb kT3v9UN6yx90L+aTqAnvXpePLKhR8xOtEB77IWXQ7Djon1fBWKifKC0zGuGLPiC4wlMvk4 v9vMYKAO8pnChQsHbqfA5ONz/6X/27HyM9af9FWWxCDJbqhIXEojDqgjC3SdRredGPi7/M YlhdaIbGcdgj9yhhb2DRdxPvQYNN73w27/gf7K/p1hZdo34KKVExtaB49M3CoajPQBZtwO Z1W4nc9WBu8H2kdPceDY1azphmSpyoMzM8C5SSXClGPNSIfm9nblLX6Opnw0ug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703744757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=u60h7ff9F6GlPoUds07zJFSVgUQTEgx8WfnDND24YBg=; b=kId7XuS/ISg+pweHxG/d9Duis9kNjyizITV9+zJ27iOfz30KbLIUSWXQSQzw2odntqX4hj BKn3AtSI5YU/01ymeuxAaP25gOhGfEjKWdy3s0++Ep4ob9tNgAhO93T7VB/jy5ZDXVhPRR blimCaDvV0qPLZ6VAqnw2LROkR4VnpmU1F55acMtMBGnwhGWJiPejxR0xUTJlwUqWCMxNM KgFSekejJgHtEmG9JK5SnwC9jabUNpZ6lAiuUi9iFWLxMPk/sZeIwBIcSXZZ4u3DymNbrC tZqMQajM3zhV2gow4fh2z+c1a1aMja9EYXoGHUiTFpLlyU4lRXncn+GTo/58Jg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T0z6F2b11z19MQ; Thu, 28 Dec 2023 06:25:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BS6Pvta080216; Thu, 28 Dec 2023 06:25:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BS6Pv38080213; Thu, 28 Dec 2023 06:25:57 GMT (envelope-from git) Date: Thu, 28 Dec 2023 06:25:57 GMT Message-Id: <202312280625.3BS6Pv38080213@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: e9da71cd35d4 - main - vtnet: Better adjust for ethernet alignment. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e9da71cd35d46ca13da4396d99e0af1703290e68 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e9da71cd35d46ca13da4396d99e0af1703290e68 commit e9da71cd35d46ca13da4396d99e0af1703290e68 Author: Warner Losh AuthorDate: 2023-12-21 20:36:12 +0000 Commit: Warner Losh CommitDate: 2023-12-28 06:25:53 +0000 vtnet: Better adjust for ethernet alignment. Move adjustment of the mbuf from where we allocate it to where we are about to queue it to the device. Do this only on those platforms that require it. This allows us to receive an entire jumbo frame on other platforms. It also doesn't make the adjustment on subsequent frames when we queue mulitple mbufs for LRO operations. For the normal use case on armv7, there's no difference because we only ever allocate one mbuf. However, for the LRO cases it increases what's available in LRO. It also ensure that we get enough mbufs in those cases as well (though I have no ability to test this on a LRO scenario with armv7). This has the side effect of reverting 527b62e37e68. Fixes: 527b62e37e68 Sponsored by: Netflix --- sys/dev/virtio/network/if_vtnet.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 360176e4f845..db7a1a18ebc2 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1532,8 +1532,8 @@ vtnet_rx_alloc_buf(struct vtnet_softc *sc, int nbufs, struct mbuf **m_tailp) m_freem(m_head); return (NULL); } + m->m_len = size; - m_adj(m, ETHER_ALIGN); if (m_head != NULL) { m_tail->m_next = m; m_tail = m; @@ -1587,6 +1587,15 @@ vtnet_rxq_replace_lro_nomrg_buf(struct vtnet_rxq *rxq, struct mbuf *m0, ("%s: mbuf size %d not expected cluster size %d", __func__, m->m_len, clustersz)); +#ifdef __NO_STRICT_ALIGNMENT + /* + * Need to offset the first mbuf in this chain to align the IP + * structure because this host requires strict alignment. + */ + if (m_prev == NULL) { + m_adj(m, ETHER_ALIGN); + } +#endif m->m_len = MIN(m->m_len, len); len -= m->m_len; @@ -1655,6 +1664,13 @@ vtnet_rxq_replace_buf(struct vtnet_rxq *rxq, struct mbuf *m, int len) if (m_new == NULL) return (ENOBUFS); +#ifdef __NO_STRICT_ALIGNMENT + /* + * Need to offset the first mbuf in this chain to align the IP + * structure because this host requires strict alignment. + */ + m_adj(m_new, ETHER_ALIGN); +#endif error = vtnet_rxq_enqueue_buf(rxq, m_new); if (error) { sc->vtnet_stats.rx_enq_replacement_failed++; @@ -1722,6 +1738,13 @@ vtnet_rxq_new_buf(struct vtnet_rxq *rxq) if (m == NULL) return (ENOBUFS); +#ifdef __NO_STRICT_ALIGNMENT + /* + * Need to offset the first mbuf in this chain to align the IP + * structure because this host requires strict alignment. + */ + m_adj(m, ETHER_ALIGN); +#endif error = vtnet_rxq_enqueue_buf(rxq, m); if (error) m_freem(m); @@ -1907,8 +1930,10 @@ vtnet_rxq_discard_buf(struct vtnet_rxq *rxq, struct mbuf *m) int error __diagused; /* - * Requeue the discarded mbuf. This should always be successful - * since it was just dequeued. + * Requeue the discarded mbuf. This should always be successful since it + * was just dequeued. There's no need to adjust for ethernet alignment + * here on strict alignment hosts because we're requeueing a packet + * already adjusted. */ error = vtnet_rxq_enqueue_buf(rxq, m); KASSERT(error == 0,