drivers/net/ethernet/broadcom/bnge/bnge_resc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnge/bnge_resc.c- Extension
.c- Size
- 14002 bytes
- Lines
- 618
- 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.
- 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/init.hlinux/module.hlinux/pci.hlinux/ethtool.hlinux/netdevice.hbnge.hbnge_hwrm.hbnge_hwrm_lib.hbnge_resc.h
Detected Declarations
function bnge_num_tx_to_cpfunction bnge_get_max_func_irqsfunction bnge_get_max_func_stat_ctxsfunction bnge_aux_has_enough_resourcesfunction bnge_get_max_func_cp_ringsfunction bnge_aux_get_dflt_msixfunction bnge_aux_get_msixfunction bnge_aux_set_msix_numfunction bnge_aux_get_stat_ctxsfunction bnge_aux_set_stat_ctxsfunction bnge_func_stat_ctxs_demandfunction bnge_get_dflt_aux_stat_ctxsfunction bnge_nqs_demandfunction bnge_cprs_demandfunction bnge_get_avail_msixfunction bnge_num_cp_to_txfunction bnge_fix_rings_countfunction bnge_adjust_ringsfunction bnge_cal_nr_rss_ctxsfunction bnge_rss_ctxs_in_usefunction bnge_get_total_vnicsfunction bnge_get_rxfh_indir_sizefunction bnge_set_dflt_rss_indir_tblfunction bnge_copy_reserved_ringsfunction bnge_rings_okfunction bnge_need_reserve_ringsfunction bnge_reserve_ringsfunction bnge_alloc_irqsfunction bnge_free_irqsfunction _bnge_get_max_ringsfunction bnge_get_max_ringsfunction bnge_get_dflt_ringsfunction bnge_trim_dflt_sh_ringsfunction bnge_net_init_dflt_ringsfunction bnge_alloc_rss_indir_tblfunction bnge_net_init_dflt_configfunction bnge_net_uninit_dflt_configfunction bnge_aux_init_dflt_config
Annotated Snippet
while (_rx + _tx > max) {
if (_rx > _tx && _rx > 1)
_rx--;
else if (_tx > 1)
_tx--;
}
*rx = _rx;
*tx = _tx;
}
return 0;
}
static int bnge_adjust_rings(struct bnge_dev *bd, u16 *rx,
u16 *tx, u16 max_nq, bool sh)
{
u16 tx_chunks = bnge_num_tx_to_cp(bd, *tx);
if (tx_chunks != *tx) {
u16 tx_saved = tx_chunks, rc;
rc = bnge_fix_rings_count(rx, &tx_chunks, max_nq, sh);
if (rc)
return rc;
if (tx_chunks != tx_saved)
*tx = bnge_num_cp_to_tx(bd, tx_chunks);
return 0;
}
return bnge_fix_rings_count(rx, tx, max_nq, sh);
}
int bnge_cal_nr_rss_ctxs(u16 rx_rings)
{
if (!rx_rings)
return 0;
return bnge_adjust_pow_two(rx_rings - 1,
BNGE_RSS_TABLE_ENTRIES);
}
static u16 bnge_rss_ctxs_in_use(struct bnge_dev *bd,
struct bnge_hw_rings *hwr)
{
return bnge_cal_nr_rss_ctxs(hwr->grp);
}
static u16 bnge_get_total_vnics(struct bnge_dev *bd, u16 rx_rings)
{
return 1;
}
u32 bnge_get_rxfh_indir_size(struct bnge_dev *bd)
{
return bnge_cal_nr_rss_ctxs(bd->rx_nr_rings) *
BNGE_RSS_TABLE_ENTRIES;
}
static void bnge_set_dflt_rss_indir_tbl(struct bnge_dev *bd)
{
u16 max_entries, pad;
u32 *rss_indir_tbl;
int i;
max_entries = bnge_get_rxfh_indir_size(bd);
rss_indir_tbl = &bd->rss_indir_tbl[0];
for (i = 0; i < max_entries; i++)
rss_indir_tbl[i] = ethtool_rxfh_indir_default(i,
bd->rx_nr_rings);
pad = bd->rss_indir_tbl_entries - max_entries;
if (pad)
memset(&rss_indir_tbl[i], 0, pad * sizeof(*rss_indir_tbl));
}
static void bnge_copy_reserved_rings(struct bnge_dev *bd,
struct bnge_hw_rings *hwr)
{
struct bnge_hw_resc *hw_resc = &bd->hw_resc;
hwr->tx = hw_resc->resv_tx_rings;
hwr->rx = hw_resc->resv_rx_rings;
hwr->nq = hw_resc->resv_irqs;
hwr->cmpl = hw_resc->resv_cp_rings;
hwr->grp = hw_resc->resv_hw_ring_grps;
hwr->vnic = hw_resc->resv_vnics;
hwr->stat = hw_resc->resv_stat_ctxs;
hwr->rss_ctx = hw_resc->resv_rsscos_ctxs;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/pci.h`, `linux/ethtool.h`, `linux/netdevice.h`, `bnge.h`, `bnge_hwrm.h`, `bnge_hwrm_lib.h`.
- Detected declarations: `function bnge_num_tx_to_cp`, `function bnge_get_max_func_irqs`, `function bnge_get_max_func_stat_ctxs`, `function bnge_aux_has_enough_resources`, `function bnge_get_max_func_cp_rings`, `function bnge_aux_get_dflt_msix`, `function bnge_aux_get_msix`, `function bnge_aux_set_msix_num`, `function bnge_aux_get_stat_ctxs`, `function bnge_aux_set_stat_ctxs`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.