From nobody Mon Feb 9 06:25:16 2026 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E56E72DB7A9 for ; Fri, 6 Feb 2026 15:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392573; cv=none; b=i4XtcOwHZlDuAacpuLs/c8rcGH/ph5KLlNorUVq5GAOtx9wzzmRKxDTDiWmWp0XyepJDjzW2F5dGF8VSopEVPwU8A6JUz34sbW9f1Jhc7FLcZ0iRcr/UkFADsG7ZD5BQ5Ipqhbw5aVLYs9cXXouyXT2FYhp4JxMOfrUopWgcdlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392573; c=relaxed/simple; bh=ZZPuiaJN8FG3TNv8aa90NTIEfkFlAIEJgSyPdO5+2gw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mbbSOKfpbltYeSvr3RudbaVKWfQsk+mOjB2MDHz3UljkM4Jvc0vcpGw5+SVuphc937cnF+DguWnL587l/5TgKvljS/kBADFPtZUr0PMRxao5jr4MV3j3oafXdOms1AOwb4WH++3oSii8J1y7rsyKF7OYd03/GzwI088rpCcs2xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E2Lvmerm; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E2Lvmerm" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8c532d8be8cso194977985a.2 for ; Fri, 06 Feb 2026 07:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770392572; x=1770997372; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xwGlkP6aevqDFVvTI7GTZ8sDS3yQCcy2dagic+cTK0I=; b=E2LvmermzvzIDZeSFNhoiCFIqa628lqXugywudIcOGeYEAUT7yKR8OWvzyWXRilDWO qZzgz0GZ61aoQ0P9F6TA6JLpqSJmPEl8do706f8ZGTidFMxoVg2coTH75edrr+NCyvgR L1M8UsgGtBg7HGHnmJCC0bsH5UjWIiUEgaG2Q3TbFrT9+E37Hajwu+DWZM6ecGdzOp5J ZoP1GfdYve49xOd0zKHfTqDyB0EGjfLYOj0uGz9aABhkwzy5VhPydRTdJTwsmx6SgD0J d89UrGPJLjIN7/ZdakHLFDiBOmRg7aOwLsUSM63UtBX7T12SqSuiXVltzyX3HQQ1vGUt dZkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770392572; x=1770997372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xwGlkP6aevqDFVvTI7GTZ8sDS3yQCcy2dagic+cTK0I=; b=KO10X1XW8TY4UNEiE9H2DvCqAcXgesYVQa5AlHKc4cCNUpRLsUypRcylKyF4kW1Jqv HkxsGNBwoW/OD5yALH63rAmm/vmfOBle23PH/cn1kvgXht3wPiyVq+BfAHBAdS45+QAM UfLqKq5QjFnrNgbhOsUFduM3wamvKF1nw+PzitM/cVGYBk0Ru1xVvjOsyLk/F9B/XMYq cUwWugHdFJepgKADEYxSwila/cjcYEBP64MEnspiwQScjBUnXSB0k/M8YnpDllaXe4oN Id2FyeuLnH7awcXzRAJkeA5D8cZDjGa9CIFdBc4xFTDIYpIskV4e/j/uKRtWMgbAOAtr E0qA== X-Forwarded-Encrypted: i=1; AJvYcCWsR700JT9kw0eZeLc8WhdxjhzqgP0PlUw/7W7DPBZFDYDQt+RBLYLS+/EBTZf2UMyGFWkMaDOPDjK98Vc=@vger.kernel.org X-Gm-Message-State: AOJu0YyU70fW7/I7wri+z1EPvdbYVKZE82jTpxieIYMj3H1bl/i5wFVb W7QErqrEclVGl2vlpYYgMzb0AsvAFMmFe1/UaKx736oHMdtj0kBl3oSfm0MDVg== X-Gm-Gg: AZuq6aIQvypCT3thEWihd/3iHBaABh4Gloy2e4JJFrjGQP5E2bs7SGWwSvNR20f6kXg mMSvtKWPn1oL3yFxZcU5b8K679Hr9sC1uWvq/5vO7sNsJJRfogb5q2lhL/dHYStJ6nslbbseYwX 4Y4JtZa/bsNx/vmChWRJoLOgngbiB/2/sxueAjInTFyoFl/C/1hYUF9Sx+BsLuFVORhw2K6kbHv 3ng/Cup9k/LTUi00vUVLe3DtxzcmjM9lBhPL+0cDGc9MNNYOPezuBjXrszv7lXLVBr93BN0g5zI hjlrj3YsxOOg25a1z7GcAJFtLOH88uxrOPzhSDA7vMCH/gptmAp5gB0pRkU3ndlKJEou9KPAiQ2 QFAA7wjqENhwrbFEATNj4zSrPNJSnI/kiW5V33duNvoJzyDdemF8NLmeSD8uG8QXmZAXNV3bmCo 4cDMSixLpPaqKqd1ksYxkAGDu3fL9+PUquCdCsjXfUAXj9 X-Received: by 2002:a05:620a:1a20:b0:8c6:a341:ac1a with SMTP id af79cd13be357-8caefeb4d98mr414420585a.52.1770392571736; Fri, 06 Feb 2026 07:42:51 -0800 (PST) Received: from PF5YBGDS.localdomain ([163.114.130.1]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8caf9eea0c0sm181499185a.42.2026.02.06.07.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 07:42:51 -0800 (PST) From: mike.marciniszyn@gmail.com To: Alexander Duyck , Jakub Kicinski , kernel-team@meta.com, Andrew Lunn , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Russell King , Jacob Keller , Mohsin Bashir , Lee Trager , "Mike Marciniszyn (Meta)" , Dan Carpenter , Pei Xiao , Stanislav Fomichev , Kuniyuki Iwashima , Samiullah Khawaja , Ahmed Zaki , Alexander Lobakin Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v12 3/5] eth fbnic: Add msix self test Date: Fri, 6 Feb 2026 10:42:43 -0500 Message-ID: <20260206154246.814-4-mike.marciniszyn@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260206154246.814-1-mike.marciniszyn@gmail.com> References: <20260206154246.814-1-mike.marciniszyn@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Mike Marciniszyn (Meta)" This function is meant to test the global interrupt registers and the PCIe IP MSI-X functionality. It essentially goes through and tests test various combinations of the set, clear, and mask bits in order to verify the behavior is as we expect it to be from the driver. Signed-off-by: Mike Marciniszyn (Meta) --- drivers/net/ethernet/meta/fbnic/fbnic.h | 1 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 27 +++ drivers/net/ethernet/meta/fbnic/fbnic_irq.c | 154 ++++++++++++++++++ 3 files changed, 183 insertions(+) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic.h b/drivers/net/ethernet= /meta/fbnic/fbnic.h index 779a083b9215..26597a2cc3c4 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic.h @@ -194,6 +194,7 @@ void fbnic_synchronize_irq(struct fbnic_dev *fbd, int n= r); int fbnic_request_irq(struct fbnic_dev *dev, int nr, irq_handler_t handler, unsigned long flags, const char *name, void *data); void fbnic_free_irq(struct fbnic_dev *dev, int nr, void *data); +int fbnic_msix_test(struct fbnic_dev *fbd); void fbnic_free_irqs(struct fbnic_dev *fbd); int fbnic_alloc_irqs(struct fbnic_dev *fbd); diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/= ethernet/meta/fbnic/fbnic_ethtool.c index 2e882dbd408d..b0c8d1b069e2 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -128,10 +128,12 @@ static const struct fbnic_stat fbnic_gstrings_xdp_sta= ts[] =3D { enum fbnic_self_test_results { TEST_REG =3D 0, + TEST_MSIX, }; static const char fbnic_gstrings_self_test[][ETH_GSTRING_LEN] =3D { [TEST_REG] =3D "Register test (offline)", + [TEST_MSIX] =3D "MSI-X Interrupt test (offline)", }; #define FBNIC_TEST_LEN ARRAY_SIZE(fbnic_gstrings_self_test) @@ -1501,6 +1503,28 @@ static int fbnic_ethtool_regs_test(struct net_device= *netdev, u64 *data) return !!*data; } +/** + * fbnic_ethtool_msix_test - Verify behavior of NIC interrupts + * @netdev: netdev device to test + * @data: Pointer to results storage + * + * This function is meant to test the global interrupt registers and the + * PCIe IP MSI-X functionality. It essentially goes through and tests + * test various combinations of the set, clear, and mask bits in order to + * verify the behavior is as we expect it to be from the driver. + * + * Return: non-zero on failure. + **/ +static int fbnic_ethtool_msix_test(struct net_device *netdev, u64 *data) +{ + struct fbnic_net *fbn =3D netdev_priv(netdev); + struct fbnic_dev *fbd =3D fbn->fbd; + + *data =3D fbnic_msix_test(fbd); + + return !!*data; +} + static void fbnic_self_test(struct net_device *netdev, struct ethtool_test *eth_test, u64 *data) { @@ -1508,6 +1532,7 @@ static void fbnic_self_test(struct net_device *netdev, if (!(eth_test->flags & ETH_TEST_FL_OFFLINE)) { data[TEST_REG] =3D 0; + data[TEST_MSIX] =3D 0; return; } @@ -1517,6 +1542,9 @@ static void fbnic_self_test(struct net_device *netdev, if (fbnic_ethtool_regs_test(netdev, &data[TEST_REG])) eth_test->flags |=3D ETH_TEST_FL_FAILED; + if (fbnic_ethtool_msix_test(netdev, &data[TEST_MSIX])) + eth_test->flags |=3D ETH_TEST_FL_FAILED; + if (if_running && netif_open(netdev, NULL)) { netdev_err(netdev, "Failed to re-initialize hardware following test\n"); diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_irq.c b/drivers/net/ethe= rnet/meta/fbnic/fbnic_irq.c index 02e8b0b257fe..925be05b329f 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_irq.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_irq.c @@ -238,6 +238,160 @@ void fbnic_free_irq(struct fbnic_dev *fbd, int nr, vo= id *data) free_irq(irq, data); } +struct fbnic_msix_test_data { + struct fbnic_dev *fbd; + unsigned long test_msix_status[BITS_TO_LONGS(FBNIC_MAX_MSIX_VECS)]; + int irq_vector[FBNIC_MAX_MSIX_VECS]; +}; + +static irqreturn_t fbnic_irq_test(int irq, void *data) +{ + struct fbnic_msix_test_data *test_data =3D data; + struct fbnic_dev *fbd =3D test_data->fbd; + int i; + + for (i =3D fbd->num_irqs; i--;) { + if (test_data->irq_vector[i] =3D=3D irq) { + set_bit(i, test_data->test_msix_status); + break; + } + } + + return IRQ_HANDLED; +} + +/** + * fbnic_msix_test - Verify behavior of NIC interrupts + * @fbd: device to test + * + * This function is meant to test the global interrupt registers and the + * PCIe IP MSI-X functionality. It essentially goes through and tests + * test various combinations of the set, clear, and mask bits in order to + * verify the behavior is as we expect it to be from the driver. + * + * Return: non-zero on failure. + **/ +int fbnic_msix_test(struct fbnic_dev *fbd) +{ + struct pci_dev *pdev =3D to_pci_dev(fbd->dev); + struct fbnic_msix_test_data *test_data; + int result =3D 0; + u32 mask =3D 0; + int i; + + /* Allocate bitmap and IRQ vector table */ + test_data =3D kzalloc(sizeof(*test_data), GFP_KERNEL); + + /* Result =3D 5 for memory allocation failure */ + if (!test_data) + return 5; + + /* Initialize test data */ + test_data->fbd =3D fbd; + + for (i =3D FBNIC_NON_NAPI_VECTORS; i < fbd->num_irqs; i++) { + /* Add IRQ to vector table so it can be found */ + test_data->irq_vector[i] =3D pci_irq_vector(pdev, i); + + /* Enable the interrupt */ + if (!fbnic_request_irq(fbd, i, fbnic_irq_test, 0, + fbd->netdev->name, test_data)) + continue; + + while (i--) + fbnic_free_irq(fbd, i, test_data); + kfree(test_data); + + /* Result =3D 10 for IRQ request failure */ + return 10; + } + + /* Test each bit individually */ + for (i =3D FBNIC_NON_NAPI_VECTORS; i < fbd->num_irqs; i++) { + mask =3D 1U << (i % 32); + + /* Start with mask set and interrupt cleared */ + fbnic_wr32(fbd, FBNIC_INTR_MASK_SET(i / 32), mask); + fbnic_wrfl(fbd); + fbnic_wr32(fbd, FBNIC_INTR_CLEAR(i / 32), mask); + fbnic_wrfl(fbd); + + /* Result =3D 20 for masking failure to prevent interrupt */ + result =3D 20; + + fbnic_wr32(fbd, FBNIC_INTR_SET(i / 32), mask); + fbnic_wrfl(fbd); + usleep_range(10000, 11000); + + if (test_bit(i, test_data->test_msix_status)) + break; + + /* Result =3D 30 for unmasking failure w/ sw status set */ + result =3D 30; + + fbnic_wr32(fbd, FBNIC_INTR_MASK_CLEAR(i / 32), mask); + fbnic_wrfl(fbd); + usleep_range(10000, 11000); + + if (!test_bit(i, test_data->test_msix_status)) + break; + + /* Result =3D 40 for interrupt when clearing mask */ + result =3D 40; + + clear_bit(i, test_data->test_msix_status); + fbnic_wr32(fbd, FBNIC_INTR_MASK_CLEAR(i / 32), mask); + fbnic_wrfl(fbd); + usleep_range(10000, 11000); + + if (test_bit(i, test_data->test_msix_status)) + break; + + /* Result =3D 50 for interrupt not triggering when not masked */ + result =3D 50; + + fbnic_wr32(fbd, FBNIC_INTR_SET(i / 32), mask); + fbnic_wrfl(fbd); + usleep_range(10000, 11000); + + if (!test_bit(i, test_data->test_msix_status)) + break; + + /* Result =3D 60 for status not cleared, or mask not set */ + result =3D 60; + if (mask & fbnic_rd32(fbd, FBNIC_INTR_STATUS(i / 32))) + break; + if (!(mask & fbnic_rd32(fbd, FBNIC_INTR_MASK(i / 32)))) + break; + + /* Result =3D 0 - Success */ + result =3D 0; + + clear_bit(i, test_data->test_msix_status); + } + + if (i < fbd->num_irqs) { + fbnic_wr32(fbd, FBNIC_INTR_MASK_SET(i / 32), mask); + fbnic_wrfl(fbd); + fbnic_wr32(fbd, FBNIC_INTR_CLEAR(i / 32), mask); + fbnic_wrfl(fbd); + clear_bit(i, test_data->test_msix_status); + } + + for (i =3D FBNIC_NON_NAPI_VECTORS; i < fbd->num_irqs; i++) { + /* Test for bits set after testing */ + if (test_bit(i, test_data->test_msix_status)) + result =3D 70; + + /* Free IRQ */ + fbnic_free_irq(fbd, i, test_data); + } + + kfree(test_data); + + return result; +} + void fbnic_napi_name_irqs(struct fbnic_dev *fbd) { unsigned int i; -- 2.43.0