drivers/s390/scsi/zfcp_diag.c
Source file repositories/reference/linux-study-clean/drivers/s390/scsi/zfcp_diag.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/scsi/zfcp_diag.c- Extension
.c- Size
- 8040 bytes
- Lines
- 264
- 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.
- 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/spinlock.hlinux/jiffies.hlinux/string.hlinux/errno.hlinux/slab.hzfcp_diag.hzfcp_ext.hzfcp_def.h
Detected Declarations
function zfcp_diag_adapter_setupfunction zfcp_diag_adapter_freefunction zfcp_diag_update_xdatafunction zfcp_fsf_exchange_port_data_syncfunction zfcp_fsf_exchange_config_data_syncfunction __zfcp_diag_update_bufferfunction __zfcp_diag_test_buffer_age_isfreshfunction zfcp_diag_update_buffer_limited
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* zfcp device driver
*
* Functions to handle diagnostics.
*
* Copyright IBM Corp. 2018
*/
#include <linux/spinlock.h>
#include <linux/jiffies.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include "zfcp_diag.h"
#include "zfcp_ext.h"
#include "zfcp_def.h"
static DECLARE_WAIT_QUEUE_HEAD(__zfcp_diag_publish_wait);
/**
* zfcp_diag_adapter_setup() - Setup storage for adapter diagnostics.
* @adapter: the adapter to setup diagnostics for.
*
* Creates the data-structures to store the diagnostics for an adapter. This
* overwrites whatever was stored before at &zfcp_adapter->diagnostics!
*
* Return:
* * 0 - Everyting is OK
* * -ENOMEM - Could not allocate all/parts of the data-structures;
* &zfcp_adapter->diagnostics remains unchanged
*/
int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter)
{
struct zfcp_diag_adapter *diag;
struct zfcp_diag_header *hdr;
diag = kzalloc_obj(*diag);
if (diag == NULL)
return -ENOMEM;
diag->max_age = (5 * 1000); /* default value: 5 s */
/* setup header for port_data */
hdr = &diag->port_data.header;
spin_lock_init(&hdr->access_lock);
hdr->buffer = &diag->port_data.data;
hdr->buffer_size = sizeof(diag->port_data.data);
/* set the timestamp so that the first test on age will always fail */
hdr->timestamp = jiffies - msecs_to_jiffies(diag->max_age);
/* setup header for config_data */
hdr = &diag->config_data.header;
spin_lock_init(&hdr->access_lock);
hdr->buffer = &diag->config_data.data;
hdr->buffer_size = sizeof(diag->config_data.data);
/* set the timestamp so that the first test on age will always fail */
hdr->timestamp = jiffies - msecs_to_jiffies(diag->max_age);
adapter->diagnostics = diag;
return 0;
}
/**
* zfcp_diag_adapter_free() - Frees all adapter diagnostics allocations.
* @adapter: the adapter whose diagnostic structures should be freed.
*
* Frees all data-structures in the given adapter that store diagnostics
* information. Can savely be called with partially setup diagnostics.
*/
void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter)
{
kfree(adapter->diagnostics);
adapter->diagnostics = NULL;
}
/**
* zfcp_diag_update_xdata() - Update a diagnostics buffer.
* @hdr: the meta data to update.
* @data: data to use for the update.
* @incomplete: flag stating whether the data in @data is incomplete.
*/
void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
const void *const data, const bool incomplete)
{
const unsigned long capture_timestamp = jiffies;
unsigned long flags;
Annotation
- Immediate include surface: `linux/spinlock.h`, `linux/jiffies.h`, `linux/string.h`, `linux/errno.h`, `linux/slab.h`, `zfcp_diag.h`, `zfcp_ext.h`, `zfcp_def.h`.
- Detected declarations: `function zfcp_diag_adapter_setup`, `function zfcp_diag_adapter_free`, `function zfcp_diag_update_xdata`, `function zfcp_fsf_exchange_port_data_sync`, `function zfcp_fsf_exchange_config_data_sync`, `function __zfcp_diag_update_buffer`, `function __zfcp_diag_test_buffer_age_isfresh`, `function zfcp_diag_update_buffer_limited`.
- Atlas domain: Driver Families / drivers/s390.
- 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.