drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c- Extension
.c- Size
- 14811 bytes
- Lines
- 601
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/pci.hlinux/netdevice.hlinux/etherdevice.hlinux/rtnetlink.hlinux/jhash.hnet/pkt_cls.hlinux/bnxt/hsi.hbnxt.hbnxt_hwrm.hbnxt_vfr.hbnxt_devlink.hbnxt_tc.h
Detected Declarations
function hwrm_cfa_vfr_allocfunction hwrm_cfa_vfr_freefunction bnxt_hwrm_vfr_qcfgfunction bnxt_vf_rep_openfunction bnxt_vf_rep_closefunction bnxt_vf_rep_xmitfunction bnxt_vf_rep_get_stats64function bnxt_vf_rep_setup_tc_block_cbfunction bnxt_vf_rep_setup_tcfunction bnxt_vf_rep_rxfunction bnxt_vf_rep_get_phys_port_namefunction bnxt_vf_rep_get_drvinfofunction bnxt_vf_rep_get_port_parent_idfunction bnxt_dev_is_vf_repfunction bnxt_vf_reps_closefunction bnxt_vf_reps_openfunction __bnxt_free_one_vf_repfunction __bnxt_vf_reps_destroyfunction bnxt_vf_reps_destroyfunction bnxt_vf_reps_freefunction bnxt_alloc_vf_repfunction bnxt_vf_reps_allocfunction bnxt_vf_rep_eth_addr_genfunction bnxt_vf_rep_netdev_initfunction bnxt_vf_reps_createfunction bnxt_dl_eswitch_mode_getfunction bnxt_dl_eswitch_mode_set
Annotated Snippet
static const struct net_device_ops bnxt_vf_rep_netdev_ops = {
.ndo_open = bnxt_vf_rep_open,
.ndo_stop = bnxt_vf_rep_close,
.ndo_start_xmit = bnxt_vf_rep_xmit,
.ndo_get_stats64 = bnxt_vf_rep_get_stats64,
.ndo_setup_tc = bnxt_vf_rep_setup_tc,
.ndo_get_port_parent_id = bnxt_vf_rep_get_port_parent_id,
.ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name
};
bool bnxt_dev_is_vf_rep(struct net_device *dev)
{
return dev->netdev_ops == &bnxt_vf_rep_netdev_ops;
}
/* Called when the parent PF interface is closed:
* As the mode transition from SWITCHDEV to LEGACY
* happens under the netdev instance lock this routine is safe
*/
void bnxt_vf_reps_close(struct bnxt *bp)
{
struct bnxt_vf_rep *vf_rep;
u16 num_vfs, i;
if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
return;
num_vfs = pci_num_vf(bp->pdev);
for (i = 0; i < num_vfs; i++) {
vf_rep = bp->vf_reps[i];
if (netif_running(vf_rep->dev))
bnxt_vf_rep_close(vf_rep->dev);
}
}
/* Called when the parent PF interface is opened (re-opened):
* As the mode transition from SWITCHDEV to LEGACY
* happen under the netdev instance lock this routine is safe
*/
void bnxt_vf_reps_open(struct bnxt *bp)
{
int i;
if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
return;
for (i = 0; i < pci_num_vf(bp->pdev); i++) {
/* Open the VF-Rep only if it is allocated in the FW */
if (bp->vf_reps[i]->tx_cfa_action != CFA_HANDLE_INVALID)
bnxt_vf_rep_open(bp->vf_reps[i]->dev);
}
}
static void __bnxt_free_one_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep)
{
if (!vf_rep)
return;
if (vf_rep->dst) {
dst_release((struct dst_entry *)vf_rep->dst);
vf_rep->dst = NULL;
}
if (vf_rep->tx_cfa_action != CFA_HANDLE_INVALID) {
hwrm_cfa_vfr_free(bp, vf_rep->vf_idx);
vf_rep->tx_cfa_action = CFA_HANDLE_INVALID;
}
}
static void __bnxt_vf_reps_destroy(struct bnxt *bp)
{
u16 num_vfs = pci_num_vf(bp->pdev);
struct bnxt_vf_rep *vf_rep;
int i;
for (i = 0; i < num_vfs; i++) {
vf_rep = bp->vf_reps[i];
if (vf_rep) {
__bnxt_free_one_vf_rep(bp, vf_rep);
if (vf_rep->dev) {
/* if register_netdev failed, then netdev_ops
* would have been set to NULL
*/
if (vf_rep->dev->netdev_ops)
unregister_netdev(vf_rep->dev);
free_netdev(vf_rep->dev);
}
}
}
kfree(bp->vf_reps);
Annotation
- Immediate include surface: `linux/pci.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/rtnetlink.h`, `linux/jhash.h`, `net/pkt_cls.h`, `linux/bnxt/hsi.h`, `bnxt.h`.
- Detected declarations: `function hwrm_cfa_vfr_alloc`, `function hwrm_cfa_vfr_free`, `function bnxt_hwrm_vfr_qcfg`, `function bnxt_vf_rep_open`, `function bnxt_vf_rep_close`, `function bnxt_vf_rep_xmit`, `function bnxt_vf_rep_get_stats64`, `function bnxt_vf_rep_setup_tc_block_cb`, `function bnxt_vf_rep_setup_tc`, `function bnxt_vf_rep_rx`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
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.