From nobody Mon Dec 27 11:38:13 2021 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 0D9D21917D23; Mon, 27 Dec 2021 11:38:14 +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 4JMwdx5Z83z3hSL; Mon, 27 Dec 2021 11:38:13 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 9EC641CE67; Mon, 27 Dec 2021 11:38:13 +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 1BRBcDcd024195; Mon, 27 Dec 2021 11:38:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BRBcDtq024194; Mon, 27 Dec 2021 11:38:13 GMT (envelope-from git) Date: Mon, 27 Dec 2021 11:38:13 GMT Message-Id: <202112271138.1BRBcDtq024194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: 96097be6a8f7 - stable/13 - vmxnet3: skip zero-length descriptor in the middle of a packet 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: avg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 96097be6a8f7a2915644ae745a31310361d99185 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640605093; 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=Hh9DIJ46KWoefBHxKO+TrwL7G5a40RPtA6mW86rW4BU=; b=lHemgvNIvHJikCJRDLyGldeTvwCFtV72sJlYHa6tKOQFn9quyf/+TYNX0g/OaNlZ+n4qFp Ida4gQT+Ha1+TRRY/71rWpIw6rGWzL1yoyS7pZH7N8Om4yCOS2qSskDvmAh8m69NZkltgY 06yDDbFmShRDgcdox0NqVmeS6saXeGJ+Mt64ruyyzcSkGck/A2wv+xv51a0m0DfVzlYxxw H/ImuRlxRTASkZbdFdQuwnk9jzI7jRfYdfzYklBrKXhRdjFfGS9UiuCycb/s2O7+vdZzZs JhxFSFI1FTb4AG68JvHs7LoCrsvMDV3qjsxqyaZL2USElpTcOzrQHfDfmTn2nw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640605093; a=rsa-sha256; cv=none; b=WUke6jsr6Ld7zziBrzX7Pm5NvCzWC8TrptplDYCTqAHgsX4ck7yWcfv9/LVvpGNK/h+Gkb vbWWbE0kekZ5HWpIote5kJ6fycRgNaJjMmpcUYlZ4cf7uJ3TUO+TbzV0ajad5sP/ZUOQyl 6s2DNRtbOwsID/XQZKJyA7IFY2WfCX9oEhjQQBtsTsC3m4pM+RZOZRmY3Iksp4HhlZQlpe TAKd4BVBdg8hBDM8n9IzKXWvY5C+Mf3Q+JSYMJRa1ZHIYcKXTAp7QGAyfHRwDJjzPcNjf2 jJ8Po/y2Bh1U5NG6w1lkdkmHyijfrWi4u71DrHcFEYd/+jn4IvqCstvmW0vOXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=96097be6a8f7a2915644ae745a31310361d99185 commit 96097be6a8f7a2915644ae745a31310361d99185 Author: Andriy Gapon AuthorDate: 2021-12-06 07:59:28 +0000 Commit: Andriy Gapon CommitDate: 2021-12-27 11:37:12 +0000 vmxnet3: skip zero-length descriptor in the middle of a packet Passing up such descriptors to iflib is obviously wasteful. But the main conern is that we may overrun iri_frags array because of them. That's been observed in practice. Also, assert that the number of fragments / descriptors / segments is less than IFLIB_MAX_RX_SEGS. Sponsored by: Panzura LLC (cherry picked from commit 9c612a5d0af17021abc6e1bb2a8baa5a4c97d05f) --- sys/dev/vmware/vmxnet3/if_vmx.c | 29 +++++++++++++++++------------ sys/dev/vmware/vmxnet3/if_vmxvar.h | 1 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/sys/dev/vmware/vmxnet3/if_vmx.c b/sys/dev/vmware/vmxnet3/if_vmx.c index 340fe1a7dd80..85f831e44755 100644 --- a/sys/dev/vmware/vmxnet3/if_vmx.c +++ b/sys/dev/vmware/vmxnet3/if_vmx.c @@ -1503,8 +1503,6 @@ vmxnet3_isc_rxd_pkt_get(void *vsc, if_rxd_info_t ri) struct vmxnet3_rxqueue *rxq; struct vmxnet3_comp_ring *rxc; struct vmxnet3_rxcompdesc *rxcd; - struct vmxnet3_rxring *rxr; - struct vmxnet3_rxdesc *rxd; if_rxd_frag_t frag; int cqidx; uint16_t total_len; @@ -1604,16 +1602,19 @@ vmxnet3_isc_rxd_pkt_get(void *vsc, if_rxd_info_t ri) rxcd = &rxc->vxcr_u.rxcd[cqidx]; KASSERT(rxcd->gen == rxc->vxcr_gen, ("%s: generation mismatch", __func__)); - flid = (rxcd->qid >= scctx->isc_nrxqsets) ? 1 : 0; - rxr = &rxq->vxrxq_cmd_ring[flid]; - rxd = &rxr->vxrxr_rxd[rxcd->rxd_idx]; - - frag = &ri->iri_frags[nfrags]; - frag->irf_flid = flid; - frag->irf_idx = rxcd->rxd_idx; - frag->irf_len = rxcd->len; - total_len += rxcd->len; - nfrags++; + KASSERT(nfrags < IFLIB_MAX_RX_SEGS, + ("%s: too many fragments", __func__)); + if (__predict_true(rxcd->len != 0)) { + frag = &ri->iri_frags[nfrags]; + flid = (rxcd->qid >= scctx->isc_nrxqsets) ? 1 : 0; + frag->irf_flid = flid; + frag->irf_idx = rxcd->rxd_idx; + frag->irf_len = rxcd->len; + total_len += rxcd->len; + nfrags++; + } else { + rxc->vcxr_zero_length_frag++; + } if (++cqidx == rxc->vxcr_ndesc) { cqidx = 0; rxc->vxcr_gen ^= 1; @@ -1885,6 +1886,7 @@ vmxnet3_rxinit(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rxq) rxc->vxcr_next = 0; rxc->vxcr_gen = VMXNET3_INIT_GEN; rxc->vxcr_zero_length = 0; + rxc->vcxr_zero_length_frag = 0; rxc->vxcr_pkt_errors = 0; /* * iflib has zeroed out the descriptor array during the prior attach @@ -2365,6 +2367,9 @@ vmxnet3_setup_debug_sysctl(struct vmxnet3_softc *sc, &rxq->vxrxq_comp_ring.vxcr_gen, 0, ""); SYSCTL_ADD_U64(ctx, list, OID_AUTO, "comp_zero_length", CTLFLAG_RD, &rxq->vxrxq_comp_ring.vxcr_zero_length, 0, ""); + SYSCTL_ADD_U64(ctx, list, OID_AUTO, "comp_zero_length_frag", + CTLFLAG_RD, &rxq->vxrxq_comp_ring.vcxr_zero_length_frag, + 0, ""); SYSCTL_ADD_U64(ctx, list, OID_AUTO, "comp_pkt_errors", CTLFLAG_RD, &rxq->vxrxq_comp_ring.vxcr_pkt_errors, 0, ""); } diff --git a/sys/dev/vmware/vmxnet3/if_vmxvar.h b/sys/dev/vmware/vmxnet3/if_vmxvar.h index e39b552ab8cf..9811ae42534d 100644 --- a/sys/dev/vmware/vmxnet3/if_vmxvar.h +++ b/sys/dev/vmware/vmxnet3/if_vmxvar.h @@ -81,6 +81,7 @@ struct vmxnet3_comp_ring { int vxcr_gen; bus_addr_t vxcr_paddr; uint64_t vxcr_zero_length; + uint64_t vcxr_zero_length_frag; uint64_t vxcr_pkt_errors; };