drivers/net/ethernet/broadcom/bnge/bnge_txrx.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnge/bnge_txrx.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/broadcom/bnge/bnge_txrx.c
Extension
.c
Size
43858 bytes
Lines
1670
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

if (bnge_alloc_rx_netmem(bn, rxr, prod, GFP_ATOMIC) != 0) {
			skb->len -= frag_len;
			skb->data_len -= frag_len;
			skb->truesize -= BNGE_RX_PAGE_SIZE;

			--shinfo->nr_frags;
			cons_rx_buf->netmem = netmem;

			/* Update prod since possibly some netmems have been
			 * allocated already.
			 */
			rxr->rx_agg_prod = prod;
			bnge_reuse_rx_agg_bufs(cpr, idx, i, agg_bufs - i, tpa);
			return 0;
		}

		page_pool_dma_sync_netmem_for_cpu(rxr->page_pool, netmem, 0,
						  BNGE_RX_PAGE_SIZE);

		total_frag_len += frag_len;
		prod = NEXT_RX_AGG(prod);
	}
	rxr->rx_agg_prod = prod;
	return total_frag_len;
}

static struct sk_buff *bnge_rx_agg_netmems_skb(struct bnge_net *bn,
					       struct bnge_cp_ring_info *cpr,
					       struct sk_buff *skb, u16 idx,
					       u32 agg_bufs, bool tpa)
{
	u32 total_frag_len;

	total_frag_len = __bnge_rx_agg_netmems(bn, cpr, idx, agg_bufs,
					       tpa, skb);
	if (!total_frag_len) {
		skb_mark_for_recycle(skb);
		dev_kfree_skb(skb);
		return NULL;
	}

	return skb;
}

static void bnge_sched_reset_rxr(struct bnge_net *bn,
				 struct bnge_rx_ring_info *rxr)
{
	if (!rxr->bnapi->in_reset) {
		rxr->bnapi->in_reset = true;

		/* TODO: Initiate reset task */
	}
	rxr->rx_next_cons = 0xffff;
}

static void bnge_sched_reset_txr(struct bnge_net *bn,
				 struct bnge_tx_ring_info *txr,
				 u16 curr)
{
	struct bnge_napi *bnapi = txr->bnapi;

	if (bnapi->tx_fault)
		return;

	netdev_err(bn->netdev, "Invalid Tx completion (ring:%d tx_hw_cons:%u cons:%u prod:%u curr:%u)",
		   txr->txq_index, txr->tx_hw_cons,
		   txr->tx_cons, txr->tx_prod, curr);
	WARN_ON_ONCE(1);
	bnapi->tx_fault = 1;
	/* TODO: Initiate reset task */
}

static u16 bnge_tpa_alloc_agg_idx(struct bnge_rx_ring_info *rxr, u16 agg_id)
{
	struct bnge_tpa_idx_map *map = rxr->rx_tpa_idx_map;
	u16 idx = agg_id & MAX_TPA_MASK;

	if (test_bit(idx, map->agg_idx_bmap)) {
		idx = find_first_zero_bit(map->agg_idx_bmap, MAX_TPA);
		if (idx >= MAX_TPA)
			return INVALID_HW_RING_ID;
	}
	__set_bit(idx, map->agg_idx_bmap);
	map->agg_id_tbl[agg_id] = idx;
	return idx;
}

static void bnge_free_agg_idx(struct bnge_rx_ring_info *rxr, u16 idx)
{
	struct bnge_tpa_idx_map *map = rxr->rx_tpa_idx_map;

Annotation

Implementation Notes