mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
06e794928b
This includes support in the kernel, camcontrol(8), libcam and the mps(4) driver for SMP passthrough. The CAM SCSI probe code has been modified to fetch Inquiry VPD page 0x00 to determine supported pages, and will now fetch page 0x83 in addition to page 0x80 if supported. Add two new CAM CCBs, XPT_SMP_IO, and XPT_GDEV_ADVINFO. The SMP CCB is intended for SMP requests and responses. The ADVINFO is currently used to fetch cached VPD page 0x83 data from the transport layer, but is intended to be extensible to fetch other types of device-specific data. SMP-only devices are not currently represented in the CAM topology, and so the current semantics are that the SIM will route SMP CCBs to either the addressed device, if it contains an SMP target, or its parent, if it contains an SMP target. (This is noted in cam_ccb.h, since it will change later once we have the ability to have SMP-only devices in CAM's topology.) smp_all.c, smp_all.h: New helper routines for SMP. This includes SMP request building routines, response parsing routines, error decoding routines, and structure definitions for a number of SMP commands. libcam/Makefile: Add smp_all.c to libcam, so that SMP functionality is available to userland applications. camcontrol.8, camcontrol.c: Add smp passthrough support to camcontrol. Several new subcommands are now available: 'smpcmd' functions much like 'cmd', except that it allows the user to send generic SMP commands. 'smprg' sends the SMP report general command, and displays the decoded output. It will automatically fetch extended output if it is available. 'smppc' sends the SMP phy control command, with any number of potential options. Among other things, this allows the user to reset a phy on a SAS expander, or disable a phy on an expander. 'smpmaninfo' sends the SMP report manufacturer information and displays the decoded output. 'smpphylist' displays a list of phys on an expander, and the CAM devices attached to those phys, if any. cam.h, cam.c: Add a status value for SMP errors (CAM_SMP_STATUS_ERROR). Add a missing description for CAM_SCSI_IT_NEXUS_LOST. Add support for SMP commands to cam_error_string(). cam_ccb.h: Rename the CAM_DIR_RESV flag to CAM_DIR_BOTH. SMP commands are by nature bi-directional, and we may need to support bi-directional SCSI commands later. Add the XPT_SMP_IO CCB. Since SMP commands are bi-directional, there are pointers for both the request and response. Add a fill routine for SMP CCBs. Add the XPT_GDEV_ADVINFO CCB. This is currently used to fetch cached page 0x83 data from the transport later, but is extensible to fetch many other types of data. cam_periph.c: Add support in cam_periph_mapmem() for XPT_SMP_IO and XPT_GDEV_ADVINFO CCBs. cam_xpt.c: Add support for executing XPT_SMP_IO CCBs. cam_xpt_internal.h: Add fields for VPD pages 0x00 and 0x83 in struct cam_ed. scsi_all.c: Add scsi_get_sas_addr(), a function that parses VPD page 0x83 data and pulls out a SAS address. scsi_all.h: Add VPD page 0x00 and 0x83 structures, and a prototype for scsi_get_sas_addr(). scsi_pass.c: Add support for mapping buffers in XPT_SMP_IO and XPT_GDEV_ADVINFO CCBs. scsi_xpt.c: In the SCSI probe code, first ask the device for VPD page 0x00. If any VPD pages are supported, that page is required to be implemented. Based on the response, we may probe for the serial number (page 0x80) or device id (page 0x83). Add support for the XPT_GDEV_ADVINFO CCB. sys/conf/files: Add smp_all.c. mps.c: Add support for passing in a uio in mps_map_command(), so we can map a S/G list at once. Add support for SMP passthrough commands in mps_data_cb(). SMP is a special case, because the first buffer in the S/G list is outbound and the second buffer is inbound. Add support for warning the user if the busdma code comes back with more buffers than will work for the command. This will, for example, help the user determine why an SMP command failed if busdma comes back with three buffers. mps_pci.c: Add sys/uio.h. mps_sas.c: Add the SAS address and the parent handle to the list of fields we pull from device page 0 and cache in struct mpssas_target. These are needed for SMP passthrough. Add support for the XPT_SMP_IO CCB. For now, this CCB is routed to the addressed device if it supports SMP, or to its parent if it does not and the parent does. This is necessary because CAM does not currently support SMP-only nodes in the topology. Make SMP passthrough support conditional on __FreeBSD_version >= 900026. This will make it easier to MFC this change to the driver without MFCing the CAM changes as well. mps_user.c: Un-staticize mpi_init_sge() so we can use it for the SMP passthrough code. mpsvar.h: Add a uio and iovecs into struct mps_command for SMP passthrough commands. Add a cm_max_segs field to struct mps_command so that we can warn the user if busdma comes back with too many segments. Clear the cm_reply when a command gets freed. If it is not cleared, reply frames will eventually get freed into the pool multiple times and corrupt the pool. (This fix is from scottl.) Add a prototype for mpi_init_sge(). sys/param.h: Bump __FreeBSD_version to 900026 for the for the inclusion of the XPT_GDEV_ADVINFO and XPT_SMP_IO CAM CCBs.
267 lines
8.8 KiB
C
267 lines
8.8 KiB
C
/*-
|
|
* Data structures and definitions for the CAM system.
|
|
*
|
|
* Copyright (c) 1997 Justin T. Gibbs.
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
* without modification, immediately at the beginning of the file.
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
* derived from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#ifndef _CAM_CAM_H
|
|
#define _CAM_CAM_H 1
|
|
|
|
#ifdef _KERNEL
|
|
#include <opt_cam.h>
|
|
#endif
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
typedef u_int path_id_t;
|
|
typedef u_int target_id_t;
|
|
typedef u_int lun_id_t;
|
|
|
|
#define CAM_XPT_PATH_ID ((path_id_t)~0)
|
|
#define CAM_BUS_WILDCARD ((path_id_t)~0)
|
|
#define CAM_TARGET_WILDCARD ((target_id_t)~0)
|
|
#define CAM_LUN_WILDCARD ((lun_id_t)~0)
|
|
|
|
/*
|
|
* Maximum length for a CAM CDB.
|
|
*/
|
|
#define CAM_MAX_CDBLEN 16
|
|
|
|
/*
|
|
* Definition of a CAM peripheral driver entry. Peripheral drivers instantiate
|
|
* one of these for each device they wish to communicate with and pass it into
|
|
* the xpt layer when they wish to schedule work on that device via the
|
|
* xpt_schedule API.
|
|
*/
|
|
struct cam_periph;
|
|
|
|
/*
|
|
* Priority information for a CAM structure.
|
|
*/
|
|
typedef enum {
|
|
CAM_RL_HOST,
|
|
CAM_RL_BUS,
|
|
CAM_RL_XPT,
|
|
CAM_RL_DEV,
|
|
CAM_RL_NORMAL,
|
|
CAM_RL_VALUES
|
|
} cam_rl;
|
|
/*
|
|
* The generation number is incremented everytime a new entry is entered into
|
|
* the queue giving round robin per priority level scheduling.
|
|
*/
|
|
typedef struct {
|
|
u_int32_t priority;
|
|
#define CAM_PRIORITY_HOST ((CAM_RL_HOST << 8) + 0x80)
|
|
#define CAM_PRIORITY_BUS ((CAM_RL_BUS << 8) + 0x80)
|
|
#define CAM_PRIORITY_XPT ((CAM_RL_XPT << 8) + 0x80)
|
|
#define CAM_PRIORITY_DEV ((CAM_RL_DEV << 8) + 0x80)
|
|
#define CAM_PRIORITY_NORMAL ((CAM_RL_NORMAL << 8) + 0x80)
|
|
#define CAM_PRIORITY_NONE (u_int32_t)-1
|
|
#define CAM_PRIORITY_TO_RL(x) ((x) >> 8)
|
|
u_int32_t generation;
|
|
int index;
|
|
#define CAM_UNQUEUED_INDEX -1
|
|
#define CAM_ACTIVE_INDEX -2
|
|
#define CAM_DONEQ_INDEX -3
|
|
} cam_pinfo;
|
|
|
|
/*
|
|
* Macro to compare two generation numbers. It is used like this:
|
|
*
|
|
* if (GENERATIONCMP(a, >=, b))
|
|
* ...;
|
|
*
|
|
* GERERATIONCMP uses modular arithmetic to guard against wraps
|
|
* wraps in the generation number.
|
|
*/
|
|
#define GENERATIONCMP(x, op, y) ((int32_t)((x) - (y)) op 0)
|
|
|
|
/* CAM flags XXX Move to cam_periph.h ??? */
|
|
typedef enum {
|
|
CAM_FLAG_NONE = 0x00,
|
|
CAM_EXPECT_INQ_CHANGE = 0x01,
|
|
CAM_RETRY_SELTO = 0x02 /* Retry Selection Timeouts */
|
|
} cam_flags;
|
|
|
|
/* CAM Status field values */
|
|
typedef enum {
|
|
CAM_REQ_INPROG, /* CCB request is in progress */
|
|
CAM_REQ_CMP, /* CCB request completed without error */
|
|
CAM_REQ_ABORTED, /* CCB request aborted by the host */
|
|
CAM_UA_ABORT, /* Unable to abort CCB request */
|
|
CAM_REQ_CMP_ERR, /* CCB request completed with an error */
|
|
CAM_BUSY, /* CAM subsystem is busy */
|
|
CAM_REQ_INVALID, /* CCB request was invalid */
|
|
CAM_PATH_INVALID, /* Supplied Path ID is invalid */
|
|
CAM_DEV_NOT_THERE, /* SCSI Device Not Installed/there */
|
|
CAM_UA_TERMIO, /* Unable to terminate I/O CCB request */
|
|
CAM_SEL_TIMEOUT, /* Target Selection Timeout */
|
|
CAM_CMD_TIMEOUT, /* Command timeout */
|
|
CAM_SCSI_STATUS_ERROR, /* SCSI error, look at error code in CCB */
|
|
CAM_MSG_REJECT_REC, /* Message Reject Received */
|
|
CAM_SCSI_BUS_RESET, /* SCSI Bus Reset Sent/Received */
|
|
CAM_UNCOR_PARITY, /* Uncorrectable parity error occurred */
|
|
CAM_AUTOSENSE_FAIL = 0x10,/* Autosense: request sense cmd fail */
|
|
CAM_NO_HBA, /* No HBA Detected error */
|
|
CAM_DATA_RUN_ERR, /* Data Overrun error */
|
|
CAM_UNEXP_BUSFREE, /* Unexpected Bus Free */
|
|
CAM_SEQUENCE_FAIL, /* Target Bus Phase Sequence Failure */
|
|
CAM_CCB_LEN_ERR, /* CCB length supplied is inadequate */
|
|
CAM_PROVIDE_FAIL, /* Unable to provide requested capability */
|
|
CAM_BDR_SENT, /* A SCSI BDR msg was sent to target */
|
|
CAM_REQ_TERMIO, /* CCB request terminated by the host */
|
|
CAM_UNREC_HBA_ERROR, /* Unrecoverable Host Bus Adapter Error */
|
|
CAM_REQ_TOO_BIG, /* The request was too large for this host */
|
|
CAM_REQUEUE_REQ, /*
|
|
* This request should be requeued to preserve
|
|
* transaction ordering. This typically occurs
|
|
* when the SIM recognizes an error that should
|
|
* freeze the queue and must place additional
|
|
* requests for the target at the sim level
|
|
* back into the XPT queue.
|
|
*/
|
|
CAM_ATA_STATUS_ERROR, /* ATA error, look at error code in CCB */
|
|
CAM_SCSI_IT_NEXUS_LOST, /* Initiator/Target Nexus lost. */
|
|
CAM_SMP_STATUS_ERROR, /* SMP error, look at error code in CCB */
|
|
CAM_IDE = 0x33, /* Initiator Detected Error */
|
|
CAM_RESRC_UNAVAIL, /* Resource Unavailable */
|
|
CAM_UNACKED_EVENT, /* Unacknowledged Event by Host */
|
|
CAM_MESSAGE_RECV, /* Message Received in Host Target Mode */
|
|
CAM_INVALID_CDB, /* Invalid CDB received in Host Target Mode */
|
|
CAM_LUN_INVALID, /* Lun supplied is invalid */
|
|
CAM_TID_INVALID, /* Target ID supplied is invalid */
|
|
CAM_FUNC_NOTAVAIL, /* The requested function is not available */
|
|
CAM_NO_NEXUS, /* Nexus is not established */
|
|
CAM_IID_INVALID, /* The initiator ID is invalid */
|
|
CAM_CDB_RECVD, /* The SCSI CDB has been received */
|
|
CAM_LUN_ALRDY_ENA, /* The LUN is already enabled for target mode */
|
|
CAM_SCSI_BUSY, /* SCSI Bus Busy */
|
|
|
|
CAM_DEV_QFRZN = 0x40, /* The DEV queue is frozen w/this err */
|
|
|
|
/* Autosense data valid for target */
|
|
CAM_AUTOSNS_VALID = 0x80,
|
|
CAM_RELEASE_SIMQ = 0x100,/* SIM ready to take more commands */
|
|
CAM_SIM_QUEUED = 0x200,/* SIM has this command in it's queue */
|
|
|
|
CAM_STATUS_MASK = 0x3F, /* Mask bits for just the status # */
|
|
|
|
/* Target Specific Adjunct Status */
|
|
CAM_SENT_SENSE = 0x40000000 /* sent sense with status */
|
|
} cam_status;
|
|
|
|
typedef enum {
|
|
CAM_ESF_NONE = 0x00,
|
|
CAM_ESF_COMMAND = 0x01,
|
|
CAM_ESF_CAM_STATUS = 0x02,
|
|
CAM_ESF_PROTO_STATUS = 0x04,
|
|
CAM_ESF_ALL = 0xff
|
|
} cam_error_string_flags;
|
|
|
|
typedef enum {
|
|
CAM_EPF_NONE = 0x00,
|
|
CAM_EPF_MINIMAL = 0x01,
|
|
CAM_EPF_NORMAL = 0x02,
|
|
CAM_EPF_ALL = 0x03,
|
|
CAM_EPF_LEVEL_MASK = 0x0f
|
|
/* All bits above bit 3 are protocol-specific */
|
|
} cam_error_proto_flags;
|
|
|
|
typedef enum {
|
|
CAM_ESF_PRINT_NONE = 0x00,
|
|
CAM_ESF_PRINT_STATUS = 0x10,
|
|
CAM_ESF_PRINT_SENSE = 0x20
|
|
} cam_error_scsi_flags;
|
|
|
|
typedef enum {
|
|
CAM_ESMF_PRINT_NONE = 0x00,
|
|
CAM_ESMF_PRINT_STATUS = 0x10,
|
|
CAM_ESMF_PRINT_FULL_CMD = 0x20,
|
|
} cam_error_smp_flags;
|
|
|
|
typedef enum {
|
|
CAM_EAF_PRINT_NONE = 0x00,
|
|
CAM_EAF_PRINT_STATUS = 0x10,
|
|
CAM_EAF_PRINT_RESULT = 0x20
|
|
} cam_error_ata_flags;
|
|
|
|
struct cam_status_entry
|
|
{
|
|
cam_status status_code;
|
|
const char *status_text;
|
|
};
|
|
|
|
extern const struct cam_status_entry cam_status_table[];
|
|
extern const int num_cam_status_entries;
|
|
union ccb;
|
|
|
|
#ifdef SYSCTL_DECL /* from sysctl.h */
|
|
SYSCTL_DECL(_kern_cam);
|
|
#endif
|
|
|
|
__BEGIN_DECLS
|
|
typedef int (cam_quirkmatch_t)(caddr_t, caddr_t);
|
|
|
|
caddr_t cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
|
|
int entry_size, cam_quirkmatch_t *comp_func);
|
|
|
|
void cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen);
|
|
|
|
int cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len);
|
|
const struct cam_status_entry*
|
|
cam_fetch_status_entry(cam_status status);
|
|
#ifdef _KERNEL
|
|
char * cam_error_string(union ccb *ccb, char *str, int str_len,
|
|
cam_error_string_flags flags,
|
|
cam_error_proto_flags proto_flags);
|
|
void cam_error_print(union ccb *ccb, cam_error_string_flags flags,
|
|
cam_error_proto_flags proto_flags);
|
|
#else /* _KERNEL */
|
|
struct cam_device;
|
|
|
|
char * cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
|
|
int str_len, cam_error_string_flags flags,
|
|
cam_error_proto_flags proto_flags);
|
|
void cam_error_print(struct cam_device *device, union ccb *ccb,
|
|
cam_error_string_flags flags,
|
|
cam_error_proto_flags proto_flags, FILE *ofile);
|
|
#endif /* _KERNEL */
|
|
__END_DECLS
|
|
|
|
#ifdef _KERNEL
|
|
static __inline void cam_init_pinfo(cam_pinfo *pinfo);
|
|
|
|
static __inline void cam_init_pinfo(cam_pinfo *pinfo)
|
|
{
|
|
pinfo->priority = CAM_PRIORITY_NONE;
|
|
pinfo->index = CAM_UNQUEUED_INDEX;
|
|
}
|
|
#endif
|
|
|
|
#endif /* _CAM_CAM_H */
|