Re: [PATCH net-next v15 4/5] net: rnpgbe: Add basic mbx_fw support
flat view
From: Yibo Dong <dong100@mucse.com>
Date: 2025-10-22 11:21:21
Also in:
linux-doc, lkml
On Wed, Oct 22, 2025 at 12:07:59PM +0100, Vadim Fedorenko wrote:
On 22/10/2025 09:13, Dong Yibo wrote:quoted
Add fundamental firmware (FW) communication operations via PF-FW mailbox, including: - FW sync (via HW info query with retries) - HW reset (post FW command to reset hardware) - MAC address retrieval (request FW for port-specific MAC) - Power management (powerup/powerdown notification to FW) Signed-off-by: Dong Yibo <dong100@mucse.com> --- drivers/net/ethernet/mucse/rnpgbe/Makefile | 3 +- drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 4 + .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c | 1 + .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c | 194 ++++++++++++++++++ .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h | 88 ++++++++ 5 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h[...]quoted
+static int mucse_mbx_get_info(struct mucse_hw *hw) +{ + struct mbx_fw_cmd_req req = { + .datalen = cpu_to_le16(MUCSE_MBX_REQ_HDR_LEN), + .opcode = cpu_to_le16(GET_HW_INFO), + }; + struct mbx_fw_cmd_reply reply = {}; + struct mucse_hw_info info = {}; + int err; + + err = mucse_fw_send_cmd_wait_resp(hw, &req, &reply); + if (!err) { + memcpy(&info, &reply.hw_info, sizeof(struct mucse_hw_info)); + hw->pfvfnum = FIELD_GET(GENMASK_U16(7, 0), + le16_to_cpu(info.pfnum));why do you need local struct mucse_hw_info info? The reply is stack allocated, nothing else will use it afterwards. You clear out info on allocation (40 bytes memset), then you copy whole structure from reply to info (another round of 40 bytes reads/writes) and then use only 2 bytes out of it - it does look like an overkill, you can access reply.hwinfo.pfnum directly.
mm, you are right, I should access it directly. Thanks.