net: txgbe: Restrict the use of mismatched FW versions
authorJiawen Wu <jiawenwu@trustnetic.com>
Wed, 21 May 2025 06:44:00 +0000 (14:44 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Mon, 26 May 2025 15:25:42 +0000 (17:25 +0200)
The new added mailbox commands require a new released firmware version.
Otherwise, a lot of logs "Unknown FW command" would be printed. And the
devices may not work properly. So add the test command in the probe
function.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/18283F17BE0FA335+20250521064402.22348-8-jiawenwu@trustnetic.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.h
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c

index af12ebb89c71a74765b0569fa50f99b9b86849a7..83b3830217909c3dd625a95946315fdef0874783 100644 (file)
@@ -50,6 +50,22 @@ irqreturn_t txgbe_gpio_irq_handler_aml(int irq, void *data)
        return IRQ_HANDLED;
 }
 
+int txgbe_test_hostif(struct wx *wx)
+{
+       struct txgbe_hic_ephy_getlink buffer;
+
+       if (wx->mac.type != wx_mac_aml)
+               return 0;
+
+       buffer.hdr.cmd = FW_PHY_GET_LINK_CMD;
+       buffer.hdr.buf_len = sizeof(struct txgbe_hic_ephy_getlink) -
+                            sizeof(struct wx_hic_hdr);
+       buffer.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
+
+       return wx_host_interface_command(wx, (u32 *)&buffer, sizeof(buffer),
+                                       WX_HI_COMMAND_TIMEOUT, true);
+}
+
 static int txgbe_identify_sfp_hostif(struct wx *wx, struct txgbe_hic_i2c_read *buffer)
 {
        buffer->hdr.cmd = FW_READ_SFP_INFO_CMD;
index 2376a021ba8dfaa3c6edf1315a607f7241cd1399..25d4971ca0d911cfcd44a323ecc0000d8487f0aa 100644 (file)
@@ -6,6 +6,7 @@
 
 void txgbe_gpio_init_aml(struct wx *wx);
 irqreturn_t txgbe_gpio_irq_handler_aml(int irq, void *data);
+int txgbe_test_hostif(struct wx *wx);
 int txgbe_set_phy_link(struct wx *wx);
 int txgbe_identify_sfp(struct wx *wx);
 void txgbe_setup_link(struct wx *wx);
index 6f3b67def51a0c937a97559a61a5b3dc70c82485..f3d2778b8e35620c827d0e7a3dc081e8fbae4562 100644 (file)
@@ -864,6 +864,13 @@ static int txgbe_probe(struct pci_dev *pdev,
        if (etrack_id < 0x20010)
                dev_warn(&pdev->dev, "Please upgrade the firmware to 0x20010 or above.\n");
 
+       err = txgbe_test_hostif(wx);
+       if (err != 0) {
+               dev_err(&pdev->dev, "Mismatched Firmware version\n");
+               err = -EIO;
+               goto err_release_hw;
+       }
+
        txgbe = devm_kzalloc(&pdev->dev, sizeof(*txgbe), GFP_KERNEL);
        if (!txgbe) {
                err = -ENOMEM;