forked from luck/tmp_suning_uos_patched
staging: remove i2o subsystem
This subsystem isn't used anymore, and the hardware isn't around. It's been in staging for a while, and it's time for it to now be removed. Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
35bb871663
commit
4a72a7af46
|
@ -108,8 +108,6 @@ source "drivers/staging/clocking-wizard/Kconfig"
|
|||
|
||||
source "drivers/staging/fbtft/Kconfig"
|
||||
|
||||
source "drivers/staging/i2o/Kconfig"
|
||||
|
||||
source "drivers/staging/fsl-mc/Kconfig"
|
||||
|
||||
endif # STAGING
|
||||
|
|
|
@ -46,5 +46,4 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein/
|
|||
obj-$(CONFIG_UNISYSSPAR) += unisys/
|
||||
obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/
|
||||
obj-$(CONFIG_FB_TFT) += fbtft/
|
||||
obj-$(CONFIG_I2O) += i2o/
|
||||
obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
menuconfig I2O
|
||||
tristate "I2O device support"
|
||||
depends on PCI
|
||||
---help---
|
||||
The Intelligent Input/Output (I2O) architecture allows hardware
|
||||
drivers to be split into two parts: an operating system specific
|
||||
module called the OSM and an hardware specific module called the
|
||||
HDM. The OSM can talk to a whole range of HDM's, and ideally the
|
||||
HDM's are not OS dependent. This allows for the same HDM driver to
|
||||
be used under different operating systems if the relevant OSM is in
|
||||
place. In order for this to work, you need to have an I2O interface
|
||||
adapter card in your computer. This card contains a special I/O
|
||||
processor (IOP), thus allowing high speeds since the CPU does not
|
||||
have to deal with I/O.
|
||||
|
||||
If you say Y here, you will get a choice of interface adapter
|
||||
drivers and OSM's with the following questions.
|
||||
|
||||
To compile this support as a module, choose M here: the
|
||||
modules will be called i2o_core.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
if I2O
|
||||
|
||||
config I2O_LCT_NOTIFY_ON_CHANGES
|
||||
bool "Enable LCT notification"
|
||||
default y
|
||||
---help---
|
||||
Only say N here if you have a I2O controller from SUN. The SUN
|
||||
firmware doesn't support LCT notification on changes. If this option
|
||||
is enabled on such a controller the driver will hang up in a endless
|
||||
loop. On all other controllers say Y.
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
config I2O_EXT_ADAPTEC
|
||||
bool "Enable Adaptec extensions"
|
||||
default y
|
||||
---help---
|
||||
Say Y for support of raidutils for Adaptec I2O controllers. You also
|
||||
have to say Y to "I2O Configuration support", "I2O SCSI OSM" below
|
||||
and to "SCSI generic support" under "SCSI device configuration".
|
||||
|
||||
config I2O_EXT_ADAPTEC_DMA64
|
||||
bool "Enable 64-bit DMA"
|
||||
depends on I2O_EXT_ADAPTEC && ( 64BIT || HIGHMEM64G )
|
||||
default y
|
||||
---help---
|
||||
Say Y for support of 64-bit DMA transfer mode on Adaptec I2O
|
||||
controllers.
|
||||
Note: You need at least firmware version 3709.
|
||||
|
||||
config I2O_CONFIG
|
||||
tristate "I2O Configuration support"
|
||||
depends on VIRT_TO_BUS
|
||||
---help---
|
||||
Say Y for support of the configuration interface for the I2O adapters.
|
||||
If you have a RAID controller from Adaptec and you want to use the
|
||||
raidutils to manage your RAID array, you have to say Y here.
|
||||
|
||||
To compile this support as a module, choose M here: the
|
||||
module will be called i2o_config.
|
||||
|
||||
Note: If you want to use the new API you have to download the
|
||||
i2o_config patch from http://i2o.shadowconnect.com/
|
||||
|
||||
config I2O_CONFIG_OLD_IOCTL
|
||||
bool "Enable ioctls (OBSOLETE)"
|
||||
depends on I2O_CONFIG
|
||||
default y
|
||||
---help---
|
||||
Enables old ioctls.
|
||||
|
||||
config I2O_BUS
|
||||
tristate "I2O Bus Adapter OSM"
|
||||
---help---
|
||||
Include support for the I2O Bus Adapter OSM. The Bus Adapter OSM
|
||||
provides access to the busses on the I2O controller. The main purpose
|
||||
is to rescan the bus to find new devices.
|
||||
|
||||
To compile this support as a module, choose M here: the
|
||||
module will be called i2o_bus.
|
||||
|
||||
config I2O_BLOCK
|
||||
tristate "I2O Block OSM"
|
||||
depends on BLOCK
|
||||
---help---
|
||||
Include support for the I2O Block OSM. The Block OSM presents disk
|
||||
and other structured block devices to the operating system. If you
|
||||
are using an RAID controller, you could access the array only by
|
||||
the Block OSM driver. But it is possible to access the single disks
|
||||
by the SCSI OSM driver, for example to monitor the disks.
|
||||
|
||||
To compile this support as a module, choose M here: the
|
||||
module will be called i2o_block.
|
||||
|
||||
config I2O_SCSI
|
||||
tristate "I2O SCSI OSM"
|
||||
depends on SCSI
|
||||
---help---
|
||||
Allows direct SCSI access to SCSI devices on a SCSI or FibreChannel
|
||||
I2O controller. You can use both the SCSI and Block OSM together if
|
||||
you wish. To access a RAID array, you must use the Block OSM driver.
|
||||
But you could use the SCSI OSM driver to monitor the single disks.
|
||||
|
||||
To compile this support as a module, choose M here: the
|
||||
module will be called i2o_scsi.
|
||||
|
||||
config I2O_PROC
|
||||
tristate "I2O /proc support"
|
||||
---help---
|
||||
If you say Y here and to "/proc file system support", you will be
|
||||
able to read I2O related information from the virtual directory
|
||||
/proc/i2o.
|
||||
|
||||
To compile this support as a module, choose M here: the
|
||||
module will be called i2o_proc.
|
||||
|
||||
endif # I2O
|
|
@ -1,16 +0,0 @@
|
|||
#
|
||||
# Makefile for the kernel I2O OSM.
|
||||
#
|
||||
# Note : at this point, these files are compiled on all systems.
|
||||
# In the future, some of these should be built conditionally.
|
||||
#
|
||||
|
||||
i2o_core-y += iop.o driver.o device.o debug.o pci.o exec-osm.o memory.o
|
||||
i2o_bus-y += bus-osm.o
|
||||
i2o_config-y += config-osm.o
|
||||
obj-$(CONFIG_I2O) += i2o_core.o
|
||||
obj-$(CONFIG_I2O_CONFIG)+= i2o_config.o
|
||||
obj-$(CONFIG_I2O_BUS) += i2o_bus.o
|
||||
obj-$(CONFIG_I2O_BLOCK) += i2o_block.o
|
||||
obj-$(CONFIG_I2O_SCSI) += i2o_scsi.o
|
||||
obj-$(CONFIG_I2O_PROC) += i2o_proc.o
|
|
@ -1,98 +0,0 @@
|
|||
|
||||
Linux I2O Support (c) Copyright 1999 Red Hat Software
|
||||
and others.
|
||||
|
||||
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 of the License, or (at your option) any later version.
|
||||
|
||||
AUTHORS (so far)
|
||||
|
||||
Alan Cox, Building Number Three Ltd.
|
||||
Core code, SCSI and Block OSMs
|
||||
|
||||
Steve Ralston, LSI Logic Corp.
|
||||
Debugging SCSI and Block OSM
|
||||
|
||||
Deepak Saxena, Intel Corp.
|
||||
Various core/block extensions
|
||||
/proc interface, bug fixes
|
||||
Ioctl interfaces for control
|
||||
Debugging LAN OSM
|
||||
|
||||
Philip Rumpf
|
||||
Fixed assorted dumb SMP locking bugs
|
||||
|
||||
Juha Sievanen, University of Helsinki Finland
|
||||
LAN OSM code
|
||||
/proc interface to LAN class
|
||||
Bug fixes
|
||||
Core code extensions
|
||||
|
||||
Auvo Häkkinen, University of Helsinki Finland
|
||||
LAN OSM code
|
||||
/Proc interface to LAN class
|
||||
Bug fixes
|
||||
Core code extensions
|
||||
|
||||
Taneli Vähäkangas, University of Helsinki Finland
|
||||
Fixes to i2o_config
|
||||
|
||||
CREDITS
|
||||
|
||||
This work was made possible by
|
||||
|
||||
Red Hat Software
|
||||
Funding for the Building #3 part of the project
|
||||
|
||||
Symbios Logic (Now LSI)
|
||||
Host adapters, hints, known to work platforms when I hit
|
||||
compatibility problems
|
||||
|
||||
BoxHill Corporation
|
||||
Loan of initial FibreChannel disk array used for development work.
|
||||
|
||||
European Commission
|
||||
Funding the work done by the University of Helsinki
|
||||
|
||||
SysKonnect
|
||||
Loan of FDDI and Gigabit Ethernet cards
|
||||
|
||||
ASUSTeK
|
||||
Loan of I2O motherboard
|
||||
|
||||
STATUS:
|
||||
|
||||
o The core setup works within limits.
|
||||
o The scsi layer seems to almost work.
|
||||
I'm still chasing down the hang bug.
|
||||
o The block OSM is mostly functional
|
||||
o LAN OSM works with FDDI and Ethernet cards.
|
||||
|
||||
TO DO:
|
||||
|
||||
General:
|
||||
o Provide hidden address space if asked
|
||||
o Long term message flow control
|
||||
o PCI IOP's without interrupts are not supported yet
|
||||
o Push FAIL handling into the core
|
||||
o DDM control interfaces for module load etc
|
||||
o Add I2O 2.0 support (Deffered to 2.5 kernel)
|
||||
|
||||
Block:
|
||||
o Multiple major numbers
|
||||
o Read ahead and cache handling stuff. Talk to Ingo and people
|
||||
o Power management
|
||||
o Finish Media changers
|
||||
|
||||
SCSI:
|
||||
o Find the right way to associate drives/luns/busses
|
||||
|
||||
Lan:
|
||||
o Performance tuning
|
||||
o Test Fibre Channel code
|
||||
|
||||
Tape:
|
||||
o Anyone seen anything implementing this ?
|
||||
(D.S: Will attempt to do so if spare cycles permit)
|
|
@ -1,394 +0,0 @@
|
|||
|
||||
Linux I2O User Space Interface
|
||||
rev 0.3 - 04/20/99
|
||||
|
||||
=============================================================================
|
||||
Originally written by Deepak Saxena(deepak@plexity.net)
|
||||
Currently maintained by Deepak Saxena(deepak@plexity.net)
|
||||
=============================================================================
|
||||
|
||||
I. Introduction
|
||||
|
||||
The Linux I2O subsystem provides a set of ioctl() commands that can be
|
||||
utilized by user space applications to communicate with IOPs and devices
|
||||
on individual IOPs. This document defines the specific ioctl() commands
|
||||
that are available to the user and provides examples of their uses.
|
||||
|
||||
This document assumes the reader is familiar with or has access to the
|
||||
I2O specification as no I2O message parameters are outlined. For information
|
||||
on the specification, see http://www.i2osig.org
|
||||
|
||||
This document and the I2O user space interface are currently maintained
|
||||
by Deepak Saxena. Please send all comments, errata, and bug fixes to
|
||||
deepak@csociety.purdue.edu
|
||||
|
||||
II. IOP Access
|
||||
|
||||
Access to the I2O subsystem is provided through the device file named
|
||||
/dev/i2o/ctl. This file is a character file with major number 10 and minor
|
||||
number 166. It can be created through the following command:
|
||||
|
||||
mknod /dev/i2o/ctl c 10 166
|
||||
|
||||
III. Determining the IOP Count
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OGETIOPS, int *count);
|
||||
|
||||
u8 count[MAX_I2O_CONTROLLERS];
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function returns the system's active IOP table. count should
|
||||
point to a buffer containing MAX_I2O_CONTROLLERS entries. Upon
|
||||
returning, each entry will contain a non-zero value if the given
|
||||
IOP unit is active, and NULL if it is inactive or non-existent.
|
||||
|
||||
RETURN VALUE.
|
||||
|
||||
Returns 0 if no errors occur, and -1 otherwise. If an error occurs,
|
||||
errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
|
||||
IV. Getting Hardware Resource Table
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OHRTGET, struct i2o_cmd_hrt *hrt);
|
||||
|
||||
struct i2o_cmd_hrtlct
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
void *resbuf; /* Buffer for result */
|
||||
u32 *reslen; /* Buffer length in bytes */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function returns the Hardware Resource Table of the IOP specified
|
||||
by hrt->iop in the buffer pointed to by hrt->resbuf. The actual size of
|
||||
the data is written into *(hrt->reslen).
|
||||
|
||||
RETURNS
|
||||
|
||||
This function returns 0 if no errors occur. If an error occurs, -1
|
||||
is returned and errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ENOBUFS Buffer not large enough. If this occurs, the required
|
||||
buffer length is written into *(hrt->reslen)
|
||||
|
||||
V. Getting Logical Configuration Table
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OLCTGET, struct i2o_cmd_lct *lct);
|
||||
|
||||
struct i2o_cmd_hrtlct
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
void *resbuf; /* Buffer for result */
|
||||
u32 *reslen; /* Buffer length in bytes */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function returns the Logical Configuration Table of the IOP specified
|
||||
by lct->iop in the buffer pointed to by lct->resbuf. The actual size of
|
||||
the data is written into *(lct->reslen).
|
||||
|
||||
RETURNS
|
||||
|
||||
This function returns 0 if no errors occur. If an error occurs, -1
|
||||
is returned and errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ENOBUFS Buffer not large enough. If this occurs, the required
|
||||
buffer length is written into *(lct->reslen)
|
||||
|
||||
VI. Setting Parameters
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OPARMSET, struct i2o_parm_setget *ops);
|
||||
|
||||
struct i2o_cmd_psetget
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
u32 tid; /* Target device TID */
|
||||
void *opbuf; /* Operation List buffer */
|
||||
u32 oplen; /* Operation List buffer length in bytes */
|
||||
void *resbuf; /* Result List buffer */
|
||||
u32 *reslen; /* Result List buffer length in bytes */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function posts a UtilParamsSet message to the device identified
|
||||
by ops->iop and ops->tid. The operation list for the message is
|
||||
sent through the ops->opbuf buffer, and the result list is written
|
||||
into the buffer pointed to by ops->resbuf. The number of bytes
|
||||
written is placed into *(ops->reslen).
|
||||
|
||||
RETURNS
|
||||
|
||||
The return value is the size in bytes of the data written into
|
||||
ops->resbuf if no errors occur. If an error occurs, -1 is returned
|
||||
and errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ENOBUFS Buffer not large enough. If this occurs, the required
|
||||
buffer length is written into *(ops->reslen)
|
||||
ETIMEDOUT Timeout waiting for reply message
|
||||
ENOMEM Kernel memory allocation error
|
||||
|
||||
A return value of 0 does not mean that the value was actually
|
||||
changed properly on the IOP. The user should check the result
|
||||
list to determine the specific status of the transaction.
|
||||
|
||||
VII. Getting Parameters
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OPARMGET, struct i2o_parm_setget *ops);
|
||||
|
||||
struct i2o_parm_setget
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
u32 tid; /* Target device TID */
|
||||
void *opbuf; /* Operation List buffer */
|
||||
u32 oplen; /* Operation List buffer length in bytes */
|
||||
void *resbuf; /* Result List buffer */
|
||||
u32 *reslen; /* Result List buffer length in bytes */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function posts a UtilParamsGet message to the device identified
|
||||
by ops->iop and ops->tid. The operation list for the message is
|
||||
sent through the ops->opbuf buffer, and the result list is written
|
||||
into the buffer pointed to by ops->resbuf. The actual size of data
|
||||
written is placed into *(ops->reslen).
|
||||
|
||||
RETURNS
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ENOBUFS Buffer not large enough. If this occurs, the required
|
||||
buffer length is written into *(ops->reslen)
|
||||
ETIMEDOUT Timeout waiting for reply message
|
||||
ENOMEM Kernel memory allocation error
|
||||
|
||||
A return value of 0 does not mean that the value was actually
|
||||
properly retrieved. The user should check the result list
|
||||
to determine the specific status of the transaction.
|
||||
|
||||
VIII. Downloading Software
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OSWDL, struct i2o_sw_xfer *sw);
|
||||
|
||||
struct i2o_sw_xfer
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
u8 flags; /* DownloadFlags field */
|
||||
u8 sw_type; /* Software type */
|
||||
u32 sw_id; /* Software ID */
|
||||
void *buf; /* Pointer to software buffer */
|
||||
u32 *swlen; /* Length of software buffer */
|
||||
u32 *maxfrag; /* Number of fragments */
|
||||
u32 *curfrag; /* Current fragment number */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function downloads a software fragment pointed by sw->buf
|
||||
to the iop identified by sw->iop. The DownloadFlags, SwID, SwType
|
||||
and SwSize fields of the ExecSwDownload message are filled in with
|
||||
the values of sw->flags, sw->sw_id, sw->sw_type and *(sw->swlen).
|
||||
|
||||
The fragments _must_ be sent in order and be 8K in size. The last
|
||||
fragment _may_ be shorter, however. The kernel will compute its
|
||||
size based on information in the sw->swlen field.
|
||||
|
||||
Please note that SW transfers can take a long time.
|
||||
|
||||
RETURNS
|
||||
|
||||
This function returns 0 no errors occur. If an error occurs, -1
|
||||
is returned and errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ETIMEDOUT Timeout waiting for reply message
|
||||
ENOMEM Kernel memory allocation error
|
||||
|
||||
IX. Uploading Software
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OSWUL, struct i2o_sw_xfer *sw);
|
||||
|
||||
struct i2o_sw_xfer
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
u8 flags; /* UploadFlags */
|
||||
u8 sw_type; /* Software type */
|
||||
u32 sw_id; /* Software ID */
|
||||
void *buf; /* Pointer to software buffer */
|
||||
u32 *swlen; /* Length of software buffer */
|
||||
u32 *maxfrag; /* Number of fragments */
|
||||
u32 *curfrag; /* Current fragment number */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function uploads a software fragment from the IOP identified
|
||||
by sw->iop, sw->sw_type, sw->sw_id and optionally sw->swlen fields.
|
||||
The UploadFlags, SwID, SwType and SwSize fields of the ExecSwUpload
|
||||
message are filled in with the values of sw->flags, sw->sw_id,
|
||||
sw->sw_type and *(sw->swlen).
|
||||
|
||||
The fragments _must_ be requested in order and be 8K in size. The
|
||||
user is responsible for allocating memory pointed by sw->buf. The
|
||||
last fragment _may_ be shorter.
|
||||
|
||||
Please note that SW transfers can take a long time.
|
||||
|
||||
RETURNS
|
||||
|
||||
This function returns 0 if no errors occur. If an error occurs, -1
|
||||
is returned and errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ETIMEDOUT Timeout waiting for reply message
|
||||
ENOMEM Kernel memory allocation error
|
||||
|
||||
X. Removing Software
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OSWDEL, struct i2o_sw_xfer *sw);
|
||||
|
||||
struct i2o_sw_xfer
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
u8 flags; /* RemoveFlags */
|
||||
u8 sw_type; /* Software type */
|
||||
u32 sw_id; /* Software ID */
|
||||
void *buf; /* Unused */
|
||||
u32 *swlen; /* Length of the software data */
|
||||
u32 *maxfrag; /* Unused */
|
||||
u32 *curfrag; /* Unused */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function removes software from the IOP identified by sw->iop.
|
||||
The RemoveFlags, SwID, SwType and SwSize fields of the ExecSwRemove message
|
||||
are filled in with the values of sw->flags, sw->sw_id, sw->sw_type and
|
||||
*(sw->swlen). Give zero in *(sw->len) if the value is unknown. IOP uses
|
||||
*(sw->swlen) value to verify correct identication of the module to remove.
|
||||
The actual size of the module is written into *(sw->swlen).
|
||||
|
||||
RETURNS
|
||||
|
||||
This function returns 0 if no errors occur. If an error occurs, -1
|
||||
is returned and errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ETIMEDOUT Timeout waiting for reply message
|
||||
ENOMEM Kernel memory allocation error
|
||||
|
||||
X. Validating Configuration
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OVALIDATE, int *iop);
|
||||
u32 iop;
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function posts an ExecConfigValidate message to the controller
|
||||
identified by iop. This message indicates that the current
|
||||
configuration is accepted. The iop changes the status of suspect drivers
|
||||
to valid and may delete old drivers from its store.
|
||||
|
||||
RETURNS
|
||||
|
||||
This function returns 0 if no erro occur. If an error occurs, -1 is
|
||||
returned and errno is set appropriately:
|
||||
|
||||
ETIMEDOUT Timeout waiting for reply message
|
||||
ENXIO Invalid IOP number
|
||||
|
||||
XI. Configuration Dialog
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
ioctl(fd, I2OHTML, struct i2o_html *htquery);
|
||||
struct i2o_html
|
||||
{
|
||||
u32 iop; /* IOP unit number */
|
||||
u32 tid; /* Target device ID */
|
||||
u32 page; /* HTML page */
|
||||
void *resbuf; /* Buffer for reply HTML page */
|
||||
u32 *reslen; /* Length in bytes of reply buffer */
|
||||
void *qbuf; /* Pointer to HTTP query string */
|
||||
u32 qlen; /* Length in bytes of query string buffer */
|
||||
};
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This function posts an UtilConfigDialog message to the device identified
|
||||
by htquery->iop and htquery->tid. The requested HTML page number is
|
||||
provided by the htquery->page field, and the resultant data is stored
|
||||
in the buffer pointed to by htquery->resbuf. If there is an HTTP query
|
||||
string that is to be sent to the device, it should be sent in the buffer
|
||||
pointed to by htquery->qbuf. If there is no query string, this field
|
||||
should be set to NULL. The actual size of the reply received is written
|
||||
into *(htquery->reslen).
|
||||
|
||||
RETURNS
|
||||
|
||||
This function returns 0 if no error occur. If an error occurs, -1
|
||||
is returned and errno is set appropriately:
|
||||
|
||||
EFAULT Invalid user space pointer was passed
|
||||
ENXIO Invalid IOP number
|
||||
ENOBUFS Buffer not large enough. If this occurs, the required
|
||||
buffer length is written into *(ops->reslen)
|
||||
ETIMEDOUT Timeout waiting for reply message
|
||||
ENOMEM Kernel memory allocation error
|
||||
|
||||
XII. Events
|
||||
|
||||
In the process of determining this. Current idea is to have use
|
||||
the select() interface to allow user apps to periodically poll
|
||||
the /dev/i2o/ctl device for events. When select() notifies the user
|
||||
that an event is available, the user would call read() to retrieve
|
||||
a list of all the events that are pending for the specific device.
|
||||
|
||||
=============================================================================
|
||||
Revision History
|
||||
=============================================================================
|
||||
|
||||
Rev 0.1 - 04/01/99
|
||||
- Initial revision
|
||||
|
||||
Rev 0.2 - 04/06/99
|
||||
- Changed return values to match UNIX ioctl() standard. Only return values
|
||||
are 0 and -1. All errors are reported through errno.
|
||||
- Added summary of proposed possible event interfaces
|
||||
|
||||
Rev 0.3 - 04/20/99
|
||||
- Changed all ioctls() to use pointers to user data instead of actual data
|
||||
- Updated error values to match the code
|
|
@ -1,177 +0,0 @@
|
|||
/*
|
||||
* Bus Adapter OSM
|
||||
*
|
||||
* Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>
|
||||
* initial version.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "i2o.h"
|
||||
|
||||
#define OSM_NAME "bus-osm"
|
||||
#define OSM_VERSION "1.317"
|
||||
#define OSM_DESCRIPTION "I2O Bus Adapter OSM"
|
||||
|
||||
static struct i2o_driver i2o_bus_driver;
|
||||
|
||||
/* Bus OSM class handling definition */
|
||||
static struct i2o_class_id i2o_bus_class_id[] = {
|
||||
{I2O_CLASS_BUS_ADAPTER},
|
||||
{I2O_CLASS_END}
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_bus_scan - Scan the bus for new devices
|
||||
* @dev: I2O device of the bus, which should be scanned
|
||||
*
|
||||
* Scans the bus dev for new / removed devices. After the scan a new LCT
|
||||
* will be fetched automatically.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int i2o_bus_scan(struct i2o_device *dev)
|
||||
{
|
||||
struct i2o_message *msg;
|
||||
|
||||
msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
|
||||
if (IS_ERR(msg))
|
||||
return -ETIMEDOUT;
|
||||
|
||||
msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
|
||||
msg->u.head[1] =
|
||||
cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.
|
||||
tid);
|
||||
|
||||
return i2o_msg_post_wait(dev->iop, msg, 60);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_bus_store_scan - Scan the I2O Bus Adapter
|
||||
* @d: device which should be scanned
|
||||
* @attr: device_attribute
|
||||
* @buf: output buffer
|
||||
* @count: buffer size
|
||||
*
|
||||
* Returns count.
|
||||
*/
|
||||
static ssize_t i2o_bus_store_scan(struct device *d,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(d);
|
||||
int rc;
|
||||
|
||||
rc = i2o_bus_scan(i2o_dev);
|
||||
if (rc)
|
||||
osm_warn("bus scan failed %d\n", rc);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Bus Adapter OSM device attributes */
|
||||
static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
|
||||
|
||||
/**
|
||||
* i2o_bus_probe - verify if dev is a I2O Bus Adapter device and install it
|
||||
* @dev: device to verify if it is a I2O Bus Adapter device
|
||||
*
|
||||
* Because we want all Bus Adapters always return 0.
|
||||
* Except when we fail. Then we are sad.
|
||||
*
|
||||
* Returns 0, except when we fail to excel.
|
||||
*/
|
||||
static int i2o_bus_probe(struct device *dev)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
|
||||
int rc;
|
||||
|
||||
rc = device_create_file(dev, &dev_attr_scan);
|
||||
if (rc)
|
||||
goto err_out;
|
||||
|
||||
osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
put_device(dev);
|
||||
return rc;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_bus_remove - remove the I2O Bus Adapter device from the system again
|
||||
* @dev: I2O Bus Adapter device which should be removed
|
||||
*
|
||||
* Always returns 0.
|
||||
*/
|
||||
static int i2o_bus_remove(struct device *dev)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
|
||||
device_remove_file(dev, &dev_attr_scan);
|
||||
|
||||
put_device(dev);
|
||||
|
||||
osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/* Bus Adapter OSM driver struct */
|
||||
static struct i2o_driver i2o_bus_driver = {
|
||||
.name = OSM_NAME,
|
||||
.classes = i2o_bus_class_id,
|
||||
.driver = {
|
||||
.probe = i2o_bus_probe,
|
||||
.remove = i2o_bus_remove,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_bus_init - Bus Adapter OSM initialization function
|
||||
*
|
||||
* Only register the Bus Adapter OSM in the I2O core.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int __init i2o_bus_init(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
|
||||
|
||||
/* Register Bus Adapter OSM into I2O core */
|
||||
rc = i2o_driver_register(&i2o_bus_driver);
|
||||
if (rc) {
|
||||
osm_err("Could not register Bus Adapter OSM\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_bus_exit - Bus Adapter OSM exit function
|
||||
*
|
||||
* Unregisters Bus Adapter OSM from I2O core.
|
||||
*/
|
||||
static void __exit i2o_bus_exit(void)
|
||||
{
|
||||
i2o_driver_unregister(&i2o_bus_driver);
|
||||
};
|
||||
|
||||
MODULE_AUTHOR("Markus Lidel <Markus.Lidel@shadowconnect.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION(OSM_DESCRIPTION);
|
||||
MODULE_VERSION(OSM_VERSION);
|
||||
|
||||
module_init(i2o_bus_init);
|
||||
module_exit(i2o_bus_exit);
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* Configuration OSM
|
||||
*
|
||||
* Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>
|
||||
* initial version.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "i2o.h"
|
||||
#include <linux/dcache.h>
|
||||
#include <linux/namei.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#define OSM_NAME "config-osm"
|
||||
#define OSM_VERSION "1.323"
|
||||
#define OSM_DESCRIPTION "I2O Configuration OSM"
|
||||
|
||||
/* access mode user rw */
|
||||
#define S_IWRSR (S_IRUSR | S_IWUSR)
|
||||
|
||||
static struct i2o_driver i2o_config_driver;
|
||||
|
||||
/* Config OSM driver struct */
|
||||
static struct i2o_driver i2o_config_driver = {
|
||||
.name = OSM_NAME,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL
|
||||
#include "i2o_config.c"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* i2o_config_init - Configuration OSM initialization function
|
||||
*
|
||||
* Registers Configuration OSM in the I2O core and if old ioctl's are
|
||||
* compiled in initialize them.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int __init i2o_config_init(void)
|
||||
{
|
||||
printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
|
||||
|
||||
if (i2o_driver_register(&i2o_config_driver)) {
|
||||
osm_err("handler register failed.\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL
|
||||
if (i2o_config_old_init()) {
|
||||
osm_err("old config handler initialization failed\n");
|
||||
i2o_driver_unregister(&i2o_config_driver);
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_config_exit - Configuration OSM exit function
|
||||
*
|
||||
* If old ioctl's are compiled in exit remove them and unregisters
|
||||
* Configuration OSM from I2O core.
|
||||
*/
|
||||
static void i2o_config_exit(void)
|
||||
{
|
||||
#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL
|
||||
i2o_config_old_exit();
|
||||
#endif
|
||||
|
||||
i2o_driver_unregister(&i2o_config_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Markus Lidel <Markus.Lidel@shadowconnect.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION(OSM_DESCRIPTION);
|
||||
MODULE_VERSION(OSM_VERSION);
|
||||
|
||||
module_init(i2o_config_init);
|
||||
module_exit(i2o_config_exit);
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* I2O core internal declarations
|
||||
*
|
||||
* Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>
|
||||
* initial version.
|
||||
*/
|
||||
|
||||
/* Exec-OSM */
|
||||
extern struct i2o_driver i2o_exec_driver;
|
||||
extern int i2o_exec_lct_get(struct i2o_controller *);
|
||||
|
||||
extern int __init i2o_exec_init(void);
|
||||
extern void i2o_exec_exit(void);
|
||||
|
||||
/* driver */
|
||||
extern struct bus_type i2o_bus_type;
|
||||
|
||||
extern int i2o_driver_dispatch(struct i2o_controller *, u32);
|
||||
|
||||
extern int __init i2o_driver_init(void);
|
||||
extern void i2o_driver_exit(void);
|
||||
|
||||
/* PCI */
|
||||
extern int __init i2o_pci_init(void);
|
||||
extern void __exit i2o_pci_exit(void);
|
||||
|
||||
/* device */
|
||||
extern const struct attribute_group *i2o_device_groups[];
|
||||
|
||||
extern void i2o_device_remove(struct i2o_device *);
|
||||
extern int i2o_device_parse_lct(struct i2o_controller *);
|
||||
|
||||
int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
|
||||
int oplen, void *reslist, int reslen);
|
||||
|
||||
/* IOP */
|
||||
extern struct i2o_controller *i2o_iop_alloc(void);
|
||||
|
||||
/**
|
||||
* i2o_iop_free - Free the i2o_controller struct
|
||||
* @c: I2O controller to free
|
||||
*/
|
||||
static inline void i2o_iop_free(struct i2o_controller *c)
|
||||
{
|
||||
i2o_pool_free(&c->in_msg);
|
||||
kfree(c);
|
||||
}
|
||||
|
||||
extern int i2o_iop_add(struct i2o_controller *);
|
||||
extern void i2o_iop_remove(struct i2o_controller *);
|
||||
|
||||
/* control registers relative to c->base */
|
||||
#define I2O_IRQ_STATUS 0x30
|
||||
#define I2O_IRQ_MASK 0x34
|
||||
#define I2O_IN_PORT 0x40
|
||||
#define I2O_OUT_PORT 0x44
|
||||
|
||||
/* Motorola/Freescale specific register offset */
|
||||
#define I2O_MOTOROLA_PORT_OFFSET 0x10400
|
||||
|
||||
#define I2O_IRQ_OUTBOUND_POST 0x00000008
|
|
@ -1,473 +0,0 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/pci.h>
|
||||
#include "i2o.h"
|
||||
|
||||
static void i2o_report_util_cmd(u8 cmd);
|
||||
static void i2o_report_exec_cmd(u8 cmd);
|
||||
static void i2o_report_fail_status(u8 req_status, u32 *msg);
|
||||
static void i2o_report_common_status(u8 req_status);
|
||||
static void i2o_report_common_dsc(u16 detailed_status);
|
||||
|
||||
/*
|
||||
* Used for error reporting/debugging purposes.
|
||||
* Report Cmd name, Request status, Detailed Status.
|
||||
*/
|
||||
void i2o_report_status(const char *severity, const char *str,
|
||||
struct i2o_message *m)
|
||||
{
|
||||
u32 *msg = (u32 *) m;
|
||||
u8 cmd = (msg[1] >> 24) & 0xFF;
|
||||
u8 req_status = (msg[4] >> 24) & 0xFF;
|
||||
u16 detailed_status = msg[4] & 0xFFFF;
|
||||
|
||||
if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
|
||||
return; /* No status in this reply */
|
||||
|
||||
printk("%s%s: ", severity, str);
|
||||
|
||||
if (cmd < 0x1F) // Utility cmd
|
||||
i2o_report_util_cmd(cmd);
|
||||
|
||||
else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd
|
||||
i2o_report_exec_cmd(cmd);
|
||||
else
|
||||
printk("Cmd = %0#2x, ", cmd); // Other cmds
|
||||
|
||||
if (msg[0] & MSG_FAIL) {
|
||||
i2o_report_fail_status(req_status, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
i2o_report_common_status(req_status);
|
||||
|
||||
if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
|
||||
i2o_report_common_dsc(detailed_status);
|
||||
else
|
||||
printk(" / DetailedStatus = %0#4x.\n",
|
||||
detailed_status);
|
||||
}
|
||||
|
||||
/* Used to dump a message to syslog during debugging */
|
||||
void i2o_dump_message(struct i2o_message *m)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
u32 *msg = (u32 *) m;
|
||||
int i;
|
||||
|
||||
printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
|
||||
msg[0] >> 16 & 0xffff, msg);
|
||||
for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
|
||||
printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for error reporting/debugging purposes.
|
||||
* Following fail status are common to all classes.
|
||||
* The preserved message must be handled in the reply handler.
|
||||
*/
|
||||
static void i2o_report_fail_status(u8 req_status, u32 *msg)
|
||||
{
|
||||
static char *FAIL_STATUS[] = {
|
||||
"0x80", /* not used */
|
||||
"SERVICE_SUSPENDED", /* 0x81 */
|
||||
"SERVICE_TERMINATED", /* 0x82 */
|
||||
"CONGESTION",
|
||||
"FAILURE",
|
||||
"STATE_ERROR",
|
||||
"TIME_OUT",
|
||||
"ROUTING_FAILURE",
|
||||
"INVALID_VERSION",
|
||||
"INVALID_OFFSET",
|
||||
"INVALID_MSG_FLAGS",
|
||||
"FRAME_TOO_SMALL",
|
||||
"FRAME_TOO_LARGE",
|
||||
"INVALID_TARGET_ID",
|
||||
"INVALID_INITIATOR_ID",
|
||||
"INVALID_INITIATOR_CONTEX", /* 0x8F */
|
||||
"UNKNOWN_FAILURE" /* 0xFF */
|
||||
};
|
||||
|
||||
if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
|
||||
printk("TRANSPORT_UNKNOWN_FAILURE (%0#2x).\n",
|
||||
req_status);
|
||||
else
|
||||
printk("TRANSPORT_%s.\n",
|
||||
FAIL_STATUS[req_status & 0x0F]);
|
||||
|
||||
/* Dump some details */
|
||||
|
||||
printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n",
|
||||
(msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
|
||||
printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
|
||||
(msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
|
||||
printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n",
|
||||
msg[5] >> 16, msg[5] & 0xFFF);
|
||||
|
||||
printk(KERN_ERR " Severity: 0x%02X\n", (msg[4] >> 16) & 0xFF);
|
||||
if (msg[4] & (1 << 16))
|
||||
printk(KERN_DEBUG "(FormatError), "
|
||||
"this msg can never be delivered/processed.\n");
|
||||
if (msg[4] & (1 << 17))
|
||||
printk(KERN_DEBUG "(PathError), "
|
||||
"this msg can no longer be delivered/processed.\n");
|
||||
if (msg[4] & (1 << 18))
|
||||
printk(KERN_DEBUG "(PathState), "
|
||||
"the system state does not allow delivery.\n");
|
||||
if (msg[4] & (1 << 19))
|
||||
printk(KERN_DEBUG
|
||||
"(Congestion), resources temporarily not available;"
|
||||
"do not retry immediately.\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for error reporting/debugging purposes.
|
||||
* Following reply status are common to all classes.
|
||||
*/
|
||||
static void i2o_report_common_status(u8 req_status)
|
||||
{
|
||||
static char *REPLY_STATUS[] = {
|
||||
"SUCCESS",
|
||||
"ABORT_DIRTY",
|
||||
"ABORT_NO_DATA_TRANSFER",
|
||||
"ABORT_PARTIAL_TRANSFER",
|
||||
"ERROR_DIRTY",
|
||||
"ERROR_NO_DATA_TRANSFER",
|
||||
"ERROR_PARTIAL_TRANSFER",
|
||||
"PROCESS_ABORT_DIRTY",
|
||||
"PROCESS_ABORT_NO_DATA_TRANSFER",
|
||||
"PROCESS_ABORT_PARTIAL_TRANSFER",
|
||||
"TRANSACTION_ERROR",
|
||||
"PROGRESS_REPORT"
|
||||
};
|
||||
|
||||
if (req_status >= ARRAY_SIZE(REPLY_STATUS))
|
||||
printk("RequestStatus = %0#2x", req_status);
|
||||
else
|
||||
printk("%s", REPLY_STATUS[req_status]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for error reporting/debugging purposes.
|
||||
* Following detailed status are valid for executive class,
|
||||
* utility class, DDM class and for transaction error replies.
|
||||
*/
|
||||
static void i2o_report_common_dsc(u16 detailed_status)
|
||||
{
|
||||
static char *COMMON_DSC[] = {
|
||||
"SUCCESS",
|
||||
"0x01", // not used
|
||||
"BAD_KEY",
|
||||
"TCL_ERROR",
|
||||
"REPLY_BUFFER_FULL",
|
||||
"NO_SUCH_PAGE",
|
||||
"INSUFFICIENT_RESOURCE_SOFT",
|
||||
"INSUFFICIENT_RESOURCE_HARD",
|
||||
"0x08", // not used
|
||||
"CHAIN_BUFFER_TOO_LARGE",
|
||||
"UNSUPPORTED_FUNCTION",
|
||||
"DEVICE_LOCKED",
|
||||
"DEVICE_RESET",
|
||||
"INAPPROPRIATE_FUNCTION",
|
||||
"INVALID_INITIATOR_ADDRESS",
|
||||
"INVALID_MESSAGE_FLAGS",
|
||||
"INVALID_OFFSET",
|
||||
"INVALID_PARAMETER",
|
||||
"INVALID_REQUEST",
|
||||
"INVALID_TARGET_ADDRESS",
|
||||
"MESSAGE_TOO_LARGE",
|
||||
"MESSAGE_TOO_SMALL",
|
||||
"MISSING_PARAMETER",
|
||||
"TIMEOUT",
|
||||
"UNKNOWN_ERROR",
|
||||
"UNKNOWN_FUNCTION",
|
||||
"UNSUPPORTED_VERSION",
|
||||
"DEVICE_BUSY",
|
||||
"DEVICE_NOT_AVAILABLE"
|
||||
};
|
||||
|
||||
if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
|
||||
printk(" / DetailedStatus = %0#4x.\n",
|
||||
detailed_status);
|
||||
else
|
||||
printk(" / %s.\n", COMMON_DSC[detailed_status]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for error reporting/debugging purposes
|
||||
*/
|
||||
static void i2o_report_util_cmd(u8 cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case I2O_CMD_UTIL_NOP:
|
||||
printk("UTIL_NOP, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_ABORT:
|
||||
printk("UTIL_ABORT, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_CLAIM:
|
||||
printk("UTIL_CLAIM, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_RELEASE:
|
||||
printk("UTIL_CLAIM_RELEASE, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_CONFIG_DIALOG:
|
||||
printk("UTIL_CONFIG_DIALOG, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_DEVICE_RESERVE:
|
||||
printk("UTIL_DEVICE_RESERVE, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_DEVICE_RELEASE:
|
||||
printk("UTIL_DEVICE_RELEASE, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_EVT_ACK:
|
||||
printk("UTIL_EVENT_ACKNOWLEDGE, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_EVT_REGISTER:
|
||||
printk("UTIL_EVENT_REGISTER, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_LOCK:
|
||||
printk("UTIL_LOCK, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_LOCK_RELEASE:
|
||||
printk("UTIL_LOCK_RELEASE, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_PARAMS_GET:
|
||||
printk("UTIL_PARAMS_GET, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_PARAMS_SET:
|
||||
printk("UTIL_PARAMS_SET, ");
|
||||
break;
|
||||
case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
|
||||
printk("UTIL_REPLY_FAULT_NOTIFY, ");
|
||||
break;
|
||||
default:
|
||||
printk("Cmd = %0#2x, ", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for error reporting/debugging purposes
|
||||
*/
|
||||
static void i2o_report_exec_cmd(u8 cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case I2O_CMD_ADAPTER_ASSIGN:
|
||||
printk("EXEC_ADAPTER_ASSIGN, ");
|
||||
break;
|
||||
case I2O_CMD_ADAPTER_READ:
|
||||
printk("EXEC_ADAPTER_READ, ");
|
||||
break;
|
||||
case I2O_CMD_ADAPTER_RELEASE:
|
||||
printk("EXEC_ADAPTER_RELEASE, ");
|
||||
break;
|
||||
case I2O_CMD_BIOS_INFO_SET:
|
||||
printk("EXEC_BIOS_INFO_SET, ");
|
||||
break;
|
||||
case I2O_CMD_BOOT_DEVICE_SET:
|
||||
printk("EXEC_BOOT_DEVICE_SET, ");
|
||||
break;
|
||||
case I2O_CMD_CONFIG_VALIDATE:
|
||||
printk("EXEC_CONFIG_VALIDATE, ");
|
||||
break;
|
||||
case I2O_CMD_CONN_SETUP:
|
||||
printk("EXEC_CONN_SETUP, ");
|
||||
break;
|
||||
case I2O_CMD_DDM_DESTROY:
|
||||
printk("EXEC_DDM_DESTROY, ");
|
||||
break;
|
||||
case I2O_CMD_DDM_ENABLE:
|
||||
printk("EXEC_DDM_ENABLE, ");
|
||||
break;
|
||||
case I2O_CMD_DDM_QUIESCE:
|
||||
printk("EXEC_DDM_QUIESCE, ");
|
||||
break;
|
||||
case I2O_CMD_DDM_RESET:
|
||||
printk("EXEC_DDM_RESET, ");
|
||||
break;
|
||||
case I2O_CMD_DDM_SUSPEND:
|
||||
printk("EXEC_DDM_SUSPEND, ");
|
||||
break;
|
||||
case I2O_CMD_DEVICE_ASSIGN:
|
||||
printk("EXEC_DEVICE_ASSIGN, ");
|
||||
break;
|
||||
case I2O_CMD_DEVICE_RELEASE:
|
||||
printk("EXEC_DEVICE_RELEASE, ");
|
||||
break;
|
||||
case I2O_CMD_HRT_GET:
|
||||
printk("EXEC_HRT_GET, ");
|
||||
break;
|
||||
case I2O_CMD_ADAPTER_CLEAR:
|
||||
printk("EXEC_IOP_CLEAR, ");
|
||||
break;
|
||||
case I2O_CMD_ADAPTER_CONNECT:
|
||||
printk("EXEC_IOP_CONNECT, ");
|
||||
break;
|
||||
case I2O_CMD_ADAPTER_RESET:
|
||||
printk("EXEC_IOP_RESET, ");
|
||||
break;
|
||||
case I2O_CMD_LCT_NOTIFY:
|
||||
printk("EXEC_LCT_NOTIFY, ");
|
||||
break;
|
||||
case I2O_CMD_OUTBOUND_INIT:
|
||||
printk("EXEC_OUTBOUND_INIT, ");
|
||||
break;
|
||||
case I2O_CMD_PATH_ENABLE:
|
||||
printk("EXEC_PATH_ENABLE, ");
|
||||
break;
|
||||
case I2O_CMD_PATH_QUIESCE:
|
||||
printk("EXEC_PATH_QUIESCE, ");
|
||||
break;
|
||||
case I2O_CMD_PATH_RESET:
|
||||
printk("EXEC_PATH_RESET, ");
|
||||
break;
|
||||
case I2O_CMD_STATIC_MF_CREATE:
|
||||
printk("EXEC_STATIC_MF_CREATE, ");
|
||||
break;
|
||||
case I2O_CMD_STATIC_MF_RELEASE:
|
||||
printk("EXEC_STATIC_MF_RELEASE, ");
|
||||
break;
|
||||
case I2O_CMD_STATUS_GET:
|
||||
printk("EXEC_STATUS_GET, ");
|
||||
break;
|
||||
case I2O_CMD_SW_DOWNLOAD:
|
||||
printk("EXEC_SW_DOWNLOAD, ");
|
||||
break;
|
||||
case I2O_CMD_SW_UPLOAD:
|
||||
printk("EXEC_SW_UPLOAD, ");
|
||||
break;
|
||||
case I2O_CMD_SW_REMOVE:
|
||||
printk("EXEC_SW_REMOVE, ");
|
||||
break;
|
||||
case I2O_CMD_SYS_ENABLE:
|
||||
printk("EXEC_SYS_ENABLE, ");
|
||||
break;
|
||||
case I2O_CMD_SYS_MODIFY:
|
||||
printk("EXEC_SYS_MODIFY, ");
|
||||
break;
|
||||
case I2O_CMD_SYS_QUIESCE:
|
||||
printk("EXEC_SYS_QUIESCE, ");
|
||||
break;
|
||||
case I2O_CMD_SYS_TAB_SET:
|
||||
printk("EXEC_SYS_TAB_SET, ");
|
||||
break;
|
||||
default:
|
||||
printk("Cmd = %#02x, ", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void i2o_debug_state(struct i2o_controller *c)
|
||||
{
|
||||
printk(KERN_INFO "%s: State = ", c->name);
|
||||
switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
|
||||
case 0x01:
|
||||
printk("INIT\n");
|
||||
break;
|
||||
case 0x02:
|
||||
printk("RESET\n");
|
||||
break;
|
||||
case 0x04:
|
||||
printk("HOLD\n");
|
||||
break;
|
||||
case 0x05:
|
||||
printk("READY\n");
|
||||
break;
|
||||
case 0x08:
|
||||
printk("OPERATIONAL\n");
|
||||
break;
|
||||
case 0x10:
|
||||
printk("FAILED\n");
|
||||
break;
|
||||
case 0x11:
|
||||
printk("FAULTED\n");
|
||||
break;
|
||||
default:
|
||||
printk("%x (unknown !!)\n",
|
||||
((i2o_status_block *) c->status_block.virt)->iop_state);
|
||||
}
|
||||
};
|
||||
|
||||
void i2o_dump_hrt(struct i2o_controller *c)
|
||||
{
|
||||
u32 *rows = (u32 *) c->hrt.virt;
|
||||
u8 *p = (u8 *) c->hrt.virt;
|
||||
u8 *d;
|
||||
int count;
|
||||
int length;
|
||||
int i;
|
||||
int state;
|
||||
|
||||
if (p[3] != 0) {
|
||||
printk(KERN_ERR
|
||||
"%s: HRT table for controller is too new a version.\n",
|
||||
c->name);
|
||||
return;
|
||||
}
|
||||
|
||||
count = p[0] | (p[1] << 8);
|
||||
length = p[2];
|
||||
|
||||
printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
|
||||
c->name, count, length << 2);
|
||||
|
||||
rows += 2;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
printk(KERN_INFO "Adapter %08X: ", rows[0]);
|
||||
p = (u8 *) (rows + 1);
|
||||
d = (u8 *) (rows + 2);
|
||||
state = p[1] << 8 | p[0];
|
||||
|
||||
printk("TID %04X:[", state & 0xFFF);
|
||||
state >>= 12;
|
||||
if (state & (1 << 0))
|
||||
printk("H"); /* Hidden */
|
||||
if (state & (1 << 2)) {
|
||||
printk("P"); /* Present */
|
||||
if (state & (1 << 1))
|
||||
printk("C"); /* Controlled */
|
||||
}
|
||||
if (state > 9)
|
||||
printk("*"); /* Hard */
|
||||
|
||||
printk("]:");
|
||||
|
||||
switch (p[3] & 0xFFFF) {
|
||||
case 0:
|
||||
/* Adapter private bus - easy */
|
||||
printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
|
||||
d[1] << 8 | d[0], *(u32 *) (d + 4));
|
||||
break;
|
||||
case 1:
|
||||
/* ISA bus */
|
||||
printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
|
||||
d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
|
||||
break;
|
||||
|
||||
case 2: /* EISA bus */
|
||||
printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
|
||||
p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
|
||||
break;
|
||||
|
||||
case 3: /* MCA bus */
|
||||
printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
|
||||
d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
|
||||
break;
|
||||
|
||||
case 4: /* PCI bus */
|
||||
printk("PCI %d: Bus %d Device %d Function %d", p[2],
|
||||
d[2], d[1], d[0]);
|
||||
break;
|
||||
|
||||
case 0x80: /* Other */
|
||||
default:
|
||||
printk("Unsupported bus type.");
|
||||
break;
|
||||
}
|
||||
printk("\n");
|
||||
rows += length;
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(i2o_dump_message);
|
|
@ -1,592 +0,0 @@
|
|||
/*
|
||||
* Functions to handle I2O devices
|
||||
*
|
||||
* Copyright (C) 2004 Markus Lidel <Markus.Lidel@shadowconnect.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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>
|
||||
* initial version.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "i2o.h"
|
||||
#include <linux/delay.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/slab.h>
|
||||
#include "core.h"
|
||||
|
||||
/**
|
||||
* i2o_device_issue_claim - claim or release a device
|
||||
* @dev: I2O device to claim or release
|
||||
* @cmd: claim or release command
|
||||
* @type: type of claim
|
||||
*
|
||||
* Issue I2O UTIL_CLAIM or UTIL_RELEASE messages. The message to be sent
|
||||
* is set by cmd. dev is the I2O device which should be claim or
|
||||
* released and the type is the claim type (see the I2O spec).
|
||||
*
|
||||
* Returs 0 on success or negative error code on failure.
|
||||
*/
|
||||
static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
|
||||
u32 type)
|
||||
{
|
||||
struct i2o_message *msg;
|
||||
|
||||
msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
|
||||
if (IS_ERR(msg))
|
||||
return PTR_ERR(msg);
|
||||
|
||||
msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
|
||||
msg->u.head[1] =
|
||||
cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid);
|
||||
msg->body[0] = cpu_to_le32(type);
|
||||
|
||||
return i2o_msg_post_wait(dev->iop, msg, 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_device_claim - claim a device for use by an OSM
|
||||
* @dev: I2O device to claim
|
||||
*
|
||||
* Do the leg work to assign a device to a given OSM. If the claim succeeds,
|
||||
* the owner is the primary. If the attempt fails a negative errno code
|
||||
* is returned. On success zero is returned.
|
||||
*/
|
||||
int i2o_device_claim(struct i2o_device *dev)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
rc = i2o_device_issue_claim(dev, I2O_CMD_UTIL_CLAIM, I2O_CLAIM_PRIMARY);
|
||||
if (!rc)
|
||||
pr_debug("i2o: claim of device %d succeeded\n",
|
||||
dev->lct_data.tid);
|
||||
else
|
||||
pr_debug("i2o: claim of device %d failed %d\n",
|
||||
dev->lct_data.tid, rc);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_device_claim_release - release a device that the OSM is using
|
||||
* @dev: device to release
|
||||
*
|
||||
* Drop a claim by an OSM on a given I2O device.
|
||||
*
|
||||
* AC - some devices seem to want to refuse an unclaim until they have
|
||||
* finished internal processing. It makes sense since you don't want a
|
||||
* new device to go reconfiguring the entire system until you are done.
|
||||
* Thus we are prepared to wait briefly.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
int i2o_device_claim_release(struct i2o_device *dev)
|
||||
{
|
||||
int tries;
|
||||
int rc = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
/*
|
||||
* If the controller takes a nonblocking approach to
|
||||
* releases we have to sleep/poll for a few times.
|
||||
*/
|
||||
for (tries = 0; tries < 10; tries++) {
|
||||
rc = i2o_device_issue_claim(dev, I2O_CMD_UTIL_RELEASE,
|
||||
I2O_CLAIM_PRIMARY);
|
||||
if (!rc)
|
||||
break;
|
||||
|
||||
ssleep(1);
|
||||
}
|
||||
|
||||
if (!rc)
|
||||
pr_debug("i2o: claim release of device %d succeeded\n",
|
||||
dev->lct_data.tid);
|
||||
else
|
||||
pr_debug("i2o: claim release of device %d failed %d\n",
|
||||
dev->lct_data.tid, rc);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_device_release - release the memory for a I2O device
|
||||
* @dev: I2O device which should be released
|
||||
*
|
||||
* Release the allocated memory. This function is called if refcount of
|
||||
* device reaches 0 automatically.
|
||||
*/
|
||||
static void i2o_device_release(struct device *dev)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
|
||||
pr_debug("i2o: device %s released\n", dev_name(dev));
|
||||
|
||||
kfree(i2o_dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* class_id_show - Displays class id of I2O device
|
||||
* @dev: device of which the class id should be displayed
|
||||
* @attr: pointer to device attribute
|
||||
* @buf: buffer into which the class id should be printed
|
||||
*
|
||||
* Returns the number of bytes which are printed into the buffer.
|
||||
*/
|
||||
static ssize_t class_id_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
|
||||
sprintf(buf, "0x%03x\n", i2o_dev->lct_data.class_id);
|
||||
return strlen(buf) + 1;
|
||||
}
|
||||
static DEVICE_ATTR_RO(class_id);
|
||||
|
||||
/**
|
||||
* tid_show - Displays TID of I2O device
|
||||
* @dev: device of which the TID should be displayed
|
||||
* @attr: pointer to device attribute
|
||||
* @buf: buffer into which the TID should be printed
|
||||
*
|
||||
* Returns the number of bytes which are printed into the buffer.
|
||||
*/
|
||||
static ssize_t tid_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
|
||||
sprintf(buf, "0x%03x\n", i2o_dev->lct_data.tid);
|
||||
return strlen(buf) + 1;
|
||||
}
|
||||
static DEVICE_ATTR_RO(tid);
|
||||
|
||||
/* I2O device attributes */
|
||||
static struct attribute *i2o_device_attrs[] = {
|
||||
&dev_attr_class_id.attr,
|
||||
&dev_attr_tid.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group i2o_device_group = {
|
||||
.attrs = i2o_device_attrs,
|
||||
};
|
||||
|
||||
const struct attribute_group *i2o_device_groups[] = {
|
||||
&i2o_device_group,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_device_alloc - Allocate a I2O device and initialize it
|
||||
*
|
||||
* Allocate the memory for a I2O device and initialize locks and lists
|
||||
*
|
||||
* Returns the allocated I2O device or a negative error code if the device
|
||||
* could not be allocated.
|
||||
*/
|
||||
static struct i2o_device *i2o_device_alloc(void)
|
||||
{
|
||||
struct i2o_device *dev;
|
||||
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (!dev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
INIT_LIST_HEAD(&dev->list);
|
||||
mutex_init(&dev->lock);
|
||||
|
||||
dev->device.bus = &i2o_bus_type;
|
||||
dev->device.release = &i2o_device_release;
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_device_add - allocate a new I2O device and add it to the IOP
|
||||
* @c: I2O controller that the device is on
|
||||
* @entry: LCT entry of the I2O device
|
||||
*
|
||||
* Allocate a new I2O device and initialize it with the LCT entry. The
|
||||
* device is appended to the device list of the controller.
|
||||
*
|
||||
* Returns zero on success, or a -ve errno.
|
||||
*/
|
||||
static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
|
||||
{
|
||||
struct i2o_device *i2o_dev, *tmp;
|
||||
int rc;
|
||||
|
||||
i2o_dev = i2o_device_alloc();
|
||||
if (IS_ERR(i2o_dev)) {
|
||||
printk(KERN_ERR "i2o: unable to allocate i2o device\n");
|
||||
return PTR_ERR(i2o_dev);
|
||||
}
|
||||
|
||||
i2o_dev->lct_data = *entry;
|
||||
|
||||
dev_set_name(&i2o_dev->device, "%d:%03x", c->unit,
|
||||
i2o_dev->lct_data.tid);
|
||||
|
||||
i2o_dev->iop = c;
|
||||
i2o_dev->device.parent = &c->device;
|
||||
|
||||
rc = device_register(&i2o_dev->device);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
list_add_tail(&i2o_dev->list, &c->devices);
|
||||
|
||||
/* create user entries for this device */
|
||||
tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
|
||||
if (tmp && (tmp != i2o_dev)) {
|
||||
rc = sysfs_create_link(&i2o_dev->device.kobj,
|
||||
&tmp->device.kobj, "user");
|
||||
if (rc)
|
||||
goto unreg_dev;
|
||||
}
|
||||
|
||||
/* create user entries referring to this device */
|
||||
list_for_each_entry(tmp, &c->devices, list)
|
||||
if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
|
||||
&& (tmp != i2o_dev)) {
|
||||
rc = sysfs_create_link(&tmp->device.kobj,
|
||||
&i2o_dev->device.kobj, "user");
|
||||
if (rc)
|
||||
goto rmlink1;
|
||||
}
|
||||
|
||||
/* create parent entries for this device */
|
||||
tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
|
||||
if (tmp && (tmp != i2o_dev)) {
|
||||
rc = sysfs_create_link(&i2o_dev->device.kobj,
|
||||
&tmp->device.kobj, "parent");
|
||||
if (rc)
|
||||
goto rmlink1;
|
||||
}
|
||||
|
||||
/* create parent entries referring to this device */
|
||||
list_for_each_entry(tmp, &c->devices, list)
|
||||
if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
|
||||
&& (tmp != i2o_dev)) {
|
||||
rc = sysfs_create_link(&tmp->device.kobj,
|
||||
&i2o_dev->device.kobj, "parent");
|
||||
if (rc)
|
||||
goto rmlink2;
|
||||
}
|
||||
|
||||
i2o_driver_notify_device_add_all(i2o_dev);
|
||||
|
||||
pr_debug("i2o: device %s added\n", dev_name(&i2o_dev->device));
|
||||
|
||||
return 0;
|
||||
|
||||
rmlink2:
|
||||
/* If link creating failed halfway, we loop whole list to cleanup.
|
||||
* And we don't care wrong removing of link, because sysfs_remove_link
|
||||
* will take care of it.
|
||||
*/
|
||||
list_for_each_entry(tmp, &c->devices, list) {
|
||||
if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
|
||||
sysfs_remove_link(&tmp->device.kobj, "parent");
|
||||
}
|
||||
sysfs_remove_link(&i2o_dev->device.kobj, "parent");
|
||||
rmlink1:
|
||||
list_for_each_entry(tmp, &c->devices, list)
|
||||
if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
|
||||
sysfs_remove_link(&tmp->device.kobj, "user");
|
||||
sysfs_remove_link(&i2o_dev->device.kobj, "user");
|
||||
unreg_dev:
|
||||
list_del(&i2o_dev->list);
|
||||
device_unregister(&i2o_dev->device);
|
||||
err:
|
||||
kfree(i2o_dev);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_device_remove - remove an I2O device from the I2O core
|
||||
* @i2o_dev: I2O device which should be released
|
||||
*
|
||||
* Is used on I2O controller removal or LCT modification, when the device
|
||||
* is removed from the system. Note that the device could still hang
|
||||
* around until the refcount reaches 0.
|
||||
*/
|
||||
void i2o_device_remove(struct i2o_device *i2o_dev)
|
||||
{
|
||||
struct i2o_device *tmp;
|
||||
struct i2o_controller *c = i2o_dev->iop;
|
||||
|
||||
i2o_driver_notify_device_remove_all(i2o_dev);
|
||||
|
||||
sysfs_remove_link(&i2o_dev->device.kobj, "parent");
|
||||
sysfs_remove_link(&i2o_dev->device.kobj, "user");
|
||||
|
||||
list_for_each_entry(tmp, &c->devices, list) {
|
||||
if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
|
||||
sysfs_remove_link(&tmp->device.kobj, "parent");
|
||||
if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
|
||||
sysfs_remove_link(&tmp->device.kobj, "user");
|
||||
}
|
||||
list_del(&i2o_dev->list);
|
||||
|
||||
device_unregister(&i2o_dev->device);
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_device_parse_lct - Parse a previously fetched LCT and create devices
|
||||
* @c: I2O controller from which the LCT should be parsed.
|
||||
*
|
||||
* The Logical Configuration Table tells us what we can talk to on the
|
||||
* board. For every entry we create an I2O device, which is registered in
|
||||
* the I2O core.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
int i2o_device_parse_lct(struct i2o_controller *c)
|
||||
{
|
||||
struct i2o_device *dev, *tmp;
|
||||
i2o_lct *lct;
|
||||
u32 *dlct = c->dlct.virt;
|
||||
int max = 0, i = 0;
|
||||
u16 table_size;
|
||||
u32 buf;
|
||||
|
||||
mutex_lock(&c->lct_lock);
|
||||
|
||||
kfree(c->lct);
|
||||
|
||||
buf = le32_to_cpu(*dlct++);
|
||||
table_size = buf & 0xffff;
|
||||
|
||||
lct = c->lct = kmalloc(table_size * 4, GFP_KERNEL);
|
||||
if (!lct) {
|
||||
mutex_unlock(&c->lct_lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
lct->lct_ver = buf >> 28;
|
||||
lct->boot_tid = buf >> 16 & 0xfff;
|
||||
lct->table_size = table_size;
|
||||
lct->change_ind = le32_to_cpu(*dlct++);
|
||||
lct->iop_flags = le32_to_cpu(*dlct++);
|
||||
|
||||
table_size -= 3;
|
||||
|
||||
pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max,
|
||||
lct->table_size);
|
||||
|
||||
while (table_size > 0) {
|
||||
i2o_lct_entry *entry = &lct->lct_entry[max];
|
||||
int found = 0;
|
||||
|
||||
buf = le32_to_cpu(*dlct++);
|
||||
entry->entry_size = buf & 0xffff;
|
||||
entry->tid = buf >> 16 & 0xfff;
|
||||
|
||||
entry->change_ind = le32_to_cpu(*dlct++);
|
||||
entry->device_flags = le32_to_cpu(*dlct++);
|
||||
|
||||
buf = le32_to_cpu(*dlct++);
|
||||
entry->class_id = buf & 0xfff;
|
||||
entry->version = buf >> 12 & 0xf;
|
||||
entry->vendor_id = buf >> 16;
|
||||
|
||||
entry->sub_class = le32_to_cpu(*dlct++);
|
||||
|
||||
buf = le32_to_cpu(*dlct++);
|
||||
entry->user_tid = buf & 0xfff;
|
||||
entry->parent_tid = buf >> 12 & 0xfff;
|
||||
entry->bios_info = buf >> 24;
|
||||
|
||||
memcpy(&entry->identity_tag, dlct, 8);
|
||||
dlct += 2;
|
||||
|
||||
entry->event_capabilities = le32_to_cpu(*dlct++);
|
||||
|
||||
/* add new devices, which are new in the LCT */
|
||||
list_for_each_entry_safe(dev, tmp, &c->devices, list) {
|
||||
if (entry->tid == dev->lct_data.tid) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
i2o_device_add(c, entry);
|
||||
|
||||
table_size -= 9;
|
||||
max++;
|
||||
}
|
||||
|
||||
/* remove devices, which are not in the LCT anymore */
|
||||
list_for_each_entry_safe(dev, tmp, &c->devices, list) {
|
||||
int found = 0;
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
if (lct->lct_entry[i].tid == dev->lct_data.tid) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
i2o_device_remove(dev);
|
||||
}
|
||||
|
||||
mutex_unlock(&c->lct_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run time support routines
|
||||
*/
|
||||
|
||||
/* Issue UTIL_PARAMS_GET or UTIL_PARAMS_SET
|
||||
*
|
||||
* This function can be used for all UtilParamsGet/Set operations.
|
||||
* The OperationList is given in oplist-buffer,
|
||||
* and results are returned in reslist-buffer.
|
||||
* Note that the minimum sized reslist is 8 bytes and contains
|
||||
* ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
|
||||
*/
|
||||
int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
|
||||
int oplen, void *reslist, int reslen)
|
||||
{
|
||||
struct i2o_message *msg;
|
||||
int i = 0;
|
||||
int rc;
|
||||
struct i2o_dma res;
|
||||
struct i2o_controller *c = i2o_dev->iop;
|
||||
struct device *dev = &c->pdev->dev;
|
||||
|
||||
res.virt = NULL;
|
||||
|
||||
if (i2o_dma_alloc(dev, &res, reslen))
|
||||
return -ENOMEM;
|
||||
|
||||
msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
|
||||
if (IS_ERR(msg)) {
|
||||
i2o_dma_free(dev, &res);
|
||||
return PTR_ERR(msg);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
msg->u.head[1] =
|
||||
cpu_to_le32(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid);
|
||||
msg->body[i++] = cpu_to_le32(0x00000000);
|
||||
msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */
|
||||
memcpy(&msg->body[i], oplist, oplen);
|
||||
i += (oplen / 4 + (oplen % 4 ? 1 : 0));
|
||||
msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */
|
||||
msg->body[i++] = cpu_to_le32(res.phys);
|
||||
|
||||
msg->u.head[0] =
|
||||
cpu_to_le32(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) |
|
||||
SGL_OFFSET_5);
|
||||
|
||||
rc = i2o_msg_post_wait_mem(c, msg, 10, &res);
|
||||
|
||||
/* This only looks like a memory leak - don't "fix" it. */
|
||||
if (rc == -ETIMEDOUT)
|
||||
return rc;
|
||||
|
||||
memcpy(reslist, res.virt, res.len);
|
||||
i2o_dma_free(dev, &res);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Query one field group value or a whole scalar group.
|
||||
*/
|
||||
int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
|
||||
void *buf, int buflen)
|
||||
{
|
||||
u32 opblk[] = { cpu_to_le32(0x00000001),
|
||||
cpu_to_le32((u16) group << 16 | I2O_PARAMS_FIELD_GET),
|
||||
cpu_to_le32((s16) field << 16 | 0x00000001)
|
||||
};
|
||||
u8 *resblk; /* 8 bytes for header */
|
||||
int rc;
|
||||
|
||||
resblk = kmalloc(buflen + 8, GFP_KERNEL);
|
||||
if (!resblk)
|
||||
return -ENOMEM;
|
||||
|
||||
rc = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk,
|
||||
sizeof(opblk), resblk, buflen + 8);
|
||||
|
||||
memcpy(buf, resblk + 8, buflen); /* cut off header */
|
||||
|
||||
kfree(resblk);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* if oper == I2O_PARAMS_TABLE_GET, get from all rows
|
||||
* if fieldcount == -1 return all fields
|
||||
* ibuf and ibuflen are unused (use NULL, 0)
|
||||
* else return specific fields
|
||||
* ibuf contains fieldindexes
|
||||
*
|
||||
* if oper == I2O_PARAMS_LIST_GET, get from specific rows
|
||||
* if fieldcount == -1 return all fields
|
||||
* ibuf contains rowcount, keyvalues
|
||||
* else return specific fields
|
||||
* fieldcount is # of fieldindexes
|
||||
* ibuf contains fieldindexes, rowcount, keyvalues
|
||||
*
|
||||
* You could also use directly function i2o_issue_params().
|
||||
*/
|
||||
int i2o_parm_table_get(struct i2o_device *dev, int oper, int group,
|
||||
int fieldcount, void *ibuf, int ibuflen, void *resblk,
|
||||
int reslen)
|
||||
{
|
||||
u16 *opblk;
|
||||
int size;
|
||||
|
||||
size = 10 + ibuflen;
|
||||
if (size % 4)
|
||||
size += 4 - size % 4;
|
||||
|
||||
opblk = kmalloc(size, GFP_KERNEL);
|
||||
if (opblk == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
opblk[0] = 1; /* operation count */
|
||||
opblk[1] = 0; /* pad */
|
||||
opblk[2] = oper;
|
||||
opblk[3] = group;
|
||||
opblk[4] = fieldcount;
|
||||
memcpy(opblk + 5, ibuf, ibuflen); /* other params */
|
||||
|
||||
size = i2o_parm_issue(dev, I2O_CMD_UTIL_PARAMS_GET, opblk,
|
||||
size, resblk, reslen);
|
||||
|
||||
kfree(opblk);
|
||||
if (size > reslen)
|
||||
return reslen;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(i2o_device_claim);
|
||||
EXPORT_SYMBOL(i2o_device_claim_release);
|
||||
EXPORT_SYMBOL(i2o_parm_field_get);
|
||||
EXPORT_SYMBOL(i2o_parm_table_get);
|
||||
EXPORT_SYMBOL(i2o_parm_issue);
|
|
@ -1,381 +0,0 @@
|
|||
/*
|
||||
* Functions to handle I2O drivers (OSMs) and I2O bus type for sysfs
|
||||
*
|
||||
* Copyright (C) 2004 Markus Lidel <Markus.Lidel@shadowconnect.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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>
|
||||
* initial version.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include "i2o.h"
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/slab.h>
|
||||
#include "core.h"
|
||||
|
||||
#define OSM_NAME "i2o"
|
||||
|
||||
/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */
|
||||
static unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
|
||||
module_param_named(max_drivers, i2o_max_drivers, uint, 0);
|
||||
MODULE_PARM_DESC(max_drivers, "maximum number of OSM's to support");
|
||||
|
||||
/* I2O drivers lock and array */
|
||||
static spinlock_t i2o_drivers_lock;
|
||||
static struct i2o_driver **i2o_drivers;
|
||||
|
||||
/**
|
||||
* i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM)
|
||||
* @dev: device which should be verified
|
||||
* @drv: the driver to match against
|
||||
*
|
||||
* Used by the bus to check if the driver wants to handle the device.
|
||||
*
|
||||
* Returns 1 if the class ids of the driver match the class id of the
|
||||
* device, otherwise 0.
|
||||
*/
|
||||
static int i2o_bus_match(struct device *dev, struct device_driver *drv)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
struct i2o_driver *i2o_drv = to_i2o_driver(drv);
|
||||
struct i2o_class_id *ids = i2o_drv->classes;
|
||||
|
||||
if (ids)
|
||||
while (ids->class_id != I2O_CLASS_END) {
|
||||
if (ids->class_id == i2o_dev->lct_data.class_id)
|
||||
return 1;
|
||||
ids++;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/* I2O bus type */
|
||||
struct bus_type i2o_bus_type = {
|
||||
.name = "i2o",
|
||||
.match = i2o_bus_match,
|
||||
.dev_groups = i2o_device_groups,
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_driver_register - Register a I2O driver (OSM) in the I2O core
|
||||
* @drv: I2O driver which should be registered
|
||||
*
|
||||
* Registers the OSM drv in the I2O core and creates an event queues if
|
||||
* necessary.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
int i2o_driver_register(struct i2o_driver *drv)
|
||||
{
|
||||
struct i2o_controller *c;
|
||||
int i;
|
||||
int rc = 0;
|
||||
unsigned long flags;
|
||||
|
||||
osm_debug("Register driver %s\n", drv->name);
|
||||
|
||||
if (drv->event) {
|
||||
drv->event_queue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1,
|
||||
drv->name);
|
||||
if (!drv->event_queue) {
|
||||
osm_err("Could not initialize event queue for driver "
|
||||
"%s\n", drv->name);
|
||||
return -EFAULT;
|
||||
}
|
||||
osm_debug("Event queue initialized for driver %s\n", drv->name);
|
||||
} else
|
||||
drv->event_queue = NULL;
|
||||
|
||||
drv->driver.name = drv->name;
|
||||
drv->driver.bus = &i2o_bus_type;
|
||||
|
||||
spin_lock_irqsave(&i2o_drivers_lock, flags);
|
||||
|
||||
for (i = 0; i2o_drivers[i]; i++)
|
||||
if (i >= i2o_max_drivers) {
|
||||
osm_err("too many drivers registered, increase max_drivers\n");
|
||||
spin_unlock_irqrestore(&i2o_drivers_lock, flags);
|
||||
rc = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
drv->context = i;
|
||||
i2o_drivers[i] = drv;
|
||||
|
||||
spin_unlock_irqrestore(&i2o_drivers_lock, flags);
|
||||
|
||||
osm_debug("driver %s gets context id %d\n", drv->name, drv->context);
|
||||
|
||||
list_for_each_entry(c, &i2o_controllers, list) {
|
||||
struct i2o_device *i2o_dev;
|
||||
|
||||
i2o_driver_notify_controller_add(drv, c);
|
||||
list_for_each_entry(i2o_dev, &c->devices, list)
|
||||
i2o_driver_notify_device_add(drv, i2o_dev);
|
||||
}
|
||||
|
||||
rc = driver_register(&drv->driver);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
return 0;
|
||||
out:
|
||||
if (drv->event_queue) {
|
||||
destroy_workqueue(drv->event_queue);
|
||||
drv->event_queue = NULL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_driver_unregister - Unregister a I2O driver (OSM) from the I2O core
|
||||
* @drv: I2O driver which should be unregistered
|
||||
*
|
||||
* Unregisters the OSM drv from the I2O core and cleanup event queues if
|
||||
* necessary.
|
||||
*/
|
||||
void i2o_driver_unregister(struct i2o_driver *drv)
|
||||
{
|
||||
struct i2o_controller *c;
|
||||
unsigned long flags;
|
||||
|
||||
osm_debug("unregister driver %s\n", drv->name);
|
||||
|
||||
driver_unregister(&drv->driver);
|
||||
|
||||
list_for_each_entry(c, &i2o_controllers, list) {
|
||||
struct i2o_device *i2o_dev;
|
||||
|
||||
list_for_each_entry(i2o_dev, &c->devices, list)
|
||||
i2o_driver_notify_device_remove(drv, i2o_dev);
|
||||
|
||||
i2o_driver_notify_controller_remove(drv, c);
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&i2o_drivers_lock, flags);
|
||||
i2o_drivers[drv->context] = NULL;
|
||||
spin_unlock_irqrestore(&i2o_drivers_lock, flags);
|
||||
|
||||
if (drv->event_queue) {
|
||||
destroy_workqueue(drv->event_queue);
|
||||
drv->event_queue = NULL;
|
||||
osm_debug("event queue removed for %s\n", drv->name);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_driver_dispatch - dispatch an I2O reply message
|
||||
* @c: I2O controller of the message
|
||||
* @m: I2O message number
|
||||
*
|
||||
* The reply is delivered to the driver from which the original message
|
||||
* was. This function is only called from interrupt context.
|
||||
*
|
||||
* Returns 0 on success and the message should not be flushed. Returns > 0
|
||||
* on success and if the message should be flushed afterwords. Returns
|
||||
* negative error code on failure (the message will be flushed too).
|
||||
*/
|
||||
int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
|
||||
{
|
||||
struct i2o_driver *drv;
|
||||
struct i2o_message *msg = i2o_msg_out_to_virt(c, m);
|
||||
u32 context = le32_to_cpu(msg->u.s.icntxt);
|
||||
unsigned long flags;
|
||||
|
||||
if (unlikely(context >= i2o_max_drivers)) {
|
||||
osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
|
||||
context);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&i2o_drivers_lock, flags);
|
||||
drv = i2o_drivers[context];
|
||||
spin_unlock_irqrestore(&i2o_drivers_lock, flags);
|
||||
|
||||
if (unlikely(!drv)) {
|
||||
osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
|
||||
context);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_UTIL_EVT_REGISTER) {
|
||||
struct i2o_device *dev, *tmp;
|
||||
struct i2o_event *evt;
|
||||
u16 size;
|
||||
u16 tid = le32_to_cpu(msg->u.head[1]) & 0xfff;
|
||||
|
||||
osm_debug("event received from device %d\n", tid);
|
||||
|
||||
if (!drv->event)
|
||||
return -EIO;
|
||||
|
||||
/* cut of header from message size (in 32-bit words) */
|
||||
size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5;
|
||||
|
||||
evt = kzalloc(size * 4 + sizeof(*evt), GFP_ATOMIC);
|
||||
if (!evt)
|
||||
return -ENOMEM;
|
||||
|
||||
evt->size = size;
|
||||
evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt);
|
||||
evt->event_indicator = le32_to_cpu(msg->body[0]);
|
||||
memcpy(&evt->data, &msg->body[1], size * 4);
|
||||
|
||||
list_for_each_entry_safe(dev, tmp, &c->devices, list)
|
||||
if (dev->lct_data.tid == tid) {
|
||||
evt->i2o_dev = dev;
|
||||
break;
|
||||
}
|
||||
|
||||
INIT_WORK(&evt->work, drv->event);
|
||||
queue_work(drv->event_queue, &evt->work);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unlikely(!drv->reply)) {
|
||||
osm_debug("%s: Reply to driver %s, but no reply function defined!\n",
|
||||
c->name, drv->name);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return drv->reply(c, m, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_controller_add_all - Send notify of added controller
|
||||
* @c: newly added controller
|
||||
*
|
||||
* Send notifications to all registered drivers that a new controller was
|
||||
* added.
|
||||
*/
|
||||
void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
|
||||
{
|
||||
int i;
|
||||
struct i2o_driver *drv;
|
||||
|
||||
for (i = 0; i < i2o_max_drivers; i++) {
|
||||
drv = i2o_drivers[i];
|
||||
|
||||
if (drv)
|
||||
i2o_driver_notify_controller_add(drv, c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_controller_remove_all - Send notify of removed controller
|
||||
* @c: controller that is being removed
|
||||
*
|
||||
* Send notifications to all registered drivers that a controller was
|
||||
* removed.
|
||||
*/
|
||||
void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
|
||||
{
|
||||
int i;
|
||||
struct i2o_driver *drv;
|
||||
|
||||
for (i = 0; i < i2o_max_drivers; i++) {
|
||||
drv = i2o_drivers[i];
|
||||
|
||||
if (drv)
|
||||
i2o_driver_notify_controller_remove(drv, c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_device_add_all - Send notify of added device
|
||||
* @i2o_dev: newly added I2O device
|
||||
*
|
||||
* Send notifications to all registered drivers that a device was added.
|
||||
*/
|
||||
void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
|
||||
{
|
||||
int i;
|
||||
struct i2o_driver *drv;
|
||||
|
||||
for (i = 0; i < i2o_max_drivers; i++) {
|
||||
drv = i2o_drivers[i];
|
||||
|
||||
if (drv)
|
||||
i2o_driver_notify_device_add(drv, i2o_dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_device_remove_all - Send notify of removed device
|
||||
* @i2o_dev: device that is being removed
|
||||
*
|
||||
* Send notifications to all registered drivers that a device was removed.
|
||||
*/
|
||||
void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev)
|
||||
{
|
||||
int i;
|
||||
struct i2o_driver *drv;
|
||||
|
||||
for (i = 0; i < i2o_max_drivers; i++) {
|
||||
drv = i2o_drivers[i];
|
||||
|
||||
if (drv)
|
||||
i2o_driver_notify_device_remove(drv, i2o_dev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_driver_init - initialize I2O drivers (OSMs)
|
||||
*
|
||||
* Registers the I2O bus and allocate memory for the array of OSMs.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
int __init i2o_driver_init(void)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
spin_lock_init(&i2o_drivers_lock);
|
||||
|
||||
if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64)) {
|
||||
osm_warn("max_drivers set to %d, but must be >=2 and <= 64\n",
|
||||
i2o_max_drivers);
|
||||
i2o_max_drivers = I2O_MAX_DRIVERS;
|
||||
}
|
||||
osm_info("max drivers = %d\n", i2o_max_drivers);
|
||||
|
||||
i2o_drivers =
|
||||
kcalloc(i2o_max_drivers, sizeof(*i2o_drivers), GFP_KERNEL);
|
||||
if (!i2o_drivers)
|
||||
return -ENOMEM;
|
||||
|
||||
rc = bus_register(&i2o_bus_type);
|
||||
|
||||
if (rc < 0)
|
||||
kfree(i2o_drivers);
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_driver_exit - clean up I2O drivers (OSMs)
|
||||
*
|
||||
* Unregisters the I2O bus and frees driver array.
|
||||
*/
|
||||
void i2o_driver_exit(void)
|
||||
{
|
||||
bus_unregister(&i2o_bus_type);
|
||||
kfree(i2o_drivers);
|
||||
};
|
||||
|
||||
EXPORT_SYMBOL(i2o_driver_register);
|
||||
EXPORT_SYMBOL(i2o_driver_unregister);
|
||||
EXPORT_SYMBOL(i2o_driver_notify_controller_add_all);
|
||||
EXPORT_SYMBOL(i2o_driver_notify_controller_remove_all);
|
||||
EXPORT_SYMBOL(i2o_driver_notify_device_add_all);
|
||||
EXPORT_SYMBOL(i2o_driver_notify_device_remove_all);
|
|
@ -1,612 +0,0 @@
|
|||
/*
|
||||
* Executive OSM
|
||||
*
|
||||
* Copyright (C) 1999-2002 Red Hat Software
|
||||
*
|
||||
* Written by Alan Cox, Building Number Three Ltd
|
||||
*
|
||||
* 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* A lot of the I2O message side code from this is taken from the Red
|
||||
* Creek RCPCI45 adapter driver by Red Creek Communications
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Philipp Rumpf
|
||||
* Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
|
||||
* Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
|
||||
* Deepak Saxena <deepak@plexity.net>
|
||||
* Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
|
||||
* Alan Cox <alan@lxorguk.ukuu.org.uk>:
|
||||
* Ported to Linux 2.5.
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>:
|
||||
* Minor fixes for 2.6.
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>:
|
||||
* Support for sysfs included.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "i2o.h"
|
||||
#include <linux/delay.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sched.h> /* wait_event_interruptible_timeout() needs this */
|
||||
#include <asm/param.h> /* HZ */
|
||||
#include "core.h"
|
||||
|
||||
#define OSM_NAME "exec-osm"
|
||||
|
||||
struct i2o_driver i2o_exec_driver;
|
||||
|
||||
/* global wait list for POST WAIT */
|
||||
static LIST_HEAD(i2o_exec_wait_list);
|
||||
|
||||
/* Wait struct needed for POST WAIT */
|
||||
struct i2o_exec_wait {
|
||||
wait_queue_head_t *wq; /* Pointer to Wait queue */
|
||||
struct i2o_dma dma; /* DMA buffers to free on failure */
|
||||
u32 tcntxt; /* transaction context from reply */
|
||||
int complete; /* 1 if reply received otherwise 0 */
|
||||
u32 m; /* message id */
|
||||
struct i2o_message *msg; /* pointer to the reply message */
|
||||
struct list_head list; /* node in global wait list */
|
||||
spinlock_t lock; /* lock before modifying */
|
||||
};
|
||||
|
||||
/* Work struct needed to handle LCT NOTIFY replies */
|
||||
struct i2o_exec_lct_notify_work {
|
||||
struct work_struct work; /* work struct */
|
||||
struct i2o_controller *c; /* controller on which the LCT NOTIFY
|
||||
was received */
|
||||
};
|
||||
|
||||
/* Exec OSM class handling definition */
|
||||
static struct i2o_class_id i2o_exec_class_id[] = {
|
||||
{I2O_CLASS_EXECUTIVE},
|
||||
{I2O_CLASS_END}
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_wait_alloc - Allocate a i2o_exec_wait struct an initialize it
|
||||
*
|
||||
* Allocate the i2o_exec_wait struct and initialize the wait.
|
||||
*
|
||||
* Returns i2o_exec_wait pointer on success or negative error code on
|
||||
* failure.
|
||||
*/
|
||||
static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
|
||||
{
|
||||
struct i2o_exec_wait *wait;
|
||||
|
||||
wait = kzalloc(sizeof(*wait), GFP_KERNEL);
|
||||
if (!wait)
|
||||
return NULL;
|
||||
|
||||
INIT_LIST_HEAD(&wait->list);
|
||||
spin_lock_init(&wait->lock);
|
||||
|
||||
return wait;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_wait_free - Free an i2o_exec_wait struct
|
||||
* @wait: I2O wait data which should be cleaned up
|
||||
*/
|
||||
static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
|
||||
{
|
||||
kfree(wait);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_post_wait_mem - Post and wait a message with DMA buffers
|
||||
* @c: controller
|
||||
* @msg: message to post
|
||||
* @timeout: time in seconds to wait
|
||||
* @dma: i2o_dma struct of the DMA buffer to free on failure
|
||||
*
|
||||
* This API allows an OSM to post a message and then be told whether or
|
||||
* not the system received a successful reply. If the message times out
|
||||
* then the value '-ETIMEDOUT' is returned. This is a special case. In
|
||||
* this situation the message may (should) complete at an indefinite time
|
||||
* in the future. When it completes it will use the memory buffer
|
||||
* attached to the request. If -ETIMEDOUT is returned then the memory
|
||||
* buffer must not be freed. Instead the event completion will free them
|
||||
* for you. In all other cases the buffer are your problem.
|
||||
*
|
||||
* Returns 0 on success, negative error code on timeout or positive error
|
||||
* code from reply.
|
||||
*/
|
||||
int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
|
||||
unsigned long timeout, struct i2o_dma *dma)
|
||||
{
|
||||
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
|
||||
struct i2o_exec_wait *wait;
|
||||
static u32 tcntxt = 0x80000000;
|
||||
unsigned long flags;
|
||||
int rc = 0;
|
||||
|
||||
wait = i2o_exec_wait_alloc();
|
||||
if (!wait) {
|
||||
i2o_msg_nop(c, msg);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (tcntxt == 0xffffffff)
|
||||
tcntxt = 0x80000000;
|
||||
|
||||
if (dma)
|
||||
wait->dma = *dma;
|
||||
|
||||
/*
|
||||
* Fill in the message initiator context and transaction context.
|
||||
* We will only use transaction contexts >= 0x80000000 for POST WAIT,
|
||||
* so we could find a POST WAIT reply easier in the reply handler.
|
||||
*/
|
||||
msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
|
||||
wait->tcntxt = tcntxt++;
|
||||
msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt);
|
||||
|
||||
wait->wq = &wq;
|
||||
/*
|
||||
* we add elements to the head, because if a entry in the list will
|
||||
* never be removed, we have to iterate over it every time
|
||||
*/
|
||||
list_add(&wait->list, &i2o_exec_wait_list);
|
||||
|
||||
/*
|
||||
* Post the message to the controller. At some point later it will
|
||||
* return. If we time out before it returns then complete will be zero.
|
||||
*/
|
||||
i2o_msg_post(c, msg);
|
||||
|
||||
wait_event_interruptible_timeout(wq, wait->complete, timeout * HZ);
|
||||
|
||||
spin_lock_irqsave(&wait->lock, flags);
|
||||
|
||||
wait->wq = NULL;
|
||||
|
||||
if (wait->complete)
|
||||
rc = le32_to_cpu(wait->msg->body[0]) >> 24;
|
||||
else {
|
||||
/*
|
||||
* We cannot remove it now. This is important. When it does
|
||||
* terminate (which it must do if the controller has not
|
||||
* died...) then it will otherwise scribble on stuff.
|
||||
*
|
||||
* FIXME: try abort message
|
||||
*/
|
||||
if (dma)
|
||||
dma->virt = NULL;
|
||||
|
||||
rc = -ETIMEDOUT;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&wait->lock, flags);
|
||||
|
||||
if (rc != -ETIMEDOUT) {
|
||||
i2o_flush_reply(c, wait->m);
|
||||
i2o_exec_wait_free(wait);
|
||||
}
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_post_wait_complete - Reply to a i2o_msg_post request from IOP
|
||||
* @c: I2O controller which answers
|
||||
* @m: message id
|
||||
* @msg: pointer to the I2O reply message
|
||||
* @context: transaction context of request
|
||||
*
|
||||
* This function is called in interrupt context only. If the reply reached
|
||||
* before the timeout, the i2o_exec_wait struct is filled with the message
|
||||
* and the task will be waked up. The task is now responsible for returning
|
||||
* the message m back to the controller! If the message reaches us after
|
||||
* the timeout clean up the i2o_exec_wait struct (including allocated
|
||||
* DMA buffer).
|
||||
*
|
||||
* Return 0 on success and if the message m should not be given back to the
|
||||
* I2O controller, or >0 on success and if the message should be given back
|
||||
* afterwords. Returns negative error code on failure. In this case the
|
||||
* message must also be given back to the controller.
|
||||
*/
|
||||
static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
|
||||
struct i2o_message *msg, u32 context)
|
||||
{
|
||||
struct i2o_exec_wait *wait, *tmp;
|
||||
unsigned long flags;
|
||||
int rc = 1;
|
||||
|
||||
/*
|
||||
* We need to search through the i2o_exec_wait_list to see if the given
|
||||
* message is still outstanding. If not, it means that the IOP took
|
||||
* longer to respond to the message than we had allowed and timer has
|
||||
* already expired. Not much we can do about that except log it for
|
||||
* debug purposes, increase timeout, and recompile.
|
||||
*/
|
||||
list_for_each_entry_safe(wait, tmp, &i2o_exec_wait_list, list) {
|
||||
if (wait->tcntxt == context) {
|
||||
spin_lock_irqsave(&wait->lock, flags);
|
||||
|
||||
list_del(&wait->list);
|
||||
|
||||
wait->m = m;
|
||||
wait->msg = msg;
|
||||
wait->complete = 1;
|
||||
|
||||
if (wait->wq)
|
||||
rc = 0;
|
||||
else
|
||||
rc = -1;
|
||||
|
||||
spin_unlock_irqrestore(&wait->lock, flags);
|
||||
|
||||
if (rc) {
|
||||
struct device *dev;
|
||||
|
||||
dev = &c->pdev->dev;
|
||||
|
||||
pr_debug("%s: timedout reply received!\n",
|
||||
c->name);
|
||||
i2o_dma_free(dev, &wait->dma);
|
||||
i2o_exec_wait_free(wait);
|
||||
} else
|
||||
wake_up_interruptible(wait->wq);
|
||||
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
osm_warn("%s: Bogus reply in POST WAIT (tr-context: %08x)!\n", c->name,
|
||||
context);
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_show_vendor_id - Displays Vendor ID of controller
|
||||
* @d: device of which the Vendor ID should be displayed
|
||||
* @attr: device_attribute to display
|
||||
* @buf: buffer into which the Vendor ID should be printed
|
||||
*
|
||||
* Returns number of bytes printed into buffer.
|
||||
*/
|
||||
static ssize_t i2o_exec_show_vendor_id(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct i2o_device *dev = to_i2o_device(d);
|
||||
u16 id;
|
||||
|
||||
if (!i2o_parm_field_get(dev, 0x0000, 0, &id, 2)) {
|
||||
sprintf(buf, "0x%04x", le16_to_cpu(id));
|
||||
return strlen(buf) + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_show_product_id - Displays Product ID of controller
|
||||
* @d: device of which the Product ID should be displayed
|
||||
* @attr: device_attribute to display
|
||||
* @buf: buffer into which the Product ID should be printed
|
||||
*
|
||||
* Returns number of bytes printed into buffer.
|
||||
*/
|
||||
static ssize_t i2o_exec_show_product_id(struct device *d,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct i2o_device *dev = to_i2o_device(d);
|
||||
u16 id;
|
||||
|
||||
if (!i2o_parm_field_get(dev, 0x0000, 1, &id, 2)) {
|
||||
sprintf(buf, "0x%04x", le16_to_cpu(id));
|
||||
return strlen(buf) + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/* Exec-OSM device attributes */
|
||||
static DEVICE_ATTR(vendor_id, S_IRUGO, i2o_exec_show_vendor_id, NULL);
|
||||
static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL);
|
||||
|
||||
/**
|
||||
* i2o_exec_probe - Called if a new I2O device (executive class) appears
|
||||
* @dev: I2O device which should be probed
|
||||
*
|
||||
* Registers event notification for every event from Executive device. The
|
||||
* return is always 0, because we want all devices of class Executive.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
*/
|
||||
static int i2o_exec_probe(struct device *dev)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
int rc;
|
||||
|
||||
rc = i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
|
||||
if (rc) goto err_out;
|
||||
|
||||
rc = device_create_file(dev, &dev_attr_vendor_id);
|
||||
if (rc) goto err_evtreg;
|
||||
rc = device_create_file(dev, &dev_attr_product_id);
|
||||
if (rc) goto err_vid;
|
||||
|
||||
i2o_dev->iop->exec = i2o_dev;
|
||||
|
||||
return 0;
|
||||
|
||||
err_vid:
|
||||
device_remove_file(dev, &dev_attr_vendor_id);
|
||||
err_evtreg:
|
||||
i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
|
||||
err_out:
|
||||
return rc;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_remove - Called on I2O device removal
|
||||
* @dev: I2O device which was removed
|
||||
*
|
||||
* Unregisters event notification from Executive I2O device.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
*/
|
||||
static int i2o_exec_remove(struct device *dev)
|
||||
{
|
||||
device_remove_file(dev, &dev_attr_product_id);
|
||||
device_remove_file(dev, &dev_attr_vendor_id);
|
||||
|
||||
i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES
|
||||
/**
|
||||
* i2o_exec_lct_notify - Send a asynchronus LCT NOTIFY request
|
||||
* @c: I2O controller to which the request should be send
|
||||
* @change_ind: change indicator
|
||||
*
|
||||
* This function sends a LCT NOTIFY request to the I2O controller with
|
||||
* the change indicator change_ind. If the change_ind == 0 the controller
|
||||
* replies immediately after the request. If change_ind > 0 the reply is
|
||||
* send after change indicator of the LCT is > change_ind.
|
||||
*/
|
||||
static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
|
||||
{
|
||||
i2o_status_block *sb = c->status_block.virt;
|
||||
struct device *dev;
|
||||
struct i2o_message *msg;
|
||||
|
||||
mutex_lock(&c->lct_lock);
|
||||
|
||||
dev = &c->pdev->dev;
|
||||
|
||||
if (i2o_dma_realloc(dev, &c->dlct,
|
||||
le32_to_cpu(sb->expected_lct_size))) {
|
||||
mutex_unlock(&c->lct_lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
|
||||
if (IS_ERR(msg)) {
|
||||
mutex_unlock(&c->lct_lock);
|
||||
return PTR_ERR(msg);
|
||||
}
|
||||
|
||||
msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
|
||||
msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
|
||||
ADAPTER_TID);
|
||||
msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
|
||||
msg->u.s.tcntxt = cpu_to_le32(0x00000000);
|
||||
msg->body[0] = cpu_to_le32(0xffffffff);
|
||||
msg->body[1] = cpu_to_le32(change_ind);
|
||||
msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
|
||||
msg->body[3] = cpu_to_le32(c->dlct.phys);
|
||||
|
||||
i2o_msg_post(c, msg);
|
||||
|
||||
mutex_unlock(&c->lct_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* i2o_exec_lct_modified - Called on LCT NOTIFY reply
|
||||
* @_work: work struct for a specific controller
|
||||
*
|
||||
* This function handles asynchronus LCT NOTIFY replies. It parses the
|
||||
* new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
|
||||
* again, otherwise send LCT NOTIFY to get informed on next LCT change.
|
||||
*/
|
||||
static void i2o_exec_lct_modified(struct work_struct *_work)
|
||||
{
|
||||
struct i2o_exec_lct_notify_work *work =
|
||||
container_of(_work, struct i2o_exec_lct_notify_work, work);
|
||||
u32 change_ind = 0;
|
||||
struct i2o_controller *c = work->c;
|
||||
|
||||
kfree(work);
|
||||
|
||||
if (i2o_device_parse_lct(c) != -EAGAIN)
|
||||
change_ind = c->lct->change_ind + 1;
|
||||
|
||||
#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES
|
||||
i2o_exec_lct_notify(c, change_ind);
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_reply - I2O Executive reply handler
|
||||
* @c: I2O controller from which the reply comes
|
||||
* @m: message id
|
||||
* @msg: pointer to the I2O reply message
|
||||
*
|
||||
* This function is always called from interrupt context. If a POST WAIT
|
||||
* reply was received, pass it to the complete function. If a LCT NOTIFY
|
||||
* reply was received, a new event is created to handle the update.
|
||||
*
|
||||
* Returns 0 on success and if the reply should not be flushed or > 0
|
||||
* on success and if the reply should be flushed. Returns negative error
|
||||
* code on failure and if the reply should be flushed.
|
||||
*/
|
||||
static int i2o_exec_reply(struct i2o_controller *c, u32 m,
|
||||
struct i2o_message *msg)
|
||||
{
|
||||
u32 context;
|
||||
|
||||
if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) {
|
||||
struct i2o_message __iomem *pmsg;
|
||||
u32 pm;
|
||||
|
||||
/*
|
||||
* If Fail bit is set we must take the transaction context of
|
||||
* the preserved message to find the right request again.
|
||||
*/
|
||||
|
||||
pm = le32_to_cpu(msg->body[3]);
|
||||
pmsg = i2o_msg_in_to_virt(c, pm);
|
||||
context = readl(&pmsg->u.s.tcntxt);
|
||||
|
||||
i2o_report_status(KERN_INFO, "i2o_core", msg);
|
||||
|
||||
/* Release the preserved msg */
|
||||
i2o_msg_nop_mfa(c, pm);
|
||||
} else
|
||||
context = le32_to_cpu(msg->u.s.tcntxt);
|
||||
|
||||
if (context & 0x80000000)
|
||||
return i2o_msg_post_wait_complete(c, m, msg, context);
|
||||
|
||||
if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
|
||||
struct i2o_exec_lct_notify_work *work;
|
||||
|
||||
pr_debug("%s: LCT notify received\n", c->name);
|
||||
|
||||
work = kmalloc(sizeof(*work), GFP_ATOMIC);
|
||||
if (!work)
|
||||
return -ENOMEM;
|
||||
|
||||
work->c = c;
|
||||
|
||||
INIT_WORK(&work->work, i2o_exec_lct_modified);
|
||||
queue_work(i2o_exec_driver.event_queue, &work->work);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this happens, we want to dump the message to the syslog so
|
||||
* it can be sent back to the card manufacturer by the end user
|
||||
* to aid in debugging.
|
||||
*
|
||||
*/
|
||||
printk(KERN_WARNING "%s: Unsolicited message reply sent to core! Message dumped to syslog\n",
|
||||
c->name);
|
||||
i2o_dump_message(msg);
|
||||
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_exec_event - Event handling function
|
||||
* @work: Work item in occurring event
|
||||
*
|
||||
* Handles events send by the Executive device. At the moment does not do
|
||||
* anything useful.
|
||||
*/
|
||||
static void i2o_exec_event(struct work_struct *work)
|
||||
{
|
||||
struct i2o_event *evt = container_of(work, struct i2o_event, work);
|
||||
|
||||
if (likely(evt->i2o_dev))
|
||||
osm_debug("Event received from device: %d\n",
|
||||
evt->i2o_dev->lct_data.tid);
|
||||
kfree(evt);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_lct_get - Get the IOP's Logical Configuration Table
|
||||
* @c: I2O controller from which the LCT should be fetched
|
||||
*
|
||||
* Send a LCT NOTIFY request to the controller, and wait
|
||||
* I2O_TIMEOUT_LCT_GET seconds until arrival of response. If the LCT is
|
||||
* to large, retry it.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
int i2o_exec_lct_get(struct i2o_controller *c)
|
||||
{
|
||||
struct i2o_message *msg;
|
||||
int i = 0;
|
||||
int rc = -EAGAIN;
|
||||
|
||||
for (i = 1; i <= I2O_LCT_GET_TRIES; i++) {
|
||||
msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
|
||||
if (IS_ERR(msg))
|
||||
return PTR_ERR(msg);
|
||||
|
||||
msg->u.head[0] =
|
||||
cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
|
||||
msg->u.head[1] =
|
||||
cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
|
||||
ADAPTER_TID);
|
||||
msg->body[0] = cpu_to_le32(0xffffffff);
|
||||
msg->body[1] = cpu_to_le32(0x00000000);
|
||||
msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
|
||||
msg->body[3] = cpu_to_le32(c->dlct.phys);
|
||||
|
||||
rc = i2o_msg_post_wait(c, msg, I2O_TIMEOUT_LCT_GET);
|
||||
if (rc < 0)
|
||||
break;
|
||||
|
||||
rc = i2o_device_parse_lct(c);
|
||||
if (rc != -EAGAIN)
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Exec OSM driver struct */
|
||||
struct i2o_driver i2o_exec_driver = {
|
||||
.name = OSM_NAME,
|
||||
.reply = i2o_exec_reply,
|
||||
.event = i2o_exec_event,
|
||||
.classes = i2o_exec_class_id,
|
||||
.driver = {
|
||||
.probe = i2o_exec_probe,
|
||||
.remove = i2o_exec_remove,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_init - Registers the Exec OSM
|
||||
*
|
||||
* Registers the Exec OSM in the I2O core.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
int __init i2o_exec_init(void)
|
||||
{
|
||||
return i2o_driver_register(&i2o_exec_driver);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_exec_exit - Removes the Exec OSM
|
||||
*
|
||||
* Unregisters the Exec OSM from the I2O core.
|
||||
*/
|
||||
void i2o_exec_exit(void)
|
||||
{
|
||||
i2o_driver_unregister(&i2o_exec_driver);
|
||||
};
|
||||
|
||||
EXPORT_SYMBOL(i2o_msg_post_wait_mem);
|
||||
EXPORT_SYMBOL(i2o_exec_lct_get);
|
|
@ -1,988 +0,0 @@
|
|||
/*
|
||||
* I2O kernel space accessible structures/APIs
|
||||
*
|
||||
* (c) Copyright 1999, 2000 Red Hat Software
|
||||
*
|
||||
* 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 of the License, or (at your option) any later version.
|
||||
*
|
||||
*************************************************************************
|
||||
*
|
||||
* This header file defined the I2O APIs/structures for use by
|
||||
* the I2O kernel modules.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _I2O_H
|
||||
#define _I2O_H
|
||||
|
||||
#include <linux/i2o-dev.h>
|
||||
|
||||
/* How many different OSM's are we allowing */
|
||||
#define I2O_MAX_DRIVERS 8
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/workqueue.h> /* work_struct */
|
||||
#include <linux/mempool.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include <linux/semaphore.h> /* Needed for MUTEX init macros */
|
||||
|
||||
#include <asm/io.h>
|
||||
|
||||
/* message queue empty */
|
||||
#define I2O_QUEUE_EMPTY 0xffffffff
|
||||
|
||||
/*
|
||||
* Cache strategies
|
||||
*/
|
||||
|
||||
/* The NULL strategy leaves everything up to the controller. This tends to be a
|
||||
* pessimal but functional choice.
|
||||
*/
|
||||
#define CACHE_NULL 0
|
||||
/* Prefetch data when reading. We continually attempt to load the next 32 sectors
|
||||
* into the controller cache.
|
||||
*/
|
||||
#define CACHE_PREFETCH 1
|
||||
/* Prefetch data when reading. We sometimes attempt to load the next 32 sectors
|
||||
* into the controller cache. When an I/O is less <= 8K we assume its probably
|
||||
* not sequential and don't prefetch (default)
|
||||
*/
|
||||
#define CACHE_SMARTFETCH 2
|
||||
/* Data is written to the cache and then out on to the disk. The I/O must be
|
||||
* physically on the medium before the write is acknowledged (default without
|
||||
* NVRAM)
|
||||
*/
|
||||
#define CACHE_WRITETHROUGH 17
|
||||
/* Data is written to the cache and then out on to the disk. The controller
|
||||
* is permitted to write back the cache any way it wants. (default if battery
|
||||
* backed NVRAM is present). It can be useful to set this for swap regardless of
|
||||
* battery state.
|
||||
*/
|
||||
#define CACHE_WRITEBACK 18
|
||||
/* Optimise for under powered controllers, especially on RAID1 and RAID0. We
|
||||
* write large I/O's directly to disk bypassing the cache to avoid the extra
|
||||
* memory copy hits. Small writes are writeback cached
|
||||
*/
|
||||
#define CACHE_SMARTBACK 19
|
||||
/* Optimise for under powered controllers, especially on RAID1 and RAID0. We
|
||||
* write large I/O's directly to disk bypassing the cache to avoid the extra
|
||||
* memory copy hits. Small writes are writethrough cached. Suitable for devices
|
||||
* lacking battery backup
|
||||
*/
|
||||
#define CACHE_SMARTTHROUGH 20
|
||||
|
||||
/*
|
||||
* Ioctl structures
|
||||
*/
|
||||
|
||||
#define BLKI2OGRSTRAT _IOR('2', 1, int)
|
||||
#define BLKI2OGWSTRAT _IOR('2', 2, int)
|
||||
#define BLKI2OSRSTRAT _IOW('2', 3, int)
|
||||
#define BLKI2OSWSTRAT _IOW('2', 4, int)
|
||||
|
||||
/*
|
||||
* I2O Function codes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Executive Class
|
||||
*/
|
||||
#define I2O_CMD_ADAPTER_ASSIGN 0xB3
|
||||
#define I2O_CMD_ADAPTER_READ 0xB2
|
||||
#define I2O_CMD_ADAPTER_RELEASE 0xB5
|
||||
#define I2O_CMD_BIOS_INFO_SET 0xA5
|
||||
#define I2O_CMD_BOOT_DEVICE_SET 0xA7
|
||||
#define I2O_CMD_CONFIG_VALIDATE 0xBB
|
||||
#define I2O_CMD_CONN_SETUP 0xCA
|
||||
#define I2O_CMD_DDM_DESTROY 0xB1
|
||||
#define I2O_CMD_DDM_ENABLE 0xD5
|
||||
#define I2O_CMD_DDM_QUIESCE 0xC7
|
||||
#define I2O_CMD_DDM_RESET 0xD9
|
||||
#define I2O_CMD_DDM_SUSPEND 0xAF
|
||||
#define I2O_CMD_DEVICE_ASSIGN 0xB7
|
||||
#define I2O_CMD_DEVICE_RELEASE 0xB9
|
||||
#define I2O_CMD_HRT_GET 0xA8
|
||||
#define I2O_CMD_ADAPTER_CLEAR 0xBE
|
||||
#define I2O_CMD_ADAPTER_CONNECT 0xC9
|
||||
#define I2O_CMD_ADAPTER_RESET 0xBD
|
||||
#define I2O_CMD_LCT_NOTIFY 0xA2
|
||||
#define I2O_CMD_OUTBOUND_INIT 0xA1
|
||||
#define I2O_CMD_PATH_ENABLE 0xD3
|
||||
#define I2O_CMD_PATH_QUIESCE 0xC5
|
||||
#define I2O_CMD_PATH_RESET 0xD7
|
||||
#define I2O_CMD_STATIC_MF_CREATE 0xDD
|
||||
#define I2O_CMD_STATIC_MF_RELEASE 0xDF
|
||||
#define I2O_CMD_STATUS_GET 0xA0
|
||||
#define I2O_CMD_SW_DOWNLOAD 0xA9
|
||||
#define I2O_CMD_SW_UPLOAD 0xAB
|
||||
#define I2O_CMD_SW_REMOVE 0xAD
|
||||
#define I2O_CMD_SYS_ENABLE 0xD1
|
||||
#define I2O_CMD_SYS_MODIFY 0xC1
|
||||
#define I2O_CMD_SYS_QUIESCE 0xC3
|
||||
#define I2O_CMD_SYS_TAB_SET 0xA3
|
||||
|
||||
/*
|
||||
* Utility Class
|
||||
*/
|
||||
#define I2O_CMD_UTIL_NOP 0x00
|
||||
#define I2O_CMD_UTIL_ABORT 0x01
|
||||
#define I2O_CMD_UTIL_CLAIM 0x09
|
||||
#define I2O_CMD_UTIL_RELEASE 0x0B
|
||||
#define I2O_CMD_UTIL_PARAMS_GET 0x06
|
||||
#define I2O_CMD_UTIL_PARAMS_SET 0x05
|
||||
#define I2O_CMD_UTIL_EVT_REGISTER 0x13
|
||||
#define I2O_CMD_UTIL_EVT_ACK 0x14
|
||||
#define I2O_CMD_UTIL_CONFIG_DIALOG 0x10
|
||||
#define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D
|
||||
#define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F
|
||||
#define I2O_CMD_UTIL_LOCK 0x17
|
||||
#define I2O_CMD_UTIL_LOCK_RELEASE 0x19
|
||||
#define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15
|
||||
|
||||
/*
|
||||
* SCSI Host Bus Adapter Class
|
||||
*/
|
||||
#define I2O_CMD_SCSI_EXEC 0x81
|
||||
#define I2O_CMD_SCSI_ABORT 0x83
|
||||
#define I2O_CMD_SCSI_BUSRESET 0x27
|
||||
|
||||
/*
|
||||
* Bus Adapter Class
|
||||
*/
|
||||
#define I2O_CMD_BUS_ADAPTER_RESET 0x85
|
||||
#define I2O_CMD_BUS_RESET 0x87
|
||||
#define I2O_CMD_BUS_SCAN 0x89
|
||||
#define I2O_CMD_BUS_QUIESCE 0x8b
|
||||
|
||||
/*
|
||||
* Random Block Storage Class
|
||||
*/
|
||||
#define I2O_CMD_BLOCK_READ 0x30
|
||||
#define I2O_CMD_BLOCK_WRITE 0x31
|
||||
#define I2O_CMD_BLOCK_CFLUSH 0x37
|
||||
#define I2O_CMD_BLOCK_MLOCK 0x49
|
||||
#define I2O_CMD_BLOCK_MUNLOCK 0x4B
|
||||
#define I2O_CMD_BLOCK_MMOUNT 0x41
|
||||
#define I2O_CMD_BLOCK_MEJECT 0x43
|
||||
#define I2O_CMD_BLOCK_POWER 0x70
|
||||
|
||||
#define I2O_CMD_PRIVATE 0xFF
|
||||
|
||||
/* Command status values */
|
||||
|
||||
#define I2O_CMD_IN_PROGRESS 0x01
|
||||
#define I2O_CMD_REJECTED 0x02
|
||||
#define I2O_CMD_FAILED 0x03
|
||||
#define I2O_CMD_COMPLETED 0x04
|
||||
|
||||
/* I2O API function return values */
|
||||
|
||||
#define I2O_RTN_NO_ERROR 0
|
||||
#define I2O_RTN_NOT_INIT 1
|
||||
#define I2O_RTN_FREE_Q_EMPTY 2
|
||||
#define I2O_RTN_TCB_ERROR 3
|
||||
#define I2O_RTN_TRANSACTION_ERROR 4
|
||||
#define I2O_RTN_ADAPTER_ALREADY_INIT 5
|
||||
#define I2O_RTN_MALLOC_ERROR 6
|
||||
#define I2O_RTN_ADPTR_NOT_REGISTERED 7
|
||||
#define I2O_RTN_MSG_REPLY_TIMEOUT 8
|
||||
#define I2O_RTN_NO_STATUS 9
|
||||
#define I2O_RTN_NO_FIRM_VER 10
|
||||
#define I2O_RTN_NO_LINK_SPEED 11
|
||||
|
||||
/* Reply message status defines for all messages */
|
||||
|
||||
#define I2O_REPLY_STATUS_SUCCESS 0x00
|
||||
#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
|
||||
#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
|
||||
#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
|
||||
#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
|
||||
#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
|
||||
#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06
|
||||
#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08
|
||||
#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09
|
||||
#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A
|
||||
#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B
|
||||
#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80
|
||||
|
||||
/* Status codes and Error Information for Parameter functions */
|
||||
|
||||
#define I2O_PARAMS_STATUS_SUCCESS 0x00
|
||||
#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01
|
||||
#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02
|
||||
#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03
|
||||
#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04
|
||||
#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05
|
||||
#define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06
|
||||
#define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07
|
||||
#define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08
|
||||
#define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09
|
||||
#define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A
|
||||
#define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B
|
||||
#define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C
|
||||
#define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D
|
||||
#define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E
|
||||
#define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F
|
||||
#define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10
|
||||
|
||||
/* DetailedStatusCode defines for Executive, DDM, Util and Transaction error
|
||||
* messages: Table 3-2 Detailed Status Codes.*/
|
||||
|
||||
#define I2O_DSC_SUCCESS 0x0000
|
||||
#define I2O_DSC_BAD_KEY 0x0002
|
||||
#define I2O_DSC_TCL_ERROR 0x0003
|
||||
#define I2O_DSC_REPLY_BUFFER_FULL 0x0004
|
||||
#define I2O_DSC_NO_SUCH_PAGE 0x0005
|
||||
#define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006
|
||||
#define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007
|
||||
#define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009
|
||||
#define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A
|
||||
#define I2O_DSC_DEVICE_LOCKED 0x000B
|
||||
#define I2O_DSC_DEVICE_RESET 0x000C
|
||||
#define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D
|
||||
#define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E
|
||||
#define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F
|
||||
#define I2O_DSC_INVALID_OFFSET 0x0010
|
||||
#define I2O_DSC_INVALID_PARAMETER 0x0011
|
||||
#define I2O_DSC_INVALID_REQUEST 0x0012
|
||||
#define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013
|
||||
#define I2O_DSC_MESSAGE_TOO_LARGE 0x0014
|
||||
#define I2O_DSC_MESSAGE_TOO_SMALL 0x0015
|
||||
#define I2O_DSC_MISSING_PARAMETER 0x0016
|
||||
#define I2O_DSC_TIMEOUT 0x0017
|
||||
#define I2O_DSC_UNKNOWN_ERROR 0x0018
|
||||
#define I2O_DSC_UNKNOWN_FUNCTION 0x0019
|
||||
#define I2O_DSC_UNSUPPORTED_VERSION 0x001A
|
||||
#define I2O_DSC_DEVICE_BUSY 0x001B
|
||||
#define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C
|
||||
|
||||
/* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed
|
||||
Status Codes.*/
|
||||
|
||||
#define I2O_BSA_DSC_SUCCESS 0x0000
|
||||
#define I2O_BSA_DSC_MEDIA_ERROR 0x0001
|
||||
#define I2O_BSA_DSC_ACCESS_ERROR 0x0002
|
||||
#define I2O_BSA_DSC_DEVICE_FAILURE 0x0003
|
||||
#define I2O_BSA_DSC_DEVICE_NOT_READY 0x0004
|
||||
#define I2O_BSA_DSC_MEDIA_NOT_PRESENT 0x0005
|
||||
#define I2O_BSA_DSC_MEDIA_LOCKED 0x0006
|
||||
#define I2O_BSA_DSC_MEDIA_FAILURE 0x0007
|
||||
#define I2O_BSA_DSC_PROTOCOL_FAILURE 0x0008
|
||||
#define I2O_BSA_DSC_BUS_FAILURE 0x0009
|
||||
#define I2O_BSA_DSC_ACCESS_VIOLATION 0x000A
|
||||
#define I2O_BSA_DSC_WRITE_PROTECTED 0x000B
|
||||
#define I2O_BSA_DSC_DEVICE_RESET 0x000C
|
||||
#define I2O_BSA_DSC_VOLUME_CHANGED 0x000D
|
||||
#define I2O_BSA_DSC_TIMEOUT 0x000E
|
||||
|
||||
/* FailureStatusCodes, Table 3-3 Message Failure Codes */
|
||||
|
||||
#define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81
|
||||
#define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82
|
||||
#define I2O_FSC_TRANSPORT_CONGESTION 0x83
|
||||
#define I2O_FSC_TRANSPORT_FAILURE 0x84
|
||||
#define I2O_FSC_TRANSPORT_STATE_ERROR 0x85
|
||||
#define I2O_FSC_TRANSPORT_TIME_OUT 0x86
|
||||
#define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87
|
||||
#define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88
|
||||
#define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89
|
||||
#define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A
|
||||
#define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B
|
||||
#define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C
|
||||
#define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D
|
||||
#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E
|
||||
#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F
|
||||
#define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF
|
||||
|
||||
/* Device Claim Types */
|
||||
#define I2O_CLAIM_PRIMARY 0x01000000
|
||||
#define I2O_CLAIM_MANAGEMENT 0x02000000
|
||||
#define I2O_CLAIM_AUTHORIZED 0x03000000
|
||||
#define I2O_CLAIM_SECONDARY 0x04000000
|
||||
|
||||
/* Message header defines for VersionOffset */
|
||||
#define I2OVER15 0x0001
|
||||
#define I2OVER20 0x0002
|
||||
|
||||
/* Default is 1.5 */
|
||||
#define I2OVERSION I2OVER15
|
||||
|
||||
#define SGL_OFFSET_0 I2OVERSION
|
||||
#define SGL_OFFSET_4 (0x0040 | I2OVERSION)
|
||||
#define SGL_OFFSET_5 (0x0050 | I2OVERSION)
|
||||
#define SGL_OFFSET_6 (0x0060 | I2OVERSION)
|
||||
#define SGL_OFFSET_7 (0x0070 | I2OVERSION)
|
||||
#define SGL_OFFSET_8 (0x0080 | I2OVERSION)
|
||||
#define SGL_OFFSET_9 (0x0090 | I2OVERSION)
|
||||
#define SGL_OFFSET_10 (0x00A0 | I2OVERSION)
|
||||
#define SGL_OFFSET_11 (0x00B0 | I2OVERSION)
|
||||
#define SGL_OFFSET_12 (0x00C0 | I2OVERSION)
|
||||
#define SGL_OFFSET(x) (((x)<<4) | I2OVERSION)
|
||||
|
||||
/* Transaction Reply Lists (TRL) Control Word structure */
|
||||
#define TRL_SINGLE_FIXED_LENGTH 0x00
|
||||
#define TRL_SINGLE_VARIABLE_LENGTH 0x40
|
||||
#define TRL_MULTIPLE_FIXED_LENGTH 0x80
|
||||
|
||||
/* msg header defines for MsgFlags */
|
||||
#define MSG_STATIC 0x0100
|
||||
#define MSG_64BIT_CNTXT 0x0200
|
||||
#define MSG_MULTI_TRANS 0x1000
|
||||
#define MSG_FAIL 0x2000
|
||||
#define MSG_FINAL 0x4000
|
||||
#define MSG_REPLY 0x8000
|
||||
|
||||
/* minimum size msg */
|
||||
#define THREE_WORD_MSG_SIZE 0x00030000
|
||||
#define FOUR_WORD_MSG_SIZE 0x00040000
|
||||
#define FIVE_WORD_MSG_SIZE 0x00050000
|
||||
#define SIX_WORD_MSG_SIZE 0x00060000
|
||||
#define SEVEN_WORD_MSG_SIZE 0x00070000
|
||||
#define EIGHT_WORD_MSG_SIZE 0x00080000
|
||||
#define NINE_WORD_MSG_SIZE 0x00090000
|
||||
#define TEN_WORD_MSG_SIZE 0x000A0000
|
||||
#define ELEVEN_WORD_MSG_SIZE 0x000B0000
|
||||
#define I2O_MESSAGE_SIZE(x) ((x)<<16)
|
||||
|
||||
/* special TID assignments */
|
||||
#define ADAPTER_TID 0
|
||||
#define HOST_TID 1
|
||||
|
||||
/* outbound queue defines */
|
||||
#define I2O_MAX_OUTBOUND_MSG_FRAMES 128
|
||||
#define I2O_OUTBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */
|
||||
|
||||
/* inbound queue definitions */
|
||||
#define I2O_MSG_INPOOL_MIN 32
|
||||
#define I2O_INBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */
|
||||
|
||||
#define I2O_POST_WAIT_OK 0
|
||||
#define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT
|
||||
|
||||
#define I2O_CONTEXT_LIST_MIN_LENGTH 15
|
||||
#define I2O_CONTEXT_LIST_USED 0x01
|
||||
#define I2O_CONTEXT_LIST_DELETED 0x02
|
||||
|
||||
/* timeouts */
|
||||
#define I2O_TIMEOUT_INIT_OUTBOUND_QUEUE 15
|
||||
#define I2O_TIMEOUT_MESSAGE_GET 5
|
||||
#define I2O_TIMEOUT_RESET 30
|
||||
#define I2O_TIMEOUT_STATUS_GET 5
|
||||
#define I2O_TIMEOUT_LCT_GET 360
|
||||
#define I2O_TIMEOUT_SCSI_SCB_ABORT 240
|
||||
|
||||
/* retries */
|
||||
#define I2O_HRT_GET_TRIES 3
|
||||
#define I2O_LCT_GET_TRIES 3
|
||||
|
||||
/* defines for max_sectors and max_phys_segments */
|
||||
#define I2O_MAX_SECTORS 1024
|
||||
#define I2O_MAX_SECTORS_LIMITED 128
|
||||
#define I2O_MAX_PHYS_SEGMENTS BLK_MAX_SEGMENTS
|
||||
|
||||
/*
|
||||
* Message structures
|
||||
*/
|
||||
struct i2o_message {
|
||||
union {
|
||||
struct {
|
||||
u8 version_offset;
|
||||
u8 flags;
|
||||
u16 size;
|
||||
u32 target_tid:12;
|
||||
u32 init_tid:12;
|
||||
u32 function:8;
|
||||
u32 icntxt; /* initiator context */
|
||||
u32 tcntxt; /* transaction context */
|
||||
} s;
|
||||
u32 head[4];
|
||||
} u;
|
||||
/* List follows */
|
||||
u32 body[0];
|
||||
};
|
||||
|
||||
/* MFA and I2O message used by mempool */
|
||||
struct i2o_msg_mfa {
|
||||
u32 mfa; /* MFA returned by the controller */
|
||||
struct i2o_message msg; /* I2O message */
|
||||
};
|
||||
|
||||
/*
|
||||
* Each I2O device entity has one of these. There is one per device.
|
||||
*/
|
||||
struct i2o_device {
|
||||
i2o_lct_entry lct_data; /* Device LCT information */
|
||||
|
||||
struct i2o_controller *iop; /* Controlling IOP */
|
||||
struct list_head list; /* node in IOP devices list */
|
||||
|
||||
struct device device;
|
||||
|
||||
struct mutex lock; /* device lock */
|
||||
};
|
||||
|
||||
/*
|
||||
* Event structure provided to the event handling function
|
||||
*/
|
||||
struct i2o_event {
|
||||
struct work_struct work;
|
||||
struct i2o_device *i2o_dev; /* I2O device pointer from which the
|
||||
event reply was initiated */
|
||||
u16 size; /* Size of data in 32-bit words */
|
||||
u32 tcntxt; /* Transaction context used at
|
||||
registration */
|
||||
u32 event_indicator; /* Event indicator from reply */
|
||||
u32 data[0]; /* Event data from reply */
|
||||
};
|
||||
|
||||
/*
|
||||
* I2O classes which could be handled by the OSM
|
||||
*/
|
||||
struct i2o_class_id {
|
||||
u16 class_id:12;
|
||||
};
|
||||
|
||||
/*
|
||||
* I2O driver structure for OSMs
|
||||
*/
|
||||
struct i2o_driver {
|
||||
char *name; /* OSM name */
|
||||
int context; /* Low 8 bits of the transaction info */
|
||||
struct i2o_class_id *classes; /* I2O classes that this OSM handles */
|
||||
|
||||
/* Message reply handler */
|
||||
int (*reply) (struct i2o_controller *, u32, struct i2o_message *);
|
||||
|
||||
/* Event handler */
|
||||
work_func_t event;
|
||||
|
||||
struct workqueue_struct *event_queue; /* Event queue */
|
||||
|
||||
struct device_driver driver;
|
||||
|
||||
/* notification of changes */
|
||||
void (*notify_controller_add) (struct i2o_controller *);
|
||||
void (*notify_controller_remove) (struct i2o_controller *);
|
||||
void (*notify_device_add) (struct i2o_device *);
|
||||
void (*notify_device_remove) (struct i2o_device *);
|
||||
|
||||
struct semaphore lock;
|
||||
};
|
||||
|
||||
/*
|
||||
* Contains DMA mapped address information
|
||||
*/
|
||||
struct i2o_dma {
|
||||
void *virt;
|
||||
dma_addr_t phys;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
/*
|
||||
* Contains slab cache and mempool information
|
||||
*/
|
||||
struct i2o_pool {
|
||||
char *name;
|
||||
struct kmem_cache *slab;
|
||||
mempool_t *mempool;
|
||||
};
|
||||
|
||||
/*
|
||||
* Contains IO mapped address information
|
||||
*/
|
||||
struct i2o_io {
|
||||
void __iomem *virt;
|
||||
unsigned long phys;
|
||||
unsigned long len;
|
||||
};
|
||||
|
||||
/*
|
||||
* Context queue entry, used for 32-bit context on 64-bit systems
|
||||
*/
|
||||
struct i2o_context_list_element {
|
||||
struct list_head list;
|
||||
u32 context;
|
||||
void *ptr;
|
||||
unsigned long timestamp;
|
||||
};
|
||||
|
||||
/*
|
||||
* Each I2O controller has one of these objects
|
||||
*/
|
||||
struct i2o_controller {
|
||||
char name[16];
|
||||
int unit;
|
||||
int type;
|
||||
|
||||
struct pci_dev *pdev; /* PCI device */
|
||||
|
||||
unsigned int promise:1; /* Promise controller */
|
||||
unsigned int adaptec:1; /* DPT / Adaptec controller */
|
||||
unsigned int raptor:1; /* split bar */
|
||||
unsigned int no_quiesce:1; /* dont quiesce before reset */
|
||||
unsigned int short_req:1; /* use small block sizes */
|
||||
unsigned int limit_sectors:1; /* limit number of sectors / request */
|
||||
unsigned int pae_support:1; /* controller has 64-bit SGL support */
|
||||
|
||||
struct list_head devices; /* list of I2O devices */
|
||||
struct list_head list; /* Controller list */
|
||||
|
||||
void __iomem *in_port; /* Inbout port address */
|
||||
void __iomem *out_port; /* Outbound port address */
|
||||
void __iomem *irq_status; /* Interrupt status register address */
|
||||
void __iomem *irq_mask; /* Interrupt mask register address */
|
||||
|
||||
struct i2o_dma status; /* IOP status block */
|
||||
|
||||
struct i2o_dma hrt; /* HW Resource Table */
|
||||
i2o_lct *lct; /* Logical Config Table */
|
||||
struct i2o_dma dlct; /* Temp LCT */
|
||||
struct mutex lct_lock; /* Lock for LCT updates */
|
||||
struct i2o_dma status_block; /* IOP status block */
|
||||
|
||||
struct i2o_io base; /* controller messaging unit */
|
||||
struct i2o_io in_queue; /* inbound message queue Host->IOP */
|
||||
struct i2o_dma out_queue; /* outbound message queue IOP->Host */
|
||||
|
||||
struct i2o_pool in_msg; /* mempool for inbound messages */
|
||||
|
||||
unsigned int battery:1; /* Has a battery backup */
|
||||
unsigned int io_alloc:1; /* An I/O resource was allocated */
|
||||
unsigned int mem_alloc:1; /* A memory resource was allocated */
|
||||
|
||||
struct resource io_resource; /* I/O resource allocated to the IOP */
|
||||
struct resource mem_resource; /* Mem resource allocated to the IOP */
|
||||
|
||||
struct device device;
|
||||
struct i2o_device *exec; /* Executive */
|
||||
#if BITS_PER_LONG == 64
|
||||
spinlock_t context_list_lock; /* lock for context_list */
|
||||
atomic_t context_list_counter; /* needed for unique contexts */
|
||||
struct list_head context_list; /* list of context id's
|
||||
and pointers */
|
||||
#endif
|
||||
spinlock_t lock; /* lock for controller
|
||||
configuration */
|
||||
void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */
|
||||
};
|
||||
|
||||
/*
|
||||
* I2O System table entry
|
||||
*
|
||||
* The system table contains information about all the IOPs in the
|
||||
* system. It is sent to all IOPs so that they can create peer2peer
|
||||
* connections between them.
|
||||
*/
|
||||
struct i2o_sys_tbl_entry {
|
||||
u16 org_id;
|
||||
u16 reserved1;
|
||||
u32 iop_id:12;
|
||||
u32 reserved2:20;
|
||||
u16 seg_num:12;
|
||||
u16 i2o_version:4;
|
||||
u8 iop_state;
|
||||
u8 msg_type;
|
||||
u16 frame_size;
|
||||
u16 reserved3;
|
||||
u32 last_changed;
|
||||
u32 iop_capabilities;
|
||||
u32 inbound_low;
|
||||
u32 inbound_high;
|
||||
};
|
||||
|
||||
struct i2o_sys_tbl {
|
||||
u8 num_entries;
|
||||
u8 version;
|
||||
u16 reserved1;
|
||||
u32 change_ind;
|
||||
u32 reserved2;
|
||||
u32 reserved3;
|
||||
struct i2o_sys_tbl_entry iops[0];
|
||||
};
|
||||
|
||||
extern struct list_head i2o_controllers;
|
||||
|
||||
/* Message functions */
|
||||
extern struct i2o_message *i2o_msg_get_wait(struct i2o_controller *, int);
|
||||
extern int i2o_msg_post_wait_mem(struct i2o_controller *, struct i2o_message *,
|
||||
unsigned long, struct i2o_dma *);
|
||||
|
||||
/* IOP functions */
|
||||
extern int i2o_status_get(struct i2o_controller *);
|
||||
|
||||
extern int i2o_event_register(struct i2o_device *, struct i2o_driver *, int,
|
||||
u32);
|
||||
extern struct i2o_device *i2o_iop_find_device(struct i2o_controller *, u16);
|
||||
extern struct i2o_controller *i2o_find_iop(int);
|
||||
|
||||
/* Functions needed for handling 64-bit pointers in 32-bit context */
|
||||
#if BITS_PER_LONG == 64
|
||||
extern u32 i2o_cntxt_list_add(struct i2o_controller *, void *);
|
||||
extern void *i2o_cntxt_list_get(struct i2o_controller *, u32);
|
||||
extern u32 i2o_cntxt_list_remove(struct i2o_controller *, void *);
|
||||
extern u32 i2o_cntxt_list_get_ptr(struct i2o_controller *, void *);
|
||||
|
||||
static inline u32 i2o_ptr_low(void *ptr)
|
||||
{
|
||||
return (u32) (u64) ptr;
|
||||
};
|
||||
|
||||
static inline u32 i2o_ptr_high(void *ptr)
|
||||
{
|
||||
return (u32) ((u64) ptr >> 32);
|
||||
};
|
||||
|
||||
static inline u32 i2o_dma_low(dma_addr_t dma_addr)
|
||||
{
|
||||
return (u32) (u64) dma_addr;
|
||||
};
|
||||
|
||||
static inline u32 i2o_dma_high(dma_addr_t dma_addr)
|
||||
{
|
||||
return (u32) ((u64) dma_addr >> 32);
|
||||
};
|
||||
#else
|
||||
static inline u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr)
|
||||
{
|
||||
return (u32) ptr;
|
||||
};
|
||||
|
||||
static inline void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context)
|
||||
{
|
||||
return (void *)context;
|
||||
};
|
||||
|
||||
static inline u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr)
|
||||
{
|
||||
return (u32) ptr;
|
||||
};
|
||||
|
||||
static inline u32 i2o_cntxt_list_get_ptr(struct i2o_controller *c, void *ptr)
|
||||
{
|
||||
return (u32) ptr;
|
||||
};
|
||||
|
||||
static inline u32 i2o_ptr_low(void *ptr)
|
||||
{
|
||||
return (u32) ptr;
|
||||
};
|
||||
|
||||
static inline u32 i2o_ptr_high(void *ptr)
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
|
||||
static inline u32 i2o_dma_low(dma_addr_t dma_addr)
|
||||
{
|
||||
return (u32) dma_addr;
|
||||
};
|
||||
|
||||
static inline u32 i2o_dma_high(dma_addr_t dma_addr)
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size);
|
||||
extern dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
|
||||
size_t size,
|
||||
enum dma_data_direction direction,
|
||||
u32 ** sg_ptr);
|
||||
extern int i2o_dma_map_sg(struct i2o_controller *c,
|
||||
struct scatterlist *sg, int sg_count,
|
||||
enum dma_data_direction direction,
|
||||
u32 ** sg_ptr);
|
||||
extern int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len);
|
||||
extern void i2o_dma_free(struct device *dev, struct i2o_dma *addr);
|
||||
extern int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr,
|
||||
size_t len);
|
||||
extern int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
|
||||
size_t size, int min_nr);
|
||||
extern void i2o_pool_free(struct i2o_pool *pool);
|
||||
/* I2O driver (OSM) functions */
|
||||
extern int i2o_driver_register(struct i2o_driver *);
|
||||
extern void i2o_driver_unregister(struct i2o_driver *);
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_controller_add - Send notification of added controller
|
||||
* @drv: I2O driver
|
||||
* @c: I2O controller
|
||||
*
|
||||
* Send notification of added controller to a single registered driver.
|
||||
*/
|
||||
static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv,
|
||||
struct i2o_controller *c)
|
||||
{
|
||||
if (drv->notify_controller_add)
|
||||
drv->notify_controller_add(c);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_controller_remove - Send notification of removed controller
|
||||
* @drv: I2O driver
|
||||
* @c: I2O controller
|
||||
*
|
||||
* Send notification of removed controller to a single registered driver.
|
||||
*/
|
||||
static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv,
|
||||
struct i2o_controller *c)
|
||||
{
|
||||
if (drv->notify_controller_remove)
|
||||
drv->notify_controller_remove(c);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_device_add - Send notification of added device
|
||||
* @drv: I2O driver
|
||||
* @i2o_dev: the added i2o_device
|
||||
*
|
||||
* Send notification of added device to a single registered driver.
|
||||
*/
|
||||
static inline void i2o_driver_notify_device_add(struct i2o_driver *drv,
|
||||
struct i2o_device *i2o_dev)
|
||||
{
|
||||
if (drv->notify_device_add)
|
||||
drv->notify_device_add(i2o_dev);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_driver_notify_device_remove - Send notification of removed device
|
||||
* @drv: I2O driver
|
||||
* @i2o_dev: the added i2o_device
|
||||
*
|
||||
* Send notification of removed device to a single registered driver.
|
||||
*/
|
||||
static inline void i2o_driver_notify_device_remove(struct i2o_driver *drv,
|
||||
struct i2o_device *i2o_dev)
|
||||
{
|
||||
if (drv->notify_device_remove)
|
||||
drv->notify_device_remove(i2o_dev);
|
||||
};
|
||||
|
||||
extern void i2o_driver_notify_controller_add_all(struct i2o_controller *);
|
||||
extern void i2o_driver_notify_controller_remove_all(struct i2o_controller *);
|
||||
extern void i2o_driver_notify_device_add_all(struct i2o_device *);
|
||||
extern void i2o_driver_notify_device_remove_all(struct i2o_device *);
|
||||
|
||||
/* I2O device functions */
|
||||
extern int i2o_device_claim(struct i2o_device *);
|
||||
extern int i2o_device_claim_release(struct i2o_device *);
|
||||
|
||||
/* Exec OSM functions */
|
||||
extern int i2o_exec_lct_get(struct i2o_controller *);
|
||||
|
||||
/* device / driver / kobject conversion functions */
|
||||
#define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver)
|
||||
#define to_i2o_device(dev) container_of(dev, struct i2o_device, device)
|
||||
#define to_i2o_controller(dev) container_of(dev, struct i2o_controller, device)
|
||||
|
||||
/**
|
||||
* i2o_out_to_virt - Turn an I2O message to a virtual address
|
||||
* @c: controller
|
||||
* @m: message engine value
|
||||
*
|
||||
* Turn a receive message from an I2O controller bus address into
|
||||
* a Linux virtual address. The shared page frame is a linear block
|
||||
* so we simply have to shift the offset. This function does not
|
||||
* work for sender side messages as they are ioremap objects
|
||||
* provided by the I2O controller.
|
||||
*/
|
||||
static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c,
|
||||
u32 m)
|
||||
{
|
||||
BUG_ON(m < c->out_queue.phys
|
||||
|| m >= c->out_queue.phys + c->out_queue.len);
|
||||
|
||||
return c->out_queue.virt + (m - c->out_queue.phys);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_in_to_virt - Turn an I2O message to a virtual address
|
||||
* @c: controller
|
||||
* @m: message engine value
|
||||
*
|
||||
* Turn a send message from an I2O controller bus address into
|
||||
* a Linux virtual address. The shared page frame is a linear block
|
||||
* so we simply have to shift the offset. This function does not
|
||||
* work for receive side messages as they are kmalloc objects
|
||||
* in a different pool.
|
||||
*/
|
||||
static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct
|
||||
i2o_controller *c,
|
||||
u32 m)
|
||||
{
|
||||
return c->in_queue.virt + m;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_get - obtain an I2O message from the IOP
|
||||
* @c: I2O controller
|
||||
*
|
||||
* This function tries to get a message frame. If no message frame is
|
||||
* available do not wait until one is available (see also i2o_msg_get_wait).
|
||||
* The returned pointer to the message frame is not in I/O memory, it is
|
||||
* allocated from a mempool. But because a MFA is allocated from the
|
||||
* controller too it is guaranteed that i2o_msg_post() will never fail.
|
||||
*
|
||||
* On a success a pointer to the message frame is returned. If the message
|
||||
* queue is empty -EBUSY is returned and if no memory is available -ENOMEM
|
||||
* is returned.
|
||||
*/
|
||||
static inline struct i2o_message *i2o_msg_get(struct i2o_controller *c)
|
||||
{
|
||||
struct i2o_msg_mfa *mmsg = mempool_alloc(c->in_msg.mempool, GFP_ATOMIC);
|
||||
if (!mmsg)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
mmsg->mfa = readl(c->in_port);
|
||||
if (unlikely(mmsg->mfa >= c->in_queue.len)) {
|
||||
u32 mfa = mmsg->mfa;
|
||||
|
||||
mempool_free(mmsg, c->in_msg.mempool);
|
||||
|
||||
if (mfa == I2O_QUEUE_EMPTY)
|
||||
return ERR_PTR(-EBUSY);
|
||||
return ERR_PTR(-EFAULT);
|
||||
}
|
||||
|
||||
return &mmsg->msg;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_post - Post I2O message to I2O controller
|
||||
* @c: I2O controller to which the message should be send
|
||||
* @msg: message returned by i2o_msg_get()
|
||||
*
|
||||
* Post the message to the I2O controller and return immediately.
|
||||
*/
|
||||
static inline void i2o_msg_post(struct i2o_controller *c,
|
||||
struct i2o_message *msg)
|
||||
{
|
||||
struct i2o_msg_mfa *mmsg;
|
||||
|
||||
mmsg = container_of(msg, struct i2o_msg_mfa, msg);
|
||||
memcpy_toio(i2o_msg_in_to_virt(c, mmsg->mfa), msg,
|
||||
(le32_to_cpu(msg->u.head[0]) >> 16) << 2);
|
||||
writel(mmsg->mfa, c->in_port);
|
||||
mempool_free(mmsg, c->in_msg.mempool);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_post_wait - Post and wait a message and wait until return
|
||||
* @c: controller
|
||||
* @msg: message to post
|
||||
* @timeout: time in seconds to wait
|
||||
*
|
||||
* This API allows an OSM to post a message and then be told whether or
|
||||
* not the system received a successful reply. If the message times out
|
||||
* then the value '-ETIMEDOUT' is returned.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static inline int i2o_msg_post_wait(struct i2o_controller *c,
|
||||
struct i2o_message *msg,
|
||||
unsigned long timeout)
|
||||
{
|
||||
return i2o_msg_post_wait_mem(c, msg, timeout, NULL);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_nop_mfa - Returns a fetched MFA back to the controller
|
||||
* @c: I2O controller from which the MFA was fetched
|
||||
* @mfa: MFA which should be returned
|
||||
*
|
||||
* This function must be used for preserved messages, because i2o_msg_nop()
|
||||
* also returns the allocated memory back to the msg_pool mempool.
|
||||
*/
|
||||
static inline void i2o_msg_nop_mfa(struct i2o_controller *c, u32 mfa)
|
||||
{
|
||||
struct i2o_message __iomem *msg;
|
||||
u32 nop[3] = {
|
||||
THREE_WORD_MSG_SIZE | SGL_OFFSET_0,
|
||||
I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID,
|
||||
0x00000000
|
||||
};
|
||||
|
||||
msg = i2o_msg_in_to_virt(c, mfa);
|
||||
memcpy_toio(msg, nop, sizeof(nop));
|
||||
writel(mfa, c->in_port);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_msg_nop - Returns a message which is not used
|
||||
* @c: I2O controller from which the message was created
|
||||
* @msg: message which should be returned
|
||||
*
|
||||
* If you fetch a message via i2o_msg_get, and can't use it, you must
|
||||
* return the message with this function. Otherwise the MFA is lost as well
|
||||
* as the allocated memory from the mempool.
|
||||
*/
|
||||
static inline void i2o_msg_nop(struct i2o_controller *c,
|
||||
struct i2o_message *msg)
|
||||
{
|
||||
struct i2o_msg_mfa *mmsg;
|
||||
mmsg = container_of(msg, struct i2o_msg_mfa, msg);
|
||||
|
||||
i2o_msg_nop_mfa(c, mmsg->mfa);
|
||||
mempool_free(mmsg, c->in_msg.mempool);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_flush_reply - Flush reply from I2O controller
|
||||
* @c: I2O controller
|
||||
* @m: the message identifier
|
||||
*
|
||||
* The I2O controller must be informed that the reply message is not needed
|
||||
* anymore. If you forget to flush the reply, the message frame can't be
|
||||
* used by the controller anymore and is therefore lost.
|
||||
*/
|
||||
static inline void i2o_flush_reply(struct i2o_controller *c, u32 m)
|
||||
{
|
||||
writel(m, c->out_port);
|
||||
};
|
||||
|
||||
/*
|
||||
* Endian handling wrapped into the macro - keeps the core code
|
||||
* cleaner.
|
||||
*/
|
||||
|
||||
#define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem)
|
||||
|
||||
extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int);
|
||||
extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int,
|
||||
void *, int);
|
||||
|
||||
/* debugging and troubleshooting/diagnostic helpers. */
|
||||
#define osm_printk(level, format, arg...) \
|
||||
printk(level "%s: " format, OSM_NAME , ## arg)
|
||||
|
||||
#ifdef DEBUG
|
||||
#define osm_debug(format, arg...) \
|
||||
osm_printk(KERN_DEBUG, format , ## arg)
|
||||
#else
|
||||
#define osm_debug(format, arg...) \
|
||||
do { } while (0)
|
||||
#endif
|
||||
|
||||
#define osm_err(format, arg...) \
|
||||
osm_printk(KERN_ERR, format , ## arg)
|
||||
#define osm_info(format, arg...) \
|
||||
osm_printk(KERN_INFO, format , ## arg)
|
||||
#define osm_warn(format, arg...) \
|
||||
osm_printk(KERN_WARNING, format , ## arg)
|
||||
|
||||
/* debugging functions */
|
||||
extern void i2o_report_status(const char *, const char *, struct i2o_message *);
|
||||
extern void i2o_dump_message(struct i2o_message *);
|
||||
extern void i2o_dump_hrt(struct i2o_controller *c);
|
||||
extern void i2o_debug_state(struct i2o_controller *c);
|
||||
|
||||
#endif /* _I2O_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* Block OSM structures/API
|
||||
*
|
||||
* Copyright (C) 1999-2002 Red Hat Software
|
||||
*
|
||||
* Written by Alan Cox, Building Number Three Ltd
|
||||
*
|
||||
* 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 of the License, 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.
|
||||
*
|
||||
* For the purpose of avoiding doubt the preferred form of the work
|
||||
* for making modifications shall be a standards compliant form such
|
||||
* gzipped tar and not one requiring a proprietary or patent encumbered
|
||||
* tool to unpack.
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Steve Ralston:
|
||||
* Multiple device handling error fixes,
|
||||
* Added a queue depth.
|
||||
* Alan Cox:
|
||||
* FC920 has an rmw bug. Dont or in the end marker.
|
||||
* Removed queue walk, fixed for 64bitness.
|
||||
* Rewrote much of the code over time
|
||||
* Added indirect block lists
|
||||
* Handle 64K limits on many controllers
|
||||
* Don't use indirects on the Promise (breaks)
|
||||
* Heavily chop down the queue depths
|
||||
* Deepak Saxena:
|
||||
* Independent queues per IOP
|
||||
* Support for dynamic device creation/deletion
|
||||
* Code cleanup
|
||||
* Support for larger I/Os through merge* functions
|
||||
* (taken from DAC960 driver)
|
||||
* Boji T Kannanthanam:
|
||||
* Set the I2O Block devices to be detected in increasing
|
||||
* order of TIDs during boot.
|
||||
* Search and set the I2O block device that we boot off
|
||||
* from as the first device to be claimed (as /dev/i2o/hda)
|
||||
* Properly attach/detach I2O gendisk structure from the
|
||||
* system gendisk list. The I2O block devices now appear in
|
||||
* /proc/partitions.
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>:
|
||||
* Minor bugfixes for 2.6.
|
||||
*/
|
||||
|
||||
#ifndef I2O_BLOCK_OSM_H
|
||||
#define I2O_BLOCK_OSM_H
|
||||
|
||||
#define I2O_BLOCK_RETRY_TIME HZ/4
|
||||
#define I2O_BLOCK_MAX_OPEN_REQUESTS 50
|
||||
|
||||
/* request queue sizes */
|
||||
#define I2O_BLOCK_REQ_MEMPOOL_SIZE 32
|
||||
|
||||
#define KERNEL_SECTOR_SHIFT 9
|
||||
#define KERNEL_SECTOR_SIZE (1 << KERNEL_SECTOR_SHIFT)
|
||||
|
||||
/* I2O Block OSM mempool struct */
|
||||
struct i2o_block_mempool {
|
||||
struct kmem_cache *slab;
|
||||
mempool_t *pool;
|
||||
};
|
||||
|
||||
/* I2O Block device descriptor */
|
||||
struct i2o_block_device {
|
||||
struct i2o_device *i2o_dev; /* pointer to I2O device */
|
||||
struct gendisk *gd;
|
||||
spinlock_t lock; /* queue lock */
|
||||
struct list_head open_queue; /* list of transferred, but unfinished
|
||||
requests */
|
||||
unsigned int open_queue_depth; /* number of requests in the queue */
|
||||
|
||||
int rcache; /* read cache flags */
|
||||
int wcache; /* write cache flags */
|
||||
int flags;
|
||||
u16 power; /* power state */
|
||||
int media_change_flag; /* media changed flag */
|
||||
};
|
||||
|
||||
/* I2O Block device request */
|
||||
struct i2o_block_request {
|
||||
struct list_head queue;
|
||||
struct request *req; /* corresponding request */
|
||||
struct i2o_block_device *i2o_blk_dev; /* I2O block device */
|
||||
struct device *dev; /* device used for DMA */
|
||||
int sg_nents; /* number of SG elements */
|
||||
struct scatterlist sg_table[I2O_MAX_PHYS_SEGMENTS]; /* SG table */
|
||||
};
|
||||
|
||||
/* I2O Block device delayed request */
|
||||
struct i2o_block_delayed_request {
|
||||
struct delayed_work work;
|
||||
struct request_queue *queue;
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,814 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* For the avoidance of doubt the "preferred form" of this code is one which
|
||||
* is in an open non patent encumbered format. Where cryptographic key signing
|
||||
* forms part of the process of creating an executable the information
|
||||
* including keys needed to generate an equivalently functional executable
|
||||
* are deemed to be part of the source code.
|
||||
*
|
||||
* Complications for I2O scsi
|
||||
*
|
||||
* o Each (bus,lun) is a logical device in I2O. We keep a map
|
||||
* table. We spoof failed selection for unmapped units
|
||||
* o Request sense buffers can come back for free.
|
||||
* o Scatter gather is a bit dynamic. We have to investigate at
|
||||
* setup time.
|
||||
* o Some of our resources are dynamically shared. The i2o core
|
||||
* needs a message reservation protocol to avoid swap v net
|
||||
* deadlocking. We need to back off queue requests.
|
||||
*
|
||||
* In general the firmware wants to help. Where its help isn't performance
|
||||
* useful we just ignore the aid. Its not worth the code in truth.
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Steve Ralston:
|
||||
* Scatter gather now works
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>:
|
||||
* Minor fixes for 2.6.
|
||||
*
|
||||
* To Do:
|
||||
* 64bit cleanups
|
||||
* Fix the resource management problems.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/prefetch.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include "i2o.h"
|
||||
#include <linux/scatterlist.h>
|
||||
|
||||
#include <asm/dma.h>
|
||||
#include <asm/io.h>
|
||||
#include <linux/atomic.h>
|
||||
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/scsi_host.h>
|
||||
#include <scsi/scsi_device.h>
|
||||
#include <scsi/scsi_cmnd.h>
|
||||
#include <scsi/sg.h>
|
||||
|
||||
#define OSM_NAME "scsi-osm"
|
||||
#define OSM_VERSION "1.316"
|
||||
#define OSM_DESCRIPTION "I2O SCSI Peripheral OSM"
|
||||
|
||||
static struct i2o_driver i2o_scsi_driver;
|
||||
|
||||
static unsigned int i2o_scsi_max_id = 16;
|
||||
static unsigned int i2o_scsi_max_lun = 255;
|
||||
|
||||
struct i2o_scsi_host {
|
||||
struct Scsi_Host *scsi_host; /* pointer to the SCSI host */
|
||||
struct i2o_controller *iop; /* pointer to the I2O controller */
|
||||
u64 lun; /* lun's used for block devices */
|
||||
struct i2o_device *channel[0]; /* channel->i2o_dev mapping table */
|
||||
};
|
||||
|
||||
static struct scsi_host_template i2o_scsi_host_template;
|
||||
|
||||
#define I2O_SCSI_CAN_QUEUE 4
|
||||
|
||||
/* SCSI OSM class handling definition */
|
||||
static struct i2o_class_id i2o_scsi_class_id[] = {
|
||||
{I2O_CLASS_SCSI_PERIPHERAL},
|
||||
{I2O_CLASS_END}
|
||||
};
|
||||
|
||||
static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c)
|
||||
{
|
||||
struct i2o_scsi_host *i2o_shost;
|
||||
struct i2o_device *i2o_dev;
|
||||
struct Scsi_Host *scsi_host;
|
||||
int max_channel = 0;
|
||||
u8 type;
|
||||
int i;
|
||||
size_t size;
|
||||
u16 body_size = 6;
|
||||
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC
|
||||
if (c->adaptec)
|
||||
body_size = 8;
|
||||
#endif
|
||||
|
||||
list_for_each_entry(i2o_dev, &c->devices, list)
|
||||
if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
|
||||
if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1)
|
||||
&& (type == 0x01)) /* SCSI bus */
|
||||
max_channel++;
|
||||
}
|
||||
|
||||
if (!max_channel) {
|
||||
osm_warn("no channels found on %s\n", c->name);
|
||||
return ERR_PTR(-EFAULT);
|
||||
}
|
||||
|
||||
size = max_channel * sizeof(struct i2o_device *)
|
||||
+ sizeof(struct i2o_scsi_host);
|
||||
|
||||
scsi_host = scsi_host_alloc(&i2o_scsi_host_template, size);
|
||||
if (!scsi_host) {
|
||||
osm_warn("Could not allocate SCSI host\n");
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
scsi_host->max_channel = max_channel - 1;
|
||||
scsi_host->max_id = i2o_scsi_max_id;
|
||||
scsi_host->max_lun = i2o_scsi_max_lun;
|
||||
scsi_host->this_id = c->unit;
|
||||
scsi_host->sg_tablesize = i2o_sg_tablesize(c, body_size);
|
||||
|
||||
i2o_shost = (struct i2o_scsi_host *)scsi_host->hostdata;
|
||||
i2o_shost->scsi_host = scsi_host;
|
||||
i2o_shost->iop = c;
|
||||
i2o_shost->lun = 1;
|
||||
|
||||
i = 0;
|
||||
list_for_each_entry(i2o_dev, &c->devices, list)
|
||||
if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
|
||||
if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1)
|
||||
&& (type == 0x01)) /* only SCSI bus */
|
||||
i2o_shost->channel[i++] = i2o_dev;
|
||||
|
||||
if (i >= max_channel)
|
||||
break;
|
||||
}
|
||||
|
||||
return i2o_shost;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_get_host - Get an I2O SCSI host
|
||||
* @c: I2O controller to for which to get the SCSI host
|
||||
*
|
||||
* If the I2O controller already exists as SCSI host, the SCSI host
|
||||
* is returned, otherwise the I2O controller is added to the SCSI
|
||||
* core.
|
||||
*
|
||||
* Returns pointer to the I2O SCSI host on success or NULL on failure.
|
||||
*/
|
||||
static struct i2o_scsi_host *i2o_scsi_get_host(struct i2o_controller *c)
|
||||
{
|
||||
return c->driver_data[i2o_scsi_driver.context];
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_remove - Remove I2O device from SCSI core
|
||||
* @dev: device which should be removed
|
||||
*
|
||||
* Removes the I2O device from the SCSI core again.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
*/
|
||||
static int i2o_scsi_remove(struct device *dev)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
struct i2o_controller *c = i2o_dev->iop;
|
||||
struct i2o_scsi_host *i2o_shost;
|
||||
struct scsi_device *scsi_dev;
|
||||
|
||||
osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid);
|
||||
|
||||
i2o_shost = i2o_scsi_get_host(c);
|
||||
|
||||
shost_for_each_device(scsi_dev, i2o_shost->scsi_host)
|
||||
if (scsi_dev->hostdata == i2o_dev) {
|
||||
sysfs_remove_link(&i2o_dev->device.kobj, "scsi");
|
||||
scsi_remove_device(scsi_dev);
|
||||
scsi_device_put(scsi_dev);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_probe - verify if dev is a I2O SCSI device and install it
|
||||
* @dev: device to verify if it is a I2O SCSI device
|
||||
*
|
||||
* Retrieve channel, id and lun for I2O device. If everything goes well
|
||||
* register the I2O device as SCSI device on the I2O SCSI controller.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int i2o_scsi_probe(struct device *dev)
|
||||
{
|
||||
struct i2o_device *i2o_dev = to_i2o_device(dev);
|
||||
struct i2o_controller *c = i2o_dev->iop;
|
||||
struct i2o_scsi_host *i2o_shost;
|
||||
struct Scsi_Host *scsi_host;
|
||||
struct i2o_device *parent;
|
||||
struct scsi_device *scsi_dev;
|
||||
u32 id = -1;
|
||||
u64 lun = -1;
|
||||
int channel = -1;
|
||||
int i, rc;
|
||||
|
||||
i2o_shost = i2o_scsi_get_host(c);
|
||||
if (!i2o_shost)
|
||||
return -EFAULT;
|
||||
|
||||
scsi_host = i2o_shost->scsi_host;
|
||||
|
||||
switch (i2o_dev->lct_data.class_id) {
|
||||
case I2O_CLASS_RANDOM_BLOCK_STORAGE:
|
||||
case I2O_CLASS_EXECUTIVE:
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC
|
||||
if (c->adaptec) {
|
||||
u8 type;
|
||||
struct i2o_device *d = i2o_shost->channel[0];
|
||||
|
||||
if (!i2o_parm_field_get(d, 0x0000, 0, &type, 1)
|
||||
&& (type == 0x01)) /* SCSI bus */
|
||||
if (!i2o_parm_field_get(d, 0x0200, 4, &id, 4)) {
|
||||
channel = 0;
|
||||
if (i2o_dev->lct_data.class_id ==
|
||||
I2O_CLASS_RANDOM_BLOCK_STORAGE)
|
||||
lun =
|
||||
cpu_to_le64(i2o_shost->
|
||||
lun++);
|
||||
else
|
||||
lun = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case I2O_CLASS_SCSI_PERIPHERAL:
|
||||
if (i2o_parm_field_get(i2o_dev, 0x0000, 3, &id, 4))
|
||||
return -EFAULT;
|
||||
|
||||
if (i2o_parm_field_get(i2o_dev, 0x0000, 4, &lun, 8))
|
||||
return -EFAULT;
|
||||
|
||||
parent = i2o_iop_find_device(c, i2o_dev->lct_data.parent_tid);
|
||||
if (!parent) {
|
||||
osm_warn("can not find parent of device %03x\n",
|
||||
i2o_dev->lct_data.tid);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
for (i = 0; i <= i2o_shost->scsi_host->max_channel; i++)
|
||||
if (i2o_shost->channel[i] == parent)
|
||||
channel = i;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (channel == -1) {
|
||||
osm_warn("can not find channel of device %03x\n",
|
||||
i2o_dev->lct_data.tid);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (le32_to_cpu(id) >= scsi_host->max_id) {
|
||||
osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)",
|
||||
le32_to_cpu(id), scsi_host->max_id);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (le64_to_cpu(lun) >= scsi_host->max_lun) {
|
||||
osm_warn("SCSI device lun (%llu) >= max_lun of I2O host (%llu)",
|
||||
le64_to_cpu(lun), scsi_host->max_lun);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
scsi_dev =
|
||||
__scsi_add_device(i2o_shost->scsi_host, channel, le32_to_cpu(id),
|
||||
le64_to_cpu(lun), i2o_dev);
|
||||
|
||||
if (IS_ERR(scsi_dev)) {
|
||||
osm_warn("can not add SCSI device %03x\n",
|
||||
i2o_dev->lct_data.tid);
|
||||
return PTR_ERR(scsi_dev);
|
||||
}
|
||||
|
||||
rc = sysfs_create_link(&i2o_dev->device.kobj,
|
||||
&scsi_dev->sdev_gendev.kobj, "scsi");
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %llu\n",
|
||||
i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
|
||||
le64_to_cpu(lun));
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
scsi_remove_device(scsi_dev);
|
||||
return rc;
|
||||
};
|
||||
|
||||
static const char *i2o_scsi_info(struct Scsi_Host *SChost)
|
||||
{
|
||||
struct i2o_scsi_host *hostdata;
|
||||
hostdata = (struct i2o_scsi_host *)SChost->hostdata;
|
||||
return hostdata->iop->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_scsi_reply - SCSI OSM message reply handler
|
||||
* @c: controller issuing the reply
|
||||
* @m: message id for flushing
|
||||
* @msg: the message from the controller
|
||||
*
|
||||
* Process reply messages (interrupts in normal scsi controller think).
|
||||
* We can get a variety of messages to process. The normal path is
|
||||
* scsi command completions. We must also deal with IOP failures,
|
||||
* the reply to a bus reset and the reply to a LUN query.
|
||||
*
|
||||
* Returns 0 on success and if the reply should not be flushed or > 0
|
||||
* on success and if the reply should be flushed. Returns negative error
|
||||
* code on failure and if the reply should be flushed.
|
||||
*/
|
||||
static int i2o_scsi_reply(struct i2o_controller *c, u32 m,
|
||||
struct i2o_message *msg)
|
||||
{
|
||||
struct scsi_cmnd *cmd;
|
||||
u32 error;
|
||||
struct device *dev;
|
||||
|
||||
cmd = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
|
||||
if (unlikely(!cmd)) {
|
||||
osm_err("NULL reply received!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Low byte is device status, next is adapter status,
|
||||
* (then one byte reserved), then request status.
|
||||
*/
|
||||
error = le32_to_cpu(msg->body[0]);
|
||||
|
||||
osm_debug("Completed %0x%p\n", cmd);
|
||||
|
||||
cmd->result = error & 0xff;
|
||||
/*
|
||||
* if DeviceStatus is not SCSI_SUCCESS copy over the sense data and let
|
||||
* the SCSI layer handle the error
|
||||
*/
|
||||
if (cmd->result)
|
||||
memcpy(cmd->sense_buffer, &msg->body[3],
|
||||
min(SCSI_SENSE_BUFFERSIZE, 40));
|
||||
|
||||
/* only output error code if AdapterStatus is not HBA_SUCCESS */
|
||||
if ((error >> 8) & 0xff)
|
||||
osm_err("SCSI error %08x\n", error);
|
||||
|
||||
dev = &c->pdev->dev;
|
||||
|
||||
scsi_dma_unmap(cmd);
|
||||
|
||||
cmd->scsi_done(cmd);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_notify_device_add - Retrieve notifications of added devices
|
||||
* @i2o_dev: the I2O device which was added
|
||||
*
|
||||
* If a I2O device is added we catch the notification, because I2O classes
|
||||
* other than SCSI peripheral will not be received through
|
||||
* i2o_scsi_probe().
|
||||
*/
|
||||
static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev)
|
||||
{
|
||||
switch (i2o_dev->lct_data.class_id) {
|
||||
case I2O_CLASS_EXECUTIVE:
|
||||
case I2O_CLASS_RANDOM_BLOCK_STORAGE:
|
||||
i2o_scsi_probe(&i2o_dev->device);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_notify_device_remove - Retrieve notifications of removed devices
|
||||
* @i2o_dev: the I2O device which was removed
|
||||
*
|
||||
* If a I2O device is removed, we catch the notification to remove the
|
||||
* corresponding SCSI device.
|
||||
*/
|
||||
static void i2o_scsi_notify_device_remove(struct i2o_device *i2o_dev)
|
||||
{
|
||||
switch (i2o_dev->lct_data.class_id) {
|
||||
case I2O_CLASS_EXECUTIVE:
|
||||
case I2O_CLASS_RANDOM_BLOCK_STORAGE:
|
||||
i2o_scsi_remove(&i2o_dev->device);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_notify_controller_add - Retrieve notifications of added controllers
|
||||
* @c: the controller which was added
|
||||
*
|
||||
* If a I2O controller is added, we catch the notification to add a
|
||||
* corresponding Scsi_Host.
|
||||
*/
|
||||
static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
|
||||
{
|
||||
struct i2o_scsi_host *i2o_shost;
|
||||
int rc;
|
||||
|
||||
i2o_shost = i2o_scsi_host_alloc(c);
|
||||
if (IS_ERR(i2o_shost)) {
|
||||
osm_err("Could not initialize SCSI host\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rc = scsi_add_host(i2o_shost->scsi_host, &c->device);
|
||||
if (rc) {
|
||||
osm_err("Could not add SCSI host\n");
|
||||
scsi_host_put(i2o_shost->scsi_host);
|
||||
return;
|
||||
}
|
||||
|
||||
c->driver_data[i2o_scsi_driver.context] = i2o_shost;
|
||||
|
||||
osm_debug("new I2O SCSI host added\n");
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_notify_controller_remove - Retrieve notifications of removed controllers
|
||||
* @c: the controller which was removed
|
||||
*
|
||||
* If a I2O controller is removed, we catch the notification to remove the
|
||||
* corresponding Scsi_Host.
|
||||
*/
|
||||
static void i2o_scsi_notify_controller_remove(struct i2o_controller *c)
|
||||
{
|
||||
struct i2o_scsi_host *i2o_shost;
|
||||
i2o_shost = i2o_scsi_get_host(c);
|
||||
if (!i2o_shost)
|
||||
return;
|
||||
|
||||
c->driver_data[i2o_scsi_driver.context] = NULL;
|
||||
|
||||
scsi_remove_host(i2o_shost->scsi_host);
|
||||
scsi_host_put(i2o_shost->scsi_host);
|
||||
osm_debug("I2O SCSI host removed\n");
|
||||
};
|
||||
|
||||
/* SCSI OSM driver struct */
|
||||
static struct i2o_driver i2o_scsi_driver = {
|
||||
.name = OSM_NAME,
|
||||
.reply = i2o_scsi_reply,
|
||||
.classes = i2o_scsi_class_id,
|
||||
.notify_device_add = i2o_scsi_notify_device_add,
|
||||
.notify_device_remove = i2o_scsi_notify_device_remove,
|
||||
.notify_controller_add = i2o_scsi_notify_controller_add,
|
||||
.notify_controller_remove = i2o_scsi_notify_controller_remove,
|
||||
.driver = {
|
||||
.probe = i2o_scsi_probe,
|
||||
.remove = i2o_scsi_remove,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_queuecommand - queue a SCSI command
|
||||
* @SCpnt: scsi command pointer
|
||||
* @done: callback for completion
|
||||
*
|
||||
* Issue a scsi command asynchronously. Return 0 on success or 1 if
|
||||
* we hit an error (normally message queue congestion). The only
|
||||
* minor complication here is that I2O deals with the device addressing
|
||||
* so we have to map the bus/dev/lun back to an I2O handle as well
|
||||
* as faking absent devices ourself.
|
||||
*
|
||||
* Locks: takes the controller lock on error path only
|
||||
*/
|
||||
|
||||
static int i2o_scsi_queuecommand_lck(struct scsi_cmnd *SCpnt,
|
||||
void (*done) (struct scsi_cmnd *))
|
||||
{
|
||||
struct i2o_controller *c;
|
||||
struct i2o_device *i2o_dev;
|
||||
int tid;
|
||||
struct i2o_message *msg;
|
||||
/*
|
||||
* ENABLE_DISCONNECT
|
||||
* SIMPLE_TAG
|
||||
* RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME
|
||||
*/
|
||||
u32 scsi_flags = 0x20a00000;
|
||||
u32 sgl_offset;
|
||||
u32 *mptr;
|
||||
u32 cmd = I2O_CMD_SCSI_EXEC << 24;
|
||||
int rc = 0;
|
||||
|
||||
/*
|
||||
* Do the incoming paperwork
|
||||
*/
|
||||
i2o_dev = SCpnt->device->hostdata;
|
||||
|
||||
SCpnt->scsi_done = done;
|
||||
|
||||
if (unlikely(!i2o_dev)) {
|
||||
osm_warn("no I2O device in request\n");
|
||||
SCpnt->result = DID_NO_CONNECT << 16;
|
||||
done(SCpnt);
|
||||
goto exit;
|
||||
}
|
||||
c = i2o_dev->iop;
|
||||
tid = i2o_dev->lct_data.tid;
|
||||
|
||||
osm_debug("qcmd: Tid = %03x\n", tid);
|
||||
osm_debug("Real scsi messages.\n");
|
||||
|
||||
/*
|
||||
* Put together a scsi execscb message
|
||||
*/
|
||||
switch (SCpnt->sc_data_direction) {
|
||||
case PCI_DMA_NONE:
|
||||
/* DATA NO XFER */
|
||||
sgl_offset = SGL_OFFSET_0;
|
||||
break;
|
||||
|
||||
case PCI_DMA_TODEVICE:
|
||||
/* DATA OUT (iop-->dev) */
|
||||
scsi_flags |= 0x80000000;
|
||||
sgl_offset = SGL_OFFSET_10;
|
||||
break;
|
||||
|
||||
case PCI_DMA_FROMDEVICE:
|
||||
/* DATA IN (iop<--dev) */
|
||||
scsi_flags |= 0x40000000;
|
||||
sgl_offset = SGL_OFFSET_10;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Unknown - kill the command */
|
||||
SCpnt->result = DID_NO_CONNECT << 16;
|
||||
done(SCpnt);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Obtain an I2O message. If there are none free then
|
||||
* throw it back to the scsi layer
|
||||
*/
|
||||
|
||||
msg = i2o_msg_get(c);
|
||||
if (IS_ERR(msg)) {
|
||||
rc = SCSI_MLQUEUE_HOST_BUSY;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mptr = &msg->body[0];
|
||||
|
||||
#if 0 /* this code can't work */
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC
|
||||
if (c->adaptec) {
|
||||
u32 adpt_flags = 0;
|
||||
|
||||
if (SCpnt->sc_request && SCpnt->sc_request->upper_private_data) {
|
||||
i2o_sg_io_hdr_t __user *usr_ptr =
|
||||
((Sg_request *) (SCpnt->sc_request->
|
||||
upper_private_data))->header.
|
||||
usr_ptr;
|
||||
|
||||
if (usr_ptr)
|
||||
get_user(adpt_flags, &usr_ptr->flags);
|
||||
}
|
||||
|
||||
switch (i2o_dev->lct_data.class_id) {
|
||||
case I2O_CLASS_EXECUTIVE:
|
||||
case I2O_CLASS_RANDOM_BLOCK_STORAGE:
|
||||
/* interpret flag has to be set for executive */
|
||||
adpt_flags ^= I2O_DPT_SG_FLAG_INTERPRET;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* for Adaptec controllers we use the PRIVATE command, because
|
||||
* the normal SCSI EXEC doesn't support all SCSI commands on
|
||||
* all controllers (for example READ CAPACITY).
|
||||
*/
|
||||
if (sgl_offset == SGL_OFFSET_10)
|
||||
sgl_offset = SGL_OFFSET_12;
|
||||
cmd = I2O_CMD_PRIVATE << 24;
|
||||
*mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC);
|
||||
*mptr++ = cpu_to_le32(adpt_flags | tid);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
|
||||
msg->u.s.icntxt = cpu_to_le32(i2o_scsi_driver.context);
|
||||
|
||||
/* We want the SCSI control block back */
|
||||
msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, SCpnt));
|
||||
|
||||
/* LSI_920_PCI_QUIRK
|
||||
*
|
||||
* Intermittant observations of msg frame word data corruption
|
||||
* observed on msg[4] after:
|
||||
* WRITE, READ-MODIFY-WRITE
|
||||
* operations. 19990606 -sralston
|
||||
*
|
||||
* (Hence we build this word via tag. Its good practice anyway
|
||||
* we don't want fetches over PCI needlessly)
|
||||
*/
|
||||
|
||||
/* Attach tags to the devices */
|
||||
/* FIXME: implement
|
||||
if(SCpnt->device->tagged_supported) {
|
||||
if(SCpnt->tag == HEAD_OF_QUEUE_TAG)
|
||||
scsi_flags |= 0x01000000;
|
||||
else if(SCpnt->tag == ORDERED_QUEUE_TAG)
|
||||
scsi_flags |= 0x01800000;
|
||||
}
|
||||
*/
|
||||
|
||||
*mptr++ = cpu_to_le32(scsi_flags | SCpnt->cmd_len);
|
||||
|
||||
/* Write SCSI command into the message - always 16 byte block */
|
||||
memcpy(mptr, SCpnt->cmnd, 16);
|
||||
mptr += 4;
|
||||
|
||||
if (sgl_offset != SGL_OFFSET_0) {
|
||||
/* write size of data addressed by SGL */
|
||||
*mptr++ = cpu_to_le32(scsi_bufflen(SCpnt));
|
||||
|
||||
/* Now fill in the SGList and command */
|
||||
|
||||
if (scsi_sg_count(SCpnt)) {
|
||||
if (!i2o_dma_map_sg(c, scsi_sglist(SCpnt),
|
||||
scsi_sg_count(SCpnt),
|
||||
SCpnt->sc_data_direction, &mptr))
|
||||
goto nomem;
|
||||
}
|
||||
}
|
||||
|
||||
/* Stick the headers on */
|
||||
msg->u.head[0] =
|
||||
cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset);
|
||||
|
||||
/* Queue the message */
|
||||
i2o_msg_post(c, msg);
|
||||
|
||||
osm_debug("Issued %0x%p\n", SCpnt);
|
||||
|
||||
return 0;
|
||||
|
||||
nomem:
|
||||
rc = -ENOMEM;
|
||||
i2o_msg_nop(c, msg);
|
||||
|
||||
exit:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static DEF_SCSI_QCMD(i2o_scsi_queuecommand)
|
||||
|
||||
/**
|
||||
* i2o_scsi_abort - abort a running command
|
||||
* @SCpnt: command to abort
|
||||
*
|
||||
* Ask the I2O controller to abort a command. This is an asynchrnous
|
||||
* process and our callback handler will see the command complete with an
|
||||
* aborted message if it succeeds.
|
||||
*
|
||||
* Returns 0 if the command is successfully aborted or negative error code
|
||||
* on failure.
|
||||
*/
|
||||
static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
|
||||
{
|
||||
struct i2o_device *i2o_dev;
|
||||
struct i2o_controller *c;
|
||||
struct i2o_message *msg;
|
||||
int tid;
|
||||
int status = FAILED;
|
||||
|
||||
osm_warn("Aborting command block.\n");
|
||||
|
||||
i2o_dev = SCpnt->device->hostdata;
|
||||
c = i2o_dev->iop;
|
||||
tid = i2o_dev->lct_data.tid;
|
||||
|
||||
msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
|
||||
if (IS_ERR(msg))
|
||||
return SCSI_MLQUEUE_HOST_BUSY;
|
||||
|
||||
msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
|
||||
msg->u.head[1] =
|
||||
cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid);
|
||||
msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt));
|
||||
|
||||
if (!i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT))
|
||||
status = SUCCESS;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_scsi_bios_param - Invent disk geometry
|
||||
* @sdev: scsi device
|
||||
* @dev: block layer device
|
||||
* @capacity: size in sectors
|
||||
* @ip: geometry array
|
||||
*
|
||||
* This is anyone's guess quite frankly. We use the same rules everyone
|
||||
* else appears to and hope. It seems to work.
|
||||
*/
|
||||
|
||||
static int i2o_scsi_bios_param(struct scsi_device *sdev,
|
||||
struct block_device *dev, sector_t capacity,
|
||||
int *ip)
|
||||
{
|
||||
int size;
|
||||
|
||||
size = capacity;
|
||||
ip[0] = 64; /* heads */
|
||||
ip[1] = 32; /* sectors */
|
||||
if ((ip[2] = size >> 11) > 1024) { /* cylinders, test for big disk */
|
||||
ip[0] = 255; /* heads */
|
||||
ip[1] = 63; /* sectors */
|
||||
ip[2] = size / (255 * 63); /* cylinders */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct scsi_host_template i2o_scsi_host_template = {
|
||||
.proc_name = OSM_NAME,
|
||||
.name = OSM_DESCRIPTION,
|
||||
.info = i2o_scsi_info,
|
||||
.queuecommand = i2o_scsi_queuecommand,
|
||||
.eh_abort_handler = i2o_scsi_abort,
|
||||
.bios_param = i2o_scsi_bios_param,
|
||||
.can_queue = I2O_SCSI_CAN_QUEUE,
|
||||
.sg_tablesize = 8,
|
||||
.cmd_per_lun = 6,
|
||||
.use_clustering = ENABLE_CLUSTERING,
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_init - SCSI OSM initialization function
|
||||
*
|
||||
* Register SCSI OSM into I2O core.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int __init i2o_scsi_init(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
|
||||
|
||||
/* Register SCSI OSM into I2O core */
|
||||
rc = i2o_driver_register(&i2o_scsi_driver);
|
||||
if (rc) {
|
||||
osm_err("Could not register SCSI driver\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_scsi_exit - SCSI OSM exit function
|
||||
*
|
||||
* Unregisters SCSI OSM from I2O core.
|
||||
*/
|
||||
static void __exit i2o_scsi_exit(void)
|
||||
{
|
||||
/* Unregister I2O SCSI OSM from I2O core */
|
||||
i2o_driver_unregister(&i2o_scsi_driver);
|
||||
};
|
||||
|
||||
MODULE_AUTHOR("Red Hat Software");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION(OSM_DESCRIPTION);
|
||||
MODULE_VERSION(OSM_VERSION);
|
||||
|
||||
module_init(i2o_scsi_init);
|
||||
module_exit(i2o_scsi_exit);
|
File diff suppressed because it is too large
Load Diff
|
@ -1,312 +0,0 @@
|
|||
/*
|
||||
* Functions to handle I2O memory
|
||||
*
|
||||
* Pulled from the inlines in i2o headers and uninlined
|
||||
*
|
||||
*
|
||||
* 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "i2o.h"
|
||||
#include <linux/delay.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/slab.h>
|
||||
#include "core.h"
|
||||
|
||||
/* Protects our 32/64bit mask switching */
|
||||
static DEFINE_MUTEX(mem_lock);
|
||||
|
||||
/**
|
||||
* i2o_sg_tablesize - Calculate the maximum number of elements in a SGL
|
||||
* @c: I2O controller for which the calculation should be done
|
||||
* @body_size: maximum body size used for message in 32-bit words.
|
||||
*
|
||||
* Return the maximum number of SG elements in a SG list.
|
||||
*/
|
||||
u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size)
|
||||
{
|
||||
i2o_status_block *sb = c->status_block.virt;
|
||||
u16 sg_count =
|
||||
(sb->inbound_frame_size - sizeof(struct i2o_message) / 4) -
|
||||
body_size;
|
||||
|
||||
if (c->pae_support) {
|
||||
/*
|
||||
* for 64-bit a SG attribute element must be added and each
|
||||
* SG element needs 12 bytes instead of 8.
|
||||
*/
|
||||
sg_count -= 2;
|
||||
sg_count /= 3;
|
||||
} else
|
||||
sg_count /= 2;
|
||||
|
||||
if (c->short_req && (sg_count > 8))
|
||||
sg_count = 8;
|
||||
|
||||
return sg_count;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(i2o_sg_tablesize);
|
||||
|
||||
|
||||
/**
|
||||
* i2o_dma_map_single - Map pointer to controller and fill in I2O message.
|
||||
* @c: I2O controller
|
||||
* @ptr: pointer to the data which should be mapped
|
||||
* @size: size of data in bytes
|
||||
* @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
|
||||
* @sg_ptr: pointer to the SG list inside the I2O message
|
||||
*
|
||||
* This function does all necessary DMA handling and also writes the I2O
|
||||
* SGL elements into the I2O message. For details on DMA handling see also
|
||||
* dma_map_single(). The pointer sg_ptr will only be set to the end of the
|
||||
* SG list if the allocation was successful.
|
||||
*
|
||||
* Returns DMA address which must be checked for failures using
|
||||
* dma_mapping_error().
|
||||
*/
|
||||
dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
|
||||
size_t size,
|
||||
enum dma_data_direction direction,
|
||||
u32 ** sg_ptr)
|
||||
{
|
||||
u32 sg_flags;
|
||||
u32 *mptr = *sg_ptr;
|
||||
dma_addr_t dma_addr;
|
||||
|
||||
switch (direction) {
|
||||
case DMA_TO_DEVICE:
|
||||
sg_flags = 0xd4000000;
|
||||
break;
|
||||
case DMA_FROM_DEVICE:
|
||||
sg_flags = 0xd0000000;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction);
|
||||
if (!dma_mapping_error(&c->pdev->dev, dma_addr)) {
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
|
||||
if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
|
||||
*mptr++ = cpu_to_le32(0x7C020002);
|
||||
*mptr++ = cpu_to_le32(PAGE_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
*mptr++ = cpu_to_le32(sg_flags | size);
|
||||
*mptr++ = cpu_to_le32(i2o_dma_low(dma_addr));
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
|
||||
if ((sizeof(dma_addr_t) > 4) && c->pae_support)
|
||||
*mptr++ = cpu_to_le32(i2o_dma_high(dma_addr));
|
||||
#endif
|
||||
*sg_ptr = mptr;
|
||||
}
|
||||
return dma_addr;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(i2o_dma_map_single);
|
||||
|
||||
/**
|
||||
* i2o_dma_map_sg - Map a SG List to controller and fill in I2O message.
|
||||
* @c: I2O controller
|
||||
* @sg: SG list to be mapped
|
||||
* @sg_count: number of elements in the SG list
|
||||
* @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
|
||||
* @sg_ptr: pointer to the SG list inside the I2O message
|
||||
*
|
||||
* This function does all necessary DMA handling and also writes the I2O
|
||||
* SGL elements into the I2O message. For details on DMA handling see also
|
||||
* dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG
|
||||
* list if the allocation was successful.
|
||||
*
|
||||
* Returns 0 on failure or 1 on success.
|
||||
*/
|
||||
int i2o_dma_map_sg(struct i2o_controller *c, struct scatterlist *sg,
|
||||
int sg_count, enum dma_data_direction direction, u32 ** sg_ptr)
|
||||
{
|
||||
u32 sg_flags;
|
||||
u32 *mptr = *sg_ptr;
|
||||
|
||||
switch (direction) {
|
||||
case DMA_TO_DEVICE:
|
||||
sg_flags = 0x14000000;
|
||||
break;
|
||||
case DMA_FROM_DEVICE:
|
||||
sg_flags = 0x10000000;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction);
|
||||
if (!sg_count)
|
||||
return 0;
|
||||
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
|
||||
if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
|
||||
*mptr++ = cpu_to_le32(0x7C020002);
|
||||
*mptr++ = cpu_to_le32(PAGE_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (sg_count-- > 0) {
|
||||
if (!sg_count)
|
||||
sg_flags |= 0xC0000000;
|
||||
*mptr++ = cpu_to_le32(sg_flags | sg_dma_len(sg));
|
||||
*mptr++ = cpu_to_le32(i2o_dma_low(sg_dma_address(sg)));
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
|
||||
if ((sizeof(dma_addr_t) > 4) && c->pae_support)
|
||||
*mptr++ = cpu_to_le32(i2o_dma_high(sg_dma_address(sg)));
|
||||
#endif
|
||||
sg = sg_next(sg);
|
||||
}
|
||||
*sg_ptr = mptr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(i2o_dma_map_sg);
|
||||
|
||||
/**
|
||||
* i2o_dma_alloc - Allocate DMA memory
|
||||
* @dev: struct device pointer to the PCI device of the I2O controller
|
||||
* @addr: i2o_dma struct which should get the DMA buffer
|
||||
* @len: length of the new DMA memory
|
||||
*
|
||||
* Allocate a coherent DMA memory and write the pointers into addr.
|
||||
*
|
||||
* Returns 0 on success or -ENOMEM on failure.
|
||||
*/
|
||||
int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
int dma_64 = 0;
|
||||
|
||||
mutex_lock(&mem_lock);
|
||||
if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_BIT_MASK(64))) {
|
||||
dma_64 = 1;
|
||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
|
||||
mutex_unlock(&mem_lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
addr->virt = dma_alloc_coherent(dev, len, &addr->phys, GFP_KERNEL);
|
||||
|
||||
if ((sizeof(dma_addr_t) > 4) && dma_64)
|
||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
|
||||
printk(KERN_WARNING "i2o: unable to set 64-bit DMA");
|
||||
mutex_unlock(&mem_lock);
|
||||
|
||||
if (!addr->virt)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(addr->virt, 0, len);
|
||||
addr->len = len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(i2o_dma_alloc);
|
||||
|
||||
|
||||
/**
|
||||
* i2o_dma_free - Free DMA memory
|
||||
* @dev: struct device pointer to the PCI device of the I2O controller
|
||||
* @addr: i2o_dma struct which contains the DMA buffer
|
||||
*
|
||||
* Free a coherent DMA memory and set virtual address of addr to NULL.
|
||||
*/
|
||||
void i2o_dma_free(struct device *dev, struct i2o_dma *addr)
|
||||
{
|
||||
if (addr->virt) {
|
||||
if (addr->phys)
|
||||
dma_free_coherent(dev, addr->len, addr->virt,
|
||||
addr->phys);
|
||||
else
|
||||
kfree(addr->virt);
|
||||
addr->virt = NULL;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(i2o_dma_free);
|
||||
|
||||
|
||||
/**
|
||||
* i2o_dma_realloc - Realloc DMA memory
|
||||
* @dev: struct device pointer to the PCI device of the I2O controller
|
||||
* @addr: pointer to a i2o_dma struct DMA buffer
|
||||
* @len: new length of memory
|
||||
*
|
||||
* If there was something allocated in the addr, free it first. If len > 0
|
||||
* than try to allocate it and write the addresses back to the addr
|
||||
* structure. If len == 0 set the virtual address to NULL.
|
||||
*
|
||||
* Returns the 0 on success or negative error code on failure.
|
||||
*/
|
||||
int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, size_t len)
|
||||
{
|
||||
i2o_dma_free(dev, addr);
|
||||
|
||||
if (len)
|
||||
return i2o_dma_alloc(dev, addr, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(i2o_dma_realloc);
|
||||
|
||||
/*
|
||||
* i2o_pool_alloc - Allocate an slab cache and mempool
|
||||
* @mempool: pointer to struct i2o_pool to write data into.
|
||||
* @name: name which is used to identify cache
|
||||
* @size: size of each object
|
||||
* @min_nr: minimum number of objects
|
||||
*
|
||||
* First allocates a slab cache with name and size. Then allocates a
|
||||
* mempool which uses the slab cache for allocation and freeing.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
|
||||
size_t size, int min_nr)
|
||||
{
|
||||
pool->name = kstrdup(name, GFP_KERNEL);
|
||||
if (!pool->name)
|
||||
goto exit;
|
||||
|
||||
pool->slab =
|
||||
kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL);
|
||||
if (!pool->slab)
|
||||
goto free_name;
|
||||
|
||||
pool->mempool = mempool_create_slab_pool(min_nr, pool->slab);
|
||||
if (!pool->mempool)
|
||||
goto free_slab;
|
||||
|
||||
return 0;
|
||||
|
||||
free_slab:
|
||||
kmem_cache_destroy(pool->slab);
|
||||
|
||||
free_name:
|
||||
kfree(pool->name);
|
||||
|
||||
exit:
|
||||
return -ENOMEM;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(i2o_pool_alloc);
|
||||
|
||||
/*
|
||||
* i2o_pool_free - Free slab cache and mempool again
|
||||
* @mempool: pointer to struct i2o_pool which should be freed
|
||||
*
|
||||
* Note that you have to return all objects to the mempool again before
|
||||
* calling i2o_pool_free().
|
||||
*/
|
||||
void i2o_pool_free(struct i2o_pool *pool)
|
||||
{
|
||||
mempool_destroy(pool->mempool);
|
||||
kmem_cache_destroy(pool->slab);
|
||||
kfree(pool->name);
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(i2o_pool_free);
|
|
@ -1,500 +0,0 @@
|
|||
/*
|
||||
* PCI handling of I2O controller
|
||||
*
|
||||
* Copyright (C) 1999-2002 Red Hat Software
|
||||
*
|
||||
* Written by Alan Cox, Building Number Three Ltd
|
||||
*
|
||||
* 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 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* A lot of the I2O message side code from this is taken from the Red
|
||||
* Creek RCPCI45 adapter driver by Red Creek Communications
|
||||
*
|
||||
* Fixes/additions:
|
||||
* Philipp Rumpf
|
||||
* Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
|
||||
* Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
|
||||
* Deepak Saxena <deepak@plexity.net>
|
||||
* Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
|
||||
* Alan Cox <alan@lxorguk.ukuu.org.uk>:
|
||||
* Ported to Linux 2.5.
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>:
|
||||
* Minor fixes for 2.6.
|
||||
* Markus Lidel <Markus.Lidel@shadowconnect.com>:
|
||||
* Support for sysfs included.
|
||||
*/
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/slab.h>
|
||||
#include "i2o.h"
|
||||
#include <linux/module.h>
|
||||
#include "core.h"
|
||||
|
||||
#define OSM_DESCRIPTION "I2O-subsystem"
|
||||
|
||||
/* PCI device id table for all I2O controllers */
|
||||
static struct pci_device_id i2o_pci_ids[] = {
|
||||
{PCI_DEVICE_CLASS(PCI_CLASS_INTELLIGENT_I2O << 8, 0xffff00)},
|
||||
{PCI_DEVICE(PCI_VENDOR_ID_DPT, 0xa511)},
|
||||
{.vendor = PCI_VENDOR_ID_INTEL,.device = 0x1962,
|
||||
.subvendor = PCI_VENDOR_ID_PROMISE,.subdevice = PCI_ANY_ID},
|
||||
{0}
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_pci_free - Frees the DMA memory for the I2O controller
|
||||
* @c: I2O controller to free
|
||||
*
|
||||
* Remove all allocated DMA memory and unmap memory IO regions. If MTRR
|
||||
* is enabled, also remove it again.
|
||||
*/
|
||||
static void i2o_pci_free(struct i2o_controller *c)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
dev = &c->pdev->dev;
|
||||
|
||||
i2o_dma_free(dev, &c->out_queue);
|
||||
i2o_dma_free(dev, &c->status_block);
|
||||
kfree(c->lct);
|
||||
i2o_dma_free(dev, &c->dlct);
|
||||
i2o_dma_free(dev, &c->hrt);
|
||||
i2o_dma_free(dev, &c->status);
|
||||
|
||||
if (c->raptor && c->in_queue.virt)
|
||||
iounmap(c->in_queue.virt);
|
||||
|
||||
if (c->base.virt)
|
||||
iounmap(c->base.virt);
|
||||
|
||||
pci_release_regions(c->pdev);
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_pci_alloc - Allocate DMA memory, map IO memory for I2O controller
|
||||
* @c: I2O controller
|
||||
*
|
||||
* Allocate DMA memory for a PCI (or in theory AGP) I2O controller. All
|
||||
* IO mappings are also done here. If MTRR is enabled, also do add memory
|
||||
* regions here.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int i2o_pci_alloc(struct i2o_controller *c)
|
||||
{
|
||||
struct pci_dev *pdev = c->pdev;
|
||||
struct device *dev = &pdev->dev;
|
||||
int i;
|
||||
|
||||
if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
|
||||
printk(KERN_ERR "%s: device already claimed\n", c->name);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
/* Skip I/O spaces */
|
||||
if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
|
||||
if (!c->base.phys) {
|
||||
c->base.phys = pci_resource_start(pdev, i);
|
||||
c->base.len = pci_resource_len(pdev, i);
|
||||
|
||||
/*
|
||||
* If we know what card it is, set the size
|
||||
* correctly. Code is taken from dpt_i2o.c
|
||||
*/
|
||||
if (pdev->device == 0xa501) {
|
||||
if (pdev->subsystem_device >= 0xc032 &&
|
||||
pdev->subsystem_device <= 0xc03b) {
|
||||
if (c->base.len > 0x400000)
|
||||
c->base.len = 0x400000;
|
||||
} else {
|
||||
if (c->base.len > 0x100000)
|
||||
c->base.len = 0x100000;
|
||||
}
|
||||
}
|
||||
if (!c->raptor)
|
||||
break;
|
||||
} else {
|
||||
c->in_queue.phys = pci_resource_start(pdev, i);
|
||||
c->in_queue.len = pci_resource_len(pdev, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 6) {
|
||||
printk(KERN_ERR "%s: I2O controller has no memory regions"
|
||||
" defined.\n", c->name);
|
||||
i2o_pci_free(c);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Map the I2O controller */
|
||||
if (c->raptor) {
|
||||
printk(KERN_INFO "%s: PCI I2O controller\n", c->name);
|
||||
printk(KERN_INFO " BAR0 at 0x%08lX size=%ld\n",
|
||||
(unsigned long)c->base.phys, (unsigned long)c->base.len);
|
||||
printk(KERN_INFO " BAR1 at 0x%08lX size=%ld\n",
|
||||
(unsigned long)c->in_queue.phys,
|
||||
(unsigned long)c->in_queue.len);
|
||||
} else
|
||||
printk(KERN_INFO "%s: PCI I2O controller at %08lX size=%ld\n",
|
||||
c->name, (unsigned long)c->base.phys,
|
||||
(unsigned long)c->base.len);
|
||||
|
||||
c->base.virt = ioremap_nocache(c->base.phys, c->base.len);
|
||||
if (!c->base.virt) {
|
||||
printk(KERN_ERR "%s: Unable to map controller.\n", c->name);
|
||||
i2o_pci_free(c);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (c->raptor) {
|
||||
c->in_queue.virt =
|
||||
ioremap_nocache(c->in_queue.phys, c->in_queue.len);
|
||||
if (!c->in_queue.virt) {
|
||||
printk(KERN_ERR "%s: Unable to map controller.\n",
|
||||
c->name);
|
||||
i2o_pci_free(c);
|
||||
return -ENOMEM;
|
||||
}
|
||||
} else
|
||||
c->in_queue = c->base;
|
||||
|
||||
c->irq_status = c->base.virt + I2O_IRQ_STATUS;
|
||||
c->irq_mask = c->base.virt + I2O_IRQ_MASK;
|
||||
c->in_port = c->base.virt + I2O_IN_PORT;
|
||||
c->out_port = c->base.virt + I2O_OUT_PORT;
|
||||
|
||||
/* Motorola/Freescale chip does not follow spec */
|
||||
if (pdev->vendor == PCI_VENDOR_ID_MOTOROLA && pdev->device == 0x18c0) {
|
||||
/* Check if CPU is enabled */
|
||||
if (be32_to_cpu(readl(c->base.virt + 0x10000)) & 0x10000000) {
|
||||
printk(KERN_INFO "%s: MPC82XX needs CPU running to "
|
||||
"service I2O.\n", c->name);
|
||||
i2o_pci_free(c);
|
||||
return -ENODEV;
|
||||
} else {
|
||||
c->irq_status += I2O_MOTOROLA_PORT_OFFSET;
|
||||
c->irq_mask += I2O_MOTOROLA_PORT_OFFSET;
|
||||
c->in_port += I2O_MOTOROLA_PORT_OFFSET;
|
||||
c->out_port += I2O_MOTOROLA_PORT_OFFSET;
|
||||
printk(KERN_INFO "%s: MPC82XX workarounds activated.\n",
|
||||
c->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (i2o_dma_alloc(dev, &c->status, 8)) {
|
||||
i2o_pci_free(c);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (i2o_dma_alloc(dev, &c->hrt, sizeof(i2o_hrt))) {
|
||||
i2o_pci_free(c);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (i2o_dma_alloc(dev, &c->dlct, 8192)) {
|
||||
i2o_pci_free(c);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (i2o_dma_alloc(dev, &c->status_block, sizeof(i2o_status_block))) {
|
||||
i2o_pci_free(c);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (i2o_dma_alloc(dev, &c->out_queue,
|
||||
I2O_MAX_OUTBOUND_MSG_FRAMES * I2O_OUTBOUND_MSG_FRAME_SIZE *
|
||||
sizeof(u32))) {
|
||||
i2o_pci_free(c);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pci_set_drvdata(pdev, c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_pci_interrupt - Interrupt handler for I2O controller
|
||||
* @irq: interrupt line
|
||||
* @dev_id: pointer to the I2O controller
|
||||
*
|
||||
* Handle an interrupt from a PCI based I2O controller. This turns out
|
||||
* to be rather simple. We keep the controller pointer in the cookie.
|
||||
*/
|
||||
static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
struct i2o_controller *c = dev_id;
|
||||
u32 m;
|
||||
irqreturn_t rc = IRQ_NONE;
|
||||
|
||||
while (readl(c->irq_status) & I2O_IRQ_OUTBOUND_POST) {
|
||||
m = readl(c->out_port);
|
||||
if (m == I2O_QUEUE_EMPTY) {
|
||||
/*
|
||||
* Old 960 steppings had a bug in the I2O unit that
|
||||
* caused the queue to appear empty when it wasn't.
|
||||
*/
|
||||
m = readl(c->out_port);
|
||||
if (unlikely(m == I2O_QUEUE_EMPTY))
|
||||
break;
|
||||
}
|
||||
|
||||
/* dispatch it */
|
||||
if (i2o_driver_dispatch(c, m))
|
||||
/* flush it if result != 0 */
|
||||
i2o_flush_reply(c, m);
|
||||
|
||||
rc = IRQ_HANDLED;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_pci_irq_enable - Allocate interrupt for I2O controller
|
||||
* @c: i2o_controller that the request is for
|
||||
*
|
||||
* Allocate an interrupt for the I2O controller, and activate interrupts
|
||||
* on the I2O controller.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int i2o_pci_irq_enable(struct i2o_controller *c)
|
||||
{
|
||||
struct pci_dev *pdev = c->pdev;
|
||||
int rc;
|
||||
|
||||
writel(0xffffffff, c->irq_mask);
|
||||
|
||||
if (pdev->irq) {
|
||||
rc = request_irq(pdev->irq, i2o_pci_interrupt, IRQF_SHARED,
|
||||
c->name, c);
|
||||
if (rc < 0) {
|
||||
printk(KERN_ERR "%s: unable to allocate interrupt %d."
|
||||
"\n", c->name, pdev->irq);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
writel(0x00000000, c->irq_mask);
|
||||
|
||||
printk(KERN_INFO "%s: Installed at IRQ %d\n", c->name, pdev->irq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_pci_irq_disable - Free interrupt for I2O controller
|
||||
* @c: I2O controller
|
||||
*
|
||||
* Disable interrupts in I2O controller and then free interrupt.
|
||||
*/
|
||||
static void i2o_pci_irq_disable(struct i2o_controller *c)
|
||||
{
|
||||
writel(0xffffffff, c->irq_mask);
|
||||
|
||||
if (c->pdev->irq > 0)
|
||||
free_irq(c->pdev->irq, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_pci_probe - Probe the PCI device for an I2O controller
|
||||
* @pdev: PCI device to test
|
||||
* @id: id which matched with the PCI device id table
|
||||
*
|
||||
* Probe the PCI device for any device which is a memory of the
|
||||
* Intelligent, I2O class or an Adaptec Zero Channel Controller. We
|
||||
* attempt to set up each such device and register it with the core.
|
||||
*
|
||||
* Returns 0 on success or negative error code on failure.
|
||||
*/
|
||||
static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
{
|
||||
struct i2o_controller *c;
|
||||
int rc;
|
||||
struct pci_dev *i960 = NULL;
|
||||
|
||||
printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
|
||||
|
||||
if ((pdev->class & 0xff) > 1) {
|
||||
printk(KERN_WARNING "i2o: %s does not support I2O 1.5 "
|
||||
"(skipping).\n", pci_name(pdev));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
rc = pci_enable_device(pdev);
|
||||
if (rc) {
|
||||
printk(KERN_WARNING "i2o: couldn't enable device %s\n",
|
||||
pci_name(pdev));
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
|
||||
printk(KERN_WARNING "i2o: no suitable DMA found for %s\n",
|
||||
pci_name(pdev));
|
||||
rc = -ENODEV;
|
||||
goto disable;
|
||||
}
|
||||
|
||||
pci_set_master(pdev);
|
||||
|
||||
c = i2o_iop_alloc();
|
||||
if (IS_ERR(c)) {
|
||||
printk(KERN_ERR "i2o: couldn't allocate memory for %s\n",
|
||||
pci_name(pdev));
|
||||
rc = PTR_ERR(c);
|
||||
goto disable;
|
||||
} else
|
||||
printk(KERN_INFO "%s: controller found (%s)\n", c->name,
|
||||
pci_name(pdev));
|
||||
|
||||
c->pdev = pdev;
|
||||
c->device.parent = &pdev->dev;
|
||||
|
||||
/* Cards that fall apart if you hit them with large I/O loads... */
|
||||
if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) {
|
||||
c->short_req = 1;
|
||||
printk(KERN_INFO "%s: Symbios FC920 workarounds activated.\n",
|
||||
c->name);
|
||||
}
|
||||
|
||||
if (pdev->subsystem_vendor == PCI_VENDOR_ID_PROMISE) {
|
||||
/*
|
||||
* Expose the ship behind i960 for initialization, or it will
|
||||
* failed
|
||||
*/
|
||||
i960 = pci_get_slot(c->pdev->bus,
|
||||
PCI_DEVFN(PCI_SLOT(c->pdev->devfn), 0));
|
||||
|
||||
if (i960) {
|
||||
pci_write_config_word(i960, 0x42, 0);
|
||||
pci_dev_put(i960);
|
||||
}
|
||||
|
||||
c->promise = 1;
|
||||
c->limit_sectors = 1;
|
||||
}
|
||||
|
||||
if (pdev->subsystem_vendor == PCI_VENDOR_ID_DPT)
|
||||
c->adaptec = 1;
|
||||
|
||||
/* Cards that go bananas if you quiesce them before you reset them. */
|
||||
if (pdev->vendor == PCI_VENDOR_ID_DPT) {
|
||||
c->no_quiesce = 1;
|
||||
if (pdev->device == 0xa511)
|
||||
c->raptor = 1;
|
||||
|
||||
if (pdev->subsystem_device == 0xc05a) {
|
||||
c->limit_sectors = 1;
|
||||
printk(KERN_INFO
|
||||
"%s: limit sectors per request to %d\n", c->name,
|
||||
I2O_MAX_SECTORS_LIMITED);
|
||||
}
|
||||
#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
|
||||
if (sizeof(dma_addr_t) > 4) {
|
||||
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
|
||||
printk(KERN_INFO "%s: 64-bit DMA unavailable\n",
|
||||
c->name);
|
||||
else {
|
||||
c->pae_support = 1;
|
||||
printk(KERN_INFO "%s: using 64-bit DMA\n",
|
||||
c->name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
rc = i2o_pci_alloc(c);
|
||||
if (rc) {
|
||||
printk(KERN_ERR "%s: DMA / IO allocation for I2O controller "
|
||||
"failed\n", c->name);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
if (i2o_pci_irq_enable(c)) {
|
||||
printk(KERN_ERR "%s: unable to enable interrupts for I2O "
|
||||
"controller\n", c->name);
|
||||
goto free_pci;
|
||||
}
|
||||
|
||||
rc = i2o_iop_add(c);
|
||||
if (rc)
|
||||
goto uninstall;
|
||||
|
||||
if (i960)
|
||||
pci_write_config_word(i960, 0x42, 0x03ff);
|
||||
|
||||
return 0;
|
||||
|
||||
uninstall:
|
||||
i2o_pci_irq_disable(c);
|
||||
|
||||
free_pci:
|
||||
i2o_pci_free(c);
|
||||
|
||||
free_controller:
|
||||
i2o_iop_free(c);
|
||||
|
||||
disable:
|
||||
pci_disable_device(pdev);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* i2o_pci_remove - Removes a I2O controller from the system
|
||||
* @pdev: I2O controller which should be removed
|
||||
*
|
||||
* Reset the I2O controller, disable interrupts and remove all allocated
|
||||
* resources.
|
||||
*/
|
||||
static void i2o_pci_remove(struct pci_dev *pdev)
|
||||
{
|
||||
struct i2o_controller *c;
|
||||
c = pci_get_drvdata(pdev);
|
||||
|
||||
i2o_iop_remove(c);
|
||||
i2o_pci_irq_disable(c);
|
||||
i2o_pci_free(c);
|
||||
|
||||
pci_disable_device(pdev);
|
||||
|
||||
printk(KERN_INFO "%s: Controller removed.\n", c->name);
|
||||
|
||||
put_device(&c->device);
|
||||
};
|
||||
|
||||
/* PCI driver for I2O controller */
|
||||
static struct pci_driver i2o_pci_driver = {
|
||||
.name = "PCI_I2O",
|
||||
.id_table = i2o_pci_ids,
|
||||
.probe = i2o_pci_probe,
|
||||
.remove = i2o_pci_remove,
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_pci_init - registers I2O PCI driver in PCI subsystem
|
||||
*
|
||||
* Returns > 0 on success or negative error code on failure.
|
||||
*/
|
||||
int __init i2o_pci_init(void)
|
||||
{
|
||||
return pci_register_driver(&i2o_pci_driver);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2o_pci_exit - unregisters I2O PCI driver from PCI subsystem
|
||||
*/
|
||||
void __exit i2o_pci_exit(void)
|
||||
{
|
||||
pci_unregister_driver(&i2o_pci_driver);
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(pci, i2o_pci_ids);
|
Loading…
Reference in New Issue
Block a user