Linux 2.6.17.7
[linux/fpc-iii.git] / drivers / fc4 / fcp_impl.h
blobc397c84bef635668f4e3e8c79e51de0695d43812
1 /* fcp_impl.h: Generic SCSI on top of FC4 - our interface defines.
3 * Copyright (C) 1997-1999 Jakub Jelinek (jj@ultra.linux.cz)
4 * Copyright (C) 1998 Jirka Hanika (geo@ff.cuni.cz)
5 */
7 #ifndef _FCP_SCSI_H
8 #define _FCP_SCSI_H
10 #include <linux/types.h>
11 #include "../scsi/scsi.h"
13 #include "fc.h"
14 #include "fcp.h"
15 #include "fc-al.h"
17 #include <asm/io.h>
18 #ifdef __sparc__
19 #include <asm/sbus.h>
20 #endif
22 /* 0 or 1 */
23 #define FCP_SCSI_USE_NEW_EH_CODE 0
25 #define FC_CLASS_OUTBOUND 0x01
26 #define FC_CLASS_INBOUND 0x02
27 #define FC_CLASS_SIMPLE 0x03
28 #define FC_CLASS_IO_WRITE 0x04
29 #define FC_CLASS_IO_READ 0x05
30 #define FC_CLASS_UNSOLICITED 0x06
31 #define FC_CLASS_OFFLINE 0x08
33 #define PROTO_OFFLINE 0x02
34 #define PROTO_REPORT_AL_MAP 0x03
35 #define PROTO_FORCE_LIP 0x06
37 struct _fc_channel;
39 typedef struct fcp_cmnd {
40 struct fcp_cmnd *next;
41 struct fcp_cmnd *prev;
42 void (*done)(Scsi_Cmnd *);
43 unsigned short proto;
44 unsigned short token;
45 unsigned int did;
46 /* FCP SCSI stuff */
47 dma_addr_t data;
48 /* From now on this cannot be touched for proto == TYPE_SCSI_FCP */
49 fc_hdr fch;
50 dma_addr_t cmd;
51 dma_addr_t rsp;
52 int cmdlen;
53 int rsplen;
54 int class;
55 int datalen;
56 /* This is just used as a verification during login */
57 struct _fc_channel *fc;
58 void *ls;
59 } fcp_cmnd;
61 typedef struct {
62 unsigned int len;
63 unsigned char list[0];
64 } fcp_posmap;
66 typedef struct _fc_channel {
67 struct _fc_channel *next;
68 int irq;
69 int state;
70 int sid;
71 int did;
72 char name[16];
73 void (*fcp_register)(struct _fc_channel *, u8, int);
74 void (*reset)(struct _fc_channel *);
75 int (*hw_enque)(struct _fc_channel *, fcp_cmnd *);
76 fc_wwn wwn_node;
77 fc_wwn wwn_nport;
78 fc_wwn wwn_dest;
79 common_svc_parm *common_svc;
80 svc_parm *class_svcs;
81 #ifdef __sparc__
82 struct sbus_dev *dev;
83 #else
84 struct pci_dev *dev;
85 #endif
86 struct module *module;
87 /* FCP SCSI stuff */
88 short can_queue;
89 short abort_count;
90 int rsp_size;
91 fcp_cmd *scsi_cmd_pool;
92 char *scsi_rsp_pool;
93 dma_addr_t dma_scsi_cmd, dma_scsi_rsp;
94 long *scsi_bitmap;
95 long scsi_bitmap_end;
96 int scsi_free;
97 int (*encode_addr)(Scsi_Cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *);
98 fcp_cmnd *scsi_que;
99 char scsi_name[4];
100 fcp_cmnd **cmd_slots;
101 int channels;
102 int targets;
103 long *ages;
104 Scsi_Cmnd *rst_pkt;
105 fcp_posmap *posmap;
106 /* LOGIN stuff */
107 fcp_cmnd *login;
108 void *ls;
109 } fc_channel;
111 extern fc_channel *fc_channels;
113 #define FC_STATE_UNINITED 0
114 #define FC_STATE_ONLINE 1
115 #define FC_STATE_OFFLINE 2
116 #define FC_STATE_RESETING 3
117 #define FC_STATE_FPORT_OK 4
118 #define FC_STATE_MAYBEOFFLINE 5
120 #define FC_STATUS_OK 0
121 #define FC_STATUS_P_RJT 2
122 #define FC_STATUS_F_RJT 3
123 #define FC_STATUS_P_BSY 4
124 #define FC_STATUS_F_BSY 5
125 #define FC_STATUS_ERR_OFFLINE 0x11
126 #define FC_STATUS_TIMEOUT 0x12
127 #define FC_STATUS_ERR_OVERRUN 0x13
128 #define FC_STATUS_POINTTOPOINT 0x15
129 #define FC_STATUS_AL 0x16
130 #define FC_STATUS_UNKNOWN_CQ_TYPE 0x20
131 #define FC_STATUS_BAD_SEG_CNT 0x21
132 #define FC_STATUS_MAX_XCHG_EXCEEDED 0x22
133 #define FC_STATUS_BAD_XID 0x23
134 #define FC_STATUS_XCHG_BUSY 0x24
135 #define FC_STATUS_BAD_POOL_ID 0x25
136 #define FC_STATUS_INSUFFICIENT_CQES 0x26
137 #define FC_STATUS_ALLOC_FAIL 0x27
138 #define FC_STATUS_BAD_SID 0x28
139 #define FC_STATUS_NO_SEQ_INIT 0x29
140 #define FC_STATUS_TIMED_OUT -1
141 #define FC_STATUS_BAD_RSP -2
143 void fcp_queue_empty(fc_channel *);
144 int fcp_init(fc_channel *);
145 void fcp_release(fc_channel *fc_chain, int count);
146 void fcp_receive_solicited(fc_channel *, int, int, int, fc_hdr *);
147 void fcp_state_change(fc_channel *, int);
148 int fc_do_plogi(fc_channel *, unsigned char, fc_wwn *, fc_wwn *);
149 int fc_do_prli(fc_channel *, unsigned char);
151 #define for_each_fc_channel(fc) \
152 for (fc = fc_channels; fc; fc = fc->next)
154 #define for_each_online_fc_channel(fc) \
155 for_each_fc_channel(fc) \
156 if (fc->state == FC_STATE_ONLINE)
158 int fcp_scsi_queuecommand(Scsi_Cmnd *, void (* done)(Scsi_Cmnd *));
159 int fcp_scsi_abort(Scsi_Cmnd *);
160 int fcp_scsi_dev_reset(Scsi_Cmnd *);
161 int fcp_scsi_host_reset(Scsi_Cmnd *);
163 #endif /* !(_FCP_SCSI_H) */