Commit ea127f97 authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Linus Torvalds

[PATCH] s390 (7/7): zfcp host adapter.

The zfcp scsi host adapater.
parent ba3b5477
......@@ -85,7 +85,35 @@ CONFIG_PFAULT=y
#
# SCSI device support
#
# CONFIG_SCSI is not set
CONFIG_SCSI=y
CONFIG_SCSI_PROC_FS=y
#
# SCSI support type (disk, tape, CD-ROM)
#
CONFIG_BLK_DEV_SD=y
CONFIG_CHR_DEV_ST=y
# CONFIG_CHR_DEV_OSST is not set
CONFIG_BLK_DEV_SR=y
CONFIG_BLK_DEV_SR_VENDOR=y
CONFIG_CHR_DEV_SG=y
#
# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
#
CONFIG_SCSI_MULTI_LUN=y
# CONFIG_SCSI_REPORT_LUNS is not set
CONFIG_SCSI_CONSTANTS=y
CONFIG_SCSI_LOGGING=y
#
# SCSI low-level drivers
#
# CONFIG_SCSI_AIC7XXX is not set
# CONFIG_SCSI_AIC7XXX_OLD is not set
# CONFIG_SCSI_EATA_PIO is not set
# CONFIG_SCSI_DEBUG is not set
CONFIG_ZFCP=y
CONFIG_CCW=y
#
......@@ -383,7 +411,11 @@ CONFIG_PARTITION_ADVANCED=y
# CONFIG_ATARI_PARTITION is not set
CONFIG_IBM_PARTITION=y
# CONFIG_MAC_PARTITION is not set
# CONFIG_MSDOS_PARTITION is not set
CONFIG_MSDOS_PARTITION=y
# CONFIG_BSD_DISKLABEL is not set
# CONFIG_MINIX_SUBPARTITION is not set
# CONFIG_SOLARIS_X86_PARTITION is not set
# CONFIG_UNIXWARE_DISKLABEL is not set
# CONFIG_LDM_PARTITION is not set
# CONFIG_NEC98_PARTITION is not set
# CONFIG_SGI_PARTITION is not set
......
......@@ -3,6 +3,6 @@
#
obj-y += s390mach.o sysinfo.o
obj-y += cio/ block/ char/ net/
obj-y += cio/ block/ char/ net/ scsi/
drivers-y += drivers/s390/built-in.o
#
# Makefile for the S/390 specific device drivers
#
zfcp-objs := zfcp_aux.o zfcp_ccw.o zfcp_scsi.o zfcp_erp.o zfcp_qdio.o \
zfcp_fsf.o zfcp_sysfs_adapter.o zfcp_sysfs_port.o \
zfcp_sysfs_unit.o zfcp_sysfs_driver.o
obj-$(CONFIG_ZFCP) += zfcp.o
This diff is collapsed.
/*
* linux/drivers/s390/scsi/zfcp_ccw.c
*
* FCP adapter driver for IBM eServer zSeries
*
* CCW driver related routines
*
* Copyright (C) 2003 IBM Entwicklung GmbH, IBM Corporation
* Authors:
* Martin Peschke <mpeschke@de.ibm.com>
* Heiko Carstens <heiko.carstens@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define ZFCP_CCW_C_REVISION "$Revision: 1.33 $"
#include <linux/init.h>
#include <linux/module.h>
#include <asm/ccwdev.h>
#include "zfcp_ext.h"
#include "zfcp_def.h"
#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
#define ZFCP_LOG_AREA_PREFIX ZFCP_LOG_AREA_PREFIX_CONFIG
static int zfcp_ccw_probe(struct ccw_device *);
static int zfcp_ccw_remove(struct ccw_device *);
static int zfcp_ccw_set_online(struct ccw_device *);
static int zfcp_ccw_set_offline(struct ccw_device *);
static struct ccw_device_id zfcp_ccw_device_id[] = {
{CCW_DEVICE_DEVTYPE(ZFCP_CONTROL_UNIT_TYPE,
ZFCP_CONTROL_UNIT_MODEL,
ZFCP_DEVICE_TYPE,
ZFCP_DEVICE_MODEL)},
{},
};
static struct ccw_driver zfcp_ccw_driver = {
.name = ZFCP_NAME,
.ids = zfcp_ccw_device_id,
.probe = zfcp_ccw_probe,
.remove = zfcp_ccw_remove,
.set_online = zfcp_ccw_set_online,
.set_offline = zfcp_ccw_set_offline,
};
MODULE_DEVICE_TABLE(ccw, zfcp_ccw_device_id);
/**
* zfcp_ccw_probe - probe function of zfcp driver
* @ccw_device: pointer to belonging ccw device
*
* This function gets called by the common i/o layer and sets up the initial
* data structures for each fcp adapter, which was detected by the system.
* Also the sysfs files for this adapter will be created by this function.
* In addition the nameserver port will be added to the ports of the adapter
* and its sysfs representation will be created too.
*/
static int
zfcp_ccw_probe(struct ccw_device *ccw_device)
{
struct zfcp_adapter *adapter;
int retval = 0;
down(&zfcp_data.config_sema);
adapter = zfcp_adapter_enqueue(ccw_device);
if (!adapter)
retval = -EINVAL;
up(&zfcp_data.config_sema);
return retval;
}
/**
* zfcp_ccw_remove - remove function of zfcp driver
* @ccw_device: pointer to belonging ccw device
*
* This function gets called by the common i/o layer and removes an adapter
* from the system. Task of this function is to get rid of all units and
* ports that belong to this adapter. And addition all resources of this
* adapter will be freed too.
*/
static int
zfcp_ccw_remove(struct ccw_device *ccw_device)
{
struct zfcp_adapter *adapter;
struct zfcp_port *port, *p;
struct zfcp_unit *unit, *u;
down(&zfcp_data.config_sema);
adapter = dev_get_drvdata(&ccw_device->dev);
write_lock_irq(&zfcp_data.config_lock);
list_for_each_entry_safe(port, p, &adapter->port_list_head, list) {
list_for_each_entry_safe(unit, u, &port->unit_list_head, list) {
list_move(&unit->list, &port->unit_remove_lh);
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE,
&unit->status);
}
list_move(&port->list, &adapter->port_remove_lh);
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
}
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
write_unlock_irq(&zfcp_data.config_lock);
list_for_each_entry_safe(port, p, &adapter->port_remove_lh, list) {
list_for_each_entry_safe(unit, u, &port->unit_remove_lh, list) {
zfcp_unit_wait(unit);
device_unregister(&unit->sysfs_device);
}
zfcp_port_wait(port);
device_unregister(&port->sysfs_device);
}
zfcp_adapter_wait(adapter);
zfcp_adapter_dequeue(adapter);
up(&zfcp_data.config_sema);
return 0;
}
/**
* zfcp_ccw_set_online - set_online function of zfcp driver
* @ccw_device: pointer to belonging ccw device
*
* This function gets called by the common i/o layer and sets an adapter
* into state online. Setting an fcp device online means that it will be
* registered with the SCSI stack, that the QDIO queues will be set up
* and that the adapter will be opened (asynchronously).
*/
static int
zfcp_ccw_set_online(struct ccw_device *ccw_device)
{
struct zfcp_adapter *adapter;
int retval;
down(&zfcp_data.config_sema);
adapter = dev_get_drvdata(&ccw_device->dev);
retval = zfcp_adapter_scsi_register(adapter);
if (retval)
goto out;
zfcp_erp_modify_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING,
ZFCP_SET);
zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED);
out:
up(&zfcp_data.config_sema);
return retval;
}
/**
* zfcp_ccw_set_offline - set_offline function of zfcp driver
* @ccw_device: pointer to belonging ccw device
*
* This function gets called by the common i/o layer and sets an adapter
* into state offline. Setting an fcp device offline means that it will be
* unregistered from the SCSI stack and that the adapter will be shut down
* asynchronously.
*/
static int
zfcp_ccw_set_offline(struct ccw_device *ccw_device)
{
struct zfcp_adapter *adapter;
down(&zfcp_data.config_sema);
adapter = dev_get_drvdata(&ccw_device->dev);
zfcp_erp_adapter_shutdown(adapter, 0);
zfcp_erp_wait(adapter);
zfcp_adapter_scsi_unregister(adapter);
up(&zfcp_data.config_sema);
return 0;
}
/**
* zfcp_ccw_register - ccw register function
*
* Registers the driver at the common i/o layer. This function will be called
* at module load time/system start.
*/
int __init
zfcp_ccw_register(void)
{
int retval;
retval = ccw_driver_register(&zfcp_ccw_driver);
if (retval)
goto out;
retval = zfcp_sysfs_driver_create_files(&zfcp_ccw_driver.driver);
if (retval)
ccw_driver_unregister(&zfcp_ccw_driver);
out:
return retval;
}
/**
* zfcp_ccw_unregister - ccw unregister function
*
* Unregisters the driver from common i/o layer. Function will be called at
* module unload/system shutdown.
*/
void __exit
zfcp_ccw_unregister(void)
{
zfcp_sysfs_driver_remove_files(&zfcp_ccw_driver.driver);
ccw_driver_unregister(&zfcp_ccw_driver);
}
#undef ZFCP_LOG_AREA
#undef ZFCP_LOG_AREA_PREFIX
This diff is collapsed.
This diff is collapsed.
/*
*
* linux/drivers/s390/scsi/zfcp_ext.h
*
* FCP adapter driver for IBM eServer zSeries
*
* Copyright 2002 IBM Corporation
* Author(s): Martin Peschke <mpeschke@de.ibm.com>
* Raimund Schroeder <raimund.schroeder@de.ibm.com>
* Aron Zeh <arzeh@de.ibm.com>
* Wolfgang Taphorn <taphorn@de.ibm.com>
* Stefan Bader <stefan.bader@de.ibm.com>
* Heiko Carstens <heiko.carstens@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef ZFCP_EXT_H
#define ZFCP_EXT_H
/* this drivers version (do not edit !!! generated and updated by cvs) */
#define ZFCP_EXT_REVISION "$Revision: 1.33 $"
#ifdef __KERNEL__
#include "zfcp_def.h"
extern struct zfcp_data zfcp_data;
/******************************** SYSFS *************************************/
extern int zfcp_sysfs_driver_create_files(struct device_driver *);
extern void zfcp_sysfs_driver_remove_files(struct device_driver *);
extern int zfcp_sysfs_adapter_create_files(struct device *);
extern void zfcp_sysfs_adapter_remove_files(struct device *);
extern int zfcp_sysfs_port_create_files(struct device *, u32);
extern int zfcp_sysfs_unit_create_files(struct device *);
extern void zfcp_sysfs_port_release(struct device *);
extern int zfcp_sysfs_port_shutdown(struct zfcp_port *);
extern void zfcp_sysfs_unit_release(struct device *);
/**************************** CONFIGURATION *********************************/
extern struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *,
fcp_lun_t fcp_lun);
extern struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *,
wwn_t wwpn);
extern struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *);
extern void zfcp_adapter_dequeue(struct zfcp_adapter *);
extern struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *, wwn_t, u32);
extern void zfcp_port_dequeue(struct zfcp_port *);
extern struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *, fcp_lun_t);
extern void zfcp_unit_dequeue(struct zfcp_unit *);
/******************************* S/390 IO ************************************/
extern int zfcp_ccw_register(void);
extern void zfcp_ccw_unregister(void);
extern int zfcp_initialize_with_0copy(struct zfcp_adapter *);
extern void zfcp_qdio_zero_sbals(struct qdio_buffer **, int, int);
extern int zfcp_qdio_allocate(struct zfcp_adapter *);
extern int zfcp_qdio_allocate_queues(struct zfcp_adapter *);
extern void zfcp_qdio_free_queues(struct zfcp_adapter *);
extern int zfcp_qdio_determine_pci(struct zfcp_qdio_queue *,
struct zfcp_fsf_req *);
extern int zfcp_qdio_reqid_check(struct zfcp_adapter *, void *);
/******************************** FSF ****************************************/
extern int zfcp_fsf_open_port(struct zfcp_erp_action *);
extern int zfcp_fsf_close_port(struct zfcp_erp_action *);
extern int zfcp_fsf_close_physical_port(struct zfcp_erp_action *);
extern int zfcp_fsf_open_unit(struct zfcp_erp_action *);
extern int zfcp_fsf_close_unit(struct zfcp_erp_action *);
extern int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *);
extern void zfcp_fsf_scsi_er_timeout_handler(unsigned long);
extern int zfcp_fsf_req_dismiss_all(struct zfcp_adapter *);
extern int zfcp_fsf_status_read(struct zfcp_adapter *, int);
extern int zfcp_fsf_req_create(struct zfcp_adapter *,u32, unsigned long *,
int, struct zfcp_fsf_req **);
extern void zfcp_fsf_req_free(struct zfcp_fsf_req *);
extern int zfcp_fsf_send_generic(struct zfcp_fsf_req *, unsigned char,
unsigned long *, struct timer_list *);
extern int zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req *, int, u32 *);
extern int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *,
struct zfcp_unit *, Scsi_Cmnd *,
int);
extern int zfcp_fsf_req_complete(struct zfcp_fsf_req *);
extern void zfcp_fsf_incoming_els(struct zfcp_fsf_req *);
extern void zfcp_fsf_req_cleanup(struct zfcp_fsf_req *);
extern struct zfcp_fsf_req *zfcp_fsf_send_fcp_command_task_management(
struct zfcp_adapter *, struct zfcp_unit *, u8, int);
extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(
unsigned long, struct zfcp_adapter *, struct zfcp_unit *, int);
/******************************** FCP ****************************************/
extern int zfcp_nameserver_enqueue(struct zfcp_adapter *);
extern int zfcp_nameserver_request(struct zfcp_erp_action *);
extern void zfcp_fsf_els_processing(struct zfcp_fsf_req *);
/******************************* SCSI ****************************************/
extern int zfcp_adapter_scsi_register(struct zfcp_adapter *);
extern void zfcp_adapter_scsi_unregister(struct zfcp_adapter *);
extern void zfcp_scsi_block_requests(struct Scsi_Host *);
extern void zfcp_scsi_insert_into_fake_queue(struct zfcp_adapter *,
Scsi_Cmnd *);
extern void zfcp_scsi_process_and_clear_fake_queue(unsigned long);
extern int zfcp_create_sbals_from_sg(struct zfcp_fsf_req *,
Scsi_Cmnd *, char, int, int);
extern void zfcp_set_fcp_dl(struct fcp_cmnd_iu *, fcp_dl_t);
extern char *zfcp_get_fcp_rsp_info_ptr(struct fcp_rsp_iu *);
extern void set_host_byte(u32 *, char);
extern void set_driver_byte(u32 *, char);
extern char *zfcp_get_fcp_sns_info_ptr(struct fcp_rsp_iu *);
extern void zfcp_fsf_start_scsi_er_timer(struct zfcp_adapter *);
extern fcp_dl_t zfcp_get_fcp_dl(struct fcp_cmnd_iu *);
/******************************** ERP ****************************************/
extern void zfcp_erp_modify_adapter_status(struct zfcp_adapter *, u32, int);
extern int zfcp_erp_adapter_reopen(struct zfcp_adapter *, int);
extern int zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int);
extern int zfcp_erp_adapter_shutdown_all(void);
extern void zfcp_erp_adapter_failed(struct zfcp_adapter *);
extern void zfcp_erp_modify_port_status(struct zfcp_port *, u32, int);
extern int zfcp_erp_port_reopen(struct zfcp_port *, int);
extern int zfcp_erp_port_shutdown(struct zfcp_port *, int);
extern int zfcp_erp_port_forced_reopen(struct zfcp_port *, int);
extern void zfcp_erp_port_failed(struct zfcp_port *);
extern int zfcp_erp_port_reopen_all(struct zfcp_adapter *, int);
extern void zfcp_erp_modify_unit_status(struct zfcp_unit *, u32, int);
extern int zfcp_erp_unit_reopen(struct zfcp_unit *, int);
extern int zfcp_erp_unit_shutdown(struct zfcp_unit *, int);
extern void zfcp_erp_unit_failed(struct zfcp_unit *);
extern void zfcp_erp_scsi_low_mem_buffer_timeout_handler(unsigned long);
extern int zfcp_erp_thread_setup(struct zfcp_adapter *);
extern int zfcp_erp_thread_kill(struct zfcp_adapter *);
extern int zfcp_erp_wait(struct zfcp_adapter *);
extern void zfcp_erp_fsf_req_handler(struct zfcp_fsf_req *);
/******************************** AUX ****************************************/
extern void zfcp_cmd_dbf_event_fsf(const char *, struct zfcp_fsf_req *,
void *, int);
extern void zfcp_cmd_dbf_event_scsi(const char *, Scsi_Cmnd *);
extern void zfcp_in_els_dbf_event(struct zfcp_adapter *, const char *,
struct fsf_status_read_buffer *, int);
#ifdef ZFCP_STAT_REQSIZES
extern int zfcp_statistics_inc(struct list_head *, u32);
#endif
#endif /* __KERNEL__ */
#endif /* ZFCP_EXT_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* linux/drivers/s390/scsi/zfcp_sysfs_driver.c
*
* FCP adapter driver for IBM eServer zSeries
*
* sysfs driver related routines
*
* Copyright (C) 2003 IBM Entwicklung GmbH, IBM Corporation
* Authors:
* Martin Peschke <mpeschke@de.ibm.com>
* Heiko Carstens <heiko.carstens@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define ZFCP_SYSFS_DRIVER_C_REVISION "$Revision: 1.8 $"
#include <asm/ccwdev.h>
#include "zfcp_ext.h"
#include "zfcp_def.h"
#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
#define ZFCP_LOG_AREA_PREFIX ZFCP_LOG_AREA_PREFIX_CONFIG
/**
* ZFCP_DEFINE_DRIVER_ATTR - define for all loglevels sysfs attributes
* @_name: name of attribute
* @_define: name of ZFCP loglevel define
*
* Generates store function for a sysfs loglevel attribute of zfcp driver.
*/
#define ZFCP_DEFINE_DRIVER_ATTR(_name, _define) \
static ssize_t zfcp_sysfs_loglevel_##_name##_store(struct device_driver *drv, \
const char *buf, \
size_t count) \
{ \
unsigned int loglevel; \
unsigned int new_loglevel; \
char *endp; \
\
new_loglevel = simple_strtoul(buf, &endp, 0); \
if ((endp + 1) < (buf + count)) \
return -EINVAL; \
if (new_loglevel > 3) \
return -EINVAL; \
down(&zfcp_data.config_sema); \
loglevel = atomic_read(&zfcp_data.loglevel); \
loglevel &= ~((unsigned int) 0xf << (ZFCP_LOG_AREA_##_define << 2)); \
loglevel |= new_loglevel << (ZFCP_LOG_AREA_##_define << 2); \
atomic_set(&zfcp_data.loglevel, loglevel); \
up(&zfcp_data.config_sema); \
return count; \
} \
\
static ssize_t zfcp_sysfs_loglevel_##_name##_show(struct device_driver *dev, \
char *buf) \
{ \
return sprintf(buf,"%d\n", ZFCP_LOG_VALUE(ZFCP_LOG_AREA_##_define)); \
} \
\
static DRIVER_ATTR(loglevel_##_name, S_IWUSR | S_IRUGO, \
zfcp_sysfs_loglevel_##_name##_show, \
zfcp_sysfs_loglevel_##_name##_store);
ZFCP_DEFINE_DRIVER_ATTR(other, OTHER);
ZFCP_DEFINE_DRIVER_ATTR(scsi, SCSI);
ZFCP_DEFINE_DRIVER_ATTR(fsf, FSF);
ZFCP_DEFINE_DRIVER_ATTR(config, CONFIG);
ZFCP_DEFINE_DRIVER_ATTR(cio, CIO);
ZFCP_DEFINE_DRIVER_ATTR(qdio, QDIO);
ZFCP_DEFINE_DRIVER_ATTR(erp, ERP);
ZFCP_DEFINE_DRIVER_ATTR(fc, FC);
static struct attribute *zfcp_driver_attrs[] = {
&driver_attr_loglevel_other.attr,
&driver_attr_loglevel_scsi.attr,
&driver_attr_loglevel_fsf.attr,
&driver_attr_loglevel_config.attr,
&driver_attr_loglevel_cio.attr,
&driver_attr_loglevel_qdio.attr,
&driver_attr_loglevel_erp.attr,
&driver_attr_loglevel_fc.attr,
NULL
};
static struct attribute_group zfcp_driver_attr_group = {
.attrs = zfcp_driver_attrs,
};
/**
* zfcp_sysfs_create_driver_files - create sysfs driver files
* @dev: pointer to belonging device
*
* Create all sysfs attributes of the zfcp device driver
*/
int
zfcp_sysfs_driver_create_files(struct device_driver *drv)
{
return sysfs_create_group(&drv->kobj, &zfcp_driver_attr_group);
}
/**
* zfcp_sysfs_remove_driver_files - remove sysfs driver files
* @dev: pointer to belonging device
*
* Remove all sysfs attributes of the zfcp device driver
*/
void
zfcp_sysfs_driver_remove_files(struct device_driver *drv)
{
sysfs_remove_group(&drv->kobj, &zfcp_driver_attr_group);
}
#undef ZFCP_LOG_AREA
#undef ZFCP_LOG_AREA_PREFIX
/*
* linux/drivers/s390/scsi/zfcp_sysfs_port.c
*
* FCP adapter driver for IBM eServer zSeries
*
* sysfs port related routines
*
* Copyright (C) 2003 IBM Entwicklung GmbH, IBM Corporation
* Authors:
* Martin Peschke <mpeschke@de.ibm.com>
* Heiko Carstens <heiko.carstens@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define ZFCP_SYSFS_PORT_C_REVISION "$Revision: 1.26 $"
#include <linux/init.h>
#include <linux/module.h>
#include <asm/ccwdev.h>
#include "zfcp_ext.h"
#include "zfcp_def.h"
#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
#define ZFCP_LOG_AREA_PREFIX ZFCP_LOG_AREA_PREFIX_CONFIG
/**
* zfcp_sysfs_port_release - gets called when a struct device port is released
* @dev: pointer to belonging device
*/
void
zfcp_sysfs_port_release(struct device *dev)
{
struct zfcp_port *port;
port = dev_get_drvdata(dev);
zfcp_port_dequeue(port);
return;
}
/**
* ZFCP_DEFINE_PORT_ATTR
* @_name: name of show attribute
* @_format: format string
* @_value: value to print
*
* Generates attributes for a port.
*/
#define ZFCP_DEFINE_PORT_ATTR(_name, _format, _value) \
static ssize_t zfcp_sysfs_port_##_name##_show(struct device *dev, \
char *buf) \
{ \
struct zfcp_port *port; \
\
port = dev_get_drvdata(dev); \
return sprintf(buf, _format, _value); \
} \
\
static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_port_##_name##_show, NULL);
ZFCP_DEFINE_PORT_ATTR(status, "0x%08x\n", atomic_read(&port->status));
ZFCP_DEFINE_PORT_ATTR(wwnn, "0x%016llx\n", port->wwnn);
ZFCP_DEFINE_PORT_ATTR(d_id, "0x%06x\n", port->d_id);
ZFCP_DEFINE_PORT_ATTR(scsi_id, "0x%x\n", port->scsi_id);
/**
* zfcp_sysfs_unit_add_store - add a unit to sysfs tree
* @dev: pointer to belonging device
* @buf: pointer to input buffer
* @count: number of bytes in buffer
*
* Store function of the "unit_add" attribute of a port.
*/
static ssize_t
zfcp_sysfs_unit_add_store(struct device *dev, const char *buf, size_t count)
{
fcp_lun_t fcp_lun;
char *endp;
struct zfcp_port *port;
struct zfcp_unit *unit;
int retval = -EINVAL;
down(&zfcp_data.config_sema);
port = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status)) {
retval = -EBUSY;
goto out;
}
fcp_lun = simple_strtoull(buf, &endp, 0);
if ((endp + 1) < (buf + count))
goto out;
unit = zfcp_unit_enqueue(port, fcp_lun);
if (!unit)
goto out;
retval = 0;
zfcp_port_get(port);
/* try to open unit only if adapter is online */
if (port->adapter->ccw_device->online == 1)
zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
zfcp_unit_put(unit);
out:
up(&zfcp_data.config_sema);
return retval ? retval : count;
}
static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
/**
* zfcp_sysfs_unit_remove_store - remove a unit from sysfs tree
* @dev: pointer to belonging device
* @buf: pointer to input buffer
* @count: number of bytes in buffer
*/
static ssize_t
zfcp_sysfs_unit_remove_store(struct device *dev, const char *buf, size_t count)
{
struct zfcp_port *port;
struct zfcp_unit *unit;
fcp_lun_t fcp_lun;
char *endp;
int retval = -EINVAL;
down(&zfcp_data.config_sema);
port = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status)) {
retval = -EBUSY;
goto out;
}
fcp_lun = simple_strtoull(buf, &endp, 0);
if ((endp + 1) < (buf + count))
goto out;
write_lock_irq(&zfcp_data.config_lock);
unit = zfcp_get_unit_by_lun(port, fcp_lun);
if (unit && (atomic_read(&unit->refcount) == 0)) {
zfcp_unit_get(unit);
atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
list_move(&unit->list, &port->unit_remove_lh);
}
else {
unit = NULL;
}
write_unlock_irq(&zfcp_data.config_lock);
if (!unit) {
retval = -ENXIO;
goto out;
}
zfcp_erp_unit_shutdown(unit, 0);
zfcp_erp_wait(unit->port->adapter);
zfcp_unit_put(unit);
device_unregister(&unit->sysfs_device);
out:
up(&zfcp_data.config_sema);
return retval ? retval : count;
}
static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);
/**
* zfcp_sysfs_port_failed_store - failed state of port
* @dev: pointer to belonging device
* @buf: pointer to input buffer
* @count: number of bytes in buffer
*
* Store function of the "failed" attribute of a port.
* If a "0" gets written to "failed", error recovery will be
* started for the belonging port.
*/
static ssize_t
zfcp_sysfs_port_failed_store(struct device *dev, const char *buf, size_t count)
{
struct zfcp_port *port;
unsigned int val;
char *endp;
int retval = 0;
down(&zfcp_data.config_sema);
port = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status)) {
retval = -EBUSY;
goto out;
}
val = simple_strtoul(buf, &endp, 0);
if (((endp + 1) < (buf + count)) || (val != 0)) {
retval = -EINVAL;
goto out;
}
/* restart error recovery only if adapter is online */
if (port->adapter->ccw_device->online != 1) {
retval = -ENXIO;
goto out;
}
zfcp_erp_modify_port_status(port, ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);
zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED);
out:
up(&zfcp_data.config_sema);
return retval ? retval : count;
}
/**
* zfcp_sysfs_port_failed_show - failed state of port
* @dev: pointer to belonging device
* @buf: pointer to input buffer
*
* Show function of "failed" attribute of port. Will be
* "0" if port is working, otherwise "1".
*/
static ssize_t
zfcp_sysfs_port_failed_show(struct device *dev, char *buf)
{
struct zfcp_port *port;
port = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &port->status))
return sprintf(buf, "1\n");
else
return sprintf(buf, "0\n");
}
static DEVICE_ATTR(failed, S_IWUSR | S_IRUGO, zfcp_sysfs_port_failed_show,
zfcp_sysfs_port_failed_store);
/**
* zfcp_sysfs_port_in_recovery_show - recovery state of port
* @dev: pointer to belonging device
* @buf: pointer to input buffer
*
* Show function of "in_recovery" attribute of port. Will be
* "0" if no error recovery is pending for port, otherwise "1".
*/
static ssize_t
zfcp_sysfs_port_in_recovery_show(struct device *dev, char *buf)
{
struct zfcp_port *port;
port = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status))
return sprintf(buf, "1\n");
else
return sprintf(buf, "0\n");
}
static DEVICE_ATTR(in_recovery, S_IRUGO, zfcp_sysfs_port_in_recovery_show,
NULL);
static struct attribute *zfcp_port_common_attrs[] = {
&dev_attr_failed.attr,
&dev_attr_in_recovery.attr,
&dev_attr_status.attr,
&dev_attr_wwnn.attr,
&dev_attr_d_id.attr,
NULL
};
static struct attribute_group zfcp_port_common_attr_group = {
.attrs = zfcp_port_common_attrs,
};
static struct attribute *zfcp_port_no_ns_attrs[] = {
&dev_attr_unit_add.attr,
&dev_attr_unit_remove.attr,
&dev_attr_scsi_id.attr,
NULL
};
static struct attribute_group zfcp_port_no_ns_attr_group = {
.attrs = zfcp_port_no_ns_attrs,
};
/**
* zfcp_sysfs_create_port_files - create sysfs port files
* @dev: pointer to belonging device
*
* Create all attributes of the sysfs representation of a port.
*/
int
zfcp_sysfs_port_create_files(struct device *dev, u32 flags)
{
int retval;
retval = sysfs_create_group(&dev->kobj, &zfcp_port_common_attr_group);
if ((flags & ZFCP_STATUS_PORT_NAMESERVER) || retval)
return retval;
retval = sysfs_create_group(&dev->kobj, &zfcp_port_no_ns_attr_group);
if (retval)
sysfs_remove_group(&dev->kobj, &zfcp_port_common_attr_group);
return retval;
}
#undef ZFCP_LOG_AREA
#undef ZFCP_LOG_AREA_PREFIX
/*
* linux/drivers/s390/scsi/zfcp_sysfs_unit.c
*
* FCP adapter driver for IBM eServer zSeries
*
* sysfs unit related routines
*
* Copyright (C) 2003 IBM Entwicklung GmbH, IBM Corporation
* Authors:
* Martin Peschke <mpeschke@de.ibm.com>
* Heiko Carstens <heiko.carstens@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define ZFCP_SYSFS_UNIT_C_REVISION "$Revision: 1.17 $"
#include <linux/init.h>
#include <linux/module.h>
#include <asm/ccwdev.h>
#include "zfcp_ext.h"
#include "zfcp_def.h"
#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
#define ZFCP_LOG_AREA_PREFIX ZFCP_LOG_AREA_PREFIX_CONFIG
/**
* zfcp_sysfs_unit_release - gets called when a struct device unit is released
* @dev: pointer to belonging device
*/
void
zfcp_sysfs_unit_release(struct device *dev)
{
struct zfcp_unit *unit;
unit = dev_get_drvdata(dev);
zfcp_unit_dequeue(unit);
return;
}
/**
* ZFCP_DEFINE_UNIT_ATTR
* @_name: name of show attribute
* @_format: format string
* @_value: value to print
*
* Generates attribute for a unit.
*/
#define ZFCP_DEFINE_UNIT_ATTR(_name, _format, _value) \
static ssize_t zfcp_sysfs_unit_##_name##_show(struct device *dev, \
char *buf) \
{ \
struct zfcp_unit *unit; \
\
unit = dev_get_drvdata(dev); \
return sprintf(buf, _format, _value); \
} \
\
static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_unit_##_name##_show, NULL);
ZFCP_DEFINE_UNIT_ATTR(status, "0x%08x\n", atomic_read(&unit->status));
ZFCP_DEFINE_UNIT_ATTR(scsi_lun, "0x%x\n", unit->scsi_lun);
/**
* zfcp_sysfs_unit_failed_store - failed state of unit
* @dev: pointer to belonging device
* @buf: pointer to input buffer
* @count: number of bytes in buffer
*
* Store function of the "failed" attribute of a unit.
* If a "0" gets written to "failed", error recovery will be
* started for the belonging unit.
*/
static ssize_t
zfcp_sysfs_unit_failed_store(struct device *dev, const char *buf, size_t count)
{
struct zfcp_unit *unit;
unsigned int val;
char *endp;
int retval = 0;
down(&zfcp_data.config_sema);
unit = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status)) {
retval = -EBUSY;
goto out;
}
val = simple_strtoul(buf, &endp, 0);
if (((endp + 1) < (buf + count)) || (val != 0)) {
retval = -EINVAL;
goto out;
}
/* restart error recovery only if adapter is online */
if (unit->port->adapter->ccw_device->online != 1) {
retval = -ENXIO;
goto out;
}
zfcp_erp_modify_unit_status(unit, ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);
zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED);
out:
up(&zfcp_data.config_sema);
return retval ? retval : count;
}
/**
* zfcp_sysfs_unit_failed_show - failed state of unit
* @dev: pointer to belonging device
* @buf: pointer to input buffer
*
* Show function of "failed" attribute of unit. Will be
* "0" if unit is working, otherwise "1".
*/
static ssize_t
zfcp_sysfs_unit_failed_show(struct device *dev, char *buf)
{
struct zfcp_unit *unit;
unit = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status))
return sprintf(buf, "1\n");
else
return sprintf(buf, "0\n");
}
static DEVICE_ATTR(failed, S_IWUSR | S_IRUGO, zfcp_sysfs_unit_failed_show,
zfcp_sysfs_unit_failed_store);
/**
* zfcp_sysfs_unit_in_recovery_show - recovery state of unit
* @dev: pointer to belonging device
* @buf: pointer to input buffer
*
* Show function of "in_recovery" attribute of unit. Will be
* "0" if no error recovery is pending for unit, otherwise "1".
*/
static ssize_t
zfcp_sysfs_unit_in_recovery_show(struct device *dev, char *buf)
{
struct zfcp_unit *unit;
unit = dev_get_drvdata(dev);
if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))
return sprintf(buf, "1\n");
else
return sprintf(buf, "0\n");
}
static DEVICE_ATTR(in_recovery, S_IRUGO, zfcp_sysfs_unit_in_recovery_show,
NULL);
static struct attribute *zfcp_unit_attrs[] = {
&dev_attr_scsi_lun.attr,
&dev_attr_failed.attr,
&dev_attr_in_recovery.attr,
&dev_attr_status.attr,
NULL
};
static struct attribute_group zfcp_unit_attr_group = {
.attrs = zfcp_unit_attrs,
};
/**
* zfcp_sysfs_create_unit_files - create sysfs unit files
* @dev: pointer to belonging device
*
* Create all attributes of the sysfs representation of a unit.
*/
int
zfcp_sysfs_unit_create_files(struct device *dev)
{
return sysfs_create_group(&dev->kobj, &zfcp_unit_attr_group);
}
#undef ZFCP_LOG_AREA
#undef ZFCP_LOG_AREA_PREFIX
......@@ -1657,6 +1657,11 @@ config WD33C93_PIO
# bool 'Cyberstorm Mk III SCSI support (EXPERIMENTAL)' CONFIG_CYBERSTORMIII_SCSI
# bool 'GVP Turbo 040/060 SCSI support (EXPERIMENTAL)' CONFIG_GVP_TURBO_SCSI
config ZFCP
tristate "IBM z900 OpenFCP/SCSI support"
depends on ARCH_S390 && SCSI
endmenu
source "drivers/scsi/pcmcia/Kconfig"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment