drivers/net/ethernet/pensando/ionic/ionic_lif.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/pensando/ionic/ionic_lif.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/pensando/ionic/ionic_lif.c
Extension
.c
Size
109699 bytes
Lines
4116
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct net_device_ops ionic_netdev_ops = {
	.ndo_open               = ionic_open,
	.ndo_stop               = ionic_stop,
	.ndo_start_xmit		= ionic_start_xmit,
	.ndo_bpf		= ionic_xdp,
	.ndo_xdp_xmit		= ionic_xdp_xmit,
	.ndo_get_stats64	= ionic_get_stats64,
	.ndo_set_rx_mode	= ionic_ndo_set_rx_mode,
	.ndo_set_features	= ionic_set_features,
	.ndo_set_mac_address	= ionic_set_mac_address,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_tx_timeout         = ionic_tx_timeout,
	.ndo_change_mtu         = ionic_change_mtu,
	.ndo_vlan_rx_add_vid    = ionic_vlan_rx_add_vid,
	.ndo_vlan_rx_kill_vid   = ionic_vlan_rx_kill_vid,
	.ndo_set_vf_vlan	= ionic_set_vf_vlan,
	.ndo_set_vf_trust	= ionic_set_vf_trust,
	.ndo_set_vf_mac		= ionic_set_vf_mac,
	.ndo_set_vf_rate	= ionic_set_vf_rate,
	.ndo_set_vf_spoofchk	= ionic_set_vf_spoofchk,
	.ndo_get_vf_config	= ionic_get_vf_config,
	.ndo_set_vf_link_state	= ionic_set_vf_link_state,
	.ndo_get_vf_stats       = ionic_get_vf_stats,
	.ndo_hwtstamp_get	= ionic_hwstamp_get,
	.ndo_hwtstamp_set	= ionic_hwstamp_set,
};

static int ionic_cmb_reconfig(struct ionic_lif *lif,
			      struct ionic_queue_params *qparam)
{
	struct ionic_queue_params start_qparams;
	int err = 0;

	/* When changing CMB queue parameters, we're using limited
	 * on-device memory and don't have extra memory to use for
	 * duplicate allocations, so we free it all first then
	 * re-allocate with the new parameters.
	 */

	/* Checkpoint for possible unwind */
	ionic_init_queue_params(lif, &start_qparams);

	/* Stop and free the queues */
	ionic_stop_queues_reconfig(lif);
	ionic_txrx_free(lif);

	/* Set up new qparams */
	ionic_set_queue_params(lif, qparam);

	if (netif_running(lif->netdev)) {
		/* Alloc and start the new configuration */
		err = ionic_txrx_alloc(lif);
		if (err) {
			dev_warn(lif->ionic->dev,
				 "CMB reconfig failed, restoring values: %d\n", err);

			/* Back out the changes */
			ionic_set_queue_params(lif, &start_qparams);
			err = ionic_txrx_alloc(lif);
			if (err) {
				dev_err(lif->ionic->dev,
					"CMB restore failed: %d\n", err);
				goto err_out;
			}
		}

		err = ionic_start_queues_reconfig(lif);
		if (err) {
			dev_err(lif->ionic->dev,
				"CMB reconfig failed: %d\n", err);
			goto err_out;
		}
	}

err_out:
	/* This was detached in ionic_stop_queues_reconfig() */
	netif_device_attach(lif->netdev);

	return err;
}

static void ionic_swap_queues(struct ionic_qcq *a, struct ionic_qcq *b)
{
	/* only swapping the queues and napi, not flags or other stuff */
	swap(a->napi,         b->napi);

	if (a->q.type == IONIC_QTYPE_RXQ) {
		swap(a->q.page_pool, b->q.page_pool);
		a->q.page_pool->p.napi = &a->napi;
		if (b->q.page_pool)  /* is NULL when increasing queue count */

Annotation

Implementation Notes