net/dsa/conduit.c
Source file repositories/reference/linux-study-clean/net/dsa/conduit.c
File Facts
- System
- Linux kernel
- Corpus path
net/dsa/conduit.c- Extension
.c- Size
- 13602 bytes
- Lines
- 536
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- 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/ethtool.hlinux/netdevice.hlinux/netlink.hnet/dsa.hnet/netdev_lock.hconduit.hdsa.hport.htag.h
Detected Declarations
function Copyrightfunction dsa_conduit_get_regsfunction dsa_conduit_append_port_statsfunction dsa_conduit_get_ethtool_statsfunction list_for_each_entryfunction dsa_conduit_get_ethtool_phy_statsfunction dsa_conduit_append_port_sset_countfunction dsa_conduit_get_sset_countfunction list_for_each_entryfunction dsa_conduit_append_port_stringsfunction dsa_conduit_get_stringsfunction list_for_each_entryfunction __dsa_conduit_hwtstamp_validatefunction list_for_each_entryfunction dsa_conduit_ethtool_setupfunction dsa_conduit_ethtool_teardownfunction dev_uc_addfunction tagging_showfunction tagging_storefunction dsa_conduit_reset_mtufunction dsa_conduit_setupfunction dsa_conduit_teardownfunction dsa_conduit_lag_setupfunction dsa_conduit_lag_teardown
Annotated Snippet
if (dsa_port_supports_hwtstamp(dp)) {
NL_SET_ERR_MSG(extack,
"HW timestamping not allowed on DSA conduit when switch supports the operation");
return -EBUSY;
}
}
return 0;
}
static int dsa_conduit_ethtool_setup(struct net_device *dev)
{
struct dsa_port *cpu_dp = dev->dsa_ptr;
struct dsa_switch *ds = cpu_dp->ds;
struct ethtool_ops *ops;
if (netif_is_lag_master(dev))
return 0;
ops = devm_kzalloc(ds->dev, sizeof(*ops), GFP_KERNEL);
if (!ops)
return -ENOMEM;
cpu_dp->orig_ethtool_ops = dev->ethtool_ops;
if (cpu_dp->orig_ethtool_ops)
memcpy(ops, cpu_dp->orig_ethtool_ops, sizeof(*ops));
ops->get_regs_len = dsa_conduit_get_regs_len;
ops->get_regs = dsa_conduit_get_regs;
ops->get_sset_count = dsa_conduit_get_sset_count;
ops->get_ethtool_stats = dsa_conduit_get_ethtool_stats;
ops->get_strings = dsa_conduit_get_strings;
ops->get_ethtool_phy_stats = dsa_conduit_get_ethtool_phy_stats;
dev->ethtool_ops = ops;
return 0;
}
static void dsa_conduit_ethtool_teardown(struct net_device *dev)
{
struct dsa_port *cpu_dp = dev->dsa_ptr;
if (netif_is_lag_master(dev))
return;
dev->ethtool_ops = cpu_dp->orig_ethtool_ops;
cpu_dp->orig_ethtool_ops = NULL;
}
/* Keep the conduit always promiscuous if the tagging protocol requires that
* (garbles MAC DA) or if it doesn't support unicast filtering, case in which
* it would revert to promiscuous mode as soon as we call dev_uc_add() on it
* anyway.
*/
static void dsa_conduit_set_promiscuity(struct net_device *dev, int inc)
{
const struct dsa_device_ops *ops = dev->dsa_ptr->tag_ops;
if ((dev->priv_flags & IFF_UNICAST_FLT) && !ops->promisc_on_conduit)
return;
ASSERT_RTNL();
dev_set_promiscuity(dev, inc);
}
static ssize_t tagging_show(struct device *d, struct device_attribute *attr,
char *buf)
{
struct net_device *dev = to_net_dev(d);
struct dsa_port *cpu_dp = dev->dsa_ptr;
return sysfs_emit(buf, "%s\n",
dsa_tag_protocol_to_str(cpu_dp->tag_ops));
}
static ssize_t tagging_store(struct device *d, struct device_attribute *attr,
const char *buf, size_t count)
{
const struct dsa_device_ops *new_tag_ops, *old_tag_ops;
const char *end = strchrnul(buf, '\n'), *name;
struct net_device *dev = to_net_dev(d);
struct dsa_port *cpu_dp = dev->dsa_ptr;
size_t len = end - buf;
int err;
/* Empty string passed */
if (!len)
return -ENOPROTOOPT;
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/netdevice.h`, `linux/netlink.h`, `net/dsa.h`, `net/netdev_lock.h`, `conduit.h`, `dsa.h`, `port.h`.
- Detected declarations: `function Copyright`, `function dsa_conduit_get_regs`, `function dsa_conduit_append_port_stats`, `function dsa_conduit_get_ethtool_stats`, `function list_for_each_entry`, `function dsa_conduit_get_ethtool_phy_stats`, `function dsa_conduit_append_port_sset_count`, `function dsa_conduit_get_sset_count`, `function list_for_each_entry`, `function dsa_conduit_append_port_strings`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.