From nobody Mon Feb 19 04:50:06 2024 X-Original-To: dev-commits-src-all@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 4TdVTB3NPSz59394; Mon, 19 Feb 2024 04:50:06 +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 4TdVTB2Ggkz51bH; Mon, 19 Feb 2024 04:50:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708318206; 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=ZGu8vupY8cSUrT6/S6ZfuRJwMhf2C0+Xr9ZXSe4adpY=; b=qe3A2Tk9rnwNoUpG2MQS4W64b7TyRuYx4mhjEtzndonAQ77kwLRdkNFoxqVkEg1DC6Hb12 UwJc34c81HiUQwKqXAbf1Ic1rI6gNcRFSn0nDHfoLvYimmJ14/kAvH/OX2FIK+NB2mTpBI F+vksgXRBc10FpsGsdviReUxkVoKqPWgju1zYwtX3WgEFNEhghI06a3d2NtXwLUH585F5O 2THkxiNkn8aQVx3wVtTeFZxGxG2BJ7m81M4yFN45XL1+u1f1LAJzlPjOVbaFe8xZ9Lgz8p aeb7cZ+XozsWtr3W+8/n2ofS7HE48IrcbMSTmjUdxoru6x4ggmrvSodMgJ6y4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708318206; 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=ZGu8vupY8cSUrT6/S6ZfuRJwMhf2C0+Xr9ZXSe4adpY=; b=kqiyV9UMrVHZiXKyp28VUEZEWiLVdGGJnivIHvRyVxScFNHNcFRcr/2Ao++yQfqR0LIrwp l1PrLVlb6+HZ06Qqi+khKo9jenua+qex+VxcNHbCFiuUEdFAPWvMyCbQG3ehnhIDpE3MPs cRfT0NYaA/X5o1h/+btyczW32pIi7OZKDfe4b8Vxm0OHT+IJXSu6Flm0prvB5GMJJexqaw /gaOJeNZbbZmPytkIu8+v+X9DxOS9/5aroMlRISZ6k+q/06YVNk2HkxgLANTuWlkB8soMb cZzYoLWNzmu/rvDkO38rkdVpJuxPgNSU1Zqvbke4z/WHHIJUmE9PgwvBR+QynQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708318206; a=rsa-sha256; cv=none; b=BaX3L7NwYOMkOoYCjKx9H1+cyUOrIneFVUm5otOlWspjhSlO0QU2bXGTa45sI/4Hg+BcM9 B/tcW0XTKqATz520dnRKKDj311P9s9cp7lH69Uxz/vfnc7KefFt1ibV4Z+Y+vwLqhbeoyK W4Ro/A9YB3S5GFkvdyZcxRtBnAsI7prvVT/m/4AgXGBJA1X7U98Nf28LHhF+ystWhszUx7 wsHTpKT+kStTHr7TYXeqz4cN+UueiMQQ0/6/btSNSKi+SO6v7uh765jbIey344hJ5nembJ WA5Re/dmgh0mnn1AHKAxjvBuqZyWKbJBoBGGcyWZNbDcTjmfFoyCvUZ9D1lwPA== 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 4TdVTB1MF7zLNk; Mon, 19 Feb 2024 04:50:06 +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 41J4o6og080288; Mon, 19 Feb 2024 04:50:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41J4o6jD080283; Mon, 19 Feb 2024 04:50:06 GMT (envelope-from git) Date: Mon, 19 Feb 2024 04:50:06 GMT Message-Id: <202402190450.41J4o6jD080283@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 9ae56ea964c8 - stable/13 - vtnet: Avoid ifdefs based on __NO_STRICT_ALIGNMENT List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 9ae56ea964c89284a998a501e6cf1b57d000d968 Auto-Submitted: auto-generated The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9ae56ea964c89284a998a501e6cf1b57d000d968 commit 9ae56ea964c89284a998a501e6cf1b57d000d968 Author: Warner Losh AuthorDate: 2024-02-05 05:43:49 +0000 Commit: Warner Losh CommitDate: 2024-02-19 04:46:43 +0000 vtnet: Avoid ifdefs based on __NO_STRICT_ALIGNMENT Some platforms require an adjustment of the ethernet hearders. Rather than make this be on __NO_STRICT_ALIGNMENT being defined, define VTNET_ETHER_ALIGN to be either 0 or ETHER_ALIGN (aka 2). Add a test to the if statements to only do them when != 0. This eliminates the #ifdef sprinkled in the code, still communicates the intent and gives the same compiled results. Sponsored by: Netflix Reviewed by: bz, bryanv Differential Revision: https://reviews.freebsd.org/D43654 (cherry picked from commit 0ea4b4084845bfeedc8c692e4d34252023b78cb3) --- sys/dev/virtio/network/if_vtnet.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index ae35d658e1bb..bd3816457cc2 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -89,6 +89,12 @@ #include #endif +#ifdef __NO_STRICT_ALIGNMENT +#define VTNET_ETHER_ALIGN 0 +#else /* Strict alignment */ +#define VTNET_ETHER_ALIGN ETHER_ALIGN +#endif + static int vtnet_modevent(module_t, int, void *); static int vtnet_probe(device_t); @@ -1237,15 +1243,13 @@ vtnet_rx_cluster_size(struct vtnet_softc *sc, int mtu) } else framesz = sizeof(struct vtnet_rx_header); framesz += sizeof(struct ether_vlan_header) + mtu; -#ifndef __NO_STRICT_ALIGNMENT /* * Account for the offsetting we'll do elsewhere so we allocate the * right size for the mtu. */ - if (sc->vtnet_hdr_size % 4 == 0) { - framesz += ETHER_ALIGN; + if (VTNET_ETHER_ALIGN != 0 && sc->vtnet_hdr_size % 4 == 0) { + framesz += VTNET_ETHER_ALIGN; } -#endif if (framesz <= MCLBYTES) return (MCLBYTES); @@ -1554,15 +1558,13 @@ vtnet_rx_alloc_buf(struct vtnet_softc *sc, int nbufs, struct mbuf **m_tailp) } m->m_len = size; -#ifndef __NO_STRICT_ALIGNMENT /* * Need to offset the mbuf if the header we're going to add * will misalign. */ - if (sc->vtnet_hdr_size % 4 == 0) { - m_adj(m, ETHER_ALIGN); + if (VTNET_ETHER_ALIGN != 0 && sc->vtnet_hdr_size % 4 == 0) { + m_adj(m, VTNET_ETHER_ALIGN); } -#endif if (m_head != NULL) { m_tail->m_next = m; m_tail = m; @@ -1589,14 +1591,12 @@ vtnet_rxq_replace_lro_nomrg_buf(struct vtnet_rxq *rxq, struct mbuf *m0, sc = rxq->vtnrx_sc; clustersz = sc->vtnet_rx_clustersz; -#ifndef __NO_STRICT_ALIGNMENT /* * Need to offset the mbuf if the header we're going to add will * misalign, account for that here. */ - if (sc->vtnet_hdr_size % 4 == 0) - clustersz -= ETHER_ALIGN; -#endif + if (VTNET_ETHER_ALIGN != 0 && sc->vtnet_hdr_size % 4 == 0) + clustersz -= VTNET_ETHER_ALIGN; m_prev = NULL; m_tail = NULL;