]> git.feebdaed.xyz Git - 0xmirror/dpdk.git/commitdiff
net/txgbe: fix mailbox interface calls
authorJiawen Wu <jiawenwu@trustnetic.com>
Wed, 26 Nov 2025 08:56:49 +0000 (16:56 +0800)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 27 Nov 2025 17:52:51 +0000 (18:52 +0100)
For different devices, the mailbox flow between software and firmware is
different. There are several mailbox commands in the txgbe driver, but only
txgbe_hic_sr_read() was changed to use the new flow.

It leads to other mailbox commands timeout for Amber-Lite devices, which
is required to use the new flow. So this patch fills in the missing part.

For the sake of code tidy, txgbe_hic_sr_read() should change to use the
locked function txgbe_host_interface_command(), and this function could
be change to pointer in struct txgbe_mbx_info for different devices.

Fixes: 6a139ade82e7 ("net/txgbe: add new SW-FW mailbox interface")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
drivers/net/txgbe/base/txgbe_aml.c
drivers/net/txgbe/base/txgbe_aml40.c
drivers/net/txgbe/base/txgbe_eeprom.c
drivers/net/txgbe/base/txgbe_hw.c
drivers/net/txgbe/base/txgbe_mng.c
drivers/net/txgbe/base/txgbe_mng.h
drivers/net/txgbe/base/txgbe_type.h

index 867cf4c2d356a486ad436a93238e5400db9761dd..b376eca5b54b3b0a03a5d8e717a17d2c8de4be3a 100644 (file)
@@ -17,6 +17,7 @@ void txgbe_init_ops_aml(struct txgbe_hw *hw)
 {
        struct txgbe_mac_info *mac = &hw->mac;
        struct txgbe_phy_info *phy = &hw->phy;
+       struct txgbe_mbx_info *mbx = &hw->mbx;
 
        txgbe_init_ops_generic(hw);
 
@@ -27,6 +28,9 @@ void txgbe_init_ops_aml(struct txgbe_hw *hw)
        mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml;
        mac->get_link_capabilities = txgbe_get_link_capabilities_aml;
        mac->check_link = txgbe_check_mac_link_aml;
+
+       /* FW interaction */
+       mbx->host_interface_command = txgbe_host_interface_command_aml;
 }
 
 s32 txgbe_check_mac_link_aml(struct txgbe_hw *hw, u32 *speed,
index c7d64cade6503fde3283da7a91bcbd3f2e5ed5e5..733bbac13a876299238fb8eb1e53c94b5ce09bfa 100644 (file)
@@ -18,6 +18,7 @@ void txgbe_init_ops_aml40(struct txgbe_hw *hw)
 {
        struct txgbe_mac_info *mac = &hw->mac;
        struct txgbe_phy_info *phy = &hw->phy;
+       struct txgbe_mbx_info *mbx = &hw->mbx;
 
        txgbe_init_ops_generic(hw);
 
@@ -28,6 +29,9 @@ void txgbe_init_ops_aml40(struct txgbe_hw *hw)
        mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml40;
        mac->get_link_capabilities = txgbe_get_link_capabilities_aml40;
        mac->check_link = txgbe_check_mac_link_aml40;
+
+       /* FW interaction */
+       mbx->host_interface_command = txgbe_host_interface_command_aml;
 }
 
 s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed,
index eb53b35a19677ca106bfb07f4f4a9928f8e27975..b1d90f6f6b4974ea1dd17993571b9acc3e96ac28 100644 (file)
@@ -137,7 +137,7 @@ void txgbe_release_eeprom_semaphore(struct txgbe_hw *hw)
 s32 txgbe_ee_read16(struct txgbe_hw *hw, u32 offset,
                              u16 *data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        u32 addr = (offset << 1);
        int err;
 
@@ -164,7 +164,7 @@ s32 txgbe_ee_read16(struct txgbe_hw *hw, u32 offset,
 s32 txgbe_ee_readw_buffer(struct txgbe_hw *hw,
                                     u32 offset, u32 words, void *data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        u32 addr = (offset << 1);
        u32 len = (words << 1);
        u8 *buf = (u8 *)data;
@@ -195,7 +195,7 @@ s32 txgbe_ee_readw_buffer(struct txgbe_hw *hw,
 s32 txgbe_ee_readw_sw(struct txgbe_hw *hw, u32 offset,
                              u16 *data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        u32 addr = hw->rom.sw_addr + (offset << 1);
        int err;
 
@@ -220,7 +220,7 @@ s32 txgbe_ee_readw_sw(struct txgbe_hw *hw, u32 offset,
  **/
 s32 txgbe_ee_read32(struct txgbe_hw *hw, u32 addr, u32 *data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        int err;
 
        err = hw->mac.acquire_swfw_sync(hw, mask);
@@ -245,7 +245,7 @@ s32 txgbe_ee_read32(struct txgbe_hw *hw, u32 addr, u32 *data)
 s32 txgbe_ee_write16(struct txgbe_hw *hw, u32 offset,
                               u16 data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        u32 addr = (offset << 1);
        int err;
 
@@ -272,7 +272,7 @@ s32 txgbe_ee_write16(struct txgbe_hw *hw, u32 offset,
 s32 txgbe_ee_writew_buffer(struct txgbe_hw *hw,
                                      u32 offset, u32 words, void *data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        u32 addr = (offset << 1);
        u32 len = (words << 1);
        u8 *buf = (u8 *)data;
@@ -301,7 +301,7 @@ s32 txgbe_ee_writew_buffer(struct txgbe_hw *hw,
 s32 txgbe_ee_writew_sw(struct txgbe_hw *hw, u32 offset,
                               u16 data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        u32 addr = hw->rom.sw_addr + (offset << 1);
        int err;
 
@@ -326,7 +326,7 @@ s32 txgbe_ee_writew_sw(struct txgbe_hw *hw, u32 offset,
  **/
 s32 txgbe_ee_write32(struct txgbe_hw *hw, u32 addr, u32 data)
 {
-       const u32 mask = TXGBE_MNGSEM_SWMBX | TXGBE_MNGSEM_SWFLASH;
+       const u32 mask = TXGBE_MNGSEM_SWFLASH;
        int err;
 
        err = hw->mac.acquire_swfw_sync(hw, mask);
index 50178868969c8d1122ae9cce58da7ee3fada4343..0f3db3a1ade0fae1c23a0f9382d061eb7fe5829c 100644 (file)
@@ -2998,6 +2998,7 @@ void txgbe_init_ops_sp(struct txgbe_hw *hw)
 {
        struct txgbe_mac_info *mac = &hw->mac;
        struct txgbe_phy_info *phy = &hw->phy;
+       struct txgbe_mbx_info *mbx = &hw->mbx;
 
        txgbe_init_ops_generic(hw);
 
@@ -3008,6 +3009,9 @@ void txgbe_init_ops_sp(struct txgbe_hw *hw)
        mac->init_mac_link_ops = txgbe_init_mac_link_ops_sp;
        mac->get_link_capabilities = txgbe_get_link_capabilities_sp;
        mac->check_link = txgbe_check_mac_link_sp;
+
+       /* FW interaction */
+       mbx->host_interface_command = txgbe_host_interface_command_sp;
 }
 
 /**
index 05eb07c0e28960f39840a0056c362cde012b7acb..a1974820b6061e2531816619c85a94e81efdc1be 100644 (file)
@@ -79,7 +79,7 @@ txgbe_hic_unlocked(struct txgbe_hw *hw, u32 *buffer, u32 length, u32 timeout)
 }
 
 /**
- *  txgbe_host_interface_command - Issue command to manageability block
+ *  txgbe_host_interface_command_sp - Issue command to manageability block
  *  @hw: pointer to the HW structure
  *  @buffer: contains the command to write and where the return status will
  *   be placed
@@ -96,9 +96,9 @@ txgbe_hic_unlocked(struct txgbe_hw *hw, u32 *buffer, u32 length, u32 timeout)
  *  else returns semaphore error when encountering an error acquiring
  *  semaphore or TXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  **/
-static s32
-txgbe_host_interface_command(struct txgbe_hw *hw, u32 *buffer,
-                                u32 length, u32 timeout, bool return_data)
+s32
+txgbe_host_interface_command_sp(struct txgbe_hw *hw, u32 *buffer,
+                               u32 length, u32 timeout, bool return_data)
 {
        u32 hdr_size = sizeof(struct txgbe_hic_hdr);
        struct txgbe_hic_hdr *resp = (struct txgbe_hic_hdr *)buffer;
@@ -160,7 +160,7 @@ rel_out:
        return err;
 }
 
-static s32
+s32
 txgbe_host_interface_command_aml(struct txgbe_hw *hw, u32 *buffer,
                                 u32 length, u32 timeout, bool return_data)
 {
@@ -303,12 +303,8 @@ s32 txgbe_hic_sr_read(struct txgbe_hw *hw, u32 addr, u8 *buf, int len)
        command.address = cpu_to_be32(addr);
        command.length = cpu_to_be16(len);
 
-       if (hw->mac.type == txgbe_mac_aml || hw->mac.type == txgbe_mac_aml40)
-               err = txgbe_host_interface_command_aml(hw, (u32 *)&command,
-                               sizeof(command), TXGBE_HI_COMMAND_TIMEOUT, false);
-       else
-               err = txgbe_hic_unlocked(hw, (u32 *)&command,
-                               sizeof(command), TXGBE_HI_COMMAND_TIMEOUT);
+       err = hw->mbx.host_interface_command(hw, (u32 *)&command,
+                       sizeof(command), TXGBE_HI_COMMAND_TIMEOUT, false);
        if (err)
                return err;
 
@@ -381,7 +377,7 @@ s32 txgbe_close_notify(struct txgbe_hw *hw)
        buffer.length = 0;
        buffer.address = 0;
 
-       status = txgbe_host_interface_command(hw, (u32 *)&buffer,
+       status = hw->mbx.host_interface_command(hw, (u32 *)&buffer,
                                              sizeof(buffer),
                                              TXGBE_HI_COMMAND_TIMEOUT, false);
        if (status)
@@ -411,7 +407,7 @@ s32 txgbe_open_notify(struct txgbe_hw *hw)
        buffer.length = 0;
        buffer.address = 0;
 
-       status = txgbe_host_interface_command(hw, (u32 *)&buffer,
+       status = hw->mbx.host_interface_command(hw, (u32 *)&buffer,
                                              sizeof(buffer),
                                              TXGBE_HI_COMMAND_TIMEOUT, false);
        if (status)
@@ -466,7 +462,7 @@ s32 txgbe_hic_set_drv_ver(struct txgbe_hw *hw, u8 maj, u8 min,
                                (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
 
        for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
-               ret_val = txgbe_host_interface_command(hw, (u32 *)&fw_cmd,
+               ret_val = hw->mbx.host_interface_command(hw, (u32 *)&fw_cmd,
                                                       sizeof(fw_cmd),
                                                       TXGBE_HI_COMMAND_TIMEOUT,
                                                       true);
@@ -511,7 +507,7 @@ txgbe_hic_reset(struct txgbe_hw *hw)
                                (FW_CEM_HDR_LEN + reset_cmd.hdr.buf_len));
 
        for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
-               err = txgbe_host_interface_command(hw, (u32 *)&reset_cmd,
+               err = hw->mbx.host_interface_command(hw, (u32 *)&reset_cmd,
                                                       sizeof(reset_cmd),
                                                       TXGBE_HI_COMMAND_TIMEOUT,
                                                       true);
@@ -568,7 +564,7 @@ s32 txgbe_hic_get_lldp(struct txgbe_hw *hw)
        buffer.hdr.checksum = FW_DEFAULT_CHECKSUM;
        buffer.func = hw->bus.lan_id;
 
-       err = txgbe_host_interface_command(hw, (u32 *)&buffer, sizeof(buffer),
+       err = hw->mbx.host_interface_command(hw, (u32 *)&buffer, sizeof(buffer),
                                           TXGBE_HI_COMMAND_TIMEOUT, true);
        if (err)
                return err;
@@ -599,7 +595,7 @@ s32 txgbe_hic_set_lldp(struct txgbe_hw *hw, bool on)
        buffer.hdr.checksum = FW_DEFAULT_CHECKSUM;
        buffer.func = hw->bus.lan_id;
 
-       return txgbe_host_interface_command(hw, (u32 *)&buffer, sizeof(buffer),
+       return hw->mbx.host_interface_command(hw, (u32 *)&buffer, sizeof(buffer),
                                            TXGBE_HI_COMMAND_TIMEOUT, false);
 }
 
@@ -619,7 +615,7 @@ s32 txgbe_hic_ephy_set_link(struct txgbe_hw *hw, u8 speed, u8 autoneg, u8 duplex
        buffer.duplex = duplex;
 
        for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
-               status = txgbe_host_interface_command(hw, (u32 *)&buffer,
+               status = hw->mbx.host_interface_command(hw, (u32 *)&buffer,
                                                      sizeof(buffer),
                                                      TXGBE_HI_COMMAND_TIMEOUT_SHORT, true);
                if (status != 0) {
index 53c5cd5487c6d626b5422f2cbb7f36abe0d95bee..da5efecefde738b1ee344f3f4d870efc92e30353 100644 (file)
@@ -208,6 +208,10 @@ struct txgbe_hic_write_lldp {
        u16 pad3;
 };
 
+s32 txgbe_host_interface_command_sp(struct txgbe_hw *hw, u32 *buffer,
+                               u32 length, u32 timeout, bool return_data);
+s32 txgbe_host_interface_command_aml(struct txgbe_hw *hw, u32 *buffer,
+                               u32 length, u32 timeout, bool return_data);
 s32 txgbe_hic_sr_read(struct txgbe_hw *hw, u32 addr, u8 *buf, int len);
 s32 txgbe_hic_sr_write(struct txgbe_hw *hw, u32 addr, u8 *buf, int len);
 s32 txgbe_close_notify(struct txgbe_hw *hw);
index b5dbc9b755a848ae715a01a83e73d4e6cf37e444..ede780321f4bede4f661e0af94bdd3e6a6e27e18 100644 (file)
@@ -786,6 +786,8 @@ struct txgbe_mbx_info {
        s32  (*check_for_msg)(struct txgbe_hw *hw, u16 mbx_id);
        s32  (*check_for_ack)(struct txgbe_hw *hw, u16 mbx_id);
        s32  (*check_for_rst)(struct txgbe_hw *hw, u16 mbx_id);
+       s32  (*host_interface_command)(struct txgbe_hw *hw, u32 *buffer,
+                               u32 length, u32 timeout, bool return_data);
 
        struct txgbe_mbx_stats stats;
        u32 timeout;