mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +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.
189 lines
6.0 KiB
C
189 lines
6.0 KiB
C
/*-
|
|
* Copyright 2009 Scott Long
|
|
* 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_XPT_INTERNAL_H
|
|
#define _CAM_CAM_XPT_INTERNAL_H 1
|
|
|
|
/* Forward Declarations */
|
|
struct cam_eb;
|
|
struct cam_et;
|
|
struct cam_ed;
|
|
|
|
typedef struct cam_ed * (*xpt_alloc_device_func)(struct cam_eb *bus,
|
|
struct cam_et *target,
|
|
lun_id_t lun_id);
|
|
typedef void (*xpt_release_device_func)(struct cam_ed *device);
|
|
typedef void (*xpt_action_func)(union ccb *start_ccb);
|
|
typedef void (*xpt_dev_async_func)(u_int32_t async_code,
|
|
struct cam_eb *bus,
|
|
struct cam_et *target,
|
|
struct cam_ed *device,
|
|
void *async_arg);
|
|
typedef void (*xpt_announce_periph_func)(struct cam_periph *periph);
|
|
|
|
struct xpt_xport {
|
|
xpt_alloc_device_func alloc_device;
|
|
xpt_release_device_func reldev;
|
|
xpt_action_func action;
|
|
xpt_dev_async_func async;
|
|
xpt_announce_periph_func announce;
|
|
};
|
|
|
|
/*
|
|
* Structure for queueing a device in a run queue.
|
|
* There is one run queue for allocating new ccbs,
|
|
* and another for sending ccbs to the controller.
|
|
*/
|
|
struct cam_ed_qinfo {
|
|
cam_pinfo pinfo;
|
|
struct cam_ed *device;
|
|
};
|
|
|
|
/*
|
|
* The CAM EDT (Existing Device Table) contains the device information for
|
|
* all devices for all busses in the system. The table contains a
|
|
* cam_ed structure for each device on the bus.
|
|
*/
|
|
struct cam_ed {
|
|
TAILQ_ENTRY(cam_ed) links;
|
|
struct cam_ed_qinfo alloc_ccb_entry;
|
|
struct cam_ed_qinfo send_ccb_entry;
|
|
struct cam_et *target;
|
|
struct cam_sim *sim;
|
|
lun_id_t lun_id;
|
|
struct camq drvq; /*
|
|
* Queue of type drivers wanting to do
|
|
* work on this device.
|
|
*/
|
|
struct cam_ccbq ccbq; /* Queue of pending ccbs */
|
|
struct async_list asyncs; /* Async callback info for this B/T/L */
|
|
struct periph_list periphs; /* All attached devices */
|
|
u_int generation; /* Generation number */
|
|
struct cam_periph *owner; /* Peripheral driver's ownership tag */
|
|
void *quirk; /* Oddities about this device */
|
|
u_int maxtags;
|
|
u_int mintags;
|
|
cam_proto protocol;
|
|
u_int protocol_version;
|
|
cam_xport transport;
|
|
u_int transport_version;
|
|
struct scsi_inquiry_data inq_data;
|
|
uint8_t *supported_vpds;
|
|
uint8_t supported_vpds_len;
|
|
uint32_t device_id_len;
|
|
uint8_t *device_id;
|
|
struct ata_params ident_data;
|
|
u_int8_t inq_flags; /*
|
|
* Current settings for inquiry flags.
|
|
* This allows us to override settings
|
|
* like disconnection and tagged
|
|
* queuing for a device.
|
|
*/
|
|
u_int8_t queue_flags; /* Queue flags from the control page */
|
|
u_int8_t serial_num_len;
|
|
u_int8_t *serial_num;
|
|
u_int32_t flags;
|
|
#define CAM_DEV_UNCONFIGURED 0x01
|
|
#define CAM_DEV_REL_TIMEOUT_PENDING 0x02
|
|
#define CAM_DEV_REL_ON_COMPLETE 0x04
|
|
#define CAM_DEV_REL_ON_QUEUE_EMPTY 0x08
|
|
#define CAM_DEV_RESIZE_QUEUE_NEEDED 0x10
|
|
#define CAM_DEV_TAG_AFTER_COUNT 0x20
|
|
#define CAM_DEV_INQUIRY_DATA_VALID 0x40
|
|
#define CAM_DEV_IN_DV 0x80
|
|
#define CAM_DEV_DV_HIT_BOTTOM 0x100
|
|
#define CAM_DEV_IDENTIFY_DATA_VALID 0x200
|
|
u_int32_t tag_delay_count;
|
|
#define CAM_TAG_DELAY_COUNT 5
|
|
u_int32_t tag_saved_openings;
|
|
u_int32_t refcount;
|
|
struct callout callout;
|
|
};
|
|
|
|
/*
|
|
* Each target is represented by an ET (Existing Target). These
|
|
* entries are created when a target is successfully probed with an
|
|
* identify, and removed when a device fails to respond after a number
|
|
* of retries, or a bus rescan finds the device missing.
|
|
*/
|
|
struct cam_et {
|
|
TAILQ_HEAD(, cam_ed) ed_entries;
|
|
TAILQ_ENTRY(cam_et) links;
|
|
struct cam_eb *bus;
|
|
target_id_t target_id;
|
|
u_int32_t refcount;
|
|
u_int generation;
|
|
struct timeval last_reset;
|
|
u_int rpl_size;
|
|
struct scsi_report_luns_data *luns;
|
|
};
|
|
|
|
/*
|
|
* Each bus is represented by an EB (Existing Bus). These entries
|
|
* are created by calls to xpt_bus_register and deleted by calls to
|
|
* xpt_bus_deregister.
|
|
*/
|
|
struct cam_eb {
|
|
TAILQ_HEAD(, cam_et) et_entries;
|
|
TAILQ_ENTRY(cam_eb) links;
|
|
path_id_t path_id;
|
|
struct cam_sim *sim;
|
|
struct timeval last_reset;
|
|
u_int32_t flags;
|
|
#define CAM_EB_RUNQ_SCHEDULED 0x01
|
|
u_int32_t refcount;
|
|
u_int generation;
|
|
device_t parent_dev;
|
|
struct xpt_xport *xport;
|
|
};
|
|
|
|
struct cam_path {
|
|
struct cam_periph *periph;
|
|
struct cam_eb *bus;
|
|
struct cam_et *target;
|
|
struct cam_ed *device;
|
|
};
|
|
|
|
struct xpt_xport * scsi_get_xport(void);
|
|
struct xpt_xport * ata_get_xport(void);
|
|
|
|
struct cam_ed * xpt_alloc_device(struct cam_eb *bus,
|
|
struct cam_et *target,
|
|
lun_id_t lun_id);
|
|
void xpt_acquire_device(struct cam_ed *device);
|
|
void xpt_release_device(struct cam_ed *device);
|
|
int xpt_schedule_dev(struct camq *queue, cam_pinfo *dev_pinfo,
|
|
u_int32_t new_priority);
|
|
u_int32_t xpt_dev_ccbq_resize(struct cam_path *path, int newopenings);
|
|
void xpt_start_tags(struct cam_path *path);
|
|
void xpt_stop_tags(struct cam_path *path);
|
|
|
|
MALLOC_DECLARE(M_CAMXPT);
|
|
|
|
#endif
|