drivers/net/ethernet/netronome/nfp/flower/main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/flower/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/flower/main.c- Extension
.c- Size
- 25214 bytes
- Lines
- 1033
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/etherdevice.hlinux/lockdep.hlinux/pci.hlinux/skbuff.hlinux/vmalloc.hnet/devlink.hnet/dst_metadata.hmain.h../nfpcore/nfp_cpp.h../nfpcore/nfp_nffw.h../nfpcore/nfp_nsp.h../nfp_app.h../nfp_main.h../nfp_net.h../nfp_net_repr.h../nfp_port.h./cmsg.h
Detected Declarations
function eswitch_mode_getfunction nfp_flower_lookup_internal_port_idfunction nfp_flower_get_internal_port_idfunction nfp_flower_get_port_id_from_netdevfunction nfp_flower_get_netdev_from_internal_port_idfunction nfp_flower_free_internal_port_idfunction nfp_flower_internal_port_event_handlerfunction nfp_flower_internal_port_initfunction nfp_flower_internal_port_cleanupfunction nfp_flower_non_repr_priv_lookupfunction __nfp_flower_non_repr_priv_getfunction nfp_flower_non_repr_priv_getfunction __nfp_flower_non_repr_priv_putfunction nfp_flower_non_repr_priv_putfunction nfp_flower_repr_get_type_and_portfunction nfp_flower_dev_getfunction nfp_flower_reprs_reifyfunction nfp_flower_wait_repr_reifyfunction atomic_readfunction nfp_flower_repr_netdev_openfunction nfp_flower_repr_netdev_stopfunction nfp_flower_repr_netdev_cleanfunction nfp_flower_repr_netdev_precleanfunction nfp_flower_sriov_disablefunction nfp_flower_spawn_vnic_reprsfunction nfp_flower_sriov_enablefunction nfp_flower_spawn_phy_reprsfunction nfp_flower_vnic_allocfunction nfp_flower_vnic_cleanfunction nfp_flower_vnic_initfunction nfp_flower_wait_host_bitfunction nfp_flower_sync_feature_bitsfunction nfp_flower_initfunction nfp_flower_cleanfunction nfp_flower_check_ackfunction nfp_flower_repr_change_mtufunction nfp_flower_check_ackfunction nfp_flower_startfunction nfp_flower_stopfunction nfp_flower_netdev_event
Annotated Snippet
if (entry == netdev) {
id = i;
break;
}
rcu_read_unlock();
return id;
}
static int
nfp_flower_get_internal_port_id(struct nfp_app *app, struct net_device *netdev)
{
struct nfp_flower_priv *priv = app->priv;
int id;
id = nfp_flower_lookup_internal_port_id(priv, netdev);
if (id > 0)
return id;
idr_preload(GFP_ATOMIC);
spin_lock_bh(&priv->internal_ports.lock);
id = idr_alloc(&priv->internal_ports.port_ids, netdev,
NFP_MIN_INT_PORT_ID, NFP_MAX_INT_PORT_ID, GFP_ATOMIC);
spin_unlock_bh(&priv->internal_ports.lock);
idr_preload_end();
return id;
}
u32 nfp_flower_get_port_id_from_netdev(struct nfp_app *app,
struct net_device *netdev)
{
struct nfp_flower_priv *priv = app->priv;
int ext_port;
int gid;
if (nfp_netdev_is_nfp_repr(netdev)) {
return nfp_repr_get_port_id(netdev);
} else if (nfp_flower_internal_port_can_offload(app, netdev)) {
ext_port = nfp_flower_get_internal_port_id(app, netdev);
if (ext_port < 0)
return 0;
return nfp_flower_internal_port_get_port_id(ext_port);
} else if (netif_is_lag_master(netdev) &&
priv->flower_ext_feats & NFP_FL_FEATS_TUNNEL_NEIGH_LAG) {
gid = nfp_flower_lag_get_output_id(app, netdev);
if (gid < 0)
return 0;
return (NFP_FL_LAG_OUT | gid);
}
return 0;
}
static struct net_device *
nfp_flower_get_netdev_from_internal_port_id(struct nfp_app *app, int port_id)
{
struct nfp_flower_priv *priv = app->priv;
struct net_device *netdev;
rcu_read_lock();
netdev = idr_find(&priv->internal_ports.port_ids, port_id);
rcu_read_unlock();
return netdev;
}
static void
nfp_flower_free_internal_port_id(struct nfp_app *app, struct net_device *netdev)
{
struct nfp_flower_priv *priv = app->priv;
int id;
id = nfp_flower_lookup_internal_port_id(priv, netdev);
if (!id)
return;
spin_lock_bh(&priv->internal_ports.lock);
idr_remove(&priv->internal_ports.port_ids, id);
spin_unlock_bh(&priv->internal_ports.lock);
}
static int
nfp_flower_internal_port_event_handler(struct nfp_app *app,
struct net_device *netdev,
unsigned long event)
{
if (event == NETDEV_UNREGISTER &&
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/lockdep.h`, `linux/pci.h`, `linux/skbuff.h`, `linux/vmalloc.h`, `net/devlink.h`, `net/dst_metadata.h`, `main.h`.
- Detected declarations: `function eswitch_mode_get`, `function nfp_flower_lookup_internal_port_id`, `function nfp_flower_get_internal_port_id`, `function nfp_flower_get_port_id_from_netdev`, `function nfp_flower_get_netdev_from_internal_port_id`, `function nfp_flower_free_internal_port_id`, `function nfp_flower_internal_port_event_handler`, `function nfp_flower_internal_port_init`, `function nfp_flower_internal_port_cleanup`, `function nfp_flower_non_repr_priv_lookup`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.