drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c- Extension
.c- Size
- 4801 bytes
- Lines
- 192
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/if_ether.hlinux/bitfield.hrnpgbe.hrnpgbe_mbx.hrnpgbe_mbx_fw.h
Detected Declarations
function mucse_fw_send_cmd_wait_respfunction mucse_mbx_get_infofunction mucse_mbx_sync_fwfunction mucse_mbx_powerupfunction mucse_mbx_reset_hwfunction mucse_mbx_get_macaddr
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2020 - 2025 Mucse Corporation. */
#include <linux/if_ether.h>
#include <linux/bitfield.h>
#include "rnpgbe.h"
#include "rnpgbe_mbx.h"
#include "rnpgbe_mbx_fw.h"
/**
* mucse_fw_send_cmd_wait_resp - Send cmd req and wait for response
* @hw: pointer to the HW structure
* @req: pointer to the cmd req structure
* @reply: pointer to the fw reply structure
*
* mucse_fw_send_cmd_wait_resp sends req to pf-fw mailbox and wait
* reply from fw.
*
* Return: 0 on success, negative errno on failure
**/
static int mucse_fw_send_cmd_wait_resp(struct mucse_hw *hw,
struct mbx_fw_cmd_req *req,
struct mbx_fw_cmd_reply *reply)
{
int len = le16_to_cpu(req->datalen);
int retry_cnt = 3;
int err;
mutex_lock(&hw->mbx.lock);
err = mucse_write_and_wait_ack_mbx(hw, (u32 *)req, len);
if (err)
goto out;
do {
err = mucse_poll_and_read_mbx(hw, (u32 *)reply,
sizeof(*reply));
if (err)
goto out;
/* mucse_write_and_wait_ack_mbx return 0 means fw has
* received request, wait for the expect opcode
* reply with 'retry_cnt' times.
*/
} while (--retry_cnt >= 0 && reply->opcode != req->opcode);
out:
mutex_unlock(&hw->mbx.lock);
if (!err && retry_cnt < 0)
return -ETIMEDOUT;
if (!err && reply->error_code)
return -EIO;
return err;
}
/**
* mucse_mbx_get_info - Get hw info from fw
* @hw: pointer to the HW structure
*
* mucse_mbx_get_info tries to get hw info from hw.
*
* Return: 0 on success, negative errno on failure
**/
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 = {};
int err;
err = mucse_fw_send_cmd_wait_resp(hw, &req, &reply);
if (!err)
hw->pfvfnum = FIELD_GET(GENMASK_U16(7, 0),
le16_to_cpu(reply.hw_info.pfnum));
return err;
}
/**
* mucse_mbx_sync_fw - Try to sync with fw
* @hw: pointer to the HW structure
*
* mucse_mbx_sync_fw tries to sync with fw. It is only called in
* probe. Nothing (register network) todo if failed.
* Try more times to do sync.
*
* Return: 0 on success, negative errno on failure
**/
int mucse_mbx_sync_fw(struct mucse_hw *hw)
{
Annotation
- Immediate include surface: `linux/if_ether.h`, `linux/bitfield.h`, `rnpgbe.h`, `rnpgbe_mbx.h`, `rnpgbe_mbx_fw.h`.
- Detected declarations: `function mucse_fw_send_cmd_wait_resp`, `function mucse_mbx_get_info`, `function mucse_mbx_sync_fw`, `function mucse_mbx_powerup`, `function mucse_mbx_reset_hw`, `function mucse_mbx_get_macaddr`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.