drivers/target/target_core_stat.c

Source file repositories/reference/linux-study-clean/drivers/target/target_core_stat.c

File Facts

System
Linux kernel
Corpus path
drivers/target/target_core_stat.c
Extension
.c
Size
36530 bytes
Lines
1313
Domain
Driver Families
Bucket
drivers/target
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-or-later
/*******************************************************************************
 * Filename:  target_core_stat.c
 *
 * Modern ConfigFS group context specific statistics based on original
 * target_core_mib.c code
 *
 * (c) Copyright 2006-2013 Datera, Inc.
 *
 * Nicholas A. Bellinger <nab@linux-iscsi.org>
 *
 ******************************************************************************/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/timer.h>
#include <linux/string.h>
#include <linux/utsname.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/configfs.h>

#include <target/target_core_base.h>
#include <target/target_core_backend.h>
#include <target/target_core_fabric.h>

#include "target_core_internal.h"

#ifndef INITIAL_JIFFIES
#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
#endif

#define SCSI_LU_INDEX			1
#define LU_COUNT			1

/*
 * SCSI Device Table
 */

static struct se_device *to_stat_dev(struct config_item *item)
{
	struct se_dev_stat_grps *sgrps = container_of(to_config_group(item),
			struct se_dev_stat_grps, scsi_dev_group);
	return container_of(sgrps, struct se_device, dev_stat_grps);
}

static ssize_t target_stat_inst_show(struct config_item *item, char *page)
{
	struct se_hba *hba = to_stat_dev(item)->se_hba;

	return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
}

static ssize_t target_stat_indx_show(struct config_item *item, char *page)
{
	return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->dev_index);
}

static ssize_t target_stat_role_show(struct config_item *item, char *page)
{
	return snprintf(page, PAGE_SIZE, "Target\n");
}

static ssize_t target_stat_ports_show(struct config_item *item, char *page)
{
	return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->export_count);
}

CONFIGFS_ATTR_RO(target_stat_, inst);
CONFIGFS_ATTR_RO(target_stat_, indx);
CONFIGFS_ATTR_RO(target_stat_, role);
CONFIGFS_ATTR_RO(target_stat_, ports);

static struct configfs_attribute *target_stat_scsi_dev_attrs[] = {
	&target_stat_attr_inst,
	&target_stat_attr_indx,
	&target_stat_attr_role,
	&target_stat_attr_ports,
	NULL,
};

static const struct config_item_type target_stat_scsi_dev_cit = {
	.ct_attrs		= target_stat_scsi_dev_attrs,
	.ct_owner		= THIS_MODULE,
};

/*
 * SCSI Target Device Table
 */

Annotation

Implementation Notes