• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/scsi/bfa/include/protocol/
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __FCPPROTO_H__
19#define __FCPPROTO_H__
20
21#include <linux/bitops.h>
22#include <protocol/scsi.h>
23
24#pragma pack(1)
25
26enum {
27	FCP_RJT		= 0x01000000,	/* SRR reject */
28	FCP_SRR_ACCEPT	= 0x02000000,	/* SRR accept */
29	FCP_SRR		= 0x14000000,	/* Sequence Retransmission Request */
30};
31
32/*
33 * SRR FC-4 LS payload
34 */
35struct fc_srr_s{
36	u32	ls_cmd;
37	u32        ox_id:16;	/* ox-id */
38	u32        rx_id:16;	/* rx-id */
39	u32        ro;		/* relative offset */
40	u32        r_ctl:8;		/* R_CTL for I.U. */
41	u32        res:24;
42};
43
44
45/*
46 * FCP_CMND definitions
47 */
48#define FCP_CMND_CDB_LEN    16
49#define FCP_CMND_LUN_LEN    8
50
51struct fcp_cmnd_s{
52	lun_t           lun;		/* 64-bit LU number */
53	u8         crn;		/* command reference number */
54#ifdef __BIGENDIAN
55	u8         resvd:1,
56			priority:4,	/* FCP-3: SAM-3 priority */
57			taskattr:3;	/* scsi task attribute */
58#else
59	u8         taskattr:3,	/* scsi task attribute */
60			priority:4,	/* FCP-3: SAM-3 priority */
61			resvd:1;
62#endif
63	u8         tm_flags;	/* task management flags */
64#ifdef __BIGENDIAN
65	u8         addl_cdb_len:6,	/* additional CDB length words */
66			iodir:2;	/* read/write FCP_DATA IUs */
67#else
68	u8         iodir:2,	/* read/write FCP_DATA IUs */
69			addl_cdb_len:6;	/* additional CDB length */
70#endif
71	struct scsi_cdb_s      cdb;
72
73	/*
74	 * !!! additional cdb bytes follows here!!!
75	 */
76	u32        fcp_dl;	/* bytes to be transferred */
77};
78
79#define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
80#define fcp_cmnd_fcpdl(_cmnd)	((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
81
82/*
83 * fcp_cmnd_t.iodir field values
84 */
85enum fcp_iodir{
86	FCP_IODIR_NONE	= 0,
87	FCP_IODIR_WRITE = 1,
88	FCP_IODIR_READ	= 2,
89	FCP_IODIR_RW	= 3,
90};
91
92/*
93 * Task attribute field
94 */
95enum {
96	FCP_TASK_ATTR_SIMPLE	= 0,
97	FCP_TASK_ATTR_HOQ	= 1,
98	FCP_TASK_ATTR_ORDERED	= 2,
99	FCP_TASK_ATTR_ACA	= 4,
100	FCP_TASK_ATTR_UNTAGGED	= 5,	/* obsolete in FCP-3 */
101};
102
103/*
104 * Task management flags field - only one bit shall be set
105 */
106enum fcp_tm_cmnd{
107	FCP_TM_ABORT_TASK_SET	= BIT(1),
108	FCP_TM_CLEAR_TASK_SET	= BIT(2),
109	FCP_TM_LUN_RESET	= BIT(4),
110	FCP_TM_TARGET_RESET	= BIT(5),	/* obsolete in FCP-3 */
111	FCP_TM_CLEAR_ACA	= BIT(6),
112};
113
114/*
115 * FCP_XFER_RDY IU defines
116 */
117struct fcp_xfer_rdy_s{
118	u32        data_ro;
119	u32        burst_len;
120	u32        reserved;
121};
122
123/*
124 * FCP_RSP residue flags
125 */
126enum fcp_residue{
127	FCP_NO_RESIDUE = 0,	/* no residue */
128	FCP_RESID_OVER = 1,	/* more data left that was not sent */
129	FCP_RESID_UNDER = 2,	/* less data than requested */
130};
131
132enum {
133	FCP_RSPINFO_GOOD = 0,
134	FCP_RSPINFO_DATALEN_MISMATCH = 1,
135	FCP_RSPINFO_CMND_INVALID = 2,
136	FCP_RSPINFO_ROLEN_MISMATCH = 3,
137	FCP_RSPINFO_TM_NOT_SUPP = 4,
138	FCP_RSPINFO_TM_FAILED = 5,
139};
140
141struct fcp_rspinfo_s{
142	u32        res0:24;
143	u32        rsp_code:8;	/* response code (as above) */
144	u32        res1;
145};
146
147struct fcp_resp_s{
148	u32        reserved[2];	/* 2 words reserved */
149	u16        reserved2;
150#ifdef __BIGENDIAN
151	u8         reserved3:3;
152	u8         fcp_conf_req:1;	/* FCP_CONF is requested */
153	u8         resid_flags:2;	/* underflow/overflow */
154	u8         sns_len_valid:1;/* sense len is valid */
155	u8         rsp_len_valid:1;/* response len is valid */
156#else
157	u8         rsp_len_valid:1;/* response len is valid */
158	u8         sns_len_valid:1;/* sense len is valid */
159	u8         resid_flags:2;	/* underflow/overflow */
160	u8         fcp_conf_req:1;	/* FCP_CONF is requested */
161	u8         reserved3:3;
162#endif
163	u8         scsi_status;	/* one byte SCSI status */
164	u32        residue;	/* residual data bytes */
165	u32        sns_len;	/* length od sense info */
166	u32        rsp_len;	/* length of response info */
167};
168
169#define fcp_snslen(__fcprsp)	((__fcprsp)->sns_len_valid ? 		\
170					(__fcprsp)->sns_len : 0)
171#define fcp_rsplen(__fcprsp)	((__fcprsp)->rsp_len_valid ? 		\
172					(__fcprsp)->rsp_len : 0)
173#define fcp_rspinfo(__fcprsp)	((struct fcp_rspinfo_s *)((__fcprsp) + 1))
174#define fcp_snsinfo(__fcprsp)	(((u8 *)fcp_rspinfo(__fcprsp)) + 	\
175						fcp_rsplen(__fcprsp))
176
177struct fcp_cmnd_fr_s{
178	struct fchs_s          fchs;
179	struct fcp_cmnd_s      fcp;
180};
181
182#pragma pack()
183
184#endif
185