drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c- Extension
.c- Size
- 89979 bytes
- Lines
- 3198
- 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
bnx2x.hbnx2x_init.hbnx2x_cmn.hbnx2x_sp.hlinux/crc32.hlinux/if_vlan.h
Detected Declarations
struct set_vf_state_cookiefunction storm_memset_vf_to_pffunction storm_memset_func_enfunction bnx2x_vf_idx_by_abs_fidfunction bnx2x_vf_igu_ack_sbfunction bnx2x_validate_vf_sp_objsfunction bnx2x_vfop_qctor_dump_txfunction bnx2x_vfop_qctor_dump_rxfunction bnx2x_vfop_qctor_prepfunction bnx2x_vf_queue_createfunction bnx2x_vf_queue_destroyfunction bnx2x_vf_set_igu_infofunction bnx2x_vf_vlan_mac_clearfunction bnx2x_vf_mac_vlan_configfunction bnx2x_vf_mac_vlan_config_listfunction bnx2x_vf_queue_setupfunction bnx2x_vf_queue_flrfunction bnx2x_validate_vf_sp_objsfunction bnx2x_vf_mcastfunction bnx2x_vf_prep_rx_modefunction bnx2x_vf_rxmodefunction bnx2x_vf_queue_teardownfunction bnx2x_vf_enable_internalfunction bnx2x_vf_semi_clear_errfunction bnx2x_vf_pglue_clear_errfunction bnx2x_vf_igu_resetfunction bnx2x_vf_enable_accessfunction bnx2x_vf_enable_trafficfunction bnx2x_vf_is_pcie_pendingfunction bnx2x_vf_flr_clnup_epilogfunction bnx2x_iov_static_rescfunction bnx2x_vf_free_rescfunction bnx2x_vf_flr_clnup_hwfunction bnx2x_vf_flrfunction bnx2x_vf_flr_clnupfunction bnx2x_vf_handle_flr_eventfunction for_each_vffunction bnx2x_iov_init_dqfunction bnx2x_iov_init_dmaefunction bnx2x_vf_domainfunction bnx2x_vf_busfunction bnx2x_vf_devfnfunction bnx2x_vf_set_barsfunction bnx2x_get_vf_igu_cam_infofunction __bnx2x_iov_free_vfdbfunction bnx2x_sriov_pci_cfg_infofunction bnx2x_sriov_infofunction bnx2x_iov_init_one
Annotated Snippet
struct set_vf_state_cookie {
struct bnx2x_virtf *vf;
u8 state;
};
static void bnx2x_set_vf_state(void *cookie)
{
struct set_vf_state_cookie *p = (struct set_vf_state_cookie *)cookie;
p->vf->state = p->state;
}
int bnx2x_vf_close(struct bnx2x *bp, struct bnx2x_virtf *vf)
{
int rc = 0, i;
DP(BNX2X_MSG_IOV, "vf[%d]\n", vf->abs_vfid);
/* Close all queues */
for (i = 0; i < vf_rxq_count(vf); i++) {
rc = bnx2x_vf_queue_teardown(bp, vf, i);
if (rc)
goto op_err;
}
/* disable the interrupts */
DP(BNX2X_MSG_IOV, "disabling igu\n");
bnx2x_vf_igu_disable(bp, vf);
/* disable the VF */
DP(BNX2X_MSG_IOV, "clearing qtbl\n");
bnx2x_vf_clr_qtbl(bp, vf);
/* need to make sure there are no outstanding stats ramrods which may
* cause the device to access the VF's stats buffer which it will free
* as soon as we return from the close flow.
*/
{
struct set_vf_state_cookie cookie;
cookie.vf = vf;
cookie.state = VF_ACQUIRED;
rc = bnx2x_stats_safe_exec(bp, bnx2x_set_vf_state, &cookie);
if (rc)
goto op_err;
}
DP(BNX2X_MSG_IOV, "set state to acquired\n");
return 0;
op_err:
BNX2X_ERR("vf[%d] CLOSE error: rc %d\n", vf->abs_vfid, rc);
return rc;
}
/* VF release can be called either: 1. The VF was acquired but
* not enabled 2. the vf was enabled or in the process of being
* enabled
*/
int bnx2x_vf_free(struct bnx2x *bp, struct bnx2x_virtf *vf)
{
int rc;
DP(BNX2X_MSG_IOV, "VF[%d] STATE: %s\n", vf->abs_vfid,
vf->state == VF_FREE ? "Free" :
vf->state == VF_ACQUIRED ? "Acquired" :
vf->state == VF_ENABLED ? "Enabled" :
vf->state == VF_RESET ? "Reset" :
"Unknown");
switch (vf->state) {
case VF_ENABLED:
rc = bnx2x_vf_close(bp, vf);
if (rc)
goto op_err;
fallthrough; /* to release resources */
case VF_ACQUIRED:
DP(BNX2X_MSG_IOV, "about to free resources\n");
bnx2x_vf_free_resc(bp, vf);
break;
case VF_FREE:
case VF_RESET:
default:
break;
}
return 0;
op_err:
BNX2X_ERR("VF[%d] RELEASE error: rc %d\n", vf->abs_vfid, rc);
return rc;
Annotation
- Immediate include surface: `bnx2x.h`, `bnx2x_init.h`, `bnx2x_cmn.h`, `bnx2x_sp.h`, `linux/crc32.h`, `linux/if_vlan.h`.
- Detected declarations: `struct set_vf_state_cookie`, `function storm_memset_vf_to_pf`, `function storm_memset_func_en`, `function bnx2x_vf_idx_by_abs_fid`, `function bnx2x_vf_igu_ack_sb`, `function bnx2x_validate_vf_sp_objs`, `function bnx2x_vfop_qctor_dump_tx`, `function bnx2x_vfop_qctor_dump_rx`, `function bnx2x_vfop_qctor_prep`, `function bnx2x_vf_queue_create`.
- 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.