Re: [PATCH net-next v9 4/5] net: rnpgbe: Add basic mbx_fw support
From: Yibo Dong <dong100@mucse.com>
Date: 2025-09-01 07:28:07
Also in:
linux-doc, linux-hardening, lkml
On Fri, Aug 29, 2025 at 09:48:12PM +0200, Andrew Lunn wrote:
quoted
Maybe I should rename it like this? /** * mucse_mbx_sync_fw_by_get_capability - Try to sync driver and fw * @hw: pointer to the HW structure * * mucse_mbx_sync_fw_by_get_capability tries to sync driver and fw * by get capabitiy mbx cmd. Many retrys will do if it is failed. * * Return: 0 on success, negative errno on failure **/ int mucse_mbx_sync_fw_by_get_capability(struct mucse_hw *hw) { struct hw_abilities ability = {}; int try_cnt = 3; int err; /* It is called once in probe, if failed nothing * (register network) todo. Try more times to get driver * and firmware in sync. */ do { err = mucse_fw_get_capability(hw, &ability); if (err) continue; break; } while (try_cnt--); if (!err) hw->pfvfnum = le16_to_cpu(ability.pfnum) & GENMASK_U16(7, 0); return err; }Why so much resistance to a NOP or firmware version, something which is not that important? Why do you want to combine getting sync and getting the capabilities?
Maybe like this?
mucse_mbx_sync_fw is called in probe with try_cnt.
mucse_mbx_get_info is the same as old mucse_mbx_get_capability.
One function one purpose, not combine two.
static int mucse_mbx_get_info(struct mucse_hw *hw)
{
struct mbx_fw_cmd_reply reply = {};
struct mbx_fw_cmd_req req = {};
struct hw_info info = {};
int err;
build_get_fw_info_req(&req);
err = mucse_fw_send_cmd_wait(hw, &req, &reply);
if (!err) {
memcpy(&info, &reply.hw_info, sizeof(struct hw_info));
hw->pfvfnum = le16_to_cpu(info.pfnum) & GENMASK_U16(7, 0);
}
return err;
}
/**
* mucse_mbx_sync_fw - Try to sync with fw
* @hw: pointer to the HW structure
*
* mucse_mbx_sync_fw tries get sync to fw hw.
* It is only called in probe
*
* Return: 0 on success, negative errno on failure
**/
int mucse_mbx_sync_fw(struct mucse_hw *hw)
{
int try_cnt = 3;
int err;
do {
err = mucse_mbx_get_info(hw);
if (err == -ETIMEDOUT)
continue;
break;
} while (try_cnt--);
return err;
}