xref: /freebsd/sys/dev/isp/isp_target.h (revision 15c62456d1eef7edbefa3d898132338fc8d74cdc)
10615a547SMatt Jacob /* $FreeBSD$ */
2098ca2bdSWarner Losh /*-
32df76c16SMatt Jacob  *  Copyright (c) 1997-2009 by Matthew Jacob
40615a547SMatt Jacob  *  All rights reserved.
50615a547SMatt Jacob  *
60615a547SMatt Jacob  *  Redistribution and use in source and binary forms, with or without
70615a547SMatt Jacob  *  modification, are permitted provided that the following conditions
80615a547SMatt Jacob  *  are met:
90615a547SMatt Jacob  *
10e48b2487SMatt Jacob  *  1. Redistributions of source code must retain the above copyright
11e48b2487SMatt Jacob  *     notice, this list of conditions and the following disclaimer.
12e48b2487SMatt Jacob  *  2. Redistributions in binary form must reproduce the above copyright
13e48b2487SMatt Jacob  *     notice, this list of conditions and the following disclaimer in the
14e48b2487SMatt Jacob  *     documentation and/or other materials provided with the distribution.
15e48b2487SMatt Jacob  *
16e48b2487SMatt Jacob  *  THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
170615a547SMatt Jacob  *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
180615a547SMatt Jacob  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19e48b2487SMatt Jacob  *  ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20e48b2487SMatt Jacob  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
210615a547SMatt Jacob  *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22e5265237SMatt Jacob  *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23e5265237SMatt Jacob  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
240615a547SMatt Jacob  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
250615a547SMatt Jacob  *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
260615a547SMatt Jacob  *  SUCH DAMAGE.
272df76c16SMatt Jacob  *
28e48b2487SMatt Jacob  */
29e48b2487SMatt Jacob /*
30e48b2487SMatt Jacob  * Qlogic Target Mode Structure and Flag Definitions
310615a547SMatt Jacob  */
32f5a44627SMatt Jacob #ifndef	_ISP_TARGET_H
33f5a44627SMatt Jacob #define	_ISP_TARGET_H
340615a547SMatt Jacob 
350615a547SMatt Jacob /*
362df76c16SMatt Jacob  * Notify structure- these are for asynchronous events that need to be sent
372df76c16SMatt Jacob  * as notifications to the outer layer. It should be pretty self-explanatory.
380615a547SMatt Jacob  */
392df76c16SMatt Jacob typedef enum {
402df76c16SMatt Jacob 	NT_UNKNOWN=0x999,
412df76c16SMatt Jacob 	NT_ABORT_TASK=0x1000,
422df76c16SMatt Jacob 	NT_ABORT_TASK_SET,
432df76c16SMatt Jacob 	NT_CLEAR_ACA,
442df76c16SMatt Jacob 	NT_CLEAR_TASK_SET,
452df76c16SMatt Jacob 	NT_LUN_RESET,
462df76c16SMatt Jacob 	NT_TARGET_RESET,
472df76c16SMatt Jacob 	NT_BUS_RESET,
482df76c16SMatt Jacob 	NT_LIP_RESET,
492df76c16SMatt Jacob 	NT_LINK_UP,
502df76c16SMatt Jacob 	NT_LINK_DOWN,
512df76c16SMatt Jacob 	NT_LOGOUT,
522df76c16SMatt Jacob 	NT_GLOBAL_LOGOUT,
53387d8239SMatt Jacob 	NT_CHANGED,
54c98d2b1fSAlexander Motin 	NT_HBA_RESET,
55c98d2b1fSAlexander Motin 	NT_QUERY_TASK_SET,
56c98d2b1fSAlexander Motin 	NT_QUERY_ASYNC_EVENT
572df76c16SMatt Jacob } isp_ncode_t;
580615a547SMatt Jacob 
592df76c16SMatt Jacob typedef struct isp_notify {
602df76c16SMatt Jacob 	void *		nt_hba;		/* HBA tag */
612df76c16SMatt Jacob 	void *		nt_tmd;
622df76c16SMatt Jacob 	void *		nt_lreserved;
632df76c16SMatt Jacob 	void *		nt_hreserved;
642df76c16SMatt Jacob 	uint64_t	nt_wwn;		/* source (wwn) */
652df76c16SMatt Jacob 	uint64_t	nt_tgt;		/* destination (wwn) */
662df76c16SMatt Jacob 	uint64_t	nt_tagval;	/* tag value */
67*15c62456SAlexander Motin 	lun_id_t	nt_lun;		/* logical unit */
682df76c16SMatt Jacob 	uint32_t
692df76c16SMatt Jacob 			nt_sid		: 24;	/* source port id */
702df76c16SMatt Jacob 	uint32_t
712df76c16SMatt Jacob 			nt_failed	: 1,	/* notify operation failed */
722df76c16SMatt Jacob 			nt_need_ack	: 1,	/* this notify needs an ACK */
732df76c16SMatt Jacob 			nt_did		: 24;	/* destination port id */
74*15c62456SAlexander Motin 	uint16_t	nt_nphdl;	/* n-port handle */
752df76c16SMatt Jacob 	uint8_t		nt_channel;	/* channel id */
762df76c16SMatt Jacob 	isp_ncode_t	nt_ncode;	/* action */
772df76c16SMatt Jacob } isp_notify_t;
782df76c16SMatt Jacob #define MATCH_TMD(tmd, iid, lun, tag)                   \
792df76c16SMatt Jacob     (                                                   \
802df76c16SMatt Jacob         (tmd) &&                                        \
812df76c16SMatt Jacob         (iid == INI_ANY || iid == tmd->cd_iid) &&       \
822df76c16SMatt Jacob         (lun == LUN_ANY || lun == tmd->cd_lun) &&       \
832df76c16SMatt Jacob         (tag == TAG_ANY || tag == tmd->cd_tagval)       \
842df76c16SMatt Jacob     )
8510365e5aSMatt Jacob /*
860615a547SMatt Jacob  * Debug macros
870615a547SMatt Jacob  */
880615a547SMatt Jacob 
890615a547SMatt Jacob #define	ISP_TDQE(isp, msg, idx, arg)	\
9069fbe07aSMatt Jacob     if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg)
910615a547SMatt Jacob 
920615a547SMatt Jacob /*
932df76c16SMatt Jacob  * Special Constatns
940615a547SMatt Jacob  */
952df76c16SMatt Jacob #define INI_ANY			((uint64_t) -1)
962df76c16SMatt Jacob #define VALID_INI(ini)		(ini != INI_NONE && ini != INI_ANY)
972df76c16SMatt Jacob #define LUN_ANY     		0xffff
982df76c16SMatt Jacob #define TGT_ANY     		((uint64_t) -1)
992df76c16SMatt Jacob #define TAG_ANY     		((uint64_t) 0)
100f5a44627SMatt Jacob #endif	/* _ISP_TARGET_H */
101