netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/2] net: txgbe: Fix to calculate EEPROM checksum for AML devices
       [not found] <20250509100003.22361-1-jiawenwu@trustnetic.com>
@ 2025-05-09 10:00 ` Jiawen Wu
  2025-05-12 10:57   ` Simon Horman
  2025-05-09 10:00 ` [PATCH net 2/2] net: libwx: Fix firmware interaction failure Jiawen Wu
  1 sibling, 1 reply; 4+ messages in thread
From: Jiawen Wu @ 2025-05-09 10:00 UTC (permalink / raw)
  To: netdev, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: mengyuanlou, Jiawen Wu

In the new firmware version, the shadow ram reserves some space to store
I2C information, so the checksum calculation needs to skip this section.
Otherwise, the driver will fail to probe because the invalid EEPROM
checksum.

Fixes: 2e5af6b2ae85 ("net: txgbe: Add basic support for new AML devices")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c   | 8 +++++++-
 drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
index 4b9921b7bb11..a054b259d435 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
@@ -99,9 +99,15 @@ static int txgbe_calc_eeprom_checksum(struct wx *wx, u16 *checksum)
 	}
 	local_buffer = eeprom_ptrs;
 
-	for (i = 0; i < TXGBE_EEPROM_LAST_WORD; i++)
+	for (i = 0; i < TXGBE_EEPROM_LAST_WORD; i++) {
+		if (wx->mac.type == wx_mac_aml) {
+			if (i >= TXGBE_EEPROM_I2C_SRART_PTR &&
+			    i < TXGBE_EEPROM_I2C_END_PTR)
+				local_buffer[i] = 0xffff;
+		}
 		if (i != wx->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM)
 			*checksum += local_buffer[i];
+	}
 
 	kvfree(eeprom_ptrs);
 
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
index cb553318641d..261a83308568 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
@@ -163,6 +163,8 @@
 #define TXGBE_EEPROM_VERSION_L                  0x1D
 #define TXGBE_EEPROM_VERSION_H                  0x1E
 #define TXGBE_ISCSI_BOOT_CONFIG                 0x07
+#define TXGBE_EEPROM_I2C_SRART_PTR              0x580
+#define TXGBE_EEPROM_I2C_END_PTR                0x800
 
 #define TXGBE_MAX_MSIX_VECTORS          64
 #define TXGBE_MAX_FDIR_INDICES          63
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] net: libwx: Fix firmware interaction failure
       [not found] <20250509100003.22361-1-jiawenwu@trustnetic.com>
  2025-05-09 10:00 ` [PATCH net 1/2] net: txgbe: Fix to calculate EEPROM checksum for AML devices Jiawen Wu
@ 2025-05-09 10:00 ` Jiawen Wu
  2025-05-12 10:57   ` Simon Horman
  1 sibling, 1 reply; 4+ messages in thread
From: Jiawen Wu @ 2025-05-09 10:00 UTC (permalink / raw)
  To: netdev, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: mengyuanlou, Jiawen Wu

There are two issues that need to be fixed on the new SW-FW interaction.

The timeout waiting for the firmware to return is too short. So that
some mailbox commands cannot be completed. Use the 'timeout' parameter
instead of fixed timeout value for flexible configuration.

Missing the error return if there is an unknown command. It causes the
driver to mistakenly believe that the interaction is complete. This
problem occurs when new driver is paired with old firmware, which does
not support the new mailbox commands.

Fixes: 2e5af6b2ae85 ("net: txgbe: Add basic support for new AML devices")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ethernet/wangxun/libwx/wx_hw.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/wangxun/libwx/wx_hw.c b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
index 3c3aa5f4ebbf..de06467898de 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_hw.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
@@ -435,7 +435,7 @@ static int wx_host_interface_command_r(struct wx *wx, u32 *buffer,
 	wr32m(wx, WX_SW2FW_MBOX_CMD, WX_SW2FW_MBOX_CMD_VLD, WX_SW2FW_MBOX_CMD_VLD);
 
 	/* polling reply from FW */
-	err = read_poll_timeout(wx_poll_fw_reply, reply, reply, 1000, 50000,
+	err = read_poll_timeout(wx_poll_fw_reply, reply, reply, 2000, timeout * 1000,
 				true, wx, buffer, send_cmd);
 	if (err) {
 		wx_err(wx, "Polling from FW messages timeout, cmd: 0x%x, index: %d\n",
@@ -443,6 +443,12 @@ static int wx_host_interface_command_r(struct wx *wx, u32 *buffer,
 		goto rel_out;
 	}
 
+	if (hdr->cmd_or_resp.ret_status == 0x80) {
+		wx_err(wx, "Unknown FW command: 0x%x\n", send_cmd);
+		err = -EINVAL;
+		goto rel_out;
+	}
+
 	/* expect no reply from FW then return */
 	if (!return_data)
 		goto rel_out;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 2/2] net: libwx: Fix firmware interaction failure
  2025-05-09 10:00 ` [PATCH net 2/2] net: libwx: Fix firmware interaction failure Jiawen Wu
@ 2025-05-12 10:57   ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-05-12 10:57 UTC (permalink / raw)
  To: Jiawen Wu
  Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, mengyuanlou

On Fri, May 09, 2025 at 06:00:03PM +0800, Jiawen Wu wrote:
> There are two issues that need to be fixed on the new SW-FW interaction.
> 
> The timeout waiting for the firmware to return is too short. So that
> some mailbox commands cannot be completed. Use the 'timeout' parameter
> instead of fixed timeout value for flexible configuration.
> 
> Missing the error return if there is an unknown command. It causes the
> driver to mistakenly believe that the interaction is complete. This
> problem occurs when new driver is paired with old firmware, which does
> not support the new mailbox commands.

Hi Jiawen Wu,

Please split this patch so that each issue is fixed in a separate patch:
the rule of thumb is one patch per fix.

> 
> Fixes: 2e5af6b2ae85 ("net: txgbe: Add basic support for new AML devices")
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
>  drivers/net/ethernet/wangxun/libwx/wx_hw.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_hw.c b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
> index 3c3aa5f4ebbf..de06467898de 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_hw.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
> @@ -435,7 +435,7 @@ static int wx_host_interface_command_r(struct wx *wx, u32 *buffer,
>  	wr32m(wx, WX_SW2FW_MBOX_CMD, WX_SW2FW_MBOX_CMD_VLD, WX_SW2FW_MBOX_CMD_VLD);
>  
>  	/* polling reply from FW */
> -	err = read_poll_timeout(wx_poll_fw_reply, reply, reply, 1000, 50000,
> +	err = read_poll_timeout(wx_poll_fw_reply, reply, reply, 2000, timeout * 1000,
>  				true, wx, buffer, send_cmd);

nit: Please line-wrap so that lines remain no wider than 80 columns.

>  	if (err) {
>  		wx_err(wx, "Polling from FW messages timeout, cmd: 0x%x, index: %d\n",
> @@ -443,6 +443,12 @@ static int wx_host_interface_command_r(struct wx *wx, u32 *buffer,
>  		goto rel_out;
>  	}
>  
> +	if (hdr->cmd_or_resp.ret_status == 0x80) {
> +		wx_err(wx, "Unknown FW command: 0x%x\n", send_cmd);
> +		err = -EINVAL;
> +		goto rel_out;
> +	}
> +
>  	/* expect no reply from FW then return */
>  	if (!return_data)
>  		goto rel_out;

-- 
pw-bot: changes-requested

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/2] net: txgbe: Fix to calculate EEPROM checksum for AML devices
  2025-05-09 10:00 ` [PATCH net 1/2] net: txgbe: Fix to calculate EEPROM checksum for AML devices Jiawen Wu
@ 2025-05-12 10:57   ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-05-12 10:57 UTC (permalink / raw)
  To: Jiawen Wu
  Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, mengyuanlou

On Fri, May 09, 2025 at 06:00:02PM +0800, Jiawen Wu wrote:
> In the new firmware version, the shadow ram reserves some space to store
> I2C information, so the checksum calculation needs to skip this section.
> Otherwise, the driver will fail to probe because the invalid EEPROM
> checksum.
> 
> Fixes: 2e5af6b2ae85 ("net: txgbe: Add basic support for new AML devices")
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-12 10:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250509100003.22361-1-jiawenwu@trustnetic.com>
2025-05-09 10:00 ` [PATCH net 1/2] net: txgbe: Fix to calculate EEPROM checksum for AML devices Jiawen Wu
2025-05-12 10:57   ` Simon Horman
2025-05-09 10:00 ` [PATCH net 2/2] net: libwx: Fix firmware interaction failure Jiawen Wu
2025-05-12 10:57   ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).