drivers/net/ethernet/netronome/nfp/nfp_port.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfp_port.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfp_port.c- Extension
.c- Size
- 5060 bytes
- Lines
- 226
- 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.
- 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/lockdep.hlinux/netdevice.hnfpcore/nfp_cpp.hnfpcore/nfp_nsp.hnfp_app.hnfp_main.hnfp_net.hnfp_port.h
Detected Declarations
function nfp_port_get_port_parent_idfunction nfp_port_setup_tcfunction nfp_port_set_featuresfunction nfp_port_get_phys_port_namefunction nfp_port_configurefunction nfp_port_init_phy_portfunction nfp_port_allocfunction nfp_port_free
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/* Copyright (C) 2017-2018 Netronome Systems, Inc. */
#include <linux/lockdep.h>
#include <linux/netdevice.h>
#include "nfpcore/nfp_cpp.h"
#include "nfpcore/nfp_nsp.h"
#include "nfp_app.h"
#include "nfp_main.h"
#include "nfp_net.h"
#include "nfp_port.h"
struct nfp_port *nfp_port_from_netdev(struct net_device *netdev)
{
if (nfp_netdev_is_nfp_net(netdev)) {
struct nfp_net *nn = netdev_priv(netdev);
return nn->port;
}
if (nfp_netdev_is_nfp_repr(netdev)) {
struct nfp_repr *repr = netdev_priv(netdev);
return repr->port;
}
WARN(1, "Unknown netdev type for nfp_port\n");
return NULL;
}
int nfp_port_get_port_parent_id(struct net_device *netdev,
struct netdev_phys_item_id *ppid)
{
struct nfp_port *port;
const u8 *serial;
port = nfp_port_from_netdev(netdev);
if (!port)
return -EOPNOTSUPP;
ppid->id_len = nfp_cpp_serial(port->app->cpp, &serial);
memcpy(&ppid->id, serial, ppid->id_len);
return 0;
}
int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type,
void *type_data)
{
struct nfp_port *port;
port = nfp_port_from_netdev(netdev);
if (!port)
return -EOPNOTSUPP;
return nfp_app_setup_tc(port->app, netdev, type, type_data);
}
int nfp_port_set_features(struct net_device *netdev, netdev_features_t features)
{
struct nfp_port *port;
port = nfp_port_from_netdev(netdev);
if (!port)
return 0;
if ((netdev->features & NETIF_F_HW_TC) > (features & NETIF_F_HW_TC) &&
port->tc_offload_cnt) {
netdev_err(netdev, "Cannot disable HW TC offload while offloads active\n");
return -EBUSY;
}
return 0;
}
struct nfp_eth_table_port *__nfp_port_get_eth_port(struct nfp_port *port)
{
if (!port)
return NULL;
if (port->type != NFP_PORT_PHYS_PORT)
return NULL;
return port->eth_port;
}
struct nfp_eth_table_port *nfp_port_get_eth_port(struct nfp_port *port)
{
if (!__nfp_port_get_eth_port(port))
Annotation
- Immediate include surface: `linux/lockdep.h`, `linux/netdevice.h`, `nfpcore/nfp_cpp.h`, `nfpcore/nfp_nsp.h`, `nfp_app.h`, `nfp_main.h`, `nfp_net.h`, `nfp_port.h`.
- Detected declarations: `function nfp_port_get_port_parent_id`, `function nfp_port_setup_tc`, `function nfp_port_set_features`, `function nfp_port_get_phys_port_name`, `function nfp_port_configure`, `function nfp_port_init_phy_port`, `function nfp_port_alloc`, `function nfp_port_free`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.