aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 15:55:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 15:55:29 -0400
commit424a6f6ef990b7e9f56f6627bfc6c46b493faeb4 (patch)
tree0028356ed8003495fbbe1f716f359e3c8ebc35b6 /include/scsi
parent1ab142d499294b844ecc81e8004db4ce029b0b61 (diff)
parentcd8df932d894f3128c884e3ae1b2b484540513db (diff)
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
SCSI updates from James Bottomley: "The update includes the usual assortment of driver updates (lpfc, qla2xxx, qla4xxx, bfa, bnx2fc, bnx2i, isci, fcoe, hpsa) plus a huge amount of infrastructure work in the SAS library and transport class as well as an iSCSI update. There's also a new SCSI based virtio driver." * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (177 commits) [SCSI] qla4xxx: Update driver version to 5.02.00-k15 [SCSI] qla4xxx: trivial cleanup [SCSI] qla4xxx: Fix sparse warning [SCSI] qla4xxx: Add support for multiple session per host. [SCSI] qla4xxx: Export CHAP index as sysfs attribute [SCSI] scsi_transport: Export CHAP index as sysfs attribute [SCSI] qla4xxx: Add support to display CHAP list and delete CHAP entry [SCSI] iscsi_transport: Add support to display CHAP list and delete CHAP entry [SCSI] pm8001: fix endian issue with code optimization. [SCSI] pm8001: Fix possible racing condition. [SCSI] pm8001: Fix bogus interrupt state flag issue. [SCSI] ipr: update PCI ID definitions for new adapters [SCSI] qla2xxx: handle default case in qla2x00_request_firmware() [SCSI] isci: improvements in driver unloading routine [SCSI] isci: improve phy event warnings [SCSI] isci: debug, provide state-enum-to-string conversions [SCSI] scsi_transport_sas: 'enable' phys on reset [SCSI] libsas: don't recover end devices attached to disabled phys [SCSI] libsas: fixup target_port_protocols for expanders that don't report sata [SCSI] libsas: set attached device type and target protocols for local phys ...
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/fc/fc_ms.h213
-rw-r--r--include/scsi/fc_encode.h363
-rw-r--r--include/scsi/iscsi_if.h79
-rw-r--r--include/scsi/libfc.h11
-rw-r--r--include/scsi/libiscsi.h3
-rw-r--r--include/scsi/libiscsi_tcp.h2
-rw-r--r--include/scsi/libsas.h71
-rw-r--r--include/scsi/sas.h4
-rw-r--r--include/scsi/sas_ata.h44
-rw-r--r--include/scsi/scsi_cmnd.h12
-rw-r--r--include/scsi/scsi_driver.h1
-rw-r--r--include/scsi/scsi_transport_fc.h32
-rw-r--r--include/scsi/scsi_transport_iscsi.h22
-rw-r--r--include/scsi/scsi_transport_sas.h12
14 files changed, 800 insertions, 69 deletions
diff --git a/include/scsi/fc/fc_ms.h b/include/scsi/fc/fc_ms.h
new file mode 100644
index 00000000000..f52b921b5c7
--- /dev/null
+++ b/include/scsi/fc/fc_ms.h
@@ -0,0 +1,213 @@
1/* * Copyright(c) 2011 Intel Corporation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms and conditions of the GNU General Public License,
5 * version 2, as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope it will be useful, but WITHOUT
8 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
10 * more details.
11 *
12 * You should have received a copy of the GNU General Public License along with
13 * this program; if not, write to the Free Software Foundation, Inc.,
14 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
15 *
16 * Maintained at www.Open-FCoE.org
17 */
18
19#ifndef _FC_MS_H_
20#define _FC_MS_H_
21
22#include <linux/types.h>
23
24/*
25 * Fibre Channel Services - Management Service (MS)
26 * From T11.org FC-GS-4 Rev 7.91 February 4, 2004
27 */
28
29/*
30 * Fabric Device Management Interface
31 */
32
33/*
34 * Common-transport sub-type for FDMI
35 */
36#define FC_FDMI_SUBTYPE 0x10 /* fs_ct_hdr.ct_fs_subtype */
37
38/*
39 * Management server FDMI Requests.
40 */
41enum fc_fdmi_req {
42 FC_FDMI_GRHL = 0x0100, /* Get Registered HBA List */
43 FC_FDMI_GHAT = 0x0101, /* Get HBA Attributes */
44 FC_FDMI_GRPL = 0x0102, /* Get Registered Port List */
45 FC_FDMI_GPAT = 0x0110, /* Get Port Attributes */
46 FC_FDMI_RHBA = 0x0200, /* Register HBA */
47 FC_FDMI_RHAT = 0x0201, /* Register HBA Attributes */
48 FC_FDMI_RPRT = 0x0210, /* Register Port */
49 FC_FDMI_RPA = 0x0211, /* Register Port Attributes */
50 FC_FDMI_DHBA = 0x0300, /* Deregister HBA */
51 FC_FDMI_DHAT = 0x0301, /* Deregister HBA Attributes */
52 FC_FDMI_DPRT = 0x0310, /* Deregister Port */
53 FC_FDMI_DPA = 0x0311, /* Deregister Port Attributes */
54};
55
56/*
57 * HBA Attribute Entry Type
58 */
59enum fc_fdmi_hba_attr_type {
60 FC_FDMI_HBA_ATTR_NODENAME = 0x0001,
61 FC_FDMI_HBA_ATTR_MANUFACTURER = 0x0002,
62 FC_FDMI_HBA_ATTR_SERIALNUMBER = 0x0003,
63 FC_FDMI_HBA_ATTR_MODEL = 0x0004,
64 FC_FDMI_HBA_ATTR_MODELDESCRIPTION = 0x0005,
65 FC_FDMI_HBA_ATTR_HARDWAREVERSION = 0x0006,
66 FC_FDMI_HBA_ATTR_DRIVERVERSION = 0x0007,
67 FC_FDMI_HBA_ATTR_OPTIONROMVERSION = 0x0008,
68 FC_FDMI_HBA_ATTR_FIRMWAREVERSION = 0x0009,
69 FC_FDMI_HBA_ATTR_OSNAMEVERSION = 0x000A,
70 FC_FDMI_HBA_ATTR_MAXCTPAYLOAD = 0x000B,
71};
72
73/*
74 * HBA Attribute Length
75 */
76#define FC_FDMI_HBA_ATTR_NODENAME_LEN 8
77#define FC_FDMI_HBA_ATTR_MANUFACTURER_LEN 64
78#define FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN 64
79#define FC_FDMI_HBA_ATTR_MODEL_LEN 256
80#define FC_FDMI_HBA_ATTR_MODELDESCR_LEN 256
81#define FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN 256
82#define FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN 256
83#define FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN 256
84#define FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN 256
85#define FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN 256
86#define FC_FDMI_HBA_ATTR_MAXCTPAYLOAD_LEN 4
87
88/*
89 * Port Attribute Type
90 */
91enum fc_fdmi_port_attr_type {
92 FC_FDMI_PORT_ATTR_FC4TYPES = 0x0001,
93 FC_FDMI_PORT_ATTR_SUPPORTEDSPEED = 0x0002,
94 FC_FDMI_PORT_ATTR_CURRENTPORTSPEED = 0x0003,
95 FC_FDMI_PORT_ATTR_MAXFRAMESIZE = 0x0004,
96 FC_FDMI_PORT_ATTR_OSDEVICENAME = 0x0005,
97 FC_FDMI_PORT_ATTR_HOSTNAME = 0x0006,
98};
99
100/*
101 * Port Attribute Length
102 */
103#define FC_FDMI_PORT_ATTR_FC4TYPES_LEN 32
104#define FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN 4
105#define FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN 4
106#define FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN 4
107#define FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN 256
108#define FC_FDMI_PORT_ATTR_HOSTNAME_LEN 256
109
110/*
111 * HBA Attribute ID
112 */
113struct fc_fdmi_hba_identifier {
114 __be64 id;
115};
116
117/*
118 * Port Name
119 */
120struct fc_fdmi_port_name {
121 __be64 portname;
122};
123
124/*
125 * Attribute Entry Block for HBA/Port Attributes
126 */
127#define FC_FDMI_ATTR_ENTRY_HEADER_LEN 4
128struct fc_fdmi_attr_entry {
129 __be16 type;
130 __be16 len;
131 __u8 value[1];
132} __attribute__((__packed__));
133
134/*
135 * Common for HBA/Port Attributes
136 */
137struct fs_fdmi_attrs {
138 __be32 numattrs;
139 struct fc_fdmi_attr_entry attr[1];
140} __attribute__((__packed__));
141
142/*
143 * Registered Port List
144 */
145struct fc_fdmi_rpl {
146 __be32 numport;
147 struct fc_fdmi_port_name port[1];
148} __attribute__((__packed__));
149
150/*
151 * Register HBA (RHBA)
152 */
153struct fc_fdmi_rhba {
154 struct fc_fdmi_hba_identifier hbaid;
155 struct fc_fdmi_rpl port;
156 struct fs_fdmi_attrs hba_attrs;
157} __attribute__((__packed__));
158
159/*
160 * Register HBA Attributes (RHAT)
161 */
162struct fc_fdmi_rhat {
163 struct fc_fdmi_hba_identifier hbaid;
164 struct fs_fdmi_attrs hba_attrs;
165} __attribute__((__packed__));
166
167/*
168 * Register Port (RPRT)
169 */
170struct fc_fdmi_rprt {
171 struct fc_fdmi_hba_identifier hbaid;
172 struct fc_fdmi_port_name port;
173 struct fs_fdmi_attrs hba_attrs;
174} __attribute__((__packed__));
175
176/*
177 * Register Port Attributes (RPA)
178 */
179struct fc_fdmi_rpa {
180 struct fc_fdmi_port_name port;
181 struct fs_fdmi_attrs hba_attrs;
182} __attribute__((__packed__));
183
184/*
185 * Deregister Port (DPRT)
186 */
187struct fc_fdmi_dprt {
188 struct fc_fdmi_port_name port;
189} __attribute__((__packed__));
190
191/*
192 * Deregister Port Attributes (DPA)
193 */
194struct fc_fdmi_dpa {
195 struct fc_fdmi_port_name port;
196 struct fs_fdmi_attrs hba_attrs;
197} __attribute__((__packed__));
198
199/*
200 * Deregister HBA Attributes (DHAT)
201 */
202struct fc_fdmi_dhat {
203 struct fc_fdmi_hba_identifier hbaid;
204} __attribute__((__packed__));
205
206/*
207 * Deregister HBA (DHBA)
208 */
209struct fc_fdmi_dhba {
210 struct fc_fdmi_hba_identifier hbaid;
211} __attribute__((__packed__));
212
213#endif /* _FC_MS_H_ */
diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h
index be418d8448a..35fd4744f3e 100644
--- a/include/scsi/fc_encode.h
+++ b/include/scsi/fc_encode.h
@@ -20,6 +20,7 @@
20#ifndef _FC_ENCODE_H_ 20#ifndef _FC_ENCODE_H_
21#define _FC_ENCODE_H_ 21#define _FC_ENCODE_H_
22#include <asm/unaligned.h> 22#include <asm/unaligned.h>
23#include <linux/utsname.h>
23 24
24/* 25/*
25 * F_CTL values for simple requests and responses. 26 * F_CTL values for simple requests and responses.
@@ -43,6 +44,10 @@ struct fc_ct_req {
43 struct fc_ns_fid fid; 44 struct fc_ns_fid fid;
44 struct fc_ns_rsnn snn; 45 struct fc_ns_rsnn snn;
45 struct fc_ns_rspn spn; 46 struct fc_ns_rspn spn;
47 struct fc_fdmi_rhba rhba;
48 struct fc_fdmi_rpa rpa;
49 struct fc_fdmi_dprt dprt;
50 struct fc_fdmi_dhba dhba;
46 } payload; 51 } payload;
47}; 52};
48 53
@@ -97,7 +102,9 @@ static inline void fc_adisc_fill(struct fc_lport *lport, struct fc_frame *fp)
97 * returns pointer to ct request. 102 * returns pointer to ct request.
98 */ 103 */
99static inline struct fc_ct_req *fc_ct_hdr_fill(const struct fc_frame *fp, 104static inline struct fc_ct_req *fc_ct_hdr_fill(const struct fc_frame *fp,
100 unsigned int op, size_t req_size) 105 unsigned int op, size_t req_size,
106 enum fc_ct_fs_type fs_type,
107 u8 subtype)
101{ 108{
102 struct fc_ct_req *ct; 109 struct fc_ct_req *ct;
103 size_t ct_plen; 110 size_t ct_plen;
@@ -106,14 +113,14 @@ static inline struct fc_ct_req *fc_ct_hdr_fill(const struct fc_frame *fp,
106 ct = fc_frame_payload_get(fp, ct_plen); 113 ct = fc_frame_payload_get(fp, ct_plen);
107 memset(ct, 0, ct_plen); 114 memset(ct, 0, ct_plen);
108 ct->hdr.ct_rev = FC_CT_REV; 115 ct->hdr.ct_rev = FC_CT_REV;
109 ct->hdr.ct_fs_type = FC_FST_DIR; 116 ct->hdr.ct_fs_type = fs_type;
110 ct->hdr.ct_fs_subtype = FC_NS_SUBTYPE; 117 ct->hdr.ct_fs_subtype = subtype;
111 ct->hdr.ct_cmd = htons((u16) op); 118 ct->hdr.ct_cmd = htons((u16) op);
112 return ct; 119 return ct;
113} 120}
114 121
115/** 122/**
116 * fc_ct_fill() - Fill in a name service request frame 123 * fc_ct_ns_fill() - Fill in a name service request frame
117 * @lport: local port. 124 * @lport: local port.
118 * @fc_id: FC_ID of non-destination rport for GPN_ID and similar inquiries. 125 * @fc_id: FC_ID of non-destination rport for GPN_ID and similar inquiries.
119 * @fp: frame to contain payload. 126 * @fp: frame to contain payload.
@@ -121,7 +128,7 @@ static inline struct fc_ct_req *fc_ct_hdr_fill(const struct fc_frame *fp,
121 * @r_ctl: pointer to FC header R_CTL. 128 * @r_ctl: pointer to FC header R_CTL.
122 * @fh_type: pointer to FC-4 type. 129 * @fh_type: pointer to FC-4 type.
123 */ 130 */
124static inline int fc_ct_fill(struct fc_lport *lport, 131static inline int fc_ct_ns_fill(struct fc_lport *lport,
125 u32 fc_id, struct fc_frame *fp, 132 u32 fc_id, struct fc_frame *fp,
126 unsigned int op, enum fc_rctl *r_ctl, 133 unsigned int op, enum fc_rctl *r_ctl,
127 enum fc_fh_type *fh_type) 134 enum fc_fh_type *fh_type)
@@ -131,23 +138,28 @@ static inline int fc_ct_fill(struct fc_lport *lport,
131 138
132 switch (op) { 139 switch (op) {
133 case FC_NS_GPN_FT: 140 case FC_NS_GPN_FT:
134 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_gid_ft)); 141 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_gid_ft),
142 FC_FST_DIR, FC_NS_SUBTYPE);
135 ct->payload.gid.fn_fc4_type = FC_TYPE_FCP; 143 ct->payload.gid.fn_fc4_type = FC_TYPE_FCP;
136 break; 144 break;
137 145
138 case FC_NS_GPN_ID: 146 case FC_NS_GPN_ID:
139 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_fid)); 147 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_fid),
148 FC_FST_DIR, FC_NS_SUBTYPE);
149 ct->payload.gid.fn_fc4_type = FC_TYPE_FCP;
140 hton24(ct->payload.fid.fp_fid, fc_id); 150 hton24(ct->payload.fid.fp_fid, fc_id);
141 break; 151 break;
142 152
143 case FC_NS_RFT_ID: 153 case FC_NS_RFT_ID:
144 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rft)); 154 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rft),
155 FC_FST_DIR, FC_NS_SUBTYPE);
145 hton24(ct->payload.rft.fid.fp_fid, lport->port_id); 156 hton24(ct->payload.rft.fid.fp_fid, lport->port_id);
146 ct->payload.rft.fts = lport->fcts; 157 ct->payload.rft.fts = lport->fcts;
147 break; 158 break;
148 159
149 case FC_NS_RFF_ID: 160 case FC_NS_RFF_ID:
150 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rff_id)); 161 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rff_id),
162 FC_FST_DIR, FC_NS_SUBTYPE);
151 hton24(ct->payload.rff.fr_fid.fp_fid, lport->port_id); 163 hton24(ct->payload.rff.fr_fid.fp_fid, lport->port_id);
152 ct->payload.rff.fr_type = FC_TYPE_FCP; 164 ct->payload.rff.fr_type = FC_TYPE_FCP;
153 if (lport->service_params & FCP_SPPF_INIT_FCN) 165 if (lport->service_params & FCP_SPPF_INIT_FCN)
@@ -157,14 +169,16 @@ static inline int fc_ct_fill(struct fc_lport *lport,
157 break; 169 break;
158 170
159 case FC_NS_RNN_ID: 171 case FC_NS_RNN_ID:
160 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rn_id)); 172 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rn_id),
173 FC_FST_DIR, FC_NS_SUBTYPE);
161 hton24(ct->payload.rn.fr_fid.fp_fid, lport->port_id); 174 hton24(ct->payload.rn.fr_fid.fp_fid, lport->port_id);
162 put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn); 175 put_unaligned_be64(lport->wwnn, &ct->payload.rn.fr_wwn);
163 break; 176 break;
164 177
165 case FC_NS_RSPN_ID: 178 case FC_NS_RSPN_ID:
166 len = strnlen(fc_host_symbolic_name(lport->host), 255); 179 len = strnlen(fc_host_symbolic_name(lport->host), 255);
167 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rspn) + len); 180 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rspn) + len,
181 FC_FST_DIR, FC_NS_SUBTYPE);
168 hton24(ct->payload.spn.fr_fid.fp_fid, lport->port_id); 182 hton24(ct->payload.spn.fr_fid.fp_fid, lport->port_id);
169 strncpy(ct->payload.spn.fr_name, 183 strncpy(ct->payload.spn.fr_name,
170 fc_host_symbolic_name(lport->host), len); 184 fc_host_symbolic_name(lport->host), len);
@@ -173,7 +187,8 @@ static inline int fc_ct_fill(struct fc_lport *lport,
173 187
174 case FC_NS_RSNN_NN: 188 case FC_NS_RSNN_NN:
175 len = strnlen(fc_host_symbolic_name(lport->host), 255); 189 len = strnlen(fc_host_symbolic_name(lport->host), 255);
176 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rsnn) + len); 190 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rsnn) + len,
191 FC_FST_DIR, FC_NS_SUBTYPE);
177 put_unaligned_be64(lport->wwnn, &ct->payload.snn.fr_wwn); 192 put_unaligned_be64(lport->wwnn, &ct->payload.snn.fr_wwn);
178 strncpy(ct->payload.snn.fr_name, 193 strncpy(ct->payload.snn.fr_name,
179 fc_host_symbolic_name(lport->host), len); 194 fc_host_symbolic_name(lport->host), len);
@@ -189,6 +204,330 @@ static inline int fc_ct_fill(struct fc_lport *lport,
189} 204}
190 205
191/** 206/**
207 * fc_ct_ms_fill() - Fill in a mgmt service request frame
208 * @lport: local port.
209 * @fc_id: FC_ID of non-destination rport for GPN_ID and similar inquiries.
210 * @fp: frame to contain payload.
211 * @op: CT opcode.
212 * @r_ctl: pointer to FC header R_CTL.
213 * @fh_type: pointer to FC-4 type.
214 */
215static inline int fc_ct_ms_fill(struct fc_lport *lport,
216 u32 fc_id, struct fc_frame *fp,
217 unsigned int op, enum fc_rctl *r_ctl,
218 enum fc_fh_type *fh_type)
219{
220 struct fc_ct_req *ct;
221 size_t len;
222 struct fc_fdmi_attr_entry *entry;
223 struct fs_fdmi_attrs *hba_attrs;
224 int numattrs = 0;
225
226 switch (op) {
227 case FC_FDMI_RHBA:
228 numattrs = 10;
229 len = sizeof(struct fc_fdmi_rhba);
230 len -= sizeof(struct fc_fdmi_attr_entry);
231 len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN);
232 len += FC_FDMI_HBA_ATTR_NODENAME_LEN;
233 len += FC_FDMI_HBA_ATTR_MANUFACTURER_LEN;
234 len += FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN;
235 len += FC_FDMI_HBA_ATTR_MODEL_LEN;
236 len += FC_FDMI_HBA_ATTR_MODELDESCR_LEN;
237 len += FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN;
238 len += FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN;
239 len += FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN;
240 len += FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN;
241 len += FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN;
242 ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT,
243 FC_FDMI_SUBTYPE);
244
245 /* HBA Identifier */
246 put_unaligned_be64(lport->wwpn, &ct->payload.rhba.hbaid.id);
247 /* Number of Ports - always 1 */
248 put_unaligned_be32(1, &ct->payload.rhba.port.numport);
249 /* Port Name */
250 put_unaligned_be64(lport->wwpn,
251 &ct->payload.rhba.port.port[0].portname);
252
253 /* HBA Attributes */
254 put_unaligned_be32(numattrs,
255 &ct->payload.rhba.hba_attrs.numattrs);
256 hba_attrs = &ct->payload.rhba.hba_attrs;
257 entry = (struct fc_fdmi_attr_entry *)hba_attrs->attr;
258 /* NodeName*/
259 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
260 len += FC_FDMI_HBA_ATTR_NODENAME_LEN;
261 put_unaligned_be16(FC_FDMI_HBA_ATTR_NODENAME,
262 &entry->type);
263 put_unaligned_be16(len, &entry->len);
264 put_unaligned_be64(lport->wwnn,
265 (__be64 *)&entry->value[0]);
266
267 /* Manufacturer */
268 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
269 FC_FDMI_HBA_ATTR_NODENAME_LEN);
270 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
271 len += FC_FDMI_HBA_ATTR_MANUFACTURER_LEN;
272 put_unaligned_be16(FC_FDMI_HBA_ATTR_MANUFACTURER,
273 &entry->type);
274 put_unaligned_be16(len, &entry->len);
275 strncpy((char *)&entry->value,
276 fc_host_manufacturer(lport->host),
277 FC_FDMI_HBA_ATTR_MANUFACTURER_LEN);
278
279 /* SerialNumber */
280 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
281 FC_FDMI_HBA_ATTR_MANUFACTURER_LEN);
282 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
283 len += FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN;
284 put_unaligned_be16(FC_FDMI_HBA_ATTR_SERIALNUMBER,
285 &entry->type);
286 put_unaligned_be16(len, &entry->len);
287 strncpy((char *)&entry->value,
288 fc_host_serial_number(lport->host),
289 FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN);
290
291 /* Model */
292 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
293 FC_FDMI_HBA_ATTR_SERIALNUMBER_LEN);
294 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
295 len += FC_FDMI_HBA_ATTR_MODEL_LEN;
296 put_unaligned_be16(FC_FDMI_HBA_ATTR_MODEL,
297 &entry->type);
298 put_unaligned_be16(len, &entry->len);
299 strncpy((char *)&entry->value,
300 fc_host_model(lport->host),
301 FC_FDMI_HBA_ATTR_MODEL_LEN);
302
303 /* Model Description */
304 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
305 FC_FDMI_HBA_ATTR_MODEL_LEN);
306 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
307 len += FC_FDMI_HBA_ATTR_MODELDESCR_LEN;
308 put_unaligned_be16(FC_FDMI_HBA_ATTR_MODELDESCRIPTION,
309 &entry->type);
310 put_unaligned_be16(len, &entry->len);
311 strncpy((char *)&entry->value,
312 fc_host_model_description(lport->host),
313 FC_FDMI_HBA_ATTR_MODELDESCR_LEN);
314
315 /* Hardware Version */
316 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
317 FC_FDMI_HBA_ATTR_MODELDESCR_LEN);
318 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
319 len += FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN;
320 put_unaligned_be16(FC_FDMI_HBA_ATTR_HARDWAREVERSION,
321 &entry->type);
322 put_unaligned_be16(len, &entry->len);
323 strncpy((char *)&entry->value,
324 fc_host_hardware_version(lport->host),
325 FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN);
326
327 /* Driver Version */
328 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
329 FC_FDMI_HBA_ATTR_HARDWAREVERSION_LEN);
330 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
331 len += FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN;
332 put_unaligned_be16(FC_FDMI_HBA_ATTR_DRIVERVERSION,
333 &entry->type);
334 put_unaligned_be16(len, &entry->len);
335 strncpy((char *)&entry->value,
336 fc_host_driver_version(lport->host),
337 FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN);
338
339 /* OptionROM Version */
340 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
341 FC_FDMI_HBA_ATTR_DRIVERVERSION_LEN);
342 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
343 len += FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN;
344 put_unaligned_be16(FC_FDMI_HBA_ATTR_OPTIONROMVERSION,
345 &entry->type);
346 put_unaligned_be16(len, &entry->len);
347 strncpy((char *)&entry->value,
348 fc_host_optionrom_version(lport->host),
349 FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN);
350
351 /* Firmware Version */
352 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
353 FC_FDMI_HBA_ATTR_OPTIONROMVERSION_LEN);
354 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
355 len += FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN;
356 put_unaligned_be16(FC_FDMI_HBA_ATTR_FIRMWAREVERSION,
357 &entry->type);
358 put_unaligned_be16(len, &entry->len);
359 strncpy((char *)&entry->value,
360 fc_host_firmware_version(lport->host),
361 FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN);
362
363 /* OS Name and Version */
364 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
365 FC_FDMI_HBA_ATTR_FIRMWAREVERSION_LEN);
366 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
367 len += FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN;
368 put_unaligned_be16(FC_FDMI_HBA_ATTR_OSNAMEVERSION,
369 &entry->type);
370 put_unaligned_be16(len, &entry->len);
371 snprintf((char *)&entry->value,
372 FC_FDMI_HBA_ATTR_OSNAMEVERSION_LEN,
373 "%s v%s",
374 init_utsname()->sysname,
375 init_utsname()->release);
376 break;
377 case FC_FDMI_RPA:
378 numattrs = 6;
379 len = sizeof(struct fc_fdmi_rpa);
380 len -= sizeof(struct fc_fdmi_attr_entry);
381 len += (numattrs * FC_FDMI_ATTR_ENTRY_HEADER_LEN);
382 len += FC_FDMI_PORT_ATTR_FC4TYPES_LEN;
383 len += FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN;
384 len += FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN;
385 len += FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN;
386 len += FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN;
387 len += FC_FDMI_PORT_ATTR_HOSTNAME_LEN;
388 ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT,
389 FC_FDMI_SUBTYPE);
390
391 /* Port Name */
392 put_unaligned_be64(lport->wwpn,
393 &ct->payload.rpa.port.portname);
394
395 /* Port Attributes */
396 put_unaligned_be32(numattrs,
397 &ct->payload.rpa.hba_attrs.numattrs);
398
399 hba_attrs = &ct->payload.rpa.hba_attrs;
400 entry = (struct fc_fdmi_attr_entry *)hba_attrs->attr;
401
402 /* FC4 types */
403 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
404 len += FC_FDMI_PORT_ATTR_FC4TYPES_LEN;
405 put_unaligned_be16(FC_FDMI_PORT_ATTR_FC4TYPES,
406 &entry->type);
407 put_unaligned_be16(len, &entry->len);
408 memcpy(&entry->value, fc_host_supported_fc4s(lport->host),
409 FC_FDMI_PORT_ATTR_FC4TYPES_LEN);
410
411 /* Supported Speed */
412 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
413 FC_FDMI_PORT_ATTR_FC4TYPES_LEN);
414 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
415 len += FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN;
416 put_unaligned_be16(FC_FDMI_PORT_ATTR_SUPPORTEDSPEED,
417 &entry->type);
418 put_unaligned_be16(len, &entry->len);
419
420 put_unaligned_be32(fc_host_supported_speeds(lport->host),
421 &entry->value);
422
423 /* Current Port Speed */
424 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
425 FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN);
426 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
427 len += FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN;
428 put_unaligned_be16(FC_FDMI_PORT_ATTR_CURRENTPORTSPEED,
429 &entry->type);
430 put_unaligned_be16(len, &entry->len);
431 put_unaligned_be32(lport->link_speed,
432 &entry->value);
433
434 /* Max Frame Size */
435 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
436 FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN);
437 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
438 len += FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN;
439 put_unaligned_be16(FC_FDMI_PORT_ATTR_MAXFRAMESIZE,
440 &entry->type);
441 put_unaligned_be16(len, &entry->len);
442 put_unaligned_be32(fc_host_maxframe_size(lport->host),
443 &entry->value);
444
445 /* OS Device Name */
446 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
447 FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN);
448 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
449 len += FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN;
450 put_unaligned_be16(FC_FDMI_PORT_ATTR_OSDEVICENAME,
451 &entry->type);
452 put_unaligned_be16(len, &entry->len);
453 /* Use the sysfs device name */
454 strncpy((char *)&entry->value,
455 dev_name(&lport->host->shost_gendev),
456 strnlen(dev_name(&lport->host->shost_gendev),
457 FC_FDMI_PORT_ATTR_HOSTNAME_LEN));
458
459 /* Host Name */
460 entry = (struct fc_fdmi_attr_entry *)((char *)entry->value +
461 FC_FDMI_PORT_ATTR_OSDEVICENAME_LEN);
462 len = FC_FDMI_ATTR_ENTRY_HEADER_LEN;
463 len += FC_FDMI_PORT_ATTR_HOSTNAME_LEN;
464 put_unaligned_be16(FC_FDMI_PORT_ATTR_HOSTNAME,
465 &entry->type);
466 put_unaligned_be16(len, &entry->len);
467 if (strlen(fc_host_system_hostname(lport->host)))
468 strncpy((char *)&entry->value,
469 fc_host_system_hostname(lport->host),
470 strnlen(fc_host_system_hostname(lport->host),
471 FC_FDMI_PORT_ATTR_HOSTNAME_LEN));
472 else
473 strncpy((char *)&entry->value,
474 init_utsname()->nodename,
475 FC_FDMI_PORT_ATTR_HOSTNAME_LEN);
476 break;
477 case FC_FDMI_DPRT:
478 len = sizeof(struct fc_fdmi_dprt);
479 ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT,
480 FC_FDMI_SUBTYPE);
481 /* Port Name */
482 put_unaligned_be64(lport->wwpn,
483 &ct->payload.dprt.port.portname);
484 break;
485 case FC_FDMI_DHBA:
486 len = sizeof(struct fc_fdmi_dhba);
487 ct = fc_ct_hdr_fill(fp, op, len, FC_FST_MGMT,
488 FC_FDMI_SUBTYPE);
489 /* HBA Identifier */
490 put_unaligned_be64(lport->wwpn, &ct->payload.dhba.hbaid.id);
491 break;
492 default:
493 return -EINVAL;
494 }
495 *r_ctl = FC_RCTL_DD_UNSOL_CTL;
496 *fh_type = FC_TYPE_CT;
497 return 0;
498}
499
500/**
501 * fc_ct_fill() - Fill in a common transport service request frame
502 * @lport: local port.
503 * @fc_id: FC_ID of non-destination rport for GPN_ID and similar inquiries.
504 * @fp: frame to contain payload.
505 * @op: CT opcode.
506 * @r_ctl: pointer to FC header R_CTL.
507 * @fh_type: pointer to FC-4 type.
508 */
509static inline int fc_ct_fill(struct fc_lport *lport,
510 u32 fc_id, struct fc_frame *fp,
511 unsigned int op, enum fc_rctl *r_ctl,
512 enum fc_fh_type *fh_type, u32 *did)
513{
514 int rc = -EINVAL;
515
516 switch (fc_id) {
517 case FC_FID_MGMT_SERV:
518 rc = fc_ct_ms_fill(lport, fc_id, fp, op, r_ctl, fh_type);
519 *did = FC_FID_MGMT_SERV;
520 break;
521 case FC_FID_DIR_SERV:
522 default:
523 rc = fc_ct_ns_fill(lport, fc_id, fp, op, r_ctl, fh_type);
524 *did = FC_FID_DIR_SERV;
525 break;
526 }
527
528 return rc;
529}
530/**
192 * fc_plogi_fill - Fill in plogi request frame 531 * fc_plogi_fill - Fill in plogi request frame
193 */ 532 */
194static inline void fc_plogi_fill(struct fc_lport *lport, struct fc_frame *fp, 533static inline void fc_plogi_fill(struct fc_lport *lport, struct fc_frame *fp,
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 2703e3bedbf..9c23ee8fd2d 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -60,6 +60,9 @@ enum iscsi_uevent_e {
60 60
61 ISCSI_UEVENT_PATH_UPDATE = UEVENT_BASE + 20, 61 ISCSI_UEVENT_PATH_UPDATE = UEVENT_BASE + 20,
62 ISCSI_UEVENT_SET_IFACE_PARAMS = UEVENT_BASE + 21, 62 ISCSI_UEVENT_SET_IFACE_PARAMS = UEVENT_BASE + 21,
63 ISCSI_UEVENT_PING = UEVENT_BASE + 22,
64 ISCSI_UEVENT_GET_CHAP = UEVENT_BASE + 23,
65 ISCSI_UEVENT_DELETE_CHAP = UEVENT_BASE + 24,
63 66
64 /* up events */ 67 /* up events */
65 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, 68 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
@@ -72,6 +75,8 @@ enum iscsi_uevent_e {
72 ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7, 75 ISCSI_KEVENT_PATH_REQ = KEVENT_BASE + 7,
73 ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8, 76 ISCSI_KEVENT_IF_DOWN = KEVENT_BASE + 8,
74 ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9, 77 ISCSI_KEVENT_CONN_LOGIN_STATE = KEVENT_BASE + 9,
78 ISCSI_KEVENT_HOST_EVENT = KEVENT_BASE + 10,
79 ISCSI_KEVENT_PING_COMP = KEVENT_BASE + 11,
75}; 80};
76 81
77enum iscsi_tgt_dscvr { 82enum iscsi_tgt_dscvr {
@@ -80,6 +85,13 @@ enum iscsi_tgt_dscvr {
80 ISCSI_TGT_DSCVR_SLP = 3, 85 ISCSI_TGT_DSCVR_SLP = 3,
81}; 86};
82 87
88enum iscsi_host_event_code {
89 ISCSI_EVENT_LINKUP = 1,
90 ISCSI_EVENT_LINKDOWN,
91 /* must always be last */
92 ISCSI_EVENT_MAX,
93};
94
83struct iscsi_uevent { 95struct iscsi_uevent {
84 uint32_t type; /* k/u events type */ 96 uint32_t type; /* k/u events type */
85 uint32_t iferror; /* carries interface or resource errors */ 97 uint32_t iferror; /* carries interface or resource errors */
@@ -178,6 +190,26 @@ struct iscsi_uevent {
178 uint32_t host_no; 190 uint32_t host_no;
179 uint32_t count; 191 uint32_t count;
180 } set_iface_params; 192 } set_iface_params;
193 struct msg_iscsi_ping {
194 uint32_t host_no;
195 uint32_t iface_num;
196 uint32_t iface_type;
197 uint32_t payload_size;
198 uint32_t pid; /* unique ping id associated
199 with each ping request */
200 } iscsi_ping;
201 struct msg_get_chap {
202 uint32_t host_no;
203 uint32_t num_entries; /* number of CHAP entries
204 * on request, number of
205 * valid CHAP entries on
206 * response */
207 uint16_t chap_tbl_idx;
208 } get_chap;
209 struct msg_delete_chap {
210 uint32_t host_no;
211 uint16_t chap_tbl_idx;
212 } delete_chap;
181 } u; 213 } u;
182 union { 214 union {
183 /* messages k -> u */ 215 /* messages k -> u */
@@ -222,6 +254,18 @@ struct iscsi_uevent {
222 struct msg_notify_if_down { 254 struct msg_notify_if_down {
223 uint32_t host_no; 255 uint32_t host_no;
224 } notify_if_down; 256 } notify_if_down;
257 struct msg_host_event {
258 uint32_t host_no;
259 uint32_t data_size;
260 enum iscsi_host_event_code code;
261 } host_event;
262 struct msg_ping_comp {
263 uint32_t host_no;
264 uint32_t status;
265 uint32_t pid; /* unique ping id associated
266 with each ping request */
267 uint32_t data_size;
268 } ping_comp;
225 } r; 269 } r;
226} __attribute__ ((aligned (sizeof(uint64_t)))); 270} __attribute__ ((aligned (sizeof(uint64_t))));
227 271
@@ -406,6 +450,9 @@ enum iscsi_param {
406 450
407 ISCSI_PARAM_TGT_RESET_TMO, 451 ISCSI_PARAM_TGT_RESET_TMO,
408 ISCSI_PARAM_TARGET_ALIAS, 452 ISCSI_PARAM_TARGET_ALIAS,
453
454 ISCSI_PARAM_CHAP_IN_IDX,
455 ISCSI_PARAM_CHAP_OUT_IDX,
409 /* must always be last */ 456 /* must always be last */
410 ISCSI_PARAM_MAX, 457 ISCSI_PARAM_MAX,
411}; 458};
@@ -416,9 +463,26 @@ enum iscsi_host_param {
416 ISCSI_HOST_PARAM_INITIATOR_NAME, 463 ISCSI_HOST_PARAM_INITIATOR_NAME,
417 ISCSI_HOST_PARAM_NETDEV_NAME, 464 ISCSI_HOST_PARAM_NETDEV_NAME,
418 ISCSI_HOST_PARAM_IPADDRESS, 465 ISCSI_HOST_PARAM_IPADDRESS,
466 ISCSI_HOST_PARAM_PORT_STATE,
467 ISCSI_HOST_PARAM_PORT_SPEED,
419 ISCSI_HOST_PARAM_MAX, 468 ISCSI_HOST_PARAM_MAX,
420}; 469};
421 470
471/* iSCSI port Speed */
472enum iscsi_port_speed {
473 ISCSI_PORT_SPEED_UNKNOWN = 0x1,
474 ISCSI_PORT_SPEED_10MBPS = 0x2,
475 ISCSI_PORT_SPEED_100MBPS = 0x4,
476 ISCSI_PORT_SPEED_1GBPS = 0x8,
477 ISCSI_PORT_SPEED_10GBPS = 0x10,
478};
479
480/* iSCSI port state */
481enum iscsi_port_state {
482 ISCSI_PORT_STATE_DOWN = 0x1,
483 ISCSI_PORT_STATE_UP = 0x2,
484};
485
422#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) 486#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
423#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) 487#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
424 488
@@ -501,4 +565,19 @@ struct iscsi_stats {
501 __attribute__ ((aligned (sizeof(uint64_t)))); 565 __attribute__ ((aligned (sizeof(uint64_t))));
502}; 566};
503 567
568enum chap_type_e {
569 CHAP_TYPE_OUT,
570 CHAP_TYPE_IN,
571};
572
573#define ISCSI_CHAP_AUTH_NAME_MAX_LEN 256
574#define ISCSI_CHAP_AUTH_SECRET_MAX_LEN 256
575struct iscsi_chap_rec {
576 uint16_t chap_tbl_idx;
577 enum chap_type_e chap_type;
578 char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
579 uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
580 uint8_t password_length;
581} __packed;
582
504#endif 583#endif
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 6a3922fe0be..8f9dfba3fcf 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -30,6 +30,7 @@
30 30
31#include <scsi/fc/fc_fcp.h> 31#include <scsi/fc/fc_fcp.h>
32#include <scsi/fc/fc_ns.h> 32#include <scsi/fc/fc_ns.h>
33#include <scsi/fc/fc_ms.h>
33#include <scsi/fc/fc_els.h> 34#include <scsi/fc/fc_els.h>
34#include <scsi/fc/fc_gs.h> 35#include <scsi/fc/fc_gs.h>
35 36
@@ -52,6 +53,8 @@
52 * @LPORT_ST_RPN_ID: Register port name by ID (RPN_ID) sent 53 * @LPORT_ST_RPN_ID: Register port name by ID (RPN_ID) sent
53 * @LPORT_ST_RFT_ID: Register Fibre Channel types by ID (RFT_ID) sent 54 * @LPORT_ST_RFT_ID: Register Fibre Channel types by ID (RFT_ID) sent
54 * @LPORT_ST_RFF_ID: Register FC-4 Features by ID (RFF_ID) sent 55 * @LPORT_ST_RFF_ID: Register FC-4 Features by ID (RFF_ID) sent
56 * @LPORT_ST_FDMI: Waiting for mgmt server rport to become ready
57 * @LPORT_ST_RHBA:
55 * @LPORT_ST_SCR: State Change Register (SCR) sent 58 * @LPORT_ST_SCR: State Change Register (SCR) sent
56 * @LPORT_ST_READY: Ready for use 59 * @LPORT_ST_READY: Ready for use
57 * @LPORT_ST_LOGO: Local port logout (LOGO) sent 60 * @LPORT_ST_LOGO: Local port logout (LOGO) sent
@@ -66,6 +69,11 @@ enum fc_lport_state {
66 LPORT_ST_RSPN_ID, 69 LPORT_ST_RSPN_ID,
67 LPORT_ST_RFT_ID, 70 LPORT_ST_RFT_ID,
68 LPORT_ST_RFF_ID, 71 LPORT_ST_RFF_ID,
72 LPORT_ST_FDMI,
73 LPORT_ST_RHBA,
74 LPORT_ST_RPA,
75 LPORT_ST_DHBA,
76 LPORT_ST_DPRT,
69 LPORT_ST_SCR, 77 LPORT_ST_SCR,
70 LPORT_ST_READY, 78 LPORT_ST_READY,
71 LPORT_ST_LOGO, 79 LPORT_ST_LOGO,
@@ -797,6 +805,7 @@ enum fc_lport_event {
797 * @host: The SCSI host associated with a local port 805 * @host: The SCSI host associated with a local port
798 * @ema_list: Exchange manager anchor list 806 * @ema_list: Exchange manager anchor list
799 * @dns_rdata: The directory server remote port 807 * @dns_rdata: The directory server remote port
808 * @ms_rdata: The management server remote port
800 * @ptp_rdata: Point to point remote port 809 * @ptp_rdata: Point to point remote port
801 * @scsi_priv: FCP layer internal data 810 * @scsi_priv: FCP layer internal data
802 * @disc: Discovery context 811 * @disc: Discovery context
@@ -842,6 +851,7 @@ struct fc_lport {
842 struct Scsi_Host *host; 851 struct Scsi_Host *host;
843 struct list_head ema_list; 852 struct list_head ema_list;
844 struct fc_rport_priv *dns_rdata; 853 struct fc_rport_priv *dns_rdata;
854 struct fc_rport_priv *ms_rdata;
845 struct fc_rport_priv *ptp_rdata; 855 struct fc_rport_priv *ptp_rdata;
846 void *scsi_priv; 856 void *scsi_priv;
847 struct fc_disc disc; 857 struct fc_disc disc;
@@ -877,6 +887,7 @@ struct fc_lport {
877 u32 does_npiv:1; 887 u32 does_npiv:1;
878 u32 npiv_enabled:1; 888 u32 npiv_enabled:1;
879 u32 point_to_multipoint:1; 889 u32 point_to_multipoint:1;
890 u32 fdmi_enabled:1;
880 u32 mfs; 891 u32 mfs;
881 u8 max_retry_count; 892 u8 max_retry_count;
882 u8 max_rport_retry_count; 893 u8 max_rport_retry_count;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index cedcff371c8..6e33386a389 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -268,7 +268,7 @@ struct iscsi_session {
268 int lu_reset_timeout; 268 int lu_reset_timeout;
269 int tgt_reset_timeout; 269 int tgt_reset_timeout;
270 int initial_r2t_en; 270 int initial_r2t_en;
271 unsigned max_r2t; 271 unsigned short max_r2t;
272 int imm_data_en; 272 int imm_data_en;
273 unsigned first_burst; 273 unsigned first_burst;
274 unsigned max_burst; 274 unsigned max_burst;
@@ -284,6 +284,7 @@ struct iscsi_session {
284 char *password; 284 char *password;
285 char *password_in; 285 char *password_in;
286 char *targetname; 286 char *targetname;
287 char *targetalias;
287 char *ifacename; 288 char *ifacename;
288 char *initiatorname; 289 char *initiatorname;
289 /* control data */ 290 /* control data */
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
index ac0cc1d925e..215469a9b80 100644
--- a/include/scsi/libiscsi_tcp.h
+++ b/include/scsi/libiscsi_tcp.h
@@ -128,7 +128,7 @@ extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn);
128/* misc helpers */ 128/* misc helpers */
129extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session); 129extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session);
130extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session); 130extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session);
131 131extern int iscsi_tcp_set_max_r2t(struct iscsi_conn *conn, char *buf);
132extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn, 132extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn,
133 struct iscsi_stats *stats); 133 struct iscsi_stats *stats);
134#endif /* LIBISCSI_TCP_H */ 134#endif /* LIBISCSI_TCP_H */
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 6a308d42d98..5f5ed1b8b41 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -86,7 +86,9 @@ enum discover_event {
86 DISCE_DISCOVER_DOMAIN = 0U, 86 DISCE_DISCOVER_DOMAIN = 0U,
87 DISCE_REVALIDATE_DOMAIN = 1, 87 DISCE_REVALIDATE_DOMAIN = 1,
88 DISCE_PORT_GONE = 2, 88 DISCE_PORT_GONE = 2,
89 DISC_NUM_EVENTS = 3, 89 DISCE_PROBE = 3,
90 DISCE_DESTRUCT = 4,
91 DISC_NUM_EVENTS = 5,
90}; 92};
91 93
92/* ---------- Expander Devices ---------- */ 94/* ---------- Expander Devices ---------- */
@@ -151,6 +153,8 @@ struct expander_device {
151 153
152 struct ex_phy *ex_phy; 154 struct ex_phy *ex_phy;
153 struct sas_port *parent_port; 155 struct sas_port *parent_port;
156
157 struct mutex cmd_mutex;
154}; 158};
155 159
156/* ---------- SATA device ---------- */ 160/* ---------- SATA device ---------- */
@@ -162,22 +166,21 @@ enum ata_command_set {
162struct sata_device { 166struct sata_device {
163 enum ata_command_set command_set; 167 enum ata_command_set command_set;
164 struct smp_resp rps_resp; /* report_phy_sata_resp */ 168 struct smp_resp rps_resp; /* report_phy_sata_resp */
165 __le16 *identify_device;
166 __le16 *identify_packet_device;
167
168 u8 port_no; /* port number, if this is a PM (Port) */ 169 u8 port_no; /* port number, if this is a PM (Port) */
169 struct list_head children; /* PM Ports if this is a PM */ 170 struct list_head children; /* PM Ports if this is a PM */
170 171
171 struct ata_port *ap; 172 struct ata_port *ap;
172 struct ata_host ata_host; 173 struct ata_host ata_host;
173 struct ata_taskfile tf; 174 struct ata_taskfile tf;
174 u32 sstatus;
175 u32 serror;
176 u32 scontrol;
177}; 175};
178 176
179/* ---------- Domain device ---------- */ 177enum {
178 SAS_DEV_GONE,
179 SAS_DEV_DESTROY,
180};
181
180struct domain_device { 182struct domain_device {
183 spinlock_t done_lock;
181 enum sas_dev_type dev_type; 184 enum sas_dev_type dev_type;
182 185
183 enum sas_linkrate linkrate; 186 enum sas_linkrate linkrate;
@@ -189,8 +192,10 @@ struct domain_device {
189 struct domain_device *parent; 192 struct domain_device *parent;
190 struct list_head siblings; /* devices on the same level */ 193 struct list_head siblings; /* devices on the same level */
191 struct asd_sas_port *port; /* shortcut to root of the tree */ 194 struct asd_sas_port *port; /* shortcut to root of the tree */
195 struct sas_phy *phy;
192 196
193 struct list_head dev_list_node; 197 struct list_head dev_list_node;
198 struct list_head disco_list_node; /* awaiting probe or destruct */
194 199
195 enum sas_protocol iproto; 200 enum sas_protocol iproto;
196 enum sas_protocol tproto; 201 enum sas_protocol tproto;
@@ -208,7 +213,8 @@ struct domain_device {
208 }; 213 };
209 214
210 void *lldd_dev; 215 void *lldd_dev;
211 int gone; 216 unsigned long state;
217 struct kref kref;
212}; 218};
213 219
214struct sas_discovery_event { 220struct sas_discovery_event {
@@ -217,7 +223,6 @@ struct sas_discovery_event {
217}; 223};
218 224
219struct sas_discovery { 225struct sas_discovery {
220 spinlock_t disc_event_lock;
221 struct sas_discovery_event disc_work[DISC_NUM_EVENTS]; 226 struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
222 unsigned long pending; 227 unsigned long pending;
223 u8 fanout_sas_addr[8]; 228 u8 fanout_sas_addr[8];
@@ -226,7 +231,6 @@ struct sas_discovery {
226 int max_level; 231 int max_level;
227}; 232};
228 233
229
230/* The port struct is Class:RW, driver:RO */ 234/* The port struct is Class:RW, driver:RO */
231struct asd_sas_port { 235struct asd_sas_port {
232/* private: */ 236/* private: */
@@ -236,9 +240,10 @@ struct asd_sas_port {
236 struct domain_device *port_dev; 240 struct domain_device *port_dev;
237 spinlock_t dev_list_lock; 241 spinlock_t dev_list_lock;
238 struct list_head dev_list; 242 struct list_head dev_list;
243 struct list_head disco_list;
244 struct list_head destroy_list;
239 enum sas_linkrate linkrate; 245 enum sas_linkrate linkrate;
240 246
241 struct sas_phy *phy;
242 struct work_struct work; 247 struct work_struct work;
243 248
244/* public: */ 249/* public: */
@@ -274,7 +279,6 @@ struct asd_sas_event {
274 */ 279 */
275struct asd_sas_phy { 280struct asd_sas_phy {
276/* private: */ 281/* private: */
277 /* protected by ha->event_lock */
278 struct asd_sas_event port_events[PORT_NUM_EVENTS]; 282 struct asd_sas_event port_events[PORT_NUM_EVENTS];
279 struct asd_sas_event phy_events[PHY_NUM_EVENTS]; 283 struct asd_sas_event phy_events[PHY_NUM_EVENTS];
280 284
@@ -320,6 +324,7 @@ struct asd_sas_phy {
320struct scsi_core { 324struct scsi_core {
321 struct Scsi_Host *shost; 325 struct Scsi_Host *shost;
322 326
327 struct mutex task_queue_flush;
323 spinlock_t task_queue_lock; 328 spinlock_t task_queue_lock;
324 struct list_head task_queue; 329 struct list_head task_queue;
325 int task_queue_size; 330 int task_queue_size;
@@ -334,18 +339,23 @@ struct sas_ha_event {
334 339
335enum sas_ha_state { 340enum sas_ha_state {
336 SAS_HA_REGISTERED, 341 SAS_HA_REGISTERED,
337 SAS_HA_UNREGISTERED 342 SAS_HA_DRAINING,
343 SAS_HA_ATA_EH_ACTIVE,
344 SAS_HA_FROZEN,
338}; 345};
339 346
340struct sas_ha_struct { 347struct sas_ha_struct {
341/* private: */ 348/* private: */
342 spinlock_t event_lock;
343 struct sas_ha_event ha_events[HA_NUM_EVENTS]; 349 struct sas_ha_event ha_events[HA_NUM_EVENTS];
344 unsigned long pending; 350 unsigned long pending;
345 351
346 enum sas_ha_state state; 352 struct list_head defer_q; /* work queued while draining */
353 struct mutex drain_mutex;
354 unsigned long state;
347 spinlock_t state_lock; 355 spinlock_t state_lock;
348 356
357 struct mutex disco_mutex;
358
349 struct scsi_core core; 359 struct scsi_core core;
350 360
351/* public: */ 361/* public: */
@@ -374,7 +384,8 @@ struct sas_ha_struct {
374 384
375 void *lldd_ha; /* not touched by sas class code */ 385 void *lldd_ha; /* not touched by sas class code */
376 386
377 struct list_head eh_done_q; 387 struct list_head eh_done_q; /* complete via scsi_eh_flush_done_q */
388 struct list_head eh_ata_q; /* scmds to promote from sas to ata eh */
378}; 389};
379 390
380#define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata) 391#define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata)
@@ -418,6 +429,11 @@ static inline unsigned int to_sas_gpio_od(int device, int bit)
418 return 3 * device + bit; 429 return 3 * device + bit;
419} 430}
420 431
432static inline void sas_put_local_phy(struct sas_phy *phy)
433{
434 put_device(&phy->dev);
435}
436
421#ifdef CONFIG_SCSI_SAS_HOST_SMP 437#ifdef CONFIG_SCSI_SAS_HOST_SMP
422int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count); 438int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count);
423#else 439#else
@@ -447,7 +463,10 @@ enum service_response {
447}; 463};
448 464
449enum exec_status { 465enum exec_status {
450 /* The SAM_STAT_.. codes fit in the lower 6 bits */ 466 /* The SAM_STAT_.. codes fit in the lower 6 bits, alias some of
467 * them here to silence 'case value not in enumerated type' warnings
468 */
469 __SAM_STAT_CHECK_CONDITION = SAM_STAT_CHECK_CONDITION,
451 470
452 SAS_DEV_NO_RESPONSE = 0x80, 471 SAS_DEV_NO_RESPONSE = 0x80,
453 SAS_DATA_UNDERRUN, 472 SAS_DATA_UNDERRUN,
@@ -487,10 +506,6 @@ enum exec_status {
487struct ata_task_resp { 506struct ata_task_resp {
488 u16 frame_len; 507 u16 frame_len;
489 u8 ending_fis[24]; /* dev to host or data-in */ 508 u8 ending_fis[24]; /* dev to host or data-in */
490 u32 sstatus;
491 u32 serror;
492 u32 scontrol;
493 u32 sactive;
494}; 509};
495 510
496#define SAS_STATUS_BUF_SIZE 96 511#define SAS_STATUS_BUF_SIZE 96
@@ -604,7 +619,8 @@ struct sas_domain_function_template {
604 int (*lldd_clear_aca)(struct domain_device *, u8 *lun); 619 int (*lldd_clear_aca)(struct domain_device *, u8 *lun);
605 int (*lldd_clear_task_set)(struct domain_device *, u8 *lun); 620 int (*lldd_clear_task_set)(struct domain_device *, u8 *lun);
606 int (*lldd_I_T_nexus_reset)(struct domain_device *); 621 int (*lldd_I_T_nexus_reset)(struct domain_device *);
607 int (*lldd_ata_soft_reset)(struct domain_device *); 622 int (*lldd_ata_check_ready)(struct domain_device *);
623 void (*lldd_ata_set_dmamode)(struct domain_device *);
608 int (*lldd_lu_reset)(struct domain_device *, u8 *lun); 624 int (*lldd_lu_reset)(struct domain_device *, u8 *lun);
609 int (*lldd_query_task)(struct sas_task *); 625 int (*lldd_query_task)(struct sas_task *);
610 626
@@ -625,14 +641,11 @@ extern int sas_unregister_ha(struct sas_ha_struct *);
625 641
626int sas_set_phy_speed(struct sas_phy *phy, 642int sas_set_phy_speed(struct sas_phy *phy,
627 struct sas_phy_linkrates *rates); 643 struct sas_phy_linkrates *rates);
628int sas_phy_enable(struct sas_phy *phy, int enabled);
629int sas_phy_reset(struct sas_phy *phy, int hard_reset); 644int sas_phy_reset(struct sas_phy *phy, int hard_reset);
630int sas_queue_up(struct sas_task *task); 645int sas_queue_up(struct sas_task *task);
631extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *); 646extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *);
632extern int sas_target_alloc(struct scsi_target *); 647extern int sas_target_alloc(struct scsi_target *);
633extern int sas_slave_alloc(struct scsi_device *);
634extern int sas_slave_configure(struct scsi_device *); 648extern int sas_slave_configure(struct scsi_device *);
635extern void sas_slave_destroy(struct scsi_device *);
636extern int sas_change_queue_depth(struct scsi_device *, int new_depth, 649extern int sas_change_queue_depth(struct scsi_device *, int new_depth,
637 int reason); 650 int reason);
638extern int sas_change_queue_type(struct scsi_device *, int qt); 651extern int sas_change_queue_type(struct scsi_device *, int qt);
@@ -649,7 +662,7 @@ void sas_init_ex_attr(void);
649 662
650int sas_ex_revalidate_domain(struct domain_device *); 663int sas_ex_revalidate_domain(struct domain_device *);
651 664
652void sas_unregister_domain_devices(struct asd_sas_port *port); 665void sas_unregister_domain_devices(struct asd_sas_port *port, int gone);
653void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *); 666void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *);
654int sas_discover_event(struct asd_sas_port *, enum discover_event ev); 667int sas_discover_event(struct asd_sas_port *, enum discover_event ev);
655 668
@@ -661,20 +674,20 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *);
661void sas_init_dev(struct domain_device *); 674void sas_init_dev(struct domain_device *);
662 675
663void sas_task_abort(struct sas_task *); 676void sas_task_abort(struct sas_task *);
664int __sas_task_abort(struct sas_task *);
665int sas_eh_device_reset_handler(struct scsi_cmnd *cmd); 677int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
666int sas_eh_bus_reset_handler(struct scsi_cmnd *cmd); 678int sas_eh_bus_reset_handler(struct scsi_cmnd *cmd);
667 679
668extern void sas_target_destroy(struct scsi_target *); 680extern void sas_target_destroy(struct scsi_target *);
669extern int sas_slave_alloc(struct scsi_device *); 681extern int sas_slave_alloc(struct scsi_device *);
670extern int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg); 682extern int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg);
683extern int sas_drain_work(struct sas_ha_struct *ha);
671 684
672extern int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, 685extern int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
673 struct request *req); 686 struct request *req);
674 687
675extern void sas_ssp_task_response(struct device *dev, struct sas_task *task, 688extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
676 struct ssp_response_iu *iu); 689 struct ssp_response_iu *iu);
677struct sas_phy *sas_find_local_phy(struct domain_device *dev); 690struct sas_phy *sas_get_local_phy(struct domain_device *dev);
678 691
679int sas_request_addr(struct Scsi_Host *shost, u8 *addr); 692int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
680 693
diff --git a/include/scsi/sas.h b/include/scsi/sas.h
index 3673d685e6a..a577a833603 100644
--- a/include/scsi/sas.h
+++ b/include/scsi/sas.h
@@ -89,8 +89,7 @@ enum sas_oob_mode {
89 SAS_OOB_MODE 89 SAS_OOB_MODE
90}; 90};
91 91
92/* See sas_discover.c if you plan on changing these. 92/* See sas_discover.c if you plan on changing these */
93 */
94enum sas_dev_type { 93enum sas_dev_type {
95 NO_DEVICE = 0, /* protocol */ 94 NO_DEVICE = 0, /* protocol */
96 SAS_END_DEV = 1, /* protocol */ 95 SAS_END_DEV = 1, /* protocol */
@@ -100,6 +99,7 @@ enum sas_dev_type {
100 SATA_DEV = 5, 99 SATA_DEV = 5,
101 SATA_PM = 7, 100 SATA_PM = 7,
102 SATA_PM_PORT= 8, 101 SATA_PM_PORT= 8,
102 SATA_PENDING = 9,
103}; 103};
104 104
105enum sas_protocol { 105enum sas_protocol {
diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h
index 9c159f74c6d..cdccd2eb7b6 100644
--- a/include/scsi/sas_ata.h
+++ b/include/scsi/sas_ata.h
@@ -32,19 +32,19 @@
32 32
33static inline int dev_is_sata(struct domain_device *dev) 33static inline int dev_is_sata(struct domain_device *dev)
34{ 34{
35 return (dev->rphy->identify.target_port_protocols & SAS_PROTOCOL_SATA); 35 return dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM ||
36 dev->dev_type == SATA_PM_PORT || dev->dev_type == SATA_PENDING;
36} 37}
37 38
38int sas_ata_init_host_and_port(struct domain_device *found_dev, 39int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy);
39 struct scsi_target *starget); 40int sas_ata_init_host_and_port(struct domain_device *found_dev);
40
41void sas_ata_task_abort(struct sas_task *task); 41void sas_ata_task_abort(struct sas_task *task);
42void sas_ata_strategy_handler(struct Scsi_Host *shost); 42void sas_ata_strategy_handler(struct Scsi_Host *shost);
43int sas_ata_timed_out(struct scsi_cmnd *cmd, struct sas_task *task, 43void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
44 enum blk_eh_timer_return *rtn); 44 struct list_head *done_q);
45int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q, 45void sas_ata_schedule_reset(struct domain_device *dev);
46 struct list_head *done_q); 46void sas_ata_wait_eh(struct domain_device *dev);
47 47void sas_probe_sata(struct asd_sas_port *port);
48#else 48#else
49 49
50 50
@@ -52,8 +52,7 @@ static inline int dev_is_sata(struct domain_device *dev)
52{ 52{
53 return 0; 53 return 0;
54} 54}
55static inline int sas_ata_init_host_and_port(struct domain_device *found_dev, 55static inline int sas_ata_init_host_and_port(struct domain_device *found_dev)
56 struct scsi_target *starget)
57{ 56{
58 return 0; 57 return 0;
59} 58}
@@ -65,18 +64,27 @@ static inline void sas_ata_strategy_handler(struct Scsi_Host *shost)
65{ 64{
66} 65}
67 66
68static inline int sas_ata_timed_out(struct scsi_cmnd *cmd, 67static inline void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
69 struct sas_task *task, 68 struct list_head *done_q)
70 enum blk_eh_timer_return *rtn)
71{ 69{
72 return 0;
73} 70}
74static inline int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q, 71
75 struct list_head *done_q) 72static inline void sas_ata_schedule_reset(struct domain_device *dev)
73{
74}
75
76static inline void sas_ata_wait_eh(struct domain_device *dev)
77{
78}
79
80static inline void sas_probe_sata(struct asd_sas_port *port)
76{ 81{
77 return 0;
78} 82}
79 83
84static inline int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
85{
86 return 0;
87}
80#endif 88#endif
81 89
82#endif /* _SAS_ATA_H_ */ 90#endif /* _SAS_ATA_H_ */
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index a5e885a111d..377df4a2851 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -10,6 +10,7 @@
10 10
11struct Scsi_Host; 11struct Scsi_Host;
12struct scsi_device; 12struct scsi_device;
13struct scsi_driver;
13 14
14/* 15/*
15 * MAX_COMMAND_SIZE is: 16 * MAX_COMMAND_SIZE is:
@@ -131,6 +132,11 @@ struct scsi_cmnd {
131 unsigned char tag; /* SCSI-II queued command tag */ 132 unsigned char tag; /* SCSI-II queued command tag */
132}; 133};
133 134
135static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
136{
137 return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
138}
139
134extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); 140extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
135extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t); 141extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t);
136extern void scsi_put_command(struct scsi_cmnd *); 142extern void scsi_put_command(struct scsi_cmnd *);
@@ -289,17 +295,17 @@ static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)
289 295
290static inline void set_msg_byte(struct scsi_cmnd *cmd, char status) 296static inline void set_msg_byte(struct scsi_cmnd *cmd, char status)
291{ 297{
292 cmd->result |= status << 8; 298 cmd->result = (cmd->result & 0xffff00ff) | (status << 8);
293} 299}
294 300
295static inline void set_host_byte(struct scsi_cmnd *cmd, char status) 301static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
296{ 302{
297 cmd->result |= status << 16; 303 cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
298} 304}
299 305
300static inline void set_driver_byte(struct scsi_cmnd *cmd, char status) 306static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
301{ 307{
302 cmd->result |= status << 24; 308 cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
303} 309}
304 310
305#endif /* _SCSI_SCSI_CMND_H */ 311#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
index 9fd6702f02e..d443aa06a72 100644
--- a/include/scsi/scsi_driver.h
+++ b/include/scsi/scsi_driver.h
@@ -16,6 +16,7 @@ struct scsi_driver {
16 16
17 void (*rescan)(struct device *); 17 void (*rescan)(struct device *);
18 int (*done)(struct scsi_cmnd *); 18 int (*done)(struct scsi_cmnd *);
19 int (*eh_action)(struct scsi_cmnd *, unsigned char *, int, int);
19}; 20};
20#define to_scsi_driver(drv) \ 21#define to_scsi_driver(drv) \
21 container_of((drv), struct scsi_driver, gendrv) 22 container_of((drv), struct scsi_driver, gendrv)
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 2a65167a8f1..719faf1863a 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -126,8 +126,8 @@ enum fc_vport_state {
126 incapable of reporting */ 126 incapable of reporting */
127#define FC_PORTSPEED_1GBIT 1 127#define FC_PORTSPEED_1GBIT 1
128#define FC_PORTSPEED_2GBIT 2 128#define FC_PORTSPEED_2GBIT 2
129#define FC_PORTSPEED_4GBIT 4 129#define FC_PORTSPEED_10GBIT 4
130#define FC_PORTSPEED_10GBIT 8 130#define FC_PORTSPEED_4GBIT 8
131#define FC_PORTSPEED_8GBIT 0x10 131#define FC_PORTSPEED_8GBIT 0x10
132#define FC_PORTSPEED_16GBIT 0x20 132#define FC_PORTSPEED_16GBIT 0x20
133#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ 133#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
@@ -486,6 +486,13 @@ struct fc_host_attrs {
486 u32 maxframe_size; 486 u32 maxframe_size;
487 u16 max_npiv_vports; 487 u16 max_npiv_vports;
488 char serial_number[FC_SERIAL_NUMBER_SIZE]; 488 char serial_number[FC_SERIAL_NUMBER_SIZE];
489 char manufacturer[FC_SERIAL_NUMBER_SIZE];
490 char model[FC_SYMBOLIC_NAME_SIZE];
491 char model_description[FC_SYMBOLIC_NAME_SIZE];
492 char hardware_version[FC_VERSION_STRING_SIZE];
493 char driver_version[FC_VERSION_STRING_SIZE];
494 char firmware_version[FC_VERSION_STRING_SIZE];
495 char optionrom_version[FC_VERSION_STRING_SIZE];
489 496
490 /* Dynamic Attributes */ 497 /* Dynamic Attributes */
491 u32 port_id; 498 u32 port_id;
@@ -541,6 +548,20 @@ struct fc_host_attrs {
541 (((struct fc_host_attrs *)(x)->shost_data)->max_npiv_vports) 548 (((struct fc_host_attrs *)(x)->shost_data)->max_npiv_vports)
542#define fc_host_serial_number(x) \ 549#define fc_host_serial_number(x) \
543 (((struct fc_host_attrs *)(x)->shost_data)->serial_number) 550 (((struct fc_host_attrs *)(x)->shost_data)->serial_number)
551#define fc_host_manufacturer(x) \
552 (((struct fc_host_attrs *)(x)->shost_data)->manufacturer)
553#define fc_host_model(x) \
554 (((struct fc_host_attrs *)(x)->shost_data)->model)
555#define fc_host_model_description(x) \
556 (((struct fc_host_attrs *)(x)->shost_data)->model_description)
557#define fc_host_hardware_version(x) \
558 (((struct fc_host_attrs *)(x)->shost_data)->hardware_version)
559#define fc_host_driver_version(x) \
560 (((struct fc_host_attrs *)(x)->shost_data)->driver_version)
561#define fc_host_firmware_version(x) \
562 (((struct fc_host_attrs *)(x)->shost_data)->firmware_version)
563#define fc_host_optionrom_version(x) \
564 (((struct fc_host_attrs *)(x)->shost_data)->optionrom_version)
544#define fc_host_port_id(x) \ 565#define fc_host_port_id(x) \
545 (((struct fc_host_attrs *)(x)->shost_data)->port_id) 566 (((struct fc_host_attrs *)(x)->shost_data)->port_id)
546#define fc_host_port_type(x) \ 567#define fc_host_port_type(x) \
@@ -700,6 +721,13 @@ struct fc_function_template {
700 unsigned long show_host_supported_speeds:1; 721 unsigned long show_host_supported_speeds:1;
701 unsigned long show_host_maxframe_size:1; 722 unsigned long show_host_maxframe_size:1;
702 unsigned long show_host_serial_number:1; 723 unsigned long show_host_serial_number:1;
724 unsigned long show_host_manufacturer:1;
725 unsigned long show_host_model:1;
726 unsigned long show_host_model_description:1;
727 unsigned long show_host_hardware_version:1;
728 unsigned long show_host_driver_version:1;
729 unsigned long show_host_firmware_version:1;
730 unsigned long show_host_optionrom_version:1;
703 /* host dynamic attributes */ 731 /* host dynamic attributes */
704 unsigned long show_host_port_id:1; 732 unsigned long show_host_port_id:1;
705 unsigned long show_host_port_type:1; 733 unsigned long show_host_port_type:1;
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 2c3a46d102f..53f0b361d66 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -144,6 +144,12 @@ struct iscsi_transport {
144 int param, char *buf); 144 int param, char *buf);
145 umode_t (*attr_is_visible)(int param_type, int param); 145 umode_t (*attr_is_visible)(int param_type, int param);
146 int (*bsg_request)(struct bsg_job *job); 146 int (*bsg_request)(struct bsg_job *job);
147 int (*send_ping) (struct Scsi_Host *shost, uint32_t iface_num,
148 uint32_t iface_type, uint32_t payload_size,
149 uint32_t pid, struct sockaddr *dst_addr);
150 int (*get_chap) (struct Scsi_Host *shost, uint16_t chap_tbl_idx,
151 uint32_t *num_entries, char *buf);
152 int (*delete_chap) (struct Scsi_Host *shost, uint16_t chap_tbl_idx);
147}; 153};
148 154
149/* 155/*
@@ -166,6 +172,17 @@ extern int iscsi_offload_mesg(struct Scsi_Host *shost,
166 struct iscsi_transport *transport, uint32_t type, 172 struct iscsi_transport *transport, uint32_t type,
167 char *data, uint16_t data_size); 173 char *data, uint16_t data_size);
168 174
175extern void iscsi_post_host_event(uint32_t host_no,
176 struct iscsi_transport *transport,
177 enum iscsi_host_event_code code,
178 uint32_t data_size,
179 uint8_t *data);
180
181extern void iscsi_ping_comp_event(uint32_t host_no,
182 struct iscsi_transport *transport,
183 uint32_t status, uint32_t pid,
184 uint32_t data_size, uint8_t *data);
185
169struct iscsi_cls_conn { 186struct iscsi_cls_conn {
170 struct list_head conn_list; /* item in connlist */ 187 struct list_head conn_list; /* item in connlist */
171 void *dd_data; /* LLD private data */ 188 void *dd_data; /* LLD private data */
@@ -238,6 +255,8 @@ struct iscsi_cls_host {
238 atomic_t nr_scans; 255 atomic_t nr_scans;
239 struct mutex mutex; 256 struct mutex mutex;
240 struct request_queue *bsg_q; 257 struct request_queue *bsg_q;
258 uint32_t port_speed;
259 uint32_t port_state;
241}; 260};
242 261
243#define iscsi_job_to_shost(_job) \ 262#define iscsi_job_to_shost(_job) \
@@ -307,5 +326,8 @@ extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost,
307 uint32_t iface_num, int dd_size); 326 uint32_t iface_num, int dd_size);
308extern void iscsi_destroy_iface(struct iscsi_iface *iface); 327extern void iscsi_destroy_iface(struct iscsi_iface *iface);
309extern struct iscsi_iface *iscsi_lookup_iface(int handle); 328extern struct iscsi_iface *iscsi_lookup_iface(int handle);
329extern char *iscsi_get_port_speed_name(struct Scsi_Host *shost);
330extern char *iscsi_get_port_state_name(struct Scsi_Host *shost);
331extern int iscsi_is_session_dev(const struct device *dev);
310 332
311#endif 333#endif
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index ffeebc34a4f..98b3a20a010 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -75,7 +75,8 @@ struct sas_phy {
75 /* for the list of phys belonging to a port */ 75 /* for the list of phys belonging to a port */
76 struct list_head port_siblings; 76 struct list_head port_siblings;
77 77
78 struct work_struct reset_work; 78 /* available to the lldd */
79 void *hostdata;
79}; 80};
80 81
81#define dev_to_phy(d) \ 82#define dev_to_phy(d) \
@@ -169,6 +170,8 @@ struct sas_function_template {
169 int (*get_bay_identifier)(struct sas_rphy *); 170 int (*get_bay_identifier)(struct sas_rphy *);
170 int (*phy_reset)(struct sas_phy *, int); 171 int (*phy_reset)(struct sas_phy *, int);
171 int (*phy_enable)(struct sas_phy *, int); 172 int (*phy_enable)(struct sas_phy *, int);
173 int (*phy_setup)(struct sas_phy *);
174 void (*phy_release)(struct sas_phy *);
172 int (*set_phy_speed)(struct sas_phy *, struct sas_phy_linkrates *); 175 int (*set_phy_speed)(struct sas_phy *, struct sas_phy_linkrates *);
173 int (*smp_handler)(struct Scsi_Host *, struct sas_rphy *, struct request *); 176 int (*smp_handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
174}; 177};
@@ -194,6 +197,7 @@ void sas_rphy_free(struct sas_rphy *);
194extern int sas_rphy_add(struct sas_rphy *); 197extern int sas_rphy_add(struct sas_rphy *);
195extern void sas_rphy_remove(struct sas_rphy *); 198extern void sas_rphy_remove(struct sas_rphy *);
196extern void sas_rphy_delete(struct sas_rphy *); 199extern void sas_rphy_delete(struct sas_rphy *);
200extern void sas_rphy_unlink(struct sas_rphy *);
197extern int scsi_is_sas_rphy(const struct device *); 201extern int scsi_is_sas_rphy(const struct device *);
198 202
199struct sas_port *sas_port_alloc(struct device *, int); 203struct sas_port *sas_port_alloc(struct device *, int);
@@ -205,6 +209,12 @@ void sas_port_add_phy(struct sas_port *, struct sas_phy *);
205void sas_port_delete_phy(struct sas_port *, struct sas_phy *); 209void sas_port_delete_phy(struct sas_port *, struct sas_phy *);
206void sas_port_mark_backlink(struct sas_port *); 210void sas_port_mark_backlink(struct sas_port *);
207int scsi_is_sas_port(const struct device *); 211int scsi_is_sas_port(const struct device *);
212struct sas_phy *sas_port_get_phy(struct sas_port *port);
213static inline void sas_port_put_phy(struct sas_phy *phy)
214{
215 if (phy)
216 put_device(&phy->dev);
217}
208 218
209extern struct scsi_transport_template * 219extern struct scsi_transport_template *
210sas_attach_transport(struct sas_function_template *); 220sas_attach_transport(struct sas_function_template *);