From nobody Mon Feb 19 04:48:51 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 4TdVRl6mkFz592r6; Mon, 19 Feb 2024 04:48:51 +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 4TdVRl47w4z50gP; Mon, 19 Feb 2024 04:48:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708318131; 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=rSt1qKTK682TzGjU9TUSpXfVefa0xT+ccWipXVdMqQM=; b=kvmnbq4u5GZsWNoRHog/HV53BcFbxxoeecMfbybr2PzyAT+fsUi3y9aLGfg7USBsmJyjSd 53xAJt7zBUAcEwo30FOlvt6YTSUV2sPAAqmSD2qGEdyUmvirfLGq0rtb6uiH4+r+o+dD/D IUpWStK0F6dqllUd+MTEjKXkxxh+0hKLSmEmbfr8IwFzYbGzo5e5ScXn7mtbVpacDWtYsU ynTiBQzWJwbNJE6AyOtuA2YL7aAMF0P3nk8BA48vx4dwpLRmisxRy8Hco8GF6pzxLfi2CK yp0gv38PmbUgmPgVfBwNg7wJo3kWOpVn6YdTatnv/XdsG1FWOL2axopHX7yXnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708318131; 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=rSt1qKTK682TzGjU9TUSpXfVefa0xT+ccWipXVdMqQM=; b=uTO6U/ppvJ1o7OX5EYm3IexpiakESe6LFuyyNYB5brzr3+OIlrlQeSFo1kpMRyxFvr/pIV mffLMigg4W6dH6C9Djiqulrk1WJOf0Xz4kQgxiOXDn3TxJDgEEURHv2JQxd+DISiAeab9i LTgRuDIahr0wFZWoD4xwBwY5DR+5ynI4wo9674MDyXnlmWDAhCNC6PC/AtiXnDgCFiiz0L tnlP6TzaQtwaR8Kpae8xBGVAkrWPUyENzF7WF6l+B92hi8RZEPiyhTYsv1iw5s+3ePWqdB t88p2on76BUJ60BNoo+YMUL9wN1I1YjSmRzzqJcm4rozmqYpiTLVfk6l6yqjmA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708318131; a=rsa-sha256; cv=none; b=SiHUoggN1OPx+YO5/iDCSoKjpYtpyprHbBzioFIbNggbr3G8vhWVW+xnKsraUYP9bkdBNo alFG95BeRrjpEJ+0QxvZV6SFe2aMftH+3pL8TNqm9PO+BqCUg1bZ3rfZmUXp9R0MypO31P I7fTL2gjxzu9sFLFsNeIhw/bgZrq8i12mPav4pcusexNzAkaUFyI/pO4Eo2yKJtqmNrzil oxhEe3HxaD7A6wUjrosEnSk3ca1Gpk2EaBc9PBB7TxucqAoGTW1wGTpMyRGCf9UOhDpvsd 8M5u/lRsZEBV1VlnQ4s0mg27UMewkLchyKMqfR1x4oJ1L2c4O8ECMA8p5JFepQ== 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 4TdVRl3DKFzKnK; Mon, 19 Feb 2024 04:48:51 +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 41J4mpEi076962; Mon, 19 Feb 2024 04:48:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41J4mpXg076959; Mon, 19 Feb 2024 04:48:51 GMT (envelope-from git) Date: Mon, 19 Feb 2024 04:48:51 GMT Message-Id: <202402190448.41J4mpXg076959@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: a9600913b4db - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: a9600913b4dbf66fb257ea90702ea4705fb40362 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=a9600913b4dbf66fb257ea90702ea4705fb40362 commit a9600913b4dbf66fb257ea90702ea4705fb40362 Author: Warner Losh AuthorDate: 2024-02-05 05:43:49 +0000 Commit: Warner Losh CommitDate: 2024-02-19 04:47:16 +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 6694c655f3af..7d6411876b3d 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -90,6 +90,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); @@ -1232,15 +1238,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); @@ -1552,15 +1556,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; @@ -1587,14 +1589,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;