drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_mbox.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_mbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_mbox.c- Extension
.c- Size
- 11742 bytes
- Lines
- 432
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/pci.hlinux/netdevice.hlinux/vmalloc.hoctep_vf_config.hoctep_vf_main.h
Detected Declarations
function octep_vf_setup_mboxfunction octep_vf_delete_mboxfunction octep_vf_mbox_version_checkfunction octep_vf_mbox_workfunction __octep_vf_mbox_send_cmdfunction octep_vf_mbox_send_cmdfunction octep_vf_mbox_bulk_readfunction octep_vf_mbox_set_mtufunction octep_vf_mbox_set_mac_addrfunction octep_vf_mbox_get_mac_addrfunction octep_vf_mbox_set_rx_statefunction octep_vf_mbox_set_link_statusfunction octep_vf_mbox_get_link_statusfunction octep_vf_mbox_dev_removefunction octep_vf_mbox_get_fw_infofunction octep_vf_mbox_set_offloads
Annotated Snippet
if (notif->s_link_status.status) {
link_info->oper_up = OCTEP_PFVF_LINK_STATUS_UP;
netif_carrier_on(oct->netdev);
dev_info(&oct->pdev->dev, "netif_carrier_on\n");
} else {
link_info->oper_up = OCTEP_PFVF_LINK_STATUS_DOWN;
netif_carrier_off(oct->netdev);
dev_info(&oct->pdev->dev, "netif_carrier_off\n");
}
break;
default:
dev_err(&oct->pdev->dev,
"Received unsupported notif %d\n", notif->s.opcode);
break;
}
}
static int __octep_vf_mbox_send_cmd(struct octep_vf_device *oct,
union octep_pfvf_mbox_word cmd,
union octep_pfvf_mbox_word *rsp)
{
struct octep_vf_mbox *mbox = oct->mbox;
u64 reg_val = 0ull;
int count;
if (!mbox)
return OCTEP_PFVF_MBOX_CMD_STATUS_NOT_SETUP;
cmd.s.type = OCTEP_PFVF_MBOX_TYPE_CMD;
writeq(cmd.u64, mbox->mbox_write_reg);
/* No response for notification messages */
if (!rsp)
return 0;
for (count = 0; count < OCTEP_PFVF_MBOX_TIMEOUT_WAIT_COUNT; count++) {
usleep_range(1000, 1500);
reg_val = readq(mbox->mbox_write_reg);
if (reg_val != cmd.u64) {
rsp->u64 = reg_val;
break;
}
}
if (count == OCTEP_PFVF_MBOX_TIMEOUT_WAIT_COUNT) {
dev_err(&oct->pdev->dev, "mbox send command timed out\n");
return OCTEP_PFVF_MBOX_CMD_STATUS_TIMEDOUT;
}
if (rsp->s.type != OCTEP_PFVF_MBOX_TYPE_RSP_ACK) {
dev_err(&oct->pdev->dev, "mbox_send: Received NACK\n");
return OCTEP_PFVF_MBOX_CMD_STATUS_NACK;
}
rsp->u64 = reg_val;
return 0;
}
int octep_vf_mbox_send_cmd(struct octep_vf_device *oct, union octep_pfvf_mbox_word cmd,
union octep_pfvf_mbox_word *rsp)
{
struct octep_vf_mbox *mbox = oct->mbox;
int ret;
if (!mbox)
return OCTEP_PFVF_MBOX_CMD_STATUS_NOT_SETUP;
mutex_lock(&mbox->lock);
if (pfvf_cmd_versions[cmd.s.opcode] > oct->mbox_neg_ver) {
dev_dbg(&oct->pdev->dev, "CMD:%d not supported in Version:%d\n",
cmd.s.opcode, oct->mbox_neg_ver);
mutex_unlock(&mbox->lock);
return -EOPNOTSUPP;
}
ret = __octep_vf_mbox_send_cmd(oct, cmd, rsp);
mutex_unlock(&mbox->lock);
return ret;
}
int octep_vf_mbox_bulk_read(struct octep_vf_device *oct, enum octep_pfvf_mbox_opcode opcode,
u8 *data, int *size)
{
struct octep_vf_mbox *mbox = oct->mbox;
union octep_pfvf_mbox_word cmd;
union octep_pfvf_mbox_word rsp;
int data_len = 0, tmp_len = 0;
int read_cnt, i = 0, ret;
if (!mbox)
return OCTEP_PFVF_MBOX_CMD_STATUS_NOT_SETUP;
mutex_lock(&mbox->lock);
cmd.u64 = 0;
cmd.s_data.opcode = opcode;
Annotation
- Immediate include surface: `linux/types.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/vmalloc.h`, `octep_vf_config.h`, `octep_vf_main.h`.
- Detected declarations: `function octep_vf_setup_mbox`, `function octep_vf_delete_mbox`, `function octep_vf_mbox_version_check`, `function octep_vf_mbox_work`, `function __octep_vf_mbox_send_cmd`, `function octep_vf_mbox_send_cmd`, `function octep_vf_mbox_bulk_read`, `function octep_vf_mbox_set_mtu`, `function octep_vf_mbox_set_mac_addr`, `function octep_vf_mbox_get_mac_addr`.
- 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.