drivers/net/ethernet/intel/ice/ice_sf_eth.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_sf_eth.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/intel/ice/ice_sf_eth.c
Extension
.c
Size
8250 bytes
Lines
332
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 ice_sf_netdev_ops = {
	.ndo_open = ice_open,
	.ndo_stop = ice_stop,
	.ndo_start_xmit = ice_start_xmit,
	.ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid,
	.ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid,
	.ndo_change_mtu = ice_change_mtu,
	.ndo_get_stats64 = ice_get_stats64,
	.ndo_tx_timeout = ice_tx_timeout,
	.ndo_bpf = ice_xdp,
	.ndo_xdp_xmit = ice_xdp_xmit,
	.ndo_xsk_wakeup = ice_xsk_wakeup,
};

/**
 * ice_sf_cfg_netdev - Allocate, configure and register a netdev
 * @dyn_port: subfunction associated with configured netdev
 * @devlink_port: subfunction devlink port to be linked with netdev
 *
 * Return: 0 on success, negative value on failure
 */
static int ice_sf_cfg_netdev(struct ice_dynamic_port *dyn_port,
			     struct devlink_port *devlink_port)
{
	struct ice_vsi *vsi = dyn_port->vsi;
	struct ice_netdev_priv *np;
	struct net_device *netdev;
	int err;

	netdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq,
				    vsi->alloc_rxq);
	if (!netdev)
		return -ENOMEM;

	SET_NETDEV_DEV(netdev, &vsi->back->pdev->dev);
	set_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
	vsi->netdev = netdev;
	np = netdev_priv(netdev);
	np->vsi = vsi;

	ice_set_netdev_features(netdev);

	netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
			       NETDEV_XDP_ACT_XSK_ZEROCOPY |
			       NETDEV_XDP_ACT_RX_SG;
	netdev->xdp_zc_max_segs = ICE_MAX_BUF_TXD;

	eth_hw_addr_set(netdev, dyn_port->hw_addr);
	ether_addr_copy(netdev->perm_addr, dyn_port->hw_addr);
	netdev->netdev_ops = &ice_sf_netdev_ops;
	SET_NETDEV_DEVLINK_PORT(netdev, devlink_port);

	err = register_netdev(netdev);
	if (err) {
		free_netdev(netdev);
		vsi->netdev = NULL;
		return -ENOMEM;
	}
	set_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
	netif_carrier_off(netdev);
	netif_tx_stop_all_queues(netdev);

	return 0;
}

static void ice_sf_decfg_netdev(struct ice_vsi *vsi)
{
	unregister_netdev(vsi->netdev);
	clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state);
	free_netdev(vsi->netdev);
	vsi->netdev = NULL;
	clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
}

/**
 * ice_sf_dev_probe - subfunction driver probe function
 * @adev: pointer to the auxiliary device
 * @id: pointer to the auxiliary_device id
 *
 * Configure VSI and netdev resources for the subfunction device.
 *
 * Return: zero on success or an error code on failure.
 */
static int ice_sf_dev_probe(struct auxiliary_device *adev,
			    const struct auxiliary_device_id *id)
{
	struct ice_sf_dev *sf_dev = ice_adev_to_sf_dev(adev);
	struct ice_dynamic_port *dyn_port = sf_dev->dyn_port;
	struct ice_vsi *vsi = dyn_port->vsi;
	struct ice_pf *pf = dyn_port->pf;

Annotation

Implementation Notes