From nobody Mon Mar 13 15:53:29 2023 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 4Pb1Qx54GMz3xsHl; Mon, 13 Mar 2023 15:53:29 +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 4Pb1Qx49wRz48PF; Mon, 13 Mar 2023 15:53:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678722809; 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=s0+a8nYhgx4ixQDny+f72+d9BQDTeAuPIf2JqhDAXIQ=; b=xeIioZrPVL/I8CwKqLuObWmBz/0XZ5UkSDQMjUa6NKzf7kr5ii99MyGqqIsIZIUb0pWElL i/85h9yrWxp1+HWv5Y1Wa6qDKq2gBizv+sh9g2SIuD9HRMVVjXIeSn2n2nqGeLgp3afvwH MXSZ1OW8zDxLiwFS6Is4u4pAUkFs4bL4ugHMCpbdts4klKpbdL07KSkUNDGLgmPJm5WuMm xVXxxhPR6smA8LkmAUVTXcRUxvXpg2PBFHRksqh1YX6Aedb/nPuu8YpBZ+71HkcduTDTqz 2bsPp6I54AORLQl2IDZVblSaIaViSTrgHQCJIOMb2aDBAn9FmvkcDGR9COHz8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678722809; 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=s0+a8nYhgx4ixQDny+f72+d9BQDTeAuPIf2JqhDAXIQ=; b=dUyb47yvFqsfGzRw/hSXX1lqZ41HPWsrjzxnkrSpV40CM2K2815S/9muRWRYAwLrx49clS KA874amwJDu4SBxMm8m+r4jTOst318AoyBdXD8XFE5UrtP8J8FJacCJPVplpoCEcplpKBU yWV9qS2gGROff4ddHxo9WJNExOqv+gjaNKSpvVjfcEGzHTPOC76tTTwo4a4p85hBSOKEeT WHEZOUw9TIa+LKZoGrNKX6y759cFHs2SPkYxoiBNd9xmw8MC9fMSj32esJGEyNh5Xy3w7h PBSABQYyH/KoTVLHFt5FMkN30EFolnUKMSmGyR3cdsnzxfj5NSuvDVNNiParbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678722809; a=rsa-sha256; cv=none; b=fg72C36qH26h/Y1td0BDSVtzOcyoNSW/k1ZkGEKbLQ//BGuCTLT/TrMXlzCUNnLRoG1jof ovrr9RuZICIuzkdnuFWRotpbf3vYARa3nla6GvdZDJh931JCSwi+i67SE54ret3fQ60TE5 Ikz3xKUbl0lyMio/dTksmbV2v9Om8KIZkKuanOG8Tw3og1zCOL4pQ8o68uqpoCcrTv7L74 diDKwGZMeK3Y4xrAM0yFEDutaEEvP3kwip4JAdZ+Yl7924+59uezYvfvzOWHosX77EDwp2 mohkzKkDjNrtpry0OPz/EbR34ozwKcCBz5+9J1NZjR8bvOgV1rUGQNTbI4U3BA== 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 4Pb1Qx3DQQz105X; Mon, 13 Mar 2023 15:53:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32DFrTei039887; Mon, 13 Mar 2023 15:53:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32DFrTJP039886; Mon, 13 Mar 2023 15:53:29 GMT (envelope-from git) Date: Mon, 13 Mar 2023 15:53:29 GMT Message-Id: <202303131553.32DFrTJP039886@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: c3bd32f225ec - stable/13 - epair: Avoid loading m_flags into a short 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c3bd32f225ec093ba0f7cd7fc1a000b02aad5211 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c3bd32f225ec093ba0f7cd7fc1a000b02aad5211 commit c3bd32f225ec093ba0f7cd7fc1a000b02aad5211 Author: Mark Johnston AuthorDate: 2023-03-06 14:39:17 +0000 Commit: Mark Johnston CommitDate: 2023-03-13 15:53:16 +0000 epair: Avoid loading m_flags into a short The m_flags field of struct mbuf is 24 bits wide and so gets truncated in a couple of places in the epair code. Instead of preserving the entire flag set, just remember whether M_BCAST or M_MCAST is set. MFC after: 1 week Sponsored by: Klara, Inc. (cherry picked from commit 48227d1c6db8fceaceebbf8578612302d64ca170) --- sys/net/if_epair.c | 95 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index e7257f5fa551..05667633fa42 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -188,39 +188,14 @@ epair_tx_start_deferred(void *arg, int pending) if_rele(sc->ifp); } -static int -epair_menq(struct mbuf *m, struct epair_softc *osc) +static struct epair_queue * +epair_select_queue(struct epair_softc *sc, struct mbuf *m) { - struct ifnet *ifp, *oifp; - int len, ret; - int ridx; - short mflags; - struct epair_queue *q = NULL; uint32_t bucket; #ifdef RSS struct ether_header *eh; -#endif - - /* - * I know this looks weird. We pass the "other sc" as we need that one - * and can get both ifps from it as well. - */ - oifp = osc->ifp; - ifp = osc->oifp; - - M_ASSERTPKTHDR(m); - epair_clear_mbuf(m); - if_setrcvif(m, oifp); - M_SETFIB(m, oifp->if_fib); - - /* Save values as once the mbuf is queued, it's not ours anymore. */ - len = m->m_pkthdr.len; - mflags = m->m_flags; - - MPASS(m->m_nextpkt == NULL); - MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0); + int ret; -#ifdef RSS ret = rss_m2bucket(m, &bucket); if (ret) { /* Actually hash the packet. */ @@ -246,7 +221,43 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) #else bucket = 0; #endif - q = &osc->queues[bucket]; + return (&sc->queues[bucket]); +} + +static void +epair_prepare_mbuf(struct mbuf *m, struct ifnet *src_ifp) +{ + M_ASSERTPKTHDR(m); + epair_clear_mbuf(m); + if_setrcvif(m, src_ifp); + M_SETFIB(m, src_ifp->if_fib); + + MPASS(m->m_nextpkt == NULL); + MPASS((m->m_pkthdr.csum_flags & CSUM_SND_TAG) == 0); +} + +static void +epair_menq(struct mbuf *m, struct epair_softc *osc) +{ + struct ifnet *ifp, *oifp; + int len, ret; + int ridx; + bool mcast; + + /* + * I know this looks weird. We pass the "other sc" as we need that one + * and can get both ifps from it as well. + */ + oifp = osc->ifp; + ifp = osc->oifp; + + epair_prepare_mbuf(m, oifp); + + /* Save values as once the mbuf is queued, it's not ours anymore. */ + len = m->m_pkthdr.len; + mcast = (m->m_flags & (M_BCAST | M_MCAST)) != 0; + + struct epair_queue *q = epair_select_queue(osc, m); atomic_set_long(&q->state, (1 << BIT_MBUF_QUEUED)); ridx = atomic_load_int(&q->ridx); @@ -255,7 +266,7 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) /* Ring is full. */ if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); m_freem(m); - return (0); + return; } if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); @@ -265,15 +276,13 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) * the logic another time. */ if_inc_counter(ifp, IFCOUNTER_OBYTES, len); - if (mflags & (M_BCAST|M_MCAST)) + if (mcast) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); /* Someone else received the packet. */ if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); if (!atomic_testandset_long(&q->state, BIT_QUEUE_TASK)) - taskqueue_enqueue(epair_tasks.tq[bucket], &q->tx_task); - - return (0); + taskqueue_enqueue(epair_tasks.tq[q->id], &q->tx_task); } static void @@ -317,8 +326,10 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) { struct epair_softc *sc; struct ifnet *oifp; - int error, len; - short mflags; +#ifdef ALTQ + int len; + bool mcast; +#endif if (m == NULL) return (0); @@ -355,10 +366,12 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) m_freem(m); return (0); } - len = m->m_pkthdr.len; - mflags = m->m_flags; #ifdef ALTQ + len = m->m_pkthdr.len; + mcast = (m->m_flags & (M_BCAST | M_MCAST)) != 0; + int error = 0; + /* Support ALTQ via the classic if_start() path. */ IF_LOCK(&ifp->if_snd); if (ALTQ_IS_ENABLED(&ifp->if_snd)) { @@ -368,7 +381,7 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) IF_UNLOCK(&ifp->if_snd); if (!error) { if_inc_counter(ifp, IFCOUNTER_OBYTES, len); - if (mflags & (M_BCAST|M_MCAST)) + if (mcast) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); epair_start(ifp); } @@ -377,8 +390,8 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) IF_UNLOCK(&ifp->if_snd); #endif - error = epair_menq(m, oifp->if_softc); - return (error); + epair_menq(m, oifp->if_softc); + return (0); } static int