License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-07-02 16:56:38 +08:00
|
|
|
/*
|
|
|
|
* zfcp device driver
|
|
|
|
*
|
|
|
|
* sysfs attributes.
|
|
|
|
*
|
2020-03-13 01:45:01 +08:00
|
|
|
* Copyright IBM Corp. 2008, 2020
|
2008-07-02 16:56:38 +08:00
|
|
|
*/
|
|
|
|
|
2008-12-25 20:39:53 +08:00
|
|
|
#define KMSG_COMPONENT "zfcp"
|
|
|
|
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver
This adds an interface to read the diagnostics of the local SFP transceiver
of an FCP-Channel from userspace. This comes in the form of new sysfs
entries that are attached to the CCW device representing the FCP
device. Each type of data gets its own sysfs entry; the whole collection of
entries is pooled into a new child-directory of the CCW device node:
"diagnostics".
Adds sysfs entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid
* temperature: transceiver temp.; unit 1/256°C;
range [-128°C, +128°C]
* vcc: supply voltage; unit 100μV; range [0, 6.55V]
* tx_bias: transmitter laser bias current; unit 2μA;
range [0, 131mA]
* tx_power: coupled TX output power; unit 0.1μW; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1μW; range [0, 6.5mW]
* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;
{0, 1}; 1 - active
* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+
This is only supported if the FCP-Channel in turn supports reporting the
SFP Diagnostic Data, otherwise read() on these new entries will return
EOPNOTSUPP (this affects only adapters older than FICON Express8S, on
Mainframe generations older than z14). Other possible errors for read()
include ENOLINK, ENODEV and ENOMEM.
With this patch the userspace-interface will only read data stored in
the corresponding "diagnostic buffer" (that was stored during completion
of an previous Exchange Port Data command). Implicit updating will
follow later in this series.
Link: https://lore.kernel.org/r/1f9cce7c829c881e7d71a3f10c5b57f3dd84ab32.1572018132.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-10-26 00:12:47 +08:00
|
|
|
#include "zfcp_diag.h"
|
2008-07-02 16:56:38 +08:00
|
|
|
#include "zfcp_ext.h"
|
|
|
|
|
|
|
|
#define ZFCP_DEV_ATTR(_feat, _name, _mode, _show, _store) \
|
|
|
|
struct device_attribute dev_attr_##_feat##_##_name = __ATTR(_name, _mode,\
|
|
|
|
_show, _store)
|
|
|
|
#define ZFCP_DEFINE_ATTR(_feat_def, _feat, _name, _format, _value) \
|
|
|
|
static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \
|
|
|
|
struct device_attribute *at,\
|
|
|
|
char *buf) \
|
|
|
|
{ \
|
2010-02-17 18:18:56 +08:00
|
|
|
struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \
|
2008-07-02 16:56:38 +08:00
|
|
|
\
|
|
|
|
return sprintf(buf, _format, _value); \
|
|
|
|
} \
|
|
|
|
static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \
|
|
|
|
zfcp_sysfs_##_feat##_##_name##_show, NULL);
|
|
|
|
|
2013-08-22 23:45:38 +08:00
|
|
|
#define ZFCP_DEFINE_ATTR_CONST(_feat, _name, _format, _value) \
|
|
|
|
static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \
|
|
|
|
struct device_attribute *at,\
|
|
|
|
char *buf) \
|
|
|
|
{ \
|
|
|
|
return sprintf(buf, _format, _value); \
|
|
|
|
} \
|
|
|
|
static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \
|
|
|
|
zfcp_sysfs_##_feat##_##_name##_show, NULL);
|
|
|
|
|
2009-11-24 23:54:00 +08:00
|
|
|
#define ZFCP_DEFINE_A_ATTR(_name, _format, _value) \
|
|
|
|
static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \
|
|
|
|
struct device_attribute *at,\
|
|
|
|
char *buf) \
|
|
|
|
{ \
|
|
|
|
struct ccw_device *cdev = to_ccwdev(dev); \
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev); \
|
|
|
|
int i; \
|
|
|
|
\
|
|
|
|
if (!adapter) \
|
|
|
|
return -ENODEV; \
|
|
|
|
\
|
|
|
|
i = sprintf(buf, _format, _value); \
|
|
|
|
zfcp_ccw_adapter_put(adapter); \
|
|
|
|
return i; \
|
|
|
|
} \
|
|
|
|
static ZFCP_DEV_ATTR(adapter, _name, S_IRUGO, \
|
|
|
|
zfcp_sysfs_adapter_##_name##_show, NULL);
|
|
|
|
|
|
|
|
ZFCP_DEFINE_A_ATTR(status, "0x%08x\n", atomic_read(&adapter->status));
|
|
|
|
ZFCP_DEFINE_A_ATTR(peer_wwnn, "0x%016llx\n",
|
|
|
|
(unsigned long long) adapter->peer_wwnn);
|
|
|
|
ZFCP_DEFINE_A_ATTR(peer_wwpn, "0x%016llx\n",
|
|
|
|
(unsigned long long) adapter->peer_wwpn);
|
|
|
|
ZFCP_DEFINE_A_ATTR(peer_d_id, "0x%06x\n", adapter->peer_d_id);
|
|
|
|
ZFCP_DEFINE_A_ATTR(card_version, "0x%04x\n", adapter->hydra_version);
|
|
|
|
ZFCP_DEFINE_A_ATTR(lic_version, "0x%08x\n", adapter->fsf_lic_version);
|
|
|
|
ZFCP_DEFINE_A_ATTR(hardware_version, "0x%08x\n", adapter->hardware_version);
|
|
|
|
ZFCP_DEFINE_A_ATTR(in_recovery, "%d\n", (atomic_read(&adapter->status) &
|
|
|
|
ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
|
2008-07-02 16:56:38 +08:00
|
|
|
|
|
|
|
ZFCP_DEFINE_ATTR(zfcp_port, port, status, "0x%08x\n",
|
|
|
|
atomic_read(&port->status));
|
|
|
|
ZFCP_DEFINE_ATTR(zfcp_port, port, in_recovery, "%d\n",
|
|
|
|
(atomic_read(&port->status) &
|
|
|
|
ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
|
2014-11-13 21:59:46 +08:00
|
|
|
ZFCP_DEFINE_ATTR_CONST(port, access_denied, "%d\n", 0);
|
2008-07-02 16:56:38 +08:00
|
|
|
|
|
|
|
ZFCP_DEFINE_ATTR(zfcp_unit, unit, status, "0x%08x\n",
|
2010-09-08 20:39:55 +08:00
|
|
|
zfcp_unit_sdev_status(unit));
|
2008-07-02 16:56:38 +08:00
|
|
|
ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n",
|
2010-09-08 20:39:55 +08:00
|
|
|
(zfcp_unit_sdev_status(unit) &
|
2008-07-02 16:56:38 +08:00
|
|
|
ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
|
|
|
|
ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n",
|
2010-09-08 20:39:55 +08:00
|
|
|
(zfcp_unit_sdev_status(unit) &
|
2008-07-02 16:56:38 +08:00
|
|
|
ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
|
2013-08-22 23:45:38 +08:00
|
|
|
ZFCP_DEFINE_ATTR_CONST(unit, access_shared, "%d\n", 0);
|
|
|
|
ZFCP_DEFINE_ATTR_CONST(unit, access_readonly, "%d\n", 0);
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2010-09-08 20:39:53 +08:00
|
|
|
static ssize_t zfcp_sysfs_port_failed_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2010-09-08 20:39:53 +08:00
|
|
|
if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
|
|
|
|
return sprintf(buf, "1\n");
|
|
|
|
|
|
|
|
return sprintf(buf, "0\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_port_failed_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
|
|
|
|
unsigned long val;
|
|
|
|
|
2013-08-22 23:49:32 +08:00
|
|
|
if (kstrtoul(buf, 0, &val) || val != 0)
|
2010-09-08 20:39:53 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-09-08 20:40:01 +08:00
|
|
|
zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_RUNNING);
|
2010-12-02 22:16:16 +08:00
|
|
|
zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, "sypfai2");
|
2010-09-08 20:39:53 +08:00
|
|
|
zfcp_erp_wait(port->adapter);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(port, failed, S_IWUSR | S_IRUGO,
|
|
|
|
zfcp_sysfs_port_failed_show,
|
|
|
|
zfcp_sysfs_port_failed_store);
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_unit_failed_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
|
2010-09-08 20:39:55 +08:00
|
|
|
struct scsi_device *sdev;
|
|
|
|
unsigned int status, failed = 1;
|
|
|
|
|
|
|
|
sdev = zfcp_unit_sdev(unit);
|
|
|
|
if (sdev) {
|
|
|
|
status = atomic_read(&sdev_to_zfcp(sdev)->status);
|
|
|
|
failed = status & ZFCP_STATUS_COMMON_ERP_FAILED ? 1 : 0;
|
|
|
|
scsi_device_put(sdev);
|
|
|
|
}
|
2010-09-08 20:39:53 +08:00
|
|
|
|
2010-09-08 20:39:55 +08:00
|
|
|
return sprintf(buf, "%d\n", failed);
|
2010-09-08 20:39:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
|
|
|
|
unsigned long val;
|
2010-09-08 20:39:55 +08:00
|
|
|
struct scsi_device *sdev;
|
2010-09-08 20:39:53 +08:00
|
|
|
|
2013-08-22 23:49:32 +08:00
|
|
|
if (kstrtoul(buf, 0, &val) || val != 0)
|
2010-09-08 20:39:53 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-09-08 20:39:55 +08:00
|
|
|
sdev = zfcp_unit_sdev(unit);
|
|
|
|
if (sdev) {
|
2010-09-08 20:40:01 +08:00
|
|
|
zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_RUNNING);
|
2010-09-08 20:39:55 +08:00
|
|
|
zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED,
|
2010-12-02 22:16:16 +08:00
|
|
|
"syufai2");
|
2010-09-08 20:39:55 +08:00
|
|
|
zfcp_erp_wait(unit->port->adapter);
|
|
|
|
} else
|
|
|
|
zfcp_unit_scsi_scan(unit);
|
2010-09-08 20:39:53 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(unit, failed, S_IWUSR | S_IRUGO,
|
|
|
|
zfcp_sysfs_unit_failed_show,
|
|
|
|
zfcp_sysfs_unit_failed_store);
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2009-11-24 23:54:00 +08:00
|
|
|
static ssize_t zfcp_sysfs_adapter_failed_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
|
|
|
|
i = sprintf(buf, "1\n");
|
|
|
|
else
|
|
|
|
i = sprintf(buf, "0\n");
|
|
|
|
|
|
|
|
zfcp_ccw_adapter_put(adapter);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_adapter_failed_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
|
|
|
|
unsigned long val;
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-08-22 23:49:32 +08:00
|
|
|
if (kstrtoul(buf, 0, &val) || val != 0) {
|
2009-11-24 23:54:00 +08:00
|
|
|
retval = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-05-18 01:15:03 +08:00
|
|
|
zfcp_erp_adapter_reset_sync(adapter, "syafai2");
|
2009-11-24 23:54:00 +08:00
|
|
|
out:
|
|
|
|
zfcp_ccw_adapter_put(adapter);
|
|
|
|
return retval ? retval : (ssize_t) count;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(adapter, failed, S_IWUSR | S_IRUGO,
|
|
|
|
zfcp_sysfs_adapter_failed_show,
|
|
|
|
zfcp_sysfs_adapter_failed_store);
|
|
|
|
|
2008-07-02 16:56:38 +08:00
|
|
|
static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2009-11-24 23:54:00 +08:00
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
|
2020-05-09 01:23:34 +08:00
|
|
|
int retval = 0;
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2009-11-24 23:54:00 +08:00
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2020-05-09 01:23:34 +08:00
|
|
|
/*
|
|
|
|
* If `scsi_host` is missing, we can't schedule `scan_work`, as it
|
|
|
|
* makes use of the corresponding fc_host object. But this state is
|
|
|
|
* only possible if xconfig/xport data has never completed yet,
|
|
|
|
* and we couldn't successfully scan for ports anyway.
|
|
|
|
*/
|
|
|
|
if (adapter->scsi_host == NULL) {
|
|
|
|
retval = -ENODEV;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
zfcp: auto port scan resiliency
This patch improves the Fibre Channel port scan behaviour of the zfcp lldd.
Without it the zfcp device driver may churn up the storage area network by
excessive scanning and scan bursts, particularly in big virtual server
environments, potentially resulting in interference of virtual servers and
reduced availability of storage connectivity.
The two main issues as to the zfcp device drivers automatic port scan in
virtual server environments are frequency and simultaneity.
On the one hand, there is no point in allowing lots of ports scans
in a row. It makes sense, though, to make sure that a scan is conducted
eventually if there has been any indication for potential SAN changes.
On the other hand, lots of virtual servers receiving the same indication
for a SAN change had better not attempt to conduct a scan instantly,
that is, at the same time.
Hence this patch has a two-fold approach for better port scanning:
the introduction of a rate limit to amend frequency issues, and the
introduction of a short random backoff to amend simultaneity issues.
Both approaches boil down to deferred port scans, with delays
comprising parts for both approaches.
The new port scan behaviour is summarised best by:
NEW: NEW:
no_auto_port_rescan random rate flush
backoff limit =wait
adapter resume/thaw yes yes no yes*
adapter online (user) no yes no yes*
port rescan (user) no no no yes
adapter recovery (user) yes yes yes no
adapter recovery (other) yes yes yes no
incoming ELS yes yes yes no
incoming ELS lost yes yes yes no
Implementation is straight-forward by converting an existing worker to
a delayed worker. But care is needed whenever that worker is going to be
flushed (in order to make sure work has been completed), since a flush
operation cancels the timer set up for deferred execution (see * above).
There is a small race window whenever a port scan work starts
running up to the point in time of storing the time stamp for that port
scan. The impact is negligible. Closing that gap isn't trivial, though, and
would the destroy the beauty of a simple work-to-delayed-work conversion.
Signed-off-by: Martin Peschke <mpeschke@linux.vnet.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-13 21:59:48 +08:00
|
|
|
/*
|
|
|
|
* Users wish is our command: immediately schedule and flush a
|
|
|
|
* worker to conduct a synchronous port scan, that is, neither
|
|
|
|
* a random delay nor a rate limit is applied here.
|
|
|
|
*/
|
|
|
|
queue_delayed_work(adapter->work_queue, &adapter->scan_work, 0);
|
|
|
|
flush_delayed_work(&adapter->scan_work);
|
2020-05-09 01:23:34 +08:00
|
|
|
out:
|
2009-11-24 23:54:00 +08:00
|
|
|
zfcp_ccw_adapter_put(adapter);
|
2020-05-09 01:23:34 +08:00
|
|
|
return retval ? retval : (ssize_t) count;
|
2008-07-02 16:56:38 +08:00
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL,
|
|
|
|
zfcp_sysfs_port_rescan_store);
|
|
|
|
|
2012-09-04 21:23:34 +08:00
|
|
|
DEFINE_MUTEX(zfcp_sysfs_port_units_mutex);
|
|
|
|
|
2019-05-23 21:23:46 +08:00
|
|
|
static void zfcp_sysfs_port_set_removing(struct zfcp_port *const port)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&zfcp_sysfs_port_units_mutex);
|
|
|
|
atomic_set(&port->units, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool zfcp_sysfs_port_is_removing(const struct zfcp_port *const port)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&zfcp_sysfs_port_units_mutex);
|
|
|
|
return atomic_read(&port->units) == -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool zfcp_sysfs_port_in_use(struct zfcp_port *const port)
|
|
|
|
{
|
|
|
|
struct zfcp_adapter *const adapter = port->adapter;
|
|
|
|
unsigned long flags;
|
|
|
|
struct scsi_device *sdev;
|
|
|
|
bool in_use = true;
|
|
|
|
|
|
|
|
mutex_lock(&zfcp_sysfs_port_units_mutex);
|
|
|
|
if (atomic_read(&port->units) > 0)
|
|
|
|
goto unlock_port_units_mutex; /* zfcp_unit(s) under port */
|
|
|
|
|
|
|
|
spin_lock_irqsave(adapter->scsi_host->host_lock, flags);
|
|
|
|
__shost_for_each_device(sdev, adapter->scsi_host) {
|
|
|
|
const struct zfcp_scsi_dev *zsdev = sdev_to_zfcp(sdev);
|
|
|
|
|
|
|
|
if (sdev->sdev_state == SDEV_DEL ||
|
|
|
|
sdev->sdev_state == SDEV_CANCEL)
|
|
|
|
continue;
|
|
|
|
if (zsdev->port != port)
|
|
|
|
continue;
|
|
|
|
/* alive scsi_device under port of interest */
|
|
|
|
goto unlock_host_lock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* port is about to be removed, so no more unit_add or slave_alloc */
|
|
|
|
zfcp_sysfs_port_set_removing(port);
|
|
|
|
in_use = false;
|
|
|
|
|
|
|
|
unlock_host_lock:
|
|
|
|
spin_unlock_irqrestore(adapter->scsi_host->host_lock, flags);
|
|
|
|
unlock_port_units_mutex:
|
|
|
|
mutex_unlock(&zfcp_sysfs_port_units_mutex);
|
|
|
|
return in_use;
|
|
|
|
}
|
|
|
|
|
2008-07-02 16:56:38 +08:00
|
|
|
static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2009-11-24 23:54:00 +08:00
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
|
2008-07-02 16:56:38 +08:00
|
|
|
struct zfcp_port *port;
|
2008-10-01 18:42:18 +08:00
|
|
|
u64 wwpn;
|
2009-11-24 23:54:05 +08:00
|
|
|
int retval = -EINVAL;
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2009-11-24 23:54:00 +08:00
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-08-22 23:49:32 +08:00
|
|
|
if (kstrtoull(buf, 0, (unsigned long long *) &wwpn))
|
2008-07-02 16:56:38 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
port = zfcp_get_port_by_wwpn(adapter, wwpn);
|
2009-11-24 23:54:05 +08:00
|
|
|
if (!port)
|
2008-07-02 16:56:38 +08:00
|
|
|
goto out;
|
2009-11-24 23:54:05 +08:00
|
|
|
else
|
|
|
|
retval = 0;
|
2009-11-24 23:53:59 +08:00
|
|
|
|
2019-05-23 21:23:46 +08:00
|
|
|
if (zfcp_sysfs_port_in_use(port)) {
|
2012-09-04 21:23:34 +08:00
|
|
|
retval = -EBUSY;
|
2019-05-23 21:23:45 +08:00
|
|
|
put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */
|
2012-09-04 21:23:34 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2009-11-24 23:53:59 +08:00
|
|
|
write_lock_irq(&adapter->port_list_lock);
|
|
|
|
list_del(&port->list);
|
|
|
|
write_unlock_irq(&adapter->port_list_lock);
|
|
|
|
|
2010-12-02 22:16:16 +08:00
|
|
|
zfcp_erp_port_shutdown(port, 0, "syprs_1");
|
2013-04-26 22:13:48 +08:00
|
|
|
device_unregister(&port->dev);
|
2021-04-15 01:08:03 +08:00
|
|
|
|
|
|
|
put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */
|
2008-07-02 16:56:38 +08:00
|
|
|
out:
|
2009-11-24 23:54:00 +08:00
|
|
|
zfcp_ccw_adapter_put(adapter);
|
2008-07-02 16:56:38 +08:00
|
|
|
return retval ? retval : (ssize_t) count;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(adapter, port_remove, S_IWUSR, NULL,
|
|
|
|
zfcp_sysfs_port_remove_store);
|
|
|
|
|
2019-10-26 00:12:51 +08:00
|
|
|
static ssize_t
|
|
|
|
zfcp_sysfs_adapter_diag_max_age_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(to_ccwdev(dev));
|
|
|
|
ssize_t rc;
|
|
|
|
|
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* ceil(log(2^64 - 1) / log(10)) = 20 */
|
|
|
|
rc = scnprintf(buf, 20 + 2, "%lu\n", adapter->diagnostics->max_age);
|
|
|
|
|
|
|
|
zfcp_ccw_adapter_put(adapter);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
zfcp_sysfs_adapter_diag_max_age_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(to_ccwdev(dev));
|
|
|
|
unsigned long max_age;
|
|
|
|
ssize_t rc;
|
|
|
|
|
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
rc = kstrtoul(buf, 10, &max_age);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
adapter->diagnostics->max_age = max_age;
|
|
|
|
|
|
|
|
rc = count;
|
|
|
|
out:
|
|
|
|
zfcp_ccw_adapter_put(adapter);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(adapter, diag_max_age, 0644,
|
|
|
|
zfcp_sysfs_adapter_diag_max_age_show,
|
|
|
|
zfcp_sysfs_adapter_diag_max_age_store);
|
|
|
|
|
2020-03-13 01:45:01 +08:00
|
|
|
static ssize_t zfcp_sysfs_adapter_fc_security_show(
|
|
|
|
struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct ccw_device *cdev = to_ccwdev(dev);
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
|
|
|
|
unsigned int status;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Adapter status COMMON_OPEN implies xconf data and xport data
|
|
|
|
* was done. Adapter FC Endpoint Security capability remains
|
|
|
|
* unchanged in case of COMMON_ERP_FAILED (e.g. due to local link
|
|
|
|
* down).
|
|
|
|
*/
|
|
|
|
status = atomic_read(&adapter->status);
|
|
|
|
if (0 == (status & ZFCP_STATUS_COMMON_OPEN))
|
|
|
|
i = sprintf(buf, "unknown\n");
|
|
|
|
else if (!(adapter->adapter_features & FSF_FEATURE_FC_SECURITY))
|
|
|
|
i = sprintf(buf, "unsupported\n");
|
|
|
|
else {
|
|
|
|
i = zfcp_fsf_scnprint_fc_security(
|
|
|
|
buf, PAGE_SIZE - 1, adapter->fc_security_algorithms,
|
|
|
|
ZFCP_FSF_PRINT_FMT_LIST);
|
|
|
|
i += scnprintf(buf + i, PAGE_SIZE - i, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
zfcp_ccw_adapter_put(adapter);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(adapter, fc_security, S_IRUGO,
|
|
|
|
zfcp_sysfs_adapter_fc_security_show,
|
|
|
|
NULL);
|
|
|
|
|
2008-07-02 16:56:38 +08:00
|
|
|
static struct attribute *zfcp_adapter_attrs[] = {
|
|
|
|
&dev_attr_adapter_failed.attr,
|
|
|
|
&dev_attr_adapter_in_recovery.attr,
|
|
|
|
&dev_attr_adapter_port_remove.attr,
|
|
|
|
&dev_attr_adapter_port_rescan.attr,
|
|
|
|
&dev_attr_adapter_peer_wwnn.attr,
|
|
|
|
&dev_attr_adapter_peer_wwpn.attr,
|
|
|
|
&dev_attr_adapter_peer_d_id.attr,
|
|
|
|
&dev_attr_adapter_card_version.attr,
|
|
|
|
&dev_attr_adapter_lic_version.attr,
|
|
|
|
&dev_attr_adapter_status.attr,
|
|
|
|
&dev_attr_adapter_hardware_version.attr,
|
2019-10-26 00:12:51 +08:00
|
|
|
&dev_attr_adapter_diag_max_age.attr,
|
2020-03-13 01:45:01 +08:00
|
|
|
&dev_attr_adapter_fc_security.attr,
|
2008-07-02 16:56:38 +08:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2021-04-15 01:08:02 +08:00
|
|
|
static const struct attribute_group zfcp_sysfs_adapter_attr_group = {
|
2008-07-02 16:56:38 +08:00
|
|
|
.attrs = zfcp_adapter_attrs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2010-02-17 18:18:56 +08:00
|
|
|
struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
|
2008-10-01 18:42:18 +08:00
|
|
|
u64 fcp_lun;
|
2012-09-04 21:23:34 +08:00
|
|
|
int retval;
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2013-08-22 23:49:32 +08:00
|
|
|
if (kstrtoull(buf, 0, (unsigned long long *) &fcp_lun))
|
2010-09-08 20:39:52 +08:00
|
|
|
return -EINVAL;
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2012-09-04 21:23:34 +08:00
|
|
|
retval = zfcp_unit_add(port, fcp_lun);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2010-09-08 20:39:52 +08:00
|
|
|
return count;
|
2008-07-02 16:56:38 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2010-02-17 18:18:56 +08:00
|
|
|
struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
|
2008-10-01 18:42:18 +08:00
|
|
|
u64 fcp_lun;
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2013-08-22 23:49:32 +08:00
|
|
|
if (kstrtoull(buf, 0, (unsigned long long *) &fcp_lun))
|
2010-09-08 20:39:52 +08:00
|
|
|
return -EINVAL;
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2010-09-08 20:39:52 +08:00
|
|
|
if (zfcp_unit_remove(port, fcp_lun))
|
|
|
|
return -EINVAL;
|
2009-11-24 23:53:58 +08:00
|
|
|
|
2010-09-08 20:39:52 +08:00
|
|
|
return count;
|
2008-07-02 16:56:38 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);
|
|
|
|
|
2020-03-13 01:45:01 +08:00
|
|
|
static ssize_t zfcp_sysfs_port_fc_security_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
|
|
|
|
struct zfcp_adapter *adapter = port->adapter;
|
|
|
|
unsigned int status = atomic_read(&port->status);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (0 == (status & ZFCP_STATUS_COMMON_OPEN) ||
|
|
|
|
0 == (status & ZFCP_STATUS_COMMON_UNBLOCKED) ||
|
|
|
|
0 == (status & ZFCP_STATUS_PORT_PHYS_OPEN) ||
|
2021-07-03 00:09:22 +08:00
|
|
|
0 != (status & ZFCP_STATUS_PORT_LINK_TEST) ||
|
2020-03-13 01:45:01 +08:00
|
|
|
0 != (status & ZFCP_STATUS_COMMON_ERP_FAILED) ||
|
|
|
|
0 != (status & ZFCP_STATUS_COMMON_ACCESS_BOXED))
|
|
|
|
i = sprintf(buf, "unknown\n");
|
|
|
|
else if (!(adapter->adapter_features & FSF_FEATURE_FC_SECURITY))
|
|
|
|
i = sprintf(buf, "unsupported\n");
|
|
|
|
else {
|
|
|
|
i = zfcp_fsf_scnprint_fc_security(
|
|
|
|
buf, PAGE_SIZE - 1, port->connection_info,
|
|
|
|
ZFCP_FSF_PRINT_FMT_SINGLEITEM);
|
|
|
|
i += scnprintf(buf + i, PAGE_SIZE - i, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(port, fc_security, S_IRUGO,
|
|
|
|
zfcp_sysfs_port_fc_security_show,
|
|
|
|
NULL);
|
|
|
|
|
2008-10-01 18:42:17 +08:00
|
|
|
static struct attribute *zfcp_port_attrs[] = {
|
2008-07-02 16:56:38 +08:00
|
|
|
&dev_attr_unit_add.attr,
|
|
|
|
&dev_attr_unit_remove.attr,
|
|
|
|
&dev_attr_port_failed.attr,
|
|
|
|
&dev_attr_port_in_recovery.attr,
|
|
|
|
&dev_attr_port_status.attr,
|
|
|
|
&dev_attr_port_access_denied.attr,
|
2020-03-13 01:45:01 +08:00
|
|
|
&dev_attr_port_fc_security.attr,
|
2008-07-02 16:56:38 +08:00
|
|
|
NULL
|
|
|
|
};
|
2013-04-26 22:13:48 +08:00
|
|
|
static struct attribute_group zfcp_port_attr_group = {
|
2008-10-01 18:42:17 +08:00
|
|
|
.attrs = zfcp_port_attrs,
|
2008-07-02 16:56:38 +08:00
|
|
|
};
|
2013-04-26 22:13:48 +08:00
|
|
|
const struct attribute_group *zfcp_port_attr_groups[] = {
|
|
|
|
&zfcp_port_attr_group,
|
|
|
|
NULL,
|
|
|
|
};
|
2008-07-02 16:56:38 +08:00
|
|
|
|
|
|
|
static struct attribute *zfcp_unit_attrs[] = {
|
|
|
|
&dev_attr_unit_failed.attr,
|
|
|
|
&dev_attr_unit_in_recovery.attr,
|
|
|
|
&dev_attr_unit_status.attr,
|
|
|
|
&dev_attr_unit_access_denied.attr,
|
2013-08-22 23:45:38 +08:00
|
|
|
&dev_attr_unit_access_shared.attr,
|
|
|
|
&dev_attr_unit_access_readonly.attr,
|
2008-07-02 16:56:38 +08:00
|
|
|
NULL
|
|
|
|
};
|
2013-04-26 22:13:49 +08:00
|
|
|
static struct attribute_group zfcp_unit_attr_group = {
|
2008-07-02 16:56:38 +08:00
|
|
|
.attrs = zfcp_unit_attrs,
|
|
|
|
};
|
2013-04-26 22:13:49 +08:00
|
|
|
const struct attribute_group *zfcp_unit_attr_groups[] = {
|
|
|
|
&zfcp_unit_attr_group,
|
|
|
|
NULL,
|
|
|
|
};
|
2008-07-02 16:56:38 +08:00
|
|
|
|
|
|
|
#define ZFCP_DEFINE_LATENCY_ATTR(_name) \
|
|
|
|
static ssize_t \
|
|
|
|
zfcp_sysfs_unit_##_name##_latency_show(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
char *buf) { \
|
|
|
|
struct scsi_device *sdev = to_scsi_device(dev); \
|
2010-09-08 20:39:55 +08:00
|
|
|
struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
|
|
|
|
struct zfcp_latencies *lat = &zfcp_sdev->latencies; \
|
|
|
|
struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; \
|
2008-07-02 16:56:38 +08:00
|
|
|
unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \
|
|
|
|
\
|
2009-03-02 20:08:57 +08:00
|
|
|
spin_lock_bh(&lat->lock); \
|
2008-07-02 16:56:38 +08:00
|
|
|
fsum = lat->_name.fabric.sum * adapter->timer_ticks; \
|
|
|
|
fmin = lat->_name.fabric.min * adapter->timer_ticks; \
|
|
|
|
fmax = lat->_name.fabric.max * adapter->timer_ticks; \
|
|
|
|
csum = lat->_name.channel.sum * adapter->timer_ticks; \
|
|
|
|
cmin = lat->_name.channel.min * adapter->timer_ticks; \
|
|
|
|
cmax = lat->_name.channel.max * adapter->timer_ticks; \
|
|
|
|
cc = lat->_name.counter; \
|
2009-03-02 20:08:57 +08:00
|
|
|
spin_unlock_bh(&lat->lock); \
|
2008-07-02 16:56:38 +08:00
|
|
|
\
|
|
|
|
do_div(fsum, 1000); \
|
|
|
|
do_div(fmin, 1000); \
|
|
|
|
do_div(fmax, 1000); \
|
|
|
|
do_div(csum, 1000); \
|
|
|
|
do_div(cmin, 1000); \
|
|
|
|
do_div(cmax, 1000); \
|
|
|
|
\
|
|
|
|
return sprintf(buf, "%llu %llu %llu %llu %llu %llu %llu\n", \
|
|
|
|
fmin, fmax, fsum, cmin, cmax, csum, cc); \
|
|
|
|
} \
|
|
|
|
static ssize_t \
|
|
|
|
zfcp_sysfs_unit_##_name##_latency_store(struct device *dev, \
|
|
|
|
struct device_attribute *attr, \
|
|
|
|
const char *buf, size_t count) \
|
|
|
|
{ \
|
|
|
|
struct scsi_device *sdev = to_scsi_device(dev); \
|
2010-09-08 20:39:55 +08:00
|
|
|
struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
|
|
|
|
struct zfcp_latencies *lat = &zfcp_sdev->latencies; \
|
2008-07-02 16:56:38 +08:00
|
|
|
unsigned long flags; \
|
|
|
|
\
|
|
|
|
spin_lock_irqsave(&lat->lock, flags); \
|
|
|
|
lat->_name.fabric.sum = 0; \
|
|
|
|
lat->_name.fabric.min = 0xFFFFFFFF; \
|
|
|
|
lat->_name.fabric.max = 0; \
|
|
|
|
lat->_name.channel.sum = 0; \
|
|
|
|
lat->_name.channel.min = 0xFFFFFFFF; \
|
|
|
|
lat->_name.channel.max = 0; \
|
|
|
|
lat->_name.counter = 0; \
|
|
|
|
spin_unlock_irqrestore(&lat->lock, flags); \
|
|
|
|
\
|
|
|
|
return (ssize_t) count; \
|
|
|
|
} \
|
|
|
|
static DEVICE_ATTR(_name##_latency, S_IWUSR | S_IRUGO, \
|
|
|
|
zfcp_sysfs_unit_##_name##_latency_show, \
|
|
|
|
zfcp_sysfs_unit_##_name##_latency_store);
|
|
|
|
|
|
|
|
ZFCP_DEFINE_LATENCY_ATTR(read);
|
|
|
|
ZFCP_DEFINE_LATENCY_ATTR(write);
|
|
|
|
ZFCP_DEFINE_LATENCY_ATTR(cmd);
|
|
|
|
|
|
|
|
#define ZFCP_DEFINE_SCSI_ATTR(_name, _format, _value) \
|
|
|
|
static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, \
|
|
|
|
struct device_attribute *attr,\
|
|
|
|
char *buf) \
|
|
|
|
{ \
|
2010-09-08 20:39:55 +08:00
|
|
|
struct scsi_device *sdev = to_scsi_device(dev); \
|
|
|
|
struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
|
2008-07-02 16:56:38 +08:00
|
|
|
\
|
|
|
|
return sprintf(buf, _format, _value); \
|
|
|
|
} \
|
|
|
|
static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL);
|
|
|
|
|
|
|
|
ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n",
|
2014-11-13 21:59:47 +08:00
|
|
|
dev_name(&zfcp_sdev->port->adapter->ccw_device->dev));
|
2008-10-01 18:42:18 +08:00
|
|
|
ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n",
|
2014-11-13 21:59:47 +08:00
|
|
|
(unsigned long long) zfcp_sdev->port->wwpn);
|
2010-09-08 20:39:53 +08:00
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_device *sdev = to_scsi_device(dev);
|
|
|
|
|
2010-09-08 20:39:55 +08:00
|
|
|
return sprintf(buf, "0x%016llx\n", zfcp_scsi_dev_lun(sdev));
|
2010-09-08 20:39:53 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL);
|
2008-07-02 16:56:38 +08:00
|
|
|
|
2014-11-13 21:59:47 +08:00
|
|
|
ZFCP_DEFINE_SCSI_ATTR(zfcp_access_denied, "%d\n",
|
|
|
|
(atomic_read(&zfcp_sdev->status) &
|
|
|
|
ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_scsi_zfcp_failed_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct scsi_device *sdev = to_scsi_device(dev);
|
|
|
|
unsigned int status = atomic_read(&sdev_to_zfcp(sdev)->status);
|
|
|
|
unsigned int failed = status & ZFCP_STATUS_COMMON_ERP_FAILED ? 1 : 0;
|
|
|
|
|
|
|
|
return sprintf(buf, "%d\n", failed);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_scsi_zfcp_failed_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct scsi_device *sdev = to_scsi_device(dev);
|
|
|
|
unsigned long val;
|
|
|
|
|
|
|
|
if (kstrtoul(buf, 0, &val) || val != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_RUNNING);
|
|
|
|
zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED,
|
|
|
|
"syufai3");
|
|
|
|
zfcp_erp_wait(sdev_to_zfcp(sdev)->port->adapter);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(zfcp_failed, S_IWUSR | S_IRUGO,
|
|
|
|
zfcp_sysfs_scsi_zfcp_failed_show,
|
|
|
|
zfcp_sysfs_scsi_zfcp_failed_store);
|
|
|
|
|
|
|
|
ZFCP_DEFINE_SCSI_ATTR(zfcp_in_recovery, "%d\n",
|
|
|
|
(atomic_read(&zfcp_sdev->status) &
|
|
|
|
ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
|
|
|
|
|
|
|
|
ZFCP_DEFINE_SCSI_ATTR(zfcp_status, "0x%08x\n",
|
|
|
|
atomic_read(&zfcp_sdev->status));
|
|
|
|
|
2021-10-13 07:35:18 +08:00
|
|
|
struct attribute *zfcp_sdev_attrs[] = {
|
|
|
|
&dev_attr_fcp_lun.attr,
|
|
|
|
&dev_attr_wwpn.attr,
|
|
|
|
&dev_attr_hba_id.attr,
|
|
|
|
&dev_attr_read_latency.attr,
|
|
|
|
&dev_attr_write_latency.attr,
|
|
|
|
&dev_attr_cmd_latency.attr,
|
|
|
|
&dev_attr_zfcp_access_denied.attr,
|
|
|
|
&dev_attr_zfcp_failed.attr,
|
|
|
|
&dev_attr_zfcp_in_recovery.attr,
|
|
|
|
&dev_attr_zfcp_status.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct attribute_group zfcp_sysfs_sdev_attr_group = {
|
|
|
|
.attrs = zfcp_sdev_attrs
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct attribute_group *zfcp_sysfs_sdev_attr_groups[] = {
|
|
|
|
&zfcp_sysfs_sdev_attr_group,
|
2008-07-02 16:56:38 +08:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static ssize_t zfcp_sysfs_adapter_util_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *scsi_host = dev_to_shost(dev);
|
|
|
|
struct fsf_qtcb_bottom_port *qtcb_port;
|
|
|
|
struct zfcp_adapter *adapter;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
|
|
|
|
if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
qtcb_port = kzalloc(sizeof(struct fsf_qtcb_bottom_port), GFP_KERNEL);
|
|
|
|
if (!qtcb_port)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2009-08-18 21:43:19 +08:00
|
|
|
retval = zfcp_fsf_exchange_port_data_sync(adapter->qdio, qtcb_port);
|
2019-10-26 00:12:43 +08:00
|
|
|
if (retval == 0 || retval == -EAGAIN)
|
2008-07-02 16:56:38 +08:00
|
|
|
retval = sprintf(buf, "%u %u %u\n", qtcb_port->cp_util,
|
|
|
|
qtcb_port->cb_util, qtcb_port->a_util);
|
|
|
|
kfree(qtcb_port);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(utilization, S_IRUGO, zfcp_sysfs_adapter_util_show, NULL);
|
|
|
|
|
|
|
|
static int zfcp_sysfs_adapter_ex_config(struct device *dev,
|
|
|
|
struct fsf_statistics_info *stat_inf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *scsi_host = dev_to_shost(dev);
|
|
|
|
struct fsf_qtcb_bottom_config *qtcb_config;
|
|
|
|
struct zfcp_adapter *adapter;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
|
|
|
|
if (!(adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
qtcb_config = kzalloc(sizeof(struct fsf_qtcb_bottom_config),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!qtcb_config)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2009-08-18 21:43:19 +08:00
|
|
|
retval = zfcp_fsf_exchange_config_data_sync(adapter->qdio, qtcb_config);
|
2019-10-26 00:12:43 +08:00
|
|
|
if (retval == 0 || retval == -EAGAIN)
|
2008-07-02 16:56:38 +08:00
|
|
|
*stat_inf = qtcb_config->stat_info;
|
|
|
|
|
|
|
|
kfree(qtcb_config);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ZFCP_SHOST_ATTR(_name, _format, _arg...) \
|
|
|
|
static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \
|
|
|
|
struct device_attribute *attr,\
|
|
|
|
char *buf) \
|
|
|
|
{ \
|
|
|
|
struct fsf_statistics_info stat_info; \
|
|
|
|
int retval; \
|
|
|
|
\
|
|
|
|
retval = zfcp_sysfs_adapter_ex_config(dev, &stat_info); \
|
|
|
|
if (retval) \
|
|
|
|
return retval; \
|
|
|
|
\
|
|
|
|
return sprintf(buf, _format, ## _arg); \
|
|
|
|
} \
|
|
|
|
static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_adapter_##_name##_show, NULL);
|
|
|
|
|
|
|
|
ZFCP_SHOST_ATTR(requests, "%llu %llu %llu\n",
|
|
|
|
(unsigned long long) stat_info.input_req,
|
|
|
|
(unsigned long long) stat_info.output_req,
|
|
|
|
(unsigned long long) stat_info.control_req);
|
|
|
|
|
|
|
|
ZFCP_SHOST_ATTR(megabytes, "%llu %llu\n",
|
|
|
|
(unsigned long long) stat_info.input_mb,
|
|
|
|
(unsigned long long) stat_info.output_mb);
|
|
|
|
|
|
|
|
ZFCP_SHOST_ATTR(seconds_active, "%llu\n",
|
|
|
|
(unsigned long long) stat_info.seconds_act);
|
|
|
|
|
2008-10-01 18:42:14 +08:00
|
|
|
static ssize_t zfcp_sysfs_adapter_q_full_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *scsi_host = class_to_shost(dev);
|
2009-08-18 21:43:19 +08:00
|
|
|
struct zfcp_qdio *qdio =
|
|
|
|
((struct zfcp_adapter *) scsi_host->hostdata[0])->qdio;
|
2009-07-13 21:06:03 +08:00
|
|
|
u64 util;
|
|
|
|
|
2009-08-18 21:43:19 +08:00
|
|
|
spin_lock_bh(&qdio->stat_lock);
|
|
|
|
util = qdio->req_q_util;
|
|
|
|
spin_unlock_bh(&qdio->stat_lock);
|
2008-10-01 18:42:14 +08:00
|
|
|
|
2009-08-18 21:43:19 +08:00
|
|
|
return sprintf(buf, "%d %llu\n", atomic_read(&qdio->req_q_full),
|
2009-07-13 21:06:03 +08:00
|
|
|
(unsigned long long)util);
|
2008-10-01 18:42:14 +08:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL);
|
|
|
|
|
2021-10-13 07:35:18 +08:00
|
|
|
static struct attribute *zfcp_sysfs_shost_attrs[] = {
|
|
|
|
&dev_attr_utilization.attr,
|
|
|
|
&dev_attr_requests.attr,
|
|
|
|
&dev_attr_megabytes.attr,
|
|
|
|
&dev_attr_seconds_active.attr,
|
|
|
|
&dev_attr_queue_full.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct attribute_group zfcp_sysfs_shost_attr_group = {
|
|
|
|
.attrs = zfcp_sysfs_shost_attrs
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct attribute_group *zfcp_sysfs_shost_attr_groups[] = {
|
|
|
|
&zfcp_sysfs_shost_attr_group,
|
2008-07-02 16:56:38 +08:00
|
|
|
NULL
|
|
|
|
};
|
scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver
This adds an interface to read the diagnostics of the local SFP transceiver
of an FCP-Channel from userspace. This comes in the form of new sysfs
entries that are attached to the CCW device representing the FCP
device. Each type of data gets its own sysfs entry; the whole collection of
entries is pooled into a new child-directory of the CCW device node:
"diagnostics".
Adds sysfs entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid
* temperature: transceiver temp.; unit 1/256°C;
range [-128°C, +128°C]
* vcc: supply voltage; unit 100μV; range [0, 6.55V]
* tx_bias: transmitter laser bias current; unit 2μA;
range [0, 131mA]
* tx_power: coupled TX output power; unit 0.1μW; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1μW; range [0, 6.5mW]
* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;
{0, 1}; 1 - active
* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+
This is only supported if the FCP-Channel in turn supports reporting the
SFP Diagnostic Data, otherwise read() on these new entries will return
EOPNOTSUPP (this affects only adapters older than FICON Express8S, on
Mainframe generations older than z14). Other possible errors for read()
include ENOLINK, ENODEV and ENOMEM.
With this patch the userspace-interface will only read data stored in
the corresponding "diagnostic buffer" (that was stored during completion
of an previous Exchange Port Data command). Implicit updating will
follow later in this series.
Link: https://lore.kernel.org/r/1f9cce7c829c881e7d71a3f10c5b57f3dd84ab32.1572018132.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-10-26 00:12:47 +08:00
|
|
|
|
2019-10-26 00:12:49 +08:00
|
|
|
static ssize_t zfcp_sysfs_adapter_diag_b2b_credit_show(
|
|
|
|
struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(to_ccwdev(dev));
|
|
|
|
struct zfcp_diag_header *diag_hdr;
|
|
|
|
struct fc_els_flogi *nsp;
|
|
|
|
ssize_t rc = -ENOLINK;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int status;
|
|
|
|
|
|
|
|
if (!adapter)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
status = atomic_read(&adapter->status);
|
|
|
|
if (0 == (status & ZFCP_STATUS_COMMON_OPEN) ||
|
|
|
|
0 == (status & ZFCP_STATUS_COMMON_UNBLOCKED) ||
|
|
|
|
0 != (status & ZFCP_STATUS_COMMON_ERP_FAILED))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
diag_hdr = &adapter->diagnostics->config_data.header;
|
|
|
|
|
2019-10-26 00:12:50 +08:00
|
|
|
rc = zfcp_diag_update_buffer_limited(
|
|
|
|
adapter, diag_hdr, zfcp_diag_update_config_data_buffer);
|
|
|
|
if (rc != 0)
|
|
|
|
goto out;
|
|
|
|
|
2019-10-26 00:12:49 +08:00
|
|
|
spin_lock_irqsave(&diag_hdr->access_lock, flags);
|
|
|
|
/* nport_serv_param doesn't contain the ELS_Command code */
|
|
|
|
nsp = (struct fc_els_flogi *)((unsigned long)
|
|
|
|
adapter->diagnostics->config_data
|
|
|
|
.data.nport_serv_param -
|
|
|
|
sizeof(u32));
|
|
|
|
|
|
|
|
rc = scnprintf(buf, 5 + 2, "%hu\n",
|
|
|
|
be16_to_cpu(nsp->fl_csp.sp_bb_cred));
|
|
|
|
spin_unlock_irqrestore(&diag_hdr->access_lock, flags);
|
|
|
|
|
|
|
|
out:
|
|
|
|
zfcp_ccw_adapter_put(adapter);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
static ZFCP_DEV_ATTR(adapter_diag, b2b_credit, 0400,
|
|
|
|
zfcp_sysfs_adapter_diag_b2b_credit_show, NULL);
|
|
|
|
|
scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver
This adds an interface to read the diagnostics of the local SFP transceiver
of an FCP-Channel from userspace. This comes in the form of new sysfs
entries that are attached to the CCW device representing the FCP
device. Each type of data gets its own sysfs entry; the whole collection of
entries is pooled into a new child-directory of the CCW device node:
"diagnostics".
Adds sysfs entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid
* temperature: transceiver temp.; unit 1/256°C;
range [-128°C, +128°C]
* vcc: supply voltage; unit 100μV; range [0, 6.55V]
* tx_bias: transmitter laser bias current; unit 2μA;
range [0, 131mA]
* tx_power: coupled TX output power; unit 0.1μW; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1μW; range [0, 6.5mW]
* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;
{0, 1}; 1 - active
* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+
This is only supported if the FCP-Channel in turn supports reporting the
SFP Diagnostic Data, otherwise read() on these new entries will return
EOPNOTSUPP (this affects only adapters older than FICON Express8S, on
Mainframe generations older than z14). Other possible errors for read()
include ENOLINK, ENODEV and ENOMEM.
With this patch the userspace-interface will only read data stored in
the corresponding "diagnostic buffer" (that was stored during completion
of an previous Exchange Port Data command). Implicit updating will
follow later in this series.
Link: https://lore.kernel.org/r/1f9cce7c829c881e7d71a3f10c5b57f3dd84ab32.1572018132.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-10-26 00:12:47 +08:00
|
|
|
#define ZFCP_DEFINE_DIAG_SFP_ATTR(_name, _qtcb_member, _prtsize, _prtfmt) \
|
|
|
|
static ssize_t zfcp_sysfs_adapter_diag_sfp_##_name##_show( \
|
|
|
|
struct device *dev, struct device_attribute *attr, char *buf) \
|
|
|
|
{ \
|
|
|
|
struct zfcp_adapter *const adapter = \
|
|
|
|
zfcp_ccw_adapter_by_cdev(to_ccwdev(dev)); \
|
|
|
|
struct zfcp_diag_header *diag_hdr; \
|
|
|
|
ssize_t rc = -ENOLINK; \
|
|
|
|
unsigned long flags; \
|
|
|
|
unsigned int status; \
|
|
|
|
\
|
|
|
|
if (!adapter) \
|
|
|
|
return -ENODEV; \
|
|
|
|
\
|
|
|
|
status = atomic_read(&adapter->status); \
|
|
|
|
if (0 == (status & ZFCP_STATUS_COMMON_OPEN) || \
|
|
|
|
0 == (status & ZFCP_STATUS_COMMON_UNBLOCKED) || \
|
|
|
|
0 != (status & ZFCP_STATUS_COMMON_ERP_FAILED)) \
|
|
|
|
goto out; \
|
|
|
|
\
|
|
|
|
if (!zfcp_diag_support_sfp(adapter)) { \
|
|
|
|
rc = -EOPNOTSUPP; \
|
|
|
|
goto out; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
diag_hdr = &adapter->diagnostics->port_data.header; \
|
|
|
|
\
|
2019-10-26 00:12:48 +08:00
|
|
|
rc = zfcp_diag_update_buffer_limited( \
|
|
|
|
adapter, diag_hdr, zfcp_diag_update_port_data_buffer); \
|
|
|
|
if (rc != 0) \
|
|
|
|
goto out; \
|
|
|
|
\
|
scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver
This adds an interface to read the diagnostics of the local SFP transceiver
of an FCP-Channel from userspace. This comes in the form of new sysfs
entries that are attached to the CCW device representing the FCP
device. Each type of data gets its own sysfs entry; the whole collection of
entries is pooled into a new child-directory of the CCW device node:
"diagnostics".
Adds sysfs entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid
* temperature: transceiver temp.; unit 1/256°C;
range [-128°C, +128°C]
* vcc: supply voltage; unit 100μV; range [0, 6.55V]
* tx_bias: transmitter laser bias current; unit 2μA;
range [0, 131mA]
* tx_power: coupled TX output power; unit 0.1μW; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1μW; range [0, 6.5mW]
* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;
{0, 1}; 1 - active
* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+
This is only supported if the FCP-Channel in turn supports reporting the
SFP Diagnostic Data, otherwise read() on these new entries will return
EOPNOTSUPP (this affects only adapters older than FICON Express8S, on
Mainframe generations older than z14). Other possible errors for read()
include ENOLINK, ENODEV and ENOMEM.
With this patch the userspace-interface will only read data stored in
the corresponding "diagnostic buffer" (that was stored during completion
of an previous Exchange Port Data command). Implicit updating will
follow later in this series.
Link: https://lore.kernel.org/r/1f9cce7c829c881e7d71a3f10c5b57f3dd84ab32.1572018132.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-10-26 00:12:47 +08:00
|
|
|
spin_lock_irqsave(&diag_hdr->access_lock, flags); \
|
|
|
|
rc = scnprintf( \
|
|
|
|
buf, (_prtsize) + 2, _prtfmt "\n", \
|
|
|
|
adapter->diagnostics->port_data.data._qtcb_member); \
|
|
|
|
spin_unlock_irqrestore(&diag_hdr->access_lock, flags); \
|
|
|
|
\
|
|
|
|
out: \
|
|
|
|
zfcp_ccw_adapter_put(adapter); \
|
|
|
|
return rc; \
|
|
|
|
} \
|
|
|
|
static ZFCP_DEV_ATTR(adapter_diag_sfp, _name, 0400, \
|
|
|
|
zfcp_sysfs_adapter_diag_sfp_##_name##_show, NULL)
|
|
|
|
|
2020-02-19 23:09:25 +08:00
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(temperature, temperature, 6, "%hd");
|
scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver
This adds an interface to read the diagnostics of the local SFP transceiver
of an FCP-Channel from userspace. This comes in the form of new sysfs
entries that are attached to the CCW device representing the FCP
device. Each type of data gets its own sysfs entry; the whole collection of
entries is pooled into a new child-directory of the CCW device node:
"diagnostics".
Adds sysfs entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid
* temperature: transceiver temp.; unit 1/256°C;
range [-128°C, +128°C]
* vcc: supply voltage; unit 100μV; range [0, 6.55V]
* tx_bias: transmitter laser bias current; unit 2μA;
range [0, 131mA]
* tx_power: coupled TX output power; unit 0.1μW; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1μW; range [0, 6.5mW]
* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;
{0, 1}; 1 - active
* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+
This is only supported if the FCP-Channel in turn supports reporting the
SFP Diagnostic Data, otherwise read() on these new entries will return
EOPNOTSUPP (this affects only adapters older than FICON Express8S, on
Mainframe generations older than z14). Other possible errors for read()
include ENOLINK, ENODEV and ENOMEM.
With this patch the userspace-interface will only read data stored in
the corresponding "diagnostic buffer" (that was stored during completion
of an previous Exchange Port Data command). Implicit updating will
follow later in this series.
Link: https://lore.kernel.org/r/1f9cce7c829c881e7d71a3f10c5b57f3dd84ab32.1572018132.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-10-26 00:12:47 +08:00
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(vcc, vcc, 5, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(tx_bias, tx_bias, 5, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(tx_power, tx_power, 5, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(rx_power, rx_power, 5, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(port_tx_type, sfp_flags.port_tx_type, 2, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(optical_port, sfp_flags.optical_port, 1, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(sfp_invalid, sfp_flags.sfp_invalid, 1, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(connector_type, sfp_flags.connector_type, 1, "%hu");
|
|
|
|
ZFCP_DEFINE_DIAG_SFP_ATTR(fec_active, sfp_flags.fec_active, 1, "%hu");
|
|
|
|
|
|
|
|
static struct attribute *zfcp_sysfs_diag_attrs[] = {
|
|
|
|
&dev_attr_adapter_diag_sfp_temperature.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_vcc.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_tx_bias.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_tx_power.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_rx_power.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_port_tx_type.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_optical_port.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_sfp_invalid.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_connector_type.attr,
|
|
|
|
&dev_attr_adapter_diag_sfp_fec_active.attr,
|
2019-10-26 00:12:49 +08:00
|
|
|
&dev_attr_adapter_diag_b2b_credit.attr,
|
scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver
This adds an interface to read the diagnostics of the local SFP transceiver
of an FCP-Channel from userspace. This comes in the form of new sysfs
entries that are attached to the CCW device representing the FCP
device. Each type of data gets its own sysfs entry; the whole collection of
entries is pooled into a new child-directory of the CCW device node:
"diagnostics".
Adds sysfs entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid
* temperature: transceiver temp.; unit 1/256°C;
range [-128°C, +128°C]
* vcc: supply voltage; unit 100μV; range [0, 6.55V]
* tx_bias: transmitter laser bias current; unit 2μA;
range [0, 131mA]
* tx_power: coupled TX output power; unit 0.1μW; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1μW; range [0, 6.5mW]
* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;
{0, 1}; 1 - active
* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+
This is only supported if the FCP-Channel in turn supports reporting the
SFP Diagnostic Data, otherwise read() on these new entries will return
EOPNOTSUPP (this affects only adapters older than FICON Express8S, on
Mainframe generations older than z14). Other possible errors for read()
include ENOLINK, ENODEV and ENOMEM.
With this patch the userspace-interface will only read data stored in
the corresponding "diagnostic buffer" (that was stored during completion
of an previous Exchange Port Data command). Implicit updating will
follow later in this series.
Link: https://lore.kernel.org/r/1f9cce7c829c881e7d71a3f10c5b57f3dd84ab32.1572018132.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-10-26 00:12:47 +08:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2021-04-15 01:08:02 +08:00
|
|
|
static const struct attribute_group zfcp_sysfs_diag_attr_group = {
|
scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver
This adds an interface to read the diagnostics of the local SFP transceiver
of an FCP-Channel from userspace. This comes in the form of new sysfs
entries that are attached to the CCW device representing the FCP
device. Each type of data gets its own sysfs entry; the whole collection of
entries is pooled into a new child-directory of the CCW device node:
"diagnostics".
Adds sysfs entries for:
* sfp_invalid: boolean value evaluating to whether the following 5
fields are invalid; {0, 1}; 1 - invalid
* temperature: transceiver temp.; unit 1/256°C;
range [-128°C, +128°C]
* vcc: supply voltage; unit 100μV; range [0, 6.55V]
* tx_bias: transmitter laser bias current; unit 2μA;
range [0, 131mA]
* tx_power: coupled TX output power; unit 0.1μW; range [0, 6.5mW]
* rx_power: received optical power; unit 0.1μW; range [0, 6.5mW]
* optical_port: boolean value evaluating to whether the FCP-Channel has
an optical port; {0, 1}; 1 - optical
* fec_active: boolean value evaluating to whether 16G FEC is active;
{0, 1}; 1 - active
* port_tx_type: nibble describing the port type; {0, 1, 2, 3};
0 - unknown, 1 - short wave,
2 - long wave LC 1310nm, 3 - long wave LL 1550nm
* connector_type: two bits describing the connector type; {0, 1};
0 - unknown, 1 - SFP+
This is only supported if the FCP-Channel in turn supports reporting the
SFP Diagnostic Data, otherwise read() on these new entries will return
EOPNOTSUPP (this affects only adapters older than FICON Express8S, on
Mainframe generations older than z14). Other possible errors for read()
include ENOLINK, ENODEV and ENOMEM.
With this patch the userspace-interface will only read data stored in
the corresponding "diagnostic buffer" (that was stored during completion
of an previous Exchange Port Data command). Implicit updating will
follow later in this series.
Link: https://lore.kernel.org/r/1f9cce7c829c881e7d71a3f10c5b57f3dd84ab32.1572018132.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-10-26 00:12:47 +08:00
|
|
|
.name = "diagnostics",
|
|
|
|
.attrs = zfcp_sysfs_diag_attrs,
|
|
|
|
};
|
2021-04-15 01:08:02 +08:00
|
|
|
|
|
|
|
const struct attribute_group *zfcp_sysfs_adapter_attr_groups[] = {
|
|
|
|
&zfcp_sysfs_adapter_attr_group,
|
|
|
|
&zfcp_sysfs_diag_attr_group,
|
|
|
|
NULL,
|
|
|
|
};
|