From nobody Mon Feb 9 00:20:30 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