From nobody Mon Apr 28 16:30:56 2025 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 4ZmTTX4Q0pz5vYYp; Mon, 28 Apr 2025 16:30:56 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZmTTX1tRLz3WXS; Mon, 28 Apr 2025 16:30:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745857856; 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=Vou0BzQaNmWRgK0Ws5z39D1Fe/IMcYpfnGpelECiaII=; b=ESGc9SP/x0no6zA1WtWp1AmPM4fbxdplkD4LCTBEQg7GVkbiKRQjYR3mfh1JxxYdDn6AKy YsO3ZPHe/RNTzQCpEp5An8s6R5Cdno2UUf5ZA/P6wx+7m9977lZmPxECyG+xs7CT/slQKV jh9ZoTPgUIuai80R7GJQ4cGb6vtow6jQvGuOYiFNhKiI4eXCGqZNLEHyvMxiC+Ez9QQccL 6pW+hW5SmTJ/L5T3Y58pdVvM/dbBZNEDAJzxkabxo035MSnRqO+M3J5HLN/3KI7XY4pVCB feoMlzSo/914xIF3J9n7Y60+63bi4y3Qdy82u2xjitBkMjuCBpIa7vORDu4tAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745857856; a=rsa-sha256; cv=none; b=Tz1ZIBvqKsN6NNQlaMno68+KUljZq0Hp5es5LnmtdYmuV1mcCxgWlOWjIGgTARk4BKy+yk MiVwy/Z3W+BzxjJcpEzT3wj9qA8+SpyNUZAZEbVo2r41fPxrzc4/inqfP6tpng5oNW3xUF sGnz+LyubICljYtc4dOIUE4U5AAm/gqQ7GbgEX2NU3rQmmclshX42FdYvpnX9wpksGsKrO f/zJEplHducX/MDFS4bjnSpiK7RjfYdzhOnRNtZbuAwitUO4bJdrUXhOIhNqvhdHyhMkKI vNIG3gaYRgIyCdd2XKFNpgwMk2zKhOXbbiY2MYpfiSg5xeEMG5OUJHCHxN/MAA== 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=1745857856; 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=Vou0BzQaNmWRgK0Ws5z39D1Fe/IMcYpfnGpelECiaII=; b=F+eDP89z77WnhqoYdkl7Pugj7CMsawXaLzt7dBQOZIeg9SOvA+PeWs3ifT4Z3i1ELwmyim CEDIRe9p6UbcX18ba9+ZT5GIyQOrCpR8T1pZaEKgVinBP8VpzshSRsJfvgeAzxhR5VEjBT PO345tZ0WsjkZ0Y3eXm7CxQbpyuHqtfrX/7/sG7dykdgglGn8oM6AeTLQ7czwfkpqoS+Ex 4WLedY1wnQwiHut9c5NA62eU/3Z5VJIQMrsZpGKhh4Qma95HD9DkG7izkOFIvongvqr7ur GTLHVB4m7YAFJYDHhaF7yyHPOTezgvFNEM7PVkM0RwoFHMVJeRsrvkI5MDybtA== 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 4ZmTTX1CKbzjyQ; Mon, 28 Apr 2025 16:30:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53SGUu8F089178; Mon, 28 Apr 2025 16:30:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53SGUuFp089175; Mon, 28 Apr 2025 16:30:56 GMT (envelope-from git) Date: Mon, 28 Apr 2025 16:30:56 GMT Message-Id: <202504281630.53SGUuFp089175@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: 3a9ebff23e85 - main - vtnet(4): Replaced compiletime checks for ALTQ support to runtime checks 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 3a9ebff23e85332542e6c35f2d394d1357e0329b Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3a9ebff23e85332542e6c35f2d394d1357e0329b commit 3a9ebff23e85332542e6c35f2d394d1357e0329b Author: Bjoern Jakobsen AuthorDate: 2025-04-28 06:27:43 +0000 Commit: Warner Losh CommitDate: 2025-04-28 16:30:36 +0000 vtnet(4): Replaced compiletime checks for ALTQ support to runtime checks Signed-off-by: Bjoern Jakobsen Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1679 --- sys/dev/virtio/network/if_vtnet.c | 99 +++++++++++++++++------------------- sys/dev/virtio/network/if_vtnetvar.h | 4 -- 2 files changed, 47 insertions(+), 56 deletions(-) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index ddc691744190..2ff9be9680b8 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -163,24 +163,24 @@ static struct mbuf * static int vtnet_txq_enqueue_buf(struct vtnet_txq *, struct mbuf **, struct vtnet_tx_header *); static int vtnet_txq_encap(struct vtnet_txq *, struct mbuf **, int); -#ifdef VTNET_LEGACY_TX + +/* Required for ALTQ */ static void vtnet_start_locked(struct vtnet_txq *, if_t); static void vtnet_start(if_t); -#else + +/* Required for MQ */ static int vtnet_txq_mq_start_locked(struct vtnet_txq *, struct mbuf *); static int vtnet_txq_mq_start(if_t, struct mbuf *); static void vtnet_txq_tq_deferred(void *, int); -#endif +static void vtnet_qflush(if_t); + + static void vtnet_txq_start(struct vtnet_txq *); static void vtnet_txq_tq_intr(void *, int); static int vtnet_txq_eof(struct vtnet_txq *); static void vtnet_tx_vq_intr(void *); static void vtnet_tx_start_all(struct vtnet_softc *); -#ifndef VTNET_LEGACY_TX -static void vtnet_qflush(if_t); -#endif - static int vtnet_watchdog(struct vtnet_txq *); static void vtnet_accum_stats(struct vtnet_softc *, struct vtnet_rxq_stats *, struct vtnet_txq_stats *); @@ -656,12 +656,9 @@ vtnet_negotiate_features(struct vtnet_softc *sc) if (no_csum || vtnet_tunable_int(sc, "lro_disable", vtnet_lro_disable)) features &= ~VTNET_LRO_FEATURES; -#ifndef VTNET_LEGACY_TX - if (vtnet_tunable_int(sc, "mq_disable", vtnet_mq_disable)) + /* Deactivate MQ Feature flag, if driver has ALTQ enabled, or MQ is explicitly disabled */ + if (VTNET_ALTQ_ENABLED || vtnet_tunable_int(sc, "mq_disable", vtnet_mq_disable)) features &= ~VIRTIO_NET_F_MQ; -#else - features &= ~VIRTIO_NET_F_MQ; -#endif negotiated_features = virtio_negotiate_features(dev, features); @@ -879,14 +876,14 @@ vtnet_init_txq(struct vtnet_softc *sc, int id) if (txq->vtntx_sg == NULL) return (ENOMEM); -#ifndef VTNET_LEGACY_TX - txq->vtntx_br = buf_ring_alloc(VTNET_DEFAULT_BUFRING_SIZE, M_DEVBUF, - M_NOWAIT, &txq->vtntx_mtx); - if (txq->vtntx_br == NULL) - return (ENOMEM); + if (!VTNET_ALTQ_ENABLED) { + txq->vtntx_br = buf_ring_alloc(VTNET_DEFAULT_BUFRING_SIZE, M_DEVBUF, + M_NOWAIT, &txq->vtntx_mtx); + if (txq->vtntx_br == NULL) + return (ENOMEM); - TASK_INIT(&txq->vtntx_defrtask, 0, vtnet_txq_tq_deferred, txq); -#endif + TASK_INIT(&txq->vtntx_defrtask, 0, vtnet_txq_tq_deferred, txq); + } TASK_INIT(&txq->vtntx_intrtask, 0, vtnet_txq_tq_intr, txq); txq->vtntx_tq = taskqueue_create(txq->vtntx_name, M_NOWAIT, taskqueue_thread_enqueue, &txq->vtntx_tq); @@ -957,12 +954,12 @@ vtnet_destroy_txq(struct vtnet_txq *txq) txq->vtntx_sg = NULL; } -#ifndef VTNET_LEGACY_TX - if (txq->vtntx_br != NULL) { - buf_ring_free(txq->vtntx_br, M_DEVBUF); - txq->vtntx_br = NULL; + if (!VTNET_ALTQ_ENABLED) { + if (txq->vtntx_br != NULL) { + buf_ring_free(txq->vtntx_br, M_DEVBUF); + txq->vtntx_br = NULL; + } } -#endif if (mtx_initialized(&txq->vtntx_mtx) != 0) mtx_destroy(&txq->vtntx_mtx); @@ -1106,15 +1103,16 @@ vtnet_setup_interface(struct vtnet_softc *sc) if_setinitfn(ifp, vtnet_init); if_setioctlfn(ifp, vtnet_ioctl); if_setgetcounterfn(ifp, vtnet_get_counter); -#ifndef VTNET_LEGACY_TX - if_settransmitfn(ifp, vtnet_txq_mq_start); - if_setqflushfn(ifp, vtnet_qflush); -#else - struct virtqueue *vq = sc->vtnet_txqs[0].vtntx_vq; - if_setstartfn(ifp, vtnet_start); - if_setsendqlen(ifp, virtqueue_size(vq) - 1); - if_setsendqready(ifp); -#endif + + if (!VTNET_ALTQ_ENABLED) { + if_settransmitfn(ifp, vtnet_txq_mq_start); + if_setqflushfn(ifp, vtnet_qflush); + } else { + struct virtqueue *vq = sc->vtnet_txqs[0].vtntx_vq; + if_setstartfn(ifp, vtnet_start); + if_setsendqlen(ifp, virtqueue_size(vq) - 1); + if_setsendqready(ifp); + } vtnet_get_macaddr(sc); @@ -2627,7 +2625,6 @@ fail: return (error); } -#ifdef VTNET_LEGACY_TX static void vtnet_start_locked(struct vtnet_txq *txq, if_t ifp) @@ -2693,7 +2690,6 @@ vtnet_start(if_t ifp) VTNET_TXQ_UNLOCK(txq); } -#else /* !VTNET_LEGACY_TX */ static int vtnet_txq_mq_start_locked(struct vtnet_txq *txq, struct mbuf *m) @@ -2804,7 +2800,6 @@ vtnet_txq_tq_deferred(void *xtxq, int pending __unused) VTNET_TXQ_UNLOCK(txq); } -#endif /* VTNET_LEGACY_TX */ static void vtnet_txq_start(struct vtnet_txq *txq) @@ -2815,13 +2810,14 @@ vtnet_txq_start(struct vtnet_txq *txq) sc = txq->vtntx_sc; ifp = sc->vtnet_ifp; -#ifdef VTNET_LEGACY_TX - if (!if_sendq_empty(ifp)) - vtnet_start_locked(txq, ifp); -#else - if (!drbr_empty(ifp, txq->vtntx_br)) - vtnet_txq_mq_start_locked(txq, NULL); -#endif + if (!VTNET_ALTQ_ENABLED) { + if (!drbr_empty(ifp, txq->vtntx_br)) + vtnet_txq_mq_start_locked(txq, NULL); + } else { + if (!if_sendq_empty(ifp)) + vtnet_start_locked(txq, ifp); + + } } static void @@ -2936,7 +2932,6 @@ vtnet_tx_start_all(struct vtnet_softc *sc) } } -#ifndef VTNET_LEGACY_TX static void vtnet_qflush(if_t ifp) { @@ -2958,7 +2953,6 @@ vtnet_qflush(if_t ifp) if_qflush(ifp); } -#endif static int vtnet_watchdog(struct vtnet_txq *txq) @@ -3039,12 +3033,14 @@ vtnet_get_counter(if_t ifp, ift_counter cnt) return (rxaccum.vrxs_ierrors); case IFCOUNTER_OPACKETS: return (txaccum.vtxs_opackets); -#ifndef VTNET_LEGACY_TX case IFCOUNTER_OBYTES: - return (txaccum.vtxs_obytes); + if (!VTNET_ALTQ_ENABLED) + return (txaccum.vtxs_obytes); + /* FALLTHROUGH */ case IFCOUNTER_OMCASTS: - return (txaccum.vtxs_omcasts); -#endif + if (!VTNET_ALTQ_ENABLED) + return (txaccum.vtxs_omcasts); + /* FALLTHROUGH */ default: return (if_get_counter_default(ifp, cnt)); } @@ -3148,9 +3144,8 @@ vtnet_drain_taskqueues(struct vtnet_softc *sc) txq = &sc->vtnet_txqs[i]; if (txq->vtntx_tq != NULL) { taskqueue_drain(txq->vtntx_tq, &txq->vtntx_intrtask); -#ifndef VTNET_LEGACY_TX - taskqueue_drain(txq->vtntx_tq, &txq->vtntx_defrtask); -#endif + if (!VTNET_ALTQ_ENABLED) + taskqueue_drain(txq->vtntx_tq, &txq->vtntx_defrtask); } } } diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h index b47b15543dce..0144b0f3232d 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -114,18 +114,14 @@ struct vtnet_txq { struct vtnet_softc *vtntx_sc; struct virtqueue *vtntx_vq; struct sglist *vtntx_sg; -#ifndef VTNET_LEGACY_TX struct buf_ring *vtntx_br; -#endif int vtntx_id; int vtntx_watchdog; int vtntx_intr_threshold; struct vtnet_txq_stats vtntx_stats; struct taskqueue *vtntx_tq; struct task vtntx_intrtask; -#ifndef VTNET_LEGACY_TX struct task vtntx_defrtask; -#endif #ifdef DEV_NETMAP struct virtio_net_hdr_mrg_rxbuf vtntx_shrhdr; #endif /* DEV_NETMAP */