drivers/net/ethernet/meta/fbnic/fbnic_fw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/meta/fbnic/fbnic_fw.c- Extension
.c- Size
- 53746 bytes
- Lines
- 2042
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitfield.hlinux/etherdevice.hlinux/delay.hlinux/dev_printk.hlinux/dma-mapping.hlinux/gfp.hlinux/types.hfbnic.hfbnic_tlv.h
Detected Declarations
function __fbnic_mbx_wr_descfunction __fbnic_mbx_invalidate_descfunction __fbnic_mbx_rd_descfunction fbnic_mbx_reset_desc_ringfunction fbnic_mbx_initfunction fbnic_mbx_map_msgfunction fbnic_mbx_unmap_and_free_msgfunction fbnic_mbx_clean_desc_ringfunction fbnic_mbx_cleanfunction fbnic_mbx_alloc_rx_msgsfunction fbnic_mbx_map_tlv_msgfunction fbnic_mbx_set_cmpl_slotfunction fbnic_mbx_clear_cmpl_slotfunction fbnic_mbx_process_tx_msgsfunction fbnic_mbx_set_cmplfunction fbnic_mbx_map_req_w_cmplfunction fbnic_mbx_clear_cmplfunction fbnic_fw_release_cmpl_datafunction fbnic_fw_get_cmpl_by_typefunction fbnic_fw_xmit_test_msgfunction fbnic_fw_xmit_simple_msgfunction fbnic_mbx_init_desc_ringfunction fbnic_mbx_eventfunction fbnic_fw_xmit_ownership_msgfunction fbnic_fw_parse_bmc_addrsfunction fbnic_fw_parse_cap_respfunction fbnic_fw_parse_ownership_respfunction fbnic_fw_parse_heartbeat_respfunction fbnic_fw_xmit_heartbeat_messagefunction fbnic_fw_heartbeat_currentfunction fbnic_fw_init_heartbeatfunction fbnic_fw_check_heartbeatfunction fbnic_fw_xmit_coredump_info_msgfunction fbnic_fw_parse_coredump_info_respfunction fbnic_fw_xmit_coredump_read_msgfunction fbnic_fw_parse_coredump_respfunction fbnic_fw_xmit_fw_start_upgradefunction fbnic_fw_parse_fw_start_upgrade_respfunction fbnic_fw_xmit_fw_write_chunkfunction fbnic_fw_parse_fw_write_chunk_reqfunction fbnic_fw_parse_fw_finish_upgrade_reqfunction fbnic_fw_xmit_qsfp_read_msgfunction fbnic_fw_parse_qsfp_read_respfunction fbnic_fw_xmit_tsene_read_msgfunction fbnic_fw_parse_tsene_read_respfunction fbnic_fw_process_log_arrayfunction fbnic_fw_parse_logsfunction fbnic_fw_parse_log_req
Annotated Snippet
if (!msg) {
err = -ENOMEM;
break;
}
err = fbnic_mbx_map_msg(fbd, FBNIC_IPC_MBX_RX_IDX, msg,
FBNIC_RX_PAGE_SIZE, 0);
if (err)
free_page((unsigned long)msg);
}
return err;
}
static int fbnic_mbx_map_tlv_msg(struct fbnic_dev *fbd,
struct fbnic_tlv_msg *msg)
{
unsigned long flags;
int err;
spin_lock_irqsave(&fbd->fw_tx_lock, flags);
err = fbnic_mbx_map_msg(fbd, FBNIC_IPC_MBX_TX_IDX, msg,
le16_to_cpu(msg->hdr.len) * sizeof(u32), 1);
spin_unlock_irqrestore(&fbd->fw_tx_lock, flags);
return err;
}
static int fbnic_mbx_set_cmpl_slot(struct fbnic_dev *fbd,
struct fbnic_fw_completion *cmpl_data)
{
struct fbnic_fw_mbx *tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX];
int free = -EXFULL;
int i;
if (!tx_mbx->ready)
return -ENODEV;
for (i = 0; i < FBNIC_MBX_CMPL_SLOTS; i++) {
if (!fbd->cmpl_data[i])
free = i;
else if (fbd->cmpl_data[i]->msg_type == cmpl_data->msg_type)
return -EEXIST;
}
if (free == -EXFULL)
return -EXFULL;
fbd->cmpl_data[free] = cmpl_data;
return 0;
}
static void fbnic_mbx_clear_cmpl_slot(struct fbnic_dev *fbd,
struct fbnic_fw_completion *cmpl_data)
{
int i;
for (i = 0; i < FBNIC_MBX_CMPL_SLOTS; i++) {
if (fbd->cmpl_data[i] == cmpl_data) {
fbd->cmpl_data[i] = NULL;
break;
}
}
}
static void fbnic_mbx_process_tx_msgs(struct fbnic_dev *fbd)
{
struct fbnic_fw_mbx *tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX];
u8 head = tx_mbx->head;
u64 desc;
while (head != tx_mbx->tail) {
desc = __fbnic_mbx_rd_desc(fbd, FBNIC_IPC_MBX_TX_IDX, head);
if (!(desc & FBNIC_IPC_MBX_DESC_FW_CMPL))
break;
fbnic_mbx_unmap_and_free_msg(fbd, FBNIC_IPC_MBX_TX_IDX, head);
head++;
head %= FBNIC_IPC_MBX_DESC_LEN;
}
/* Record head for next interrupt */
tx_mbx->head = head;
}
int fbnic_mbx_set_cmpl(struct fbnic_dev *fbd,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/etherdevice.h`, `linux/delay.h`, `linux/dev_printk.h`, `linux/dma-mapping.h`, `linux/gfp.h`, `linux/types.h`, `fbnic.h`.
- Detected declarations: `function __fbnic_mbx_wr_desc`, `function __fbnic_mbx_invalidate_desc`, `function __fbnic_mbx_rd_desc`, `function fbnic_mbx_reset_desc_ring`, `function fbnic_mbx_init`, `function fbnic_mbx_map_msg`, `function fbnic_mbx_unmap_and_free_msg`, `function fbnic_mbx_clean_desc_ring`, `function fbnic_mbx_clean`, `function fbnic_mbx_alloc_rx_msgs`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.