drivers/s390/net/ctcm_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/s390/net/ctcm_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/net/ctcm_sysfs.c- Extension
.c- Size
- 5522 bytes
- Lines
- 210
- Domain
- Driver Families
- Bucket
- drivers/s390
- 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/device.hlinux/sysfs.hlinux/slab.hctcm_main.h
Detected Declarations
function ctcm_buffer_showfunction ctcm_buffer_writefunction ctcm_print_statisticsfunction stats_showfunction stats_writefunction ctcm_proto_showfunction ctcm_proto_storefunction ctcm_type_show
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright IBM Corp. 2007, 2007
* Authors: Peter Tiedemann (ptiedem@de.ibm.com)
*
*/
#undef DEBUG
#undef DEBUGDATA
#undef DEBUGCCW
#define pr_fmt(fmt) "ctcm: " fmt
#include <linux/device.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
#include "ctcm_main.h"
/*
* sysfs attributes
*/
static ssize_t ctcm_buffer_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctcm_priv *priv = dev_get_drvdata(dev);
if (!priv)
return -ENODEV;
return sysfs_emit(buf, "%d\n", priv->buffer_size);
}
static ssize_t ctcm_buffer_write(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct net_device *ndev;
unsigned int bs1;
struct ctcm_priv *priv = dev_get_drvdata(dev);
int rc;
if (!(priv && priv->channel[CTCM_READ] &&
priv->channel[CTCM_READ]->netdev)) {
CTCM_DBF_TEXT(SETUP, CTC_DBF_ERROR, "bfnondev");
return -ENODEV;
}
ndev = priv->channel[CTCM_READ]->netdev;
rc = kstrtouint(buf, 0, &bs1);
if (rc)
goto einval;
if (bs1 > CTCM_BUFSIZE_LIMIT)
goto einval;
if (bs1 < (576 + LL_HEADER_LENGTH + 2))
goto einval;
priv->buffer_size = bs1; /* just to overwrite the default */
if ((ndev->flags & IFF_RUNNING) &&
(bs1 < (ndev->mtu + LL_HEADER_LENGTH + 2)))
goto einval;
priv->channel[CTCM_READ]->max_bufsize = bs1;
priv->channel[CTCM_WRITE]->max_bufsize = bs1;
if (!(ndev->flags & IFF_RUNNING))
ndev->mtu = bs1 - LL_HEADER_LENGTH - 2;
priv->channel[CTCM_READ]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED;
priv->channel[CTCM_WRITE]->flags |= CHANNEL_FLAGS_BUFSIZE_CHANGED;
CTCM_DBF_DEV(SETUP, ndev, buf);
return count;
einval:
CTCM_DBF_DEV(SETUP, ndev, "buff_err");
return -EINVAL;
}
static void ctcm_print_statistics(struct ctcm_priv *priv)
{
char *sbuf;
char *p;
if (!priv)
return;
sbuf = kmalloc(2048, GFP_KERNEL);
if (sbuf == NULL)
return;
p = sbuf;
p += scnprintf(p, CTCM_STATSIZE_LIMIT, " Device FSM state: %s\n",
fsm_getstate_str(priv->fsm));
p += scnprintf(p, CTCM_STATSIZE_LIMIT, " RX channel FSM state: %s\n",
Annotation
- Immediate include surface: `linux/device.h`, `linux/sysfs.h`, `linux/slab.h`, `ctcm_main.h`.
- Detected declarations: `function ctcm_buffer_show`, `function ctcm_buffer_write`, `function ctcm_print_statistics`, `function stats_show`, `function stats_write`, `function ctcm_proto_show`, `function ctcm_proto_store`, `function ctcm_type_show`.
- Atlas domain: Driver Families / drivers/s390.
- 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.