1139743Simp/*-
2107178Snjl * Ioctl definitions for the SCSI Target Driver
339213Sgibbs *
4107178Snjl * Copyright (c) 2002 Nate Lawson.
539213Sgibbs * Copyright (c) 1998 Justin T. Gibbs.
639213Sgibbs * All rights reserved.
739213Sgibbs *
839213Sgibbs * Redistribution and use in source and binary forms, with or without
939213Sgibbs * modification, are permitted provided that the following conditions
1039213Sgibbs * are met:
1139213Sgibbs * 1. Redistributions of source code must retain the above copyright
1239213Sgibbs *    notice, this list of conditions, and the following disclaimer,
1339213Sgibbs *    without modification, immediately at the beginning of the file.
1439213Sgibbs * 2. The name of the author may not be used to endorse or promote products
1539213Sgibbs *    derived from this software without specific prior written permission.
1639213Sgibbs *
1739213Sgibbs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1839213Sgibbs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1939213Sgibbs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2039213Sgibbs * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
2139213Sgibbs * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2239213Sgibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2339213Sgibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2439213Sgibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2539213Sgibbs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2639213Sgibbs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2739213Sgibbs * SUCH DAMAGE.
2839213Sgibbs *
2950477Speter * $FreeBSD$
3039213Sgibbs */
3139213Sgibbs
3239213Sgibbs#ifndef _CAM_SCSI_SCSI_TARGETIO_H_
3339213Sgibbs#define _CAM_SCSI_SCSI_TARGETIO_H_
3455205Speter#ifndef _KERNEL
3539213Sgibbs#include <sys/types.h>
3639213Sgibbs#endif
3739213Sgibbs#include <sys/ioccom.h>
3839213Sgibbs
3939213Sgibbs#include <cam/cam.h>
4039213Sgibbs#include <cam/cam_ccb.h>
4139213Sgibbs
4239213Sgibbs/*
43107178Snjl * CCBs (ATIO, CTIO, INOT, REL_SIMQ) are sent to the kernel driver
44107178Snjl * by writing one or more pointers.  The user receives notification
45107178Snjl * of CCB completion through poll/select/kqueue and then calls
46107178Snjl * read(2) which outputs pointers to the completed CCBs.
4739213Sgibbs */
4839213Sgibbs
4939213Sgibbs/*
50107178Snjl * Enable and disable a target mode instance.  For enabling, the path_id,
51107178Snjl * target_id, and lun_id fields must be set.  The grp6/7_len fields
52107178Snjl * specify the length of vendor-specific CDBs the target expects and
53107178Snjl * should normally be set to 0.  On successful completion
54107178Snjl * of enable, the specified target instance will answer selection.
55107178Snjl * Disable causes the target instance to abort any outstanding commands
56107178Snjl * and stop accepting new ones.  The aborted CCBs will be returned to
57107178Snjl * the user via read(2) or discarded if the user closes the device.
58107178Snjl * The user can then re-enable the device for a new path.
5939213Sgibbs */
60107178Snjlstruct ioc_enable_lun {
6180574Smjacob	path_id_t	path_id;
6280574Smjacob	target_id_t	target_id;
6380574Smjacob	lun_id_t	lun_id;
64107178Snjl	int		grp6_len;
65107178Snjl	int		grp7_len;
6680574Smjacob};
67107178Snjl#define TARGIOCENABLE	_IOW('C', 5, struct ioc_enable_lun)
68107178Snjl#define TARGIOCDISABLE	 _IO('C', 6)
6980574Smjacob
7044504Sgibbs/*
7163173Smjacob * Set/clear debugging for this target mode instance
7263173Smjacob */
73107178Snjl#define	TARGIOCDEBUG	_IOW('C', 7, int)
7480576Smjacob
75107178SnjlTAILQ_HEAD(ccb_queue, ccb_hdr);
76107178Snjl
7739213Sgibbs#endif /* _CAM_SCSI_SCSI_TARGETIO_H_ */
78