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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
ice.hice_lib.hice_txrx.hice_fltr.hice_sf_eth.hdevlink/devlink.hdevlink/port.h
Detected Declarations
function ice_sf_cfg_netdevfunction ice_sf_decfg_netdevfunction ice_sf_dev_probefunction ice_sf_dev_removefunction ice_sf_driver_registerfunction ice_sf_driver_unregisterfunction ice_sf_dev_releasefunction ice_sf_eth_activatefunction ice_sf_eth_deactivate
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
- Immediate include surface: `ice.h`, `ice_lib.h`, `ice_txrx.h`, `ice_fltr.h`, `ice_sf_eth.h`, `devlink/devlink.h`, `devlink/port.h`.
- Detected declarations: `function ice_sf_cfg_netdev`, `function ice_sf_decfg_netdev`, `function ice_sf_dev_probe`, `function ice_sf_dev_remove`, `function ice_sf_driver_register`, `function ice_sf_driver_unregister`, `function ice_sf_dev_release`, `function ice_sf_eth_activate`, `function ice_sf_eth_deactivate`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
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.