From nobody Sat Feb 7 17:49:07 2026 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 133B12D0620 for ; Fri, 6 Feb 2026 15:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392570; cv=none; b=ZJB2u04z0X/Kji+e75P28iUaFWxz19iwfqig4dFdOnWPfd2r1Sv+rcugxrped1jmWXQNrrQoKS073isw8CSr2+yppEbHogzEUeCNqZL7BTB8WPUb5wm4seTr73jZIel7hnhJw1Z7TYqmH8QiK4YPIRMAVs4LM2uwq9+FX/8ZWS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392570; c=relaxed/simple; bh=RgNHkO1t0LY/JdKK9DJjaXVvcw9gEDHDg22uEBqQJJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WUdH0jUq+Rb+AhrtN7UiMykzNDgctYsiAF76UmHpC460eQ2xSxoG9NgUy1KpvmOBxWVSpVhNYP0X/+r7/osJW80lVK7uYYl9uhK95VkcGj8bzfVeFtbnSshh4X80+r4mah0+TlIp1aIyvL+atP/Ovk/L/qsGny0QGm1G5xfLZYA= 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=QqUHIvzP; arc=none smtp.client-ip=209.85.222.172 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="QqUHIvzP" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-8c5320536bfso217003085a.1 for ; Fri, 06 Feb 2026 07:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770392569; x=1770997369; 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=ctrVGJ4rkCHHyx+/hoFia9xDzknoZ2CE0M4UFFU9GRI=; b=QqUHIvzP/z+N7ZhXInxPdJXipxXjOAdX/FeimemPwkQ9BdHlnILytIazSerEmGQR9E ErQ572BpjyHwOcOs6KGqTG9HiuNhhYMdlkht+Itz6MSmPXcrNPeJQnl3w/NL8ZqoIJiX yDCoEtvZ1K2T+UVejrJmrkRin6JajJua+MYD2JpKmlWQ/9WNMvuAjW4JMb7eda7WMwky u0Ukv469cQA7yOPICQFuv/WV0le2Z5PE1LrbhSvPdLF0uOJ5vXJXulxKYmOz8s4Rw0UP vQDbgve8ANfj5QfaBa9WI7xTeWETFM4YaAk5wOpWWBRF2By3UaMIH/XJ5S0h6lXyHAE+ VWBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770392569; x=1770997369; 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=ctrVGJ4rkCHHyx+/hoFia9xDzknoZ2CE0M4UFFU9GRI=; b=FM7ty/n2HtxM/ioNPI45z+1TvuosPuQNDQ/TqArePD5Q9jPzdsfst9+aCk9GTBCD82 KKOpEacTxkvbVE6Bnwx2VzZeD4CKSjTkC8x58iBdl+WuLRblMAIdEZSC3PMknoLwL6MX VOSgV14yDiXpFQcxHLZAnxZy8fTn6LYoRDZpt3RHgAQexlbXsqaOw8rOQxt8NpKggNes uctXxKNjPew55HSaR69/OZCmm2ykvl+J+RouVH7OmusaiRxApSz+JZWQ6aftdUhw1nZo uI1PcqM5dOBoXqdAzIb7Gc3upb7d4CdoQ/9slHOejRPzJyBks6YyE5Qh2rg+yDyrapfm 45/g== X-Forwarded-Encrypted: i=1; AJvYcCUHJagKnt2F9nGJikmrcEciW4yY95L59C/hq/VUtALeZilW5i9r5NKOGsdeGC9nhpJe9HBtRT4Orputfn8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8tBQHKnvX+yTUhcl45h4rSnFIrXsNWXi/s7y6b4uoxEnTrkr1 vLm9FV5A082Ixg0CwWMY3tp9xPYq77OIWS9y+jOjbD9wq09zlDpajSdg X-Gm-Gg: AZuq6aJgI0PesYS5RddeW9t/mnE5drUjLwBTw8xc+HyX8X4NpCV+4QfHmqcVQSpsrKs FKATlFRzdMIoQmUgq+ggFHLDU//NXLRXNVHXx4xD7Xz6X2dtmtB0CzSWqUHNH+PRIj+iewbX5X5 tYPmyJMeT3VNI6X9zioPlchwO+fcy4B1JNx5EXx72a5wrm36RcxyVVo7Ei23E4AqAzqdtddTVQo jZXipkJAc82BCyUMk/1iI+y7dHbkB/slb3Lv62B6oMhJZp0ToaMsGSmsmCRKNC0Z0lMtmVv31kz c8TO5sBuzol37yO2eZOq2Zb2mJo2sRrZMh5laZU4WoTAuPpqU/53Xfya5XfYWX2zFjtPj0O4uhT HIPQCqpeFx5KZ23Fl+x1+GQWcTZKTo2kcqXqn34uL3H63mMZX2PjSDsozObl/u/3YbTTD+fLgdY /7Op7vpHM3FqlU71ZXyTXvQ4sZ99bFTJHc+TwmQwHUCLtq X-Received: by 2002:a05:620a:1a8c:b0:8ca:4288:b163 with SMTP id af79cd13be357-8caeef2f874mr390689285a.17.1770392569116; Fri, 06 Feb 2026 07:42:49 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 07:42:48 -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 1/5] net: export netif_open for self_test usage Date: Fri, 6 Feb 2026 10:42:41 -0500 Message-ID: <20260206154246.814-2-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 export is required for the following fbnic self tests to avoid calling ndo_stop() and ndo_open() in favor of the more appropriate netif_open() and netif_close() that notifies any listeners that the interface went down to test and is now coming back up. dev_open() already is exported, but drivers which use the netdev instance lock need to use netif_open() instead. netif_close() is also already exported [1] so this completes the pairing. Link: https://patch.msgid.link/20250309215851.2003708-1-sdf@fomichev.me [1] Signed-off-by: Mike Marciniszyn (Meta) --- net/core/dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/dev.c b/net/core/dev.c index 43de5af0d6ec..d1d5694d1ff0 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1724,6 +1724,7 @@ int netif_open(struct net_device *dev, struct netlink= _ext_ack *extack) return ret; } +EXPORT_SYMBOL(netif_open); static void __dev_close_many(struct list_head *head) { -- 2.43.0 From nobody Sat Feb 7 17:49:07 2026 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 9114C2D7DF2 for ; Fri, 6 Feb 2026 15:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392571; cv=none; b=AuDHyhgB2TlMl7SvtFLH53uY99K3EVJSKsUfwxGGOWBCNOh2WfKF9lRqwd+3os8a+81gNQxVyx86ncou/Lq2bcXDD8VyNy7nEbRN+ANrM0dePq7yB9Uxn13TjBum5nI2yupfEFmQrPju/vXWUlNg85lzGmPZrZ9TO4q7i41sv+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392571; c=relaxed/simple; bh=00tZ7hEKaVSKAGSZ3kjjf4Nu/LRjLj2wUt3oFw5KAcA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gDv/8Pi/WSFbKEE3XxkqGHOsnu1ub0vRfneHmHqkZ4LH+XQXb6RwjMbIDs3GSgm1dnyRu9CXWLrpq71LJMl5tT4vp/J8tpqa4RGhbQ7ro7feAvV+Rg1b0DyoO6+9XkJzgKiaMoloSazLmUd5du+nhzYyOxTZlImvd2+0rOaTfjQ= 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=NhkTVQMG; arc=none smtp.client-ip=209.85.222.172 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="NhkTVQMG" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-8c6aaf3cd62so213598385a.3 for ; Fri, 06 Feb 2026 07:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770392570; x=1770997370; 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=+eYlMgeBfdVMTpRaGQ8tUVtwdsLeLniXT3Abva0RN7Y=; b=NhkTVQMGBryqOfrPlLlZng0BAcfGQiI46hpoAJveY6rFxUbt89rVSCP9Fo1rub3EJy cUUkdY1LrXY2CTorjrYNpF+oRRv0jwtHeX6/U4ikcb/p0XmDgmgvaosPuusqAyIcF+Du hk3aCiqVky3Xs9LizrBMPZtu+d0kbk7vuMsOjHFgB8WtSkRgYO7CFDMS3hylzOTmHgdK GPgDaqdGBuqxxrYVL1h/qzLKGvCr9dPD7XubB226IkGVL39uNAJz5ZTybIOljBe42/w/ WeGjCFSt2dIlG5GyTjUnschyPDKJQ9rQwJgrkHIGKEkaRsbk6RZPWHDAQ4PcTpwDuRNQ pYFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770392570; x=1770997370; 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=+eYlMgeBfdVMTpRaGQ8tUVtwdsLeLniXT3Abva0RN7Y=; b=QqNqaXyy2GeNVbu7wzC3GO34I2r1Da3qPRNcfev01NgXAVxFabOzqyyHEmgVbRSaRd pnDEAfhP+3QyeFRinucRD4071K1PDmmoffuLPsLpAWMC8+NxM5ZRta6UfkgH6i4vkQQX yqRrJUgwwLO4/hjyuylA+gR3Tsewr2KfnnD2P1DC1rVZaAuyd1pSnibnvAk6QVXRiLVi EKwqQzd5071rGhNvWAhBsTeeZvCc6RKkYumOt7swy8dyyoLUs40MTjdpdMopTvDY8zh5 hmtF6glhB46CkOjRXXe/7UWNkdbj394LYILcDBXICJ6015ZndwIAAPei06XEGT6VR8Wb jw+A== X-Forwarded-Encrypted: i=1; AJvYcCVl8QTIQDP6GWl/OpnZUluJmKgJPDJ6mPnhXWGId07sGvykLRf1dxULzvxGBQODMWIZPkphVFBonMCg4no=@vger.kernel.org X-Gm-Message-State: AOJu0Yyon08r6HZw50woGvjZvxBIhiiC5MkgRz0EcnPXSTzkKABJY2mi BK/Pla18yyoH8WrQ3jAktttcpXm2FOrf6Ny48/7aypek7MXvZi6YqwQA X-Gm-Gg: AZuq6aJOco06I/EMfKZnuQhyvxdxjtGpn+beGKhLgUkxl06MOW7ggp5drqvDOO51Ud1 PQPWYm2SvRc5NAJ70krWJGozwZeo5CdkPsSwhKk01NKDKN/Ond6sp6GvSOkPoP0+0fbVlfEhNVf 5a4Hi5h8uwfcfdEItCAQ2HwQkVF/WB6X2yEFgWWCZhfbAN0RvrSPhHcqETSSjOrDIQplRY+4NSW u11BXfU7aaCXMuGAt/f7MXYMi8wrfBRszkdzl8CsupwOSKRQCmA0X3MuTvecHGcS9yghVq4HAsW fPElbXjU1Rgv3hJVGpr2bVelm1QkERQBR6KxPGECLwbaBWwlF3l5yEC7A6CK3BhWvAIXTBDcy/g iRhbaP2LkY49uDCi5qL1j50uBhZmoYdIvcR1B2m4w4o76CMxtZr/p9n8ngTOJQEW3zpCv7dJO9K gj9wr4k8ZkmIoOzp0dsV/2VUcx2Ag40te/0/16Vg/4kCQ4 X-Received: by 2002:a05:620a:bc9:b0:8ca:d5cb:6841 with SMTP id af79cd13be357-8caf1acb650mr389015585a.49.1770392570454; Fri, 06 Feb 2026 07:42:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 07:42:50 -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 2/5] eth fbnic: Add register self test Date: Fri, 6 Feb 2026 10:42:42 -0500 Message-ID: <20260206154246.814-3-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)" The register test will be used to verify hardware is behaving as expected. The test itself will have us writing to registers that should have no side effects due to us resetting after the test has been completed. While the test is being run the interface should be offline. This patch counts on the first patch of this series to export netif_open() and also ensures that the half close calls netif_close() to avoid deadlock. Signed-off-by: Mike Marciniszyn (Meta) --- drivers/net/ethernet/meta/fbnic/fbnic_csr.c | 126 ++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 4 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 50 +++++++ 3 files changed, 180 insertions(+) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.c b/drivers/net/ethe= rnet/meta/fbnic/fbnic_csr.c index d9c0dc1c2af9..c1541388d23c 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.c @@ -147,3 +147,129 @@ int fbnic_csr_regs_len(struct fbnic_dev *fbd) return len; } + +/* CSR register test data + * + * The register test will be used to verify hardware is behaving as expect= ed. + * + * The test itself will have us writing to registers that should have no + * side effects due to us resetting after the test has been completed. + * While the test is being run the interface should be offline. + */ +struct fbnic_csr_reg_test_data { + int reg; + u16 reg_offset; + u8 array_len; + u32 read; + u32 write; +}; + +#define FBNIC_QUEUE_REG_TEST(_name, _read, _write) { \ + .reg =3D FBNIC_QUEUE(0) + FBNIC_QUEUE_##_name, \ + .reg_offset =3D FBNIC_QUEUE_STRIDE, \ + .array_len =3D 64, \ + .read =3D _read, \ + .write =3D _write \ +} + +static const struct fbnic_csr_reg_test_data pattern_test[] =3D { + FBNIC_QUEUE_REG_TEST(TWQ0_CTL, FBNIC_QUEUE_TWQ_CTL_RESET, + FBNIC_QUEUE_TWQ_CTL_RESET), + FBNIC_QUEUE_REG_TEST(TWQ0_PTRS, 0, ~0), + FBNIC_QUEUE_REG_TEST(TWQ0_SIZE, FBNIC_QUEUE_TWQ_SIZE_MASK, ~0), + FBNIC_QUEUE_REG_TEST(TWQ0_BAL, FBNIC_QUEUE_BAL_MASK, ~0), + FBNIC_QUEUE_REG_TEST(TWQ0_BAH, ~0, ~0), + FBNIC_QUEUE_REG_TEST(TWQ1_CTL, FBNIC_QUEUE_TWQ_CTL_RESET, + FBNIC_QUEUE_TWQ_CTL_RESET), + FBNIC_QUEUE_REG_TEST(TWQ1_PTRS, 0, ~0), + FBNIC_QUEUE_REG_TEST(TWQ1_SIZE, FBNIC_QUEUE_TWQ_SIZE_MASK, ~0), + FBNIC_QUEUE_REG_TEST(TWQ1_BAL, FBNIC_QUEUE_BAL_MASK, ~0), + FBNIC_QUEUE_REG_TEST(TWQ1_BAH, ~0, ~0), + FBNIC_QUEUE_REG_TEST(TCQ_CTL, FBNIC_QUEUE_TCQ_CTL_RESET, + FBNIC_QUEUE_TCQ_CTL_RESET), + FBNIC_QUEUE_REG_TEST(TCQ_PTRS, 0, ~0), + FBNIC_QUEUE_REG_TEST(TCQ_SIZE, FBNIC_QUEUE_TCQ_SIZE_MASK, ~0), + FBNIC_QUEUE_REG_TEST(TCQ_BAL, FBNIC_QUEUE_BAL_MASK, ~0), + FBNIC_QUEUE_REG_TEST(TCQ_BAH, ~0, ~0), + FBNIC_QUEUE_REG_TEST(RCQ_CTL, FBNIC_QUEUE_RCQ_CTL_RESET, + FBNIC_QUEUE_RCQ_CTL_RESET), + FBNIC_QUEUE_REG_TEST(RCQ_PTRS, 0, ~0), + FBNIC_QUEUE_REG_TEST(RCQ_SIZE, FBNIC_QUEUE_RCQ_SIZE_MASK, ~0), + FBNIC_QUEUE_REG_TEST(RCQ_BAL, FBNIC_QUEUE_BAL_MASK, ~0), + FBNIC_QUEUE_REG_TEST(RCQ_BAH, ~0, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_CTL, FBNIC_QUEUE_BDQ_CTL_RESET, + FBNIC_QUEUE_BDQ_CTL_RESET), + FBNIC_QUEUE_REG_TEST(BDQ_HPQ_PTRS, 0, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_HPQ_SIZE, FBNIC_QUEUE_BDQ_SIZE_MASK, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_HPQ_BAL, FBNIC_QUEUE_BAL_MASK, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_HPQ_BAH, ~0, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_PPQ_PTRS, 0, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_PPQ_SIZE, FBNIC_QUEUE_BDQ_SIZE_MASK, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_PPQ_BAL, FBNIC_QUEUE_BAL_MASK, ~0), + FBNIC_QUEUE_REG_TEST(BDQ_PPQ_BAH, ~0, ~0), +}; + +static int +fbnic_csr_reg_pattern_test(struct fbnic_dev *fbd, int index, + const struct fbnic_csr_reg_test_data *test_data) +{ + static const u32 pattern[] =3D { ~0, 0x5A5A5A5A, 0xA5A5A5A5, 0}; + u32 reg =3D test_data->reg + test_data->reg_offset * index; + int i; + + for (i =3D 0; i < ARRAY_SIZE(pattern); i++) { + u32 val =3D pattern[i] & test_data->write; + u32 result; + + wr32(fbd, reg, val); + result =3D rd32(fbd, reg); + val &=3D test_data->read; + + if (result =3D=3D val) + continue; + + dev_err(fbd->dev, + "%s: reg 0x%06X failed, expected 0x%08X received 0x%08X\n", + __func__, reg, val, result); + + /* Note that FBNIC_INTR_STATUS(0) could be tested and fail + * and the result would not be reported since the register + * offset is 0. However as that register isn't included in + * the register test that isn't an issue. + */ + return reg; + } + + return 0; +} + +/** + * fbnic_csr_regs_test() - Verify behavior of NIC registers + * @fbd: device to test + * + * This function is meant to test the bit values of various registers in + * the NIC device. Specifically this test will verify which bits are + * writable and which ones are not. It will write varying patterns of bits + * to the registers testing for sticky bits, or bits that are writable but + * should not be. + * + * Return: non-zero on failure. + **/ +int fbnic_csr_regs_test(struct fbnic_dev *fbd) +{ + const struct fbnic_csr_reg_test_data *test_data; + + for (test_data =3D pattern_test; + test_data < pattern_test + ARRAY_SIZE(pattern_test); test_data++) { + u32 i; + + for (i =3D 0; i < test_data->array_len; i++) { + int reg =3D fbnic_csr_reg_pattern_test(fbd, i, test_data); + + if (reg) + return reg; + } + } + + return 0; +} diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethe= rnet/meta/fbnic/fbnic_csr.h index b717db879cd3..633a29146617 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h @@ -1210,4 +1210,8 @@ enum{ FBNIC_CSR_VERSION_V1_0_ASIC =3D 1, }; +struct fbnic_dev; + +int fbnic_csr_regs_test(struct fbnic_dev *fbd); + #endif /* _FBNIC_CSR_H_ */ diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/= ethernet/meta/fbnic/fbnic_ethtool.c index 11745a2d8a44..2e882dbd408d 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -126,6 +126,16 @@ static const struct fbnic_stat fbnic_gstrings_xdp_stat= s[] =3D { #define FBNIC_STATS_LEN \ (FBNIC_HW_STATS_LEN + FBNIC_XDP_STATS_LEN * FBNIC_MAX_XDPQS) +enum fbnic_self_test_results { + TEST_REG =3D 0, +}; + +static const char fbnic_gstrings_self_test[][ETH_GSTRING_LEN] =3D { + [TEST_REG] =3D "Register test (offline)", +}; + +#define FBNIC_TEST_LEN ARRAY_SIZE(fbnic_gstrings_self_test) + static void fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvin= fo) { @@ -475,6 +485,10 @@ static void fbnic_get_strings(struct net_device *dev, = u32 sset, u8 *data) for (i =3D 0; i < FBNIC_MAX_XDPQS; i++) fbnic_get_xdp_queue_strings(&data, i); break; + case ETH_SS_TEST: + memcpy(data, fbnic_gstrings_self_test, + sizeof(fbnic_gstrings_self_test)); + break; } } @@ -566,6 +580,8 @@ static int fbnic_get_sset_count(struct net_device *dev,= int sset) switch (sset) { case ETH_SS_STATS: return FBNIC_STATS_LEN; + case ETH_SS_TEST: + return FBNIC_TEST_LEN; default: return -EOPNOTSUPP; } @@ -1475,6 +1491,39 @@ fbnic_remove_rxfh_context(struct net_device *netdev, return 0; } +static int fbnic_ethtool_regs_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_csr_regs_test(fbd); + + return !!*data; +} + +static void fbnic_self_test(struct net_device *netdev, + struct ethtool_test *eth_test, u64 *data) +{ + bool if_running =3D netif_running(netdev); + + if (!(eth_test->flags & ETH_TEST_FL_OFFLINE)) { + data[TEST_REG] =3D 0; + return; + } + + if (if_running) + netif_close(netdev); + + if (fbnic_ethtool_regs_test(netdev, &data[TEST_REG])) + 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"); + eth_test->flags |=3D ETH_TEST_FL_FAILED; + } +} + static void fbnic_get_channels(struct net_device *netdev, struct ethtool_channels *ch) { @@ -1893,6 +1942,7 @@ static const struct ethtool_ops fbnic_ethtool_ops =3D= { .get_pause_stats =3D fbnic_get_pause_stats, .get_pauseparam =3D fbnic_phylink_get_pauseparam, .set_pauseparam =3D fbnic_phylink_set_pauseparam, + .self_test =3D fbnic_self_test, .get_strings =3D fbnic_get_strings, .get_ethtool_stats =3D fbnic_get_ethtool_stats, .get_sset_count =3D fbnic_get_sset_count, -- 2.43.0 From nobody Sat Feb 7 17:49:07 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 From nobody Sat Feb 7 17:49:07 2026 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 261422DCC05 for ; Fri, 6 Feb 2026 15:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392574; cv=none; b=DE5B2KBCSJAAct6lm7yj0sRCK5EODx7EjSkQVZ37zCIzcIENinUChLV++qvBmbCWvHs8eBkFPtPU+dkKhaDztCXzGCLsXtb02pjbhx4CLOd9felabXNWugJ9f6KBNzNa4ErktinzeRwQFnHcGjKC8S4TYsL3FguN9BiSLohTHa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392574; c=relaxed/simple; bh=nk6FBo5oHu46xrfexvRbcHaZ0aBYk3+ins4qA5pSGSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CIaCA+XUsaAV0PlpoRs+0uf4MbVY+m2ZrDwxvxS0PzkwDeC7ejWrYqR9YN0+eG/OKRPy0ZDax05lKOCmZFnF0a9UQsZWq4BqNcL0VmKu4rh0tz1wDYkQsniOSzdeuMeM7o4tudOCN8wwfutbWcQBOnU6WmVyZIWR1Vf+U3At4pk= 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=HU0wY6hW; arc=none smtp.client-ip=209.85.222.172 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="HU0wY6hW" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-8c70c6b2bcaso226535285a.3 for ; Fri, 06 Feb 2026 07:42:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770392573; x=1770997373; 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=4CrpLjsEJ97mU1tWann7pmgOTRqhJQHSEffGujRvSNk=; b=HU0wY6hWTxEEE0K9XCjtI/Rk365WjHwSEXj+oL1zebQJxhqUGPH4noh9H/CppEiDP1 1PoGUlavq9qs2TqI9JQKdWm6u+pW3fhBggU2zJeM1V4OhvUYTWd41xK5B/gKnI48YkxF YRQNCLBUa8cDqeLNYjdmXoFURFy/52eQblmnlbFmIsFO5RpblMgk3KEXK5Bn+jLnUBTK 78PjEZWwH59OO+3tQbHjEhynMOHHJJPluRPj0ylSQTRJKTZkB6O9yWtt5yZxhuiiz9k/ JgEFHkNnCTVNW2VmnBYEoAaahsLH8FdW+RP0CUD7SSp7z6te+CMFgTcupQVD+IZXhRt0 +fuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770392573; x=1770997373; 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=4CrpLjsEJ97mU1tWann7pmgOTRqhJQHSEffGujRvSNk=; b=Yu8VB7teaREw4VooKMALBeDRLlBEzC9HmEBIEwe/8ZpkC2NVP1gZcn2BTvJRbPzjNg rdnUYrxxh2r+tqg1HUA0di7vr6nisnTHGcgp3pPy5ggQxDeon+S+hbMT+RpKaRV8tSmN BFhUViayYNPIVDyZMVFNlSLbTIBH+HIhHHaZBgRij5ppAfhk1bdOEZTia1iX/qXhbsAr afvUn9XvuegRsJvcqqS6wK1pm+BYzUfpu4kFUxaPR1Ku+DtIK9DFazVftUoS46nejdCv esO8pT2yJWwZD7eZEuHhE0Q5G3HawsOOZD/mvnLNuDnYCghwkE97PQTANkXGNhT879ur 8/+Q== X-Forwarded-Encrypted: i=1; AJvYcCW9vdG30HwlU81MucM8APg1vW9l7YncM6hJFU9mHDWjl9JOPjNMNVvjNLv6cJiFqAfLMIcDv/XfARig1CQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyUGOP6lkWtnEiWj0zjp+QpqGkHaZ+boO9j/c1rh/wUFkprh6w0 CzyLaaBmT3Z8pOgQvMlb70xMknrTzNUqpAKo50ClvvNdFyOqPRpGx2DE X-Gm-Gg: AZuq6aILL/WmuirPhfyjlLBNUCEh3dn71piyrm1C4qwrY9Uyw4Tgefv4Nhi3FaRqC4w tQL0TxovENaaAx3l/N1mJL4VmbRnCPg6kAOQMfljn/3+DxOA667PVHQWALIZw9rvNGXA4UaITpg wjm1k4Jr+fH4l2uxVQgaNU4Ybg1IX4AfPOIgX6hOGjQQ/gZWhq/aGHG4+29vg4zBU6fNl7BRDYh lg8cbAErOHZzSVXmEalGVVZvodarvbg6uPT3UlsOPWQmoMo7+ic9hIvksQx4rdWecU6oG3nhfxG OLUBEbnyAmJhYgEgPJHkAcTLf4AZ8dulPkEnUtBOWFrNFPP85JrDW1+cSm5aPYCBpFvYqkM9IRn nAU2AeQHm5rHhF9azuVynjoMEeVe9GVVy6RiSnS2/RcBJyRTTAWw6OWFUHZULGM/i0BGC/SCceX JxDrAzUKtvoemMXQHOreVzpMbWjXVvIHU2eDKdWCyTO4ZN X-Received: by 2002:a05:620a:462c:b0:8b2:598d:6e66 with SMTP id af79cd13be357-8caef30bf03mr378659585a.22.1770392573045; Fri, 06 Feb 2026 07:42:53 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 07:42:52 -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 4/5] eth fbnic: TLV support for use by MBX self test Date: Fri, 6 Feb 2026 10:42:44 -0500 Message-ID: <20260206154246.814-5-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)" The TLV (Type-Value-Length) self uses a known set of data to create a TLV message. These routines support the MBX self test by creating the test messages and parsing the response message coming back from the firmware. Signed-off-by: Mike Marciniszyn (Meta) --- diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c b/drivers/net/ethe= rnet/meta/fbnic/fbnic_tlv.c index 517ed8b2f1cb..c55d4f76a5fc 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c @@ -551,6 +551,172 @@ int fbnic_tlv_parser_error(void *opaque, struct fbnic= _tlv_msg **results) return -EBADMSG; } +#define FBNIC_TLV_TEST_STRING_LEN 32 + +struct fbnic_tlv_test { + u64 test_u64; + s64 test_s64; + u32 test_u32; + s32 test_s32; + u16 test_u16; + s16 test_s16; + u8 test_mac[ETH_ALEN]; + u8 test_mac_array[4][ETH_ALEN]; + u8 test_true; + u8 test_false; + char test_string[FBNIC_TLV_TEST_STRING_LEN]; +}; + +static struct fbnic_tlv_test test_struct; + +const struct fbnic_tlv_index fbnic_tlv_test_index[] =3D { + FBNIC_TLV_ATTR_U64(FBNIC_TLV_TEST_MSG_U64), + FBNIC_TLV_ATTR_S64(FBNIC_TLV_TEST_MSG_S64), + FBNIC_TLV_ATTR_U32(FBNIC_TLV_TEST_MSG_U32), + FBNIC_TLV_ATTR_S32(FBNIC_TLV_TEST_MSG_S32), + FBNIC_TLV_ATTR_U32(FBNIC_TLV_TEST_MSG_U16), + FBNIC_TLV_ATTR_S32(FBNIC_TLV_TEST_MSG_S16), + FBNIC_TLV_ATTR_MAC_ADDR(FBNIC_TLV_TEST_MSG_MAC_ADDR), + FBNIC_TLV_ATTR_FLAG(FBNIC_TLV_TEST_MSG_FLAG_TRUE), + FBNIC_TLV_ATTR_FLAG(FBNIC_TLV_TEST_MSG_FLAG_FALSE), + FBNIC_TLV_ATTR_STRING(FBNIC_TLV_TEST_MSG_STRING, + FBNIC_TLV_TEST_STRING_LEN), + FBNIC_TLV_ATTR_ARRAY(FBNIC_TLV_TEST_MSG_ARRAY), + FBNIC_TLV_ATTR_NESTED(FBNIC_TLV_TEST_MSG_NESTED), + FBNIC_TLV_ATTR_LAST +}; + +static void fbnic_tlv_test_struct_init(void) +{ + int i =3D FBNIC_TLV_TEST_STRING_LEN - 1; + + /* Populate the struct with random data */ + get_random_once(&test_struct, + offsetof(struct fbnic_tlv_test, test_string) + i); + + /* Force true/false to their expected values */ + test_struct.test_false =3D false; + test_struct.test_true =3D true; + + /* Convert test_string to a true ASCII string */ + test_struct.test_string[i] =3D '\0'; + while (i--) { + /* Force characters into displayable range */ + if (test_struct.test_string[i] < 64 || + test_struct.test_string[i] >=3D 96) { + test_struct.test_string[i] %=3D 32; + test_struct.test_string[i] +=3D 64; + } + } +} + +static int fbnic_tlv_test_attr_data(struct fbnic_tlv_msg *msg) +{ + struct fbnic_tlv_msg *array; + int err, i; + + err =3D fbnic_tlv_attr_put_int(msg, FBNIC_TLV_TEST_MSG_U64, + test_struct.test_u64); + if (err) + return err; + + err =3D fbnic_tlv_attr_put_int(msg, FBNIC_TLV_TEST_MSG_S64, + test_struct.test_s64); + if (err) + return err; + + err =3D fbnic_tlv_attr_put_int(msg, FBNIC_TLV_TEST_MSG_U32, + test_struct.test_u32); + if (err) + return err; + + err =3D fbnic_tlv_attr_put_int(msg, FBNIC_TLV_TEST_MSG_S32, + test_struct.test_s32); + if (err) + return err; + + err =3D fbnic_tlv_attr_put_int(msg, FBNIC_TLV_TEST_MSG_U16, + test_struct.test_u16); + if (err) + return err; + + err =3D fbnic_tlv_attr_put_int(msg, FBNIC_TLV_TEST_MSG_S16, + test_struct.test_s16); + if (err) + return err; + + err =3D fbnic_tlv_attr_put_value(msg, FBNIC_TLV_TEST_MSG_MAC_ADDR, + test_struct.test_mac, ETH_ALEN); + if (err) + return err; + + /* Start MAC address array */ + array =3D fbnic_tlv_attr_nest_start(msg, FBNIC_TLV_TEST_MSG_ARRAY); + if (!array) + return -ENOSPC; + + for (i =3D 0; i < 4; i++) { + err =3D fbnic_tlv_attr_put_value(array, + FBNIC_TLV_TEST_MSG_MAC_ADDR, + test_struct.test_mac_array[i], + ETH_ALEN); + if (err) + return err; + } + + /* Close array */ + fbnic_tlv_attr_nest_stop(msg); + + err =3D fbnic_tlv_attr_put_flag(msg, FBNIC_TLV_TEST_MSG_FLAG_TRUE); + if (err) + return err; + + return fbnic_tlv_attr_put_string(msg, FBNIC_TLV_TEST_MSG_STRING, + test_struct.test_string); +} + +/** + * fbnic_tlv_test_create - Allocate a test message and fill it w/ data + * @fbd: FBNIC device structure + * + * Return: NULL on failure to allocate or pointer to new TLV test message. + **/ +struct fbnic_tlv_msg *fbnic_tlv_test_create(struct fbnic_dev *fbd) +{ + struct fbnic_tlv_msg *msg, *nest; + int err; + + msg =3D fbnic_tlv_msg_alloc(FBNIC_TLV_MSG_ID_TEST); + if (!msg) + return NULL; + + /* Randomize struct data */ + fbnic_tlv_test_struct_init(); + + /* Add first level of data to message */ + err =3D fbnic_tlv_test_attr_data(msg); + if (err) + goto free_message; + + /* Start second level nested */ + nest =3D fbnic_tlv_attr_nest_start(msg, FBNIC_TLV_TEST_MSG_NESTED); + if (!nest) + goto free_message; + + /* Add nested data */ + err =3D fbnic_tlv_test_attr_data(nest); + if (err) + goto free_message; + + /* Close nest and report full message */ + fbnic_tlv_attr_nest_stop(msg); + + return msg; +free_message: + free_page((unsigned long)msg); + return NULL; +} + void fbnic_tlv_attr_addr_copy(u8 *dest, struct fbnic_tlv_msg *src) { u8 *mac_addr; @@ -558,3 +724,113 @@ void fbnic_tlv_attr_addr_copy(u8 *dest, struct fbnic_= tlv_msg *src) mac_addr =3D fbnic_tlv_attr_get_value_ptr(src); memcpy(dest, mac_addr, ETH_ALEN); } + +/** + * fbnic_tlv_parser_test_attr - Function loading test attributes into stru= cture + * @str: Test structure to load + * @results: Pointer to results array + * + * Copies attributes into structure. Any attribute that doesn't exist in t= he + * results array is not populated. + **/ +static void fbnic_tlv_parser_test_attr(struct fbnic_tlv_test *str, + struct fbnic_tlv_msg **results) +{ + struct fbnic_tlv_msg *array_results[4]; + struct fbnic_tlv_msg *attr; + char *string =3D NULL; + int i, err; + + str->test_u64 =3D fta_get_uint(results, FBNIC_TLV_TEST_MSG_U64); + str->test_u32 =3D fta_get_uint(results, FBNIC_TLV_TEST_MSG_U32); + str->test_u16 =3D fta_get_uint(results, FBNIC_TLV_TEST_MSG_U16); + + str->test_s64 =3D fta_get_sint(results, FBNIC_TLV_TEST_MSG_S64); + str->test_s32 =3D fta_get_sint(results, FBNIC_TLV_TEST_MSG_S32); + str->test_s16 =3D fta_get_sint(results, FBNIC_TLV_TEST_MSG_S16); + + attr =3D results[FBNIC_TLV_TEST_MSG_MAC_ADDR]; + if (attr) + fbnic_tlv_attr_addr_copy(str->test_mac, attr); + + attr =3D results[FBNIC_TLV_TEST_MSG_ARRAY]; + if (attr) { + int len =3D le16_to_cpu(attr->hdr.len) / sizeof(u32) - 1; + + err =3D fbnic_tlv_attr_parse_array(&attr[1], len, + array_results, + fbnic_tlv_test_index, + FBNIC_TLV_TEST_MSG_MAC_ADDR, + 4); + if (!err) { + for (i =3D 0; i < 4 && array_results[i]; i++) + fbnic_tlv_attr_addr_copy(str->test_mac_array[i], + array_results[i]); + } + } + + str->test_true =3D !!results[FBNIC_TLV_TEST_MSG_FLAG_TRUE]; + str->test_false =3D !!results[FBNIC_TLV_TEST_MSG_FLAG_FALSE]; + + attr =3D results[FBNIC_TLV_TEST_MSG_STRING]; + if (attr) { + string =3D fbnic_tlv_attr_get_value_ptr(attr); + strscpy(str->test_string, string, FBNIC_TLV_TEST_STRING_LEN); + } +} + +static void fbnic_tlv_test_dump(struct fbnic_tlv_test *value, char *prefix) +{ + print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET, 16, 1, + value, sizeof(*value), true); +} + +/** + * fbnic_tlv_parser_test - Function for parsing and testing test message + * @opaque: Unused value + * @results: Results of parser output + * + * Return: negative value on error, or 0 on success. + * + * Parses attributes to structures and compares the structure to the + * expected test value that should have been used to populate the message. + * + * Used to verify message generation and parser are working correctly. + **/ +int fbnic_tlv_parser_test(void *opaque, struct fbnic_tlv_msg **results) +{ + struct fbnic_tlv_msg *nest_results[FBNIC_TLV_RESULTS_MAX] =3D { 0 }; + struct fbnic_tlv_test result_struct; + struct fbnic_tlv_msg *attr; + int err; + + memset(&result_struct, 0, sizeof(result_struct)); + fbnic_tlv_parser_test_attr(&result_struct, results); + + if (memcmp(&test_struct, &result_struct, sizeof(test_struct))) { + fbnic_tlv_test_dump(&result_struct, "fbnic: found - "); + fbnic_tlv_test_dump(&test_struct, "fbnic: expected - "); + return -EINVAL; + } + + attr =3D results[FBNIC_TLV_TEST_MSG_NESTED]; + if (!attr) + return -EINVAL; + + err =3D fbnic_tlv_attr_parse(&attr[1], + le16_to_cpu(attr->hdr.len) / sizeof(u32) - 1, + nest_results, fbnic_tlv_test_index); + if (err) + return err; + + memset(&result_struct, 0, sizeof(result_struct)); + fbnic_tlv_parser_test_attr(&result_struct, nest_results); + + if (memcmp(&test_struct, &result_struct, sizeof(test_struct))) { + fbnic_tlv_test_dump(&result_struct, "fbnic: found - "); + fbnic_tlv_test_dump(&test_struct, "fbnic: expected - "); + return -EINVAL; + } + + return 0; +} diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h b/drivers/net/ethe= rnet/meta/fbnic/fbnic_tlv.h index 3508b46ebdd0..ee663a03b2aa 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h @@ -8,6 +8,7 @@ #include #include #include +struct fbnic_dev; #define FBNIC_TLV_MSG_ALIGN(len) ALIGN(len, sizeof(u32)) #define FBNIC_TLV_MSG_SIZE(len) \ @@ -153,6 +154,31 @@ int fbnic_tlv_parser_error(void *opaque, struct fbnic_= tlv_msg **results); #define fta_get_str(_results, _id, _dst, _dstsize) \ fbnic_tlv_attr_get_string(_results[_id], _dst, _dstsize) +#define FBNIC_TLV_MSG_ID_TEST 0 + +enum fbnic_tlv_test_attr_id { + FBNIC_TLV_TEST_MSG_U64, + FBNIC_TLV_TEST_MSG_S64, + FBNIC_TLV_TEST_MSG_U32, + FBNIC_TLV_TEST_MSG_S32, + FBNIC_TLV_TEST_MSG_U16, + FBNIC_TLV_TEST_MSG_S16, + FBNIC_TLV_TEST_MSG_MAC_ADDR, + FBNIC_TLV_TEST_MSG_FLAG_TRUE, + FBNIC_TLV_TEST_MSG_FLAG_FALSE, + FBNIC_TLV_TEST_MSG_STRING, + FBNIC_TLV_TEST_MSG_NESTED, + FBNIC_TLV_TEST_MSG_ARRAY, + FBNIC_TLV_TEST_MSG_MAX +}; + +extern const struct fbnic_tlv_index fbnic_tlv_test_index[]; +struct fbnic_tlv_msg *fbnic_tlv_test_create(struct fbnic_dev *fbd); +int fbnic_tlv_parser_test(void *opaque, struct fbnic_tlv_msg **results); + +#define FBNIC_TLV_MSG_TEST \ + FBNIC_TLV_PARSER(TEST, fbnic_tlv_test_index, \ + fbnic_tlv_parser_test) #define FBNIC_TLV_MSG_ERROR \ FBNIC_TLV_PARSER(UNKNOWN, NULL, fbnic_tlv_parser_error) #endif /* _FBNIC_TLV_H_ */ -- 2.43.0 From nobody Sat Feb 7 17:49:07 2026 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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 793D32E091B for ; Fri, 6 Feb 2026 15:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392575; cv=none; b=J0/XOB1ng3rgsobMgDK9/ZqfwUlFF2xEMcTjuL87CB6NwD0YlOWahFptsRpF84cd9T/wzR3IkSrO7ATWfrqhgFtmaky+gCnYIsxZxEvwSMhbLziGEEG0UpgemnZ+CMxIOBujcCYkxbsfxgDH/H9qS3ElF8icZcQAb2fJaWCPZv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770392575; c=relaxed/simple; bh=gUufKabp52w0cEl5iOG80SMMxhThKKEKi0gMp23tmE8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z0EjsXyQn4IIFtxJ/874g40C+rMcLnPbWA7TGbIbgiKvlKGt3zTa0tEZacpDP14f9xCYKU3zAniuDfURjnJBMMQJqYRqZkSb6AExtFdPCzXrrgIUdYpswA7xP4D/rYXs0Hn446uPpn6XQhDtdN7pBQxBP1oitz+qxccZrG88c4w= 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=KKSQ2m4V; arc=none smtp.client-ip=209.85.219.51 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="KKSQ2m4V" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-895341058b1so10125286d6.3 for ; Fri, 06 Feb 2026 07:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770392574; x=1770997374; 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=hD+rNwMUIX3Jn1r3ZokuEe2+nahxokzufdjdWGwdbJ8=; b=KKSQ2m4Vk2O+3T5D8NefaV3JLXBxD6SlNcEIWrswlrOQnWw/PdQsy7V3l/NrFZFcW3 HXAsa6mgWeYCc62GUL709AoLVTBdZkRYkbJ0s/0mFowyKtgOKHtKDQyRLfnRzCDxa92p +EKEHaG2gSbh9BO/4orCWQwVwu40adugrUBxnllEtx9MUTc+Oyi4jO2kSW8UOublYS7y PxlYdPXUCGomUbxGJy7vsvjewH/OWSipUWY4bKgDR6luzVWkrguxfcS1F0FvNIUogBkm oYfdPdaABSq/7+b3yfSh6P8AmZAZ8xW8IOGBD3m/Iqn+NEnuDc2Sqvvh/ZcwPRVRxnIG TOuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770392574; x=1770997374; 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=hD+rNwMUIX3Jn1r3ZokuEe2+nahxokzufdjdWGwdbJ8=; b=oDI59vi6Kb1Ww2TFa9o3vcvGBLg3ceNkkjJuw9zuTQuWp2V4ZH3ZhOKD6riCNmmmgn mx02oX0wBEkc9RttUAaQUc5gS4wUvo2nffkJn3rUT4lFvbTR5JnNg3hCorc8E4iaqkGK LBT7j7hLk1KorE1peE/5mYqvfchsXJT0MIJXwgoCYz8IttC2l6EOSELFOXsQE2jjX3LT lKSp1vm60Bb8MvQLJ7tv6PPlvhf6UT3wxlQll3c5JPOKfN+3Pmy+eLjIo1PwMQ/AlNIF ZlZ5uzt5++Cab0UNahkheDCF/GsKLOoWfvZS5pZ9mmGTmos/RsbOoHbVgyUVmi+oUiSY HrAg== X-Forwarded-Encrypted: i=1; AJvYcCWcJebTQw6ZAAlulqTIyk5FqvUgpidvGD5dOkBoy+5DNhSZ6MnWE5ZD2OvRNhSiIBq+2pvRf+XYnjyuWSk=@vger.kernel.org X-Gm-Message-State: AOJu0YyzFSJWyL1h7F4V/zbNXS//Ddjuu9Nf8MTBEUDpqRCGj/g+sQ4l cijfUlZayzUSudVHt+oGqkmq4bifxAeJYN10SA7VNK0Qz0kmBtNj5v1Q X-Gm-Gg: AZuq6aI953DKduGuNI9RK7W32BM5D7ATRzFpw5/UITjqBI0QeHau3GYd2P4qJNlwjcD TGZZXiFjRSoVeqEnynmeIZKr8zw1CqjaVIHL00xmxRV3madrRT5/UTnSoaF8rXrM5iDlFp0mLlh hWMHLvOiyJv56c5U8iu2AuiXu5+m8MKo/xQNaWvGMJCpvSsbjCUcdQluTY3+mgAq9y6rilxd3qU 1/R/kBdyNPR0k7vaq87tS3uJOdxP0Thvc+JVLj+AhZxeWmScU+/bzhyiCfBy5uEfd69ouruT0J6 UYuzW5aRSU4WRmFMAL6N+WvcBbE4scbLRbyIEi7Y4XuGYW3UNXS8T/mmcddnJfDnGhLhVpRZAIj nyWUk3kjqdznJmyrIi01E95UDMKnWEFaqjpNJC7Pa3xFBv7SYoDtKjoaB7/00coBYfs6PwgdyHr qYtu3GuioHe0oQf6S6G7tvttV293gUw9jmtoByrAVLSIPv X-Received: by 2002:a05:6214:9b4:b0:895:47ee:2b86 with SMTP id 6a1803df08f44-89547ee2d22mr1370846d6.67.1770392574372; Fri, 06 Feb 2026 07:42:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 07:42:54 -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 5/5] eth fbnic: Add mailbox self test Date: Fri, 6 Feb 2026 10:42:45 -0500 Message-ID: <20260206154246.814-6-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)" The mailbox self test ensures the interface to and from the firmware is healthy by sending a test message and fielding the response from the firmware. This patch uses the new completion API [1][2] that allocates a completion structure, binds the completion to the TEST message, and uses a new FW parsing routine that wraps the completion processing around the TLV parser. Link: https://patch.msgid.link/20250516164804.741348-1-lee@trager.us [1] Link: https://patch.msgid.link/20260115003353.4150771-6-mohsin.bashr@gmail.= com [2] Signed-off-by: Mike Marciniszyn (Meta) --- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 15 +++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 92 +++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 3 + 3 files changed, 110 insertions(+) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/= ethernet/meta/fbnic/fbnic_ethtool.c index b0c8d1b069e2..251de64baa5a 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c @@ -129,11 +129,13 @@ static const struct fbnic_stat fbnic_gstrings_xdp_sta= ts[] =3D { enum fbnic_self_test_results { TEST_REG =3D 0, TEST_MSIX, + TEST_MBX, }; 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)", + [TEST_MBX] =3D "FW mailbox test (on/offline)", }; #define FBNIC_TEST_LEN ARRAY_SIZE(fbnic_gstrings_self_test) @@ -1525,11 +1527,24 @@ static int fbnic_ethtool_msix_test(struct net_devic= e *netdev, u64 *data) return !!*data; } +static int fbnic_ethtool_mbx_self_test(struct net_device *netdev, u64 *dat= a) +{ + struct fbnic_net *fbn =3D netdev_priv(netdev); + struct fbnic_dev *fbd =3D fbn->fbd; + + *data =3D fbnic_fw_mbx_self_test(fbd); + + return !!*data; +} + static void fbnic_self_test(struct net_device *netdev, struct ethtool_test *eth_test, u64 *data) { bool if_running =3D netif_running(netdev); + if (fbnic_ethtool_mbx_self_test(netdev, &data[TEST_MBX])) + eth_test->flags |=3D ETH_TEST_FL_FAILED; + if (!(eth_test->flags & ETH_TEST_FL_OFFLINE)) { data[TEST_REG] =3D 0; data[TEST_MSIX] =3D 0; diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c b/drivers/net/ether= net/meta/fbnic/fbnic_fw.c index 1f0b6350bef4..0fb8dc9091ca 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c +++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.c @@ -378,6 +378,37 @@ fbnic_fw_get_cmpl_by_type(struct fbnic_dev *fbd, u32 m= sg_type) return cmpl_data; } +/** + * fbnic_fw_xmit_test_msg - Create and transmit a test message to FW mailb= ox + * @fbd: FBNIC device structure + * @cmpl: fw completion struct + * + * Return: zero on success, negative value on failure + * + * Generates a single page mailbox test message and places it in the Tx + * mailbox queue. Expectation is that the FW will validate that the nested + * value matches the external values, and then will echo them back to us. + * + * Also sets a completion slot for use in the completion wait calls when + * the cmpl arg is non-NULL. + */ +int fbnic_fw_xmit_test_msg(struct fbnic_dev *fbd, + struct fbnic_fw_completion *cmpl) +{ + struct fbnic_tlv_msg *test_msg; + int err; + + test_msg =3D fbnic_tlv_test_create(fbd); + if (!test_msg) + return -ENOMEM; + + err =3D fbnic_mbx_map_req_w_cmpl(fbd, test_msg, cmpl); + if (err) + free_page((unsigned long)test_msg); + + return err; +} + /** * fbnic_fw_xmit_simple_msg - Transmit a simple single TLV message w/o data * @fbd: FBNIC device structure @@ -1556,7 +1587,29 @@ int fbnic_fw_xmit_send_logs(struct fbnic_dev *fbd, b= ool enable, return err; } +static int +fbnic_fw_parser_test(void *opaque, struct fbnic_tlv_msg **results) +{ + struct fbnic_fw_completion *cmpl; + struct fbnic_dev *fbd =3D opaque; + int err; + + /* find cmpl */ + cmpl =3D fbnic_fw_get_cmpl_by_type(fbd, FBNIC_TLV_MSG_ID_TEST); + if (!cmpl) + return -ENOSPC; + + err =3D fbnic_tlv_parser_test(opaque, results); + + cmpl->result =3D err; + complete(&cmpl->done); + fbnic_fw_put_cmpl(cmpl); + + return err; +} + static const struct fbnic_tlv_parser fbnic_fw_tlv_parser[] =3D { + FBNIC_TLV_PARSER(TEST, fbnic_tlv_test_index, fbnic_fw_parser_test), FBNIC_TLV_PARSER(FW_CAP_RESP, fbnic_fw_cap_resp_index, fbnic_fw_parse_cap_resp), FBNIC_TLV_PARSER(OWNERSHIP_RESP, fbnic_ownership_resp_index, @@ -1787,6 +1840,45 @@ void fbnic_mbx_flush_tx(struct fbnic_dev *fbd) } while (time_is_after_jiffies(timeout)); } +int fbnic_fw_mbx_self_test(struct fbnic_dev *fbd) +{ + struct fbnic_fw_completion *cmpl; + int err; + + /* Skip test if FW interface is not present */ + if (!fbnic_fw_present(fbd)) + return 10; + + cmpl =3D fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_TEST); + if (!cmpl) + return 20; + + /* Load a test message onto the FW mailbox interface + * and arm the completion. + */ + err =3D fbnic_fw_xmit_test_msg(fbd, cmpl); + if (err) { + err =3D 30; + goto exit_free; + } + + /* Verify we received a message back */ + if (!fbnic_mbx_wait_for_cmpl(cmpl)) { + err =3D 40; + goto exit_cleanup; + } + + /* Verify there were no parsing errors */ + if (cmpl->result) + err =3D 50; +exit_cleanup: + fbnic_mbx_clear_cmpl(fbd, cmpl); +exit_free: + fbnic_fw_put_cmpl(cmpl); + + return err; +} + int fbnic_fw_xmit_rpc_macda_sync(struct fbnic_dev *fbd) { struct fbnic_tlv_msg *mac_array; diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_fw.h b/drivers/net/ether= net/meta/fbnic/fbnic_fw.h index 8f7218900562..054d8f104486 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.h @@ -104,6 +104,9 @@ void fbnic_mbx_clear_cmpl(struct fbnic_dev *fbd, void fbnic_mbx_poll(struct fbnic_dev *fbd); int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd); void fbnic_mbx_flush_tx(struct fbnic_dev *fbd); +int fbnic_fw_mbx_self_test(struct fbnic_dev *fbd); +int fbnic_fw_xmit_test_msg(struct fbnic_dev *fbd, + struct fbnic_fw_completion *c); int fbnic_fw_xmit_ownership_msg(struct fbnic_dev *fbd, bool take_ownership= ); int fbnic_fw_init_heartbeat(struct fbnic_dev *fbd, bool poll); void fbnic_fw_check_heartbeat(struct fbnic_dev *fbd); -- 2.43.0