From nobody Thu Apr 18 23:23:18 2024 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 4VLDNR096Dz5HJSl; Thu, 18 Apr 2024 23:23:19 +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 4VLDNQ6HVjz4kJh; Thu, 18 Apr 2024 23:23:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713482598; 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=4cBFtPmWDO3LPEreB2wB0bLF8klADIwn/3M77/G3kfk=; b=rJV3rFH5PphmNnGjZbyFUfZVhq02TNLRQHSsBtd4aavx8BOisk/9u84PEK7g2b4uw3hmDB nFeEatEIBmj6Zu2NuTrHOF/T3pYW13KZ4AM0mOS98MVL4iiwzZu92ryWKRlra+sjy3wN1R 8DI8ePntd4hnbRMiJXFYQR2HWD97Coo+3h3AzYVA+QHmge86xN0yiTfW20E9odFGvpHSEn VJCY1yX7LZ5rSAnfflm2d9vUeBFXJcb76es2n1+cLDgKyYv2R7ccFmRWOJDoS40eWZDTxA zSUhiYcDtylQ/uPXZizH+W1/td7tg/aM2hb9XoAgJwdCaqPIZzvFTdv5X0qCmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713482598; a=rsa-sha256; cv=none; b=YkK8oWQ4MELaUreJh2LUXhZR5Vob3Agnlcxv6N9BoAPnua2IcsTMgI9/QmfKWeROFTOme+ V0O5Ntp6O/M6IL/43pi8TnG5bOzyj9u1sJvURWwBcDQSoxsauVpMgg8Fai6rUWH4KubHJW c8y30/V7RmVBlrLnCheUTQQlBc21wC4Tc6PUdmnGQSz9pZjM1VzOQh1Go8ITjamVod4E1V 4i/0a4TF/CIAq3g4HJdpkJebZ1T94AURKusOBpfIkc7orC0xLzLHoksQ4KyA8CuztijXSD KuWzup9jonb0+zTiztBBB8hAKlnfstkDuFu7TAKomgBz9YnTXmIDIyT31IueQg== 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=1713482598; 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=4cBFtPmWDO3LPEreB2wB0bLF8klADIwn/3M77/G3kfk=; b=m5jRaI57nKGicse8+jGZ8RnEDwvB5i98R0QtAo7EifMrxrf6Z2UF3ciMS/5Foaxrv07pPS u0nzWKl9FfKE9bCBmCvBhNQYSofvCsCf9aIeXON+JAmWro+4epVJUIfsGkoM9YmvvusvpK LtisrtpjAPjRa8CNGJ99DIUvgSmbmrUT5DCUPZTlWPunGm0n6F4kt4tvCgDlVI6/Aa4pBc J02bJsGhS+mKQ/INxY+SxaSp0Z7V8i7LQv4UCQTm42W9gFERDcdcB4bxP2kXv+F9PAfH9a 5R5yRESRMpQDGWOa9KYxsx1SQav4wieY0cjh+gsZcbJDt1fY2CYfDVX/OoH/CA== 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 4VLDNQ5sfdzVMR; Thu, 18 Apr 2024 23:23:18 +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 43INNIg0045590; Thu, 18 Apr 2024 23:23:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43INNI0Z045587; Thu, 18 Apr 2024 23:23:18 GMT (envelope-from git) Date: Thu, 18 Apr 2024 23:23:18 GMT Message-Id: <202404182323.43INNI0Z045587@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric Joyner Subject: git: ed34a6b6eab9 - main - iflib: Add subinterface interrupt allocation function 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: erj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed34a6b6eab9ea39759ccd3f12876a815d271929 Auto-Submitted: auto-generated The branch main has been updated by erj: URL: https://cgit.FreeBSD.org/src/commit/?id=ed34a6b6eab9ea39759ccd3f12876a815d271929 commit ed34a6b6eab9ea39759ccd3f12876a815d271929 Author: Eric Joyner AuthorDate: 2023-01-18 00:46:39 +0000 Commit: Eric Joyner CommitDate: 2024-04-18 23:14:02 +0000 iflib: Add subinterface interrupt allocation function The ice(4) driver will add the ability to create extra interfaces that hang off of the base interface; to do that the driver requires a method for the subinterface to request hardware interrupt resources from the base interface. Signed-off-by: Eric Joyner MFC after: 3 days Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D39930 --- sys/net/iflib.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- sys/net/iflib.h | 12 +++++++++ 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 9be99df08a81..8129fb3f2f0b 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -1469,8 +1469,8 @@ iflib_dma_alloc_align(if_ctx_t ctx, int size, int align, iflib_dma_info_t dma, i &dma->idi_tag); if (err) { device_printf(dev, - "%s: bus_dma_tag_create failed: %d\n", - __func__, err); + "%s: bus_dma_tag_create failed: %d (size=%d, align=%d)\n", + __func__, err, size, align); goto fail_0; } @@ -6199,6 +6199,81 @@ iflib_irq_set_affinity(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, return (0); } +/* + * Allocate a hardware interrupt for subctx using the parent (ctx)'s hardware + * resources. + * + * Similar to iflib_irq_alloc_generic(), but for interrupt type IFLIB_INTR_RXTX + * only. + * + * XXX: Could be removed if subctx's dev has its intr resource allocation + * methods replaced with custom ones? + */ +int +iflib_irq_alloc_generic_subctx(if_ctx_t ctx, if_ctx_t subctx, if_irq_t irq, + int rid, iflib_intr_type_t type, + driver_filter_t *filter, void *filter_arg, + int qid, const char *name) +{ + device_t dev, subdev; + struct grouptask *gtask; + struct taskqgroup *tqg; + iflib_filter_info_t info; + gtask_fn_t *fn; + int tqrid, err; + driver_filter_t *intr_fast; + void *q; + + MPASS(ctx != NULL); + MPASS(subctx != NULL); + + tqrid = rid; + dev = ctx->ifc_dev; + subdev = subctx->ifc_dev; + + switch (type) { + case IFLIB_INTR_RXTX: + q = &subctx->ifc_rxqs[qid]; + info = &subctx->ifc_rxqs[qid].ifr_filter_info; + gtask = &subctx->ifc_rxqs[qid].ifr_task; + tqg = qgroup_if_io_tqg; + fn = _task_fn_rx; + intr_fast = iflib_fast_intr_rxtx; + NET_GROUPTASK_INIT(gtask, 0, fn, q); + break; + default: + device_printf(dev, "%s: unknown net intr type for subctx %s (%d)\n", + __func__, device_get_nameunit(subdev), type); + return (EINVAL); + } + + info->ifi_filter = filter; + info->ifi_filter_arg = filter_arg; + info->ifi_task = gtask; + info->ifi_ctx = q; + + NET_GROUPTASK_INIT(gtask, 0, fn, q); + + /* Allocate interrupts from hardware using parent context */ + err = _iflib_irq_alloc(ctx, irq, rid, intr_fast, NULL, info, name); + if (err != 0) { + device_printf(dev, "_iflib_irq_alloc failed for subctx %s: %d\n", + device_get_nameunit(subdev), err); + return (err); + } + + if (tqrid != -1) { + err = iflib_irq_set_affinity(ctx, irq, type, qid, gtask, tqg, q, + name); + if (err) + return (err); + } else { + taskqgroup_attach(tqg, gtask, q, dev, irq->ii_res, name); + } + + return (0); +} + int iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid, iflib_intr_type_t type, driver_filter_t *filter, diff --git a/sys/net/iflib.h b/sys/net/iflib.h index 5e1adccf202c..bf40c7429fb8 100644 --- a/sys/net/iflib.h +++ b/sys/net/iflib.h @@ -393,6 +393,11 @@ typedef enum { * function. */ #define IFLIB_FEATURE_QUEUE_SELECT_V2 1400073 +/* + * Driver can create subinterfaces with their own Tx/Rx queues + * that all share a single device (or commonly, port) + */ +#define IFLIB_FEATURE_SUB_INTERFACES 1500014 /* * These enum values are used in iflib_needs_restart to indicate to iflib @@ -491,4 +496,11 @@ void iflib_add_int_delay_sysctl(if_ctx_t, const char *, const char *, if_int_delay_info_t, int, int); uint16_t iflib_get_extra_msix_vectors_sysctl(if_ctx_t ctx); +/* + * Sub-interface support + */ +int iflib_irq_alloc_generic_subctx(if_ctx_t ctx, if_ctx_t subctx, if_irq_t irq, + int rid, iflib_intr_type_t type, + driver_filter_t *filter, void *filter_arg, + int qid, const char *name); #endif /* __IFLIB_H_ */