isp_target.h revision 240015
1230557Sjimharris/* $FreeBSD: stable/9/sys/dev/isp/isp_target.h 240015 2012-09-02 15:03:40Z mjacob $ */
2230557Sjimharris/*-
3230557Sjimharris *  Copyright (c) 1997-2009 by Matthew Jacob
4230557Sjimharris *  All rights reserved.
5230557Sjimharris *
6230557Sjimharris *  Redistribution and use in source and binary forms, with or without
7230557Sjimharris *  modification, are permitted provided that the following conditions
8230557Sjimharris *  are met:
9230557Sjimharris *
10230557Sjimharris *  1. Redistributions of source code must retain the above copyright
11230557Sjimharris *     notice, this list of conditions and the following disclaimer.
12230557Sjimharris *  2. Redistributions in binary form must reproduce the above copyright
13230557Sjimharris *     notice, this list of conditions and the following disclaimer in the
14230557Sjimharris *     documentation and/or other materials provided with the distribution.
15230557Sjimharris *
16230557Sjimharris *  THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17230557Sjimharris *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18230557Sjimharris *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19230557Sjimharris *  ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20230557Sjimharris *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21230557Sjimharris *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22230557Sjimharris *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23230557Sjimharris *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24230557Sjimharris *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25230557Sjimharris *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26230557Sjimharris *  SUCH DAMAGE.
27230557Sjimharris *
28230557Sjimharris */
29230557Sjimharris/*
30230557Sjimharris * Qlogic Target Mode Structure and Flag Definitions
31230557Sjimharris */
32230557Sjimharris#ifndef	_ISP_TARGET_H
33230557Sjimharris#define	_ISP_TARGET_H
34230557Sjimharris
35230557Sjimharris/*
36230557Sjimharris * Notify structure- these are for asynchronous events that need to be sent
37230557Sjimharris * as notifications to the outer layer. It should be pretty self-explanatory.
38230557Sjimharris */
39230557Sjimharristypedef enum {
40230557Sjimharris	NT_UNKNOWN=0x999,
41230557Sjimharris	NT_ABORT_TASK=0x1000,
42230557Sjimharris	NT_ABORT_TASK_SET,
43230557Sjimharris	NT_CLEAR_ACA,
44230557Sjimharris	NT_CLEAR_TASK_SET,
45230557Sjimharris	NT_LUN_RESET,
46230557Sjimharris	NT_TARGET_RESET,
47230557Sjimharris	NT_BUS_RESET,
48230557Sjimharris	NT_LIP_RESET,
49230557Sjimharris	NT_LINK_UP,
50230557Sjimharris	NT_LINK_DOWN,
51230557Sjimharris	NT_LOGOUT,
52230557Sjimharris	NT_GLOBAL_LOGOUT,
53230557Sjimharris	NT_CHANGED,
54230557Sjimharris	NT_ARRIVED,
55230557Sjimharris	NT_DEPARTED,
56230557Sjimharris	NT_HBA_RESET
57230557Sjimharris} isp_ncode_t;
58230557Sjimharris
59230557Sjimharristypedef struct isp_notify {
60230557Sjimharris	void *		nt_hba;		/* HBA tag */
61230557Sjimharris	void *		nt_tmd;
62230557Sjimharris	void *		nt_lreserved;
63230557Sjimharris	void *		nt_hreserved;
64230557Sjimharris	uint64_t	nt_wwn;		/* source (wwn) */
65230557Sjimharris	uint64_t	nt_tgt;		/* destination (wwn) */
66230557Sjimharris	uint64_t	nt_tagval;	/* tag value */
67230557Sjimharris	uint32_t
68230557Sjimharris			nt_sid		: 24;	/* source port id */
69230557Sjimharris	uint32_t
70230557Sjimharris			nt_failed	: 1,	/* notify operation failed */
71230557Sjimharris			nt_need_ack	: 1,	/* this notify needs an ACK */
72230557Sjimharris			nt_did		: 24;	/* destination port id */
73230557Sjimharris	uint32_t
74230557Sjimharris			nt_lun		: 16,	/* logical unit */
75230557Sjimharris			nt_nphdl  	: 16;	/* n-port handle */
76230557Sjimharris	uint8_t		nt_channel;		/* channel id */
77230557Sjimharris	isp_ncode_t	nt_ncode;	/* action */
78230557Sjimharris} isp_notify_t;
79230557Sjimharris#define MATCH_TMD(tmd, iid, lun, tag)                   \
80230557Sjimharris    (                                                   \
81230557Sjimharris        (tmd) &&                                        \
82230557Sjimharris        (iid == INI_ANY || iid == tmd->cd_iid) &&       \
83230557Sjimharris        (lun == LUN_ANY || lun == tmd->cd_lun) &&       \
84230557Sjimharris        (tag == TAG_ANY || tag == tmd->cd_tagval)       \
85230557Sjimharris    )
86230557Sjimharris/*
87230557Sjimharris * Debug macros
88230557Sjimharris */
89230557Sjimharris
90230557Sjimharris#define	ISP_TDQE(isp, msg, idx, arg)	\
91230557Sjimharris    if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg)
92230557Sjimharris
93230557Sjimharris/*
94230557Sjimharris * Special Constatns
95230557Sjimharris */
96230557Sjimharris#define INI_ANY			((uint64_t) -1)
97230557Sjimharris#define VALID_INI(ini)		(ini != INI_NONE && ini != INI_ANY)
98230557Sjimharris#define LUN_ANY     		0xffff
99230557Sjimharris#define TGT_ANY     		((uint64_t) -1)
100230557Sjimharris#define TAG_ANY     		((uint64_t) 0)
101230557Sjimharris#endif	/* _ISP_TARGET_H */
102230557Sjimharris