drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c- Extension
.c- Size
- 12956 bytes
- Lines
- 449
- 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/string.hlinux/types.hlinux/etherdevice.hlinux/pci.hlinux/wait.hoctep_config.hoctep_main.hoctep_ctrl_net.hoctep_pfvf_mbox.h
Detected Declarations
function init_send_reqfunction octep_send_mbox_reqfunction octep_ctrl_net_initfunction octep_ctrl_net_get_link_statusfunction octep_ctrl_net_set_link_statusfunction octep_ctrl_net_set_rx_statefunction octep_ctrl_net_get_mac_addrfunction octep_ctrl_net_set_mac_addrfunction octep_ctrl_net_get_mtufunction octep_ctrl_net_set_mtufunction octep_ctrl_net_get_if_statsfunction octep_ctrl_net_get_link_infofunction octep_ctrl_net_set_link_infofunction process_mbox_respfunction list_for_each_entry_safefunction process_mbox_notifyfunction octep_ctrl_net_recv_fw_messagesfunction octep_ctrl_net_get_infofunction octep_ctrl_net_dev_removefunction octep_ctrl_net_set_offloadsfunction octep_ctrl_net_uninit
Annotated Snippet
if (pos->msg.hdr.s.msg_id == msg->hdr.s.msg_id) {
memcpy(&pos->data.resp,
msg->sg_list[0].msg,
msg->hdr.s.sz);
pos->done = 1;
wake_up_interruptible_all(&oct->ctrl_req_wait_q);
break;
}
}
}
static int process_mbox_notify(struct octep_device *oct,
struct octep_ctrl_mbox_msg *msg)
{
struct net_device *netdev = oct->netdev;
struct octep_ctrl_net_f2h_req *req;
int cmd;
req = (struct octep_ctrl_net_f2h_req *)msg->sg_list[0].msg;
cmd = req->hdr.s.cmd;
/* check if we support this command */
if (octep_ctrl_net_f2h_cmd_versions[cmd] > OCTEP_CP_VERSION_CURRENT ||
octep_ctrl_net_f2h_cmd_versions[cmd] < OCTEP_CP_VERSION_CURRENT)
return -EOPNOTSUPP;
if (msg->hdr.s.is_vf) {
octep_pfvf_notify(oct, msg);
return 0;
}
switch (cmd) {
case OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS:
if (netif_running(netdev)) {
if (req->link.state) {
dev_info(&oct->pdev->dev, "netif_carrier_on\n");
netif_carrier_on(netdev);
} else {
dev_info(&oct->pdev->dev, "netif_carrier_off\n");
netif_carrier_off(netdev);
}
}
break;
default:
pr_info("Unknown mbox req : %u\n", req->hdr.s.cmd);
break;
}
return 0;
}
void octep_ctrl_net_recv_fw_messages(struct octep_device *oct)
{
static u16 msg_sz = sizeof(union octep_ctrl_net_max_data);
union octep_ctrl_net_max_data data = {};
struct octep_ctrl_mbox_msg msg = {};
int ret;
msg.hdr.s.sz = msg_sz;
msg.sg_num = 1;
msg.sg_list[0].sz = msg_sz;
msg.sg_list[0].msg = &data;
while (true) {
/* mbox will overwrite msg.hdr.s.sz so initialize it */
msg.hdr.s.sz = msg_sz;
ret = octep_ctrl_mbox_recv(&oct->ctrl_mbox, (struct octep_ctrl_mbox_msg *)&msg);
if (ret < 0)
break;
if (msg.hdr.s.flags & OCTEP_CTRL_MBOX_MSG_HDR_FLAG_RESP)
process_mbox_resp(oct, &msg);
else if (msg.hdr.s.flags & OCTEP_CTRL_MBOX_MSG_HDR_FLAG_NOTIFY)
process_mbox_notify(oct, &msg);
}
}
int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
struct octep_fw_info *info)
{
struct octep_ctrl_net_wait_data d = {};
struct octep_ctrl_net_h2f_resp *resp;
struct octep_ctrl_net_h2f_req *req;
int err;
req = &d.data.req;
init_send_req(&d.msg, req, 0, vfid);
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_GET_INFO;
req->link_info.cmd = OCTEP_CTRL_NET_CMD_GET;
err = octep_send_mbox_req(oct, &d, true);
if (err < 0)
Annotation
- Immediate include surface: `linux/string.h`, `linux/types.h`, `linux/etherdevice.h`, `linux/pci.h`, `linux/wait.h`, `octep_config.h`, `octep_main.h`, `octep_ctrl_net.h`.
- Detected declarations: `function init_send_req`, `function octep_send_mbox_req`, `function octep_ctrl_net_init`, `function octep_ctrl_net_get_link_status`, `function octep_ctrl_net_set_link_status`, `function octep_ctrl_net_set_rx_state`, `function octep_ctrl_net_get_mac_addr`, `function octep_ctrl_net_set_mac_addr`, `function octep_ctrl_net_get_mtu`, `function octep_ctrl_net_set_mtu`.
- 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.