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.

Dependency Surface

Detected Declarations

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

Implementation Notes