drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c- Extension
.c- Size
- 70677 bytes
- Lines
- 2261
- 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/ethtool.hlinux/pci.ht4vf_common.ht4vf_defs.h../cxgb4/t4_regs.h../cxgb4/t4_values.h../cxgb4/t4fw_api.h
Detected Declarations
function Copyrightfunction get_mbox_rplfunction t4vf_record_mboxfunction FWfunction FW_PORT_CAP32_FEC_Vfunction fwcap_to_cc_pausefunction fwcap_to_cc_fecfunction fwcap_to_speedfunction fwcap_to_fwspeedfunction init_link_configfunction t4_handle_get_port_infofunction t4vf_port_initfunction t4vf_fw_resetfunction t4vf_query_paramsfunction t4vf_set_paramsfunction t4vf_fl_pkt_alignfunction t4vf_bar2_sge_qregsfunction t4vf_get_pf_from_vffunction t4vf_get_sge_paramsfunction t4vf_get_vpd_paramsfunction t4vf_get_dev_paramsfunction t4vf_get_rss_glb_configfunction t4vf_get_vfresfunction t4vf_read_rss_vi_configfunction t4vf_write_rss_vi_configfunction t4vf_config_rss_rangefunction t4vf_alloc_vifunction t4vf_free_vifunction t4vf_enable_vifunction t4vf_os_link_changedfunction t4vf_identify_portfunction t4vf_set_rxmodefunction t4vf_alloc_mac_filtfunction t4vf_free_mac_filtfunction t4vf_change_macfunction t4vf_set_addr_hashfunction t4vf_get_port_statsfunction t4vf_iq_freefunction t4vf_eth_eq_freefunction t4vf_handle_get_port_infofunction init_link_configfunction t4vf_update_port_infofunction t4vf_handle_fw_rplfunction for_each_portfunction t4vf_prep_adapterfunction t4vf_get_vf_mac_aclfunction t4vf_get_vf_vlan_acl
Annotated Snippet
if (i > FW_CMD_MAX_TIMEOUT) {
spin_lock(&adapter->mbox_lock);
list_del(&entry.list);
spin_unlock(&adapter->mbox_lock);
ret = -EBUSY;
t4vf_record_mbox(adapter, cmd, size, access, ret);
return ret;
}
/* If we're at the head, break out and start the mailbox
* protocol.
*/
if (list_first_entry(&adapter->mlist.list, struct mbox_list,
list) == &entry)
break;
/* Delay for a bit before checking again ... */
if (sleep_ok) {
ms = delay[delay_idx]; /* last element may repeat */
if (delay_idx < ARRAY_SIZE(delay) - 1)
delay_idx++;
msleep(ms);
} else {
mdelay(ms);
}
}
/*
* Loop trying to get ownership of the mailbox. Return an error
* if we can't gain ownership.
*/
v = MBOWNER_G(t4_read_reg(adapter, mbox_ctl));
for (i = 0; v == MBOX_OWNER_NONE && i < 3; i++)
v = MBOWNER_G(t4_read_reg(adapter, mbox_ctl));
if (v != MBOX_OWNER_DRV) {
spin_lock(&adapter->mbox_lock);
list_del(&entry.list);
spin_unlock(&adapter->mbox_lock);
ret = (v == MBOX_OWNER_FW) ? -EBUSY : -ETIMEDOUT;
t4vf_record_mbox(adapter, cmd, size, access, ret);
return ret;
}
/*
* Write the command array into the Mailbox Data register array and
* transfer ownership of the mailbox to the firmware.
*
* For the VFs, the Mailbox Data "registers" are actually backed by
* T4's "MA" interface rather than PL Registers (as is the case for
* the PFs). Because these are in different coherency domains, the
* write to the VF's PL-register-backed Mailbox Control can race in
* front of the writes to the MA-backed VF Mailbox Data "registers".
* So we need to do a read-back on at least one byte of the VF Mailbox
* Data registers before doing the write to the VF Mailbox Control
* register.
*/
if (cmd_op != FW_VI_STATS_CMD)
t4vf_record_mbox(adapter, cmd, size, access, 0);
for (i = 0, p = cmd; i < size; i += 8)
t4_write_reg64(adapter, mbox_data + i, be64_to_cpu(*p++));
t4_read_reg(adapter, mbox_data); /* flush write */
t4_write_reg(adapter, mbox_ctl,
MBMSGVALID_F | MBOWNER_V(MBOX_OWNER_FW));
t4_read_reg(adapter, mbox_ctl); /* flush write */
/*
* Spin waiting for firmware to acknowledge processing our command.
*/
delay_idx = 0;
ms = delay[0];
for (i = 0; i < FW_CMD_MAX_TIMEOUT; i += ms) {
if (sleep_ok) {
ms = delay[delay_idx];
if (delay_idx < ARRAY_SIZE(delay) - 1)
delay_idx++;
msleep(ms);
} else
mdelay(ms);
/*
* If we're the owner, see if this is the reply we wanted.
*/
v = t4_read_reg(adapter, mbox_ctl);
if (MBOWNER_G(v) == MBOX_OWNER_DRV) {
/*
* If the Message Valid bit isn't on, revoke ownership
* of the mailbox and continue waiting for our reply.
*/
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/pci.h`, `t4vf_common.h`, `t4vf_defs.h`, `../cxgb4/t4_regs.h`, `../cxgb4/t4_values.h`, `../cxgb4/t4fw_api.h`.
- Detected declarations: `function Copyright`, `function get_mbox_rpl`, `function t4vf_record_mbox`, `function FW`, `function FW_PORT_CAP32_FEC_V`, `function fwcap_to_cc_pause`, `function fwcap_to_cc_fec`, `function fwcap_to_speed`, `function fwcap_to_fwspeed`, `function init_link_config`.
- 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.