From nobody Thu Apr 9 17:58:04 2026 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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 82EBE34A76F for ; Sat, 7 Mar 2026 10:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772881141; cv=none; b=OiZrtB7r/USB8OvmOkBGkOqznpbBZq16txg6S2qC0e+FukQtI1tYx6c6BzHOJVydgfHwUDbzlM3Xnw5Gp9Jm80MdKsnWpGPie+NJpXpaxiT2gRT+y7UN7VQLI0HZj8c8Wwxr7zIbgFobHA0NRdVIZtgHaelTcaMy01mzSYHNeJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772881141; c=relaxed/simple; bh=FDd2xI8Jd7D9gB0fKiSlbyHiTNXBNZ0++jcrlUyV+Ts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T44NF0X8dCJn2BAq8GhTbs+60HYnPD5fj2eTILxaspEZ+8k4bVAjQ4+z9LHmFncK5YLUwm0aSYhxLvSTFgfCGnaI9md8ycAUhaWWq/yWOqSjgvQ/9rT24Q/IpBNG0kbejGJGqTE1OiwG5pgpqsRgYuPrQtedmZOiOCzLsBcW5aM= 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=UveXsbBq; arc=none smtp.client-ip=209.85.222.176 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="UveXsbBq" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-8cd722c2923so138530485a.1 for ; Sat, 07 Mar 2026 02:58:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772881137; x=1773485937; 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=YWqt7jbBjf5NmoQedgg0t/HNcW4ltoXPePYOrcGOf0c=; b=UveXsbBq9n1AIxvHpcbSZcWpFZMk6sJRt8LK9yjHXD75E84Xjq3GksYdQi/KF1fG/j yx00sIhZRJP3XI0QRdYq4FfziQuGYc7IhQpCP1UvD4vsqPkDgwaKkO/SAK6Illwbl9GD f34by7Qrap9P6RY8zy8t7O1zHj009hp3ghTitE559Ecrizplq5GVIWJRVRl9opOnRNA+ P5+U6QEz3tpuqaFlocG2Yzn8NEUZGPSCFT3fNy3BlejUpWoKYlfEZcwas+NPS0LlDJ/a Yc5fP/K7TEZOTsnGSM7DsFdVKcP1RiCb49gtnyEYFcUiPBBTNBIkmn2JMF64EMrLE25R Zemw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772881137; x=1773485937; 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=YWqt7jbBjf5NmoQedgg0t/HNcW4ltoXPePYOrcGOf0c=; b=P6Qjzc7jHavZB8MFVns9QyHgp8BvLms04h5ISs0Oy8L3EnybwzK2/cOOTlM9kb9pns kIPKqL5sqDMUsSL/selEmLNbxbfnlRtvR0wh5QZi42/jMqVu4Z+4I573kkuuZBo2NQdH q1E5M833vg+NHf2spBiGfsdiAkCrL8L0896WW93kQFONIHaQykK4Pbmdx7np4SxkSE66 ljFwLvZaGSPTuhF7KWZWasCOQhLMQ7EQBRos8yKBIATke5ul1wRfGG9z8brLddP5AQB/ nfxHQZhNNbDmxsOM1s4rkl4Ia0WqcyN6ArPjndzdLuFyTXv94Lpy5F30lLXnYEjXrWv5 KugQ== X-Forwarded-Encrypted: i=1; AJvYcCUncIKMD/Ik/okhXpsJ7yWCh1DtEtKBLlFfo35GbfXcvpYag1hmWwlP3UXMVHrJwT67qKi/vbiARvyNej0=@vger.kernel.org X-Gm-Message-State: AOJu0YyS4mAoltiTXmKjFfRocbjZgBoh45xlTk9w3Rbo3DXJY01xKUH9 XEqLMdN6bnE8atHwmXp4XCXwPwVjtIU0uoZ4phn6Y5RkH2rGhm2tc1xq X-Gm-Gg: ATEYQzx3TuIpSZLYLGGaaILs3yjXjA70PYd/l+FYaEcotBkibojcNG+zq4TIRbcl+o0 Yl23UDNVwzo7JunC0LepvH9fE7dNaeOMgSQ7wWOldlr9I4vlIO+QZ191KQD+vIXvjKxdgHwQMae OrsojXYNt1z/HPETpMuiOY6YbhBK0nHmL18tV2GgK34J6kvJ04SYSXVi02hdz6tMQ1qm5ES2b/F a2TwSKH//zCoY+zUWnwx2OeOtpuOUrZGlObpx5ZYvNa07nCl0jct4TZaNbkgTmvsE7JW1rVsHV3 2m0GP6CA3XOWq419mNVqt/TAU3Vyz6SdSTwlAuQZY102IPNLROHEJNkjZHxw2ZwfWWqFFXacv4L fFj7UXcsj1v3vuFUpkOZea1znYGr6YGup0Eez8uPhEqwZLCiHI5EpGR1jBr+7hb+xlaeSQrgCiM udF26wlFje2CvKwBhhPsDeDB8nmJpYUYPbIJR8ya2w4NprbFlcXzO8U7rc3TT0gFTz8pU= X-Received: by 2002:a05:620a:2549:b0:89f:8bb8:c103 with SMTP id af79cd13be357-8cd6d4b4f11mr640784885a.49.1772881137186; Sat, 07 Mar 2026 02:58:57 -0800 (PST) Received: from PF5YBGDS.localdomain ([163.114.130.7]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cd6f4a2fdasm293278485a.17.2026.03.07.02.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 02:58:56 -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 , Dan Carpenter , Pei Xiao , Stanislav Fomichev , Kuniyuki Iwashima , Samiullah Khawaja , Hangbin Liu Cc: mike.marciniszyn@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 5/5] eth fbnic: Add mailbox self test Date: Sat, 7 Mar 2026 05:58:47 -0500 Message-ID: <20260307105847.1438-6-mike.marciniszyn@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260307105847.1438-1-mike.marciniszyn@gmail.com> References: <20260307105847.1438-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) --- v2 - add enum for test return codes v3 - no changes v4 - no changes drivers/net/ethernet/meta/fbnic/fbnic.h | 14 ++- .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 15 +++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 100 ++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 27 +++++ 3 files changed, 142 insertions(+) diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/= ethernet/meta/fbnic/fbnic_ethtool.c index b5012601b102..f14de2366854 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, }; =20 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)", }; =20 #define FBNIC_TEST_LEN ARRAY_SIZE(fbnic_gstrings_self_test) @@ -1528,11 +1530,24 @@ static int fbnic_ethtool_msix_test(struct net_devic= e *netdev, u64 *data) return !!*data; } =20 +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); =20 + 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..c2bad51bdde6 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; } =20 +/** + * 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; } =20 +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,53 @@ void fbnic_mbx_flush_tx(struct fbnic_dev *fbd) } while (time_is_after_jiffies(timeout)); } =20 +/** + * fbnic_fw_mbx_self_test() - verify firmware interface + * @fbd: device to test + * + * This function tests the interfaces to/from the firmware. + * + * Return: See enum fbnic_fw_self_test_codes + **/ +enum fbnic_fw_self_test_codes fbnic_fw_mbx_self_test(struct fbnic_dev *fbd) +{ + enum fbnic_fw_self_test_codes err; + struct fbnic_fw_completion *cmpl; + + /* Skip test if FW interface is not present */ + if (!fbnic_fw_present(fbd)) + return FBNIC_TEST_FW_NO_FIRMWARE; + + cmpl =3D fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_TEST); + if (!cmpl) + return FBNIC_TEST_FW_NO_CMPL; + + /* 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 FBNIC_TEST_FW_NO_XMIT; + goto exit_free; + } + + /* Verify we received a message back */ + if (!fbnic_mbx_wait_for_cmpl(cmpl)) { + err =3D FBNIC_TEST_FW_NO_MSG; + goto exit_cleanup; + } + + /* Verify there were no parsing errors */ + if (cmpl->result) + err =3D FBNIC_TEST_FW_PARSE; +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..d84723e4cfa3 100644 --- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.h +++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.h @@ -104,6 +104,33 @@ 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); + +/** + * enum fbnic_fw_self_test_codes - return codes from self test routines + * + * These are the codes returned from the self test routines and + * stored in the test result array indexed by the specific + * test name. + * + * @FBNIC_TEST_FW_SUCCESS: test success + * @FBNIC_TEST_FW_NO_FIRMWARE: FW interface not present + * @FBNIC_TEST_FW_NO_CMPL: No completion available + * @FBNIC_TEST_FW_NO_XMIT: Could not xmit message + * @FBNIC_TEST_FW_NO_MSG: no message returned + * @FBNIC_TEST_FW_PARSE: returned message had parsing error + */ +enum fbnic_fw_self_test_codes { + FBNIC_TEST_FW_SUCCESS =3D 0, + FBNIC_TEST_FW_NO_FIRMWARE =3D 10, + FBNIC_TEST_FW_NO_CMPL =3D 20, + FBNIC_TEST_FW_NO_XMIT =3D 30, + FBNIC_TEST_FW_NO_MSG =3D 40, + FBNIC_TEST_FW_PARSE =3D 50, +}; + +enum fbnic_fw_self_test_codes 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); --=20 2.43.0